From 7870298086cfdde020437e23ba86abb61741129e Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 25 Oct 2009 23:24:18 +0800 Subject: glapi: Allow normal entry points to be skipped. Reorganize glapitemp.h such that it is possible to skip normal entry points or protocol entry points by defining _GLAPI_SKIP_NORMAL_ENTRY_POINTS or _GLAPI_SKIP_PROTO_ENTRY_POINTS. Protocol entry points are those with different GLX protocols. They are skipped in libglapi.a when GLX_INDIRECT_RENDERING is defined. Signed-off-by: Chia-I Wu --- src/mesa/glapi/gl_apitemp.py | 100 ++++++++--- src/mesa/glapi/glapitemp.h | 385 ++++++++++++++++++++++--------------------- src/mesa/main/dispatch.c | 4 + 3 files changed, 274 insertions(+), 215 deletions(-) diff --git a/src/mesa/glapi/gl_apitemp.py b/src/mesa/glapi/gl_apitemp.py index a37c08d6ce..d4f8b1d8f8 100644 --- a/src/mesa/glapi/gl_apitemp.py +++ b/src/mesa/glapi/gl_apitemp.py @@ -82,9 +82,6 @@ class PrintGlOffsets(gl_XML.gl_print_base): else: dispatch = "DISPATCH" - if f.has_different_protocol(name): - print '#ifndef GLX_INDIRECT_RENDERING' - if not f.is_static_entry_point(name): print '%s %s KEYWORD2 NAME(%s)(%s);' % (keyword, f.return_type, n, f.get_parameter_string(name)) print '' @@ -98,8 +95,6 @@ class PrintGlOffsets(gl_XML.gl_print_base): print ' %s(%s, (%s), (F, "gl%s(%s);\\n", %s));' \ % (dispatch, f.name, p_string, name, t_string, o_string) print '}' - if f.has_different_protocol(name): - print '#endif /* GLX_INDIRECT_RENDERING */' print '' return @@ -172,6 +167,10 @@ class PrintGlOffsets(gl_XML.gl_print_base): #error TABLE_ENTRY must be defined #endif +#ifdef _GLAPI_SKIP_NORMAL_ENTRY_POINTS +#error _GLAPI_SKIP_NORMAL_ENTRY_POINTS must not be defined +#endif + static _glapi_proc DISPATCH_TABLE_NAME[] = {""" for f in api.functionIterateByOffset(): print ' TABLE_ENTRY(%s),' % (f.dispatch_name()) @@ -198,33 +197,88 @@ static _glapi_proc DISPATCH_TABLE_NAME[] = {""" #ifdef UNUSED_TABLE_NAME static _glapi_proc UNUSED_TABLE_NAME[] = {""" + normal_entries = [] + proto_entries = [] for f in api.functionIterateByOffset(): - for n in f.entry_points: - if n != f.name: - if f.is_static_entry_point(n): - text = ' TABLE_ENTRY(%s),' % (n) - - if f.has_different_protocol(n): - print '#ifndef GLX_INDIRECT_RENDERING' - print text - print '#endif' - else: - print text + normal_ents, proto_ents = self.classifyEntryPoints(f) + + # exclude f.name + if f.name in normal_ents: + normal_ents.remove(f.name) + elif f.name in proto_ents: + proto_ents.remove(f.name) + + normal_ents = [f.static_name(ent) for ent in normal_ents] + proto_ents = [f.static_name(ent) for ent in proto_ents] + + normal_entries.extend(normal_ents) + proto_entries.extend(proto_ents) + + print '#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS' + for ent in normal_entries: + print ' TABLE_ENTRY(%s),' % (ent) + print '#endif /* _GLAPI_SKIP_NORMAL_ENTRY_POINTS */' + print '#ifndef _GLAPI_SKIP_PROTO_ENTRY_POINTS' + for ent in proto_entries: + print ' TABLE_ENTRY(%s),' % (ent) + print '#endif /* _GLAPI_SKIP_PROTO_ENTRY_POINTS */' + print '};' print '#endif /*UNUSED_TABLE_NAME*/' print '' return + def classifyEntryPoints(self, func): + normal_names = [] + normal_stubs = [] + proto_names = [] + proto_stubs = [] + # classify the entry points + for name in func.entry_points: + if func.has_different_protocol(name): + if func.is_static_entry_point(name): + proto_names.append(name) + else: + proto_stubs.append(name) + else: + if func.is_static_entry_point(name): + normal_names.append(name) + else: + normal_stubs.append(name) + # there can be at most one stub for a function + if normal_stubs: + normal_names.append(normal_stubs[0]) + elif proto_stubs: + proto_names.append(proto_stubs[0]) + + return (normal_names, proto_names) + def printBody(self, api): + normal_entry_points = [] + proto_entry_points = [] for func in api.functionIterateByOffset(): - got_stub = 0 - for n in func.entry_points: - if func.is_static_entry_point(n): - self.printFunction(func, n) - elif not got_stub: - self.printFunction(func, n) - got_stub = 1 + normal_ents, proto_ents = self.classifyEntryPoints(func) + normal_entry_points.append((func, normal_ents)) + proto_entry_points.append((func, proto_ents)) + + print '#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS' + print '' + for func, ents in normal_entry_points: + for ent in ents: + self.printFunction(func, ent) + print '' + print '#endif /* _GLAPI_SKIP_NORMAL_ENTRY_POINTS */' + print '' + print '/* these entry points might require different protocols */' + print '#ifndef _GLAPI_SKIP_PROTO_ENTRY_POINTS' + print '' + for func, ents in proto_entry_points: + for ent in ents: + self.printFunction(func, ent) + print '' + print '#endif /* _GLAPI_SKIP_PROTO_ENTRY_POINTS */' + print '' self.printInitDispatch(api) self.printAliasedTable(api) diff --git a/src/mesa/glapi/glapitemp.h b/src/mesa/glapi/glapitemp.h index d9a3690f2a..0138abddb8 100644 --- a/src/mesa/glapi/glapitemp.h +++ b/src/mesa/glapi/glapitemp.h @@ -80,6 +80,8 @@ #endif +#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS + KEYWORD1 void KEYWORD2 NAME(NewList)(GLuint list, GLenum mode) { DISPATCH(NewList, (list, mode), (F, "glNewList(%d, 0x%x);\n", list, mode)); @@ -1710,13 +1712,6 @@ KEYWORD1 GLboolean KEYWORD2 NAME(AreTexturesResident)(GLsizei n, const GLuint * RETURN_DISPATCH(AreTexturesResident, (n, textures, residences), (F, "glAreTexturesResident(%d, %p, %p);\n", n, (const void *) textures, (const void *) residences)); } -#ifndef GLX_INDIRECT_RENDERING -KEYWORD1 GLboolean KEYWORD2 NAME(AreTexturesResidentEXT)(GLsizei n, const GLuint * textures, GLboolean * residences) -{ - RETURN_DISPATCH(AreTexturesResident, (n, textures, residences), (F, "glAreTexturesResidentEXT(%d, %p, %p);\n", n, (const void *) textures, (const void *) residences)); -} -#endif /* GLX_INDIRECT_RENDERING */ - KEYWORD1 void KEYWORD2 NAME(CopyTexImage1D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border) { DISPATCH(CopyTexImage1D, (target, level, internalformat, x, y, width, border), (F, "glCopyTexImage1D(0x%x, %d, 0x%x, %d, %d, %d, %d);\n", target, level, internalformat, x, y, width, border)); @@ -1762,25 +1757,11 @@ KEYWORD1 void KEYWORD2 NAME(DeleteTextures)(GLsizei n, const GLuint * textures) DISPATCH(DeleteTextures, (n, textures), (F, "glDeleteTextures(%d, %p);\n", n, (const void *) textures)); } -#ifndef GLX_INDIRECT_RENDERING -KEYWORD1 void KEYWORD2 NAME(DeleteTexturesEXT)(GLsizei n, const GLuint * textures) -{ - DISPATCH(DeleteTextures, (n, textures), (F, "glDeleteTexturesEXT(%d, %p);\n", n, (const void *) textures)); -} -#endif /* GLX_INDIRECT_RENDERING */ - KEYWORD1 void KEYWORD2 NAME(GenTextures)(GLsizei n, GLuint * textures) { DISPATCH(GenTextures, (n, textures), (F, "glGenTextures(%d, %p);\n", n, (const void *) textures)); } -#ifndef GLX_INDIRECT_RENDERING -KEYWORD1 void KEYWORD2 NAME(GenTexturesEXT)(GLsizei n, GLuint * textures) -{ - DISPATCH(GenTextures, (n, textures), (F, "glGenTexturesEXT(%d, %p);\n", n, (const void *) textures)); -} -#endif /* GLX_INDIRECT_RENDERING */ - KEYWORD1 void KEYWORD2 NAME(GetPointerv)(GLenum pname, GLvoid ** params) { DISPATCH(GetPointerv, (pname, params), (F, "glGetPointerv(0x%x, %p);\n", pname, (const void *) params)); @@ -1796,13 +1777,6 @@ KEYWORD1 GLboolean KEYWORD2 NAME(IsTexture)(GLuint texture) RETURN_DISPATCH(IsTexture, (texture), (F, "glIsTexture(%d);\n", texture)); } -#ifndef GLX_INDIRECT_RENDERING -KEYWORD1 GLboolean KEYWORD2 NAME(IsTextureEXT)(GLuint texture) -{ - RETURN_DISPATCH(IsTexture, (texture), (F, "glIsTextureEXT(%d);\n", texture)); -} -#endif /* GLX_INDIRECT_RENDERING */ - KEYWORD1 void KEYWORD2 NAME(PrioritizeTextures)(GLsizei n, const GLuint * textures, const GLclampf * priorities) { DISPATCH(PrioritizeTextures, (n, textures, priorities), (F, "glPrioritizeTextures(%d, %p, %p);\n", n, (const void *) textures, (const void *) priorities)); @@ -1878,6 +1852,11 @@ KEYWORD1 void KEYWORD2 NAME(ColorTable)(GLenum target, GLenum internalformat, GL DISPATCH(ColorTable, (target, internalformat, width, format, type, table), (F, "glColorTable(0x%x, 0x%x, %d, 0x%x, 0x%x, %p);\n", target, internalformat, width, format, type, (const void *) table)); } +KEYWORD1 void KEYWORD2 NAME(ColorTableEXT)(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * table) +{ + DISPATCH(ColorTable, (target, internalformat, width, format, type, table), (F, "glColorTableEXT(0x%x, 0x%x, %d, 0x%x, 0x%x, %p);\n", target, internalformat, width, format, type, (const void *) table)); +} + KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_339)(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * table); KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_339)(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * table) @@ -1885,11 +1864,6 @@ KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_339)(GLenum target, GLenum intern DISPATCH(ColorTable, (target, internalformat, width, format, type, table), (F, "glColorTableSGI(0x%x, 0x%x, %d, 0x%x, 0x%x, %p);\n", target, internalformat, width, format, type, (const void *) table)); } -KEYWORD1 void KEYWORD2 NAME(ColorTableEXT)(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * table) -{ - DISPATCH(ColorTable, (target, internalformat, width, format, type, table), (F, "glColorTableEXT(0x%x, 0x%x, %d, 0x%x, 0x%x, %p);\n", target, internalformat, width, format, type, (const void *) table)); -} - KEYWORD1 void KEYWORD2 NAME(ColorTableParameterfv)(GLenum target, GLenum pname, const GLfloat * params) { DISPATCH(ColorTableParameterfv, (target, pname, params), (F, "glColorTableParameterfv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); @@ -1931,64 +1905,16 @@ KEYWORD1 void KEYWORD2 NAME(GetColorTable)(GLenum target, GLenum format, GLenum DISPATCH(GetColorTable, (target, format, type, table), (F, "glGetColorTable(0x%x, 0x%x, 0x%x, %p);\n", target, format, type, (const void *) table)); } -#ifndef GLX_INDIRECT_RENDERING -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_343)(GLenum target, GLenum format, GLenum type, GLvoid * table); - -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_343)(GLenum target, GLenum format, GLenum type, GLvoid * table) -{ - DISPATCH(GetColorTable, (target, format, type, table), (F, "glGetColorTableSGI(0x%x, 0x%x, 0x%x, %p);\n", target, format, type, (const void *) table)); -} -#endif /* GLX_INDIRECT_RENDERING */ - -#ifndef GLX_INDIRECT_RENDERING -KEYWORD1 void KEYWORD2 NAME(GetColorTableEXT)(GLenum target, GLenum format, GLenum type, GLvoid * table) -{ - DISPATCH(GetColorTable, (target, format, type, table), (F, "glGetColorTableEXT(0x%x, 0x%x, 0x%x, %p);\n", target, format, type, (const void *) table)); -} -#endif /* GLX_INDIRECT_RENDERING */ - KEYWORD1 void KEYWORD2 NAME(GetColorTableParameterfv)(GLenum target, GLenum pname, GLfloat * params) { DISPATCH(GetColorTableParameterfv, (target, pname, params), (F, "glGetColorTableParameterfv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); } -#ifndef GLX_INDIRECT_RENDERING -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_344)(GLenum target, GLenum pname, GLfloat * params); - -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_344)(GLenum target, GLenum pname, GLfloat * params) -{ - DISPATCH(GetColorTableParameterfv, (target, pname, params), (F, "glGetColorTableParameterfvSGI(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); -} -#endif /* GLX_INDIRECT_RENDERING */ - -#ifndef GLX_INDIRECT_RENDERING -KEYWORD1 void KEYWORD2 NAME(GetColorTableParameterfvEXT)(GLenum target, GLenum pname, GLfloat * params) -{ - DISPATCH(GetColorTableParameterfv, (target, pname, params), (F, "glGetColorTableParameterfvEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); -} -#endif /* GLX_INDIRECT_RENDERING */ - KEYWORD1 void KEYWORD2 NAME(GetColorTableParameteriv)(GLenum target, GLenum pname, GLint * params) { DISPATCH(GetColorTableParameteriv, (target, pname, params), (F, "glGetColorTableParameteriv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); } -#ifndef GLX_INDIRECT_RENDERING -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_345)(GLenum target, GLenum pname, GLint * params); - -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_345)(GLenum target, GLenum pname, GLint * params) -{ - DISPATCH(GetColorTableParameteriv, (target, pname, params), (F, "glGetColorTableParameterivSGI(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); -} -#endif /* GLX_INDIRECT_RENDERING */ - -#ifndef GLX_INDIRECT_RENDERING -KEYWORD1 void KEYWORD2 NAME(GetColorTableParameterivEXT)(GLenum target, GLenum pname, GLint * params) -{ - DISPATCH(GetColorTableParameteriv, (target, pname, params), (F, "glGetColorTableParameterivEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); -} -#endif /* GLX_INDIRECT_RENDERING */ - KEYWORD1 void KEYWORD2 NAME(ColorSubTable)(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid * data) { DISPATCH(ColorSubTable, (target, start, count, format, type, data), (F, "glColorSubTable(0x%x, %d, %d, 0x%x, 0x%x, %p);\n", target, start, count, format, type, (const void *) data)); @@ -2114,57 +2040,21 @@ KEYWORD1 void KEYWORD2 NAME(GetConvolutionFilter)(GLenum target, GLenum format, DISPATCH(GetConvolutionFilter, (target, format, type, image), (F, "glGetConvolutionFilter(0x%x, 0x%x, 0x%x, %p);\n", target, format, type, (const void *) image)); } -#ifndef GLX_INDIRECT_RENDERING -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_356)(GLenum target, GLenum format, GLenum type, GLvoid * image); - -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_356)(GLenum target, GLenum format, GLenum type, GLvoid * image) -{ - DISPATCH(GetConvolutionFilter, (target, format, type, image), (F, "glGetConvolutionFilterEXT(0x%x, 0x%x, 0x%x, %p);\n", target, format, type, (const void *) image)); -} -#endif /* GLX_INDIRECT_RENDERING */ - KEYWORD1 void KEYWORD2 NAME(GetConvolutionParameterfv)(GLenum target, GLenum pname, GLfloat * params) { DISPATCH(GetConvolutionParameterfv, (target, pname, params), (F, "glGetConvolutionParameterfv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); } -#ifndef GLX_INDIRECT_RENDERING -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_357)(GLenum target, GLenum pname, GLfloat * params); - -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_357)(GLenum target, GLenum pname, GLfloat * params) -{ - DISPATCH(GetConvolutionParameterfv, (target, pname, params), (F, "glGetConvolutionParameterfvEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); -} -#endif /* GLX_INDIRECT_RENDERING */ - KEYWORD1 void KEYWORD2 NAME(GetConvolutionParameteriv)(GLenum target, GLenum pname, GLint * params) { DISPATCH(GetConvolutionParameteriv, (target, pname, params), (F, "glGetConvolutionParameteriv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); } -#ifndef GLX_INDIRECT_RENDERING -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_358)(GLenum target, GLenum pname, GLint * params); - -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_358)(GLenum target, GLenum pname, GLint * params) -{ - DISPATCH(GetConvolutionParameteriv, (target, pname, params), (F, "glGetConvolutionParameterivEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); -} -#endif /* GLX_INDIRECT_RENDERING */ - KEYWORD1 void KEYWORD2 NAME(GetSeparableFilter)(GLenum target, GLenum format, GLenum type, GLvoid * row, GLvoid * column, GLvoid * span) { DISPATCH(GetSeparableFilter, (target, format, type, row, column, span), (F, "glGetSeparableFilter(0x%x, 0x%x, 0x%x, %p, %p, %p);\n", target, format, type, (const void *) row, (const void *) column, (const void *) span)); } -#ifndef GLX_INDIRECT_RENDERING -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_359)(GLenum target, GLenum format, GLenum type, GLvoid * row, GLvoid * column, GLvoid * span); - -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_359)(GLenum target, GLenum format, GLenum type, GLvoid * row, GLvoid * column, GLvoid * span) -{ - DISPATCH(GetSeparableFilter, (target, format, type, row, column, span), (F, "glGetSeparableFilterEXT(0x%x, 0x%x, 0x%x, %p, %p, %p);\n", target, format, type, (const void *) row, (const void *) column, (const void *) span)); -} -#endif /* GLX_INDIRECT_RENDERING */ - KEYWORD1 void KEYWORD2 NAME(SeparableFilter2D)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * row, const GLvoid * column) { DISPATCH(SeparableFilter2D, (target, internalformat, width, height, format, type, row, column), (F, "glSeparableFilter2D(0x%x, 0x%x, %d, %d, 0x%x, 0x%x, %p, %p);\n", target, internalformat, width, height, format, type, (const void *) row, (const void *) column)); @@ -2182,85 +2072,31 @@ KEYWORD1 void KEYWORD2 NAME(GetHistogram)(GLenum target, GLboolean reset, GLenum DISPATCH(GetHistogram, (target, reset, format, type, values), (F, "glGetHistogram(0x%x, %d, 0x%x, 0x%x, %p);\n", target, reset, format, type, (const void *) values)); } -#ifndef GLX_INDIRECT_RENDERING -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_361)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values); - -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_361)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values) -{ - DISPATCH(GetHistogram, (target, reset, format, type, values), (F, "glGetHistogramEXT(0x%x, %d, 0x%x, 0x%x, %p);\n", target, reset, format, type, (const void *) values)); -} -#endif /* GLX_INDIRECT_RENDERING */ - KEYWORD1 void KEYWORD2 NAME(GetHistogramParameterfv)(GLenum target, GLenum pname, GLfloat * params) { DISPATCH(GetHistogramParameterfv, (target, pname, params), (F, "glGetHistogramParameterfv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); } -#ifndef GLX_INDIRECT_RENDERING -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_362)(GLenum target, GLenum pname, GLfloat * params); - -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_362)(GLenum target, GLenum pname, GLfloat * params) -{ - DISPATCH(GetHistogramParameterfv, (target, pname, params), (F, "glGetHistogramParameterfvEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); -} -#endif /* GLX_INDIRECT_RENDERING */ - KEYWORD1 void KEYWORD2 NAME(GetHistogramParameteriv)(GLenum target, GLenum pname, GLint * params) { DISPATCH(GetHistogramParameteriv, (target, pname, params), (F, "glGetHistogramParameteriv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); } -#ifndef GLX_INDIRECT_RENDERING -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_363)(GLenum target, GLenum pname, GLint * params); - -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_363)(GLenum target, GLenum pname, GLint * params) -{ - DISPATCH(GetHistogramParameteriv, (target, pname, params), (F, "glGetHistogramParameterivEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); -} -#endif /* GLX_INDIRECT_RENDERING */ - KEYWORD1 void KEYWORD2 NAME(GetMinmax)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values) { DISPATCH(GetMinmax, (target, reset, format, type, values), (F, "glGetMinmax(0x%x, %d, 0x%x, 0x%x, %p);\n", target, reset, format, type, (const void *) values)); } -#ifndef GLX_INDIRECT_RENDERING -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_364)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values); - -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_364)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values) -{ - DISPATCH(GetMinmax, (target, reset, format, type, values), (F, "glGetMinmaxEXT(0x%x, %d, 0x%x, 0x%x, %p);\n", target, reset, format, type, (const void *) values)); -} -#endif /* GLX_INDIRECT_RENDERING */ - KEYWORD1 void KEYWORD2 NAME(GetMinmaxParameterfv)(GLenum target, GLenum pname, GLfloat * params) { DISPATCH(GetMinmaxParameterfv, (target, pname, params), (F, "glGetMinmaxParameterfv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); } -#ifndef GLX_INDIRECT_RENDERING -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_365)(GLenum target, GLenum pname, GLfloat * params); - -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_365)(GLenum target, GLenum pname, GLfloat * params) -{ - DISPATCH(GetMinmaxParameterfv, (target, pname, params), (F, "glGetMinmaxParameterfvEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); -} -#endif /* GLX_INDIRECT_RENDERING */ - KEYWORD1 void KEYWORD2 NAME(GetMinmaxParameteriv)(GLenum target, GLenum pname, GLint * params) { DISPATCH(GetMinmaxParameteriv, (target, pname, params), (F, "glGetMinmaxParameteriv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); } -#ifndef GLX_INDIRECT_RENDERING -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_366)(GLenum target, GLenum pname, GLint * params); - -KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_366)(GLenum target, GLenum pname, GLint * params) -{ - DISPATCH(GetMinmaxParameteriv, (target, pname, params), (F, "glGetMinmaxParameterivEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); -} -#endif /* GLX_INDIRECT_RENDERING */ - KEYWORD1 void KEYWORD2 NAME(Histogram)(GLenum target, GLsizei width, GLenum internalformat, GLboolean sink) { DISPATCH(Histogram, (target, width, internalformat, sink), (F, "glHistogram(0x%x, %d, 0x%x, %d);\n", target, width, internalformat, sink)); @@ -5732,6 +5568,141 @@ KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_794)(GLuint id, GLenum pname, GLu } +#endif /* _GLAPI_SKIP_NORMAL_ENTRY_POINTS */ + +/* these entry points might require different protocols */ +#ifndef _GLAPI_SKIP_PROTO_ENTRY_POINTS + +KEYWORD1 GLboolean KEYWORD2 NAME(AreTexturesResidentEXT)(GLsizei n, const GLuint * textures, GLboolean * residences) +{ + RETURN_DISPATCH(AreTexturesResident, (n, textures, residences), (F, "glAreTexturesResidentEXT(%d, %p, %p);\n", n, (const void *) textures, (const void *) residences)); +} + +KEYWORD1 void KEYWORD2 NAME(DeleteTexturesEXT)(GLsizei n, const GLuint * textures) +{ + DISPATCH(DeleteTextures, (n, textures), (F, "glDeleteTexturesEXT(%d, %p);\n", n, (const void *) textures)); +} + +KEYWORD1 void KEYWORD2 NAME(GenTexturesEXT)(GLsizei n, GLuint * textures) +{ + DISPATCH(GenTextures, (n, textures), (F, "glGenTexturesEXT(%d, %p);\n", n, (const void *) textures)); +} + +KEYWORD1 GLboolean KEYWORD2 NAME(IsTextureEXT)(GLuint texture) +{ + RETURN_DISPATCH(IsTexture, (texture), (F, "glIsTextureEXT(%d);\n", texture)); +} + +KEYWORD1 void KEYWORD2 NAME(GetColorTableEXT)(GLenum target, GLenum format, GLenum type, GLvoid * table) +{ + DISPATCH(GetColorTable, (target, format, type, table), (F, "glGetColorTableEXT(0x%x, 0x%x, 0x%x, %p);\n", target, format, type, (const void *) table)); +} + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_343)(GLenum target, GLenum format, GLenum type, GLvoid * table); + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_343)(GLenum target, GLenum format, GLenum type, GLvoid * table) +{ + DISPATCH(GetColorTable, (target, format, type, table), (F, "glGetColorTableSGI(0x%x, 0x%x, 0x%x, %p);\n", target, format, type, (const void *) table)); +} + +KEYWORD1 void KEYWORD2 NAME(GetColorTableParameterfvEXT)(GLenum target, GLenum pname, GLfloat * params) +{ + DISPATCH(GetColorTableParameterfv, (target, pname, params), (F, "glGetColorTableParameterfvEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); +} + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_344)(GLenum target, GLenum pname, GLfloat * params); + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_344)(GLenum target, GLenum pname, GLfloat * params) +{ + DISPATCH(GetColorTableParameterfv, (target, pname, params), (F, "glGetColorTableParameterfvSGI(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); +} + +KEYWORD1 void KEYWORD2 NAME(GetColorTableParameterivEXT)(GLenum target, GLenum pname, GLint * params) +{ + DISPATCH(GetColorTableParameteriv, (target, pname, params), (F, "glGetColorTableParameterivEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); +} + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_345)(GLenum target, GLenum pname, GLint * params); + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_345)(GLenum target, GLenum pname, GLint * params) +{ + DISPATCH(GetColorTableParameteriv, (target, pname, params), (F, "glGetColorTableParameterivSGI(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); +} + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_356)(GLenum target, GLenum format, GLenum type, GLvoid * image); + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_356)(GLenum target, GLenum format, GLenum type, GLvoid * image) +{ + DISPATCH(GetConvolutionFilter, (target, format, type, image), (F, "glGetConvolutionFilterEXT(0x%x, 0x%x, 0x%x, %p);\n", target, format, type, (const void *) image)); +} + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_357)(GLenum target, GLenum pname, GLfloat * params); + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_357)(GLenum target, GLenum pname, GLfloat * params) +{ + DISPATCH(GetConvolutionParameterfv, (target, pname, params), (F, "glGetConvolutionParameterfvEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); +} + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_358)(GLenum target, GLenum pname, GLint * params); + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_358)(GLenum target, GLenum pname, GLint * params) +{ + DISPATCH(GetConvolutionParameteriv, (target, pname, params), (F, "glGetConvolutionParameterivEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); +} + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_359)(GLenum target, GLenum format, GLenum type, GLvoid * row, GLvoid * column, GLvoid * span); + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_359)(GLenum target, GLenum format, GLenum type, GLvoid * row, GLvoid * column, GLvoid * span) +{ + DISPATCH(GetSeparableFilter, (target, format, type, row, column, span), (F, "glGetSeparableFilterEXT(0x%x, 0x%x, 0x%x, %p, %p, %p);\n", target, format, type, (const void *) row, (const void *) column, (const void *) span)); +} + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_361)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values); + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_361)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values) +{ + DISPATCH(GetHistogram, (target, reset, format, type, values), (F, "glGetHistogramEXT(0x%x, %d, 0x%x, 0x%x, %p);\n", target, reset, format, type, (const void *) values)); +} + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_362)(GLenum target, GLenum pname, GLfloat * params); + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_362)(GLenum target, GLenum pname, GLfloat * params) +{ + DISPATCH(GetHistogramParameterfv, (target, pname, params), (F, "glGetHistogramParameterfvEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); +} + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_363)(GLenum target, GLenum pname, GLint * params); + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_363)(GLenum target, GLenum pname, GLint * params) +{ + DISPATCH(GetHistogramParameteriv, (target, pname, params), (F, "glGetHistogramParameterivEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); +} + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_364)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values); + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_364)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values) +{ + DISPATCH(GetMinmax, (target, reset, format, type, values), (F, "glGetMinmaxEXT(0x%x, %d, 0x%x, 0x%x, %p);\n", target, reset, format, type, (const void *) values)); +} + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_365)(GLenum target, GLenum pname, GLfloat * params); + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_365)(GLenum target, GLenum pname, GLfloat * params) +{ + DISPATCH(GetMinmaxParameterfv, (target, pname, params), (F, "glGetMinmaxParameterfvEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); +} + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_366)(GLenum target, GLenum pname, GLint * params); + +KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_366)(GLenum target, GLenum pname, GLint * params) +{ + DISPATCH(GetMinmaxParameteriv, (target, pname, params), (F, "glGetMinmaxParameterivEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params)); +} + + +#endif /* _GLAPI_SKIP_PROTO_ENTRY_POINTS */ + + #endif /* defined( NAME ) */ /* @@ -5744,6 +5715,10 @@ KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_794)(GLuint id, GLenum pname, GLu #error TABLE_ENTRY must be defined #endif +#ifdef _GLAPI_SKIP_NORMAL_ENTRY_POINTS +#error _GLAPI_SKIP_NORMAL_ENTRY_POINTS must not be defined +#endif + static _glapi_proc DISPATCH_TABLE_NAME[] = { TABLE_ENTRY(NewList), TABLE_ENTRY(EndList), @@ -6653,26 +6628,15 @@ static _glapi_proc DISPATCH_TABLE_NAME[] = { */ #ifdef UNUSED_TABLE_NAME static _glapi_proc UNUSED_TABLE_NAME[] = { +#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS TABLE_ENTRY(ArrayElementEXT), TABLE_ENTRY(BindTextureEXT), TABLE_ENTRY(DrawArraysEXT), -#ifndef GLX_INDIRECT_RENDERING - TABLE_ENTRY(AreTexturesResidentEXT), -#endif TABLE_ENTRY(CopyTexImage1DEXT), TABLE_ENTRY(CopyTexImage2DEXT), TABLE_ENTRY(CopyTexSubImage1DEXT), TABLE_ENTRY(CopyTexSubImage2DEXT), -#ifndef GLX_INDIRECT_RENDERING - TABLE_ENTRY(DeleteTexturesEXT), -#endif -#ifndef GLX_INDIRECT_RENDERING - TABLE_ENTRY(GenTexturesEXT), -#endif TABLE_ENTRY(GetPointervEXT), -#ifndef GLX_INDIRECT_RENDERING - TABLE_ENTRY(IsTextureEXT), -#endif TABLE_ENTRY(PrioritizeTexturesEXT), TABLE_ENTRY(TexSubImage1DEXT), TABLE_ENTRY(TexSubImage2DEXT), @@ -6680,15 +6644,25 @@ static _glapi_proc UNUSED_TABLE_NAME[] = { TABLE_ENTRY(BlendEquationEXT), TABLE_ENTRY(DrawRangeElementsEXT), TABLE_ENTRY(ColorTableEXT), -#ifndef GLX_INDIRECT_RENDERING - TABLE_ENTRY(GetColorTableEXT), -#endif -#ifndef GLX_INDIRECT_RENDERING - TABLE_ENTRY(GetColorTableParameterfvEXT), -#endif -#ifndef GLX_INDIRECT_RENDERING - TABLE_ENTRY(GetColorTableParameterivEXT), -#endif + TABLE_ENTRY(_dispatch_stub_339), + TABLE_ENTRY(_dispatch_stub_340), + TABLE_ENTRY(_dispatch_stub_341), + TABLE_ENTRY(_dispatch_stub_342), + TABLE_ENTRY(_dispatch_stub_346), + TABLE_ENTRY(_dispatch_stub_347), + TABLE_ENTRY(_dispatch_stub_348), + TABLE_ENTRY(_dispatch_stub_349), + TABLE_ENTRY(_dispatch_stub_350), + TABLE_ENTRY(_dispatch_stub_351), + TABLE_ENTRY(_dispatch_stub_352), + TABLE_ENTRY(_dispatch_stub_353), + TABLE_ENTRY(_dispatch_stub_354), + TABLE_ENTRY(_dispatch_stub_355), + TABLE_ENTRY(_dispatch_stub_360), + TABLE_ENTRY(_dispatch_stub_367), + TABLE_ENTRY(_dispatch_stub_368), + TABLE_ENTRY(_dispatch_stub_369), + TABLE_ENTRY(_dispatch_stub_370), TABLE_ENTRY(TexImage3DEXT), TABLE_ENTRY(TexSubImage3DEXT), TABLE_ENTRY(CopyTexSubImage3DEXT), @@ -6726,6 +6700,7 @@ static _glapi_proc UNUSED_TABLE_NAME[] = { TABLE_ENTRY(MultiTexCoord4iv), TABLE_ENTRY(MultiTexCoord4s), TABLE_ENTRY(MultiTexCoord4sv), + TABLE_ENTRY(_dispatch_stub_423), TABLE_ENTRY(LoadTransposeMatrixd), TABLE_ENTRY(LoadTransposeMatrixf), TABLE_ENTRY(MultTransposeMatrixd), @@ -6839,8 +6814,10 @@ static _glapi_proc UNUSED_TABLE_NAME[] = { TABLE_ENTRY(DrawBuffersATI), TABLE_ENTRY(PointParameterf), TABLE_ENTRY(PointParameterfARB), + TABLE_ENTRY(_dispatch_stub_592), TABLE_ENTRY(PointParameterfv), TABLE_ENTRY(PointParameterfvARB), + TABLE_ENTRY(_dispatch_stub_593), TABLE_ENTRY(SecondaryColor3b), TABLE_ENTRY(SecondaryColor3bv), TABLE_ENTRY(SecondaryColor3d), @@ -6866,6 +6843,7 @@ static _glapi_proc UNUSED_TABLE_NAME[] = { TABLE_ENTRY(FogCoordf), TABLE_ENTRY(FogCoordfv), TABLE_ENTRY(BlendFuncSeparate), + TABLE_ENTRY(_dispatch_stub_623), TABLE_ENTRY(WindowPos2d), TABLE_ENTRY(WindowPos2dARB), TABLE_ENTRY(WindowPos2dv), @@ -6929,6 +6907,29 @@ static _glapi_proc UNUSED_TABLE_NAME[] = { TABLE_ENTRY(BlitFramebuffer), TABLE_ENTRY(FramebufferTextureLayer), TABLE_ENTRY(ProvokingVertex), +#endif /* _GLAPI_SKIP_NORMAL_ENTRY_POINTS */ +#ifndef _GLAPI_SKIP_PROTO_ENTRY_POINTS + TABLE_ENTRY(AreTexturesResidentEXT), + TABLE_ENTRY(DeleteTexturesEXT), + TABLE_ENTRY(GenTexturesEXT), + TABLE_ENTRY(IsTextureEXT), + TABLE_ENTRY(GetColorTableEXT), + TABLE_ENTRY(_dispatch_stub_343), + TABLE_ENTRY(GetColorTableParameterfvEXT), + TABLE_ENTRY(_dispatch_stub_344), + TABLE_ENTRY(GetColorTableParameterivEXT), + TABLE_ENTRY(_dispatch_stub_345), + TABLE_ENTRY(_dispatch_stub_356), + TABLE_ENTRY(_dispatch_stub_357), + TABLE_ENTRY(_dispatch_stub_358), + TABLE_ENTRY(_dispatch_stub_359), + TABLE_ENTRY(_dispatch_stub_361), + TABLE_ENTRY(_dispatch_stub_362), + TABLE_ENTRY(_dispatch_stub_363), + TABLE_ENTRY(_dispatch_stub_364), + TABLE_ENTRY(_dispatch_stub_365), + TABLE_ENTRY(_dispatch_stub_366), +#endif /* _GLAPI_SKIP_PROTO_ENTRY_POINTS */ }; #endif /*UNUSED_TABLE_NAME*/ diff --git a/src/mesa/main/dispatch.c b/src/mesa/main/dispatch.c index 97d213e8e1..cd5410514d 100644 --- a/src/mesa/main/dispatch.c +++ b/src/mesa/main/dispatch.c @@ -89,6 +89,10 @@ #define GLAPIENTRY #endif +#ifdef GLX_INDIRECT_RENDERING +/* those link to libglapi.a should provide the entry points */ +#define _GLAPI_SKIP_PROTO_ENTRY_POINTS +#endif #include "glapi/glapitemp.h" #endif /* USE_X86_ASM */ -- cgit v1.2.3 From 888429360a30090b9ecd17bfd160a88141195235 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 15 Oct 2009 18:07:22 +0800 Subject: mesa/xlib: Fix missing symbols when GLX_INDIRECT_RENDERING is defined. When GLX_INDIRECT_RENDERING is defined, some symbols are used in libglapi.a but are not defined. Define them through the help of glapitemp.h. Signed-off-by: Chia-I Wu --- src/mesa/drivers/x11/glxapi.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/mesa/drivers/x11/glxapi.c b/src/mesa/drivers/x11/glxapi.c index 02eea25a71..66b9a41f13 100644 --- a/src/mesa/drivers/x11/glxapi.c +++ b/src/mesa/drivers/x11/glxapi.c @@ -50,6 +50,36 @@ struct display_dispatch { struct display_dispatch *Next; }; + +/** + * When GLX_INDIRECT_RENDERING is defined, some symbols are missing in + * libglapi.a. We need to define them here. + */ +#ifdef GLX_INDIRECT_RENDERING + +#include "glapi/dispatch.h" + +#define KEYWORD1 PUBLIC + +#if defined(USE_MGL_NAMESPACE) +#define NAME(func) mgl##func +#else +#define NAME(func) gl##func +#endif + +#define DISPATCH(FUNC, ARGS, MESSAGE) \ + CALL_ ## FUNC(GET_DISPATCH(), ARGS); + +#define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \ + return CALL_ ## FUNC(GET_DISPATCH(), ARGS); + +/* skip normal ones */ +#define _GLAPI_SKIP_NORMAL_ENTRY_POINTS +#include "glapi/glapitemp.h" + +#endif /* GLX_INDIRECT_RENDERING */ + + static struct display_dispatch *DispatchList = NULL; -- cgit v1.2.3 From 6678f597e7c9ba784c9af0c86cfc6821558bcaa7 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 15 Oct 2009 18:25:24 +0800 Subject: gallium/xlib: Fix missing symbols when GLX_INDIRECT_RENDERING is defined. When GLX_INDIRECT_RENDERING is defined, some symbols are used in libglapi.a but are not defined. Define them through the help of glapitemp.h. Signed-off-by: Chia-I Wu --- src/gallium/winsys/xlib/xlib.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/gallium/winsys/xlib/xlib.c b/src/gallium/winsys/xlib/xlib.c index 163cc8863c..bf2fb230eb 100644 --- a/src/gallium/winsys/xlib/xlib.c +++ b/src/gallium/winsys/xlib/xlib.c @@ -112,3 +112,33 @@ extern void (*linker_foo(const unsigned char *procName))() { return glXGetProcAddress(procName); } + + +/** + * When GLX_INDIRECT_RENDERING is defined, some symbols are missing in + * libglapi.a. We need to define them here. + */ +#ifdef GLX_INDIRECT_RENDERING + +#define GL_GLEXT_PROTOTYPES +#include "GL/gl.h" +#include "glapi/glapi.h" +#include "glapi/dispatch.h" + +#if defined(USE_MGL_NAMESPACE) +#define NAME(func) mgl##func +#else +#define NAME(func) gl##func +#endif + +#define DISPATCH(FUNC, ARGS, MESSAGE) \ + CALL_ ## FUNC(GET_DISPATCH(), ARGS); + +#define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \ + return CALL_ ## FUNC(GET_DISPATCH(), ARGS); + +/* skip normal ones */ +#define _GLAPI_SKIP_NORMAL_ENTRY_POINTS +#include "glapi/glapitemp.h" + +#endif /* GLX_INDIRECT_RENDERING */ -- cgit v1.2.3 From c3d61d378574878deedb44d84f506ca23e66c6ca Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 7 Sep 2009 14:46:22 +0800 Subject: mesa/main: Add support for point size array in _mesa_GetPointerv. Signed-off-by: Chia-I Wu --- src/mesa/main/getstring.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c index 6599ed9698..4b1f4b0ea1 100644 --- a/src/mesa/main/getstring.c +++ b/src/mesa/main/getstring.c @@ -242,6 +242,11 @@ _mesa_GetPointerv( GLenum pname, GLvoid **params ) case GL_SELECTION_BUFFER_POINTER: *params = ctx->Select.Buffer; break; +#if FEATURE_point_size_array + case GL_POINT_SIZE_ARRAY_POINTER_OES: + *params = (GLvoid *) ctx->Array.ArrayObj->PointSize.Ptr; + break; +#endif default: _mesa_error( ctx, GL_INVALID_ENUM, "glGetPointerv" ); return; -- cgit v1.2.3 From 8d2edbf1395ca1e2d23b3bd2ba2c5d54f21d377b Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 21 Sep 2009 18:46:28 +0800 Subject: mesa/main: Add more OpenGL ES types to glheader.h. Signed-off-by: Chia-I Wu --- src/mesa/main/glheader.h | 7 +++++++ src/mesa/swrast/swrast.h | 6 ------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h index 81d4ccf919..77544c88c6 100644 --- a/src/mesa/main/glheader.h +++ b/src/mesa/main/glheader.h @@ -57,6 +57,13 @@ #ifndef GL_FIXED #define GL_FIXED 0x140C +typedef int GLfixed; +typedef int GLclampx; +#endif + + +#ifndef GL_OES_EGL_image +typedef void *GLeglImageOES; #endif diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h index c183b315b6..c01cf7d1f0 100644 --- a/src/mesa/swrast/swrast.h +++ b/src/mesa/swrast/swrast.h @@ -75,12 +75,6 @@ typedef struct { } SWvertex; -/** - * Fixed point data type. - */ -typedef int GLfixed; - - #define FRAG_ATTRIB_CI FRAG_ATTRIB_COL0 -- cgit v1.2.3 From 6418f836d470b41c2a5dbfad52b797db1ec3871b Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 20 Oct 2009 14:32:39 +0800 Subject: glapi: Add is_abi() to test if a function is in the ABI. The test is done by checking if the offset is manually assigned. The generated headers are unchanged. Signed-off-by: Chia-I Wu --- src/mesa/glapi/gl_XML.py | 3 +++ src/mesa/glapi/gl_offsets.py | 5 +---- src/mesa/glapi/gl_table.py | 5 +---- src/mesa/glapi/remap_helper.py | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/mesa/glapi/gl_XML.py b/src/mesa/glapi/gl_XML.py index b98919134f..bafb00306f 100644 --- a/src/mesa/glapi/gl_XML.py +++ b/src/mesa/glapi/gl_XML.py @@ -738,6 +738,9 @@ class gl_function( gl_item ): return p_string + def is_abi(self): + return (self.offset >= 0 and not self.assign_offset) + def is_static_entry_point(self, name): return name in self.static_entry_points diff --git a/src/mesa/glapi/gl_offsets.py b/src/mesa/glapi/gl_offsets.py index ca6c90ffd8..b8b509d09f 100644 --- a/src/mesa/glapi/gl_offsets.py +++ b/src/mesa/glapi/gl_offsets.py @@ -41,8 +41,6 @@ class PrintGlOffsets(gl_XML.gl_print_base): return def printBody(self, api): - abi = [ "1.0", "1.1", "1.2", "GL_ARB_multitexture" ] - print '/* this file should not be included directly in mesa */' print '' @@ -50,8 +48,7 @@ class PrintGlOffsets(gl_XML.gl_print_base): abi_functions = [] count = 0 for f in api.functionIterateByOffset(): - [category, num] = api.get_category_for_name( f.name ) - if category not in abi: + if not f.is_abi(): functions.append( [f, count] ) count += 1 else: diff --git a/src/mesa/glapi/gl_table.py b/src/mesa/glapi/gl_table.py index 0e05b3431a..698795fb0a 100644 --- a/src/mesa/glapi/gl_table.py +++ b/src/mesa/glapi/gl_table.py @@ -113,14 +113,11 @@ class PrintRemapTable(gl_XML.gl_print_base): print ' } while(0)' print '' - abi = [ "1.0", "1.1", "1.2", "GL_ARB_multitexture" ] - functions = [] abi_functions = [] count = 0 for f in api.functionIterateByOffset(): - [category, num] = api.get_category_for_name( f.name ) - if category not in abi: + if not f.is_abi(): functions.append( [f, count] ) count += 1 else: diff --git a/src/mesa/glapi/remap_helper.py b/src/mesa/glapi/remap_helper.py index e47583a5d3..2a1f5adc32 100644 --- a/src/mesa/glapi/remap_helper.py +++ b/src/mesa/glapi/remap_helper.py @@ -145,7 +145,7 @@ class PrintGlRemap(gl_XML.gl_print_base): funcs = [] for f in extension_functions[ext]: # test if the function is in the ABI - if not f.assign_offset and f.offset >= 0: + if f.is_abi(): funcs.append(f) if not funcs: continue -- cgit v1.2.3 From 7df4c7e1b8faf0c0339ca7287e3560fafab02b6a Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 20 Oct 2009 14:15:45 +0800 Subject: glapi: Avoid hardcoded category names in remap helper script. The output of the script is unchanged. Signed-off-by: Chia-I Wu --- src/mesa/glapi/remap_helper.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/mesa/glapi/remap_helper.py b/src/mesa/glapi/remap_helper.py index 2a1f5adc32..d93c7a4285 100644 --- a/src/mesa/glapi/remap_helper.py +++ b/src/mesa/glapi/remap_helper.py @@ -123,18 +123,26 @@ class PrintGlRemap(gl_XML.gl_print_base): print '};' print '' - abi = [ "1.0", "1.1", "1.2", "GL_ARB_multitexture" ] + # collect functions by versions/extensions extension_functions = {} - - # collect non-ABI functions + abi_extensions = [] for f in api.functionIterateAll(): for n in f.entry_points: category, num = api.get_category_for_name(n) - if category not in abi: - c = gl_XML.real_category_name(category) + # consider only GL_VERSION_X_Y or extensions + c = gl_XML.real_category_name(category) + if c.startswith("GL_"): if not extension_functions.has_key(c): extension_functions[c] = [] extension_functions[c].append(f) + # remember the ext names of the ABI + if (f.is_abi() and n == f.name and + c not in abi_extensions): + abi_extensions.append(c) + # ignore the ABI itself + for ext in abi_extensions: + extension_functions.pop(ext) + extensions = extension_functions.keys() extensions.sort() @@ -144,8 +152,8 @@ class PrintGlRemap(gl_XML.gl_print_base): for ext in extensions: funcs = [] for f in extension_functions[ext]: - # test if the function is in the ABI - if f.is_abi(): + # test if the function is in the ABI and has alt names + if f.is_abi() and len(f.entry_points) > 1: funcs.append(f) if not funcs: continue @@ -171,7 +179,7 @@ class PrintGlRemap(gl_XML.gl_print_base): remapped.append(f) else: # these functions are either in the - # abi, or have offset -1 + # abi, or have offset -1 funcs.append(f) print '#if defined(need_%s)' % (ext) -- cgit v1.2.3 From 5b426288c2dbc42ef44ea13fe37afa77223107bb Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 3 Sep 2009 11:03:20 +0800 Subject: glapi: Include headers with directory prefixes. This allows different sets of generated sources and headers to be used. Signed-off-by: Chia-I Wu --- src/mesa/glapi/dispatch.h | 6 +++--- src/mesa/glapi/gl_enums.py | 8 ++++---- src/mesa/glapi/gl_x86-64_asm.py | 2 +- src/mesa/glapi/gl_x86_asm.py | 2 +- src/mesa/glapi/glapi.c | 8 ++++---- src/mesa/glapi/glapi_getproc.c | 8 ++++---- src/mesa/glapi/glthread.c | 2 +- src/mesa/main/enums.c | 8 ++++---- src/mesa/main/remap.c | 2 +- src/mesa/x86-64/glapi_x86-64.S | 2 +- src/mesa/x86/glapi_x86.S | 2 +- 11 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/mesa/glapi/dispatch.h b/src/mesa/glapi/dispatch.h index 6623d52469..27f80a5062 100644 --- a/src/mesa/glapi/dispatch.h +++ b/src/mesa/glapi/dispatch.h @@ -30,8 +30,8 @@ #define _GLAPI_USE_REMAP_TABLE #endif -#include "glapitable.h" -#include "glapioffsets.h" -#include "glapidispatch.h" +#include "glapi/glapitable.h" +#include "glapi/glapioffsets.h" +#include "glapi/glapidispatch.h" #endif /* _DISPATCH_H */ diff --git a/src/mesa/glapi/gl_enums.py b/src/mesa/glapi/gl_enums.py index 27ab119537..acaa06ab37 100644 --- a/src/mesa/glapi/gl_enums.py +++ b/src/mesa/glapi/gl_enums.py @@ -42,10 +42,10 @@ class PrintGlEnums(gl_XML.gl_print_base): def printRealHeader(self): - print '#include "glheader.h"' - print '#include "mfeatures.h"' - print '#include "enums.h"' - print '#include "imports.h"' + print '#include "main/glheader.h"' + print '#include "main/mfeatures.h"' + print '#include "main/enums.h"' + print '#include "main/imports.h"' print '' print 'typedef struct {' print ' size_t offset;' diff --git a/src/mesa/glapi/gl_x86-64_asm.py b/src/mesa/glapi/gl_x86-64_asm.py index f36ad3a5d8..31c1a2b93a 100644 --- a/src/mesa/glapi/gl_x86-64_asm.py +++ b/src/mesa/glapi/gl_x86-64_asm.py @@ -122,7 +122,7 @@ class PrintGenericStubs(gl_XML.gl_print_base): print " * the symbol visibility mode to 'default'." print ' */' print '' - print '#include "../x86/assyntax.h"' + print '#include "x86/assyntax.h"' print '' print '#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303' print '# pragma GCC visibility push(default)' diff --git a/src/mesa/glapi/gl_x86_asm.py b/src/mesa/glapi/gl_x86_asm.py index 36f0e31fe2..d293497736 100644 --- a/src/mesa/glapi/gl_x86_asm.py +++ b/src/mesa/glapi/gl_x86_asm.py @@ -53,7 +53,7 @@ class PrintGenericStubs(gl_XML.gl_print_base): def printRealHeader(self): - print '#include "assyntax.h"' + print '#include "x86/assyntax.h"' print '#include "glapi/glapioffsets.h"' print '' print '#if defined(STDCALL_API)' diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index e36fccb354..ad72fe48be 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -69,9 +69,9 @@ #include #endif -#include "glapi.h" -#include "glapioffsets.h" -#include "glapitable.h" +#include "glapi/glapi.h" +#include "glapi/glapioffsets.h" +#include "glapi/glapitable.h" /***** BEGIN NO-OP DISPATCH *****/ @@ -145,7 +145,7 @@ static GLint NoOpUnused(void) return 0; } -#include "glapitemp.h" +#include "glapi/glapitemp.h" /***** END NO-OP DISPATCH *****/ diff --git a/src/mesa/glapi/glapi_getproc.c b/src/mesa/glapi/glapi_getproc.c index ed443c12c8..decdd05b13 100644 --- a/src/mesa/glapi/glapi_getproc.c +++ b/src/mesa/glapi/glapi_getproc.c @@ -34,9 +34,9 @@ #include #include "main/glheader.h" #include "main/compiler.h" -#include "glapi.h" -#include "glapioffsets.h" -#include "glapitable.h" +#include "glapi/glapi.h" +#include "glapi/glapioffsets.h" +#include "glapi/glapitable.h" static void @@ -75,7 +75,7 @@ str_dup(const char *str) #endif /* The code in this file is auto-generated with Python */ -#include "glprocs.h" +#include "glapi/glprocs.h" /** diff --git a/src/mesa/glapi/glthread.c b/src/mesa/glapi/glthread.c index 737fd4d6a8..dc90b3602c 100644 --- a/src/mesa/glapi/glthread.c +++ b/src/mesa/glapi/glthread.c @@ -33,7 +33,7 @@ #endif #include "main/compiler.h" -#include "glthread.h" +#include "glapi/glthread.h" /* diff --git a/src/mesa/main/enums.c b/src/mesa/main/enums.c index 606d50c59a..dedb6af7b5 100644 --- a/src/mesa/main/enums.c +++ b/src/mesa/main/enums.c @@ -25,10 +25,10 @@ * SOFTWARE. */ -#include "glheader.h" -#include "mfeatures.h" -#include "enums.h" -#include "imports.h" +#include "main/glheader.h" +#include "main/mfeatures.h" +#include "main/enums.h" +#include "main/imports.h" typedef struct { size_t offset; diff --git a/src/mesa/main/remap.c b/src/mesa/main/remap.c index 0385ae8d7d..5f32a48258 100644 --- a/src/mesa/main/remap.c +++ b/src/mesa/main/remap.c @@ -45,7 +45,7 @@ #define need_MESA_remap_table -#include "remap_helper.h" +#include "main/remap_helper.h" #define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) #define MAX_ENTRY_POINTS 16 diff --git a/src/mesa/x86-64/glapi_x86-64.S b/src/mesa/x86-64/glapi_x86-64.S index 72d0532906..05afbb294c 100644 --- a/src/mesa/x86-64/glapi_x86-64.S +++ b/src/mesa/x86-64/glapi_x86-64.S @@ -29,7 +29,7 @@ * the symbol visibility mode to 'default'. */ -#include "../x86/assyntax.h" +#include "x86/assyntax.h" #if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 # pragma GCC visibility push(default) diff --git a/src/mesa/x86/glapi_x86.S b/src/mesa/x86/glapi_x86.S index 12c77f434e..117e31ede0 100644 --- a/src/mesa/x86/glapi_x86.S +++ b/src/mesa/x86/glapi_x86.S @@ -26,7 +26,7 @@ * SOFTWARE. */ -#include "assyntax.h" +#include "x86/assyntax.h" #include "glapi/glapioffsets.h" #if defined(STDCALL_API) -- cgit v1.2.3 From 7cdf8ab0967b1a80c16d317ed5b0e3b810312ad1 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 20 Oct 2009 12:39:56 +0800 Subject: mesa/main: Make _mesa_TexGenf and _mesa_GetTexGenfv global again. They are needed by OpenGL ES overlay. Signed-off-by: Chia-I Wu --- src/mesa/main/texgen.c | 4 ++-- src/mesa/main/texgen.h | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/texgen.c b/src/mesa/main/texgen.c index 733e129fcf..8d114108f8 100644 --- a/src/mesa/main/texgen.c +++ b/src/mesa/main/texgen.c @@ -208,7 +208,7 @@ _mesa_TexGendv(GLenum coord, GLenum pname, const GLdouble *params ) } -static void GLAPIENTRY +void GLAPIENTRY _mesa_TexGenf( GLenum coord, GLenum pname, GLfloat param ) { _mesa_TexGenfv(coord, pname, ¶m); @@ -261,7 +261,7 @@ _mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params ) -static void GLAPIENTRY +void GLAPIENTRY _mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ) { struct gl_texture_unit *texUnit; diff --git a/src/mesa/main/texgen.h b/src/mesa/main/texgen.h index f6924ef722..eb4626033a 100644 --- a/src/mesa/main/texgen.h +++ b/src/mesa/main/texgen.h @@ -40,9 +40,15 @@ extern void GLAPIENTRY _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ); +extern void GLAPIENTRY +_mesa_TexGenf( GLenum coord, GLenum pname, GLfloat param ); + extern void GLAPIENTRY _mesa_TexGeni( GLenum coord, GLenum pname, GLint param ); +extern void GLAPIENTRY +_mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ); + extern void _mesa_init_texgen_dispatch(struct _glapi_table *disp); -- cgit v1.2.3 From f68bf0621d1f865033b078191c1f4ec1fa0bbc5c Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 2 Sep 2009 12:04:56 +0800 Subject: mesa/es: Add OpenGL ES XMLs. These XMLs define OpenGL ES 1.x and 2.x APIs. Signed-off-by: Chia-I Wu --- src/mesa/es/glapi/Makefile | 90 ++ src/mesa/es/glapi/base1_API.xml | 744 ++++++++++ src/mesa/es/glapi/base2_API.xml | 533 +++++++ src/mesa/es/glapi/es1_API.xml | 1100 ++++++++++++++ src/mesa/es/glapi/es1_COMPAT.xml | 135 ++ src/mesa/es/glapi/es1_EXT.xml | 693 +++++++++ src/mesa/es/glapi/es2_API.xml | 294 ++++ src/mesa/es/glapi/es2_COMPAT.xml | 368 +++++ src/mesa/es/glapi/es2_EXT.xml | 122 ++ src/mesa/es/glapi/es_COMPAT.xml | 2646 ++++++++++++++++++++++++++++++++++ src/mesa/es/glapi/es_EXT.xml | 83 ++ src/mesa/es/glapi/gl_compare.py | 354 +++++ src/mesa/es/glapi/gl_parse_header.py | 450 ++++++ 13 files changed, 7612 insertions(+) create mode 100644 src/mesa/es/glapi/Makefile create mode 100644 src/mesa/es/glapi/base1_API.xml create mode 100644 src/mesa/es/glapi/base2_API.xml create mode 100644 src/mesa/es/glapi/es1_API.xml create mode 100644 src/mesa/es/glapi/es1_COMPAT.xml create mode 100644 src/mesa/es/glapi/es1_EXT.xml create mode 100644 src/mesa/es/glapi/es2_API.xml create mode 100644 src/mesa/es/glapi/es2_COMPAT.xml create mode 100644 src/mesa/es/glapi/es2_EXT.xml create mode 100644 src/mesa/es/glapi/es_COMPAT.xml create mode 100644 src/mesa/es/glapi/es_EXT.xml create mode 100644 src/mesa/es/glapi/gl_compare.py create mode 100644 src/mesa/es/glapi/gl_parse_header.py diff --git a/src/mesa/es/glapi/Makefile b/src/mesa/es/glapi/Makefile new file mode 100644 index 0000000000..5f2aa8225b --- /dev/null +++ b/src/mesa/es/glapi/Makefile @@ -0,0 +1,90 @@ +TOP = ../../../.. +GLAPI = ../../glapi +include $(TOP)/configs/current + +OUTPUTS := \ + glapi/glapidispatch.h \ + glapi/glapioffsets.h \ + glapi/glapitable.h \ + glapi/glapitemp.h \ + glapi/glprocs.h \ + sparc/glapi_sparc.S \ + x86-64/glapi_x86-64.S \ + x86/glapi_x86.S \ + main/enums.c \ + main/remap_helper.h + +COMMON = gl_XML.py glX_XML.py license.py typeexpr.py +COMMON := $(addprefix $(GLAPI)/, $(COMMON)) + +ES1_APIXML := es1_API.xml +ES2_APIXML := es2_API.xml +ES1_OUTPUT_DIR := glapi-es1 +ES2_OUTPUT_DIR := glapi-es2 + +ES1_DEPS = $(ES1_APIXML) base1_API.xml es1_EXT.xml es_EXT.xml \ + es1_COMPAT.xml es_COMPAT.xml +ES2_DEPS = $(ES2_APIXML) base2_API.xml es2_EXT.xml es_EXT.xml \ + es2_COMPAT.xml es_COMPAT.xml + +ES1_OUTPUTS := $(addprefix $(ES1_OUTPUT_DIR)/, $(OUTPUTS)) +ES2_OUTPUTS := $(addprefix $(ES2_OUTPUT_DIR)/, $(OUTPUTS)) + +all: $(ES1_OUTPUTS) $(ES2_OUTPUTS) + +$(ES1_OUTPUTS): APIXML := $(ES1_APIXML) +$(ES2_OUTPUTS): APIXML := $(ES2_APIXML) +$(ES1_OUTPUTS): $(ES1_DEPS) +$(ES2_OUTPUTS): $(ES2_DEPS) + +define gen-glapi + @mkdir -p $(dir $@) + $(PYTHON2) $(PYTHON_FLAGS) $< -f $(APIXML) $(1) > $@ +endef + +%/glapidispatch.h: $(GLAPI)/gl_table.py $(COMMON) + $(call gen-glapi,-c -m remap_table) + +%/glapioffsets.h: $(GLAPI)/gl_offsets.py $(COMMON) + $(call gen-glapi,-c) + +%/glapitable.h: $(GLAPI)/gl_table.py $(COMMON) + $(call gen-glapi,-c) + +%/glapitemp.h: $(GLAPI)/gl_apitemp.py $(COMMON) + $(call gen-glapi) + +%/glprocs.h: $(GLAPI)/gl_procs.py $(COMMON) + $(call gen-glapi,-c) + +%/sparc/glapi_sparc.S: $(GLAPI)/gl_SPARC_asm.py $(COMMON) + $(call gen-glapi) + +%/x86-64/glapi_x86-64.S: $(GLAPI)/gl_x86-64_asm.py $(COMMON) + $(call gen-glapi) + +%/x86/glapi_x86.S: $(GLAPI)/gl_x86_asm.py $(COMMON) + $(call gen-glapi) + +%/main/enums.c: $(GLAPI)/gl_enums.py $(COMMON) + $(call gen-glapi) + +%/main/remap_helper.h: $(GLAPI)/remap_helper.py $(COMMON) + $(call gen-glapi) + +verify_xml: + @if [ ! -f gl.h ]; then \ + echo "Please copy gl.h and gl2.h to this directory"; \ + exit 1; \ + fi + @echo "Verifying that es1_API.xml covers OpenGL ES 1.1..." + @$(PYTHON2) $(PYTHON_FLAGS) gl_parse_header.py gl.h > tmp.xml + @$(PYTHON2) $(PYTHON_FLAGS) gl_compare.py difference tmp.xml es1_API.xml + @echo "Verifying that es2_API.xml covers OpenGL ES 2.0..." + @$(PYTHON2) $(PYTHON_FLAGS) gl_parse_header.py gl2.h > tmp.xml + @$(PYTHON2) $(PYTHON_FLAGS) gl_compare.py difference tmp.xml es2_API.xml + @rm -f tmp.xml + +clean: + -rm -rf $(ES1_OUTPUT_DIR) $(ES2_OUTPUT_DIR) + -rm -f *~ *.pyc *.pyo diff --git a/src/mesa/es/glapi/base1_API.xml b/src/mesa/es/glapi/base1_API.xml new file mode 100644 index 0000000000..f5d136ccef --- /dev/null +++ b/src/mesa/es/glapi/base1_API.xml @@ -0,0 +1,744 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mesa/es/glapi/base2_API.xml b/src/mesa/es/glapi/base2_API.xml new file mode 100644 index 0000000000..6aa43b728a --- /dev/null +++ b/src/mesa/es/glapi/base2_API.xml @@ -0,0 +1,533 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mesa/es/glapi/es1_API.xml b/src/mesa/es/glapi/es1_API.xml new file mode 100644 index 0000000000..7ee5515f19 --- /dev/null +++ b/src/mesa/es/glapi/es1_API.xml @@ -0,0 +1,1100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mesa/es/glapi/es1_COMPAT.xml b/src/mesa/es/glapi/es1_COMPAT.xml new file mode 100644 index 0000000000..4fc9223cc0 --- /dev/null +++ b/src/mesa/es/glapi/es1_COMPAT.xml @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mesa/es/glapi/es1_EXT.xml b/src/mesa/es/glapi/es1_EXT.xml new file mode 100644 index 0000000000..7c7c585736 --- /dev/null +++ b/src/mesa/es/glapi/es1_EXT.xml @@ -0,0 +1,693 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mesa/es/glapi/es2_API.xml b/src/mesa/es/glapi/es2_API.xml new file mode 100644 index 0000000000..266c07613c --- /dev/null +++ b/src/mesa/es/glapi/es2_API.xml @@ -0,0 +1,294 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mesa/es/glapi/es2_COMPAT.xml b/src/mesa/es/glapi/es2_COMPAT.xml new file mode 100644 index 0000000000..61f11a604e --- /dev/null +++ b/src/mesa/es/glapi/es2_COMPAT.xml @@ -0,0 +1,368 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mesa/es/glapi/es2_EXT.xml b/src/mesa/es/glapi/es2_EXT.xml new file mode 100644 index 0000000000..fef6368022 --- /dev/null +++ b/src/mesa/es/glapi/es2_EXT.xml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mesa/es/glapi/es_COMPAT.xml b/src/mesa/es/glapi/es_COMPAT.xml new file mode 100644 index 0000000000..bb6d28db83 --- /dev/null +++ b/src/mesa/es/glapi/es_COMPAT.xml @@ -0,0 +1,2646 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mesa/es/glapi/es_EXT.xml b/src/mesa/es/glapi/es_EXT.xml new file mode 100644 index 0000000000..28f41ae09a --- /dev/null +++ b/src/mesa/es/glapi/es_EXT.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mesa/es/glapi/gl_compare.py b/src/mesa/es/glapi/gl_compare.py new file mode 100644 index 0000000000..7a2148cb1f --- /dev/null +++ b/src/mesa/es/glapi/gl_compare.py @@ -0,0 +1,354 @@ +#!/usr/bin/python +# +# Copyright (C) 2009 Chia-I Wu +# +# 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 +# on the rights to use, copy, modify, merge, publish, distribute, sub +# license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL +# IBM AND/OR ITS SUPPLIERS 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. + +import sys +import os.path +import getopt + +GLAPI = "../../glapi" +sys.path.append(GLAPI) + +import gl_XML +import glX_XML + +class ApiSet(object): + def __init__(self, api, elts=["enum", "type", "function"]): + self.api = api + self.elts = elts + + def _check_enum(self, e1, e2, strict=True): + if e1.name != e2.name: + raise ValueError("%s: name mismatch" % e1.name) + if e1.value != e2.value: + raise ValueError("%s: value 0x%04x != 0x%04x" + % (e1.name, e1.value, e2.value)) + + def _check_type(self, t1, t2, strict=True): + if t1.name != t2.name: + raise ValueError("%s: name mismatch" % t1.name) + if t1.type_expr.string() != t2.type_expr.string(): + raise ValueError("%s: type %s != %s" + % (t1.name, t1.type_expr.string(), t2.type_expr.string())) + + def _check_function(self, f1, f2, strict=True): + if f1.name != f2.name: + raise ValueError("%s: name mismatch" % f1.name) + if f1.return_type != f2.return_type: + raise ValueError("%s: return type %s != %s" + % (f1.name, f1.return_type, f2.return_type)) + # there might be padded parameters + if strict and len(f1.parameters) != len(f2.parameters): + raise ValueError("%s: parameter length %d != %d" + % (f1.name, len(f1.parameters), len(f2.parameters))) + if f1.assign_offset != f2.assign_offset: + if ((f1.assign_offset and f2.offset < 0) or + (f2.assign_offset and f1.offset < 0)): + raise ValueError("%s: assign offset %d != %d" + % (f1.name, f1.assign_offset, f2.assign_offset)) + elif not f1.assign_offset: + if f1.offset != f2.offset: + raise ValueError("%s: offset %d != %d" + % (f1.name, f1.offset, f2.offset)) + + if strict: + l1 = f1.entry_points + l2 = f2.entry_points + l1.sort() + l2.sort() + if l1 != l2: + raise ValueError("%s: entry points %s != %s" + % (f1.name, l1, l2)) + + l1 = f1.static_entry_points + l2 = f2.static_entry_points + l1.sort() + l2.sort() + if l1 != l2: + raise ValueError("%s: static entry points %s != %s" + % (f1.name, l1, l2)) + + pad = 0 + for i in xrange(len(f1.parameters)): + p1 = f1.parameters[i] + p2 = f2.parameters[i + pad] + + if not strict and p1.is_padding != p2.is_padding: + if p1.is_padding: + pad -= 1 + continue + else: + pad += 1 + p2 = f2.parameters[i + pad] + + if strict and p1.name != p2.name: + raise ValueError("%s: parameter %d name %s != %s" + % (f1.name, i, p1.name, p2.name)) + if p1.type_expr.string() != p2.type_expr.string(): + if (strict or + # special case + f1.name == "TexImage2D" and p1.name != "internalformat"): + raise ValueError("%s: parameter %s type %s != %s" + % (f1.name, p1.name, p1.type_expr.string(), + p2.type_expr.string())) + + def union(self, other): + union = gl_XML.gl_api(None) + + if "enum" in self.elts: + union.enums_by_name = other.enums_by_name.copy() + for key, val in self.api.enums_by_name.iteritems(): + if key not in union.enums_by_name: + union.enums_by_name[key] = val + else: + self._check_enum(val, other.enums_by_name[key]) + + if "type" in self.elts: + union.types_by_name = other.types_by_name.copy() + for key, val in self.api.types_by_name.iteritems(): + if key not in union.types_by_name: + union.types_by_name[key] = val + else: + self._check_type(val, other.types_by_name[key]) + + if "function" in self.elts: + union.functions_by_name = other.functions_by_name.copy() + for key, val in self.api.functions_by_name.iteritems(): + if key not in union.functions_by_name: + union.functions_by_name[key] = val + else: + self._check_function(val, other.functions_by_name[key]) + + return union + + def intersection(self, other): + intersection = gl_XML.gl_api(None) + + if "enum" in self.elts: + for key, val in self.api.enums_by_name.iteritems(): + if key in other.enums_by_name: + self._check_enum(val, other.enums_by_name[key]) + intersection.enums_by_name[key] = val + + if "type" in self.elts: + for key, val in self.api.types_by_name.iteritems(): + if key in other.types_by_name: + self._check_type(val, other.types_by_name[key]) + intersection.types_by_name[key] = val + + if "function" in self.elts: + for key, val in self.api.functions_by_name.iteritems(): + if key in other.functions_by_name: + self._check_function(val, other.functions_by_name[key]) + intersection.functions_by_name[key] = val + + return intersection + + def difference(self, other): + difference = gl_XML.gl_api(None) + + if "enum" in self.elts: + for key, val in self.api.enums_by_name.iteritems(): + if key not in other.enums_by_name: + difference.enums_by_name[key] = val + else: + self._check_enum(val, other.enums_by_name[key]) + + if "type" in self.elts: + for key, val in self.api.types_by_name.iteritems(): + if key not in other.types_by_name: + difference.types_by_name[key] = val + else: + self._check_type(val, other.types_by_name[key]) + + if "function" in self.elts: + for key, val in self.api.functions_by_name.iteritems(): + if key not in other.functions_by_name: + difference.functions_by_name[key] = val + else: + self._check_function(val, other.functions_by_name[key], False) + + return difference + +def cmp_enum(e1, e2): + if e1.value < e2.value: + return -1 + elif e1.value > e2.value: + return 1 + else: + return 0 + +def cmp_type(t1, t2): + return t1.size - t2.size + +def cmp_function(f1, f2): + if f1.name > f2.name: + return 1 + elif f1.name < f2.name: + return -1 + else: + return 0 + +def spaces(n, str=""): + spaces = n - len(str) + if spaces < 1: + spaces = 1 + return " " * spaces + +def output_enum(e, indent=0): + attrs = 'name="%s"' % e.name + if e.default_count > 0: + tab = spaces(37, attrs) + attrs += '%scount="%d"' % (tab, e.default_count) + tab = spaces(48, attrs) + val = "%04x" % e.value + val = "0x" + val.upper() + attrs += '%svalue="%s"' % (tab, val) + + # no child + if not e.functions: + print '%s' % (spaces(indent), attrs) + return + + print '%s' % (spaces(indent), attrs) + for key, val in e.functions.iteritems(): + attrs = 'name="%s"' % key + if val[0] != e.default_count: + attrs += ' count="%d"' % val[0] + if not val[1]: + attrs += ' mode="get"' + + print '%s' % (spaces(indent * 2), attrs) + + print '%s' % spaces(indent) + +def output_type(t, indent=0): + tab = spaces(16, t.name) + attrs = 'name="%s"%ssize="%d"' % (t.name, tab, t.size) + ctype = t.type_expr.string() + if ctype.find("unsigned") != -1: + attrs += ' unsigned="true"' + elif ctype.find("signed") == -1: + attrs += ' float="true"' + print '%s' % (spaces(indent), attrs) + +def output_function(f, indent=0): + attrs = 'name="%s"' % f.name + if f.offset > 0: + if f.assign_offset: + attrs += ' offset="assign"' + else: + attrs += ' offset="%d"' % f.offset + print '%s' % (spaces(indent), attrs) + + for p in f.parameters: + attrs = 'name="%s" type="%s"' \ + % (p.name, p.type_expr.original_string) + print '%s' % (spaces(indent * 2), attrs) + if f.return_type != "void": + attrs = 'type="%s"' % f.return_type + print '%s' % (spaces(indent * 2), attrs) + + print '%s' % spaces(indent) + +def output_category(api, indent=0): + enums = api.enums_by_name.values() + enums.sort(cmp_enum) + types = api.types_by_name.values() + types.sort(cmp_type) + functions = api.functions_by_name.values() + functions.sort(cmp_function) + + for e in enums: + output_enum(e, indent) + if enums and types: + print + for t in types: + output_type(t, indent) + if enums or types: + print + for f in functions: + output_function(f, indent) + if f != functions[-1]: + print + +def is_api_empty(api): + return bool(not api.enums_by_name and + not api.types_by_name and + not api.functions_by_name) + +def show_usage(ops): + print "Usage: %s [-k elts] <%s> " % (sys.argv[0], "|".join(ops)) + print " -k elts A comma separated string of types of elements to" + print " skip. Possible types are enum, type, and function." + sys.exit(1) + +def main(): + ops = ["union", "intersection", "difference"] + elts = ["enum", "type", "function"] + + try: + options, args = getopt.getopt(sys.argv[1:], "k:") + except Exception, e: + show_usage(ops) + + if len(args) != 3: + show_usage(ops) + op, file1, file2 = args + if op not in ops: + show_usage(ops) + + skips = [] + for opt, val in options: + if opt == "-k": + skips = val.split(",") + + for elt in skips: + try: + elts.remove(elt) + except ValueError: + show_usage(ops) + + api1 = gl_XML.parse_GL_API(file1, glX_XML.glx_item_factory()) + api2 = gl_XML.parse_GL_API(file2, glX_XML.glx_item_factory()) + + set = ApiSet(api1, elts) + func = getattr(set, op) + result = func(api2) + + if not is_api_empty(result): + cat_name = "%s_of_%s_and_%s" \ + % (op, os.path.basename(file1), os.path.basename(file2)) + + print '' + print '' % GLAPI + print + print '' + print + print '' % (cat_name) + output_category(result, 4) + print '' + print + print '' + +if __name__ == "__main__": + main() diff --git a/src/mesa/es/glapi/gl_parse_header.py b/src/mesa/es/glapi/gl_parse_header.py new file mode 100644 index 0000000000..8b8d16b395 --- /dev/null +++ b/src/mesa/es/glapi/gl_parse_header.py @@ -0,0 +1,450 @@ +#!/usr/bin/python +# +# Copyright (C) 2009 Chia-I Wu +# +# 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 +# on the rights to use, copy, modify, merge, publish, distribute, sub +# license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL +# IBM AND/OR ITS SUPPLIERS 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. + +import sys +import os.path +import getopt +import re + +GLAPI = "../../glapi" +sys.path.append(GLAPI) + +class HeaderParser(object): + """Parser for GL header files.""" + + def __init__(self, verbose=0): + # match #if and #ifdef + self.IFDEF = re.compile('#\s*if(n?def\s+(?P\w+)|\s+(?P.+))') + # match #endif + self.ENDIF = re.compile('#\s*endif') + # match typedef abc def; + self.TYPEDEF = re.compile('typedef\s+(?P[\w ]+)\s+(?P\w+);') + # match #define XYZ VAL + self.DEFINE = re.compile('#\s*define\s+(?P\w+)(?P\s+[\w"]*)?') + # match GLAPI + self.GLAPI = re.compile('^GL_?API(CALL)?\s+(?P[\w\s*]+[\w*])\s+(GL)?_?APIENTRY\s+(?P\w+)\s*\((?P[\w\s(,*\[\])]+)\)\s*;') + + self.split_params = re.compile('\s*,\s*') + self.split_ctype = re.compile('(\W)') + # ignore GL_VERSION_X_Y + self.ignore_enum = re.compile('GL(_ES)?_VERSION(_ES_C[ML])?_\d_\d') + + self.verbose = verbose + self._reset() + + def _reset(self): + """Reset to initial state.""" + self.ifdef_levels = [] + self.need_char = False + + # use typeexpr? + def _format_ctype(self, ctype, fix=True): + """Format a ctype string, optionally fix it.""" + # split the type string + tmp = self.split_ctype.split(ctype) + tmp = [s for s in tmp if s and s != " "] + + pretty = "" + for i in xrange(len(tmp)): + # add missing GL prefix + if (fix and tmp[i] != "const" and tmp[i] != "*" and + not tmp[i].startswith("GL")): + tmp[i] = "GL" + tmp[i] + + if i == 0: + pretty = tmp[i] + else: + sep = " " + if tmp[i - 1] == "*": + sep = "" + pretty += sep + tmp[i] + return pretty + + # use typeexpr? + def _get_ctype_attrs(self, ctype): + """Get the attributes of a ctype.""" + is_float = (ctype.find("float") != -1 or ctype.find("double") != -1) + is_signed = not (ctype.find("unsigned") != -1) + + size = 0 + if ctype.find("char") != -1: + size = 1 + elif ctype.find("short") != -1: + size = 2 + elif ctype.find("int") != -1: + size = 4 + elif is_float: + if ctype.find("float") != -1: + size = 4 + else: + size = 8 + + return (size, is_float, is_signed) + + def _parse_define(self, line): + """Parse a #define line for an .""" + m = self.DEFINE.search(line) + if not m: + if self.verbose and line.find("#define") >= 0: + print "ignore %s" % (line) + return None + + key = m.group("key").strip() + val = m.group("value").strip() + + # enum must begin with GL_ and be all uppercase + if ((not (key.startswith("GL_") and key.isupper())) or + (self.ignore_enum.match(key) and val == "1")): + if self.verbose: + print "ignore enum %s" % (key) + return None + + return (key, val) + + def _parse_typedef(self, line): + """Parse a typedef line for a .""" + m = self.TYPEDEF.search(line) + if not m: + if self.verbose and line.find("typedef") >= 0: + print "ignore %s" % (line) + return None + + f = m.group("from").strip() + t = m.group("to").strip() + if not t.startswith("GL"): + if self.verbose: + print "ignore type %s" % (t) + return None + attrs = self._get_ctype_attrs(f) + + return (f, t, attrs) + + def _parse_gl_api(self, line): + """Parse a GLAPI line for a .""" + m = self.GLAPI.search(line) + if not m: + if self.verbose and line.find("APIENTRY") >= 0: + print "ignore %s" % (line) + return None + + rettype = m.group("return") + rettype = self._format_ctype(rettype) + if rettype == "GLvoid": + rettype = "" + + name = m.group("name") + + param_str = m.group("params") + chunks = self.split_params.split(param_str) + chunks = [s.strip() for s in chunks] + if len(chunks) == 1 and (chunks[0] == "void" or chunks[0] == "GLvoid"): + chunks = [] + + params = [] + for c in chunks: + # split type and variable name + idx = c.rfind("*") + if idx < 0: + idx = c.rfind(" ") + if idx >= 0: + idx += 1 + ctype = c[:idx] + var = c[idx:] + else: + ctype = c + var = "unnamed" + + # convert array to pointer + idx = var.find("[") + if idx >= 0: + var = var[:idx] + ctype += "*" + + ctype = self._format_ctype(ctype) + var = var.strip() + + if not self.need_char and ctype.find("GLchar") >= 0: + self.need_char = True + + params.append((ctype, var)) + + return (rettype, name, params) + + def _change_level(self, line): + """Parse a #ifdef line and change level.""" + m = self.IFDEF.search(line) + if m: + ifdef = m.group("ifdef") + if not ifdef: + ifdef = m.group("if") + self.ifdef_levels.append(ifdef) + return True + m = self.ENDIF.search(line) + if m: + self.ifdef_levels.pop() + return True + return False + + def _read_header(self, header): + """Open a header file and read its contents.""" + lines = [] + try: + fp = open(header, "rb") + lines = fp.readlines() + fp.close() + except IOError, e: + print "failed to read %s: %s" % (header, e) + return lines + + def _cmp_enum(self, enum1, enum2): + """Compare two enums.""" + # sort by length of the values as strings + val1 = enum1[1] + val2 = enum2[1] + ret = len(val1) - len(val2) + # sort by the values + if not ret: + val1 = int(val1, 16) + val2 = int(val2, 16) + ret = val1 - val2 + # in case int cannot hold the result + if ret > 0: + ret = 1 + elif ret < 0: + ret = -1 + # sort by the names + if not ret: + if enum1[0] < enum2[0]: + ret = -1 + elif enum1[0] > enum2[0]: + ret = 1 + return ret + + def _cmp_type(self, type1, type2): + """Compare two types.""" + attrs1 = type1[2] + attrs2 = type2[2] + # sort by type size + ret = attrs1[0] - attrs2[0] + # float is larger + if not ret: + ret = attrs1[1] - attrs2[1] + # signed is larger + if not ret: + ret = attrs1[2] - attrs2[2] + # reverse + ret = -ret + return ret + + def _cmp_function(self, func1, func2): + """Compare two functions.""" + name1 = func1[1] + name2 = func2[1] + ret = 0 + # sort by the names + if name1 < name2: + ret = -1 + elif name1 > name2: + ret = 1 + return ret + + def _postprocess_dict(self, hdict): + """Post-process a header dict and return an ordered list.""" + hlist = [] + largest = 0 + for key, cat in hdict.iteritems(): + size = len(cat["enums"]) + len(cat["types"]) + len(cat["functions"]) + # ignore empty category + if not size: + continue + + cat["enums"].sort(self._cmp_enum) + # remove duplicates + dup = [] + for i in xrange(1, len(cat["enums"])): + if cat["enums"][i] == cat["enums"][i - 1]: + dup.insert(0, i) + for i in dup: + e = cat["enums"].pop(i) + if self.verbose: + print "remove duplicate enum %s" % e[0] + + cat["types"].sort(self._cmp_type) + cat["functions"].sort(self._cmp_function) + + # largest category comes first + if size > largest: + hlist.insert(0, (key, cat)) + largest = size + else: + hlist.append((key, cat)) + return hlist + + def parse(self, header): + """Parse a header file.""" + self._reset() + + if self.verbose: + print "Parsing %s" % (header) + + hdict = {} + lines = self._read_header(header) + for line in lines: + if self._change_level(line): + continue + + # skip until the first ifdef (i.e. __gl_h_) + if not self.ifdef_levels: + continue + + cat_name = os.path.basename(header) + # check if we are in an extension + if (len(self.ifdef_levels) > 1 and + self.ifdef_levels[-1].startswith("GL_")): + cat_name = self.ifdef_levels[-1] + + try: + cat = hdict[cat_name] + except KeyError: + cat = { + "enums": [], + "types": [], + "functions": [] + } + hdict[cat_name] = cat + + key = "enums" + elem = self._parse_define(line) + if not elem: + key = "types" + elem = self._parse_typedef(line) + if not elem: + key = "functions" + elem = self._parse_gl_api(line) + + if elem: + cat[key].append(elem) + + if self.need_char: + if self.verbose: + print "define GLchar" + elem = self._parse_typedef("typedef char GLchar;") + cat["types"].append(elem) + return self._postprocess_dict(hdict) + +def spaces(n, str=""): + spaces = n - len(str) + if spaces < 1: + spaces = 1 + return " " * spaces + +def output_xml(name, hlist): + """Output a parsed header in OpenGLAPI XML.""" + + for i in xrange(len(hlist)): + cat_name, cat = hlist[i] + + print '' % (cat_name) + indent = 4 + + for enum in cat["enums"]: + name = enum[0][3:] + value = enum[1] + tab = spaces(41, name) + attrs = 'name="%s"%svalue="%s"' % (name, tab, value) + print '%s' % (spaces(indent), attrs) + + if cat["enums"] and cat["types"]: + print + + for type in cat["types"]: + ctype = type[0] + size, is_float, is_signed = type[2] + + attrs = 'name="%s"' % (type[1][2:]) + attrs += spaces(16, attrs) + 'size="%d"' % (size) + if is_float: + attrs += ' float="true"' + elif not is_signed: + attrs += ' unsigned="true"' + + print '%s' % (spaces(indent), attrs) + + for func in cat["functions"]: + print + ret = func[0] + name = func[1][2:] + params = func[2] + + attrs = 'name="%s" offset="assign"' % name + print '%s' % (spaces(indent), attrs) + + for param in params: + attrs = 'name="%s" type="%s"' % (param[1], param[0]) + print '%s' % (spaces(indent * 2), attrs) + if ret: + attrs = 'type="%s"' % ret + print '%s' % (spaces(indent * 2), attrs) + + print '%s' % spaces(indent) + + print '' + print + +def show_usage(): + print "Usage: %s [-v]
..." % sys.argv[0] + sys.exit(1) + +def main(): + try: + args, headers = getopt.getopt(sys.argv[1:], "v") + except Exception, e: + show_usage() + if not headers: + show_usage() + + verbose = 0 + for arg in args: + if arg[0] == "-v": + verbose += 1 + + need_xml_header = True + parser = HeaderParser(verbose) + for h in headers: + h = os.path.abspath(h) + hlist = parser.parse(h) + + if need_xml_header: + print '' + print '' % GLAPI + need_xml_header = False + + print + print '' % (h) + print '' + print + output_xml(h, hlist) + print '' + +if __name__ == '__main__': + main() -- cgit v1.2.3 From bfa66bd6f941920cf32ce79fb103c3755b4dd8fb Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 21 Sep 2009 17:57:57 +0800 Subject: mesa/es: Add OpenGL ES overlay. This is primitive support for OpenGL ES. It uses a subset of mesa sources to build libesXgallium.a and libesXapi.a, where X is 1 for OpenGL ES 1.x, 2 for OpenGL ES 2.x. The static libraries serve the same purpose as libmesagallium.a and libglapi.a do for OpenGL. This is based on the work of opengl-es branch. Signed-off-by: Chia-I Wu --- Makefile | 20 +- src/mesa/es/Makefile | 125 ++ src/mesa/es/main/APIspec.txt | 2886 ++++++++++++++++++++++++++++++++++++ src/mesa/es/main/apiutil.py | 1117 ++++++++++++++ src/mesa/es/main/es1_special | 8 + src/mesa/es/main/es2_special | 5 + src/mesa/es/main/es_cpaltex.c | 240 +++ src/mesa/es/main/es_fbo.c | 37 + src/mesa/es/main/es_generator.py | 773 ++++++++++ src/mesa/es/main/es_query_matrix.c | 199 +++ src/mesa/es/main/get_gen.py | 785 ++++++++++ src/mesa/es/main/mfeatures_es1.h | 115 ++ src/mesa/es/main/mfeatures_es2.h | 115 ++ src/mesa/es/main/specials_es1.c | 186 +++ src/mesa/es/main/specials_es2.c | 176 +++ src/mesa/es/main/stubs.c | 138 ++ src/mesa/es/sources.mak | 164 ++ 17 files changed, 7087 insertions(+), 2 deletions(-) create mode 100644 src/mesa/es/Makefile create mode 100644 src/mesa/es/main/APIspec.txt create mode 100644 src/mesa/es/main/apiutil.py create mode 100644 src/mesa/es/main/es1_special create mode 100644 src/mesa/es/main/es2_special create mode 100644 src/mesa/es/main/es_cpaltex.c create mode 100644 src/mesa/es/main/es_fbo.c create mode 100644 src/mesa/es/main/es_generator.py create mode 100644 src/mesa/es/main/es_query_matrix.c create mode 100644 src/mesa/es/main/get_gen.py create mode 100644 src/mesa/es/main/mfeatures_es1.h create mode 100644 src/mesa/es/main/mfeatures_es2.h create mode 100644 src/mesa/es/main/specials_es1.c create mode 100644 src/mesa/es/main/specials_es2.c create mode 100644 src/mesa/es/main/stubs.c create mode 100644 src/mesa/es/sources.mak diff --git a/Makefile b/Makefile index 7f073fd516..4c4aba025e 100644 --- a/Makefile +++ b/Makefile @@ -303,10 +303,25 @@ MAIN_FILES = \ $(DIRECTORY)/progs/util/sampleMakefile \ $(DIRECTORY)/windows/VC8/ -EGL_FILES = \ - $(DIRECTORY)/include/EGL/*.h \ +ES_FILES = \ $(DIRECTORY)/include/GLES/*.h \ $(DIRECTORY)/include/GLES2/*.h \ + $(DIRECTORY)/src/mesa/glapi/*.xml \ + $(DIRECTORY)/src/mesa/glapi/*.py \ + $(DIRECTORY)/src/mesa/glapi/*.dtd \ + $(DIRECTORY)/src/mesa/es/glapi/Makefile \ + $(DIRECTORY)/src/mesa/es/glapi/*.xml \ + $(DIRECTORY)/src/mesa/es/glapi/*.py \ + $(DIRECTORY)/src/mesa/es/state_tracker/*.[ch] \ + $(DIRECTORY)/src/mesa/es/main/*.[ch] \ + $(DIRECTORY)/src/mesa/es/main/*.py \ + $(DIRECTORY)/src/mesa/es/main/*.txt \ + $(DIRECTORY)/src/mesa/es/main/es*_special \ + $(DIRECTORY)/src/mesa/es/Makefile \ + $(DIRECTORY)/src/mesa/es/sources.mak \ + +EGL_FILES = \ + $(DIRECTORY)/include/EGL/*.h \ $(DIRECTORY)/src/egl/Makefile \ $(DIRECTORY)/src/egl/*/Makefile \ $(DIRECTORY)/src/egl/*/*.[ch] \ @@ -477,6 +492,7 @@ DEPEND_FILES = \ LIB_FILES = \ $(MAIN_FILES) \ + $(ES_FILES) \ $(EGL_FILES) \ $(GALLIUM_FILES) \ $(DRI_FILES) \ diff --git a/src/mesa/es/Makefile b/src/mesa/es/Makefile new file mode 100644 index 0000000000..42347d0b07 --- /dev/null +++ b/src/mesa/es/Makefile @@ -0,0 +1,125 @@ +# src/mesa/es/Makefile +# +TOP := ../../.. +MESA := .. + +include $(TOP)/configs/current +include sources.mak + +ES1_LIBS := libes1gallium.a libes1api.a +ES2_LIBS := libes2gallium.a libes2api.a + +# Default rule: create ES1 and ES2 libs +.PHONY: default +default: subdirs depend es1 es2 + +es1: $(ES1_LIBS) + +es2: $(ES2_LIBS) + +# force the inclusion of es's mfeatures.h +ES1_CPPFLAGS := -include main/mfeatures_es1.h -D__GL_EXPORTS +ES2_CPPFLAGS := -include main/mfeatures_es2.h -D__GL_EXPORTS + +ES1_OBJ_DIR := objs-es1 +ES2_OBJ_DIR := objs-es2 + +# adjust output dirs +ES1_OBJECTS := $(addprefix $(ES1_OBJ_DIR)/, $(ES1_OBJECTS)) +ES1_GALLIUM_OBJECTS := $(addprefix $(ES1_OBJ_DIR)/, $(ES1_GALLIUM_OBJECTS)) +ES1_API_OBJECTS := $(addprefix $(ES1_OBJ_DIR)/, $(ES1_API_OBJECTS)) + +ES2_OBJECTS := $(addprefix $(ES2_OBJ_DIR)/, $(ES2_OBJECTS)) +ES2_GALLIUM_OBJECTS := $(addprefix $(ES2_OBJ_DIR)/, $(ES2_GALLIUM_OBJECTS)) +ES2_API_OBJECTS := $(addprefix $(ES2_OBJ_DIR)/, $(ES2_API_OBJECTS)) + +# compile either ES1 or ES2 sources +define es-compile + @mkdir -p $(dir $@) + $(CC) -c $(CFLAGS) $(ES$(1)_CPPFLAGS) $(ES$(1)_INCLUDES) -o $@ $< +endef + +$(ES1_OBJ_DIR)/%.o: %.c + $(call es-compile,1) + +$(ES1_OBJ_DIR)/%.o: %.S + $(call es-compile,1) + +$(ES1_OBJ_DIR)/%.o: $(MESA)/%.c + $(call es-compile,1) + +$(ES1_OBJ_DIR)/%.o: $(MESA)/%.S + $(call es-compile,1) + +$(ES2_OBJ_DIR)/%.o: %.c + $(call es-compile,2) + +$(ES2_OBJ_DIR)/%.o: %.S + $(call es-compile,2) + +$(ES2_OBJ_DIR)/%.o: $(MESA)/%.c + $(call es-compile,2) + +$(ES2_OBJ_DIR)/%.o: $(MESA)/%.S + $(call es-compile,2) + +libes1.a: $(ES1_OBJECTS) + @$(TOP)/bin/mklib -o es1 -static $(ES1_OBJECTS) + +libes2.a: $(ES2_OBJECTS) + @$(TOP)/bin/mklib -o es2 -static $(ES1_OBJECTS) + +libes1gallium.a: $(ES1_GALLIUM_OBJECTS) + @$(TOP)/bin/mklib -o es1gallium -static $(ES1_GALLIUM_OBJECTS) + +libes2gallium.a: $(ES2_GALLIUM_OBJECTS) + @$(TOP)/bin/mklib -o es2gallium -static $(ES2_GALLIUM_OBJECTS) + +libes1api.a: $(ES1_API_OBJECTS) + @$(TOP)/bin/mklib -o es1api -static $(ES1_API_OBJECTS) + +libes2api.a: $(ES2_API_OBJECTS) + @$(TOP)/bin/mklib -o es2api -static $(ES2_API_OBJECTS) + +GENERATED_SOURCES := \ + main/api_exec_es1.c \ + main/api_exec_es2.c \ + main/get_es1.c \ + main/get_es2.c + +main/api_exec_es1.c: main/APIspec.txt main/es_generator.py main/apiutil.py main/es1_special + $(PYTHON2) $(PYTHON_FLAGS) main/es_generator.py -S main/APIspec.txt -V GLES1.1 > $@ + +main/api_exec_es2.c: main/APIspec.txt main/es_generator.py main/apiutil.py main/es2_special + $(PYTHON2) $(PYTHON_FLAGS) main/es_generator.py -S main/APIspec.txt -V GLES2.0 > $@ + +main/get_es1.c: main/get_gen.py + $(PYTHON2) $(PYTHON_FLAGS) $< 1 > $@ + +main/get_es2.c: main/get_gen.py + $(PYTHON2) $(PYTHON_FLAGS) $< 2 > $@ + +.PHONY: clean +clean: + -rm -f $(ES1_LIBS) $(ES2_LIBS) + -rm -rf $(ES1_OBJ_DIR) $(ES2_OBJ_DIR) + -rm -f $(GENERATED_SOURCES) + -rm -f depend + -rm -f *~ + +subdirs: + make -C glapi + make -C $(MESA) asm_subdirs + +depend: $(ES1_ALL_SOURCES) $(ES2_ALL_SOURCES) + @echo "running $(MKDEP)" + @touch depend + @# MESA is "..", but luckily, directories are longer than 2 characters + @$(MKDEP) -f- -p$(ES1_OBJ_DIR)/ $(DEFINES) $(ES1_CFLAGS) \ + $(ES1_INCLUDES) $(ES1_ALL_SOURCES) 2>/dev/null | \ + sed -e 's,^$(ES1_OBJ_DIR)/$(MESA)/,$(ES1_OBJ_DIR)/,' > depend + @$(MKDEP) -f- -p$(ES2_OBJ_DIR)/ $(DEFINES) $(ES2_CFLAGS) \ + $(ES2_INCLUDES) $(ES2_ALL_SOURCES) 2>/dev/null | \ + sed -e 's,^$(ES2_OBJ_DIR)/$(MESA)/,$(ES2_OBJ_DIR)/,' >> depend + +-include depend diff --git a/src/mesa/es/main/APIspec.txt b/src/mesa/es/main/APIspec.txt new file mode 100644 index 0000000000..86dd546f63 --- /dev/null +++ b/src/mesa/es/main/APIspec.txt @@ -0,0 +1,2886 @@ +## Adapted from Mesa and Chromium. +# Python scripts read this file and generate various C files. + +# Possible lines: +# name Name of the function (without "gl" prefix). Required. +# +# return Datatype of returned value, or void. Required. +# +# param Zero or more of these lines may be present. Each describes a +# function parameter. Two fields follow: parameter name and the +# parameter type (which may be several tokens like "const GLvoid *"). +# +# vector Used to indicate the size of constant arrays referenced by +# the given parameter. (If the number of elements in the +# array is dependent on another parameter, use "dependentvector" +# (below) instead.) +# Two fields follow: the parameter name (previously defined by a +# 'param' line) and a number indicating how may elements are +# referenced by the vector. If the number is unknown, don't use +# a vector line. Example for glGetClipPlane: +# vector equation 4 +# +# dependentvector Used to indicate how many elements are referenced by +# pointer params, if the number depends on the value of another +# parameter. It is followed by the parameter name of the vector +# parameter (previously defined by a 'param' line, one of the +# potential sizes of the array, the name of the controlling +# parameter, and a list (one or more) of parameter values of the +# controlling parameter that are associated with the given size. +# There will always be more than one line of this type (or otherwise +# you could have used the "vector" specifier above). +# As a convenience, each parameter value named in a +# "dependentvector" specifier will also be considered as a +# "paramprop" specifier. +# Example for glLightfv: +# dependentvector params 4 pname GL_AMBIENT GL_DIFFUSE GL_SPECULAR GL_POSITION +# dependentvector params 3 pname GL_SPOT_DIRECTION +# dependentvector params 1 pname GL_SPOT_EXPONENT GL_SPOT_CUTOFF GL_CONSTANT_ATTENUATION GL_LINEAR_ATTENUATION GL_QUADRATIC_ATTENUATION +# +# category May be 1.x to indicate that the function belongs to OpenGL +# version 1.x. Or may be the name of an extension such as +# GL_ARB_multitexture. Or may be GLES1.x to indicate +# that the function belongs to GLES version 1.x. Required. +# May have more than one token to indicate that a function +# belongs to more than one category. +# +# alias Names the Mesa function _mesa_ that will be called. +# Mostly used when the function was originally defined and +# introduced into Mesa as an extension function (i.e. ARB); +# even though the function loses the extension as it is adopted +# into the core, the Mesa support remains named the same +# (for compatibility). +# +# aliasprefix May be used to change the default Mesa support functional +# prefix on a per-function basis. By default, it's "_mesa_"; +# but this allows it to be changed (e.g. to "_vbo_" for many +# of the core functions). +# +# props An optional list of properties for this function. Possible +# properties include: +# get - the function is a state-getter +# +# convertalias +# +# convertparams +# +# checkparam +# +# checkdependentparam + +name Color4f +aliasprefix _vbo_ +return void +param red GLfloat +param green GLfloat +param blue GLfloat +param alpha GLfloat +category 1.0 GLES1.1 + +name Color4ub +return void +param red GLubyte +param green GLubyte +param blue GLubyte +param alpha GLubyte +aliasprefix _vbo_ +convertalias Color4f +convertparams GLfloat red green blue alpha +category 1.0 GLES1.1 + +name Color4x +return void +param red GLfixed +param green GLfixed +param blue GLfixed +param alpha GLfixed +aliasprefix _vbo_ +convertalias Color4f +convertparams GLfloat red green blue alpha +category GLES1.1 GLES1.1:OES_fixed_point + +name ClipPlane +return void +param plane GLenum +checkparam plane GL_CLIP_PLANE0 GL_CLIP_PLANE1 GL_CLIP_PLANE2 GL_CLIP_PLANE3 GL_CLIP_PLANE4 GL_CLIP_PLANE5 +param equation const GLdouble * +vector equation 4 +category 1.0 + +name ClipPlanef +return void +param plane GLenum +checkparam plane GL_CLIP_PLANE0 GL_CLIP_PLANE1 GL_CLIP_PLANE2 GL_CLIP_PLANE3 GL_CLIP_PLANE4 GL_CLIP_PLANE5 +param equation const GLfloat * +vector equation 4 +convertalias ClipPlane +convertparams GLdouble equation +category GLES1.1 GLES1.1:OES_single_precision + +name ClipPlanex +return void +param plane GLenum +checkparam plane GL_CLIP_PLANE0 GL_CLIP_PLANE1 GL_CLIP_PLANE2 GL_CLIP_PLANE3 GL_CLIP_PLANE4 GL_CLIP_PLANE5 +param equation const GLfixed * +vector equation 4 +convertalias ClipPlane +convertparams GLdouble equation +category GLES1.1 GLES1.1:OES_fixed_point + +name CullFace +return void +param mode GLenum +checkparam mode GL_FRONT GL_BACK GL_FRONT_AND_BACK +category 1.0 GLES1.1 GLES2.0 + +name Fogf +return void +param pname GLenum +checkparam pname GL_FOG_MODE GL_FOG_DENSITY GL_FOG_START GL_FOG_END +param param GLfloat +checkdependentparam pname GL_FOG_MODE param GL_EXP GL_EXP2 GL_LINEAR +category 1.0 GLES1.1 + +name Fogfv +return void +param pname GLenum +param params const GLfloat * +paramvec params GL_LINEAR +dependentvector params 4 pname GL_FOG_COLOR +dependentvector params 1 pname GL_FOG_DENSITY GL_FOG_START GL_FOG_END +dependentvector params 1 pname GL_FOG_MODE +checkdependentparam pname GL_FOG_MODE params GL_EXP GL_EXP2 GL_LINEAR +category 1.0 GLES1.1 + +name Fogx +return void +param pname GLenum +checkparam pname GL_FOG_MODE GL_FOG_DENSITY GL_FOG_START GL_FOG_END +param param GLfixed +checkdependentparam pname GL_FOG_MODE param GL_EXP GL_EXP2 GL_LINEAR +convertalias Fogf +convertparams GLfloat param +category GLES1.1 GLES1.1:OES_fixed_point + +name Fogxv +return void +param pname GLenum +param params const GLfixed * +dependentvector params 4 pname GL_FOG_COLOR +dependentvector params 1 pname GL_FOG_DENSITY GL_FOG_START GL_FOG_END +dependentvector params 1 pname GL_FOG_MODE +checkdependentparam pname GL_FOG_MODE params GL_EXP GL_EXP2 GL_LINEAR +convertalias Fogfv +convertparams GLfloat params +category GLES1.1 GLES1.1:OES_fixed_point + +name FrontFace +return void +param mode GLenum +checkparam mode GL_CW GL_CCW +category 1.0 GLES1.1 GLES2.0 + +name Hint +return void +param target GLenum +param mode GLenum +checkparam target GLES1.1:GL_FOG_HINT GLES1.1:GL_LINE_SMOOTH_HINT GLES1.1:GL_PERSPECTIVE_CORRECTION_HINT GLES1.1:GL_POINT_SMOOTH_HINT +checkparam target GL_GENERATE_MIPMAP_HINT +checkparam mode GL_FASTEST GL_NICEST GL_DONT_CARE +# OES_standard_derivatives +checkparam target GLES2.0:GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES +category GLES1.1 GLES2.0 + +name Lightf +return void +param light GLenum +checkparam light GL_LIGHT0 GL_LIGHT1 GL_LIGHT2 GL_LIGHT3 GL_LIGHT4 GL_LIGHT5 GL_LIGHT6 GL_LIGHT7 +param pname GLenum +checkparam pname GL_SPOT_EXPONENT GL_SPOT_CUTOFF GL_CONSTANT_ATTENUATION GL_LINEAR_ATTENUATION GL_QUADRATIC_ATTENUATION +param param GLfloat +category 1.0 GLES1.1 + +name Lightfv +return void +param light GLenum +checkparam light GL_LIGHT0 GL_LIGHT1 GL_LIGHT2 GL_LIGHT3 GL_LIGHT4 GL_LIGHT5 GL_LIGHT6 GL_LIGHT7 +param pname GLenum +param params const GLfloat * +paramvec params 0.0 1.0 1.0 0.0 +dependentvector params 4 pname GL_AMBIENT GL_DIFFUSE GL_SPECULAR GL_POSITION +dependentvector params 3 pname GL_SPOT_DIRECTION +dependentvector params 1 pname GL_SPOT_EXPONENT GL_SPOT_CUTOFF GL_CONSTANT_ATTENUATION GL_LINEAR_ATTENUATION GL_QUADRATIC_ATTENUATION +category 1.0 1.1 GLES1.1 + +name Lightx +return void +param light GLenum +checkparam light GL_LIGHT0 GL_LIGHT1 GL_LIGHT2 GL_LIGHT3 GL_LIGHT4 GL_LIGHT5 GL_LIGHT6 GL_LIGHT7 +param pname GLenum +checkparam pname GL_SPOT_EXPONENT GL_SPOT_CUTOFF GL_CONSTANT_ATTENUATION GL_LINEAR_ATTENUATION GL_QUADRATIC_ATTENUATION +param param GLfixed +convertalias Lightf +convertparams GLfloat param +category GLES1.1 GLES1.1:OES_fixed_point + +name Lightxv +return void +param light GLenum +checkparam light GL_LIGHT0 GL_LIGHT1 GL_LIGHT2 GL_LIGHT3 GL_LIGHT4 GL_LIGHT5 GL_LIGHT6 GL_LIGHT7 +param pname GLenum +param params const GLfixed * +dependentvector params 4 pname GL_AMBIENT GL_DIFFUSE GL_SPECULAR GL_POSITION +dependentvector params 3 pname GL_SPOT_DIRECTION +dependentvector params 1 pname GL_SPOT_EXPONENT GL_SPOT_CUTOFF GL_CONSTANT_ATTENUATION GL_LINEAR_ATTENUATION GL_QUADRATIC_ATTENUATION +convertalias Lightfv +convertparams GLfloat params +category GLES1.1 GLES1.1:OES_fixed_point + +name LightModelf +return void +param pname GLenum +checkparam pname GL_LIGHT_MODEL_TWO_SIDE +param param GLfloat +checkdependentparam pname GL_LIGHT_MODEL_TWO_SIDE param GL_TRUE GL_FALSE +category 1.0 GLES1.1 + +name LightModelfv +return void +param pname GLenum +param params const GLfloat * +dependentvector params 4 pname GL_LIGHT_MODEL_AMBIENT +dependentvector params 1 pname GL_LIGHT_MODEL_TWO_SIDE +category 1.0 GLES1.1 + +name LightModelx +return void +param pname GLenum +checkparam pname GL_LIGHT_MODEL_TWO_SIDE +param param GLfixed +checkdependentparam pname GL_LIGHT_MODEL_TWO_SIDE param GL_TRUE GL_FALSE +convertalias LightModelf +convertparams GLfloat param +category GLES1.1 GLES1.1:OES_fixed_point + +name LightModelxv +return void +param pname GLenum +param params const GLfixed * +dependentvector params 4 pname GL_LIGHT_MODEL_AMBIENT +dependentvector params 1 pname GL_LIGHT_MODEL_TWO_SIDE +checkdependentparam pname GL_LIGHT_MODEL_TWO_SIDE params GL_TRUE GL_FALSE +convertalias LightModelfv +convertparams GLfloat params +category GLES1.1 GLES1.1:OES_fixed_point + +name LineWidth +return void +param width GLfloat +category 1.0 GLES1.1 GLES2.0 + +name LineWidthx +return void +param width GLfixed +convertalias LineWidth +convertparams GLfloat width +category GLES1.1 GLES1.1:OES_fixed_point + +name Materialf +aliasprefix _vbo_ +return void +param face GLenum +checkparam face GL_FRONT_AND_BACK +param pname GLenum +checkparam pname GL_SHININESS +param param GLfloat +category 1.0 GLES1.1 + +name Materialfv +aliasprefix _vbo_ +return void +param face GLenum +checkparam face GL_FRONT_AND_BACK +param pname GLenum +param params const GLfloat * +paramvec params 0.8 0.8 0.5 0.1 +dependentvector params 4 pname GL_AMBIENT GL_DIFFUSE GL_AMBIENT_AND_DIFFUSE GL_SPECULAR GL_EMISSION +dependentvector params 1 pname GL_SHININESS +category 1.0 GLES1.1 + +name Materialx +return void +param face GLenum +checkparam face GL_FRONT_AND_BACK +param pname GLenum +checkparam pname GL_SHININESS +param param GLfixed +aliasprefix _vbo_ +convertalias Materialf +convertparams GLfloat param +category GLES1.1 GLES1.1:OES_fixed_point + +name Materialxv +return void +param face GLenum +checkparam face GL_FRONT_AND_BACK +param pname GLenum +param params const GLfixed * +dependentvector params 4 pname GL_AMBIENT GL_DIFFUSE GL_AMBIENT_AND_DIFFUSE GL_SPECULAR GL_EMISSION +dependentvector params 1 pname GL_SHININESS +aliasprefix _vbo_ +convertalias Materialfv +convertparams GLfloat params +category GLES1.1 GLES1.1:OES_fixed_point + +name PointSize +return void +param size GLfloat +category 1.0 GLES1.1 + +name PointSizex +return void +param size GLfixed +convertalias PointSize +convertparams GLfloat size +category GLES1.1 GLES1.1:OES_fixed_point + +name PointSizePointer +return void +param type GLenum +checkparam type GL_FIXED GL_FLOAT +param stride GLsizei +param pointer const GLvoid * +props setclient +# OES_vertex_half_float - not in glext.h +#checkparam type GL_HALF_FLOAT_OES +category GLES1.1:OES_point_size_array + +name Scissor +return void +param x GLint +param y GLint +param width GLsizei +param height GLsizei +category 1.0 GLES1.1 GLES2.0 + +name ShadeModel +return void +param mode GLenum +checkparam mode GL_FLAT GL_SMOOTH +category 1.0 GLES1.1 + +name TexParameterf +return void +param target GLenum +checkparam target GL_TEXTURE_2D GLES2.0:GL_TEXTURE_CUBE_MAP +param pname GLenum +param param GLfloat +checkdependentparam pname GL_TEXTURE_WRAP_S param GL_CLAMP_TO_EDGE GL_REPEAT GLES2.0:GL_MIRRORED_REPEAT +checkdependentparam pname GL_TEXTURE_WRAP_T param GL_CLAMP_TO_EDGE GL_REPEAT GLES2.0:GL_MIRRORED_REPEAT +checkdependentparam pname GL_TEXTURE_MIN_FILTER param GL_NEAREST GL_LINEAR GL_NEAREST_MIPMAP_NEAREST GL_NEAREST_MIPMAP_LINEAR GL_LINEAR_MIPMAP_NEAREST GL_LINEAR_MIPMAP_LINEAR +checkdependentparam pname GL_TEXTURE_MAG_FILTER param GL_NEAREST GL_LINEAR +checkdependentparam pname GL_GENERATE_MIPMAP param GLES1.1:GL_TRUE GLES1.1:GL_FALSE +# OES_texture_cube_map +checkparam target GLES1.1:GL_TEXTURE_CUBE_MAP_OES +# OES_texture_mirrored_repeat +checkdependentparam pname GL_TEXTURE_WRAP_S param GLES1.1:GL_MIRRORED_REPEAT_OES +checkdependentparam pname GL_TEXTURE_WRAP_T param GLES1.1:GL_MIRRORED_REPEAT_OES +# EXT_texture_filter_anisotropic +checkparam pname GL_TEXTURE_MAX_ANISOTROPY_EXT +# OES_texture_3D +checkdependentparam pname GL_TEXTURE_WRAP_R_OES param GLES2.0:GL_CLAMP_TO_EDGE GLES2.0:GL_REPEAT GLES2.0:GL_MIRRORED_REPEAT +category GLES1.1 GLES2.0 + +name TexParameterfv +return void +param target GLenum +checkparam target GL_TEXTURE_2D GLES2.0:GL_TEXTURE_CUBE_MAP +param pname GLenum +param params const GLfloat * +dependentvector params 1 pname GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_TEXTURE_MIN_FILTER GL_TEXTURE_MAG_FILTER GLES1.1:GL_GENERATE_MIPMAP +checkdependentparam pname GL_TEXTURE_WRAP_S params GL_CLAMP_TO_EDGE GL_REPEAT GLES2.0:GL_MIRRORED_REPEAT +checkdependentparam pname GL_TEXTURE_WRAP_T params GL_CLAMP_TO_EDGE GL_REPEAT GLES2.0:GL_MIRRORED_REPEAT +checkdependentparam pname GL_TEXTURE_MIN_FILTER params GL_NEAREST GL_LINEAR GL_NEAREST_MIPMAP_NEAREST GL_NEAREST_MIPMAP_LINEAR GL_LINEAR_MIPMAP_NEAREST GL_LINEAR_MIPMAP_LINEAR +checkdependentparam pname GL_TEXTURE_MAG_FILTER params GL_NEAREST GL_LINEAR +checkdependentparam pname GL_GENERATE_MIPMAP params GLES1.1:GL_TRUE GLES1.1:GL_FALSE +# OES_texture_cube_map +checkparam target GLES1.1:GL_TEXTURE_CUBE_MAP_OES +# OES_texture_mirrored_repeat +checkdependentparam pname GL_TEXTURE_WRAP_S params GLES1.1:GL_MIRRORED_REPEAT_OES +checkdependentparam pname GL_TEXTURE_WRAP_T params GLES1.1:GL_MIRRORED_REPEAT_OES +# EXT_texture_filter_anisotropic +dependentvector params 1 pname GL_TEXTURE_MAX_ANISOTROPY_EXT +# OES_texture_3D +checkdependentparam pname GL_TEXTURE_WRAP_R_OES params GLES2.0:GL_CLAMP_TO_EDGE GLES2.0:GL_REPEAT GLES2.0:GL_MIRRORED_REPEAT +category GLES1.1 GLES2.0 + +name TexParameteri +return void +param target GLenum +checkparam target GL_TEXTURE_2D GLES2.0:GL_TEXTURE_CUBE_MAP +param pname GLenum +param param GLint +checkdependentparam pname GL_TEXTURE_WRAP_S param GL_CLAMP_TO_EDGE GL_REPEAT GLES2.0:GL_MIRRORED_REPEAT +checkdependentparam pname GL_TEXTURE_WRAP_T param GL_CLAMP_TO_EDGE GL_REPEAT GLES2.0:GL_MIRRORED_REPEAT +checkdependentparam pname GL_TEXTURE_MIN_FILTER param GL_NEAREST GL_LINEAR GL_NEAREST_MIPMAP_NEAREST GL_NEAREST_MIPMAP_LINEAR GL_LINEAR_MIPMAP_NEAREST GL_LINEAR_MIPMAP_LINEAR +checkdependentparam pname GL_TEXTURE_MAG_FILTER param GL_NEAREST GL_LINEAR +checkdependentparam pname GL_GENERATE_MIPMAP param GLES1.1:GL_TRUE GLES1.1:GL_FALSE +# OES_texture_cube_map +checkparam target GLES1.1:GL_TEXTURE_CUBE_MAP_OES +# OES_texture_mirrored_repeat +checkdependentparam pname GL_TEXTURE_WRAP_S param GLES1.1:GL_MIRRORED_REPEAT_OES +checkdependentparam pname GL_TEXTURE_WRAP_T param GLES1.1:GL_MIRRORED_REPEAT_OES +# EXT_texture_filter_anisotropic +checkparam pname GL_TEXTURE_MAX_ANISOTROPY_EXT +# OES_texture_3D +checkdependentparam pname GL_TEXTURE_WRAP_R_OES param GLES2.0:GL_CLAMP_TO_EDGE GLES2.0:GL_REPEAT GLES2.0:GL_MIRRORED_REPEAT +category GLES1.1 GLES2.0 + +name TexParameteriv +return void +param target GLenum +checkparam target GL_TEXTURE_2D GLES2.0:GL_TEXTURE_CUBE_MAP +param pname GLenum +param params const GLint * +dependentvector params 1 pname GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_TEXTURE_MIN_FILTER GL_TEXTURE_MAG_FILTER GLES1.1:GL_GENERATE_MIPMAP +checkdependentparam pname GL_TEXTURE_WRAP_S params GL_CLAMP_TO_EDGE GL_REPEAT GLES2.0:GL_MIRRORED_REPEAT +checkdependentparam pname GL_TEXTURE_WRAP_T params GL_CLAMP_TO_EDGE GL_REPEAT GLES2.0:GL_MIRRORED_REPEAT +checkdependentparam pname GL_TEXTURE_MIN_FILTER params GL_NEAREST GL_LINEAR GL_NEAREST_MIPMAP_NEAREST GL_NEAREST_MIPMAP_LINEAR GL_LINEAR_MIPMAP_NEAREST GL_LINEAR_MIPMAP_LINEAR +checkdependentparam pname GL_TEXTURE_MAG_FILTER params GL_NEAREST GL_LINEAR +checkdependentparam pname GL_GENERATE_MIPMAP params GLES1.1:GL_TRUE GLES1.1:GL_FALSE +# OES_texture_cube_map +checkparam target GLES1.1:GL_TEXTURE_CUBE_MAP_OES +# OES_texture_mirrored_repeat +checkdependentparam pname GL_TEXTURE_WRAP_S params GLES1.1:GL_MIRRORED_REPEAT_OES +checkdependentparam pname GL_TEXTURE_WRAP_T params GLES1.1:GL_MIRRORED_REPEAT_OES +# EXT_texture_filter_anisotropic +dependentvector params 1 pname GL_TEXTURE_MAX_ANISOTROPY_EXT +# OES_texture_3D +checkdependentparam pname GL_TEXTURE_WRAP_R_OES params GLES2.0:GL_CLAMP_TO_EDGE GLES2.0:GL_REPEAT GLES2.0:GL_MIRRORED_REPEAT +category GLES1.1 GLES2.0 + +name TexParameterx +return void +param target GLenum +checkparam target GL_TEXTURE_2D +param pname GLenum +param param GLfixed +checkdependentparam pname GL_TEXTURE_WRAP_S param GL_CLAMP_TO_EDGE GL_REPEAT +checkdependentparam pname GL_TEXTURE_WRAP_T param GL_CLAMP_TO_EDGE GL_REPEAT +checkdependentparam pname GL_TEXTURE_MIN_FILTER param GL_NEAREST GL_LINEAR GL_NEAREST_MIPMAP_NEAREST GL_NEAREST_MIPMAP_LINEAR GL_LINEAR_MIPMAP_NEAREST GL_LINEAR_MIPMAP_LINEAR +checkdependentparam pname GL_TEXTURE_MAG_FILTER param GL_NEAREST GL_LINEAR +checkdependentparam pname GL_GENERATE_MIPMAP param GL_TRUE GL_FALSE +convertalias TexParameterf +convertparams GLfloat param +# OES_texture_cube_map +checkparam target GL_TEXTURE_CUBE_MAP_OES +# OES_texture_mirrored_repeat +checkdependentparam pname GL_TEXTURE_WRAP_S param GL_MIRRORED_REPEAT_OES +checkdependentparam pname GL_TEXTURE_WRAP_T param GL_MIRRORED_REPEAT_OES +# EXT_texture_filter_anisotropic +checkparam pname GL_TEXTURE_MAX_ANISOTROPY_EXT +category GLES1.1 GLES1.1:OES_fixed_point + + +# Same is true for this function. +name TexParameterxv +return void +param target GLenum +checkparam target GL_TEXTURE_2D GL_TEXTURE_CUBE_MAP_OES +param pname GLenum +param params const GLfixed * +vector params 1 +dependentvector params 1 pname GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_TEXTURE_MIN_FILTER GL_TEXTURE_MAG_FILTER GL_GENERATE_MIPMAP +checkdependentparam pname GL_TEXTURE_WRAP_S params GL_CLAMP_TO_EDGE GL_REPEAT +checkdependentparam pname GL_TEXTURE_WRAP_T params GL_CLAMP_TO_EDGE GL_REPEAT +checkdependentparam pname GL_TEXTURE_MIN_FILTER params GL_NEAREST GL_LINEAR GL_NEAREST_MIPMAP_NEAREST GL_NEAREST_MIPMAP_LINEAR GL_LINEAR_MIPMAP_NEAREST GL_LINEAR_MIPMAP_LINEAR +checkdependentparam pname GL_TEXTURE_MAG_FILTER params GL_NEAREST GL_LINEAR +checkdependentparam pname GL_GENERATE_MIPMAP params GL_TRUE GL_FALSE +convertalias TexParameterfv +convertparams GLfloat params +# OES_texture_cube_map +checkparam target GL_TEXTURE_CUBE_MAP_OES +# OES_texture_mirrored_repeat +checkdependentparam pname GL_TEXTURE_WRAP_S params GL_MIRRORED_REPEAT_OES +checkdependentparam pname GL_TEXTURE_WRAP_T params GL_MIRRORED_REPEAT_OES +# EXT_texture_filter_anisotropic +dependentvector params 1 pname GL_TEXTURE_MAX_ANISOTROPY_EXT +category GLES1.1 GLES1.1:OES_fixed_point + +# TexImage2D has *different* versions for GLES1 and GLES2, strangely, +# with different types for "internalFormat". There's also a few +# tokens with different spellings. +name TexImage2D +return void +param target GLenum +checkparam target GL_TEXTURE_2D +param level GLint +param internalFormat GLint +param width GLsizei +param height GLsizei +param border GLint +param format GLenum +param type GLenum +param pixels const GLvoid * +checkparam internalFormat /GL_INVALID_VALUE GL_ALPHA GL_LUMINANCE GL_LUMINANCE_ALPHA GL_RGB GL_RGBA +checkparam border /GL_INVALID_VALUE 0 +# OES_texture_cube_map +checkparam target GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES +## OES_packed_depth_stencil - only appears in GLES2 header files? +#checkdependentparam format GL_DEPTH_STENCIL_OES internalFormat GL_UNSIGNED_INT_24_8_OES +category 1.0 GLES1.1 + +name TexImage2D +return void +param target GLenum +param level GLint +# it is compiled with OpenGL header +#param internalFormat GLenum +param internalFormat GLint +param width GLsizei +param height GLsizei +param border GLint +param format GLenum +param type GLenum +param pixels const GLvoid * +checkparam target GL_TEXTURE_2D GL_TEXTURE_CUBE_MAP_POSITIVE_X GL_TEXTURE_CUBE_MAP_POSITIVE_Y GL_TEXTURE_CUBE_MAP_POSITIVE_Z GL_TEXTURE_CUBE_MAP_NEGATIVE_X GL_TEXTURE_CUBE_MAP_NEGATIVE_Y GL_TEXTURE_CUBE_MAP_NEGATIVE_Z +checkparam internalFormat /GL_INVALID_VALUE GL_ALPHA GL_LUMINANCE GL_LUMINANCE_ALPHA GL_RGB GL_RGBA +checkparam border /GL_INVALID_VALUE 0 +checkdependentparam format GL_ALPHA type GL_UNSIGNED_BYTE +checkdependentparam format GL_RGB type GL_UNSIGNED_BYTE GL_UNSIGNED_SHORT_5_6_5 +checkdependentparam format GL_RGBA type GL_UNSIGNED_BYTE GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_5_5_5_1 +checkdependentparam format GL_LUMINANCE type GL_UNSIGNED_BYTE +checkdependentparam format GL_LUMINANCE_ALPHA type GL_UNSIGNED_BYTE +# OES_texture_float +checkdependentparam format GL_ALPHA type GL_FLOAT +checkdependentparam format GL_RGB type GL_FLOAT +checkdependentparam format GL_RGBA type GL_FLOAT +checkdependentparam format GL_LUMINANCE type GL_FLOAT +checkdependentparam format GL_LUMINANCE_ALPHA type GL_FLOAT +# OES_texture_half_float +checkdependentparam format GL_ALPHA type GL_HALF_FLOAT_OES +checkdependentparam format GL_RGB type GL_HALF_FLOAT_OES +checkdependentparam format GL_RGBA type GL_HALF_FLOAT_OES +checkdependentparam format GL_LUMINANCE type GL_HALF_FLOAT_OES +checkdependentparam format GL_LUMINANCE_ALPHA type GL_HALF_FLOAT_OES +# EXT_texture_type_2_10_10_10_REV +checkdependentparam format GL_RGBA type GL_UNSIGNED_INT_2_10_10_10_REV_EXT +# OES_depth_texture +checkdependentparam format GL_DEPTH_COMPONENT type GL_UNSIGNED_SHORT GL_UNSIGNED_INT +checkparam internalFormat GL_DEPTH_COMPONENT +category GLES2.0 + +name TexEnvf +return void +param target GLenum +param pname GLenum +param param GLfloat +checkdependentparam target GL_TEXTURE_ENV pname GL_TEXTURE_ENV_MODE GL_COMBINE_RGB GL_COMBINE_ALPHA GL_RGB_SCALE GL_ALPHA_SCALE GL_SRC0_RGB GL_OPERAND0_RGB GL_SRC0_ALPHA GL_OPERAND0_ALPHA GL_SRC1_RGB GL_OPERAND1_RGB GL_SRC1_ALPHA GL_OPERAND1_ALPHA GL_SRC2_RGB GL_OPERAND2_RGB GL_SRC2_ALPHA GL_OPERAND2_ALPHA +checkdependentparam pname GL_TEXTURE_ENV_MODE param GL_REPLACE GL_MODULATE GL_DECAL GL_BLEND GL_ADD GL_COMBINE +checkdependentparam pname GL_COMBINE_RGB param GL_REPLACE GL_MODULATE GL_ADD GL_ADD_SIGNED GL_INTERPOLATE GL_SUBTRACT GL_DOT3_RGB GL_DOT3_RGBA +checkdependentparam pname GL_COMBINE_ALPHA param GL_REPLACE GL_MODULATE GL_ADD GL_ADD_SIGNED GL_INTERPOLATE GL_SUBTRACT +checkdependentparam pname GL_RGB_SCALE param /GL_INVALID_VALUE 1.0 2.0 4.0 +checkdependentparam pname GL_ALPHA_SCALE param /GL_INVALID_VALUE 1.0 2.0 4.0 +checkdependentparam pname GL_SRC0_RGB param GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND0_RGB param GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC0_ALPHA param GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND0_ALPHA param GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC1_RGB param GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND1_RGB param GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC1_ALPHA param GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND1_ALPHA param GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC2_RGB param GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND2_RGB param GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC2_ALPHA param GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND2_ALPHA param GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +# OES_texture_env_crossbar +checkdependentparam pname GL_SRC0_RGB param GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC1_RGB param GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC2_RGB param GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC0_ALPHA param GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC1_ALPHA param GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC2_ALPHA param GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +# OES_point_sprite +checkdependentparam target GL_POINT_SPRITE_OES pname GL_COORD_REPLACE_OES +checkdependentparam pname GL_COORD_REPLACE_OES param GL_TRUE GL_FALSE +category 1.0 GLES1.1 + +name TexEnvfv +return void +param target GLenum +param pname GLenum +param params const GLfloat * +checkdependentparam target GL_POINT_SPRITE_OES pname GL_COORD_REPLACE_OES +checkdependentparam pname GL_COORD_REPLACE_OES params GL_TRUE GL_FALSE +checkdependentparam target GL_TEXTURE_ENV pname GL_TEXTURE_ENV_MODE GL_TEXTURE_ENV_COLOR GL_COMBINE_RGB GL_COMBINE_ALPHA GL_RGB_SCALE GL_ALPHA_SCALE GL_SRC0_RGB GL_OPERAND0_RGB GL_SRC0_ALPHA GL_OPERAND0_ALPHA GL_SRC1_RGB GL_OPERAND1_RGB GL_SRC1_ALPHA GL_OPERAND1_ALPHA GL_SRC2_RGB GL_OPERAND2_RGB GL_SRC2_ALPHA GL_OPERAND2_ALPHA +checkdependentparam pname GL_TEXTURE_ENV_MODE params GL_REPLACE GL_MODULATE GL_DECAL GL_BLEND GL_ADD GL_COMBINE +checkdependentparam pname GL_COMBINE_RGB params GL_REPLACE GL_MODULATE GL_ADD GL_ADD_SIGNED GL_INTERPOLATE GL_SUBTRACT GL_DOT3_RGB GL_DOT3_RGBA +checkdependentparam pname GL_COMBINE_ALPHA params GL_REPLACE GL_MODULATE GL_ADD GL_ADD_SIGNED GL_INTERPOLATE GL_SUBTRACT +checkdependentparam pname GL_SRC0_RGB params GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND0_RGB params GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC0_ALPHA params GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND0_ALPHA params GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC1_RGB params GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND1_RGB params GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC1_ALPHA params GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND1_ALPHA params GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC2_RGB params GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND2_RGB params GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC2_ALPHA params GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND2_ALPHA params GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_RGB_SCALE params /GL_INVALID_VALUE 1.0 2.0 4.0 +checkdependentparam pname GL_ALPHA_SCALE params /GL_INVALID_VALUE 1.0 2.0 4.0 +dependentvector params 4 pname GL_TEXTURE_ENV_COLOR +dependentvector params 1 pname GL_TEXTURE_ENV_MODE GL_COMBINE_RGB GL_COMBINE_ALPHA GL_COORD_REPLACE_OES GL_SRC0_RGB GL_OPERAND0_RGB GL_SRC0_ALPHA GL_OPERAND0_ALPHA GL_SRC1_RGB GL_OPERAND1_RGB GL_SRC1_ALPHA GL_OPERAND1_ALPHA GL_SRC2_RGB GL_OPERAND2_RGB GL_SRC2_ALPHA GL_OPERAND2_ALPHA +dependentvector params 1 pname GL_RGB_SCALE GL_ALPHA_SCALE +# OES_texture_env_crossbar +dependentvector params 1 pname GL_SRC0_RGB GL_SRC1_RGB GL_SRC2_RGB GL_SRC0_ALPHA GL_SRC1_ALPHA GL_SRC2_ALPHA +checkdependentparam pname GL_SRC0_RGB params GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC1_RGB params GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC2_RGB params GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC0_ALPHA params GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC1_ALPHA params GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC2_ALPHA params GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +category 1.0 GLES1.1 + +name TexEnvi +return void +param target GLenum +param pname GLenum +param param GLint +checkdependentparam target GL_POINT_SPRITE_OES pname GL_COORD_REPLACE_OES +checkdependentparam pname GL_COORD_REPLACE_OES param GL_TRUE GL_FALSE +checkdependentparam target GL_TEXTURE_ENV pname GL_TEXTURE_ENV_MODE GL_COMBINE_RGB GL_COMBINE_ALPHA GL_RGB_SCALE GL_ALPHA_SCALE GL_SRC0_RGB GL_OPERAND0_RGB GL_SRC0_ALPHA GL_OPERAND0_ALPHA GL_SRC1_RGB GL_OPERAND1_RGB GL_SRC1_ALPHA GL_OPERAND1_ALPHA GL_SRC2_RGB GL_OPERAND2_RGB GL_SRC2_ALPHA GL_OPERAND2_ALPHA +checkdependentparam pname GL_TEXTURE_ENV_MODE param GL_REPLACE GL_MODULATE GL_DECAL GL_BLEND GL_ADD GL_COMBINE +checkdependentparam pname GL_COMBINE_RGB param GL_REPLACE GL_MODULATE GL_ADD GL_ADD_SIGNED GL_INTERPOLATE GL_SUBTRACT GL_DOT3_RGB GL_DOT3_RGBA +checkdependentparam pname GL_COMBINE_ALPHA param GL_REPLACE GL_MODULATE GL_ADD GL_ADD_SIGNED GL_INTERPOLATE GL_SUBTRACT +checkdependentparam pname GL_RGB_SCALE param /GL_INVALID_VALUE 1.0 2.0 4.0 +checkdependentparam pname GL_ALPHA_SCALE param /GL_INVALID_VALUE 1.0 2.0 4.0 +checkdependentparam pname GL_SRC0_RGB param GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND0_RGB param GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC0_ALPHA param GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND0_ALPHA param GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC1_RGB param GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND1_RGB param GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC1_ALPHA param GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND1_ALPHA param GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC2_RGB param GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND2_RGB param GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC2_ALPHA param GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND2_ALPHA param GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +# OES_texture_env_crossbar +checkdependentparam pname GL_SRC0_RGB param GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC1_RGB param GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC2_RGB param GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC0_ALPHA param GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC1_ALPHA param GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC2_ALPHA param GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +category 1.0 GLES1.1 + +name TexEnviv +return void +param target GLenum +param pname GLenum +param params const GLint * +checkdependentparam target GL_POINT_SPRITE_OES pname GL_COORD_REPLACE_OES +checkdependentparam pname GL_COORD_REPLACE_OES params GL_TRUE GL_FALSE +checkdependentparam target GL_TEXTURE_ENV pname GL_TEXTURE_ENV_MODE GL_TEXTURE_ENV_COLOR GL_COMBINE_RGB GL_COMBINE_ALPHA GL_RGB_SCALE GL_ALPHA_SCALE GL_SRC0_RGB GL_OPERAND0_RGB GL_SRC0_ALPHA GL_OPERAND0_ALPHA GL_SRC1_RGB GL_OPERAND1_RGB GL_SRC1_ALPHA GL_OPERAND1_ALPHA GL_SRC2_RGB GL_OPERAND2_RGB GL_SRC2_ALPHA GL_OPERAND2_ALPHA +checkdependentparam pname GL_TEXTURE_ENV_MODE params GL_REPLACE GL_MODULATE GL_DECAL GL_BLEND GL_ADD GL_COMBINE +checkdependentparam pname GL_COMBINE_RGB params GL_REPLACE GL_MODULATE GL_ADD GL_ADD_SIGNED GL_INTERPOLATE GL_SUBTRACT GL_DOT3_RGB GL_DOT3_RGBA +checkdependentparam pname GL_COMBINE_ALPHA params GL_REPLACE GL_MODULATE GL_ADD GL_ADD_SIGNED GL_INTERPOLATE GL_SUBTRACT +checkdependentparam pname GL_SRC0_RGB params GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND0_RGB params GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC0_ALPHA params GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND0_ALPHA params GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC1_RGB params GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND1_RGB params GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC1_ALPHA params GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND1_ALPHA params GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC2_RGB params GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND2_RGB params GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC2_ALPHA params GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND2_ALPHA params GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_RGB_SCALE params /GL_INVALID_VALUE 1.0 2.0 4.0 +checkdependentparam pname GL_ALPHA_SCALE params /GL_INVALID_VALUE 1.0 2.0 4.0 +dependentvector params 4 pname GL_TEXTURE_ENV_COLOR +dependentvector params 1 pname GL_TEXTURE_ENV_MODE GL_COMBINE_RGB GL_COMBINE_ALPHA GL_COORD_REPLACE_OES GL_SRC0_RGB GL_OPERAND0_RGB GL_SRC0_ALPHA GL_OPERAND0_ALPHA GL_SRC1_RGB GL_OPERAND1_RGB GL_SRC1_ALPHA GL_OPERAND1_ALPHA GL_SRC2_RGB GL_OPERAND2_RGB GL_SRC2_ALPHA GL_OPERAND2_ALPHA +dependentvector params 1 pname GL_RGB_SCALE GL_ALPHA_SCALE +# OES_texture_env_crossbar +checkdependentparam pname GL_SRC0_RGB params GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC1_RGB params GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC2_RGB params GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC0_ALPHA params GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC1_ALPHA params GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC2_ALPHA params GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +category 1.0 GLES1.1 + +name TexEnvx +return void +param target GLenum +param pname GLenum +param param GLfixed +checkdependentparam target GL_POINT_SPRITE_OES pname GL_COORD_REPLACE_OES +checkdependentparam pname GL_COORD_REPLACE_OES param GL_TRUE GL_FALSE +checkdependentparam target GL_TEXTURE_ENV pname GL_TEXTURE_ENV_MODE GL_COMBINE_RGB GL_COMBINE_ALPHA GL_RGB_SCALE GL_ALPHA_SCALE GL_SRC0_RGB GL_OPERAND0_RGB GL_SRC0_ALPHA GL_OPERAND0_ALPHA GL_SRC1_RGB GL_OPERAND1_RGB GL_SRC1_ALPHA GL_OPERAND1_ALPHA GL_SRC2_RGB GL_OPERAND2_RGB GL_SRC2_ALPHA GL_OPERAND2_ALPHA +checkdependentparam pname GL_TEXTURE_ENV_MODE param GL_REPLACE GL_MODULATE GL_DECAL GL_BLEND GL_ADD GL_COMBINE +checkdependentparam pname GL_COMBINE_RGB param GL_REPLACE GL_MODULATE GL_ADD GL_ADD_SIGNED GL_INTERPOLATE GL_SUBTRACT GL_DOT3_RGB GL_DOT3_RGBA +checkdependentparam pname GL_COMBINE_ALPHA param GL_REPLACE GL_MODULATE GL_ADD GL_ADD_SIGNED GL_INTERPOLATE GL_SUBTRACT +checkdependentparam pname GL_RGB_SCALE param /GL_INVALID_VALUE 1.0 2.0 4.0 +checkdependentparam pname GL_ALPHA_SCALE param /GL_INVALID_VALUE 1.0 2.0 4.0 +checkdependentparam pname GL_SRC0_RGB param GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND0_RGB param GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC0_ALPHA param GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND0_ALPHA param GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC1_RGB param GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND1_RGB param GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC1_ALPHA param GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND1_ALPHA param GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC2_RGB param GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND2_RGB param GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC2_ALPHA param GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND2_ALPHA param GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +convertalias TexEnvf +convertparams GLfloat param +# OES_texture_env_crossbar +checkdependentparam pname GL_SRC0_RGB param GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC1_RGB param GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC2_RGB param GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC0_ALPHA param GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC1_ALPHA param GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC2_ALPHA param GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +category 1.0 GLES1.1 GLES1.1:OES_fixed_point + +name TexEnvxv +return void +param target GLenum +param pname GLenum +param params const GLfixed * +checkdependentparam target GL_POINT_SPRITE_OES pname GL_COORD_REPLACE_OES +checkdependentparam pname GL_COORD_REPLACE_OES params GL_TRUE GL_FALSE +checkdependentparam target GL_TEXTURE_ENV pname GL_TEXTURE_ENV_MODE GL_TEXTURE_ENV_COLOR GL_COMBINE_RGB GL_COMBINE_ALPHA GL_RGB_SCALE GL_ALPHA_SCALE GL_SRC0_RGB GL_OPERAND0_RGB GL_SRC0_ALPHA GL_OPERAND0_ALPHA GL_SRC1_RGB GL_OPERAND1_RGB GL_SRC1_ALPHA GL_OPERAND1_ALPHA GL_SRC2_RGB GL_OPERAND2_RGB GL_SRC2_ALPHA GL_OPERAND2_ALPHA +checkdependentparam pname GL_TEXTURE_ENV_MODE params GL_REPLACE GL_MODULATE GL_DECAL GL_BLEND GL_ADD GL_COMBINE +checkdependentparam pname GL_COMBINE_RGB params GL_REPLACE GL_MODULATE GL_ADD GL_ADD_SIGNED GL_INTERPOLATE GL_SUBTRACT GL_DOT3_RGB GL_DOT3_RGBA +checkdependentparam pname GL_COMBINE_ALPHA params GL_REPLACE GL_MODULATE GL_ADD GL_ADD_SIGNED GL_INTERPOLATE GL_SUBTRACT +checkdependentparam pname GL_SRC0_RGB params GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND0_RGB params GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC0_ALPHA params GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND0_ALPHA params GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC1_RGB params GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND1_RGB params GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC1_ALPHA params GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND1_ALPHA params GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC2_RGB params GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND2_RGB params GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_SRC2_ALPHA params GL_TEXTURE GL_CONSTANT GL_PRIMARY_COLOR GL_PREVIOUS +checkdependentparam pname GL_OPERAND2_ALPHA params GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA +checkdependentparam pname GL_RGB_SCALE params /GL_INVALID_VALUE 1.0 2.0 4.0 +checkdependentparam pname GL_ALPHA_SCALE params /GL_INVALID_VALUE 1.0 2.0 4.0 +dependentvector params 4 pname GL_TEXTURE_ENV_COLOR +dependentvector params 1 pname GL_TEXTURE_ENV_MODE GL_COMBINE_RGB GL_COMBINE_ALPHA GL_COORD_REPLACE_OES GL_SRC0_RGB GL_OPERAND0_RGB GL_SRC0_ALPHA GL_OPERAND0_ALPHA GL_SRC1_RGB GL_OPERAND1_RGB GL_SRC1_ALPHA GL_OPERAND1_ALPHA GL_SRC2_RGB GL_OPERAND2_RGB GL_SRC2_ALPHA GL_OPERAND2_ALPHA +dependentvector params 1 pname GL_RGB_SCALE GL_ALPHA_SCALE +convertalias TexEnvfv +convertparams GLfloat params +# OES_texture_env_crossbar +dependentvector params 1 pname GL_SRC0_RGB GL_SRC1_RGB GL_SRC2_RGB GL_SRC0_ALPHA GL_SRC1_ALPHA GL_SRC2_ALPHA +checkdependentparam pname GL_SRC0_RGB params GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC1_RGB params GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC2_RGB params GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC0_ALPHA params GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC1_ALPHA params GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +checkdependentparam pname GL_SRC2_ALPHA params GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +category GLES1.1 GLES1.1:OES_fixed_point + +name TexGenx +return void +param coord GLenum +checkparam coord GL_TEXTURE_GEN_STR_OES +param pname GLenum +param param GLfixed +checkdependentparam pname GL_TEXTURE_GEN_MODE_OES param GL_NORMAL_MAP_OES GL_REFLECTION_MAP_OES +convertalias TexGenf +convertparams GLfloat param +category GLES1.1:OES_texture_cube_map + +name TexGenxv +return void +param coord GLenum +checkparam coord GL_TEXTURE_GEN_STR_OES +param pname GLenum +param params const GLfixed * +dependentvector params 1 pname GL_TEXTURE_GEN_MODE_OES +checkdependentparam pname GL_TEXTURE_GEN_MODE_OES params GL_NORMAL_MAP_OES GL_REFLECTION_MAP_OES +convertalias TexGenfv +convertparams GLfloat params +category GLES1.1:OES_texture_cube_map + +name TexGenf +return void +param coord GLenum +checkparam coord GL_TEXTURE_GEN_STR_OES +param pname GLenum +checkparam pname GL_TEXTURE_GEN_MODE_OES +param param GLfloat +checkdependentparam pname GL_TEXTURE_GEN_MODE_OES param GL_NORMAL_MAP_OES GL_REFLECTION_MAP_OES +category 1.0 GLES1.1:OES_texture_cube_map + +name TexGenfv +return void +param coord GLenum +checkparam coord GL_TEXTURE_GEN_STR_OES +param pname GLenum +param params const GLfloat * +dependentvector params 1 pname GL_TEXTURE_GEN_MODE_OES +checkdependentparam pname GL_TEXTURE_GEN_MODE_OES params GL_NORMAL_MAP_OES GL_REFLECTION_MAP_OES +category 1.0 GLES1.1:OES_texture_cube_map + +name TexGeni +return void +param coord GLenum +checkparam coord GL_TEXTURE_GEN_STR_OES +param pname GLenum +checkparam pname GL_TEXTURE_GEN_MODE_OES +param param GLint +checkdependentparam pname GL_TEXTURE_GEN_MODE_OES param GL_NORMAL_MAP_OES GL_REFLECTION_MAP_OES +category 1.0 GLES1.1:OES_texture_cube_map + +name TexGeniv +return void +param coord GLenum +checkparam coord GL_TEXTURE_GEN_STR_OES +param pname GLenum +checkparam pname GL_TEXTURE_GEN_MODE_OES +param params const GLint * +dependentvector params 1 pname GL_TEXTURE_GEN_MODE_OES +checkdependentparam pname GL_TEXTURE_GEN_MODE_OES params GL_NORMAL_MAP_OES GL_REFLECTION_MAP_OES +convertalias TexGenfv +convertparams GLfloat params +category 1.0 GLES1.1:OES_texture_cube_map + +name Clear +return void +param mask GLbitfield +checkparam mask /GL_INVALID_VALUE 0 (GL_COLOR_BUFFER_BIT) (GL_DEPTH_BUFFER_BIT) (GL_STENCIL_BUFFER_BIT) (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) (GL_COLOR_BUFFER_BIT|GL_STENCIL_BUFFER_BIT) (GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT) (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT) +category 1.0 GLES1.1 GLES2.0 + +name ClearColor +return void +param red GLclampf +param green GLclampf +param blue GLclampf +param alpha GLclampf +category 1.0 GLES1.1 GLES2.0 + +name ClearColorx +return void +param red GLclampx +param green GLclampx +param blue GLclampx +param alpha GLclampx +convertalias ClearColor +convertparams GLclampf red green blue alpha +category GLES1.1 GLES1.1:OES_fixed_point + +name ClearStencil +return void +param s GLint +category 1.0 GLES1.1 GLES2.0 + +name ClearDepthf +return void +param depth GLclampf +convertalias ClearDepth +convertparams GLclampd depth +category GLES1.1 GLES1.1:OES_single_precision GLES2.0 + +name ClearDepthx +return void +param depth GLclampx +convertalias ClearDepth +convertparams GLclampd depth +category GLES1.1 GLES1.1:OES_fixed_point + +name StencilMask +return void +param mask GLuint +category 1.0 GLES1.1 GLES2.0 + +name StencilMaskSeparate +return void +param face GLenum +param mask GLuint +checkparam face GL_FRONT GL_BACK GL_FRONT_AND_BACK +category GLES2.0 + +name ColorMask +return void +param red GLboolean +param green GLboolean +param blue GLboolean +param alpha GLboolean +category 1.0 GLES1.1 GLES2.0 + +name DepthMask +return void +param flag GLboolean +category 1.0 GLES1.1 GLES2.0 + +# Two versions, as GLES2 has a vastly different set of enable/disable capabilities +name Disable +return void +param cap GLenum +checkparam cap GL_VERTEX_ARRAY GL_NORMAL_ARRAY GL_COLOR_ARRAY GL_TEXTURE_COORD_ARRAY GL_NORMALIZE GL_RESCALE_NORMAL GL_CLIP_PLANE0 GL_CLIP_PLANE1 GL_CLIP_PLANE2 GL_CLIP_PLANE3 GL_CLIP_PLANE4 GL_CLIP_PLANE5 GL_FOG GL_LIGHTING GL_COLOR_MATERIAL GL_LIGHT0 GL_LIGHT1 GL_LIGHT2 GL_LIGHT3 GL_LIGHT4 GL_LIGHT5 GL_LIGHT6 GL_LIGHT7 GL_POINT_SMOOTH GL_LINE_SMOOTH GL_CULL_FACE GL_POLYGON_OFFSET_FILL GL_MULTISAMPLE GL_SAMPLE_ALPHA_TO_COVERAGE GL_SAMPLE_ALPHA_TO_ONE GL_SAMPLE_COVERAGE GL_TEXTURE_2D GL_SCISSOR_TEST GL_ALPHA_TEST GL_STENCIL_TEST GL_DEPTH_TEST GL_BLEND GL_DITHER GL_COLOR_LOGIC_OP +# OES_matrix_palette +checkparam cap GL_MATRIX_INDEX_ARRAY_OES GL_WEIGHT_ARRAY_OES +# OES_point_size_array +checkparam cap GL_POINT_SIZE_ARRAY_OES +# OES_point_sprite +checkparam cap GL_POINT_SPRITE_OES +# OES_texture_cube_map +checkparam cap GL_TEXTURE_CUBE_MAP_OES GL_TEXTURE_GEN_STR_OES +category GLES1.1 + +name Disable +return void +param cap GLenum +checkparam cap GL_CULL_FACE GL_SCISSOR_TEST GL_POLYGON_OFFSET_FILL GL_SAMPLE_ALPHA_TO_COVERAGE GL_SAMPLE_COVERAGE GL_STENCIL_TEST GL_DEPTH_TEST GL_DITHER GL_BLEND +category GLES2.0 + +# Two versions, as GLES2 has a vastly different set of enable/disable capabilities +name Enable +return void +param cap GLenum +checkparam cap GL_VERTEX_ARRAY GL_NORMAL_ARRAY GL_COLOR_ARRAY GL_TEXTURE_COORD_ARRAY GL_NORMALIZE GL_RESCALE_NORMAL GL_CLIP_PLANE0 GL_CLIP_PLANE1 GL_CLIP_PLANE2 GL_CLIP_PLANE3 GL_CLIP_PLANE4 GL_CLIP_PLANE5 GL_FOG GL_LIGHTING GL_COLOR_MATERIAL GL_LIGHT0 GL_LIGHT1 GL_LIGHT2 GL_LIGHT3 GL_LIGHT4 GL_LIGHT5 GL_LIGHT6 GL_LIGHT7 GL_POINT_SMOOTH GL_LINE_SMOOTH GL_CULL_FACE GL_POLYGON_OFFSET_FILL GL_MULTISAMPLE GL_SAMPLE_ALPHA_TO_COVERAGE GL_SAMPLE_ALPHA_TO_ONE GL_SAMPLE_COVERAGE GL_TEXTURE_2D GL_SCISSOR_TEST GL_ALPHA_TEST GL_STENCIL_TEST GL_DEPTH_TEST GL_BLEND GL_DITHER GL_COLOR_LOGIC_OP +# OES_matrix_palette +checkparam cap GL_MATRIX_INDEX_ARRAY_OES GL_WEIGHT_ARRAY_OES +# OES_point_size_array +checkparam cap GL_POINT_SIZE_ARRAY_OES +# OES_point_sprite +checkparam cap GL_POINT_SPRITE_OES +# OES_texture_cube_map +checkparam cap GL_TEXTURE_CUBE_MAP_OES GL_TEXTURE_GEN_STR_OES +category GLES1.1 + +name Enable +return void +param cap GLenum +checkparam cap GL_CULL_FACE GL_SCISSOR_TEST GL_POLYGON_OFFSET_FILL GL_SAMPLE_ALPHA_TO_COVERAGE GL_SAMPLE_COVERAGE GL_STENCIL_TEST GL_DEPTH_TEST GL_DITHER GL_BLEND +category GLES2.0 + +name Finish +return void +category 1.0 GLES1.1 GLES2.0 + +name Flush +return void +category 1.0 GLES1.1 GLES2.0 + +name AlphaFunc +return void +param func GLenum +checkparam func GL_NEVER GL_LESS GL_EQUAL GL_LEQUAL GL_GREATER GL_NOTEQUAL GL_GEQUAL GL_ALWAYS +param ref GLclampf +category 1.0 GLES1.1 + +name AlphaFuncx +return void +param func GLenum +checkparam func GL_NEVER GL_LESS GL_EQUAL GL_LEQUAL GL_GREATER GL_NOTEQUAL GL_GEQUAL GL_ALWAYS +param ref GLclampx +convertalias AlphaFunc +convertparams GLclampf ref +category GLES1.1 GLES1.1:OES_fixed_point + +name BlendFunc +return void +param sfactor GLenum +checkparam sfactor GL_ZERO GL_ONE GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_DST_COLOR GL_ONE_MINUS_DST_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_DST_COLOR GL_DST_ALPHA GL_ONE_MINUS_DST_COLOR GL_ONE_MINUS_DST_ALPHA GL_SRC_ALPHA_SATURATE +checkparam sfactor GLES2.0:GL_CONSTANT_COLOR GLES2.0:GL_CONSTANT_ALPHA GLES2.0:GL_ONE_MINUS_CONSTANT_COLOR GLES2.0:GL_ONE_MINUS_CONSTANT_ALPHA +param dfactor GLenum +checkparam dfactor GL_ZERO GL_ONE GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_DST_COLOR GL_DST_ALPHA GL_ONE_MINUS_DST_COLOR GL_ONE_MINUS_DST_ALPHA +checkparam dfactor GLES2.0:GL_CONSTANT_COLOR GLES2.0:GL_CONSTANT_ALPHA GLES2.0:GL_ONE_MINUS_CONSTANT_COLOR GLES2.0:GL_ONE_MINUS_CONSTANT_ALPHA +category 1.0 GLES1.1 GLES2.0 + +name LogicOp +return void +param opcode GLenum +checkparam opcode GL_CLEAR GL_SET GL_COPY GL_COPY_INVERTED GL_NOOP GL_INVERT GL_AND GL_NAND GL_OR GL_NOR GL_XOR GL_EQUIV GL_AND_REVERSE GL_AND_INVERTED GL_OR_REVERSE GL_OR_INVERTED +category 1.0 GLES1.1 + +name StencilFunc +return void +param func GLenum +param ref GLint +param mask GLuint +checkparam func GL_NEVER GL_LESS GL_LEQUAL GL_GREATER GL_GEQUAL GL_EQUAL GL_NOTEQUAL GL_ALWAYS +category 1.0 GLES1.1 GLES2.0 + +name StencilFuncSeparate +return void +param face GLenum +param func GLenum +param ref GLint +param mask GLuint +checkparam face GL_FRONT GL_BACK GL_FRONT_AND_BACK +checkparam func GL_NEVER GL_LESS GL_LEQUAL GL_GREATER GL_GEQUAL GL_EQUAL GL_NOTEQUAL GL_ALWAYS +category GLES2.0 + +name StencilOp +return void +param fail GLenum +param zfail GLenum +param zpass GLenum +checkparam fail GL_KEEP GL_ZERO GL_REPLACE GL_INCR GL_DECR GL_INVERT GLES2.0:GL_INCR_WRAP GLES2.0:GL_DECR_WRAP +checkparam zfail GL_KEEP GL_ZERO GL_REPLACE GL_INCR GL_DECR GL_INVERT GLES2.0:GL_INCR_WRAP GLES2.0:GL_DECR_WRAP +checkparam zpass GL_KEEP GL_ZERO GL_REPLACE GL_INCR GL_DECR GL_INVERT GLES2.0:GL_INCR_WRAP GLES2.0:GL_DECR_WRAP +# OES_stencil_wrap +checkparam fail GLES1.1:GL_INCR_WRAP_OES GLES1.1:GL_DECR_WRAP_OES +checkparam zfail GLES1.1:GL_INCR_WRAP_OES GLES1.1:GL_DECR_WRAP_OES +checkparam zpass GLES1.1:GL_INCR_WRAP_OES GLES1.1:GL_DECR_WRAP_OES +category GLES1.1 GLES2.0 + +name StencilOpSeparate +return void +param face GLenum +param fail GLenum +param zfail GLenum +param zpass GLenum +checkparam face GL_FRONT GL_BACK GL_FRONT_AND_BACK +checkparam fail GL_KEEP GL_ZERO GL_REPLACE GL_INCR GL_DECR GL_INVERT GL_INCR_WRAP GL_DECR_WRAP +checkparam zfail GL_KEEP GL_ZERO GL_REPLACE GL_INCR GL_DECR GL_INVERT GL_INCR_WRAP GL_DECR_WRAP +checkparam zpass GL_KEEP GL_ZERO GL_REPLACE GL_INCR GL_DECR GL_INVERT GL_INCR_WRAP GL_DECR_WRAP +category GLES2.0 + +name DepthFunc +return void +param func GLenum +checkparam func GL_NEVER GL_LESS GL_EQUAL GL_LEQUAL GL_GREATER GL_NOTEQUAL GL_GEQUAL GL_ALWAYS +category 1.0 GLES1.1 GLES2.0 + +name PixelStorei +return void +param pname GLenum +checkparam pname GL_PACK_ALIGNMENT GL_UNPACK_ALIGNMENT +param param GLint +checkparam param /GL_INVALID_VALUE 1 2 4 8 +category 1.0 GLES1.1 GLES2.0 + +name ReadPixels +return void +param x GLint +param y GLint +param width GLsizei +param height GLsizei +param format GLenum +param type GLenum +param pixels GLvoid * +# Technically, only two combinations are actually allowed: +# GL_RGBA/GL_UNSIGNED_BYTE, and some implementation-specific internal +# preferred combination. I don't know what that is, so I'm allowing +# any valid combination for now; the underlying support should fail +# when necessary. +checkdependentparam format GL_RGBA type GL_UNSIGNED_BYTE +checkdependentparam format GL_RGBA type GL_UNSIGNED_BYTE GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_5_5_5_1 +checkdependentparam format GL_RGB type GL_UNSIGNED_BYTE GL_UNSIGNED_SHORT_5_6_5 +checkdependentparam format GL_LUMINANCE_ALPHA format GL_UNSIGNED_BYTE +checkdependentparam format GL_LUMINANCE format GL_UNSIGNED_BYTE +checkdependentparam format GL_ALPHA format GL_UNSIGNED_BYTE +props get +category 1.0 GLES1.1 GLES2.0 + +# Note: glGetBooleanv param checking done inside Mesa +name GetBooleanv +return void +param pname GLenum +param params GLboolean * +props get +category GLES1.1 GLES2.0 + +name GetClipPlanef +return void +param plane GLenum +checkparam plane GL_CLIP_PLANE0 GL_CLIP_PLANE1 GL_CLIP_PLANE2 GL_CLIP_PLANE3 GL_CLIP_PLANE4 GL_CLIP_PLANE5 +param equation GLfloat * +paramvec equation 0.0 0.0 0.0 0.0 +vector equation 4 +convertalias GetClipPlane +convertparams GLdouble equation +props get +category GLES1.1 GLES1.1:OES_single_precision + +name GetClipPlanex +return void +param plane GLenum +checkparam plane GL_CLIP_PLANE0 GL_CLIP_PLANE1 GL_CLIP_PLANE2 GL_CLIP_PLANE3 GL_CLIP_PLANE4 GL_CLIP_PLANE5 +param equation GLfixed * +paramvec equation 0.0 0.0 0.0 0.0 +vector equation 4 +convertalias GetClipPlane +convertparams GLdouble equation +props get +category GLES1.1 GLES1.1:OES_fixed_point + +name GetError +return GLenum +props get +category 1.0 GLES1.1 GLES2.0 + +# Note: glGetFloatv param checking done inside Mesa +name GetFloatv +return void +param pname GLenum +param params GLfloat * +props get +category GLES1.1 GLES2.0 + +name GetFixedv +return void +param pname GLenum +param params GLfixed * +convertalias GetFloatv +convertparams GLfloat params +props get +dependentvector params 1 pname GL_CLIENT_ACTIVE_TEXTURE GL_VERTEX_ARRAY GL_VERTEX_ARRAY_SIZE GL_VERTEX_ARRAY_TYPE GL_VERTEX_ARRAY_STRIDE GL_NORMAL_ARRAY GL_NORMAL_ARRAY_TYPE GL_NORMAL_ARRAY_STRIDE GL_COLOR_ARRAY GL_COLOR_ARRAY_SIZE GL_COLOR_ARRAY_TYPE +dependentvector params 1 pname GL_TEXTURE_COORD_ARRAY GL_TEXTURE_COORD_ARRAY_SIZE GL_TEXTURE_COORD_ARRAY_TYPE GL_TEXTURE_COORD_ARRAY_STRIDE GL_POINT_SIZE_ARRAY_OES GL_POINT_SIZE_ARRAY_STRIDE_OES GL_ARRAY_BUFFER_BINDING GL_VERTEX_ARRAY_BUFFER_BINDING GL_NORMAL_ARRAY_BUFFER_BINDING GL_COLOR_ARRAY_BUFFER_BINDING GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES GL_ELEMENT_ARRAY_BUFFER_BINDING +dependentvector params 1 pname GL_MODELVIEW_STACK_DEPTH GL_PROJECTION_STACK_DEPTH GL_TEXTURE_STACK_DEPTH GL_MATRIX_MODE GL_NORMALIZE GL_RESCALE_NORMAL GL_CLIP_PLANE0 GL_CLIP_PLANE1 GL_CLIP_PLANE2 GL_CLIP_PLANE3 GL_CLIP_PLANE4 GL_CLIP_PLANE5 +dependentvector params 1 pname GL_FOG_DENSITY GL_FOG_START GL_FOG_END GL_FOG_MODE GL_FOG GL_SHADE_MODEL +dependentvector params 1 pname GL_LIGHTING GL_COLOR_MATERIAL GL_LIGHT_MODEL_TWO_SIDE +dependentvector params 1 pname GL_POINT_SIZE GL_POINT_SMOOTH GL_POINT_SIZE_MIN GL_POINT_SIZE_MAX GL_POINT_FADE_THRESHOLD_SIZE GL_POINT_SPRITE_OES GL_LINE_WIDTH GL_LINE_SMOOTH GL_CULL_FACE GL_CULL_FACE_MODE GL_FRONT_FACE GL_POLYGON_OFFSET_FACTOR GL_POLYGON_OFFSET_UNITS GL_POLYGON_OFFSET_FILL +dependentvector params 1 pname GL_MULTISAMPLE GL_SAMPLE_ALPHA_TO_COVERAGE GL_SAMPLE_ALPHA_TO_ONE GL_SAMPLE_COVERAGE GL_SAMPLE_COVERAGE_VALUE +dependentvector params 1 pname GL_TEXTURE_2D GL_TEXTURE_BINDING_2D +dependentvector params 1 pname GL_ACTIVE_TEXTURE +dependentvector params 1 pname GL_SCISSOR_TEST GL_ALPHA_TEST_FUNC GL_ALPHA_TEST_REF GL_STENCIL_TEST GL_STENCIL_FUNC GL_STENCIL_VALUE_MASK GL_STENCIL_REF GL_STENCIL_FAIL GL_STENCIL_PASS_DEPTH_FAIL GL_STENCIL_PASS_DEPTH_PASS GL_DEPTH_TEST GL_DEPTH_FUNC GL_BLEND GL_BLEND_SRC GL_BLEND_DST GL_DITHER GL_COLOR_LOGIC_OP GL_LOGIC_OP_MODE +dependentvector params 1 pname GL_DEPTH_WRITEMASK GL_STENCIL_WRITEMASK GL_DEPTH_CLEAR_VALUE GL_STENCIL_CLEAR_VALUE +dependentvector params 1 pname GL_UNPACK_ALIGNMENT GL_PACK_ALIGNMENT +dependentvector params 1 pname GL_PERSPECTIVE_CORRECTION_HINT GL_POINT_SMOOTH_HINT GL_LINE_SMOOTH_HINT GL_FOG_HINT GL_GENERATE_MIPMAP_HINT +dependentvector params 1 pname GL_MAX_LIGHTS GL_MAX_CLIP_PLANES GL_MAX_MODELVIEW_STACK_DEPTH GL_MAX_PROJECTION_STACK_DEPTH GL_MAX_TEXTURE_STACK_DEPTH GL_SUBPIXEL_BITS GL_MAX_TEXTURE_SIZE GL_MAX_TEXTURE_UNITS GL_SAMPLE_BUFFERS GL_SAMPLES GL_NUM_COMPRESSED_TEXTURE_FORMATS GL_RED_BITS GL_GREEN_BITS GL_BLUE_BITS GL_ALPHA_BITS GL_DEPTH_BITS GL_STENCIL_BITS +dependentvector params 2 pname GL_MAX_VIEWPORT_DIMS GL_ALIASED_POINT_SIZE_RANGE GL_SMOOTH_POINT_SIZE_RANGE GL_ALIASED_LINE_WIDTH_RANGE GL_SMOOTH_LINE_WIDTH_RANGE +dependentvector params 2 pname GL_DEPTH_RANGE +dependentvector params 3 pname GL_CURRENT_NORMAL +dependentvector params 3 pname GL_POINT_DISTANCE_ATTENUATION +dependentvector params 4 pname GL_CURRENT_COLOR GL_CURRENT_TEXTURE_COORDS +dependentvector params 4 pname GL_SCISSOR_BOX +dependentvector params 4 pname GL_COLOR_WRITEMASK GL_COLOR_CLEAR_VALUE +dependentvector params 4 pname GL_LIGHT_MODEL_AMBIENT +dependentvector params 4 pname GL_VIEWPORT +dependentvector params 4 pname GL_FOG_COLOR +dependentvector params 16 pname GL_MODELVIEW_MATRIX GL_PROJECTION_MATRIX GL_TEXTURE_MATRIX +dependentvector params _get_size(GL_NUM_COMPRESSED_TEXTURE_FORMATS) pname GL_COMPRESSED_TEXTURE_FORMATS +# OES_blend_subtract +dependentvector params 1 pname GL_BLEND_SRC_RGB_OES GL_BLEND_DST_RGB_OES GL_BLEND_SRC_ALPHA_OES GL_BLEND_DST_ALPHA_OES +# OES_blend_equation_separate +dependentvector params 1 pname GL_BLEND_EQUATION_RGB_OES GL_BLEND_EQUATION_ALPHA_OES +# OES_framebuffer_object +dependentvector params 1 pname GL_FRAMEBUFFER_BINDING_OES GL_RENDERBUFFER_BINDING_OES GL_MAX_RENDERBUFFER_SIZE_OES +# OES_matrix_get +dependentvector params 16 pname GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES +# OES_matrix_palette +dependentvector params 1 pname GL_MAX_PALETTE_MATRICES_OES GL_MAX_VERTEX_UNITS_OES GL_CURRENT_PALETTE_MATRIX_OES +dependentvector params 1 pname GL_MATRIX_INDEX_ARRAY_SIZE_OES GL_MATRIX_INDEX_ARRAY_TYPE_OES GL_MATRIX_INDEX_ARRAY_STRIDE_OES GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES GL_WEIGHT_ARRAY_SIZE_OES GL_WEIGHT_ARRAY_TYPE_OES GL_WEIGHT_ARRAY_STRIDE_OES GL_WEIGHT_ARRAY_BUFFER_BINDING_OES +# OES_point_size_array +dependentvector params 1 pname GL_POINT_SIZE_ARRAY_TYPE_OES GL_POINT_SIZE_ARRAY_STRIDE_OES GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES +# OES_read_format +dependentvector params 1 pname GL_IMPLEMENTATION_COLOR_READ_TYPE_OES GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES +# OES_texture_cube_map +dependentvector params 1 pname GL_TEXTURE_CUBE_MAP_OES GL_TEXTURE_BINDING_CUBE_MAP_OES GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES +# EXT_texture_filter_anisotropic +dependentvector params 1 pname GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT +# These values return booleans or GLenums, and should not have their +# value converted when used with glGetFixed() +dependentnovalueconvert params pname GL_VERTEX_ARRAY GL_VERTEX_ARRAY_TYPE GL_NORMAL_ARRAY GL_NORMAL_ARRAY_TYPE GL_COLOR_ARRAY GL_COLOR_ARRAY_TYPE GL_TEXTURE_COORD_ARRAY GL_TEXTURE_COORD_ARRAY_TYPE GL_POINT_SIZE_ARRAY_OES GL_MATRIX_MODE GL_NORMALIZE GL_RESCALE_NORMAL GL_CLIP_PLANE0 GL_CLIP_PLANE1 GL_CLIP_PLANE2 GL_CLIP_PLANE3 GL_CLIP_PLANE4 GL_CLIP_PLANE5 GL_FOG_MODE GL_FOG GL_SHADE_MODEL GL_LIGHTING GL_COLOR_MATERIAL GL_LIGHT_MODEL_TWO_SIDE GL_LIGHT0 GL_LIGHT1 GL_LIGHT2 GL_LIGHT3 GL_LIGHT4 GL_LIGHT5 GL_LIGHT6 GL_LIGHT7 GL_POINT_SMOOTH GL_POINT_SPRITE_OES GL_LINE_SMOOTH GL_CULL_FACE GL_CULL_FACE_MODE GL_FRONT_FACE GL_POLYGON_OFFSET_FILL GL_MULTISAMPLE GL_SAMPLE_ALPHA_TO_COVERAGE GL_SAMPLE_ALPHA_TO_ONE GL_SAMPLE_COVERAGE GL_TEXTURE_2D GL_ACTIVE_TEXTURE GL_SCISSOR_TEST GL_ALPHA_TEST GL_ALPHA_TEST_FUNC GL_STENCIL_TEST GL_STENCIL_FUNC GL_STENCIL_FAIL GL_STENCIL_PASS_DEPTH_FAIL GL_STENCIL_PASS_DEPTH_PASS GL_DEPTH_TEST GL_DEPTH_FUNC GL_BLEND GL_BLEND_SRC GL_BLEND_DST GL_DITHER GL_COLOR_LOGIC_OP GL_LOGIC_OP_MODE GL_DEPTH_WRITEMASK GL_PERSPECTIVE_CORRECTION_HINT GL_POINT_SMOOTH_HINT GL_LINE_SMOOTH_HINT GL_FOG_HINT GL_GENERATE_MIPMAP_HINT GL_COMPRESSED_TEXTURE_FORMATS GL_IMPLEMENTATION_COLOR_READ_TYPE_OES GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES GL_BLEND_SRC_RGB_OES GL_BLEND_DST_RGB_OES GL_BLEND_SRC_ALPHA_OES GL_BLEND_DST_ALPHA_OES GL_BLEND_EQUATION_RGB_OES GL_BLEND_EQUATION_ALPHA_OES GL_MATRIX_INDEX_ARRAY_TYPE_OES GL_WEIGHT_ARRAY_TYPE_OES GL_POINT_SIZE_ARRAY_TYPE_OES GL_TEXTURE_CUBE_MAP_OES +category GLES1.1 GLES1.1:OES_fixed_point + +# Note: glGetIntegerv param checking done inside Mesa +name GetIntegerv +return void +param pname GLenum +param params GLint * +props get +category GLES1.1 GLES2.0 + + +# This does *not* specify dependent vectors because everything is just +# passed down to Mesa - no copy or conversion is done. +name GetLightfv +return void +param light GLenum +checkparam light GL_LIGHT0 GL_LIGHT1 GL_LIGHT2 GL_LIGHT3 GL_LIGHT4 GL_LIGHT5 GL_LIGHT6 GL_LIGHT7 +param pname GLenum +checkparam pname GL_AMBIENT GL_DIFFUSE GL_SPECULAR GL_POSITION GL_SPOT_DIRECTION GL_SPOT_EXPONENT GL_SPOT_CUTOFF GL_CONSTANT_ATTENUATION GL_LINEAR_ATTENUATION GL_QUADRATIC_ATTENUATION +param params GLfloat * +props get +category 1.0 GLES1.1 + +name GetLightxv +return void +param light GLenum +checkparam light GL_LIGHT0 GL_LIGHT1 GL_LIGHT2 GL_LIGHT3 GL_LIGHT4 GL_LIGHT5 GL_LIGHT6 GL_LIGHT7 +param pname GLenum +param params GLfixed * +dependentvector params 4 pname GL_AMBIENT GL_DIFFUSE GL_SPECULAR GL_POSITION +dependentvector params 3 pname GL_SPOT_DIRECTION +dependentvector params 1 pname GL_SPOT_EXPONENT GL_SPOT_CUTOFF GL_CONSTANT_ATTENUATION GL_QUADRATIC_ATTENUATION +convertalias GetLightfv +convertparams GLfloat params +props get +category GLES1.1 GLES1.1:OES_fixed_point + +name GetMaterialfv +return void +param face GLenum +checkparam face GL_FRONT GL_BACK +param pname GLenum +checkparam pname GL_AMBIENT GL_DIFFUSE GL_AMBIENT_AND_DIFFUSE GL_SPECULAR GL_EMISSION GL_SHININESS +param params GLfloat * +props get +category 1.0 GLES1.1 + +name GetMaterialiv +return void +param face GLenum +checkparam face GL_FRONT GL_BACK +param pname GLenum +checkparam pname GL_AMBIENT GL_DIFFUSE GL_AMBIENT_AND_DIFFUSE GL_SPECULAR GL_EMISSION GL_SHININESS +param params GLint * +category 1.0 +props get + +name GetMaterialxv +return void +param face GLenum +checkparam face GL_FRONT GL_BACK +param pname GLenum +param params GLfixed * +props get +dependentvector params 1 pname GL_SHININESS +dependentvector params 4 pname GL_AMBIENT GL_DIFFUSE GL_AMBIENT_AND_DIFFUSE GL_SPECULAR GL_EMISSION +convertalias GetMaterialfv +convertparams GLfloat params +category GLES1.1 GLES1.1:OES_fixed_point + +name GetString +return const GLubyte * +param name GLenum +checkparam name GL_VENDOR GL_RENDERER GL_VERSION GL_EXTENSIONS +props get +category 1.0 GLES1.1 GLES2.0 + +name GetTexEnvfv +return void +param target GLenum +param pname GLenum +param params GLfloat * +checkdependentparam target GL_POINT_SPRITE_OES pname GL_COORD_REPLACE_OES +checkdependentparam target GL_TEXTURE_ENV pname GL_TEXTURE_ENV_MODE GL_TEXTURE_ENV_COLOR GL_COMBINE_RGB GL_COMBINE_ALPHA GL_RGB_SCALE GL_ALPHA_SCALE GL_SRC0_RGB GL_OPERAND0_RGB GL_SRC0_ALPHA GL_OPERAND0_ALPHA GL_SRC1_RGB GL_OPERAND1_RGB GL_SRC1_ALPHA GL_OPERAND1_ALPHA GL_SRC2_RGB GL_OPERAND2_RGB GL_SRC2_ALPHA GL_OPERAND2_ALPHA +dependentvector params 4 pname GL_TEXTURE_ENV_COLOR +dependentvector params 1 pname GL_RGB_SCALE GL_ALPHA_SCALE +dependentvector params 1 pname GL_TEXTURE_ENV_MODE GL_COMBINE_RGB GL_COMBINE_ALPHA GL_SRC0_RGB GL_SRC1_RGB GL_SRC2_RGB GL_SRC0_ALPHA GL_SRC1_ALPHA GL_SRC2_ALPHA GL_OPERAND0_RGB GL_OPERAND1_RGB GL_OPERAND2_RGB GL_OPERAND0_ALPHA GL_OPERAND1_ALPHA GL_OPERAND2_ALPHA GL_COORD_REPLACE_OES +dependentnovalueconvert params pname GL_COORD_REPLACE_OES GL_TEXTURE_ENV_MODE GL_COMBINE_RGB GL_COMBINE_ALPHA GL_SRC0_RGB GL_OPERAND0_RGB GL_SRC0_ALPHA GL_OPERAND0_ALPHA GL_SRC1_RGB GL_OPERAND1_RGB GL_SRC1_ALPHA GL_OPERAND1_ALPHA GL_SRC2_RGB GL_OPERAND2_RGB GL_SRC2_ALPHA GL_OPERAND2_ALPHA +props get +category 1.0 GLES1.1 + +name GetTexEnviv +return void +param target GLenum +param pname GLenum +param params GLint * +props get +checkdependentparam target GL_POINT_SPRITE_OES pname GL_COORD_REPLACE_OES +checkdependentparam target GL_TEXTURE_ENV pname GL_TEXTURE_ENV_MODE GL_COMBINE_RGB GL_COMBINE_ALPHA GL_RGB_SCALE GL_ALPHA_SCALE GL_SRC0_RGB GL_OPERAND0_RGB GL_SRC0_ALPHA GL_OPERAND0_ALPHA GL_SRC1_RGB GL_OPERAND1_RGB GL_SRC1_ALPHA GL_OPERAND1_ALPHA GL_SRC2_RGB GL_OPERAND2_RGB GL_SRC2_ALPHA GL_OPERAND2_ALPHA +category 1.0 GLES1.1 +dependentvector params 4 pname GL_TEXTURE_ENV_COLOR +dependentvector params 1 pname GL_RGB_SCALE GL_ALPHA_SCALE +dependentvector params 1 pname GL_TEXTURE_ENV_MODE GL_COMBINE_RGB GL_COMBINE_ALPHA GL_SRC0_RGB GL_SRC1_RGB GL_SRC2_RGB GL_SRC0_ALPHA GL_SRC1_ALPHA GL_SRC2_ALPHA GL_OPERAND0_RGB GL_OPERAND1_RGB GL_OPERAND2_RGB GL_OPERAND0_ALPHA GL_OPERAND1_ALPHA GL_OPERAND2_ALPHA GL_COORD_REPLACE_OES +dependentnovalueconvert params pname GL_COORD_REPLACE_OES GL_TEXTURE_ENV_MODE GL_COMBINE_RGB GL_COMBINE_ALPHA GL_SRC0_RGB GL_OPERAND0_RGB GL_SRC0_ALPHA GL_OPERAND0_ALPHA GL_SRC1_RGB GL_OPERAND1_RGB GL_SRC1_ALPHA GL_OPERAND1_ALPHA GL_SRC2_RGB GL_OPERAND2_RGB GL_SRC2_ALPHA GL_OPERAND2_ALPHA + +name GetTexEnvxv +return void +param target GLenum +param pname GLenum +param params GLfixed * +checkdependentparam target GL_POINT_SPRITE_OES pname GL_COORD_REPLACE_OES +checkdependentparam target GL_TEXTURE_ENV pname GL_TEXTURE_ENV_MODE GL_TEXTURE_ENV_COLOR GL_COMBINE_RGB GL_COMBINE_ALPHA GL_RGB_SCALE GL_ALPHA_SCALE GL_SRC0_RGB GL_OPERAND0_RGB GL_SRC0_ALPHA GL_OPERAND0_ALPHA GL_SRC1_RGB GL_OPERAND1_RGB GL_SRC1_ALPHA GL_OPERAND1_ALPHA GL_SRC2_RGB GL_OPERAND2_RGB GL_SRC2_ALPHA GL_OPERAND2_ALPHA +dependentvector params 4 pname GL_TEXTURE_ENV_COLOR +dependentvector params 1 pname GL_RGB_SCALE GL_ALPHA_SCALE +dependentvector params 1 pname GL_TEXTURE_ENV_MODE GL_COMBINE_RGB GL_COMBINE_ALPHA GL_SRC0_RGB GL_SRC1_RGB GL_SRC2_RGB GL_SRC0_ALPHA GL_SRC1_ALPHA GL_SRC2_ALPHA GL_OPERAND0_RGB GL_OPERAND1_RGB GL_OPERAND2_RGB GL_OPERAND0_ALPHA GL_OPERAND1_ALPHA GL_OPERAND2_ALPHA GL_COORD_REPLACE_OES +dependentnovalueconvert params pname GL_COORD_REPLACE_OES GL_TEXTURE_ENV_MODE GL_COMBINE_RGB GL_COMBINE_ALPHA GL_SRC0_RGB GL_OPERAND0_RGB GL_SRC0_ALPHA GL_OPERAND0_ALPHA GL_SRC1_RGB GL_OPERAND1_RGB GL_SRC1_ALPHA GL_OPERAND1_ALPHA GL_SRC2_RGB GL_OPERAND2_RGB GL_SRC2_ALPHA GL_OPERAND2_ALPHA +convertalias GetTexEnvfv +convertparams GLfloat params +props get +category GLES1.1 GLES1.1:OES_fixed_point + +name GetTexGenfv +return void +param coord GLenum +checkparam coord GL_TEXTURE_GEN_STR_OES +param pname GLenum +param params GLfloat * +dependentvector params 1 pname GL_TEXTURE_GEN_MODE_OES +props get +category 1.0 GLES1.1:OES_texture_cube_map + +name GetTexGenxv +return void +param coord GLenum +checkparam coord GL_TEXTURE_GEN_STR_OES +param pname GLenum +param params GLfixed * +dependentvector params 1 pname GL_TEXTURE_GEN_MODE_OES +convertalias GetTexGenfv +convertparams GLfloat params +dependentnovalueconvert params pname GL_TEXTURE_GEN_MODE_OES +props get +category 1.0 GLES1.1:OES_texture_cube_map + +name GetTexGeniv +return void +param coord GLenum +checkparam coord GL_TEXTURE_GEN_STR_OES +param pname GLenum +param params GLint * +dependentvector params 1 pname GL_TEXTURE_GEN_MODE_OES +convertalias GetTexGenfv +convertparams GLfloat params +dependentnovalueconvert params pname GL_TEXTURE_GEN_MODE_OES +props get +category 1.0 GLES1.1:OES_texture_cube_map + +name GetTexParameterfv +return void +param target GLenum +checkparam target GL_TEXTURE_2D GLES2.0:GL_TEXTURE_CUBE_MAP +param pname GLenum +param params GLfloat * +dependentvector params 1 pname GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_TEXTURE_MIN_FILTER GL_TEXTURE_MAG_FILTER GLES1.1:GL_GENERATE_MIPMAP +props get +# OES_texture_cube_map +checkparam target GLES1.1:GL_TEXTURE_CUBE_MAP_OES +category GLES1.1 GLES2.0 + +name GetTexParameteriv +return void +param target GLenum +checkparam target GL_TEXTURE_2D GLES2.0:GL_TEXTURE_CUBE_MAP +param pname GLenum +param params GLint * +dependentvector params 1 pname GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_TEXTURE_MIN_FILTER GL_TEXTURE_MAG_FILTER GLES1.1:GL_GENERATE_MIPMAP +props get +# OES_texture_cube_map +checkparam target GLES1.1:GL_TEXTURE_CUBE_MAP_OES +# OES_texture_3D +checkparam target GLES2.0:GL_TEXTURE_3D_OES +category GLES1.1 GLES2.0 + +name GetTexParameterxv +return void +param target GLenum +checkparam target GL_TEXTURE_2D +param pname GLenum +param params GLfixed * +dependentvector params 1 pname GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_TEXTURE_MIN_FILTER GL_TEXTURE_MAG_FILTER GL_GENERATE_MIPMAP +convertalias GetTexParameterfv +convertparams GLfloat params +dependentnovalueconvert params pname GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_TEXTURE_MIN_FILTER GL_TEXTURE_MAG_FILTER GL_GENERATE_MIPMAP +props get +# OES_texture_cube_map +checkparam target GL_TEXTURE_CUBE_MAP_OES +category GLES1.1 GLES1.1:OES_fixed_point + +# GLES1.1 and GLES2.0 have different capabilities +name IsEnabled +return GLboolean +param cap GLenum +props get +checkparam cap GL_VERTEX_ARRAY GL_NORMAL_ARRAY GL_COLOR_ARRAY GL_TEXTURE_COORD_ARRAY GL_NORMALIZE GL_RESCALE_NORMAL GL_CLIP_PLANE0 GL_CLIP_PLANE1 GL_CLIP_PLANE2 GL_CLIP_PLANE3 GL_CLIP_PLANE4 GL_CLIP_PLANE5 GL_FOG GL_LIGHTING GL_COLOR_MATERIAL GL_LIGHT0 GL_LIGHT1 GL_LIGHT2 GL_LIGHT3 GL_LIGHT4 GL_LIGHT5 GL_LIGHT6 GL_LIGHT7 GL_POINT_SMOOTH GL_LINE_SMOOTH GL_CULL_FACE GL_POLYGON_OFFSET_FILL GL_MULTISAMPLE GL_SAMPLE_ALPHA_TO_COVERAGE GL_SAMPLE_ALPHA_TO_ONE GL_SAMPLE_COVERAGE GL_TEXTURE_2D GL_SCISSOR_TEST GL_ALPHA_TEST GL_STENCIL_TEST GL_DEPTH_TEST GL_BLEND GL_DITHER GL_COLOR_LOGIC_OP +# OES_matrix_palette +checkparam cap GL_MATRIX_INDEX_ARRAY_OES GL_WEIGHT_ARRAY_OES +# OES_point_size_array +checkparam cap GL_POINT_SIZE_ARRAY_OES +# OES_point_sprite +checkparam cap GL_POINT_SPRITE_OES +# OES_texture_cube_map +checkparam cap GL_TEXTURE_CUBE_MAP_OES GL_TEXTURE_GEN_STR_OES +category GLES1.1 + +name IsEnabled +return GLboolean +param cap GLenum +checkparam cap GL_CULL_FACE GL_SCISSOR_TEST GL_POLYGON_OFFSET_FILL GL_SAMPLE_ALPHA_TO_COVERAGE GL_SAMPLE_COVERAGE GL_STENCIL_TEST GL_DEPTH_TEST GL_DITHER GL_BLEND +props get +category GLES2.0 + + +name DepthRangef +return void +param zNear GLclampf +param zFar GLclampf +convertalias DepthRange +convertparams GLclampd zNear zFar +category GLES1.1 GLES1.1:OES_single_precision GLES2.0 + +name DepthRangex +return void +param zNear GLclampx +param zFar GLclampx +convertalias DepthRange +convertparams GLclampd zNear zFar +category GLES1.1 GLES1.1:OES_fixed_point + +name Frustumf +return void +param left GLfloat +param right GLfloat +param bottom GLfloat +param top GLfloat +param zNear GLfloat +param zFar GLfloat +convertalias Frustum +convertparams GLdouble left right bottom top zNear zFar +category GLES1.1 GLES1.1:OES_single_precision + +name Frustumx +return void +param left GLfixed +param right GLfixed +param bottom GLfixed +param top GLfixed +param zNear GLfixed +param zFar GLfixed +convertalias Frustum +convertparams GLdouble left right bottom top zNear zFar +category GLES1.1 GLES1.1:OES_fixed_point + +name LoadIdentity +return void +category 1.0 GLES1.1 + +name LoadMatrixf +return void +param m const GLfloat * +vector m 16 +category 1.0 GLES1.1 + +name LoadMatrixx +return void +param m const GLfixed * +vector m 16 +convertalias LoadMatrixf +convertparams GLfloat m +category GLES1.1 GLES1.1:OES_fixed_point + +name MatrixMode +return void +param mode GLenum +checkparam mode GL_MODELVIEW GL_PROJECTION GL_TEXTURE +# OES_matrix_palette +checkparam mode GL_MATRIX_PALETTE_OES +category 1.0 GLES1.1 + +name MultMatrixf +return void +param m const GLfloat * +vector m 16 +category 1.0 GLES1.1 + +name MultMatrixx +return void +param m const GLfixed * +vector m 16 +convertalias MultMatrixf +convertparams GLfloat m +category GLES1.1 GLES1.1:OES_fixed_point + +name Orthof +return void +param left GLfloat +param right GLfloat +param bottom GLfloat +param top GLfloat +param zNear GLfloat +param zFar GLfloat +convertalias Ortho +convertparams GLdouble left right bottom top zNear zFar +category GLES1.1 GLES1.1:OES_single_precision + +name Orthox +return void +param left GLfixed +param right GLfixed +param bottom GLfixed +param top GLfixed +param zNear GLfixed +param zFar GLfixed +convertalias Ortho +convertparams GLdouble left right bottom top zNear zFar +category GLES1.1 GLES1.1:OES_fixed_point + +name PopMatrix +return void +category GLES1.1 + +name PushMatrix +return void +category GLES1.1 + +name Rotatef +return void +param angle GLfloat +param x GLfloat +param y GLfloat +param z GLfloat +category 1.0 GLES1.1 + +name Rotatex +return void +param angle GLfixed +param x GLfixed +param y GLfixed +param z GLfixed +convertalias Rotatef +convertparams GLfloat angle x y z +category GLES1.1 GLES1.1:OES_fixed_point + +name Scalef +return void +param x GLfloat +param y GLfloat +param z GLfloat +category 1.0 GLES1.1 + +name Scalex +return void +param x GLfixed +param y GLfixed +param z GLfixed +convertalias Scalef +convertparams GLfloat x y z +category GLES1.1 GLES1.1:OES_fixed_point + +name Translatef +return void +param x GLfloat +param y GLfloat +param z GLfloat +category 1.0 GLES1.1 + +name Translatex +return void +param x GLfixed +param y GLfixed +param z GLfixed +convertalias Translatef +convertparams GLfloat x y z +category GLES1.1 GLES1.1:OES_fixed_point + +name Viewport +return void +param x GLint +param y GLint +param width GLsizei +param height GLsizei +category 1.0 GLES1.1 GLES2.0 + +name ColorPointer +return void +param size GLint +param type GLenum +param stride GLsizei +paramlist stride 0 +param pointer const GLvoid * +checkparam size /GL_INVALID_VALUE 4 +checkparam type GL_UNSIGNED_BYTE GL_FIXED GL_FLOAT +# OES_vertex_half_float: its values aren't in glext.h yet +#checkparam type GL_HALF_FLOAT_OES +category 1.1 GLES1.1 + +name DisableClientState +return void +param array GLenum +checkparam array GL_COLOR_ARRAY GL_NORMAL_ARRAY GL_TEXTURE_COORD_ARRAY GL_VERTEX_ARRAY +# OES_matrix_palette +checkparam array GL_MATRIX_INDEX_ARRAY_OES GL_WEIGHT_ARRAY_OES +# OES_point_size_array +checkparam array GL_POINT_SIZE_ARRAY_OES +category 1.1 GLES1.1 + +name DrawArrays +return void +param mode GLenum +checkparam mode GL_POINTS GL_LINE_STRIP GL_LINE_LOOP GL_LINES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_TRIANGLES +param first GLint +param count GLsizei +category 1.1 GLES1.1 GLES2.0 + +name DrawElements +return void +param mode GLenum +checkparam mode GL_POINTS GL_LINE_STRIP GL_LINE_LOOP GL_LINES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_TRIANGLES +param count GLsizei +param type GLenum +checkparam type GL_UNSIGNED_BYTE GL_UNSIGNED_SHORT +param indices const GLvoid * +# OES_element_index_uint - not in GLES1.1 extension headers yet +checkparam type GLES2.0:GL_UNSIGNED_INT +category 1.1 GLES1.1 GLES2.0 + +name EnableClientState +return void +param array GLenum +checkparam array GL_COLOR_ARRAY GL_NORMAL_ARRAY GL_TEXTURE_COORD_ARRAY GL_VERTEX_ARRAY +# OES_matrix_palette +checkparam array GL_MATRIX_INDEX_ARRAY_OES GL_WEIGHT_ARRAY_OES +# OES_point_size_array +checkparam array GL_POINT_SIZE_ARRAY_OES +category 1.1 GLES1.1 + +name GetPointerv +return void +param pname GLenum +checkparam pname GL_COLOR_ARRAY_POINTER GL_NORMAL_ARRAY_POINTER GL_TEXTURE_COORD_ARRAY_POINTER GL_VERTEX_ARRAY_POINTER +param params GLvoid ** +props get +# OES_matrix_palette +checkparam pname GL_MATRIX_INDEX_ARRAY_POINTER_OES GL_WEIGHT_ARRAY_POINTER_OES +# OES_point_size_array +checkparam pname GL_POINT_SIZE_ARRAY_POINTER_OES +category 1.1 GLES1.1 + +name Normal3f +aliasprefix _vbo_ +return void +param nx GLfloat +param ny GLfloat +param nz GLfloat +category GLES1.1 + +name Normal3x +aliasprefix _vbo_ +return void +param nx GLfixed +param ny GLfixed +param nz GLfixed +convertalias Normal3f +convertparams GLfloat nx ny nz +category GLES1.1 GLES1.1:OES_fixed_point + +name NormalPointer +return void +param type GLenum +checkparam type GL_BYTE GL_SHORT GL_FIXED GL_FLOAT +param stride GLsizei +param pointer const GLvoid * +# OES_vertex_half_float - not yet in glext.h +#checkparam type GL_HALF_FLOAT_OES +category 1.1 GLES1.1 + +name TexCoordPointer +return void +param size GLint +param type GLenum +param stride GLsizei +param pointer const GLvoid * +checkparam size /GL_INVALID_VALUE 2 3 4 +checkparam type GL_BYTE GL_SHORT GL_FIXED GL_FLOAT +# OES_vertex_half_float - not yet in glext.h +#checkparam type GL_HALF_FLOAT_OES +category 1.1 GLES1.1 + +name VertexPointer +return void +param size GLint +param type GLenum +param stride GLsizei +param pointer const GLvoid * +checkparam size /GL_INVALID_VALUE 2 3 4 +checkparam type GL_BYTE GL_SHORT GL_FIXED GL_FLOAT +# OES_vertex_half_float - not yet in glext.h +#checkparam type GL_HALF_FLOAT_OES +category 1.1 GLES1.1 + +name PolygonOffset +return void +param factor GLfloat +param units GLfloat +category 1.1 GLES1.1 GLES2.0 + +name PolygonOffsetx +return void +param factor GLfixed +param units GLfixed +convertalias PolygonOffset +convertparams GLfloat factor units +category GLES1.1 GLES1.1:OES_fixed_point + +name CopyTexImage2D +return void +param target GLenum +checkparam target GL_TEXTURE_2D GLES2.0:GL_TEXTURE_CUBE_MAP_POSITIVE_X GLES2.0:GL_TEXTURE_CUBE_MAP_POSITIVE_Y GLES2.0:GL_TEXTURE_CUBE_MAP_POSITIVE_Z GLES2.0:GL_TEXTURE_CUBE_MAP_NEGATIVE_X GLES2.0:GL_TEXTURE_CUBE_MAP_NEGATIVE_Y GLES2.0:GL_TEXTURE_CUBE_MAP_NEGATIVE_Z +param level GLint +param internalFormat GLenum +param x GLint +param y GLint +param width GLsizei +param height GLsizei +param border GLint +checkparam internalFormat /GL_INVALID_VALUE GL_ALPHA GL_LUMINANCE GL_LUMINANCE_ALPHA GL_RGB GL_RGBA +checkparam border /GL_INVALID_VALUE 0 +# OES_texture_cube_map +checkparam target GLES1.1:GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES GLES1.1:GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES GLES1.1:GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES GLES1.1:GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES GLES1.1:GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES GLES1.1:GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES +# OES_depth_texture +checkparam internalFormat GLES2.0:GL_DEPTH_COMPONENT +category GLES1.1 GLES2.0 + +name CopyTexSubImage2D +return void +param target GLenum +checkparam target GL_TEXTURE_2D GLES2.0:GL_TEXTURE_CUBE_MAP_POSITIVE_X GLES2.0:GL_TEXTURE_CUBE_MAP_POSITIVE_Y GLES2.0:GL_TEXTURE_CUBE_MAP_POSITIVE_Z GLES2.0:GL_TEXTURE_CUBE_MAP_NEGATIVE_X GLES2.0:GL_TEXTURE_CUBE_MAP_NEGATIVE_Y GLES2.0:GL_TEXTURE_CUBE_MAP_NEGATIVE_Z +param level GLint +param xoffset GLint +param yoffset GLint +param x GLint +param y GLint +param width GLsizei +param height GLsizei +# OES_texture_cube_map +checkparam target GLES1.1:GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES GLES1.1:GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES GLES1.1:GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES GLES1.1:GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES GLES1.1:GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES GLES1.1:GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES +category GLES1.1 GLES2.0 + +name TexSubImage2D +return void +param target GLenum +checkparam target GL_TEXTURE_2D GLES2.0:GL_TEXTURE_CUBE_MAP_POSITIVE_X GLES2.0:GL_TEXTURE_CUBE_MAP_POSITIVE_Y GLES2.0:GL_TEXTURE_CUBE_MAP_POSITIVE_Z GLES2.0:GL_TEXTURE_CUBE_MAP_NEGATIVE_X GLES2.0:GL_TEXTURE_CUBE_MAP_NEGATIVE_Y GLES2.0:GL_TEXTURE_CUBE_MAP_NEGATIVE_Z +checkparam target GL_TEXTURE_2D GLES2.0:GL_TEXTURE_CUBE_MAP +param level GLint +param xoffset GLint +param yoffset GLint +param width GLsizei +param height GLsizei +param format GLenum +param type GLenum +param pixels const GLvoid * +checkparam format /GL_INVALID_VALUE GL_ALPHA GL_LUMINANCE GL_LUMINANCE_ALPHA GL_RGB GL_RGBA +checkdependentparam format GL_RGBA type GL_UNSIGNED_BYTE GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_5_5_5_1 +checkdependentparam format GL_RGB type GL_UNSIGNED_BYTE GL_UNSIGNED_SHORT_5_6_5 +checkdependentparam format GL_LUMINANCE_ALPHA type GL_UNSIGNED_BYTE +checkdependentparam format GL_LUMINANCE type GL_UNSIGNED_BYTE +checkdependentparam format GL_ALPHA type GL_UNSIGNED_BYTE +# OES_texture_cube_map +checkparam target GLES1.1:GL_TEXTURE_CUBE_MAP_OES +checkparam target GLES1.1:GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES GLES1.1:GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES GLES1.1:GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES GLES1.1:GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES GLES1.1:GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES GLES1.1:GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES +# OES_texture_float +checkdependentparam format GL_ALPHA type GL_FLOAT +checkdependentparam format GL_RGB type GL_FLOAT +checkdependentparam format GL_RGBA type GL_FLOAT +checkdependentparam format GL_LUMINANCE type GL_FLOAT +checkdependentparam format GL_LUMINANCE_ALPHA type GL_FLOAT +# OES_texture_half_float +checkdependentparam format GL_ALPHA type GLES2.0:GL_HALF_FLOAT_OES +checkdependentparam format GL_RGB type GLES2.0:GL_HALF_FLOAT_OES +checkdependentparam format GL_RGBA type GLES2.0:GL_HALF_FLOAT_OES +checkdependentparam format GL_LUMINANCE type GLES2.0:GL_HALF_FLOAT_OES +checkdependentparam format GL_LUMINANCE_ALPHA type GLES2.0:GL_HALF_FLOAT_OES +# EXT_texture_type_2_10_10_10_REV +checkdependentparam format GL_RGBA type GLES2.0:GL_UNSIGNED_INT_2_10_10_10_REV_EXT +# OES_depth_texture +checkdependentparam format GL_DEPTH_COMPONENT type GLES2.0:GL_UNSIGNED_SHORT GLES2.0:GL_UNSIGNED_INT +category GLES1.1 GLES2.0 + +name BindTexture +return void +param target GLenum +checkparam target GL_TEXTURE_2D GLES2.0:GL_TEXTURE_CUBE_MAP +param texture GLuint +# OES_texture_cube_map +checkparam target GLES1.1:GL_TEXTURE_CUBE_MAP_OES +category GLES1.1 GLES2.0 + +name DeleteTextures +return void +param n GLsizei +param textures const GLuint * +category 1.1 GLES1.1 GLES2.0 + +name GenTextures +return void +param n GLsizei +param textures GLuint * +props get +category 1.1 GLES1.1 GLES2.0 + +name IsTexture +return GLboolean +param texture GLuint +props get +category 1.1 GLES1.1 GLES2.0 + +name BlendColor +return void +param red GLclampf +param green GLclampf +param blue GLclampf +param alpha GLclampf +category 1.2 GLES2.0 + +name BlendEquation +return void +param mode GLenum +checkparam mode GLES1.1:GL_FUNC_ADD_OES GLES1.1:GL_FUNC_SUBTRACT_OES GLES1.1:GL_FUNC_REVERSE_SUBTRACT_OES +checkparam mode GLES2.0:GL_FUNC_ADD GLES2.0:GL_FUNC_SUBTRACT GLES2.0:GL_FUNC_REVERSE_SUBTRACT +category GLES1.1:OES_blend_subtract GLES2.0 + +name BlendEquationSeparate +alias BlendEquationSeparateEXT +return void +param modeRGB GLenum +param modeAlpha GLenum +checkparam modeRGB GLES1.1:GL_FUNC_ADD_OES GLES1.1:GL_FUNC_SUBTRACT_OES GLES1.1:GL_FUNC_REVERSE_SUBTRACT_OES +checkparam modeAlpha GLES1.1:GL_FUNC_ADD_OES GLES1.1:GL_FUNC_SUBTRACT_OES GLES1.1:GL_FUNC_REVERSE_SUBTRACT_OES +checkparam modeRGB GLES1.1:GL_FUNC_ADD_OES GLES1.1:GL_FUNC_SUBTRACT_OES GLES1.1:GL_FUNC_REVERSE_SUBTRACT_OES +checkparam modeAlpha GLES1.1:GL_FUNC_ADD_OES GLES1.1:GL_FUNC_SUBTRACT_OES GLES1.1:GL_FUNC_REVERSE_SUBTRACT_OES +checkparam modeRGB GLES2.0:GL_FUNC_ADD GLES2.0:GL_FUNC_SUBTRACT GLES2.0:GL_FUNC_REVERSE_SUBTRACT +checkparam modeAlpha GLES2.0:GL_FUNC_ADD GLES2.0:GL_FUNC_SUBTRACT GLES2.0:GL_FUNC_REVERSE_SUBTRACT +checkparam modeRGB GLES2.0:GL_FUNC_ADD GLES2.0:GL_FUNC_SUBTRACT GLES2.0:GL_FUNC_REVERSE_SUBTRACT +checkparam modeAlpha GLES2.0:GL_FUNC_ADD GLES2.0:GL_FUNC_SUBTRACT GLES2.0:GL_FUNC_REVERSE_SUBTRACT +category GLES1.1:OES_blend_equation_separate GLES2.0 + +name TexImage3D +return void +param target GLenum +checkparam target GL_TEXTURE_3D_OES +param level GLint +param internalFormat GLenum +checkparam internalFormat GL_ALPHA GL_LUMINANCE GL_LUMINANCE_ALPHA GL_RGB GL_RGBA +param width GLsizei +param height GLsizei +param depth GLsizei +param border GLint +param format GLenum +param type GLenum +param pixels const GLvoid * +# OES_texture_float +checkparam type GL_FLOAT +# OES_texture_half_float +checkparam type GL_HALF_FLOAT_OES +category GLES2.0:OES_texture_3D + +name TexSubImage3D +return void +param target GLenum +param level GLint +param xoffset GLint +param yoffset GLint +param zoffset GLint +param width GLsizei +param height GLsizei +param depth GLsizei +param format GLenum +param type GLenum +param pixels const GLvoid * +# OES_texture_float +checkparam type GL_FLOAT +# OES_texture_half_float +checkparam type GL_HALF_FLOAT_OES +category GLES2.0:OES_texture_3D + +name CopyTexSubImage3D +return void +param target GLenum +checkparam target GL_TEXTURE_3D_OES +param level GLint +param xoffset GLint +param yoffset GLint +param zoffset GLint +param x GLint +param y GLint +param width GLsizei +param height GLsizei +category GLES2.0:OES_texture_3D + +name MultiTexCoord4x +return void +param texture GLenum +checkparam texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLfixed +param t GLfixed +param r GLfixed +param q GLfixed +aliasprefix _vbo_ +convertalias MultiTexCoord4f +convertparams GLfloat s t r q +category GLES1.1 GLES1.1:OES_fixed_point + +name CompressedTexImage3D +alias CompressedTexImage3DARB +return void +param target GLenum +checkparam target GL_TEXTURE_3D_OES +param level GLint +param internalFormat GLenum +checkparam internalFormat GL_ALPHA GL_LUMINANCE GL_LUMINANCE_ALPHA GL_RGB GL_RGBA +param width GLsizei +param height GLsizei +param depth GLsizei +param border GLint +param imagesize GLsizei +param data const GLvoid * +# AMD_compressed_3DC_texture +checkparam internalFormat GL_3DC_X_AMD GL_3DC_XY_AMD +# AMD_compressed_ATC_texture +checkparam internalFormat GL_ATC_RGB_AMD GL_ATC_RGBA_EXPLICIT_ALPHA_AMD GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD +category GLES2.0:OES_texture_3D + +name CompressedTexSubImage3D +alias CompressedTexSubImage3DARB +return void +param target GLenum +checkparam target GL_TEXTURE_3D_OES +param level GLint +param xoffset GLint +param yoffset GLint +param zoffset GLint +param width GLsizei +param height GLsizei +param depth GLsizei +param format GLenum +param imagesize GLsizei +param data const GLvoid * +category GLES2.0:OES_texture_3D + +name ActiveTexture +alias ActiveTextureARB +return void +param texture GLenum +checkparam texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +category 1.3 GLES1.1 GLES2.0 + +name ClientActiveTexture +alias ClientActiveTextureARB +return void +param texture GLenum +checkparam texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +category 1.3 GLES1.1 + +name MultiTexCoord4f +aliasprefix _vbo_ +return void +param texture GLenum +checkparam texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 GL_TEXTURE8 GL_TEXTURE9 GL_TEXTURE10 GL_TEXTURE11 GL_TEXTURE12 GL_TEXTURE13 GL_TEXTURE14 GL_TEXTURE15 GL_TEXTURE16 GL_TEXTURE17 GL_TEXTURE18 GL_TEXTURE19 GL_TEXTURE20 GL_TEXTURE21 GL_TEXTURE22 GL_TEXTURE23 GL_TEXTURE24 GL_TEXTURE25 GL_TEXTURE26 GL_TEXTURE27 GL_TEXTURE28 GL_TEXTURE29 GL_TEXTURE30 GL_TEXTURE31 +param s GLfloat +param t GLfloat +param r GLfloat +param q GLfloat +category 1.3 GLES1.1 + +name SampleCoverage +alias SampleCoverageARB +return void +param value GLclampf +param invert GLboolean +category 1.3 GLES1.1 GLES2.0 + +name SampleCoveragex +return void +param value GLclampx +param invert GLboolean +convertalias SampleCoverageARB +convertparams GLclampf value +category GLES1.1 GLES1.1:OES_fixed_point + +name CompressedTexImage2D +alias CompressedTexImage2DARB +return void +param target GLenum +param level GLint +param internalFormat GLenum +param width GLsizei +param height GLsizei +param border GLint +param imageSize GLsizei +param data const GLvoid * +checkparam target GL_TEXTURE_2D GLES2.0:GL_TEXTURE_CUBE_MAP_POSITIVE_X GLES2.0:GL_TEXTURE_CUBE_MAP_POSITIVE_Y GLES2.0:GL_TEXTURE_CUBE_MAP_POSITIVE_Z GLES2.0:GL_TEXTURE_CUBE_MAP_NEGATIVE_X GLES2.0:GL_TEXTURE_CUBE_MAP_NEGATIVE_Y GLES2.0:GL_TEXTURE_CUBE_MAP_NEGATIVE_Z +checkparam border /GL_INVALID_VALUE 0 +# OES_texture_cube_map +checkparam target GLES1.1:GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES GLES1.1:GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES GLES1.1:GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES GLES1.1:GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES GLES1.1:GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES GLES1.1:GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES +# OES_compressed_paletted_texture +checkparam internalFormat /GL_INVALID_VALUE GL_PALETTE4_RGB8_OES GL_PALETTE4_RGBA8_OES GL_PALETTE4_R5_G6_B5_OES GL_PALETTE4_RGBA4_OES GL_PALETTE4_RGB5_A1_OES GL_PALETTE8_RGB8_OES GL_PALETTE8_RGBA8_OES GL_PALETTE8_R5_G6_B5_OES GL_PALETTE8_RGBA4_OES GL_PALETTE8_RGB5_A1_OES +# OES_compressed_ETC1_RGB8_texture +checkparam internalFormat GL_ETC1_RGB8_OES +# AMD_compressed_3DC_texture +checkparam internalFormat GL_3DC_X_AMD GL_3DC_XY_AMD +# AMD_compressed_ATC_texture (GLES2.0 only?) +checkparam internalFormat GL_ATC_RGB_AMD GL_ATC_RGBA_EXPLICIT_ALPHA_AMD GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD +category GLES1.1 GLES2.0 + +name CompressedTexSubImage2D +alias CompressedTexSubImage2DARB +return void +param target GLenum +param level GLint +param xoffset GLint +param yoffset GLint +param width GLsizei +param height GLsizei +param format GLenum +param imageSize GLsizei +param data const GLvoid * +checkparam target GL_TEXTURE_2D GLES2.0:GL_TEXTURE_CUBE_MAP_POSITIVE_X GLES2.0:GL_TEXTURE_CUBE_MAP_POSITIVE_Y GLES2.0:GL_TEXTURE_CUBE_MAP_POSITIVE_Z GLES2.0:GL_TEXTURE_CUBE_MAP_NEGATIVE_X GLES2.0:GL_TEXTURE_CUBE_MAP_NEGATIVE_Y GLES2.0:GL_TEXTURE_CUBE_MAP_NEGATIVE_Z +checkparam format GL_PALETTE4_RGB8_OES GL_PALETTE4_RGBA8_OES GL_PALETTE4_R5_G6_B5_OES GL_PALETTE4_RGBA4_OES GL_PALETTE4_RGB5_A1_OES GL_PALETTE8_RGB8_OES GL_PALETTE8_RGBA8_OES GL_PALETTE8_R5_G6_B5_OES GL_PALETTE8_RGBA4_OES GL_PALETTE8_RGB5_A1_OES +# OES_texture_cube_map +checkparam target GLES1.1:GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES GLES1.1:GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES GLES1.1:GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES GLES1.1:GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES GLES1.1:GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES GLES1.1:GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES +category GLES1.1 GLES2.0 + +name BlendFuncSeparate +alias BlendFuncSeparateEXT +return void +param srcRGB GLenum +param dstRGB GLenum +param srcAlpha GLenum +param dstAlpha GLenum +checkparam srcRGB GL_ZERO GL_ONE GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_DST_COLOR GL_ONE_MINUS_DST_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_DST_ALPHA GL_ONE_MINUS_DST_ALPHA GL_SRC_ALPHA_SATURATE GLES2.0:GL_CONSTANT_COLOR GLES2.0:GL_ONE_MINUS_CONSTANT_COLOR GLES2.0:GL_CONSTANT_ALPHA GLES2.0:GL_ONE_MINUS_CONSTANT_ALPHA +checkparam dstRGB GL_ZERO GL_ONE GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_DST_COLOR GL_ONE_MINUS_DST_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_DST_ALPHA GL_ONE_MINUS_DST_ALPHA GLES2.0:GL_CONSTANT_COLOR GLES2.0:GL_ONE_MINUS_CONSTANT_COLOR GLES2.0:GL_CONSTANT_ALPHA GLES2.0:GL_ONE_MINUS_CONSTANT_ALPHA +checkparam srcAlpha GL_ZERO GL_ONE GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_DST_COLOR GL_ONE_MINUS_DST_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_DST_ALPHA GL_ONE_MINUS_DST_ALPHA GL_SRC_ALPHA_SATURATE GLES2.0:GL_CONSTANT_COLOR GLES2.0:GL_ONE_MINUS_CONSTANT_COLOR GLES2.0:GL_CONSTANT_ALPHA GLES2.0:GL_ONE_MINUS_CONSTANT_ALPHA +checkparam dstAlpha GL_ZERO GL_ONE GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_DST_COLOR GL_ONE_MINUS_DST_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_DST_ALPHA GL_ONE_MINUS_DST_ALPHA GLES2.0:GL_CONSTANT_COLOR GLES2.0:GL_ONE_MINUS_CONSTANT_COLOR GLES2.0:GL_CONSTANT_ALPHA GLES2.0:GL_ONE_MINUS_CONSTANT_ALPHA +category GLES1.1:OES_blend_func_separate GLES2.0 + +name PointParameterf +return void +param pname GLenum +checkparam pname GL_POINT_SIZE_MIN GL_POINT_SIZE_MAX GL_POINT_FADE_THRESHOLD_SIZE +param param GLfloat +category 1.4 GLES1.1 + +name PointParameterfv +return void +param pname GLenum +checkparam pname GL_POINT_SIZE_MIN GL_POINT_SIZE_MAX GL_POINT_FADE_THRESHOLD_SIZE GL_POINT_DISTANCE_ATTENUATION +param params const GLfloat * +dependentvector params 1 pname GL_POINT_SIZE_MIN GL_POINT_SIZE_MAX GL_POINT_FADE_THRESHOLD_SIZE +dependentvector params 3 pname GL_POINT_DISTANCE_ATTENUATION +category 1.4 GLES1.1 + +name PointParameterx +return void +param pname GLenum +checkparam pname GL_POINT_SIZE_MIN GL_POINT_SIZE_MAX GL_POINT_FADE_THRESHOLD_SIZE +param param GLfixed +convertalias PointParameterf +convertparams GLfloat param +category GLES1.1 GLES1.1:OES_fixed_point + +name PointParameterxv +return void +param pname GLenum +checkparam pname GL_POINT_SIZE_MIN GL_POINT_SIZE_MAX GL_POINT_FADE_THRESHOLD_SIZE GL_POINT_DISTANCE_ATTENUATION +param params const GLfixed * +dependentvector params 1 pname GL_POINT_SIZE_MIN GL_POINT_SIZE_MAX GL_POINT_FADE_THRESHOLD_SIZE +dependentvector params 3 pname GL_POINT_DISTANCE_ATTENUATION +convertalias PointParameterfv +convertparams GLfloat params +category GLES1.1 GLES1.1:OES_fixed_point + +name VertexAttrib1f +aliasprefix _vbo_ +return void +param index GLuint +param x GLfloat +category GLES2.0 + +name VertexAttrib2f +aliasprefix _vbo_ +return void +param index GLuint +param x GLfloat +param y GLfloat +category GLES2.0 + +name VertexAttrib3f +aliasprefix _vbo_ +return void +param index GLuint +param x GLfloat +param y GLfloat +param z GLfloat +category GLES2.0 + +name VertexAttrib4f +aliasprefix _vbo_ +return void +param index GLuint +param x GLfloat +param y GLfloat +param z GLfloat +param w GLfloat +category GLES2.0 + +name VertexAttrib1fv +aliasprefix _vbo_ +return void +param index GLuint +param v const GLfloat * +vector v 1 +category GLES2.0 + +name VertexAttrib2fv +aliasprefix _vbo_ +return void +param index GLuint +param v const GLfloat * +vector v 2 +category GLES2.0 + +name VertexAttrib3fv +aliasprefix _vbo_ +return void +param index GLuint +param v const GLfloat * +vector v 3 +category GLES2.0 + +name VertexAttrib4fv +aliasprefix _vbo_ +return void +param index GLuint +param v const GLfloat * +vector v 4 +category GLES2.0 + +name VertexAttribPointer +alias VertexAttribPointerARB +return void +param index GLuint +param size GLint +checkparam size /GL_INVALID_VALUE 1 2 3 4 +param type GLenum +checkparam type /GL_INVALID_VALUE GL_BYTE GL_UNSIGNED_BYTE GL_SHORT GL_UNSIGNED_SHORT GL_FIXED GL_FLOAT +param normalized GLboolean +param stride GLsizei +param pointer const GLvoid * +# OES_vertex_half_float +checkparam type GL_HALF_FLOAT_OES +# OES_vertex_type_10_10_10_2 +checkdependentparam type GL_UNSIGNED_INT_10_10_10_2_OES size /GL_INVALID_VALUE 3 4 +checkdependentparam type GL_INT_10_10_10_2_OES size /GL_INVALID_VALUE 3 4 +category GLES2.0 + +name EnableVertexAttribArray +alias EnableVertexAttribArrayARB +return void +param index GLuint +category GLES2.0 + +name DisableVertexAttribArray +alias DisableVertexAttribArrayARB +return void +param index GLuint +category GLES2.0 + +name IsProgram +return GLboolean +param program GLuint +props get +category GLES2.0 + +name GetProgramiv +return void +param program GLuint +param pname GLenum +checkparam pname GL_DELETE_STATUS GL_LINK_STATUS GL_VALIDATE_STATUS GL_INFO_LOG_LENGTH GL_ATTACHED_SHADERS GL_ACTIVE_ATTRIBUTES GL_ACTIVE_ATTRIBUTE_MAX_LENGTH GL_ACTIVE_UNIFORMS GL_ACTIVE_UNIFORM_MAX_LENGTH +param params GLint * +props get +# OES_get_program_binary +checkparam pname GL_PROGRAM_BINARY_LENGTH_OES +category GLES2.0 + +name GetVertexAttribfv +alias GetVertexAttribfvARB +return void +param index GLuint +param pname GLenum +param params GLfloat * +dependentvector params 1 pname GL_VERTEX_ATTRIB_ARRAY_ENABLED GL_VERTEX_ATTRIB_ARRAY_SIZE GL_VERTEX_ATTRIB_ARRAY_STRIDE GL_VERTEX_ATTRIB_ARRAY_TYPE GL_VERTEX_ATTRIB_ARRAY_NORMALIZED GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING +dependentvector params 16? pname GL_CURRENT_VERTEX_ATTRIB +props get +category GLES2.0 + +name GetVertexAttribiv +alias GetVertexAttribivARB +return void +param index GLuint +param pname GLenum +param params GLint * +dependentvector params 1 pname GL_VERTEX_ATTRIB_ARRAY_ENABLED GL_VERTEX_ATTRIB_ARRAY_SIZE GL_VERTEX_ATTRIB_ARRAY_STRIDE GL_VERTEX_ATTRIB_ARRAY_TYPE GL_VERTEX_ATTRIB_ARRAY_NORMALIZED GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING GL_CURRENT_VERTEX_ATTRIB +props get +category GLES2.0 + +name GetVertexAttribPointerv +alias GetVertexAttribPointervARB +return void +param index GLuint +param pname GLenum +checkparam pname GL_VERTEX_ATTRIB_ARRAY_POINTER +param pointer GLvoid ** +props get +category GLES2.0 + +name GetBufferPointerv +alias GetBufferPointervARB +return void +param target GLenum +checkparam target GL_ARRAY_BUFFER GL_ELEMENT_ARRAY_BUFFER +param pname GLenum +checkparam pname GL_BUFFER_MAP_POINTER_OES +param params GLvoid ** +props get +category GLES1.1:OES_mapbuffer GLES2.0:OES_mapbuffer + +name MapBuffer +alias MapBufferARB +return void * +param target GLenum +checkparam target GL_ARRAY_BUFFER GL_ELEMENT_ARRAY_BUFFER +param access GLenum +checkparam access GL_WRITE_ONLY_OES +props get +category GLES1.1:OES_mapbuffer GLES2.0:OES_mapbuffer + +name UnmapBuffer +alias UnmapBufferARB +return GLboolean +param target GLenum +checkparam target GL_ARRAY_BUFFER GL_ELEMENT_ARRAY_BUFFER +props get +category GLES1.1:OES_mapbuffer GLES2.0:OES_mapbuffer + +name BindBuffer +alias BindBufferARB +return void +param target GLenum +checkparam target GL_ARRAY_BUFFER GL_ELEMENT_ARRAY_BUFFER +param buffer GLuint +category 1.5 GLES1.1 GLES2.0 + +name BufferData +alias BufferDataARB +return void +param target GLenum +checkparam target GL_ARRAY_BUFFER GL_ELEMENT_ARRAY_BUFFER +param size GLsizeiptr +param data const GLvoid * +param usage GLenum +checkparam usage GL_STATIC_DRAW GL_DYNAMIC_DRAW GLES2.0:GL_STREAM_DRAW +category GLES1.1 GLES2.0 + +name BufferSubData +alias BufferSubDataARB +return void +param target GLenum +checkparam target GL_ARRAY_BUFFER GL_ELEMENT_ARRAY_BUFFER +param offset GLintptr +param size GLsizeiptr +param data const GLvoid * +category 1.5 GLES1.1 GLES2.0 + +name DeleteBuffers +return void +param n GLsizei +param buffer const GLuint * +category 1.5 GLES1.1 GLES2.0 +alias DeleteBuffersARB + +name GenBuffers +alias GenBuffersARB +return void +param n GLsizei +param buffer GLuint * +props get +category 1.5 GLES1.1 GLES2.0 + +name GetBufferParameteriv +alias GetBufferParameterivARB +return void +param target GLenum +checkparam target GL_ARRAY_BUFFER GL_ELEMENT_ARRAY_BUFFER +param pname GLenum +checkparam pname GL_BUFFER_SIZE GL_BUFFER_USAGE +param params GLint * +props get +# OES_mapbuffer +checkparam pname GL_BUFFER_ACCESS_OES GL_BUFFER_MAPPED_OES +category 1.5 GLES1.1 GLES2.0 + +name IsBuffer +alias IsBufferARB +return GLboolean +param buffer GLuint +paramlist buffer 0 +props get +category 1.5 GLES1.1 GLES2.0 + +name CreateShader +return GLuint +param type GLenum +checkparam type GL_VERTEX_SHADER GL_FRAGMENT_SHADER +category GLES2.0 + +name ShaderSource +alias ShaderSourceARB +return void +param shader GLuint +param count GLsizei +param string const GLchar ** +param length const int * +category GLES2.0 + +name CompileShader +alias CompileShaderARB +return void +param shader GLuint +category GLES2.0 + +name ReleaseShaderCompiler +return void +category GLES2.0 + +name DeleteShader +return void +param shader GLuint +category GLES2.0 + +name ShaderBinary +return void +param n GLsizei +param shaders const GLuint * +param binaryformat GLenum +param binary const GLvoid * +param length GLsizei +category GLES2.0 + +name CreateProgram +return GLuint +category GLES2.0 + +name AttachShader +return void +param program GLuint +param shader GLuint +category GLES2.0 + +name DetachShader +return void +param program GLuint +param shader GLuint +category GLES2.0 + +name LinkProgram +alias LinkProgramARB +return void +param program GLuint +category GLES2.0 + +name UseProgram +alias UseProgramObjectARB +return void +param program GLuint +category GLES2.0 + +name DeleteProgram +return void +param program GLuint +category GLES2.0 + +name GetActiveAttrib +alias GetActiveAttribARB +return void +param program GLuint +param index GLuint +param bufSize GLsizei +param length GLsizei * +param size GLint * +param type GLenum * +param name GLchar * +props get +category GLES2.0 + +name GetAttribLocation +alias GetAttribLocationARB +return GLint +param program GLuint +param name const char * +props get +category GLES2.0 + +name BindAttribLocation +alias BindAttribLocationARB +return void +param program GLuint +param index GLuint +param name const char * +category GLES2.0 + +name GetUniformLocation +alias GetUniformLocationARB +return GLint +param program GLuint +param name const char * +props get +category GLES2.0 + +name GetActiveUniform +alias GetActiveUniformARB +return void +param program GLuint +param index GLuint +param bufSize GLsizei +param length GLsizei * +param size GLint * +param type GLenum * +param name GLchar * +props get +category GLES2.0 + +name Uniform1f +alias Uniform1fARB +return void +param location GLint +param v0 GLfloat +category GLES2.0 + +name Uniform2f +alias Uniform2fARB +return void +return void +param location GLint +param v0 GLfloat +param v1 GLfloat +category GLES2.0 + +name Uniform3f +alias Uniform3fARB +return void +return void +param location GLint +param v0 GLfloat +param v1 GLfloat +param v2 GLfloat +category GLES2.0 + +name Uniform4f +alias Uniform4fARB +return void +return void +param location GLint +param v0 GLfloat +param v1 GLfloat +param v2 GLfloat +param v3 GLfloat +category GLES2.0 + +name Uniform1i +alias Uniform1iARB +return void +param location GLint +param v0 GLint +category GLES2.0 + +name Uniform2i +alias Uniform2iARB +return void +param location GLint +param v0 GLint +param v1 GLint +category GLES2.0 + +name Uniform3i +alias Uniform3iARB +return void +param location GLint +param v0 GLint +param v1 GLint +param v2 GLint +category GLES2.0 + +name Uniform4i +alias Uniform4iARB +return void +param location GLint +param v0 GLint +param v1 GLint +param v2 GLint +param v3 GLint +category GLES2.0 + +name Uniform1fv +alias Uniform1fvARB +return void +param location GLint +param count GLsizei +param values const GLfloat * +category GLES2.0 + +name Uniform2fv +alias Uniform2fvARB +return void +param location GLint +param count GLsizei +param values const GLfloat * +category GLES2.0 + +name Uniform3fv +alias Uniform3fvARB +return void +param location GLint +param count GLsizei +param values const GLfloat * +category GLES2.0 + +name Uniform4fv +alias Uniform4fvARB +return void +param location GLint +param count GLsizei +param values const GLfloat * +category GLES2.0 + +name Uniform1iv +alias Uniform1ivARB +return void +param location GLint +param count GLsizei +param values const GLint * +category GLES2.0 + +name Uniform2iv +alias Uniform2ivARB +return void +param location GLint +param count GLsizei +param values const GLint * +category GLES2.0 + +name Uniform3iv +alias Uniform3ivARB +return void +param location GLint +param count GLsizei +param values const GLint * +category GLES2.0 + +name Uniform4iv +alias Uniform4ivARB +return void +param location GLint +param count GLsizei +param values const GLint * +category GLES2.0 + +name UniformMatrix2fv +alias UniformMatrix2fvARB +return void +param location GLint +param count GLsizei +param transpose GLboolean +param value const GLfloat * +category GLES2.0 + +name UniformMatrix3fv +alias UniformMatrix3fvARB +return void +param location GLint +param count GLsizei +param transpose GLboolean +param value const GLfloat * +category GLES2.0 + +name UniformMatrix4fv +alias UniformMatrix4fvARB +return void +param location GLint +param count GLsizei +param transpose GLboolean +param value const GLfloat * +category GLES2.0 + +name ValidateProgram +alias ValidateProgramARB +return void +param program GLuint +category GLES2.0 + +name GenerateMipmap +alias GenerateMipmapEXT +return void +param target GLenum +checkparam target GL_TEXTURE_2D GLES2.0:GL_TEXTURE_CUBE_MAP +# OES_texture_cube_map +checkparam target GLES1.1:GL_TEXTURE_CUBE_MAP_OES +category GLES1.1:OES_framebuffer_object GLES2.0 + + +name BindFramebuffer +alias BindFramebufferEXT +return void +param target GLenum +checkparam target GLES1.1:GL_FRAMEBUFFER_OES GLES2.0:GL_FRAMEBUFFER +param framebuffer GLuint +category GLES1.1:OES_framebuffer_object GLES2.0 + +name DeleteFramebuffers +alias DeleteFramebuffersEXT +return void +param n GLsizei +param framebuffers const GLuint * +category GLES2.0 GLES1.1:OES_framebuffer_object + +name GenFramebuffers +alias GenFramebuffersEXT +return void +param n GLsizei +param ids GLuint * +category GLES2.0 GLES1.1:OES_framebuffer_object + +name BindRenderbuffer +alias BindRenderbufferEXT +return void +param target GLenum +checkparam target GLES1.1:GL_RENDERBUFFER_OES GLES2.0:GL_RENDERBUFFER +param renderbuffer GLuint +category GLES1.1:OES_framebuffer_object GLES2.0 + +name DeleteRenderbuffers +alias DeleteRenderbuffersEXT +return void +param n GLsizei +param renderbuffers const GLuint * +category GLES2.0 GLES1.1:OES_framebuffer_object + +name GenRenderbuffers +alias GenRenderbuffersEXT +return void +param n GLsizei +param renderbuffers GLuint * +category GLES2.0 GLES1.1:OES_framebuffer_object + +name RenderbufferStorage +alias RenderbufferStorageEXT +return void +param target GLenum +checkparam target GLES1.1:GL_RENDERBUFFER_OES GLES2.0:GL_RENDERBUFFER +param internalFormat GLenum +checkparam internalFormat GL_DEPTH_COMPONENT16_OES GL_RGBA4_OES GL_RGB5_A1_OES GL_RGB565_OES +param width GLsizei +param height GLsizei +# OES_depth24 +checkparam internalFormat GL_DEPTH_COMPONENT24_OES +# OES_depth32 +checkparam internalFormat GL_DEPTH_COMPONENT32_OES +# OES_rgb8_rgba8 +checkparam internalFormat GL_RGB8_OES GL_RGBA8_OES +# OES_stencil1 +checkparam internalFormat GL_STENCIL_INDEX1_OES +# OES_stencil4 +checkparam internalFormat GL_STENCIL_INDEX4_OES +# OES_stencil8 +checkparam internalFormat GL_STENCIL_INDEX8_OES +# OES_packed_depth_stencil - not in glext.h yet +checkparam internalFormat GLES2.0:GL_DEPTH24_STENCIL8_OES +category GLES1.1:OES_framebuffer_object GLES2.0 + +name FramebufferRenderbuffer +alias FramebufferRenderbufferEXT +return void +param target GLenum +checkparam target GLES1.1:GL_FRAMEBUFFER_OES GLES2.0:GL_FRAMEBUFFER +param attachment GLenum +checkparam attachment GLES1.1:GL_COLOR_ATTACHMENT0_OES GLES1.1:GL_DEPTH_ATTACHMENT_OES GLES1.1:GL_STENCIL_ATTACHMENT_OES +checkparam attachment GLES2.0:GL_COLOR_ATTACHMENT0 GLES2.0:GL_DEPTH_ATTACHMENT GLES2.0:GL_STENCIL_ATTACHMENT +param renderbuffertarget GLenum +checkparam renderbuffertarget GLES1.1:GL_RENDERBUFFER_OES GLES2.0:GL_RENDERBUFFER +param renderbuffer GLuint +category GLES1.1:OES_framebuffer_object GLES2.0 + +name FramebufferTexture2D +alias FramebufferTexture2DEXT +return void +param target GLenum +checkparam target GLES1.1:GL_FRAMEBUFFER_OES GLES2.0:GL_FRAMEBUFFER +param attachment GLenum +checkparam attachment GLES1.1:GL_COLOR_ATTACHMENT0_OES GLES1.1:GL_DEPTH_ATTACHMENT_OES GLES1.1:GL_STENCIL_ATTACHMENT_OES +checkparam attachment GLES2.0:GL_COLOR_ATTACHMENT0 GLES2.0:GL_DEPTH_ATTACHMENT GLES2.0:GL_STENCIL_ATTACHMENT +param textarget GLenum +checkparam textarget /GL_INVALID_OPERATION GL_TEXTURE_2D GLES2.0:GL_TEXTURE_CUBE_MAP_POSITIVE_X GLES2.0:GL_TEXTURE_CUBE_MAP_POSITIVE_Y GLES2.0:GL_TEXTURE_CUBE_MAP_POSITIVE_Z GLES2.0:GL_TEXTURE_CUBE_MAP_NEGATIVE_X GLES2.0:GL_TEXTURE_CUBE_MAP_NEGATIVE_Y GLES2.0:GL_TEXTURE_CUBE_MAP_NEGATIVE_Z +param texture GLuint +param level GLint +# OES_texture_cube_map +checkparam textarget GLES1.1:GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES GLES1.1:GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES GLES1.1:GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES GLES1.1:GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES GLES1.1:GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES GLES1.1:GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES +# According to the base specification, "level" must be 0. But +# extension GL_OES_fbo_render_mipmap lifts that restriction, +# so no restriction is placed here. +category GLES1.1:OES_framebuffer_object GLES2.0 + +name FramebufferTexture3D +alias FramebufferTexture3DEXT +return void +param target GLenum +param attachment GLenum +param textarget GLenum +param texture GLuint +param level GLint +param zoffset GLint +category GLES2.0:OES_texture_3D + +name CheckFramebufferStatus +alias CheckFramebufferStatusEXT +return GLenum +param target GLenum +checkparam target GLES1.1:GL_FRAMEBUFFER_OES GLES2.0:GL_FRAMEBUFFER +props get +category GLES1.1:OES_framebuffer_object GLES2.0 + +# One for GLES1.1 extension, one for GLES2.0 core +name GetFramebufferAttachmentParameteriv +alias GetFramebufferAttachmentParameterivEXT +return void +param target GLenum +checkparam target GLES1.1:GL_FRAMEBUFFER_OES GLES2.0:GL_FRAMEBUFFER +param attachment GLenum +param pname GLenum +param params GLint * +props get +dependentvector params 1 pname GLES1.1:GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES GLES1.1:GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES GLES1.1:GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES GLES1.1:GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES +dependentvector params 1 pname GLES2.0:GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE GLES2.0:GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME GLES2.0:GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL GLES2.0:GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE +# OES_texture3D +dependentvector params 1 pname GLES2.0:GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES +category GLES1.1:OES_framebuffer_object GLES2.0 + +name GetRenderbufferParameteriv +alias GetRenderbufferParameterivEXT +return void +param target GLenum +checkparam target GLES1.1:GL_RENDERBUFFER_OES GLES2.0:GL_RENDERBUFFER +param pname GLenum +param params GLint * +props get +dependentvector params 1 pname GLES1.1:GL_RENDERBUFFER_WIDTH_OES GLES1.1:GL_RENDERBUFFER_HEIGHT_OES GLES1.1:GL_RENDERBUFFER_INTERNAL_FORMAT_OES GLES1.1:GL_RENDERBUFFER_RED_SIZE_OES GLES1.1:GL_RENDERBUFFER_GREEN_SIZE_OES GLES1.1:GL_RENDERBUFFER_BLUE_SIZE_OES GLES1.1:GL_RENDERBUFFER_ALPHA_SIZE_OES GLES1.1:GL_RENDERBUFFER_DEPTH_SIZE_OES GLES1.1:GL_RENDERBUFFER_STENCIL_SIZE_OES +dependentvector params 1 pname GLES2.0:GL_RENDERBUFFER_WIDTH GLES2.0:GL_RENDERBUFFER_HEIGHT GLES2.0:GL_RENDERBUFFER_INTERNAL_FORMAT GLES2.0:GL_RENDERBUFFER_RED_SIZE GLES2.0:GL_RENDERBUFFER_GREEN_SIZE GLES2.0:GL_RENDERBUFFER_BLUE_SIZE GLES2.0:GL_RENDERBUFFER_ALPHA_SIZE GLES2.0:GL_RENDERBUFFER_DEPTH_SIZE GLES2.0:GL_RENDERBUFFER_STENCIL_SIZE +category GLES1.1:OES_framebuffer_object GLES2.0 + +name IsRenderbuffer +alias IsRenderbufferEXT +return GLboolean +param renderbuffer GLuint +props get +category GLES2.0 GLES1.1:OES_framebuffer_object + +name IsFramebuffer +alias IsFramebufferEXT +return GLboolean +param framebuffer GLuint +props get +category GLES2.0 GLES1.1:OES_framebuffer_object + +name IsShader +return GLboolean +param shader GLuint +props get +category GLES2.0 + +name GetShaderiv +return void +param shader GLuint +param pname GLenum +param params GLint * +props get +checkparam pname GL_SHADER_TYPE GL_COMPILE_STATUS GL_DELETE_STATUS GL_INFO_LOG_LENGTH GL_SHADER_SOURCE_LENGTH +category GLES2.0 + +name GetAttachedShaders +return void +param program GLuint +param maxCount GLsizei +param count GLsizei * +param shaders GLuint * +props get +category GLES2.0 + +name GetShaderInfoLog +return void +param shader GLuint +param bufSize GLsizei +param length GLsizei * +param infoLog GLchar * +props get +category GLES2.0 + +name GetProgramInfoLog +return void +param program GLuint +param bufSize GLsizei +param length GLsizei * +param infoLog GLchar * +props get +category GLES2.0 + +name GetShaderSource +alias GetShaderSourceARB +return void +param shader GLuint +param bufSize GLsizei +param length GLsizei * +param source GLchar * +props get +category GLES2.0 + +name GetShaderPrecisionFormat +return void +param shadertype GLenum +param precisiontype GLenum +param range GLint * +param precision GLint * +props get +checkparam shadertype GL_VERTEX_SHADER GL_FRAGMENT_SHADER +checkparam precisiontype GL_LOW_FLOAT GL_MEDIUM_FLOAT GL_HIGH_FLOAT GL_LOW_INT GL_MEDIUM_INT GL_HIGH_INT +category GLES2.0 + +name GetUniformfv +alias GetUniformfvARB +return void +param program GLuint +param location GLint +param params GLfloat * +props get +category GLES2.0 + +name GetUniformiv +alias GetUniformivARB +return void +param program GLuint +param location GLint +param params GLint * +props get +category GLES2.0 + +name QueryMatrixx +return GLbitfield +param mantissa GLfixed * +vector mantissa 16 +param exponent GLint * +vector exponent 16 +props get +category GLES1.1:OES_query_matrix + +# We don't support OES_get_program_binary yet either +#name GetProgramBinary +#return void +#param program GLuint +#param bufSize GLsizei +#param length GLsizei * +#param binaryFormat GLenum * +#param binary GLvoid * +#category GLES2.0:OES_get_program_binary +# +#name ProgramBinary +#return void +#param program GLuint +#param binaryFormat GLenum +#param binary const GLvoid * +#param length GLint +#category GLES2.0:OES_get_program_binary diff --git a/src/mesa/es/main/apiutil.py b/src/mesa/es/main/apiutil.py new file mode 100644 index 0000000000..7fb1afc3a8 --- /dev/null +++ b/src/mesa/es/main/apiutil.py @@ -0,0 +1,1117 @@ + +# apiutil.py +# +# This file defines a bunch of utility functions for OpenGL API code +# generation. + +import sys, string, re + + +#====================================================================== + +def CopyrightC( ): + print """/* Copyright (c) 2001, Stanford University + All rights reserved. + + See the file LICENSE.txt for information on redistributing this software. */ + """ + +def CopyrightDef( ): + print """; Copyright (c) 2001, Stanford University + ; All rights reserved. + ; + ; See the file LICENSE.txt for information on redistributing this software. + """ + + +#====================================================================== + +class APIFunction: + """Class to represent a GL API function (name, return type, + parameters, etc).""" + def __init__(self): + self.name = '' + self.returnType = '' + self.category = '' + self.categories = [] + self.offset = -1 + self.alias = '' + self.vectoralias = '' + self.convertalias = '' + self.aliasprefix = '' + self.params = [] + self.paramlist = [] + self.paramvec = [] + self.paramaction = [] + self.paramprop = [] + self.paramset = [] + self.props = [] + self.chromium = [] + +def FindParamIndex(params, paramName): + """Given a function record, find the index of a named parameter""" + for i in range (len(params)): + if paramName == params[i][0]: + return i + # If we get here, there was no such parameter + return None + +def SetTupleIndex(tuple, index, value): + t = () + for i in range(len(tuple)): + if i == index: + t += (value,) + else: + t += (tuple[i],) + return t + +def VersionSpecificValues(category, values): + selectedValues = [] + for value in values: + # Version-specific values are prefixed with the version + # number, e.g. GLES1.0:GL_TEXTURE_CUBE_MAP_OES + splitValue = value.split(":") + if len(splitValue) == 2: + if category != None and splitValue[0] != category: + # Don't want this one. + continue + else: + selectedValues.append(splitValue[1]) + else: + selectedValues.append(value) + return selectedValues + +def ProcessSpecFile(filename, userFunc, category = None): + """Open the named API spec file and call userFunc(record, category) for each record + processed.""" + specFile = open(filename, "r") + if not specFile: + print >>sys.stderr, "Error: couldn't open %s file!" % filename + sys.exit() + + record = APIFunction() + + for line in specFile.readlines(): + + # split line into tokens + tokens = string.split(line) + + if len(tokens) > 0 and line[0] != '#': + + if tokens[0] == 'name': + if record.name != '': + # process the old function now + userFunc(record, category) + # reset the record + record = APIFunction() + + record.name = tokens[1] + + elif tokens[0] == 'return': + record.returnType = string.join(tokens[1:], ' ') + + elif tokens[0] == 'param': + name = tokens[1] + type = string.join(tokens[2:], ' ') + vecSize = 0 + record.params.append((name, type, vecSize, None, [], None)) + + elif tokens[0] == 'paramprop': + name = tokens[1] + str = tokens[2:] + enums = [] + for i in range(len(str)): + enums.append(str[i]) + record.paramprop.append((name, enums)) + + elif tokens[0] == 'paramlist': + name = tokens[1] + str = tokens[2:] + list = [] + for i in range(len(str)): + list.append(str[i]) + record.paramlist.append((name,list)) + + elif tokens[0] == 'paramvec': + name = tokens[1] + str = tokens[2:] + vec = [] + for i in range(len(str)): + vec.append(str[i]) + record.paramvec.append((name,vec)) + + elif tokens[0] == 'paramset': + line = tokens[1:] + result = [] + for i in range(len(line)): + tset = line[i] + if tset == '[': + nlist = [] + elif tset == ']': + result.append(nlist) + nlist = [] + else: + nlist.append(tset) + if result != []: + record.paramset.append(result) + + elif tokens[0] == 'paramaction': + name = tokens[1] + str = tokens[2:] + list = [] + for i in range(len(str)): + list.append(str[i]) + record.paramaction.append((name,list)) + + elif tokens[0] == 'category': + record.category = tokens[1] + record.categories = tokens[1:] + + elif tokens[0] == 'offset': + if tokens[1] == '?': + record.offset = -2 + else: + record.offset = int(tokens[1]) + + elif tokens[0] == 'alias': + record.alias = tokens[1] + + elif tokens[0] == 'vectoralias': + record.vectoralias = tokens[1] + + elif tokens[0] == 'convertalias': + record.convertalias = tokens[1] + + elif tokens[0] == 'aliasprefix': + record.aliasprefix = tokens[1] + + elif tokens[0] == 'props': + record.props = tokens[1:] + + elif tokens[0] == 'chromium': + record.chromium = tokens[1:] + + elif tokens[0] == 'vector': + vecName = tokens[1] + vecSize = int(tokens[2]) + index = FindParamIndex(record.params, vecName) + if index == None: + print >>sys.stderr, "Can't find vector '%s' for function '%s'" % (vecName, record.name) + # Adjust just the vector size + record.params[index] = SetTupleIndex(record.params[index], 2, vecSize) + + elif tokens[0] == 'dependentvector': + dependentVecName = tokens[1] + # the dependentVecSize may be an int + # expression + dependentVecSize = tokens[2] + controllingParam = tokens[3] + controllingParamIndex = FindParamIndex(record.params, controllingParam) + if controllingParamIndex == None: + print >>sys.stderr, "Can't find controlling param '%s' for function '%s'" % (controllingParam, record.name) + controllingValues = tokens[4:] + + # Remember that all of the controllingValues + # are valid values for the controllingParam. + # We may be duplicating controllingValues + # here (i.e. if we get them from different + # places); we'll sort them out later. + validValues = record.params[controllingParamIndex][4] + for value in VersionSpecificValues(category, controllingValues): + validValues.append((value, dependentVecSize, dependentVecName, [], None, None)) + # Don't need to reassign validValues back + # to the tuple - it's a shallow pointer, + # so the tuple is already modified. + # (And attempting to do so would produce an + # error anyway.) + + elif tokens[0] == "dependentnovalueconvert": + paramName = tokens[1] + controllingParamName = tokens[2] + controllingValues = tokens[3:] + + controllingParamIndex = FindParamIndex(record.params, controllingParamName) + if controllingParamIndex == None: + print >>sys.stderr, "Can't find controlling param '%s' for function '%s'" % (controllingParamName, record.name) + + validValues = record.params[controllingParamIndex][4] + for value in VersionSpecificValues(category, controllingValues): + validValues.append((value, None, None, [], None, "noconvert")) + + + + elif tokens[0] == 'checkparam': + paramName = tokens[1] + values = tokens[2:] + paramIndex = FindParamIndex(record.params, paramName) + if paramIndex == None: + print >>sys.stderr, "Can't find checked param '%s' for function '%s'" % (paramName, record.name) + + errorCode = None + + # We may be duplicating valid values here; + # just add all values to the existing + # record, and we'll prune out duplicates + # later + validValues = record.params[paramIndex][4] + + # A /GL_* value represents an error, not + # a real value. Look through the values + # and only append the non-error values. + for v in VersionSpecificValues(category, values): + if v[0] == "/": + errorCode = v[1:] + else: + validValues.append((v, None, None, [], errorCode, None)) + # Don't need to reassign validValues back + # to the parameter tuple - it's a shallow pointer, + # so the tuple is already modified. + # (And attempting to do so would produce an + # error anyway.) + + elif tokens[0] == 'checkdependentparam': + paramName = tokens[1] + controllingValue = tokens[2] + dependentParamName = tokens[3] + validDependentValues = tokens[4:] + errorCode = None + + # A /GL_* value represents an error, not + # a real value. Look through the values + # and only append the non-error values. + validDependentValues = [] + for v in tokens[4:]: + if v[0] == "/": + errorCode = v[1:] + else: + validDependentValues.append(v) + + paramIndex = FindParamIndex(record.params, paramName) + if paramIndex == None: + print >>sys.stderr, "Can't find dependent param '%s' for function '%s'" % (paramName, record.name) + + validValues = record.params[paramIndex][4] + # We may be duplicating valid values here; + # we'll sort them out later. Avoid + # adding a controlling value record + # at all if there are no values + # in the list of values (so that + # controlling values with only + # version-specific values listed + # end up as version-specific + # themselves). + versionSpecificValues = VersionSpecificValues(category, validDependentValues) + if versionSpecificValues != []: + validValues.append((controllingValue, None, dependentParamName, versionSpecificValues, errorCode, None)) + # Don't need to reassign validValues back + # to the tuple - it's a shallow pointer, + # so the tuple is already modified. + # (And attempting to do so would produce an + # error anyway.) + + elif tokens[0] == 'convertparams': + convertToType = tokens[1] + # Replace the conversion type in each named + # parameter + for paramName in tokens[2:]: + paramIndex = FindParamIndex(record.params, paramName) + if paramIndex == None: + print >>sys.stderr, "Can't find converted param '%s' for function '%s'" % (paramName, record.name) + # Tuples don't support item assignment, + # so to replace scalar values in a + # tuple, you have to reassign the + # whole friggin' thing. + record.params[paramIndex] = SetTupleIndex(record.params[paramIndex], 3, convertToType) + + else: + print >>sys.stderr, 'Invalid token %s after function %s' % (tokens[0], record.name) + #endif + #endif + #endfor + + # Call the user function for the last record, if we still have one + # lying around nearly finished + if record.name != '': + # process the function now + userFunc(record, category) + specFile.close() +#enddef + + +# Dictionary [name] of APIFunction: +__FunctionDict = {} + +# Dictionary [name] of name +__VectorVersion = {} + +# Reverse mapping of function name aliases +__ReverseAliases = {} + +def CheckCategories(category, categories): + for c in categories: + if category == c.split(":")[0]: + return 1 + + return 0 + +def AddFunction(record, category): + # If there is a category, we only want records from that category. + # Note that a category may be in the form "GLES1.1:OES_extension_name", + # which means that the function is supported as an extension in + # GLES1.1... + if category and not CheckCategories(category, record.categories): + return + + # Don't allow duplicates + if __FunctionDict.has_key(record.name): + print >>sys.stderr, "Duplicate record name '%s' ignored" % record.name + return + + # Clean up a bit. We collected valid values for parameters + # on the fly; it's quite possible that there are duplicates. + # If there are, collect them together. + # + # We're also going to keep track of all the dependent values + # that can show up for a parameter; the number of GLenum values + # (identified with a prefixed "GL_") affects how parameter + # value conversion happens, as GLenum values are not scaled + # when converted to or from GLfixed values, the way integer + # and floating point values are. + paramValueConversion = {} + + for i in range(len(record.params)): + foundValidValues = {} + + (name, type, maxVecSize, convertToType, validValues, valueConversion) = record.params[i] + for (controllingValue, vecSize, dependentParamName, dependentValues, errorCode, valueConvert) in validValues: + # Keep track of the maximum vector size for the + # *dependent* parameter, not for the controlling + # parameter. Note that the dependent parameter + # may be an expression - in this case, don't + # consider it. + if dependentParamName != None and vecSize != None and vecSize.isdigit(): + dependentParamIndex = FindParamIndex(record.params, dependentParamName) + if dependentParamIndex == None: + print >>sys.stderr, "Couldn't find dependent parameter '%s' of function '%s'" % (dependentParamName, record.name) + (dName, dType, dMaxVecSize, dConvert, dValid, dValueConversion) = record.params[dependentParamIndex] + if dMaxVecSize == None or int(vecSize) > dMaxVecSize: + dMaxVecSize = int(vecSize) + record.params[dependentParamIndex] = (dName, dType, dMaxVecSize, dConvert, dValid, dValueConversion) + + # Make sure an entry for the controlling value + # exists in the foundValidValues dictionary + if controllingValue in foundValidValues: + # The value was already there. Merge the + # two together, giving errors if needed. + (oldControllingValue, oldVecSize, oldDependentParamName, oldDependentValues, oldErrorCode, oldValueConvert) = foundValidValues[controllingValue] + + # Make sure the vector sizes are compatible; + # either one should be None (and be + # overridden by the other), or they should + # match exactly. If one is not an + # integer (this can happen if the + # dependent value is an integer expression, + # which occurs a couple of times), don't + # use it. + if oldVecSize == None: + oldVecSize = vecSize + elif vecSize != None and vecSize != oldVecSize: + print >>sys.stderr, "Found two different vector sizes (%s and %s) for the same controlling value '%s' of the same parameter '%s' of function '%s'" % (oldVecSize, vecSize, controllingValue, name, record.name) + + # Same for the dependent parameter name. + if oldDependentParamName == None: + oldDependentParamName = dependentParamName + elif dependentParamName != None and dependentParamName != oldDependentParamName: + print >>sys.stderr, "Found two different dependent parameter names (%s and %s) for the same controlling value '%s' of the same parameter '%s' of function '%s'" % (oldDependentParamName, dependentParamName, controllingValue, name, record.name) + + # And for the error code. + if oldErrorCode == None: + oldErrorCode = errorCode + elif errorCode != None and errorCode != oldErrorCode: + print >>sys.stderr, "Found two different error codes(%s and %s) for the same controlling value '%s' of the same parameter '%s' of function '%s'" % (oldErrorCode, errorCode, controllingValue, name, record.name) + + # And for the value conversion flag + if oldValueConvert == None: + oldValueConvert = valueConvert + elif valueConvert != None and valueConvert != oldValueConvert: + print >>sys.stderr, "Found two different value conversions(%s and %s) for the same controlling value '%s' of the same parameter '%s' of function '%s'" % (oldValueConvert, valueConvert, controllingValue, name, record.name) + + # Combine the dependentValues together + # directly, but uniquely + for value in dependentValues: + if value not in oldDependentValues: + oldDependentValues.append(value) + + # Stick the combined value back into the + # dictionary. We'll sort it back to the + # array later. + foundValidValues[oldControllingValue] = (oldControllingValue, oldVecSize, oldDependentParamName, oldDependentValues, oldErrorCode, oldValueConvert) + else: # new controlling value + # Just add it to the dictionary so we don't + # add the same value more than once. + foundValidValues[controllingValue] = (controllingValue, vecSize, dependentParamName, dependentValues, errorCode, valueConvert) + # endif a new controlling value + + # endfor all valid values for this parameter + + # Now the foundValidValues[] dictionary holds all the + # pruned values (at most one for each valid value). + # But the validValues[] array still holds the order, + # which we want to maintain. Go through the validValues + # array just for the names of the controlling values; + # add any uncopied values to the prunedValidValues array. + prunedValidValues = [] + + for (controllingValue, vecSize, dependentParamName, dependentValues, errorCode, valueConvert) in validValues: + if controllingValue in foundValidValues: + prunedValidValues.append(foundValidValues[controllingValue]) + # Delete it from the dictionary so it isn't + # copied again. + del foundValidValues[controllingValue] + + # Each parameter that is being converted may have a + # subset of values that are GLenums and are never + # converted. In some cases, the parameter will + # be implicitly determined to be such, by examining + # the listed possible values and determining for + # any particular controlling value whether there are + # any GLenum-valued allowed values. + # + # In other cases, the parameter will be explicitly + # marked as such with the "dependentnovalueconvert" flag; + # this is the way it has to be done with queries (which + # cannot list a valid list of values to be passed, + # because values are returned, not passed). + # + # For each value of controlling GLenum, we'll also + # need to know whether its dependent values are + # always converted (none of its values require + # GLenums to be passed in dependent parameters), + # never converted (all of its values require GLenums), + # or sometimes converted. + numNoConvertValues = 0 + allDependentParams = [] + for j in range(len(prunedValidValues)): + (controllingValue, vecSize, dependentParamName, dependentValues, errorCode, valueConvert) = prunedValidValues[j] + if dependentParamName != None and dependentParamName not in allDependentParams: + allDependentParams.append(dependentParamName) + + # Check for an explicit noconvert marking... + if valueConvert == "noconvert": + numNoConvertValues += 1 + else: + # Or check for an implicit one. + for value in dependentValues: + if value[0:3] == "GL_": + valueConvert = "noconvert" + prunedValidValues[j] = (controllingValue, vecSize, dependentParamName, dependentValues, errorCode, valueConvert) + numNoConvertValues += 1 + break + + # For each named dependent param, set the value conversion + # flag based on whether all values, none, or some need + # value conversion. This value is set stepwise + # for each parameter examined - + for dp in allDependentParams: + if numNoConvertValues == 0: + if not paramValueConversion.has_key(dp): + paramValueConversion[dp] = "all" + elif paramValueConversion[dp] == "none": + paramValueConversion[dp] = "some" + elif numNoConvertValues == len(prunedValidValues): + if not paramValueConversion.has_key(dp): + paramValueConversion[dp] = "none" + elif paramValueConversion[dp] == "all": + paramValueConversion[dp] = "some" + else: + paramValueConversion[dp] = "some" + + # Save away the record. Save a placeholder in the + # valueConversion field - we can't set that until we've + # examined all the parameters. + record.params[i] = (name, type, maxVecSize, convertToType, prunedValidValues, None) + + # endfor each param of the passed-in function record + + # One more pass: for each parameter, if it is a parameter that + # needs conversion, save its value conversion type ("all", "none", + # or "some"). We only have to worry about conditional value + # conversion for GLfixed parameters; in all other cases, we + # either don't convert at all (for non-converting parameters) or + # we convert everything. + for i in range(len(record.params)): + (name, type, maxVecSize, convertToType, validValues, valueConversion) = record.params[i] + if convertToType == None: + valueConversion = None + elif paramValueConversion.has_key(name): + valueConversion = paramValueConversion[name] + else: + valueConversion = "all" + + record.params[i] = (name, type, maxVecSize, convertToType, validValues, valueConversion) + + # We're done cleaning up! + # Add the function to the permanent record and we're done. + __FunctionDict[record.name] = record + + +def GetFunctionDict(specFile = "", category = None): + if not specFile: + specFile = "../glapi_parser/APIspec.txt" + if len(__FunctionDict) == 0: + ProcessSpecFile(specFile, AddFunction, category) + # Look for vector aliased functions + for func in __FunctionDict.keys(): + va = __FunctionDict[func].vectoralias + if va != '': + __VectorVersion[va] = func + #endif + + # and look for regular aliases (for glloader) + a = __FunctionDict[func].alias + if a: + __ReverseAliases[a] = func + #endif + #endfor + #endif + return __FunctionDict + + +def GetAllFunctions(specFile = "", category = None): + """Return sorted list of all functions known to Chromium.""" + d = GetFunctionDict(specFile, category) + funcs = [] + for func in d.keys(): + rec = d[func] + if not "omit" in rec.chromium: + funcs.append(func) + funcs.sort() + return funcs + + +def GetDispatchedFunctions(specFile = "", category = None): + """Return sorted list of all functions handled by SPU dispatch table.""" + d = GetFunctionDict(specFile, category) + funcs = [] + for func in d.keys(): + rec = d[func] + if (not "omit" in rec.chromium and + not "stub" in rec.chromium and + rec.alias == ''): + funcs.append(func) + funcs.sort() + return funcs + +#====================================================================== + +def ReturnType(funcName): + """Return the C return type of named function. + Examples: "void" or "const GLubyte *". """ + d = GetFunctionDict() + return d[funcName].returnType + + +def Parameters(funcName): + """Return list of tuples (name, type, vecSize) of function parameters. + Example: if funcName=="ClipPlane" return + [ ("plane", "GLenum", 0), ("equation", "const GLdouble *", 4) ] """ + d = GetFunctionDict() + return d[funcName].params + +def ParamAction(funcName): + """Return list of names of actions for testing. + For PackerTest only.""" + d = GetFunctionDict() + return d[funcName].paramaction + +def ParamList(funcName): + """Return list of tuples (name, list of values) of function parameters. + For PackerTest only.""" + d = GetFunctionDict() + return d[funcName].paramlist + +def ParamVec(funcName): + """Return list of tuples (name, vector of values) of function parameters. + For PackerTest only.""" + d = GetFunctionDict() + return d[funcName].paramvec + +def ParamSet(funcName): + """Return list of tuples (name, list of values) of function parameters. + For PackerTest only.""" + d = GetFunctionDict() + return d[funcName].paramset + + +def Properties(funcName): + """Return list of properties of the named GL function.""" + d = GetFunctionDict() + return d[funcName].props + +def AllWithProperty(property): + """Return list of functions that have the named property.""" + funcs = [] + for funcName in GetDispatchedFunctions(): + if property in Properties(funcName): + funcs.append(funcName) + return funcs + +def Category(funcName): + """Return the primary category of the named GL function.""" + d = GetFunctionDict() + return d[funcName].category + +def Categories(funcName): + """Return all the categories of the named GL function.""" + d = GetFunctionDict() + return d[funcName].categories + +def ChromiumProps(funcName): + """Return list of Chromium-specific properties of the named GL function.""" + d = GetFunctionDict() + return d[funcName].chromium + +def ParamProps(funcName): + """Return list of Parameter-specific properties of the named GL function.""" + d = GetFunctionDict() + return d[funcName].paramprop + +def Alias(funcName): + """Return the function that the named function is an alias of. + Ex: Alias('DrawArraysEXT') = 'DrawArrays'. + """ + d = GetFunctionDict() + return d[funcName].alias + +def AliasPrefix(funcName): + """Return the function that the named function is an alias of. + Ex: Alias('DrawArraysEXT') = 'DrawArrays'. + """ + d = GetFunctionDict() + if d[funcName].aliasprefix == '': + return "_mesa_" + else: + return d[funcName].aliasprefix + +def ReverseAlias(funcName): + """Like Alias(), but the inverse.""" + d = GetFunctionDict() + if funcName in __ReverseAliases.keys(): + return __ReverseAliases[funcName] + else: + return '' + +def NonVectorFunction(funcName): + """Return the non-vector version of the given function, or ''. + For example: NonVectorFunction("Color3fv") = "Color3f".""" + d = GetFunctionDict() + return d[funcName].vectoralias + +def ConversionFunction(funcName): + """Return a function that can be used to implement the + given function, using different types. + For example: ConvertedFunction("Color4x") = "Color4f".""" + d = GetFunctionDict() + return d[funcName].convertalias + +def VectorFunction(funcName): + """Return the vector version of the given non-vector-valued function, + or ''. + For example: VectorVersion("Color3f") = "Color3fv".""" + d = GetFunctionDict() + if funcName in __VectorVersion.keys(): + return __VectorVersion[funcName] + else: + return '' + +def GetCategoryWrapper(func_name): + """Return a C preprocessor token to test in order to wrap code. + This handles extensions. + Example: GetTestWrapper("glActiveTextureARB") = "CR_multitexture" + Example: GetTestWrapper("glBegin") = "" + """ + cat = Category(func_name) + if (cat == "1.0" or + cat == "1.1" or + cat == "1.2" or + cat == "Chromium" or + cat == "GL_chromium"): + return '' + elif cat[0] =='1': + # i.e. OpenGL 1.3 or 1.4 or 1.5 + return "OPENGL_VERSION_" + string.replace(cat, ".", "_") + else: + assert cat != '' + return string.replace(cat, "GL_", "") + + +def CanCompile(funcName): + """Return 1 if the function can be compiled into display lists, else 0.""" + props = Properties(funcName) + if ("nolist" in props or + "get" in props or + "setclient" in props): + return 0 + else: + return 1 + +def HasChromiumProperty(funcName, propertyList): + """Return 1 if the function or any alias has any property in the + propertyList""" + for funcAlias in [funcName, NonVectorFunction(funcName), VectorFunction(funcName)]: + if funcAlias: + props = ChromiumProps(funcAlias) + for p in propertyList: + if p in props: + return 1 + return 0 + +def CanPack(funcName): + """Return 1 if the function can be packed, else 0.""" + return HasChromiumProperty(funcName, ['pack', 'extpack', 'expandpack']) + +def HasPackOpcode(funcName): + """Return 1 if the function has a true pack opcode""" + return HasChromiumProperty(funcName, ['pack', 'extpack']) + +def SetsState(funcName): + """Return 1 if the function sets server-side state, else 0.""" + props = Properties(funcName) + + # Exceptions. The first set of these functions *do* have + # server-side state-changing effects, but will be missed + # by the general query, because they either render (e.g. + # Bitmap) or do not compile into display lists (e.g. all the others). + # + # The second set do *not* have server-side state-changing + # effects, despite the fact that they do not render + # and can be compiled. They are control functions + # that are not trackable via state. + if funcName in ['Bitmap', 'DeleteTextures', 'FeedbackBuffer', + 'RenderMode', 'BindBufferARB', 'DeleteFencesNV']: + return 1 + elif funcName in ['ExecuteProgramNV']: + return 0 + + # All compilable functions that do not render and that do + # not set or use client-side state (e.g. DrawArrays, et al.), set + # server-side state. + if CanCompile(funcName) and "render" not in props and "useclient" not in props and "setclient" not in props: + return 1 + + # All others don't set server-side state. + return 0 + +def SetsClientState(funcName): + """Return 1 if the function sets client-side state, else 0.""" + props = Properties(funcName) + if "setclient" in props: + return 1 + return 0 + +def SetsTrackedState(funcName): + """Return 1 if the function sets state that is tracked by + the state tracker, else 0.""" + # These functions set state, but aren't tracked by the state + # tracker for various reasons: + # - because the state tracker doesn't manage display lists + # (e.g. CallList and CallLists) + # - because the client doesn't have information about what + # the server supports, so the function has to go to the + # server (e.g. CompressedTexImage calls) + # - because they require a round-trip to the server (e.g. + # the CopyTexImage calls, SetFenceNV, TrackMatrixNV) + if funcName in [ + 'CopyTexImage1D', 'CopyTexImage2D', + 'CopyTexSubImage1D', 'CopyTexSubImage2D', 'CopyTexSubImage3D', + 'CallList', 'CallLists', + 'CompressedTexImage1DARB', 'CompressedTexSubImage1DARB', + 'CompressedTexImage2DARB', 'CompressedTexSubImage2DARB', + 'CompressedTexImage3DARB', 'CompressedTexSubImage3DARB', + 'SetFenceNV' + ]: + return 0 + + # Anything else that affects client-side state is trackable. + if SetsClientState(funcName): + return 1 + + # Anything else that doesn't set state at all is certainly + # not trackable. + if not SetsState(funcName): + return 0 + + # Per-vertex state isn't tracked the way other state is + # tracked, so it is specifically excluded. + if "pervertex" in Properties(funcName): + return 0 + + # Everything else is fine + return 1 + +def UsesClientState(funcName): + """Return 1 if the function uses client-side state, else 0.""" + props = Properties(funcName) + if "pixelstore" in props or "useclient" in props: + return 1 + return 0 + +def IsQuery(funcName): + """Return 1 if the function returns information to the user, else 0.""" + props = Properties(funcName) + if "get" in props: + return 1 + return 0 + +def FuncGetsState(funcName): + """Return 1 if the function gets GL state, else 0.""" + d = GetFunctionDict() + props = Properties(funcName) + if "get" in props: + return 1 + else: + return 0 + +def IsPointer(dataType): + """Determine if the datatype is a pointer. Return 1 or 0.""" + if string.find(dataType, "*") == -1: + return 0 + else: + return 1 + + +def PointerType(pointerType): + """Return the type of a pointer. + Ex: PointerType('const GLubyte *') = 'GLubyte' + """ + t = string.split(pointerType, ' ') + if t[0] == "const": + t[0] = t[1] + return t[0] + + + + +def OpcodeName(funcName): + """Return the C token for the opcode for the given function.""" + return "CR_" + string.upper(funcName) + "_OPCODE" + + +def ExtendedOpcodeName(funcName): + """Return the C token for the extended opcode for the given function.""" + return "CR_" + string.upper(funcName) + "_EXTEND_OPCODE" + + + + +#====================================================================== + +def MakeCallString(params): + """Given a list of (name, type, vectorSize) parameters, make a C-style + formal parameter string. + Ex return: 'index, x, y, z'. + """ + result = '' + i = 1 + n = len(params) + for (name, type, vecSize, convertToType, validValues, valueConversion) in params: + result += name + if i < n: + result = result + ', ' + i += 1 + #endfor + return result +#enddef + + +def MakeDeclarationString(params): + """Given a list of (name, type, vectorSize) parameters, make a C-style + parameter declaration string. + Ex return: 'GLuint index, GLfloat x, GLfloat y, GLfloat z'. + """ + n = len(params) + if n == 0: + return 'void' + else: + result = '' + i = 1 + for (name, type, vecSize, convertToType, validValues, valueConversion) in params: + result = result + type + ' ' + name + if i < n: + result = result + ', ' + i += 1 + #endfor + return result + #endif +#enddef + + +def MakePrototypeString(params): + """Given a list of (name, type, vectorSize) parameters, make a C-style + parameter prototype string (types only). + Ex return: 'GLuint, GLfloat, GLfloat, GLfloat'. + """ + n = len(params) + if n == 0: + return 'void' + else: + result = '' + i = 1 + for (name, type, vecSize, convertToType, validValues, valueConversion) in params: + result = result + type + # see if we need a comma separator + if i < n: + result = result + ', ' + i += 1 + #endfor + return result + #endif +#enddef + + +#====================================================================== + +__lengths = { + 'GLbyte': 1, + 'GLubyte': 1, + 'GLshort': 2, + 'GLushort': 2, + 'GLint': 4, + 'GLuint': 4, + 'GLfloat': 4, + 'GLclampf': 4, + 'GLdouble': 8, + 'GLclampd': 8, + 'GLenum': 4, + 'GLboolean': 1, + 'GLsizei': 4, + 'GLbitfield': 4, + 'void': 0, # XXX why? + 'int': 4, + 'GLintptrARB': 4, # XXX or 8 bytes? + 'GLsizeiptrARB': 4 # XXX or 8 bytes? +} + +def sizeof(type): + """Return size of C datatype, in bytes.""" + if not type in __lengths.keys(): + print >>sys.stderr, "%s not in lengths!" % type + return __lengths[type] + + +#====================================================================== +align_types = 1 + +def FixAlignment( pos, alignment ): + # if we want double-alignment take word-alignment instead, + # yes, this is super-lame, but we know what we are doing + if alignment > 4: + alignment = 4 + if align_types and alignment and ( pos % alignment ): + pos += alignment - ( pos % alignment ) + return pos + +def WordAlign( pos ): + return FixAlignment( pos, 4 ) + +def PointerSize(): + return 8 # Leave room for a 64 bit pointer + +def PacketLength( params ): + len = 0 + for (name, type, vecSize, convertToType, validValues, valueConversion) in params: + if IsPointer(type): + size = PointerSize() + else: + assert string.find(type, "const") == -1 + size = sizeof(type) + len = FixAlignment( len, size ) + size + len = WordAlign( len ) + return len + +#====================================================================== + +__specials = {} + +def LoadSpecials( filename ): + table = {} + try: + f = open( filename, "r" ) + except: + __specials[filename] = {} + print >>sys.stderr, "%s not present" % filename + return {} + + for line in f.readlines(): + line = string.strip(line) + if line == "" or line[0] == '#': + continue + table[line] = 1 + + __specials[filename] = table + return table + + +def FindSpecial( filename, glName ): + table = {} + try: + table = __specials[filename] + except KeyError: + table = LoadSpecials( filename ) + + try: + if (table[glName] == 1): + return 1 + else: + return 0 #should never happen + except KeyError: + return 0 + + +def AllSpecials( table_file ): + table = {} + filename = table_file + "_special" + try: + table = __specials[filename] + except KeyError: + table = LoadSpecials( filename ) + + keys = table.keys() + keys.sort() + return keys + + +def AllSpecials( table_file ): + filename = table_file + "_special" + table = {} + try: + table = __specials[filename] + except KeyError: + table = LoadSpecials(filename) + + ret = table.keys() + ret.sort() + return ret + + +def NumSpecials( table_file ): + filename = table_file + "_special" + table = {} + try: + table = __specials[filename] + except KeyError: + table = LoadSpecials(filename) + return len(table.keys()) + +def PrintRecord(record): + argList = MakeDeclarationString(record.params) + if record.category == "Chromium": + prefix = "cr" + else: + prefix = "gl" + print '%s %s%s(%s);' % (record.returnType, prefix, record.name, argList ) + if len(record.props) > 0: + print ' /* %s */' % string.join(record.props, ' ') + +#ProcessSpecFile("APIspec.txt", PrintRecord) + diff --git a/src/mesa/es/main/es1_special b/src/mesa/es/main/es1_special new file mode 100644 index 0000000000..4cc97c30f3 --- /dev/null +++ b/src/mesa/es/main/es1_special @@ -0,0 +1,8 @@ +# GetString is always special. +GetString +# CompressedTexImage2D calls out to two different functions based on +# whether the image is a paletted image or not +CompressedTexImage2D +# QueryMatrixx returns values in an unusual, decomposed, fixed-value +# form; it has its own code for this +QueryMatrixx diff --git a/src/mesa/es/main/es2_special b/src/mesa/es/main/es2_special new file mode 100644 index 0000000000..8de76a3735 --- /dev/null +++ b/src/mesa/es/main/es2_special @@ -0,0 +1,5 @@ +# GetString must always have its own implementation, so we return our +# implementation values instead of Mesa's. +GetString +CompressedTexImage2D +RenderbufferStorage diff --git a/src/mesa/es/main/es_cpaltex.c b/src/mesa/es/main/es_cpaltex.c new file mode 100644 index 0000000000..0d6f7410c3 --- /dev/null +++ b/src/mesa/es/main/es_cpaltex.c @@ -0,0 +1,240 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + **************************************************************************/ + + +/** + * Code to convert compressed/paletted texture images to ordinary 4-byte RGBA. + * See the GL_OES_compressed_paletted_texture spec at + * http://khronos.org/registry/gles/extensions/OES/OES_compressed_paletted_texture.txt + */ + + +#include +#include +#include "GLES/gl.h" +#include "GLES/glext.h" + + +void GL_APIENTRY _es_CompressedTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); + +void GL_APIENTRY _mesa_TexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +void GL_APIENTRY _mesa_CompressedTexImage2DARB(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); + + +static const struct { + GLenum format; + GLuint palette_size; + GLuint size; +} formats[] = { + { GL_PALETTE4_RGB8_OES, 16, 3 }, + { GL_PALETTE4_RGBA8_OES, 16, 4 }, + { GL_PALETTE4_R5_G6_B5_OES, 16, 2 }, + { GL_PALETTE4_RGBA4_OES, 16, 2 }, + { GL_PALETTE4_RGB5_A1_OES, 16, 2 }, + { GL_PALETTE8_RGB8_OES, 256, 3 }, + { GL_PALETTE8_RGBA8_OES, 256, 4 }, + { GL_PALETTE8_R5_G6_B5_OES, 256, 2 }, + { GL_PALETTE8_RGBA4_OES, 256, 2 }, + { GL_PALETTE8_RGB5_A1_OES, 256, 2 } +}; + + +/** + * Get a color/entry from the palette. Convert to GLubyte/RGBA format. + */ +static void +get_palette_entry(GLenum format, const void *palette, GLuint index, + GLubyte rgba[4]) +{ + switch (format) { + case GL_PALETTE4_RGB8_OES: + case GL_PALETTE8_RGB8_OES: + { + const GLubyte *pal = (const GLubyte *) palette; + rgba[0] = pal[index * 3 + 0]; + rgba[1] = pal[index * 3 + 1]; + rgba[2] = pal[index * 3 + 2]; + rgba[3] = 255; + } + break; + case GL_PALETTE4_RGBA8_OES: + case GL_PALETTE8_RGBA8_OES: + { + const GLubyte *pal = (const GLubyte *) palette; + rgba[0] = pal[index * 4 + 0]; + rgba[1] = pal[index * 4 + 1]; + rgba[2] = pal[index * 4 + 2]; + rgba[3] = pal[index * 4 + 3]; + } + break; + case GL_PALETTE4_R5_G6_B5_OES: + case GL_PALETTE8_R5_G6_B5_OES: + { + const GLushort *pal = (const GLushort *) palette; + const GLushort color = pal[index]; + rgba[0] = ((color >> 8) & 0xf8) | ((color >> 11) & 0x3); + rgba[1] = ((color >> 3) & 0xfc) | ((color >> 1 ) & 0x3); + rgba[2] = ((color << 3) & 0xf8) | ((color ) & 0x7); + rgba[3] = 255; + } + break; + case GL_PALETTE4_RGBA4_OES: + case GL_PALETTE8_RGBA4_OES: + { + const GLushort *pal = (const GLushort *) palette; + const GLushort color = pal[index]; + rgba[0] = ((color & 0xf000) >> 8) | ((color & 0xf000) >> 12); + rgba[1] = ((color & 0x0f00) >> 4) | ((color & 0x0f00) >> 8); + rgba[2] = ((color & 0x00f0) ) | ((color & 0x00f0) >> 4); + rgba[3] = ((color & 0x000f) << 4) | ((color & 0x000f) ); + } + break; + case GL_PALETTE4_RGB5_A1_OES: + case GL_PALETTE8_RGB5_A1_OES: + { + const GLushort *pal = (const GLushort *) palette; + const GLushort color = pal[index]; + rgba[0] = ((color >> 8) & 0xf8) | ((color >> 11) & 0x7); + rgba[1] = ((color >> 3) & 0xf8) | ((color >> 6) & 0x7); + rgba[2] = ((color << 2) & 0xf8) | ((color >> 1) & 0x7); + rgba[3] = (color & 0x1) * 255; + } + break; + default: + assert(0); + } +} + + +/** + * Convert paletted texture to simple GLubyte/RGBA format. + */ +static void +paletted_to_rgba(GLenum src_format, + const void *palette, + const void *indexes, + GLsizei width, GLsizei height, + GLubyte *rgba) +{ + GLuint pal_ents, i; + + assert(src_format >= GL_PALETTE4_RGB8_OES); + assert(src_format <= GL_PALETTE8_RGB5_A1_OES); + assert(formats[src_format - GL_PALETTE4_RGB8_OES].format == src_format); + + pal_ents = formats[src_format - GL_PALETTE4_RGB8_OES].palette_size; + + if (pal_ents == 16) { + /* 4 bits per index */ + const GLubyte *ind = (const GLubyte *) indexes; + + if (width * height == 1) { + /* special case the only odd-sized image */ + GLuint index0 = ind[0] >> 4; + get_palette_entry(src_format, palette, index0, rgba); + return; + } + /* two pixels per iteration */ + for (i = 0; i < width * height / 2; i++) { + GLuint index0 = ind[i] >> 4; + GLuint index1 = ind[i] & 0xf; + get_palette_entry(src_format, palette, index0, rgba + i * 8); + get_palette_entry(src_format, palette, index1, rgba + i * 8 + 4); + } + } + else { + /* 8 bits per index */ + const GLubyte *ind = (const GLubyte *) indexes; + for (i = 0; i < width * height; i++) { + GLuint index = ind[i]; + get_palette_entry(src_format, palette, index, rgba + i * 4); + } + } +} + + +/** + * Convert a call to glCompressedTexImage2D() where internalFormat is a + * compressed palette format into a regular GLubyte/RGBA glTexImage2D() call. + */ +static void +cpal_compressed_teximage2d(GLenum target, GLint level, + GLenum internalFormat, + GLsizei width, GLsizei height, + const void *pixels) +{ + GLuint pal_ents, pal_ent_size, pal_bytes; + const GLint num_levels = level + 1; + GLint lvl; + const GLubyte *indexes; + + assert(internalFormat >= GL_PALETTE4_RGB8_OES); + assert(internalFormat <= GL_PALETTE8_RGB5_A1_OES); + assert(formats[internalFormat - GL_PALETTE4_RGB8_OES].format == internalFormat); + + pal_ents = formats[internalFormat - GL_PALETTE4_RGB8_OES].palette_size; + pal_ent_size = formats[internalFormat - GL_PALETTE4_RGB8_OES].size; + pal_bytes = pal_ents * pal_ent_size; + + /* first image follows the palette */ + indexes = (const GLubyte *) pixels + pal_bytes; + + /* No worries about glPixelStore state since the only supported parameter is + * GL_UNPACK_ALIGNMENT and it doesn't matter when unpacking GLubyte/RGBA. + */ + + for (lvl = 0; lvl < num_levels; lvl++) { + /* Allocate GLubyte/RGBA dest image buffer */ + GLubyte *rgba = (GLubyte *) malloc(width * height * 4); + + if (pixels) + paletted_to_rgba(internalFormat, pixels, indexes, width, height, rgba); + + _mesa_TexImage2D(target, lvl, GL_RGBA, width, height, 0, + GL_RGBA, GL_UNSIGNED_BYTE, rgba); + + free(rgba); + + /* advance index pointer to point to next src mipmap */ + if (pal_ents == 4) + indexes += width * height / 2; + else + indexes += width * height; + + /* next mipmap level size */ + if (width > 1) + width /= 2; + if (height > 1) + height /= 2; + } +} + + +void GL_APIENTRY +_es_CompressedTexImage2D(GLenum target, GLint level, GLenum internalFormat, + GLsizei width, GLsizei height, GLint border, + GLsizei imageSize, const GLvoid *data) +{ + switch (internalFormat) { + case GL_PALETTE4_RGB8_OES: + case GL_PALETTE4_RGBA8_OES: + case GL_PALETTE4_R5_G6_B5_OES: + case GL_PALETTE4_RGBA4_OES: + case GL_PALETTE4_RGB5_A1_OES: + case GL_PALETTE8_RGB8_OES: + case GL_PALETTE8_RGBA8_OES: + case GL_PALETTE8_R5_G6_B5_OES: + case GL_PALETTE8_RGBA4_OES: + case GL_PALETTE8_RGB5_A1_OES: + cpal_compressed_teximage2d(target, level, internalFormat, + width, height, data); + break; + default: + _mesa_CompressedTexImage2DARB(target, level, internalFormat, + width, height, border, imageSize, data); + } +} diff --git a/src/mesa/es/main/es_fbo.c b/src/mesa/es/main/es_fbo.c new file mode 100644 index 0000000000..545c46ca99 --- /dev/null +++ b/src/mesa/es/main/es_fbo.c @@ -0,0 +1,37 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + **************************************************************************/ + + +#include "GLES2/gl2.h" +#include "GLES2/gl2ext.h" + + +extern void GL_APIENTRY _es_RenderbufferStorage(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height); + +extern void GL_APIENTRY _mesa_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height); + + +void GL_APIENTRY +_es_RenderbufferStorage(GLenum target, GLenum internalFormat, + GLsizei width, GLsizei height) +{ + switch (internalFormat) { + case GL_RGBA4: + case GL_RGB5_A1: + case GL_RGB565: + internalFormat = GL_RGBA; + break; + case GL_STENCIL_INDEX1_OES: + case GL_STENCIL_INDEX4_OES: + case GL_STENCIL_INDEX8: + internalFormat = GL_STENCIL_INDEX; + break; + default: + ; /* no op */ + } + _mesa_RenderbufferStorageEXT(target, internalFormat, width, height); +} diff --git a/src/mesa/es/main/es_generator.py b/src/mesa/es/main/es_generator.py new file mode 100644 index 0000000000..2e38b59d9e --- /dev/null +++ b/src/mesa/es/main/es_generator.py @@ -0,0 +1,773 @@ +#************************************************************************* +# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. +# All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# TUNGSTEN GRAPHICS 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. +#************************************************************************* + + +import sys, os +import apiutil + +# These dictionary entries are used for automatic conversion. +# The string will be used as a format string with the conversion +# variable. +Converters = { + 'GLfloat': { + 'GLdouble': "(GLdouble) (%s)", + 'GLfixed' : "(GLint) (%s * 65536)", + }, + 'GLfixed': { + 'GLfloat': "(GLfloat) (%s / 65536.0f)", + 'GLdouble': "(GLdouble) (%s / 65536.0)", + }, + 'GLdouble': { + 'GLfloat': "(GLfloat) (%s)", + 'GLfixed': "(GLfixed) (%s * 65536)", + }, + 'GLclampf': { + 'GLclampd': "(GLclampd) (%s)", + 'GLclampx': "(GLclampx) (%s * 65536)", + }, + 'GLclampx': { + 'GLclampf': "(GLclampf) (%s / 65536.0f)", + 'GLclampd': "(GLclampd) (%s / 65536.0)", + }, + 'GLubyte': { + 'GLfloat': "(GLfloat) (%s / 255.0f)", + }, +} + +def GetBaseType(type): + typeTokens = type.split(' ') + baseType = None + typeModifiers = [] + for t in typeTokens: + if t in ['const', '*']: + typeModifiers.append(t) + else: + baseType = t + return (baseType, typeModifiers) + +def ConvertValue(value, fromType, toType): + """Returns a string that represents the given parameter string, + type-converted if necessary.""" + + if not Converters.has_key(fromType): + print >> sys.stderr, "No base converter for type '%s' found. Ignoring." % fromType + return value + + if not Converters[fromType].has_key(toType): + print >> sys.stderr, "No converter found for type '%s' to type '%s'. Ignoring." % (fromType, toType) + return value + + # This part is simple. Return the proper conversion. + conversionString = Converters[fromType][toType] + return conversionString % value + +def GetLoopSizeExpression(funcName, paramName, paramMaxVecSize): + # The VariantArrays() list will have all the information (for all + # parameters) on how to calculate variant array sizes. + variantArrays = apiutil.VariantArrays(funcName) + defaultSize = paramMaxVecSize + loopSizeExpression = '' + + # There can be many different entries in the variantArrays for the + # same parameter. We have to look at all of them and pick out the + # ones of interest. + for (variantName, variantSize, controllingParam, controllingValues) in variantArrays: + if paramName == variantName: + # This variant specification applies to us. It may be of + # the form "param size default", meaning that the value should + # replace the default size, or it may be + # "param size controlParam value...", in which case the size should + # be used if the controlParam has any one of the given values. + if len(controllingValues) == 0: + defaultSize = variantSize + else: + # Create a compound conditional that expresses + # all the possible values in the list + conditional = '' + for value in controllingValues: + if len(conditional) > 0: + conditional = conditional + " || " + conditional = conditional + "%s == %s" % (controllingParam, value) + + # Add the possibly compound conditional and + # the associated vector size to the + # loop control expression + loopSizeExpression = loopSizeExpression + "(%s) ? %s : " % (conditional, variantSize) + + # end if the name matches + # end for the list of all variant array declarations + + # Return the expression that returns the actual size of the + # array. Note that 'loopSizeExpression' will already have a + # trailing ": " if it is nonempty. + if len(loopSizeExpression) > 0: + return "(%s%s)" % (loopSizeExpression, defaultSize) + else: + return "%s" % defaultSize + +FormatStrings = { + 'GLenum' : '0x%x', + 'GLfloat' : '%f', + 'GLint' : '%d', + 'GLbitfield' : '0x%x', +} +def GetFormatString(type): + if FormatStrings.has_key(type): + return FormatStrings[type] + else: + return None + + +###################################################################### +# Version-specific values to be used in the main script +# header: which header file to include +# api: what text specifies an API-level function +# special: the name of the "specials" file +VersionSpecificValues = { + 'GLES1.1' : { + 'description' : 'GLES1.1 functions', + 'header' : 'GLES/gl.h', + 'extheader' : 'GLES/glext.h', + 'special' : 'es1_special', + }, + 'GLES2.0': { + 'description' : 'GLES2.0 functions', + 'header' : 'GLES2/gl2.h', + 'extheader' : 'GLES2/gl2ext.h', + 'special' : 'es2_special', + } +} + + +###################################################################### +# Main code for the script begins here. + +# Get the name of the program (without the directory part) for use in +# error messages. +program = os.path.basename(sys.argv[0]) + +# We assume that the directory that the Python script is in also +# houses the "special" files. +programDir = os.path.dirname(sys.argv[0]) + +# Set default values +verbose = 0 +functionList = "APIspec.txt" +version = "GLES1.1" + +# Allow for command-line switches +import getopt, time +options = "hvV:S:" +try: + optlist, args = getopt.getopt(sys.argv[1:], options) +except getopt.GetoptError, message: + sys.stderr.write("%s: %s. Use -h for help.\n" % (program, message)) + sys.exit(1) + +for option, optarg in optlist: + if option == "-h": + sys.stderr.write("Usage: %s [-%s]\n" % (program, options)) + sys.stderr.write("Parse an API specification file and generate wrapper functions for a given GLES version\n") + sys.stderr.write("-h gives help\n") + sys.stderr.write("-v is verbose\n") + sys.stderr.write("-V specifies GLES version to generate [%s]:\n" % version) + for key in VersionSpecificValues.keys(): + sys.stderr.write(" %s - %s\n" % (key, VersionSpecificValues[key]['description'])) + sys.stderr.write("-S specifies API specification file to use [%s]\n" % functionList) + sys.exit(1) + elif option == "-v": + verbose += 1 + elif option == "-V": + version = optarg + elif option == "-S": + functionList = optarg + +# Beyond switches, we support no further command-line arguments +if len(args) > 0: + sys.stderr.write("%s: only switch arguments are supported - use -h for help\n" % program) + sys.exit(1) + +# If we don't have a valid version, abort. +if not VersionSpecificValues.has_key(version): + sys.stderr.write("%s: version '%s' is not valid - use -h for help\n" % (program, version)) + sys.exit(1) + +# Grab the version-specific items we need to use +versionHeader = VersionSpecificValues[version]['header'] +versionExtHeader = VersionSpecificValues[version]['extheader'] +versionSpecial = VersionSpecificValues[version]['special'] + +# We're probably being invoked from a different directory, +# so look for the "special" file in the same directory that +# holds the Python script +specialFile = os.path.join(programDir, versionSpecial) +if not os.path.isfile(specialFile): + sys.stderr.write("%s: can't find special file '%s' for version '%s' - aborting" % (program, specialFile, version)) + sys.exit(1) + +allSpecials = apiutil.AllSpecials(specialFile.split("_")[0]) + +# If we get to here, we're good to go. The "version" parameter +# directs GetDispatchedFunctions to only allow functions from +# that "category" (version in our parlance). This allows +# functions with different declarations in different categories +# to exist (glTexImage2D, for example, is different between +# GLES1 and GLES2). +keys = apiutil.GetAllFunctions(functionList, version) + +print """/* DO NOT EDIT ************************************************* + * THIS FILE AUTOMATICALLY GENERATED BY THE %s SCRIPT + * API specification file: %s + * GLES version: %s + * date: %s + */ +""" % (program, functionList, version, time.strftime("%Y-%m-%d %H:%M:%S")) + +# The headers we choose are version-specific. +print """ +#include "%s" +#include "%s" +""" % (versionHeader, versionExtHeader) + +# Everyone needs these types. +print """ +/* These types are needed for the Mesa veneer, but are not defined in + * the standard GLES headers. + */ +typedef double GLdouble; +typedef double GLclampd; + +/* This type is normally in glext.h, but needed here */ +typedef char GLchar; + +/* Mesa error handling requires these */ +extern void *_mesa_get_current_context(void); +extern void _mesa_error(void *ctx, GLenum error, const char *fmtString, ... ); + +#include "main/compiler.h" +#include "main/api_exec.h" + +#include "glapi/dispatch.h" + +typedef void (*_glapi_proc)(void); /* generic function pointer */ +""" + +# All variant-length arrays in the GLES API are controlled by some +# selector parameter. Almost all of those are constant length based +# on the selector parameter (e.g., in glFogfv(), if the "pname" +# parameter is GL_FOG_COLOR, the "params" array is considered to be +# 4 floats long; for any other value of "pname", the "params' array +# is considered to be 1 float long. +# +# There are a very few instances where the selector parameter chooses +# a runtime-determined value: +# glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS) +# glGetIntegerv(GL_SHADER_BINARY_FORMATS) +# plus the glGetBooleanv, glGetFloatv, glGetFixedv counterparts. +# +# The number of formats in both cases is not a constant, but is a +# runtime-determined value (based on the return value of +# glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS) or +# glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS). +# +# Rather than hard-code some value (and risk memory errors when we +# overshoot arrays), in these cases we'll use a constant expresssion +# (e.g. _get_size(GL_NUM_COMPRESSED_TEXTURE_FORMATS)) to get the +# value of the variant array. Note, though, that in these cases the +# "vector" parameter should be set to some size large enough to hold +# all values (and must be set for GLfixed-based conversions, which +# need it to define an auxiliary array size). +# +# Here's the function itself. Although we only need a couple of values, +# we'll make it general. +print """ +extern void GLAPIENTRY _mesa_GetIntegerv(GLenum, GLint *); +static INLINE unsigned int _get_size(GLenum pname) +{ + /* In case of error, make sure the value returned is 0. */ + GLint value = 0; + _mesa_GetIntegerv(pname, &value); + return (unsigned int) value; +} +""" + +# Finally we get to the all-important functions +print """/************************************************************* + * Generated functions begin here + */ +""" +for funcName in keys: + if verbose > 0: sys.stderr.write("%s: processing function %s\n" % (program, funcName)) + + # start figuring out what this function will look like. + returnType = apiutil.ReturnType(funcName) + props = apiutil.Properties(funcName) + params = apiutil.Parameters(funcName) + declarationString = apiutil.MakeDeclarationString(params) + + # In case of error, a function may have to return. Make + # sure we have valid return values in this case. + if returnType == "void": + errorReturn = "return" + elif returnType == "GLboolean": + errorReturn = "return GL_FALSE" + else: + errorReturn = "return (%s) 0" % returnType + + # These are the output of this large calculation block. + # passthroughDeclarationString: a typed set of parameters that + # will be used to create the "extern" reference for the + # underlying Mesa or support function. Note that as generated + # these have an extra ", " at the beginning, which will be + # removed before use. + # + # passthroughDeclarationString: an untyped list of parameters + # that will be used to call the underlying Mesa or support + # function (including references to converted parameters). + # This will also be generated with an extra ", " at the + # beginning, which will be removed before use. + # + # variables: C code to create any local variables determined to + # be necessary. + # conversionCodeOutgoing: C code to convert application parameters + # to a necessary type before calling the underlying support code. + # May be empty if no conversion is required. + # conversionCodeIncoming: C code to do the converse: convert + # values returned by underlying Mesa code to the types needed + # by the application. + # Note that *either* the conversionCodeIncoming will be used (for + # generated query functions), *or* the conversionCodeOutgoing will + # be used (for generated non-query functions), never both. + passthroughFuncName = "" + passthroughDeclarationString = "" + passthroughCallString = "" + variables = [] + conversionCodeOutgoing = [] + conversionCodeIncoming = [] + switchCode = [] + + # Calculate the name of the underlying support function to call. + # By default, the passthrough function is named _mesa_. + # We're allowed to override the prefix and/or the function name + # for each function record, though. The "ConversionFunction" + # utility is poorly named, BTW... + aliasprefix = apiutil.AliasPrefix(funcName) + alias = apiutil.ConversionFunction(funcName) + if not alias: + # There may still be a Mesa alias for the function + if apiutil.Alias(funcName): + passthroughFuncName = "%s%s" % (aliasprefix, apiutil.Alias(funcName)) + else: + passthroughFuncName = "%s%s" % (aliasprefix, funcName) + else: # a specific alias is provided + passthroughFuncName = "%s%s" % (aliasprefix, alias) + + # Look at every parameter: each one may have only specific + # allowed values, or dependent parameters to check, or + # variant-sized vector arrays to calculate + for (paramName, paramType, paramMaxVecSize, paramConvertToType, paramValidValues, paramValueConversion) in params: + # We'll need this below if we're doing conversions + (paramBaseType, paramTypeModifiers) = GetBaseType(paramType) + + # Conversion management. + # We'll handle three cases, easiest to hardest: a parameter + # that doesn't require conversion, a scalar parameter that + # requires conversion, and a vector parameter that requires + # conversion. + if paramConvertToType == None: + # Unconverted parameters are easy, whether they're vector + # or scalar - just add them to the call list. No conversions + # or anything to worry about. + passthroughDeclarationString += ", %s %s" % (paramType, paramName) + passthroughCallString += ", %s" % paramName + + elif paramMaxVecSize == 0: # a scalar parameter that needs conversion + # A scalar to hold a converted parameter + variables.append(" %s converted_%s;" % (paramConvertToType, paramName)) + + # Outgoing conversion depends on whether we have to conditionally + # perform value conversion. + if paramValueConversion == "none": + conversionCodeOutgoing.append(" converted_%s = (%s) %s;" % (paramName, paramConvertToType, paramName)) + elif paramValueConversion == "some": + # We'll need a conditional variable to keep track of + # whether we're converting values or not. + if (" int convert_%s_value = 1;" % paramName) not in variables: + variables.append(" int convert_%s_value = 1;" % paramName) + + # Write code based on that conditional. + conversionCodeOutgoing.append(" if (convert_%s_value) {" % paramName) + conversionCodeOutgoing.append(" converted_%s = %s;" % (paramName, ConvertValue(paramName, paramBaseType, paramConvertToType))) + conversionCodeOutgoing.append(" } else {") + conversionCodeOutgoing.append(" converted_%s = (%s) %s;" % (paramName, paramConvertToType, paramName)) + conversionCodeOutgoing.append(" }") + else: # paramValueConversion == "all" + conversionCodeOutgoing.append(" converted_%s = %s;" % (paramName, ConvertValue(paramName, paramBaseType, paramConvertToType))) + + # Note that there can be no incoming conversion for a + # scalar parameter; changing the scalar will only change + # the local value, and won't ultimately change anything + # that passes back to the application. + + # Call strings. The unusual " ".join() call will join the + # array of parameter modifiers with spaces as separators. + passthroughDeclarationString += ", %s %s %s" % (paramConvertToType, " ".join(paramTypeModifiers), paramName) + passthroughCallString += ", converted_%s" % paramName + + else: # a vector parameter that needs conversion + # We'll need an index variable for conversions + if " register unsigned int i;" not in variables: + variables.append(" register unsigned int i;") + + # This variable will hold the (possibly variant) size of + # this array needing conversion. By default, we'll set + # it to the maximal size (which is correct for functions + # with a constant-sized vector parameter); for true + # variant arrays, we'll modify it with other code. + variables.append(" unsigned int n_%s = %d;" % (paramName, paramMaxVecSize)) + + # This array will hold the actual converted values. + variables.append(" %s converted_%s[%d];" % (paramConvertToType, paramName, paramMaxVecSize)) + + # Again, we choose the conversion code based on whether we + # have to always convert values, never convert values, or + # conditionally convert values. + if paramValueConversion == "none": + conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeOutgoing.append(" converted_%s[i] = (%s) %s[i];" % (paramName, paramConvertToType, paramName)) + conversionCodeOutgoing.append(" }") + elif paramValueConversion == "some": + # We'll need a conditional variable to keep track of + # whether we're converting values or not. + if (" int convert_%s_value = 1;" % paramName) not in variables: + variables.append(" int convert_%s_value = 1;" % paramName) + # Write code based on that conditional. + conversionCodeOutgoing.append(" if (convert_%s_value) {" % paramName) + conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeOutgoing.append(" converted_%s[i] = %s;" % (paramName, ConvertValue("%s[i]" % paramName, paramBaseType, paramConvertToType))) + conversionCodeOutgoing.append(" }") + conversionCodeOutgoing.append(" } else {") + conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeOutgoing.append(" converted_%s[i] = (%s) %s[i];" % (paramName, paramConvertToType, paramName)) + conversionCodeOutgoing.append(" }") + conversionCodeOutgoing.append(" }") + else: # paramValueConversion == "all" + conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeOutgoing.append(" converted_%s[i] = %s;" % (paramName, ConvertValue("%s[i]" % paramName, paramBaseType, paramConvertToType))) + + conversionCodeOutgoing.append(" }") + + # If instead we need an incoming conversion (i.e. results + # from Mesa have to be converted before handing back + # to the application), this is it. Fortunately, we don't + # have to worry about conditional value conversion - the + # functions that do (e.g. glGetFixedv()) are handled + # specially, outside this code generation. + # + # Whether we use incoming conversion or outgoing conversion + # is determined later - we only ever use one or the other. + + if paramValueConversion == "none": + conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeIncoming.append(" %s[i] = (%s) converted_%s[i];" % (paramName, paramConvertToType, paramName)) + conversionCodeIncoming.append(" }") + elif paramValueConversion == "some": + # We'll need a conditional variable to keep track of + # whether we're converting values or not. + if (" int convert_%s_value = 1;" % paramName) not in variables: + variables.append(" int convert_%s_value = 1;" % paramName) + + # Write code based on that conditional. + conversionCodeIncoming.append(" if (convert_%s_value) {" % paramName) + conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeIncoming.append(" %s[i] = %s;" % (paramName, ConvertValue("converted_%s[i]" % paramName, paramConvertToType, paramBaseType))) + conversionCodeIncoming.append(" }") + conversionCodeIncoming.append(" } else {") + conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeIncoming.append(" %s[i] = (%s) converted_%s[i];" % (paramName, paramBaseType, paramName)) + conversionCodeIncoming.append(" }") + conversionCodeIncoming.append(" }") + else: # paramValueConversion == "all" + conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName) + conversionCodeIncoming.append(" %s[i] = %s;" % (paramName, ConvertValue("converted_%s[i]" % paramName, paramConvertToType, paramBaseType))) + conversionCodeIncoming.append(" }") + + # Call strings. The unusual " ".join() call will join the + # array of parameter modifiers with spaces as separators. + passthroughDeclarationString += ", %s %s %s" % (paramConvertToType, " ".join(paramTypeModifiers), paramName) + passthroughCallString += ", converted_%s" % paramName + + # endif conversion management + + # Parameter checking. If the parameter has a specific list of + # valid values, we have to make sure that the passed-in values + # match these, or we make an error. + if len(paramValidValues) > 0: + # We're about to make a big switch statement with an + # error at the end. By default, the error is GL_INVALID_ENUM, + # unless we find a "case" statement in the middle with a + # non-GLenum value. + errorDefaultCase = "GL_INVALID_ENUM" + + # This parameter has specific valid values. Make a big + # switch statement to handle it. Note that the original + # parameters are always what is checked, not the + # converted parameters. + switchCode.append(" switch(%s) {" % paramName) + + for valueIndex in range(len(paramValidValues)): + (paramValue, dependentVecSize, dependentParamName, dependentValidValues, errorCode, valueConvert) = paramValidValues[valueIndex] + + # We're going to need information on the dependent param + # as well. + if dependentParamName: + depParamIndex = apiutil.FindParamIndex(params, dependentParamName) + if depParamIndex == None: + sys.stderr.write("%s: can't find dependent param '%s' for function '%s'\n" % (program, dependentParamName, funcName)) + + (depParamName, depParamType, depParamMaxVecSize, depParamConvertToType, depParamValidValues, depParamValueConversion) = params[depParamIndex] + else: + (depParamName, depParamType, depParamMaxVecSize, depParamConvertToType, depParamValidValues, depParamValueConversion) = (None, None, None, None, [], None) + + # This is a sneaky trick. It's valid syntax for a parameter + # that is *not* going to be converted to be declared + # with a dependent vector size; but in this case, the + # dependent vector size is unused and unnecessary. + # So check for this and ignore the dependent vector size + # if the parameter is not going to be converted. + if depParamConvertToType: + usedDependentVecSize = dependentVecSize + else: + usedDependentVecSize = None + + # We'll peek ahead at the next parameter, to see whether + # we can combine cases + if valueIndex + 1 < len(paramValidValues) : + (nextParamValue, nextDependentVecSize, nextDependentParamName, nextDependentValidValues, nextErrorCode, nextValueConvert) = paramValidValues[valueIndex + 1] + if depParamConvertToType: + usedNextDependentVecSize = nextDependentVecSize + else: + usedNextDependentVecSize = None + + # Create a case for this value. As a mnemonic, + # if we have a dependent vector size that we're ignoring, + # add it as a comment. + if usedDependentVecSize == None and dependentVecSize != None: + switchCode.append(" case %s: /* size %s */" % (paramValue, dependentVecSize)) + else: + switchCode.append(" case %s:" % paramValue) + + # If this is not a GLenum case, then switch our error + # if no value is matched to be GL_INVALID_VALUE instead + # of GL_INVALID_ENUM. (Yes, this does get confused + # if there are both values and GLenums in the same + # switch statement, which shouldn't happen.) + if paramValue[0:3] != "GL_": + errorDefaultCase = "GL_INVALID_VALUE" + + # If all the remaining parameters are identical to the + # next set, then we're done - we'll just create the + # official code on the next pass through, and the two + # cases will share the code. + if valueIndex + 1 < len(paramValidValues) and usedDependentVecSize == usedNextDependentVecSize and dependentParamName == nextDependentParamName and dependentValidValues == nextDependentValidValues and errorCode == nextErrorCode and valueConvert == nextValueConvert: + continue + + # Otherwise, we'll have to generate code for this case. + # Start off with a check: if there is a dependent parameter, + # and a list of valid values for that parameter, we need + # to generate an error if something other than one + # of those values is passed. + if len(dependentValidValues) > 0: + conditional="" + + # If the parameter being checked is actually an array, + # check only its first element. + if depParamMaxVecSize == 0: + valueToCheck = dependentParamName + else: + valueToCheck = "%s[0]" % dependentParamName + + for v in dependentValidValues: + conditional += " && %s != %s" % (valueToCheck, v) + switchCode.append(" if (%s) {" % conditional[4:]) + if errorCode == None: + errorCode = "GL_INVALID_ENUM" + switchCode.append(' _mesa_error(_mesa_get_current_context(), %s, "gl%s(%s=0x%s)", %s);' % (errorCode, funcName, paramName, "%x", paramName)) + switchCode.append(" %s;" % errorReturn) + switchCode.append(" }") + # endif there are dependent valid values + + # The dependent parameter may require conditional + # value conversion. If it does, and we don't want + # to convert values, we'll have to generate code for that + if depParamValueConversion == "some" and valueConvert == "noconvert": + switchCode.append(" convert_%s_value = 0;" % dependentParamName) + + # If there's a dependent vector size for this parameter + # that we're actually going to use (i.e. we need conversion), + # mark it. + if usedDependentVecSize: + switchCode.append(" n_%s = %s;" % (dependentParamName, dependentVecSize)) + + # In all cases, break out of the switch if any valid + # value is found. + switchCode.append(" break;") + + + # Need a default case to catch all the other, invalid + # parameter values. These will all generate errors. + switchCode.append(" default:") + if errorCode == None: + errorCode = "GL_INVALID_ENUM" + formatString = GetFormatString(paramType) + if formatString == None: + switchCode.append(' _mesa_error(_mesa_get_current_context(), %s, "gl%s(%s)");' % (errorCode, funcName, paramName)) + else: + switchCode.append(' _mesa_error(_mesa_get_current_context(), %s, "gl%s(%s=%s)", %s);' % (errorCode, funcName, paramName, formatString, paramName)) + switchCode.append(" %s;" % errorReturn) + + # End of our switch code. + switchCode.append(" }") + + # endfor every recognized parameter value + + # endfor every param + + # Here, the passthroughDeclarationString and passthroughCallString + # are complete; remove the extra ", " at the front of each. + passthroughDeclarationString = passthroughDeclarationString[2:] + passthroughCallString = passthroughCallString[2:] + + # The Mesa functions are scattered across all the Mesa + # header files. The easiest way to manage declarations + # is to create them ourselves. + if funcName not in allSpecials: + print "extern %s GLAPIENTRY %s(%s);" % (returnType, passthroughFuncName, passthroughDeclarationString) + + # A function may be a core function (i.e. it exists in + # the core specification), a core addition (extension + # functions added officially to the core), a required + # extension (usually an extension for an earlier version + # that has been officially adopted), or an optional extension. + # + # Core functions have a simple category (e.g. "GLES1.1"); + # we generate only a simple callback for them. + # + # Core additions have two category listings, one simple + # and one compound (e.g. ["GLES1.1", "GLES1.1:OES_fixed_point"]). + # We generate the core function, and also an extension function. + # + # Required extensions and implemented optional extensions + # have a single compound category "GLES1.1:OES_point_size_array". + # For these we generate just the extension function. + for categorySpec in apiutil.Categories(funcName): + compoundCategory = categorySpec.split(":") + + # This category isn't for us, if the base category doesn't match + # our version + if compoundCategory[0] != version: + continue + + # Otherwise, determine if we're writing code for a core + # function (no suffix) or an extension function. + if len(compoundCategory) == 1: + # This is a core function + extensionName = None + fullFuncName = "_es_" + funcName + else: + # This is an extension function. We'll need to append + # the extension suffix. + extensionName = compoundCategory[1] + extensionSuffix = extensionName.split("_")[0] + fullFuncName = "_es_" + funcName + extensionSuffix + + # Now the generated function. The text used to mark an API-level + # function, oddly, is version-specific. + if extensionName: + print "/* Extension %s */" % extensionName + + if funcName in allSpecials: + print "/* this function is special and is defined elsewhere */" + print "extern %s %s(%s);" % (returnType, fullFuncName, declarationString) + print + continue + + print "static %s %s(%s)" % (returnType, fullFuncName, declarationString) + print "{" + + # Start printing our code pieces. Start with any local + # variables we need. This unusual syntax joins the + # lines in the variables[] array with the "\n" separator. + if len(variables) > 0: + print "\n".join(variables) + "\n" + + # If there's any sort of parameter checking or variable + # array sizing, the switch code will contain it. + if len(switchCode) > 0: + print "\n".join(switchCode) + "\n" + + # In the case of an outgoing conversion (i.e. parameters must + # be converted before calling the underlying Mesa function), + # use the appropriate code. + if "get" not in props and len(conversionCodeOutgoing) > 0: + print "\n".join(conversionCodeOutgoing) + "\n" + + # Call the Mesa function. Note that there are very few functions + # that return a value (i.e. returnType is not "void"), and that + # none of them require incoming translation; so we're safe + # to generate code that directly returns in those cases, + # even though it's not completely independent. + + if returnType == "void": + print " %s(%s);" % (passthroughFuncName, passthroughCallString) + else: + print " return %s(%s);" % (passthroughFuncName, passthroughCallString) + + # If the function is one that returns values (i.e. "get" in props), + # it might return values of a different type than we need, that + # require conversion before passing back to the application. + if "get" in props and len(conversionCodeIncoming) > 0: + print "\n".join(conversionCodeIncoming) + + # All done. + print "}" + print + # end for each category provided for a function + +# end for each function + +print "void" +print "_mesa_init_exec_table(struct _glapi_table *exec)" +print "{" +for func in keys: + for spec in apiutil.Categories(func): + ext = spec.split(":") + # version does not match + if ext.pop(0) != version: + continue + entry = func + if ext: + suffix = ext[0].split("_")[0] + entry += suffix + print " SET_%s(exec, _es_%s);" % (entry, entry) +print "}" diff --git a/src/mesa/es/main/es_query_matrix.c b/src/mesa/es/main/es_query_matrix.c new file mode 100644 index 0000000000..82b6fe7ab9 --- /dev/null +++ b/src/mesa/es/main/es_query_matrix.c @@ -0,0 +1,199 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + **************************************************************************/ + + +/** + * Code to implement GL_OES_query_matrix. See the spec at: + * http://www.khronos.org/registry/gles/extensions/OES/OES_query_matrix.txt + */ + + +#include +#include +#include "GLES/gl.h" +#include "GLES/glext.h" + + +/** + * This is from the GL_OES_query_matrix extension specification: + * + * GLbitfield glQueryMatrixxOES( GLfixed mantissa[16], + * GLint exponent[16] ) + * mantissa[16] contains the contents of the current matrix in GLfixed + * format. exponent[16] contains the unbiased exponents applied to the + * matrix components, so that the internal representation of component i + * is close to mantissa[i] * 2^exponent[i]. The function returns a status + * word which is zero if all the components are valid. If + * status & (1< + +enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL} +fpclassify(double x) +{ + switch(_fpclass(x)) { + case _FPCLASS_SNAN: /* signaling NaN */ + case _FPCLASS_QNAN: /* quiet NaN */ + return FP_NAN; + case _FPCLASS_NINF: /* negative infinity */ + case _FPCLASS_PINF: /* positive infinity */ + return FP_INFINITE; + case _FPCLASS_NN: /* negative normal */ + case _FPCLASS_PN: /* positive normal */ + return FP_NORMAL; + case _FPCLASS_ND: /* negative denormalized */ + case _FPCLASS_PD: /* positive denormalized */ + return FP_SUBNORMAL; + case _FPCLASS_NZ: /* negative zero */ + case _FPCLASS_PZ: /* positive zero */ + return FP_ZERO; + default: + /* Should never get here; but if we do, this will guarantee + * that the pattern is not treated like a number. + */ + return FP_NAN; + } +} +#endif + +extern GLbitfield GL_APIENTRY _es_QueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16]); + +/* The Mesa functions we'll need */ +extern void GL_APIENTRY _mesa_GetIntegerv(GLenum pname, GLint *params); +extern void GL_APIENTRY _mesa_GetFloatv(GLenum pname, GLfloat *params); + +GLbitfield GL_APIENTRY _es_QueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16]) +{ + GLfloat matrix[16]; + GLint tmp; + GLenum currentMode = GL_FALSE; + GLenum desiredMatrix = GL_FALSE; + /* The bitfield returns 1 for each component that is invalid (i.e. + * NaN or Inf). In case of error, everything is invalid. + */ + GLbitfield rv; + register unsigned int i; + unsigned int bit; + + /* This data structure defines the mapping between the current matrix + * mode and the desired matrix identifier. + */ + static struct { + GLenum currentMode; + GLenum desiredMatrix; + } modes[] = { + {GL_MODELVIEW, GL_MODELVIEW_MATRIX}, + {GL_PROJECTION, GL_PROJECTION_MATRIX}, + {GL_TEXTURE, GL_TEXTURE_MATRIX}, +#if 0 + /* this doesn't exist in GLES */ + {GL_COLOR, GL_COLOR_MATRIX}, +#endif + }; + + /* Call Mesa to get the current matrix in floating-point form. First, + * we have to figure out what the current matrix mode is. + */ + _mesa_GetIntegerv(GL_MATRIX_MODE, &tmp); + currentMode = (GLenum) tmp; + + /* The mode is either GL_FALSE, if for some reason we failed to query + * the mode, or a given mode from the above table. Search for the + * returned mode to get the desired matrix; if we don't find it, + * we can return immediately, as _mesa_GetInteger() will have + * logged the necessary error already. + */ + for (i = 0; i < sizeof(modes)/sizeof(modes[0]); i++) { + if (modes[i].currentMode == currentMode) { + desiredMatrix = modes[i].desiredMatrix; + break; + } + } + if (desiredMatrix == GL_FALSE) { + /* Early error means all values are invalid. */ + return 0xffff; + } + + /* Now pull the matrix itself. */ + _mesa_GetFloatv(desiredMatrix, matrix); + + rv = 0; + for (i = 0, bit = 1; i < 16; i++, bit<<=1) { + float normalizedFraction; + int exp; + + switch (fpclassify(matrix[i])) { + /* A "subnormal" or denormalized number is too small to be + * represented in normal format; but despite that it's a + * valid floating point number. FP_ZERO and FP_NORMAL + * are both valid as well. We should be fine treating + * these three cases as legitimate floating-point numbers. + */ + case FP_SUBNORMAL: + case FP_NORMAL: + case FP_ZERO: + normalizedFraction = (GLfloat)frexp(matrix[i], &exp); + mantissa[i] = FLOAT_TO_FIXED(normalizedFraction); + exponent[i] = (GLint) exp; + break; + + /* If the entry is not-a-number or an infinity, then the + * matrix component is invalid. The invalid flag for + * the component is already set; might as well set the + * other return values to known values. We'll set + * distinct values so that a savvy end user could determine + * whether the matrix component was a NaN or an infinity, + * but this is more useful for debugging than anything else + * since the standard doesn't specify any such magic + * values to return. + */ + case FP_NAN: + mantissa[i] = INT_TO_FIXED(0); + exponent[i] = (GLint) 0; + rv |= bit; + break; + + case FP_INFINITE: + /* Return +/- 1 based on whether it's a positive or + * negative infinity. + */ + if (matrix[i] > 0) { + mantissa[i] = INT_TO_FIXED(1); + } + else { + mantissa[i] = -INT_TO_FIXED(1); + } + exponent[i] = (GLint) 0; + rv |= bit; + break; + + /* We should never get here; but here's a catching case + * in case fpclassify() is returnings something unexpected. + */ + default: + mantissa[i] = INT_TO_FIXED(2); + exponent[i] = (GLint) 0; + rv |= bit; + break; + } + + } /* for each component */ + + /* All done */ + return rv; +} diff --git a/src/mesa/es/main/get_gen.py b/src/mesa/es/main/get_gen.py new file mode 100644 index 0000000000..516facc8a3 --- /dev/null +++ b/src/mesa/es/main/get_gen.py @@ -0,0 +1,785 @@ +#!/usr/bin/env python + +# Mesa 3-D graphics library +# +# Copyright (C) 1999-2006 Brian Paul All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# BRIAN PAUL 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. + + +# This script is used to generate the get.c file: +# python get_gen.py > get.c + + +import string +import sys + + +GLint = 1 +GLenum = 2 +GLfloat = 3 +GLdouble = 4 +GLboolean = 5 +GLfloatN = 6 # A normalized value, such as a color or depth range + + +TypeStrings = { + GLint : "GLint", + GLenum : "GLenum", + GLfloat : "GLfloat", + GLdouble : "GLdouble", + GLboolean : "GLboolean" +} + + +# Each entry is a tuple of: +# - the GL state name, such as GL_CURRENT_COLOR +# - the state datatype, one of GLint, GLfloat, GLboolean or GLenum +# - list of code fragments to get the state, such as ["ctx->Foo.Bar"] +# - optional extra code or empty string +# - optional extensions to check, or None +# + +# Present in ES 1.x and 2.x: +StateVars_common = [ + ( "GL_ALPHA_BITS", GLint, ["ctx->DrawBuffer->Visual.alphaBits"], + "", None ), + ( "GL_BLEND", GLboolean, ["ctx->Color.BlendEnabled"], "", None ), + ( "GL_BLEND_SRC", GLenum, ["ctx->Color.BlendSrcRGB"], "", None ), + ( "GL_BLUE_BITS", GLint, ["ctx->DrawBuffer->Visual.blueBits"], "", None ), + ( "GL_COLOR_CLEAR_VALUE", GLfloatN, + [ "ctx->Color.ClearColor[0]", + "ctx->Color.ClearColor[1]", + "ctx->Color.ClearColor[2]", + "ctx->Color.ClearColor[3]" ], "", None ), + ( "GL_COLOR_WRITEMASK", GLint, + [ "ctx->Color.ColorMask[RCOMP] ? 1 : 0", + "ctx->Color.ColorMask[GCOMP] ? 1 : 0", + "ctx->Color.ColorMask[BCOMP] ? 1 : 0", + "ctx->Color.ColorMask[ACOMP] ? 1 : 0" ], "", None ), + ( "GL_CULL_FACE", GLboolean, ["ctx->Polygon.CullFlag"], "", None ), + ( "GL_CULL_FACE_MODE", GLenum, ["ctx->Polygon.CullFaceMode"], "", None ), + ( "GL_DEPTH_BITS", GLint, ["ctx->DrawBuffer->Visual.depthBits"], + "", None ), + ( "GL_DEPTH_CLEAR_VALUE", GLfloatN, ["ctx->Depth.Clear"], "", None ), + ( "GL_DEPTH_FUNC", GLenum, ["ctx->Depth.Func"], "", None ), + ( "GL_DEPTH_RANGE", GLfloatN, + [ "ctx->Viewport.Near", "ctx->Viewport.Far" ], "", None ), + ( "GL_DEPTH_TEST", GLboolean, ["ctx->Depth.Test"], "", None ), + ( "GL_DEPTH_WRITEMASK", GLboolean, ["ctx->Depth.Mask"], "", None ), + ( "GL_DITHER", GLboolean, ["ctx->Color.DitherFlag"], "", None ), + ( "GL_FRONT_FACE", GLenum, ["ctx->Polygon.FrontFace"], "", None ), + ( "GL_GREEN_BITS", GLint, ["ctx->DrawBuffer->Visual.greenBits"], + "", None ), + ( "GL_LINE_WIDTH", GLfloat, ["ctx->Line.Width"], "", None ), + ( "GL_ALIASED_LINE_WIDTH_RANGE", GLfloat, + ["ctx->Const.MinLineWidth", + "ctx->Const.MaxLineWidth"], "", None ), + ( "GL_MAX_ELEMENTS_INDICES", GLint, ["ctx->Const.MaxArrayLockSize"], "", None ), + ( "GL_MAX_ELEMENTS_VERTICES", GLint, ["ctx->Const.MaxArrayLockSize"], "", None ), + + ( "GL_MAX_TEXTURE_SIZE", GLint, ["1 << (ctx->Const.MaxTextureLevels - 1)"], "", None ), + ( "GL_MAX_VIEWPORT_DIMS", GLint, + ["ctx->Const.MaxViewportWidth", "ctx->Const.MaxViewportHeight"], + "", None ), + ( "GL_PACK_ALIGNMENT", GLint, ["ctx->Pack.Alignment"], "", None ), + ( "GL_ALIASED_POINT_SIZE_RANGE", GLfloat, + ["ctx->Const.MinPointSize", + "ctx->Const.MaxPointSize"], "", None ), + ( "GL_POLYGON_OFFSET_FACTOR", GLfloat, ["ctx->Polygon.OffsetFactor "], "", None ), + ( "GL_POLYGON_OFFSET_UNITS", GLfloat, ["ctx->Polygon.OffsetUnits "], "", None ), + ( "GL_RED_BITS", GLint, ["ctx->DrawBuffer->Visual.redBits"], "", None ), + ( "GL_SCISSOR_BOX", GLint, + ["ctx->Scissor.X", + "ctx->Scissor.Y", + "ctx->Scissor.Width", + "ctx->Scissor.Height"], "", None ), + ( "GL_SCISSOR_TEST", GLboolean, ["ctx->Scissor.Enabled"], "", None ), + ( "GL_STENCIL_BITS", GLint, ["ctx->DrawBuffer->Visual.stencilBits"], "", None ), + ( "GL_STENCIL_CLEAR_VALUE", GLint, ["ctx->Stencil.Clear"], "", None ), + ( "GL_STENCIL_FAIL", GLenum, + ["ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]"], "", None ), + ( "GL_STENCIL_FUNC", GLenum, + ["ctx->Stencil.Function[ctx->Stencil.ActiveFace]"], "", None ), + ( "GL_STENCIL_PASS_DEPTH_FAIL", GLenum, + ["ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace]"], "", None ), + ( "GL_STENCIL_PASS_DEPTH_PASS", GLenum, + ["ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]"], "", None ), + ( "GL_STENCIL_REF", GLint, + ["ctx->Stencil.Ref[ctx->Stencil.ActiveFace]"], "", None ), + ( "GL_STENCIL_TEST", GLboolean, ["ctx->Stencil.Enabled"], "", None ), + ( "GL_STENCIL_VALUE_MASK", GLint, + ["ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]"], "", None ), + ( "GL_STENCIL_WRITEMASK", GLint, + ["ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]"], "", None ), + ( "GL_SUBPIXEL_BITS", GLint, ["ctx->Const.SubPixelBits"], "", None ), + ( "GL_TEXTURE_BINDING_2D", GLint, + ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_INDEX]->Name"], "", None ), + ( "GL_UNPACK_ALIGNMENT", GLint, ["ctx->Unpack.Alignment"], "", None ), + ( "GL_VIEWPORT", GLint, [ "ctx->Viewport.X", "ctx->Viewport.Y", + "ctx->Viewport.Width", "ctx->Viewport.Height" ], "", None ), + + # GL_ARB_multitexture + ( "GL_ACTIVE_TEXTURE_ARB", GLint, + [ "GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit"], "", ["ARB_multitexture"] ), + + # Note that all the OES_* extensions require that the Mesa + # "struct gl_extensions" include a member with the name of + # the extension. That structure does not yet include OES + # extensions (and we're not sure whether it will). If + # it does, all the OES_* extensions below should mark the + # dependency. + + # OES_texture_cube_map + ( "GL_TEXTURE_BINDING_CUBE_MAP_ARB", GLint, + ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_CUBE_INDEX]->Name"], + "", None), + ( "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB", GLint, + ["(1 << (ctx->Const.MaxCubeTextureLevels - 1))"], + "", None), + + # OES_blend_subtract + ( "GL_BLEND_SRC_RGB_EXT", GLenum, ["ctx->Color.BlendSrcRGB"], "", None), + ( "GL_BLEND_DST_RGB_EXT", GLenum, ["ctx->Color.BlendDstRGB"], "", None), + ( "GL_BLEND_SRC_ALPHA_EXT", GLenum, ["ctx->Color.BlendSrcA"], "", None), + ( "GL_BLEND_DST_ALPHA_EXT", GLenum, ["ctx->Color.BlendDstA"], "", None), + + # GL_BLEND_EQUATION_RGB, which is what we're really after, + # is defined identically to GL_BLEND_EQUATION. + ( "GL_BLEND_EQUATION", GLenum, ["ctx->Color.BlendEquationRGB "], "", None), + ( "GL_BLEND_EQUATION_ALPHA_EXT", GLenum, ["ctx->Color.BlendEquationA "], + "", None), + + # GL_ARB_texture_compression */ +# ( "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB", GLint, +# ["_mesa_get_compressed_formats(ctx, NULL, GL_FALSE)"], +# "", ["ARB_texture_compression"] ), +# ( "GL_COMPRESSED_TEXTURE_FORMATS_ARB", GLenum, +# [], +# """GLint formats[100]; +# GLuint i, n = _mesa_get_compressed_formats(ctx, formats, GL_FALSE); +# ASSERT(n <= 100); +# for (i = 0; i < n; i++) +# params[i] = ENUM_TO_INT(formats[i]);""", +# ["ARB_texture_compression"] ), + + # GL_ARB_multisample + ( "GL_SAMPLE_ALPHA_TO_COVERAGE_ARB", GLboolean, + ["ctx->Multisample.SampleAlphaToCoverage"], "", ["ARB_multisample"] ), + ( "GL_SAMPLE_COVERAGE_ARB", GLboolean, + ["ctx->Multisample.SampleCoverage"], "", ["ARB_multisample"] ), + ( "GL_SAMPLE_COVERAGE_VALUE_ARB", GLfloat, + ["ctx->Multisample.SampleCoverageValue"], "", ["ARB_multisample"] ), + ( "GL_SAMPLE_COVERAGE_INVERT_ARB", GLboolean, + ["ctx->Multisample.SampleCoverageInvert"], "", ["ARB_multisample"] ), + ( "GL_SAMPLE_BUFFERS_ARB", GLint, + ["ctx->DrawBuffer->Visual.sampleBuffers"], "", ["ARB_multisample"] ), + ( "GL_SAMPLES_ARB", GLint, + ["ctx->DrawBuffer->Visual.samples"], "", ["ARB_multisample"] ), + + + # GL_SGIS_generate_mipmap + ( "GL_GENERATE_MIPMAP_HINT_SGIS", GLenum, ["ctx->Hint.GenerateMipmap"], + "", ["SGIS_generate_mipmap"] ), + + # GL_ARB_vertex_buffer_object + ( "GL_ARRAY_BUFFER_BINDING_ARB", GLint, + ["ctx->Array.ArrayBufferObj->Name"], "", ["ARB_vertex_buffer_object"] ), + # GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB - not supported + ( "GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB", GLint, + ["ctx->Array.ElementArrayBufferObj->Name"], + "", ["ARB_vertex_buffer_object"] ), + + # GL_OES_read_format + ( "GL_IMPLEMENTATION_COLOR_READ_TYPE_OES", GLint, + ["ctx->Const.ColorReadType"], "", None), + ( "GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES", GLint, + ["ctx->Const.ColorReadFormat"], "", None), + + # GL_OES_framebuffer_object + ( "GL_FRAMEBUFFER_BINDING_EXT", GLint, ["ctx->DrawBuffer->Name"], "", + None), + ( "GL_RENDERBUFFER_BINDING_EXT", GLint, + ["ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0"], "", + None), + ( "GL_MAX_RENDERBUFFER_SIZE_EXT", GLint, + ["ctx->Const.MaxRenderbufferSize"], "", + None), + + # OpenGL ES 1/2 special: + ( "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB", GLint, + [ "ARRAY_SIZE(compressed_formats)" ], + "", + None ), + + ("GL_COMPRESSED_TEXTURE_FORMATS_ARB", GLint, + [], + """ + int i; + for (i = 0; i < ARRAY_SIZE(compressed_formats); i++) { + params[i] = compressed_formats[i]; + }""", + None ), + + ( "GL_POLYGON_OFFSET_FILL", GLboolean, ["ctx->Polygon.OffsetFill"], "", None ), + +] + +# Only present in ES 1.x: +StateVars_es1 = [ + ( "GL_MAX_LIGHTS", GLint, ["ctx->Const.MaxLights"], "", None ), + ( "GL_LIGHT0", GLboolean, ["ctx->Light.Light[0].Enabled"], "", None ), + ( "GL_LIGHT1", GLboolean, ["ctx->Light.Light[1].Enabled"], "", None ), + ( "GL_LIGHT2", GLboolean, ["ctx->Light.Light[2].Enabled"], "", None ), + ( "GL_LIGHT3", GLboolean, ["ctx->Light.Light[3].Enabled"], "", None ), + ( "GL_LIGHT4", GLboolean, ["ctx->Light.Light[4].Enabled"], "", None ), + ( "GL_LIGHT5", GLboolean, ["ctx->Light.Light[5].Enabled"], "", None ), + ( "GL_LIGHT6", GLboolean, ["ctx->Light.Light[6].Enabled"], "", None ), + ( "GL_LIGHT7", GLboolean, ["ctx->Light.Light[7].Enabled"], "", None ), + ( "GL_LIGHTING", GLboolean, ["ctx->Light.Enabled"], "", None ), + ( "GL_LIGHT_MODEL_AMBIENT", GLfloatN, + ["ctx->Light.Model.Ambient[0]", + "ctx->Light.Model.Ambient[1]", + "ctx->Light.Model.Ambient[2]", + "ctx->Light.Model.Ambient[3]"], "", None ), + ( "GL_LIGHT_MODEL_TWO_SIDE", GLboolean, ["ctx->Light.Model.TwoSide"], "", None ), + ( "GL_ALPHA_TEST", GLboolean, ["ctx->Color.AlphaEnabled"], "", None ), + ( "GL_ALPHA_TEST_FUNC", GLenum, ["ctx->Color.AlphaFunc"], "", None ), + ( "GL_ALPHA_TEST_REF", GLfloatN, ["ctx->Color.AlphaRef"], "", None ), + ( "GL_BLEND_DST", GLenum, ["ctx->Color.BlendDstRGB"], "", None ), + ( "GL_MAX_CLIP_PLANES", GLint, ["ctx->Const.MaxClipPlanes"], "", None ), + ( "GL_CLIP_PLANE0", GLboolean, + [ "(ctx->Transform.ClipPlanesEnabled >> 0) & 1" ], "", None ), + ( "GL_CLIP_PLANE1", GLboolean, + [ "(ctx->Transform.ClipPlanesEnabled >> 1) & 1" ], "", None ), + ( "GL_CLIP_PLANE2", GLboolean, + [ "(ctx->Transform.ClipPlanesEnabled >> 2) & 1" ], "", None ), + ( "GL_CLIP_PLANE3", GLboolean, + [ "(ctx->Transform.ClipPlanesEnabled >> 3) & 1" ], "", None ), + ( "GL_CLIP_PLANE4", GLboolean, + [ "(ctx->Transform.ClipPlanesEnabled >> 4) & 1" ], "", None ), + ( "GL_CLIP_PLANE5", GLboolean, + [ "(ctx->Transform.ClipPlanesEnabled >> 5) & 1" ], "", None ), + ( "GL_COLOR_MATERIAL", GLboolean, + ["ctx->Light.ColorMaterialEnabled"], "", None ), + ( "GL_CURRENT_COLOR", GLfloatN, + [ "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0]", + "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1]", + "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2]", + "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3]" ], + "FLUSH_CURRENT(ctx, 0);", None ), + ( "GL_CURRENT_NORMAL", GLfloatN, + [ "ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0]", + "ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1]", + "ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2]"], + "FLUSH_CURRENT(ctx, 0);", None ), + ( "GL_CURRENT_TEXTURE_COORDS", GLfloat, + ["ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][0]", + "ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][1]", + "ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][2]", + "ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][3]"], + "const GLuint texUnit = ctx->Texture.CurrentUnit;", None ), + ( "GL_DISTANCE_ATTENUATION_EXT", GLfloat, + ["ctx->Point.Params[0]", + "ctx->Point.Params[1]", + "ctx->Point.Params[2]"], "", None ), + ( "GL_FOG", GLboolean, ["ctx->Fog.Enabled"], "", None ), + ( "GL_FOG_COLOR", GLfloatN, + [ "ctx->Fog.Color[0]", + "ctx->Fog.Color[1]", + "ctx->Fog.Color[2]", + "ctx->Fog.Color[3]" ], "", None ), + ( "GL_FOG_DENSITY", GLfloat, ["ctx->Fog.Density"], "", None ), + ( "GL_FOG_END", GLfloat, ["ctx->Fog.End"], "", None ), + ( "GL_FOG_HINT", GLenum, ["ctx->Hint.Fog"], "", None ), + ( "GL_FOG_MODE", GLenum, ["ctx->Fog.Mode"], "", None ), + ( "GL_FOG_START", GLfloat, ["ctx->Fog.Start"], "", None ), + ( "GL_LINE_SMOOTH", GLboolean, ["ctx->Line.SmoothFlag"], "", None ), + ( "GL_LINE_SMOOTH_HINT", GLenum, ["ctx->Hint.LineSmooth"], "", None ), + ( "GL_LINE_WIDTH_RANGE", GLfloat, + ["ctx->Const.MinLineWidthAA", + "ctx->Const.MaxLineWidthAA"], "", None ), + ( "GL_COLOR_LOGIC_OP", GLboolean, ["ctx->Color.ColorLogicOpEnabled"], "", None ), + ( "GL_LOGIC_OP_MODE", GLenum, ["ctx->Color.LogicOp"], "", None ), + ( "GL_MATRIX_MODE", GLenum, ["ctx->Transform.MatrixMode"], "", None ), + + ( "GL_MAX_MODELVIEW_STACK_DEPTH", GLint, ["MAX_MODELVIEW_STACK_DEPTH"], "", None ), + ( "GL_MAX_PROJECTION_STACK_DEPTH", GLint, ["MAX_PROJECTION_STACK_DEPTH"], "", None ), + ( "GL_MAX_TEXTURE_STACK_DEPTH", GLint, ["MAX_TEXTURE_STACK_DEPTH"], "", None ), + ( "GL_MODELVIEW_MATRIX", GLfloat, + [ "matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]", + "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]", + "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]", + "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ], + "const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m;", None ), + ( "GL_MODELVIEW_STACK_DEPTH", GLint, ["ctx->ModelviewMatrixStack.Depth + 1"], "", None ), + ( "GL_NORMALIZE", GLboolean, ["ctx->Transform.Normalize"], "", None ), + ( "GL_PACK_SKIP_IMAGES_EXT", GLint, ["ctx->Pack.SkipImages"], "", None ), + ( "GL_PERSPECTIVE_CORRECTION_HINT", GLenum, + ["ctx->Hint.PerspectiveCorrection"], "", None ), + ( "GL_POINT_SIZE", GLfloat, ["ctx->Point.Size"], "", None ), + ( "GL_POINT_SIZE_RANGE", GLfloat, + ["ctx->Const.MinPointSizeAA", + "ctx->Const.MaxPointSizeAA"], "", None ), + ( "GL_POINT_SMOOTH", GLboolean, ["ctx->Point.SmoothFlag"], "", None ), + ( "GL_POINT_SMOOTH_HINT", GLenum, ["ctx->Hint.PointSmooth"], "", None ), + ( "GL_POINT_SIZE_MIN_EXT", GLfloat, ["ctx->Point.MinSize"], "", None ), + ( "GL_POINT_SIZE_MAX_EXT", GLfloat, ["ctx->Point.MaxSize"], "", None ), + ( "GL_POINT_FADE_THRESHOLD_SIZE_EXT", GLfloat, + ["ctx->Point.Threshold"], "", None ), + ( "GL_PROJECTION_MATRIX", GLfloat, + [ "matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]", + "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]", + "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]", + "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ], + "const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m;", None ), + ( "GL_PROJECTION_STACK_DEPTH", GLint, + ["ctx->ProjectionMatrixStack.Depth + 1"], "", None ), + ( "GL_RESCALE_NORMAL", GLboolean, + ["ctx->Transform.RescaleNormals"], "", None ), + ( "GL_SHADE_MODEL", GLenum, ["ctx->Light.ShadeModel"], "", None ), + ( "GL_TEXTURE_2D", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_2D)"], "", None ), + ( "GL_TEXTURE_MATRIX", GLfloat, + ["matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]", + "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]", + "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]", + "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ], + "const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m;", None ), + ( "GL_TEXTURE_STACK_DEPTH", GLint, + ["ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Depth + 1"], "", None ), + ( "GL_VERTEX_ARRAY", GLboolean, ["ctx->Array.ArrayObj->Vertex.Enabled"], "", None ), + ( "GL_VERTEX_ARRAY_SIZE", GLint, ["ctx->Array.ArrayObj->Vertex.Size"], "", None ), + ( "GL_VERTEX_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Vertex.Type"], "", None ), + ( "GL_VERTEX_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Vertex.Stride"], "", None ), + ( "GL_NORMAL_ARRAY", GLenum, ["ctx->Array.ArrayObj->Normal.Enabled"], "", None ), + ( "GL_NORMAL_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Normal.Type"], "", None ), + ( "GL_NORMAL_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Normal.Stride"], "", None ), + ( "GL_COLOR_ARRAY", GLboolean, ["ctx->Array.ArrayObj->Color.Enabled"], "", None ), + ( "GL_COLOR_ARRAY_SIZE", GLint, ["ctx->Array.ArrayObj->Color.Size"], "", None ), + ( "GL_COLOR_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Color.Type"], "", None ), + ( "GL_COLOR_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Color.Stride"], "", None ), + ( "GL_TEXTURE_COORD_ARRAY", GLboolean, + ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled"], "", None ), + ( "GL_TEXTURE_COORD_ARRAY_SIZE", GLint, + ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Size"], "", None ), + ( "GL_TEXTURE_COORD_ARRAY_TYPE", GLenum, + ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Type"], "", None ), + ( "GL_TEXTURE_COORD_ARRAY_STRIDE", GLint, + ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Stride"], "", None ), + # GL_ARB_multitexture + ( "GL_MAX_TEXTURE_UNITS_ARB", GLint, + ["ctx->Const.MaxTextureUnits"], "", ["ARB_multitexture"] ), + ( "GL_CLIENT_ACTIVE_TEXTURE_ARB", GLint, + ["GL_TEXTURE0_ARB + ctx->Array.ActiveTexture"], "", ["ARB_multitexture"] ), + # OES_texture_cube_map + ( "GL_TEXTURE_CUBE_MAP_ARB", GLboolean, + ["_mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB)"], "", None), + ( "GL_TEXTURE_GEN_S", GLboolean, + ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0)"], "", None), + ( "GL_TEXTURE_GEN_T", GLboolean, + ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & T_BIT) ? 1 : 0)"], "", None), + ( "GL_TEXTURE_GEN_R", GLboolean, + ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & R_BIT) ? 1 : 0)"], "", None), + # ARB_multisample + ( "GL_MULTISAMPLE_ARB", GLboolean, + ["ctx->Multisample.Enabled"], "", ["ARB_multisample"] ), + ( "GL_SAMPLE_ALPHA_TO_ONE_ARB", GLboolean, + ["ctx->Multisample.SampleAlphaToOne"], "", ["ARB_multisample"] ), + + ( "GL_VERTEX_ARRAY_BUFFER_BINDING_ARB", GLint, + ["ctx->Array.ArrayObj->Vertex.BufferObj->Name"], "", ["ARB_vertex_buffer_object"] ), + ( "GL_NORMAL_ARRAY_BUFFER_BINDING_ARB", GLint, + ["ctx->Array.ArrayObj->Normal.BufferObj->Name"], "", ["ARB_vertex_buffer_object"] ), + ( "GL_COLOR_ARRAY_BUFFER_BINDING_ARB", GLint, + ["ctx->Array.ArrayObj->Color.BufferObj->Name"], "", ["ARB_vertex_buffer_object"] ), + ( "GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB", GLint, + ["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].BufferObj->Name"], + "", ["ARB_vertex_buffer_object"] ), + + # OES_point_sprite + ( "GL_POINT_SPRITE_NV", GLboolean, ["ctx->Point.PointSprite"], # == GL_POINT_SPRITE_ARB + "", None), + + # GL_ARB_fragment_shader + ( "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB", GLint, + ["ctx->Const.FragmentProgram.MaxUniformComponents"], "", + ["ARB_fragment_shader"] ), + + # GL_ARB_vertex_shader + ( "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB", GLint, + ["ctx->Const.VertexProgram.MaxUniformComponents"], "", + ["ARB_vertex_shader"] ), + ( "GL_MAX_VARYING_FLOATS_ARB", GLint, + ["ctx->Const.MaxVarying * 4"], "", ["ARB_vertex_shader"] ), + + # OES_matrix_get + ( "GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES", GLint, [], + """ + /* See GL_OES_matrix_get */ + { + const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m; + memcpy(params, matrix, 16 * sizeof(GLint)); + }""", + None), + + ( "GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES", GLint, [], + """ + /* See GL_OES_matrix_get */ + { + const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m; + memcpy(params, matrix, 16 * sizeof(GLint)); + }""", + None), + + ( "GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES", GLint, [], + """ + /* See GL_OES_matrix_get */ + { + const GLfloat *matrix = + ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m; + memcpy(params, matrix, 16 * sizeof(GLint)); + }""", + None), + + # OES_point_size_array + ("GL_POINT_SIZE_ARRAY_OES", GLboolean, + ["ctx->Array.ArrayObj->PointSize.Enabled"], "", None), + ("GL_POINT_SIZE_ARRAY_TYPE_OES", GLenum, + ["ctx->Array.ArrayObj->PointSize.Type"], "", None), + ("GL_POINT_SIZE_ARRAY_STRIDE_OES", GLint, + ["ctx->Array.ArrayObj->PointSize.Stride"], "", None), + ("GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES", GLint, + ["ctx->Array.ArrayObj->PointSize.BufferObj->Name"], "", None), + + # GL_EXT_texture_filter_anisotropic + ( "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT", GLfloat, + ["ctx->Const.MaxTextureMaxAnisotropy"], "", ["EXT_texture_filter_anisotropic"]), + +] + +# Only present in ES 2.x: +StateVars_es2 = [ + # XXX These entries are not spec'ed for GLES 2, but are + # needed for Mesa's GLSL: + ( "GL_MAX_LIGHTS", GLint, ["ctx->Const.MaxLights"], "", None ), + ( "GL_MAX_CLIP_PLANES", GLint, ["ctx->Const.MaxClipPlanes"], "", None ), + ( "GL_MAX_TEXTURE_COORDS_ARB", GLint, # == GL_MAX_TEXTURE_COORDS_NV + ["ctx->Const.MaxTextureCoordUnits"], "", + ["ARB_fragment_program", "NV_fragment_program"] ), + ( "GL_MAX_DRAW_BUFFERS_ARB", GLint, + ["ctx->Const.MaxDrawBuffers"], "", ["ARB_draw_buffers"] ), + ( "GL_BLEND_COLOR_EXT", GLfloatN, + [ "ctx->Color.BlendColor[0]", + "ctx->Color.BlendColor[1]", + "ctx->Color.BlendColor[2]", + "ctx->Color.BlendColor[3]"], "", None ), + + # This is required for GLES2, but also needed for GLSL: + ( "GL_MAX_TEXTURE_IMAGE_UNITS_ARB", GLint, # == GL_MAX_TEXTURE_IMAGE_UNI + ["ctx->Const.MaxTextureImageUnits"], "", + ["ARB_fragment_program", "NV_fragment_program"] ), + + ( "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB", GLint, + ["ctx->Const.MaxVertexTextureImageUnits"], "", ["ARB_vertex_shader"] ), + ( "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB", GLint, + ["MAX_COMBINED_TEXTURE_IMAGE_UNITS"], "", ["ARB_vertex_shader"] ), + + # GL_ARB_shader_objects + # Actually, this token isn't part of GL_ARB_shader_objects, but is + # close enough for now. + ( "GL_CURRENT_PROGRAM", GLint, + ["ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0"], + "", ["ARB_shader_objects"] ), + + # OpenGL 2.0 + ( "GL_STENCIL_BACK_FUNC", GLenum, ["ctx->Stencil.Function[1]"], "", None ), + ( "GL_STENCIL_BACK_VALUE_MASK", GLint, ["ctx->Stencil.ValueMask[1]"], "", None ), + ( "GL_STENCIL_BACK_WRITEMASK", GLint, ["ctx->Stencil.WriteMask[1]"], "", None ), + ( "GL_STENCIL_BACK_REF", GLint, ["ctx->Stencil.Ref[1]"], "", None ), + ( "GL_STENCIL_BACK_FAIL", GLenum, ["ctx->Stencil.FailFunc[1]"], "", None ), + ( "GL_STENCIL_BACK_PASS_DEPTH_FAIL", GLenum, ["ctx->Stencil.ZFailFunc[1]"], "", None ), + ( "GL_STENCIL_BACK_PASS_DEPTH_PASS", GLenum, ["ctx->Stencil.ZPassFunc[1]"], "", None ), + + ( "GL_MAX_VERTEX_ATTRIBS_ARB", GLint, + ["ctx->Const.VertexProgram.MaxAttribs"], "", ["ARB_vertex_program"] ), + + # OES_texture_3D + ( "GL_TEXTURE_BINDING_3D", GLint, + ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_3D_INDEX]->Name"], "", None), + ( "GL_MAX_3D_TEXTURE_SIZE", GLint, ["1 << (ctx->Const.Max3DTextureLevels - 1)"], "", None), + + # OES_standard_derivatives + ( "GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB", GLenum, + ["ctx->Hint.FragmentShaderDerivative"], "", ["ARB_fragment_shader"] ), + + # Unique to ES 2 (not in full GL) + ( "GL_MAX_FRAGMENT_UNIFORM_VECTORS", GLint, + ["ctx->Const.FragmentProgram.MaxUniformComponents / 4"], "", None), + ( "GL_MAX_VARYING_VECTORS", GLint, + ["ctx->Const.MaxVarying"], "", None), + ( "GL_MAX_VERTEX_UNIFORM_VECTORS", GLint, + ["ctx->Const.VertexProgram.MaxUniformComponents / 4"], "", None), + ( "GL_SHADER_COMPILER", GLint, ["1"], "", None), + # OES_get_program_binary + ( "GL_NUM_SHADER_BINARY_FORMATS", GLint, ["0"], "", None), + ( "GL_SHADER_BINARY_FORMATS", GLint, [], "", None), +] + + + +def ConversionFunc(fromType, toType): + """Return the name of the macro to convert between two data types.""" + if fromType == toType: + return "" + elif fromType == GLfloat and toType == GLint: + return "IROUND" + elif fromType == GLfloatN and toType == GLfloat: + return "" + elif fromType == GLint and toType == GLfloat: # but not GLfloatN! + return "(GLfloat)" + else: + if fromType == GLfloatN: + fromType = GLfloat + fromStr = TypeStrings[fromType] + fromStr = string.upper(fromStr[2:]) + toStr = TypeStrings[toType] + toStr = string.upper(toStr[2:]) + return fromStr + "_TO_" + toStr + + +def EmitGetFunction(stateVars, returnType): + """Emit the code to implement glGetBooleanv, glGetIntegerv or glGetFloatv.""" + assert (returnType == GLboolean or + returnType == GLint or + returnType == GLfloat) + + strType = TypeStrings[returnType] + # Capitalize first letter of return type + if returnType == GLint: + function = "_mesa_GetIntegerv" + elif returnType == GLboolean: + function = "_mesa_GetBooleanv" + elif returnType == GLfloat: + function = "_mesa_GetFloatv" + else: + abort() + + print "void GLAPIENTRY" + print "%s( GLenum pname, %s *params )" % (function, strType) + print "{" + print " GET_CURRENT_CONTEXT(ctx);" + print " ASSERT_OUTSIDE_BEGIN_END(ctx);" + print "" + print " if (!params)" + print " return;" + print "" + print " if (ctx->NewState)" + print " _mesa_update_state(ctx);" + print "" + print " switch (pname) {" + + for (name, varType, state, optionalCode, extensions) in stateVars: + print " case " + name + ":" + if extensions: + if len(extensions) == 1: + print (' CHECK_EXT1(%s, "%s");' % + (extensions[0], function)) + elif len(extensions) == 2: + print (' CHECK_EXT2(%s, %s, "%s");' % + (extensions[0], extensions[1], function)) + elif len(extensions) == 3: + print (' CHECK_EXT3(%s, %s, %s, "%s");' % + (extensions[0], extensions[1], extensions[2], function)) + else: + assert len(extensions) == 4 + print (' CHECK_EXT4(%s, %s, %s, %s, "%s");' % + (extensions[0], extensions[1], extensions[2], extensions[3], function)) + if optionalCode: + print " {" + print " " + optionalCode + conversion = ConversionFunc(varType, returnType) + n = len(state) + for i in range(n): + if conversion: + print " params[%d] = %s(%s);" % (i, conversion, state[i]) + else: + print " params[%d] = %s;" % (i, state[i]) + if optionalCode: + print " }" + print " break;" + + print " default:" + print ' _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(pname=0x%%x)", pname);' % function + print " }" + print "}" + print "" + return + + + +def EmitHeader(): + """Print the get.c file header.""" + print """ +/*** + *** NOTE!!! DO NOT EDIT THIS FILE!!! IT IS GENERATED BY get_gen.py + ***/ + +#include "main/glheader.h" +#include "main/context.h" +#include "main/enable.h" +#include "main/extensions.h" +#include "main/fbobject.h" +#include "main/get.h" +#include "main/macros.h" +#include "main/mtypes.h" +#include "main/state.h" +#include "main/texcompress.h" + + +/* ES1 tokens that should be in gl.h but aren't */ +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 + + +/* ES2 special tokens */ +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_SHADER_COMPILER 0x8DFA +#define GL_PLATFORM_BINARY 0x8D63 +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 + + +#ifndef GL_OES_matrix_get +#define GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES 0x898D +#define GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES 0x898E +#define GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES 0x898F +#endif + +#ifndef GL_OES_compressed_paletted_texture +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif + + +#define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE ) + +#define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE ) + +#define BOOLEAN_TO_INT(B) ( (GLint) (B) ) +#define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F ) + + +/* + * Check if named extension is enabled, if not generate error and return. + */ +#define CHECK_EXT1(EXT1, FUNC) \\ + if (!ctx->Extensions.EXT1) { \\ + _mesa_error(ctx, GL_INVALID_ENUM, FUNC "(0x%x)", (int) pname); \\ + return; \\ + } + +/* + * Check if either of two extensions is enabled. + */ +#define CHECK_EXT2(EXT1, EXT2, FUNC) \\ + if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \\ + _mesa_error(ctx, GL_INVALID_ENUM, FUNC "(0x%x)", (int) pname); \\ + return; \\ + } + +/* + * Check if either of three extensions is enabled. + */ +#define CHECK_EXT3(EXT1, EXT2, EXT3, FUNC) \\ + if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2 && \\ + !ctx->Extensions.EXT3) { \\ + _mesa_error(ctx, GL_INVALID_ENUM, FUNC "(0x%x)", (int) pname); \\ + return; \\ + } + +/* + * Check if either of four extensions is enabled. + */ +#define CHECK_EXT4(EXT1, EXT2, EXT3, EXT4, FUNC) \\ + if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2 && \\ + !ctx->Extensions.EXT3 && !ctx->Extensions.EXT4) { \\ + _mesa_error(ctx, GL_INVALID_ENUM, FUNC "(0x%x)", (int) pname); \\ + return; \\ + } + + + +/** + * List of compressed texture formats supported by ES. + */ +static GLenum compressed_formats[] = { + GL_PALETTE4_RGB8_OES, + GL_PALETTE4_RGBA8_OES, + GL_PALETTE4_R5_G6_B5_OES, + GL_PALETTE4_RGBA4_OES, + GL_PALETTE4_RGB5_A1_OES, + GL_PALETTE8_RGB8_OES, + GL_PALETTE8_RGBA8_OES, + GL_PALETTE8_R5_G6_B5_OES, + GL_PALETTE8_RGBA4_OES, + GL_PALETTE8_RGB5_A1_OES +}; + +#define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0])) + +""" + return + + +def EmitAll(stateVars): + EmitHeader() + EmitGetFunction(stateVars, GLboolean) + EmitGetFunction(stateVars, GLfloat) + EmitGetFunction(stateVars, GLint) + + +def main(args): + # Determine whether to generate ES1 or ES2 queries + if len(args) > 1 and args[1] == "1": + API = 1 + elif len(args) > 1 and args[1] == "2": + API = 2 + else: + API = 1 + #print "len args = %d API = %d" % (len(args), API) + + if API == 1: + vars = StateVars_common + StateVars_es1 + else: + vars = StateVars_common + StateVars_es2 + + EmitAll(vars) + + +main(sys.argv) diff --git a/src/mesa/es/main/mfeatures_es1.h b/src/mesa/es/main/mfeatures_es1.h new file mode 100644 index 0000000000..9c65596089 --- /dev/null +++ b/src/mesa/es/main/mfeatures_es1.h @@ -0,0 +1,115 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * 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, sub license, 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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 mfeatures.h + * + * The #defines in this file enable/disable Mesa features needed + * for OpenGL ES 1.1. + */ + + +#ifndef MFEATURES_ES1_H +#define MFEATURES_ES1_H + +/* this file replaces main/mfeatures.h */ +#ifdef FEATURES_H +#error "main/mfeatures.h was wrongly included" +#endif +#define FEATURES_H + +#define ASSERT_NO_FEATURE() ASSERT(0) + +/* + * Enable/disable features (blocks of code) by setting FEATURE_xyz to 0 or 1. + */ +#ifndef _HAVE_FULL_GL +#define _HAVE_FULL_GL 1 +#endif + +#ifdef IN_DRI_DRIVER +#define FEATURE_remap_table 1 +#else +#define FEATURE_remap_table 0 +#endif + +#define FEATURE_accum 0 +#define FEATURE_arrayelt 0 +#define FEATURE_attrib 0 +#define FEATURE_beginend 0 +#define FEATURE_colortable 0 +#define FEATURE_convolve 0 +#define FEATURE_dispatch 1 +#define FEATURE_dlist 0 +#define FEATURE_draw_read_buffer 0 +#define FEATURE_drawpix 0 +#define FEATURE_eval 0 +#define FEATURE_feedback 0 +#define FEATURE_fixedpt 1 +#define FEATURE_histogram 0 +#define FEATURE_pixel 0 +#define FEATURE_point_size_array 1 +#define FEATURE_queryobj 0 +#define FEATURE_rastpos 0 +#define FEATURE_texgen 1 +#define FEATURE_texture_fxt1 0 +#define FEATURE_texture_s3tc 0 +#define FEATURE_userclip 1 +#define FEATURE_vertex_array_byte 1 +#define FEATURE_es2_glsl 0 + +#define FEATURE_ARB_fragment_program _HAVE_FULL_GL +#define FEATURE_ARB_vertex_buffer_object _HAVE_FULL_GL +#define FEATURE_ARB_vertex_program _HAVE_FULL_GL + +#define FEATURE_ARB_vertex_shader _HAVE_FULL_GL +#define FEATURE_ARB_fragment_shader _HAVE_FULL_GL +#define FEATURE_ARB_shader_objects (FEATURE_ARB_vertex_shader || FEATURE_ARB_fragment_shader) +#define FEATURE_ARB_shading_language_100 FEATURE_ARB_shader_objects +#define FEATURE_ARB_shading_language_120 FEATURE_ARB_shader_objects + +#define FEATURE_EXT_framebuffer_blit 0 +#define FEATURE_EXT_framebuffer_object _HAVE_FULL_GL +#define FEATURE_EXT_pixel_buffer_object _HAVE_FULL_GL +#define FEATURE_EXT_texture_sRGB 0 +#define FEATURE_ATI_fragment_shader 0 +#define FEATURE_MESA_program_debug _HAVE_FULL_GL +#define FEATURE_NV_fence 0 +#define FEATURE_NV_fragment_program 0 +#define FEATURE_NV_vertex_program 0 + +#define FEATURE_OES_framebuffer_object 1 +#define FEATURE_OES_mapbuffer 1 + +#define FEATURE_extra_context_init 1 + +/*@}*/ + + + + +#endif /* MFEATURES_ES1_H */ diff --git a/src/mesa/es/main/mfeatures_es2.h b/src/mesa/es/main/mfeatures_es2.h new file mode 100644 index 0000000000..6ed7b678dc --- /dev/null +++ b/src/mesa/es/main/mfeatures_es2.h @@ -0,0 +1,115 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * 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, sub license, 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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 mfeatures.h + * + * The #defines in this file enable/disable Mesa features needed + * for OpenGL ES 2.0. + */ + + +#ifndef MFEATURES_ES2_H +#define MFEATURES_ES2_H + +/* this file replaces main/mfeatures.h */ +#ifdef FEATURES_H +#error "main/mfeatures.h was wrongly included" +#endif +#define FEATURES_H + +#define ASSERT_NO_FEATURE() ASSERT(0) + +/* + * Enable/disable features (blocks of code) by setting FEATURE_xyz to 0 or 1. + */ +#ifndef _HAVE_FULL_GL +#define _HAVE_FULL_GL 1 +#endif + +#ifdef IN_DRI_DRIVER +#define FEATURE_remap_table 1 +#else +#define FEATURE_remap_table 0 +#endif + +#define FEATURE_accum 0 +#define FEATURE_arrayelt 0 +#define FEATURE_attrib 0 +#define FEATURE_beginend 0 +#define FEATURE_colortable 0 +#define FEATURE_convolve 0 +#define FEATURE_dispatch 1 +#define FEATURE_dlist 0 +#define FEATURE_draw_read_buffer 0 +#define FEATURE_drawpix 0 +#define FEATURE_eval 0 +#define FEATURE_feedback 0 +#define FEATURE_fixedpt 1 +#define FEATURE_histogram 0 +#define FEATURE_pixel 0 +#define FEATURE_point_size_array 1 +#define FEATURE_queryobj 0 +#define FEATURE_rastpos 0 +#define FEATURE_texgen 1 +#define FEATURE_texture_fxt1 0 +#define FEATURE_texture_s3tc 0 +#define FEATURE_userclip 1 +#define FEATURE_vertex_array_byte 1 +#define FEATURE_es2_glsl 1 + +#define FEATURE_ARB_fragment_program _HAVE_FULL_GL +#define FEATURE_ARB_vertex_buffer_object _HAVE_FULL_GL +#define FEATURE_ARB_vertex_program _HAVE_FULL_GL + +#define FEATURE_ARB_vertex_shader _HAVE_FULL_GL +#define FEATURE_ARB_fragment_shader _HAVE_FULL_GL +#define FEATURE_ARB_shader_objects (FEATURE_ARB_vertex_shader || FEATURE_ARB_fragment_shader) +#define FEATURE_ARB_shading_language_100 FEATURE_ARB_shader_objects +#define FEATURE_ARB_shading_language_120 FEATURE_ARB_shader_objects + +#define FEATURE_EXT_framebuffer_blit 0 +#define FEATURE_EXT_framebuffer_object _HAVE_FULL_GL +#define FEATURE_EXT_pixel_buffer_object _HAVE_FULL_GL +#define FEATURE_EXT_texture_sRGB 0 +#define FEATURE_ATI_fragment_shader 0 +#define FEATURE_MESA_program_debug _HAVE_FULL_GL +#define FEATURE_NV_fence 0 +#define FEATURE_NV_fragment_program 0 +#define FEATURE_NV_vertex_program 0 + +#define FEATURE_OES_framebuffer_object 1 +#define FEATURE_OES_mapbuffer 1 + +#define FEATURE_extra_context_init 1 + +/*@}*/ + + + + +#endif /* MFEATURES_ES2_H */ diff --git a/src/mesa/es/main/specials_es1.c b/src/mesa/es/main/specials_es1.c new file mode 100644 index 0000000000..84d339ebf6 --- /dev/null +++ b/src/mesa/es/main/specials_es1.c @@ -0,0 +1,186 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * TUNGSTEN GRAPHICS 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. + **************************************************************************/ + + +#include "main/mtypes.h" +#include "main/context.h" +#include "main/imports.h" +#include "main/get.h" + + +extern const GLubyte * GLAPIENTRY _es_GetString(GLenum name); + + +static const GLubyte * +compute_es_version(void) +{ + GET_CURRENT_CONTEXT(ctx); + static const char es_1_0[] = "OpenGL ES-CM 1.0"; + static const char es_1_1[] = "OpenGL ES-CM 1.1"; + /* OpenGL ES 1.0 is derived from OpenGL 1.3 */ + const GLboolean ver_1_0 = (ctx->Extensions.ARB_multisample && + ctx->Extensions.ARB_multitexture && + ctx->Extensions.ARB_texture_compression && + ctx->Extensions.EXT_texture_env_add && + ctx->Extensions.ARB_texture_env_combine && + ctx->Extensions.ARB_texture_env_dot3); + /* OpenGL ES 1.1 is derived from OpenGL 1.5 */ + const GLboolean ver_1_1 = (ver_1_0 && + ctx->Extensions.EXT_point_parameters && + ctx->Extensions.SGIS_generate_mipmap && + ctx->Extensions.ARB_vertex_buffer_object); + if (ver_1_1) + return (const GLubyte *) es_1_1; + + if (!ver_1_0) + _mesa_problem(ctx, "Incomplete OpenGL ES 1.0 support."); + return (const GLubyte *) es_1_0; +} + + +static size_t +append_extension(char **str, const char *ext) +{ + char *s = *str; + size_t len = strlen(ext); + + if (s) { + memcpy(s, ext, len); + s[len++] = ' '; + s[len] = '\0'; + + *str += len; + } + else { + len++; + } + + return len; +} + + +static size_t +make_extension_string(const GLcontext *ctx, char *str) +{ + size_t len = 0; + + /* Core additions */ + len += append_extension(&str, "GL_OES_byte_coordinates"); + len += append_extension(&str, "GL_OES_fixed_point"); + len += append_extension(&str, "GL_OES_single_precision"); + len += append_extension(&str, "GL_OES_matrix_get"); + + /* 1.1 required extensions */ + len += append_extension(&str, "GL_OES_read_format"); + len += append_extension(&str, "GL_OES_compressed_paletted_texture"); + len += append_extension(&str, "GL_OES_point_size_array"); + len += append_extension(&str, "GL_OES_point_sprite"); + + /* 1.1 deprecated extensions */ + len += append_extension(&str, "GL_OES_query_matrix"); + + if (ctx->Extensions.EXT_blend_equation_separate) + len += append_extension(&str, "GL_OES_blend_equation_separate"); + if (ctx->Extensions.EXT_blend_func_separate) + len += append_extension(&str, "GL_OES_blend_func_separate"); + if (ctx->Extensions.EXT_blend_subtract) + len += append_extension(&str, "GL_OES_blend_subtract"); + + if (ctx->Extensions.EXT_stencil_wrap) + len += append_extension(&str, "GL_OES_stencil_wrap"); + + if (ctx->Extensions.ARB_texture_cube_map) + len += append_extension(&str, "GL_OES_texture_cube_map"); + if (ctx->Extensions.ARB_texture_env_crossbar) + len += append_extension(&str, "GL_OES_texture_env_crossbar"); + if (ctx->Extensions.ARB_texture_mirrored_repeat) + len += append_extension(&str, "GL_OES_texture_mirrored_repeat"); + + if (ctx->Extensions.ARB_framebuffer_object) { + len += append_extension(&str, "GL_OES_framebuffer_object"); + len += append_extension(&str, "GL_OES_depth24"); + len += append_extension(&str, "GL_OES_depth32"); + len += append_extension(&str, "GL_OES_fbo_render_mipmap"); + len += append_extension(&str, "GL_OES_rgb8_rgba8"); + len += append_extension(&str, "GL_OES_stencil1"); + len += append_extension(&str, "GL_OES_stencil4"); + len += append_extension(&str, "GL_OES_stencil8"); + } + + if (ctx->Extensions.EXT_vertex_array) + len += append_extension(&str, "GL_OES_element_index_uint"); + if (ctx->Extensions.ARB_vertex_buffer_object) + len += append_extension(&str, "GL_OES_mapbuffer"); + if (ctx->Extensions.EXT_texture_filter_anisotropic) + len += append_extension(&str, "GL_EXT_texture_filter_anisotropic"); + + if (ctx->Extensions.ARB_texture_non_power_of_two) + len += append_extension(&str, "GL_ARB_texture_non_power_of_two"); + if (ctx->Extensions.EXT_multi_draw_arrays) + len += append_extension(&str, "GL_EXT_multi_draw_arrays"); + + return len; +} + + +static const GLubyte * +compute_es_extensions(void) +{ + GET_CURRENT_CONTEXT(ctx); + + if (!ctx->Extensions.String) { + char *s; + unsigned int len; + + len = make_extension_string(ctx, NULL); + s = (char *) _mesa_malloc(len + 1); + if (!s) + return NULL; + make_extension_string(ctx, s); + ctx->Extensions.String = (const GLubyte *) s; + } + + return ctx->Extensions.String; +} + + +const GLubyte * GLAPIENTRY +_es_GetString(GLenum name) +{ + switch (name) { + case GL_VERSION: + return compute_es_version(); + case GL_EXTENSIONS: + return compute_es_extensions(); + default: + return _mesa_GetString(name); + } +} + + +void +_mesa_initialize_context_extra(GLcontext *ctx) +{ + /* nothing here */ +} diff --git a/src/mesa/es/main/specials_es2.c b/src/mesa/es/main/specials_es2.c new file mode 100644 index 0000000000..ef8c581618 --- /dev/null +++ b/src/mesa/es/main/specials_es2.c @@ -0,0 +1,176 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * TUNGSTEN GRAPHICS 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. + **************************************************************************/ + + +#include "main/mtypes.h" +#include "main/context.h" +#include "main/imports.h" +#include "main/get.h" + + +const GLubyte * GLAPIENTRY _es_GetString(GLenum name); + + +static const GLubyte * +compute_es_version(void) +{ + GET_CURRENT_CONTEXT(ctx); + static const char es_2_0[] = "OpenGL ES 2.0"; + /* OpenGL ES 2.0 is derived from OpenGL 2.0 */ + const GLboolean ver_2_0 = (ctx->Extensions.ARB_multisample && + ctx->Extensions.ARB_multitexture && + ctx->Extensions.ARB_texture_compression && + ctx->Extensions.ARB_texture_cube_map && + ctx->Extensions.ARB_texture_mirrored_repeat && + ctx->Extensions.EXT_blend_color && + ctx->Extensions.EXT_blend_func_separate && + ctx->Extensions.EXT_blend_minmax && + ctx->Extensions.EXT_blend_subtract && + ctx->Extensions.EXT_stencil_wrap && + ctx->Extensions.ARB_vertex_buffer_object && + ctx->Extensions.ARB_shader_objects && + ctx->Extensions.ARB_vertex_shader && + ctx->Extensions.ARB_fragment_shader && + ctx->Extensions.ARB_texture_non_power_of_two && + ctx->Extensions.EXT_blend_equation_separate); + if (!ver_2_0) + _mesa_problem(ctx, "Incomplete OpenGL ES 2.0 support."); + return (const GLubyte *) es_2_0; +} + + +static size_t +append_extension(char **str, const char *ext) +{ + char *s = *str; + size_t len = strlen(ext); + + if (s) { + memcpy(s, ext, len); + s[len++] = ' '; + s[len] = '\0'; + + *str += len; + } + else { + len++; + } + + return len; +} + + +static size_t +make_extension_string(const GLcontext *ctx, char *str) +{ + size_t len = 0; + + /* Core additions */ + len += append_extension(&str, "GL_OES_single_precision"); + + /* Required extensions */ + len += append_extension(&str, "GL_OES_compressed_paletted_texture"); + + if (ctx->Extensions.ARB_framebuffer_object) { + len += append_extension(&str, "GL_OES_framebuffer_object"); + len += append_extension(&str, "GL_OES_depth24"); + len += append_extension(&str, "GL_OES_depth32"); + len += append_extension(&str, "GL_OES_fbo_render_mipmap"); + len += append_extension(&str, "GL_OES_rgb8_rgba8"); + len += append_extension(&str, "GL_OES_stencil1"); + len += append_extension(&str, "GL_OES_stencil4"); + len += append_extension(&str, "GL_OES_stencil8"); + } + + if (ctx->Extensions.EXT_vertex_array) + len += append_extension(&str, "GL_OES_element_index_uint"); + if (ctx->Extensions.ARB_vertex_buffer_object) + len += append_extension(&str, "GL_OES_mapbuffer"); + + if (ctx->Extensions.EXT_texture3D) + len += append_extension(&str, "GL_OES_texture_3D"); + if (ctx->Extensions.ARB_texture_non_power_of_two) + len += append_extension(&str, "GL_OES_texture_npot"); + if (ctx->Extensions.EXT_texture_filter_anisotropic) + len += append_extension(&str, "GL_EXT_texture_filter_anisotropic"); + + len += append_extension(&str, "GL_EXT_texture_type_2_10_10_10_REV"); + if (ctx->Extensions.ARB_depth_texture) + len += append_extension(&str, "GL_OES_depth_texture"); + if (ctx->Extensions.EXT_packed_depth_stencil) + len += append_extension(&str, "GL_OES_packed_depth_stencil"); + if (ctx->Extensions.ARB_fragment_shader) + len += append_extension(&str, "GL_OES_standard_derivatives"); + + if (ctx->Extensions.EXT_multi_draw_arrays) + len += append_extension(&str, "GL_EXT_multi_draw_arrays"); + + return len; +} + + +static const GLubyte * +compute_es_extensions(void) +{ + GET_CURRENT_CONTEXT(ctx); + + if (!ctx->Extensions.String) { + char *s; + unsigned int len; + + len = make_extension_string(ctx, NULL); + s = (char *) _mesa_malloc(len + 1); + if (!s) + return NULL; + make_extension_string(ctx, s); + ctx->Extensions.String = (const GLubyte *) s; + } + + return ctx->Extensions.String; +} + +const GLubyte * GLAPIENTRY +_es_GetString(GLenum name) +{ + switch (name) { + case GL_VERSION: + return compute_es_version(); + case GL_SHADING_LANGUAGE_VERSION: + return (const GLubyte *) "OpenGL ES GLSL ES 1.0.16"; + case GL_EXTENSIONS: + return compute_es_extensions(); + default: + return _mesa_GetString(name); + } +} + + +void +_mesa_initialize_context_extra(GLcontext *ctx) +{ + ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE; + ctx->VertexProgram._MaintainTnlProgram = GL_TRUE; + + ctx->Point.PointSprite = GL_TRUE; /* always on for ES 2.x */ +} diff --git a/src/mesa/es/main/stubs.c b/src/mesa/es/main/stubs.c new file mode 100644 index 0000000000..e7b8bc780f --- /dev/null +++ b/src/mesa/es/main/stubs.c @@ -0,0 +1,138 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * TUNGSTEN GRAPHICS 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. + **************************************************************************/ + + +/** + * Temporary stubs for "missing" mesa functions. + */ + + +#include "main/mtypes.h" +#include "main/imports.h" +#include "vbo/vbo.h" + +#define NEED_IMPLEMENT() do { \ + GET_CURRENT_CONTEXT(ctx); \ + _mesa_error(ctx, GL_INVALID_OPERATION, __FUNCTION__); \ + } while (0) + +#if FEATURE_accum +/* This is a sanity check that to be sure we're using the correct mfeatures.h + * header. We don't want to accidentally use the one from mainline Mesa. + */ +#error "The wrong mfeatures.h file is being included!" +#endif + + +/* silence compiler warnings */ +extern void GLAPIENTRY _vbo_Materialf(GLenum face, GLenum pname, GLfloat param); +extern void GLAPIENTRY _mesa_GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); +extern void GLAPIENTRY _mesa_ReleaseShaderCompiler(void); +extern void GLAPIENTRY _mesa_ShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length); +extern void GLAPIENTRY _vbo_VertexAttrib1f(GLuint indx, GLfloat x); +extern void GLAPIENTRY _vbo_VertexAttrib1fv(GLuint indx, const GLfloat* values); +extern void GLAPIENTRY _vbo_VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y); +extern void GLAPIENTRY _vbo_VertexAttrib2fv(GLuint indx, const GLfloat* values); +extern void GLAPIENTRY _vbo_VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z); +extern void GLAPIENTRY _vbo_VertexAttrib3fv(GLuint indx, const GLfloat* values); +extern void GLAPIENTRY _vbo_VertexAttrib4fv(GLuint indx, const GLfloat* values); + + +void GLAPIENTRY +_vbo_Materialf(GLenum face, GLenum pname, GLfloat param) +{ + _vbo_Materialfv(face, pname, ¶m); +} + + +void GLAPIENTRY +_mesa_GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, + GLint* range, GLint* precision) +{ + NEED_IMPLEMENT(); +} + + +void GLAPIENTRY +_mesa_ReleaseShaderCompiler(void) +{ + NEED_IMPLEMENT(); +} + + +void GLAPIENTRY +_mesa_ShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, + const void* binary, GLint length) +{ + NEED_IMPLEMENT(); +} + + +void GLAPIENTRY +_vbo_VertexAttrib1f(GLuint indx, GLfloat x) +{ + _vbo_VertexAttrib4f(indx, x, 0.0, 0.0, 1.0f); +} + + +void GLAPIENTRY +_vbo_VertexAttrib1fv(GLuint indx, const GLfloat* values) +{ + _vbo_VertexAttrib4f(indx, values[0], 0.0, 0.0, 1.0f); +} + + +void GLAPIENTRY +_vbo_VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) +{ + _vbo_VertexAttrib4f(indx, x, y, 0.0, 1.0f); +} + + +void GLAPIENTRY +_vbo_VertexAttrib2fv(GLuint indx, const GLfloat* values) +{ + _vbo_VertexAttrib4f(indx, values[0], values[1], 0.0, 1.0f); +} + + +void GLAPIENTRY +_vbo_VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) +{ + _vbo_VertexAttrib4f(indx, x, y, z, 1.0f); +} + + +void GLAPIENTRY +_vbo_VertexAttrib3fv(GLuint indx, const GLfloat* values) +{ + _vbo_VertexAttrib4f(indx, values[0], values[1], values[2], 1.0f); +} + + +void GLAPIENTRY +_vbo_VertexAttrib4fv(GLuint indx, const GLfloat* values) +{ + _vbo_VertexAttrib4f(indx, values[0], values[1], values[2], values[3]); +} diff --git a/src/mesa/es/sources.mak b/src/mesa/es/sources.mak new file mode 100644 index 0000000000..d12acaae80 --- /dev/null +++ b/src/mesa/es/sources.mak @@ -0,0 +1,164 @@ +include $(MESA)/sources.mak + +# LOCAL sources + +LOCAL_ES1_SOURCES := \ + main/api_exec_es1.c \ + main/get_es1.c \ + main/specials_es1.c \ + main/drawtex.c \ + main/es_cpaltex.c \ + main/es_fbo.c \ + main/es_query_matrix.c \ + main/stubs.c \ + glapi/glapi-es1/main/enums.c + +LOCAL_ES1_GALLIUM_SOURCES := \ + $(LOCAL_ES1_SOURCES) + +# always use local version of GLAPI_ASM_SOURCES +LOCAL_ES1_API_ASM := $(addprefix glapi/glapi-es1/, $(GLAPI_ASM_SOURCES)) + +LOCAL_ES1_INCLUDES := \ + -I. \ + -I./glapi/glapi-es1 \ + -I./state_tracker \ + -I$(MESA)/state_tracker + +LOCAL_ES2_SOURCES := \ + main/api_exec_es2.c \ + main/get_es2.c \ + main/specials_es2.c \ + main/es_cpaltex.c \ + main/es_fbo.c \ + main/stubs.c \ + glapi/glapi-es2/main/enums.c + +LOCAL_ES2_GALLIUM_SOURCES := \ + $(LOCAL_ES2_SOURCES) + +LOCAL_ES2_API_ASM := $(subst es1,es2, $(LOCAL_ES1_API_ASM)) +LOCAL_ES2_INCLUDES := $(subst es1,es2, $(LOCAL_ES1_INCLUDES)) + +# MESA sources + +MAIN_OMITTED := \ + main/api_exec.c \ + main/dlopen.c \ + main/enums.c \ + main/get.c +MAIN_SOURCES := $(filter-out $(MAIN_OMITTED), $(MAIN_SOURCES)) + +VBO_OMITTED := \ + vbo/vbo_save.c \ + vbo/vbo_save_api.c \ + vbo/vbo_save_draw.c \ + vbo/vbo_save_loopback.c +VBO_SOURCES := $(filter-out $(VBO_OMITTED), $(VBO_SOURCES)) + +STATETRACKER_OMITTED := \ + state_tracker/st_api.c \ + state_tracker/st_cb_drawpixels.c \ + state_tracker/st_cb_feedback.c \ + state_tracker/st_cb_rasterpos.c \ + state_tracker/st_draw_feedback.c +STATETRACKER_SOURCES := $(filter-out $(STATETRACKER_OMITTED), $(STATETRACKER_SOURCES)) + +SHADER_OMITTED := \ + shader/atifragshader.c \ + shader/nvfragparse.c \ + shader/nvprogram.c \ + shader/nvvertparse.c +SHADER_SOURCES := $(filter-out $(SHADER_OMITTED), $(SHADER_SOURCES)) + +MESA_ES1_SOURCES := \ + $(MAIN_SOURCES) \ + $(MATH_SOURCES) \ + $(MATH_XFORM_SOURCES) \ + $(VBO_SOURCES) \ + $(TNL_SOURCES) \ + $(SHADER_SOURCES) \ + $(SWRAST_SOURCES) \ + $(SWRAST_SETUP_SOURCES) \ + $(COMMON_DRIVER_SOURCES) \ + $(ASM_C_SOURCES) \ + $(SLANG_SOURCES) + +MESA_ES1_GALLIUM_SOURCES := \ + $(MAIN_SOURCES) \ + $(MATH_SOURCES) \ + $(VBO_SOURCES) \ + $(STATETRACKER_SOURCES) \ + $(SHADER_SOURCES) \ + ppc/common_ppc.c \ + x86/common_x86.c \ + $(SLANG_SOURCES) + +MESA_ES1_API_SOURCES := \ + $(GLAPI_SOURCES) + +MESA_ES1_INCLUDES := $(INCLUDE_DIRS) + +# remove LOCAL sources from MESA sources +MESA_ES1_SOURCES := $(filter-out $(LOCAL_ES1_SOURCES), $(MESA_ES1_SOURCES)) +MESA_ES1_GALLIUM_SOURCES := $(filter-out $(LOCAL_ES1_GALLIUM_SOURCES), $(MESA_ES1_GALLIUM_SOURCES)) + +# right now es2 and es1 share MESA sources +MESA_ES2_SOURCES := $(MESA_ES1_SOURCES) +MESA_ES2_GALLIUM_SOURCES := $(MESA_ES1_GALLIUM_SOURCES) +MESA_ES2_API_SOURCES := $(MESA_ES1_API_SOURCES) + +MESA_ES2_INCLUDES := $(MESA_ES1_INCLUDES) + +# asm is shared by any ES version and any library +MESA_ES_ASM := $(MESA_ASM_SOURCES) + +# collect sources, adjust the pathes +ES1_SOURCES := $(LOCAL_ES1_SOURCES) $(addprefix $(MESA)/,$(MESA_ES1_SOURCES)) +ES1_GALLIUM_SOURCES := $(LOCAL_ES1_GALLIUM_SOURCES) $(addprefix $(MESA)/,$(MESA_ES1_GALLIUM_SOURCES)) +ES1_API_SOURCES := $(addprefix $(MESA)/,$(MESA_ES1_API_SOURCES)) + +ES2_SOURCES := $(LOCAL_ES2_SOURCES) $(addprefix $(MESA)/,$(MESA_ES2_SOURCES)) +ES2_GALLIUM_SOURCES := $(LOCAL_ES2_GALLIUM_SOURCES) $(addprefix $(MESA)/,$(MESA_ES2_GALLIUM_SOURCES)) +ES2_API_SOURCES := $(addprefix $(MESA)/,$(MESA_ES2_API_SOURCES)) + +# collect includes +ES1_INCLUDES := $(LOCAL_ES1_INCLUDES) $(MESA_ES1_INCLUDES) +ES2_INCLUDES := $(LOCAL_ES2_INCLUDES) $(MESA_ES2_INCLUDES) + +# collect objects, including asm +ES1_OBJECTS := \ + $(LOCAL_ES1_SOURCES:.c=.o) \ + $(MESA_ES1_SOURCES:.c=.o) \ + $(MESA_ES_ASM:.S=.o) + +ES1_GALLIUM_OBJECTS := \ + $(LOCAL_ES1_GALLIUM_SOURCES:.c=.o) \ + $(MESA_ES1_GALLIUM_SOURCES:.c=.o) \ + $(MESA_ES_ASM:.S=.o) + +ES1_API_OBJECTS := \ + $(LOCAL_ES1_API_ASM:.S=.o) \ + $(MESA_ES1_API_SOURCES:.c=.o) + +ES2_OBJECTS := \ + $(LOCAL_ES2_SOURCES:.c=.o) \ + $(MESA_ES2_SOURCES:.c=.o) \ + $(MESA_ES_ASM:.S=.o) + +ES2_GALLIUM_OBJECTS := \ + $(LOCAL_ES2_GALLIUM_SOURCES:.c=.o) \ + $(MESA_ES2_GALLIUM_SOURCES:.c=.o) \ + $(MESA_ES_ASM:.S=.o) + +ES2_API_OBJECTS := \ + $(LOCAL_ES2_API_ASM:.S=.o) \ + $(MESA_ES2_API_SOURCES:.c=.o) + +# collect sources for makedepend +ES1_ALL_SOURCES := $(ES1_SOURCES) $(ES1_GALLIUM_SOURCES) $(ES1_API_SOURCES) +ES2_ALL_SOURCES := $(ES2_SOURCES) $(ES2_GALLIUM_SOURCES) $(ES2_API_SOURCES) + +# sort to remove duplicates +ES1_ALL_SOURCES := $(sort $(ES1_ALL_SOURCES)) +ES2_ALL_SOURCES := $(sort $(ES2_ALL_SOURCES)) -- cgit v1.2.3 From 34064756a5e2c8952c9de26eaebafddabd562540 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 22 Sep 2009 15:00:24 +0800 Subject: mesa/es: Add support for GL_OES_draw_texture. Signed-off-by: Chia-I Wu --- src/mesa/es/main/APIspec.txt | 77 ++++++++ src/mesa/es/main/drawtex.c | 148 +++++++++++++++ src/mesa/es/main/drawtex.h | 77 ++++++++ src/mesa/es/main/mfeatures_es1.h | 1 + src/mesa/es/main/mfeatures_es2.h | 1 + src/mesa/es/main/specials_es1.c | 5 + src/mesa/es/sources.mak | 4 +- src/mesa/es/state_tracker/st_cb_drawtex.c | 297 ++++++++++++++++++++++++++++++ src/mesa/es/state_tracker/st_cb_drawtex.h | 18 ++ src/mesa/main/dd.h | 10 + src/mesa/main/extensions.c | 3 + src/mesa/main/mtypes.h | 3 + src/mesa/state_tracker/st_context.c | 9 +- src/mesa/state_tracker/st_extensions.c | 4 + 14 files changed, 654 insertions(+), 3 deletions(-) create mode 100644 src/mesa/es/main/drawtex.c create mode 100644 src/mesa/es/main/drawtex.h create mode 100644 src/mesa/es/state_tracker/st_cb_drawtex.c create mode 100644 src/mesa/es/state_tracker/st_cb_drawtex.h diff --git a/src/mesa/es/main/APIspec.txt b/src/mesa/es/main/APIspec.txt index 86dd546f63..6d18ae67d9 100644 --- a/src/mesa/es/main/APIspec.txt +++ b/src/mesa/es/main/APIspec.txt @@ -412,6 +412,8 @@ checkdependentparam pname GL_TEXTURE_WRAP_T params GLES1.1:GL_MIRRORED_REPEAT_OE dependentvector params 1 pname GL_TEXTURE_MAX_ANISOTROPY_EXT # OES_texture_3D checkdependentparam pname GL_TEXTURE_WRAP_R_OES params GLES2.0:GL_CLAMP_TO_EDGE GLES2.0:GL_REPEAT GLES2.0:GL_MIRRORED_REPEAT +# OES_draw_texture - not in gl2ext.h +dependentvector params 4 pname GLES1.1:GL_TEXTURE_CROP_RECT_OES category GLES1.1 GLES2.0 name TexParameteri @@ -457,6 +459,8 @@ checkdependentparam pname GL_TEXTURE_WRAP_T params GLES1.1:GL_MIRRORED_REPEAT_OE dependentvector params 1 pname GL_TEXTURE_MAX_ANISOTROPY_EXT # OES_texture_3D checkdependentparam pname GL_TEXTURE_WRAP_R_OES params GLES2.0:GL_CLAMP_TO_EDGE GLES2.0:GL_REPEAT GLES2.0:GL_MIRRORED_REPEAT +# OES_draw_texture - not in gl2ext.h +dependentvector params 4 pname GLES1.1:GL_TEXTURE_CROP_RECT_OES category GLES1.1 GLES2.0 name TexParameterx @@ -498,6 +502,8 @@ checkdependentparam pname GL_TEXTURE_MAG_FILTER params GL_NEAREST GL_LINEAR checkdependentparam pname GL_GENERATE_MIPMAP params GL_TRUE GL_FALSE convertalias TexParameterfv convertparams GLfloat params +# OES_draw_texture +dependentvector params 4 pname GL_TEXTURE_CROP_RECT_OES # OES_texture_cube_map checkparam target GL_TEXTURE_CUBE_MAP_OES # OES_texture_mirrored_repeat @@ -1352,6 +1358,8 @@ param pname GLenum param params GLfloat * dependentvector params 1 pname GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_TEXTURE_MIN_FILTER GL_TEXTURE_MAG_FILTER GLES1.1:GL_GENERATE_MIPMAP props get +# OES_draw_texture - not in gl2ext.h +dependentvector params 4 pname GLES1.1:GL_TEXTURE_CROP_RECT_OES # OES_texture_cube_map checkparam target GLES1.1:GL_TEXTURE_CUBE_MAP_OES category GLES1.1 GLES2.0 @@ -1366,6 +1374,8 @@ dependentvector params 1 pname GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_TEXTURE_MI props get # OES_texture_cube_map checkparam target GLES1.1:GL_TEXTURE_CUBE_MAP_OES +# OES_draw_texture - not in gl2ext.h +dependentvector params 4 pname GLES1.1:GL_TEXTURE_CROP_RECT_OES # OES_texture_3D checkparam target GLES2.0:GL_TEXTURE_3D_OES category GLES1.1 GLES2.0 @@ -1383,6 +1393,8 @@ dependentnovalueconvert params pname GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_TEXT props get # OES_texture_cube_map checkparam target GL_TEXTURE_CUBE_MAP_OES +# OES_draw_texture +dependentvector params 4 pname GL_TEXTURE_CROP_RECT_OES category GLES1.1 GLES1.1:OES_fixed_point # GLES1.1 and GLES2.0 have different capabilities @@ -2867,6 +2879,71 @@ vector exponent 16 props get category GLES1.1:OES_query_matrix +# OES_draw_texture +name DrawTexf +return void +param x GLfloat +param y GLfloat +param z GLfloat +param w GLfloat +param h GLfloat +category GLES1.1:OES_draw_texture + +name DrawTexi +return void +param x GLint +param y GLint +param z GLint +param w GLint +param h GLint +category GLES1.1:OES_draw_texture + +name DrawTexs +return void +param x GLshort +param y GLshort +param z GLshort +param w GLshort +param h GLshort +category GLES1.1:OES_draw_texture + +name DrawTexx +return void +param x GLfixed +param y GLfixed +param z GLfixed +param w GLfixed +param h GLfixed +convertalias DrawTexf +convertparams GLfloat x y z w h +category GLES1.1:OES_draw_texture + +name DrawTexfv +return void +param coords const GLfloat * +vector coords 5 +category GLES1.1:OES_draw_texture + +name DrawTexiv +return void +param coords const GLint * +vector coords 5 +category GLES1.1:OES_draw_texture + +name DrawTexsv +return void +param coords const GLshort * +vector coords 5 +category GLES1.1:OES_draw_texture + +name DrawTexxv +return void +param coords const GLfixed * +vector coords 5 +convertalias DrawTexfv +convertparams GLfloat coords +category GLES1.1:OES_draw_texture + # We don't support OES_get_program_binary yet either #name GetProgramBinary #return void diff --git a/src/mesa/es/main/drawtex.c b/src/mesa/es/main/drawtex.c new file mode 100644 index 0000000000..cbd41ca975 --- /dev/null +++ b/src/mesa/es/main/drawtex.c @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2009 Chia-I Wu + * + * 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. + */ + +#include "drawtex.h" +#include "main/state.h" +#include "main/imports.h" + +#include "glapi/dispatch.h" + + +#if FEATURE_OES_draw_texture + + +static void +draw_texture(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, + GLfloat width, GLfloat height) +{ + if (!ctx->Extensions.OES_draw_texture) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glDrawTex(unsupported)"); + return; + } + if (width <= 0.0f || height <= 0.0f) { + _mesa_error(ctx, GL_INVALID_VALUE, "glDrawTex(width or height <= 0)"); + return; + } + + if (ctx->NewState) + _mesa_update_state(ctx); + + ASSERT(ctx->Driver.DrawTex); + ctx->Driver.DrawTex(ctx, x, y, z, width, height); +} + + +void GLAPIENTRY +_mesa_DrawTexf(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, x, y, z, width, height); +} + + +void GLAPIENTRY +_mesa_DrawTexfv(const GLfloat *coords) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, coords[0], coords[1], coords[2], coords[3], coords[4]); +} + + +void GLAPIENTRY +_mesa_DrawTexi(GLint x, GLint y, GLint z, GLint width, GLint height) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, (GLfloat) x, (GLfloat) y, (GLfloat) z, + (GLfloat) width, (GLfloat) height); +} + + +void GLAPIENTRY +_mesa_DrawTexiv(const GLint *coords) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, (GLfloat) coords[0], (GLfloat) coords[1], + (GLfloat) coords[2], (GLfloat) coords[3], (GLfloat) coords[4]); +} + + +void GLAPIENTRY +_mesa_DrawTexs(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, (GLfloat) x, (GLfloat) y, (GLfloat) z, + (GLfloat) width, (GLfloat) height); +} + + +void GLAPIENTRY +_mesa_DrawTexsv(const GLshort *coords) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, (GLfloat) coords[0], (GLfloat) coords[1], + (GLfloat) coords[2], (GLfloat) coords[3], (GLfloat) coords[4]); +} + + +void GLAPIENTRY +_mesa_DrawTexx(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, + (GLfloat) x / 65536.0f, + (GLfloat) y / 65536.0f, + (GLfloat) z / 65536.0f, + (GLfloat) width / 65536.0f, + (GLfloat) height / 65536.0f); +} + + +void GLAPIENTRY +_mesa_DrawTexxv(const GLfixed *coords) +{ + GET_CURRENT_CONTEXT(ctx); + draw_texture(ctx, + (GLfloat) coords[0] / 65536.0f, + (GLfloat) coords[1] / 65536.0f, + (GLfloat) coords[2] / 65536.0f, + (GLfloat) coords[3] / 65536.0f, + (GLfloat) coords[4] / 65536.0f); +} + + +void +_mesa_init_drawtex_dispatch(struct _glapi_table *disp) +{ + SET_DrawTexfOES(disp, _mesa_DrawTexf); + SET_DrawTexfvOES(disp, _mesa_DrawTexfv); + SET_DrawTexiOES(disp, _mesa_DrawTexi); + SET_DrawTexivOES(disp, _mesa_DrawTexiv); + SET_DrawTexsOES(disp, _mesa_DrawTexs); + SET_DrawTexsvOES(disp, _mesa_DrawTexsv); + SET_DrawTexxOES(disp, _mesa_DrawTexx); + SET_DrawTexxvOES(disp, _mesa_DrawTexxv); +} + + +#endif /* FEATURE_OES_draw_texture */ diff --git a/src/mesa/es/main/drawtex.h b/src/mesa/es/main/drawtex.h new file mode 100644 index 0000000000..0f3bac38c7 --- /dev/null +++ b/src/mesa/es/main/drawtex.h @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2009 Chia-I Wu + * + * 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. + */ + +#ifndef DRAWTEX_H +#define DRAWTEX_H + + +#include "main/mtypes.h" + + +#if FEATURE_OES_draw_texture + +#define _MESA_INIT_DRAWTEX_FUNCTIONS(driver, impl) \ + do { \ + (driver)->DrawTex = impl ## DrawTex; \ + } while (0) + +extern void GLAPIENTRY +_mesa_DrawTexf(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height); + +extern void GLAPIENTRY +_mesa_DrawTexfv(const GLfloat *coords); + +extern void GLAPIENTRY +_mesa_DrawTexi(GLint x, GLint y, GLint z, GLint width, GLint height); + +extern void GLAPIENTRY +_mesa_DrawTexiv(const GLint *coords); + +extern void GLAPIENTRY +_mesa_DrawTexs(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height); + +extern void GLAPIENTRY +_mesa_DrawTexsv(const GLshort *coords); + +extern void GLAPIENTRY +_mesa_DrawTexx(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height); + +extern void GLAPIENTRY +_mesa_DrawTexxv(const GLfixed *coords); + +extern void +_mesa_init_drawtex_dispatch(struct _glapi_table *disp); + +#else /* FEATURE_OES_draw_texture */ + +#define _MESA_INIT_DRAWTEX_FUNCTIONS(driver, impl) do { } while (0) + +static INLINE void +_mesa_init_drawtex_dispatch(struct _glapi_table *disp) +{ +} + +#endif /* FEATURE_OES_draw_texture */ + + +#endif /* DRAWTEX_H */ diff --git a/src/mesa/es/main/mfeatures_es1.h b/src/mesa/es/main/mfeatures_es1.h index 9c65596089..6c2ece2608 100644 --- a/src/mesa/es/main/mfeatures_es1.h +++ b/src/mesa/es/main/mfeatures_es1.h @@ -103,6 +103,7 @@ #define FEATURE_NV_vertex_program 0 #define FEATURE_OES_framebuffer_object 1 +#define FEATURE_OES_draw_texture 1 #define FEATURE_OES_mapbuffer 1 #define FEATURE_extra_context_init 1 diff --git a/src/mesa/es/main/mfeatures_es2.h b/src/mesa/es/main/mfeatures_es2.h index 6ed7b678dc..f34782fedb 100644 --- a/src/mesa/es/main/mfeatures_es2.h +++ b/src/mesa/es/main/mfeatures_es2.h @@ -103,6 +103,7 @@ #define FEATURE_NV_vertex_program 0 #define FEATURE_OES_framebuffer_object 1 +#define FEATURE_OES_draw_texture 0 #define FEATURE_OES_mapbuffer 1 #define FEATURE_extra_context_init 1 diff --git a/src/mesa/es/main/specials_es1.c b/src/mesa/es/main/specials_es1.c index 84d339ebf6..548fb0f029 100644 --- a/src/mesa/es/main/specials_es1.c +++ b/src/mesa/es/main/specials_es1.c @@ -100,6 +100,11 @@ make_extension_string(const GLcontext *ctx, char *str) /* 1.1 deprecated extensions */ len += append_extension(&str, "GL_OES_query_matrix"); +#if FEATURE_OES_draw_texture + if (ctx->Extensions.OES_draw_texture) + len += append_extension(&str, "GL_OES_draw_texture"); +#endif + if (ctx->Extensions.EXT_blend_equation_separate) len += append_extension(&str, "GL_OES_blend_equation_separate"); if (ctx->Extensions.EXT_blend_func_separate) diff --git a/src/mesa/es/sources.mak b/src/mesa/es/sources.mak index d12acaae80..11f735d52a 100644 --- a/src/mesa/es/sources.mak +++ b/src/mesa/es/sources.mak @@ -4,6 +4,7 @@ include $(MESA)/sources.mak LOCAL_ES1_SOURCES := \ main/api_exec_es1.c \ + main/drawtex.c \ main/get_es1.c \ main/specials_es1.c \ main/drawtex.c \ @@ -14,7 +15,8 @@ LOCAL_ES1_SOURCES := \ glapi/glapi-es1/main/enums.c LOCAL_ES1_GALLIUM_SOURCES := \ - $(LOCAL_ES1_SOURCES) + $(LOCAL_ES1_SOURCES) \ + state_tracker/st_cb_drawtex.c # always use local version of GLAPI_ASM_SOURCES LOCAL_ES1_API_ASM := $(addprefix glapi/glapi-es1/, $(GLAPI_ASM_SOURCES)) diff --git a/src/mesa/es/state_tracker/st_cb_drawtex.c b/src/mesa/es/state_tracker/st_cb_drawtex.c new file mode 100644 index 0000000000..3b98b9c40b --- /dev/null +++ b/src/mesa/es/state_tracker/st_cb_drawtex.c @@ -0,0 +1,297 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + **************************************************************************/ + + +/** + * Implementation of glDrawTex() for GL_OES_draw_tex + */ + + + +#include "main/imports.h" +#include "main/image.h" +#include "main/bufferobj.h" +#include "main/drawtex.h" +#include "main/macros.h" +#include "main/state.h" +#include "main/texformat.h" +#include "shader/program.h" +#include "shader/prog_parameter.h" +#include "shader/prog_print.h" + +#include "st_context.h" +#include "st_atom.h" +#include "st_atom_constbuf.h" +#include "st_draw.h" +#include "st_cb_drawtex.h" + +#include "pipe/p_context.h" +#include "pipe/p_defines.h" +#include "pipe/p_inlines.h" +#include "pipe/p_shader_tokens.h" +#include "util/u_tile.h" +#include "util/u_draw_quad.h" +#include "util/u_simple_shaders.h" + +#include "cso_cache/cso_context.h" + + +struct cached_shader +{ + //struct pipe_shader_state shader; + void *handle; + + uint num_attribs; + uint semantic_names[2 + MAX_TEXTURE_UNITS]; + uint semantic_indexes[2 + MAX_TEXTURE_UNITS]; +}; + +#define MAX_SHADERS (2 * MAX_TEXTURE_UNITS) + +/** + * Simple linear list cache. + * Most of the time there'll only be one cached shader. + */ +static struct cached_shader CachedShaders[MAX_SHADERS]; +static GLuint NumCachedShaders = 0; + + +#if FEATURE_OES_draw_texture + + +static void * +lookup_shader(struct pipe_context *pipe, + uint num_attribs, + const uint *semantic_names, + const uint *semantic_indexes) +{ + GLuint i, j; + + /* look for existing shader with same attributes */ + for (i = 0; i < NumCachedShaders; i++) { + if (CachedShaders[i].num_attribs == num_attribs) { + GLboolean match = GL_TRUE; + for (j = 0; j < num_attribs; j++) { + if (semantic_names[j] != CachedShaders[i].semantic_names[j] || + semantic_indexes[j] != CachedShaders[i].semantic_indexes[j]) { + match = GL_FALSE; + break; + } + } + if (match) + return CachedShaders[i].handle; + } + } + + /* not found - create new one now */ + if (NumCachedShaders >= MAX_SHADERS) { + return NULL; + } + + CachedShaders[i].num_attribs = num_attribs; + for (j = 0; j < num_attribs; j++) { + CachedShaders[i].semantic_names[j] = semantic_names[j]; + CachedShaders[i].semantic_indexes[j] = semantic_indexes[j]; + } + + CachedShaders[i].handle = + util_make_vertex_passthrough_shader(pipe, + num_attribs, + semantic_names, + semantic_indexes); + NumCachedShaders++; + + return CachedShaders[i].handle; +} + +static void +st_DrawTex(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, + GLfloat width, GLfloat height) +{ + struct st_context *st = ctx->st; + struct pipe_context *pipe = st->pipe; + struct cso_context *cso = ctx->st->cso_context; + struct pipe_buffer *vbuffer; + GLuint i, numTexCoords, numAttribs; + GLboolean emitColor; + uint semantic_names[2 + MAX_TEXTURE_UNITS]; + uint semantic_indexes[2 + MAX_TEXTURE_UNITS]; + GLbitfield inputs = VERT_BIT_POS; + + /* determine if we need vertex color */ + if (ctx->FragmentProgram._Current->Base.InputsRead & FRAG_BIT_COL0) + emitColor = GL_TRUE; + else + emitColor = GL_FALSE; + + /* determine how many enabled sets of texcoords */ + numTexCoords = 0; + for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { + if (ctx->Texture.Unit[i]._ReallyEnabled & TEXTURE_2D_BIT) { + inputs |= VERT_BIT_TEX(i); + numTexCoords++; + } + } + + /* total number of attributes per vertex */ + numAttribs = 1 + emitColor + numTexCoords; + + + /* create the vertex buffer */ + vbuffer = pipe_buffer_create(pipe->screen, 32, PIPE_BUFFER_USAGE_VERTEX, + numAttribs * 4 * 4 * sizeof(GLfloat)); + + /* load vertex buffer */ + { +#define SET_ATTRIB(VERT, ATTR, X, Y, Z, W) \ + do { \ + GLuint k = (((VERT) * numAttribs + (ATTR)) * 4); \ + assert(k < 4 * 4 * numAttribs); \ + vbuf[k + 0] = X; \ + vbuf[k + 1] = Y; \ + vbuf[k + 2] = Z; \ + vbuf[k + 3] = W; \ + } while (0) + + const GLfloat x0 = x, y0 = y, x1 = x + width, y1 = y + height; + GLfloat *vbuf = (GLfloat *) pipe_buffer_map(pipe->screen, vbuffer, + PIPE_BUFFER_USAGE_CPU_WRITE); + GLuint attr; + + z = CLAMP(z, 0.0f, 1.0f); + + /* positions (in clip coords) */ + { + const struct gl_framebuffer *fb = st->ctx->DrawBuffer; + const GLfloat fb_width = (GLfloat)fb->Width; + const GLfloat fb_height = (GLfloat)fb->Height; + + const GLfloat clip_x0 = (GLfloat)(x0 / fb_width * 2.0 - 1.0); + const GLfloat clip_y0 = (GLfloat)(y0 / fb_height * 2.0 - 1.0); + const GLfloat clip_x1 = (GLfloat)(x1 / fb_width * 2.0 - 1.0); + const GLfloat clip_y1 = (GLfloat)(y1 / fb_height * 2.0 - 1.0); + + SET_ATTRIB(0, 0, clip_x0, clip_y0, z, 1.0f); /* lower left */ + SET_ATTRIB(1, 0, clip_x1, clip_y0, z, 1.0f); /* lower right */ + SET_ATTRIB(2, 0, clip_x1, clip_y1, z, 1.0f); /* upper right */ + SET_ATTRIB(3, 0, clip_x0, clip_y1, z, 1.0f); /* upper left */ + + semantic_names[0] = TGSI_SEMANTIC_POSITION; + semantic_indexes[0] = 0; + } + + /* colors */ + if (emitColor) { + const GLfloat *c = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; + SET_ATTRIB(0, 1, c[0], c[1], c[2], c[3]); + SET_ATTRIB(1, 1, c[0], c[1], c[2], c[3]); + SET_ATTRIB(2, 1, c[0], c[1], c[2], c[3]); + SET_ATTRIB(3, 1, c[0], c[1], c[2], c[3]); + semantic_names[1] = TGSI_SEMANTIC_COLOR; + semantic_indexes[1] = 0; + attr = 2; + } + else { + attr = 1; + } + + /* texcoords */ + for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { + if (ctx->Texture.Unit[i]._ReallyEnabled & TEXTURE_2D_BIT) { + struct gl_texture_object *obj = ctx->Texture.Unit[i]._Current; + struct gl_texture_image *img = obj->Image[0][obj->BaseLevel]; + const GLfloat wt = (GLfloat) img->Width; + const GLfloat ht = (GLfloat) img->Height; + const GLfloat s0 = obj->CropRect[0] / wt; + const GLfloat t0 = obj->CropRect[1] / ht; + const GLfloat s1 = (obj->CropRect[0] + obj->CropRect[2]) / wt; + const GLfloat t1 = (obj->CropRect[1] + obj->CropRect[3]) / ht; + + /*printf("crop texcoords: %g, %g .. %g, %g\n", s0, t0, s1, t1);*/ + SET_ATTRIB(0, attr, s0, t0, 0.0f, 1.0f); /* lower left */ + SET_ATTRIB(1, attr, s1, t0, 0.0f, 1.0f); /* lower right */ + SET_ATTRIB(2, attr, s1, t1, 0.0f, 1.0f); /* upper right */ + SET_ATTRIB(3, attr, s0, t1, 0.0f, 1.0f); /* upper left */ + + semantic_names[attr] = TGSI_SEMANTIC_GENERIC; + semantic_indexes[attr] = 0; + + attr++; + } + } + + pipe_buffer_unmap(pipe->screen, vbuffer); + +#undef SET_ATTRIB + } + + + cso_save_viewport(cso); + cso_save_vertex_shader(cso); + + { + void *vs = lookup_shader(pipe, numAttribs, + semantic_names, semantic_indexes); + cso_set_vertex_shader_handle(cso, vs); + } + + /* viewport state: viewport matching window dims */ + { + const struct gl_framebuffer *fb = st->ctx->DrawBuffer; + const GLboolean invert = (st_fb_orientation(fb) == Y_0_TOP); + const GLfloat width = (GLfloat)fb->Width; + const GLfloat height = (GLfloat)fb->Height; + struct pipe_viewport_state vp; + vp.scale[0] = 0.5f * width; + vp.scale[1] = height * (invert ? -0.5f : 0.5f); + vp.scale[2] = 1.0f; + vp.scale[3] = 1.0f; + vp.translate[0] = 0.5f * width; + vp.translate[1] = 0.5f * height; + vp.translate[2] = 0.0f; + vp.translate[3] = 0.0f; + cso_set_viewport(cso, &vp); + } + + + util_draw_vertex_buffer(pipe, vbuffer, + 0, /* offset */ + PIPE_PRIM_TRIANGLE_FAN, + 4, /* verts */ + numAttribs); /* attribs/vert */ + + + pipe_buffer_reference(&vbuffer, NULL); + + /* restore state */ + cso_restore_viewport(cso); + cso_restore_vertex_shader(cso); +} + + +#endif /* FEATURE_OES_draw_texture */ + + +void +st_init_drawtex_functions(struct dd_function_table *functions) +{ + _MESA_INIT_DRAWTEX_FUNCTIONS(functions, st_); +} + + +/** + * Free any cached shaders + */ +void +st_destroy_drawtex(struct st_context *st) +{ + GLuint i; + for (i = 0; i < NumCachedShaders; i++) { + cso_delete_vertex_shader(st->cso_context, CachedShaders[i].handle); + } + NumCachedShaders = 0; +} diff --git a/src/mesa/es/state_tracker/st_cb_drawtex.h b/src/mesa/es/state_tracker/st_cb_drawtex.h new file mode 100644 index 0000000000..7b0da70279 --- /dev/null +++ b/src/mesa/es/state_tracker/st_cb_drawtex.h @@ -0,0 +1,18 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + **************************************************************************/ + + +#ifndef ST_CB_DRAWTEX_H +#define ST_CB_DRAWTEX_H + +extern void +st_init_drawtex_functions(struct dd_function_table *functions); + +extern void +st_destroy_drawtex(struct st_context *st); + +#endif /* ST_CB_DRAWTEX_H */ diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 99f2cad402..0488a693b2 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -1046,6 +1046,16 @@ struct dd_function_table { GLbitfield, GLuint64); /*@}*/ #endif + +#if FEATURE_OES_draw_texture + /** + * \name GL_OES_draw_texture interface + */ + /*@{*/ + void (*DrawTex)(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, + GLfloat width, GLfloat height); + /*@}*/ +#endif }; diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 54cf37c5f4..7a8184ffc8 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -185,6 +185,9 @@ static const struct { { ON, "GL_SGIS_texture_lod", F(SGIS_texture_lod) }, { ON, "GL_SUN_multi_draw_arrays", F(EXT_multi_draw_arrays) }, { OFF, "GL_S3_s3tc", F(S3_s3tc) }, +#if FEATURE_OES_draw_texture + { OFF, "GL_OES_draw_texture", F(OES_draw_texture) }, +#endif /* FEATURE_OES_draw_texture */ }; diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 94d29a7dbb..e91c7e5ac1 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2485,6 +2485,9 @@ struct gl_extensions GLboolean SGIS_texture_lod; GLboolean TDFX_texture_compression_FXT1; GLboolean S3_s3tc; +#if FEATURE_OES_draw_texture + GLboolean OES_draw_texture; +#endif /* FEATURE_OES_draw_texture */ /** The extension string */ const GLubyte *String; }; diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index f0eddafd33..e82598c8e7 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -47,7 +47,7 @@ #include "st_cb_drawpixels.h" #include "st_cb_rasterpos.h" #endif -#ifdef FEATURE_OES_draw_texture +#if FEATURE_OES_draw_texture #include "st_cb_drawtex.h" #endif #include "st_cb_fbo.h" @@ -209,7 +209,7 @@ static void st_destroy_context_priv( struct st_context *st ) st_destroy_bitmap(st); st_destroy_drawpix(st); #endif -#ifdef FEATURE_OES_draw_texture +#if FEATURE_OES_draw_texture st_destroy_drawtex(st); #endif @@ -330,6 +330,11 @@ void st_init_driver_functions(struct dd_function_table *functions) st_init_drawpixels_functions(functions); st_init_rasterpos_functions(functions); #endif + +#if FEATURE_OES_draw_texture + st_init_drawtex_functions(functions); +#endif + st_init_fbo_functions(functions); st_init_get_functions(functions); #if FEATURE_feedback diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 3f835d38dd..ce3c302e48 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -183,6 +183,10 @@ void st_init_extensions(struct st_context *st) ctx->Extensions.NV_texgen_reflection = GL_TRUE; ctx->Extensions.NV_texture_env_combine4 = GL_TRUE; +#if FEATURE_OES_draw_texture + ctx->Extensions.OES_draw_texture = GL_TRUE; +#endif + ctx->Extensions.SGI_color_matrix = GL_TRUE; ctx->Extensions.SGIS_generate_mipmap = GL_TRUE; -- cgit v1.2.3 From d14ac1073cda7ea4f623f312eb469554c3041315 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 3 Sep 2009 11:31:17 +0800 Subject: st/es: Add OpenGL ES state trackers. Signed-off-by: Chia-I Wu --- src/gallium/state_trackers/es/Makefile | 88 ++++++++++++++++++++++++++++++++++ src/gallium/state_trackers/es/st_es1.c | 1 + src/gallium/state_trackers/es/st_es2.c | 1 + 3 files changed, 90 insertions(+) create mode 100644 src/gallium/state_trackers/es/Makefile create mode 100644 src/gallium/state_trackers/es/st_es1.c create mode 100644 src/gallium/state_trackers/es/st_es2.c diff --git a/src/gallium/state_trackers/es/Makefile b/src/gallium/state_trackers/es/Makefile new file mode 100644 index 0000000000..41d4ccb1a6 --- /dev/null +++ b/src/gallium/state_trackers/es/Makefile @@ -0,0 +1,88 @@ +# src/gallium/state_trackers/es/Makefile + +# Build the ES 1/2 state tracker libraries +# This consists of core Mesa ES, plus GL/gallium state tracker. + +TOP = ../../../.. +include $(TOP)/configs/current + +GLES_1_VERSION_MAJOR = 1 +GLES_1_VERSION_MINOR = 1 +GLES_1_VERSION_PATCH = 0 + +GLES_2_VERSION_MAJOR = 2 +GLES_2_VERSION_MINOR = 0 +GLES_2_VERSION_PATCH = 0 + + +# Maybe move these into configs/default: +GLES_1_LIB = GLESv1_CM +GLES_1_LIB_NAME = lib$(GLES_1_LIB).so +GLES_2_LIB = GLESv2 +GLES_2_LIB_NAME = lib$(GLES_2_LIB).so + + +ES1_OBJECTS = st_es1.o +ES2_OBJECTS = st_es2.o + + +# we only need the gallium libs that the state trackers directly use: +GALLIUM_LIBS = \ + $(TOP)/src/gallium/auxiliary/cso_cache/libcso_cache.a \ + $(TOP)/src/gallium/auxiliary/rtasm/librtasm.a \ + $(TOP)/src/gallium/auxiliary/tgsi/libtgsi.a \ + $(TOP)/src/gallium/auxiliary/util/libutil.a + +ES1_LIBS = \ + $(TOP)/src/mesa/es/libes1gallium.a \ + $(TOP)/src/mesa/es/libes1api.a + +ES2_LIBS = \ + $(TOP)/src/mesa/es/libes2gallium.a \ + $(TOP)/src/mesa/es/libes2api.a + +SYS_LIBS = -lm -pthread + + +.c.o: + $(CC) -c $(CFLAGS) $< -o $@ + + +# Default: make both GL ES 1.1 and GL ES 2.0 libraries +default: $(TOP)/$(LIB_DIR)/$(GLES_1_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLES_2_LIB_NAME) + +# Make the shared libs +$(TOP)/$(LIB_DIR)/$(GLES_1_LIB_NAME): $(ES1_OBJECTS) $(ES1_LIBS) + $(TOP)/bin/mklib -o $(GLES_1_LIB) \ + -major $(GLES_1_VERSION_MAJOR) \ + -minor $(GLES_1_VERSION_MINOR) \ + -patch $(GLES_1_VERSION_PATCH) \ + -install $(TOP)/$(LIB_DIR) \ + $(ES1_OBJECTS) \ + -Wl,--whole-archive $(ES1_LIBS) -Wl,--no-whole-archive \ + -Wl,--start-group $(GALLIUM_LIBS) -Wl,--end-group \ + $(SYS_LIBS) + +$(TOP)/$(LIB_DIR)/$(GLES_2_LIB_NAME): $(ES2_OBJECTS) $(ES1_LIBS) + $(TOP)/bin/mklib -o $(GLES_2_LIB) \ + -major $(GLES_2_VERSION_MAJOR) \ + -minor $(GLES_2_VERSION_MINOR) \ + -patch $(GLES_2_VERSION_PATCH) \ + -install $(TOP)/$(LIB_DIR) \ + $(ES2_OBJECTS) \ + -Wl,--whole-archive $(ES2_LIBS) -Wl,--no-whole-archive \ + -Wl,--start-group $(GALLIUM_LIBS) -Wl,--end-group \ + $(SYS_LIBS) + +install: default + $(INSTALL) -d $(INSTALL_DIR)/include/GLES + $(INSTALL) -m 644 $(TOP)/include/GLES/*.h $(INSTALL_DIR)/include/GLES + $(INSTALL) -d $(INSTALL_DIR)/include/GLES2 + $(INSTALL) -m 644 $(TOP)/include/GLES2/*.h $(INSTALL_DIR)/include/GLES2 + $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR) + $(INSTALL) $(TOP)/$(LIB_DIR)/libGLESv1* $(INSTALL_DIR)/$(LIB_DIR) + $(INSTALL) $(TOP)/$(LIB_DIR)/libGLESv2* $(INSTALL_DIR)/$(LIB_DIR) + +clean: + -rm -f *.o *~ + -rm -f $(TOP)/$(LIB_DIR)/$(GLES_1_LIB_NAME)* $(TOP)/$(LIB_DIR)/$(GLES_2_LIB_NAME)* diff --git a/src/gallium/state_trackers/es/st_es1.c b/src/gallium/state_trackers/es/st_es1.c new file mode 100644 index 0000000000..7f0c038957 --- /dev/null +++ b/src/gallium/state_trackers/es/st_es1.c @@ -0,0 +1 @@ +const int st_api_OpenGL_ES1 = 1; diff --git a/src/gallium/state_trackers/es/st_es2.c b/src/gallium/state_trackers/es/st_es2.c new file mode 100644 index 0000000000..78e3791fbe --- /dev/null +++ b/src/gallium/state_trackers/es/st_es2.c @@ -0,0 +1 @@ +const int st_api_OpenGL_ES2 = 1; -- cgit v1.2.3 From 5b85cada603ff0325dcf852f159837086a5bda14 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 2 Oct 2009 15:33:55 +0800 Subject: progs/es: OpenGL ES 1.x and 2.X demo programs. The demo programs are written by Brian Paul, and cherry-picked from opengl-es branch. Several minor issues such as a linking problem are fixed. Signed-off-by: Chia-I Wu --- progs/es1/xegl/Makefile | 77 ++++++ progs/es1/xegl/drawtex.c | 427 ++++++++++++++++++++++++++++ progs/es1/xegl/es1_info.c | 274 ++++++++++++++++++ progs/es1/xegl/msaa.c | 442 +++++++++++++++++++++++++++++ progs/es1/xegl/pbuffer.c | 607 ++++++++++++++++++++++++++++++++++++++++ progs/es1/xegl/render_tex.c | 657 ++++++++++++++++++++++++++++++++++++++++++++ progs/es1/xegl/torus.c | 509 ++++++++++++++++++++++++++++++++++ progs/es1/xegl/tri.c | 470 +++++++++++++++++++++++++++++++ progs/es1/xegl/two_win.c | 433 +++++++++++++++++++++++++++++ progs/es2/xegl/Makefile | 51 ++++ progs/es2/xegl/tri.c | 514 ++++++++++++++++++++++++++++++++++ 11 files changed, 4461 insertions(+) create mode 100644 progs/es1/xegl/Makefile create mode 100644 progs/es1/xegl/drawtex.c create mode 100644 progs/es1/xegl/es1_info.c create mode 100644 progs/es1/xegl/msaa.c create mode 100644 progs/es1/xegl/pbuffer.c create mode 100644 progs/es1/xegl/render_tex.c create mode 100644 progs/es1/xegl/torus.c create mode 100644 progs/es1/xegl/tri.c create mode 100644 progs/es1/xegl/two_win.c create mode 100644 progs/es2/xegl/Makefile create mode 100644 progs/es2/xegl/tri.c diff --git a/progs/es1/xegl/Makefile b/progs/es1/xegl/Makefile new file mode 100644 index 0000000000..7f684d68e3 --- /dev/null +++ b/progs/es1/xegl/Makefile @@ -0,0 +1,77 @@ +# progs/es1/xegl/Makefile + +TOP = ../../.. +include $(TOP)/configs/current + + +INCLUDE_DIRS = \ + -I$(TOP)/include \ + +HEADERS = $(TOP)/include/GLES/egl.h + + +ES1_LIB_DEPS = \ + $(TOP)/$(LIB_DIR)/libEGL.so \ + $(TOP)/$(LIB_DIR)/libGLESv1_CM.so + + +ES1_LIBS = \ + -L$(TOP)/$(LIB_DIR) -lEGL \ + -L$(TOP)/$(LIB_DIR) -lGLESv1_CM $(LIBDRM_LIB) -lX11 + +PROGRAMS = \ + drawtex \ + es1_info \ + msaa \ + pbuffer \ + render_tex \ + torus \ + tri \ + two_win + + +.c.o: + $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ + + + +default: $(PROGRAMS) + + + +drawtex: drawtex.o $(ES1_LIB_DEPS) + $(CC) $(CFLAGS) drawtex.o $(ES1_LIBS) -o $@ + + +es1_info: es1_info.o $(ES1_LIB_DEPS) + $(CC) $(CFLAGS) es1_info.o $(ES1_LIBS) -o $@ + + +msaa: msaa.o $(ES1_LIB_DEPS) + $(CC) $(CFLAGS) msaa.o $(ES1_LIBS) -o $@ + + +pbuffer: pbuffer.o $(ES1_LIB_DEPS) + $(CC) $(CFLAGS) pbuffer.o $(ES1_LIBS) -o $@ + + +render_tex: render_tex.o $(ES1_LIB_DEPS) + $(CC) $(CFLAGS) render_tex.o $(ES1_LIBS) -o $@ + + +torus: torus.o $(ES1_LIB_DEPS) + $(CC) $(CFLAGS) torus.o $(ES1_LIBS) -o $@ + + +two_win: two_win.o $(ES1_LIB_DEPS) + $(CC) $(CFLAGS) two_win.o $(ES1_LIBS) -o $@ + + +tri: tri.o $(ES1_LIB_DEPS) + $(CC) $(CFLAGS) tri.o $(ES1_LIBS) -o $@ + + +clean: + rm -f *.o *~ + rm -f $(PROGRAMS) + diff --git a/progs/es1/xegl/drawtex.c b/progs/es1/xegl/drawtex.c new file mode 100644 index 0000000000..ca0615e267 --- /dev/null +++ b/progs/es1/xegl/drawtex.c @@ -0,0 +1,427 @@ +/* + * Copyright (C) 2008 Tunsgten Graphics,Inc. All Rights Reserved. + */ + +/* + * Test GL_OES_draw_texture + * Brian Paul + * August 2008 + */ + +#define GL_GLEXT_PROTOTYPES + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +static GLfloat view_posx = 10.0, view_posy = 20.0; +static GLfloat width = 200, height = 200; + + +static void +draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glDrawTexfOES(view_posx, view_posy, 0.0, width, height); +} + + +/* new window size or exposure */ +static void +reshape(int width, int height) +{ + GLfloat ar = (GLfloat) width / (GLfloat) height; + + glViewport(0, 0, (GLint) width, (GLint) height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + +#ifdef GL_VERSION_ES_CM_1_0 + glFrustumf(-ar, ar, -1, 1, 5.0, 60.0); +#else + glFrustum(-ar, ar, -1, 1, 5.0, 60.0); +#endif + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -15.0); +} + + +static float +dist(GLuint i, GLuint j, float x, float y) +{ + return sqrt((i-x) * (i-x) + (j-y) * (j-y)); +} + +static void +make_smile_texture(void) +{ +#define SZ 128 + GLenum Filter = GL_LINEAR; + GLubyte image[SZ][SZ][4]; + GLuint i, j; + GLint cropRect[4]; + + for (i = 0; i < SZ; i++) { + for (j = 0; j < SZ; j++) { + GLfloat d_mouth = dist(i, j, SZ/2, SZ/2); + GLfloat d_rt_eye = dist(i, j, SZ*3/4, SZ*3/4); + GLfloat d_lt_eye = dist(i, j, SZ*3/4, SZ*1/4); + if (d_rt_eye < SZ / 8 || d_lt_eye < SZ / 8) { + image[i][j][0] = 20; + image[i][j][1] = 50; + image[i][j][2] = 255; + image[i][j][3] = 255; + } + else if (i < SZ/2 && d_mouth < SZ/3) { + image[i][j][0] = 255; + image[i][j][1] = 20; + image[i][j][2] = 20; + image[i][j][3] = 255; + } + else { + image[i][j][0] = 200; + image[i][j][1] = 200; + image[i][j][2] = 200; + image[i][j][3] = 255; + } + } + } + + glActiveTexture(GL_TEXTURE0); /* unit 0 */ + glBindTexture(GL_TEXTURE_2D, 42); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SZ, SZ, 0, + GL_RGBA, GL_UNSIGNED_BYTE, image); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, Filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, Filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + + cropRect[0] = 0; + cropRect[1] = 0; + cropRect[2] = SZ; + cropRect[3] = SZ; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, cropRect); +#undef SZ +} + + + +static void +init(void) +{ + const char *ext = (char *) glGetString(GL_EXTENSIONS); + + if (!strstr(ext, "GL_OES_draw_texture")) { + fprintf(stderr, "Sorry, this program requires GL_OES_draw_texture"); + exit(1); + } + + glClearColor(0.4, 0.4, 0.4, 0.0); + + make_smile_texture(); + glEnable(GL_TEXTURE_2D); +} + + +/* + * Create an RGB, double-buffered X window. + * Return the window and context handles. + */ +static void +make_x_window(Display *x_dpy, EGLDisplay egl_dpy, + const char *name, + int x, int y, int width, int height, + Window *winRet, + EGLContext *ctxRet, + EGLSurface *surfRet) +{ + static const EGLint attribs[] = { + EGL_RED_SIZE, 1, + EGL_GREEN_SIZE, 1, + EGL_BLUE_SIZE, 1, + EGL_NONE + }; + + int scrnum; + XSetWindowAttributes attr; + unsigned long mask; + Window root; + Window win; + XVisualInfo *visInfo, visTemplate; + int num_visuals; + EGLContext ctx; + EGLConfig config; + EGLint num_configs; + EGLint vid; + + scrnum = DefaultScreen( x_dpy ); + root = RootWindow( x_dpy, scrnum ); + + if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) { + printf("Error: couldn't get an EGL visual config\n"); + exit(1); + } + + assert(config); + assert(num_configs > 0); + + if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) { + printf("Error: eglGetConfigAttrib() failed\n"); + exit(1); + } + + /* The X window visual must match the EGL config */ + visTemplate.visualid = vid; + visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals); + if (!visInfo) { + printf("Error: couldn't get X visual\n"); + exit(1); + } + + /* window attributes */ + attr.background_pixel = 0; + attr.border_pixel = 0; + attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone); + attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; + mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; + + win = XCreateWindow( x_dpy, root, 0, 0, width, height, + 0, visInfo->depth, InputOutput, + visInfo->visual, mask, &attr ); + + /* set hints and properties */ + { + XSizeHints sizehints; + sizehints.x = x; + sizehints.y = y; + sizehints.width = width; + sizehints.height = height; + sizehints.flags = USSize | USPosition; + XSetNormalHints(x_dpy, win, &sizehints); + XSetStandardProperties(x_dpy, win, name, name, + None, (char **)NULL, 0, &sizehints); + } + + eglBindAPI(EGL_OPENGL_ES_API); + + ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL ); + if (!ctx) { + printf("Error: eglCreateContext failed\n"); + exit(1); + } + + *surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL); + + if (!*surfRet) { + printf("Error: eglCreateWindowSurface failed\n"); + exit(1); + } + + XFree(visInfo); + + *winRet = win; + *ctxRet = ctx; +} + + +static void +event_loop(Display *dpy, Window win, + EGLDisplay egl_dpy, EGLSurface egl_surf) +{ + int anim = 0; + + while (1) { + int redraw = 0; + + if (!anim || XPending(dpy)) { + XEvent event; + XNextEvent(dpy, &event); + + switch (event.type) { + case Expose: + redraw = 1; + break; + case ConfigureNotify: + reshape(event.xconfigure.width, event.xconfigure.height); + break; + case KeyPress: + { + char buffer[10]; + int r, code; + code = XLookupKeysym(&event.xkey, 0); + if (code == XK_Left) { + view_posx -= 1.0; + } + else if (code == XK_Right) { + view_posx += 1.0; + } + else if (code == XK_Up) { + view_posy += 1.0; + } + else if (code == XK_Down) { + view_posy -= 1.0; + } + else { + r = XLookupString(&event.xkey, buffer, sizeof(buffer), + NULL, NULL); + if (buffer[0] == ' ') { + anim = !anim; + } + else if (buffer[0] == 'w') { + width -= 1.0f; + } + else if (buffer[0] == 'W') { + width += 1.0f; + } + else if (buffer[0] == 'h') { + height -= 1.0f; + } + else if (buffer[0] == 'H') { + height += 1.0f; + } + else if (buffer[0] == 27) { + /* escape */ + return; + } + } + } + redraw = 1; + break; + default: + ; /*no-op*/ + } + } + + if (anim) { + view_posx += 1.0; + view_posy += 2.0; + redraw = 1; + } + + if (redraw) { + draw(); + eglSwapBuffers(egl_dpy, egl_surf); + } + } +} + + +static void +usage(void) +{ + printf("Usage:\n"); + printf(" -display set the display to run on\n"); + printf(" -info display OpenGL renderer info\n"); +} + + +int +main(int argc, char *argv[]) +{ + const int winWidth = 400, winHeight = 300; + Display *x_dpy; + Window win; + EGLSurface egl_surf; + EGLContext egl_ctx; + EGLDisplay egl_dpy; + char *dpyName = NULL; + GLboolean printInfo = GL_FALSE; + EGLint egl_major, egl_minor; + int i; + const char *s; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-display") == 0) { + dpyName = argv[i+1]; + i++; + } + else if (strcmp(argv[i], "-info") == 0) { + printInfo = GL_TRUE; + } + else { + usage(); + return -1; + } + } + + x_dpy = XOpenDisplay(dpyName); + if (!x_dpy) { + printf("Error: couldn't open display %s\n", + dpyName ? dpyName : getenv("DISPLAY")); + return -1; + } + + egl_dpy = eglGetDisplay(x_dpy); + if (!egl_dpy) { + printf("Error: eglGetDisplay() failed\n"); + return -1; + } + + if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) { + printf("Error: eglInitialize() failed\n"); + return -1; + } + + s = eglQueryString(egl_dpy, EGL_VERSION); + printf("EGL_VERSION = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_VENDOR); + printf("EGL_VENDOR = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_EXTENSIONS); + printf("EGL_EXTENSIONS = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_CLIENT_APIS); + printf("EGL_CLIENT_APIS = %s\n", s); + + make_x_window(x_dpy, egl_dpy, + "drawtex", 0, 0, winWidth, winHeight, + &win, &egl_ctx, &egl_surf); + + XMapWindow(x_dpy, win); + if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) { + printf("Error: eglMakeCurrent() failed\n"); + return -1; + } + + if (printInfo) { + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS)); + } + + init(); + + /* Set initial projection/viewing transformation. + * We can't be sure we'll get a ConfigureNotify event when the window + * first appears. + */ + reshape(winWidth, winHeight); + + event_loop(x_dpy, win, egl_dpy, egl_surf); + + eglDestroyContext(egl_dpy, egl_ctx); + eglDestroySurface(egl_dpy, egl_surf); + eglTerminate(egl_dpy); + + + XDestroyWindow(x_dpy, win); + XCloseDisplay(x_dpy); + + return 0; +} diff --git a/progs/es1/xegl/es1_info.c b/progs/es1/xegl/es1_info.c new file mode 100644 index 0000000000..963304de13 --- /dev/null +++ b/progs/es1/xegl/es1_info.c @@ -0,0 +1,274 @@ +/* + * Copyright (C) 2008 Tunsgten Graphics,Inc. All Rights Reserved. + */ + +/* + * List OpenGL ES extensions. + * Print ES 1 or ES 2 extensions depending on which library we're + * linked with: libGLESv1_CM.so vs libGLESv2.so + */ + +#define GL_GLEXT_PROTOTYPES + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +/* + * Print a list of extensions, with word-wrapping. + */ +static void +print_extension_list(const char *ext) +{ + const char *indentString = " "; + const int indent = 4; + const int max = 79; + int width, i, j; + + if (!ext || !ext[0]) + return; + + width = indent; + printf(indentString); + i = j = 0; + while (1) { + if (ext[j] == ' ' || ext[j] == 0) { + /* found end of an extension name */ + const int len = j - i; + if (width + len > max) { + /* start a new line */ + printf("\n"); + width = indent; + printf(indentString); + } + /* print the extension name between ext[i] and ext[j] */ + while (i < j) { + printf("%c", ext[i]); + i++; + } + /* either we're all done, or we'll continue with next extension */ + width += len + 1; + if (ext[j] == 0) { + break; + } + else { + i++; + j++; + if (ext[j] == 0) + break; + printf(", "); + width += 2; + } + } + j++; + } + printf("\n"); +} + + +static void +info(EGLDisplay egl_dpy) +{ + const char *s; + + s = eglQueryString(egl_dpy, EGL_VERSION); + printf("EGL_VERSION = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_VENDOR); + printf("EGL_VENDOR = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_EXTENSIONS); + printf("EGL_EXTENSIONS = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_CLIENT_APIS); + printf("EGL_CLIENT_APIS = %s\n", s); + + printf("GL_VERSION: %s\n", (char *) glGetString(GL_VERSION)); + printf("GL_RENDERER: %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_EXTENSIONS:\n"); + print_extension_list((char *) glGetString(GL_EXTENSIONS)); +} + + +/* + * Create an RGB, double-buffered X window. + * Return the window and context handles. + */ +static void +make_x_window(Display *x_dpy, EGLDisplay egl_dpy, + const char *name, + int x, int y, int width, int height, + Window *winRet, + EGLContext *ctxRet, + EGLSurface *surfRet) +{ + static const EGLint attribs[] = { + EGL_RED_SIZE, 1, + EGL_GREEN_SIZE, 1, + EGL_BLUE_SIZE, 1, + EGL_NONE + }; + + int scrnum; + XSetWindowAttributes attr; + unsigned long mask; + Window root; + Window win; + XVisualInfo *visInfo, visTemplate; + int num_visuals; + EGLContext ctx; + EGLConfig config; + EGLint num_configs; + EGLint vid; + + scrnum = DefaultScreen( x_dpy ); + root = RootWindow( x_dpy, scrnum ); + + if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) { + printf("Error: couldn't get an EGL visual config\n"); + exit(1); + } + + assert(config); + assert(num_configs > 0); + + if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) { + printf("Error: eglGetConfigAttrib() failed\n"); + exit(1); + } + + /* The X window visual must match the EGL config */ + visTemplate.visualid = vid; + visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals); + if (!visInfo) { + printf("Error: couldn't get X visual\n"); + exit(1); + } + + /* window attributes */ + attr.background_pixel = 0; + attr.border_pixel = 0; + attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone); + attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; + mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; + + win = XCreateWindow( x_dpy, root, 0, 0, width, height, + 0, visInfo->depth, InputOutput, + visInfo->visual, mask, &attr ); + + /* set hints and properties */ + { + XSizeHints sizehints; + sizehints.x = x; + sizehints.y = y; + sizehints.width = width; + sizehints.height = height; + sizehints.flags = USSize | USPosition; + XSetNormalHints(x_dpy, win, &sizehints); + XSetStandardProperties(x_dpy, win, name, name, + None, (char **)NULL, 0, &sizehints); + } + + eglBindAPI(EGL_OPENGL_ES_API); + + ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL ); + if (!ctx) { + printf("Error: eglCreateContext failed\n"); + exit(1); + } + + *surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL); + + if (!*surfRet) { + printf("Error: eglCreateWindowSurface failed\n"); + exit(1); + } + + XFree(visInfo); + + *winRet = win; + *ctxRet = ctx; +} + + +static void +usage(void) +{ + printf("Usage:\n"); + printf(" -display set the display to run on\n"); +} + + +int +main(int argc, char *argv[]) +{ + const int winWidth = 400, winHeight = 300; + Display *x_dpy; + Window win; + EGLSurface egl_surf; + EGLContext egl_ctx; + EGLDisplay egl_dpy; + char *dpyName = NULL; + EGLint egl_major, egl_minor; + int i; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-display") == 0) { + dpyName = argv[i+1]; + i++; + } + else { + usage(); + return -1; + } + } + + x_dpy = XOpenDisplay(dpyName); + if (!x_dpy) { + printf("Error: couldn't open display %s\n", + dpyName ? dpyName : getenv("DISPLAY")); + return -1; + } + + egl_dpy = eglGetDisplay(x_dpy); + if (!egl_dpy) { + printf("Error: eglGetDisplay() failed\n"); + return -1; + } + + if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) { + printf("Error: eglInitialize() failed\n"); + return -1; + } + + make_x_window(x_dpy, egl_dpy, + "ES info", 0, 0, winWidth, winHeight, + &win, &egl_ctx, &egl_surf); + + /*XMapWindow(x_dpy, win);*/ + if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) { + printf("Error: eglMakeCurrent() failed\n"); + return -1; + } + + info(egl_dpy); + + eglDestroyContext(egl_dpy, egl_ctx); + eglDestroySurface(egl_dpy, egl_surf); + eglTerminate(egl_dpy); + + + XDestroyWindow(x_dpy, win); + XCloseDisplay(x_dpy); + + return 0; +} diff --git a/progs/es1/xegl/msaa.c b/progs/es1/xegl/msaa.c new file mode 100644 index 0000000000..b4c6c63217 --- /dev/null +++ b/progs/es1/xegl/msaa.c @@ -0,0 +1,442 @@ +/* + * Copyright (C) 2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL 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. + */ + +/* + * Test MSAA with X/EGL and OpenGL ES 1.x + * Brian Paul + * 15 September 2008 + */ + +#define USE_FULL_GL 0 + + +#include +#include +#include +#include +#include +#include +#include +#include +#if USE_FULL_GL +#include /* use full OpenGL */ +#else +#include /* use OpenGL ES 1.x */ +#include +#endif +#include + + + +static GLfloat view_rotx = 0.0, view_roty = 0.0, view_rotz = 0.0; +static GLboolean AA = 0*GL_TRUE; + + +static void +draw(void) +{ + float a; + + static const GLfloat verts[4][2] = { + { -1, -.1 }, + { 1, -.1 }, + { -1, .1 }, + { 1, .1 } + }; + static const GLfloat colors[4][4] = { + { 1, 0, 0, 1 }, + { 0, 1, 0, 1 }, + { 0, 0, 1, 1 }, + { 1, 0, 1, 1 } + }; + + if (AA) { + printf("MSAA enabled\n"); + glEnable(GL_MULTISAMPLE); + } + else { + printf("MSAA disabled\n"); + glDisable(GL_MULTISAMPLE); + } + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + glRotatef(view_rotx, 1, 0, 0); + glRotatef(view_roty, 0, 1, 0); + glRotatef(view_rotz, 0, 0, 1); + + { + glVertexPointer(2, GL_FLOAT, 0, verts); + glColorPointer(4, GL_FLOAT, 0, colors); + + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + + for (a = 0; a < 360; a += 20.0) { + glPushMatrix(); + + glRotatef(a, 0, 0, 1); + glTranslatef(1.5, 0, 0); + + /* draw triangle */ + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + glPopMatrix(); + } + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + } + + glPopMatrix(); +} + + +/* new window size or exposure */ +static void +reshape(int width, int height) +{ + GLfloat ary = 3.0; + GLfloat arx = ary * (GLfloat) width / (GLfloat) height; + + glViewport(0, 0, (GLint) width, (GLint) height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); +#ifdef GL_VERSION_ES_CM_1_0 + glOrthof(-arx, arx, -ary, ary, -1.0, 1.0); +#else + glOrtho(-arx, arx, -ary, ary, -1.0, 1.0); +#endif + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + + + +static void +init(void) +{ + printf("Press 'a' to toggle multisample antialiasing\n"); + printf("Press 'Esc' to exit\n"); +} + + +/* + * Create an RGB, double-buffered X window. + * Return the window and context handles. + */ +static void +make_x_window(Display *x_dpy, EGLDisplay egl_dpy, + const char *name, + int x, int y, int width, int height, + Window *winRet, + EGLContext *ctxRet, + EGLSurface *surfRet) +{ + static const EGLint attribs[] = { + EGL_RED_SIZE, 1, + EGL_GREEN_SIZE, 1, + EGL_BLUE_SIZE, 1, + EGL_DEPTH_SIZE, 1, + EGL_SAMPLES, 1, + EGL_SAMPLE_BUFFERS, 1, + EGL_NONE + }; + + int scrnum; + XSetWindowAttributes attr; + unsigned long mask; + Window root; + Window win; + XVisualInfo *visInfo, visTemplate; + int num_visuals; + EGLContext ctx; + EGLConfig config; + EGLint num_configs; + EGLint vid; + + scrnum = DefaultScreen( x_dpy ); + root = RootWindow( x_dpy, scrnum ); + + if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) { + printf("Error: couldn't get an EGL visual config\n"); + exit(1); + } + + if (num_configs < 1) { + printf("Error: Unable to find multisample pixel format.\n"); + printf("Try running glxinfo to see if your server supports MSAA.\n"); + exit(1); + } + + if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) { + printf("Error: eglGetConfigAttrib() failed\n"); + exit(1); + } + + /* The X window visual must match the EGL config */ + visTemplate.visualid = vid; + visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals); + if (!visInfo) { + printf("Error: couldn't get X visual\n"); + exit(1); + } + + /* window attributes */ + attr.background_pixel = 0; + attr.border_pixel = 0; + attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone); + attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; + mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; + + win = XCreateWindow( x_dpy, root, 0, 0, width, height, + 0, visInfo->depth, InputOutput, + visInfo->visual, mask, &attr ); + + /* set hints and properties */ + { + XSizeHints sizehints; + sizehints.x = x; + sizehints.y = y; + sizehints.width = width; + sizehints.height = height; + sizehints.flags = USSize | USPosition; + XSetNormalHints(x_dpy, win, &sizehints); + XSetStandardProperties(x_dpy, win, name, name, + None, (char **)NULL, 0, &sizehints); + } + +#if USE_FULL_GL + eglBindAPI(EGL_OPENGL_API); +#else + eglBindAPI(EGL_OPENGL_ES_API); +#endif + + ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL ); + if (!ctx) { + printf("Error: eglCreateContext failed\n"); + exit(1); + } + + *surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL); + + if (!*surfRet) { + printf("Error: eglCreateWindowSurface failed\n"); + exit(1); + } + + XFree(visInfo); + + *winRet = win; + *ctxRet = ctx; +} + + +static void +event_loop(Display *dpy, Window win, + EGLDisplay egl_dpy, EGLSurface egl_surf) +{ + while (1) { + int redraw = 0; + XEvent event; + + XNextEvent(dpy, &event); + + switch (event.type) { + case Expose: + redraw = 1; + break; + case ConfigureNotify: + reshape(event.xconfigure.width, event.xconfigure.height); + break; + case KeyPress: + { + char buffer[10]; + int r, code; + code = XLookupKeysym(&event.xkey, 0); + if (code == XK_Left) { + view_roty += 5.0; + } + else if (code == XK_Right) { + view_roty -= 5.0; + } + else if (code == XK_Up) { + view_rotx += 5.0; + } + else if (code == XK_Down) { + view_rotx -= 5.0; + } + else { + r = XLookupString(&event.xkey, buffer, sizeof(buffer), + NULL, NULL); + if (buffer[0] == 'a') { + AA = !AA; + redraw = 1; + } + else if (buffer[0] == 27) { + /* escape */ + return; + } + } + } + redraw = 1; + break; + default: + ; /*no-op*/ + } + + if (redraw) { + draw(); + eglSwapBuffers(egl_dpy, egl_surf); + } + } +} + + +static void +usage(void) +{ + printf("Usage:\n"); + printf(" -display set the display to run on\n"); + printf(" -info display OpenGL renderer info\n"); +} + + +int +main(int argc, char *argv[]) +{ + const int winWidth = 600, winHeight = 600; + Display *x_dpy; + Window win; + EGLSurface egl_surf; + EGLContext egl_ctx; + EGLDisplay egl_dpy; + char *dpyName = NULL; + GLboolean printInfo = GL_FALSE; + EGLint egl_major, egl_minor; + int i; + const char *s; + + static struct { + char *name; + GLenum value; + enum {GetString, GetInteger} type; + } info_items[] = { + {"GL_RENDERER", GL_RENDERER, GetString}, + {"GL_VERSION", GL_VERSION, GetString}, + {"GL_VENDOR", GL_VENDOR, GetString}, + {"GL_EXTENSIONS", GL_EXTENSIONS, GetString}, + {"GL_MAX_PALETTE_MATRICES_OES", GL_MAX_PALETTE_MATRICES_OES, GetInteger}, + {"GL_MAX_VERTEX_UNITS_OES", GL_MAX_VERTEX_UNITS_OES, GetInteger}, + }; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-display") == 0) { + dpyName = argv[i+1]; + i++; + } + else if (strcmp(argv[i], "-info") == 0) { + printInfo = GL_TRUE; + } + else { + usage(); + return -1; + } + } + + x_dpy = XOpenDisplay(dpyName); + if (!x_dpy) { + printf("Error: couldn't open display %s\n", + dpyName ? dpyName : getenv("DISPLAY")); + return -1; + } + + egl_dpy = eglGetDisplay(x_dpy); + if (!egl_dpy) { + printf("Error: eglGetDisplay() failed\n"); + return -1; + } + + if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) { + printf("Error: eglInitialize() failed\n"); + return -1; + } + + s = eglQueryString(egl_dpy, EGL_VERSION); + printf("EGL_VERSION = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_VENDOR); + printf("EGL_VENDOR = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_EXTENSIONS); + printf("EGL_EXTENSIONS = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_CLIENT_APIS); + printf("EGL_CLIENT_APIS = %s\n", s); + + make_x_window(x_dpy, egl_dpy, + "msaa", 0, 0, winWidth, winHeight, + &win, &egl_ctx, &egl_surf); + + XMapWindow(x_dpy, win); + if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) { + printf("Error: eglMakeCurrent() failed\n"); + return -1; + } + + if (printInfo) { + for (i = 0; i < sizeof(info_items)/sizeof(info_items[0]); i++) { + switch (info_items[i].type) { + case GetString: + printf("%s = %s\n", info_items[i].name, (char *)glGetString(info_items[i].value)); + break; + case GetInteger: { + GLint rv = -1; + glGetIntegerv(info_items[i].value, &rv); + printf("%s = %d\n", info_items[i].name, rv); + break; + } + } + } + }; + init(); + + /* Set initial projection/viewing transformation. + * We can't be sure we'll get a ConfigureNotify event when the window + * first appears. + */ + reshape(winWidth, winHeight); + + event_loop(x_dpy, win, egl_dpy, egl_surf); + + eglDestroyContext(egl_dpy, egl_ctx); + eglDestroySurface(egl_dpy, egl_surf); + eglTerminate(egl_dpy); + + + XDestroyWindow(x_dpy, win); + XCloseDisplay(x_dpy); + + return 0; +} diff --git a/progs/es1/xegl/pbuffer.c b/progs/es1/xegl/pbuffer.c new file mode 100644 index 0000000000..011c2af58f --- /dev/null +++ b/progs/es1/xegl/pbuffer.c @@ -0,0 +1,607 @@ +/* + * Copyright (C) 2008 Tunsgten Graphics,Inc. All Rights Reserved. + */ + +/* + * Test EGL Pbuffers + * Brian Paul + * August 2008 + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +static int WinWidth = 300, WinHeight = 300; + +static GLfloat view_rotx = 0.0, view_roty = 0.0, view_rotz = 0.0; + + +static void +Normal(GLfloat *n, GLfloat nx, GLfloat ny, GLfloat nz) +{ + n[0] = nx; + n[1] = ny; + n[2] = nz; +} + +static void +Vertex(GLfloat *v, GLfloat vx, GLfloat vy, GLfloat vz) +{ + v[0] = vx; + v[1] = vy; + v[2] = vz; +} + +static void +Texcoord(GLfloat *v, GLfloat s, GLfloat t) +{ + v[0] = s; + v[1] = t; +} + + +/* Borrowed from glut, adapted */ +static void +draw_torus(GLfloat r, GLfloat R, GLint nsides, GLint rings) +{ + int i, j; + GLfloat theta, phi, theta1; + GLfloat cosTheta, sinTheta; + GLfloat cosTheta1, sinTheta1; + GLfloat ringDelta, sideDelta; + GLfloat varray[100][3], narray[100][3], tarray[100][2]; + int vcount; + + glVertexPointer(3, GL_FLOAT, 0, varray); + glNormalPointer(GL_FLOAT, 0, narray); + glTexCoordPointer(2, GL_FLOAT, 0, tarray); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_NORMAL_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + ringDelta = 2.0 * M_PI / rings; + sideDelta = 2.0 * M_PI / nsides; + + theta = 0.0; + cosTheta = 1.0; + sinTheta = 0.0; + for (i = rings - 1; i >= 0; i--) { + theta1 = theta + ringDelta; + cosTheta1 = cos(theta1); + sinTheta1 = sin(theta1); + + vcount = 0; /* glBegin(GL_QUAD_STRIP); */ + + phi = 0.0; + for (j = nsides; j >= 0; j--) { + GLfloat s0, s1, t; + GLfloat cosPhi, sinPhi, dist; + + phi += sideDelta; + cosPhi = cos(phi); + sinPhi = sin(phi); + dist = R + r * cosPhi; + + s0 = 20.0 * theta / (2.0 * M_PI); + s1 = 20.0 * theta1 / (2.0 * M_PI); + t = 8.0 * phi / (2.0 * M_PI); + + Normal(narray[vcount], cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi); + Texcoord(tarray[vcount], s1, t); + Vertex(varray[vcount], cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi); + vcount++; + + Normal(narray[vcount], cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi); + Texcoord(tarray[vcount], s0, t); + Vertex(varray[vcount], cosTheta * dist, -sinTheta * dist, r * sinPhi); + vcount++; + } + + /*glEnd();*/ + assert(vcount <= 100); + glDrawArrays(GL_TRIANGLE_STRIP, 0, vcount); + + theta = theta1; + cosTheta = cosTheta1; + sinTheta = sinTheta1; + } + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_NORMAL_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); +} + + +static void +draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + glRotatef(view_rotx, 1, 0, 0); + glRotatef(view_roty, 0, 1, 0); + glRotatef(view_rotz, 0, 0, 1); + glScalef(0.5, 0.5, 0.5); + + draw_torus(1.0, 3.0, 30, 60); + + glPopMatrix(); + + glFinish(); +} + + +/** + * Draw to both the window and pbuffer and compare results. + */ +static void +draw_both(EGLDisplay egl_dpy, EGLSurface egl_surf, EGLSurface egl_pbuf, + EGLContext egl_ctx) +{ + unsigned *wbuf, *pbuf; + int x = 100, y = 110; + int i, dif; + + wbuf = (unsigned *) malloc(WinWidth * WinHeight * 4); + pbuf = (unsigned *) malloc(WinWidth * WinHeight * 4); + + glPixelStorei(GL_PACK_ALIGNMENT, 1); + + /* first draw to window */ + if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) { + printf("Error: eglMakeCurrent(window) failed\n"); + return; + } + draw(); + glReadPixels(0, 0, WinWidth, WinHeight, GL_RGBA, GL_UNSIGNED_BYTE, wbuf); + printf("Window[%d,%d] = 0x%08x\n", x, y, wbuf[y*WinWidth+x]); + + /* then draw to pbuffer */ + if (!eglMakeCurrent(egl_dpy, egl_pbuf, egl_pbuf, egl_ctx)) { + printf("Error: eglMakeCurrent(pbuffer) failed\n"); + return; + } + draw(); + glReadPixels(0, 0, WinWidth, WinHeight, GL_RGBA, GL_UNSIGNED_BYTE, pbuf); + printf("Pbuffer[%d,%d] = 0x%08x\n", x, y, pbuf[y*WinWidth+x]); + + eglSwapBuffers(egl_dpy, egl_surf); + + /* compare renderings */ + for (dif = i = 0; i < WinWidth * WinHeight; i++) { + if (wbuf[i] != pbuf[i]) { + dif = 1; + break; + } + } + + if (dif) + printf("Difference at %d: 0x%08x vs. 0x%08x\n", i, wbuf[i], pbuf[i]); + else + printf("Window rendering matches Pbuffer rendering!\n"); + + free(wbuf); + free(pbuf); +} + + +/* new window size or exposure */ +static void +reshape(int width, int height) +{ + GLfloat ar = (GLfloat) width / (GLfloat) height; + + WinWidth = width; + WinHeight = height; + + glViewport(0, 0, (GLint) width, (GLint) height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + +#ifdef GL_VERSION_ES_CM_1_0 + glFrustumf(-ar, ar, -1, 1, 5.0, 60.0); +#else + glFrustum(-ar, ar, -1, 1, 5.0, 60.0); +#endif + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -15.0); +} + + +static void +make_texture(void) +{ +#define SZ 64 + GLenum Filter = GL_LINEAR; + GLubyte image[SZ][SZ][4]; + GLuint i, j; + + for (i = 0; i < SZ; i++) { + for (j = 0; j < SZ; j++) { + GLfloat d = (i - SZ/2) * (i - SZ/2) + (j - SZ/2) * (j - SZ/2); + d = sqrt(d); + if (d < SZ/3) { + image[i][j][0] = 255; + image[i][j][1] = 255; + image[i][j][2] = 255; + image[i][j][3] = 255; + } + else { + image[i][j][0] = 127; + image[i][j][1] = 127; + image[i][j][2] = 127; + image[i][j][3] = 255; + } + } + } + + glActiveTexture(GL_TEXTURE0); /* unit 0 */ + glBindTexture(GL_TEXTURE_2D, 42); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SZ, SZ, 0, + GL_RGBA, GL_UNSIGNED_BYTE, image); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, Filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, Filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); +#undef SZ +} + + + +static void +init(void) +{ + static const GLfloat red[4] = {1, 0, 0, 0}; + static const GLfloat white[4] = {1.0, 1.0, 1.0, 1.0}; + static const GLfloat diffuse[4] = {0.7, 0.7, 0.7, 1.0}; + static const GLfloat specular[4] = {0.001, 0.001, 0.001, 1.0}; + static const GLfloat pos[4] = {20, 20, 50, 1}; + + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, red); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white); + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 9.0); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glLightfv(GL_LIGHT0, GL_POSITION, pos); + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); + glLightfv(GL_LIGHT0, GL_SPECULAR, specular); + + glClearColor(0.4, 0.4, 0.4, 0.0); + glEnable(GL_DEPTH_TEST); + + make_texture(); + glEnable(GL_TEXTURE_2D); +} + + +/* + * Create an RGB, double-buffered X window. + * Return the window and context handles. + */ +static void +make_x_window(Display *x_dpy, EGLDisplay egl_dpy, + const char *name, + int x, int y, int width, int height, + Window *winRet, + EGLContext *ctxRet, + EGLSurface *surfRet) +{ + static const EGLint attribs[] = { + EGL_RED_SIZE, 1, + EGL_GREEN_SIZE, 1, + EGL_BLUE_SIZE, 1, + EGL_DEPTH_SIZE, 1, + EGL_NONE + }; + + int scrnum; + XSetWindowAttributes attr; + unsigned long mask; + Window root; + Window win; + XVisualInfo *visInfo, visTemplate; + int num_visuals; + EGLContext ctx; + EGLConfig config; + EGLint num_configs; + EGLint vid; + + scrnum = DefaultScreen( x_dpy ); + root = RootWindow( x_dpy, scrnum ); + + if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) { + printf("Error: couldn't get an EGL visual config\n"); + exit(1); + } + + assert(config); + assert(num_configs > 0); + + if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) { + printf("Error: eglGetConfigAttrib() failed\n"); + exit(1); + } + + /* The X window visual must match the EGL config */ + visTemplate.visualid = vid; + visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals); + if (!visInfo) { + printf("Error: couldn't get X visual\n"); + exit(1); + } + + /* window attributes */ + attr.background_pixel = 0; + attr.border_pixel = 0; + attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone); + attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; + mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; + + win = XCreateWindow( x_dpy, root, 0, 0, width, height, + 0, visInfo->depth, InputOutput, + visInfo->visual, mask, &attr ); + + /* set hints and properties */ + { + XSizeHints sizehints; + sizehints.x = x; + sizehints.y = y; + sizehints.width = width; + sizehints.height = height; + sizehints.flags = USSize | USPosition; + XSetNormalHints(x_dpy, win, &sizehints); + XSetStandardProperties(x_dpy, win, name, name, + None, (char **)NULL, 0, &sizehints); + } + + eglBindAPI(EGL_OPENGL_ES_API); + + ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL ); + if (!ctx) { + printf("Error: eglCreateContext failed\n"); + exit(1); + } + + *surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL); + + if (!*surfRet) { + printf("Error: eglCreateWindowSurface failed\n"); + exit(1); + } + + XFree(visInfo); + + *winRet = win; + *ctxRet = ctx; +} + + +static EGLSurface +make_pbuffer(Display *x_dpy, EGLDisplay egl_dpy, int width, int height) +{ + static const EGLint config_attribs[] = { + EGL_RED_SIZE, 1, + EGL_GREEN_SIZE, 1, + EGL_BLUE_SIZE, 1, + EGL_DEPTH_SIZE, 1, + EGL_NONE + }; + EGLConfig config; + EGLSurface pbuf; + EGLint num_configs; + EGLint pbuf_attribs[5]; + + pbuf_attribs[0] = EGL_WIDTH; + pbuf_attribs[1] = width; + pbuf_attribs[2] = EGL_HEIGHT; + pbuf_attribs[3] = height; + pbuf_attribs[4] = EGL_NONE; + + if (!eglChooseConfig( egl_dpy, config_attribs, &config, 1, &num_configs)) { + printf("Error: couldn't get an EGL config for pbuffer\n"); + exit(1); + } + + pbuf = eglCreatePbufferSurface(egl_dpy, config, pbuf_attribs); + + return pbuf; +} + + +static void +event_loop(Display *dpy, Window win, + EGLDisplay egl_dpy, EGLSurface egl_surf, EGLSurface egl_pbuf, + EGLContext egl_ctx) +{ + int anim = 0; + + while (1) { + int redraw = 0; + + if (!anim || XPending(dpy)) { + XEvent event; + XNextEvent(dpy, &event); + + switch (event.type) { + case Expose: + redraw = 1; + break; + case ConfigureNotify: + if (event.xconfigure.window == win) + reshape(event.xconfigure.width, event.xconfigure.height); + break; + case KeyPress: + { + char buffer[10]; + int r, code; + code = XLookupKeysym(&event.xkey, 0); + if (code == XK_Left) { + view_roty += 5.0; + } + else if (code == XK_Right) { + view_roty -= 5.0; + } + else if (code == XK_Up) { + view_rotx += 5.0; + } + else if (code == XK_Down) { + view_rotx -= 5.0; + } + else { + r = XLookupString(&event.xkey, buffer, sizeof(buffer), + NULL, NULL); + if (buffer[0] == ' ') { + anim = !anim; + } + else if (buffer[0] == 27) { + /* escape */ + return; + } + } + } + redraw = 1; + break; + default: + ; /*no-op*/ + } + } + + if (anim) { + view_rotx += 1.0; + view_roty += 2.0; + redraw = 1; + } + + if (redraw) { + draw_both(egl_dpy, egl_surf, egl_pbuf, egl_ctx); + } + } +} + + +static void +usage(void) +{ + printf("Usage:\n"); + printf(" -display set the display to run on\n"); + printf(" -info display OpenGL renderer info\n"); +} + + +int +main(int argc, char *argv[]) +{ + Display *x_dpy; + Window win; + EGLSurface egl_surf, egl_pbuf; + EGLContext egl_ctx; + EGLDisplay egl_dpy; + char *dpyName = NULL; + GLboolean printInfo = GL_FALSE; + EGLint egl_major, egl_minor; + int i; + const char *s; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-display") == 0) { + dpyName = argv[i+1]; + i++; + } + else if (strcmp(argv[i], "-info") == 0) { + printInfo = GL_TRUE; + } + else { + usage(); + return -1; + } + } + + x_dpy = XOpenDisplay(dpyName); + if (!x_dpy) { + printf("Error: couldn't open display %s\n", + dpyName ? dpyName : getenv("DISPLAY")); + return -1; + } + + egl_dpy = eglGetDisplay(x_dpy); + if (!egl_dpy) { + printf("Error: eglGetDisplay() failed\n"); + return -1; + } + + if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) { + printf("Error: eglInitialize() failed\n"); + return -1; + } + + s = eglQueryString(egl_dpy, EGL_VERSION); + printf("EGL_VERSION = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_VENDOR); + printf("EGL_VENDOR = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_EXTENSIONS); + printf("EGL_EXTENSIONS = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_CLIENT_APIS); + printf("EGL_CLIENT_APIS = %s\n", s); + + make_x_window(x_dpy, egl_dpy, + "pbuffer", 0, 0, WinWidth, WinHeight, + &win, &egl_ctx, &egl_surf); + + egl_pbuf = make_pbuffer(x_dpy, egl_dpy, WinWidth, WinHeight); + if (!egl_pbuf) { + printf("Error: eglCreatePBufferSurface() failed\n"); + return -1; + } + + XMapWindow(x_dpy, win); + if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) { + printf("Error: eglMakeCurrent() failed\n"); + return -1; + } + + if (printInfo) { + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS)); + } + + init(); + + /* Set initial projection/viewing transformation. + * We can't be sure we'll get a ConfigureNotify event when the window + * first appears. + */ + reshape(WinWidth, WinHeight); + + event_loop(x_dpy, win, egl_dpy, egl_surf, egl_pbuf, egl_ctx); + + eglDestroyContext(egl_dpy, egl_ctx); + eglDestroySurface(egl_dpy, egl_surf); + eglTerminate(egl_dpy); + + + XDestroyWindow(x_dpy, win); + XCloseDisplay(x_dpy); + + return 0; +} diff --git a/progs/es1/xegl/render_tex.c b/progs/es1/xegl/render_tex.c new file mode 100644 index 0000000000..0d1027b712 --- /dev/null +++ b/progs/es1/xegl/render_tex.c @@ -0,0 +1,657 @@ +/* + * Copyright (C) 2008 Tunsgten Graphics,Inc. All Rights Reserved. + */ + +/* + * Test EGL render to texture. + * Brian Paul + * August 2008 + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +static int TexWidth = 256, TexHeight = 256; + +static int WinWidth = 300, WinHeight = 300; + +static GLfloat view_rotx = 0.0, view_roty = 0.0, view_rotz = 0.0; + +static GLuint DotTexture, RenderTexture; + + +static void +Normal(GLfloat *n, GLfloat nx, GLfloat ny, GLfloat nz) +{ + n[0] = nx; + n[1] = ny; + n[2] = nz; +} + +static void +Vertex(GLfloat *v, GLfloat vx, GLfloat vy, GLfloat vz) +{ + v[0] = vx; + v[1] = vy; + v[2] = vz; +} + +static void +Texcoord(GLfloat *v, GLfloat s, GLfloat t) +{ + v[0] = s; + v[1] = t; +} + + +/* Borrowed from glut, adapted */ +static void +draw_torus(GLfloat r, GLfloat R, GLint nsides, GLint rings) +{ + int i, j; + GLfloat theta, phi, theta1; + GLfloat cosTheta, sinTheta; + GLfloat cosTheta1, sinTheta1; + GLfloat ringDelta, sideDelta; + GLfloat varray[100][3], narray[100][3], tarray[100][2]; + int vcount; + + glVertexPointer(3, GL_FLOAT, 0, varray); + glNormalPointer(GL_FLOAT, 0, narray); + glTexCoordPointer(2, GL_FLOAT, 0, tarray); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_NORMAL_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + ringDelta = 2.0 * M_PI / rings; + sideDelta = 2.0 * M_PI / nsides; + + theta = 0.0; + cosTheta = 1.0; + sinTheta = 0.0; + for (i = rings - 1; i >= 0; i--) { + theta1 = theta + ringDelta; + cosTheta1 = cos(theta1); + sinTheta1 = sin(theta1); + + vcount = 0; /* glBegin(GL_QUAD_STRIP); */ + + phi = 0.0; + for (j = nsides; j >= 0; j--) { + GLfloat s0, s1, t; + GLfloat cosPhi, sinPhi, dist; + + phi += sideDelta; + cosPhi = cos(phi); + sinPhi = sin(phi); + dist = R + r * cosPhi; + + s0 = 20.0 * theta / (2.0 * M_PI); + s1 = 20.0 * theta1 / (2.0 * M_PI); + t = 8.0 * phi / (2.0 * M_PI); + + Normal(narray[vcount], cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi); + Texcoord(tarray[vcount], s1, t); + Vertex(varray[vcount], cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi); + vcount++; + + Normal(narray[vcount], cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi); + Texcoord(tarray[vcount], s0, t); + Vertex(varray[vcount], cosTheta * dist, -sinTheta * dist, r * sinPhi); + vcount++; + } + + /*glEnd();*/ + assert(vcount <= 100); + glDrawArrays(GL_TRIANGLE_STRIP, 0, vcount); + + theta = theta1; + cosTheta = cosTheta1; + sinTheta = sinTheta1; + } + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_NORMAL_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); +} + + +static void +draw_torus_to_texture(void) +{ + glViewport(0, 0, TexWidth, TexHeight); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustumf(-1, 1, -1, 1, 5.0, 60.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -15.0); + + glClearColor(0.4, 0.4, 0.4, 0.0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glBindTexture(GL_TEXTURE_2D, DotTexture); + + glEnable(GL_LIGHTING); + + glPushMatrix(); + glRotatef(view_roty, 0, 1, 0); + glScalef(0.5, 0.5, 0.5); + + draw_torus(1.0, 3.0, 30, 60); + + glPopMatrix(); + + glDisable(GL_LIGHTING); + +#if 0 + glBindTexture(GL_TEXTURE_2D, RenderTexture); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, TexWidth, TexHeight); +#endif + + glFinish(); +} + + +static void +draw_textured_quad(void) +{ + GLfloat ar = (GLfloat) WinWidth / (GLfloat) WinHeight; + + glViewport(0, 0, WinWidth, WinHeight); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustumf(-ar, ar, -1, 1, 5.0, 60.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -8.0); + + glClearColor(0.4, 0.4, 1.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glBindTexture(GL_TEXTURE_2D, RenderTexture); + + glPushMatrix(); + glRotatef(view_rotx, 1, 0, 0); + glRotatef(view_rotz, 0, 0, 1); + + { + static const GLfloat texcoord[4][2] = { + { 0, 0 }, { 1, 0 }, { 0, 1 }, { 1, 1 } + }; + static const GLfloat vertex[4][2] = { + { -1, -1 }, { 1, -1 }, { -1, 1 }, { 1, 1 } + }; + + glVertexPointer(2, GL_FLOAT, 0, vertex); + glTexCoordPointer(2, GL_FLOAT, 0, texcoord); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } + + glPopMatrix(); +} + + + +static void +draw(EGLDisplay egl_dpy, EGLSurface egl_surf, EGLSurface egl_pbuf, + EGLContext egl_ctx) +{ + /*printf("Begin draw\n");*/ + + /* first draw torus to pbuffer /texture */ +#if 01 + if (!eglMakeCurrent(egl_dpy, egl_pbuf, egl_pbuf, egl_ctx)) { +#else + if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) { +#endif + printf("Error: eglMakeCurrent(pbuf) failed\n"); + return; + } + glBindTexture(GL_TEXTURE_2D, RenderTexture); + eglBindTexImage(egl_dpy, egl_pbuf, EGL_BACK_BUFFER); + draw_torus_to_texture(); + eglReleaseTexImage(egl_dpy, egl_pbuf, EGL_BACK_BUFFER); + + /* draw textured quad to window */ + if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) { + printf("Error: eglMakeCurrent(pbuffer) failed\n"); + return; + } + draw_textured_quad(); + eglSwapBuffers(egl_dpy, egl_surf); + + /*printf("End draw\n");*/ +} + + + +static void +make_dot_texture(void) +{ +#define SZ 64 + GLenum Filter = GL_LINEAR; + GLubyte image[SZ][SZ][4]; + GLuint i, j; + + for (i = 0; i < SZ; i++) { + for (j = 0; j < SZ; j++) { + GLfloat d = (i - SZ/2) * (i - SZ/2) + (j - SZ/2) * (j - SZ/2); + d = sqrt(d); + if (d < SZ/3) { + image[i][j][0] = 255; + image[i][j][1] = 255; + image[i][j][2] = 255; + image[i][j][3] = 255; + } + else { + image[i][j][0] = 127; + image[i][j][1] = 127; + image[i][j][2] = 127; + image[i][j][3] = 255; + } + } + } + + glGenTextures(1, &DotTexture); + glBindTexture(GL_TEXTURE_2D, DotTexture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SZ, SZ, 0, + GL_RGBA, GL_UNSIGNED_BYTE, image); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, Filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, Filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); +#undef SZ +} + + +static void +make_render_texture(void) +{ + GLenum Filter = GL_LINEAR; + glGenTextures(1, &RenderTexture); + glBindTexture(GL_TEXTURE_2D, RenderTexture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TexWidth, TexHeight, 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, Filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, Filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); +} + + +static void +init(void) +{ + static const GLfloat red[4] = {1, 0, 0, 0}; + static const GLfloat white[4] = {1.0, 1.0, 1.0, 1.0}; + static const GLfloat diffuse[4] = {0.7, 0.7, 0.7, 1.0}; + static const GLfloat specular[4] = {0.001, 0.001, 0.001, 1.0}; + static const GLfloat pos[4] = {20, 20, 50, 1}; + + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, red); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white); + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 9.0); + + glEnable(GL_LIGHT0); + glLightfv(GL_LIGHT0, GL_POSITION, pos); + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); + glLightfv(GL_LIGHT0, GL_SPECULAR, specular); + + glEnable(GL_DEPTH_TEST); + + make_dot_texture(); + make_render_texture(); + + printf("DotTexture=%u RenderTexture=%u\n", DotTexture, RenderTexture); + + glEnable(GL_TEXTURE_2D); +} + + +/* + * Create an RGB, double-buffered X window. + * Return the window and context handles. + */ +static void +make_x_window(Display *x_dpy, EGLDisplay egl_dpy, + const char *name, + int x, int y, int width, int height, + Window *winRet, + EGLContext *ctxRet, + EGLSurface *surfRet) +{ + static const EGLint attribs[] = { + EGL_RED_SIZE, 1, + EGL_GREEN_SIZE, 1, + EGL_BLUE_SIZE, 1, + EGL_DEPTH_SIZE, 1, + EGL_NONE + }; + + int scrnum; + XSetWindowAttributes attr; + unsigned long mask; + Window root; + Window win; + XVisualInfo *visInfo, visTemplate; + int num_visuals; + EGLContext ctx; + EGLConfig config; + EGLint num_configs; + EGLint vid; + + scrnum = DefaultScreen( x_dpy ); + root = RootWindow( x_dpy, scrnum ); + + if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) { + printf("Error: couldn't get an EGL visual config\n"); + exit(1); + } + + assert(config); + assert(num_configs > 0); + + if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) { + printf("Error: eglGetConfigAttrib() failed\n"); + exit(1); + } + + /* The X window visual must match the EGL config */ + visTemplate.visualid = vid; + visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals); + if (!visInfo) { + printf("Error: couldn't get X visual\n"); + exit(1); + } + + /* window attributes */ + attr.background_pixel = 0; + attr.border_pixel = 0; + attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone); + attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; + mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; + + win = XCreateWindow( x_dpy, root, 0, 0, width, height, + 0, visInfo->depth, InputOutput, + visInfo->visual, mask, &attr ); + + /* set hints and properties */ + { + XSizeHints sizehints; + sizehints.x = x; + sizehints.y = y; + sizehints.width = width; + sizehints.height = height; + sizehints.flags = USSize | USPosition; + XSetNormalHints(x_dpy, win, &sizehints); + XSetStandardProperties(x_dpy, win, name, name, + None, (char **)NULL, 0, &sizehints); + } + + eglBindAPI(EGL_OPENGL_ES_API); + + ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL ); + if (!ctx) { + printf("Error: eglCreateContext failed\n"); + exit(1); + } + + *surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL); + + if (!*surfRet) { + printf("Error: eglCreateWindowSurface failed\n"); + exit(1); + } + + XFree(visInfo); + + *winRet = win; + *ctxRet = ctx; +} + + +static EGLSurface +make_pbuffer(Display *x_dpy, EGLDisplay egl_dpy, int width, int height) +{ + static const EGLint config_attribs[] = { + EGL_RED_SIZE, 1, + EGL_GREEN_SIZE, 1, + EGL_BLUE_SIZE, 1, + EGL_DEPTH_SIZE, 1, + EGL_NONE + }; + EGLConfig config; + EGLSurface pbuf; + EGLint num_configs; + EGLint pbuf_attribs[15]; + int i = 0; + + pbuf_attribs[i++] = EGL_WIDTH; + pbuf_attribs[i++] = width; + pbuf_attribs[i++] = EGL_HEIGHT; + pbuf_attribs[i++] = height; + pbuf_attribs[i++] = EGL_TEXTURE_FORMAT; + pbuf_attribs[i++] = EGL_TEXTURE_RGBA; + pbuf_attribs[i++] = EGL_TEXTURE_TARGET; + pbuf_attribs[i++] = EGL_TEXTURE_2D; + pbuf_attribs[i++] = EGL_MIPMAP_TEXTURE; + pbuf_attribs[i++] = EGL_FALSE; + pbuf_attribs[i++] = EGL_NONE; + assert(i <= 15); + + if (!eglChooseConfig( egl_dpy, config_attribs, &config, 1, &num_configs)) { + printf("Error: couldn't get an EGL config for pbuffer\n"); + exit(1); + } + + pbuf = eglCreatePbufferSurface(egl_dpy, config, pbuf_attribs); + + return pbuf; +} + + +static void +event_loop(Display *dpy, Window win, + EGLDisplay egl_dpy, EGLSurface egl_surf, EGLSurface egl_pbuf, + EGLContext egl_ctx) +{ + int anim = 0; + + while (1) { + int redraw = 0; + + if (!anim || XPending(dpy)) { + XEvent event; + XNextEvent(dpy, &event); + + switch (event.type) { + case Expose: + redraw = 1; + break; + case ConfigureNotify: + if (event.xconfigure.window == win) { + WinWidth = event.xconfigure.width; + WinHeight = event.xconfigure.height; + } + break; + case KeyPress: + { + char buffer[10]; + int r, code; + code = XLookupKeysym(&event.xkey, 0); + if (code == XK_Left) { + view_roty += 5.0; + } + else if (code == XK_Right) { + view_roty -= 5.0; + } + else if (code == XK_Up) { + view_rotx += 5.0; + } + else if (code == XK_Down) { + view_rotx -= 5.0; + } + else { + r = XLookupString(&event.xkey, buffer, sizeof(buffer), + NULL, NULL); + if (buffer[0] == ' ') { + anim = !anim; + } + else if (buffer[0] == 'z') { + view_rotz += 5.0; + } + else if (buffer[0] == 'Z') { + view_rotz -= 5.0; + } + else if (buffer[0] == 27) { + /* escape */ + return; + } + } + } + redraw = 1; + break; + default: + ; /*no-op*/ + } + } + + if (anim) { + view_rotx += 1.0; + view_roty += 2.0; + redraw = 1; + } + + if (redraw) { + draw(egl_dpy, egl_surf, egl_pbuf, egl_ctx); + } + } +} + + +static void +usage(void) +{ + printf("Usage:\n"); + printf(" -display set the display to run on\n"); + printf(" -info display OpenGL renderer info\n"); +} + + +int +main(int argc, char *argv[]) +{ + Display *x_dpy; + Window win; + EGLSurface egl_surf, egl_pbuf; + EGLContext egl_ctx; + EGLDisplay egl_dpy; + char *dpyName = NULL; + GLboolean printInfo = GL_FALSE; + EGLint egl_major, egl_minor; + int i; + const char *s; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-display") == 0) { + dpyName = argv[i+1]; + i++; + } + else if (strcmp(argv[i], "-info") == 0) { + printInfo = GL_TRUE; + } + else { + usage(); + return -1; + } + } + + x_dpy = XOpenDisplay(dpyName); + if (!x_dpy) { + printf("Error: couldn't open display %s\n", + dpyName ? dpyName : getenv("DISPLAY")); + return -1; + } + + egl_dpy = eglGetDisplay(x_dpy); + if (!egl_dpy) { + printf("Error: eglGetDisplay() failed\n"); + return -1; + } + + if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) { + printf("Error: eglInitialize() failed\n"); + return -1; + } + + s = eglQueryString(egl_dpy, EGL_VERSION); + printf("EGL_VERSION = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_VENDOR); + printf("EGL_VENDOR = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_EXTENSIONS); + printf("EGL_EXTENSIONS = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_CLIENT_APIS); + printf("EGL_CLIENT_APIS = %s\n", s); + + make_x_window(x_dpy, egl_dpy, + "render_tex", 0, 0, WinWidth, WinHeight, + &win, &egl_ctx, &egl_surf); + + egl_pbuf = make_pbuffer(x_dpy, egl_dpy, TexWidth, TexHeight); + if (!egl_pbuf) { + printf("Error: eglCreatePBufferSurface() failed\n"); + return -1; + } + + XMapWindow(x_dpy, win); + if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) { + printf("Error: eglMakeCurrent() failed\n"); + return -1; + } + + if (printInfo) { + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS)); + } + + init(); + + event_loop(x_dpy, win, egl_dpy, egl_surf, egl_pbuf, egl_ctx); + + eglDestroyContext(egl_dpy, egl_ctx); + eglDestroySurface(egl_dpy, egl_surf); + eglTerminate(egl_dpy); + + + XDestroyWindow(x_dpy, win); + XCloseDisplay(x_dpy); + + return 0; +} diff --git a/progs/es1/xegl/torus.c b/progs/es1/xegl/torus.c new file mode 100644 index 0000000000..634d12641c --- /dev/null +++ b/progs/es1/xegl/torus.c @@ -0,0 +1,509 @@ +/* + * Copyright (C) 2008 Tunsgten Graphics,Inc. All Rights Reserved. + */ + +/* + * Draw a lit, textured torus with X/EGL and OpenGL ES 1.x + * Brian Paul + * July 2008 + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + + +static GLfloat view_rotx = 0.0, view_roty = 0.0, view_rotz = 0.0; + + +static void +Normal(GLfloat *n, GLfloat nx, GLfloat ny, GLfloat nz) +{ + n[0] = nx; + n[1] = ny; + n[2] = nz; +} + +static void +Vertex(GLfloat *v, GLfloat vx, GLfloat vy, GLfloat vz) +{ + v[0] = vx; + v[1] = vy; + v[2] = vz; +} + +static void +Texcoord(GLfloat *v, GLfloat s, GLfloat t) +{ + v[0] = s; + v[1] = t; +} + + +/* Borrowed from glut, adapted */ +static void +draw_torus(GLfloat r, GLfloat R, GLint nsides, GLint rings) +{ + int i, j; + GLfloat theta, phi, theta1; + GLfloat cosTheta, sinTheta; + GLfloat cosTheta1, sinTheta1; + GLfloat ringDelta, sideDelta; + GLfloat varray[100][3], narray[100][3], tarray[100][2]; + int vcount; + + glVertexPointer(3, GL_FLOAT, 0, varray); + glNormalPointer(GL_FLOAT, 0, narray); + glTexCoordPointer(2, GL_FLOAT, 0, tarray); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_NORMAL_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + ringDelta = 2.0 * M_PI / rings; + sideDelta = 2.0 * M_PI / nsides; + + theta = 0.0; + cosTheta = 1.0; + sinTheta = 0.0; + for (i = rings - 1; i >= 0; i--) { + theta1 = theta + ringDelta; + cosTheta1 = cos(theta1); + sinTheta1 = sin(theta1); + + vcount = 0; /* glBegin(GL_QUAD_STRIP); */ + + phi = 0.0; + for (j = nsides; j >= 0; j--) { + GLfloat s0, s1, t; + GLfloat cosPhi, sinPhi, dist; + + phi += sideDelta; + cosPhi = cos(phi); + sinPhi = sin(phi); + dist = R + r * cosPhi; + + s0 = 20.0 * theta / (2.0 * M_PI); + s1 = 20.0 * theta1 / (2.0 * M_PI); + t = 8.0 * phi / (2.0 * M_PI); + + Normal(narray[vcount], cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi); + Texcoord(tarray[vcount], s1, t); + Vertex(varray[vcount], cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi); + vcount++; + + Normal(narray[vcount], cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi); + Texcoord(tarray[vcount], s0, t); + Vertex(varray[vcount], cosTheta * dist, -sinTheta * dist, r * sinPhi); + vcount++; + } + + /*glEnd();*/ + assert(vcount <= 100); + glDrawArrays(GL_TRIANGLE_STRIP, 0, vcount); + + theta = theta1; + cosTheta = cosTheta1; + sinTheta = sinTheta1; + } + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_NORMAL_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); +} + + +static void +draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + glRotatef(view_rotx, 1, 0, 0); + glRotatef(view_roty, 0, 1, 0); + glRotatef(view_rotz, 0, 0, 1); + glScalef(0.5, 0.5, 0.5); + + draw_torus(1.0, 3.0, 30, 60); + + glPopMatrix(); +} + + +/* new window size or exposure */ +static void +reshape(int width, int height) +{ + GLfloat ar = (GLfloat) width / (GLfloat) height; + + glViewport(0, 0, (GLint) width, (GLint) height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + +#ifdef GL_VERSION_ES_CM_1_0 + glFrustumf(-ar, ar, -1, 1, 5.0, 60.0); +#else + glFrustum(-ar, ar, -1, 1, 5.0, 60.0); +#endif + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -15.0); +} + + +static void +make_texture(void) +{ +#define SZ 64 + GLenum Filter = GL_LINEAR; + GLubyte image[SZ][SZ][4]; + GLuint i, j; + + for (i = 0; i < SZ; i++) { + for (j = 0; j < SZ; j++) { + GLfloat d = (i - SZ/2) * (i - SZ/2) + (j - SZ/2) * (j - SZ/2); + d = sqrt(d); + if (d < SZ/3) { + image[i][j][0] = 255; + image[i][j][1] = 255; + image[i][j][2] = 255; + image[i][j][3] = 255; + } + else { + image[i][j][0] = 127; + image[i][j][1] = 127; + image[i][j][2] = 127; + image[i][j][3] = 255; + } + } + } + + glActiveTexture(GL_TEXTURE0); /* unit 0 */ + glBindTexture(GL_TEXTURE_2D, 42); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SZ, SZ, 0, + GL_RGBA, GL_UNSIGNED_BYTE, image); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, Filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, Filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); +#undef SZ +} + + + +static void +init(void) +{ + static const GLfloat red[4] = {1, 0, 0, 0}; + static const GLfloat white[4] = {1.0, 1.0, 1.0, 1.0}; + static const GLfloat diffuse[4] = {0.7, 0.7, 0.7, 1.0}; + static const GLfloat specular[4] = {0.001, 0.001, 0.001, 1.0}; + static const GLfloat pos[4] = {20, 20, 50, 1}; + + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, red); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white); + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 9.0); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glLightfv(GL_LIGHT0, GL_POSITION, pos); + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); + glLightfv(GL_LIGHT0, GL_SPECULAR, specular); + + glClearColor(0.4, 0.4, 0.4, 0.0); + glEnable(GL_DEPTH_TEST); + + make_texture(); + glEnable(GL_TEXTURE_2D); +} + + +/* + * Create an RGB, double-buffered X window. + * Return the window and context handles. + */ +static void +make_x_window(Display *x_dpy, EGLDisplay egl_dpy, + const char *name, + int x, int y, int width, int height, + Window *winRet, + EGLContext *ctxRet, + EGLSurface *surfRet) +{ + static const EGLint attribs[] = { + EGL_RED_SIZE, 1, + EGL_GREEN_SIZE, 1, + EGL_BLUE_SIZE, 1, + EGL_DEPTH_SIZE, 1, + EGL_NONE + }; + + int scrnum; + XSetWindowAttributes attr; + unsigned long mask; + Window root; + Window win; + XVisualInfo *visInfo, visTemplate; + int num_visuals; + EGLContext ctx; + EGLConfig config; + EGLint num_configs; + EGLint vid; + + scrnum = DefaultScreen( x_dpy ); + root = RootWindow( x_dpy, scrnum ); + + if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) { + printf("Error: couldn't get an EGL visual config\n"); + exit(1); + } + + assert(config); + assert(num_configs > 0); + + if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) { + printf("Error: eglGetConfigAttrib() failed\n"); + exit(1); + } + + /* The X window visual must match the EGL config */ + visTemplate.visualid = vid; + visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals); + if (!visInfo) { + printf("Error: couldn't get X visual\n"); + exit(1); + } + + /* window attributes */ + attr.background_pixel = 0; + attr.border_pixel = 0; + attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone); + attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; + mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; + + win = XCreateWindow( x_dpy, root, 0, 0, width, height, + 0, visInfo->depth, InputOutput, + visInfo->visual, mask, &attr ); + + /* set hints and properties */ + { + XSizeHints sizehints; + sizehints.x = x; + sizehints.y = y; + sizehints.width = width; + sizehints.height = height; + sizehints.flags = USSize | USPosition; + XSetNormalHints(x_dpy, win, &sizehints); + XSetStandardProperties(x_dpy, win, name, name, + None, (char **)NULL, 0, &sizehints); + } + + eglBindAPI(EGL_OPENGL_ES_API); + + ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL ); + if (!ctx) { + printf("Error: eglCreateContext failed\n"); + exit(1); + } + + *surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL); + + if (!*surfRet) { + printf("Error: eglCreateWindowSurface failed\n"); + exit(1); + } + + XFree(visInfo); + + *winRet = win; + *ctxRet = ctx; +} + + +static void +event_loop(Display *dpy, Window win, + EGLDisplay egl_dpy, EGLSurface egl_surf) +{ + int anim = 1; + + while (1) { + int redraw = 0; + + if (!anim || XPending(dpy)) { + XEvent event; + XNextEvent(dpy, &event); + + switch (event.type) { + case Expose: + redraw = 1; + break; + case ConfigureNotify: + reshape(event.xconfigure.width, event.xconfigure.height); + break; + case KeyPress: + { + char buffer[10]; + int r, code; + code = XLookupKeysym(&event.xkey, 0); + if (code == XK_Left) { + view_roty += 5.0; + } + else if (code == XK_Right) { + view_roty -= 5.0; + } + else if (code == XK_Up) { + view_rotx += 5.0; + } + else if (code == XK_Down) { + view_rotx -= 5.0; + } + else { + r = XLookupString(&event.xkey, buffer, sizeof(buffer), + NULL, NULL); + if (buffer[0] == ' ') { + anim = !anim; + } + else if (buffer[0] == 27) { + /* escape */ + return; + } + } + } + redraw = 1; + break; + default: + ; /*no-op*/ + } + } + + if (anim) { + view_rotx += 1.0; + view_roty += 2.0; + redraw = 1; + } + + if (redraw) { + draw(); + eglSwapBuffers(egl_dpy, egl_surf); + } + } +} + + +static void +usage(void) +{ + printf("Usage:\n"); + printf(" -display set the display to run on\n"); + printf(" -info display OpenGL renderer info\n"); +} + + +int +main(int argc, char *argv[]) +{ + const int winWidth = 300, winHeight = 300; + Display *x_dpy; + Window win; + EGLSurface egl_surf; + EGLContext egl_ctx; + EGLDisplay egl_dpy; + char *dpyName = NULL; + GLboolean printInfo = GL_FALSE; + EGLint egl_major, egl_minor; + int i; + const char *s; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-display") == 0) { + dpyName = argv[i+1]; + i++; + } + else if (strcmp(argv[i], "-info") == 0) { + printInfo = GL_TRUE; + } + else { + usage(); + return -1; + } + } + + x_dpy = XOpenDisplay(dpyName); + if (!x_dpy) { + printf("Error: couldn't open display %s\n", + dpyName ? dpyName : getenv("DISPLAY")); + return -1; + } + + egl_dpy = eglGetDisplay(x_dpy); + if (!egl_dpy) { + printf("Error: eglGetDisplay() failed\n"); + return -1; + } + + if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) { + printf("Error: eglInitialize() failed\n"); + return -1; + } + + s = eglQueryString(egl_dpy, EGL_VERSION); + printf("EGL_VERSION = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_VENDOR); + printf("EGL_VENDOR = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_EXTENSIONS); + printf("EGL_EXTENSIONS = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_CLIENT_APIS); + printf("EGL_CLIENT_APIS = %s\n", s); + + make_x_window(x_dpy, egl_dpy, + "torus", 0, 0, winWidth, winHeight, + &win, &egl_ctx, &egl_surf); + + XMapWindow(x_dpy, win); + if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) { + printf("Error: eglMakeCurrent() failed\n"); + return -1; + } + + if (printInfo) { + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS)); + } + + init(); + + /* Set initial projection/viewing transformation. + * We can't be sure we'll get a ConfigureNotify event when the window + * first appears. + */ + reshape(winWidth, winHeight); + + event_loop(x_dpy, win, egl_dpy, egl_surf); + + eglDestroyContext(egl_dpy, egl_ctx); + eglDestroySurface(egl_dpy, egl_surf); + eglTerminate(egl_dpy); + + + XDestroyWindow(x_dpy, win); + XCloseDisplay(x_dpy); + + return 0; +} diff --git a/progs/es1/xegl/tri.c b/progs/es1/xegl/tri.c new file mode 100644 index 0000000000..42a978207c --- /dev/null +++ b/progs/es1/xegl/tri.c @@ -0,0 +1,470 @@ +/* + * Copyright (C) 2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL 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. + */ + +/* + * Draw a triangle with X/EGL and OpenGL ES 1.x + * Brian Paul + * 5 June 2008 + */ + +#define USE_FULL_GL 0 + +#define USE_FIXED_POINT 0 + + +#include +#include +#include +#include +#include +#include +#include +#include +#if USE_FULL_GL +#include /* use full OpenGL */ +#else +#include /* use OpenGL ES 1.x */ +#include +#endif +#include + + +#define FLOAT_TO_FIXED(X) ((X) * 65535.0) + + + +static GLfloat view_rotx = 0.0, view_roty = 0.0, view_rotz = 0.0; + + +static void +draw(void) +{ +#if USE_FIXED_POINT + static const GLfixed verts[3][2] = { + { -65536, -65536 }, + { 65536, -65536 }, + { 0, 65536 } + }; + static const GLfixed colors[3][4] = { + { 65536, 0, 0, 65536 }, + { 0, 65536, 0 , 65536}, + { 0, 0, 65536 , 65536} + }; +#else + static const GLfloat verts[3][2] = { + { -1, -1 }, + { 1, -1 }, + { 0, 1 } + }; + static const GLfloat colors[3][4] = { + { 1, 0, 0, 1 }, + { 0, 1, 0, 1 }, + { 0, 0, 1, 1 } + }; +#endif + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + glRotatef(view_rotx, 1, 0, 0); + glRotatef(view_roty, 0, 1, 0); + glRotatef(view_rotz, 0, 0, 1); + + { +#if USE_FIXED_POINT + glVertexPointer(2, GL_FIXED, 0, verts); + glColorPointer(4, GL_FIXED, 0, colors); +#else + glVertexPointer(2, GL_FLOAT, 0, verts); + glColorPointer(4, GL_FLOAT, 0, colors); +#endif + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + + /* draw triangle */ + glDrawArrays(GL_TRIANGLES, 0, 3); + + /* draw some points */ + glPointSizex(FLOAT_TO_FIXED(15.5)); + glDrawArrays(GL_POINTS, 0, 3); + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + } + + if (0) { + /* test code */ + GLfixed size; + glGetFixedv(GL_POINT_SIZE, &size); + printf("GL_POINT_SIZE = 0x%x %f\n", size, size / 65536.0); + } + + glPopMatrix(); +} + + +/* new window size or exposure */ +static void +reshape(int width, int height) +{ + GLfloat ar = (GLfloat) width / (GLfloat) height; + + glViewport(0, 0, (GLint) width, (GLint) height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); +#ifdef GL_VERSION_ES_CM_1_0 + glFrustumf(-ar, ar, -1, 1, 5.0, 60.0); +#else + glFrustum(-ar, ar, -1, 1, 5.0, 60.0); +#endif + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -10.0); +} + + +static void +test_query_matrix(void) +{ + PFNGLQUERYMATRIXXOESPROC procQueryMatrixx; + typedef void (*voidproc)(); + GLfixed mantissa[16]; + GLint exponent[16]; + GLbitfield rv; + int i; + + procQueryMatrixx = (PFNGLQUERYMATRIXXOESPROC) eglGetProcAddress("glQueryMatrixxOES"); + assert(procQueryMatrixx); + /* Actually try out this one */ + rv = (*procQueryMatrixx)(mantissa, exponent); + for (i = 0; i < 16; i++) { + if (rv & (1< 0); + + if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) { + printf("Error: eglGetConfigAttrib() failed\n"); + exit(1); + } + + /* The X window visual must match the EGL config */ + visTemplate.visualid = vid; + visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals); + if (!visInfo) { + printf("Error: couldn't get X visual\n"); + exit(1); + } + + /* window attributes */ + attr.background_pixel = 0; + attr.border_pixel = 0; + attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone); + attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; + mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; + + win = XCreateWindow( x_dpy, root, 0, 0, width, height, + 0, visInfo->depth, InputOutput, + visInfo->visual, mask, &attr ); + + /* set hints and properties */ + { + XSizeHints sizehints; + sizehints.x = x; + sizehints.y = y; + sizehints.width = width; + sizehints.height = height; + sizehints.flags = USSize | USPosition; + XSetNormalHints(x_dpy, win, &sizehints); + XSetStandardProperties(x_dpy, win, name, name, + None, (char **)NULL, 0, &sizehints); + } + +#if USE_FULL_GL + eglBindAPI(EGL_OPENGL_API); +#else + eglBindAPI(EGL_OPENGL_ES_API); +#endif + + ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL ); + if (!ctx) { + printf("Error: eglCreateContext failed\n"); + exit(1); + } + + *surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL); + + if (!*surfRet) { + printf("Error: eglCreateWindowSurface failed\n"); + exit(1); + } + + XFree(visInfo); + + *winRet = win; + *ctxRet = ctx; +} + + +static void +event_loop(Display *dpy, Window win, + EGLDisplay egl_dpy, EGLSurface egl_surf) +{ + while (1) { + int redraw = 0; + XEvent event; + + XNextEvent(dpy, &event); + + switch (event.type) { + case Expose: + redraw = 1; + break; + case ConfigureNotify: + reshape(event.xconfigure.width, event.xconfigure.height); + break; + case KeyPress: + { + char buffer[10]; + int r, code; + code = XLookupKeysym(&event.xkey, 0); + if (code == XK_Left) { + view_roty += 5.0; + } + else if (code == XK_Right) { + view_roty -= 5.0; + } + else if (code == XK_Up) { + view_rotx += 5.0; + } + else if (code == XK_Down) { + view_rotx -= 5.0; + } + else { + r = XLookupString(&event.xkey, buffer, sizeof(buffer), + NULL, NULL); + if (buffer[0] == 27) { + /* escape */ + return; + } + } + } + redraw = 1; + break; + default: + ; /*no-op*/ + } + + if (redraw) { + draw(); + eglSwapBuffers(egl_dpy, egl_surf); + } + } +} + + +static void +usage(void) +{ + printf("Usage:\n"); + printf(" -display set the display to run on\n"); + printf(" -info display OpenGL renderer info\n"); +} + + +int +main(int argc, char *argv[]) +{ + const int winWidth = 300, winHeight = 300; + Display *x_dpy; + Window win; + EGLSurface egl_surf; + EGLContext egl_ctx; + EGLDisplay egl_dpy; + char *dpyName = NULL; + GLboolean printInfo = GL_FALSE; + EGLint egl_major, egl_minor; + int i; + const char *s; + + static struct { + char *name; + GLenum value; + enum {GetString, GetInteger} type; + } info_items[] = { + {"GL_RENDERER", GL_RENDERER, GetString}, + {"GL_VERSION", GL_VERSION, GetString}, + {"GL_VENDOR", GL_VENDOR, GetString}, + {"GL_EXTENSIONS", GL_EXTENSIONS, GetString}, + {"GL_MAX_PALETTE_MATRICES_OES", GL_MAX_PALETTE_MATRICES_OES, GetInteger}, + {"GL_MAX_VERTEX_UNITS_OES", GL_MAX_VERTEX_UNITS_OES, GetInteger}, + }; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-display") == 0) { + dpyName = argv[i+1]; + i++; + } + else if (strcmp(argv[i], "-info") == 0) { + printInfo = GL_TRUE; + } + else { + usage(); + return -1; + } + } + + x_dpy = XOpenDisplay(dpyName); + if (!x_dpy) { + printf("Error: couldn't open display %s\n", + dpyName ? dpyName : getenv("DISPLAY")); + return -1; + } + + egl_dpy = eglGetDisplay(x_dpy); + if (!egl_dpy) { + printf("Error: eglGetDisplay() failed\n"); + return -1; + } + + if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) { + printf("Error: eglInitialize() failed\n"); + return -1; + } + + s = eglQueryString(egl_dpy, EGL_VERSION); + printf("EGL_VERSION = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_VENDOR); + printf("EGL_VENDOR = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_EXTENSIONS); + printf("EGL_EXTENSIONS = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_CLIENT_APIS); + printf("EGL_CLIENT_APIS = %s\n", s); + + make_x_window(x_dpy, egl_dpy, + "OpenGL ES 1.x tri", 0, 0, winWidth, winHeight, + &win, &egl_ctx, &egl_surf); + + XMapWindow(x_dpy, win); + if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) { + printf("Error: eglMakeCurrent() failed\n"); + return -1; + } + + if (printInfo) { + for (i = 0; i < sizeof(info_items)/sizeof(info_items[0]); i++) { + switch (info_items[i].type) { + case GetString: + printf("%s = %s\n", info_items[i].name, (char *)glGetString(info_items[i].value)); + break; + case GetInteger: { + GLint rv = -1; + glGetIntegerv(info_items[i].value, &rv); + printf("%s = %d\n", info_items[i].name, rv); + break; + } + } + } + }; + init(); + + /* Set initial projection/viewing transformation. + * We can't be sure we'll get a ConfigureNotify event when the window + * first appears. + */ + reshape(winWidth, winHeight); + + event_loop(x_dpy, win, egl_dpy, egl_surf); + + eglDestroyContext(egl_dpy, egl_ctx); + eglDestroySurface(egl_dpy, egl_surf); + eglTerminate(egl_dpy); + + + XDestroyWindow(x_dpy, win); + XCloseDisplay(x_dpy); + + return 0; +} diff --git a/progs/es1/xegl/two_win.c b/progs/es1/xegl/two_win.c new file mode 100644 index 0000000000..4785e5304d --- /dev/null +++ b/progs/es1/xegl/two_win.c @@ -0,0 +1,433 @@ +/* + * Copyright (C) 2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL 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. + */ + +/* + * Test drawing to two windows. + * Brian Paul + * August 2008 + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +static int WinWidth[2] = {150, 300}, WinHeight[2] = {150, 300}; + + +static GLfloat view_rotx = 0.0, view_roty = 0.0, view_rotz = 0.0; + + +/* new window size or exposure */ +static void +reshape(int width, int height) +{ + GLfloat ar = (GLfloat) width / (GLfloat) height; + + glViewport(0, 0, (GLint) width, (GLint) height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); +#ifdef GL_VERSION_ES_CM_1_0 + glFrustumf(-ar, ar, -1, 1, 5.0, 60.0); +#else + glFrustum(-ar, ar, -1, 1, 5.0, 60.0); +#endif + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -10.0); +} + + +static void +draw(int win) +{ + static const GLfloat verts[3][2] = { + { -1, -1 }, + { 1, -1 }, + { 0, 1 } + }; + static const GLfloat colors[3][4] = { + { 1, 0, 0, 1 }, + { 0, 1, 0, 1 }, + { 0, 0, 1, 1 } + }; + + assert(win == 0 || win == 1); + + reshape(WinWidth[win], WinHeight[win]); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + glRotatef(view_rotx, 1, 0, 0); + glRotatef(view_roty, 0, 1, 0); + glRotatef(view_rotz, 0, 0, 1); + + /* draw triangle */ + { + glVertexPointer(2, GL_FLOAT, 0, verts); + glColorPointer(4, GL_FLOAT, 0, colors); + + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + + glDrawArrays(GL_TRIANGLES, 0, 3); + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + } + + glPopMatrix(); +} + + +static void +init(void) +{ + glClearColor(0.4, 0.4, 0.4, 0.0); +} + + +/* + * Create an RGB, double-buffered X window. + * Return the window and context handles. + */ +static void +make_x_window(Display *x_dpy, EGLDisplay egl_dpy, + const char *name, + int x, int y, int width, int height, + Window *winRet, + EGLContext *ctxRet, + EGLSurface *surfRet) +{ + static const EGLint attribs[] = { + EGL_RED_SIZE, 1, + EGL_GREEN_SIZE, 1, + EGL_BLUE_SIZE, 1, + EGL_DEPTH_SIZE, 1, + EGL_NONE + }; + + int scrnum; + XSetWindowAttributes attr; + unsigned long mask; + Window root; + Window win; + XVisualInfo *visInfo, visTemplate; + int num_visuals; + EGLContext ctx; + EGLConfig config; + EGLint num_configs; + EGLint vid; + + scrnum = DefaultScreen( x_dpy ); + root = RootWindow( x_dpy, scrnum ); + + if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) { + printf("Error: couldn't get an EGL visual config\n"); + exit(1); + } + + assert(config); + assert(num_configs > 0); + + if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) { + printf("Error: eglGetConfigAttrib() failed\n"); + exit(1); + } + + /* The X window visual must match the EGL config */ + visTemplate.visualid = vid; + visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals); + if (!visInfo) { + printf("Error: couldn't get X visual\n"); + exit(1); + } + + /* window attributes */ + attr.background_pixel = 0; + attr.border_pixel = 0; + attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone); + attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; + mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; + + win = XCreateWindow( x_dpy, root, x, y, width, height, + 0, visInfo->depth, InputOutput, + visInfo->visual, mask, &attr ); + + /* set hints and properties */ + { + XSizeHints sizehints; + sizehints.x = x; + sizehints.y = y; + sizehints.width = width; + sizehints.height = height; + sizehints.flags = USSize | USPosition; + XSetNormalHints(x_dpy, win, &sizehints); + XSetStandardProperties(x_dpy, win, name, name, + None, (char **)NULL, 0, &sizehints); + } + +#if USE_FULL_GL + eglBindAPI(EGL_OPENGL_API); +#else + eglBindAPI(EGL_OPENGL_ES_API); +#endif + + if (ctxRet) { + ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL ); + if (!ctx) { + printf("Error: eglCreateContext failed\n"); + exit(1); + } + *ctxRet = ctx; + } + + *surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL); + + if (!*surfRet) { + printf("Error: eglCreateWindowSurface failed\n"); + exit(1); + } + + XFree(visInfo); + + *winRet = win; +} + + +static void +event_loop(Display *dpy, Window win1, Window win2, + EGLDisplay egl_dpy, EGLSurface egl_surf1, EGLSurface egl_surf2, + EGLContext egl_ctx) +{ + while (1) { + int redraw = 0; + int win; + XEvent event; + + XNextEvent(dpy, &event); + + switch (event.type) { + case Expose: + redraw = 1; + break; + case ConfigureNotify: + if (event.xconfigure.window == win1) + win = 0; + else + win = 1; + WinWidth[win] = event.xconfigure.width; + WinHeight[win] = event.xconfigure.height; + break; + case KeyPress: + { + char buffer[10]; + int r, code; + code = XLookupKeysym(&event.xkey, 0); + if (code == XK_Left) { + view_roty += 5.0; + } + else if (code == XK_Right) { + view_roty -= 5.0; + } + else if (code == XK_Up) { + view_rotx += 5.0; + } + else if (code == XK_Down) { + view_rotx -= 5.0; + } + else { + r = XLookupString(&event.xkey, buffer, sizeof(buffer), + NULL, NULL); + if (buffer[0] == 27) { + /* escape */ + return; + } + } + } + redraw = 1; + break; + default: + ; /*no-op*/ + } + + if (redraw) { + /* win 1 */ + if (!eglMakeCurrent(egl_dpy, egl_surf1, egl_surf1, egl_ctx)) { + printf("Error: eglMakeCurrent(1) failed\n"); + return; + } + draw(0); + eglSwapBuffers(egl_dpy, egl_surf1); + + /* win 2 */ + if (!eglMakeCurrent(egl_dpy, egl_surf2, egl_surf2, egl_ctx)) { + printf("Error: eglMakeCurrent(2) failed\n"); + return; + } + draw(1); + eglSwapBuffers(egl_dpy, egl_surf2); + } + } +} + + +static void +usage(void) +{ + printf("Usage:\n"); + printf(" -display set the display to run on\n"); + printf(" -info display OpenGL renderer info\n"); +} + + +int +main(int argc, char *argv[]) +{ + Display *x_dpy; + Window win1, win2; + EGLSurface egl_surf1, egl_surf2; + EGLContext egl_ctx; + EGLDisplay egl_dpy; + char *dpyName = NULL; + GLboolean printInfo = GL_FALSE; + EGLint egl_major, egl_minor; + int i; + const char *s; + + static struct { + char *name; + GLenum value; + enum {GetString, GetInteger} type; + } info_items[] = { + {"GL_RENDERER", GL_RENDERER, GetString}, + {"GL_VERSION", GL_VERSION, GetString}, + {"GL_VENDOR", GL_VENDOR, GetString}, + {"GL_EXTENSIONS", GL_EXTENSIONS, GetString}, + {"GL_MAX_PALETTE_MATRICES_OES", GL_MAX_PALETTE_MATRICES_OES, GetInteger}, + {"GL_MAX_VERTEX_UNITS_OES", GL_MAX_VERTEX_UNITS_OES, GetInteger}, + }; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-display") == 0) { + dpyName = argv[i+1]; + i++; + } + else if (strcmp(argv[i], "-info") == 0) { + printInfo = GL_TRUE; + } + else { + usage(); + return -1; + } + } + + x_dpy = XOpenDisplay(dpyName); + if (!x_dpy) { + printf("Error: couldn't open display %s\n", + dpyName ? dpyName : getenv("DISPLAY")); + return -1; + } + + egl_dpy = eglGetDisplay(x_dpy); + if (!egl_dpy) { + printf("Error: eglGetDisplay() failed\n"); + return -1; + } + + if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) { + printf("Error: eglInitialize() failed\n"); + return -1; + } + + s = eglQueryString(egl_dpy, EGL_VERSION); + printf("EGL_VERSION = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_VENDOR); + printf("EGL_VENDOR = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_EXTENSIONS); + printf("EGL_EXTENSIONS = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_CLIENT_APIS); + printf("EGL_CLIENT_APIS = %s\n", s); + + make_x_window(x_dpy, egl_dpy, + "xegl_two_win #1", 0, 0, WinWidth[0], WinHeight[0], + &win1, &egl_ctx, &egl_surf1); + + make_x_window(x_dpy, egl_dpy, + "xegl_two_win #2", WinWidth[0] + 50, 0, + WinWidth[1], WinHeight[1], + &win2, NULL, &egl_surf2); + + XMapWindow(x_dpy, win1); + + XMapWindow(x_dpy, win2); + + if (!eglMakeCurrent(egl_dpy, egl_surf1, egl_surf1, egl_ctx)) { + printf("Error: eglMakeCurrent() failed\n"); + return -1; + } + + if (printInfo) { + for (i = 0; i < sizeof(info_items)/sizeof(info_items[0]); i++) { + switch (info_items[i].type) { + case GetString: + printf("%s = %s\n", info_items[i].name, (char *)glGetString(info_items[i].value)); + break; + case GetInteger: { + GLint rv = -1; + glGetIntegerv(info_items[i].value, &rv); + printf("%s = %d\n", info_items[i].name, rv); + break; + } + } + } + }; + + init(); + + event_loop(x_dpy, win1, win2, egl_dpy, egl_surf1, egl_surf2, egl_ctx); + + eglDestroyContext(egl_dpy, egl_ctx); + eglDestroySurface(egl_dpy, egl_surf1); + eglDestroySurface(egl_dpy, egl_surf2); + eglTerminate(egl_dpy); + + XDestroyWindow(x_dpy, win1); + XDestroyWindow(x_dpy, win2); + XCloseDisplay(x_dpy); + + return 0; +} diff --git a/progs/es2/xegl/Makefile b/progs/es2/xegl/Makefile new file mode 100644 index 0000000000..88bb0127f8 --- /dev/null +++ b/progs/es2/xegl/Makefile @@ -0,0 +1,51 @@ +# progs/es2/xegl/Makefile + +TOP = ../../.. +include $(TOP)/configs/current + + +INCLUDE_DIRS = \ + -I$(TOP)/include \ + +HEADERS = $(TOP)/include/GLES/egl.h + + +ES2_LIB_DEPS = \ + $(TOP)/$(LIB_DIR)/libEGL.so \ + $(TOP)/$(LIB_DIR)/libGLESv2.so + + +ES2_LIBS = \ + -L$(TOP)/$(LIB_DIR) -lEGL \ + -L$(TOP)/$(LIB_DIR) -lGLESv2 $(LIBDRM_LIB) -lX11 + +PROGRAMS = \ + es2_info \ + tri + + +.c.o: + $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ + + + +default: $(PROGRAMS) + + + +es2_info.c: + cp ../../es1/xegl/es1_info.c es2_info.c + +es2_info: es2_info.o $(ES2_LIB_DEPS) + $(CC) $(CFLAGS) es2_info.o $(ES2_LIBS) -o $@ + +tri: tri.o $(ES2_LIB_DEPS) + $(CC) $(CFLAGS) tri.o $(ES2_LIBS) -o $@ + + + +clean: + rm -f *.o *~ + rm -f $(PROGRAMS) + rm -f es2_info.c + diff --git a/progs/es2/xegl/tri.c b/progs/es2/xegl/tri.c new file mode 100644 index 0000000000..eb52b10620 --- /dev/null +++ b/progs/es2/xegl/tri.c @@ -0,0 +1,514 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + **************************************************************************/ + +/* + * Draw a triangle with X/EGL and OpenGL ES 2.x + */ + +#define USE_FULL_GL 0 + + + +#include +#include +#include +#include +#include +#include +#include +#include +#if USE_FULL_GL +#include /* use full OpenGL */ +#else +#include /* use OpenGL ES 2.x */ +#endif +#include + + +#define FLOAT_TO_FIXED(X) ((X) * 65535.0) + + + +static GLfloat view_rotx = 0.0, view_roty = 0.0; + +static GLint u_matrix = -1; +static GLint attr_pos = 0, attr_color = 1; + + +static void +make_z_rot_matrix(GLfloat angle, GLfloat *m) +{ + float c = cos(angle * M_PI / 180.0); + float s = sin(angle * M_PI / 180.0); + int i; + for (i = 0; i < 16; i++) + m[i] = 0.0; + m[0] = m[5] = m[10] = m[15] = 1.0; + + m[0] = c; + m[1] = s; + m[4] = -s; + m[5] = c; +} + +static void +make_scale_matrix(GLfloat xs, GLfloat ys, GLfloat zs, GLfloat *m) +{ + int i; + for (i = 0; i < 16; i++) + m[i] = 0.0; + m[0] = xs; + m[5] = ys; + m[10] = zs; + m[15] = 1.0; +} + + +static void +mul_matrix(GLfloat *prod, const GLfloat *a, const GLfloat *b) +{ +#define A(row,col) a[(col<<2)+row] +#define B(row,col) b[(col<<2)+row] +#define P(row,col) p[(col<<2)+row] + GLfloat p[16]; + GLint i; + for (i = 0; i < 4; i++) { + const GLfloat ai0=A(i,0), ai1=A(i,1), ai2=A(i,2), ai3=A(i,3); + P(i,0) = ai0 * B(0,0) + ai1 * B(1,0) + ai2 * B(2,0) + ai3 * B(3,0); + P(i,1) = ai0 * B(0,1) + ai1 * B(1,1) + ai2 * B(2,1) + ai3 * B(3,1); + P(i,2) = ai0 * B(0,2) + ai1 * B(1,2) + ai2 * B(2,2) + ai3 * B(3,2); + P(i,3) = ai0 * B(0,3) + ai1 * B(1,3) + ai2 * B(2,3) + ai3 * B(3,3); + } + memcpy(prod, p, sizeof(p)); +#undef A +#undef B +#undef PROD +} + + +static void +draw(void) +{ + static const GLfloat verts[3][2] = { + { -1, -1 }, + { 1, -1 }, + { 0, 1 } + }; + static const GLfloat colors[3][3] = { + { 1, 0, 0 }, + { 0, 1, 0 }, + { 0, 0, 1 } + }; + GLfloat mat[16], rot[16], scale[16]; + + /* Set modelview/projection matrix */ + make_z_rot_matrix(view_rotx, rot); + make_scale_matrix(0.5, 0.5, 0.5, scale); + mul_matrix(mat, rot, scale); + glUniformMatrix4fv(u_matrix, 1, GL_FALSE, mat); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + { + glVertexAttribPointer(attr_pos, 2, GL_FLOAT, GL_FALSE, 0, verts); + glVertexAttribPointer(attr_color, 3, GL_FLOAT, GL_FALSE, 0, colors); + glEnableVertexAttribArray(attr_pos); + glEnableVertexAttribArray(attr_color); + + glDrawArrays(GL_TRIANGLES, 0, 3); + + glDisableVertexAttribArray(attr_pos); + glDisableVertexAttribArray(attr_color); + } +} + + +/* new window size or exposure */ +static void +reshape(int width, int height) +{ + glViewport(0, 0, (GLint) width, (GLint) height); +} + + +static void +create_shaders(void) +{ + static const char *fragShaderText = + "varying vec4 v_color;\n" + "void main() {\n" + " gl_FragColor = v_color;\n" + "}\n"; + static const char *vertShaderText = + "uniform mat4 modelviewProjection;\n" + "attribute vec4 pos;\n" + "attribute vec4 color;\n" + "varying vec4 v_color;\n" + "void main() {\n" + " gl_Position = modelviewProjection * pos;\n" + " v_color = color;\n" + "}\n"; + + GLuint fragShader, vertShader, program; + GLint stat; + + fragShader = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(fragShader, 1, (const char **) &fragShaderText, NULL); + glCompileShader(fragShader); + glGetShaderiv(fragShader, GL_COMPILE_STATUS, &stat); + if (!stat) { + printf("Error: fragment shader did not compile!\n"); + exit(1); + } + + vertShader = glCreateShader(GL_VERTEX_SHADER); + glShaderSource(vertShader, 1, (const char **) &vertShaderText, NULL); + glCompileShader(vertShader); + glGetShaderiv(vertShader, GL_COMPILE_STATUS, &stat); + if (!stat) { + printf("Error: vertex shader did not compile!\n"); + exit(1); + } + + program = glCreateProgram(); + glAttachShader(program, fragShader); + glAttachShader(program, vertShader); + glLinkProgram(program); + + glGetProgramiv(program, GL_LINK_STATUS, &stat); + if (!stat) { + char log[1000]; + GLsizei len; + glGetProgramInfoLog(program, 1000, &len, log); + printf("Error: linking:\n%s\n", log); + exit(1); + } + + glUseProgram(program); + + if (1) { + /* test setting attrib locations */ + glBindAttribLocation(program, attr_pos, "pos"); + glBindAttribLocation(program, attr_color, "color"); + glLinkProgram(program); /* needed to put attribs into effect */ + } + else { + /* test automatic attrib locations */ + attr_pos = glGetAttribLocation(program, "pos"); + attr_color = glGetAttribLocation(program, "color"); + } + + u_matrix = glGetUniformLocation(program, "modelviewProjection"); + printf("Uniform modelviewProjection at %d\n", u_matrix); + printf("Attrib pos at %d\n", attr_pos); + printf("Attrib color at %d\n", attr_color); +} + + +static void +init(void) +{ + typedef void (*proc)(); + +#if 1 /* test code */ + proc p = eglGetProcAddress("glMapBufferOES"); + assert(p); +#endif + + glClearColor(0.4, 0.4, 0.4, 0.0); + + create_shaders(); +} + + +/* + * Create an RGB, double-buffered X window. + * Return the window and context handles. + */ +static void +make_x_window(Display *x_dpy, EGLDisplay egl_dpy, + const char *name, + int x, int y, int width, int height, + Window *winRet, + EGLContext *ctxRet, + EGLSurface *surfRet) +{ + static const EGLint attribs[] = { + EGL_RED_SIZE, 1, + EGL_GREEN_SIZE, 1, + EGL_BLUE_SIZE, 1, + EGL_DEPTH_SIZE, 1, + EGL_NONE + }; + static const EGLint ctx_attribs[] = { + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_NONE + }; + int scrnum; + XSetWindowAttributes attr; + unsigned long mask; + Window root; + Window win; + XVisualInfo *visInfo, visTemplate; + int num_visuals; + EGLContext ctx; + EGLConfig config; + EGLint num_configs; + EGLint vid; + + scrnum = DefaultScreen( x_dpy ); + root = RootWindow( x_dpy, scrnum ); + + if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) { + printf("Error: couldn't get an EGL visual config\n"); + exit(1); + } + + assert(config); + assert(num_configs > 0); + + if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) { + printf("Error: eglGetConfigAttrib() failed\n"); + exit(1); + } + + /* The X window visual must match the EGL config */ + visTemplate.visualid = vid; + visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals); + if (!visInfo) { + printf("Error: couldn't get X visual\n"); + exit(1); + } + + /* window attributes */ + attr.background_pixel = 0; + attr.border_pixel = 0; + attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone); + attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; + mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; + + win = XCreateWindow( x_dpy, root, 0, 0, width, height, + 0, visInfo->depth, InputOutput, + visInfo->visual, mask, &attr ); + + /* set hints and properties */ + { + XSizeHints sizehints; + sizehints.x = x; + sizehints.y = y; + sizehints.width = width; + sizehints.height = height; + sizehints.flags = USSize | USPosition; + XSetNormalHints(x_dpy, win, &sizehints); + XSetStandardProperties(x_dpy, win, name, name, + None, (char **)NULL, 0, &sizehints); + } + +#if USE_FULL_GL /* XXX fix this when eglBindAPI() works */ + eglBindAPI(EGL_OPENGL_API); +#else + eglBindAPI(EGL_OPENGL_ES_API); +#endif + + ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs ); + if (!ctx) { + printf("Error: eglCreateContext failed\n"); + exit(1); + } + + /* test eglQueryContext() */ + { + EGLint val; + eglQueryContext(egl_dpy, ctx, EGL_CONTEXT_CLIENT_VERSION, &val); + assert(val == 2); + } + + *surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL); + if (!*surfRet) { + printf("Error: eglCreateWindowSurface failed\n"); + exit(1); + } + + { + EGLint val; + eglQuerySurface(egl_dpy, *surfRet, EGL_WIDTH, &val); + assert(val == width); + eglQuerySurface(egl_dpy, *surfRet, EGL_HEIGHT, &val); + assert(val == height); + eglQuerySurface(egl_dpy, *surfRet, EGL_SURFACE_TYPE, &val); + assert(val == EGL_WINDOW_BIT); + } + + XFree(visInfo); + + *winRet = win; + *ctxRet = ctx; +} + + +static void +event_loop(Display *dpy, Window win, + EGLDisplay egl_dpy, EGLSurface egl_surf) +{ + while (1) { + int redraw = 0; + XEvent event; + + XNextEvent(dpy, &event); + + switch (event.type) { + case Expose: + redraw = 1; + break; + case ConfigureNotify: + reshape(event.xconfigure.width, event.xconfigure.height); + break; + case KeyPress: + { + char buffer[10]; + int r, code; + code = XLookupKeysym(&event.xkey, 0); + if (code == XK_Left) { + view_roty += 5.0; + } + else if (code == XK_Right) { + view_roty -= 5.0; + } + else if (code == XK_Up) { + view_rotx += 5.0; + } + else if (code == XK_Down) { + view_rotx -= 5.0; + } + else { + r = XLookupString(&event.xkey, buffer, sizeof(buffer), + NULL, NULL); + if (buffer[0] == 27) { + /* escape */ + return; + } + } + } + redraw = 1; + break; + default: + ; /*no-op*/ + } + + if (redraw) { + draw(); + eglSwapBuffers(egl_dpy, egl_surf); + } + } +} + + +static void +usage(void) +{ + printf("Usage:\n"); + printf(" -display set the display to run on\n"); + printf(" -info display OpenGL renderer info\n"); +} + + +int +main(int argc, char *argv[]) +{ + const int winWidth = 300, winHeight = 300; + Display *x_dpy; + Window win; + EGLSurface egl_surf; + EGLContext egl_ctx; + EGLDisplay egl_dpy; + char *dpyName = NULL; + GLboolean printInfo = GL_FALSE; + EGLint egl_major, egl_minor; + int i; + const char *s; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-display") == 0) { + dpyName = argv[i+1]; + i++; + } + else if (strcmp(argv[i], "-info") == 0) { + printInfo = GL_TRUE; + } + else { + usage(); + return -1; + } + } + + x_dpy = XOpenDisplay(dpyName); + if (!x_dpy) { + printf("Error: couldn't open display %s\n", + dpyName ? dpyName : getenv("DISPLAY")); + return -1; + } + + egl_dpy = eglGetDisplay(x_dpy); + if (!egl_dpy) { + printf("Error: eglGetDisplay() failed\n"); + return -1; + } + + if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) { + printf("Error: eglInitialize() failed\n"); + return -1; + } + + s = eglQueryString(egl_dpy, EGL_VERSION); + printf("EGL_VERSION = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_VENDOR); + printf("EGL_VENDOR = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_EXTENSIONS); + printf("EGL_EXTENSIONS = %s\n", s); + + s = eglQueryString(egl_dpy, EGL_CLIENT_APIS); + printf("EGL_CLIENT_APIS = %s\n", s); + + make_x_window(x_dpy, egl_dpy, + "OpenGL ES 2.x tri", 0, 0, winWidth, winHeight, + &win, &egl_ctx, &egl_surf); + + XMapWindow(x_dpy, win); + if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) { + printf("Error: eglMakeCurrent() failed\n"); + return -1; + } + + if (printInfo) { + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS)); + } + + init(); + + /* Set initial projection/viewing transformation. + * We can't be sure we'll get a ConfigureNotify event when the window + * first appears. + */ + reshape(winWidth, winHeight); + + event_loop(x_dpy, win, egl_dpy, egl_surf); + + eglDestroyContext(egl_dpy, egl_ctx); + eglDestroySurface(egl_dpy, egl_surf); + eglTerminate(egl_dpy); + + + XDestroyWindow(x_dpy, win); + XCloseDisplay(x_dpy); + + return 0; +} -- cgit v1.2.3 From 1af44e9e5a3b522dd083f7e1486146376b01fdff Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 3 Sep 2009 11:05:06 +0800 Subject: glapi: Add OpenGL ES compatibility mode to scripts. When the mode is on, the scripts would generate headers that are suitable for OpenGL ES. There are two differences. One is that they will generate function prototypes for OpenGL ES specific functions. The other is that, when a function has multiple names, SET/GET/CALL macros would be generated for each of names. Signed-off-by: Chia-I Wu --- src/mesa/glapi/gl_apitemp.py | 21 +++++++++++++++++---- src/mesa/glapi/gl_offsets.py | 25 +++++++++++++++++++++---- src/mesa/glapi/gl_procs.py | 37 ++++++++++++++++++++++++++++++++----- src/mesa/glapi/gl_table.py | 44 ++++++++++++++++++++++++++++++++++++++------ 4 files changed, 108 insertions(+), 19 deletions(-) diff --git a/src/mesa/glapi/gl_apitemp.py b/src/mesa/glapi/gl_apitemp.py index d4f8b1d8f8..09b0d364ce 100644 --- a/src/mesa/glapi/gl_apitemp.py +++ b/src/mesa/glapi/gl_apitemp.py @@ -30,7 +30,7 @@ import license import sys, getopt class PrintGlOffsets(gl_XML.gl_print_base): - def __init__(self): + def __init__(self, es=False): gl_XML.gl_print_base.__init__(self) self.name = "gl_apitemp.py (from Mesa)" @@ -38,6 +38,8 @@ class PrintGlOffsets(gl_XML.gl_print_base): """Copyright (C) 1999-2001 Brian Paul All Rights Reserved. (C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM") + self.es = es + self.undef_list.append( "KEYWORD1" ) self.undef_list.append( "KEYWORD1_ALT" ) self.undef_list.append( "KEYWORD2" ) @@ -82,7 +84,14 @@ class PrintGlOffsets(gl_XML.gl_print_base): else: dispatch = "DISPATCH" + need_proto = False if not f.is_static_entry_point(name): + need_proto = True + elif self.es: + cat, num = api.get_category_for_name(name) + if (cat.startswith("es") or cat.startswith("GL_OES")): + need_proto = True + if need_proto: print '%s %s KEYWORD2 NAME(%s)(%s);' % (keyword, f.return_type, n, f.get_parameter_string(name)) print '' @@ -286,22 +295,26 @@ static _glapi_proc UNUSED_TABLE_NAME[] = {""" def show_usage(): - print "Usage: %s [-f input_file_name]" % sys.argv[0] + print "Usage: %s [-f input_file_name] [-c]" % sys.argv[0] + print "-c Enable compatibility with OpenGL ES." sys.exit(1) if __name__ == '__main__': file_name = "gl_API.xml" try: - (args, trail) = getopt.getopt(sys.argv[1:], "f:") + (args, trail) = getopt.getopt(sys.argv[1:], "f:c") except Exception,e: show_usage() + es = False for (arg,val) in args: if arg == "-f": file_name = val + elif arg == "-c": + es = True api = gl_XML.parse_GL_API(file_name, glX_XML.glx_item_factory()) - printer = PrintGlOffsets() + printer = PrintGlOffsets(es) printer.Print(api) diff --git a/src/mesa/glapi/gl_offsets.py b/src/mesa/glapi/gl_offsets.py index b8b509d09f..54867b3463 100644 --- a/src/mesa/glapi/gl_offsets.py +++ b/src/mesa/glapi/gl_offsets.py @@ -30,9 +30,10 @@ import license import sys, getopt class PrintGlOffsets(gl_XML.gl_print_base): - def __init__(self): + def __init__(self, es=False): gl_XML.gl_print_base.__init__(self) + self.es = es self.name = "gl_offsets.py (from Mesa)" self.header_tag = '_GLAPI_OFFSETS_H_' self.license = license.bsd_license_template % ( \ @@ -46,6 +47,7 @@ class PrintGlOffsets(gl_XML.gl_print_base): functions = [] abi_functions = [] + alias_functions = [] count = 0 for f in api.functionIterateByOffset(): if not f.is_abi(): @@ -54,6 +56,10 @@ class PrintGlOffsets(gl_XML.gl_print_base): else: abi_functions.append( f ) + if self.es: + # remember functions with aliases + if len(f.entry_points) > 1: + alias_functions.append(f) for f in abi_functions: print '#define _gloffset_%s %d' % (f.name, f.offset) @@ -78,26 +84,37 @@ class PrintGlOffsets(gl_XML.gl_print_base): print '' print '#endif /* !defined(_GLAPI_USE_REMAP_TABLE) */' + if alias_functions: + print '' + print '/* define aliases for compatibility */' + for f in alias_functions: + for name in f.entry_points: + if name != f.name: + print '#define _gloffset_%s _gloffset_%s' % (name, f.name) return def show_usage(): - print "Usage: %s [-f input_file_name]" % sys.argv[0] + print "Usage: %s [-f input_file_name] [-c]" % sys.argv[0] + print " -c Enable compatibility with OpenGL ES." sys.exit(1) if __name__ == '__main__': file_name = "gl_API.xml" try: - (args, trail) = getopt.getopt(sys.argv[1:], "f:") + (args, trail) = getopt.getopt(sys.argv[1:], "f:c") except Exception,e: show_usage() + es = False for (arg,val) in args: if arg == "-f": file_name = val + elif arg == "-c": + es = True api = gl_XML.parse_GL_API( file_name ) - printer = PrintGlOffsets() + printer = PrintGlOffsets(es) printer.Print( api ) diff --git a/src/mesa/glapi/gl_procs.py b/src/mesa/glapi/gl_procs.py index cd1a68cee1..5de61fbdfe 100644 --- a/src/mesa/glapi/gl_procs.py +++ b/src/mesa/glapi/gl_procs.py @@ -30,9 +30,10 @@ import gl_XML, glX_XML import sys, getopt class PrintGlProcs(gl_XML.gl_print_base): - def __init__(self, long_strings): + def __init__(self, long_strings, es=False): gl_XML.gl_print_base.__init__(self) + self.es = es self.long_strings = long_strings self.name = "gl_procs.py (from Mesa)" self.license = license.bsd_license_template % ( \ @@ -141,6 +142,28 @@ typedef struct { print '%s GLAPIENTRY gl_dispatch_stub_%u(%s);' % (func.return_type, func.offset, func.get_parameter_string()) break + if self.es: + categories = {} + for func in api.functionIterateByOffset(): + for n in func.entry_points: + cat, num = api.get_category_for_name(n) + if (cat.startswith("es") or cat.startswith("GL_OES")): + if not categories.has_key(cat): + categories[cat] = [] + proto = 'GLAPI %s GLAPIENTRY %s(%s);' \ + % (func.return_type, "gl" + n, func.get_parameter_string(n)) + categories[cat].append(proto) + if categories: + print '' + print '/* OpenGL ES specific prototypes */' + print '' + keys = categories.keys() + keys.sort() + for key in keys: + print '/* category %s */' % key + print "\n".join(categories[key]) + print '' + print '#endif /* defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING) */' print '' @@ -155,8 +178,9 @@ typedef struct { def show_usage(): - print "Usage: %s [-f input_file_name] [-m mode]" % sys.argv[0] - print "mode can be one of:" + print "Usage: %s [-f input_file_name] [-m mode] [-c]" % sys.argv[0] + print "-c Enable compatibility with OpenGL ES." + print "-m mode mode can be one of:" print " long - Create code for compilers that can handle very" print " long string constants. (default)" print " short - Create code for compilers that can only handle" @@ -167,11 +191,12 @@ if __name__ == '__main__': file_name = "gl_API.xml" try: - (args, trail) = getopt.getopt(sys.argv[1:], "f:m:") + (args, trail) = getopt.getopt(sys.argv[1:], "f:m:c") except Exception,e: show_usage() long_string = 1 + es = False for (arg,val) in args: if arg == "-f": file_name = val @@ -182,7 +207,9 @@ if __name__ == '__main__': long_string = 1 else: show_usage() + elif arg == "-c": + es = True api = gl_XML.parse_GL_API(file_name, glX_XML.glx_item_factory()) - printer = PrintGlProcs(long_string) + printer = PrintGlProcs(long_string, es) printer.Print(api) diff --git a/src/mesa/glapi/gl_table.py b/src/mesa/glapi/gl_table.py index 698795fb0a..3bd7569e92 100644 --- a/src/mesa/glapi/gl_table.py +++ b/src/mesa/glapi/gl_table.py @@ -30,9 +30,10 @@ import license import sys, getopt class PrintGlTable(gl_XML.gl_print_base): - def __init__(self): + def __init__(self, es=False): gl_XML.gl_print_base.__init__(self) + self.es = es self.header_tag = '_GLAPI_TABLE_H_' self.name = "gl_table.py (from Mesa)" self.license = license.bsd_license_template % ( \ @@ -68,9 +69,10 @@ class PrintGlTable(gl_XML.gl_print_base): class PrintRemapTable(gl_XML.gl_print_base): - def __init__(self): + def __init__(self, es=False): gl_XML.gl_print_base.__init__(self) + self.es = es self.header_tag = '_GLAPI_DISPATCH_H_' self.name = "gl_table.py (from Mesa)" self.license = license.bsd_license_template % ("(C) Copyright IBM Corporation 2005", "IBM") @@ -115,6 +117,7 @@ class PrintRemapTable(gl_XML.gl_print_base): functions = [] abi_functions = [] + alias_functions = [] count = 0 for f in api.functionIterateByOffset(): if not f.is_abi(): @@ -123,6 +126,11 @@ class PrintRemapTable(gl_XML.gl_print_base): else: abi_functions.append( f ) + if self.es: + # remember functions with aliases + if len(f.entry_points) > 1: + alias_functions.append(f) + for f in abi_functions: print '#define CALL_%s(disp, parameters) (*((disp)->%s)) parameters' % (f.name, f.name) @@ -162,33 +170,57 @@ class PrintRemapTable(gl_XML.gl_print_base): print '' print '#endif /* !defined(_GLAPI_USE_REMAP_TABLE) */' + + if alias_functions: + print '' + print '/* define aliases for compatibility */' + for f in alias_functions: + for name in f.entry_points: + if name != f.name: + print '#define CALL_%s(disp, parameters) CALL_%s(disp, parameters)' % (name, f.name) + print '#define GET_%s(disp) GET_%s(disp)' % (name, f.name) + print '#define SET_%s(disp, fn) SET_%s(disp, fn)' % (name, f.name) + print '' + + print '#if defined(_GLAPI_USE_REMAP_TABLE)' + for f in alias_functions: + for name in f.entry_points: + if name != f.name: + print '#define %s_remap_index %s_remap_index' % (name, f.name) + print '#endif /* defined(_GLAPI_USE_REMAP_TABLE) */' + print '' + return def show_usage(): - print "Usage: %s [-f input_file_name] [-m mode]" % sys.argv[0] + print "Usage: %s [-f input_file_name] [-m mode] [-c]" % sys.argv[0] print " -m mode Mode can be 'table' or 'remap_table'." + print " -c Enable compatibility with OpenGL ES." sys.exit(1) if __name__ == '__main__': file_name = "gl_API.xml" try: - (args, trail) = getopt.getopt(sys.argv[1:], "f:m:") + (args, trail) = getopt.getopt(sys.argv[1:], "f:m:c") except Exception,e: show_usage() mode = "table" + es = False for (arg,val) in args: if arg == "-f": file_name = val elif arg == "-m": mode = val + elif arg == "-c": + es = True if mode == "table": - printer = PrintGlTable() + printer = PrintGlTable(es) elif mode == "remap_table": - printer = PrintRemapTable() + printer = PrintRemapTable(es) else: show_usage() -- cgit v1.2.3 From f1c7874cd95e19929030038a78d889ac095a122a Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 6 Nov 2009 16:49:04 +0800 Subject: mesa/es: Fix symbol conflicts and warnings. drawtex.c was listed in LOCAL_ES1_SOURCES twice. My mistake when merging the patches. Also, run gl_apitemp.py with -c to silence warnings and add target "install". Signed-off-by: Chia-I Wu --- src/mesa/es/Makefile | 3 +++ src/mesa/es/glapi/Makefile | 2 +- src/mesa/es/sources.mak | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mesa/es/Makefile b/src/mesa/es/Makefile index 42347d0b07..48b11a6ad2 100644 --- a/src/mesa/es/Makefile +++ b/src/mesa/es/Makefile @@ -107,6 +107,9 @@ clean: -rm -f depend -rm -f *~ +# nothing to install +install: + subdirs: make -C glapi make -C $(MESA) asm_subdirs diff --git a/src/mesa/es/glapi/Makefile b/src/mesa/es/glapi/Makefile index 5f2aa8225b..1e32af867d 100644 --- a/src/mesa/es/glapi/Makefile +++ b/src/mesa/es/glapi/Makefile @@ -52,7 +52,7 @@ endef $(call gen-glapi,-c) %/glapitemp.h: $(GLAPI)/gl_apitemp.py $(COMMON) - $(call gen-glapi) + $(call gen-glapi,-c) %/glprocs.h: $(GLAPI)/gl_procs.py $(COMMON) $(call gen-glapi,-c) diff --git a/src/mesa/es/sources.mak b/src/mesa/es/sources.mak index 11f735d52a..f00e41b011 100644 --- a/src/mesa/es/sources.mak +++ b/src/mesa/es/sources.mak @@ -4,7 +4,6 @@ include $(MESA)/sources.mak LOCAL_ES1_SOURCES := \ main/api_exec_es1.c \ - main/drawtex.c \ main/get_es1.c \ main/specials_es1.c \ main/drawtex.c \ -- cgit v1.2.3 From 37dca7955a55c0d1422dffa8a65d5b4ebe143d47 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 6 Nov 2009 15:17:15 +0800 Subject: mesa/es: Improve support for parallel execution of make. Running make with -j for the first time might fail because glapi headers haven't been generated. This commit should make it more reliable. Signed-off-by: Chia-I Wu --- src/mesa/es/Makefile | 14 ++++++++++---- src/mesa/es/glapi/Makefile | 6 +++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/mesa/es/Makefile b/src/mesa/es/Makefile index 48b11a6ad2..8cf2eaccab 100644 --- a/src/mesa/es/Makefile +++ b/src/mesa/es/Makefile @@ -110,11 +110,17 @@ clean: # nothing to install install: -subdirs: - make -C glapi - make -C $(MESA) asm_subdirs +glapi/glapi-stamp: + $(MAKE) -C glapi -depend: $(ES1_ALL_SOURCES) $(ES2_ALL_SOURCES) +subdirs: glapi/glapi-stamp + $(MAKE) -C $(MESA) asm_subdirs + +# remove generated sources because "depend" is checked even when "make clean" +DEPEND_SOURCES := $(filter-out $(GENERATED_SOURCES), $(ES1_ALL_SOURCES) $(ES2_ALL_SOURCES)) +DEPEND_SOURCES := $(filter-out glapi/%, $(DEPEND_SOURCES)) + +depend: glapi/glapi-stamp $(DEPEND_SOURCES) @echo "running $(MKDEP)" @touch depend @# MESA is "..", but luckily, directories are longer than 2 characters diff --git a/src/mesa/es/glapi/Makefile b/src/mesa/es/glapi/Makefile index 1e32af867d..1256be953d 100644 --- a/src/mesa/es/glapi/Makefile +++ b/src/mesa/es/glapi/Makefile @@ -30,7 +30,10 @@ ES2_DEPS = $(ES2_APIXML) base2_API.xml es2_EXT.xml es_EXT.xml \ ES1_OUTPUTS := $(addprefix $(ES1_OUTPUT_DIR)/, $(OUTPUTS)) ES2_OUTPUTS := $(addprefix $(ES2_OUTPUT_DIR)/, $(OUTPUTS)) -all: $(ES1_OUTPUTS) $(ES2_OUTPUTS) +all: glapi-stamp + +glapi-stamp: $(ES1_OUTPUTS) $(ES2_OUTPUTS) + @touch glapi-stamp $(ES1_OUTPUTS): APIXML := $(ES1_APIXML) $(ES2_OUTPUTS): APIXML := $(ES2_APIXML) @@ -86,5 +89,6 @@ verify_xml: @rm -f tmp.xml clean: + -rm -f glapi-stamp -rm -rf $(ES1_OUTPUT_DIR) $(ES2_OUTPUT_DIR) -rm -f *~ *.pyc *.pyo -- cgit v1.2.3 From 7fb41df2cbae4cf35d0f73c2261a9409a1367903 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 30 Oct 2009 14:09:09 +0800 Subject: mesa/main: linear_to_nonlinear is not always available. Signed-off-by: Chia-I Wu --- src/mesa/main/texgetimage.c | 62 +++++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index 2f88718933..4b0915b3b2 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -42,30 +42,6 @@ -#if FEATURE_EXT_texture_sRGB - -/** - * Convert a float value from linear space to a - * non-linear sRGB value in [0, 255]. - * Not terribly efficient. - */ -static INLINE GLfloat -linear_to_nonlinear(GLfloat cl) -{ - /* can't have values outside [0, 1] */ - GLfloat cs; - if (cl < 0.0031308f) { - cs = 12.92f * cl; - } - else { - cs = (GLfloat)(1.055 * _mesa_pow(cl, 0.41666) - 0.055); - } - return cs; -} - -#endif /* FEATURE_EXT_texture_sRGB */ - - /** * Can the given type represent negative values? */ @@ -233,6 +209,29 @@ get_tex_ycbcr(GLcontext *ctx, GLuint dimensions, } +#if FEATURE_EXT_texture_sRGB + + +/** + * Convert a float value from linear space to a + * non-linear sRGB value in [0, 255]. + * Not terribly efficient. + */ +static INLINE GLfloat +linear_to_nonlinear(GLfloat cl) +{ + /* can't have values outside [0, 1] */ + GLfloat cs; + if (cl < 0.0031308f) { + cs = 12.92f * cl; + } + else { + cs = (GLfloat)(1.055 * _mesa_pow(cl, 0.41666) - 0.055); + } + return cs; +} + + /** * glGetTexImagefor sRGB pixels; */ @@ -284,6 +283,21 @@ get_tex_srgb(GLcontext *ctx, GLuint dimensions, } +#else /* FEATURE_EXT_texture_sRGB */ + + +static INLINE void +get_tex_srgb(GLcontext *ctx, GLuint dimensions, + GLenum format, GLenum type, GLvoid *pixels, + const struct gl_texture_image *texImage) +{ + ASSERT_NO_FEATURE(); +} + + +#endif /* FEATURE_EXT_texture_sRGB */ + + /** * glGetTexImagefor RGBA, Luminance, etc. pixels. * This is the slow way since we use texture sampling. -- cgit v1.2.3 From 1046f70a7d0592aaf10837ff9d2523de53910a31 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 6 Nov 2009 17:11:43 +0800 Subject: gallium: Allow state trackers to install files. State trackers like es or vega need to install their libraries. Signed-off-by: Chia-I Wu --- src/gallium/state_trackers/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/Makefile b/src/gallium/state_trackers/Makefile index 265ca468c2..0900efc664 100644 --- a/src/gallium/state_trackers/Makefile +++ b/src/gallium/state_trackers/Makefile @@ -21,5 +21,9 @@ clean: rm -f `find . -name depend` -# Dummy install target install: + @for dir in $(SUBDIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir && $(MAKE) $@) || exit 1 ; \ + fi \ + done -- cgit v1.2.3 From 97ea8e9263814634d2f718c82fb58464d20683f8 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 6 Nov 2009 16:27:19 +0800 Subject: Add new config for OpenGL ES. Signed-off-by: Chia-I Wu --- Makefile | 1 + configs/linux-opengl-es | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 configs/linux-opengl-es diff --git a/Makefile b/Makefile index 4c4aba025e..5029f72367 100644 --- a/Makefile +++ b/Makefile @@ -126,6 +126,7 @@ linux-ia64-icc-static \ linux-icc \ linux-icc-static \ linux-llvm \ +linux-opengl-es \ linux-osmesa \ linux-osmesa-static \ linux-osmesa16 \ diff --git a/configs/linux-opengl-es b/configs/linux-opengl-es new file mode 100644 index 0000000000..2ba94b61de --- /dev/null +++ b/configs/linux-opengl-es @@ -0,0 +1,21 @@ +# Configuration for OpenGL ES on Linux + +include $(TOP)/configs/linux + +CONFIG_NAME = linux-opengl-es + +# Directories to build +LIB_DIR = lib +SRC_DIRS = egl mesa/es gallium gallium/winsys +PROGRAM_DIRS = es1/xegl es2/xegl + +# no mesa or egl drivers +DRIVER_DIRS = +EGL_DRIVERS_DIRS = + +GALLIUM_DRIVERS_DIRS = softpipe + +# build egl_softpipe.so +GALLIUM_WINSYS_DIRS = egl_xlib +# and libGLES*.so +GALLIUM_STATE_TRACKERS_DIRS = es -- cgit v1.2.3 From 9de051e85e8d118414b113ce6524b03456bcd6d9 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 9 Nov 2009 10:23:23 +0800 Subject: mesa/es: Add .gitignore. Signed-off-by: Chia-I Wu --- src/mesa/es/.gitignore | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/mesa/es/.gitignore diff --git a/src/mesa/es/.gitignore b/src/mesa/es/.gitignore new file mode 100644 index 0000000000..7643e9f0db --- /dev/null +++ b/src/mesa/es/.gitignore @@ -0,0 +1,5 @@ +glapi/glapi-es* +glapi/glapi-stamp +main/get_es*.c +main/api_exec_es*.c +objs-es* -- cgit v1.2.3 From 0b9f0ba7065c9cdbeaeac477c801dead001ab215 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 9 Nov 2009 10:33:04 +0800 Subject: progs/es: Add .gitignore. Signed-off-by: Chia-I Wu --- progs/es1/.gitignore | 8 ++++++++ progs/es2/.gitignore | 3 +++ 2 files changed, 11 insertions(+) create mode 100644 progs/es1/.gitignore create mode 100644 progs/es2/.gitignore diff --git a/progs/es1/.gitignore b/progs/es1/.gitignore new file mode 100644 index 0000000000..2e7946f4dd --- /dev/null +++ b/progs/es1/.gitignore @@ -0,0 +1,8 @@ +xegl/drawtex +xegl/es1_info +xegl/msaa +xegl/pbuffer +xegl/render_tex +xegl/torus +xegl/tri +xegl/two_win diff --git a/progs/es2/.gitignore b/progs/es2/.gitignore new file mode 100644 index 0000000000..7d5c16936c --- /dev/null +++ b/progs/es2/.gitignore @@ -0,0 +1,3 @@ +xegl/es2_info.c +xegl/es2_info +xegl/tri -- cgit v1.2.3 From 5f0ea53747c14b1cd9686bcf650b96504128116e Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 10 Nov 2009 13:10:55 +0800 Subject: egl_softpipe: Clean up Makefile. Fix generation of depend. Link to the dynamic libraries used. Signed-off-by: Chia-I Wu --- src/gallium/winsys/egl_xlib/Makefile | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/gallium/winsys/egl_xlib/Makefile b/src/gallium/winsys/egl_xlib/Makefile index 3efb7ed4af..06c1fb0b91 100644 --- a/src/gallium/winsys/egl_xlib/Makefile +++ b/src/gallium/winsys/egl_xlib/Makefile @@ -29,13 +29,7 @@ WINSYS_OBJECTS = $(WINSYS_SOURCES:.c=.o) LIBS = \ $(GALLIUM_DRIVERS) \ $(GALLIUM_AUXILIARIES) - -# XXX temporary (should create a separate lib with the GL API funcs and -# mesa code, as done for ES 1.x, 2.x, OpenVG, etc) -UNUSED_LIBS = \ - $(TOP)/src/mesa/libglapi.a \ - $(TOP)/src/mesa/libmesagallium.a \ - +LIB_DEPS = $(EGL_LIB_DEPS) -lm -lX11 LOCAL_CFLAGS = @@ -60,14 +54,15 @@ $(TOP)/$(LIB_DIR)/$(DRIVER_NAME): $(WINSYS_OBJECTS) $(LIBS) -noprefix \ -install $(TOP)/$(LIB_DIR) \ $(MKLIB_OPTIONS) $(WINSYS_OBJECTS) \ - -Wl,--whole-archive $(LIBS) -Wl,--no-whole-archive + -Wl,--whole-archive $(LIBS) -Wl,--no-whole-archive \ + $(LIB_DEPS) -depend: $(ALL_SOURCES) +depend: $(WINSYS_SOURCES) @ echo "running $(MKDEP)" @ rm -f depend # workaround oops on gutsy?!? @ touch depend - @ $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(ALL_SOURCES) \ + @ $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(WINSYS_SOURCES) \ > /dev/null 2>/dev/null -- cgit v1.2.3 From 4b9cc50345b5b10bb998ce5ce6f7cb37b72f354f Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 9 Nov 2009 10:54:19 +0800 Subject: st/egl: Allow APIs other than OpenGL. This is done by stopping linking to libmesagallium.a and removing DRI related stuff. The state tracker an application links to decides the API supported. Signed-off-by: Chia-I Wu --- src/gallium/state_trackers/egl/egl_tracker.c | 2 -- src/gallium/winsys/drm/intel/egl/Makefile | 29 ++++++++++++++++++---------- src/gallium/winsys/drm/intel/egl/dummy.c | 1 + src/gallium/winsys/drm/radeon/egl/Makefile | 28 +++++++++++++++++++-------- src/gallium/winsys/drm/radeon/egl/dummy.c | 1 + 5 files changed, 41 insertions(+), 20 deletions(-) create mode 100644 src/gallium/winsys/drm/intel/egl/dummy.c create mode 100644 src/gallium/winsys/drm/radeon/egl/dummy.c diff --git a/src/gallium/state_trackers/egl/egl_tracker.c b/src/gallium/state_trackers/egl/egl_tracker.c index 8d29bf490b..1ad0097786 100644 --- a/src/gallium/state_trackers/egl/egl_tracker.c +++ b/src/gallium/state_trackers/egl/egl_tracker.c @@ -167,8 +167,6 @@ drm_initialize(_EGLDriver *drv, _EGLDisplay *disp, EGLint *major, EGLint *minor) goto err_screen; dev->winsys = dev->screen->winsys; - driInitExtensions(NULL, NULL, GL_FALSE); - drm_update_res(dev); res = dev->res; if (res) diff --git a/src/gallium/winsys/drm/intel/egl/Makefile b/src/gallium/winsys/drm/intel/egl/Makefile index 1397e9f729..c9c92b69b6 100644 --- a/src/gallium/winsys/drm/intel/egl/Makefile +++ b/src/gallium/winsys/drm/intel/egl/Makefile @@ -2,7 +2,7 @@ TOP = ../../../../../.. GALLIUMDIR = ../../../.. include $(TOP)/configs/current -LIBNAME = EGL_i915.so +LIBNAME = egl_i915.so PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/egl/libegldrm.a \ @@ -11,19 +11,28 @@ PIPE_DRIVERS = \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/i915/libi915.a -DRIVER_SOURCES = +DRIVER_EXTRAS = -lm -lpthread -ldrm_intel -C_SOURCES = \ - $(COMMON_GALLIUM_SOURCES) \ - $(DRIVER_SOURCES) +OBJECTS = dummy.o -DRIVER_EXTRAS = -ldrm_intel +default: $(TOP)/$(LIB_DIR)/$(LIBNAME) -ASM_SOURCES = +$(TOP)/$(LIB_DIR)/$(LIBNAME): $(LIBNAME) + @mkdir -p $(TOP)/$(LIB_DIR) + $(INSTALL) $(LIBNAME) $(TOP)/$(LIB_DIR) -DRIVER_DEFINES = -I../gem $(shell pkg-config libdrm --atleast-version=2.3.1 \ - && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP") +$(LIBNAME): $(OBJECTS) $(GALLIUM_AUXILIARIES) $(PIPE_DRIVERS) Makefile + $(MKLIB) -noprefix -o $@ $(OBJECTS) \ + -Wl,--whole-archive $(PIPE_DRIVERS) -Wl,--no-whole-archive \ + -Wl,--start-group $(GALLIUM_AUXILIARIES) -Wl,--end-group \ + $(DRI_LIB_DEPS) $(DRIVER_EXTRAS) -include ../../Makefile.template +clean: + -rm -f *.o *.so *~ + +depend: symlinks: + +install: $(LIBNAME) + $(MINSTALL) -m 755 $(LIBNAME) $(INSTALL_DIR)/$(LIB_DIR) diff --git a/src/gallium/winsys/drm/intel/egl/dummy.c b/src/gallium/winsys/drm/intel/egl/dummy.c new file mode 100644 index 0000000000..58c7af84e0 --- /dev/null +++ b/src/gallium/winsys/drm/intel/egl/dummy.c @@ -0,0 +1 @@ +/* mklib expects at least one .o is given */ diff --git a/src/gallium/winsys/drm/radeon/egl/Makefile b/src/gallium/winsys/drm/radeon/egl/Makefile index 6a1448d1b9..2bd05a8175 100644 --- a/src/gallium/winsys/drm/radeon/egl/Makefile +++ b/src/gallium/winsys/drm/radeon/egl/Makefile @@ -2,7 +2,7 @@ TOP = ../../../../../.. GALLIUMDIR = ../../../.. include $(TOP)/configs/current -LIBNAME = EGL_r300.so +LIBNAME = egl_r300.so PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/egl/libegldrm.a \ @@ -11,16 +11,28 @@ PIPE_DRIVERS = \ $(TOP)/src/gallium/drivers/trace/libtrace.a \ $(TOP)/src/gallium/drivers/r300/libr300.a -DRIVER_SOURCES = +DRIVER_EXTRAS = -lm -lpthread -ldrm_radeon -C_SOURCES = \ - $(COMMON_GALLIUM_SOURCES) \ - $(DRIVER_SOURCES) +OBJECTS = dummy.o -DRIVER_EXTRAS = -ldrm_radeon +default: $(TOP)/$(LIB_DIR)/$(LIBNAME) -ASM_SOURCES = +$(TOP)/$(LIB_DIR)/$(LIBNAME): $(LIBNAME) + @mkdir -p $(TOP)/$(LIB_DIR) + $(INSTALL) $(LIBNAME) $(TOP)/$(LIB_DIR) -include ../../Makefile.template +$(LIBNAME): $(OBJECTS) $(GALLIUM_AUXILIARIES) $(PIPE_DRIVERS) Makefile + $(MKLIB) -noprefix -o $@ $(OBJECTS) \ + -Wl,--whole-archive $(PIPE_DRIVERS) -Wl,--no-whole-archive \ + -Wl,--start-group $(GALLIUM_AUXILIARIES) -Wl,--end-group \ + $(DRI_LIB_DEPS) $(DRIVER_EXTRAS) + +clean: + -rm -f *.o *.so *~ + +depend: symlinks: + +install: $(LIBNAME) + $(MINSTALL) -m 755 $(LIBNAME) $(INSTALL_DIR)/$(LIB_DIR) diff --git a/src/gallium/winsys/drm/radeon/egl/dummy.c b/src/gallium/winsys/drm/radeon/egl/dummy.c new file mode 100644 index 0000000000..58c7af84e0 --- /dev/null +++ b/src/gallium/winsys/drm/radeon/egl/dummy.c @@ -0,0 +1 @@ +/* mklib expects at least one .o is given */ -- cgit v1.2.3 From 381cbc71923288ed189504b5b784c551f88a1010 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 9 Nov 2009 11:13:38 +0800 Subject: progs/es1: Port egltri to OpenGL ES 1.1. This demo requires EGL_MESA_screen_surface to run. Signed-off-by: Chia-I Wu --- progs/es1/.gitignore | 1 + progs/es1/screen/Makefile | 28 +++++ progs/es1/screen/tri.c | 129 ++++++++++++++++++++++ progs/es1/screen/winsys.c | 272 ++++++++++++++++++++++++++++++++++++++++++++++ progs/es1/screen/winsys.h | 36 ++++++ 5 files changed, 466 insertions(+) create mode 100644 progs/es1/screen/Makefile create mode 100644 progs/es1/screen/tri.c create mode 100644 progs/es1/screen/winsys.c create mode 100644 progs/es1/screen/winsys.h diff --git a/progs/es1/.gitignore b/progs/es1/.gitignore index 2e7946f4dd..ac79ee48f2 100644 --- a/progs/es1/.gitignore +++ b/progs/es1/.gitignore @@ -1,3 +1,4 @@ +screen/tri xegl/drawtex xegl/es1_info xegl/msaa diff --git a/progs/es1/screen/Makefile b/progs/es1/screen/Makefile new file mode 100644 index 0000000000..27be054d89 --- /dev/null +++ b/progs/es1/screen/Makefile @@ -0,0 +1,28 @@ +# progs/es1/screen/Makefile + +TOP = ../../.. +include $(TOP)/configs/current + +ES1_CFLAGS = -I$(TOP)/include +ES1_LIBS = -L$(TOP)/$(LIB_DIR) -lEGL -lGLESv1_CM + +ES1_LIB_DEPS = \ + $(TOP)/$(LIB_DIR)/libEGL.so \ + $(TOP)/$(LIB_DIR)/libGLESv1_CM.so + +WINSYS_OBJS = winsys.o + +PROGRAMS = \ + tri + +.c.o: + $(CC) -c $(ES1_CFLAGS) $(CFLAGS) $< -o $@ + +default: $(PROGRAMS) + +tri: tri.o $(WINSYS_OBJS) $(ES1_LIB_DEPS) + $(CC) $(CFLAGS) -o $@ $@.o $(WINSYS_OBJS) $(ES1_LIBS) + +clean: + -rm -f *.o *~ + -rm -f $(PROGRAMS) diff --git a/progs/es1/screen/tri.c b/progs/es1/screen/tri.c new file mode 100644 index 0000000000..bab9499944 --- /dev/null +++ b/progs/es1/screen/tri.c @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2009 Chia-I Wu + * + * Based on egltri by + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 2008 Brian Paul All Rights Reserved. + * Copyright (C) 2008 Jakob Bornecrantz All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL 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. + */ + +#include +#include +#include +#include +#include "winsys.h" + +static GLfloat view_rotx = 0.0, view_roty = 0.0, view_rotz = 0.0; + +static void tri_init() +{ + glClearColor(0.4, 0.4, 0.4, 0.0); +} + +static void tri_reshape(int width, int height) +{ + GLfloat ar = (GLfloat) width / (GLfloat) height; + + glViewport(0, 0, (GLint) width, (GLint) height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustumf(-ar, ar, -1, 1, 5.0, 60.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -10.0); +} + +static void tri_draw(void *data) +{ + static const GLfloat verts[3][2] = { + { -1, -1 }, + { 1, -1 }, + { 0, 1 } + }; + static const GLfloat colors[3][4] = { + { 1, 0, 0, 1 }, + { 0, 1, 0, 1 }, + { 0, 0, 1, 1 } + }; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + glRotatef(view_rotx, 1, 0, 0); + glRotatef(view_roty, 0, 1, 0); + glRotatef(view_rotz, 0, 0, 1); + + { + glVertexPointer(2, GL_FLOAT, 0, verts); + glColorPointer(4, GL_FLOAT, 0, colors); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + + glDrawArrays(GL_TRIANGLES, 0, 3); + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + } + + glPopMatrix(); +} + +static void tri_run(void) +{ + winsysRun(3.0, tri_draw, NULL); +} + +int main(int argc, char *argv[]) +{ + EGLint width, height; + GLboolean printInfo = GL_FALSE; + int i; + + /* parse cmd line args */ + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-info") == 0) { + printInfo = GL_TRUE; + } + else { + printf("Warning: unknown parameter: %s\n", argv[i]); + } + } + + if (!winsysInitScreen()) + exit(1); + winsysQueryScreenSize(&width, &height); + + if (printInfo) { + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS)); + } + + tri_init(); + tri_reshape(width, height); + tri_run(); + + winsysFiniScreen(); + + return 0; +} diff --git a/progs/es1/screen/winsys.c b/progs/es1/screen/winsys.c new file mode 100644 index 0000000000..84d00471eb --- /dev/null +++ b/progs/es1/screen/winsys.c @@ -0,0 +1,272 @@ +/* + * Copyright (C) 2009 Chia-I Wu + * + * Based on eglgears by + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL 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. + */ + +#include +#include +#include +#include +#include + +#define EGL_EGLEXT_PROTOTYPES + +#include +#include + +#include "winsys.h" + +#define MAX_MODES 100 + +static struct { + EGLBoolean verbose; + + EGLDisplay dpy; + EGLConfig conf; + + EGLScreenMESA screen; + EGLModeMESA mode; + EGLint width, height; + + EGLContext ctx; + EGLSurface surf; +} screen; + + +static EGLBoolean +init_screen(void) +{ + EGLModeMESA modes[MAX_MODES]; + EGLint num_screens, num_modes; + EGLint width, height, best_mode; + EGLint i; + + if (!eglGetScreensMESA(screen.dpy, &screen.screen, 1, &num_screens) || + !num_screens) { + printf("eglGetScreensMESA failed\n"); + return EGL_FALSE; + } + + if (!eglGetModesMESA(screen.dpy, screen.screen, modes, MAX_MODES, + &num_modes) || + !num_modes) { + printf("eglGetModesMESA failed!\n"); + return EGL_FALSE; + } + + printf("Found %d modes:\n", num_modes); + + best_mode = 0; + width = 0; + height = 0; + for (i = 0; i < num_modes; i++) { + EGLint w, h; + eglGetModeAttribMESA(screen.dpy, modes[i], EGL_WIDTH, &w); + eglGetModeAttribMESA(screen.dpy, modes[i], EGL_HEIGHT, &h); + printf("%3d: %d x %d\n", i, w, h); + if (w > width && h > height) { + width = w; + height = h; + best_mode = i; + } + } + + screen.mode = modes[best_mode]; + screen.width = width; + screen.height = height; + + return EGL_TRUE; +} + + +static EGLBoolean +init_display(void) +{ + EGLint maj, min; + const char *exts; + const EGLint attribs[] = { + EGL_SURFACE_TYPE, 0x0, /* should be EGL_SCREEN_BIT_MESA */ + EGL_RENDERABLE_TYPE, 0x0, /* should be EGL_OPENGL_ES_BIT */ + EGL_NONE + }; + EGLint num_configs; + + screen.dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (!screen.dpy) { + printf("eglGetDisplay failed\n"); + return EGL_FALSE; + } + + if (!eglInitialize(screen.dpy, &maj, &min)) { + printf("eglInitialize failed\n"); + return EGL_FALSE; + } + + printf("EGL_VERSION = %s\n", eglQueryString(screen.dpy, EGL_VERSION)); + printf("EGL_VENDOR = %s\n", eglQueryString(screen.dpy, EGL_VENDOR)); + + exts = eglQueryString(screen.dpy, EGL_EXTENSIONS); + assert(exts); + + if (!strstr(exts, "EGL_MESA_screen_surface")) { + printf("EGL_MESA_screen_surface is not supported\n"); + return EGL_FALSE; + } + + if (!eglChooseConfig(screen.dpy, attribs, &screen.conf, 1, + &num_configs) || + !num_configs) { + printf("eglChooseConfig failed\n"); + return EGL_FALSE; + } + + return EGL_TRUE; +} + + +EGLBoolean +winsysInitScreen(void) +{ + EGLint surf_attribs[20]; + EGLint i; + EGLBoolean ok; + + if (!init_display()) + goto fail; + if (!init_screen()) + goto fail; + + /* create context */ + screen.ctx = eglCreateContext(screen.dpy, screen.conf, + EGL_NO_CONTEXT, NULL); + if (screen.ctx == EGL_NO_CONTEXT) { + printf("eglCreateContext failed\n"); + goto fail; + } + + i = 0; + surf_attribs[i++] = EGL_WIDTH; + surf_attribs[i++] = screen.width; + surf_attribs[i++] = EGL_HEIGHT; + surf_attribs[i++] = screen.height; + surf_attribs[i++] = EGL_NONE; + + /* create surface */ + printf("Using screen size: %d x %d\n", screen.width, screen.height); + screen.surf = eglCreateScreenSurfaceMESA(screen.dpy, screen.conf, + surf_attribs); + if (screen.surf == EGL_NO_SURFACE) { + printf("eglCreateScreenSurfaceMESA failed\n"); + goto fail; + } + + ok = eglMakeCurrent(screen.dpy, screen.surf, screen.surf, screen.ctx); + if (!ok) { + printf("eglMakeCurrent failed\n"); + goto fail; + } + + ok = eglShowScreenSurfaceMESA(screen.dpy, screen.screen, + screen.surf, screen.mode); + if (!ok) { + printf("eglShowScreenSurfaceMESA failed\n"); + goto fail; + } + + return EGL_TRUE; + +fail: + winsysFiniScreen(); + return EGL_FALSE; +} + + +EGLBoolean +winsysQueryScreenSize(EGLint *width, EGLint *height) +{ + if (!screen.dpy) + return EGL_FALSE; + + if (width) + *width = screen.width; + if (height) + *height = screen.height; + + return EGL_TRUE; +} + + +void +winsysFiniScreen(void) +{ + if (screen.dpy) { + eglMakeCurrent(screen.dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, + EGL_NO_CONTEXT); + if (screen.surf != EGL_NO_SURFACE) + eglDestroySurface(screen.dpy, screen.surf); + if (screen.ctx != EGL_NO_CONTEXT) + eglDestroyContext(screen.dpy, screen.ctx); + eglTerminate(screen.dpy); + + memset(&screen, 0, sizeof(screen)); + } +} + + +void +winsysSwapBuffers(void) +{ + eglSwapBuffers(screen.dpy, screen.surf); +} + + +/* return current time (in seconds) */ +double +winsysNow(void) +{ + struct timeval tv; + gettimeofday(&tv, NULL); + return (double) tv.tv_sec + tv.tv_usec / 1000000.0; +} + + +void +winsysRun(double seconds, void (*draw_frame)(void *data), void *data) +{ + double begin, end, last_frame, duration; + EGLint num_frames = 0; + + begin = winsysNow(); + end = begin + seconds; + + last_frame = begin; + while (last_frame < end) { + draw_frame(data); + winsysSwapBuffers(); + last_frame = winsysNow(); + num_frames++; + } + + duration = last_frame - begin; + printf("%d frames in %3.1f seconds = %6.3f FPS\n", + num_frames, duration, (double) num_frames / duration); +} diff --git a/progs/es1/screen/winsys.h b/progs/es1/screen/winsys.h new file mode 100644 index 0000000000..679c7e0bd6 --- /dev/null +++ b/progs/es1/screen/winsys.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2009 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL 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. + */ + +#ifndef _WINSYS_H_ +#define _WINSYS_H_ + +#include + +EGLBoolean winsysInitScreen(void); +EGLBoolean winsysQueryScreenSize(EGLint *width, EGLint *height); +void winsysFiniScreen(void); + +void winsysSwapBuffers(void); +double winsysNow(void); + +void winsysRun(double seconds, void (*draw_frame)(void *data), void *data); + +#endif /* _WINSYS_H_ */ -- cgit v1.2.3 From b30876658b27284ff0271ff821769179cbed2d97 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 9 Nov 2009 13:25:49 +0800 Subject: progs/es1: Port eglgears to OpenGL ES 1.1. This demo requires EGL_MESA_screen_surface to run. Signed-off-by: Chia-I Wu --- progs/es1/.gitignore | 1 + progs/es1/screen/Makefile | 4 + progs/es1/screen/gears.c | 374 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 379 insertions(+) create mode 100644 progs/es1/screen/gears.c diff --git a/progs/es1/.gitignore b/progs/es1/.gitignore index ac79ee48f2..4f1427531a 100644 --- a/progs/es1/.gitignore +++ b/progs/es1/.gitignore @@ -1,3 +1,4 @@ +screen/gears screen/tri xegl/drawtex xegl/es1_info diff --git a/progs/es1/screen/Makefile b/progs/es1/screen/Makefile index 27be054d89..4ba2f9a7dc 100644 --- a/progs/es1/screen/Makefile +++ b/progs/es1/screen/Makefile @@ -13,6 +13,7 @@ ES1_LIB_DEPS = \ WINSYS_OBJS = winsys.o PROGRAMS = \ + gears \ tri .c.o: @@ -20,6 +21,9 @@ PROGRAMS = \ default: $(PROGRAMS) +gears: gears.o $(WINSYS_OBJS) $(ES1_LIB_DEPS) + $(CC) $(CFLAGS) -o $@ $@.o $(WINSYS_OBJS) $(ES1_LIBS) + tri: tri.o $(WINSYS_OBJS) $(ES1_LIB_DEPS) $(CC) $(CFLAGS) -o $@ $@.o $(WINSYS_OBJS) $(ES1_LIBS) diff --git a/progs/es1/screen/gears.c b/progs/es1/screen/gears.c new file mode 100644 index 0000000000..c7625826b9 --- /dev/null +++ b/progs/es1/screen/gears.c @@ -0,0 +1,374 @@ +/* + * Copyright (C) 2009 Chia-I Wu + * + * Based on eglgears by + * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL 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. + */ + +#include +#include +#include +#include + +#include +#include "winsys.h" + +#ifndef M_PI +#define M_PI 3.14159265 +#endif + + +struct gear { + GLuint vbo; + GLfloat *vertices; + GLsizei stride; + + GLint num_teeth; +}; + +static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; +static struct gear gears[3]; +static GLfloat angle = 0.0; + +/* + * Initialize a gear wheel. + * + * Input: gear - gear to initialize + * inner_radius - radius of hole at center + * outer_radius - radius at center of teeth + * width - width of gear + * teeth - number of teeth + * tooth_depth - depth of tooth + */ +static void +init_gear(struct gear *gear, GLfloat inner_radius, GLfloat outer_radius, + GLfloat width, GLint teeth, GLfloat tooth_depth) +{ + GLfloat r0, r1, r2; + GLfloat a0, da; + GLint verts_per_tooth, total_verts, total_size; + GLint count, i; + GLfloat *verts; + + r0 = inner_radius; + r1 = outer_radius - tooth_depth / 2.0; + r2 = outer_radius + tooth_depth / 2.0; + + a0 = 2.0 * M_PI / teeth; + da = a0 / 4.0; + + gear->vbo = 0; + gear->vertices = NULL; + gear->stride = sizeof(GLfloat) * 6; /* XYZ + normal */ + gear->num_teeth = teeth; + + verts_per_tooth = 10 + 4; + total_verts = teeth * verts_per_tooth; + total_size = total_verts * gear->stride; + + verts = malloc(total_size); + if (!verts) { + printf("failed to allocate vertices\n"); + return; + } + +#define GEAR_VERT(r, n, sign) \ + do { \ + verts[count * 6 + 0] = (r) * vx[n]; \ + verts[count * 6 + 1] = (r) * vy[n]; \ + verts[count * 6 + 2] = (sign) * width * 0.5; \ + verts[count * 6 + 3] = normal[0]; \ + verts[count * 6 + 4] = normal[1]; \ + verts[count * 6 + 5] = normal[2]; \ + count++; \ + } while (0) + + count = 0; + for (i = 0; i < teeth; i++) { + GLfloat normal[3]; + GLfloat vx[5], vy[5]; + GLfloat u, v; + + normal[0] = 0.0; + normal[1] = 0.0; + normal[2] = 0.0; + + vx[0] = cos(i * a0 + 0 * da); + vy[0] = sin(i * a0 + 0 * da); + vx[1] = cos(i * a0 + 1 * da); + vy[1] = sin(i * a0 + 1 * da); + vx[2] = cos(i * a0 + 2 * da); + vy[2] = sin(i * a0 + 2 * da); + vx[3] = cos(i * a0 + 3 * da); + vy[3] = sin(i * a0 + 3 * da); + vx[4] = cos(i * a0 + 4 * da); + vy[4] = sin(i * a0 + 4 * da); + + /* outward faces of a tooth, 10 verts */ + normal[0] = vx[0]; + normal[1] = vy[0]; + GEAR_VERT(r1, 0, 1); + GEAR_VERT(r1, 0, -1); + + u = r2 * vx[1] - r1 * vx[0]; + v = r2 * vy[1] - r1 * vy[0]; + normal[0] = v; + normal[1] = -u; + GEAR_VERT(r2, 1, 1); + GEAR_VERT(r2, 1, -1); + + normal[0] = vx[0]; + normal[1] = vy[0]; + GEAR_VERT(r2, 2, 1); + GEAR_VERT(r2, 2, -1); + + u = r1 * vx[3] - r2 * vx[2]; + v = r1 * vy[3] - r2 * vy[2]; + normal[0] = v; + normal[1] = -u; + GEAR_VERT(r1, 3, 1); + GEAR_VERT(r1, 3, -1); + + normal[0] = vx[0]; + normal[1] = vy[0]; + GEAR_VERT(r1, 4, 1); + GEAR_VERT(r1, 4, -1); + + /* inside radius cylinder, 4 verts */ + normal[0] = -vx[4]; + normal[1] = -vy[4]; + GEAR_VERT(r0, 4, 1); + GEAR_VERT(r0, 4, -1); + + normal[0] = -vx[0]; + normal[1] = -vy[0]; + GEAR_VERT(r0, 0, 1); + GEAR_VERT(r0, 0, -1); + + assert(count % verts_per_tooth == 0); + } + assert(count == total_verts); +#undef GEAR_VERT + + gear->vertices = verts; + + /* setup VBO */ + glGenBuffers(1, &gear->vbo); + if (gear->vbo) { + glBindBuffer(GL_ARRAY_BUFFER, gear->vbo); + glBufferData(GL_ARRAY_BUFFER, total_size, verts, GL_STATIC_DRAW); + } +} + + +static void +draw_gear(const struct gear *gear) +{ + GLint i; + + if (!gear->vbo && !gear->vertices) { + printf("nothing to be drawn\n"); + return; + } + + if (gear->vbo) { + glBindBuffer(GL_ARRAY_BUFFER, gear->vbo); + glVertexPointer(3, GL_FLOAT, gear->stride, (const GLvoid *) 0); + glNormalPointer(GL_FLOAT, gear->stride, (const GLvoid *) (sizeof(GLfloat) * 3)); + } else { + glBindBuffer(GL_ARRAY_BUFFER, 0); + glVertexPointer(3, GL_FLOAT, gear->stride, gear->vertices); + glNormalPointer(GL_FLOAT, gear->stride, gear->vertices + 3); + } + + glEnableClientState(GL_VERTEX_ARRAY); + + for (i = 0; i < gear->num_teeth; i++) { + const GLint base = (10 + 4) * i; + GLushort indices[7]; + + glShadeModel(GL_FLAT); + + /* front face */ + indices[0] = base + 12; + indices[1] = base + 0; + indices[2] = base + 2; + indices[3] = base + 4; + indices[4] = base + 6; + indices[5] = base + 8; + indices[6] = base + 10; + + glNormal3f(0.0, 0.0, 1.0); + glDrawElements(GL_TRIANGLE_FAN, 7, GL_UNSIGNED_SHORT, indices); + + /* back face */ + indices[0] = base + 13; + indices[1] = base + 11; + indices[2] = base + 9; + indices[3] = base + 7; + indices[4] = base + 5; + indices[5] = base + 3; + indices[6] = base + 1; + + glNormal3f(0.0, 0.0, -1.0); + glDrawElements(GL_TRIANGLE_FAN, 7, GL_UNSIGNED_SHORT, indices); + + glEnableClientState(GL_NORMAL_ARRAY); + + /* outward face of a tooth */ + glDrawArrays(GL_TRIANGLE_STRIP, base, 10); + + /* inside radius cylinder */ + glShadeModel(GL_SMOOTH); + glDrawArrays(GL_TRIANGLE_STRIP, base + 10, 4); + + glDisableClientState(GL_NORMAL_ARRAY); + } + + glDisableClientState(GL_VERTEX_ARRAY); +} + + +static void +gears_draw(void *data) +{ + static const GLfloat red[4] = { 0.8, 0.1, 0.0, 1.0 }; + static const GLfloat green[4] = { 0.0, 0.8, 0.2, 1.0 }; + static const GLfloat blue[4] = { 0.2, 0.2, 1.0, 1.0 }; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glPushMatrix(); + glRotatef(view_rotx, 1.0, 0.0, 0.0); + glRotatef(view_roty, 0.0, 1.0, 0.0); + glRotatef(view_rotz, 0.0, 0.0, 1.0); + + glPushMatrix(); + glTranslatef(-3.0, -2.0, 0.0); + glRotatef(angle, 0.0, 0.0, 1.0); + + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, red); + draw_gear(&gears[0]); + + glPopMatrix(); + + glPushMatrix(); + glTranslatef(3.1, -2.0, 0.0); + glRotatef(-2.0 * angle - 9.0, 0.0, 0.0, 1.0); + + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, green); + draw_gear(&gears[1]); + + glPopMatrix(); + + glPushMatrix(); + glTranslatef(-3.1, 4.2, 0.0); + glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0); + + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blue); + draw_gear(&gears[2]); + + glPopMatrix(); + + glPopMatrix(); + + /* advance rotation for next frame */ + angle += 0.5; /* 0.5 degree per frame */ + if (angle > 3600.0) + angle -= 3600.0; +} + + +static void gears_fini(void) +{ + GLint i; + for (i = 0; i < 3; i++) { + struct gear *gear = &gears[i]; + if (gear->vbo) { + glDeleteBuffers(1, &gear->vbo); + gear->vbo = 0; + } + if (gear->vertices) { + free(gear->vertices); + gear->vertices = NULL; + } + } +} + + +static void gears_init(void) +{ + static const GLfloat pos[4] = { 5.0, 5.0, 10.0, 0.0 }; + + glLightfv(GL_LIGHT0, GL_POSITION, pos); + glEnable(GL_CULL_FACE); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_DEPTH_TEST); + glEnable(GL_NORMALIZE); + + init_gear(&gears[0], 1.0, 4.0, 1.0, 20, 0.7); + init_gear(&gears[1], 0.5, 2.0, 2.0, 10, 0.7); + init_gear(&gears[2], 1.3, 2.0, 0.5, 10, 0.7); +} + + +/* new window size or exposure */ +static void +gears_reshape(int width, int height) +{ + GLfloat h = (GLfloat) height / (GLfloat) width; + + glViewport(0, 0, (GLint) width, (GLint) height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustumf(-1.0, 1.0, -h, h, 5.0, 60.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -40.0); +} + + +static void gears_run(void) +{ + winsysRun(5.0, gears_draw, NULL); +} + + +int +main(int argc, char *argv[]) +{ + EGLint width, height; + + if (!winsysInitScreen()) + exit(1); + winsysQueryScreenSize(&width, &height); + + gears_init(); + gears_reshape(width, height); + gears_run(); + gears_fini(); + + winsysFiniScreen(); + + return 0; +} -- cgit v1.2.3 From 9f38553018552ccf85b390d63cb57c701bd233ad Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 10 Nov 2009 12:48:14 +0800 Subject: Update config linux-opengl-es. Build demos that require EGL_MESA_screen_surface, and build egl_i915.so that supports EGL_MESA_screen_surface. Signed-off-by: Chia-I Wu --- configs/linux-opengl-es | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/configs/linux-opengl-es b/configs/linux-opengl-es index 2ba94b61de..1254f0693d 100644 --- a/configs/linux-opengl-es +++ b/configs/linux-opengl-es @@ -7,7 +7,7 @@ CONFIG_NAME = linux-opengl-es # Directories to build LIB_DIR = lib SRC_DIRS = egl mesa/es gallium gallium/winsys -PROGRAM_DIRS = es1/xegl es2/xegl +PROGRAM_DIRS = es1/screen es1/xegl es2/xegl # no mesa or egl drivers DRIVER_DIRS = @@ -19,3 +19,9 @@ GALLIUM_DRIVERS_DIRS = softpipe GALLIUM_WINSYS_DIRS = egl_xlib # and libGLES*.so GALLIUM_STATE_TRACKERS_DIRS = es + +# build egl_i915.so +GALLIUM_DRIVERS_DIRS += trace i915 +GALLIUM_STATE_TRACKERS_DIRS += egl +GALLIUM_WINSYS_DIRS += drm +GALLIUM_WINSYS_DRM_DIRS = intel -- cgit v1.2.3 From 0c1a7bbe0d0c6727a432890164032188787e7e26 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 22 Nov 2009 20:09:06 +0800 Subject: mesa/es: Add APIspec.xml and its parser. APIspec.xml is based on APIspec.txt. The new format has less code duplications and should be easier to read. Signed-off-by: Chia-I Wu --- src/mesa/es/main/APIspec.dtd | 52 + src/mesa/es/main/APIspec.py | 601 ++++++ src/mesa/es/main/APIspec.xml | 4405 +++++++++++++++++++++++++++++++++++++++ src/mesa/es/main/APIspecutil.py | 262 +++ 4 files changed, 5320 insertions(+) create mode 100644 src/mesa/es/main/APIspec.dtd create mode 100644 src/mesa/es/main/APIspec.py create mode 100644 src/mesa/es/main/APIspec.xml create mode 100644 src/mesa/es/main/APIspecutil.py diff --git a/src/mesa/es/main/APIspec.dtd b/src/mesa/es/main/APIspec.dtd new file mode 100644 index 0000000000..efcfa31f10 --- /dev/null +++ b/src/mesa/es/main/APIspec.dtd @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mesa/es/main/APIspec.py b/src/mesa/es/main/APIspec.py new file mode 100644 index 0000000000..f07e4261fa --- /dev/null +++ b/src/mesa/es/main/APIspec.py @@ -0,0 +1,601 @@ +#!/usr/bin/python +# +# Copyright (C) 2009 Chia-I Wu +# +# 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 +# on the rights to use, copy, modify, merge, publish, distribute, sub +# license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL +# IBM AND/OR ITS SUPPLIERS 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. +""" +A parser for APIspec. +""" + +class SpecError(Exception): + """Error in the spec file.""" + + +class Spec(object): + """A Spec is an abstraction of the API spec.""" + + def __init__(self, doc): + self.doc = doc + + self.spec_node = doc.getRootElement() + self.tmpl_nodes = {} + self.api_nodes = {} + self.impl_node = None + + # parse + node = self.spec_node.children + while node: + if node.type == "element": + if node.name == "template": + self.tmpl_nodes[node.prop("name")] = node + elif node.name == "api": + self.api_nodes[node.prop("name")] = node + else: + raise SpecError("unexpected node %s in apispec" % + node.name) + node = node.next + + # find an implementation + for name, node in self.api_nodes.iteritems(): + if node.prop("implementation") == "true": + self.impl_node = node + break + if not self.impl_node: + raise SpecError("unable to find an implementation") + + def get_impl(self): + """Return the implementation.""" + return API(self, self.impl_node) + + def get_api(self, name): + """Return an API.""" + return API(self, self.api_nodes[name]) + + +class API(object): + """An API consists of categories and functions.""" + + def __init__(self, spec, api_node): + self.name = api_node.prop("name") + self.is_impl = (api_node.prop("implementation") == "true") + + self.categories = [] + self.functions = [] + + # parse + func_nodes = [] + node = api_node.children + while node: + if node.type == "element": + if node.name == "category": + cat = node.prop("name") + self.categories.append(cat) + elif node.name == "function": + func_nodes.append(node) + else: + raise SpecError("unexpected node %s in api" % node.name) + node = node.next + + # realize functions + for func_node in func_nodes: + tmpl_node = spec.tmpl_nodes[func_node.prop("template")] + try: + func = Function(tmpl_node, func_node, self.is_impl, + self.categories) + except SpecError, e: + func_name = func_node.prop("name") + raise SpecError("failed to parse %s: %s" % (func_name, e)) + self.functions.append(func) + + def match(self, func, conversions={}): + """Find a matching function in the API.""" + match = None + need_conv = False + for f in self.functions: + matched, conv = f.match(func, conversions) + if matched: + match = f + need_conv = conv + # exact match + if not need_conv: + break + return (match, need_conv) + + +class Function(object): + """Parse and realize a @@ -3674,8 +3679,6 @@ - - diff --git a/src/mesa/es/main/APIspecutil.py b/src/mesa/es/main/APIspecutil.py index 5bfb699ba7..27a8fe8a6d 100644 --- a/src/mesa/es/main/APIspecutil.py +++ b/src/mesa/es/main/APIspecutil.py @@ -59,8 +59,11 @@ def _ParseXML(filename, apiname): for func in api.functions: alias, need_conv = impl.match(func, conversions) if not alias: - print >>sys.stderr, "Error: unable to dispatch %s" % func.name + # external functions are manually dispatched + if not func.is_external: + print >>sys.stderr, "Error: unable to dispatch %s" % func.name alias = func + need_conv = False __functions[func.name] = func __aliases[func.name] = (alias, need_conv) diff --git a/src/mesa/es/main/es_cpaltex.c b/src/mesa/es/main/es_cpaltex.c index 0d6f7410c3..15b6ad3617 100644 --- a/src/mesa/es/main/es_cpaltex.c +++ b/src/mesa/es/main/es_cpaltex.c @@ -19,7 +19,7 @@ #include "GLES/glext.h" -void GL_APIENTRY _es_CompressedTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +void GL_APIENTRY _es_CompressedTexImage2DARB(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); void GL_APIENTRY _mesa_TexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); void GL_APIENTRY _mesa_CompressedTexImage2DARB(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); @@ -215,9 +215,9 @@ cpal_compressed_teximage2d(GLenum target, GLint level, void GL_APIENTRY -_es_CompressedTexImage2D(GLenum target, GLint level, GLenum internalFormat, - GLsizei width, GLsizei height, GLint border, - GLsizei imageSize, const GLvoid *data) +_es_CompressedTexImage2DARB(GLenum target, GLint level, GLenum internalFormat, + GLsizei width, GLsizei height, GLint border, + GLsizei imageSize, const GLvoid *data) { switch (internalFormat) { case GL_PALETTE4_RGB8_OES: diff --git a/src/mesa/es/main/es_fbo.c b/src/mesa/es/main/es_fbo.c index 545c46ca99..db53a1449f 100644 --- a/src/mesa/es/main/es_fbo.c +++ b/src/mesa/es/main/es_fbo.c @@ -10,14 +10,14 @@ #include "GLES2/gl2ext.h" -extern void GL_APIENTRY _es_RenderbufferStorage(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height); +extern void GL_APIENTRY _es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height); extern void GL_APIENTRY _mesa_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height); void GL_APIENTRY -_es_RenderbufferStorage(GLenum target, GLenum internalFormat, - GLsizei width, GLsizei height) +_es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, + GLsizei width, GLsizei height) { switch (internalFormat) { case GL_RGBA4: diff --git a/src/mesa/es/main/es_generator.py b/src/mesa/es/main/es_generator.py index 349e0faa35..590f5940a7 100644 --- a/src/mesa/es/main/es_generator.py +++ b/src/mesa/es/main/es_generator.py @@ -272,7 +272,13 @@ for funcName in keys: # We're allowed to override the prefix and/or the function name # for each function record, though. The "ConversionFunction" # utility is poorly named, BTW... - aliasprefix = apiutil.AliasPrefix(funcName) + if funcName in allSpecials: + # perform checks and pass through + funcPrefix = "_check_" + aliasprefix = "_es_" + else: + funcPrefix = "_es_" + aliasprefix = apiutil.AliasPrefix(funcName) alias = apiutil.ConversionFunction(funcName) if not alias: # There may still be a Mesa alias for the function @@ -562,8 +568,9 @@ for funcName in keys: # The Mesa functions are scattered across all the Mesa # header files. The easiest way to manage declarations # is to create them ourselves. - if funcName not in allSpecials: - print "extern %s GLAPIENTRY %s(%s);" % (returnType, passthroughFuncName, passthroughDeclarationString) + if funcName in allSpecials: + print "/* this function is special and is defined elsewhere */" + print "extern %s GLAPIENTRY %s(%s);" % (returnType, passthroughFuncName, passthroughDeclarationString) # A function may be a core function (i.e. it exists in # the core specification), a core addition (extension @@ -594,22 +601,25 @@ for funcName in keys: if len(compoundCategory) == 1: # This is a core function extensionName = None - fullFuncName = "_es_" + funcName + extensionSuffix = "" else: # This is an extension function. We'll need to append # the extension suffix. extensionName = compoundCategory[1] extensionSuffix = extensionName.split("_")[0] - fullFuncName = "_es_" + funcName + extensionSuffix + fullFuncName = funcPrefix + funcName + extensionSuffix # Now the generated function. The text used to mark an API-level # function, oddly, is version-specific. if extensionName: print "/* Extension %s */" % extensionName - if funcName in allSpecials: - print "/* this function is special and is defined elsewhere */" - print "extern %s %s(%s);" % (returnType, fullFuncName, declarationString) + if (not variables and + not switchCode and + not conversionCodeOutgoing and + not conversionCodeIncoming): + # pass through directly + print "#define %s %s" % (fullFuncName, passthroughFuncName) print continue @@ -661,6 +671,7 @@ print "void" print "_mesa_init_exec_table(struct _glapi_table *exec)" print "{" for func in keys: + prefix = "_es_" if func not in allSpecials else "_check_" for spec in apiutil.Categories(func): ext = spec.split(":") # version does not match @@ -670,5 +681,5 @@ for func in keys: if ext: suffix = ext[0].split("_")[0] entry += suffix - print " SET_%s(exec, _es_%s);" % (entry, entry) + print " SET_%s(exec, %s%s);" % (entry, prefix, entry) print "}" -- cgit v1.2.3 From 29bd20ad1452bdc43d4cb0e42db65cf1069615cf Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 23 Nov 2009 15:04:49 +0800 Subject: mesa/es: Add more extensions to glapi. This commit adds definitions of GL_OES_texture_half_float_linear, GL_OES_texture_float_linear GL_OES_texture_half_float, GL_OES_texture_float GL_OES_vertex_half_float GL_OES_vertex_type_10_10_10_2 GL_OES_get_program_binary GL_EXT_texture_compression_dxt1 GL_EXT_texture_format_BGRA8888 GL_EXT_texture_lod_bias GL_EXT_blend_minmax GL_EXT_read_format_bgra GL_EXT_multi_draw_arrays to glapi. Signed-off-by: Chia-I Wu --- src/mesa/es/glapi/es1_EXT.xml | 32 +++++++++++++++++++------------- src/mesa/es/glapi/es2_EXT.xml | 40 ++++++++++++++++++++++++++++++++++++++++ src/mesa/es/glapi/es_EXT.xml | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 13 deletions(-) diff --git a/src/mesa/es/glapi/es1_EXT.xml b/src/mesa/es/glapi/es1_EXT.xml index 7c7c585736..de4868cfd4 100644 --- a/src/mesa/es/glapi/es1_EXT.xml +++ b/src/mesa/es/glapi/es1_EXT.xml @@ -607,19 +607,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -690,4 +690,10 @@ + + + + + + diff --git a/src/mesa/es/glapi/es2_EXT.xml b/src/mesa/es/glapi/es2_EXT.xml index fef6368022..3615772b56 100644 --- a/src/mesa/es/glapi/es2_EXT.xml +++ b/src/mesa/es/glapi/es2_EXT.xml @@ -97,10 +97,24 @@ + + + + + + + + + + + + + + @@ -119,4 +133,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mesa/es/glapi/es_EXT.xml b/src/mesa/es/glapi/es_EXT.xml index 28f41ae09a..b76cda929a 100644 --- a/src/mesa/es/glapi/es_EXT.xml +++ b/src/mesa/es/glapi/es_EXT.xml @@ -80,4 +80,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From f88297b369e9c2d4521554d8a6c66e288eb3b178 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 23 Nov 2009 17:07:08 +0800 Subject: mesa/es: Add more exnteions to APIspec. This commit adds definitions of GL_EXT_texture_compression_dxt1 GL_EXT_texture_lod_bias GL_EXT_blend_minmax GL_EXT_multi_draw_arrays to APIspec.xml and get_gen.py. Some of the enums are not avaiable in the header files and the defining extensions are disabled. Signed-off-by: Chia-I Wu --- src/mesa/es/main/APIspec.xml | 147 ++++++++++++++++++++++++++++++++++++------- src/mesa/es/main/get_gen.py | 4 ++ 2 files changed, 130 insertions(+), 21 deletions(-) diff --git a/src/mesa/es/main/APIspec.xml b/src/mesa/es/main/APIspec.xml index d8d85e6645..8926007f8d 100644 --- a/src/mesa/es/main/APIspec.xml +++ b/src/mesa/es/main/APIspec.xml @@ -492,6 +492,19 @@ + + + + + + + + + + + + + @@ -1312,6 +1325,19 @@ + + + + + + + + + + + + + @@ -1675,7 +1701,8 @@ - + + @@ -2033,6 +2060,9 @@ + + + @@ -2050,6 +2080,9 @@ + + + @@ -2059,6 +2092,9 @@ + + + @@ -2363,22 +2399,28 @@ - - - - - - - - - - + + + + + + + + + + + + + + + + @@ -2417,16 +2459,8 @@ - - - - - - - - - - + + @@ -3420,6 +3454,54 @@ + + + + @@ -3685,6 +3767,10 @@ + + + + @@ -3718,7 +3804,13 @@ + + @@ -3973,6 +4065,10 @@ + + + + @@ -3994,6 +4090,11 @@ + + @@ -4188,6 +4289,10 @@ + + + + diff --git a/src/mesa/es/main/get_gen.py b/src/mesa/es/main/get_gen.py index 3303c4cb5b..9da0b6b742 100644 --- a/src/mesa/es/main/get_gen.py +++ b/src/mesa/es/main/get_gen.py @@ -468,6 +468,10 @@ StateVars_es1 = [ ("GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES", GLint, ["ctx->Array.ArrayObj->PointSize.BufferObj->Name"], "", None), + # GL_EXT_texture_lod_bias + ( "GL_MAX_TEXTURE_LOD_BIAS_EXT", GLfloat, + ["ctx->Const.MaxTextureLodBias"], "", ["EXT_texture_lod_bias"]), + # GL_EXT_texture_filter_anisotropic ( "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT", GLfloat, ["ctx->Const.MaxTextureMaxAnisotropy"], "", ["EXT_texture_filter_anisotropic"]), -- cgit v1.2.3 From 3a4d0811b43295519d771fa192bd3d28bd5312d5 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 23 Nov 2009 17:10:12 +0800 Subject: mesa/es: Clean up extension string. Add some new extensions and remove those that do not belong to OpenGL ES 2.0. Signed-off-by: Chia-I Wu --- src/mesa/es/main/specials_es1.c | 8 ++++++++ src/mesa/es/main/specials_es2.c | 10 ++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/mesa/es/main/specials_es1.c b/src/mesa/es/main/specials_es1.c index 548fb0f029..0ace2924b3 100644 --- a/src/mesa/es/main/specials_es1.c +++ b/src/mesa/es/main/specials_es1.c @@ -140,8 +140,16 @@ make_extension_string(const GLcontext *ctx, char *str) if (ctx->Extensions.EXT_texture_filter_anisotropic) len += append_extension(&str, "GL_EXT_texture_filter_anisotropic"); + /* some applications check this for NPOT support */ if (ctx->Extensions.ARB_texture_non_power_of_two) len += append_extension(&str, "GL_ARB_texture_non_power_of_two"); + + if (ctx->Extensions.EXT_texture_compression_s3tc) + len += append_extension(&str, "GL_EXT_texture_compression_dxt1"); + if (ctx->Extensions.EXT_texture_lod_bias) + len += append_extension(&str, "GL_EXT_texture_lod_bias"); + if (ctx->Extensions.EXT_blend_minmax) + len += append_extension(&str, "GL_EXT_blend_minmax"); if (ctx->Extensions.EXT_multi_draw_arrays) len += append_extension(&str, "GL_EXT_multi_draw_arrays"); diff --git a/src/mesa/es/main/specials_es2.c b/src/mesa/es/main/specials_es2.c index ef8c581618..e11ade9b94 100644 --- a/src/mesa/es/main/specials_es2.c +++ b/src/mesa/es/main/specials_es2.c @@ -86,21 +86,15 @@ make_extension_string(const GLcontext *ctx, char *str) { size_t len = 0; - /* Core additions */ - len += append_extension(&str, "GL_OES_single_precision"); - - /* Required extensions */ len += append_extension(&str, "GL_OES_compressed_paletted_texture"); if (ctx->Extensions.ARB_framebuffer_object) { - len += append_extension(&str, "GL_OES_framebuffer_object"); len += append_extension(&str, "GL_OES_depth24"); len += append_extension(&str, "GL_OES_depth32"); len += append_extension(&str, "GL_OES_fbo_render_mipmap"); len += append_extension(&str, "GL_OES_rgb8_rgba8"); len += append_extension(&str, "GL_OES_stencil1"); len += append_extension(&str, "GL_OES_stencil4"); - len += append_extension(&str, "GL_OES_stencil8"); } if (ctx->Extensions.EXT_vertex_array) @@ -123,6 +117,10 @@ make_extension_string(const GLcontext *ctx, char *str) if (ctx->Extensions.ARB_fragment_shader) len += append_extension(&str, "GL_OES_standard_derivatives"); + if (ctx->Extensions.EXT_texture_compression_s3tc) + len += append_extension(&str, "GL_EXT_texture_compression_dxt1"); + if (ctx->Extensions.EXT_blend_minmax) + len += append_extension(&str, "GL_EXT_blend_minmax"); if (ctx->Extensions.EXT_multi_draw_arrays) len += append_extension(&str, "GL_EXT_multi_draw_arrays"); -- cgit v1.2.3 From b80ec33f3559e9a14d08f84c8e369a0dc81b46d7 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 24 Nov 2009 10:28:27 +0800 Subject: mesa/es: Fix GL_OES_texture_cube_map support. Unlike in OpenGL, GL_OES_texture_cube_map says that all coordinates are changed the same time by the token GL_TEXTURE_GEN_STR_OES, and the initial mode is GL_REFLECTION_MAP_OES. Signed-off-by: Chia-I Wu --- src/mesa/es/main/APIspec.xml | 25 ++++++----- src/mesa/es/main/es_enable.c | 91 +++++++++++++++++++++++++++++++++++++++++ src/mesa/es/main/es_texgen.c | 73 +++++++++++++++++++++++++++++++++ src/mesa/es/main/get_gen.py | 11 ++--- src/mesa/es/main/specials_es1.c | 16 +++++++- src/mesa/es/sources.mak | 2 + 6 files changed, 199 insertions(+), 19 deletions(-) create mode 100644 src/mesa/es/main/es_enable.c create mode 100644 src/mesa/es/main/es_texgen.c diff --git a/src/mesa/es/main/APIspec.xml b/src/mesa/es/main/APIspec.xml index 8926007f8d..a7dbdc4249 100644 --- a/src/mesa/es/main/APIspec.xml +++ b/src/mesa/es/main/APIspec.xml @@ -3546,7 +3546,6 @@ - @@ -3873,12 +3872,12 @@ - - - - - - + + + + + + @@ -3892,8 +3891,8 @@ - - + + @@ -3932,15 +3931,15 @@ - - - + + + - + diff --git a/src/mesa/es/main/es_enable.c b/src/mesa/es/main/es_enable.c new file mode 100644 index 0000000000..351caacd77 --- /dev/null +++ b/src/mesa/es/main/es_enable.c @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2009 Chia-I Wu + * + * 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. + */ + +#include "GLES/gl.h" +#include "GLES/glext.h" + +#include "main/compiler.h" /* for ASSERT */ + + +#ifndef GL_TEXTURE_GEN_S +#define GL_TEXTURE_GEN_S 0x0C60 +#define GL_TEXTURE_GEN_T 0x0C61 +#define GL_TEXTURE_GEN_R 0x0C62 +#endif + + +extern void GL_APIENTRY _es_Disable(GLenum cap); +extern void GL_APIENTRY _es_Enable(GLenum cap); +extern GLboolean GL_APIENTRY _es_IsEnabled(GLenum cap); + +extern void GL_APIENTRY _mesa_Disable(GLenum cap); +extern void GL_APIENTRY _mesa_Enable(GLenum cap); +extern GLboolean GL_APIENTRY _mesa_IsEnabled(GLenum cap); + + +void GL_APIENTRY +_es_Disable(GLenum cap) +{ + switch (cap) { + case GL_TEXTURE_GEN_STR_OES: + /* disable S, T, and R at the same time */ + _mesa_Disable(GL_TEXTURE_GEN_S); + _mesa_Disable(GL_TEXTURE_GEN_T); + _mesa_Disable(GL_TEXTURE_GEN_R); + break; + default: + _mesa_Disable(cap); + break; + } +} + + +void GL_APIENTRY +_es_Enable(GLenum cap) +{ + switch (cap) { + case GL_TEXTURE_GEN_STR_OES: + /* enable S, T, and R at the same time */ + _mesa_Enable(GL_TEXTURE_GEN_S); + _mesa_Enable(GL_TEXTURE_GEN_T); + _mesa_Enable(GL_TEXTURE_GEN_R); + break; + default: + _mesa_Enable(cap); + break; + } +} + + +GLboolean GL_APIENTRY +_es_IsEnabled(GLenum cap) +{ + switch (cap) { + case GL_TEXTURE_GEN_STR_OES: + cap = GL_TEXTURE_GEN_S; + default: + break; + } + + return _mesa_IsEnabled(cap); +} diff --git a/src/mesa/es/main/es_texgen.c b/src/mesa/es/main/es_texgen.c new file mode 100644 index 0000000000..c29a0a7f13 --- /dev/null +++ b/src/mesa/es/main/es_texgen.c @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2009 Chia-I Wu + * + * 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. + */ + +#include "GLES/gl.h" +#include "GLES/glext.h" + +#include "main/compiler.h" /* for ASSERT */ + + +#ifndef GL_S +#define GL_S 0x2000 +#define GL_T 0x2001 +#define GL_R 0x2002 +#endif + + +extern void GL_APIENTRY _es_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params); +extern void GL_APIENTRY _es_TexGenf(GLenum coord, GLenum pname, GLfloat param); +extern void GL_APIENTRY _es_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params); + +extern void GL_APIENTRY _mesa_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params); +extern void GL_APIENTRY _mesa_TexGenf(GLenum coord, GLenum pname, GLfloat param); +extern void GL_APIENTRY _mesa_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params); + + +void GL_APIENTRY +_es_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params) +{ + ASSERT(coord == GL_TEXTURE_GEN_STR_OES); + _mesa_GetTexGenfv(GL_S, pname, params); +} + + +void GL_APIENTRY +_es_TexGenf(GLenum coord, GLenum pname, GLfloat param) +{ + ASSERT(coord == GL_TEXTURE_GEN_STR_OES); + /* set S, T, and R at the same time */ + _mesa_TexGenf(GL_S, pname, param); + _mesa_TexGenf(GL_T, pname, param); + _mesa_TexGenf(GL_R, pname, param); +} + + +void GL_APIENTRY +_es_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params) +{ + ASSERT(coord == GL_TEXTURE_GEN_STR_OES); + /* set S, T, and R at the same time */ + _mesa_TexGenfv(GL_S, pname, params); + _mesa_TexGenfv(GL_T, pname, params); + _mesa_TexGenfv(GL_R, pname, params); +} diff --git a/src/mesa/es/main/get_gen.py b/src/mesa/es/main/get_gen.py index 9da0b6b742..fee6670104 100644 --- a/src/mesa/es/main/get_gen.py +++ b/src/mesa/es/main/get_gen.py @@ -391,12 +391,9 @@ StateVars_es1 = [ # OES_texture_cube_map ( "GL_TEXTURE_CUBE_MAP_ARB", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB)"], "", None), - ( "GL_TEXTURE_GEN_S", GLboolean, + ( "GL_TEXTURE_GEN_STR_OES", GLboolean, + # S, T, and R are always set at the same time ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0)"], "", None), - ( "GL_TEXTURE_GEN_T", GLboolean, - ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & T_BIT) ? 1 : 0)"], "", None), - ( "GL_TEXTURE_GEN_R", GLboolean, - ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & R_BIT) ? 1 : 0)"], "", None), # ARB_multisample ( "GL_MULTISAMPLE_ARB", GLboolean, ["ctx->Multisample.Enabled"], "", ["ARB_multisample"] ), @@ -695,6 +692,10 @@ def EmitHeader(): #define GL_PALETTE8_RGB5_A1_OES 0x8B99 #endif +/* GL_OES_texture_cube_map */ +#ifndef GL_OES_texture_cube_map +#define GL_TEXTURE_GEN_STR_OES 0x8D60 +#endif #define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE ) #define FLOAT_TO_FIXED(F) ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : \\ diff --git a/src/mesa/es/main/specials_es1.c b/src/mesa/es/main/specials_es1.c index 0ace2924b3..a4f14490f3 100644 --- a/src/mesa/es/main/specials_es1.c +++ b/src/mesa/es/main/specials_es1.c @@ -195,5 +195,19 @@ _es_GetString(GLenum name) void _mesa_initialize_context_extra(GLcontext *ctx) { - /* nothing here */ + GLuint i; + + /** + * GL_OES_texture_cube_map says + * "Initially all texture generation modes are set to REFLECTION_MAP_OES" + */ + for (i = 0; i < MAX_TEXTURE_UNITS; i++) { + struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i]; + texUnit->GenS.Mode = GL_REFLECTION_MAP_NV; + texUnit->GenT.Mode = GL_REFLECTION_MAP_NV; + texUnit->GenR.Mode = GL_REFLECTION_MAP_NV; + texUnit->GenS._ModeBit = TEXGEN_REFLECTION_MAP_NV; + texUnit->GenT._ModeBit = TEXGEN_REFLECTION_MAP_NV; + texUnit->GenR._ModeBit = TEXGEN_REFLECTION_MAP_NV; + } } diff --git a/src/mesa/es/sources.mak b/src/mesa/es/sources.mak index f00e41b011..84fad26773 100644 --- a/src/mesa/es/sources.mak +++ b/src/mesa/es/sources.mak @@ -8,8 +8,10 @@ LOCAL_ES1_SOURCES := \ main/specials_es1.c \ main/drawtex.c \ main/es_cpaltex.c \ + main/es_enable.c \ main/es_fbo.c \ main/es_query_matrix.c \ + main/es_texgen.c \ main/stubs.c \ glapi/glapi-es1/main/enums.c -- cgit v1.2.3 From c4b9e1aa1a2f1fda9e5764e3f7dd1a268216df09 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 24 Nov 2009 12:11:26 +0800 Subject: mesa/es: Fix GL_RGB565 support in FBO. In GL_OES_framebuffer_object and OpenGL ES 2.0, GL_RGB565 is a valid internal format. Since it is not supported by the core, map it to GL_RGB5 as a workaround. Signed-off-by: Chia-I Wu --- src/mesa/es/main/APIspec.xml | 2 +- src/mesa/es/main/es_fbo.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/mesa/es/main/APIspec.xml b/src/mesa/es/main/APIspec.xml index a7dbdc4249..f6f33130b1 100644 --- a/src/mesa/es/main/APIspec.xml +++ b/src/mesa/es/main/APIspec.xml @@ -4041,7 +4041,7 @@ - + diff --git a/src/mesa/es/main/es_fbo.c b/src/mesa/es/main/es_fbo.c index db53a1449f..1803637830 100644 --- a/src/mesa/es/main/es_fbo.c +++ b/src/mesa/es/main/es_fbo.c @@ -10,6 +10,11 @@ #include "GLES2/gl2ext.h" +#ifndef GL_RGB5 +#define GL_RGB5 0x8050 +#endif + + extern void GL_APIENTRY _es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height); extern void GL_APIENTRY _mesa_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height); @@ -20,18 +25,13 @@ _es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height) { switch (internalFormat) { - case GL_RGBA4: - case GL_RGB5_A1: case GL_RGB565: - internalFormat = GL_RGBA; - break; - case GL_STENCIL_INDEX1_OES: - case GL_STENCIL_INDEX4_OES: - case GL_STENCIL_INDEX8: - internalFormat = GL_STENCIL_INDEX; + /* XXX this confuses GL_RENDERBUFFER_INTERNAL_FORMAT_OES */ + /* choose a closest format */ + internalFormat = GL_RGB5; break; default: - ; /* no op */ + break; } _mesa_RenderbufferStorageEXT(target, internalFormat, width, height); } -- cgit v1.2.3 From a316b700effd615fcc895d0a2e015356854c6f44 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 24 Nov 2009 12:21:03 +0800 Subject: mesa/es: Improve support for GL_OES_compressed_paletted_texture. Add error checking and fix handling of level (it should be negative). Besides, always use the palette entry format/type when calling _mesa_TexImage2D. It respects the base internal formats of the cpal formats, and is simpler and faster, except for cases where the unpack alignment needs to be changed. Signed-off-by: Chia-I Wu --- src/mesa/es/main/es_cpaltex.c | 275 ++++++++++++++++++++---------------------- 1 file changed, 133 insertions(+), 142 deletions(-) diff --git a/src/mesa/es/main/es_cpaltex.c b/src/mesa/es/main/es_cpaltex.c index 15b6ad3617..0c497774ff 100644 --- a/src/mesa/es/main/es_cpaltex.c +++ b/src/mesa/es/main/es_cpaltex.c @@ -7,210 +7,201 @@ /** - * Code to convert compressed/paletted texture images to ordinary 4-byte RGBA. + * Code to convert compressed/paletted texture images to ordinary images. * See the GL_OES_compressed_paletted_texture spec at * http://khronos.org/registry/gles/extensions/OES/OES_compressed_paletted_texture.txt + * + * XXX this makes it impossible to add hardware support... */ -#include -#include #include "GLES/gl.h" #include "GLES/glext.h" +#include "main/compiler.h" /* for ASSERT */ + void GL_APIENTRY _es_CompressedTexImage2DARB(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +void GL_APIENTRY _mesa_GetIntegerv(GLenum pname, GLint *params); +void GL_APIENTRY _mesa_PixelStorei(GLenum pname, GLint param); void GL_APIENTRY _mesa_TexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); void GL_APIENTRY _mesa_CompressedTexImage2DARB(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +void *_mesa_get_current_context(void); +void _mesa_error(void *ctx, GLenum error, const char *fmtString, ... ); + -static const struct { +static const struct cpal_format_info { + GLenum cpal_format; GLenum format; + GLenum type; GLuint palette_size; GLuint size; } formats[] = { - { GL_PALETTE4_RGB8_OES, 16, 3 }, - { GL_PALETTE4_RGBA8_OES, 16, 4 }, - { GL_PALETTE4_R5_G6_B5_OES, 16, 2 }, - { GL_PALETTE4_RGBA4_OES, 16, 2 }, - { GL_PALETTE4_RGB5_A1_OES, 16, 2 }, - { GL_PALETTE8_RGB8_OES, 256, 3 }, - { GL_PALETTE8_RGBA8_OES, 256, 4 }, - { GL_PALETTE8_R5_G6_B5_OES, 256, 2 }, - { GL_PALETTE8_RGBA4_OES, 256, 2 }, - { GL_PALETTE8_RGB5_A1_OES, 256, 2 } + { GL_PALETTE4_RGB8_OES, GL_RGB, GL_UNSIGNED_BYTE, 16, 3 }, + { GL_PALETTE4_RGBA8_OES, GL_RGBA, GL_UNSIGNED_BYTE, 16, 4 }, + { GL_PALETTE4_R5_G6_B5_OES, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 16, 2 }, + { GL_PALETTE4_RGBA4_OES, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 16, 2 }, + { GL_PALETTE4_RGB5_A1_OES, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 16, 2 }, + { GL_PALETTE8_RGB8_OES, GL_RGB, GL_UNSIGNED_BYTE, 256, 3 }, + { GL_PALETTE8_RGBA8_OES, GL_RGBA, GL_UNSIGNED_BYTE, 256, 4 }, + { GL_PALETTE8_R5_G6_B5_OES, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 256, 2 }, + { GL_PALETTE8_RGBA4_OES, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 256, 2 }, + { GL_PALETTE8_RGB5_A1_OES, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 256, 2 } }; /** - * Get a color/entry from the palette. Convert to GLubyte/RGBA format. + * Get a color/entry from the palette. */ -static void -get_palette_entry(GLenum format, const void *palette, GLuint index, - GLubyte rgba[4]) +static GLuint +get_palette_entry(const struct cpal_format_info *info, const GLubyte *palette, + GLuint index, GLubyte *pixel) { - switch (format) { - case GL_PALETTE4_RGB8_OES: - case GL_PALETTE8_RGB8_OES: - { - const GLubyte *pal = (const GLubyte *) palette; - rgba[0] = pal[index * 3 + 0]; - rgba[1] = pal[index * 3 + 1]; - rgba[2] = pal[index * 3 + 2]; - rgba[3] = 255; - } - break; - case GL_PALETTE4_RGBA8_OES: - case GL_PALETTE8_RGBA8_OES: - { - const GLubyte *pal = (const GLubyte *) palette; - rgba[0] = pal[index * 4 + 0]; - rgba[1] = pal[index * 4 + 1]; - rgba[2] = pal[index * 4 + 2]; - rgba[3] = pal[index * 4 + 3]; - } - break; - case GL_PALETTE4_R5_G6_B5_OES: - case GL_PALETTE8_R5_G6_B5_OES: - { - const GLushort *pal = (const GLushort *) palette; - const GLushort color = pal[index]; - rgba[0] = ((color >> 8) & 0xf8) | ((color >> 11) & 0x3); - rgba[1] = ((color >> 3) & 0xfc) | ((color >> 1 ) & 0x3); - rgba[2] = ((color << 3) & 0xf8) | ((color ) & 0x7); - rgba[3] = 255; - } - break; - case GL_PALETTE4_RGBA4_OES: - case GL_PALETTE8_RGBA4_OES: - { - const GLushort *pal = (const GLushort *) palette; - const GLushort color = pal[index]; - rgba[0] = ((color & 0xf000) >> 8) | ((color & 0xf000) >> 12); - rgba[1] = ((color & 0x0f00) >> 4) | ((color & 0x0f00) >> 8); - rgba[2] = ((color & 0x00f0) ) | ((color & 0x00f0) >> 4); - rgba[3] = ((color & 0x000f) << 4) | ((color & 0x000f) ); - } - break; - case GL_PALETTE4_RGB5_A1_OES: - case GL_PALETTE8_RGB5_A1_OES: - { - const GLushort *pal = (const GLushort *) palette; - const GLushort color = pal[index]; - rgba[0] = ((color >> 8) & 0xf8) | ((color >> 11) & 0x7); - rgba[1] = ((color >> 3) & 0xf8) | ((color >> 6) & 0x7); - rgba[2] = ((color << 2) & 0xf8) | ((color >> 1) & 0x7); - rgba[3] = (color & 0x1) * 255; - } - break; - default: - assert(0); - } + memcpy(pixel, palette + info->size * index, info->size); + return info->size; } /** - * Convert paletted texture to simple GLubyte/RGBA format. + * Convert paletted texture to color texture. */ static void -paletted_to_rgba(GLenum src_format, - const void *palette, - const void *indexes, - GLsizei width, GLsizei height, - GLubyte *rgba) +paletted_to_color(const struct cpal_format_info *info, const GLubyte *palette, + const void *indices, GLuint num_pixels, GLubyte *image) { - GLuint pal_ents, i; - - assert(src_format >= GL_PALETTE4_RGB8_OES); - assert(src_format <= GL_PALETTE8_RGB5_A1_OES); - assert(formats[src_format - GL_PALETTE4_RGB8_OES].format == src_format); + GLubyte *pix = image; + GLuint remain, i; - pal_ents = formats[src_format - GL_PALETTE4_RGB8_OES].palette_size; - - if (pal_ents == 16) { + if (info->palette_size == 16) { /* 4 bits per index */ - const GLubyte *ind = (const GLubyte *) indexes; + const GLubyte *ind = (const GLubyte *) indices; - if (width * height == 1) { - /* special case the only odd-sized image */ - GLuint index0 = ind[0] >> 4; - get_palette_entry(src_format, palette, index0, rgba); - return; - } /* two pixels per iteration */ - for (i = 0; i < width * height / 2; i++) { - GLuint index0 = ind[i] >> 4; - GLuint index1 = ind[i] & 0xf; - get_palette_entry(src_format, palette, index0, rgba + i * 8); - get_palette_entry(src_format, palette, index1, rgba + i * 8 + 4); + remain = num_pixels % 2; + for (i = 0; i < num_pixels / 2; i++) { + pix += get_palette_entry(info, palette, (ind[i] >> 4) & 0xf, pix); + pix += get_palette_entry(info, palette, ind[i] & 0xf, pix); + } + if (remain) { + get_palette_entry(info, palette, (ind[i] >> 4) & 0xf, pix); } } else { /* 8 bits per index */ - const GLubyte *ind = (const GLubyte *) indexes; - for (i = 0; i < width * height; i++) { - GLuint index = ind[i]; - get_palette_entry(src_format, palette, index, rgba + i * 4); - } + const GLubyte *ind = (const GLubyte *) indices; + for (i = 0; i < num_pixels; i++) + pix += get_palette_entry(info, palette, ind[i], pix); } } +static const struct cpal_format_info * +cpal_get_info(GLint level, GLenum internalFormat, + GLsizei width, GLsizei height, GLsizei imageSize) +{ + const struct cpal_format_info *info; + GLint lvl, num_levels; + GLsizei w, h, expect_size; + + info = &formats[internalFormat - GL_PALETTE4_RGB8_OES]; + ASSERT(info->cpal_format == internalFormat); + + if (level > 0) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, + "glCompressedTexImage2D(level=%d)", level); + return NULL; + } + + num_levels = -level + 1; + expect_size = info->palette_size * info->size; + for (lvl = 0; lvl < num_levels; lvl++) { + w = width >> lvl; + if (!w) + w = 1; + h = height >> lvl; + if (!h) + h = 1; + + if (info->palette_size == 16) + expect_size += (w * h + 1) / 2; + else + expect_size += w * h; + } + if (expect_size > imageSize) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, + "glCompressedTexImage2D(imageSize=%d)", imageSize); + return NULL; + } + return info; +} + /** * Convert a call to glCompressedTexImage2D() where internalFormat is a * compressed palette format into a regular GLubyte/RGBA glTexImage2D() call. */ static void -cpal_compressed_teximage2d(GLenum target, GLint level, - GLenum internalFormat, - GLsizei width, GLsizei height, - const void *pixels) +cpal_compressed_teximage2d(GLenum target, GLint level, GLenum internalFormat, + GLsizei width, GLsizei height, GLsizei imageSize, + const void *palette) { - GLuint pal_ents, pal_ent_size, pal_bytes; - const GLint num_levels = level + 1; - GLint lvl; - const GLubyte *indexes; + const struct cpal_format_info *info; + GLint lvl, num_levels; + const GLubyte *indices; + GLint saved_align, align; - assert(internalFormat >= GL_PALETTE4_RGB8_OES); - assert(internalFormat <= GL_PALETTE8_RGB5_A1_OES); - assert(formats[internalFormat - GL_PALETTE4_RGB8_OES].format == internalFormat); + info = cpal_get_info(level, internalFormat, width, height, imageSize); + if (!info) + return; - pal_ents = formats[internalFormat - GL_PALETTE4_RGB8_OES].palette_size; - pal_ent_size = formats[internalFormat - GL_PALETTE4_RGB8_OES].size; - pal_bytes = pal_ents * pal_ent_size; + info = &formats[internalFormat - GL_PALETTE4_RGB8_OES]; + ASSERT(info->cpal_format == internalFormat); + num_levels = -level + 1; /* first image follows the palette */ - indexes = (const GLubyte *) pixels + pal_bytes; + indices = (const GLubyte *) palette + info->palette_size * info->size; - /* No worries about glPixelStore state since the only supported parameter is - * GL_UNPACK_ALIGNMENT and it doesn't matter when unpacking GLubyte/RGBA. - */ + _mesa_GetIntegerv(GL_UNPACK_ALIGNMENT, &saved_align); + align = saved_align; for (lvl = 0; lvl < num_levels; lvl++) { - /* Allocate GLubyte/RGBA dest image buffer */ - GLubyte *rgba = (GLubyte *) malloc(width * height * 4); - - if (pixels) - paletted_to_rgba(internalFormat, pixels, indexes, width, height, rgba); + GLsizei w, h; + GLuint num_texels; + GLubyte *image = NULL; + + w = width >> lvl; + if (!w) + w = 1; + h = height >> lvl; + if (!h) + h = 1; + num_texels = w * h; + if (w * info->size % align) { + _mesa_PixelStorei(GL_UNPACK_ALIGNMENT, 1); + align = 1; + } - _mesa_TexImage2D(target, lvl, GL_RGBA, width, height, 0, - GL_RGBA, GL_UNSIGNED_BYTE, rgba); + /* allocate and fill dest image buffer */ + if (palette) { + image = (GLubyte *) malloc(num_texels * info->size); + paletted_to_color(info, palette, indices, num_texels, image); + } - free(rgba); + _mesa_TexImage2D(target, lvl, info->format, w, h, 0, + info->format, info->type, image); + if (image) + free(image); /* advance index pointer to point to next src mipmap */ - if (pal_ents == 4) - indexes += width * height / 2; + if (info->palette_size == 16) + indices += (num_texels + 1) / 2; else - indexes += width * height; - - /* next mipmap level size */ - if (width > 1) - width /= 2; - if (height > 1) - height /= 2; + indices += num_texels; } + + if (saved_align != align) + _mesa_PixelStorei(GL_UNPACK_ALIGNMENT, saved_align); } @@ -231,7 +222,7 @@ _es_CompressedTexImage2DARB(GLenum target, GLint level, GLenum internalFormat, case GL_PALETTE8_RGBA4_OES: case GL_PALETTE8_RGB5_A1_OES: cpal_compressed_teximage2d(target, level, internalFormat, - width, height, data); + width, height, imageSize, data); break; default: _mesa_CompressedTexImage2DARB(target, level, internalFormat, -- cgit v1.2.3 From 8e6774937f58fe12e300d3aa0f487b63fa88b10a Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 24 Nov 2009 14:34:17 +0800 Subject: progs/es1: Add compressed paletted texture tests to torus. The tests can be toggled by `t'. It will print current texture format and the size of the image. Signed-off-by: Chia-I Wu --- progs/es1/xegl/torus.c | 151 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 149 insertions(+), 2 deletions(-) diff --git a/progs/es1/xegl/torus.c b/progs/es1/xegl/torus.c index 634d12641c..9438a4fe59 100644 --- a/progs/es1/xegl/torus.c +++ b/progs/es1/xegl/torus.c @@ -22,9 +22,27 @@ #include - +static const struct { + GLenum internalFormat; + const char *name; + GLuint num_entries; + GLuint size; +} cpal_formats[] = { + { GL_PALETTE4_RGB8_OES, "GL_PALETTE4_RGB8_OES", 16, 3 }, + { GL_PALETTE4_RGBA8_OES, "GL_PALETTE4_RGBA8_OES", 16, 4 }, + { GL_PALETTE4_R5_G6_B5_OES, "GL_PALETTE4_R5_G6_B5_OES", 16, 2 }, + { GL_PALETTE4_RGBA4_OES, "GL_PALETTE4_RGBA4_OES", 16, 2 }, + { GL_PALETTE4_RGB5_A1_OES, "GL_PALETTE4_RGB5_A1_OES", 16, 2 }, + { GL_PALETTE8_RGB8_OES, "GL_PALETTE8_RGB8_OES", 256, 3 }, + { GL_PALETTE8_RGBA8_OES, "GL_PALETTE8_RGBA8_OES", 256, 4 }, + { GL_PALETTE8_R5_G6_B5_OES, "GL_PALETTE8_R5_G6_B5_OES", 256, 2 }, + { GL_PALETTE8_RGBA4_OES, "GL_PALETTE8_RGBA4_OES", 256, 2 }, + { GL_PALETTE8_RGB5_A1_OES, "GL_PALETTE8_RGB5_A1_OES", 256, 2 } +}; +#define NUM_CPAL_FORMATS (sizeof(cpal_formats) / sizeof(cpal_formats[0])) static GLfloat view_rotx = 0.0, view_roty = 0.0, view_rotz = 0.0; +static GLint tex_format = NUM_CPAL_FORMATS; static void @@ -163,7 +181,121 @@ reshape(int width, int height) } -static void +static GLint +make_cpal_texture(GLint idx) +{ +#define SZ 64 + GLenum internalFormat = GL_PALETTE4_RGB8_OES + idx; + GLenum Filter = GL_LINEAR; + GLubyte palette[256 * 4 + SZ * SZ]; + GLubyte *indices; + GLsizei image_size; + GLuint i, j; + GLuint packed_indices = 0; + + assert(cpal_formats[idx].internalFormat == internalFormat); + + /* init palette */ + switch (internalFormat) { + case GL_PALETTE4_RGB8_OES: + case GL_PALETTE8_RGB8_OES: + /* first entry */ + palette[0] = 255; + palette[1] = 255; + palette[2] = 255; + /* second entry */ + palette[3] = 127; + palette[4] = 127; + palette[5] = 127; + break; + case GL_PALETTE4_RGBA8_OES: + case GL_PALETTE8_RGBA8_OES: + /* first entry */ + palette[0] = 255; + palette[1] = 255; + palette[2] = 255; + palette[3] = 255; + /* second entry */ + palette[4] = 127; + palette[5] = 127; + palette[6] = 127; + palette[7] = 255; + break; + case GL_PALETTE4_R5_G6_B5_OES: + case GL_PALETTE8_R5_G6_B5_OES: + { + GLushort *pal = (GLushort *) palette; + /* first entry */ + pal[0] = (31 << 11 | 63 << 5 | 31); + /* second entry */ + pal[1] = (15 << 11 | 31 << 5 | 15); + } + break; + case GL_PALETTE4_RGBA4_OES: + case GL_PALETTE8_RGBA4_OES: + { + GLushort *pal = (GLushort *) palette; + /* first entry */ + pal[0] = (15 << 12 | 15 << 8 | 15 << 4 | 15); + /* second entry */ + pal[1] = (7 << 12 | 7 << 8 | 7 << 4 | 15); + } + break; + case GL_PALETTE4_RGB5_A1_OES: + case GL_PALETTE8_RGB5_A1_OES: + { + GLushort *pal = (GLushort *) palette; + /* first entry */ + pal[0] = (31 << 11 | 31 << 6 | 31 << 1 | 1); + /* second entry */ + pal[1] = (15 << 11 | 15 << 6 | 15 << 1 | 1); + } + break; + } + + image_size = cpal_formats[idx].size * cpal_formats[idx].num_entries; + indices = palette + image_size; + for (i = 0; i < SZ; i++) { + for (j = 0; j < SZ; j++) { + GLfloat d; + GLint index; + d = (i - SZ/2) * (i - SZ/2) + (j - SZ/2) * (j - SZ/2); + d = sqrt(d); + index = (d < SZ / 3) ? 0 : 1; + + if (cpal_formats[idx].num_entries == 16) { + /* 4-bit indices packed in GLubyte */ + packed_indices |= index << (4 * (1 - (j % 2))); + if (j % 2) { + *(indices + (i * SZ + j - 1) / 2) = packed_indices & 0xff; + packed_indices = 0; + image_size += 1; + } + } + else { + /* 8-bit indices */ + *(indices + i * SZ + j) = index; + image_size += 1; + } + } + } + + glActiveTexture(GL_TEXTURE0); /* unit 0 */ + glBindTexture(GL_TEXTURE_2D, 42); + glCompressedTexImage2D(GL_TEXTURE_2D, 0, internalFormat, SZ, SZ, 0, + image_size, palette); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, Filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, Filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); +#undef SZ + + return image_size; +} + + +static GLint make_texture(void) { #define SZ 64 @@ -199,6 +331,8 @@ make_texture(void) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); #undef SZ + + return sizeof(image); } @@ -369,6 +503,19 @@ event_loop(Display *dpy, Window win, else if (code == XK_Down) { view_rotx -= 5.0; } + else if (code == XK_t) { + GLint size; + tex_format = (tex_format + 1) % (NUM_CPAL_FORMATS + 1); + if (tex_format < NUM_CPAL_FORMATS) { + size = make_cpal_texture(tex_format); + printf("Using %s (%d bytes)\n", + cpal_formats[tex_format].name, size); + } + else { + size = make_texture(); + printf("Using uncompressed texture (%d bytes)\n", size); + } + } else { r = XLookupString(&event.xkey, buffer, sizeof(buffer), NULL, NULL); -- cgit v1.2.3 From 976c858acc36b5ec1bf03c24b10e8bae81c2a21f Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 23 Dec 2009 11:18:48 +0800 Subject: Clean up ES_FILES. Signed-off-by: Chia-I Wu --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 5029f72367..b74e8485ab 100644 --- a/Makefile +++ b/Makefile @@ -315,9 +315,9 @@ ES_FILES = \ $(DIRECTORY)/src/mesa/es/glapi/*.py \ $(DIRECTORY)/src/mesa/es/state_tracker/*.[ch] \ $(DIRECTORY)/src/mesa/es/main/*.[ch] \ + $(DIRECTORY)/src/mesa/es/main/*.xml \ $(DIRECTORY)/src/mesa/es/main/*.py \ - $(DIRECTORY)/src/mesa/es/main/*.txt \ - $(DIRECTORY)/src/mesa/es/main/es*_special \ + $(DIRECTORY)/src/mesa/es/main/*.dtd \ $(DIRECTORY)/src/mesa/es/Makefile \ $(DIRECTORY)/src/mesa/es/sources.mak \ -- cgit v1.2.3 From e5d351dcfde58777162552cf5cd2a9cd8299f4cd Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 23 Dec 2009 11:18:00 +0800 Subject: Add es state tracker to autoconf. mesa/es is needed in SRC_DIRS to build es state tracker. Signed-off-by: Chia-I Wu --- configure.ac | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index cc588d5fab..2984ee24a0 100644 --- a/configure.ac +++ b/configure.ac @@ -1154,14 +1154,22 @@ yes) test -d "$srcdir/src/gallium/state_trackers/$tracker" || \ AC_MSG_ERROR([state tracker '$tracker' doesn't exist]) - if test "$tracker" = egl && test "x$enable_egl" != xyes; then - AC_MSG_ERROR([cannot build egl state tracker without EGL library]) - fi - if test "$tracker" = xorg; then + case "$tracker" in + egl) + if test "x$enable_egl" != xyes; then + AC_MSG_ERROR([cannot build egl state tracker without EGL library]) + fi + ;; + xorg) PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1], HAVE_XEXTPROTO_71="yes"; DEFINES="$DEFINES -DHAVE_XEXTPROTO_71", HAVE_XEXTPROTO_71="no") - fi + ;; + es) + # mesa/es is required to build es state tracker + SRC_DIRS="mesa/es $SRC_DIRS" + ;; + esac done GALLIUM_STATE_TRACKERS_DIRS="$state_trackers" ;; -- cgit v1.2.3 From bffe94d48ac70d1498581d80f2cb3be78ccc24f4 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 5 Jan 2010 15:57:13 +0800 Subject: mesa/es: Fix build issue after merge. In cd6b8dd9e82fedc55d033131fbc0f8ee950567c8, color read/type fields are moved; Based on 068596c9a7e8d330ffdff8ad8700bd6093b5bdea and cc020425e929110613ddb405d3e82313d27a35ed, GLSL builtin library is autogenerated and GLSL libraries are built and used. Signed-off-by: Chia-I Wu --- configs/linux-opengl-es | 2 +- src/mesa/es/Makefile | 21 +++++++++++---------- src/mesa/es/main/get_gen.py | 5 +++-- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/configs/linux-opengl-es b/configs/linux-opengl-es index 1254f0693d..566cd758e3 100644 --- a/configs/linux-opengl-es +++ b/configs/linux-opengl-es @@ -6,7 +6,7 @@ CONFIG_NAME = linux-opengl-es # Directories to build LIB_DIR = lib -SRC_DIRS = egl mesa/es gallium gallium/winsys +SRC_DIRS = egl glsl mesa/es gallium gallium/winsys PROGRAM_DIRS = es1/screen es1/xegl es2/xegl # no mesa or egl drivers diff --git a/src/mesa/es/Makefile b/src/mesa/es/Makefile index 6a4756c1b5..ca38dc4aed 100644 --- a/src/mesa/es/Makefile +++ b/src/mesa/es/Makefile @@ -63,23 +63,23 @@ $(ES2_OBJ_DIR)/%.o: $(MESA)/%.c $(ES2_OBJ_DIR)/%.o: $(MESA)/%.S $(call es-compile,2) -libes1.a: $(ES1_OBJECTS) - @$(TOP)/bin/mklib -o es1 -static $(ES1_OBJECTS) +libes1.a: $(ES1_OBJECTS) $(GLSL_LIBS) + @$(MKLIB) -o es1 -static $(ES1_OBJECTS) $(GLSL_LIBS) -libes2.a: $(ES2_OBJECTS) - @$(TOP)/bin/mklib -o es2 -static $(ES1_OBJECTS) +libes2.a: $(ES2_OBJECTS) $(GLSL_LIBS) + @$(MKLIB) -o es2 -static $(ES1_OBJECTS) $(GLSL_LIBS) -libes1gallium.a: $(ES1_GALLIUM_OBJECTS) - @$(TOP)/bin/mklib -o es1gallium -static $(ES1_GALLIUM_OBJECTS) +libes1gallium.a: $(ES1_GALLIUM_OBJECTS) $(GLSL_LIBS) + @$(MKLIB) -o es1gallium -static $(ES1_GALLIUM_OBJECTS) $(GLSL_LIBS) -libes2gallium.a: $(ES2_GALLIUM_OBJECTS) - @$(TOP)/bin/mklib -o es2gallium -static $(ES2_GALLIUM_OBJECTS) +libes2gallium.a: $(ES2_GALLIUM_OBJECTS) $(GLSL_LIBS) + @$(MKLIB) -o es2gallium -static $(ES2_GALLIUM_OBJECTS) $(GLSL_LIBS) libes1api.a: $(ES1_API_OBJECTS) - @$(TOP)/bin/mklib -o es1api -static $(ES1_API_OBJECTS) + @$(MKLIB) -o es1api -static $(ES1_API_OBJECTS) libes2api.a: $(ES2_API_OBJECTS) - @$(TOP)/bin/mklib -o es2api -static $(ES2_API_OBJECTS) + @$(MKLIB) -o es2api -static $(ES2_API_OBJECTS) GENERATED_SOURCES := \ main/api_exec_es1.c \ @@ -115,6 +115,7 @@ glapi/glapi-stamp: subdirs: glapi/glapi-stamp $(MAKE) -C $(MESA) asm_subdirs + $(MAKE) -C $(MESA) glsl_builtin # remove generated sources because "depend" is checked even when "make clean" DEPEND_SOURCES := $(filter-out $(GENERATED_SOURCES), $(ES1_ALL_SOURCES) $(ES2_ALL_SOURCES)) diff --git a/src/mesa/es/main/get_gen.py b/src/mesa/es/main/get_gen.py index fee6670104..b820157be0 100644 --- a/src/mesa/es/main/get_gen.py +++ b/src/mesa/es/main/get_gen.py @@ -209,9 +209,9 @@ StateVars_common = [ # GL_OES_read_format ( "GL_IMPLEMENTATION_COLOR_READ_TYPE_OES", GLint, - ["ctx->Const.ColorReadType"], "", None), + ["_mesa_get_color_read_type(ctx)"], "", ["OES_read_format"] ), ( "GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES", GLint, - ["ctx->Const.ColorReadFormat"], "", None), + ["_mesa_get_color_read_format(ctx)"], "", ["OES_read_format"] ), # GL_OES_framebuffer_object ( "GL_FRAMEBUFFER_BINDING_EXT", GLint, ["ctx->DrawBuffer->Name"], "", @@ -655,6 +655,7 @@ def EmitHeader(): #include "main/mtypes.h" #include "main/state.h" #include "main/texcompress.h" +#include "main/framebuffer.h" /* ES1 tokens that should be in gl.h but aren't */ -- cgit v1.2.3 From 0ce5b128d750e18e1ac2120f7f0435f8f4952dde Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 5 Jan 2010 16:52:06 +0800 Subject: mesa/es: Update sources.mk. Add/remove files that are unused/used to the omit list. Finally, they should all be features that can be omitted. Signed-off-by: Chia-I Wu --- src/mesa/es/sources.mak | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/mesa/es/sources.mak b/src/mesa/es/sources.mak index 84fad26773..55bb31b80d 100644 --- a/src/mesa/es/sources.mak +++ b/src/mesa/es/sources.mak @@ -44,9 +44,11 @@ LOCAL_ES2_API_ASM := $(subst es1,es2, $(LOCAL_ES1_API_ASM)) LOCAL_ES2_INCLUDES := $(subst es1,es2, $(LOCAL_ES1_INCLUDES)) # MESA sources +# Ideally, the omit list should be replaced by features. MAIN_OMITTED := \ main/api_exec.c \ + main/condrender.c \ main/dlopen.c \ main/enums.c \ main/get.c @@ -68,10 +70,7 @@ STATETRACKER_OMITTED := \ STATETRACKER_SOURCES := $(filter-out $(STATETRACKER_OMITTED), $(STATETRACKER_SOURCES)) SHADER_OMITTED := \ - shader/atifragshader.c \ - shader/nvfragparse.c \ - shader/nvprogram.c \ - shader/nvvertparse.c + shader/atifragshader.c SHADER_SOURCES := $(filter-out $(SHADER_OMITTED), $(SHADER_SOURCES)) MESA_ES1_SOURCES := \ -- cgit v1.2.3 From 182c38281383a3c0798c427b3d1f338dbf1e0533 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 5 Jan 2010 16:15:25 +0800 Subject: st/es: Fix build issue after merge. In c847a13d38d4e8c5f4c386d060dcc8ec09e491a3, auxiliaries becomes a single library; In e388d62b4712bcd75cecad53f5ca20a2bb6f89b1, the default build is changed to have -fvisibility=hidden. Signed-off-by: Chia-I Wu --- src/gallium/state_trackers/es/Makefile | 32 ++++++++++++++------------------ src/gallium/state_trackers/es/st_es1.c | 4 +++- src/gallium/state_trackers/es/st_es2.c | 4 +++- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/gallium/state_trackers/es/Makefile b/src/gallium/state_trackers/es/Makefile index 41d4ccb1a6..b8ee0c8387 100644 --- a/src/gallium/state_trackers/es/Makefile +++ b/src/gallium/state_trackers/es/Makefile @@ -26,13 +26,6 @@ ES1_OBJECTS = st_es1.o ES2_OBJECTS = st_es2.o -# we only need the gallium libs that the state trackers directly use: -GALLIUM_LIBS = \ - $(TOP)/src/gallium/auxiliary/cso_cache/libcso_cache.a \ - $(TOP)/src/gallium/auxiliary/rtasm/librtasm.a \ - $(TOP)/src/gallium/auxiliary/tgsi/libtgsi.a \ - $(TOP)/src/gallium/auxiliary/util/libutil.a - ES1_LIBS = \ $(TOP)/src/mesa/es/libes1gallium.a \ $(TOP)/src/mesa/es/libes1api.a @@ -44,35 +37,36 @@ ES2_LIBS = \ SYS_LIBS = -lm -pthread +INCLUDE_DIRS = \ + -I$(TOP)/src/gallium/include + .c.o: - $(CC) -c $(CFLAGS) $< -o $@ + $(CC) -c $(INCLUDE_DIRS) $(DEFINES) $(CFLAGS) $< -o $@ # Default: make both GL ES 1.1 and GL ES 2.0 libraries default: $(TOP)/$(LIB_DIR)/$(GLES_1_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLES_2_LIB_NAME) # Make the shared libs -$(TOP)/$(LIB_DIR)/$(GLES_1_LIB_NAME): $(ES1_OBJECTS) $(ES1_LIBS) - $(TOP)/bin/mklib -o $(GLES_1_LIB) \ +$(TOP)/$(LIB_DIR)/$(GLES_1_LIB_NAME): $(ES1_OBJECTS) $(ES1_LIBS) $(GALLIUM_AUXILIARIES) + $(MKLIB) -o $(GLES_1_LIB) \ -major $(GLES_1_VERSION_MAJOR) \ -minor $(GLES_1_VERSION_MINOR) \ -patch $(GLES_1_VERSION_PATCH) \ - -install $(TOP)/$(LIB_DIR) \ + -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \ $(ES1_OBJECTS) \ -Wl,--whole-archive $(ES1_LIBS) -Wl,--no-whole-archive \ - -Wl,--start-group $(GALLIUM_LIBS) -Wl,--end-group \ - $(SYS_LIBS) + $(GALLIUM_AUXILIARIES) $(SYS_LIBS) -$(TOP)/$(LIB_DIR)/$(GLES_2_LIB_NAME): $(ES2_OBJECTS) $(ES1_LIBS) - $(TOP)/bin/mklib -o $(GLES_2_LIB) \ +$(TOP)/$(LIB_DIR)/$(GLES_2_LIB_NAME): $(ES2_OBJECTS) $(ES1_LIBS) $(GALLIUM_AUXILIARIES) + $(MKLIB) -o $(GLES_2_LIB) \ -major $(GLES_2_VERSION_MAJOR) \ -minor $(GLES_2_VERSION_MINOR) \ -patch $(GLES_2_VERSION_PATCH) \ - -install $(TOP)/$(LIB_DIR) \ + -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \ $(ES2_OBJECTS) \ -Wl,--whole-archive $(ES2_LIBS) -Wl,--no-whole-archive \ - -Wl,--start-group $(GALLIUM_LIBS) -Wl,--end-group \ - $(SYS_LIBS) + $(GALLIUM_AUXILIARIES) $(SYS_LIBS) install: default $(INSTALL) -d $(INSTALL_DIR)/include/GLES @@ -86,3 +80,5 @@ install: default clean: -rm -f *.o *~ -rm -f $(TOP)/$(LIB_DIR)/$(GLES_1_LIB_NAME)* $(TOP)/$(LIB_DIR)/$(GLES_2_LIB_NAME)* + +depend: diff --git a/src/gallium/state_trackers/es/st_es1.c b/src/gallium/state_trackers/es/st_es1.c index 7f0c038957..25bc53b21e 100644 --- a/src/gallium/state_trackers/es/st_es1.c +++ b/src/gallium/state_trackers/es/st_es1.c @@ -1 +1,3 @@ -const int st_api_OpenGL_ES1 = 1; +#include "pipe/p_compiler.h" + +PUBLIC const int st_api_OpenGL_ES1 = 1; diff --git a/src/gallium/state_trackers/es/st_es2.c b/src/gallium/state_trackers/es/st_es2.c index 78e3791fbe..171ea62b97 100644 --- a/src/gallium/state_trackers/es/st_es2.c +++ b/src/gallium/state_trackers/es/st_es2.c @@ -1 +1,3 @@ -const int st_api_OpenGL_ES2 = 1; +#include "pipe/p_compiler.h" + +PUBLIC const int st_api_OpenGL_ES2 = 1; -- cgit v1.2.3 From 3f3340ca16a07aff26a3bd27a7f5ae161d77b11d Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 11 Jan 2010 17:44:00 +0800 Subject: st/es: Clean up install target. Use DESTDIR and MINSTALL. Signed-off-by: Chia-I Wu --- src/gallium/state_trackers/es/Makefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gallium/state_trackers/es/Makefile b/src/gallium/state_trackers/es/Makefile index b8ee0c8387..095ffbb938 100644 --- a/src/gallium/state_trackers/es/Makefile +++ b/src/gallium/state_trackers/es/Makefile @@ -69,13 +69,13 @@ $(TOP)/$(LIB_DIR)/$(GLES_2_LIB_NAME): $(ES2_OBJECTS) $(ES1_LIBS) $(GALLIUM_AUXIL $(GALLIUM_AUXILIARIES) $(SYS_LIBS) install: default - $(INSTALL) -d $(INSTALL_DIR)/include/GLES - $(INSTALL) -m 644 $(TOP)/include/GLES/*.h $(INSTALL_DIR)/include/GLES - $(INSTALL) -d $(INSTALL_DIR)/include/GLES2 - $(INSTALL) -m 644 $(TOP)/include/GLES2/*.h $(INSTALL_DIR)/include/GLES2 - $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR) - $(INSTALL) $(TOP)/$(LIB_DIR)/libGLESv1* $(INSTALL_DIR)/$(LIB_DIR) - $(INSTALL) $(TOP)/$(LIB_DIR)/libGLESv2* $(INSTALL_DIR)/$(LIB_DIR) + $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GLES + $(INSTALL) -m 644 $(TOP)/include/GLES/*.h $(DESTDIR)$(INSTALL_DIR)/include/GLES + $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GLES2 + $(INSTALL) -m 644 $(TOP)/include/GLES2/*.h $(DESTDIR)$(INSTALL_DIR)/include/GLES2 + $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/libGLESv1* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/libGLESv2* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) clean: -rm -f *.o *~ -- cgit v1.2.3 From 99a37ed195801fd0a0b64a20f08c8d4f9d66137f Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 5 Jan 2010 17:39:05 +0800 Subject: configure.ac: Fix es state tracker build. mesa/es should be built before the es state trackers. This is done by separating those that need to be built early from SRC_DIRS to CORE_DIRS. The new variable is not exported, and will be prepended to SRC_DIRS. Signed-off-by: Chia-I Wu --- configure.ac | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 1f94248824..a5e181dbf4 100644 --- a/configure.ac +++ b/configure.ac @@ -419,7 +419,11 @@ esac dnl dnl Driver specific build directories dnl -SRC_DIRS="glsl mesa glew" + +dnl this variable will be prepended to SRC_DIRS and is not exported +CORE_DIRS="glsl mesa" + +SRC_DIRS="glew" GLU_DIRS="sgi" WINDOW_SYSTEM="" GALLIUM_DIRS="auxiliary drivers state_trackers" @@ -434,7 +438,7 @@ xlib) GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS xlib" ;; dri) - SRC_DIRS="glx/x11 $SRC_DIRS" + CORE_DIRS="glx/x11 $CORE_DIRS" DRIVER_DIRS="dri" WINDOW_SYSTEM="dri" GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm" @@ -1191,7 +1195,7 @@ yes) ;; es) # mesa/es is required to build es state tracker - SRC_DIRS="mesa/es $SRC_DIRS" + CORE_DIRS="$CORE_DIRS mesa/es" ;; esac done @@ -1306,6 +1310,8 @@ if test "x$enable_gallium_nouveau" = xyes; then GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nv04 nv10 nv20 nv30 nv40 nv50" fi +dnl prepend CORE_DIRS to SRC_DIRS +SRC_DIRS="$CORE_DIRS $SRC_DIRS" dnl Restore LDFLAGS and CPPFLAGS LDFLAGS="$_SAVE_LDFLAGS" -- cgit v1.2.3 From 43f67b61fd1020e7ec847c21e1dbae9544d463ec Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 11 Jan 2010 13:53:03 +0800 Subject: progs/es1: Bind texture image after rendering. Unlike FBO, eglBindTexImage is supposed to be called after rendering. Signed-off-by: Chia-I Wu --- progs/es1/xegl/render_tex.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/progs/es1/xegl/render_tex.c b/progs/es1/xegl/render_tex.c index 0d1027b712..0200fa4cb0 100644 --- a/progs/es1/xegl/render_tex.c +++ b/progs/es1/xegl/render_tex.c @@ -229,17 +229,19 @@ draw(EGLDisplay egl_dpy, EGLSurface egl_surf, EGLSurface egl_pbuf, printf("Error: eglMakeCurrent(pbuf) failed\n"); return; } - glBindTexture(GL_TEXTURE_2D, RenderTexture); - eglBindTexImage(egl_dpy, egl_pbuf, EGL_BACK_BUFFER); draw_torus_to_texture(); - eglReleaseTexImage(egl_dpy, egl_pbuf, EGL_BACK_BUFFER); /* draw textured quad to window */ if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) { printf("Error: eglMakeCurrent(pbuffer) failed\n"); return; } + + glBindTexture(GL_TEXTURE_2D, RenderTexture); + eglBindTexImage(egl_dpy, egl_pbuf, EGL_BACK_BUFFER); draw_textured_quad(); + eglReleaseTexImage(egl_dpy, egl_pbuf, EGL_BACK_BUFFER); + eglSwapBuffers(egl_dpy, egl_surf); /*printf("End draw\n");*/ -- cgit v1.2.3 From 76e726515aedab426a55a389d0a1132456932856 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 11 Jan 2010 14:00:39 +0800 Subject: progs/es2: Correctly set renderable type and client version. Correctly set EGL_RENDERABLE_TYPE and EGL_CONTEXT_CLIENT_VERSION for OpenGL ES 2.0. Because es2_info is copied from es1_info, the fix for it actually goes to es1_info. Signed-off-by: Chia-I Wu --- progs/es1/xegl/es1_info.c | 25 ++++++++++++++++++++----- progs/es2/xegl/Makefile | 4 ++-- progs/es2/xegl/tri.c | 1 + 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/progs/es1/xegl/es1_info.c b/progs/es1/xegl/es1_info.c index 963304de13..93816b5215 100644 --- a/progs/es1/xegl/es1_info.c +++ b/progs/es1/xegl/es1_info.c @@ -106,17 +106,22 @@ info(EGLDisplay egl_dpy) static void make_x_window(Display *x_dpy, EGLDisplay egl_dpy, const char *name, - int x, int y, int width, int height, + int x, int y, int width, int height, int es_ver, Window *winRet, EGLContext *ctxRet, EGLSurface *surfRet) { - static const EGLint attribs[] = { + EGLint attribs[] = { + EGL_RENDERABLE_TYPE, 0x0, EGL_RED_SIZE, 1, EGL_GREEN_SIZE, 1, EGL_BLUE_SIZE, 1, EGL_NONE }; + EGLint ctx_attribs[] = { + EGL_CONTEXT_CLIENT_VERSION, 0, + EGL_NONE + }; int scrnum; XSetWindowAttributes attr; @@ -133,6 +138,12 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy, scrnum = DefaultScreen( x_dpy ); root = RootWindow( x_dpy, scrnum ); + if (es_ver == 1) + attribs[1] = EGL_OPENGL_ES_BIT; + else + attribs[1] = EGL_OPENGL_ES2_BIT; + ctx_attribs[1] = es_ver; + if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) { printf("Error: couldn't get an EGL visual config\n"); exit(1); @@ -180,7 +191,7 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy, eglBindAPI(EGL_OPENGL_ES_API); - ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL ); + ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs ); if (!ctx) { printf("Error: eglCreateContext failed\n"); exit(1); @@ -218,7 +229,7 @@ main(int argc, char *argv[]) EGLContext egl_ctx; EGLDisplay egl_dpy; char *dpyName = NULL; - EGLint egl_major, egl_minor; + EGLint egl_major, egl_minor, es_ver; int i; for (i = 1; i < argc; i++) { @@ -250,8 +261,12 @@ main(int argc, char *argv[]) return -1; } + es_ver = 1; + /* decide the version from the executable's name */ + if (argc > 0 && argv[0] && strstr(argv[0], "es2")) + es_ver = 2; make_x_window(x_dpy, egl_dpy, - "ES info", 0, 0, winWidth, winHeight, + "ES info", 0, 0, winWidth, winHeight, es_ver, &win, &egl_ctx, &egl_surf); /*XMapWindow(x_dpy, win);*/ diff --git a/progs/es2/xegl/Makefile b/progs/es2/xegl/Makefile index 88bb0127f8..5bb167c1c6 100644 --- a/progs/es2/xegl/Makefile +++ b/progs/es2/xegl/Makefile @@ -33,8 +33,8 @@ default: $(PROGRAMS) -es2_info.c: - cp ../../es1/xegl/es1_info.c es2_info.c +es2_info.c: ../../es1/xegl/es1_info.c + cp -f $^ $@ es2_info: es2_info.o $(ES2_LIB_DEPS) $(CC) $(CFLAGS) es2_info.o $(ES2_LIBS) -o $@ diff --git a/progs/es2/xegl/tri.c b/progs/es2/xegl/tri.c index eb52b10620..7729a09957 100644 --- a/progs/es2/xegl/tri.c +++ b/progs/es2/xegl/tri.c @@ -242,6 +242,7 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy, EGL_GREEN_SIZE, 1, EGL_BLUE_SIZE, 1, EGL_DEPTH_SIZE, 1, + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_NONE }; static const EGLint ctx_attribs[] = { -- cgit v1.2.3 From d8299af4ab6fe4b334292e3b6e69e4331c05d86f Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 11 Jan 2010 18:25:03 +0800 Subject: docs: Add documentation for OpenGL ES. Signed-off-by: Chia-I Wu --- docs/opengles.html | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 docs/opengles.html diff --git a/docs/opengles.html b/docs/opengles.html new file mode 100644 index 0000000000..d460bccf6c --- /dev/null +++ b/docs/opengles.html @@ -0,0 +1,78 @@ + + +OpenGL ES State Trackers + + + + + +

OpenGL ES State Trackers

+ +

The current version of the OpenGL ES state trackers implement OpenGL ES 1.1 and OpenGL ES 2.0. +More informations about OpenGL ES can be found at +http://www.khronos.org/opengles/.

+ +

The OpenGL ES state trackers depends on the Gallium architecture and a +working EGL implementation.

+ + +

Build the Libraries

+
    +
  1. Run configure with --with-state-trackers=egl_g3d,es and enable the Gallium driver for your hardware.
  2. +
  3. Build and install Mesa as usual.
  4. +
+ +

It will install libGLESv1_CM, libGLESv2, libEGL, and one or more EGL drivers for your hardware.

+

Run the Demos

+ +

There are some demos in progs/es1/ and progs/es2/. You can use them to test your build. For example,

+ +
+  $ export EGL_DRIVER=/usr/local/lib/dri/egl_x11_i915.so # specify the EGL driver
+  $ cd progs/es1/xegl
+  $ make
+  $ ./torus
+
+ +

Developers

+ +

The core of OpenGL ES state trackers is the ES overlay. It is located in +src/mesa/es/.

+ +

Structure

+ +

The ES overlay uses as much code as possible from Mesa. It has its own glapi XMLs to describe the APIs of OpenGL ES. The ES overlay can be built parallelly with Mesa, and they will give

+ + + + + + + + + +
Library NameUsageSource
libmesagallium.aOpenGL state trackerMesa
libes1gallium.aOpenGL ES 1.x state trackerES overlay
libes2gallium.aOpenGL ES 2.x state trackerES overlay
libglapi.aOpenGL APIMesa
libes1api.aOpenGL ES 1.x APIES overlay
libes2api.aOpenGL ES 2.x APIES overlay
+ +

The OpenGL ES state trackers and APIs are then used by src/gallium/state_trackers/es/ to create the final libraries.

+ +

Dispatch Table

+ +

The ES overlay uses an additional indirection when dispatching fucntions

+ +
+  Mesa:       glFoo() --> _mesa_Foo()
+  ES overlay: glFoo() --> _es_Foo() --> _mesa_Foo()
+
+ +

The indirection serves several purposes

+ +
    +
  • When a function is in Mesa and the type matches, it checks the arguments and calls the Mesa function.
  • +
  • When a function is in Mesa but the type mismatches, it checks and converts the arguments before calling the Mesa function.
  • +
  • When a function is not available in Mesa, or accepts arguments that are not available in OpenGL, it provides its own implementation.
  • +
+ +

Other than the last case, the ES overlay uses APIspec.xml to generate functions to check and/or converts the arguments.

+ + + -- cgit v1.2.3 From 6890b0698254051f366e0083eee40ed42613c58c Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 14 Jan 2010 17:54:47 -0800 Subject: st/mesa: Remove unnecessary headers from st_gen_mipmap.c. --- src/mesa/state_tracker/st_gen_mipmap.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index 2d404d5f42..cffb880a74 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -44,9 +44,7 @@ #include "st_debug.h" #include "st_context.h" -#include "st_draw.h" #include "st_gen_mipmap.h" -#include "st_program.h" #include "st_texture.h" #include "st_cb_texture.h" #include "st_inlines.h" -- cgit v1.2.3 From eaedc1bb3e651884a184f520bd81aa12c569c29b Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 14 Jan 2010 18:10:06 -0800 Subject: st/mesa: Remove unnecessary headers from st_framebuffer.c. --- src/mesa/state_tracker/st_framebuffer.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c index a5d1ae3b03..835142e3d4 100644 --- a/src/mesa/state_tracker/st_framebuffer.c +++ b/src/mesa/state_tracker/st_framebuffer.c @@ -30,15 +30,11 @@ #include "main/buffers.h" #include "main/context.h" #include "main/framebuffer.h" -#include "main/matrix.h" #include "main/renderbuffer.h" -#include "main/scissor.h" -#include "main/viewport.h" #include "st_context.h" #include "st_cb_fbo.h" #include "st_public.h" #include "pipe/p_defines.h" -#include "pipe/p_context.h" struct st_framebuffer * -- cgit v1.2.3 From 8a8a27b01a60ba80608f736c46da82747c215586 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 14 Jan 2010 18:19:39 -0800 Subject: st/mesa: Remove unnecessary header from st_format.c. --- src/mesa/state_tracker/st_format.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index 27857282c1..6b1c49954f 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -35,7 +35,6 @@ #include "main/imports.h" #include "main/context.h" #include "main/texstore.h" -#include "main/texformat.h" #include "main/enums.h" #include "main/macros.h" -- cgit v1.2.3 From 9e7778d7aa9bd079a4a5d3d1656d75d6e4978a1d Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 14 Jan 2010 18:34:59 -0800 Subject: st/mesa: Remove unnecessary header from st_extensions.c. --- src/mesa/state_tracker/st_extensions.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 57fe72d76a..54d7c61ae0 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -28,7 +28,6 @@ #include "main/imports.h" #include "main/context.h" -#include "main/extensions.h" #include "main/macros.h" #include "pipe/p_context.h" -- cgit v1.2.3 From 604e9ec2c436b8bc595faf97db1a4f57fe5368f2 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 14 Jan 2010 18:46:51 -0800 Subject: st/mesa: Remove unnecessary header from st_draw_feedback.c. --- src/mesa/state_tracker/st_draw_feedback.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c index b2d682ef64..0660a2c482 100644 --- a/src/mesa/state_tracker/st_draw_feedback.c +++ b/src/mesa/state_tracker/st_draw_feedback.c @@ -28,7 +28,6 @@ #include "main/imports.h" #include "main/image.h" #include "main/macros.h" -#include "shader/prog_uniform.h" #include "vbo/vbo.h" -- cgit v1.2.3 From 53c6c384125726ad4e528d57272be95f197fb630 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 14 Jan 2010 18:53:51 -0800 Subject: st/mesa: Remove unnecessary headers from st_context.c. --- src/mesa/state_tracker/st_context.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index d18a25ab51..6c463ca939 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -27,11 +27,6 @@ #include "main/imports.h" #include "main/context.h" -#include "main/extensions.h" -#include "main/matrix.h" -#include "main/buffers.h" -#include "main/scissor.h" -#include "main/viewport.h" #include "vbo/vbo.h" #include "shader/shader_api.h" #include "glapi/glapi.h" @@ -68,7 +63,6 @@ #include "st_program.h" #include "pipe/p_context.h" #include "draw/draw_context.h" -#include "cso_cache/cso_cache.h" #include "cso_cache/cso_context.h" -- cgit v1.2.3 From 4f8baf7dce47b1295292bf3d153d1e93ea83e6a1 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 14 Jan 2010 19:00:27 -0800 Subject: st/mesa: Remove unnecessary headers from st_cb_viewport.c. --- src/mesa/state_tracker/st_cb_viewport.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_viewport.c b/src/mesa/state_tracker/st_cb_viewport.c index 75b0a219ce..9450b3a45b 100644 --- a/src/mesa/state_tracker/st_cb_viewport.c +++ b/src/mesa/state_tracker/st_cb_viewport.c @@ -27,11 +27,9 @@ #include "main/glheader.h" #include "st_context.h" -#include "st_public.h" #include "st_cb_viewport.h" #include "pipe/p_context.h" -#include "pipe/p_inlines.h" #include "pipe/p_state.h" #include "pipe/p_defines.h" #include "pipe/internal/p_winsys_screen.h" -- cgit v1.2.3 From 644572a3723bc5167fb71f15e0bbfec3f999be9b Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 14 Jan 2010 22:27:13 -0800 Subject: st/mesa: Remove unnecessary headers from st_cb_texture.c. --- src/mesa/state_tracker/st_cb_texture.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index cb9106c7de..e9c30cb5de 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -36,10 +36,8 @@ #include "main/imports.h" #include "main/macros.h" #include "main/mipmap.h" -#include "main/pixel.h" #include "main/texcompress.h" #include "main/texfetch.h" -#include "main/texformat.h" #include "main/texgetimage.h" #include "main/teximage.h" #include "main/texobj.h" -- cgit v1.2.3 From cde041cd1320849be70dc8571da1460b8b913f14 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 14 Jan 2010 22:30:00 -0800 Subject: st/mesa: Remove unnecessary header from st_cb_strings.c. --- src/mesa/state_tracker/st_cb_strings.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/state_tracker/st_cb_strings.c b/src/mesa/state_tracker/st_cb_strings.c index bb931f17c4..f22c5369e4 100644 --- a/src/mesa/state_tracker/st_cb_strings.c +++ b/src/mesa/state_tracker/st_cb_strings.c @@ -33,7 +33,6 @@ #include "main/glheader.h" #include "main/macros.h" -#include "main/version.h" #include "pipe/p_context.h" #include "pipe/p_screen.h" #include "st_context.h" -- cgit v1.2.3 From 9c2ef74a76fc3707ca428dca2ca401da790cb915 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 14 Jan 2010 23:03:37 -0800 Subject: st/mesa: Remove unnecessary headers from st_cb_readpixels.c. --- src/mesa/state_tracker/st_cb_readpixels.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 772bb3bb69..be98195662 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -45,10 +45,8 @@ #include "st_debug.h" #include "st_context.h" -#include "st_cb_bitmap.h" #include "st_cb_readpixels.h" #include "st_cb_fbo.h" -#include "st_format.h" #include "st_public.h" #include "st_texture.h" #include "st_inlines.h" -- cgit v1.2.3 From 79a5a2839029eef23f4c238fec6878b5f87ceec3 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 14 Jan 2010 23:05:42 -0800 Subject: st/mesa: Remove unnecessary header from st_cb_rasterpos.c. --- src/mesa/state_tracker/st_cb_rasterpos.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index d82b2a2035..42a1377809 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -47,7 +47,6 @@ #include "st_draw.h" #include "draw/draw_context.h" #include "draw/draw_pipe.h" -#include "shader/prog_instruction.h" #include "vbo/vbo.h" -- cgit v1.2.3 From 73856817973caab283427c52152672f524c49a07 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 15 Jan 2010 14:19:23 -0700 Subject: swrast: fix broken _swrast_depth_clamp_span() The integer Z clamping range depends on the number of bits in the Z buffer because that's the scale factor used when we transform NDC coords by the viewport/depth range. Fixes fd.o bug #25972 but only for Z buffers up to a depth of 30 bits. Beyond that we get into messy integer overflow issues and things fall apart. --- src/mesa/swrast/s_depth.c | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c index 0b6bb7e3ec..ac5dae2148 100644 --- a/src/mesa/swrast/s_depth.c +++ b/src/mesa/swrast/s_depth.c @@ -497,17 +497,24 @@ depth_test_span32( GLcontext *ctx, GLuint n, return passed; } -/* Apply ARB_depth_clamp to span of fragments. */ + + +/** + * Clamp fragment Z values to the depth near/far range (glDepthRange()). + * This is used when GL_ARB_depth_clamp/GL_DEPTH_CLAMP is turned on. + * In that case, vertexes are not clipped against the near/far planes + * so rasterization will produce fragment Z values outside the usual + * [0,1] range. + */ void _swrast_depth_clamp_span( GLcontext *ctx, SWspan *span ) { struct gl_framebuffer *fb = ctx->DrawBuffer; - struct gl_renderbuffer *rb = fb->_DepthBuffer; const GLuint count = span->end; - GLuint *zValues = span->array->z; - GLuint min, max; + GLint *zValues = (GLint *) span->array->z; /* sign change */ + GLint min, max; GLfloat min_f, max_f; - int i; + GLuint i; if (ctx->Viewport.Near < ctx->Viewport.Far) { min_f = ctx->Viewport.Near; @@ -517,15 +524,21 @@ _swrast_depth_clamp_span( GLcontext *ctx, SWspan *span ) max_f = ctx->Viewport.Near; } - if (rb->DataType == GL_UNSIGNED_SHORT) { - CLAMPED_FLOAT_TO_USHORT(min, min_f); - CLAMPED_FLOAT_TO_USHORT(max, max_f); - } else { - assert(rb->DataType == GL_UNSIGNED_INT); - min = FLOAT_TO_UINT(min_f); - max = FLOAT_TO_UINT(max_f); - } - + /* Convert floating point values in [0,1] to device Z coordinates in + * [0, DepthMax]. + * ex: If the the Z buffer has 24 bits, DepthMax = 0xffffff. + * + * XXX this all falls apart if we have 31 or more bits of Z because + * the triangle rasterization code produces unsigned Z values. Negative + * vertex Z values come out as large fragment Z uints. + */ + min = (GLint) (min_f * fb->_DepthMaxF); + max = (GLint) (max_f * fb->_DepthMaxF); + if (max < 0) + max = 0x7fffffff; /* catch over flow for 30-bit z */ + + /* Note that we do the comparisons here using signed integers. + */ for (i = 0; i < count; i++) { if (zValues[i] < min) zValues[i] = min; -- cgit v1.2.3 From 2c5aa02e2086f5e79630cdffec804a3e9de0d966 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 15 Jan 2010 14:25:30 -0700 Subject: swrast: add missing call to _swrast_depth_bounds_test() We were calling this from the CI span function, but not the RGBA span function. I don't know of a test program for the GL_EXT_depth_bounds_test extension... --- src/mesa/swrast/s_span.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index 1a51d4f045..07248c71af 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -1316,6 +1316,13 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span) ASSERT(span->end <= MAX_WIDTH); + /* Depth bounds test */ + if (ctx->Depth.BoundsTest && fb->Visual.depthBits > 0) { + if (!_swrast_depth_bounds_test(ctx, span)) { + return; + } + } + #ifdef DEBUG /* Make sure all fragments are within window bounds */ if (span->arrayMask & SPAN_XY) { -- cgit v1.2.3 From f595e72337f4cdc2ec6b0378f747e31666e70d5c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 15 Jan 2010 14:57:55 -0700 Subject: tgsi: fix detection of front-facing attribute This code was not updated when we added TGSI_SEMANTIC_FACE a while ago. --- src/gallium/auxiliary/tgsi/tgsi_scan.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_scan.c b/src/gallium/auxiliary/tgsi/tgsi_scan.c index f9c16f1b6c..a4414d118a 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_scan.c +++ b/src/gallium/auxiliary/tgsi/tgsi_scan.c @@ -101,12 +101,10 @@ tgsi_scan_shader(const struct tgsi_token *tokens, if (src->SrcRegister.File == TGSI_FILE_INPUT) { const int ind = src->SrcRegister.Index; if (info->input_semantic_name[ind] == TGSI_SEMANTIC_FOG) { - if (src->SrcRegister.SwizzleX == TGSI_SWIZZLE_X) { - info->uses_fogcoord = TRUE; - } - else if (src->SrcRegister.SwizzleX == TGSI_SWIZZLE_Y) { - info->uses_frontfacing = TRUE; - } + info->uses_fogcoord = TRUE; + } + else if (info->input_semantic_name[ind] == TGSI_SEMANTIC_FACE) { + info->uses_frontfacing = TRUE; } } } -- cgit v1.2.3 From fbda223893301cc10182fb12c91493c959e3fe8b Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Fri, 15 Jan 2010 16:27:28 -0800 Subject: st/mesa: Remove unnecessary header from st_cb_queryobj.c. --- src/mesa/state_tracker/st_cb_queryobj.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/state_tracker/st_cb_queryobj.c b/src/mesa/state_tracker/st_cb_queryobj.c index dcf4c38eb6..5ef7765017 100644 --- a/src/mesa/state_tracker/st_cb_queryobj.c +++ b/src/mesa/state_tracker/st_cb_queryobj.c @@ -41,7 +41,6 @@ #include "pipe/p_defines.h" #include "st_context.h" #include "st_cb_queryobj.h" -#include "st_public.h" struct st_query_object -- cgit v1.2.3 From 2d2d8900485ac9f462fccdb0a817f7fc598b95f8 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Fri, 15 Jan 2010 16:28:56 -0800 Subject: st/mesa: Remove unnecessary header from st_cb_program.c. --- src/mesa/state_tracker/st_cb_program.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index b2d5c39a3a..22cb61c380 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -36,7 +36,6 @@ #include "shader/prog_instruction.h" #include "shader/prog_parameter.h" #include "shader/program.h" -#include "shader/programopt.h" #include "shader/shader_api.h" #include "cso_cache/cso_context.h" -- cgit v1.2.3 From a9f625543169e0919c507966889d82ecf9db4c5f Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Fri, 15 Jan 2010 18:20:56 -0800 Subject: st/mesa: Remove unnecessary headers from st_cb_feedback.c. --- src/mesa/state_tracker/st_cb_feedback.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c index 93f7145219..17261f8321 100644 --- a/src/mesa/state_tracker/st_cb_feedback.c +++ b/src/mesa/state_tracker/st_cb_feedback.c @@ -45,14 +45,11 @@ #include "vbo/vbo.h" #include "st_context.h" -#include "st_atom.h" #include "st_draw.h" #include "st_cb_feedback.h" -#include "st_cb_bufferobjects.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" -#include "cso_cache/cso_cache.h" #include "draw/draw_context.h" #include "draw/draw_pipe.h" -- cgit v1.2.3 From 56cd5806e89fea9598e296ce656dfe550bf2b96e Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Fri, 15 Jan 2010 18:24:12 -0800 Subject: st/mesa: Remove unnecessary header from st_cb_fbo.c. --- src/mesa/state_tracker/st_cb_fbo.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 65ce12ccd4..9cdff5354b 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -44,7 +44,6 @@ #include "pipe/p_screen.h" #include "st_context.h" #include "st_cb_fbo.h" -#include "st_cb_texture.h" #include "st_format.h" #include "st_public.h" #include "st_texture.h" -- cgit v1.2.3 From 114ab07aee9cc3f007a22ae4642e5c4302900d2f Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Fri, 15 Jan 2010 20:53:53 -0500 Subject: r600: fix typo in SQ setup --- src/mesa/drivers/dri/r600/r700_state.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r700_state.c b/src/mesa/drivers/dri/r600/r700_state.c index 16b05d5cd9..82bd48b97b 100644 --- a/src/mesa/drivers/dri/r600/r700_state.c +++ b/src/mesa/drivers/dri/r600/r700_state.c @@ -1576,9 +1576,9 @@ static void r700InitSQConfig(GLcontext * ctx) SETbit(r700->sq_config.SQ_CONFIG.u32All, DX9_CONSTS_bit); SETbit(r700->sq_config.SQ_CONFIG.u32All, ALU_INST_PREFER_VECTOR_bit); SETfield(r700->sq_config.SQ_CONFIG.u32All, ps_prio, PS_PRIO_shift, PS_PRIO_mask); - SETfield(r700->sq_config.SQ_CONFIG.u32All, ps_prio, VS_PRIO_shift, VS_PRIO_mask); - SETfield(r700->sq_config.SQ_CONFIG.u32All, ps_prio, GS_PRIO_shift, GS_PRIO_mask); - SETfield(r700->sq_config.SQ_CONFIG.u32All, ps_prio, ES_PRIO_shift, ES_PRIO_mask); + SETfield(r700->sq_config.SQ_CONFIG.u32All, vs_prio, VS_PRIO_shift, VS_PRIO_mask); + SETfield(r700->sq_config.SQ_CONFIG.u32All, gs_prio, GS_PRIO_shift, GS_PRIO_mask); + SETfield(r700->sq_config.SQ_CONFIG.u32All, es_prio, ES_PRIO_shift, ES_PRIO_mask); r700->sq_config.SQ_GPR_RESOURCE_MGMT_1.u32All = 0; SETfield(r700->sq_config.SQ_GPR_RESOURCE_MGMT_1.u32All, num_ps_gprs, NUM_PS_GPRS_shift, NUM_PS_GPRS_mask); -- cgit v1.2.3 From 81eed59a2c6add1d1514574bf7c3b29b1bf6e8c0 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Fri, 15 Jan 2010 20:54:12 -0500 Subject: r600: set tiling correctly for texturing from depth buffer --- src/mesa/drivers/dri/r600/r600_texstate.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/mesa/drivers/dri/r600/r600_texstate.c b/src/mesa/drivers/dri/r600/r600_texstate.c index fb5abdcadc..61c9730627 100644 --- a/src/mesa/drivers/dri/r600/r600_texstate.c +++ b/src/mesa/drivers/dri/r600/r600_texstate.c @@ -85,6 +85,7 @@ static GLboolean r600GetTexFormat(struct gl_texture_object *tObj, gl_format mesa CLEARfield(t->SQ_TEX_RESOURCE4, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask); CLEARfield(t->SQ_TEX_RESOURCE4, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask); CLEARfield(t->SQ_TEX_RESOURCE4, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask); + CLEARbit(t->SQ_TEX_RESOURCE4, SQ_TEX_RESOURCE_WORD4_0__FORCE_DEGAMMA_bit); SETfield(t->SQ_TEX_RESOURCE4, SQ_FORMAT_COMP_UNSIGNED, FORMAT_COMP_X_shift, FORMAT_COMP_X_mask); @@ -95,6 +96,11 @@ static GLboolean r600GetTexFormat(struct gl_texture_object *tObj, gl_format mesa SETfield(t->SQ_TEX_RESOURCE4, SQ_FORMAT_COMP_UNSIGNED, FORMAT_COMP_W_shift, FORMAT_COMP_W_mask); + CLEARbit(t->SQ_TEX_RESOURCE0, TILE_TYPE_bit); + SETfield(t->SQ_TEX_RESOURCE0, ARRAY_LINEAR_GENERAL, + SQ_TEX_RESOURCE_WORD0_0__TILE_MODE_shift, + SQ_TEX_RESOURCE_WORD0_0__TILE_MODE_mask); + switch (mesa_format) /* This is mesa format. */ { case MESA_FORMAT_RGBA8888: @@ -515,6 +521,10 @@ static GLboolean r600GetTexFormat(struct gl_texture_object *tObj, gl_format mesa case MESA_FORMAT_Z24_S8: case MESA_FORMAT_Z32: case MESA_FORMAT_S8: + SETbit(t->SQ_TEX_RESOURCE0, TILE_TYPE_bit); + SETfield(t->SQ_TEX_RESOURCE0, ARRAY_1D_TILED_THIN1, + SQ_TEX_RESOURCE_WORD0_0__TILE_MODE_shift, + SQ_TEX_RESOURCE_WORD0_0__TILE_MODE_mask); switch (mesa_format) { case MESA_FORMAT_Z16: SETfield(t->SQ_TEX_RESOURCE1, FMT_16, -- cgit v1.2.3 From adcde22952bb94dd73785bf5971a317e929fbec9 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Fri, 15 Jan 2010 22:23:40 -0500 Subject: r600: fill in some missing XRGB tex formats --- src/mesa/drivers/dri/r600/r600_texstate.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/mesa/drivers/dri/r600/r600_texstate.c b/src/mesa/drivers/dri/r600/r600_texstate.c index 61c9730627..8fdca0bab1 100644 --- a/src/mesa/drivers/dri/r600/r600_texstate.c +++ b/src/mesa/drivers/dri/r600/r600_texstate.c @@ -164,6 +164,32 @@ static GLboolean r600GetTexFormat(struct gl_texture_object *tObj, gl_format mesa SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_W, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask); break; + case MESA_FORMAT_XRGB8888: + SETfield(t->SQ_TEX_RESOURCE1, FMT_8_8_8_8, + SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask); + + SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z, + SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask); + SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Y, + SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask); + SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X, + SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask); + SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_1, + SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask); + break; + case MESA_FORMAT_XRGB8888_REV: + SETfield(t->SQ_TEX_RESOURCE1, FMT_8_8_8_8, + SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask); + + SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_1, + SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_X_mask); + SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_Z, + SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Y_mask); + SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_W, + SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_Z_mask); + SETfield(t->SQ_TEX_RESOURCE4, SQ_SEL_X, + SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_shift, SQ_TEX_RESOURCE_WORD4_0__DST_SEL_W_mask); + break; case MESA_FORMAT_ARGB8888_REV: SETfield(t->SQ_TEX_RESOURCE1, FMT_8_8_8_8, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_shift, SQ_TEX_RESOURCE_WORD1_0__DATA_FORMAT_mask); -- cgit v1.2.3 From 668d871d95e74862953c90e04e4f04ed02526421 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Fri, 15 Jan 2010 22:55:47 -0800 Subject: st/mesa: Remove unnecessary headers from st_cb_drawpixels.c. --- src/mesa/state_tracker/st_cb_drawpixels.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 1d33e81c2c..fe9a11d098 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -36,24 +36,19 @@ #include "main/macros.h" #include "main/texformat.h" #include "main/texstore.h" -#include "main/state.h" #include "shader/program.h" -#include "shader/prog_parameter.h" #include "shader/prog_print.h" #include "st_debug.h" #include "st_context.h" #include "st_atom.h" #include "st_atom_constbuf.h" -#include "st_draw.h" #include "st_program.h" #include "st_cb_drawpixels.h" #include "st_cb_readpixels.h" #include "st_cb_fbo.h" -#include "st_cb_texture.h" #include "st_draw.h" #include "st_format.h" -#include "st_mesa_to_tgsi.h" #include "st_texture.h" #include "st_inlines.h" -- cgit v1.2.3 From 6906bf08cc0ca43cd4fd1a2c6f841ad87c232ece Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Fri, 15 Jan 2010 23:02:07 -0800 Subject: st/mesa: Remove unnecessary headers from st_cb_clear.c. --- src/mesa/state_tracker/st_cb_clear.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index e83b6c92ef..7c0d74acb5 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -42,17 +42,14 @@ #include "st_cb_accum.h" #include "st_cb_clear.h" #include "st_cb_fbo.h" -#include "st_draw.h" #include "st_program.h" #include "st_public.h" -#include "st_mesa_to_tgsi.h" #include "st_inlines.h" #include "pipe/p_context.h" #include "pipe/p_inlines.h" #include "pipe/p_state.h" #include "pipe/p_defines.h" -#include "util/u_pack_color.h" #include "util/u_simple_shaders.h" #include "util/u_draw_quad.h" -- cgit v1.2.3 From cc770c8409b31dd2dff7dd80cf441f90f191a048 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Fri, 15 Jan 2010 23:17:00 -0800 Subject: st/mesa: Remove unnecessary headers from st_cb_blit.c. --- src/mesa/state_tracker/st_cb_blit.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c index 563615ed0d..65aa2a28ac 100644 --- a/src/mesa/state_tracker/st_cb_blit.c +++ b/src/mesa/state_tracker/st_cb_blit.c @@ -33,14 +33,10 @@ #include "main/imports.h" #include "main/image.h" #include "main/macros.h" -#include "main/texformat.h" #include "shader/program.h" -#include "shader/prog_parameter.h" -#include "shader/prog_print.h" #include "st_context.h" #include "st_texture.h" -#include "st_program.h" #include "st_cb_blit.h" #include "st_cb_fbo.h" -- cgit v1.2.3 From e1d4781cd49cd6df2fed171ad6e034f576f219a8 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 00:08:54 -0800 Subject: st/mesa: Remove unnecessary headers from st_cb_bitmap.c. --- src/mesa/state_tracker/st_cb_bitmap.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index 1960d171bf..4b85bf2e16 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -34,9 +34,7 @@ #include "main/image.h" #include "main/bufferobj.h" #include "main/macros.h" -#include "main/texformat.h" #include "shader/program.h" -#include "shader/prog_parameter.h" #include "shader/prog_print.h" #include "st_context.h" @@ -44,15 +42,12 @@ #include "st_atom_constbuf.h" #include "st_program.h" #include "st_cb_bitmap.h" -#include "st_cb_program.h" -#include "st_mesa_to_tgsi.h" #include "st_texture.h" #include "st_inlines.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_inlines.h" -#include "util/u_tile.h" #include "util/u_draw_quad.h" #include "util/u_simple_shaders.h" #include "shader/prog_instruction.h" -- cgit v1.2.3 From cc2f2268f5fcfbc7d942fab82a1bb00ac496fc23 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 00:30:25 -0800 Subject: st/mesa: Remove unnecessary headers from st_cb_accum.c. --- src/mesa/state_tracker/st_cb_accum.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index a6b9765452..6625dfba33 100644 --- a/src/mesa/state_tracker/st_cb_accum.c +++ b/src/mesa/state_tracker/st_cb_accum.c @@ -38,9 +38,7 @@ #include "st_context.h" #include "st_cb_accum.h" #include "st_cb_fbo.h" -#include "st_draw.h" #include "st_public.h" -#include "st_format.h" #include "st_texture.h" #include "st_inlines.h" #include "pipe/p_context.h" -- cgit v1.2.3 From 227fc5a3083290bf8c494f1f08e911eed6e4cfcc Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 00:36:31 -0800 Subject: st/mesa: Remove unnecessary header from st_atom_shader.c. --- src/mesa/state_tracker/st_atom_shader.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index 9208f3f446..9fad58a489 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -53,7 +53,6 @@ #include "st_atom.h" #include "st_program.h" #include "st_atom_shader.h" -#include "st_mesa_to_tgsi.h" /** -- cgit v1.2.3 From bc639f291bd6127730845f9e6208e48e51cb83ff Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 00:45:36 -0800 Subject: st/mesa: Remove unnecessary header from st_atom_sampler.c. --- src/mesa/state_tracker/st_atom_sampler.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c index 6611956ae8..7b1734c4f3 100644 --- a/src/mesa/state_tracker/st_atom_sampler.c +++ b/src/mesa/state_tracker/st_atom_sampler.c @@ -37,7 +37,6 @@ #include "st_context.h" #include "st_cb_texture.h" #include "st_atom.h" -#include "st_program.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" -- cgit v1.2.3 From 3eb85bf7d941aff1c72e0e0e2d8af18b8b7e496a Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 00:52:34 -0800 Subject: st/mesa: Remove unnecessary header from st_atom_pixeltransfer.c. --- src/mesa/state_tracker/st_atom_pixeltransfer.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c index babfcc87b4..8300300161 100644 --- a/src/mesa/state_tracker/st_atom_pixeltransfer.c +++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c @@ -43,7 +43,6 @@ #include "st_context.h" #include "st_format.h" -#include "st_program.h" #include "st_texture.h" #include "st_inlines.h" -- cgit v1.2.3 From 533b6e8deb3443719bd82c57c79ec106e5473589 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 01:39:04 -0800 Subject: st/mesa: Remove unnecessary header from st_atom_framebuffer.c. --- src/mesa/state_tracker/st_atom_framebuffer.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index e18c0f6e0a..1e18497590 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -37,7 +37,6 @@ #include "st_public.h" #include "st_texture.h" #include "pipe/p_context.h" -#include "pipe/p_inlines.h" #include "cso_cache/cso_context.h" #include "util/u_rect.h" -- cgit v1.2.3 From 10bd931949d8dd3c63fe8bcc00899875d7dde105 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 01:50:08 -0800 Subject: glsl: Remove unnecessary header from slang_log.c. --- src/mesa/shader/slang/slang_log.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/shader/slang/slang_log.c b/src/mesa/shader/slang/slang_log.c index d7d2b4fbfd..4f6b8541c5 100644 --- a/src/mesa/shader/slang/slang_log.c +++ b/src/mesa/shader/slang/slang_log.c @@ -24,7 +24,6 @@ */ #include "main/imports.h" -#include "main/context.h" #include "slang_log.h" #include "slang_utility.h" -- cgit v1.2.3 From 1d3bdc20908f860316e0bfeaa54dc8fa6d344d0c Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 02:02:49 -0800 Subject: glsl: Remove unnecessary header from slang_link.c. --- src/mesa/shader/slang/slang_link.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index 0a2bc49780..e9f1ee44ce 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -31,7 +31,6 @@ #include "main/imports.h" #include "main/context.h" -#include "main/hash.h" #include "main/macros.h" #include "shader/program.h" #include "shader/prog_instruction.h" -- cgit v1.2.3 From 535084996b050a75f230dc10c15bd6239e2aa08a Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 02:16:24 -0800 Subject: glsl: Remove unnecessary headers from slang_compile.c. --- src/mesa/shader/slang/slang_compile.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index 57e3555c22..6a91d0f3f0 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -40,14 +40,11 @@ #include "slang_compile.h" #include "slang_preprocess.h" #include "slang_storage.h" -#include "slang_emit.h" #include "slang_log.h" #include "slang_mem.h" #include "slang_vartable.h" #include "slang_simplify.h" -#include "slang_print.h" - /* * This is a straightforward implementation of the slang front-end * compiler. Lots of error-checking functionality is missing but -- cgit v1.2.3 From 59db91e2eec1e755de71deba87227a647845b1c9 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 02:20:51 -0800 Subject: glsl: Remove unnecessary header from slang_builtin.c. --- src/mesa/shader/slang/slang_builtin.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/shader/slang/slang_builtin.c b/src/mesa/shader/slang/slang_builtin.c index e5809509c9..0a9f0b97fb 100644 --- a/src/mesa/shader/slang/slang_builtin.c +++ b/src/mesa/shader/slang/slang_builtin.c @@ -36,7 +36,6 @@ #include "shader/prog_parameter.h" #include "shader/prog_statevars.h" #include "shader/slang/slang_ir.h" -#include "shader/slang/slang_emit.h" #include "shader/slang/slang_builtin.h" -- cgit v1.2.3 From 89950fbe24a351fbb10330b6695d653c9f2d6887 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 13:29:15 -0800 Subject: st/mesa: Remove unnecessary header from st_cb_drawpixels.c. --- src/mesa/state_tracker/st_cb_drawpixels.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index fe9a11d098..23db3f1968 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -47,7 +47,6 @@ #include "st_cb_drawpixels.h" #include "st_cb_readpixels.h" #include "st_cb_fbo.h" -#include "st_draw.h" #include "st_format.h" #include "st_texture.h" #include "st_inlines.h" -- cgit v1.2.3 From 1f7762f62bb082fceb579434a4ca78f13d78da49 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 15:00:29 -0800 Subject: glsl: Remove unnecessary header from slang_emit.c. --- src/mesa/shader/slang/slang_emit.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index c0e4b27aa5..f812a3fbc5 100644 --- a/src/mesa/shader/slang/slang_emit.c +++ b/src/mesa/shader/slang/slang_emit.c @@ -38,7 +38,6 @@ #include "main/imports.h" #include "main/context.h" -#include "main/macros.h" #include "shader/program.h" #include "shader/prog_instruction.h" #include "shader/prog_parameter.h" -- cgit v1.2.3 From 0d622420826ccbf35eed80b663994ffb918dc9a1 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 15:35:56 -0800 Subject: glsl: Remove unnecessary headers from shader_api.c. --- src/mesa/shader/shader_api.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 453cd3964a..e522d7017a 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -39,10 +39,8 @@ #include "main/glheader.h" #include "main/context.h" #include "main/hash.h" -#include "main/macros.h" #include "shader/program.h" #include "shader/prog_parameter.h" -#include "shader/prog_print.h" #include "shader/prog_statevars.h" #include "shader/prog_uniform.h" #include "shader/shader_api.h" -- cgit v1.2.3 From 148498d8cc897d70c54e9ddc09e957a855a597d4 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 15:51:52 -0800 Subject: glsl: Remove unnecessary header from prog_statevars.c. --- src/mesa/shader/prog_statevars.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/shader/prog_statevars.c b/src/mesa/shader/prog_statevars.c index 058d4bbafb..3a446fd9bb 100644 --- a/src/mesa/shader/prog_statevars.c +++ b/src/mesa/shader/prog_statevars.c @@ -31,7 +31,6 @@ #include "main/glheader.h" #include "main/context.h" -#include "main/hash.h" #include "main/imports.h" #include "main/macros.h" #include "main/mtypes.h" -- cgit v1.2.3 From 5a4d5b694c0fa92b613bd73138d32f68b966a56c Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 16:06:58 -0800 Subject: glsl: Remove unnecessary header from prog_execute.c. --- src/mesa/shader/prog_execute.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/shader/prog_execute.c b/src/mesa/shader/prog_execute.c index 192d39aed1..1ef801a17d 100644 --- a/src/mesa/shader/prog_execute.c +++ b/src/mesa/shader/prog_execute.c @@ -38,7 +38,6 @@ #include "main/glheader.h" #include "main/colormac.h" #include "main/context.h" -#include "program.h" #include "prog_execute.h" #include "prog_instruction.h" #include "prog_parameter.h" -- cgit v1.2.3 From 97fc7ae69f4e620a5b14a3dbe574c4810741293c Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 16:15:37 -0800 Subject: mesa: Remove unnecessary header from nvvertparse.c. --- src/mesa/shader/nvvertparse.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/shader/nvvertparse.c b/src/mesa/shader/nvvertparse.c index 8574016050..baff7658d1 100644 --- a/src/mesa/shader/nvvertparse.c +++ b/src/mesa/shader/nvvertparse.c @@ -40,7 +40,6 @@ #include "main/glheader.h" #include "main/context.h" #include "main/imports.h" -#include "main/macros.h" #include "nvprogram.h" #include "nvvertparse.h" #include "prog_instruction.h" -- cgit v1.2.3 From 97e44cde17ce508fd3708d391f7701e1919352fb Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 16 Jan 2010 23:41:05 -0800 Subject: mesa: Remove unnecessary headers from arbprogparse.c. --- src/mesa/shader/arbprogparse.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index dd732b6666..a33f5100db 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -54,11 +54,8 @@ having three separate program parameter arrays. #include "main/glheader.h" #include "main/imports.h" #include "main/context.h" -#include "main/macros.h" #include "main/mtypes.h" -#include "shader/grammar/grammar_mesa.h" #include "arbprogparse.h" -#include "program.h" #include "programopt.h" #include "prog_parameter.h" #include "prog_statevars.h" -- cgit v1.2.3 From ae943f8e202fc3791bd56ac863e5493cd17bb44c Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 17 Jan 2010 01:49:16 -0800 Subject: mesa: Remove unnecessary headers from vtxfmt.c. --- src/mesa/main/vtxfmt.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mesa/main/vtxfmt.c b/src/mesa/main/vtxfmt.c index c9eea8ab83..0dd3e5e52e 100644 --- a/src/mesa/main/vtxfmt.c +++ b/src/mesa/main/vtxfmt.c @@ -28,11 +28,9 @@ #include "glheader.h" #include "api_arrayelt.h" -#include "api_loopback.h" #include "context.h" #include "imports.h" #include "mtypes.h" -#include "state.h" #include "vtxfmt.h" #include "eval.h" #include "dlist.h" -- cgit v1.2.3 From 6b6ac9aca08603fb0e3f91bf53fd6d49a1701e2a Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 17 Jan 2010 15:48:39 -0800 Subject: mesa: Use preprocessor to comment out code. --- src/mesa/main/texstore.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 792c83141e..fcd0a56d76 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -263,7 +263,7 @@ compute_component_mapping(GLenum inFormat, GLenum outFormat, map[ZERO] = ZERO; map[ONE] = ONE; -/* +#if 0 _mesa_printf("from %x/%s to %x/%s map %d %d %d %d %d %d\n", inFormat, _mesa_lookup_enum_by_nr(inFormat), outFormat, _mesa_lookup_enum_by_nr(outFormat), @@ -273,7 +273,7 @@ compute_component_mapping(GLenum inFormat, GLenum outFormat, map[3], map[4], map[5]); -*/ +#endif } -- cgit v1.2.3 From 3e876431d01c50b5672d0ad28f7f8dbd20670616 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 17 Jan 2010 16:08:59 -0800 Subject: mesa: Remove unnecessary headers from texstate.c. --- src/mesa/main/texstate.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index c735e18aff..25333d8994 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -35,11 +35,9 @@ #include "context.h" #include "enums.h" #include "macros.h" -#include "texcompress.h" #include "texobj.h" #include "teximage.h" #include "texstate.h" -#include "texenvprogram.h" #include "mtypes.h" -- cgit v1.2.3 From 59eed7a2015cf301ea20392febc0de6b8d1ee0b1 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 17 Jan 2010 16:21:11 -0800 Subject: mesa: Remove unnecessary header from texparam.c. --- src/mesa/main/texparam.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c index 9e1a889bce..93c5d6c10d 100644 --- a/src/mesa/main/texparam.c +++ b/src/mesa/main/texparam.c @@ -33,7 +33,6 @@ #include "main/glheader.h" #include "main/colormac.h" #include "main/context.h" -#include "main/enums.h" #include "main/formats.h" #include "main/macros.h" #include "main/texcompress.h" -- cgit v1.2.3 From c847e7d07b3f43d5c05a920cf6326b89b31ed92b Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 17 Jan 2010 20:50:15 -0800 Subject: mesa: Remove unnecessary header from texobj.c. --- src/mesa/main/texobj.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 237b6eb00d..7f6255747b 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -38,7 +38,6 @@ #include "imports.h" #include "macros.h" #include "teximage.h" -#include "texstate.h" #include "texobj.h" #include "mtypes.h" #include "shader/prog_instruction.h" -- cgit v1.2.3 From 6938dccf1ac0955026ac68794a03f49bc370fd44 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 17 Jan 2010 22:31:53 -0800 Subject: mesa: Remove unnecessary header from teximage.c. --- src/mesa/main/teximage.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index b946f3c69d..76273b0267 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -46,7 +46,6 @@ #include "texfetch.h" #include "teximage.h" #include "texstate.h" -#include "texstore.h" #include "mtypes.h" -- cgit v1.2.3 From 39824945fa738666b4bb804382904b0537322878 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 00:14:51 -0800 Subject: mesa: Remove unnecessary headers from texgetimage.c. --- src/mesa/main/texgetimage.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index ac467c490a..0cc6a563a0 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -35,10 +35,8 @@ #include "context.h" #include "formats.h" #include "image.h" -#include "texcompress.h" #include "texgetimage.h" #include "teximage.h" -#include "texstate.h" -- cgit v1.2.3 From d773f28ff29a0abbb9f856cb4a3c60fcaeea1d3b Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 00:47:56 -0800 Subject: mesa: Remove unnecessary headers from texformat.c. --- src/mesa/main/texformat.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c index 1a374e7bee..096945a643 100644 --- a/src/mesa/main/texformat.c +++ b/src/mesa/main/texformat.c @@ -35,8 +35,6 @@ #include "context.h" #include "texcompress.h" -#include "texcompress_fxt1.h" -#include "texcompress_s3tc.h" #include "texformat.h" -- cgit v1.2.3 From 5f2d60a7154f896bb418231662663465269ce9b8 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Mon, 18 Jan 2010 13:33:08 +0100 Subject: st/dri: Don't request a fake front if the server adds one automatically. We use the presence of the getBuffersWithFormat extension function to detect whether the server automatically adds a front. Signed-off-by: Thomas Hellstrom --- src/gallium/state_trackers/dri/dri_drawable.c | 12 +++++++----- src/gallium/state_trackers/dri/dri_screen.c | 5 +++++ src/gallium/state_trackers/dri/dri_screen.h | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 3c17ccde0a..0a8c1cd361 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -123,11 +123,12 @@ dri_get_buffers(__DRIdrawablePrivate * dPriv) struct dri_drawable *drawable = dri_drawable(dPriv); struct pipe_surface *surface = NULL; - struct pipe_screen *screen = dri_screen(drawable->sPriv)->pipe_screen; + struct dri_screen *st_screen = dri_screen(drawable->sPriv); + struct pipe_screen *screen = st_screen->pipe_screen; __DRIbuffer *buffers = NULL; __DRIscreen *dri_screen = drawable->sPriv; __DRIdrawable *dri_drawable = drawable->dPriv; - struct drm_api *api = ((struct dri_screen*)(dri_screen->private))->api; + struct drm_api *api = st_screen->api; boolean have_depth = FALSE; int i, count; @@ -180,7 +181,8 @@ dri_get_buffers(__DRIdrawablePrivate * dPriv) switch (buffers[i].attachment) { case __DRI_BUFFER_FRONT_LEFT: - continue; + if (!st_screen->auto_fake_front) + continue; case __DRI_BUFFER_FAKE_FRONT_LEFT: index = ST_SURFACE_FRONT_LEFT; format = drawable->color_format; @@ -365,8 +367,8 @@ dri_create_buffer(__DRIscreenPrivate * sPriv, /* TODO incase of double buffer visual, delay fake creation */ i = 0; drawable->attachments[i++] = __DRI_BUFFER_FRONT_LEFT; - drawable->attachments[i++] = __DRI_BUFFER_FAKE_FRONT_LEFT; - + if (!screen->auto_fake_front) + drawable->attachments[i++] = __DRI_BUFFER_FAKE_FRONT_LEFT; if (visual->doubleBufferMode) drawable->attachments[i++] = __DRI_BUFFER_BACK_LEFT; if (visual->depthBits && visual->stencilBits) diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index cb864d45d5..11ea28bcbe 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -289,6 +289,8 @@ dri_init_screen2(__DRIscreenPrivate * sPriv) { struct dri_screen *screen; struct drm_create_screen_arg arg; + const __DRIdri2LoaderExtension *dri2_ext = + sPriv->dri2.loader; screen = CALLOC_STRUCT(dri_screen); if (!screen) @@ -313,6 +315,9 @@ dri_init_screen2(__DRIscreenPrivate * sPriv) driParseOptionInfo(&screen->optionCache, __driConfigOptions, __driNConfigOptions); + screen->auto_fake_front = dri2_ext->base.version >= 3 && + dri2_ext->getBuffersWithFormat != NULL; + return dri_fill_in_modes(screen, 32); fail: return NULL; diff --git a/src/gallium/state_trackers/dri/dri_screen.h b/src/gallium/state_trackers/dri/dri_screen.h index f6c56d0f0c..10319f808b 100644 --- a/src/gallium/state_trackers/dri/dri_screen.h +++ b/src/gallium/state_trackers/dri/dri_screen.h @@ -59,6 +59,7 @@ struct dri_screen struct pipe_screen *pipe_screen; boolean d_depth_bits_last; boolean sd_depth_bits_last; + boolean auto_fake_front; }; /** cast wrapper */ -- cgit v1.2.3 From ae97520e37ee70c813a198c805c7338aefbd8156 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Mon, 18 Jan 2010 15:55:17 +0100 Subject: ws/vmware: Check DRM version also when bootstrapping in dri2 mode. Signed-off-by: Thomas Hellstrom --- src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c index 5995eee34b..7c47d434f0 100644 --- a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c +++ b/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c @@ -85,6 +85,23 @@ vmw_drm_create_screen(struct drm_api *drm_api, struct pipe_screen *screen; struct dri1_create_screen_arg *dri1; + if (!arg || arg->mode == DRM_CREATE_NORMAL) { + struct dri1_api_version drm_ver; + drmVersionPtr ver; + + ver = drmGetVersion(fd); + if (ver == NULL) + return NULL; + + drm_ver.major = ver->version_major; + drm_ver.minor = ver->version_minor; + + drmFreeVersion(ver); + if (!vmw_dri1_check_version(&drm_ver, &drm_required, + &drm_compat, "vmwgfx drm driver")) + return NULL; + } + if (arg != NULL) { switch (arg->mode) { case DRM_CREATE_NORMAL: -- cgit v1.2.3 From 3e1241d4f872cca96616edcbdcaea5b59d37e78f Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 15 Jan 2010 01:14:55 +0000 Subject: st/xorg: Set enforce version to 1 if not defined --- src/gallium/state_trackers/xorg/xorg_dri2.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c index 4fa47548a4..4f03dbae74 100644 --- a/src/gallium/state_trackers/xorg/xorg_dri2.c +++ b/src/gallium/state_trackers/xorg/xorg_dri2.c @@ -43,9 +43,8 @@ #include "util/u_rect.h" /* Make all the #if cases in the code esier to read */ -/* XXX can it be set to 1? */ #ifndef DRI2INFOREC_VERSION -#define DRI2INFOREC_VERSION 0 +#define DRI2INFOREC_VERSION 1 #endif typedef struct { @@ -370,11 +369,7 @@ xorg_dri2_init(ScreenPtr pScreen) modesettingPtr ms = modesettingPTR(pScrn); DRI2InfoRec dri2info; -#if DRI2INFOREC_VERSION >= 2 dri2info.version = DRI2INFOREC_VERSION; -#else - dri2info.version = 1; -#endif dri2info.fd = ms->fd; dri2info.driverName = pScrn->driverName; -- cgit v1.2.3 From ccc888c39ee8a7c460dca5b1b659d28dbbc4c689 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 15 Jan 2010 01:29:13 +0000 Subject: st/xorg: If dri2 version is 2 support version 1 as well Thanks to X server commit 2e2c5b216cc1c7a9bc26bd2c68226aaed5fc52ca it is possible to be ABI compatible in version 2 with version 1 of the DRI2 interface. --- src/gallium/state_trackers/xorg/xorg_dri2.c | 40 ++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c index 4f03dbae74..8267da309f 100644 --- a/src/gallium/state_trackers/xorg/xorg_dri2.c +++ b/src/gallium/state_trackers/xorg/xorg_dri2.c @@ -47,6 +47,10 @@ #define DRI2INFOREC_VERSION 1 #endif +#if DRI2INFOREC_VERSION == 2 +static Bool set_format_in_do_create_buffer; +#endif + typedef struct { PixmapPtr pPixmap; struct pipe_texture *tex; @@ -146,7 +150,9 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int form buffer->driverPrivate = private; buffer->flags = 0; /* not tiled */ #if DRI2INFOREC_VERSION == 2 - ((DRI2Buffer2Ptr)buffer)->format = 0; + /* ABI forwards/backwards compatibility */ + if (set_format_in_do_create_buffer) + ((DRI2Buffer2Ptr)buffer)->format = 0; #elif DRI2INFOREC_VERSION >= 3 buffer->format = 0; #endif @@ -210,7 +216,9 @@ dri2_destroy_buffer(DrawablePtr pDraw, DRI2Buffer2Ptr buffer) xfree(buffer); } -#else /* DRI2INFOREC_VERSION < 2 */ +#endif /* DRI2INFOREC_VERSION >= 2 */ + +#if DRI2INFOREC_VERSION <= 2 static DRI2BufferPtr dri2_create_buffers(DrawablePtr pDraw, unsigned int *attachments, int count) @@ -260,7 +268,7 @@ dri2_destroy_buffers(DrawablePtr pDraw, DRI2BufferPtr buffers, int count) } } -#endif /* DRI2INFOREC_VERSION >= 2 */ +#endif /* DRI2INFOREC_VERSION <= 2 */ static void dri2_copy_region(DrawablePtr pDraw, RegionPtr pRegion, @@ -368,6 +376,15 @@ xorg_dri2_init(ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; modesettingPtr ms = modesettingPTR(pScrn); DRI2InfoRec dri2info; + int major, minor; + + if (xf86LoaderCheckSymbol("DRI2Version")) { + DRI2Version(&major, &minor); + } else { + /* Assume version 1.0 */ + major = 1; + minor = 0; + } dri2info.version = DRI2INFOREC_VERSION; dri2info.fd = ms->fd; @@ -378,7 +395,22 @@ xorg_dri2_init(ScreenPtr pScreen) #if DRI2INFOREC_VERSION >= 2 dri2info.CreateBuffer = dri2_create_buffer; dri2info.DestroyBuffer = dri2_destroy_buffer; -#else +#endif + + /* For X servers in the 1.6.x series there where two DRI2 version. + * This allows us to build one binary that works on both servers. + */ +#if DRI2INFOREC_VERSION == 2 + if (minor == 0) { + set_format_in_do_create_buffer = FALSE; + dri2info.CreateBuffers = dri2_create_buffers; + dri2info.DestroyBuffers = dri2_destroy_buffers; + } else + set_format_in_do_create_buffer = FALSE; +#endif + + /* For version 1 set these unconditionaly. */ +#if DRI2INFOREC_VERSION == 1 dri2info.CreateBuffers = dri2_create_buffers; dri2info.DestroyBuffers = dri2_destroy_buffers; #endif -- cgit v1.2.3 From eedebfa5793844728f1d41a6b0a899825eba176a Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 16 Jan 2010 17:45:34 -0800 Subject: r300g: Respect fill modes in indices fallback. --- src/gallium/drivers/r300/r300_render.c | 17 +++++++++++++++-- src/gallium/drivers/r300/r300_state.c | 3 --- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 710d850163..64083f2dd5 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -257,10 +257,23 @@ static struct pipe_buffer* r300_translate_elts(struct r300_context* r300, struct pipe_buffer* new_elts; void *in_map, *out_map; unsigned out_prim, out_index_size, out_nr; + struct pipe_rasterizer_state* rs; u_translate_func out_translate; - (void)u_index_translator(~0, *mode, *size, *count, PV_LAST, PV_LAST, - &out_prim, &out_index_size, &out_nr, &out_translate); + rs = &((struct r300_rs_state*)r300->rs_state.state)->rs; + + if (rs->fill_cw == rs->fill_ccw && + rs->fill_cw != PIPE_POLYGON_MODE_FILL) { + (void)u_unfilled_translator(*mode, *size, *count, rs->fill_cw, + &out_prim, &out_index_size, &out_nr, &out_translate); + } else { + (void)u_index_translator(~0, *mode, *size, *count, PV_LAST, PV_LAST, + &out_prim, &out_index_size, &out_nr, &out_translate); + } + + debug_printf("r300: old mode %d, new mode %d\n", *mode, out_prim); + debug_printf("r300: old count %d, new count %d\n", *count, out_nr); + debug_printf("r300: old size %d, new size %d\n", *size, out_index_size); new_elts = screen->buffer_create(screen, 32, PIPE_BUFFER_USAGE_INDEX | diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 60ad763cf4..609b910e12 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -602,9 +602,6 @@ static void* r300_create_rs_state(struct pipe_context* pipe, rs->line_control = pack_float_16_6x(state->line_width) | R300_GA_LINE_CNTL_END_TYPE_COMP; - /* XXX I think there is something wrong with the polygon mode, - * XXX re-test when r300g is in a better shape */ - /* Enable polygon mode */ if (state->fill_cw != PIPE_POLYGON_MODE_FILL || state->fill_ccw != PIPE_POLYGON_MODE_FILL) { -- cgit v1.2.3 From c69bd0ead755b695ee5c64dc9efd45c53b299f21 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 16 Jan 2010 18:16:26 -0800 Subject: r300g: Stop using indices. Sorry, it was a good game, but it just doesn't work. --- src/gallium/drivers/r300/r300_render.c | 54 +++++++++++----------------------- 1 file changed, 17 insertions(+), 37 deletions(-) diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 64083f2dd5..90de062bcd 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -26,8 +26,6 @@ #include "draw/draw_context.h" #include "draw/draw_vbuf.h" -#include "indices/u_indices.h" - #include "pipe/p_inlines.h" #include "util/u_memory.h" @@ -247,53 +245,35 @@ validate: return TRUE; } -static struct pipe_buffer* r300_translate_elts(struct r300_context* r300, - struct pipe_buffer* elts, - unsigned* size, - unsigned* mode, - unsigned* count) +static void r300_shorten_ubyte_elts(struct r300_context* r300, + struct pipe_buffer** elts, + unsigned count) { struct pipe_screen* screen = r300->context.screen; struct pipe_buffer* new_elts; - void *in_map, *out_map; - unsigned out_prim, out_index_size, out_nr; - struct pipe_rasterizer_state* rs; - u_translate_func out_translate; - - rs = &((struct r300_rs_state*)r300->rs_state.state)->rs; - - if (rs->fill_cw == rs->fill_ccw && - rs->fill_cw != PIPE_POLYGON_MODE_FILL) { - (void)u_unfilled_translator(*mode, *size, *count, rs->fill_cw, - &out_prim, &out_index_size, &out_nr, &out_translate); - } else { - (void)u_index_translator(~0, *mode, *size, *count, PV_LAST, PV_LAST, - &out_prim, &out_index_size, &out_nr, &out_translate); - } - - debug_printf("r300: old mode %d, new mode %d\n", *mode, out_prim); - debug_printf("r300: old count %d, new count %d\n", *count, out_nr); - debug_printf("r300: old size %d, new size %d\n", *size, out_index_size); + unsigned char *in_map; + unsigned short *out_map; + unsigned i; new_elts = screen->buffer_create(screen, 32, PIPE_BUFFER_USAGE_INDEX | PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_GPU_READ, - out_index_size * out_nr); + 2 * count); - in_map = pipe_buffer_map(screen, elts, PIPE_BUFFER_USAGE_CPU_READ); + in_map = pipe_buffer_map(screen, *elts, PIPE_BUFFER_USAGE_CPU_READ); out_map = pipe_buffer_map(screen, new_elts, PIPE_BUFFER_USAGE_CPU_WRITE); - out_translate(in_map, *count, out_map); + for (i = 0; i < count; i++) { + *out_map = (unsigned short)*in_map; + in_map++; + out_map++; + } - pipe_buffer_unmap(screen, elts); + pipe_buffer_unmap(screen, *elts); pipe_buffer_unmap(screen, new_elts); - *size = out_index_size; - *mode = out_prim; - *count = out_nr; - - return new_elts; + *elts = new_elts; } /* This is the fast-path drawing & emission for HW TCL. */ @@ -327,8 +307,8 @@ void r300_draw_range_elements(struct pipe_context* pipe, } if (indexSize == 1) { - indexBuffer = r300_translate_elts(r300, indexBuffer, - &indexSize, &mode, &count); + r300_shorten_ubyte_elts(r300, &indexBuffer, count); + indexSize = 2; } if (!r300->winsys->add_buffer(r300->winsys, indexBuffer, -- cgit v1.2.3 From 816cb90e7c41ee9cc02a8b12f64b368bd0c2fd03 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 17 Jan 2010 00:55:39 -0800 Subject: radeon_compiler: include main/compiler.h for compiler portability macros Signed-off-by: Alan Coopersmith Reviewed-by: Corbin Simpson --- src/mesa/drivers/dri/r300/compiler/radeon_compiler.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_compiler.h b/src/mesa/drivers/dri/r300/compiler/radeon_compiler.h index 731adc1af2..f27f858652 100644 --- a/src/mesa/drivers/dri/r300/compiler/radeon_compiler.h +++ b/src/mesa/drivers/dri/r300/compiler/radeon_compiler.h @@ -23,6 +23,8 @@ #ifndef RADEON_COMPILER_H #define RADEON_COMPILER_H +#include "../../../../main/compiler.h" + #include "memory_pool.h" #include "radeon_code.h" #include "radeon_program.h" -- cgit v1.2.3 From 37897a65e27842bbbfe32c37d2fcf775a5c127eb Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sat, 16 Jan 2010 00:56:33 +0100 Subject: r300g: fix the CS size when emitting invariant state --- src/gallium/drivers/r300/r300_state_invariant.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/r300/r300_state_invariant.c b/src/gallium/drivers/r300/r300_state_invariant.c index b0f309695c..47d7e60a40 100644 --- a/src/gallium/drivers/r300/r300_state_invariant.c +++ b/src/gallium/drivers/r300/r300_state_invariant.c @@ -79,7 +79,8 @@ void r300_emit_invariant_state(struct r300_context* r300) END_CS; /* XXX unsorted stuff from surface_fill */ - BEGIN_CS(44 + (caps->has_tcl ? 7 : 0) + (caps->is_r500 ? 4 : 0)); + BEGIN_CS(44 + (caps->has_tcl ? 7 : 0) + + (caps->family >= CHIP_FAMILY_RV350 ? 4 : 0)); if (caps->has_tcl) { /*Flushing PVS is required before the VAP_GB registers can be changed*/ -- cgit v1.2.3 From 21f3bbf1495ce44ecde4f353fed9f85e6e0fdd2d Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sat, 16 Jan 2010 00:48:53 +0100 Subject: r300g: disable the MIP filter for NPOT textures Safety first. --- src/gallium/drivers/r300/r300_emit.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 9f93327e59..11bd3346c7 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -705,12 +705,18 @@ void r300_emit_texture(struct r300_context* r300, filter0 |= R300_TX_WRAP_T(R300_TX_CLAMP_TO_EDGE); } - /* determine min/max levels */ - /* the MAX_MIP level is the largest (finest) one */ - max_level = MIN2(sampler->max_lod, tex->tex.last_level); - min_level = MIN2(sampler->min_lod, max_level); - format0 |= R300_TX_NUM_LEVELS(max_level); - filter0 |= R300_TX_MAX_MIP_LEVEL(min_level); + if (tex->is_npot) { + /* NPOT textures don't support mip filter, unfortunately. + * This prevents incorrect rendering. */ + filter0 &= ~R300_TX_MIN_FILTER_MIP_MASK; + } else { + /* determine min/max levels */ + /* the MAX_MIP level is the largest (finest) one */ + max_level = MIN2(sampler->max_lod, tex->tex.last_level); + min_level = MIN2(sampler->min_lod, max_level); + format0 |= R300_TX_NUM_LEVELS(max_level); + filter0 |= R300_TX_MAX_MIP_LEVEL(min_level); + } BEGIN_CS(16); OUT_CS_REG(R300_TX_FILTER0_0 + (offset * 4), filter0 | -- cgit v1.2.3 From 08edbe9f14712f719f838769c61123f83768af76 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sat, 9 Jan 2010 18:38:54 +0100 Subject: r300g: move debug flags into r300_screen --- src/gallium/drivers/r300/r300_context.c | 2 -- src/gallium/drivers/r300/r300_context.h | 39 ++++++++---------------------- src/gallium/drivers/r300/r300_debug.c | 8 +++--- src/gallium/drivers/r300/r300_screen.c | 1 + src/gallium/drivers/r300/r300_screen.h | 43 +++++++++++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 35 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 5e4f6552c3..6bd2b0278f 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -153,8 +153,6 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, r300->context.winsys = (struct pipe_winsys*)radeon_winsys; r300->context.screen = screen; - r300_init_debug(r300); - r300->context.destroy = r300_destroy_context; r300->context.clear = r300_clear; diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 682b9179c8..c65d23823c 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -30,6 +30,8 @@ #include "pipe/p_context.h" #include "pipe/p_inlines.h" +#include "r300_screen.h" + struct r300_context; struct r300_fragment_shader; @@ -324,9 +326,6 @@ struct r300_context { uint32_t dirty_hw; /* Whether the TCL engine should be in bypass mode. */ boolean tcl_bypass; - - /** Combination of DBG_xxx flags */ - unsigned debug; }; /* Convenience cast wrapper. */ @@ -340,35 +339,15 @@ struct draw_stage* r300_draw_stage(struct r300_context* r300); void r300_init_state_functions(struct r300_context* r300); void r300_init_surface_functions(struct r300_context* r300); -/* Debug functionality. */ - -/** - * Debug flags to disable/enable certain groups of debugging outputs. - * - * \note These may be rather coarse, and the grouping may be impractical. - * If you find, while debugging the driver, that a different grouping - * of these flags would be beneficial, just feel free to change them - * but make sure to update the documentation in r300_debug.c to reflect - * those changes. - */ -/*@{*/ -#define DBG_HELP 0x0000001 -#define DBG_FP 0x0000002 -#define DBG_VP 0x0000004 -#define DBG_CS 0x0000008 -#define DBG_DRAW 0x0000010 -#define DBG_TEX 0x0000020 -#define DBG_FALL 0x0000040 -/*@}*/ - -static INLINE boolean DBG_ON(struct r300_context * ctx, unsigned flags) +static INLINE boolean CTX_DBG_ON(struct r300_context * ctx, unsigned flags) { - return (ctx->debug & flags) ? TRUE : FALSE; + return SCREEN_DBG_ON(r300_screen(ctx->context.screen), flags); } -static INLINE void DBG(struct r300_context * ctx, unsigned flags, const char * fmt, ...) +static INLINE void CTX_DBG(struct r300_context * ctx, unsigned flags, + const char * fmt, ...) { - if (DBG_ON(ctx, flags)) { + if (CTX_DBG_ON(ctx, flags)) { va_list va; va_start(va, fmt); debug_vprintf(fmt, va); @@ -376,6 +355,8 @@ static INLINE void DBG(struct r300_context * ctx, unsigned flags, const char * f } } -void r300_init_debug(struct r300_context * ctx); +#define DBG_ON CTX_DBG_ON +#define DBG CTX_DBG #endif /* R300_CONTEXT_H */ + diff --git a/src/gallium/drivers/r300/r300_debug.c b/src/gallium/drivers/r300/r300_debug.c index 2a6ed54ac9..00d4f31c2b 100644 --- a/src/gallium/drivers/r300/r300_debug.c +++ b/src/gallium/drivers/r300/r300_debug.c @@ -46,7 +46,7 @@ static struct debug_option debug_options[] = { { 0, 0, 0 } }; -void r300_init_debug(struct r300_context * ctx) +void r300_init_debug(struct r300_screen * screen) { const char * options = debug_get_option("RADEON_DEBUG", 0); boolean printhint = FALSE; @@ -64,7 +64,7 @@ void r300_init_debug(struct r300_context * ctx) for(opt = debug_options; opt->name; ++opt) { if (!strncmp(options, opt->name, length)) { - ctx->debug |= opt->flag; + screen->debug |= opt->flag; break; } } @@ -77,11 +77,11 @@ void r300_init_debug(struct r300_context * ctx) options += length; } - if (!ctx->debug) + if (!screen->debug) printhint = TRUE; } - if (printhint || ctx->debug & DBG_HELP) { + if (printhint || screen->debug & DBG_HELP) { debug_printf("You can enable debug output by setting the RADEON_DEBUG environment variable\n" "to a comma-separated list of debug options. Available options are:\n"); for(opt = debug_options; opt->name; ++opt) { diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index 287664b1d2..e16d659ec8 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -396,6 +396,7 @@ struct pipe_screen* r300_create_screen(struct radeon_winsys* radeon_winsys) caps->num_frag_pipes = radeon_winsys->gb_pipes; caps->num_z_pipes = radeon_winsys->z_pipes; + r300_init_debug(r300screen); r300_parse_chipset(caps); r300screen->caps = caps; diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h index 2217988add..580fda3984 100644 --- a/src/gallium/drivers/r300/r300_screen.h +++ b/src/gallium/drivers/r300/r300_screen.h @@ -35,6 +35,9 @@ struct r300_screen { /* Chipset capabilities */ struct r300_capabilities* caps; + + /** Combination of DBG_xxx flags */ + unsigned debug; }; struct r300_transfer { @@ -60,4 +63,44 @@ r300_transfer(struct pipe_transfer* transfer) /* Creates a new r300 screen. */ struct pipe_screen* r300_create_screen(struct radeon_winsys* radeon_winsys); +/* Debug functionality. */ + +/** + * Debug flags to disable/enable certain groups of debugging outputs. + * + * \note These may be rather coarse, and the grouping may be impractical. + * If you find, while debugging the driver, that a different grouping + * of these flags would be beneficial, just feel free to change them + * but make sure to update the documentation in r300_debug.c to reflect + * those changes. + */ +/*@{*/ +#define DBG_HELP 0x0000001 +#define DBG_FP 0x0000002 +#define DBG_VP 0x0000004 +#define DBG_CS 0x0000008 +#define DBG_DRAW 0x0000010 +#define DBG_TEX 0x0000020 +#define DBG_FALL 0x0000040 +/*@}*/ + +static INLINE boolean SCREEN_DBG_ON(struct r300_screen * screen, unsigned flags) +{ + return (screen->debug & flags) ? TRUE : FALSE; +} + +static INLINE void SCREEN_DBG(struct r300_screen * screen, unsigned flags, + const char * fmt, ...) +{ + if (SCREEN_DBG_ON(screen, flags)) { + va_list va; + va_start(va, fmt); + debug_vprintf(fmt, va); + va_end(va); + } +} + +void r300_init_debug(struct r300_screen* ctx); + #endif /* R300_SCREEN_H */ + -- cgit v1.2.3 From 8959608051ef8e4a97214323009d09c5e9e633fb Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sat, 9 Jan 2010 19:19:44 +0100 Subject: r300g: output texture debug messages if only RADEON_DEBUG=tex is set --- src/gallium/drivers/r300/r300_context.c | 2 +- src/gallium/drivers/r300/r300_screen.c | 6 ++-- src/gallium/drivers/r300/r300_texture.c | 37 +++++++++++++++---------- src/gallium/drivers/r300/r300_texture.h | 6 ++-- src/gallium/drivers/r300/r300_winsys.h | 3 +- src/gallium/winsys/drm/radeon/core/radeon_drm.c | 7 +++-- src/gallium/winsys/drm/radeon/core/radeon_drm.h | 1 + 7 files changed, 36 insertions(+), 26 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 6bd2b0278f..94a9ab3ef3 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -87,7 +87,7 @@ r300_is_texture_referenced(struct pipe_context *pipe, { struct pipe_buffer* buf = 0; - r300_get_texture_buffer(texture, &buf, NULL); + r300_get_texture_buffer(pipe->screen, texture, &buf, NULL); return pipe->is_buffer_referenced(pipe, buf); } diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index e16d659ec8..d0f2c13df1 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -319,6 +319,7 @@ r300_get_tex_transfer(struct pipe_screen *screen, { struct r300_texture *tex = (struct r300_texture *)texture; struct r300_transfer *trans; + struct r300_screen *rscreen = r300_screen(screen); unsigned offset; offset = r300_texture_get_offset(tex, level, zslice, face); /* in bytes */ @@ -330,11 +331,8 @@ r300_get_tex_transfer(struct pipe_screen *screen, trans->transfer.y = y; trans->transfer.width = w; trans->transfer.height = h; - trans->transfer.stride = r300_texture_get_stride(tex, level); + trans->transfer.stride = r300_texture_get_stride(rscreen, tex, level); trans->transfer.usage = usage; - - /* XXX not sure whether it's required to set these two, - the driver doesn't use them */ trans->transfer.zslice = zslice; trans->transfer.face = face; diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index a9bbdd56d8..c6dd27272b 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -42,10 +42,11 @@ static const unsigned microblock_table[5][3][2] = { {{ 2, 1}, {0, 0}, {0, 0}} /* 128 bits per pixel */ }; -static void r300_setup_texture_state(struct r300_texture* tex, boolean is_r500) +static void r300_setup_texture_state(struct r300_screen* screen, struct r300_texture* tex) { struct r300_texture_state* state = &tex->state; struct pipe_texture *pt = &tex->tex; + boolean is_r500 = screen->caps->is_r500; state->format0 = R300_TX_WIDTH((pt->width0 - 1) & 0x7ff) | R300_TX_HEIGHT((pt->height0 - 1) & 0x7ff); @@ -79,8 +80,8 @@ static void r300_setup_texture_state(struct r300_texture* tex, boolean is_r500) } assert(is_r500 || (pt->width0 <= 2048 && pt->height0 <= 2048)); - debug_printf("r300: Set texture state (%dx%d, %d levels)\n", - pt->width0, pt->height0, pt->last_level); + SCREEN_DBG(screen, DBG_TEX, "r300: Set texture state (%dx%d, %d levels)\n", + pt->width0, pt->height0, pt->last_level); } unsigned r300_texture_get_offset(struct r300_texture* tex, unsigned level, @@ -123,7 +124,8 @@ static unsigned r300_texture_get_tile_size(struct r300_texture* tex, int dim) * Return the stride, in bytes, of the texture images of the given texture * at the given level. */ -unsigned r300_texture_get_stride(struct r300_texture* tex, unsigned level) +unsigned r300_texture_get_stride(struct r300_screen* screen, + struct r300_texture* tex, unsigned level) { unsigned tile_width, width; @@ -132,8 +134,8 @@ unsigned r300_texture_get_stride(struct r300_texture* tex, unsigned level) /* Check the level. */ if (level > tex->tex.last_level) { - debug_printf("%s: level (%u) > last_level (%u)\n", __FUNCTION__, - level, tex->tex.last_level); + SCREEN_DBG(screen, DBG_TEX, "%s: level (%u) > last_level (%u)\n", + __FUNCTION__, level, tex->tex.last_level); return 0; } @@ -155,15 +157,17 @@ static unsigned r300_texture_get_nblocksy(struct r300_texture* tex, return util_format_get_nblocksy(tex->tex.format, height); } -static void r300_setup_miptree(struct r300_texture* tex) +static void r300_setup_miptree(struct r300_screen* screen, + struct r300_texture* tex) { struct pipe_texture* base = &tex->tex; unsigned stride, size, layer_size, nblocksy, i; - debug_printf("r300: Making miptree for texture, format %s\n", pf_name(base->format)); + SCREEN_DBG(screen, DBG_TEX, "r300: Making miptree for texture, format %s\n", + pf_name(base->format)); for (i = 0; i <= base->last_level; i++) { - stride = r300_texture_get_stride(tex, i); + stride = r300_texture_get_stride(screen, tex, i); nblocksy = r300_texture_get_nblocksy(tex, i); layer_size = stride * nblocksy; @@ -177,7 +181,7 @@ static void r300_setup_miptree(struct r300_texture* tex) tex->layer_size[i] = layer_size; tex->pitch[i] = stride / util_format_get_blocksize(base->format); - debug_printf("r300: Texture miptree: Level %d " + SCREEN_DBG(screen, DBG_TEX, "r300: Texture miptree: Level %d " "(%dx%dx%d px, pitch %d bytes) %d bytes total\n", i, u_minify(base->width0, i), u_minify(base->height0, i), u_minify(base->depth0, i), stride, tex->size); @@ -196,6 +200,7 @@ static struct pipe_texture* const struct pipe_texture* template) { struct r300_texture* tex = CALLOC_STRUCT(r300_texture); + struct r300_screen* rscreen = r300_screen(screen); if (!tex) { return NULL; @@ -206,8 +211,8 @@ static struct pipe_texture* tex->tex.screen = screen; r300_setup_flags(tex); - r300_setup_miptree(tex); - r300_setup_texture_state(tex, r300_screen(screen)->caps->is_r500); + r300_setup_miptree(rscreen, tex); + r300_setup_texture_state(rscreen, tex); tex->buffer = screen->buffer_create(screen, 2048, PIPE_BUFFER_USAGE_PIXEL, @@ -273,6 +278,7 @@ static struct pipe_texture* struct pipe_buffer* buffer) { struct r300_texture* tex; + struct r300_screen* rscreen = r300_screen(screen); /* Support only 2D textures without mipmaps */ if (base->target != PIPE_TEXTURE_2D || @@ -294,7 +300,7 @@ static struct pipe_texture* tex->pitch[0] = *stride / util_format_get_blocksize(base->format); r300_setup_flags(tex); - r300_setup_texture_state(tex, r300_screen(screen)->caps->is_r500); + r300_setup_texture_state(rscreen, tex); pipe_buffer_reference(&tex->buffer, buffer); @@ -361,7 +367,8 @@ void r300_init_screen_texture_functions(struct pipe_screen* screen) screen->video_surface_destroy= r300_video_surface_destroy; } -boolean r300_get_texture_buffer(struct pipe_texture* texture, +boolean r300_get_texture_buffer(struct pipe_screen* screen, + struct pipe_texture* texture, struct pipe_buffer** buffer, unsigned* stride) { @@ -373,7 +380,7 @@ boolean r300_get_texture_buffer(struct pipe_texture* texture, pipe_buffer_reference(buffer, tex->buffer); if (stride) { - *stride = r300_texture_get_stride(tex, 0); + *stride = r300_texture_get_stride(r300_screen(screen), tex, 0); } return TRUE; diff --git a/src/gallium/drivers/r300/r300_texture.h b/src/gallium/drivers/r300/r300_texture.h index 55ceb1a513..1be1e6843c 100644 --- a/src/gallium/drivers/r300/r300_texture.h +++ b/src/gallium/drivers/r300/r300_texture.h @@ -31,7 +31,8 @@ struct r300_texture; void r300_init_screen_texture_functions(struct pipe_screen* screen); -unsigned r300_texture_get_stride(struct r300_texture* tex, unsigned level); +unsigned r300_texture_get_stride(struct r300_screen* screen, + struct r300_texture* tex, unsigned level); unsigned r300_texture_get_offset(struct r300_texture* tex, unsigned level, unsigned zslice, unsigned face); @@ -115,7 +116,8 @@ r300_video_surface(struct pipe_video_surface *pvs) #ifndef R300_WINSYS_H -boolean r300_get_texture_buffer(struct pipe_texture* texture, +boolean r300_get_texture_buffer(struct pipe_screen* screen, + struct pipe_texture* texture, struct pipe_buffer** buffer, unsigned* stride); diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h index 1ae6de70fe..bdb8b54bab 100644 --- a/src/gallium/drivers/r300/r300_winsys.h +++ b/src/gallium/drivers/r300/r300_winsys.h @@ -40,7 +40,8 @@ extern "C" { struct pipe_context* r300_create_context(struct pipe_screen* screen, struct radeon_winsys* radeon_winsys); -boolean r300_get_texture_buffer(struct pipe_texture* texture, +boolean r300_get_texture_buffer(struct pipe_screen* screen, + struct pipe_texture* texture, struct pipe_buffer** buffer, unsigned* stride); diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c index 851c223697..dd73b33ee0 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c @@ -136,12 +136,13 @@ struct pipe_context* radeon_create_context(struct drm_api* api, } boolean radeon_buffer_from_texture(struct drm_api* api, + struct pipe_screen* screen, struct pipe_texture* texture, struct pipe_buffer** buffer, unsigned* stride) { /* XXX fix this */ - return r300_get_texture_buffer(texture, buffer, stride); + return r300_get_texture_buffer(screen, texture, buffer, stride); } /* Create a buffer from a handle. */ @@ -208,7 +209,7 @@ static boolean radeon_shared_handle_from_texture(struct drm_api *api, struct radeon_pipe_buffer* radeon_buffer; struct pipe_buffer *buffer = NULL; - if (!radeon_buffer_from_texture(api, texture, &buffer, stride)) { + if (!radeon_buffer_from_texture(api, screen, texture, &buffer, stride)) { return FALSE; } @@ -240,7 +241,7 @@ static boolean radeon_local_handle_from_texture(struct drm_api *api, unsigned *handle) { struct pipe_buffer *buffer = NULL; - if (!radeon_buffer_from_texture(api, texture, &buffer, stride)) { + if (!radeon_buffer_from_texture(api, screen, texture, &buffer, stride)) { return FALSE; } diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.h b/src/gallium/winsys/drm/radeon/core/radeon_drm.h index bf0e78138d..28f2ba818e 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.h @@ -56,6 +56,7 @@ struct pipe_context* radeon_create_context(struct drm_api* api, struct pipe_screen* screen); boolean radeon_buffer_from_texture(struct drm_api* api, + struct pipe_screen* screen, struct pipe_texture* texture, struct pipe_buffer** buffer, unsigned* stride); -- cgit v1.2.3 From c4a2f13a5c59f3527e4e04cb2d8f55e639e1fd46 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 17 Jan 2010 02:25:50 +0100 Subject: r300g: simplify is_format_supported --- src/gallium/drivers/r300/r300_screen.c | 57 +++++++--------------------------- 1 file changed, 11 insertions(+), 46 deletions(-) diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index d0f2c13df1..e9727e99df 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -183,10 +183,14 @@ static float r300_get_paramf(struct pipe_screen* pscreen, int param) } } -static boolean check_tex_format(enum pipe_format format, uint32_t usage, - boolean is_r500) +static boolean r300_is_format_supported(struct pipe_screen* screen, + enum pipe_format format, + enum pipe_texture_target target, + unsigned usage, + unsigned geom_flags) { uint32_t retval = 0; + boolean is_r500 = r300_screen(screen)->caps->is_r500; switch (format) { /* Supported formats. */ @@ -247,28 +251,13 @@ static boolean check_tex_format(enum pipe_format format, uint32_t usage, case PIPE_FORMAT_Z32_UNORM: case PIPE_FORMAT_S8Z24_UNORM: case PIPE_FORMAT_X8Z24_UNORM: - debug_printf("r300: Note: Got unsupported format: %s in %s\n", - pf_name(format), __FUNCTION__); + SCREEN_DBG(r300_screen(screen), DBG_TEX, + "r300: Note: Got unsupported format: %s in %s\n", + pf_name(format), __FUNCTION__); return FALSE; - /* XXX These don't even exist - case PIPE_FORMAT_A32R32G32B32: - case PIPE_FORMAT_A16R16G16B16: */ - /* XXX What the deuce is UV88? (r3xx accel page 14) - debug_printf("r300: Warning: Got unimplemented format: %s in %s\n", - pf_name(format), __FUNCTION__); - return FALSE; */ - - /* XXX Supported yet unimplemented r5xx formats: */ - /* XXX Again, what is UV1010 this time? (r5xx accel page 148) */ - /* XXX Even more that don't exist - case PIPE_FORMAT_A10R10G10B10_UNORM: - case PIPE_FORMAT_A2R10G10B10_UNORM: - case PIPE_FORMAT_I10_UNORM: - debug_printf( - "r300: Warning: Got unimplemented r500 format: %s in %s\n", - pf_name(format), __FUNCTION__); - return FALSE; */ + /* XXX Add all remaining gallium-supported formats, + * see util/u_format.csv. */ default: /* Unknown format... */ @@ -286,30 +275,6 @@ static boolean check_tex_format(enum pipe_format format, uint32_t usage, return (retval >= usage); } -static boolean r300_is_format_supported(struct pipe_screen* pscreen, - enum pipe_format format, - enum pipe_texture_target target, - unsigned tex_usage, - unsigned geom_flags) -{ - switch (target) { - case PIPE_TEXTURE_1D: /* handle 1D textures as 2D ones */ - case PIPE_TEXTURE_2D: - case PIPE_TEXTURE_3D: - case PIPE_TEXTURE_CUBE: - return check_tex_format(format, tex_usage, - r300_screen(pscreen)->caps->is_r500); - - default: - debug_printf("r300: Fatal: This is not a format target: %d\n", - target); - assert(0); - break; - } - - return FALSE; -} - static struct pipe_transfer* r300_get_tex_transfer(struct pipe_screen *screen, struct pipe_texture *texture, -- cgit v1.2.3 From 7d3090f0fe41757582729bb5a580ad5b9a03f765 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 17 Jan 2010 04:41:51 +0100 Subject: r300g: fix vertex colors with 8 bits per channel The piglit BGRA tests pass now. --- src/gallium/drivers/r300/r300_state_inlines.h | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index 35be00e1b0..a9ee0a26f1 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -537,6 +537,7 @@ r300_translate_vertex_data_type(enum pipe_format format) { static INLINE uint16_t r300_translate_vertex_data_swizzle(enum pipe_format format) { const struct util_format_description *desc = util_format_description(format); + unsigned swizzle[4], i; assert(format); @@ -547,11 +548,22 @@ r300_translate_vertex_data_swizzle(enum pipe_format format) { return 0; } - return ((desc->swizzle[0] << R300_SWIZZLE_SELECT_X_SHIFT) | - (desc->swizzle[1] << R300_SWIZZLE_SELECT_Y_SHIFT) | - (desc->swizzle[2] << R300_SWIZZLE_SELECT_Z_SHIFT) | - (desc->swizzle[3] << R300_SWIZZLE_SELECT_W_SHIFT) | - (0xf << R300_WRITE_ENA_SHIFT)); + /* Swizzles for 8bits formats are in the reversed order, not sure why. */ + if (desc->channel[0].size == 8) { + for (i = 0; i < 4; i++) { + swizzle[i] = 3 - desc->swizzle[i]; + } + } else { + for (i = 0; i < 4; i++) { + swizzle[i] = desc->swizzle[i]; + } + } + + return ((swizzle[0] << R300_SWIZZLE_SELECT_X_SHIFT) | + (swizzle[1] << R300_SWIZZLE_SELECT_Y_SHIFT) | + (swizzle[2] << R300_SWIZZLE_SELECT_Z_SHIFT) | + (swizzle[3] << R300_SWIZZLE_SELECT_W_SHIFT) | + (0xf << R300_WRITE_ENA_SHIFT)); } #endif /* R300_STATE_INLINES_H */ -- cgit v1.2.3 From b62d339301f32d29c0a0fdaba2a0e192bff42c23 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 17 Jan 2010 04:49:07 +0100 Subject: r300g: fix the rasterization of secondary color When the secondary color is used, the primary color must always be rasterized regardless of whether it is used or not. --- src/gallium/drivers/r300/r300_state_derived.c | 3 ++- src/gallium/drivers/r300/r300_vs.c | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 192846411b..99c2720897 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -350,7 +350,8 @@ static void r300_update_rs_block(struct r300_context* r300, /* Rasterize colors. */ for (i = 0; i < ATTR_COLOR_COUNT; i++) { - if (vs_outputs->color[i] != ATTR_UNUSED || any_bcolor_used) { + if (vs_outputs->color[i] != ATTR_UNUSED || any_bcolor_used || + vs_outputs->color[1] != ATTR_UNUSED) { /* Always rasterize if it's written by the VS, * otherwise it locks up. */ rX00_rs_col(rs, col_count, i, FALSE); diff --git a/src/gallium/drivers/r300/r300_vs.c b/src/gallium/drivers/r300/r300_vs.c index 68aef70872..9fbb830047 100644 --- a/src/gallium/drivers/r300/r300_vs.c +++ b/src/gallium/drivers/r300/r300_vs.c @@ -124,7 +124,8 @@ static void r300_shader_vap_output_fmt(struct r300_vertex_shader* vs) /* Colors. */ for (i = 0; i < ATTR_COLOR_COUNT; i++) { - if (vs_outputs->color[i] != ATTR_UNUSED || any_bcolor_used) { + if (vs_outputs->color[i] != ATTR_UNUSED || any_bcolor_used || + vs_outputs->color[1] != ATTR_UNUSED) { hwfmt[1] |= R300_INPUT_CNTL_COLOR; hwfmt[2] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT << i; } @@ -182,7 +183,8 @@ static void r300_stream_locations_notcl( /* Colors. */ for (i = 0; i < ATTR_COLOR_COUNT; i++) { - if (vs_outputs->color[i] != ATTR_UNUSED || any_bcolor_used) { + if (vs_outputs->color[i] != ATTR_UNUSED || any_bcolor_used || + vs_outputs->color[1] != ATTR_UNUSED) { stream_loc[tabi++] = 2 + i; } } @@ -259,7 +261,8 @@ static void set_vertex_inputs_outputs(struct r300_vertex_program_compiler * c) for (i = 0; i < ATTR_COLOR_COUNT; i++) { if (outputs->color[i] != ATTR_UNUSED) { c->code->outputs[outputs->color[i]] = reg++; - } else if (any_bcolor_used) { + } else if (any_bcolor_used || + outputs->color[1] != ATTR_UNUSED) { reg++; } } -- cgit v1.2.3 From 945cea01d9620ddd6a459e30517080e2bceb6bc5 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sun, 17 Jan 2010 01:13:45 -0800 Subject: r300g: Check for bogus texture targets. --- src/gallium/drivers/r300/r300_screen.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index e9727e99df..67325c6b80 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -192,6 +192,12 @@ static boolean r300_is_format_supported(struct pipe_screen* screen, uint32_t retval = 0; boolean is_r500 = r300_screen(screen)->caps->is_r500; + if (target >= PIPE_MAX_TEXTURE_TYPES) { + debug_printf("r300: Implementation error: Received bogus texture " + "target %d in %s\n", target, __FUNCTION__); + return FALSE; + } + switch (format) { /* Supported formats. */ /* Colorbuffer */ -- cgit v1.2.3 From 31c626811a20d74f28cee4c96a756ade2ca81141 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 17 Jan 2010 12:21:56 +0000 Subject: i965g: Link against drm_intel instead of drm_radeon --- src/gallium/winsys/drm/i965/xorg/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/winsys/drm/i965/xorg/Makefile b/src/gallium/winsys/drm/i965/xorg/Makefile index 65d521fc1c..c25726b0bb 100644 --- a/src/gallium/winsys/drm/i965/xorg/Makefile +++ b/src/gallium/winsys/drm/i965/xorg/Makefile @@ -36,7 +36,7 @@ all default: $(TARGET) $(TARGET_STAGING) $(TARGET): $(OBJECTS) Makefile $(GALLIUMDIR)/state_trackers/xorg/libxorgtracker.a $(LIBS) $(TOP)/bin/mklib -noprefix -o $@ \ - $(OBJECTS) $(LIBS) $(shell pkg-config --libs libdrm) -ldrm_radeon + $(OBJECTS) $(LIBS) $(shell pkg-config --libs libdrm) -ldrm_intel $(TOP)/$(LIB_DIR)/gallium: mkdir -p $@ -- cgit v1.2.3 From 876a6b4865a5ab422b6d80d6248cf66a42869172 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 17 Jan 2010 14:40:49 +0000 Subject: gallium: Support swig "compiler" in p_compiler.h --- src/gallium/include/pipe/p_compiler.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gallium/include/pipe/p_compiler.h b/src/gallium/include/pipe/p_compiler.h index 18ebd0c948..819f27f6df 100644 --- a/src/gallium/include/pipe/p_compiler.h +++ b/src/gallium/include/pipe/p_compiler.h @@ -162,6 +162,13 @@ typedef unsigned char boolean; #define PIPE_ALIGN_STACK +#elif defined(SWIG) + +#define PIPE_ALIGN_TYPE(_alignment, _type) _type +#define PIPE_ALIGN_VAR(_alignment) + +#define PIPE_ALIGN_STACK + #else #error "Unsupported compiler" -- cgit v1.2.3 From 0e4e2c57d1b5659ba4fce2f9077fb6d4c7fd18d5 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 17 Jan 2010 16:24:53 +0000 Subject: st/xlib: Make glXGetProcAddressARB visible --- src/gallium/state_trackers/glx/xlib/glx_getproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/glx/xlib/glx_getproc.c b/src/gallium/state_trackers/glx/xlib/glx_getproc.c index 84d47b12ed..bd4a85caa0 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_getproc.c +++ b/src/gallium/state_trackers/glx/xlib/glx_getproc.c @@ -193,7 +193,7 @@ _glxapi_get_proc_address(const char *funcName) } -__GLXextFuncPtr +PUBLIC __GLXextFuncPtr glXGetProcAddressARB(const GLubyte *procName) { __GLXextFuncPtr f; -- cgit v1.2.3 From a4bbabf494a127dcffc51f9c4734f2ecf75b3961 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 17 Jan 2010 14:18:26 +0000 Subject: softpipe: Move st/python's malloc winsys to softpipe Users of softpipe can still specify thier own winsys but now there is a default one also that uses malloc. This allows the malloc winsys to be shared with other users of softpipe. --- src/gallium/drivers/softpipe/Makefile | 3 +- src/gallium/drivers/softpipe/SConscript | 1 + src/gallium/drivers/softpipe/sp_winsys.c | 245 +++++++++++++++++++++ src/gallium/drivers/softpipe/sp_winsys.h | 13 +- .../state_trackers/python/st_softpipe_winsys.c | 219 +----------------- 5 files changed, 260 insertions(+), 221 deletions(-) create mode 100644 src/gallium/drivers/softpipe/sp_winsys.c diff --git a/src/gallium/drivers/softpipe/Makefile b/src/gallium/drivers/softpipe/Makefile index bcb887a0b2..e4ac49fa85 100644 --- a/src/gallium/drivers/softpipe/Makefile +++ b/src/gallium/drivers/softpipe/Makefile @@ -32,6 +32,7 @@ C_SOURCES = \ sp_tex_tile_cache.c \ sp_tile_cache.c \ sp_surface.c \ - sp_video_context.c + sp_video_context.c \ + sp_winsys.c include ../../Makefile.template diff --git a/src/gallium/drivers/softpipe/SConscript b/src/gallium/drivers/softpipe/SConscript index aac9edf44e..3042e556c6 100644 --- a/src/gallium/drivers/softpipe/SConscript +++ b/src/gallium/drivers/softpipe/SConscript @@ -34,6 +34,7 @@ softpipe = env.ConvenienceLibrary( 'sp_texture.c', 'sp_tile_cache.c', 'sp_video_context.c', + 'sp_winsys.c' ]) Export('softpipe') diff --git a/src/gallium/drivers/softpipe/sp_winsys.c b/src/gallium/drivers/softpipe/sp_winsys.c new file mode 100644 index 0000000000..8169071dc9 --- /dev/null +++ b/src/gallium/drivers/softpipe/sp_winsys.c @@ -0,0 +1,245 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA + * All Rights Reserved. + * + * 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, sub license, 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 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * + **************************************************************************/ + +/** + * @file + * Malloc softpipe winsys. Uses malloc for all memory allocations. + * + * @author Keith Whitwell + * @author Brian Paul + * @author Jose Fonseca + */ + + +#include "pipe/internal/p_winsys_screen.h"/* port to just p_screen */ +#include "pipe/p_format.h" +#include "pipe/p_context.h" +#include "pipe/p_inlines.h" +#include "util/u_format.h" +#include "util/u_math.h" +#include "util/u_memory.h" +#include "softpipe/sp_winsys.h" + + +struct st_softpipe_buffer +{ + struct pipe_buffer base; + boolean userBuffer; /** Is this a user-space buffer? */ + void *data; + void *mapped; +}; + + +/** Cast wrapper */ +static INLINE struct st_softpipe_buffer * +st_softpipe_buffer( struct pipe_buffer *buf ) +{ + return (struct st_softpipe_buffer *)buf; +} + + +static void * +st_softpipe_buffer_map(struct pipe_winsys *winsys, + struct pipe_buffer *buf, + unsigned flags) +{ + struct st_softpipe_buffer *st_softpipe_buf = st_softpipe_buffer(buf); + st_softpipe_buf->mapped = st_softpipe_buf->data; + return st_softpipe_buf->mapped; +} + + +static void +st_softpipe_buffer_unmap(struct pipe_winsys *winsys, + struct pipe_buffer *buf) +{ + struct st_softpipe_buffer *st_softpipe_buf = st_softpipe_buffer(buf); + st_softpipe_buf->mapped = NULL; +} + + +static void +st_softpipe_buffer_destroy(struct pipe_buffer *buf) +{ + struct st_softpipe_buffer *oldBuf = st_softpipe_buffer(buf); + + if (oldBuf->data) { + if (!oldBuf->userBuffer) + align_free(oldBuf->data); + + oldBuf->data = NULL; + } + + FREE(oldBuf); +} + + +static void +st_softpipe_flush_frontbuffer(struct pipe_winsys *winsys, + struct pipe_surface *surf, + void *context_private) +{ +} + + + +static const char * +st_softpipe_get_name(struct pipe_winsys *winsys) +{ + return "softpipe"; +} + + +static struct pipe_buffer * +st_softpipe_buffer_create(struct pipe_winsys *winsys, + unsigned alignment, + unsigned usage, + unsigned size) +{ + struct st_softpipe_buffer *buffer = CALLOC_STRUCT(st_softpipe_buffer); + + pipe_reference_init(&buffer->base.reference, 1); + buffer->base.alignment = alignment; + buffer->base.usage = usage; + buffer->base.size = size; + + buffer->data = align_malloc(size, alignment); + + return &buffer->base; +} + + +/** + * Create buffer which wraps user-space data. + */ +static struct pipe_buffer * +st_softpipe_user_buffer_create(struct pipe_winsys *winsys, + void *ptr, + unsigned bytes) +{ + struct st_softpipe_buffer *buffer; + + buffer = CALLOC_STRUCT(st_softpipe_buffer); + if(!buffer) + return NULL; + + pipe_reference_init(&buffer->base.reference, 1); + buffer->base.size = bytes; + buffer->userBuffer = TRUE; + buffer->data = ptr; + + return &buffer->base; +} + + +static struct pipe_buffer * +st_softpipe_surface_buffer_create(struct pipe_winsys *winsys, + unsigned width, unsigned height, + enum pipe_format format, + unsigned usage, + unsigned tex_usage, + unsigned *stride) +{ + const unsigned alignment = 64; + unsigned nblocksy; + + nblocksy = util_format_get_nblocksy(format, height); + *stride = align(util_format_get_stride(format, width), alignment); + + return winsys->buffer_create(winsys, alignment, + usage, + *stride * nblocksy); +} + + +static void +st_softpipe_fence_reference(struct pipe_winsys *winsys, + struct pipe_fence_handle **ptr, + struct pipe_fence_handle *fence) +{ +} + + +static int +st_softpipe_fence_signalled(struct pipe_winsys *winsys, + struct pipe_fence_handle *fence, + unsigned flag) +{ + return 0; +} + + +static int +st_softpipe_fence_finish(struct pipe_winsys *winsys, + struct pipe_fence_handle *fence, + unsigned flag) +{ + return 0; +} + + +static void +st_softpipe_destroy(struct pipe_winsys *winsys) +{ + FREE(winsys); +} + + +struct pipe_screen * +softpipe_create_screen_malloc(void) +{ + static struct pipe_winsys *winsys; + struct pipe_screen *screen; + + winsys = CALLOC_STRUCT(pipe_winsys); + if(!winsys) + return NULL; + + winsys->destroy = st_softpipe_destroy; + + winsys->buffer_create = st_softpipe_buffer_create; + winsys->user_buffer_create = st_softpipe_user_buffer_create; + winsys->buffer_map = st_softpipe_buffer_map; + winsys->buffer_unmap = st_softpipe_buffer_unmap; + winsys->buffer_destroy = st_softpipe_buffer_destroy; + + winsys->surface_buffer_create = st_softpipe_surface_buffer_create; + + winsys->fence_reference = st_softpipe_fence_reference; + winsys->fence_signalled = st_softpipe_fence_signalled; + winsys->fence_finish = st_softpipe_fence_finish; + + winsys->flush_frontbuffer = st_softpipe_flush_frontbuffer; + winsys->get_name = st_softpipe_get_name; + + screen = softpipe_create_screen(winsys); + if(!screen) + st_softpipe_destroy(winsys); + + return screen; +} diff --git a/src/gallium/drivers/softpipe/sp_winsys.h b/src/gallium/drivers/softpipe/sp_winsys.h index f203ded29e..3042e01a05 100644 --- a/src/gallium/drivers/softpipe/sp_winsys.h +++ b/src/gallium/drivers/softpipe/sp_winsys.h @@ -49,10 +49,17 @@ struct pipe_buffer; struct pipe_context *softpipe_create( struct pipe_screen * ); +/** + * Create a softpipe screen that uses the + * given winsys for allocating buffers. + */ +struct pipe_screen *softpipe_create_screen( struct pipe_winsys * ); -struct pipe_screen * -softpipe_create_screen(struct pipe_winsys *); - +/** + * Create a softpipe screen that uses + * regular malloc to create all its buffers. + */ +struct pipe_screen *softpipe_create_screen_malloc(void); boolean softpipe_get_texture_buffer( struct pipe_texture *texture, diff --git a/src/gallium/state_trackers/python/st_softpipe_winsys.c b/src/gallium/state_trackers/python/st_softpipe_winsys.c index a3294e877a..dfe3e465f7 100644 --- a/src/gallium/state_trackers/python/st_softpipe_winsys.c +++ b/src/gallium/state_trackers/python/st_softpipe_winsys.c @@ -35,225 +35,10 @@ * @author Jose Fonseca */ - -#include "pipe/internal/p_winsys_screen.h"/* port to just p_screen */ -#include "pipe/p_format.h" -#include "pipe/p_context.h" -#include "pipe/p_inlines.h" -#include "util/u_format.h" -#include "util/u_math.h" -#include "util/u_memory.h" #include "softpipe/sp_winsys.h" #include "st_winsys.h" - -struct st_softpipe_buffer -{ - struct pipe_buffer base; - boolean userBuffer; /** Is this a user-space buffer? */ - void *data; - void *mapped; -}; - - -/** Cast wrapper */ -static INLINE struct st_softpipe_buffer * -st_softpipe_buffer( struct pipe_buffer *buf ) -{ - return (struct st_softpipe_buffer *)buf; -} - - -static void * -st_softpipe_buffer_map(struct pipe_winsys *winsys, - struct pipe_buffer *buf, - unsigned flags) -{ - struct st_softpipe_buffer *st_softpipe_buf = st_softpipe_buffer(buf); - st_softpipe_buf->mapped = st_softpipe_buf->data; - return st_softpipe_buf->mapped; -} - - -static void -st_softpipe_buffer_unmap(struct pipe_winsys *winsys, - struct pipe_buffer *buf) -{ - struct st_softpipe_buffer *st_softpipe_buf = st_softpipe_buffer(buf); - st_softpipe_buf->mapped = NULL; -} - - -static void -st_softpipe_buffer_destroy(struct pipe_buffer *buf) -{ - struct st_softpipe_buffer *oldBuf = st_softpipe_buffer(buf); - - if (oldBuf->data) { - if (!oldBuf->userBuffer) - align_free(oldBuf->data); - - oldBuf->data = NULL; - } - - FREE(oldBuf); -} - - -static void -st_softpipe_flush_frontbuffer(struct pipe_winsys *winsys, - struct pipe_surface *surf, - void *context_private) -{ -} - - - -static const char * -st_softpipe_get_name(struct pipe_winsys *winsys) -{ - return "softpipe"; -} - - -static struct pipe_buffer * -st_softpipe_buffer_create(struct pipe_winsys *winsys, - unsigned alignment, - unsigned usage, - unsigned size) -{ - struct st_softpipe_buffer *buffer = CALLOC_STRUCT(st_softpipe_buffer); - - pipe_reference_init(&buffer->base.reference, 1); - buffer->base.alignment = alignment; - buffer->base.usage = usage; - buffer->base.size = size; - - buffer->data = align_malloc(size, alignment); - - return &buffer->base; -} - - -/** - * Create buffer which wraps user-space data. - */ -static struct pipe_buffer * -st_softpipe_user_buffer_create(struct pipe_winsys *winsys, - void *ptr, - unsigned bytes) -{ - struct st_softpipe_buffer *buffer; - - buffer = CALLOC_STRUCT(st_softpipe_buffer); - if(!buffer) - return NULL; - - pipe_reference_init(&buffer->base.reference, 1); - buffer->base.size = bytes; - buffer->userBuffer = TRUE; - buffer->data = ptr; - - return &buffer->base; -} - - -static struct pipe_buffer * -st_softpipe_surface_buffer_create(struct pipe_winsys *winsys, - unsigned width, unsigned height, - enum pipe_format format, - unsigned usage, - unsigned tex_usage, - unsigned *stride) -{ - const unsigned alignment = 64; - unsigned nblocksy; - - nblocksy = util_format_get_nblocksy(format, height); - *stride = align(util_format_get_stride(format, width), alignment); - - return winsys->buffer_create(winsys, alignment, - usage, - *stride * nblocksy); -} - - -static void -st_softpipe_fence_reference(struct pipe_winsys *winsys, - struct pipe_fence_handle **ptr, - struct pipe_fence_handle *fence) -{ -} - - -static int -st_softpipe_fence_signalled(struct pipe_winsys *winsys, - struct pipe_fence_handle *fence, - unsigned flag) -{ - return 0; -} - - -static int -st_softpipe_fence_finish(struct pipe_winsys *winsys, - struct pipe_fence_handle *fence, - unsigned flag) -{ - return 0; -} - - -static void -st_softpipe_destroy(struct pipe_winsys *winsys) -{ - FREE(winsys); -} - - -static struct pipe_screen * -st_softpipe_screen_create(void) -{ - static struct pipe_winsys *winsys; - struct pipe_screen *screen; - - winsys = CALLOC_STRUCT(pipe_winsys); - if(!winsys) - return NULL; - - winsys->destroy = st_softpipe_destroy; - - winsys->buffer_create = st_softpipe_buffer_create; - winsys->user_buffer_create = st_softpipe_user_buffer_create; - winsys->buffer_map = st_softpipe_buffer_map; - winsys->buffer_unmap = st_softpipe_buffer_unmap; - winsys->buffer_destroy = st_softpipe_buffer_destroy; - - winsys->surface_buffer_create = st_softpipe_surface_buffer_create; - - winsys->fence_reference = st_softpipe_fence_reference; - winsys->fence_signalled = st_softpipe_fence_signalled; - winsys->fence_finish = st_softpipe_fence_finish; - - winsys->flush_frontbuffer = st_softpipe_flush_frontbuffer; - winsys->get_name = st_softpipe_get_name; - - screen = softpipe_create_screen(winsys); - if(!screen) - st_softpipe_destroy(winsys); - - return screen; -} - - -static struct pipe_context * -st_softpipe_context_create(struct pipe_screen *screen) -{ - return softpipe_create(screen); -} - - const struct st_winsys st_softpipe_winsys = { - &st_softpipe_screen_create, - &st_softpipe_context_create, + &softpipe_create_screen_malloc, + &softpipe_create, }; -- cgit v1.2.3 From 1448d2f252efc1ab8d3175c7fd9701dfe3079577 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sun, 17 Jan 2010 17:37:55 +0100 Subject: nv50: implement instanced drawing Too bad we don't have hw array divisors or a method for setting startInstance. --- src/gallium/drivers/nv50/nv50_context.c | 2 + src/gallium/drivers/nv50/nv50_context.h | 16 +- src/gallium/drivers/nv50/nv50_program.c | 22 +- src/gallium/drivers/nv50/nv50_screen.c | 16 +- src/gallium/drivers/nv50/nv50_screen.h | 2 + src/gallium/drivers/nv50/nv50_state_validate.c | 3 + src/gallium/drivers/nv50/nv50_vbo.c | 292 ++++++++++++++++++++++--- 7 files changed, 314 insertions(+), 39 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_context.c b/src/gallium/drivers/nv50/nv50_context.c index 22a8498c69..1e69746322 100644 --- a/src/gallium/drivers/nv50/nv50_context.c +++ b/src/gallium/drivers/nv50/nv50_context.c @@ -104,7 +104,9 @@ nv50_create(struct pipe_screen *pscreen, unsigned pctx_id) nv50->pipe.destroy = nv50_destroy; nv50->pipe.draw_arrays = nv50_draw_arrays; + nv50->pipe.draw_arrays_instanced = nv50_draw_arrays_instanced; nv50->pipe.draw_elements = nv50_draw_elements; + nv50->pipe.draw_elements_instanced = nv50_draw_elements_instanced; nv50->pipe.clear = nv50_clear; nv50->pipe.flush = nv50_flush; diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index d024be6ea9..bebcd95054 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -29,9 +29,7 @@ #define NV50_CB_PVP 1 #define NV50_CB_PFP 2 #define NV50_CB_PGP 3 -#define NV50_CB_TIC 4 -#define NV50_CB_TSC 5 -#define NV50_CB_PUPLOAD 6 +#define NV50_CB_AUX 4 #define NV50_NEW_BLEND (1 << 0) #define NV50_NEW_ZSA (1 << 1) @@ -137,6 +135,7 @@ struct nv50_state { struct nouveau_stateobj *vtxfmt; struct nouveau_stateobj *vtxbuf; struct nouveau_stateobj *vtxattr; + struct nouveau_stateobj *instbuf; unsigned vtxelt_nr; }; @@ -198,11 +197,22 @@ extern struct draw_stage *nv50_draw_render_stage(struct nv50_context *nv50); /* nv50_vbo.c */ extern void nv50_draw_arrays(struct pipe_context *, unsigned mode, unsigned start, unsigned count); +extern void nv50_draw_arrays_instanced(struct pipe_context *, unsigned mode, + unsigned start, unsigned count, + unsigned startInstance, + unsigned instanceCount); extern void nv50_draw_elements(struct pipe_context *pipe, struct pipe_buffer *indexBuffer, unsigned indexSize, unsigned mode, unsigned start, unsigned count); +extern void nv50_draw_elements_instanced(struct pipe_context *pipe, + struct pipe_buffer *indexBuffer, + unsigned indexSize, + unsigned mode, unsigned start, + unsigned count, + unsigned startInstance, + unsigned instanceCount); extern void nv50_vbo_validate(struct nv50_context *nv50); /* nv50_clear.c */ diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index acd695b39b..4111d212e6 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -95,6 +95,8 @@ struct nv50_reg { int vtx; /* vertex index, for GP inputs (TGSI Dimension.Index) */ int indirect[2]; /* index into pc->addr, or -1 */ + + ubyte buf_index; /* c{0 .. 15}[] or g{0 .. 15}[] */ }; #define NV50_MOD_NEG 1 @@ -188,6 +190,7 @@ ctor_reg(struct nv50_reg *reg, unsigned type, int index, int hw) reg->vtx = -1; reg->acc = 0; reg->indirect[0] = reg->indirect[1] = -1; + reg->buf_index = (type == P_CONST) ? 1 : 0; } static INLINE unsigned @@ -631,7 +634,7 @@ set_data(struct nv50_pc *pc, struct nv50_reg *src, unsigned m, unsigned s, set_addr(e, pc->addr[src->indirect[0]]); } - e->inst[1] |= (((src->type == P_IMMD) ? 0 : 1) << 22); + e->inst[1] |= (src->buf_index << 22); } /* Never apply nv50_reg::mod in emit_mov, or carefully check the code !!! */ @@ -3482,6 +3485,19 @@ load_frontfacing(struct nv50_pc *pc, struct nv50_reg *sv) free_temp(pc, temp); } +static void +load_instance_id(struct nv50_pc *pc, unsigned index) +{ + struct nv50_reg reg, mem; + + ctor_reg(®, P_TEMP, -1, -1); + ctor_reg(&mem, P_CONST, -1, 24); /* startInstance */ + mem.buf_index = 2; + + emit_add_b32(pc, ®, &pc->sysval[index], &mem); + pc->sysval[index] = reg; +} + static void copy_semantic_info(struct nv50_program *p) { @@ -3668,8 +3684,10 @@ nv50_program_tx_prep(struct nv50_pc *pc) } if (p->cfg.regs[0] & (1 << 0)) pc->sysval[vertex_id].hw = rid++; - if (p->cfg.regs[0] & (1 << 4)) + if (p->cfg.regs[0] & (1 << 4)) { pc->sysval[instance_id].hw = rid++; + load_instance_id(pc, instance_id); + } } for (i = 0, rid = 0; i < pc->result_nr; ++i) { diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 73205652cc..9d58f3c965 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -329,7 +329,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) so_ref(NULL, &so); /* Static tesla init */ - so = so_new(44, 90, 22); + so = so_new(47, 95, 24); so_method(so, screen->tesla, NV50TCL_COND_MODE, 1); so_data (so, NV50TCL_COND_MODE_ALWAYS); @@ -372,7 +372,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) } for (i = 0; i < 3; i++) { - ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, (128 * 4) * 4, + ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, (256 * 4) * 4, &screen->constbuf_parm[i]); if (ret) { nv50_screen_destroy(pscreen); @@ -411,6 +411,18 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1); so_data (so, 0x00000031 | (NV50_CB_PMISC << 12)); + /* bind auxiliary constbuf to immediate data bo */ + so_method(so, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3); + so_reloc (so, screen->constbuf_misc[0], (128 * 4) * 4, + NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0); + so_reloc (so, screen->constbuf_misc[0], (128 * 4) * 4, + NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0); + so_data (so, (NV50_CB_AUX << 16) | 0x00000200); + so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1); + so_data (so, 0x00000201 | (NV50_CB_AUX << 12)); + so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1); + so_data (so, 0x00000221 | (NV50_CB_AUX << 12)); + so_method(so, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3); so_reloc (so, screen->constbuf_parm[PIPE_SHADER_VERTEX], 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0); diff --git a/src/gallium/drivers/nv50/nv50_screen.h b/src/gallium/drivers/nv50/nv50_screen.h index 7a155ca9c4..0d786b0f2e 100644 --- a/src/gallium/drivers/nv50/nv50_screen.h +++ b/src/gallium/drivers/nv50/nv50_screen.h @@ -23,6 +23,8 @@ struct nv50_screen { struct nouveau_resource *immd_heap[1]; struct nouveau_resource *parm_heap[PIPE_SHADER_TYPES]; + struct pipe_buffer *strm_vbuf[16]; + struct nouveau_bo *tic; struct nouveau_bo *tsc; diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index fcd07b59cd..956da9b304 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -274,6 +274,9 @@ nv50_state_flush_notify(struct nouveau_channel *chan) so_emit_reloc_markers(chan, nv50->state.fragprog); so_emit_reloc_markers(chan, nv50->state.vtxbuf); so_emit_reloc_markers(chan, nv50->screen->static_init); + + if (nv50->state.instbuf) + so_emit_reloc_markers(chan, nv50->state.instbuf); } boolean diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index 89a94d2fe8..3238629461 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -160,6 +160,188 @@ nv50_vbo_vtxelt_to_hw(struct pipe_vertex_element *ve) return (hw_type | hw_size); } +/* For instanced drawing from user buffers, hitting the FIFO repeatedly + * with the same vertex data is probably worse than uploading all data. + */ +static boolean +nv50_upload_vtxbuf(struct nv50_context *nv50, unsigned i) +{ + struct nv50_screen *nscreen = nv50->screen; + struct pipe_screen *pscreen = &nscreen->base.base; + struct pipe_buffer *buf = nscreen->strm_vbuf[i]; + struct pipe_vertex_buffer *vb = &nv50->vtxbuf[i]; + uint8_t *src; + unsigned size = MAX2(vb->buffer->size, 4096); + + if (buf && buf->size < size) + pipe_buffer_reference(&nscreen->strm_vbuf[i], NULL); + + if (!nscreen->strm_vbuf[i]) { + nscreen->strm_vbuf[i] = pipe_buffer_create( + pscreen, 0, PIPE_BUFFER_USAGE_VERTEX, size); + buf = nscreen->strm_vbuf[i]; + } + + src = pipe_buffer_map(pscreen, vb->buffer, PIPE_BUFFER_USAGE_CPU_READ); + if (!src) + return FALSE; + src += vb->buffer_offset; + + size = (vb->max_index + 1) * vb->stride + 16; /* + 16 is for stride 0 */ + if (vb->buffer_offset + size > vb->buffer->size) + size = vb->buffer->size - vb->buffer_offset; + + pipe_buffer_write(pscreen, buf, vb->buffer_offset, size, src); + pipe_buffer_unmap(pscreen, vb->buffer); + + vb->buffer = buf; /* don't pipe_reference, this is a private copy */ + return TRUE; +} + +static void +nv50_upload_user_vbufs(struct nv50_context *nv50) +{ + unsigned i; + + if (nv50->vbo_fifo) + nv50->dirty |= NV50_NEW_ARRAYS; + if (!(nv50->dirty & NV50_NEW_ARRAYS)) + return; + + for (i = 0; i < nv50->vtxbuf_nr; ++i) { + if (nv50->vtxbuf[i].buffer->usage & PIPE_BUFFER_USAGE_VERTEX) + continue; + nv50_upload_vtxbuf(nv50, i); + } +} + +static unsigned +init_per_instance_arrays(struct nv50_context *nv50, + unsigned startInstance, + unsigned pos[16], unsigned step[16]) +{ + struct nouveau_grobj *tesla = nv50->screen->tesla; + struct nouveau_channel *chan = tesla->channel; + struct nouveau_bo *bo; + struct nouveau_stateobj *so; + unsigned i, b, count = 0; + const uint32_t rl = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD; + + so = so_new(nv50->vtxelt_nr, nv50->vtxelt_nr * 2, nv50->vtxelt_nr * 2); + + for (i = 0; i < nv50->vtxelt_nr; ++i) { + if (!nv50->vtxelt[i].instance_divisor) + continue; + ++count; + b = nv50->vtxelt[i].vertex_buffer_index; + + pos[i] = nv50->vtxelt[i].src_offset + + nv50->vtxbuf[b].buffer_offset + + startInstance * nv50->vtxbuf[b].stride; + + if (!startInstance) { + step[i] = 0; + continue; + } + step[i] = startInstance % nv50->vtxelt[i].instance_divisor; + + bo = nouveau_bo(nv50->vtxbuf[b].buffer); + + so_method(so, tesla, NV50TCL_VERTEX_ARRAY_START_HIGH(i), 2); + so_reloc (so, bo, pos[i], rl | NOUVEAU_BO_LOW, 0, 0); + so_reloc (so, bo, pos[i], rl | NOUVEAU_BO_HIGH, 0, 0); + } + + if (count) { + so_ref (so, &nv50->state.instbuf); /* for flush notify */ + so_emit(chan, nv50->state.instbuf); + } + so_ref (NULL, &so); + + return count; +} + +static void +step_per_instance_arrays(struct nv50_context *nv50, + unsigned pos[16], unsigned step[16]) +{ + struct nouveau_grobj *tesla = nv50->screen->tesla; + struct nouveau_channel *chan = tesla->channel; + struct nouveau_bo *bo; + struct nouveau_stateobj *so; + unsigned i, b; + const uint32_t rl = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD; + + so = so_new(nv50->vtxelt_nr, nv50->vtxelt_nr * 2, nv50->vtxelt_nr * 2); + + for (i = 0; i < nv50->vtxelt_nr; ++i) { + if (!nv50->vtxelt[i].instance_divisor) + continue; + b = nv50->vtxelt[i].vertex_buffer_index; + + if (++step[i] == nv50->vtxelt[i].instance_divisor) { + step[i] = 0; + pos[i] += nv50->vtxbuf[b].stride; + } + + bo = nouveau_bo(nv50->vtxbuf[b].buffer); + + so_method(so, tesla, NV50TCL_VERTEX_ARRAY_START_HIGH(i), 2); + so_reloc (so, bo, pos[i], rl | NOUVEAU_BO_LOW, 0, 0); + so_reloc (so, bo, pos[i], rl | NOUVEAU_BO_HIGH, 0, 0); + } + + so_ref (so, &nv50->state.instbuf); /* for flush notify */ + so_ref (NULL, &so); + + so_emit(chan, nv50->state.instbuf); +} + +void +nv50_draw_arrays_instanced(struct pipe_context *pipe, + unsigned mode, unsigned start, unsigned count, + unsigned startInstance, unsigned instanceCount) +{ + struct nv50_context *nv50 = nv50_context(pipe); + struct nouveau_channel *chan = nv50->screen->tesla->channel; + struct nouveau_grobj *tesla = nv50->screen->tesla; + unsigned i, nz_divisors; + unsigned step[16], pos[16]; + + nv50_upload_user_vbufs(nv50); + + nv50_state_validate(nv50); + + nz_divisors = init_per_instance_arrays(nv50, startInstance, pos, step); + + BEGIN_RING(chan, tesla, NV50TCL_CB_ADDR, 2); + OUT_RING (chan, NV50_CB_AUX | (24 << 8)); + OUT_RING (chan, startInstance); + + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); + OUT_RING (chan, nv50_prim(mode)); + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BUFFER_FIRST, 2); + OUT_RING (chan, start); + OUT_RING (chan, count); + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); + OUT_RING (chan, 0); + + for (i = 1; i < instanceCount; i++) { + if (nz_divisors) /* any non-zero array divisors ? */ + step_per_instance_arrays(nv50, pos, step); + + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); + OUT_RING (chan, nv50_prim(mode) | (1 << 28)); + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BUFFER_FIRST, 2); + OUT_RING (chan, start); + OUT_RING (chan, count); + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); + OUT_RING (chan, 0); + } + + so_ref(NULL, &nv50->state.instbuf); +} + void nv50_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) @@ -285,6 +467,75 @@ nv50_draw_elements_inline_u32(struct nv50_context *nv50, uint32_t *map, return TRUE; } +static INLINE void +nv50_draw_elements_inline(struct nv50_context *nv50, + void *map, unsigned indexSize, + unsigned start, unsigned count) +{ + switch (indexSize) { + case 1: + nv50_draw_elements_inline_u08(nv50, map, start, count); + break; + case 2: + nv50_draw_elements_inline_u16(nv50, map, start, count); + break; + case 4: + nv50_draw_elements_inline_u32(nv50, map, start, count); + break; + } +} + +void +nv50_draw_elements_instanced(struct pipe_context *pipe, + struct pipe_buffer *indexBuffer, + unsigned indexSize, + unsigned mode, unsigned start, unsigned count, + unsigned startInstance, unsigned instanceCount) +{ + struct nv50_context *nv50 = nv50_context(pipe); + struct nouveau_grobj *tesla = nv50->screen->tesla; + struct nouveau_channel *chan = tesla->channel; + struct pipe_screen *pscreen = pipe->screen; + void *map; + unsigned i, nz_divisors; + unsigned step[16], pos[16]; + + map = pipe_buffer_map(pscreen, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ); + + nv50_upload_user_vbufs(nv50); + + nv50_state_validate(nv50); + + nz_divisors = init_per_instance_arrays(nv50, startInstance, pos, step); + + BEGIN_RING(chan, tesla, NV50TCL_CB_ADDR, 2); + OUT_RING (chan, NV50_CB_AUX | (24 << 8)); + OUT_RING (chan, startInstance); + + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); + OUT_RING (chan, nv50_prim(mode) | (1 << 28)); + + nv50_draw_elements_inline(nv50, map, indexSize, start, count); + + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); + OUT_RING (chan, 0); + + for (i = 1; i < instanceCount; ++i) { + if (nz_divisors) /* any non-zero array divisors ? */ + step_per_instance_arrays(nv50, pos, step); + + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); + OUT_RING (chan, nv50_prim(mode) | (1 << 28)); + + nv50_draw_elements_inline(nv50, map, indexSize, start, count); + + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); + OUT_RING (chan, 0); + } + + so_ref(NULL, &nv50->state.instbuf); +} + void nv50_draw_elements(struct pipe_context *pipe, struct pipe_buffer *indexBuffer, unsigned indexSize, @@ -295,7 +546,6 @@ nv50_draw_elements(struct pipe_context *pipe, struct nouveau_grobj *tesla = nv50->screen->tesla; struct pipe_screen *pscreen = pipe->screen; void *map; - boolean ret; map = pipe_buffer_map(pscreen, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ); @@ -308,29 +558,13 @@ nv50_draw_elements(struct pipe_context *pipe, BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); OUT_RING (chan, nv50_prim(mode)); - switch (indexSize) { - case 1: - ret = nv50_draw_elements_inline_u08(nv50, map, start, count); - break; - case 2: - ret = nv50_draw_elements_inline_u16(nv50, map, start, count); - break; - case 4: - ret = nv50_draw_elements_inline_u32(nv50, map, start, count); - break; - default: - assert(0); - ret = FALSE; - break; - } + + nv50_draw_elements_inline(nv50, map, indexSize, start, count); + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); OUT_RING (chan, 0); pipe_buffer_unmap(pscreen, indexBuffer); - - /* XXX: what to do if ret != TRUE? Flush and retry? - */ - assert(ret); } static INLINE boolean @@ -343,23 +577,16 @@ nv50_vbo_static_attrib(struct nv50_context *nv50, unsigned attrib, struct nouveau_stateobj *so; struct nouveau_grobj *tesla = nv50->screen->tesla; struct nouveau_bo *bo = nouveau_bo(vb->buffer); - float *v; + float v[4]; int ret; - enum pipe_format pf = ve->src_format; - const struct util_format_description *desc; - - desc = util_format_description(pf); - assert(desc); - - if ((desc->channel[0].type != UTIL_FORMAT_TYPE_FLOAT) || - util_format_get_component_bits(pf, UTIL_FORMAT_COLORSPACE_RGB, 0) != 32) - return FALSE; ret = nouveau_bo_map(bo, NOUVEAU_BO_RD); if (ret) return FALSE; - v = (float *)(bo->map + (vb->buffer_offset + ve->src_offset)); + util_format_read_4f(ve->src_format, v, 0, (uint8_t *)bo->map + + (vb->buffer_offset + ve->src_offset), 0, + 0, 0, 1, 1); so = *pso; if (!so) *pso = so = so_new(nv50->vtxelt_nr, nv50->vtxelt_nr * 4, 0); @@ -455,7 +682,8 @@ nv50_vbo_validate(struct nv50_context *nv50) } so_method(vtxbuf, tesla, NV50TCL_VERTEX_ARRAY_FORMAT(i), 3); - so_data (vtxbuf, 0x20000000 | vb->stride); + so_data (vtxbuf, 0x20000000 | + (ve->instance_divisor ? 0 : vb->stride)); so_reloc (vtxbuf, bo, vb->buffer_offset + ve->src_offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0); -- cgit v1.2.3 From 2a60302e51987ae65455b083fa3d9e9bb0e2087b Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 18 Jan 2010 00:04:48 +0000 Subject: softpipe: Fix leak in vbuf draw module --- src/gallium/drivers/softpipe/sp_prim_vbuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/softpipe/sp_prim_vbuf.c b/src/gallium/drivers/softpipe/sp_prim_vbuf.c index 7f573aef3c..5812d1eefe 100644 --- a/src/gallium/drivers/softpipe/sp_prim_vbuf.c +++ b/src/gallium/drivers/softpipe/sp_prim_vbuf.c @@ -526,6 +526,7 @@ static void sp_vbuf_destroy(struct vbuf_render *vbr) { struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr); + align_free(cvbr->vertex_buffer); sp_setup_destroy_context(cvbr->setup); FREE(cvbr); } @@ -541,7 +542,6 @@ sp_create_vbuf_backend(struct softpipe_context *sp) assert(sp->draw); - cvbr->base.max_indices = SP_MAX_VBUF_INDEXES; cvbr->base.max_vertex_buffer_bytes = SP_MAX_VBUF_SIZE; -- cgit v1.2.3 From 90cdf0d67c1086a8fd274689aa2e1b8da3a9ebdc Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 18 Jan 2010 00:07:24 +0000 Subject: cso: Add set_vertex_samplers function --- src/gallium/auxiliary/cso_cache/cso_context.c | 32 +++++++++++++++++++++++++++ src/gallium/auxiliary/cso_cache/cso_context.h | 4 ++++ 2 files changed, 36 insertions(+) diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 2b16332e14..fdfb5faa59 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -539,6 +539,38 @@ void cso_restore_samplers(struct cso_context *ctx) cso_single_sampler_done( ctx ); } +/* + * If the function encouters any errors it will return the + * last one. Done to always try to set as many samplers + * as possible. + */ +enum pipe_error cso_set_vertex_samplers(struct cso_context *ctx, + unsigned nr, + const struct pipe_sampler_state **templates) +{ + unsigned i; + enum pipe_error temp, error = PIPE_OK; + + /* TODO: fastpath + */ + + for (i = 0; i < nr; i++) { + temp = cso_single_vertex_sampler( ctx, i, templates[i] ); + if (temp != PIPE_OK) + error = temp; + } + + for ( ; i < ctx->nr_samplers; i++) { + temp = cso_single_vertex_sampler( ctx, i, NULL ); + if (temp != PIPE_OK) + error = temp; + } + + cso_single_vertex_sampler_done( ctx ); + + return error; +} + void cso_save_vertex_samplers(struct cso_context *ctx) { diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h index b9e313e32d..d2089b1c88 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.h +++ b/src/gallium/auxiliary/cso_cache/cso_context.h @@ -84,6 +84,10 @@ enum pipe_error cso_single_sampler( struct cso_context *cso, void cso_single_sampler_done( struct cso_context *cso ); +enum pipe_error cso_set_vertex_samplers(struct cso_context *cso, + unsigned count, + const struct pipe_sampler_state **states); + void cso_save_vertex_samplers(struct cso_context *cso); -- cgit v1.2.3 From 3b71386426b96c447248bc6102c6ff6182f65431 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 15 Jan 2010 17:59:16 +0800 Subject: tgsi: Add missing semantic name in text parser. This time, INSTANCEID is missing... --- src/gallium/auxiliary/tgsi/tgsi_text.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c index 9fcffeda36..7fe5dad5ff 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_text.c +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c @@ -933,7 +933,8 @@ static const char *semantic_names[TGSI_SEMANTIC_COUNT] = "NORMAL", "FACE", "EDGEFLAG", - "PRIM_ID" + "PRIM_ID", + "INSTANCEID" }; static const char *interpolate_names[TGSI_INTERPOLATE_COUNT] = -- cgit v1.2.3 From ef517c9385521f6e46a1f56ef6817518434ca349 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 15 Jan 2010 17:52:10 +0800 Subject: st/vega: Call screen->update_buffer instead of winsys->update_buffer. This removes the last reference to winsys and is per mesa/st. --- src/gallium/state_trackers/vega/api_masks.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gallium/state_trackers/vega/api_masks.c b/src/gallium/state_trackers/vega/api_masks.c index 4f9f3dae17..97cbe69205 100644 --- a/src/gallium/state_trackers/vega/api_masks.c +++ b/src/gallium/state_trackers/vega/api_masks.c @@ -32,7 +32,6 @@ #include "vg_context.h" #include "pipe/p_context.h" #include "pipe/p_inlines.h" -#include "pipe/internal/p_winsys_screen.h" /* for winsys->update_buffer */ #include "util/u_pack_color.h" #include "util/u_draw_quad.h" @@ -116,8 +115,8 @@ clear_with_quad(struct vg_context *st, float x0, float y0, x1, y1); */ - if (st->pipe->winsys && st->pipe->winsys->update_buffer) - st->pipe->winsys->update_buffer( st->pipe->winsys, + if (st->pipe->screen && st->pipe->screen->update_buffer) + st->pipe->screen->update_buffer( st->pipe->screen, st->pipe->priv ); cso_save_blend(st->cso_context); -- cgit v1.2.3 From 1ed63119452396e764a0f5b11db78903a2594df1 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 18 Jan 2010 12:05:25 +0800 Subject: st/vega: Fix window resizing with egl_g3d. egl_g3d calls st_set_framebuffer_surface on window resize. It updates the renderbuffer's geometry and makes st_resize_framebuffer a no-op. This commit improves the no-op check a little bit. It can do better after gallium-fb-dimensions is merged. --- src/gallium/state_trackers/vega/vg_context.h | 2 +- src/gallium/state_trackers/vega/vg_tracker.c | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gallium/state_trackers/vega/vg_context.h b/src/gallium/state_trackers/vega/vg_context.h index ff8c1a0421..bc88c8d139 100644 --- a/src/gallium/state_trackers/vega/vg_context.h +++ b/src/gallium/state_trackers/vega/vg_context.h @@ -50,7 +50,7 @@ struct st_renderbuffer { }; struct st_framebuffer { - VGint init_width, init_height; + VGint width, height; struct st_renderbuffer *strb; struct st_renderbuffer *dsrb; diff --git a/src/gallium/state_trackers/vega/vg_tracker.c b/src/gallium/state_trackers/vega/vg_tracker.c index ff80aab03a..617c174eb6 100644 --- a/src/gallium/state_trackers/vega/vg_tracker.c +++ b/src/gallium/state_trackers/vega/vg_tracker.c @@ -193,8 +193,8 @@ struct st_framebuffer * st_create_framebuffer(const void *visual, */ stfb->alpha_mask = 0; - stfb->init_width = width; - stfb->init_height = height; + stfb->width = width; + stfb->height = height; stfb->privateData = privateData; } @@ -282,11 +282,14 @@ void st_resize_framebuffer(struct st_framebuffer *stfb, /* If this is a noop, exit early and don't do the clear, etc below. */ - if (strb->width == width && - strb->height == height && + if (stfb->width == width && + stfb->height == height && state->zsbuf) return; + stfb->width = width; + stfb->height = height; + if (strb->width != width || strb->height != height) st_renderbuffer_alloc_storage(ctx, strb, width, height); -- cgit v1.2.3 From fda897ad71738dd76a218280fd2e635d5dcdcee1 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 18 Jan 2010 12:11:15 +0800 Subject: st/egl_g3d: Update validate to use an attachment mask. A validate call asks for the buffers of a native surface. Using a mask to represent the interested buffers is more intuitive. It also rules out corner cases such as a single attachment being listed multiple times. --- .../state_trackers/egl_g3d/common/egl_g3d.c | 51 ++++++------- .../state_trackers/egl_g3d/common/egl_g3d.h | 4 +- src/gallium/state_trackers/egl_g3d/common/native.h | 29 ++++--- .../state_trackers/egl_g3d/kms/native_kms.c | 29 ++++--- .../state_trackers/egl_g3d/x11/native_dri2.c | 89 +++++++++++----------- .../state_trackers/egl_g3d/x11/native_ximage.c | 43 ++++------- 6 files changed, 116 insertions(+), 129 deletions(-) diff --git a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c index 51da8e19f5..08f796d083 100644 --- a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c @@ -44,8 +44,13 @@ egl_g3d_validate_context(_EGLDisplay *dpy, _EGLContext *ctx) struct egl_g3d_display *gdpy = egl_g3d_display(dpy); struct pipe_screen *screen = gdpy->native->screen; struct egl_g3d_context *gctx = egl_g3d_context(ctx); - EGLint num_surfaces; - EGLint s, i; + const uint st_att_map[NUM_NATIVE_ATTACHMENTS] = { + ST_SURFACE_FRONT_LEFT, + ST_SURFACE_BACK_LEFT, + ST_SURFACE_FRONT_RIGHT, + ST_SURFACE_BACK_RIGHT, + }; + EGLint num_surfaces, s; /* validate draw and/or read buffers */ num_surfaces = (gctx->base.ReadSurface == gctx->base.DrawSurface) ? 1 : 2; @@ -53,6 +58,7 @@ egl_g3d_validate_context(_EGLDisplay *dpy, _EGLContext *ctx) struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS]; struct egl_g3d_surface *gsurf; struct egl_g3d_buffer *gbuf; + EGLint att; if (s == 0) { gsurf = egl_g3d_surface(gctx->base.DrawSurface); @@ -66,30 +72,31 @@ egl_g3d_validate_context(_EGLDisplay *dpy, _EGLContext *ctx) if (!gctx->force_validate) { unsigned int seq_num; - gsurf->native->validate(gsurf->native, - gbuf->native_atts, gbuf->num_atts, + gsurf->native->validate(gsurf->native, gbuf->attachment_mask, &seq_num, NULL, NULL, NULL); /* skip validation */ if (gsurf->sequence_number == seq_num) continue; } - gsurf->native->validate(gsurf->native, - gbuf->native_atts, gbuf->num_atts, + pipe_surface_reference(&gsurf->render_surface, NULL); + memset(textures, 0, sizeof(textures)); + + gsurf->native->validate(gsurf->native, gbuf->attachment_mask, &gsurf->sequence_number, textures, &gsurf->base.Width, &gsurf->base.Height); - for (i = 0; i < gbuf->num_atts; i++) { - struct pipe_texture *pt = textures[i]; + for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { + struct pipe_texture *pt = textures[att]; struct pipe_surface *ps; - if (pt) { + if (native_attachment_mask_test(gbuf->attachment_mask, att) && pt) { ps = screen->get_tex_surface(screen, pt, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE); gctx->stapi->st_set_framebuffer_surface(gbuf->st_fb, - gbuf->st_atts[i], ps); + st_att_map[att], ps); - if (gbuf->native_atts[i] == gsurf->render_att) + if (gsurf->render_att == att) pipe_surface_reference(&gsurf->render_surface, ps); pipe_surface_reference(&ps, NULL); @@ -128,13 +135,7 @@ static void egl_g3d_route_context(_EGLDisplay *dpy, _EGLContext *ctx) { struct egl_g3d_context *gctx = egl_g3d_context(ctx); - const uint st_att_map[NUM_NATIVE_ATTACHMENTS] = { - ST_SURFACE_FRONT_LEFT, - ST_SURFACE_BACK_LEFT, - ST_SURFACE_FRONT_RIGHT, - ST_SURFACE_BACK_RIGHT, - }; - EGLint s, i; + EGLint s; /* route draw and read buffers' attachments */ for (s = 0; s < 2; s++) { @@ -150,11 +151,7 @@ egl_g3d_route_context(_EGLDisplay *dpy, _EGLContext *ctx) gbuf = &gctx->read; } - gbuf->native_atts[0] = gsurf->render_att; - gbuf->num_atts = 1; - - for (i = 0; i < gbuf->num_atts; i++) - gbuf->st_atts[i] = st_att_map[gbuf->native_atts[i]]; + gbuf->attachment_mask = (1 << gsurf->render_att); /* FIXME OpenGL defaults to draw the front or back buffer when the * context is single-buffered or double-buffered respectively. In EGL, @@ -196,19 +193,19 @@ egl_g3d_realloc_context(_EGLDisplay *dpy, _EGLContext *ctx) if (!gdraw || priv != (void *) &gdraw->base) { gctx->stapi->st_unreference_framebuffer(gctx->draw.st_fb); gctx->draw.st_fb = NULL; - gctx->draw.num_atts = 0; + gctx->draw.attachment_mask = 0x0; } if (is_equal) { gctx->read.st_fb = NULL; - gctx->draw.num_atts = 0; + gctx->draw.attachment_mask = 0x0; } else { priv = gctx->stapi->st_framebuffer_private(gctx->read.st_fb); if (!gread || priv != (void *) &gread->base) { gctx->stapi->st_unreference_framebuffer(gctx->read.st_fb); gctx->read.st_fb = NULL; - gctx->draw.num_atts = 0; + gctx->draw.attachment_mask = 0x0; } } } @@ -628,7 +625,7 @@ init_surface_geometry(_EGLSurface *surf) { struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - return gsurf->native->validate(gsurf->native, NULL, 0, + return gsurf->native->validate(gsurf->native, 0x0, &gsurf->sequence_number, NULL, &gsurf->base.Width, &gsurf->base.Height); } diff --git a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.h b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.h index 4c8b8dfe9e..1da8af495b 100644 --- a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.h +++ b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.h @@ -52,9 +52,7 @@ struct egl_g3d_display { struct egl_g3d_buffer { struct st_framebuffer *st_fb; - EGLint num_atts; - enum native_attachment native_atts[NUM_NATIVE_ATTACHMENTS]; - uint st_atts[NUM_NATIVE_ATTACHMENTS]; + uint attachment_mask; }; struct egl_g3d_context { diff --git a/src/gallium/state_trackers/egl_g3d/common/native.h b/src/gallium/state_trackers/egl_g3d/common/native.h index 76f0e0c78a..6cd161bdf6 100644 --- a/src/gallium/state_trackers/egl_g3d/common/native.h +++ b/src/gallium/state_trackers/egl_g3d/common/native.h @@ -64,18 +64,18 @@ struct native_surface { boolean (*flush_frontbuffer)(struct native_surface *nsurf); /** - * Validate the buffers of the surface. The returned textures are owned by - * the caller. A sequence number is also returned. The caller can use it - * to check if anything has changed since the last call. Any of the pointers - * may be NULL and it indicates the caller has no interest in those values. + * Validate the buffers of the surface. textures, if not NULL, points to an + * array of size NUM_NATIVE_ATTACHMENTS and the returned textures are owned + * by the caller. A sequence number is also returned. The caller can use + * it to check if anything has changed since the last call. Any of the + * pointers may be NULL and it indicates the caller has no interest in those + * values. * - * If this function is called multiple times with different attachments, - * those not listed in the latest call might be destroyed. This behavior - * might change in the future. + * If this function is called multiple times with different attachment + * masks, those not listed in the latest call might be destroyed. This + * behavior might change in the future. */ - boolean (*validate)(struct native_surface *nsurf, - const enum native_attachment *natts, - unsigned num_natts, + boolean (*validate)(struct native_surface *nsurf, uint attachment_mask, unsigned int *seq_num, struct pipe_texture **textures, int *width, int *height); @@ -211,6 +211,15 @@ struct native_display_modeset { const struct native_mode *nmode); }; +/** + * Test whether an attachment is set in the mask. + */ +static INLINE boolean +native_attachment_mask_test(uint mask, enum native_attachment att) +{ + return !!(mask & (1 << att)); +} + const char * native_get_name(void); diff --git a/src/gallium/state_trackers/egl_g3d/kms/native_kms.c b/src/gallium/state_trackers/egl_g3d/kms/native_kms.c index 65829fc7b3..dc66436630 100644 --- a/src/gallium/state_trackers/egl_g3d/kms/native_kms.c +++ b/src/gallium/state_trackers/egl_g3d/kms/native_kms.c @@ -33,9 +33,7 @@ #include "native_kms.h" static boolean -kms_surface_validate(struct native_surface *nsurf, - const enum native_attachment *natts, - unsigned num_natts, +kms_surface_validate(struct native_surface *nsurf, uint attachment_mask, unsigned int *seq_num, struct pipe_texture **textures, int *width, int *height) { @@ -43,12 +41,9 @@ kms_surface_validate(struct native_surface *nsurf, struct kms_display *kdpy = ksurf->kdpy; struct pipe_screen *screen = kdpy->base.screen; struct pipe_texture templ, *ptex; - int i; - - if (num_natts) { - if (textures) - memset(textures, 0, sizeof(*textures) * num_natts); + int att; + if (attachment_mask) { memset(&templ, 0, sizeof(templ)); templ.target = PIPE_TEXTURE_2D; templ.last_level = 0; @@ -62,17 +57,21 @@ kms_surface_validate(struct native_surface *nsurf, } /* create textures */ - for (i = 0; i < num_natts; i++) { - enum native_attachment natt = natts[i]; + for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { + /* delay the allocation */ + if (!native_attachment_mask_test(attachment_mask, att)) + continue; - ptex = ksurf->textures[natt]; + ptex = ksurf->textures[att]; if (!ptex) { ptex = screen->texture_create(screen, &templ); - ksurf->textures[natt] = ptex; + ksurf->textures[att] = ptex; } - if (textures) - pipe_texture_reference(&textures[i], ptex); + if (textures) { + textures[att] = NULL; + pipe_texture_reference(&textures[att], ptex); + } } if (seq_num) @@ -113,7 +112,7 @@ kms_surface_init_framebuffers(struct native_surface *nsurf, boolean need_back) if (!fb->texture) { /* make sure the texture has been allocated */ - kms_surface_validate(&ksurf->base, &natt, 1, NULL, NULL, NULL, NULL); + kms_surface_validate(&ksurf->base, 1 << natt, NULL, NULL, NULL, NULL); if (!ksurf->textures[natt]) return FALSE; diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c b/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c index f497d8c1c7..f675a8e686 100644 --- a/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c +++ b/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c @@ -134,22 +134,18 @@ dri2_surface_swap_buffers(struct native_surface *nsurf) } static boolean -dri2_surface_validate(struct native_surface *nsurf, - const enum native_attachment *natts, - unsigned num_natts, - unsigned int *seq_num, - struct pipe_texture **textures, - int *width, int *height) +dri2_surface_validate(struct native_surface *nsurf, uint attachment_mask, + unsigned int *seq_num, struct pipe_texture **textures, + int *width, int *height) { struct dri2_surface *dri2surf = dri2_surface(nsurf); struct dri2_display *dri2dpy = dri2surf->dri2dpy; unsigned int dri2atts[NUM_NATIVE_ATTACHMENTS]; - EGLint texture_indices[NUM_NATIVE_ATTACHMENTS]; struct pipe_texture templ; struct x11_drawable_buffer *xbufs; - int num_ins, num_outs, i; + int num_ins, num_outs, att, i; - if (num_natts) { + if (attachment_mask) { memset(&templ, 0, sizeof(templ)); templ.target = PIPE_TEXTURE_2D; templ.last_level = 0; @@ -160,24 +156,27 @@ dri2_surface_validate(struct native_surface *nsurf, templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; if (textures) - memset(textures, 0, sizeof(*textures) * num_natts); + memset(textures, 0, sizeof(*textures) * NUM_NATIVE_ATTACHMENTS); } /* create textures for pbuffer */ if (dri2surf->type == DRI2_SURFACE_TYPE_PBUFFER) { struct pipe_screen *screen = dri2dpy->base.screen; - for (i = 0; i < num_natts; i++) { - enum native_attachment natt = natts[i]; - struct pipe_texture *ptex = dri2surf->pbuffer_textures[natt]; + for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { + struct pipe_texture *ptex = dri2surf->pbuffer_textures[att]; + + /* delay the allocation */ + if (!native_attachment_mask_test(attachment_mask, att)) + continue; if (!ptex) { ptex = screen->texture_create(screen, &templ); - dri2surf->pbuffer_textures[natt] = ptex; + dri2surf->pbuffer_textures[att] = ptex; } if (textures) - pipe_texture_reference(&textures[i], ptex); + pipe_texture_reference(&textures[att], ptex); } if (seq_num) @@ -190,34 +189,34 @@ dri2_surface_validate(struct native_surface *nsurf, return TRUE; } - for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) - texture_indices[i] = -1; - /* prepare the attachments */ - num_ins = num_natts; - for (i = 0; i < num_natts; i++) { - unsigned int dri2att; + num_ins = 0; + for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { + if (native_attachment_mask_test(attachment_mask, att)) { + unsigned int dri2att; + + switch (att) { + case NATIVE_ATTACHMENT_FRONT_LEFT: + dri2att = DRI2BufferFrontLeft; + break; + case NATIVE_ATTACHMENT_BACK_LEFT: + dri2att = DRI2BufferBackLeft; + break; + case NATIVE_ATTACHMENT_FRONT_RIGHT: + dri2att = DRI2BufferFrontRight; + break; + case NATIVE_ATTACHMENT_BACK_RIGHT: + dri2att = DRI2BufferBackRight; + break; + default: + assert(0); + dri2att = 0; + break; + } - switch (natts[i]) { - case NATIVE_ATTACHMENT_FRONT_LEFT: - dri2att = DRI2BufferFrontLeft; - break; - case NATIVE_ATTACHMENT_BACK_LEFT: - dri2att = DRI2BufferBackLeft; - break; - case NATIVE_ATTACHMENT_FRONT_RIGHT: - dri2att = DRI2BufferFrontRight; - break; - case NATIVE_ATTACHMENT_BACK_RIGHT: - dri2att = DRI2BufferBackRight; - break; - default: - assert(0); - dri2att = 0; - break; + dri2atts[num_ins] = dri2att; + num_ins++; } - dri2atts[i] = dri2att; - texture_indices[natts[i]] = i; } dri2surf->have_back = FALSE; @@ -266,13 +265,13 @@ dri2_surface_validate(struct native_surface *nsurf, break; } - if (!desc || texture_indices[natt] < 0 || - (textures && textures[texture_indices[natt]])) { + if (!desc || !native_attachment_mask_test(attachment_mask, natt) || + (textures && textures[natt])) { if (!desc) _eglLog(_EGL_WARNING, "unknown buffer %d", xbuf->attachment); - else if (texture_indices[natt] < 0) + else if (!native_attachment_mask_test(attachment_mask, natt)) _eglLog(_EGL_WARNING, "unexpected buffer %d", xbuf->attachment); - else if (textures && textures[texture_indices[natt]]) + else _eglLog(_EGL_WARNING, "both real and fake front buffers are listed"); continue; } @@ -284,7 +283,7 @@ dri2_surface_validate(struct native_surface *nsurf, desc, xbuf->pitch, xbuf->name); if (ptex) { /* the caller owns the textures */ - textures[texture_indices[natt]] = ptex; + textures[natt] = ptex; } } } diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c b/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c index 24a50df7a0..1f136235c0 100644 --- a/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c +++ b/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c @@ -289,27 +289,21 @@ ximage_surface_update_geometry(struct native_surface *nsurf) } static boolean -ximage_surface_validate(struct native_surface *nsurf, - const enum native_attachment *natts, - unsigned num_natts, - unsigned int *seq_num, - struct pipe_texture **textures, - int *width, int *height) +ximage_surface_validate(struct native_surface *nsurf, uint attachment_mask, + unsigned int *seq_num, struct pipe_texture **textures, + int *width, int *height) { struct ximage_surface *xsurf = ximage_surface(nsurf); - boolean new_buffers = FALSE, error = FALSE; - unsigned i; + boolean new_buffers = FALSE; + int att; ximage_surface_update_geometry(&xsurf->base); - if (textures) - memset(textures, 0, sizeof(*textures) * num_natts); + for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { + struct ximage_buffer *xbuf = &xsurf->buffers[att]; - for (i = 0; i < num_natts; i++) { - enum native_attachment natt = natts[i]; - struct ximage_buffer *xbuf = &xsurf->buffers[natt]; - - if (!xbuf) + /* delay the allocation */ + if (!native_attachment_mask_test(attachment_mask, att)) continue; /* reallocate the texture */ @@ -317,7 +311,7 @@ ximage_surface_validate(struct native_surface *nsurf, xsurf->width != xbuf->texture->width0 || xsurf->height != xbuf->texture->height0) { new_buffers = TRUE; - if (ximage_surface_alloc_buffer(&xsurf->base, natt)) { + if (ximage_surface_alloc_buffer(&xsurf->base, att)) { /* update ximage */ if (xbuf->ximage) { xbuf->ximage->width = xbuf->transfer->width; @@ -327,19 +321,10 @@ ximage_surface_validate(struct native_surface *nsurf, } } - /* allocation failed */ - if (!xbuf->texture) { - unsigned j; - for (j = 0; j < i; j++) - pipe_texture_reference(&textures[j], NULL); - for (j = i; j < num_natts; j++) - textures[j] = NULL; - error = TRUE; - break; + if (textures) { + textures[att] = NULL; + pipe_texture_reference(&textures[att], xbuf->texture); } - - if (textures) - pipe_texture_reference(&textures[i], xbuf->texture); } /* increase the sequence number so that caller knows */ @@ -353,7 +338,7 @@ ximage_surface_validate(struct native_surface *nsurf, if (height) *height = xsurf->height; - return !error; + return TRUE; } static void -- cgit v1.2.3 From f8244e294646c1b5127a2bf3e92811300b0e3b9e Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 18 Jan 2010 15:49:20 +0800 Subject: st/egl_g3d: Add is_pixmap_supported to native display interface. The function may be used to support, for example, EGL_MATCH_NATIVE_PIXMAP and EGL_KHR_image_pixmap. --- src/gallium/state_trackers/egl_g3d/common/native.h | 11 +++++++ .../state_trackers/egl_g3d/x11/native_dri2.c | 16 ++++++++++ .../state_trackers/egl_g3d/x11/native_ximage.c | 29 +++++++++++++++++ .../state_trackers/egl_g3d/x11/x11_screen.c | 36 ++++++++++++++++++++++ .../state_trackers/egl_g3d/x11/x11_screen.h | 4 +++ 5 files changed, 96 insertions(+) diff --git a/src/gallium/state_trackers/egl_g3d/common/native.h b/src/gallium/state_trackers/egl_g3d/common/native.h index 6cd161bdf6..f374f2e4a6 100644 --- a/src/gallium/state_trackers/egl_g3d/common/native.h +++ b/src/gallium/state_trackers/egl_g3d/common/native.h @@ -135,6 +135,17 @@ struct native_display { const struct native_config **(*get_configs)(struct native_display *ndpy, int *num_configs); + /** + * Test if a pixmap is supported by the given config. Required unless no + * config has GLX_PIXMAP_BIT set. + * + * This function is usually called to find a config that supports a given + * pixmap. Thus, it is usually called with the same pixmap in a row. + */ + boolean (*is_pixmap_supported)(struct native_display *ndpy, + EGLNativePixmapType pix, + const struct native_config *nconf); + /** * Create a pipe context. */ diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c b/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c index f675a8e686..07f82d878c 100644 --- a/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c +++ b/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c @@ -588,6 +588,21 @@ dri2_display_get_configs(struct native_display *ndpy, int *num_configs) return configs; } +static boolean +dri2_display_is_pixmap_supported(struct native_display *ndpy, + EGLNativePixmapType pix, + const struct native_config *nconf) +{ + struct dri2_display *dri2dpy = dri2_display(ndpy); + uint depth, nconf_depth; + + depth = x11_drawable_get_depth(dri2dpy->xscr, (Drawable) pix); + nconf_depth = util_format_get_blocksizebits(nconf->color_format); + + /* simple depth match for now */ + return (depth == nconf_depth || (depth == 24 && depth + 8 == nconf_depth)); +} + static void dri2_display_destroy(struct native_display *ndpy) { @@ -680,6 +695,7 @@ x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api) dri2dpy->base.destroy = dri2_display_destroy; dri2dpy->base.get_configs = dri2_display_get_configs; + dri2dpy->base.is_pixmap_supported = dri2_display_is_pixmap_supported; dri2dpy->base.create_context = dri2_display_create_context; dri2dpy->base.create_window_surface = dri2_display_create_window_surface; dri2dpy->base.create_pixmap_surface = dri2_display_create_pixmap_surface; diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c b/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c index 1f136235c0..d76107c47f 100644 --- a/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c +++ b/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c @@ -600,6 +600,34 @@ ximage_display_get_configs(struct native_display *ndpy, int *num_configs) return configs; } +static boolean +ximage_display_is_pixmap_supported(struct native_display *ndpy, + EGLNativePixmapType pix, + const struct native_config *nconf) +{ + struct ximage_display *xdpy = ximage_display(ndpy); + enum pipe_format fmt; + uint depth; + + depth = x11_drawable_get_depth(xdpy->xscr, (Drawable) pix); + switch (depth) { + case 32: + fmt = PIPE_FORMAT_A8R8G8B8_UNORM; + break; + case 24: + fmt = PIPE_FORMAT_X8R8G8B8_UNORM; + break; + case 16: + fmt = PIPE_FORMAT_R5G6B5_UNORM; + break; + default: + fmt = PIPE_FORMAT_NONE; + break; + } + + return (fmt == nconf->color_format); +} + static void ximage_display_destroy(struct native_display *ndpy) { @@ -652,6 +680,7 @@ x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm) xdpy->base.destroy = ximage_display_destroy; xdpy->base.get_configs = ximage_display_get_configs; + xdpy->base.is_pixmap_supported = ximage_display_is_pixmap_supported; xdpy->base.create_context = ximage_display_create_context; xdpy->base.create_window_surface = ximage_display_create_window_surface; xdpy->base.create_pixmap_surface = ximage_display_create_pixmap_surface; diff --git a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c index 1e98943242..bfff91db8b 100644 --- a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c +++ b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c @@ -30,6 +30,7 @@ #include #include "util/u_memory.h" #include "util/u_math.h" +#include "util/u_format.h" #include "xf86drm.h" #include "egllog.h" @@ -50,6 +51,10 @@ struct x11_screen { XVisualInfo *visuals; int num_visuals; + + /* cached values for x11_drawable_get_format */ + Drawable last_drawable; + unsigned int last_depth; }; @@ -350,6 +355,37 @@ x11_drawable_get_buffers(struct x11_screen *xscr, Drawable drawable, return (struct x11_drawable_buffer *) dri2bufs; } +/** + * Return the depth of a drawable. + * + * Unlike other drawable functions, the drawable needs not be a DRI2 drawable. + */ +uint +x11_drawable_get_depth(struct x11_screen *xscr, Drawable drawable) +{ + unsigned int depth; + + if (drawable != xscr->last_drawable) { + Window root; + int x, y; + unsigned int w, h, border; + Status ok; + + ok = XGetGeometry(xscr->dpy, drawable, &root, + &x, &y, &w, &h, &border, &depth); + if (!ok) + depth = 0; + + xscr->last_drawable = drawable; + xscr->last_depth = depth; + } + else { + depth = xscr->last_depth; + } + + return depth; +} + /** * Create a mode list of the given size. */ diff --git a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h index 86e8e0501a..ad42bffbe9 100644 --- a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h +++ b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h @@ -29,6 +29,7 @@ #include #include #include "pipe/p_compiler.h" +#include "pipe/p_format.h" #include "common/native.h" enum x11_screen_extension { @@ -96,4 +97,7 @@ x11_drawable_get_buffers(struct x11_screen *xscr, Drawable drawable, int *width, int *height, unsigned int *attachments, boolean with_format, int num_ins, int *num_outs); +uint +x11_drawable_get_depth(struct x11_screen *xscr, Drawable drawable); + #endif /* _X11_SCREEN_H_ */ -- cgit v1.2.3 From ede755af4c4a22fd0076f1e18a5356879ac9c7e7 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 18 Jan 2010 15:28:13 +0800 Subject: st/egl_g3d: Add support for eglCopyBuffers. It uses a slow path to copy the render buffer of the surface to the target pixmap. We might be able to create a pipe context for EGLDisplay's use and use a blitter context for the purpose. It is left for a future consideration. --- .../state_trackers/egl_g3d/common/egl_g3d.c | 97 ++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c index 08f796d083..042e9518c2 100644 --- a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c @@ -26,6 +26,7 @@ #include #include "pipe/p_screen.h" #include "util/u_memory.h" +#include "util/u_rect.h" #include "egldriver.h" #include "eglcurrent.h" #include "eglconfigutil.h" @@ -861,6 +862,101 @@ egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) return EGL_TRUE; } +/** + * Find a config that supports the pixmap. + */ +static _EGLConfig * +find_pixmap_config(_EGLDisplay *dpy, EGLNativePixmapType pix) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_config *gconf; + EGLint i; + + for (i = 0; i < dpy->NumConfigs; i++) { + gconf = egl_g3d_config(dpy->Configs[i]); + if (gdpy->native->is_pixmap_supported(gdpy->native, pix, gconf->native)) + break; + } + + return (i < dpy->NumConfigs) ? &gconf->base : NULL; +} + +/** + * Get the pipe surface of the given attachment of the native surface. + */ +static struct pipe_surface * +get_pipe_surface(struct native_display *ndpy, struct native_surface *nsurf, + enum native_attachment natt) +{ + struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS]; + struct pipe_surface *psurf; + + textures[natt] = NULL; + nsurf->validate(nsurf, 1 << natt, NULL, textures, NULL, NULL); + if (!textures[natt]) + return NULL; + + psurf = ndpy->screen->get_tex_surface(ndpy->screen, textures[natt], + 0, 0, 0, PIPE_BUFFER_USAGE_CPU_WRITE); + pipe_texture_reference(&textures[natt], NULL); + + return psurf; +} + +static EGLBoolean +egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, + NativePixmapType target) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + _EGLContext *ctx = _eglGetCurrentContext(); + struct egl_g3d_config *gconf; + struct native_surface *nsurf; + struct pipe_screen *screen = gdpy->native->screen; + struct pipe_surface *psurf; + + if (!gsurf->render_surface) + return EGL_TRUE; + + gconf = egl_g3d_config(find_pixmap_config(dpy, target)); + if (!gconf) + return _eglError(EGL_BAD_NATIVE_PIXMAP, "eglCopyBuffers"); + + nsurf = gdpy->native->create_pixmap_surface(gdpy->native, + target, gconf->native); + if (!nsurf) + return _eglError(EGL_BAD_NATIVE_PIXMAP, "eglCopyBuffers"); + + /* flush if the surface is current */ + if (ctx && ctx->DrawSurface == &gsurf->base) { + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + gctx->stapi->st_flush(gctx->st_ctx, + PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); + } + + psurf = get_pipe_surface(gdpy->native, nsurf, NATIVE_ATTACHMENT_FRONT_LEFT); + if (psurf) { + struct pipe_context pipe; + + /** + * XXX This is hacky. If we might allow the EGLDisplay to create a pipe + * context of its own and use the blitter context for this. + */ + memset(&pipe, 0, sizeof(pipe)); + pipe.screen = screen; + + util_surface_copy(&pipe, FALSE, psurf, 0, 0, + gsurf->render_surface, 0, 0, psurf->width, psurf->height); + + pipe_surface_reference(&psurf, NULL); + nsurf->flush_frontbuffer(nsurf); + } + + nsurf->destroy(nsurf); + + return EGL_TRUE; +} + static EGLBoolean egl_g3d_wait_client(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) { @@ -1114,6 +1210,7 @@ _eglMain(const char *args) gdrv->base.API.DestroySurface = egl_g3d_destroy_surface; gdrv->base.API.MakeCurrent = egl_g3d_make_current; gdrv->base.API.SwapBuffers = egl_g3d_swap_buffers; + gdrv->base.API.CopyBuffers = egl_g3d_copy_buffers; gdrv->base.API.WaitClient = egl_g3d_wait_client; gdrv->base.API.WaitNative = egl_g3d_wait_native; gdrv->base.API.GetProcAddress = egl_g3d_get_proc_address; -- cgit v1.2.3 From 8311a49b2d4c34d17186d6d7e83307eb989a8260 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 18 Jan 2010 16:30:07 +0800 Subject: progs/egl: Pass EGLDisplay to eglCopyBuffers. X Display was wrongly passed to eglCopyBuffers. --- progs/egl/xeglgears.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/progs/egl/xeglgears.c b/progs/egl/xeglgears.c index 614a625603..9fdf474244 100644 --- a/progs/egl/xeglgears.c +++ b/progs/egl/xeglgears.c @@ -604,7 +604,7 @@ event_loop(struct egl_manager *eman, EGLint surface_type, EGLint w, EGLint h) break; case EGL_PBUFFER_BIT: eglWaitClient(); - if (!eglCopyBuffers(eman->xdpy, eman->pbuf, eman->xpix)) + if (!eglCopyBuffers(eman->dpy, eman->pbuf, eman->xpix)) break; /* fall through */ case EGL_PIXMAP_BIT: -- cgit v1.2.3 From 11a2bbc3e96a5d72cc1473362c771ddebe0f9b8d Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sun, 17 Jan 2010 15:57:26 -0800 Subject: radeong: Use vram_size instead of vram_visible. The kernel will decide on its own what to give us. --- src/gallium/winsys/drm/radeon/core/radeon_drm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c index dd73b33ee0..017d1bea1a 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c @@ -55,8 +55,8 @@ static void do_ioctls(int fd, struct radeon_winsys* winsys) * * The GEM info is actually bogus on the kernel side, as well as our side * (see radeon_gem_info_ioctl in radeon_gem.c) but that's alright because - * we don't actually use the info for anything yet. - * XXX update the above when we can safely use vram_size instead of vram_visible */ + * we don't actually use the info for anything yet. */ + info.request = RADEON_INFO_DEVICE_ID; retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info)); if (retval) { @@ -92,8 +92,7 @@ static void do_ioctls(int fd, struct radeon_winsys* winsys) exit(1); } winsys->gart_size = gem_info.gart_size; - /* XXX */ - winsys->vram_size = gem_info.vram_visible; + winsys->vram_size = gem_info.vram_size; } /* Guess at whether this chipset should use r300g. -- cgit v1.2.3 From 58a7d8db98e5ffd0699d4cb59663d7621bc20594 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 18 Jan 2010 00:35:11 -0800 Subject: radeong: Check DRM version, and report stats. --- src/gallium/winsys/drm/radeon/core/radeon_drm.c | 27 ++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c index 017d1bea1a..572c5df458 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c @@ -40,12 +40,16 @@ static void do_ioctls(int fd, struct radeon_winsys* winsys) struct drm_radeon_info info = {0}; int target = 0; int retval; + drmVersionPtr version; info.value = (unsigned long)⌖ /* We do things in a specific order here. * - * First, the PCI ID. This is essential and should return usable numbers + * DRM version first. We need to be sure we're running on a KMS chipset. + * This is also for some features. + * + * Then, the PCI ID. This is essential and should return usable numbers * for all Radeons. If this fails, we probably got handed an FD for some * non-Radeon card. * @@ -57,6 +61,16 @@ static void do_ioctls(int fd, struct radeon_winsys* winsys) * (see radeon_gem_info_ioctl in radeon_gem.c) but that's alright because * we don't actually use the info for anything yet. */ + version = drmGetVersion(fd); + if (version->version_major != 2) { + fprintf(stderr, "%s: DRM version is %d.%d.%d but this driver is " + "only compatible with 2.x.x\n", __FUNCTION__, + version->version_major, version->version_minor, + version->version_patchlevel); + drmFreeVersion(version); + exit(1); + } + info.request = RADEON_INFO_DEVICE_ID; retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info)); if (retval) { @@ -93,6 +107,17 @@ static void do_ioctls(int fd, struct radeon_winsys* winsys) } winsys->gart_size = gem_info.gart_size; winsys->vram_size = gem_info.vram_size; + + debug_printf("radeon: Successfully grabbed chipset info from kernel!\n" + "radeon: DRM version: %d.%d.%d ID: 0x%04x GB: %d Z: %d\n" + "radeon: GART size: %d MB VRAM size: %d MB\n", + version->version_major, version->version_minor, + version->version_patchlevel, winsys->pci_id, + winsys->gb_pipes, winsys->z_pipes, + winsys->gart_size / 1024 / 1024, + winsys->vram_size / 1024 / 1024); + + drmFreeVersion(version); } /* Guess at whether this chipset should use r300g. -- cgit v1.2.3 From c273ab007dc4194b62965c3b1d9c8a90ea573680 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 18 Jan 2010 00:36:04 -0800 Subject: dri: Properly calculate number of modes for MSAA. Split from the next patch for bisection purposes only. --- src/gallium/state_trackers/dri/dri_screen.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index 793db087ee..d9f1fd4f41 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -158,7 +158,7 @@ dri_fill_in_modes(struct dri_screen *screen, depth_bits_array, stencil_bits_array, depth_buffer_factor, back_buffer_modes, back_buffer_factor, - msaa_samples_array, 1); + msaa_samples_array, msaa_samples_factor); } else { __DRIconfig **configs_a8r8g8b8 = NULL; __DRIconfig **configs_x8r8g8b8 = NULL; @@ -170,7 +170,8 @@ dri_fill_in_modes(struct dri_screen *screen, depth_buffer_factor, back_buffer_modes, back_buffer_factor, - msaa_samples_array, 1); + msaa_samples_array, + msaa_samples_factor); if (pf_x8r8g8b8) configs_x8r8g8b8 = driCreateConfigs(GL_BGR, GL_UNSIGNED_INT_8_8_8_8_REV, depth_bits_array, @@ -178,7 +179,8 @@ dri_fill_in_modes(struct dri_screen *screen, depth_buffer_factor, back_buffer_modes, back_buffer_factor, - msaa_samples_array, 1); + msaa_samples_array, + msaa_samples_factor); if (configs_a8r8g8b8 && configs_x8r8g8b8) configs = driConcatConfigs(configs_x8r8g8b8, configs_a8r8g8b8); -- cgit v1.2.3 From a16d353b5ea0e14887a2cd2db222beb357b37d65 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 18 Jan 2010 00:37:21 -0800 Subject: dri: Add an MSAA-enabled factor to DRI configs. 4 samples should be enough for GLUT to be satisfied, and I think most of the HW that does any MSAA, can do it. Note that any pipe that doesn't multisample can just ignore the corresponding flag in pipe_rasterizer_state. --- src/gallium/state_trackers/dri/dri_screen.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index d9f1fd4f41..d8c054313b 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -83,7 +83,7 @@ dri_fill_in_modes(struct dri_screen *screen, unsigned num_modes; uint8_t depth_bits_array[5]; uint8_t stencil_bits_array[5]; - uint8_t msaa_samples_array[1]; + uint8_t msaa_samples_array[2]; unsigned depth_buffer_factor; unsigned back_buffer_factor; unsigned msaa_samples_factor; @@ -147,8 +147,9 @@ dri_fill_in_modes(struct dri_screen *screen, } msaa_samples_array[0] = 0; + msaa_samples_array[1] = 4; back_buffer_factor = 3; - msaa_samples_factor = 1; + msaa_samples_factor = 2; num_modes = depth_buffer_factor * back_buffer_factor * msaa_samples_factor * 4; -- cgit v1.2.3 From 064eb0a095b1ac56e20459c216c9271bef01cb9f Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 18 Jan 2010 17:12:50 +0800 Subject: st/egl_g3d: Clean up for x11_drawable_get_depth. Fix a wrong comment and remove an unnecessary #include. --- src/gallium/state_trackers/egl_g3d/x11/x11_screen.c | 2 +- src/gallium/state_trackers/egl_g3d/x11/x11_screen.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c index bfff91db8b..4d68a88d2e 100644 --- a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c +++ b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c @@ -52,7 +52,7 @@ struct x11_screen { XVisualInfo *visuals; int num_visuals; - /* cached values for x11_drawable_get_format */ + /* cached values for x11_drawable_get_depth */ Drawable last_drawable; unsigned int last_depth; }; diff --git a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h index ad42bffbe9..bf48218905 100644 --- a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h +++ b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h @@ -29,7 +29,6 @@ #include #include #include "pipe/p_compiler.h" -#include "pipe/p_format.h" #include "common/native.h" enum x11_screen_extension { -- cgit v1.2.3 From cd553ec8be14eea7db2d21b9f26ea6e72474a471 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sat, 16 Jan 2010 01:45:10 +0100 Subject: r300g: do not align compressed textures to a tile size --- src/gallium/drivers/r300/r300_texture.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index c6dd27272b..1f73f74c26 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -139,11 +139,15 @@ unsigned r300_texture_get_stride(struct r300_screen* screen, return 0; } - tile_width = r300_texture_get_tile_size(tex, TILE_WIDTH); - width = align(u_minify(tex->tex.width0, level), tile_width); + width = u_minify(tex->tex.width0, level); - /* Should already be aligned except for S3TC. */ - return align(util_format_get_stride(tex->tex.format, width), 32); + if (!util_format_is_compressed(tex->tex.format)) { + tile_width = r300_texture_get_tile_size(tex, TILE_WIDTH); + width = align(width, tile_width); + return util_format_get_stride(tex->tex.format, width); + } else { + return align(util_format_get_stride(tex->tex.format, width), 32); + } } static unsigned r300_texture_get_nblocksy(struct r300_texture* tex, @@ -151,8 +155,12 @@ static unsigned r300_texture_get_nblocksy(struct r300_texture* tex, { unsigned height, tile_height; - tile_height = r300_texture_get_tile_size(tex, TILE_HEIGHT); - height = align(u_minify(tex->tex.height0, level), tile_height); + height = u_minify(tex->tex.height0, level); + + if (!util_format_is_compressed(tex->tex.format)) { + tile_height = r300_texture_get_tile_size(tex, TILE_HEIGHT); + height = align(height, tile_height); + } return util_format_get_nblocksy(tex->tex.format, height); } -- cgit v1.2.3 From d3d41cbc3504536c2d2dfa2faaae86b2ae5eb670 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 17 Jan 2010 14:54:35 +0100 Subject: r300g: fix vertex data swizzle --- src/gallium/drivers/r300/r300_state_inlines.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index a9ee0a26f1..e2180b33b7 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -551,7 +551,11 @@ r300_translate_vertex_data_swizzle(enum pipe_format format) { /* Swizzles for 8bits formats are in the reversed order, not sure why. */ if (desc->channel[0].size == 8) { for (i = 0; i < 4; i++) { - swizzle[i] = 3 - desc->swizzle[i]; + if (desc->swizzle[i] <= 3) { + swizzle[i] = 3 - desc->swizzle[i]; + } else { + swizzle[i] = desc->swizzle[i]; + } } } else { for (i = 0; i < 4; i++) { -- cgit v1.2.3 From 673ae6266ebf66145bf2bd7d37965f3fe60371d5 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 17 Jan 2010 19:21:03 +0100 Subject: r300g: fix polygon offset As per classic r300. Not sure why glean/polygonOffset still fails, but we do emit the same register values as in classic. --- src/gallium/drivers/r300/r300_context.h | 12 ++++++++---- src/gallium/drivers/r300/r300_emit.c | 30 ++++++++++++++++++++++++------ src/gallium/drivers/r300/r300_state.c | 26 ++++++++++++++++++++++---- 3 files changed, 54 insertions(+), 14 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index c65d23823c..5e33dc042a 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -87,10 +87,10 @@ struct r300_rs_state { uint32_t point_size; /* R300_GA_POINT_SIZE: 0x421c */ uint32_t point_minmax; /* R300_GA_POINT_MINMAX: 0x4230 */ uint32_t line_control; /* R300_GA_LINE_CNTL: 0x4234 */ - uint32_t depth_scale_front; /* R300_SU_POLY_OFFSET_FRONT_SCALE: 0x42a4 */ - uint32_t depth_offset_front;/* R300_SU_POLY_OFFSET_FRONT_OFFSET: 0x42a8 */ - uint32_t depth_scale_back; /* R300_SU_POLY_OFFSET_BACK_SCALE: 0x42ac */ - uint32_t depth_offset_back; /* R300_SU_POLY_OFFSET_BACK_OFFSET: 0x42b0 */ + float depth_scale; /* R300_SU_POLY_OFFSET_FRONT_SCALE: 0x42a4 */ + /* R300_SU_POLY_OFFSET_BACK_SCALE: 0x42ac */ + float depth_offset; /* R300_SU_POLY_OFFSET_FRONT_OFFSET: 0x42a8 */ + /* R300_SU_POLY_OFFSET_BACK_OFFSET: 0x42b0 */ uint32_t polygon_offset_enable; /* R300_SU_POLY_OFFSET_ENABLE: 0x42b4 */ uint32_t cull_mode; /* R300_SU_CULL_MODE: 0x42b8 */ uint32_t line_stipple_config; /* R300_GA_LINE_STIPPLE_CONFIG: 0x4328 */ @@ -326,6 +326,10 @@ struct r300_context { uint32_t dirty_hw; /* Whether the TCL engine should be in bypass mode. */ boolean tcl_bypass; + /* Whether polygon offset is enabled. */ + boolean polygon_offset_enabled; + /* Z buffer bit depth. */ + uint32_t zbuffer_bpp; }; /* Convenience cast wrapper. */ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 11bd3346c7..2ea9fab015 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -584,19 +584,37 @@ void r300_emit_query_end(struct r300_context* r300) void r300_emit_rs_state(struct r300_context* r300, void* state) { struct r300_rs_state* rs = (struct r300_rs_state*)state; + float scale, offset; CS_LOCALS(r300); - BEGIN_CS(22); + BEGIN_CS(18 + (rs->polygon_offset_enable ? 5 : 0)); OUT_CS_REG(R300_VAP_CNTL_STATUS, rs->vap_control_status); OUT_CS_REG(R300_GA_POINT_SIZE, rs->point_size); OUT_CS_REG_SEQ(R300_GA_POINT_MINMAX, 2); OUT_CS(rs->point_minmax); OUT_CS(rs->line_control); - OUT_CS_REG_SEQ(R300_SU_POLY_OFFSET_FRONT_SCALE, 6); - OUT_CS(rs->depth_scale_front); - OUT_CS(rs->depth_offset_front); - OUT_CS(rs->depth_scale_back); - OUT_CS(rs->depth_offset_back); + + if (rs->polygon_offset_enable) { + scale = rs->depth_scale * 12; + offset = rs->depth_offset; + + switch (r300->zbuffer_bpp) { + case 16: + offset *= 4; + break; + case 24: + offset *= 2; + break; + } + + OUT_CS_REG_SEQ(R300_SU_POLY_OFFSET_FRONT_SCALE, 4); + OUT_CS_32F(scale); + OUT_CS_32F(offset); + OUT_CS_32F(scale); + OUT_CS_32F(offset); + } + + OUT_CS_REG_SEQ(R300_SU_POLY_OFFSET_ENABLE, 2); OUT_CS(rs->polygon_offset_enable); OUT_CS(rs->cull_mode); OUT_CS_REG(R300_GA_LINE_STIPPLE_CONFIG, rs->line_stipple_config); diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 609b910e12..e2ec0bc5bd 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -486,6 +486,7 @@ static void const struct pipe_framebuffer_state* state) { struct r300_context* r300 = r300_context(pipe); + uint32_t zbuffer_bpp = 0; if (r300->draw) { draw_flush(r300->draw); @@ -499,6 +500,23 @@ static void r300->blend_state.dirty = TRUE; r300->dsa_state.dirty = TRUE; r300->scissor_state.dirty = TRUE; + + /* Polyfon offset depends on the zbuffer bit depth. */ + if (state->zsbuf && r300->polygon_offset_enabled) { + switch (util_format_get_blocksize(state->zsbuf->texture->format)) { + case 2: + zbuffer_bpp = 16; + break; + case 4: + zbuffer_bpp = 24; + break; + } + + if (r300->zbuffer_bpp != zbuffer_bpp) { + r300->zbuffer_bpp = zbuffer_bpp; + r300->rs_state.dirty = TRUE; + } + } } /* Create fragment shader state. */ @@ -654,10 +672,8 @@ static void* r300_create_rs_state(struct pipe_context* pipe, } if (rs->polygon_offset_enable) { - rs->depth_offset_front = rs->depth_offset_back = - fui(state->offset_units); - rs->depth_scale_front = rs->depth_scale_back = - fui(state->offset_scale); + rs->depth_offset = state->offset_units; + rs->depth_scale = state->offset_scale; } if (state->line_stipple_enable) { @@ -691,8 +707,10 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state) if (rs) { r300->tcl_bypass = rs->rs.bypass_vs_clip_and_viewport; + r300->polygon_offset_enabled = rs->rs.offset_cw || rs->rs.offset_ccw; } else { r300->tcl_bypass = FALSE; + r300->polygon_offset_enabled = FALSE; } r300->rs_state.state = rs; -- cgit v1.2.3 From 0857f38c398bf14526bb47e0c57602be4e7a0ae4 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 18 Jan 2010 02:30:49 -0800 Subject: radeong: Don't allocate HW BOs for constantbufs. We have broken 1000 FPS. Hell yes. Heavily inspired by Marek's patch, but using pipebuffer instead of a roll-your-own malloc. --- src/gallium/winsys/drm/radeon/core/radeon_buffer.c | 31 +++++++++++++++++++--- src/gallium/winsys/drm/radeon/core/radeon_buffer.h | 5 +++- src/gallium/winsys/drm/radeon/core/radeon_drm.c | 8 ------ src/gallium/winsys/drm/radeon/core/radeon_drm.h | 9 +++++++ 4 files changed, 41 insertions(+), 12 deletions(-) diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c index 385fa857b5..b020ff38fa 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c @@ -58,6 +58,7 @@ static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws, { struct radeon_winsys *radeon_ws = (struct radeon_winsys *)ws; struct radeon_pipe_buffer *radeon_buffer; + struct pb_desc desc; uint32_t domain; radeon_buffer = CALLOC_STRUCT(radeon_pipe_buffer); @@ -70,6 +71,14 @@ static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws, radeon_buffer->base.usage = usage; radeon_buffer->base.size = size; + if (usage == PIPE_BUFFER_USAGE_CONSTANT && is_r3xx(radeon_ws->pci_id)) { + /* Don't bother allocating a BO, as it'll never get to the card. */ + desc.alignment = alignment; + desc.usage = usage; + radeon_buffer->pb = pb_malloc_buffer_create(size, &desc); + return &radeon_buffer->base; + } + domain = 0; if (usage & PIPE_BUFFER_USAGE_PIXEL) { @@ -133,8 +142,16 @@ static void radeon_buffer_del(struct pipe_buffer *buffer) struct radeon_pipe_buffer *radeon_buffer = (struct radeon_pipe_buffer*)buffer; - radeon_bo_unref(radeon_buffer->bo); - free(radeon_buffer); + if (radeon_buffer->pb) { + pipe_reference_init(&radeon_buffer->pb->base.reference, 0); + pb_destroy(radeon_buffer->pb); + } + + if (radeon_buffer->bo) { + radeon_bo_unref(radeon_buffer->bo); + } + + FREE(radeon_buffer); } static void *radeon_buffer_map(struct pipe_winsys *ws, @@ -146,6 +163,10 @@ static void *radeon_buffer_map(struct pipe_winsys *ws, (struct radeon_pipe_buffer*)buffer; int write = 0; + if (radeon_buffer->pb) { + return pb_map(radeon_buffer->pb, flags); + } + if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) { uint32_t domain; @@ -174,7 +195,11 @@ static void radeon_buffer_unmap(struct pipe_winsys *ws, struct radeon_pipe_buffer *radeon_buffer = (struct radeon_pipe_buffer*)buffer; - radeon_bo_unmap(radeon_buffer->bo); + if (radeon_buffer->pb) { + pb_unmap(radeon_buffer->pb); + } else { + radeon_bo_unmap(radeon_buffer->bo); + } } static void radeon_fence_reference(struct pipe_winsys *ws, diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h index d7f17564a9..de71cb2f42 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h @@ -36,7 +36,7 @@ #include "pipe/p_defines.h" #include "pipe/p_inlines.h" -//#include "state_tracker/st_public.h" +#include "pipebuffer/pb_buffer.h" #include "util/u_memory.h" @@ -49,7 +49,10 @@ struct radeon_pipe_buffer { struct pipe_buffer base; + /* Pointer to GPU-backed BO. */ struct radeon_bo *bo; + /* Pointer to fallback PB buffer. */ + struct pb_buffer *pb; boolean flinked; uint32_t flink; }; diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c index 572c5df458..9552f0ad6a 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c @@ -120,14 +120,6 @@ static void do_ioctls(int fd, struct radeon_winsys* winsys) drmFreeVersion(version); } -/* Guess at whether this chipset should use r300g. - * - * I believe that this check is valid, but I haven't been exhaustive. */ -static boolean is_r3xx(int pciid) -{ - return (pciid > 0x3150) && (pciid < 0x796f); -} - /* Create a pipe_screen. */ struct pipe_screen* radeon_create_screen(struct drm_api* api, int drmFB, diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.h b/src/gallium/winsys/drm/radeon/core/radeon_drm.h index 28f2ba818e..ddd7983824 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.h @@ -77,4 +77,13 @@ boolean radeon_global_handle_from_buffer(struct drm_api* api, unsigned* handle); void radeon_destroy_drm_api(struct drm_api* api); + +/* Guess at whether this chipset should use r300g. + * + * I believe that this check is valid, but I haven't been exhaustive. */ +static boolean is_r3xx(int pciid) +{ + return (pciid > 0x3150) && (pciid < 0x796f); +} + #endif -- cgit v1.2.3 From 7b82f0f67e4614fc12aee492b0a3cdf5db7391df Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Mon, 18 Jan 2010 12:42:10 +0200 Subject: r600: fix shadow_ambient shader rtype enums are different, DST_REG_OUTPUT got SRC_REG_CONSTANT in some shaders and produced invalid output/hang as TEX output is temp register always set out src to SRC_REG_TEMPORARY --- src/mesa/drivers/dri/r600/r700_assembler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/r600/r700_assembler.c b/src/mesa/drivers/dri/r600/r700_assembler.c index 0ff16b4ddd..20e165ed7d 100644 --- a/src/mesa/drivers/dri/r600/r700_assembler.c +++ b/src/mesa/drivers/dri/r600/r700_assembler.c @@ -4469,7 +4469,7 @@ GLboolean assemble_TEX(r700_AssemblerBase *pAsm) } pAsm->D2.dst2.SaturateMode = 1; - pAsm->S[0].src.rtype = pAsm->D.dst.rtype; + pAsm->S[0].src.rtype = SRC_REG_TEMPORARY; pAsm->S[0].src.reg = pAsm->D.dst.reg; noswizzle_PVSSRC(&(pAsm->S[0].src)); noneg_PVSSRC(&(pAsm->S[0].src)); -- cgit v1.2.3 From 46dc6fd3ed5ef96cda53641a97bc68c3bc104a9f Mon Sep 17 00:00:00 2001 From: Jerome Glisse Date: Mon, 18 Jan 2010 11:05:50 +0100 Subject: r6xx/r7xx: emit relocation for FRAG & TILE buffer FRAG & TILE buffer are unused but still they need to be associated with a valid relocation so that userspace can't try to abuse them to overwritte GART and then try to write anywhere in system memory. --- src/mesa/drivers/dri/r600/r700_chip.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r700_chip.c b/src/mesa/drivers/dri/r600/r700_chip.c index 3bc2d2ba02..1a1a87c3cf 100644 --- a/src/mesa/drivers/dri/r600/r700_chip.c +++ b/src/mesa/drivers/dri/r600/r700_chip.c @@ -453,13 +453,31 @@ static void r700SendRenderTargetState(GLcontext *ctx, struct radeon_state_atom * R600_OUT_BATCH((2 << id)); END_BATCH(); } + /* Set CMASK & TILE buffer to the offset of color buffer as + * we don't use those this shouldn't cause any issue and we + * then have a valid cmd stream + */ + BEGIN_BATCH_NO_AUTOSTATE(3 + 2); + R600_OUT_BATCH_REGSEQ(CB_COLOR0_TILE + (4 * id), 1); + R600_OUT_BATCH(r700->render_target[id].CB_COLOR0_TILE.u32All); + R600_OUT_BATCH_RELOC(r700->render_target[id].CB_COLOR0_BASE.u32All, + rrb->bo, + r700->render_target[id].CB_COLOR0_BASE.u32All, + 0, RADEON_GEM_DOMAIN_VRAM, 0); + END_BATCH(); + BEGIN_BATCH_NO_AUTOSTATE(3 + 2); + R600_OUT_BATCH_REGSEQ(CB_COLOR0_FRAG + (4 * id), 1); + R600_OUT_BATCH(r700->render_target[id].CB_COLOR0_FRAG.u32All); + R600_OUT_BATCH_RELOC(r700->render_target[id].CB_COLOR0_BASE.u32All, + rrb->bo, + r700->render_target[id].CB_COLOR0_BASE.u32All, + 0, RADEON_GEM_DOMAIN_VRAM, 0); + END_BATCH(); - BEGIN_BATCH_NO_AUTOSTATE(18); + BEGIN_BATCH_NO_AUTOSTATE(12); R600_OUT_BATCH_REGVAL(CB_COLOR0_SIZE + (4 * id), r700->render_target[id].CB_COLOR0_SIZE.u32All); R600_OUT_BATCH_REGVAL(CB_COLOR0_VIEW + (4 * id), r700->render_target[id].CB_COLOR0_VIEW.u32All); R600_OUT_BATCH_REGVAL(CB_COLOR0_INFO + (4 * id), r700->render_target[id].CB_COLOR0_INFO.u32All); - R600_OUT_BATCH_REGVAL(CB_COLOR0_TILE + (4 * id), r700->render_target[id].CB_COLOR0_TILE.u32All); - R600_OUT_BATCH_REGVAL(CB_COLOR0_FRAG + (4 * id), r700->render_target[id].CB_COLOR0_FRAG.u32All); R600_OUT_BATCH_REGVAL(CB_COLOR0_MASK + (4 * id), r700->render_target[id].CB_COLOR0_MASK.u32All); END_BATCH(); -- cgit v1.2.3 From 15601835361e2fdd34b38b265cfc3007749ee24d Mon Sep 17 00:00:00 2001 From: Jerome Glisse Date: Mon, 18 Jan 2010 15:32:24 +0100 Subject: r600: Update default state size to account for the new relocation the new relocation for CB_COLOR0_FRAG & CB_COLOR0_TILE add 4 dwords to the default command stream. Increase the prediction default size to take this into account --- src/mesa/drivers/dri/r600/r700_render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/r600/r700_render.c b/src/mesa/drivers/dri/r600/r700_render.c index eab27cbd84..3a6210c53a 100644 --- a/src/mesa/drivers/dri/r600/r700_render.c +++ b/src/mesa/drivers/dri/r600/r700_render.c @@ -422,7 +422,7 @@ static void r700RunRenderPrimitiveImmediate(GLcontext * ctx, int start, int end, } /* start 3d, idle, cb/db flush */ -#define PRE_EMIT_STATE_BUFSZ 10 + 5 + 14 +#define PRE_EMIT_STATE_BUFSZ 10 + 5 + 18 static GLuint r700PredictRenderSize(GLcontext* ctx, const struct _mesa_prim *prim, -- cgit v1.2.3 From 3310fe0e91c86df098a499a55f7aed5530f10290 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Mon, 18 Jan 2010 11:21:19 -0500 Subject: r600: fix some warnings --- src/mesa/drivers/dri/r600/r700_assembler.c | 12 ++++++------ src/mesa/drivers/dri/r600/r700_assembler.h | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r700_assembler.c b/src/mesa/drivers/dri/r600/r700_assembler.c index 20e165ed7d..c01b2fbb14 100644 --- a/src/mesa/drivers/dri/r600/r700_assembler.c +++ b/src/mesa/drivers/dri/r600/r700_assembler.c @@ -5090,15 +5090,15 @@ void add_return_inst(r700_AssemblerBase *pAsm) { if(GL_FALSE == add_cf_instruction(pAsm) ) { - return GL_FALSE; + return; } //pAsm->cf_current_cf_clause_ptr->m_Word1.f.pop_count = 1; pAsm->cf_current_cf_clause_ptr->m_Word1.f.pop_count = 0; - pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_const = 0x0; + pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_const = 0x0; pAsm->cf_current_cf_clause_ptr->m_Word1.f.cond = SQ_CF_COND_ACTIVE; pAsm->cf_current_cf_clause_ptr->m_Word1.f.end_of_program = 0x0; - pAsm->cf_current_cf_clause_ptr->m_Word1.f.valid_pixel_mode = 0x0; + pAsm->cf_current_cf_clause_ptr->m_Word1.f.valid_pixel_mode = 0x0; pAsm->cf_current_cf_clause_ptr->m_Word1.f.cf_inst = SQ_CF_INST_RETURN; pAsm->cf_current_cf_clause_ptr->m_Word1.f.whole_quad_mode = 0x0; @@ -5302,7 +5302,7 @@ GLboolean assemble_CAL(r700_AssemblerBase *pAsm, GLboolean setRetInLoopFlag(r700_AssemblerBase *pAsm, GLuint flagValue) { - GLfloat fLiteral[2] = {0.1, 0.0}; + /*GLfloat fLiteral[2] = {0.1, 0.0};*/ pAsm->D.dst.opcode = SQ_OP2_INST_MOV; pAsm->D.dst.op3 = 0; @@ -5353,7 +5353,7 @@ GLboolean setRetInLoopFlag(r700_AssemblerBase *pAsm, GLuint flagValue) GLboolean testFlag(r700_AssemblerBase *pAsm) { - GLfloat fLiteral[2] = {0.1, 0.0}; + /*GLfloat fLiteral[2] = {0.1, 0.0};*/ //Test flag GLuint tmp = gethelpr(pAsm); @@ -6123,7 +6123,7 @@ GLboolean callPreSub(r700_AssemblerBase* pAsm, R700ControlFlowGenericClause* prelude_cf_ptr = NULL; - /* copy srcs to presub inputs */ + /* copy srcs to presub inputs */ pAsm->alu_x_opcode = SQ_CF_INST_ALU; for(i=0; i Date: Sun, 17 Jan 2010 14:47:53 -0800 Subject: st/mesa: fix memory leak in st_translate_mesa_program Signed-off-by: Brian Paul --- src/mesa/state_tracker/st_mesa_to_tgsi.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index e788008dfe..f07846f821 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -779,6 +779,7 @@ st_translate_mesa_program( { struct st_translate translate, *t; unsigned i; + enum pipe_error ret = PIPE_OK; t = &translate; memset(t, 0, sizeof *t); @@ -865,8 +866,10 @@ st_translate_mesa_program( t->constants = CALLOC( program->Parameters->NumParameters, sizeof t->constants[0] ); - if (t->constants == NULL) + if (t->constants == NULL) { + ret = PIPE_ERROR_OUT_OF_MEMORY; goto out; + } for (i = 0; i < program->Parameters->NumParameters; i++) { switch (program->Parameters->Parameters[i].Type) { @@ -920,8 +923,6 @@ st_translate_mesa_program( t->insn[t->labels[i].branch_target] ); } - return PIPE_OK; - out: FREE(t->insn); FREE(t->labels); @@ -931,7 +932,7 @@ out: debug_printf("%s: translate error flag set\n", __FUNCTION__); } - return PIPE_ERROR_OUT_OF_MEMORY; + return ret; } -- cgit v1.2.3 From 0766780a98a86c474c70dcd0179d697b906ecfdb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 18 Jan 2010 10:43:33 -0700 Subject: st/mesa: updated comments and whitespace --- src/mesa/state_tracker/st_mesa_to_tgsi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index f07846f821..05b56c9b58 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -48,6 +48,10 @@ struct label { unsigned token; }; + +/** + * Intermediate state used during shader translation. + */ struct st_translate { struct ureg_program *ureg; @@ -730,6 +734,7 @@ emit_face_var( struct st_translate *t, t->inputs[t->inputMapping[FRAG_ATTRIB_FACE]] = ureg_src(face_temp); } + static void emit_edgeflags( struct st_translate *t, const struct gl_program *program ) @@ -741,6 +746,7 @@ emit_edgeflags( struct st_translate *t, ureg_MOV( ureg, edge_dst, edge_src ); } + /** * Translate Mesa program to TGSI format. * \param program the program to translate @@ -758,7 +764,7 @@ emit_edgeflags( struct st_translate *t, * \param outputSemanticIndex the semantic index (ex: which texcoord) for * each output * - * \return array of translated tokens, caller's responsibility to free + * \return PIPE_OK or PIPE_ERROR_OUT_OF_MEMORY */ enum pipe_error st_translate_mesa_program( -- cgit v1.2.3 From 23ae31820042f2bc4694f7c48696a697d674b802 Mon Sep 17 00:00:00 2001 From: Marcin Slusarz Date: Sun, 17 Jan 2010 14:49:34 -0800 Subject: glxgears: unbind current context before "destroying" it glXDestroyContext does not destroy the context if it's still connected to some window. Unbind context from window to test it. Signed-off-by: Brian Paul --- progs/xdemos/glxgears.c | 1 + 1 file changed, 1 insertion(+) diff --git a/progs/xdemos/glxgears.c b/progs/xdemos/glxgears.c index 088f25a357..2993c82416 100644 --- a/progs/xdemos/glxgears.c +++ b/progs/xdemos/glxgears.c @@ -771,6 +771,7 @@ main(int argc, char *argv[]) glDeleteLists(gear1, 1); glDeleteLists(gear2, 1); glDeleteLists(gear3, 1); + glXMakeCurrent(dpy, None, NULL); glXDestroyContext(dpy, ctx); XDestroyWindow(dpy, win); XCloseDisplay(dpy); -- cgit v1.2.3 From e978b24c87be6d7572ed3272e6b186d5c54fb414 Mon Sep 17 00:00:00 2001 From: Marcin Slusarz Date: Mon, 18 Jan 2010 10:48:06 -0700 Subject: st/dri: fix optionCache memory leaks Signed-off-by: Brian Paul --- src/gallium/state_trackers/dri/dri_context.c | 6 ++++++ src/gallium/state_trackers/dri/dri_screen.c | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c index 8819936fca..cd9d8b682e 100644 --- a/src/gallium/state_trackers/dri/dri_context.c +++ b/src/gallium/state_trackers/dri/dri_context.c @@ -101,6 +101,12 @@ dri_destroy_context(__DRIcontextPrivate * cPriv) { struct dri_context *ctx = dri_context(cPriv); + /* note: we are freeing values and nothing more because + * driParseConfigFiles allocated values only - the rest + * is owned by screen optionCache. + */ + FREE(ctx->optionCache.values); + /* No particular reason to wait for command completion before * destroying a context, but it is probably worthwhile flushing it * to avoid having to add code elsewhere to cope with flushing a diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index 11ea28bcbe..d95c62745e 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -327,8 +327,18 @@ static void dri_destroy_screen(__DRIscreenPrivate * sPriv) { struct dri_screen *screen = dri_screen(sPriv); + int i; screen->pipe_screen->destroy(screen->pipe_screen); + + for (i = 0; i < (1 << screen->optionCache.tableSize); ++i) { + FREE(screen->optionCache.info[i].name); + FREE(screen->optionCache.info[i].ranges); + } + + FREE(screen->optionCache.info); + FREE(screen->optionCache.values); + FREE(screen); sPriv->private = NULL; } -- cgit v1.2.3 From 4c041fac96303200f84b379829fd2f72cbc46423 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 18 Jan 2010 11:06:55 -0700 Subject: glsl: remove __inline directive It makes no difference with gcc -O3, for example. --- src/glsl/cl/sl_cl_parse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/cl/sl_cl_parse.c b/src/glsl/cl/sl_cl_parse.c index e9b3707ac1..e256ab8213 100644 --- a/src/glsl/cl/sl_cl_parse.c +++ b/src/glsl/cl/sl_cl_parse.c @@ -345,7 +345,7 @@ struct parse_state { }; -static __inline unsigned int +static unsigned int _emit(struct parse_context *ctx, unsigned int *out, unsigned char b) -- cgit v1.2.3 From 4698a865e076998107c188b39db039bdcbaac3a9 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 18 Jan 2010 12:11:05 +0100 Subject: tgsi: Add ureg_DECL_immediate_block_uint(). Allows declaring a contiguous block of immediates. Useful for relative indexing. --- src/gallium/auxiliary/tgsi/tgsi_ureg.c | 29 +++++++++++++++++++++++++++++ src/gallium/auxiliary/tgsi/tgsi_ureg.h | 5 +++++ 2 files changed, 34 insertions(+) diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index 8bd6f68dcc..a67d9c37f8 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -655,6 +655,35 @@ ureg_DECL_immediate_uint( struct ureg_program *ureg, } +struct ureg_src +ureg_DECL_immediate_block_uint( struct ureg_program *ureg, + const unsigned *v, + unsigned nr ) +{ + uint index; + uint i; + + if (ureg->nr_immediates + (nr + 3) / 4 > UREG_MAX_IMMEDIATE) { + set_bad(ureg); + return ureg_src_register(TGSI_FILE_IMMEDIATE, 0); + } + + index = ureg->nr_immediates; + ureg->nr_immediates += (nr + 3) / 4; + + for (i = index; i < ureg->nr_immediates; i++) { + ureg->immediate[i].type = TGSI_IMM_UINT32; + ureg->immediate[i].nr = nr > 4 ? 4 : nr; + memcpy(ureg->immediate[i].value.u, + &v[(i - index) * 4], + ureg->immediate[i].nr * sizeof(uint)); + nr -= 4; + } + + return ureg_src_register(TGSI_FILE_IMMEDIATE, index); +} + + struct ureg_src ureg_DECL_immediate_int( struct ureg_program *ureg, const int *v, diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h index 03eaf24854..a743be702b 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h @@ -167,6 +167,11 @@ ureg_DECL_immediate_uint( struct ureg_program *, const unsigned *v, unsigned nr ); +struct ureg_src +ureg_DECL_immediate_block_uint( struct ureg_program *, + const unsigned *v, + unsigned nr ); + struct ureg_src ureg_DECL_immediate_int( struct ureg_program *, const int *v, -- cgit v1.2.3 From 463351ea6c953c3db7f135ba97160a212562daef Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 18 Jan 2010 14:01:40 +0100 Subject: tgsi: Allow TEMPORARY registers as indirect address into source operands. --- src/gallium/auxiliary/tgsi/tgsi_sanity.c | 4 ---- src/gallium/auxiliary/tgsi/tgsi_ureg.c | 3 ++- src/gallium/auxiliary/tgsi/tgsi_ureg.h | 12 +++++++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_sanity.c b/src/gallium/auxiliary/tgsi/tgsi_sanity.c index e1e4f97967..8bea457a63 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sanity.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sanity.c @@ -335,10 +335,6 @@ iter_instruction( fill_scan_register1d(ind_reg, inst->Src[i].Indirect.File, inst->Src[i].Indirect.Index); - if (!(ind_reg->file == TGSI_FILE_ADDRESS || ind_reg->file == TGSI_FILE_LOOP) || - ind_reg->indices[0] != 0) { - report_warning(ctx, "Indirect register neither ADDR[0] nor LOOP[0]"); - } check_register_usage( ctx, ind_reg, diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index a67d9c37f8..ab557a23f9 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -247,6 +247,7 @@ ureg_src_register( unsigned file, src.SwizzleZ = TGSI_SWIZZLE_Z; src.SwizzleW = TGSI_SWIZZLE_W; src.Indirect = 0; + src.IndirectFile = TGSI_FILE_NULL; src.IndirectIndex = 0; src.IndirectSwizzle = 0; src.Absolute = 0; @@ -720,7 +721,7 @@ ureg_emit_src( struct ureg_program *ureg, if (src.Indirect) { out[0].src.Indirect = 1; out[n].value = 0; - out[n].src.File = TGSI_FILE_ADDRESS; + out[n].src.File = src.IndirectFile; out[n].src.SwizzleX = src.IndirectSwizzle; out[n].src.SwizzleY = src.IndirectSwizzle; out[n].src.SwizzleZ = src.IndirectSwizzle; diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h index a743be702b..8c8a6bbce6 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h @@ -52,9 +52,10 @@ struct ureg_src unsigned Absolute : 1; /* BOOL */ unsigned Negate : 1; /* BOOL */ int Index : 16; /* SINT */ + unsigned IndirectFile : 4; /* TGSI_FILE_ */ int IndirectIndex : 16; /* SINT */ - int IndirectSwizzle : 2; /* TGSI_SWIZZLE_ */ - int DimensionIndex : 16; /* SINT */ + unsigned IndirectSwizzle : 2; /* TGSI_SWIZZLE_ */ + int DimensionIndex : 16; /* SINT */ }; /* Very similar to a tgsi_dst_register, removing unsupported fields @@ -773,8 +774,9 @@ static INLINE struct ureg_src ureg_src_indirect( struct ureg_src reg, struct ureg_src addr ) { assert(reg.File != TGSI_FILE_NULL); - assert(addr.File == TGSI_FILE_ADDRESS); + assert(addr.File == TGSI_FILE_ADDRESS || addr.File == TGSI_FILE_TEMPORARY); reg.Indirect = 1; + reg.IndirectFile = addr.File; reg.IndirectIndex = addr.Index; reg.IndirectSwizzle = addr.SwizzleX; return reg; @@ -794,6 +796,8 @@ ureg_dst( struct ureg_src src ) { struct ureg_dst dst; + assert(!src.Indirect || src.IndirectFile == TGSI_FILE_ADDRESS); + dst.File = src.File; dst.WriteMask = TGSI_WRITEMASK_XYZW; dst.Indirect = src.Indirect; @@ -822,6 +826,7 @@ ureg_src( struct ureg_dst dst ) src.SwizzleZ = TGSI_SWIZZLE_Z; src.SwizzleW = TGSI_SWIZZLE_W; src.Indirect = dst.Indirect; + src.IndirectFile = TGSI_FILE_ADDRESS; src.IndirectIndex = dst.IndirectIndex; src.IndirectSwizzle = dst.IndirectSwizzle; src.Absolute = 0; @@ -868,6 +873,7 @@ ureg_src_undef( void ) src.SwizzleZ = 0; src.SwizzleW = 0; src.Indirect = 0; + src.IndirectFile = TGSI_FILE_NULL; src.IndirectIndex = 0; src.IndirectSwizzle = 0; src.Absolute = 0; -- cgit v1.2.3 From 7472cd0f1f0f8284729274bc5c453d59d9ab4b55 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 18 Jan 2010 19:07:44 +0100 Subject: tgsi: Fix behaviour of dimension index. The dimension index always addresses the second-dimension axis. --- src/gallium/auxiliary/tgsi/tgsi_dump.c | 13 +++++----- src/gallium/auxiliary/tgsi/tgsi_exec.c | 41 +++++++++++++++++--------------- src/gallium/auxiliary/tgsi/tgsi_sanity.c | 2 +- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c index d7ff262f30..c254a7274f 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_dump.c +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c @@ -219,8 +219,13 @@ _dump_register_src( struct dump_ctx *ctx, const struct tgsi_full_src_register *src ) { + ENM(src->Register.File, file_names); + if (src->Register.Dimension) { + CHR('['); + SID(src->Dimension.Index); + CHR(']'); + } if (src->Register.Indirect) { - ENM( src->Register.File, file_names ); CHR( '[' ); ENM( src->Indirect.File, file_names ); CHR( '[' ); @@ -234,16 +239,10 @@ _dump_register_src( } CHR( ']' ); } else { - ENM( src->Register.File, file_names ); CHR( '[' ); SID( src->Register.Index ); CHR( ']' ); } - if (src->Register.Dimension) { - CHR( '[' ); - SID( src->Dimension.Index ); - CHR( ']' ); - } } static void diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 118a638ab4..83646b73c1 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -1129,11 +1129,14 @@ fetch_source(const struct tgsi_exec_machine *mach, * subscript to a register file. Effectively it means that * the register file is actually a 2D array of registers. * - * file[1][3] == file[1*sizeof(file[1])+3], + * file[3][1] == file[3*sizeof(file[1])+1], * where: * [3] = Dimension.Index */ if (reg->Register.Dimension) { + int array_size; + union tgsi_exec_channel dim_index; + /* The size of the first-order array depends on the register file type. * We need to multiply the index to the first array to get an effective, * "flat" index that points to the beginning of the second-order array. @@ -1141,32 +1144,27 @@ fetch_source(const struct tgsi_exec_machine *mach, switch (reg->Register.File) { case TGSI_FILE_INPUT: case TGSI_FILE_SYSTEM_VALUE: - index.i[0] *= TGSI_EXEC_MAX_INPUT_ATTRIBS; - index.i[1] *= TGSI_EXEC_MAX_INPUT_ATTRIBS; - index.i[2] *= TGSI_EXEC_MAX_INPUT_ATTRIBS; - index.i[3] *= TGSI_EXEC_MAX_INPUT_ATTRIBS; + array_size = TGSI_EXEC_MAX_INPUT_ATTRIBS; break; case TGSI_FILE_CONSTANT: - index.i[0] *= TGSI_EXEC_MAX_CONST_BUFFER; - index.i[1] *= TGSI_EXEC_MAX_CONST_BUFFER; - index.i[2] *= TGSI_EXEC_MAX_CONST_BUFFER; - index.i[3] *= TGSI_EXEC_MAX_CONST_BUFFER; + array_size = TGSI_EXEC_MAX_CONST_BUFFER; break; default: assert( 0 ); + array_size = 0; } - index.i[0] += reg->Dimension.Index; - index.i[1] += reg->Dimension.Index; - index.i[2] += reg->Dimension.Index; - index.i[3] += reg->Dimension.Index; + dim_index.i[0] = + dim_index.i[1] = + dim_index.i[2] = + dim_index.i[3] = reg->Dimension.Index; /* Again, the second subscript index can be addressed indirectly * identically to the first one. * Nothing stops us from indirectly addressing the indirect register, * but there is no need for that, so we won't exercise it. * - * file[1][ind[4].y+3], + * file[ind[4].y+3][1], * where: * ind = DimIndirect.File * [4] = DimIndirect.Index @@ -1191,20 +1189,25 @@ fetch_source(const struct tgsi_exec_machine *mach, &index2, &indir_index ); - index.i[0] += indir_index.i[0]; - index.i[1] += indir_index.i[1]; - index.i[2] += indir_index.i[2]; - index.i[3] += indir_index.i[3]; + dim_index.i[0] += indir_index.i[0]; + dim_index.i[1] += indir_index.i[1]; + dim_index.i[2] += indir_index.i[2]; + dim_index.i[3] += indir_index.i[3]; /* for disabled execution channels, zero-out the index to * avoid using a potential garbage value. */ for (i = 0; i < QUAD_SIZE; i++) { if ((execmask & (1 << i)) == 0) - index.i[i] = 0; + dim_index.i[i] = 0; } } + index.i[0] += dim_index.i[0] * array_size; + index.i[1] += dim_index.i[1] * array_size; + index.i[2] += dim_index.i[2] * array_size; + index.i[3] += dim_index.i[3] * array_size; + /* If by any chance there was a need for a 3D array of register * files, we would have to check whether Dimension is followed * by a dimension register and continue the saga. diff --git a/src/gallium/auxiliary/tgsi/tgsi_sanity.c b/src/gallium/auxiliary/tgsi/tgsi_sanity.c index 8bea457a63..431c3ffb14 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sanity.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sanity.c @@ -408,7 +408,7 @@ iter_declaration( uint vert; for (vert = 0; vert < ctx->implied_array_size; ++vert) { scan_register *reg = MALLOC(sizeof(scan_register)); - fill_scan_register2d(reg, file, vert, i); + fill_scan_register2d(reg, file, i, vert); check_and_declare(ctx, reg); } } else { -- cgit v1.2.3 From 28576c9ac5a3b6459d94822f333d2e3fbefe5003 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 18 Jan 2010 11:26:55 -0700 Subject: st/mesa: change instruction count assertion to > 0 Shaders should at least have an END instruction. --- src/mesa/state_tracker/st_atom_shader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index 9fad58a489..4c106eb89b 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -146,7 +146,7 @@ find_translated_vp(struct st_context *st, stfp->num_input_slots = numIn; - assert(stfp->Base.Base.NumInstructions > 1); + assert(stfp->Base.Base.NumInstructions > 0); st_translate_fragment_program(st, stfp, stfp->input_to_slot); } -- cgit v1.2.3 From 9fb9c9f9ca27fbdb90fc0a7a01bdff64d32c05bb Mon Sep 17 00:00:00 2001 From: Marcin Slusarz Date: Mon, 18 Jan 2010 16:12:38 +0100 Subject: nv50: fix nv50_program->immd memory leak --- src/gallium/drivers/nv50/nv50_program.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 4111d212e6..22fa6e6ae4 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -4659,6 +4659,7 @@ nv50_program_destroy(struct nv50_context *nv50, struct nv50_program *p) nouveau_bo_ref(NULL, &p->bo); + FREE(p->immd); nouveau_resource_free(&p->data[0]); p->translated = 0; -- cgit v1.2.3 From e74db4f20fdc4bd71259480f6f93436c98275cb9 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Mon, 18 Jan 2010 16:22:59 +0100 Subject: nv50: cannot exit shaders on a control flow instruction Fixes lockup triggered by this ingenious shader: 1: CALL :3 2: END 3: BGNSUB ... --- src/gallium/drivers/nv50/nv50_program.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 22fa6e6ae4..20db51070f 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -477,6 +477,12 @@ is_join(struct nv50_program_exec *e) return FALSE; } +static INLINE boolean +is_control_flow(struct nv50_program_exec *e) +{ + return (e->inst[0] & 2); +} + static INLINE void set_pred(struct nv50_pc *pc, unsigned pred, unsigned idx, struct nv50_program_exec *e) @@ -3166,7 +3172,9 @@ nv50_program_tx_insn(struct nv50_pc *pc, if (!is_long(pc->p->exec_tail)) convert_to_long(pc, pc->p->exec_tail); else - if (is_immd(pc->p->exec_tail) || is_join(pc->p->exec_tail)) + if (is_immd(pc->p->exec_tail) || + is_join(pc->p->exec_tail) || + is_control_flow(pc->p->exec_tail)) emit_nop(pc); pc->p->exec_tail->inst[1] |= 1; /* set exit bit */ -- cgit v1.2.3 From 0d6e3dd84d21a9c0a60cd64304d39d8928f37238 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Mon, 18 Jan 2010 19:52:34 +0100 Subject: nv50: make instanced drawing work with edge flags And fix some obvious mistakes introduced in the previous instancing commit. --- src/gallium/drivers/nv50/nv50_vbo.c | 207 ++++++++++++++++++++++++++++-------- 1 file changed, 162 insertions(+), 45 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index 3238629461..b9cf0754b7 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -40,6 +40,8 @@ nv50_push_elements_u32(struct nv50_context *, uint32_t *, unsigned); static boolean nv50_push_arrays(struct nv50_context *, unsigned, unsigned); +#define NV50_USING_LOATHED_EDGEFLAG(ctx) ((ctx)->vertprog->cfg.edgeflag_in < 16) + static INLINE unsigned nv50_prim(unsigned mode) { @@ -171,7 +173,7 @@ nv50_upload_vtxbuf(struct nv50_context *nv50, unsigned i) struct pipe_buffer *buf = nscreen->strm_vbuf[i]; struct pipe_vertex_buffer *vb = &nv50->vtxbuf[i]; uint8_t *src; - unsigned size = MAX2(vb->buffer->size, 4096); + unsigned size = align(vb->buffer->size, 4096); if (buf && buf->size < size) pipe_buffer_reference(&nscreen->strm_vbuf[i], NULL); @@ -215,6 +217,74 @@ nv50_upload_user_vbufs(struct nv50_context *nv50) } } +static void +nv50_set_static_vtxattr(struct nv50_context *nv50, unsigned i, void *data) +{ + struct nouveau_grobj *tesla = nv50->screen->tesla; + struct nouveau_channel *chan = tesla->channel; + float v[4]; + + util_format_read_4f(nv50->vtxelt[i].src_format, + v, 0, data, 0, 0, 0, 1, 1); + + switch (nv50->vtxelt[i].nr_components) { + case 4: + BEGIN_RING(chan, tesla, NV50TCL_VTX_ATTR_4F_X(i), 4); + OUT_RING (chan, v[0]); + OUT_RING (chan, v[1]); + OUT_RING (chan, v[2]); + OUT_RING (chan, v[3]); + break; + case 3: + BEGIN_RING(chan, tesla, NV50TCL_VTX_ATTR_3F_X(i), 4); + OUT_RING (chan, v[0]); + OUT_RING (chan, v[1]); + OUT_RING (chan, v[2]); + break; + case 2: + BEGIN_RING(chan, tesla, NV50TCL_VTX_ATTR_2F_X(i), 4); + OUT_RING (chan, v[0]); + OUT_RING (chan, v[1]); + break; + case 1: + BEGIN_RING(chan, tesla, NV50TCL_VTX_ATTR_1F(i), 4); + OUT_RING (chan, v[0]); + break; + default: + assert(0); + break; + } +} + +static unsigned +init_per_instance_arrays_immd(struct nv50_context *nv50, + unsigned startInstance, + unsigned pos[16], unsigned step[16]) +{ + struct nouveau_bo *bo; + unsigned i, b, count = 0; + + for (i = 0; i < nv50->vtxelt_nr; ++i) { + if (!nv50->vtxelt[i].instance_divisor) + continue; + ++count; + b = nv50->vtxelt[i].vertex_buffer_index; + + pos[i] = nv50->vtxelt[i].src_offset + + nv50->vtxbuf[b].buffer_offset + + startInstance * nv50->vtxbuf[b].stride; + step[i] = startInstance % nv50->vtxelt[i].instance_divisor; + + bo = nouveau_bo(nv50->vtxbuf[b].buffer); + if (!bo->map) + nouveau_bo_map(bo, NOUVEAU_BO_RD); + + nv50_set_static_vtxattr(nv50, i, (uint8_t *)bo->map + pos[i]); + } + + return count; +} + static unsigned init_per_instance_arrays(struct nv50_context *nv50, unsigned startInstance, @@ -227,6 +297,10 @@ init_per_instance_arrays(struct nv50_context *nv50, unsigned i, b, count = 0; const uint32_t rl = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD; + if (nv50->vbo_fifo) + return init_per_instance_arrays_immd(nv50, startInstance, + pos, step); + so = so_new(nv50->vtxelt_nr, nv50->vtxelt_nr * 2, nv50->vtxelt_nr * 2); for (i = 0; i < nv50->vtxelt_nr; ++i) { @@ -248,11 +322,11 @@ init_per_instance_arrays(struct nv50_context *nv50, bo = nouveau_bo(nv50->vtxbuf[b].buffer); so_method(so, tesla, NV50TCL_VERTEX_ARRAY_START_HIGH(i), 2); - so_reloc (so, bo, pos[i], rl | NOUVEAU_BO_LOW, 0, 0); so_reloc (so, bo, pos[i], rl | NOUVEAU_BO_HIGH, 0, 0); + so_reloc (so, bo, pos[i], rl | NOUVEAU_BO_LOW, 0, 0); } - if (count) { + if (count && startInstance) { so_ref (so, &nv50->state.instbuf); /* for flush notify */ so_emit(chan, nv50->state.instbuf); } @@ -261,6 +335,28 @@ init_per_instance_arrays(struct nv50_context *nv50, return count; } +static void +step_per_instance_arrays_immd(struct nv50_context *nv50, + unsigned pos[16], unsigned step[16]) +{ + struct nouveau_bo *bo; + unsigned i, b; + + for (i = 0; i < nv50->vtxelt_nr; ++i) { + if (!nv50->vtxelt[i].instance_divisor) + continue; + if (++step[i] != nv50->vtxelt[i].instance_divisor) + continue; + b = nv50->vtxelt[i].vertex_buffer_index; + bo = nouveau_bo(nv50->vtxbuf[b].buffer); + + step[i] = 0; + pos[i] += nv50->vtxbuf[b].stride; + + nv50_set_static_vtxattr(nv50, i, (uint8_t *)bo->map + pos[i]); + } +} + static void step_per_instance_arrays(struct nv50_context *nv50, unsigned pos[16], unsigned step[16]) @@ -272,6 +368,11 @@ step_per_instance_arrays(struct nv50_context *nv50, unsigned i, b; const uint32_t rl = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD; + if (nv50->vbo_fifo) { + step_per_instance_arrays_immd(nv50, pos, step); + return; + } + so = so_new(nv50->vtxelt_nr, nv50->vtxelt_nr * 2, nv50->vtxelt_nr * 2); for (i = 0; i < nv50->vtxelt_nr; ++i) { @@ -287,8 +388,8 @@ step_per_instance_arrays(struct nv50_context *nv50, bo = nouveau_bo(nv50->vtxbuf[b].buffer); so_method(so, tesla, NV50TCL_VERTEX_ARRAY_START_HIGH(i), 2); - so_reloc (so, bo, pos[i], rl | NOUVEAU_BO_LOW, 0, 0); so_reloc (so, bo, pos[i], rl | NOUVEAU_BO_HIGH, 0, 0); + so_reloc (so, bo, pos[i], rl | NOUVEAU_BO_LOW, 0, 0); } so_ref (so, &nv50->state.instbuf); /* for flush notify */ @@ -297,6 +398,16 @@ step_per_instance_arrays(struct nv50_context *nv50, so_emit(chan, nv50->state.instbuf); } +static INLINE void +nv50_unmap_vbufs(struct nv50_context *nv50) +{ + unsigned i; + + for (i = 0; i < nv50->vtxbuf_nr; ++i) + if (nouveau_bo(nv50->vtxbuf[i].buffer)->map) + nouveau_bo_unmap(nouveau_bo(nv50->vtxbuf[i].buffer)); +} + void nv50_draw_arrays_instanced(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count, @@ -308,7 +419,8 @@ nv50_draw_arrays_instanced(struct pipe_context *pipe, unsigned i, nz_divisors; unsigned step[16], pos[16]; - nv50_upload_user_vbufs(nv50); + if (!NV50_USING_LOATHED_EDGEFLAG(nv50)) + nv50_upload_user_vbufs(nv50); nv50_state_validate(nv50); @@ -320,9 +432,14 @@ nv50_draw_arrays_instanced(struct pipe_context *pipe, BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); OUT_RING (chan, nv50_prim(mode)); - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BUFFER_FIRST, 2); - OUT_RING (chan, start); - OUT_RING (chan, count); + + if (nv50->vbo_fifo) + nv50_push_arrays(nv50, start, count); + else { + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BUFFER_FIRST, 2); + OUT_RING (chan, start); + OUT_RING (chan, count); + } BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); OUT_RING (chan, 0); @@ -332,12 +449,18 @@ nv50_draw_arrays_instanced(struct pipe_context *pipe, BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); OUT_RING (chan, nv50_prim(mode) | (1 << 28)); - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BUFFER_FIRST, 2); - OUT_RING (chan, start); - OUT_RING (chan, count); + + if (nv50->vbo_fifo) + nv50_push_arrays(nv50, start, count); + else { + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BUFFER_FIRST, 2); + OUT_RING (chan, start); + OUT_RING (chan, count); + } BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); OUT_RING (chan, 0); } + nv50_unmap_vbufs(nv50); so_ref(NULL, &nv50->state.instbuf); } @@ -372,6 +495,8 @@ nv50_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); OUT_RING (chan, 0); + nv50_unmap_vbufs(nv50); + /* XXX: not sure what to do if ret != TRUE: flush and retry? */ assert(ret); @@ -400,7 +525,7 @@ nv50_draw_elements_inline_u08(struct nv50_context *nv50, uint8_t *map, unsigned nr = count > 2046 ? 2046 : count; int i; - BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U16 | 0x40000000, nr >> 1); + BEGIN_RING_NI(chan, tesla, NV50TCL_VB_ELEMENT_U16, nr >> 1); for (i = 0; i < nr; i += 2) OUT_RING (chan, (map[i + 1] << 16) | map[i]); @@ -433,7 +558,7 @@ nv50_draw_elements_inline_u16(struct nv50_context *nv50, uint16_t *map, unsigned nr = count > 2046 ? 2046 : count; int i; - BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U16 | 0x40000000, nr >> 1); + BEGIN_RING_NI(chan, tesla, NV50TCL_VB_ELEMENT_U16, nr >> 1); for (i = 0; i < nr; i += 2) OUT_RING (chan, (map[i + 1] << 16) | map[i]); @@ -458,7 +583,7 @@ nv50_draw_elements_inline_u32(struct nv50_context *nv50, uint32_t *map, while (count) { unsigned nr = count > 2047 ? 2047 : count; - BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U32 | 0x40000000, nr); + BEGIN_RING_NI(chan, tesla, NV50TCL_VB_ELEMENT_U32, nr); OUT_RINGp (chan, map, nr); count -= nr; @@ -502,7 +627,8 @@ nv50_draw_elements_instanced(struct pipe_context *pipe, map = pipe_buffer_map(pscreen, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ); - nv50_upload_user_vbufs(nv50); + if (!NV50_USING_LOATHED_EDGEFLAG(nv50)) + nv50_upload_user_vbufs(nv50); nv50_state_validate(nv50); @@ -513,7 +639,7 @@ nv50_draw_elements_instanced(struct pipe_context *pipe, OUT_RING (chan, startInstance); BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); - OUT_RING (chan, nv50_prim(mode) | (1 << 28)); + OUT_RING (chan, nv50_prim(mode)); nv50_draw_elements_inline(nv50, map, indexSize, start, count); @@ -532,6 +658,7 @@ nv50_draw_elements_instanced(struct pipe_context *pipe, BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); OUT_RING (chan, 0); } + nv50_unmap_vbufs(nv50); so_ref(NULL, &nv50->state.instbuf); } @@ -564,6 +691,8 @@ nv50_draw_elements(struct pipe_context *pipe, BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); OUT_RING (chan, 0); + nv50_unmap_vbufs(nv50); + pipe_buffer_unmap(pscreen, indexBuffer); } @@ -644,7 +773,7 @@ nv50_vbo_validate(struct nv50_context *nv50) !(nv50->vtxbuf[i].buffer->usage & PIPE_BUFFER_USAGE_VERTEX)) nv50->vbo_fifo = 0xffff; - if (nv50->vertprog->cfg.edgeflag_in < 16) + if (NV50_USING_LOATHED_EDGEFLAG(nv50)) nv50->vbo_fifo = 0xffff; /* vertprog can't set edgeflag */ n_ve = MAX2(nv50->vtxelt_nr, nv50->state.vtxelt_nr); @@ -672,14 +801,16 @@ nv50_vbo_validate(struct nv50_context *nv50) nv50->vbo_fifo &= ~(1 << i); continue; } - so_data(vtxfmt, hw | i); if (nv50->vbo_fifo) { + so_data (vtxfmt, hw | + (ve->instance_divisor ? (1 << 4) : i)); so_method(vtxbuf, tesla, NV50TCL_VERTEX_ARRAY_FORMAT(i), 1); so_data (vtxbuf, 0); continue; } + so_data(vtxfmt, hw | i); so_method(vtxbuf, tesla, NV50TCL_VERTEX_ARRAY_FORMAT(i), 3); so_data (vtxbuf, 0x20000000 | @@ -721,7 +852,7 @@ typedef void (*pfn_push)(struct nouveau_channel *, void *); struct nv50_vbo_emitctx { pfn_push push[16]; - void *map[16]; + uint8_t *map[16]; unsigned stride[16]; unsigned nr_ve; unsigned vtx_dwords; @@ -759,19 +890,18 @@ nv50_map_vbufs(struct nv50_context *nv50) for (i = 0; i < nv50->vtxbuf_nr; ++i) { struct pipe_vertex_buffer *vb = &nv50->vtxbuf[i]; - unsigned size, delta; + unsigned size = vb->stride * (vb->max_index + 1) + 16; if (nouveau_bo(vb->buffer)->map) continue; - size = vb->stride * (vb->max_index + 1); - delta = vb->buffer_offset; - + size = vb->stride * (vb->max_index + 1) + 16; + size = MIN2(size, vb->buffer->size); if (!size) - size = vb->buffer->size - vb->buffer_offset; + size = vb->buffer->size; if (nouveau_bo_map_range(nouveau_bo(vb->buffer), - delta, size, NOUVEAU_BO_RD)) + 0, size, NOUVEAU_BO_RD)) break; } @@ -782,16 +912,6 @@ nv50_map_vbufs(struct nv50_context *nv50) return FALSE; } -static INLINE void -nv50_unmap_vbufs(struct nv50_context *nv50) -{ - unsigned i; - - for (i = 0; i < nv50->vtxbuf_nr; ++i) - if (nouveau_bo(nv50->vtxbuf[i].buffer)->map) - nouveau_bo_unmap(nouveau_bo(nv50->vtxbuf[i].buffer)); -} - static void emit_b32_1(struct nouveau_channel *chan, void *data) { @@ -886,12 +1006,13 @@ emit_prepare(struct nv50_context *nv50, struct nv50_vbo_emitctx *emit, ve = &nv50->vtxelt[i]; vb = &nv50->vtxbuf[ve->vertex_buffer_index]; - if (!(nv50->vbo_fifo & (1 << i))) + if (!(nv50->vbo_fifo & (1 << i)) || ve->instance_divisor) continue; n = emit->nr_ve++; emit->stride[n] = vb->stride; - emit->map[n] = nouveau_bo(vb->buffer)->map + + emit->map[n] = (uint8_t *)nouveau_bo(vb->buffer)->map + + vb->buffer_offset + (start * vb->stride + ve->src_offset); desc = util_format_description(ve->src_format); @@ -981,13 +1102,12 @@ nv50_push_arrays(struct nv50_context *nv50, unsigned start, unsigned count) set_edgeflag(chan, tesla, &emit, 0); /* nr will be 1 */ - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_DATA | 0x40000000, dw); + BEGIN_RING_NI(chan, tesla, NV50TCL_VERTEX_DATA, dw); for (i = 0; i < nr; ++i) emit_vtx_next(chan, &emit); count -= nr; } - nv50_unmap_vbufs(nv50); return TRUE; } @@ -1008,13 +1128,12 @@ nv50_push_elements_u32(struct nv50_context *nv50, uint32_t *map, unsigned count) set_edgeflag(chan, tesla, &emit, *map); - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_DATA | 0x40000000, dw); + BEGIN_RING_NI(chan, tesla, NV50TCL_VERTEX_DATA, dw); for (i = 0; i < nr; ++i) emit_vtx(chan, &emit, *map++); count -= nr; } - nv50_unmap_vbufs(nv50); return TRUE; } @@ -1035,13 +1154,12 @@ nv50_push_elements_u16(struct nv50_context *nv50, uint16_t *map, unsigned count) set_edgeflag(chan, tesla, &emit, *map); - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_DATA | 0x40000000, dw); + BEGIN_RING_NI(chan, tesla, NV50TCL_VERTEX_DATA, dw); for (i = 0; i < nr; ++i) emit_vtx(chan, &emit, *map++); count -= nr; } - nv50_unmap_vbufs(nv50); return TRUE; } @@ -1062,13 +1180,12 @@ nv50_push_elements_u08(struct nv50_context *nv50, uint8_t *map, unsigned count) set_edgeflag(chan, tesla, &emit, *map); - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_DATA | 0x40000000, dw); + BEGIN_RING_NI(chan, tesla, NV50TCL_VERTEX_DATA, dw); for (i = 0; i < nr; ++i) emit_vtx(chan, &emit, *map++); count -= nr; } - nv50_unmap_vbufs(nv50); return TRUE; } -- cgit v1.2.3 From c6559b7e01bbbf7f8d23d6ca58b5fe3d8514ad97 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Mon, 18 Jan 2010 21:37:33 +0100 Subject: nv50: fix constant vtxattr methods This function was untested, sorry. --- src/gallium/drivers/nv50/nv50_vbo.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index b9cf0754b7..bfb1b34d27 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -230,25 +230,25 @@ nv50_set_static_vtxattr(struct nv50_context *nv50, unsigned i, void *data) switch (nv50->vtxelt[i].nr_components) { case 4: BEGIN_RING(chan, tesla, NV50TCL_VTX_ATTR_4F_X(i), 4); - OUT_RING (chan, v[0]); - OUT_RING (chan, v[1]); - OUT_RING (chan, v[2]); - OUT_RING (chan, v[3]); + OUT_RINGf (chan, v[0]); + OUT_RINGf (chan, v[1]); + OUT_RINGf (chan, v[2]); + OUT_RINGf (chan, v[3]); break; case 3: - BEGIN_RING(chan, tesla, NV50TCL_VTX_ATTR_3F_X(i), 4); - OUT_RING (chan, v[0]); - OUT_RING (chan, v[1]); - OUT_RING (chan, v[2]); + BEGIN_RING(chan, tesla, NV50TCL_VTX_ATTR_3F_X(i), 3); + OUT_RINGf (chan, v[0]); + OUT_RINGf (chan, v[1]); + OUT_RINGf (chan, v[2]); break; case 2: - BEGIN_RING(chan, tesla, NV50TCL_VTX_ATTR_2F_X(i), 4); - OUT_RING (chan, v[0]); - OUT_RING (chan, v[1]); + BEGIN_RING(chan, tesla, NV50TCL_VTX_ATTR_2F_X(i), 2); + OUT_RINGf (chan, v[0]); + OUT_RINGf (chan, v[1]); break; case 1: - BEGIN_RING(chan, tesla, NV50TCL_VTX_ATTR_1F(i), 4); - OUT_RING (chan, v[0]); + BEGIN_RING(chan, tesla, NV50TCL_VTX_ATTR_1F(i), 1); + OUT_RINGf (chan, v[0]); break; default: assert(0); -- cgit v1.2.3 From d5b964234c37673ec6b444d0a8fa3b823f03fd05 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 9 Jan 2010 02:03:13 -0800 Subject: i965: Fix loads of non-relative-addr constants after a reladdr load. Fixes piglit vp-arl-constant-array-huge-overwritten. --- src/mesa/drivers/dri/i965/brw_vs_emit.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c index 1b84dd505f..59334c9ebb 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c @@ -771,7 +771,13 @@ get_constant(struct brw_vs_compile *c, if (c->current_const[argIndex].index != src->Index || relAddr) { struct brw_reg addrReg = c->regs[PROGRAM_ADDRESS][0]; - c->current_const[argIndex].index = src->Index; + /* If using a non-relative-addressed constant, then keep track of it for + * later use without reloading. + */ + if (relAddr) + c->current_const[argIndex].index = -1; + else + c->current_const[argIndex].index = src->Index; #if 0 printf(" fetch const[%d] for arg %d into reg %d\n", -- cgit v1.2.3 From c653f5f3872862da396353df63ef93ed86f608fa Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 11 Jan 2010 08:45:58 -0800 Subject: i965: Only set up the stack register if it's going to get used. --- src/mesa/drivers/dri/i965/brw_vs.h | 2 ++ src/mesa/drivers/dri/i965/brw_vs_emit.c | 27 +++++++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_vs.h b/src/mesa/drivers/dri/i965/brw_vs.h index 4a591365c9..249d48bc18 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.h +++ b/src/mesa/drivers/dri/i965/brw_vs.h @@ -81,6 +81,8 @@ struct brw_vs_compile { GLint index; struct brw_reg reg; } current_const[3]; + + GLboolean needs_stack; }; void brw_vs_emit( struct brw_vs_compile *c ); diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c index 59334c9ebb..c307ddcfd3 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c @@ -214,8 +214,10 @@ static void brw_vs_alloc_regs( struct brw_vs_compile *c ) } } - c->stack = brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, reg, 0); - reg += 2; + if (c->needs_stack) { + c->stack = brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, reg, 0); + reg += 2; + } /* Some opcodes need an internal temporary: */ @@ -1386,12 +1388,14 @@ void brw_vs_emit(struct brw_vs_compile *c ) brw_set_compression_control(p, BRW_COMPRESSION_NONE); brw_set_access_mode(p, BRW_ALIGN_16); - - /* Message registers can't be read, so copy the output into GRF register - if they are used in source registers */ + for (insn = 0; insn < nr_insns; insn++) { GLuint i; struct prog_instruction *inst = &c->vp->program.Base.Instructions[insn]; + + /* Message registers can't be read, so copy the output into GRF + * register if they are used in source registers + */ for (i = 0; i < 3; i++) { struct prog_src_register *src = &inst->SrcReg[i]; GLuint index = src->Index; @@ -1399,12 +1403,23 @@ void brw_vs_emit(struct brw_vs_compile *c ) if (file == PROGRAM_OUTPUT && index != VERT_RESULT_HPOS) c->output_regs[index].used_in_src = GL_TRUE; } + + switch (inst->Opcode) { + case OPCODE_CAL: + case OPCODE_RET: + c->needs_stack = GL_TRUE; + break; + default: + break; + } } /* Static register allocation */ brw_vs_alloc_regs(c); - brw_MOV(p, get_addr_reg(stack_index), brw_address(c->stack)); + + if (c->needs_stack) + brw_MOV(p, get_addr_reg(stack_index), brw_address(c->stack)); for (insn = 0; insn < nr_insns; insn++) { -- cgit v1.2.3 From 0714474ae225d12ea00da683785600c0c211f901 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 11 Jan 2010 09:23:41 -0800 Subject: i965: Clean up constbuf handling by splitting reladdr/non-reladdr loads. The codepaths in the function were almost entirely different. --- src/mesa/drivers/dri/i965/brw_vs_emit.c | 114 +++++++++++++++++++------------- 1 file changed, 68 insertions(+), 46 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c index c307ddcfd3..7a252dde6c 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c @@ -764,22 +764,15 @@ get_constant(struct brw_vs_compile *c, { const struct prog_src_register *src = &inst->SrcReg[argIndex]; struct brw_compile *p = &c->func; - struct brw_reg const_reg; - struct brw_reg const2_reg; - const GLboolean relAddr = src->RelAddr; + struct brw_reg const_reg = c->current_const[argIndex].reg; assert(argIndex < 3); - if (c->current_const[argIndex].index != src->Index || relAddr) { + if (c->current_const[argIndex].index != src->Index) { struct brw_reg addrReg = c->regs[PROGRAM_ADDRESS][0]; - /* If using a non-relative-addressed constant, then keep track of it for - * later use without reloading. - */ - if (relAddr) - c->current_const[argIndex].index = -1; - else - c->current_const[argIndex].index = src->Index; + /* Keep track of the last constant loaded in this slot, for reuse. */ + c->current_const[argIndex].index = src->Index; #if 0 printf(" fetch const[%d] for arg %d into reg %d\n", @@ -787,48 +780,74 @@ get_constant(struct brw_vs_compile *c, #endif /* need to fetch the constant now */ brw_dp_READ_4_vs(p, - c->current_const[argIndex].reg,/* writeback dest */ + const_reg, /* writeback dest */ 0, /* oword */ - relAddr, /* relative indexing? */ + 0, /* relative indexing? */ addrReg, /* address register */ 16 * src->Index, /* byte offset */ SURF_INDEX_VERT_CONST_BUFFER /* binding table index */ ); - - if (relAddr) { - /* second read */ - const2_reg = get_tmp(c); - - /* use upper half of address reg for second read */ - addrReg = stride(addrReg, 0, 4, 0); - addrReg.subnr = 16; - - brw_dp_READ_4_vs(p, - const2_reg, /* writeback dest */ - 1, /* oword */ - relAddr, /* relative indexing? */ - addrReg, /* address register */ - 16 * src->Index, /* byte offset */ - SURF_INDEX_VERT_CONST_BUFFER - ); - } } - const_reg = c->current_const[argIndex].reg; + /* replicate lower four floats into upper half (to get XYZWXYZW) */ + const_reg = stride(const_reg, 0, 4, 0); + const_reg.subnr = 0; - if (relAddr) { - /* merge the two Owords into the constant register */ - /* const_reg[7..4] = const2_reg[7..4] */ - brw_MOV(p, - suboffset(stride(const_reg, 0, 4, 1), 4), - suboffset(stride(const2_reg, 0, 4, 1), 4)); - release_tmp(c, const2_reg); - } - else { - /* replicate lower four floats into upper half (to get XYZWXYZW) */ - const_reg = stride(const_reg, 0, 4, 0); - const_reg.subnr = 0; - } + return const_reg; +} + +static struct brw_reg +get_reladdr_constant(struct brw_vs_compile *c, + const struct prog_instruction *inst, + GLuint argIndex) +{ + const struct prog_src_register *src = &inst->SrcReg[argIndex]; + struct brw_compile *p = &c->func; + struct brw_reg const_reg = c->current_const[argIndex].reg; + struct brw_reg const2_reg; + struct brw_reg addrReg = c->regs[PROGRAM_ADDRESS][0]; + + assert(argIndex < 3); + + /* Can't reuse a reladdr constant load. */ + c->current_const[argIndex].index = -1; + + #if 0 + printf(" fetch const[a0.x+%d] for arg %d into reg %d\n", + src->Index, argIndex, c->current_const[argIndex].reg.nr); +#endif + + /* fetch the first vec4 */ + brw_dp_READ_4_vs(p, + const_reg, /* writeback dest */ + 0, /* oword */ + 1, /* relative indexing? */ + addrReg, /* address register */ + 16 * src->Index, /* byte offset */ + SURF_INDEX_VERT_CONST_BUFFER /* binding table index */ + ); + /* second vec4 */ + const2_reg = get_tmp(c); + + /* use upper half of address reg for second read */ + addrReg = stride(addrReg, 0, 4, 0); + addrReg.subnr = 16; + + brw_dp_READ_4_vs(p, + const2_reg, /* writeback dest */ + 1, /* oword */ + 1, /* relative indexing? */ + addrReg, /* address register */ + 16 * src->Index, /* byte offset */ + SURF_INDEX_VERT_CONST_BUFFER + ); + + /* merge the two Owords into the constant register */ + /* const_reg[7..4] = const2_reg[7..4] */ + brw_MOV(p, + suboffset(stride(const_reg, 0, 4, 1), 4), + suboffset(stride(const2_reg, 0, 4, 1), 4)); + release_tmp(c, const2_reg); return const_reg; } @@ -936,7 +955,10 @@ get_src_reg( struct brw_vs_compile *c, case PROGRAM_ENV_PARAM: case PROGRAM_LOCAL_PARAM: if (c->vp->use_const_buffer) { - return get_constant(c, inst, argIndex); + if (relAddr) + return get_reladdr_constant(c, inst, argIndex); + else + return get_constant(c, inst, argIndex); } else if (relAddr) { return deref(c, c->regs[PROGRAM_STATE_VAR][0], index); -- cgit v1.2.3 From 9811ebf61f5d1220ef0c7e33e6677304e9b31052 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 18 Jan 2010 15:09:30 -0800 Subject: docs: PIPE_TEXTURE_USAGE info. From IRC with Jakob. --- src/gallium/docs/source/screen.rst | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index 9631e6967e..8cb7c70cd3 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -3,6 +3,26 @@ Screen A screen is an object representing the context-independent part of a device. +Useful Flags +------------ + +PIPE_TEXTURE_USAGE +^^^^^^^^^^^^^^^^^^ + +These flags determine the possible roles a texture may be used for during its +lifetime. Texture usage flags are cumulative and may be combined to create a +texture that can be used as multiple things. + +* ``RENDER_TARGET``: A colorbuffer or pixelbuffer. +* ``DISPLAY_TARGET``: A sharable buffer that can be given to another process. +* ``PRIMARY``: A frontbuffer or scanout buffer. +* ``DEPTH_STENCIL``: A depthbuffer, stencilbuffer, or Z buffer. Gallium does + not explicitly provide for stencil-only buffers, so any stencilbuffer + validated here is implicitly also a depthbuffer. +* ``SAMPLER``: A texture that may be sampled from in a fragment or vertex + shader. +* ``DYNAMIC``: XXX undefined + Methods ------- @@ -33,6 +53,10 @@ is_format_supported See if a format can be used in a specific manner. +**usage** is a bitmask of ``PIPE_TEXTURE_USAGE`` flags. + +Returns TRUE if all usages can be satisfied. + texture_create ^^^^^^^^^^^^^^ -- cgit v1.2.3 From 4f52dfeda2b3bc40b6c0acea0e9012c3b8cb36e8 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 18 Jan 2010 15:24:51 -0800 Subject: docs: Slowly keep fleshing out more info. --- src/gallium/docs/source/distro.rst | 25 ++++++++++++++++--------- src/gallium/docs/source/glossary.rst | 5 +++++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/gallium/docs/source/distro.rst b/src/gallium/docs/source/distro.rst index a448203c6f..05c3df67e3 100644 --- a/src/gallium/docs/source/distro.rst +++ b/src/gallium/docs/source/distro.rst @@ -61,10 +61,7 @@ VMWare SVGA ATI r300 ^^^^^^^^ -AMD/ATI r600 -^^^^^^^^^^^^ - -Highly experimental. +Testing-quality. Softpipe ^^^^^^^^ @@ -109,20 +106,29 @@ Auxiliary CSO Cache ^^^^^^^^^ +The CSO cache is used to accelerate preparation of state by saving +driver-specific state structures for later use. + Draw ^^^^ +Draw is a software :ref:`TCL` pipeline for hardware that lacks vertex shaders +or other essential parts of pre-rasterization vertex preparation. + Gallivm ^^^^^^^ Indices ^^^^^^^ -Tool for translating or generating element indices for element-based -rendering. +Indices provides tools for translating or generating element indices for +use with element-based rendering. + +Pipe Buffer Managers +^^^^^^^^^^^^^^^^^^^^ -Pipe Buffer Manager -^^^^^^^^^^^^^^^^^^^ +Each of these managers provides various services to drivers that are not +fully utilizing a memory manager. Remote Debugger ^^^^^^^^^^^^^^^ @@ -133,7 +139,8 @@ Runtime Assembly Emission TGSI ^^^^ -Basic utilities for manipulating TGSI streams. +The TGSI auxiliary module provides basic utilities for manipulating TGSI +streams. Translate ^^^^^^^^^ diff --git a/src/gallium/docs/source/glossary.rst b/src/gallium/docs/source/glossary.rst index 6a9110ce78..aec89f8b5c 100644 --- a/src/gallium/docs/source/glossary.rst +++ b/src/gallium/docs/source/glossary.rst @@ -8,3 +8,8 @@ Glossary Multi-Sampled Anti-Aliasing. A basic anti-aliasing technique that takes multiple samples of the depth buffer, and uses this information to smooth the edges of polygons. + + TCL + Transform, Clipping, & Lighting. The three stages of preparation in a + rasterizing pipeline prior to the actual rasterization of vertices into + fragments. -- cgit v1.2.3 From 2b4ad023211ebd69e53ebb2c261af66d09383440 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 18 Jan 2010 16:40:39 -0800 Subject: docs: Fix terms and refs. I fail at Sphinx-style ReST. --- src/gallium/docs/source/cso/rasterizer.rst | 2 +- src/gallium/docs/source/distro.rst | 2 +- src/gallium/docs/source/screen.rst | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gallium/docs/source/cso/rasterizer.rst b/src/gallium/docs/source/cso/rasterizer.rst index 4d8e1708e7..ba0a7d10ee 100644 --- a/src/gallium/docs/source/cso/rasterizer.rst +++ b/src/gallium/docs/source/cso/rasterizer.rst @@ -108,7 +108,7 @@ scissor Whether the scissor test is enabled. multisample - Whether :ref:`MSAA` is enabled. + Whether :term:`MSAA` is enabled. bypass_vs_clip_and_viewport Whether the entire TCL pipeline should be bypassed. This implies that diff --git a/src/gallium/docs/source/distro.rst b/src/gallium/docs/source/distro.rst index 05c3df67e3..596e4c0048 100644 --- a/src/gallium/docs/source/distro.rst +++ b/src/gallium/docs/source/distro.rst @@ -112,7 +112,7 @@ driver-specific state structures for later use. Draw ^^^^ -Draw is a software :ref:`TCL` pipeline for hardware that lacks vertex shaders +Draw is a software :term:`TCL` pipeline for hardware that lacks vertex shaders or other essential parts of pre-rasterization vertex preparation. Gallivm diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index 8cb7c70cd3..bac63135b5 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -6,6 +6,8 @@ A screen is an object representing the context-independent part of a device. Useful Flags ------------ +.. _pipe_texture_usage: + PIPE_TEXTURE_USAGE ^^^^^^^^^^^^^^^^^^ @@ -53,7 +55,7 @@ is_format_supported See if a format can be used in a specific manner. -**usage** is a bitmask of ``PIPE_TEXTURE_USAGE`` flags. +**usage** is a bitmask of :ref:`PIPE_TEXTURE_USAGE` flags. Returns TRUE if all usages can be satisfied. -- cgit v1.2.3 From 2598f00078cf34b1828bde2bd6ab73fed6c8c4d7 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 18 Jan 2010 17:12:13 -0800 Subject: docs: Cleanup Rasterizer a bit. I'm getting better at this, I think. --- src/gallium/docs/source/cso/rasterizer.rst | 92 +++++++++++++++--------------- src/gallium/docs/source/distro.rst | 2 + 2 files changed, 49 insertions(+), 45 deletions(-) diff --git a/src/gallium/docs/source/cso/rasterizer.rst b/src/gallium/docs/source/cso/rasterizer.rst index ba0a7d10ee..b801caae53 100644 --- a/src/gallium/docs/source/cso/rasterizer.rst +++ b/src/gallium/docs/source/cso/rasterizer.rst @@ -11,19 +11,56 @@ multisample state, scissoring and flat/smooth shading. Members ------- +bypass_vs_clip_and_viewport +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Whether the entire TCL pipeline should be bypassed. This implies that +vertices are pre-transformed for the viewport, and will not be run +through the vertex shader. + +.. note:: + + Implementations may still clip away vertices that are not in the viewport + when this is set. + flatshade - If set, the provoking vertex of each polygon is used to determine the - color of the entire polygon. If not set, fragment colors will be - interpolated between the vertex colors. - Note that this is separate from the fragment shader input attributes - CONSTANT, LINEAR and PERSPECTIVE. We need the flatshade state at +^^^^^^^^^ + +If set, the provoking vertex of each polygon is used to determine the color +of the entire polygon. If not set, fragment colors will be interpolated +between the vertex colors. + +The actual interpolated shading algorithm is obviously +implementation-dependent, but will usually be Gourard for most hardware. + +.. note:: + + This is separate from the fragment shader input attributes + CONSTANT, LINEAR and PERSPECTIVE. The flatshade state is needed at clipping time to determine how to set the color of new vertices. - Also note that the draw module can implement flat shading by copying - the provoking vertex color to all the other vertices in the primitive. + + :ref:`Draw` can implement flat shading by copying the provoking vertex + color to all the other vertices in the primitive. flatshade_first - Whether the first vertex should be the provoking vertex, for most - primitives. If not set, the last vertex is the provoking vertex. +^^^^^^^^^^^^^^^ + +Whether the first vertex should be the provoking vertex, for most primitives. +If not set, the last vertex is the provoking vertex. + +There are several important exceptions to the specification of this rule. + +* ``PIPE_PRIMITIVE_POLYGON``: The provoking vertex is always the first + vertex. If the caller wishes to change the provoking vertex, they merely + need to rotate the vertices themselves. +* ``PIPE_PRIMITIVE_QUAD``, ``PIPE_PRIMITIVE_QUAD_STRIP``: This option has no + effect; the provoking vertex is always the last vertex. +* ``PIPE_PRIMITIVE_TRIANGLE_FAN``: When set, the provoking vertex is the + second vertex, not the first. This permits each segment of the fan to have + a different color. + +Other Members +^^^^^^^^^^^^^ light_twoside If set, there are per-vertex back-facing colors. The draw module @@ -33,6 +70,7 @@ light_twoside front_winding Indicates the window order of front-facing polygons, either PIPE_WINDING_CW or PIPE_WINDING_CCW + cull_mode Indicates which polygons to cull, either PIPE_WINDING_NONE (cull no polygons), PIPE_WINDING_CW (cull clockwise-winding polygons), @@ -110,43 +148,7 @@ scissor multisample Whether :term:`MSAA` is enabled. -bypass_vs_clip_and_viewport - Whether the entire TCL pipeline should be bypassed. This implies that - vertices are pre-transformed for the viewport, and will not be run - through the vertex shader. Note that implementations may still clip away - vertices that are not in the viewport. - gl_rasterization_rules Whether the rasterizer should use (0.5, 0.5) pixel centers. When not set, the rasterizer will use (0, 0) for pixel centers. - -Notes ------ - -flatshade -^^^^^^^^^ - -The actual interpolated shading algorithm is obviously -implementation-dependent, but will usually be Gourard for most hardware. - -bypass_vs_clip_and_viewport -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -When set, this implies that vertices are pre-transformed for the viewport, and -will not be run through the vertex shader. Note that implementations may still -clip away vertices that are not visible. - -flatshade_first -^^^^^^^^^^^^^^^ - -There are several important exceptions to the specification of this rule. - -* ``PIPE_PRIMITIVE_POLYGON``: The provoking vertex is always the first - vertex. If the caller wishes to change the provoking vertex, they merely - need to rotate the vertices themselves. -* ``PIPE_PRIMITIVE_QUAD``, ``PIPE_PRIMITIVE_QUAD_STRIP``: This option has no - effect; the provoking vertex is always the last vertex. -* ``PIPE_PRIMITIVE_TRIANGLE_FAN``: When set, the provoking vertex is the - second vertex, not the first. This permits each segment of the fan to have - a different color. diff --git a/src/gallium/docs/source/distro.rst b/src/gallium/docs/source/distro.rst index 596e4c0048..0ef9fe2645 100644 --- a/src/gallium/docs/source/distro.rst +++ b/src/gallium/docs/source/distro.rst @@ -109,6 +109,8 @@ CSO Cache The CSO cache is used to accelerate preparation of state by saving driver-specific state structures for later use. +.. _draw: + Draw ^^^^ -- cgit v1.2.3 From 28fd246634cc05f617753cb86cadbbb9520a4266 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 18 Jan 2010 17:17:09 -0800 Subject: docs: Grammar and refs in Rasterizer. --- src/gallium/docs/source/cso/rasterizer.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gallium/docs/source/cso/rasterizer.rst b/src/gallium/docs/source/cso/rasterizer.rst index b801caae53..bfa4a1170a 100644 --- a/src/gallium/docs/source/cso/rasterizer.rst +++ b/src/gallium/docs/source/cso/rasterizer.rst @@ -7,7 +7,6 @@ The rasterizer state controls the rendering of points, lines and triangles. Attributes include polygon culling state, line width, line stipple, multisample state, scissoring and flat/smooth shading. - Members ------- @@ -63,7 +62,7 @@ Other Members ^^^^^^^^^^^^^ light_twoside - If set, there are per-vertex back-facing colors. The draw module + If set, there are per-vertex back-facing colors. :ref:`Draw` uses this state along with the front/back information to set the final vertex colors prior to rasterization. @@ -106,7 +105,7 @@ line_stipple_enable line_stipple_pattern 16-bit bitfield of on/off flags, used to pattern the line stipple. line_stipple_factor - When drawinga stippled line, each bit in the stipple pattern is + When drawing a stippled line, each bit in the stipple pattern is repeated N times, where N = line_stipple_factor + 1. line_last_pixel Controls whether the last pixel in a line is drawn or not. OpenGL @@ -134,7 +133,7 @@ sprite_coord_mode lower left vertex will have coordinate (0,0,0,1). For PIPE_SPRITE_COORD_UPPER_LEFT, the upper-left vertex will have coordinate (0,0,0,1). - This state is needed by the 'draw' module because that's where each + This state is needed by :ref:`Draw` because that's where each point vertex is converted into four quad vertices. There's no other place to emit the new vertex texture coordinates which are required for sprite rendering. -- cgit v1.2.3 From 047719182f2df147449535d7573b2f9653306a2e Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 18 Jan 2010 17:31:56 -0800 Subject: docs: Spacing in TGSI formulae. Some of those still look atrocious. :T --- src/gallium/docs/source/tgsi.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/gallium/docs/source/tgsi.rst b/src/gallium/docs/source/tgsi.rst index ebee4902b0..d9a043fde8 100644 --- a/src/gallium/docs/source/tgsi.rst +++ b/src/gallium/docs/source/tgsi.rst @@ -516,8 +516,11 @@ SEQ - Set On Equal .. math:: dst.x = (src0.x == src1.x) ? 1 : 0 + dst.y = (src0.y == src1.y) ? 1 : 0 + dst.z = (src0.z == src1.z) ? 1 : 0 + dst.w = (src0.w == src1.w) ? 1 : 0 @@ -526,8 +529,11 @@ SFL - Set On False .. math:: dst.x = 0 + dst.y = 0 + dst.z = 0 + dst.w = 0 Considered for removal. @@ -537,8 +543,11 @@ SGT - Set On Greater Than .. math:: dst.x = (src0.x > src1.x) ? 1 : 0 + dst.y = (src0.y > src1.y) ? 1 : 0 + dst.z = (src0.z > src1.z) ? 1 : 0 + dst.w = (src0.w > src1.w) ? 1 : 0 @@ -560,8 +569,11 @@ SLE - Set On Less Equal Than .. math:: dst.x = (src0.x <= src1.x) ? 1 : 0 + dst.y = (src0.y <= src1.y) ? 1 : 0 + dst.z = (src0.z <= src1.z) ? 1 : 0 + dst.w = (src0.w <= src1.w) ? 1 : 0 @@ -570,8 +582,11 @@ SNE - Set On Not Equal .. math:: dst.x = (src0.x != src1.x) ? 1 : 0 + dst.y = (src0.y != src1.y) ? 1 : 0 + dst.z = (src0.z != src1.z) ? 1 : 0 + dst.w = (src0.w != src1.w) ? 1 : 0 @@ -580,8 +595,11 @@ STR - Set On True .. math:: dst.x = 1 + dst.y = 1 + dst.z = 1 + dst.w = 1 @@ -629,8 +647,11 @@ X2D - 2D Coordinate Transformation .. math:: dst.x = src0.x + src1.x \times src2.x + src1.y \times src2.y + dst.y = src0.y + src1.x \times src2.z + src1.y \times src2.w + dst.z = src0.x + src1.x \times src2.x + src1.y \times src2.y + dst.w = src0.y + src1.x \times src2.z + src1.y \times src2.w Considered for removal. -- cgit v1.2.3 From 1ced546577745d361ad06577914f44f484656d37 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Mon, 18 Jan 2010 20:51:15 -0500 Subject: r200: add blit support Only enabled with KMS. --- src/mesa/drivers/dri/r200/Makefile | 2 + src/mesa/drivers/dri/r200/r200_blit.c | 373 +++++++++++++++++++++++++++++++ src/mesa/drivers/dri/r200/r200_blit.h | 54 +++++ src/mesa/drivers/dri/r200/r200_context.c | 5 + src/mesa/drivers/dri/r200/r200_context.h | 2 + src/mesa/drivers/dri/r200/r200_texcopy.c | 168 ++++++++++++++ 6 files changed, 604 insertions(+) create mode 100644 src/mesa/drivers/dri/r200/r200_blit.c create mode 100644 src/mesa/drivers/dri/r200/r200_blit.h create mode 100644 src/mesa/drivers/dri/r200/r200_texcopy.c diff --git a/src/mesa/drivers/dri/r200/Makefile b/src/mesa/drivers/dri/r200/Makefile index 8212dc1203..2155ece216 100644 --- a/src/mesa/drivers/dri/r200/Makefile +++ b/src/mesa/drivers/dri/r200/Makefile @@ -46,6 +46,8 @@ DRIVER_SOURCES = r200_context.c \ r200_sanity.c \ r200_fragshader.c \ r200_vertprog.c \ + r200_blit.c \ + r200_texcopy.c \ radeon_screen.c \ $(EGL_SOURCES) \ $(RADEON_COMMON_SOURCES) \ diff --git a/src/mesa/drivers/dri/r200/r200_blit.c b/src/mesa/drivers/dri/r200/r200_blit.c new file mode 100644 index 0000000000..b6bed85a6c --- /dev/null +++ b/src/mesa/drivers/dri/r200/r200_blit.c @@ -0,0 +1,373 @@ +/* + * Copyright (C) 2009 Maciej Cencora + * + * All Rights Reserved. + * + * 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 COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS 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. + * + */ + +#include "radeon_common.h" +#include "r200_context.h" +#include "r200_blit.h" + +static inline uint32_t cmdpacket0(struct radeon_screen *rscrn, + int reg, int count) +{ + if (count) + return CP_PACKET0(reg, count - 1); + return CP_PACKET2; +} + +static inline void emit_vtx_state(struct r200_context *r200) +{ + BATCH_LOCALS(&r200->radeon); + + BEGIN_BATCH(14); + if (r200->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL) { + OUT_BATCH_REGVAL(R200_SE_VAP_CNTL_STATUS, 0); + } else { + OUT_BATCH_REGVAL(R200_SE_VAP_CNTL_STATUS, RADEON_TCL_BYPASS); + } + OUT_BATCH_REGVAL(R200_SE_VAP_CNTL, (R200_VAP_FORCE_W_TO_ONE | + (9 << R200_VAP_VF_MAX_VTX_NUM__SHIFT))); + OUT_BATCH_REGVAL(R200_SE_VTX_STATE_CNTL, 0); + OUT_BATCH_REGVAL(R200_SE_VTE_CNTL, 0); + OUT_BATCH_REGVAL(R200_SE_VTX_FMT_0, R200_VTX_XY); + OUT_BATCH_REGVAL(R200_SE_VTX_FMT_1, (2 << R200_VTX_TEX0_COMP_CNT_SHIFT)); + OUT_BATCH_REGVAL(RADEON_SE_CNTL, (RADEON_DIFFUSE_SHADE_GOURAUD | + RADEON_BFACE_SOLID | + RADEON_FFACE_SOLID | + RADEON_VTX_PIX_CENTER_OGL | + RADEON_ROUND_MODE_ROUND | + RADEON_ROUND_PREC_4TH_PIX)); + END_BATCH(); +} + +static void inline emit_tx_setup(struct r200_context *r200, + gl_format mesa_format, + struct radeon_bo *bo, + intptr_t offset, + unsigned width, + unsigned height, + unsigned pitch) +{ + uint32_t txformat = R200_TXFORMAT_NON_POWER2; + BATCH_LOCALS(&r200->radeon); + + assert(width <= 2047); + assert(height <= 2047); + assert(offset % 32 == 0); + + /* XXX others? BE/LE? */ + switch (mesa_format) { + case MESA_FORMAT_ARGB8888: + txformat |= R200_TXFORMAT_ARGB8888 | R200_TXFORMAT_ALPHA_IN_MAP; + break; + case MESA_FORMAT_XRGB8888: + txformat |= R200_TXFORMAT_ARGB8888; + break; + case MESA_FORMAT_RGB565: + txformat |= R200_TXFORMAT_RGB565; + break; + case MESA_FORMAT_ARGB1555: + txformat |= R200_TXFORMAT_ARGB1555 | R200_TXFORMAT_ALPHA_IN_MAP; + break; + case MESA_FORMAT_A8: + txformat |= R200_TXFORMAT_I8 | R200_TXFORMAT_ALPHA_IN_MAP; + break; + default: + break; + } + + BEGIN_BATCH(28); + OUT_BATCH_REGVAL(RADEON_PP_CNTL, RADEON_TEX_0_ENABLE | RADEON_TEX_BLEND_0_ENABLE); + OUT_BATCH_REGVAL(R200_PP_CNTL_X, 0); + OUT_BATCH_REGVAL(R200_PP_TXMULTI_CTL_0, 0); + OUT_BATCH_REGVAL(R200_PP_TXCBLEND_0, (R200_TXC_ARG_A_ZERO | + R200_TXC_ARG_B_ZERO | + R200_TXC_ARG_C_R0_COLOR | + R200_TXC_OP_MADD)); + OUT_BATCH_REGVAL(R200_PP_TXCBLEND2_0, R200_TXC_CLAMP_0_1 | R200_TXC_OUTPUT_REG_R0); + OUT_BATCH_REGVAL(R200_PP_TXABLEND_0, (R200_TXA_ARG_A_ZERO | + R200_TXA_ARG_B_ZERO | + R200_TXA_ARG_C_R0_ALPHA | + R200_TXA_OP_MADD)); + OUT_BATCH_REGVAL(R200_PP_TXABLEND2_0, R200_TXA_CLAMP_0_1 | R200_TXA_OUTPUT_REG_R0); + OUT_BATCH_REGVAL(R200_PP_TXFILTER_0, (R200_CLAMP_S_CLAMP_LAST | + R200_CLAMP_T_CLAMP_LAST | + R200_MAG_FILTER_NEAREST | + R200_MIN_FILTER_NEAREST)); + OUT_BATCH_REGVAL(R200_PP_TXFORMAT_0, txformat); + OUT_BATCH_REGVAL(R200_PP_TXFORMAT_X_0, 0); + OUT_BATCH_REGVAL(R200_PP_TXSIZE_0, ((width - 1) | + ((height - 1) << RADEON_TEX_VSIZE_SHIFT))); + OUT_BATCH_REGVAL(R200_PP_TXPITCH_0, pitch - 32); + + OUT_BATCH_REGSEQ(R200_PP_TXOFFSET_0, 1); + OUT_BATCH_RELOC(0, bo, 0, RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0); + + END_BATCH(); +} + +static inline void emit_cb_setup(struct r200_context *r200, + struct radeon_bo *bo, + intptr_t offset, + gl_format mesa_format, + unsigned pitch, + unsigned width, + unsigned height) +{ + uint32_t dst_pitch = pitch; + uint32_t dst_format = 0; + BATCH_LOCALS(&r200->radeon); + + /* XXX others? BE/LE? */ + switch (mesa_format) { + case MESA_FORMAT_ARGB8888: + case MESA_FORMAT_XRGB8888: + dst_format = RADEON_COLOR_FORMAT_ARGB8888; + break; + case MESA_FORMAT_RGB565: + dst_format = RADEON_COLOR_FORMAT_RGB565; + break; + case MESA_FORMAT_ARGB1555: + dst_format = RADEON_COLOR_FORMAT_ARGB1555; + break; + case MESA_FORMAT_A8: + dst_format = RADEON_COLOR_FORMAT_RGB8; + break; + default: + break; + } + + BEGIN_BATCH_NO_AUTOSTATE(22); + OUT_BATCH_REGVAL(R200_RE_AUX_SCISSOR_CNTL, 0); + OUT_BATCH_REGVAL(R200_RE_CNTL, 0); + OUT_BATCH_REGVAL(RADEON_RE_TOP_LEFT, 0); + OUT_BATCH_REGVAL(RADEON_RE_WIDTH_HEIGHT, ((width << RADEON_RE_WIDTH_SHIFT) | + (height << RADEON_RE_HEIGHT_SHIFT))); + OUT_BATCH_REGVAL(RADEON_RB3D_PLANEMASK, 0xffffffff); + OUT_BATCH_REGVAL(RADEON_RB3D_BLENDCNTL, RADEON_SRC_BLEND_GL_ONE | RADEON_DST_BLEND_GL_ZERO); + OUT_BATCH_REGVAL(RADEON_RB3D_CNTL, dst_format); + + OUT_BATCH_REGSEQ(RADEON_RB3D_COLOROFFSET, 1); + OUT_BATCH_RELOC(0, bo, 0, 0, RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0); + OUT_BATCH_REGSEQ(RADEON_RB3D_COLORPITCH, 1); + OUT_BATCH_RELOC(dst_pitch, bo, dst_pitch, 0, RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0); + + END_BATCH(); +} + +static GLboolean validate_buffers(struct r200_context *r200, + struct radeon_bo *src_bo, + struct radeon_bo *dst_bo) +{ + int ret; + radeon_cs_space_add_persistent_bo(r200->radeon.cmdbuf.cs, + src_bo, RADEON_GEM_DOMAIN_VRAM, 0); + + radeon_cs_space_add_persistent_bo(r200->radeon.cmdbuf.cs, + dst_bo, 0, RADEON_GEM_DOMAIN_VRAM); + + ret = radeon_cs_space_check_with_bo(r200->radeon.cmdbuf.cs, + first_elem(&r200->radeon.dma.reserved)->bo, + RADEON_GEM_DOMAIN_GTT, 0); + if (ret) + return GL_FALSE; + + return GL_TRUE; +} + +/** + * Calculate texcoords for given image region. + * Output values are [minx, maxx, miny, maxy] + */ +static inline void calc_tex_coords(float img_width, float img_height, + float x, float y, + float reg_width, float reg_height, + unsigned flip_y, float *buf) +{ + buf[0] = x / img_width; + buf[1] = buf[0] + reg_width / img_width; + buf[2] = y / img_height; + buf[3] = buf[2] + reg_height / img_height; + if (flip_y) + { + float tmp = buf[2]; + buf[2] = 1.0 - buf[3]; + buf[3] = 1.0 - tmp; + } +} + +static inline void emit_draw_packet(struct r200_context *r200, + unsigned src_width, unsigned src_height, + unsigned src_x_offset, unsigned src_y_offset, + unsigned dst_x_offset, unsigned dst_y_offset, + unsigned reg_width, unsigned reg_height, + unsigned flip_y) +{ + float texcoords[4]; + float verts[12]; + BATCH_LOCALS(&r200->radeon); + + calc_tex_coords(src_width, src_height, + src_x_offset, src_y_offset, + reg_width, reg_height, + flip_y, texcoords); + + verts[0] = dst_x_offset; + verts[1] = dst_y_offset + reg_height; + verts[2] = texcoords[0]; + verts[3] = texcoords[2]; + + verts[4] = dst_x_offset + reg_width; + verts[5] = dst_y_offset + reg_height; + verts[6] = texcoords[1]; + verts[7] = texcoords[2]; + + verts[8] = dst_x_offset + reg_width; + verts[9] = dst_y_offset; + verts[10] = texcoords[1]; + verts[11] = texcoords[3]; + + BEGIN_BATCH(14); + OUT_BATCH(R200_CP_CMD_3D_DRAW_IMMD_2 | (12 << 16)); + OUT_BATCH(RADEON_CP_VC_CNTL_PRIM_WALK_RING | + RADEON_CP_VC_CNTL_PRIM_TYPE_RECT_LIST | + (3 << 16)); + OUT_BATCH_TABLE(verts, 12); + END_BATCH(); +} + +/** + * Copy a region of [@a width x @a height] pixels from source buffer + * to destination buffer. + * @param[in] r200 r200 context + * @param[in] src_bo source radeon buffer object + * @param[in] src_offset offset of the source image in the @a src_bo + * @param[in] src_mesaformat source image format + * @param[in] src_pitch aligned source image width + * @param[in] src_width source image width + * @param[in] src_height source image height + * @param[in] src_x_offset x offset in the source image + * @param[in] src_y_offset y offset in the source image + * @param[in] dst_bo destination radeon buffer object + * @param[in] dst_offset offset of the destination image in the @a dst_bo + * @param[in] dst_mesaformat destination image format + * @param[in] dst_pitch aligned destination image width + * @param[in] dst_width destination image width + * @param[in] dst_height destination image height + * @param[in] dst_x_offset x offset in the destination image + * @param[in] dst_y_offset y offset in the destination image + * @param[in] width region width + * @param[in] height region height + * @param[in] flip_y set if y coords of the source image need to be flipped + */ +GLboolean r200_blit(struct r200_context *r200, + struct radeon_bo *src_bo, + intptr_t src_offset, + gl_format src_mesaformat, + unsigned src_pitch, + unsigned src_width, + unsigned src_height, + unsigned src_x_offset, + unsigned src_y_offset, + struct radeon_bo *dst_bo, + intptr_t dst_offset, + gl_format dst_mesaformat, + unsigned dst_pitch, + unsigned dst_width, + unsigned dst_height, + unsigned dst_x_offset, + unsigned dst_y_offset, + unsigned reg_width, + unsigned reg_height, + unsigned flip_y) +{ + if (_mesa_get_format_bits(src_mesaformat, GL_DEPTH_BITS) > 0) + return GL_FALSE; + + /* Make sure that colorbuffer has even width - hw limitation */ + if (dst_pitch % 2 > 0) + ++dst_pitch; + + /* Rendering to small buffer doesn't work. + * Looks like a hw limitation. + */ + if (dst_pitch < 32) + return GL_FALSE; + + /* Need to clamp the region size to make sure + * we don't read outside of the source buffer + * or write outside of the destination buffer. + */ + if (reg_width + src_x_offset > src_width) + reg_width = src_width - src_x_offset; + if (reg_height + src_y_offset > src_height) + reg_height = src_height - src_y_offset; + if (reg_width + dst_x_offset > dst_width) + reg_width = dst_width - dst_x_offset; + if (reg_height + dst_y_offset > dst_height) + reg_height = dst_height - dst_y_offset; + + if (src_bo == dst_bo) { + return GL_FALSE; + } + + if (0) { + fprintf(stderr, "src: size [%d x %d], pitch %d, " + "offset [%d x %d], format %s, bo %p\n", + src_width, src_height, src_pitch, + src_x_offset, src_y_offset, + _mesa_get_format_name(src_mesaformat), + src_bo); + fprintf(stderr, "dst: pitch %d, offset[%d x %d], format %s, bo %p\n", + dst_pitch, dst_x_offset, dst_y_offset, + _mesa_get_format_name(dst_mesaformat), dst_bo); + fprintf(stderr, "region: %d x %d\n", reg_width, reg_height); + } + + /* Flush is needed to make sure that source buffer has correct data */ + radeonFlush(r200->radeon.glCtx); + + rcommonEnsureCmdBufSpace(&r200->radeon, 78, __FUNCTION__); + + if (!validate_buffers(r200, src_bo, dst_bo)) + return GL_FALSE; + + /* 14 */ + emit_vtx_state(r200); + /* 28 */ + emit_tx_setup(r200, src_mesaformat, src_bo, src_offset, src_width, src_height, src_pitch); + /* 22 */ + emit_cb_setup(r200, dst_bo, dst_offset, dst_mesaformat, dst_pitch, dst_width, dst_height); + /* 14 */ + emit_draw_packet(r200, src_width, src_height, + src_x_offset, src_y_offset, + dst_x_offset, dst_y_offset, + reg_width, reg_height, + flip_y); + + radeonFlush(r200->radeon.glCtx); + + return GL_TRUE; +} diff --git a/src/mesa/drivers/dri/r200/r200_blit.h b/src/mesa/drivers/dri/r200/r200_blit.h new file mode 100644 index 0000000000..2d0e893623 --- /dev/null +++ b/src/mesa/drivers/dri/r200/r200_blit.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2009 Maciej Cencora + * + * All Rights Reserved. + * + * 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 COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS 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. + * + */ + +#ifndef R200_BLIT_H +#define R200_BLIT_H + +void r200_blit_init(struct r200_context *r200); + +GLboolean r200_blit(struct r200_context *r200, + struct radeon_bo *src_bo, + intptr_t src_offset, + gl_format src_mesaformat, + unsigned src_pitch, + unsigned src_width, + unsigned src_height, + unsigned src_x_offset, + unsigned src_y_offset, + struct radeon_bo *dst_bo, + intptr_t dst_offset, + gl_format dst_mesaformat, + unsigned dst_pitch, + unsigned dst_width, + unsigned dst_height, + unsigned dst_x_offset, + unsigned dst_y_offset, + unsigned width, + unsigned height, + unsigned flip_y); + +#endif // R200_BLIT_H diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c index f34e319222..217004c265 100644 --- a/src/mesa/drivers/dri/r200/r200_context.c +++ b/src/mesa/drivers/dri/r200/r200_context.c @@ -294,6 +294,7 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, if ( !rmesa ) return GL_FALSE; + rmesa->radeon.radeonScreen = screen; r200_init_vtbl(&rmesa->radeon); /* init exp fog table data */ r200InitStaticFogData(); @@ -330,6 +331,10 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, r200InitShaderFuncs(&functions); radeonInitQueryObjFunctions(&functions); + if (rmesa->radeon.radeonScreen->kernel_mm) { + r200_init_texcopy_functions(&functions); + } + if (!radeonInitContext(&rmesa->radeon, &functions, glVisual, driContextPriv, sharedContextPrivate)) { diff --git a/src/mesa/drivers/dri/r200/r200_context.h b/src/mesa/drivers/dri/r200/r200_context.h index 17e4d8962e..a9dce310ae 100644 --- a/src/mesa/drivers/dri/r200/r200_context.h +++ b/src/mesa/drivers/dri/r200/r200_context.h @@ -645,6 +645,8 @@ extern GLboolean r200MakeCurrent( __DRIcontext *driContextPriv, __DRIdrawable *driReadPriv ); extern GLboolean r200UnbindContext( __DRIcontext *driContextPriv ); +extern void r200_init_texcopy_functions(struct dd_function_table *table); + /* ================================================================ * Debugging: */ diff --git a/src/mesa/drivers/dri/r200/r200_texcopy.c b/src/mesa/drivers/dri/r200/r200_texcopy.c new file mode 100644 index 0000000000..cdb6cd7bdf --- /dev/null +++ b/src/mesa/drivers/dri/r200/r200_texcopy.c @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2009 Maciej Cencora + * + * All Rights Reserved. + * + * 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 COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS 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. + * + */ + +#include "radeon_common.h" +#include "r200_context.h" + +#include "main/image.h" +#include "main/teximage.h" +#include "main/texstate.h" +#include "drivers/common/meta.h" + +#include "radeon_mipmap_tree.h" +#include "r200_blit.h" +#include
+ +// TODO: +// need to pass correct pitch for small dst textures! +static GLboolean +do_copy_texsubimage(GLcontext *ctx, + GLenum target, GLint level, + struct radeon_tex_obj *tobj, + radeon_texture_image *timg, + GLint dstx, GLint dsty, + GLint x, GLint y, + GLsizei width, GLsizei height) +{ + struct r200_context *r200 = R200_CONTEXT(ctx); + struct radeon_renderbuffer *rrb; + + if (_mesa_get_format_bits(timg->base.TexFormat, GL_DEPTH_BITS) > 0) { + rrb = radeon_get_depthbuffer(&r200->radeon); + } else { + rrb = radeon_get_colorbuffer(&r200->radeon); + } + + if (!timg->mt) { + radeon_validate_texture_miptree(ctx, &tobj->base); + } + + assert(rrb && rrb->bo); + assert(timg->mt->bo); + assert(timg->base.Width >= dstx + width); + assert(timg->base.Height >= dsty + height); + + intptr_t src_offset = rrb->draw_offset; + intptr_t dst_offset = radeon_miptree_image_offset(timg->mt, _mesa_tex_target_to_face(target), level); + + if (src_offset % 32 || dst_offset % 32) { + return GL_FALSE; + } + + if (0) { + fprintf(stderr, "%s: copying to face %d, level %d\n", + __FUNCTION__, _mesa_tex_target_to_face(target), level); + fprintf(stderr, "to: x %d, y %d, offset %d\n", dstx, dsty, (uint32_t) dst_offset); + fprintf(stderr, "from (%dx%d) width %d, height %d, offset %d, pitch %d\n", + x, y, rrb->base.Width, rrb->base.Height, (uint32_t) src_offset, rrb->pitch/rrb->cpp); + fprintf(stderr, "src size %d, dst size %d\n", rrb->bo->size, timg->mt->bo->size); + + } + + /* blit from src buffer to texture */ + return r200_blit(r200, rrb->bo, src_offset, rrb->base.Format, rrb->pitch, + rrb->base.Width, rrb->base.Height, x, y, + timg->mt->bo, dst_offset, timg->base.TexFormat, + timg->base.Width, timg->base.Width, timg->base.Height, + dstx, dsty, width, height, 1); +} + +static void +r200CopyTexImage2D(GLcontext *ctx, GLenum target, GLint level, + GLenum internalFormat, + GLint x, GLint y, GLsizei width, GLsizei height, + GLint border) +{ + struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); + struct gl_texture_object *texObj = + _mesa_select_tex_object(ctx, texUnit, target); + struct gl_texture_image *texImage = + _mesa_select_tex_image(ctx, texObj, target, level); + int srcx, srcy, dstx, dsty; + + if (border) + goto fail; + + /* Setup or redefine the texture object, mipmap tree and texture + * image. Don't populate yet. + */ + ctx->Driver.TexImage2D(ctx, target, level, internalFormat, + width, height, border, + GL_RGBA, GL_UNSIGNED_BYTE, NULL, + &ctx->DefaultPacking, texObj, texImage); + + srcx = x; + srcy = y; + dstx = 0; + dsty = 0; + if (!_mesa_clip_copytexsubimage(ctx, + &dstx, &dsty, + &srcx, &srcy, + &width, &height)) { + return; + } + + if (!do_copy_texsubimage(ctx, target, level, + radeon_tex_obj(texObj), (radeon_texture_image *)texImage, + 0, 0, x, y, width, height)) { + goto fail; + } + + return; + +fail: + _mesa_meta_CopyTexImage2D(ctx, target, level, internalFormat, x, y, + width, height, border); +} + +static void +r200CopyTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLsizei height) +{ + struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); + struct gl_texture_object *texObj = _mesa_select_tex_object(ctx, texUnit, target); + struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texObj, target, level); + + if (!do_copy_texsubimage(ctx, target, level, + radeon_tex_obj(texObj), (radeon_texture_image *)texImage, + xoffset, yoffset, x, y, width, height)) { + + //DEBUG_FALLBACKS + + _mesa_meta_CopyTexSubImage2D(ctx, target, level, + xoffset, yoffset, x, y, width, height); + } +} + + +void r200_init_texcopy_functions(struct dd_function_table *table) +{ + table->CopyTexImage2D = r200CopyTexImage2D; + table->CopyTexSubImage2D = r200CopyTexSubImage2D; +} -- cgit v1.2.3 From daccc962a15f333a4759849d7088b0c985189175 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Mon, 18 Jan 2010 20:56:11 -0500 Subject: r100: add blit support Only enabled with KMS. --- src/mesa/drivers/dri/radeon/Makefile | 2 + src/mesa/drivers/dri/radeon/radeon_blit.c | 369 ++++++++++++++++++++++++ src/mesa/drivers/dri/radeon/radeon_blit.h | 54 ++++ src/mesa/drivers/dri/radeon/radeon_context.c | 5 + src/mesa/drivers/dri/radeon/radeon_context.h | 2 +- src/mesa/drivers/dri/radeon/radeon_texcopy.c | 168 +++++++++++ src/mesa/drivers/dri/radeon/server/radeon_reg.h | 25 +- 7 files changed, 623 insertions(+), 2 deletions(-) create mode 100644 src/mesa/drivers/dri/radeon/radeon_blit.c create mode 100644 src/mesa/drivers/dri/radeon/radeon_blit.h create mode 100644 src/mesa/drivers/dri/radeon/radeon_texcopy.c diff --git a/src/mesa/drivers/dri/radeon/Makefile b/src/mesa/drivers/dri/radeon/Makefile index 2b2f2c4aa7..70b946b2fd 100644 --- a/src/mesa/drivers/dri/radeon/Makefile +++ b/src/mesa/drivers/dri/radeon/Makefile @@ -40,6 +40,8 @@ DRIVER_SOURCES = \ radeon_swtcl.c \ radeon_maos.c \ radeon_sanity.c \ + radeon_blit.c \ + radeon_texcopy.c \ $(RADEON_COMMON_SOURCES) C_SOURCES = \ diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.c b/src/mesa/drivers/dri/radeon/radeon_blit.c new file mode 100644 index 0000000000..4abe7a2960 --- /dev/null +++ b/src/mesa/drivers/dri/radeon/radeon_blit.c @@ -0,0 +1,369 @@ +/* + * Copyright (C) 2010 Advanced Micro Devices, Inc. + * + * All Rights Reserved. + * + * 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 COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS 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. + * + */ + +#include "radeon_common.h" +#include "radeon_context.h" +#include "radeon_blit.h" + +static inline uint32_t cmdpacket0(struct radeon_screen *rscrn, + int reg, int count) +{ + if (count) + return CP_PACKET0(reg, count - 1); + return CP_PACKET2; +} + +static inline void emit_vtx_state(struct r100_context *r100) +{ + BATCH_LOCALS(&r100->radeon); + + BEGIN_BATCH(8); + if (r100->radeon.radeonScreen->chip_flags & RADEON_CHIPSET_TCL) { + OUT_BATCH_REGVAL(RADEON_SE_CNTL_STATUS, 0); + } else { + OUT_BATCH_REGVAL(RADEON_SE_CNTL_STATUS, RADEON_TCL_BYPASS); + + } + OUT_BATCH_REGVAL(RADEON_SE_COORD_FMT, (RADEON_VTX_XY_PRE_MULT_1_OVER_W0 | + RADEON_TEX1_W_ROUTING_USE_W0)); + OUT_BATCH_REGVAL(RADEON_SE_VTX_FMT, RADEON_SE_VTX_FMT_XY | RADEON_SE_VTX_FMT_ST0); + OUT_BATCH_REGVAL(RADEON_SE_CNTL, (RADEON_DIFFUSE_SHADE_GOURAUD | + RADEON_BFACE_SOLID | + RADEON_FFACE_SOLID | + RADEON_VTX_PIX_CENTER_OGL | + RADEON_ROUND_MODE_ROUND | + RADEON_ROUND_PREC_4TH_PIX)); + END_BATCH(); +} + +static void inline emit_tx_setup(struct r100_context *r100, + gl_format mesa_format, + struct radeon_bo *bo, + intptr_t offset, + unsigned width, + unsigned height, + unsigned pitch) +{ + uint32_t txformat = RADEON_TXFORMAT_NON_POWER2; + BATCH_LOCALS(&r100->radeon); + + assert(width <= 2047); + assert(height <= 2047); + assert(offset % 32 == 0); + + /* XXX others? BE/LE? */ + switch (mesa_format) { + case MESA_FORMAT_ARGB8888: + txformat |= RADEON_TXFORMAT_ARGB8888 | RADEON_TXFORMAT_ALPHA_IN_MAP; + break; + case MESA_FORMAT_XRGB8888: + txformat |= RADEON_TXFORMAT_ARGB8888; + break; + case MESA_FORMAT_RGB565: + txformat |= RADEON_TXFORMAT_RGB565; + break; + case MESA_FORMAT_ARGB1555: + txformat |= RADEON_TXFORMAT_ARGB1555 | RADEON_TXFORMAT_ALPHA_IN_MAP; + break; + case MESA_FORMAT_A8: + txformat |= RADEON_TXFORMAT_I8 | RADEON_TXFORMAT_ALPHA_IN_MAP; + break; + default: + break; + } + + BEGIN_BATCH(18); + OUT_BATCH_REGVAL(RADEON_PP_CNTL, RADEON_TEX_0_ENABLE | RADEON_TEX_BLEND_0_ENABLE); + OUT_BATCH_REGVAL(RADEON_PP_TXCBLEND_0, (RADEON_COLOR_ARG_A_ZERO | + RADEON_COLOR_ARG_B_ZERO | + RADEON_COLOR_ARG_C_T0_COLOR | + RADEON_BLEND_CTL_ADD | + RADEON_CLAMP_TX)); + OUT_BATCH_REGVAL(RADEON_PP_TXABLEND_0, (RADEON_ALPHA_ARG_A_ZERO | + RADEON_ALPHA_ARG_B_ZERO | + RADEON_ALPHA_ARG_C_T0_ALPHA | + RADEON_BLEND_CTL_ADD | + RADEON_CLAMP_TX)); + OUT_BATCH_REGVAL(RADEON_PP_TXFILTER_0, (RADEON_CLAMP_S_CLAMP_LAST | + RADEON_CLAMP_T_CLAMP_LAST | + RADEON_MAG_FILTER_NEAREST | + RADEON_MIN_FILTER_NEAREST)); + OUT_BATCH_REGVAL(RADEON_PP_TXFORMAT_0, txformat); + OUT_BATCH_REGVAL(RADEON_PP_TEX_SIZE_0, ((width - 1) | + ((height - 1) << RADEON_TEX_VSIZE_SHIFT))); + OUT_BATCH_REGVAL(RADEON_PP_TEX_PITCH_0, pitch - 32); + + OUT_BATCH_REGSEQ(RADEON_PP_TXOFFSET_0, 1); + OUT_BATCH_RELOC(0, bo, 0, RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0); + + END_BATCH(); +} + +static inline void emit_cb_setup(struct r100_context *r100, + struct radeon_bo *bo, + intptr_t offset, + gl_format mesa_format, + unsigned pitch, + unsigned width, + unsigned height) +{ + uint32_t dst_pitch = pitch; + uint32_t dst_format = 0; + BATCH_LOCALS(&r100->radeon); + + /* XXX others? BE/LE? */ + switch (mesa_format) { + case MESA_FORMAT_ARGB8888: + case MESA_FORMAT_XRGB8888: + dst_format = RADEON_COLOR_FORMAT_ARGB8888; + break; + case MESA_FORMAT_RGB565: + dst_format = RADEON_COLOR_FORMAT_RGB565; + break; + case MESA_FORMAT_ARGB1555: + dst_format = RADEON_COLOR_FORMAT_ARGB1555; + break; + case MESA_FORMAT_A8: + dst_format = RADEON_COLOR_FORMAT_RGB8; + break; + default: + break; + } + + BEGIN_BATCH_NO_AUTOSTATE(18); + OUT_BATCH_REGVAL(RADEON_RE_TOP_LEFT, 0); + OUT_BATCH_REGVAL(RADEON_RE_WIDTH_HEIGHT, ((width << RADEON_RE_WIDTH_SHIFT) | + (height << RADEON_RE_HEIGHT_SHIFT))); + OUT_BATCH_REGVAL(RADEON_RB3D_PLANEMASK, 0xffffffff); + OUT_BATCH_REGVAL(RADEON_RB3D_BLENDCNTL, RADEON_SRC_BLEND_GL_ONE | RADEON_DST_BLEND_GL_ZERO); + OUT_BATCH_REGVAL(RADEON_RB3D_CNTL, dst_format); + + OUT_BATCH_REGSEQ(RADEON_RB3D_COLOROFFSET, 1); + OUT_BATCH_RELOC(0, bo, 0, 0, RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0); + OUT_BATCH_REGSEQ(RADEON_RB3D_COLORPITCH, 1); + OUT_BATCH_RELOC(dst_pitch, bo, dst_pitch, 0, RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0); + + END_BATCH(); +} + +static GLboolean validate_buffers(struct r100_context *r100, + struct radeon_bo *src_bo, + struct radeon_bo *dst_bo) +{ + int ret; + radeon_cs_space_add_persistent_bo(r100->radeon.cmdbuf.cs, + src_bo, RADEON_GEM_DOMAIN_VRAM, 0); + + radeon_cs_space_add_persistent_bo(r100->radeon.cmdbuf.cs, + dst_bo, 0, RADEON_GEM_DOMAIN_VRAM); + + ret = radeon_cs_space_check_with_bo(r100->radeon.cmdbuf.cs, + first_elem(&r100->radeon.dma.reserved)->bo, + RADEON_GEM_DOMAIN_GTT, 0); + if (ret) + return GL_FALSE; + + return GL_TRUE; +} + +/** + * Calculate texcoords for given image region. + * Output values are [minx, maxx, miny, maxy] + */ +static inline void calc_tex_coords(float img_width, float img_height, + float x, float y, + float reg_width, float reg_height, + unsigned flip_y, float *buf) +{ + buf[0] = x / img_width; + buf[1] = buf[0] + reg_width / img_width; + buf[2] = y / img_height; + buf[3] = buf[2] + reg_height / img_height; + if (flip_y) + { + float tmp = buf[2]; + buf[2] = 1.0 - buf[3]; + buf[3] = 1.0 - tmp; + } +} + +static inline void emit_draw_packet(struct r100_context *r100, + unsigned src_width, unsigned src_height, + unsigned src_x_offset, unsigned src_y_offset, + unsigned dst_x_offset, unsigned dst_y_offset, + unsigned reg_width, unsigned reg_height, + unsigned flip_y) +{ + float texcoords[4]; + float verts[12]; + BATCH_LOCALS(&r100->radeon); + + calc_tex_coords(src_width, src_height, + src_x_offset, src_y_offset, + reg_width, reg_height, + flip_y, texcoords); + + verts[0] = dst_x_offset; + verts[1] = dst_y_offset + reg_height; + verts[2] = texcoords[0]; + verts[3] = texcoords[2]; + + verts[4] = dst_x_offset + reg_width; + verts[5] = dst_y_offset + reg_height; + verts[6] = texcoords[1]; + verts[7] = texcoords[2]; + + verts[8] = dst_x_offset + reg_width; + verts[9] = dst_y_offset; + verts[10] = texcoords[1]; + verts[11] = texcoords[3]; + + BEGIN_BATCH(15); + OUT_BATCH(RADEON_CP_PACKET3_3D_DRAW_IMMD | (13 << 16)); + OUT_BATCH(RADEON_CP_VC_FRMT_XY | RADEON_CP_VC_FRMT_ST0); + OUT_BATCH(RADEON_CP_VC_CNTL_PRIM_WALK_RING | + RADEON_CP_VC_CNTL_PRIM_TYPE_RECT_LIST | + RADEON_CP_VC_CNTL_MAOS_ENABLE | + RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE | + (3 << 16)); + OUT_BATCH_TABLE(verts, 12); + END_BATCH(); +} + +/** + * Copy a region of [@a width x @a height] pixels from source buffer + * to destination buffer. + * @param[in] r100 r100 context + * @param[in] src_bo source radeon buffer object + * @param[in] src_offset offset of the source image in the @a src_bo + * @param[in] src_mesaformat source image format + * @param[in] src_pitch aligned source image width + * @param[in] src_width source image width + * @param[in] src_height source image height + * @param[in] src_x_offset x offset in the source image + * @param[in] src_y_offset y offset in the source image + * @param[in] dst_bo destination radeon buffer object + * @param[in] dst_offset offset of the destination image in the @a dst_bo + * @param[in] dst_mesaformat destination image format + * @param[in] dst_pitch aligned destination image width + * @param[in] dst_width destination image width + * @param[in] dst_height destination image height + * @param[in] dst_x_offset x offset in the destination image + * @param[in] dst_y_offset y offset in the destination image + * @param[in] width region width + * @param[in] height region height + * @param[in] flip_y set if y coords of the source image need to be flipped + */ +GLboolean r100_blit(struct r100_context *r100, + struct radeon_bo *src_bo, + intptr_t src_offset, + gl_format src_mesaformat, + unsigned src_pitch, + unsigned src_width, + unsigned src_height, + unsigned src_x_offset, + unsigned src_y_offset, + struct radeon_bo *dst_bo, + intptr_t dst_offset, + gl_format dst_mesaformat, + unsigned dst_pitch, + unsigned dst_width, + unsigned dst_height, + unsigned dst_x_offset, + unsigned dst_y_offset, + unsigned reg_width, + unsigned reg_height, + unsigned flip_y) +{ + if (_mesa_get_format_bits(src_mesaformat, GL_DEPTH_BITS) > 0) + return GL_FALSE; + + /* Make sure that colorbuffer has even width - hw limitation */ + if (dst_pitch % 2 > 0) + ++dst_pitch; + + /* Rendering to small buffer doesn't work. + * Looks like a hw limitation. + */ + if (dst_pitch < 32) + return GL_FALSE; + + /* Need to clamp the region size to make sure + * we don't read outside of the source buffer + * or write outside of the destination buffer. + */ + if (reg_width + src_x_offset > src_width) + reg_width = src_width - src_x_offset; + if (reg_height + src_y_offset > src_height) + reg_height = src_height - src_y_offset; + if (reg_width + dst_x_offset > dst_width) + reg_width = dst_width - dst_x_offset; + if (reg_height + dst_y_offset > dst_height) + reg_height = dst_height - dst_y_offset; + + if (src_bo == dst_bo) { + return GL_FALSE; + } + + if (0) { + fprintf(stderr, "src: size [%d x %d], pitch %d, " + "offset [%d x %d], format %s, bo %p\n", + src_width, src_height, src_pitch, + src_x_offset, src_y_offset, + _mesa_get_format_name(src_mesaformat), + src_bo); + fprintf(stderr, "dst: pitch %d, offset[%d x %d], format %s, bo %p\n", + dst_pitch, dst_x_offset, dst_y_offset, + _mesa_get_format_name(dst_mesaformat), dst_bo); + fprintf(stderr, "region: %d x %d\n", reg_width, reg_height); + } + + /* Flush is needed to make sure that source buffer has correct data */ + radeonFlush(r100->radeon.glCtx); + + rcommonEnsureCmdBufSpace(&r100->radeon, 59, __FUNCTION__); + + if (!validate_buffers(r100, src_bo, dst_bo)) + return GL_FALSE; + + /* 8 */ + emit_vtx_state(r100); + /* 18 */ + emit_tx_setup(r100, src_mesaformat, src_bo, src_offset, src_width, src_height, src_pitch); + /* 18 */ + emit_cb_setup(r100, dst_bo, dst_offset, dst_mesaformat, dst_pitch, dst_width, dst_height); + /* 15 */ + emit_draw_packet(r100, src_width, src_height, + src_x_offset, src_y_offset, + dst_x_offset, dst_y_offset, + reg_width, reg_height, + flip_y); + + radeonFlush(r100->radeon.glCtx); + + return GL_TRUE; +} diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.h b/src/mesa/drivers/dri/radeon/radeon_blit.h new file mode 100644 index 0000000000..c0203d0a54 --- /dev/null +++ b/src/mesa/drivers/dri/radeon/radeon_blit.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2010 Advanced Micro Devices, Inc. + * + * All Rights Reserved. + * + * 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 COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS 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. + * + */ + +#ifndef RADEON_BLIT_H +#define RADEON_BLIT_H + +void r100_blit_init(struct r100_context *r100); + +GLboolean r100_blit(struct r100_context *r100, + struct radeon_bo *src_bo, + intptr_t src_offset, + gl_format src_mesaformat, + unsigned src_pitch, + unsigned src_width, + unsigned src_height, + unsigned src_x_offset, + unsigned src_y_offset, + struct radeon_bo *dst_bo, + intptr_t dst_offset, + gl_format dst_mesaformat, + unsigned dst_pitch, + unsigned dst_width, + unsigned dst_height, + unsigned dst_x_offset, + unsigned dst_y_offset, + unsigned width, + unsigned height, + unsigned flip_y); + +#endif // RADEON_BLIT_H diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c index 3cd305b0a2..1182fc7f0d 100644 --- a/src/mesa/drivers/dri/radeon/radeon_context.c +++ b/src/mesa/drivers/dri/radeon/radeon_context.c @@ -228,6 +228,7 @@ r100CreateContext( const __GLcontextModes *glVisual, if ( !rmesa ) return GL_FALSE; + rmesa->radeon.radeonScreen = screen; r100_init_vtbl(&rmesa->radeon); /* init exp fog table data */ @@ -260,6 +261,10 @@ r100CreateContext( const __GLcontextModes *glVisual, radeonInitTextureFuncs( &functions ); radeonInitQueryObjFunctions(&functions); + if (rmesa->radeon.radeonScreen->kernel_mm) { + r100_init_texcopy_functions(&functions); + } + if (!radeonInitContext(&rmesa->radeon, &functions, glVisual, driContextPriv, sharedContextPrivate)) { diff --git a/src/mesa/drivers/dri/radeon/radeon_context.h b/src/mesa/drivers/dri/radeon/radeon_context.h index dfedc38bfd..c52eff855f 100644 --- a/src/mesa/drivers/dri/radeon/radeon_context.h +++ b/src/mesa/drivers/dri/radeon/radeon_context.h @@ -453,7 +453,7 @@ struct r100_context { extern GLboolean r100CreateContext( const __GLcontextModes *glVisual, __DRIcontext *driContextPriv, void *sharedContextPrivate); - +extern void r100_init_texcopy_functions(struct dd_function_table *table); #endif /* __RADEON_CONTEXT_H__ */ diff --git a/src/mesa/drivers/dri/radeon/radeon_texcopy.c b/src/mesa/drivers/dri/radeon/radeon_texcopy.c new file mode 100644 index 0000000000..d4328982c3 --- /dev/null +++ b/src/mesa/drivers/dri/radeon/radeon_texcopy.c @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2009 Maciej Cencora + * + * All Rights Reserved. + * + * 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 COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS 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. + * + */ + +#include "radeon_common.h" +#include "radeon_context.h" + +#include "main/image.h" +#include "main/teximage.h" +#include "main/texstate.h" +#include "drivers/common/meta.h" + +#include "radeon_mipmap_tree.h" +#include "radeon_blit.h" +#include
+ +// TODO: +// need to pass correct pitch for small dst textures! +static GLboolean +do_copy_texsubimage(GLcontext *ctx, + GLenum target, GLint level, + struct radeon_tex_obj *tobj, + radeon_texture_image *timg, + GLint dstx, GLint dsty, + GLint x, GLint y, + GLsizei width, GLsizei height) +{ + struct r100_context *r100 = R100_CONTEXT(ctx); + struct radeon_renderbuffer *rrb; + + if (_mesa_get_format_bits(timg->base.TexFormat, GL_DEPTH_BITS) > 0) { + rrb = radeon_get_depthbuffer(&r100->radeon); + } else { + rrb = radeon_get_colorbuffer(&r100->radeon); + } + + if (!timg->mt) { + radeon_validate_texture_miptree(ctx, &tobj->base); + } + + assert(rrb && rrb->bo); + assert(timg->mt->bo); + assert(timg->base.Width >= dstx + width); + assert(timg->base.Height >= dsty + height); + + intptr_t src_offset = rrb->draw_offset; + intptr_t dst_offset = radeon_miptree_image_offset(timg->mt, _mesa_tex_target_to_face(target), level); + + if (src_offset % 32 || dst_offset % 32) { + return GL_FALSE; + } + + if (0) { + fprintf(stderr, "%s: copying to face %d, level %d\n", + __FUNCTION__, _mesa_tex_target_to_face(target), level); + fprintf(stderr, "to: x %d, y %d, offset %d\n", dstx, dsty, (uint32_t) dst_offset); + fprintf(stderr, "from (%dx%d) width %d, height %d, offset %d, pitch %d\n", + x, y, rrb->base.Width, rrb->base.Height, (uint32_t) src_offset, rrb->pitch/rrb->cpp); + fprintf(stderr, "src size %d, dst size %d\n", rrb->bo->size, timg->mt->bo->size); + + } + + /* blit from src buffer to texture */ + return r100_blit(r100, rrb->bo, src_offset, rrb->base.Format, rrb->pitch, + rrb->base.Width, rrb->base.Height, x, y, + timg->mt->bo, dst_offset, timg->base.TexFormat, + timg->base.Width, timg->base.Width, timg->base.Height, + dstx, dsty, width, height, 1); +} + +static void +r100CopyTexImage2D(GLcontext *ctx, GLenum target, GLint level, + GLenum internalFormat, + GLint x, GLint y, GLsizei width, GLsizei height, + GLint border) +{ + struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); + struct gl_texture_object *texObj = + _mesa_select_tex_object(ctx, texUnit, target); + struct gl_texture_image *texImage = + _mesa_select_tex_image(ctx, texObj, target, level); + int srcx, srcy, dstx, dsty; + + if (border) + goto fail; + + /* Setup or redefine the texture object, mipmap tree and texture + * image. Don't populate yet. + */ + ctx->Driver.TexImage2D(ctx, target, level, internalFormat, + width, height, border, + GL_RGBA, GL_UNSIGNED_BYTE, NULL, + &ctx->DefaultPacking, texObj, texImage); + + srcx = x; + srcy = y; + dstx = 0; + dsty = 0; + if (!_mesa_clip_copytexsubimage(ctx, + &dstx, &dsty, + &srcx, &srcy, + &width, &height)) { + return; + } + + if (!do_copy_texsubimage(ctx, target, level, + radeon_tex_obj(texObj), (radeon_texture_image *)texImage, + 0, 0, x, y, width, height)) { + goto fail; + } + + return; + +fail: + _mesa_meta_CopyTexImage2D(ctx, target, level, internalFormat, x, y, + width, height, border); +} + +static void +r100CopyTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLsizei height) +{ + struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); + struct gl_texture_object *texObj = _mesa_select_tex_object(ctx, texUnit, target); + struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texObj, target, level); + + if (!do_copy_texsubimage(ctx, target, level, + radeon_tex_obj(texObj), (radeon_texture_image *)texImage, + xoffset, yoffset, x, y, width, height)) { + + //DEBUG_FALLBACKS + + _mesa_meta_CopyTexSubImage2D(ctx, target, level, + xoffset, yoffset, x, y, width, height); + } +} + + +void r100_init_texcopy_functions(struct dd_function_table *table) +{ + table->CopyTexImage2D = r100CopyTexImage2D; + table->CopyTexSubImage2D = r100CopyTexSubImage2D; +} diff --git a/src/mesa/drivers/dri/radeon/server/radeon_reg.h b/src/mesa/drivers/dri/radeon/server/radeon_reg.h index e81d7fdcd0..1b33de1edf 100644 --- a/src/mesa/drivers/dri/radeon/server/radeon_reg.h +++ b/src/mesa/drivers/dri/radeon/server/radeon_reg.h @@ -1959,7 +1959,30 @@ #define RADEON_SE_ZBIAS_FACTOR 0x1db0 #define RADEON_SE_ZBIAS_CONSTANT 0x1db4 - +#define RADEON_SE_VTX_FMT 0x2080 +# define RADEON_SE_VTX_FMT_XY 0x00000000 +# define RADEON_SE_VTX_FMT_W0 0x00000001 +# define RADEON_SE_VTX_FMT_FPCOLOR 0x00000002 +# define RADEON_SE_VTX_FMT_FPALPHA 0x00000004 +# define RADEON_SE_VTX_FMT_PKCOLOR 0x00000008 +# define RADEON_SE_VTX_FMT_FPSPEC 0x00000010 +# define RADEON_SE_VTX_FMT_FPFOG 0x00000020 +# define RADEON_SE_VTX_FMT_PKSPEC 0x00000040 +# define RADEON_SE_VTX_FMT_ST0 0x00000080 +# define RADEON_SE_VTX_FMT_ST1 0x00000100 +# define RADEON_SE_VTX_FMT_Q1 0x00000200 +# define RADEON_SE_VTX_FMT_ST2 0x00000400 +# define RADEON_SE_VTX_FMT_Q2 0x00000800 +# define RADEON_SE_VTX_FMT_ST3 0x00001000 +# define RADEON_SE_VTX_FMT_Q3 0x00002000 +# define RADEON_SE_VTX_FMT_Q0 0x00004000 +# define RADEON_SE_VTX_FMT_BLND_WEIGHT_CNT_MASK 0x00038000 +# define RADEON_SE_VTX_FMT_N0 0x00040000 +# define RADEON_SE_VTX_FMT_XY1 0x08000000 +# define RADEON_SE_VTX_FMT_Z1 0x10000000 +# define RADEON_SE_VTX_FMT_W1 0x20000000 +# define RADEON_SE_VTX_FMT_N1 0x40000000 +# define RADEON_SE_VTX_FMT_Z 0x80000000 /* Registers for CP and Microcode Engine */ #define RADEON_CP_ME_RAM_ADDR 0x07d4 -- cgit v1.2.3 From f90733c116acb68d79b3c4dda76983819062a5f1 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 18 Jan 2010 17:37:25 -0800 Subject: docs: Use proper XOR symbol. --- src/gallium/docs/source/tgsi.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gallium/docs/source/tgsi.rst b/src/gallium/docs/source/tgsi.rst index d9a043fde8..65a669d8cf 100644 --- a/src/gallium/docs/source/tgsi.rst +++ b/src/gallium/docs/source/tgsi.rst @@ -1000,13 +1000,13 @@ XOR - Bitwise Xor .. math:: - dst.x = src0.x ^ src1.x + dst.x = src0.x \oplus src1.x - dst.y = src0.y ^ src1.y + dst.y = src0.y \oplus src1.y - dst.z = src0.z ^ src1.z + dst.z = src0.z \oplus src1.z - dst.w = src0.w ^ src1.w + dst.w = src0.w \oplus src1.w SAD - Sum Of Absolute Differences -- cgit v1.2.3 From 09f69b1e5d4e9a4086950de97e0bff46e70bd686 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 18 Jan 2010 18:05:55 -0800 Subject: docs: Clarify PIPE_TEXTURE_USAGE_DYNAMIC. --- src/gallium/docs/source/screen.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index bac63135b5..72bb75a55d 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -23,7 +23,7 @@ texture that can be used as multiple things. validated here is implicitly also a depthbuffer. * ``SAMPLER``: A texture that may be sampled from in a fragment or vertex shader. -* ``DYNAMIC``: XXX undefined +* ``DYNAMIC``: A texture that will be mapped frequently. Methods ------- @@ -59,6 +59,10 @@ See if a format can be used in a specific manner. Returns TRUE if all usages can be satisfied. +.. note:: + + ``PIPE_TEXTURE_USAGE_DYNAMIC`` is not a valid usage. + texture_create ^^^^^^^^^^^^^^ -- cgit v1.2.3 From f8db32acbd03079d4ef30daa1db1339aa35b5cfb Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 18:14:03 -0800 Subject: st/dri: Add comment for intentional fallthrough in case statement. --- src/gallium/state_trackers/dri/dri_drawable.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 0a8c1cd361..99dc022549 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -183,6 +183,7 @@ dri_get_buffers(__DRIdrawablePrivate * dPriv) case __DRI_BUFFER_FRONT_LEFT: if (!st_screen->auto_fake_front) continue; + /* fallthrough */ case __DRI_BUFFER_FAKE_FRONT_LEFT: index = ST_SURFACE_FRONT_LEFT; format = drawable->color_format; -- cgit v1.2.3 From ec29ba12a687c8a08ecba002216bbd9f56facef0 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 18:52:24 -0800 Subject: mesa: Remove unnecessary headers from texcompress.c. --- src/mesa/main/texcompress.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c index a4f1926ab3..cff6de89ee 100644 --- a/src/mesa/main/texcompress.c +++ b/src/mesa/main/texcompress.c @@ -35,10 +35,7 @@ #include "colormac.h" #include "context.h" #include "formats.h" -#include "image.h" -#include "mipmap.h" #include "texcompress.h" -#include "texstore.h" /** -- cgit v1.2.3 From 66035503532a17110e36d1d1053e98a1595d03d9 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 18:54:54 -0800 Subject: mesa: Remove unnecessary header from state.c. --- src/mesa/main/state.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index f10e6b04b7..904ad01205 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -48,7 +48,6 @@ #include "texenvprogram.h" #include "texobj.h" #include "texstate.h" -#include "viewport.h" static void -- cgit v1.2.3 From f6d529083fe7d945d522b4ab65314e89540238c4 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Mon, 18 Jan 2010 21:58:02 -0500 Subject: r60: Add relocs for CB_TILE/FRAG as per 46dc6fd3ed5ef96cda53641a97bc68c3bc104a9f --- src/mesa/drivers/dri/r600/r600_blit.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r600_blit.c b/src/mesa/drivers/dri/r600/r600_blit.c index de3a58706e..a75b1003cb 100644 --- a/src/mesa/drivers/dri/r600/r600_blit.c +++ b/src/mesa/drivers/dri/r600/r600_blit.c @@ -310,12 +310,31 @@ set_render_target(context_t *context, struct radeon_bo *bo, gl_format mesa_forma END_BATCH(); } - BEGIN_BATCH_NO_AUTOSTATE(18); + /* Set CMASK & TILE buffer to the offset of color buffer as + * we don't use those this shouldn't cause any issue and we + * then have a valid cmd stream + */ + BEGIN_BATCH_NO_AUTOSTATE(3 + 2); + R600_OUT_BATCH_REGSEQ(CB_COLOR0_TILE + (4 * id), 1); + R600_OUT_BATCH(cb_color0_base); + R600_OUT_BATCH_RELOC(0, + bo, + 0, + 0, RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT, 0); + END_BATCH(); + BEGIN_BATCH_NO_AUTOSTATE(3 + 2); + R600_OUT_BATCH_REGSEQ(CB_COLOR0_FRAG + (4 * id), 1); + R600_OUT_BATCH(cb_color0_base); + R600_OUT_BATCH_RELOC(0, + bo, + 0, + 0, RADEON_GEM_DOMAIN_VRAM | RADEON_GEM_DOMAIN_GTT, 0); + END_BATCH(); + + BEGIN_BATCH_NO_AUTOSTATE(12); R600_OUT_BATCH_REGVAL(CB_COLOR0_SIZE + (4 * id), cb_color0_size); R600_OUT_BATCH_REGVAL(CB_COLOR0_VIEW + (4 * id), cb_color0_view); R600_OUT_BATCH_REGVAL(CB_COLOR0_INFO + (4 * id), cb_color0_info); - R600_OUT_BATCH_REGVAL(CB_COLOR0_TILE + (4 * id), 0); - R600_OUT_BATCH_REGVAL(CB_COLOR0_FRAG + (4 * id), 0); R600_OUT_BATCH_REGVAL(CB_COLOR0_MASK + (4 * id), 0); END_BATCH(); @@ -1529,7 +1548,7 @@ GLboolean r600_blit(context_t *context, /* Flush is needed to make sure that source buffer has correct data */ radeonFlush(context->radeon.glCtx); - rcommonEnsureCmdBufSpace(&context->radeon, 302, __FUNCTION__); + rcommonEnsureCmdBufSpace(&context->radeon, 304, __FUNCTION__); /* load shaders */ load_shaders(context->radeon.glCtx); @@ -1554,7 +1573,7 @@ GLboolean r600_blit(context_t *context, set_tex_sampler(context); /* dst */ - /* 25 */ + /* 27 */ set_render_target(context, dst_bo, dst_mesaformat, dst_pitch, dst_width, dst_height, dst_offset); /* scissors */ -- cgit v1.2.3 From 80ea879cfa63354ec1312a107f63934c1e6c7824 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 19:03:54 -0800 Subject: mesa: Remove unnecessary header from polygon.c. --- src/mesa/main/polygon.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c index 376a87a396..dcde6758c3 100644 --- a/src/mesa/main/polygon.c +++ b/src/mesa/main/polygon.c @@ -34,7 +34,6 @@ #include "context.h" #include "image.h" #include "enums.h" -#include "macros.h" #include "polygon.h" #include "mtypes.h" -- cgit v1.2.3 From 419ae5a48339795d369a41d66312246b2e19f201 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 19:10:05 -0800 Subject: mesa: Remove unnecessary header from points.c. --- src/mesa/main/points.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c index dcaeccd90d..e743a2e6bd 100644 --- a/src/mesa/main/points.c +++ b/src/mesa/main/points.c @@ -32,7 +32,6 @@ #include "context.h" #include "macros.h" #include "points.h" -#include "texstate.h" #include "mtypes.h" -- cgit v1.2.3 From 2f83948370c686d1f5f0b1e0d23b5286169e850d Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 19:14:23 -0800 Subject: mesa: Remove unnecessary headers from pixelstore.c. --- src/mesa/main/pixelstore.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/mesa/main/pixelstore.c b/src/mesa/main/pixelstore.c index 6a641f83f2..ec585ef0cc 100644 --- a/src/mesa/main/pixelstore.c +++ b/src/mesa/main/pixelstore.c @@ -30,10 +30,7 @@ #include "glheader.h" #include "bufferobj.h" -#include "colormac.h" #include "context.h" -#include "image.h" -#include "macros.h" #include "pixelstore.h" #include "mtypes.h" -- cgit v1.2.3 From ed5a116eb411aed2a2f1986a1effbb8a426b0065 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 19:20:56 -0800 Subject: mesa: Remove unnecessary header from pixel.c. --- src/mesa/main/pixel.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c index 3820ebd889..f6f9c1173a 100644 --- a/src/mesa/main/pixel.c +++ b/src/mesa/main/pixel.c @@ -32,7 +32,6 @@ #include "bufferobj.h" #include "colormac.h" #include "context.h" -#include "image.h" #include "macros.h" #include "pixel.h" #include "mtypes.h" -- cgit v1.2.3 From d0125e3c29942ae7a81a66748ea53b402114993d Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 19:23:47 -0800 Subject: mesa: Remove unnecessary header from mipmap.c. --- src/mesa/main/mipmap.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c index 7350c7a3d2..77cd1d4159 100644 --- a/src/mesa/main/mipmap.c +++ b/src/mesa/main/mipmap.c @@ -30,7 +30,6 @@ #include "imports.h" #include "formats.h" #include "mipmap.h" -#include "texcompress.h" #include "teximage.h" #include "texstore.h" #include "image.h" -- cgit v1.2.3 From ebd10755984d582fa65c71b58bc20015e2ea9caf Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 19:32:51 -0800 Subject: mesa: Remove unnecessary headers from lines.c. --- src/mesa/main/lines.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mesa/main/lines.c b/src/mesa/main/lines.c index 81d0d33abb..cc63a759ec 100644 --- a/src/mesa/main/lines.c +++ b/src/mesa/main/lines.c @@ -25,10 +25,8 @@ #include "glheader.h" #include "context.h" -#include "depth.h" #include "lines.h" #include "macros.h" -#include "texstate.h" #include "mtypes.h" -- cgit v1.2.3 From dc298559c6c838d8ad744e07c134a1c8846c9b33 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 14 Jan 2010 15:06:48 +0000 Subject: svga: Ensure buffer size/alignment is not zero. --- src/gallium/drivers/svga/svga_screen_buffer.c | 3 +++ src/gallium/drivers/svga/svga_swtnl_backend.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/svga/svga_screen_buffer.c b/src/gallium/drivers/svga/svga_screen_buffer.c index 1f8a889672..c014f2ee20 100644 --- a/src/gallium/drivers/svga/svga_screen_buffer.c +++ b/src/gallium/drivers/svga/svga_screen_buffer.c @@ -594,6 +594,9 @@ svga_buffer_create(struct pipe_screen *screen, struct svga_screen *ss = svga_screen(screen); struct svga_buffer *sbuf; + assert(size); + assert(alignment); + sbuf = CALLOC_STRUCT(svga_buffer); if(!sbuf) goto error1; diff --git a/src/gallium/drivers/svga/svga_swtnl_backend.c b/src/gallium/drivers/svga/svga_swtnl_backend.c index b4f757a47a..3d82e4f880 100644 --- a/src/gallium/drivers/svga/svga_swtnl_backend.c +++ b/src/gallium/drivers/svga/svga_swtnl_backend.c @@ -87,13 +87,13 @@ svga_vbuf_render_allocate_vertices( struct vbuf_render *render, if (!svga_render->vbuf) { svga_render->vbuf_size = MAX2(size, svga_render->vbuf_alloc_size); svga_render->vbuf = pipe_buffer_create(screen, - 0, + 16, PIPE_BUFFER_USAGE_VERTEX, svga_render->vbuf_size); if(!svga_render->vbuf) { svga_context_flush(svga, NULL); svga_render->vbuf = pipe_buffer_create(screen, - 0, + 16, PIPE_BUFFER_USAGE_VERTEX, svga_render->vbuf_size); assert(svga_render->vbuf); @@ -259,7 +259,7 @@ svga_vbuf_render_draw( struct vbuf_render *render, if (!svga_render->ibuf) { svga_render->ibuf_size = MAX2(size, svga_render->ibuf_alloc_size); svga_render->ibuf = pipe_buffer_create(screen, - 0, + 2, PIPE_BUFFER_USAGE_VERTEX, svga_render->ibuf_size); svga_render->ibuf_offset = 0; -- cgit v1.2.3 From bcadde2068563b818a280e40e6189191e10fd371 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 14 Jan 2010 15:07:20 +0000 Subject: pipebuffer: Ensure buffer size/alignment is not zero. --- src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c index 6e3214ca9c..8f74180a11 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c @@ -371,6 +371,9 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr, struct pb_desc real_desc; pb_size real_size; + assert(size); + assert(desc->alignment); + buf = CALLOC_STRUCT(pb_debug_buffer); if(!buf) return NULL; -- cgit v1.2.3 From 8fb92e96e90a8cb57da78444fd3395aba424cb0a Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 18 Jan 2010 19:32:36 -0800 Subject: mesa: Handle PIPE_FORMAT_B8G8R8X8_UNORM. --- src/mesa/state_tracker/st_format.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index 6b1c49954f..d2bc0dc8ba 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -293,6 +293,8 @@ st_pipe_format_to_mesa_format(enum pipe_format pipeFormat) return MESA_FORMAT_XRGB8888; case PIPE_FORMAT_B8G8R8A8_UNORM: return MESA_FORMAT_ARGB8888_REV; + case PIPE_FORMAT_B8G8R8X8_UNORM: + return MESA_FORMAT_XRGB8888_REV; case PIPE_FORMAT_A1R5G5B5_UNORM: return MESA_FORMAT_ARGB1555; case PIPE_FORMAT_A4R4G4B4_UNORM: -- cgit v1.2.3 From 65fa11959f118a75a82d1e432df0b635d316889f Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 18 Jan 2010 19:33:13 -0800 Subject: softpipe: Skip depth testing for PIPE_S8_UNORM. --- src/gallium/drivers/softpipe/sp_quad_depth_test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/softpipe/sp_quad_depth_test.c b/src/gallium/drivers/softpipe/sp_quad_depth_test.c index 0ca86c4e1c..03f569d466 100644 --- a/src/gallium/drivers/softpipe/sp_quad_depth_test.c +++ b/src/gallium/drivers/softpipe/sp_quad_depth_test.c @@ -667,6 +667,7 @@ depth_test_quads_fallback(struct quad_stage *qs, } if (qs->softpipe->framebuffer.zsbuf && + pf_get_component_bits(qs->softpipe->framebuffer.zsbuf->format, PIPE_FORMAT_COMP_Z) && (qs->softpipe->depth_stencil->depth.enabled || qs->softpipe->depth_stencil->stencil[0].enabled)) { @@ -885,6 +886,7 @@ choose_depth_test(struct quad_stage *qs, boolean alpha = qs->softpipe->depth_stencil->alpha.enabled; boolean depth = (qs->softpipe->framebuffer.zsbuf && + pf_get_component_bits(qs->softpipe->framebuffer.zsbuf->format, PIPE_FORMAT_COMP_Z) && qs->softpipe->depth_stencil->depth.enabled); unsigned depthfunc = qs->softpipe->depth_stencil->depth.func; @@ -895,7 +897,6 @@ choose_depth_test(struct quad_stage *qs, boolean occlusion = qs->softpipe->active_query_count; - if (!alpha && !depth && !stencil) { -- cgit v1.2.3 From 2cbc3e0a206b701780c893cf96507778ab1fb5a1 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 21:02:19 -0800 Subject: mesa: Remove unnecessary header from image.c. --- src/mesa/main/image.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 3b685cb947..1dfcc48195 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -36,7 +36,6 @@ #include "image.h" #include "imports.h" #include "macros.h" -#include "pixel.h" /** -- cgit v1.2.3 From b6dce54214c804e46aab05acd03a64c35a9baa63 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 21:07:53 -0800 Subject: mesa: Remove unnecessary header from formats.c. --- src/mesa/main/formats.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index 5983f00e2d..d0c9c0028b 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -27,7 +27,6 @@ #include "imports.h" #include "formats.h" #include "config.h" -#include "texstore.h" /** -- cgit v1.2.3 From 536e3c9168c315651210ca853eb8cb4423f9f71c Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 21:14:04 -0800 Subject: mesa: Remove unnecessary headers from fbobject.c. --- src/mesa/main/fbobject.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 7b3599f932..56e806559f 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -40,13 +40,10 @@ #include "framebuffer.h" #include "hash.h" #include "macros.h" -#include "mipmap.h" #include "renderbuffer.h" #include "state.h" #include "teximage.h" #include "texobj.h" -#include "texstore.h" -#include "texstate.h" /** Set this to 1 to help debug FBO incompleteness problems */ -- cgit v1.2.3 From 0b3109aa053539b2e07ec16da980615f16dd8c2b Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 21:17:45 -0800 Subject: mesa: Remove unnecessary header from enable.c. --- src/mesa/main/enable.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 12ce14c5d0..1573bc27ce 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -32,7 +32,6 @@ #include "context.h" #include "enable.h" #include "light.h" -#include "macros.h" #include "simple_list.h" #include "mtypes.h" #include "enums.h" -- cgit v1.2.3 From 7395ab042aedb3ef29d3c5d974138bc4430cb772 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 21:22:47 -0800 Subject: mesa: Remove unnecessary header from drawpix.c. --- src/mesa/main/drawpix.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c index 5d4b53af4c..0afd47b797 100644 --- a/src/mesa/main/drawpix.c +++ b/src/mesa/main/drawpix.c @@ -30,7 +30,6 @@ #include "enums.h" #include "feedback.h" #include "framebuffer.h" -#include "image.h" #include "readpix.h" #include "state.h" #include "glapi/dispatch.h" -- cgit v1.2.3 From 2660511ea94c2d3abe8495258f7ea693cae3759e Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 21:31:02 -0800 Subject: mesa: Remove unnecessary headers from dlist.c. --- src/mesa/main/dlist.c | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index b692c335a7..a90bb6c5fb 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -35,46 +35,25 @@ #include "api_loopback.h" #include "config.h" #include "mfeatures.h" -#include "attrib.h" -#include "blend.h" -#include "buffers.h" #if FEATURE_ARB_vertex_buffer_object #include "bufferobj.h" #endif #include "arrayobj.h" -#include "clip.h" -#include "colortab.h" #include "context.h" -#include "convolve.h" -#include "depth.h" #include "dlist.h" -#include "enable.h" #include "enums.h" #include "eval.h" -#include "extensions.h" -#include "feedback.h" #include "framebuffer.h" -#include "get.h" #include "glapi/glapi.h" #include "hash.h" -#include "histogram.h" #include "image.h" #include "light.h" -#include "lines.h" #include "dlist.h" #include "macros.h" -#include "matrix.h" -#include "pixel.h" -#include "points.h" -#include "polygon.h" #include "queryobj.h" -#include "state.h" -#include "texobj.h" #include "teximage.h" -#include "texstate.h" #include "mtypes.h" #include "varray.h" -#include "vtxfmt.h" #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program #include "shader/arbprogram.h" #include "shader/program.h" -- cgit v1.2.3 From 6deb8c9831c60ed5ae93966b5a37d1215b8682a4 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 21:34:25 -0800 Subject: mesa: Remove unnecessary header from depthstencil.c. --- src/mesa/main/depthstencil.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/main/depthstencil.c b/src/mesa/main/depthstencil.c index 193c7f8255..49946a6506 100644 --- a/src/mesa/main/depthstencil.c +++ b/src/mesa/main/depthstencil.c @@ -25,7 +25,6 @@ #include "glheader.h" #include "imports.h" #include "context.h" -#include "fbobject.h" #include "formats.h" #include "mtypes.h" #include "depthstencil.h" -- cgit v1.2.3 From b36b85f9d0c721188582e6daa3328ab9766f85c0 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 21:37:18 -0800 Subject: mesa: Remove unnecessary headers from debug.c. --- src/mesa/main/debug.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c index a42113edca..d4d099a08b 100644 --- a/src/mesa/main/debug.c +++ b/src/mesa/main/debug.c @@ -26,7 +26,6 @@ #include "mtypes.h" #include "attrib.h" #include "colormac.h" -#include "context.h" #include "enums.h" #include "formats.h" #include "hash.h" @@ -35,7 +34,6 @@ #include "get.h" #include "pixelstore.h" #include "readpix.h" -#include "texgetimage.h" #include "texobj.h" -- cgit v1.2.3 From 08063ba4499c47c9b55c80878a668050c6272c30 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 21:41:31 -0800 Subject: mesa: Fix typo of 'unknown' in debug.c. --- src/mesa/main/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c index d4d099a08b..9bad83487f 100644 --- a/src/mesa/main/debug.c +++ b/src/mesa/main/debug.c @@ -52,7 +52,7 @@ const char *_mesa_prim_name[GL_POLYGON+4] = { "GL_QUAD_STRIP", "GL_POLYGON", "outside begin/end", - "inside unkown primitive", + "inside unknown primitive", "unknown state" }; -- cgit v1.2.3 From 7366d8e7d20efc673702d7c6c9603d507edcf06d Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 21:56:58 -0800 Subject: mesa: Remove unnecessary header from convolve.c. --- src/mesa/main/convolve.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/main/convolve.c b/src/mesa/main/convolve.c index 8db3e79d38..5ed93e0c60 100644 --- a/src/mesa/main/convolve.c +++ b/src/mesa/main/convolve.c @@ -38,7 +38,6 @@ #include "context.h" #include "image.h" #include "mtypes.h" -#include "pixel.h" #include "state.h" #include "glapi/dispatch.h" -- cgit v1.2.3 From c4ad036ce145ab04677b6e40c18315906b897a31 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 22:17:03 -0800 Subject: mesa: Remove unnecessary headers from buffers.c. --- src/mesa/main/buffers.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index 97f0659758..fb30b59960 100644 --- a/src/mesa/main/buffers.c +++ b/src/mesa/main/buffers.c @@ -35,8 +35,6 @@ #include "colormac.h" #include "context.h" #include "enums.h" -#include "fbobject.h" -#include "state.h" #define BAD_MASK ~0u -- cgit v1.2.3 From a67cd1994f3474dd638af76b2bf5b19490863cba Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Tue, 19 Jan 2010 01:26:35 -0500 Subject: r100/r200: add blit support for ARGB4444 --- src/mesa/drivers/dri/r200/r200_blit.c | 6 ++++++ src/mesa/drivers/dri/radeon/radeon_blit.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/mesa/drivers/dri/r200/r200_blit.c b/src/mesa/drivers/dri/r200/r200_blit.c index b6bed85a6c..2b3b165c5f 100644 --- a/src/mesa/drivers/dri/r200/r200_blit.c +++ b/src/mesa/drivers/dri/r200/r200_blit.c @@ -88,6 +88,9 @@ static void inline emit_tx_setup(struct r200_context *r200, case MESA_FORMAT_RGB565: txformat |= R200_TXFORMAT_RGB565; break; + case MESA_FORMAT_ARGB4444: + txformat |= R200_TXFORMAT_ARGB4444 | R200_TXFORMAT_ALPHA_IN_MAP; + break; case MESA_FORMAT_ARGB1555: txformat |= R200_TXFORMAT_ARGB1555 | R200_TXFORMAT_ALPHA_IN_MAP; break; @@ -149,6 +152,9 @@ static inline void emit_cb_setup(struct r200_context *r200, case MESA_FORMAT_RGB565: dst_format = RADEON_COLOR_FORMAT_RGB565; break; + case MESA_FORMAT_ARGB4444: + dst_format = RADEON_COLOR_FORMAT_ARGB4444; + break; case MESA_FORMAT_ARGB1555: dst_format = RADEON_COLOR_FORMAT_ARGB1555; break; diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.c b/src/mesa/drivers/dri/radeon/radeon_blit.c index 4abe7a2960..bc46018255 100644 --- a/src/mesa/drivers/dri/radeon/radeon_blit.c +++ b/src/mesa/drivers/dri/radeon/radeon_blit.c @@ -86,6 +86,9 @@ static void inline emit_tx_setup(struct r100_context *r100, case MESA_FORMAT_RGB565: txformat |= RADEON_TXFORMAT_RGB565; break; + case MESA_FORMAT_ARGB4444: + txformat |= RADEON_TXFORMAT_ARGB4444 | RADEON_TXFORMAT_ALPHA_IN_MAP; + break; case MESA_FORMAT_ARGB1555: txformat |= RADEON_TXFORMAT_ARGB1555 | RADEON_TXFORMAT_ALPHA_IN_MAP; break; @@ -144,6 +147,9 @@ static inline void emit_cb_setup(struct r100_context *r100, case MESA_FORMAT_RGB565: dst_format = RADEON_COLOR_FORMAT_RGB565; break; + case MESA_FORMAT_ARGB4444: + dst_format = RADEON_COLOR_FORMAT_ARGB4444; + break; case MESA_FORMAT_ARGB1555: dst_format = RADEON_COLOR_FORMAT_ARGB1555; break; -- cgit v1.2.3 From 2b1d5ea4f0250a6a7fa312ced0a7af85e909381b Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Tue, 19 Jan 2010 01:42:41 -0500 Subject: r100/r200/r600: check if blitting for given format is supported earlier based on Maciej's r300 patch. --- src/mesa/drivers/dri/r200/r200_blit.c | 25 ++++++++++++- src/mesa/drivers/dri/r600/r600_blit.c | 59 +++++++++++++++++++++++++++++-- src/mesa/drivers/dri/radeon/radeon_blit.c | 25 ++++++++++++- 3 files changed, 105 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/r200/r200_blit.c b/src/mesa/drivers/dri/r200/r200_blit.c index 2b3b165c5f..27f18e0738 100644 --- a/src/mesa/drivers/dri/r200/r200_blit.c +++ b/src/mesa/drivers/dri/r200/r200_blit.c @@ -37,6 +37,29 @@ static inline uint32_t cmdpacket0(struct radeon_screen *rscrn, return CP_PACKET2; } +/* common formats supported as both textures and render targets */ +static unsigned is_blit_supported(gl_format mesa_format) +{ + /* XXX others? BE/LE? */ + switch (mesa_format) { + case MESA_FORMAT_ARGB8888: + case MESA_FORMAT_XRGB8888: + case MESA_FORMAT_RGB565: + case MESA_FORMAT_ARGB4444: + case MESA_FORMAT_ARGB1555: + case MESA_FORMAT_A8: + break; + default: + return 0; + } + + /* ??? */ + if (_mesa_get_format_bits(mesa_format, GL_DEPTH_BITS) > 0) + return 0; + + return 1; +} + static inline void emit_vtx_state(struct r200_context *r200) { BATCH_LOCALS(&r200->radeon); @@ -309,7 +332,7 @@ GLboolean r200_blit(struct r200_context *r200, unsigned reg_height, unsigned flip_y) { - if (_mesa_get_format_bits(src_mesaformat, GL_DEPTH_BITS) > 0) + if (is_blit_supported(dst_mesaformat)) return GL_FALSE; /* Make sure that colorbuffer has even width - hw limitation */ diff --git a/src/mesa/drivers/dri/r600/r600_blit.c b/src/mesa/drivers/dri/r600/r600_blit.c index a75b1003cb..1e87d3d7c8 100644 --- a/src/mesa/drivers/dri/r600/r600_blit.c +++ b/src/mesa/drivers/dri/r600/r600_blit.c @@ -32,6 +32,62 @@ #include "r600_blit_shaders.h" #include "r600_cmdbuf.h" +/* common formats supported as both textures and render targets */ +static unsigned is_blit_supported(gl_format mesa_format) +{ + switch (mesa_format) { + case MESA_FORMAT_RGBA8888: + case MESA_FORMAT_SIGNED_RGBA8888: + case MESA_FORMAT_RGBA8888_REV: + case MESA_FORMAT_SIGNED_RGBA8888_REV: + case MESA_FORMAT_ARGB8888: + case MESA_FORMAT_XRGB8888: + case MESA_FORMAT_ARGB8888_REV: + case MESA_FORMAT_XRGB8888_REV: + case MESA_FORMAT_RGB565: + case MESA_FORMAT_RGB565_REV: + case MESA_FORMAT_ARGB4444: + case MESA_FORMAT_ARGB4444_REV: + case MESA_FORMAT_ARGB1555: + case MESA_FORMAT_ARGB1555_REV: + case MESA_FORMAT_AL88: + case MESA_FORMAT_AL88_REV: + case MESA_FORMAT_RGB332: + case MESA_FORMAT_A8: + case MESA_FORMAT_I8: + case MESA_FORMAT_CI8: + case MESA_FORMAT_L8: + case MESA_FORMAT_RGBA_FLOAT32: + case MESA_FORMAT_RGBA_FLOAT16: + case MESA_FORMAT_ALPHA_FLOAT32: + case MESA_FORMAT_ALPHA_FLOAT16: + case MESA_FORMAT_LUMINANCE_FLOAT32: + case MESA_FORMAT_LUMINANCE_FLOAT16: + case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32: + case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16: + case MESA_FORMAT_INTENSITY_FLOAT32: /* X, X, X, X */ + case MESA_FORMAT_INTENSITY_FLOAT16: /* X, X, X, X */ + case MESA_FORMAT_X8_Z24: + case MESA_FORMAT_S8_Z24: + case MESA_FORMAT_Z24_S8: + case MESA_FORMAT_Z16: + case MESA_FORMAT_Z32: + case MESA_FORMAT_SRGBA8: + case MESA_FORMAT_SLA8: + case MESA_FORMAT_SL8: + break; + default: + return 0; + } + + /* ??? */ + /* not sure blit to depth works or not yet */ + if (_mesa_get_format_bits(mesa_format, GL_DEPTH_BITS) > 0) + return 0; + + return 1; +} + static inline void set_render_target(context_t *context, struct radeon_bo *bo, gl_format mesa_format, int pitch, int w, int h, intptr_t dst_offset) @@ -1526,8 +1582,7 @@ GLboolean r600_blit(context_t *context, { int id = 0; - /* not sure blit to depth works or not yet */ - if (_mesa_get_format_bits(src_mesaformat, GL_DEPTH_BITS) > 0) + if (is_blit_supported(dst_mesaformat)) return GL_FALSE; if (src_bo == dst_bo) { diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.c b/src/mesa/drivers/dri/radeon/radeon_blit.c index bc46018255..d9343b3064 100644 --- a/src/mesa/drivers/dri/radeon/radeon_blit.c +++ b/src/mesa/drivers/dri/radeon/radeon_blit.c @@ -37,6 +37,29 @@ static inline uint32_t cmdpacket0(struct radeon_screen *rscrn, return CP_PACKET2; } +/* common formats supported as both textures and render targets */ +static unsigned is_blit_supported(gl_format mesa_format) +{ + /* XXX others? BE/LE? */ + switch (mesa_format) { + case MESA_FORMAT_ARGB8888: + case MESA_FORMAT_XRGB8888: + case MESA_FORMAT_RGB565: + case MESA_FORMAT_ARGB4444: + case MESA_FORMAT_ARGB1555: + case MESA_FORMAT_A8: + break; + default: + return 0; + } + + /* ??? */ + if (_mesa_get_format_bits(mesa_format, GL_DEPTH_BITS) > 0) + return 0; + + return 1; +} + static inline void emit_vtx_state(struct r100_context *r100) { BATCH_LOCALS(&r100->radeon); @@ -305,7 +328,7 @@ GLboolean r100_blit(struct r100_context *r100, unsigned reg_height, unsigned flip_y) { - if (_mesa_get_format_bits(src_mesaformat, GL_DEPTH_BITS) > 0) + if (is_blit_supported(dst_mesaformat)) return GL_FALSE; /* Make sure that colorbuffer has even width - hw limitation */ -- cgit v1.2.3 From 2613fa815abd7d794ec7144f0ad19ef4f65da991 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 22:45:23 -0800 Subject: mesa: Remove unnecessary header from blend.c. --- src/mesa/main/blend.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index 830e3b2e51..0b6ff1a034 100644 --- a/src/mesa/main/blend.c +++ b/src/mesa/main/blend.c @@ -35,7 +35,6 @@ #include "enums.h" #include "macros.h" #include "mtypes.h" -#include "glapi/glapitable.h" /** -- cgit v1.2.3 From ef631104d51d011ef1dbaf7b4aeba274ae103ad7 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Tue, 19 Jan 2010 01:47:04 -0500 Subject: r100/r200/r600: fix typo in 2b1d5ea4f0250a6a7fa312ced0a7af85e909381b --- src/mesa/drivers/dri/r200/r200_blit.c | 2 +- src/mesa/drivers/dri/r600/r600_blit.c | 2 +- src/mesa/drivers/dri/radeon/radeon_blit.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/r200/r200_blit.c b/src/mesa/drivers/dri/r200/r200_blit.c index 27f18e0738..081218b3a5 100644 --- a/src/mesa/drivers/dri/r200/r200_blit.c +++ b/src/mesa/drivers/dri/r200/r200_blit.c @@ -332,7 +332,7 @@ GLboolean r200_blit(struct r200_context *r200, unsigned reg_height, unsigned flip_y) { - if (is_blit_supported(dst_mesaformat)) + if (!is_blit_supported(dst_mesaformat)) return GL_FALSE; /* Make sure that colorbuffer has even width - hw limitation */ diff --git a/src/mesa/drivers/dri/r600/r600_blit.c b/src/mesa/drivers/dri/r600/r600_blit.c index 1e87d3d7c8..418544a08d 100644 --- a/src/mesa/drivers/dri/r600/r600_blit.c +++ b/src/mesa/drivers/dri/r600/r600_blit.c @@ -1582,7 +1582,7 @@ GLboolean r600_blit(context_t *context, { int id = 0; - if (is_blit_supported(dst_mesaformat)) + if (!is_blit_supported(dst_mesaformat)) return GL_FALSE; if (src_bo == dst_bo) { diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.c b/src/mesa/drivers/dri/radeon/radeon_blit.c index d9343b3064..1ccfa4e78e 100644 --- a/src/mesa/drivers/dri/radeon/radeon_blit.c +++ b/src/mesa/drivers/dri/radeon/radeon_blit.c @@ -328,7 +328,7 @@ GLboolean r100_blit(struct r100_context *r100, unsigned reg_height, unsigned flip_y) { - if (is_blit_supported(dst_mesaformat)) + if (!is_blit_supported(dst_mesaformat)) return GL_FALSE; /* Make sure that colorbuffer has even width - hw limitation */ -- cgit v1.2.3 From 45a27eacd6301078c6f62682193dda3141088fe2 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 18 Jan 2010 22:50:08 -0800 Subject: mesa: Remove unnecessary header from attrib.c. --- src/mesa/main/attrib.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index a14f71c330..7adb2e2eac 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -33,7 +33,6 @@ #include "bufferobj.h" #include "clear.h" #include "colormac.h" -#include "colortab.h" #include "context.h" #include "depth.h" #include "enable.h" -- cgit v1.2.3 From faa99dd31de7dad4e9851b12f7f788adb6fce0fc Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Tue, 19 Jan 2010 00:45:16 -0800 Subject: unichrome: Remove unnecessary headers. --- src/mesa/drivers/dri/unichrome/via_context.c | 3 --- src/mesa/drivers/dri/unichrome/via_ioctl.c | 1 - src/mesa/drivers/dri/unichrome/via_render.c | 1 - src/mesa/drivers/dri/unichrome/via_screen.c | 4 ---- src/mesa/drivers/dri/unichrome/via_state.c | 3 --- src/mesa/drivers/dri/unichrome/via_tex.c | 2 -- src/mesa/drivers/dri/unichrome/via_texcombine.c | 1 - 7 files changed, 15 deletions(-) diff --git a/src/mesa/drivers/dri/unichrome/via_context.c b/src/mesa/drivers/dri/unichrome/via_context.c index 0524becf3e..ff666a383b 100644 --- a/src/mesa/drivers/dri/unichrome/via_context.c +++ b/src/mesa/drivers/dri/unichrome/via_context.c @@ -33,10 +33,7 @@ #include "main/glheader.h" #include "main/context.h" #include "main/formats.h" -#include "main/matrix.h" -#include "main/state.h" #include "main/simple_list.h" -#include "main/extensions.h" #include "main/framebuffer.h" #include "main/renderbuffer.h" diff --git a/src/mesa/drivers/dri/unichrome/via_ioctl.c b/src/mesa/drivers/dri/unichrome/via_ioctl.c index 91c94fa377..69eac44193 100644 --- a/src/mesa/drivers/dri/unichrome/via_ioctl.c +++ b/src/mesa/drivers/dri/unichrome/via_ioctl.c @@ -34,7 +34,6 @@ #include "via_context.h" #include "via_tris.h" #include "via_ioctl.h" -#include "via_state.h" #include "via_fb.h" #include "via_3d_reg.h" diff --git a/src/mesa/drivers/dri/unichrome/via_render.c b/src/mesa/drivers/dri/unichrome/via_render.c index f676cc13c8..896c43db1b 100644 --- a/src/mesa/drivers/dri/unichrome/via_render.c +++ b/src/mesa/drivers/dri/unichrome/via_render.c @@ -37,7 +37,6 @@ #include "via_context.h" #include "via_tris.h" -#include "via_state.h" #include "via_ioctl.h" /* diff --git a/src/mesa/drivers/dri/unichrome/via_screen.c b/src/mesa/drivers/dri/unichrome/via_screen.c index e0bf58ca9a..115d3fbffd 100644 --- a/src/mesa/drivers/dri/unichrome/via_screen.c +++ b/src/mesa/drivers/dri/unichrome/via_screen.c @@ -30,17 +30,13 @@ #include "main/context.h" #include "main/framebuffer.h" #include "main/renderbuffer.h" -#include "main/matrix.h" #include "main/simple_list.h" #include "vblank.h" #include "via_state.h" #include "via_tex.h" #include "via_span.h" -#include "via_tris.h" -#include "via_ioctl.h" #include "via_screen.h" -#include "via_fb.h" #include "via_dri.h" #include "GL/internal/dri_interface.h" diff --git a/src/mesa/drivers/dri/unichrome/via_state.c b/src/mesa/drivers/dri/unichrome/via_state.c index 840e4e42da..e65f5fd60d 100644 --- a/src/mesa/drivers/dri/unichrome/via_state.c +++ b/src/mesa/drivers/dri/unichrome/via_state.c @@ -35,7 +35,6 @@ #include "via_context.h" #include "via_state.h" #include "via_tex.h" -#include "via_tris.h" #include "via_ioctl.h" #include "via_3d_reg.h" @@ -44,8 +43,6 @@ #include "tnl/tnl.h" #include "swrast_setup/swrast_setup.h" -#include "tnl/t_pipeline.h" - static GLuint ROP[16] = { HC_HROP_BLACK, /* GL_CLEAR 0 */ diff --git a/src/mesa/drivers/dri/unichrome/via_tex.c b/src/mesa/drivers/dri/unichrome/via_tex.c index 24924d2613..917f975466 100644 --- a/src/mesa/drivers/dri/unichrome/via_tex.c +++ b/src/mesa/drivers/dri/unichrome/via_tex.c @@ -37,14 +37,12 @@ #include "main/mipmap.h" #include "main/mm.h" #include "main/simple_list.h" -#include "main/texcompress.h" #include "main/texobj.h" #include "main/texstore.h" #include "via_context.h" #include "via_fb.h" #include "via_tex.h" -#include "via_state.h" #include "via_ioctl.h" #include "via_3d_reg.h" diff --git a/src/mesa/drivers/dri/unichrome/via_texcombine.c b/src/mesa/drivers/dri/unichrome/via_texcombine.c index b646897848..f87ba071f3 100644 --- a/src/mesa/drivers/dri/unichrome/via_texcombine.c +++ b/src/mesa/drivers/dri/unichrome/via_texcombine.c @@ -38,7 +38,6 @@ #include "main/enums.h" #include "via_context.h" -#include "via_state.h" #include "via_tex.h" #include "via_3d_reg.h" -- cgit v1.2.3 From e5da7b8548842500e751b133b96b28113fbe0d76 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 19 Jan 2010 05:39:18 -0800 Subject: softpipe: Fix vertex buffer memory leak. --- src/gallium/drivers/softpipe/sp_prim_vbuf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/drivers/softpipe/sp_prim_vbuf.c b/src/gallium/drivers/softpipe/sp_prim_vbuf.c index 7f573aef3c..43a0bd4415 100644 --- a/src/gallium/drivers/softpipe/sp_prim_vbuf.c +++ b/src/gallium/drivers/softpipe/sp_prim_vbuf.c @@ -526,6 +526,8 @@ static void sp_vbuf_destroy(struct vbuf_render *vbr) { struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr); + if(cvbr->vertex_buffer) + align_free(cvbr->vertex_buffer); sp_setup_destroy_context(cvbr->setup); FREE(cvbr); } -- cgit v1.2.3 From 5e870f4fe9e71b7f467f2a0b03934352f90846cc Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 19 Jan 2010 06:12:10 -0800 Subject: wgl: Don't export pure-stencil pixel formats. They cause DCT's conform to always fail. --- src/gallium/state_trackers/wgl/stw_pixelformat.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gallium/state_trackers/wgl/stw_pixelformat.c b/src/gallium/state_trackers/wgl/stw_pixelformat.c index 7abe5d9f7f..c310c78ccf 100644 --- a/src/gallium/state_trackers/wgl/stw_pixelformat.c +++ b/src/gallium/state_trackers/wgl/stw_pixelformat.c @@ -94,8 +94,6 @@ stw_pf_depth_stencil[] = { { PIPE_FORMAT_Z24X8_UNORM, {24, 0} }, { PIPE_FORMAT_X8Z24_UNORM, {24, 0} }, { PIPE_FORMAT_Z16_UNORM, {16, 0} }, - /* pure stencil */ - { PIPE_FORMAT_S8_UNORM, { 0, 8} }, /* combined depth-stencil */ { PIPE_FORMAT_S8Z24_UNORM, {24, 8} }, { PIPE_FORMAT_Z24S8_UNORM, {24, 8} } -- cgit v1.2.3 From 7a39a5c1cb5087a1b8247f9bed59bf9374717cb3 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 19 Jan 2010 06:13:44 -0800 Subject: wgl: Check for PIPE_TEXTURE_USAGE_DISPLAY_TARGET support in exported color pixel formats. Since all formats we export have PFD_DRAW_TO_WINDOW flag. --- src/gallium/state_trackers/wgl/stw_pixelformat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/wgl/stw_pixelformat.c b/src/gallium/state_trackers/wgl/stw_pixelformat.c index c310c78ccf..95e1957e07 100644 --- a/src/gallium/state_trackers/wgl/stw_pixelformat.c +++ b/src/gallium/state_trackers/wgl/stw_pixelformat.c @@ -219,7 +219,8 @@ stw_pixelformat_init( void ) const struct stw_pf_color_info *color = &stw_pf_color[j]; if(!screen->is_format_supported(screen, color->format, PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) + PIPE_TEXTURE_USAGE_RENDER_TARGET | + PIPE_TEXTURE_USAGE_DISPLAY_TARGET, 0)) continue; for(k = 0; k < Elements(stw_pf_doublebuffer); ++k) { -- cgit v1.2.3 From e88294328cb71dc32941556da5bd4ed40e8b95f1 Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Sat, 16 Jan 2010 23:19:19 -0800 Subject: glx: Set GL context to null in __glXSetCurrentContextNull __glXSetCurrentContextNull currently does not set the GL context to null in the direct rendering case. This can result in a segfault trying to flush an invalid old context in glXMakeCurrent. This fixes a crash starting the Unigine demos (they still don't work due to missing extensions though). Signed-off-by: Brian Paul --- src/glx/x11/glxcurrent.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glx/x11/glxcurrent.c b/src/glx/x11/glxcurrent.c index fae1bd9fa6..50de7d612b 100644 --- a/src/glx/x11/glxcurrent.c +++ b/src/glx/x11/glxcurrent.c @@ -162,6 +162,7 @@ __glXSetCurrentContextNull(void) __glXSetCurrentContext(&dummyContext); #ifdef GLX_DIRECT_RENDERING _glapi_set_dispatch(NULL); /* no-op functions */ + _glapi_set_context(NULL); #endif } -- cgit v1.2.3 From 116a02be2264807dafb5fdfd4e3c913bb728c11f Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Mon, 11 Jan 2010 11:41:47 +1000 Subject: st/dri: update dri2 drawables when viewport is changed Fixes gnome-shell on nouveau, as well as window resize with various other applications. Signed-off-by: Ben Skeggs --- src/gallium/include/pipe/p_screen.h | 5 +++++ src/gallium/state_trackers/dri/dri_drawable.c | 8 ++++++++ src/gallium/state_trackers/dri/dri_drawable.h | 3 +++ src/gallium/state_trackers/dri/dri_screen.c | 1 + src/mesa/state_tracker/st_cb_viewport.c | 4 ++-- 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h index f0a4de5df3..b8e001a6b0 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -266,6 +266,11 @@ struct pipe_screen { void (*video_surface_destroy)( struct pipe_video_surface *vsfc ); + /** + * Do any special operations to ensure buffer size is correct + */ + void (*update_buffer)( struct pipe_screen *ws, + void *context_private ); /** * Do any special operations to ensure frontbuffer contents are diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 99dc022549..c20b71e958 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -271,6 +271,14 @@ void dri2_set_tex_buffer(__DRIcontext *pDRICtx, GLint target, dri2_set_tex_buffer2(pDRICtx, target, GLX_TEXTURE_FORMAT_RGBA_EXT, dPriv); } +void +dri_update_buffer(struct pipe_screen *screen, void *context_private) +{ + struct dri_context *ctx = (struct dri_context *)context_private; + + dri_get_buffers(ctx->dPriv); +} + void dri_flush_frontbuffer(struct pipe_screen *screen, struct pipe_surface *surf, void *context_private) diff --git a/src/gallium/state_trackers/dri/dri_drawable.h b/src/gallium/state_trackers/dri/dri_drawable.h index b910930db4..a0fb05d7b2 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.h +++ b/src/gallium/state_trackers/dri/dri_drawable.h @@ -80,6 +80,9 @@ dri_create_buffer(__DRIscreenPrivate * sPriv, __DRIdrawablePrivate * dPriv, const __GLcontextModes * visual, boolean isPixmap); +void +dri_update_buffer(struct pipe_screen *screen, void *context_private); + void dri_flush_frontbuffer(struct pipe_screen *screen, struct pipe_surface *surf, void *context_private); diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index d95c62745e..25c392e849 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -310,6 +310,7 @@ dri_init_screen2(__DRIscreenPrivate * sPriv) } /* We need to hook in here */ + screen->pipe_screen->update_buffer = dri_update_buffer; screen->pipe_screen->flush_frontbuffer = dri_flush_frontbuffer; driParseOptionInfo(&screen->optionCache, diff --git a/src/mesa/state_tracker/st_cb_viewport.c b/src/mesa/state_tracker/st_cb_viewport.c index 9450b3a45b..d8bd24405c 100644 --- a/src/mesa/state_tracker/st_cb_viewport.c +++ b/src/mesa/state_tracker/st_cb_viewport.c @@ -40,8 +40,8 @@ static void st_viewport(GLcontext * ctx, GLint x, GLint y, { struct st_context *st = ctx->st; - if (st->pipe->winsys && st->pipe->winsys->update_buffer) - st->pipe->winsys->update_buffer( st->pipe->winsys, + if (st->pipe->screen && st->pipe->screen->update_buffer) + st->pipe->screen->update_buffer( st->pipe->screen, st->pipe->priv ); } -- cgit v1.2.3 From a5fb5d6a54195d19942482873d0738eaade9e986 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 19 Jan 2010 16:46:28 +0000 Subject: st/drm: Expose kernel driver name Based on patch by Chia-I Wu Expose the name of the kernel driver as accepted by drmOpenByName. --- src/gallium/drivers/trace/tr_drm.c | 1 + src/gallium/include/state_tracker/drm_api.h | 5 +++++ src/gallium/winsys/drm/intel/gem/intel_drm_api.c | 1 + src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c | 1 + src/gallium/winsys/drm/radeon/core/radeon_drm.c | 1 + src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c | 1 + 6 files changed, 10 insertions(+) diff --git a/src/gallium/drivers/trace/tr_drm.c b/src/gallium/drivers/trace/tr_drm.c index 48d1c4051c..e7ca3a86ea 100644 --- a/src/gallium/drivers/trace/tr_drm.c +++ b/src/gallium/drivers/trace/tr_drm.c @@ -173,6 +173,7 @@ trace_drm_create(struct drm_api *api) if (!tr_api) goto error; + tr_api->base.driver_name = api->driver_name; tr_api->base.create_screen = trace_drm_create_screen; tr_api->base.create_context = trace_drm_create_context; tr_api->base.texture_from_shared_handle = trace_drm_texture_from_shared_handle; diff --git a/src/gallium/include/state_tracker/drm_api.h b/src/gallium/include/state_tracker/drm_api.h index 4d1259e1ee..78882f3aa7 100644 --- a/src/gallium/include/state_tracker/drm_api.h +++ b/src/gallium/include/state_tracker/drm_api.h @@ -28,6 +28,11 @@ struct drm_create_screen_arg { struct drm_api { + /** + * Kernel driver name, as accepted by drmOpenByName. + */ + const char *driver_name; + /** * Special buffer functions */ diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_api.c b/src/gallium/winsys/drm/intel/gem/intel_drm_api.c index 5ed2a10af1..89b72fd613 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_drm_api.c +++ b/src/gallium/winsys/drm/intel/gem/intel_drm_api.c @@ -195,6 +195,7 @@ destroy(struct drm_api *api) struct drm_api intel_drm_api = { + .driver_name = "i915", .create_context = intel_drm_create_context, .create_screen = intel_drm_create_screen, .texture_from_shared_handle = intel_drm_texture_from_shared_handle, diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c index 317dc44d22..6fccc358e9 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c @@ -252,6 +252,7 @@ nouveau_drm_handle_from_pt(struct drm_api *api, struct pipe_screen *pscreen, } struct drm_api drm_api_hooks = { + .driver_name = "nouveau", .create_screen = nouveau_drm_create_screen, .create_context = nouveau_drm_create_context, .texture_from_shared_handle = nouveau_drm_pt_from_name, diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c index 69f14e54f2..4d962c3abc 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c @@ -176,6 +176,7 @@ static boolean radeon_local_handle_from_texture(struct drm_api *api, } struct drm_api drm_api_hooks = { + .driver_name = "radeon", .create_screen = radeon_create_screen, .create_context = radeon_create_context, .texture_from_shared_handle = radeon_texture_from_shared_handle, diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c index 7c47d434f0..dbbe1701f1 100644 --- a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c +++ b/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c @@ -375,6 +375,7 @@ static struct dri1_api dri1_api_hooks = { }; static struct drm_api vmw_drm_api_hooks = { + .driver_name = "vmwgfx", .create_screen = vmw_drm_create_screen, .create_context = vmw_drm_create_context, .texture_from_shared_handle = vmw_drm_texture_from_handle, -- cgit v1.2.3 From 65354a7e3d8fd094837b7a999e8975dcfbd9d9c9 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 19 Jan 2010 17:14:19 +0000 Subject: st/xorg: Pass kernel driver name to drmOpen --- src/gallium/state_trackers/xorg/xorg_driver.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index b02fe68f31..ed185d314f 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -206,10 +206,19 @@ drv_init_drm(ScrnInfoPtr pScrn) ms->PciInfo->dev, ms->PciInfo->func ); - ms->fd = drmOpen(NULL, BusID); - if (ms->fd < 0) - return FALSE; + ms->api = drm_api_create(); + ms->fd = drmOpen(ms->api ? ms->api->driver_name : NULL, BusID); + + if (ms->fd >= 0) + return TRUE; + + if (ms->api->destroy) + ms->api->destroy(ms->api); + + ms->api = NULL; + + return FALSE; } return TRUE; @@ -229,7 +238,6 @@ drv_init_resource_management(ScrnInfoPtr pScrn) if (ms->screen || ms->kms) return TRUE; - ms->api = drm_api_create(); if (ms->api) { ms->screen = ms->api->create_screen(ms->api, ms->fd, NULL); -- cgit v1.2.3 From aec3fe82e490efa36c432b2f43cbeebefa91e88f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 19 Jan 2010 11:14:00 -0700 Subject: softpipe: remove redundant assignments We initialized width/height/depth from pt->width0/height0/depth0 above. --- src/gallium/drivers/softpipe/sp_texture.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index a9436a3394..fae72c81aa 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -57,13 +57,8 @@ softpipe_texture_layout(struct pipe_screen *screen, unsigned width = pt->width0; unsigned height = pt->height0; unsigned depth = pt->depth0; - unsigned buffer_size = 0; - pt->width0 = width; - pt->height0 = height; - pt->depth0 = depth; - for (level = 0; level <= pt->last_level; level++) { spt->stride[level] = util_format_get_stride(pt->format, width); -- cgit v1.2.3 From adda7f3215a0f749751977cbbb6cef67f7163be5 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 16 Jan 2010 18:34:23 -0800 Subject: Check if gcc supports -fvisibility=hidden before adding to CFLAGS Signed-off-by: Alan Coopersmith --- configure.ac | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d01d0f1884..f121002d4b 100644 --- a/configure.ac +++ b/configure.ac @@ -96,7 +96,14 @@ esac dnl Add flags for gcc and g++ if test "x$GCC" = xyes; then - CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math -fvisibility=hidden" + CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -std=c99 -ffast-math" + + # Enable -fvisibility=hidden if using a gcc that supports it + save_CFLAGS="$CFLAGS" + AC_MSG_CHECKING([whether $(CC) supports -fvisibility=hidden]) + CFLAGS="$CFLAGS -fvisibility=hidden" + AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]), + [CFLAGS="$save_CFLAGS" ; AC_MSG_RESULT([no])]); # Work around aliasing bugs - developers should comment this out CFLAGS="$CFLAGS -fno-strict-aliasing" -- cgit v1.2.3 From a7aaf052f935cb51b7b616a7a764c57fc01b2821 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 16 Jan 2010 20:21:35 -0800 Subject: Sun compilers now support some gcc __attribute__ values Sun cc 5.9 and later (__SUNPRO_C >= 0x590) support __attribute__ calls for aligned, always_inline, noinline, pure, const, and malloc. This commit includes updates to files that were regenerated by gl_XML.py after adding the __SUNPRO_C checks to it Signed-off-by: Alan Coopersmith Signed-off-by: Brian Paul --- include/GL/gl.h | 3 ++- src/egl/main/eglcompiler.h | 3 ++- src/gallium/include/pipe/p_compiler.h | 5 +++-- src/glx/x11/indirect.c | 2 +- src/glx/x11/indirect.h | 4 ++-- src/glx/x11/indirect_size.c | 4 ++-- src/glx/x11/indirect_size.h | 4 ++-- src/mesa/glapi/gl_XML.py | 6 +++--- src/mesa/glapi/glapitemp.h | 2 +- src/mesa/main/compiler.h | 3 ++- 10 files changed, 20 insertions(+), 16 deletions(-) diff --git a/include/GL/gl.h b/include/GL/gl.h index c163171dc7..36153b159b 100644 --- a/include/GL/gl.h +++ b/include/GL/gl.h @@ -67,7 +67,8 @@ #elif defined(__CYGWIN__) && defined(USE_OPENGL32) /* use native windows opengl32 */ # define GLAPI extern # define GLAPIENTRY __stdcall -#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 +#elif (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303) \ + || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) # define GLAPI __attribute__((visibility("default"))) # define GLAPIENTRY #endif /* WIN32 && !CYGWIN */ diff --git a/src/egl/main/eglcompiler.h b/src/egl/main/eglcompiler.h index f7c93f14ce..5a3fb49ac2 100644 --- a/src/egl/main/eglcompiler.h +++ b/src/egl/main/eglcompiler.h @@ -64,7 +64,8 @@ /** * Function visibility */ -#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 +#if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303) \ + || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) # define PUBLIC __attribute__((visibility("default"))) #else # define PUBLIC diff --git a/src/gallium/include/pipe/p_compiler.h b/src/gallium/include/pipe/p_compiler.h index 819f27f6df..272d0308cc 100644 --- a/src/gallium/include/pipe/p_compiler.h +++ b/src/gallium/include/pipe/p_compiler.h @@ -104,7 +104,8 @@ typedef unsigned char boolean; /* Function visibility */ #ifndef PUBLIC -# if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 +# if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303) \ + || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) # define PUBLIC __attribute__((visibility("default"))) # else # define PUBLIC @@ -140,7 +141,7 @@ typedef unsigned char boolean; /* Macros for data alignment. */ -#if defined(__GNUC__) +#if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) /* See http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Type-Attributes.html */ #define PIPE_ALIGN_TYPE(_alignment, _type) _type __attribute__((aligned(_alignment))) diff --git a/src/glx/x11/indirect.c b/src/glx/x11/indirect.c index ea90ce4463..262637a947 100644 --- a/src/glx/x11/indirect.c +++ b/src/glx/x11/indirect.c @@ -47,7 +47,7 @@ # else # define FASTCALL # endif -# if defined(__GNUC__) +# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) # define NOINLINE __attribute__((noinline)) # else # define NOINLINE diff --git a/src/glx/x11/indirect.h b/src/glx/x11/indirect.h index 19a8c0d134..9e73b33818 100644 --- a/src/glx/x11/indirect.h +++ b/src/glx/x11/indirect.h @@ -37,7 +37,7 @@ * \author Ian Romanick */ -# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) +# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))) && defined(__ELF__) # define HIDDEN __attribute__((visibility("hidden"))) # else # define HIDDEN @@ -47,7 +47,7 @@ # else # define FASTCALL # endif -# if defined(__GNUC__) +# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) # define NOINLINE __attribute__((noinline)) # else # define NOINLINE diff --git a/src/glx/x11/indirect_size.c b/src/glx/x11/indirect_size.c index cdaf02ffe6..f8541b5758 100644 --- a/src/glx/x11/indirect_size.c +++ b/src/glx/x11/indirect_size.c @@ -29,7 +29,7 @@ #include #include "indirect_size.h" -# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) # define PURE __attribute__((pure)) # else # define PURE @@ -41,7 +41,7 @@ # define FASTCALL # endif -# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) +# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))) && defined(__ELF__) # define INTERNAL __attribute__((visibility("internal"))) # else # define INTERNAL diff --git a/src/glx/x11/indirect_size.h b/src/glx/x11/indirect_size.h index 9ba0bd6907..af0919f964 100644 --- a/src/glx/x11/indirect_size.h +++ b/src/glx/x11/indirect_size.h @@ -36,7 +36,7 @@ * \author Ian Romanick */ -# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) # define PURE __attribute__((pure)) # else # define PURE @@ -48,7 +48,7 @@ # define FASTCALL # endif -# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) +# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))) && defined(__ELF__) # define INTERNAL __attribute__((visibility("internal"))) # else # define INTERNAL diff --git a/src/mesa/glapi/gl_XML.py b/src/mesa/glapi/gl_XML.py index b98919134f..ec3c2917f6 100644 --- a/src/mesa/glapi/gl_XML.py +++ b/src/mesa/glapi/gl_XML.py @@ -184,7 +184,7 @@ class gl_print_base: The name is also added to the file's undef_list. """ self.undef_list.append("PURE") - print """# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) + print """# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) # define PURE __attribute__((pure)) # else # define PURE @@ -224,7 +224,7 @@ class gl_print_base: """ self.undef_list.append(S) - print """# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) + print """# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))) && defined(__ELF__) # define %s __attribute__((visibility("%s"))) # else # define %s @@ -244,7 +244,7 @@ class gl_print_base: """ self.undef_list.append("NOINLINE") - print """# if defined(__GNUC__) + print """# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) # define NOINLINE __attribute__((noinline)) # else # define NOINLINE diff --git a/src/mesa/glapi/glapitemp.h b/src/mesa/glapi/glapitemp.h index 96b2ac7268..c0a947432a 100644 --- a/src/mesa/glapi/glapitemp.h +++ b/src/mesa/glapi/glapitemp.h @@ -27,7 +27,7 @@ */ -# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) +# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))) && defined(__ELF__) # define HIDDEN __attribute__((visibility("hidden"))) # else # define HIDDEN diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h index 4eb249b4af..9eab1ead24 100644 --- a/src/mesa/main/compiler.h +++ b/src/mesa/main/compiler.h @@ -173,7 +173,8 @@ extern "C" { * We also need to define a USED attribute, so the optimizer doesn't * inline a static function that we later use in an alias. - ajax */ -#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 +#if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303) \ + || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) # define PUBLIC __attribute__((visibility("default"))) # define USED __attribute__((used)) #else -- cgit v1.2.3 From 7d4e674b212c9dc6408c13913a399bd4a2b9a1e3 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 19 Jan 2010 10:55:21 -0800 Subject: intel: Use the new DRI2 flush invalidate entrypoint to signal frame done. Previously for frame throttling we would wait on the first batch after a swap before emitting another swap, because we had no hook after a swap was emitted. This meant that if an app managed to squeeze everything it for a frame had into one batch, it would lock-step with the GPU. With the swapbuffers changes, we now have the entrypoint we want. This takes the WoW intro screen from 25% GPU idle and visibly jerky to 4-5% GPU idle and rather smooth. Other apps such as OpenArena have run into this problem as well. --- src/mesa/drivers/dri/intel/intel_context.c | 20 -------------------- src/mesa/drivers/dri/intel/intel_screen.c | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 3f6634c65a..d52fe2eef2 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -506,27 +506,7 @@ intelFlush(GLcontext * ctx) static void intel_glFlush(GLcontext *ctx) { - struct intel_context *intel = intel_context(ctx); - intel_flush(ctx, GL_TRUE); - - /* We're using glFlush as an indicator that a frame is done, which is - * what DRI2 does before calling SwapBuffers (and means we should catch - * people doing front-buffer rendering, as well).. - * - * Wait for the swapbuffers before the one we just emitted, so we don't - * get too many swaps outstanding for apps that are GPU-heavy but not - * CPU-heavy. - * - * Unfortunately, we don't have a handle to the batch containing the swap, - * and getting our hands on that doesn't seem worth it, so we just us the - * first batch we emitted after the last swap. - */ - if (intel->first_post_swapbuffers_batch != NULL) { - drm_intel_bo_wait_rendering(intel->first_post_swapbuffers_batch); - drm_intel_bo_unreference(intel->first_post_swapbuffers_batch); - intel->first_post_swapbuffers_batch = NULL; - } } void diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index e240957197..6c2cb3b57e 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -128,8 +128,29 @@ intelDRI2Flush(__DRIdrawable *drawable) static void intelDRI2FlushInvalidate(__DRIdrawable *drawable) { + struct intel_context *intel = drawable->driContextPriv->driverPrivate; + intelDRI2Flush(drawable); drawable->validBuffers = GL_FALSE; + + /* We're using FlushInvalidate as an indicator that a frame is + * done. It's only called immediately after SwapBuffers, so it + * won't affect front-buffer rendering or applications explicitly + * managing swap regions using MESA_copy_buffer. + * + * Wait for the swapbuffers before the one we just emitted, so we don't + * get too many swaps outstanding for apps that are GPU-heavy but not + * CPU-heavy. + * + * Unfortunately, we don't have a handle to the batch containing the swap, + * and getting our hands on that doesn't seem worth it, so we just use the + * first batch we emitted after the last swap. + */ + if (intel->first_post_swapbuffers_batch != NULL) { + drm_intel_bo_wait_rendering(intel->first_post_swapbuffers_batch); + drm_intel_bo_unreference(intel->first_post_swapbuffers_batch); + intel->first_post_swapbuffers_batch = NULL; + } } static const struct __DRI2flushExtensionRec intelFlushExtension = { -- cgit v1.2.3 From 62a96f74c9a1fd07301d349e4181a7212fc7d45c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 18 Jan 2010 13:27:47 -0800 Subject: i965: Allow for variable-sized auxdata in the state cache. Everything has been constant-sized until now, but constant buffer handling changes will make us want some additional variable sized array. --- src/mesa/drivers/dri/i965/brw_cc.c | 3 +- src/mesa/drivers/dri/i965/brw_clip.c | 15 ++- src/mesa/drivers/dri/i965/brw_clip_state.c | 3 +- src/mesa/drivers/dri/i965/brw_context.h | 1 - src/mesa/drivers/dri/i965/brw_gs.c | 13 +- src/mesa/drivers/dri/i965/brw_gs_state.c | 3 +- src/mesa/drivers/dri/i965/brw_sf.c | 13 +- src/mesa/drivers/dri/i965/brw_sf_state.c | 3 +- src/mesa/drivers/dri/i965/brw_state.h | 30 +++-- src/mesa/drivers/dri/i965/brw_state_cache.c | 158 ++++++++--------------- src/mesa/drivers/dri/i965/brw_vs.c | 13 +- src/mesa/drivers/dri/i965/brw_vs_state.c | 3 +- src/mesa/drivers/dri/i965/brw_vs_surface_state.c | 3 +- src/mesa/drivers/dri/i965/brw_wm.c | 13 +- src/mesa/drivers/dri/i965/brw_wm_sampler_state.c | 3 +- src/mesa/drivers/dri/i965/brw_wm_state.c | 3 +- src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 12 +- 17 files changed, 124 insertions(+), 168 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_cc.c b/src/mesa/drivers/dri/i965/brw_cc.c index bac1c3a49c..016f27a6a3 100644 --- a/src/mesa/drivers/dri/i965/brw_cc.c +++ b/src/mesa/drivers/dri/i965/brw_cc.c @@ -295,8 +295,7 @@ cc_unit_create_from_key(struct brw_context *brw, struct brw_cc_unit_key *key) bo = brw_upload_cache(&brw->cache, BRW_CC_UNIT, key, sizeof(*key), &brw->cc.vp_bo, 1, - &cc, sizeof(cc), - NULL, NULL); + &cc, sizeof(cc)); /* Emit CC viewport relocation */ dri_bo_emit_reloc(bo, diff --git a/src/mesa/drivers/dri/i965/brw_clip.c b/src/mesa/drivers/dri/i965/brw_clip.c index af1d975de9..d3275c7a89 100644 --- a/src/mesa/drivers/dri/i965/brw_clip.c +++ b/src/mesa/drivers/dri/i965/brw_clip.c @@ -130,13 +130,14 @@ static void compile_clip_prog( struct brw_context *brw, /* Upload */ dri_bo_unreference(brw->clip.prog_bo); - brw->clip.prog_bo = brw_upload_cache( &brw->cache, - BRW_CLIP_PROG, - &c.key, sizeof(c.key), - NULL, 0, - program, program_size, - &c.prog_data, - &brw->clip.prog_data ); + brw->clip.prog_bo = brw_upload_cache_with_auxdata(&brw->cache, + BRW_CLIP_PROG, + &c.key, sizeof(c.key), + NULL, 0, + program, program_size, + &c.prog_data, + sizeof(c.prog_data), + &brw->clip.prog_data); } /* Calculate interpolants for triangle and line rasterization. diff --git a/src/mesa/drivers/dri/i965/brw_clip_state.c b/src/mesa/drivers/dri/i965/brw_clip_state.c index c8f24a94e4..22df7722b6 100644 --- a/src/mesa/drivers/dri/i965/brw_clip_state.c +++ b/src/mesa/drivers/dri/i965/brw_clip_state.c @@ -143,8 +143,7 @@ clip_unit_create_from_key(struct brw_context *brw, bo = brw_upload_cache(&brw->cache, BRW_CLIP_UNIT, key, sizeof(*key), &brw->clip.prog_bo, 1, - &clip, sizeof(clip), - NULL, NULL); + &clip, sizeof(clip)); /* Emit clip program relocation */ assert(brw->clip.prog_bo); diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 0dd3087143..21d82977b7 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -332,7 +332,6 @@ struct brw_cache { struct brw_cache_item **items; GLuint size, n_items; - GLuint aux_size[BRW_MAX_CACHE]; char *name[BRW_MAX_CACHE]; /* Record of the last BOs chosen for each cache_id. Used to set diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c index 1bc3eccf49..7261b316c1 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.c +++ b/src/mesa/drivers/dri/i965/brw_gs.c @@ -125,12 +125,13 @@ static void compile_gs_prog( struct brw_context *brw, /* Upload */ dri_bo_unreference(brw->gs.prog_bo); - brw->gs.prog_bo = brw_upload_cache( &brw->cache, BRW_GS_PROG, - &c.key, sizeof(c.key), - NULL, 0, - program, program_size, - &c.prog_data, - &brw->gs.prog_data ); + brw->gs.prog_bo = brw_upload_cache_with_auxdata(&brw->cache, BRW_GS_PROG, + &c.key, sizeof(c.key), + NULL, 0, + program, program_size, + &c.prog_data, + sizeof(c.prog_data), + &brw->gs.prog_data); } static const GLenum gs_prim[GL_POLYGON+1] = { diff --git a/src/mesa/drivers/dri/i965/brw_gs_state.c b/src/mesa/drivers/dri/i965/brw_gs_state.c index 1af5790a67..7d5a944bf7 100644 --- a/src/mesa/drivers/dri/i965/brw_gs_state.c +++ b/src/mesa/drivers/dri/i965/brw_gs_state.c @@ -108,8 +108,7 @@ gs_unit_create_from_key(struct brw_context *brw, struct brw_gs_unit_key *key) bo = brw_upload_cache(&brw->cache, BRW_GS_UNIT, key, sizeof(*key), &brw->gs.prog_bo, 1, - &gs, sizeof(gs), - NULL, NULL); + &gs, sizeof(gs)); if (key->prog_active) { /* Emit GS program relocation */ diff --git a/src/mesa/drivers/dri/i965/brw_sf.c b/src/mesa/drivers/dri/i965/brw_sf.c index 968890f7fb..8e6839b812 100644 --- a/src/mesa/drivers/dri/i965/brw_sf.c +++ b/src/mesa/drivers/dri/i965/brw_sf.c @@ -117,12 +117,13 @@ static void compile_sf_prog( struct brw_context *brw, /* Upload */ dri_bo_unreference(brw->sf.prog_bo); - brw->sf.prog_bo = brw_upload_cache( &brw->cache, BRW_SF_PROG, - &c.key, sizeof(c.key), - NULL, 0, - program, program_size, - &c.prog_data, - &brw->sf.prog_data ); + brw->sf.prog_bo = brw_upload_cache_with_auxdata(&brw->cache, BRW_SF_PROG, + &c.key, sizeof(c.key), + NULL, 0, + program, program_size, + &c.prog_data, + sizeof(c.prog_data), + &brw->sf.prog_data); } /* Calculate interpolants for triangle and line rasterization. diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c b/src/mesa/drivers/dri/i965/brw_sf_state.c index 09223b7cfb..b9b42cd6d5 100644 --- a/src/mesa/drivers/dri/i965/brw_sf_state.c +++ b/src/mesa/drivers/dri/i965/brw_sf_state.c @@ -309,8 +309,7 @@ sf_unit_create_from_key(struct brw_context *brw, struct brw_sf_unit_key *key, bo = brw_upload_cache(&brw->cache, BRW_SF_UNIT, key, sizeof(*key), reloc_bufs, 2, - &sf, sizeof(sf), - NULL, NULL); + &sf, sizeof(sf)); /* STATE_PREFETCH command description describes this state as being * something loaded through the GPE (L2 ISC), so it's INSTRUCTION domain. diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h index 9c9d145c4b..536fe8b249 100644 --- a/src/mesa/drivers/dri/i965/brw_state.h +++ b/src/mesa/drivers/dri/i965/brw_state.h @@ -124,16 +124,26 @@ dri_bo *brw_cache_data(struct brw_cache *cache, dri_bo **reloc_bufs, GLuint nr_reloc_bufs); -dri_bo *brw_upload_cache( struct brw_cache *cache, - enum brw_cache_id cache_id, - const void *key, - GLuint key_sz, - dri_bo **reloc_bufs, - GLuint nr_reloc_bufs, - const void *data, - GLuint data_sz, - const void *aux, - void *aux_return ); +drm_intel_bo *brw_upload_cache(struct brw_cache *cache, + enum brw_cache_id cache_id, + const void *key, + GLuint key_sz, + dri_bo **reloc_bufs, + GLuint nr_reloc_bufs, + const void *data, + GLuint data_sz); + +drm_intel_bo *brw_upload_cache_with_auxdata(struct brw_cache *cache, + enum brw_cache_id cache_id, + const void *key, + GLuint key_sz, + dri_bo **reloc_bufs, + GLuint nr_reloc_bufs, + const void *data, + GLuint data_sz, + const void *aux, + GLuint aux_sz, + void *aux_return); dri_bo *brw_search_cache( struct brw_cache *cache, enum brw_cache_id cache_id, diff --git a/src/mesa/drivers/dri/i965/brw_state_cache.c b/src/mesa/drivers/dri/i965/brw_state_cache.c index e4c9ba7d87..502ad0bd6c 100644 --- a/src/mesa/drivers/dri/i965/brw_state_cache.c +++ b/src/mesa/drivers/dri/i965/brw_state_cache.c @@ -200,22 +200,22 @@ brw_search_cache(struct brw_cache *cache, } -dri_bo * -brw_upload_cache( struct brw_cache *cache, - enum brw_cache_id cache_id, - const void *key, - GLuint key_size, - dri_bo **reloc_bufs, - GLuint nr_reloc_bufs, - const void *data, - GLuint data_size, - const void *aux, - void *aux_return ) +drm_intel_bo * +brw_upload_cache_with_auxdata(struct brw_cache *cache, + enum brw_cache_id cache_id, + const void *key, + GLuint key_size, + dri_bo **reloc_bufs, + GLuint nr_reloc_bufs, + const void *data, + GLuint data_size, + const void *aux, + GLuint aux_size, + void *aux_return) { struct brw_cache_item *item = CALLOC_STRUCT(brw_cache_item); GLuint hash = hash_key(key, key_size, reloc_bufs, nr_reloc_bufs); GLuint relocs_size = nr_reloc_bufs * sizeof(dri_bo *); - GLuint aux_size = cache->aux_size[cache_id]; void *tmp; dri_bo *bo; int i; @@ -229,7 +229,7 @@ brw_upload_cache( struct brw_cache *cache, tmp = _mesa_malloc(key_size + aux_size + relocs_size); memcpy(tmp, key, key_size); - memcpy(tmp + key_size, aux, cache->aux_size[cache_id]); + memcpy(tmp + key_size, aux, aux_size); memcpy(tmp + key_size + aux_size, reloc_bufs, relocs_size); for (i = 0; i < nr_reloc_bufs; i++) { if (reloc_bufs[i] != NULL) @@ -255,7 +255,6 @@ brw_upload_cache( struct brw_cache *cache, cache->n_items++; if (aux_return) { - assert(cache->aux_size[cache_id]); *(void **)aux_return = (void *)((char *)item->key + item->key_size); } @@ -272,6 +271,23 @@ brw_upload_cache( struct brw_cache *cache, return bo; } +drm_intel_bo * +brw_upload_cache(struct brw_cache *cache, + enum brw_cache_id cache_id, + const void *key, + GLuint key_size, + dri_bo **reloc_bufs, + GLuint nr_reloc_bufs, + const void *data, + GLuint data_size) +{ + return brw_upload_cache_with_auxdata(cache, cache_id, + key, key_size, + reloc_bufs, nr_reloc_bufs, + data, data_size, + NULL, 0, + NULL); +} /** * Wrapper around brw_cache_data_sz using the cache_id's canonical key size. @@ -306,8 +322,7 @@ brw_cache_data(struct brw_cache *cache, bo = brw_upload_cache(cache, cache_id, data, data_size, reloc_bufs, nr_reloc_bufs, - data, data_size, - NULL, NULL); + data, data_size); return bo; } @@ -321,11 +336,9 @@ enum pool_type { static void brw_init_cache_id(struct brw_cache *cache, const char *name, - enum brw_cache_id id, - GLuint aux_size) + enum brw_cache_id id) { cache->name[id] = strdup(name); - cache->aux_size[id] = aux_size; } @@ -341,80 +354,28 @@ brw_init_non_surface_cache(struct brw_context *brw) cache->items = (struct brw_cache_item **) _mesa_calloc(cache->size * sizeof(struct brw_cache_item)); - brw_init_cache_id(cache, - "CC_VP", - BRW_CC_VP, - 0); - - brw_init_cache_id(cache, - "CC_UNIT", - BRW_CC_UNIT, - 0); - - brw_init_cache_id(cache, - "WM_PROG", - BRW_WM_PROG, - sizeof(struct brw_wm_prog_data)); - - brw_init_cache_id(cache, - "SAMPLER_DEFAULT_COLOR", - BRW_SAMPLER_DEFAULT_COLOR, - 0); - - brw_init_cache_id(cache, - "SAMPLER", - BRW_SAMPLER, - 0); - - brw_init_cache_id(cache, - "WM_UNIT", - BRW_WM_UNIT, - 0); - - brw_init_cache_id(cache, - "SF_PROG", - BRW_SF_PROG, - sizeof(struct brw_sf_prog_data)); - - brw_init_cache_id(cache, - "SF_VP", - BRW_SF_VP, - 0); - - brw_init_cache_id(cache, - "SF_UNIT", - BRW_SF_UNIT, - 0); - - brw_init_cache_id(cache, - "VS_UNIT", - BRW_VS_UNIT, - 0); - - brw_init_cache_id(cache, - "VS_PROG", - BRW_VS_PROG, - sizeof(struct brw_vs_prog_data)); - - brw_init_cache_id(cache, - "CLIP_UNIT", - BRW_CLIP_UNIT, - 0); - - brw_init_cache_id(cache, - "CLIP_PROG", - BRW_CLIP_PROG, - sizeof(struct brw_clip_prog_data)); - - brw_init_cache_id(cache, - "GS_UNIT", - BRW_GS_UNIT, - 0); - - brw_init_cache_id(cache, - "GS_PROG", - BRW_GS_PROG, - sizeof(struct brw_gs_prog_data)); + brw_init_cache_id(cache, "CC_VP", BRW_CC_VP); + brw_init_cache_id(cache, "CC_UNIT", BRW_CC_UNIT); + brw_init_cache_id(cache, "WM_PROG", BRW_WM_PROG); + brw_init_cache_id(cache, "SAMPLER_DEFAULT_COLOR", BRW_SAMPLER_DEFAULT_COLOR); + brw_init_cache_id(cache, "SAMPLER", BRW_SAMPLER); + brw_init_cache_id(cache, "WM_UNIT", BRW_WM_UNIT); + brw_init_cache_id(cache, "SF_PROG", BRW_SF_PROG); + brw_init_cache_id(cache, "SF_VP", BRW_SF_VP); + + brw_init_cache_id(cache, "SF_UNIT", BRW_SF_UNIT); + + brw_init_cache_id(cache, "VS_UNIT", BRW_VS_UNIT); + + brw_init_cache_id(cache, "VS_PROG", BRW_VS_PROG); + + brw_init_cache_id(cache, "CLIP_UNIT", BRW_CLIP_UNIT); + + brw_init_cache_id(cache, "CLIP_PROG", BRW_CLIP_PROG); + + brw_init_cache_id(cache, "GS_UNIT", BRW_GS_UNIT); + + brw_init_cache_id(cache, "GS_PROG", BRW_GS_PROG); } @@ -430,15 +391,8 @@ brw_init_surface_cache(struct brw_context *brw) cache->items = (struct brw_cache_item **) _mesa_calloc(cache->size * sizeof(struct brw_cache_item)); - brw_init_cache_id(cache, - "SS_SURFACE", - BRW_SS_SURFACE, - 0); - - brw_init_cache_id(cache, - "SS_SURF_BIND", - BRW_SS_SURF_BIND, - 0); + brw_init_cache_id(cache, "SS_SURFACE", BRW_SS_SURFACE); + brw_init_cache_id(cache, "SS_SURF_BIND", BRW_SS_SURF_BIND); } diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c index fd055e225e..a66927235e 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.c +++ b/src/mesa/drivers/dri/i965/brw_vs.c @@ -74,12 +74,13 @@ static void do_vs_prog( struct brw_context *brw, program = brw_get_program(&c.func, &program_size); dri_bo_unreference(brw->vs.prog_bo); - brw->vs.prog_bo = brw_upload_cache( &brw->cache, BRW_VS_PROG, - &c.key, sizeof(c.key), - NULL, 0, - program, program_size, - &c.prog_data, - &brw->vs.prog_data ); + brw->vs.prog_bo = brw_upload_cache_with_auxdata(&brw->cache, BRW_VS_PROG, + &c.key, sizeof(c.key), + NULL, 0, + program, program_size, + &c.prog_data, + sizeof(c.prog_data), + &brw->vs.prog_data); } diff --git a/src/mesa/drivers/dri/i965/brw_vs_state.c b/src/mesa/drivers/dri/i965/brw_vs_state.c index 345ffa7ee1..fd9f2fee42 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_state.c +++ b/src/mesa/drivers/dri/i965/brw_vs_state.c @@ -164,8 +164,7 @@ vs_unit_create_from_key(struct brw_context *brw, struct brw_vs_unit_key *key) bo = brw_upload_cache(&brw->cache, BRW_VS_UNIT, key, sizeof(*key), &brw->vs.prog_bo, 1, - &vs, sizeof(vs), - NULL, NULL); + &vs, sizeof(vs)); /* Emit VS program relocation */ dri_bo_emit_reloc(bo, diff --git a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c index 3bc9840a97..3f6e16fcb0 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c @@ -168,8 +168,7 @@ brw_vs_get_binding_table(struct brw_context *brw) bind_bo = brw_upload_cache( &brw->surface_cache, BRW_SS_SURF_BIND, NULL, 0, brw->vs.surf_bo, BRW_VS_MAX_SURF, - data, data_size, - NULL, NULL); + data, data_size); /* Emit binding table relocations to surface state */ for (i = 0; i < BRW_VS_MAX_SURF; i++) { diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c index 6895f64410..fb24379c90 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.c +++ b/src/mesa/drivers/dri/i965/brw_wm.c @@ -199,12 +199,13 @@ static void do_wm_prog( struct brw_context *brw, program = brw_get_program(&c->func, &program_size); dri_bo_unreference(brw->wm.prog_bo); - brw->wm.prog_bo = brw_upload_cache( &brw->cache, BRW_WM_PROG, - &c->key, sizeof(c->key), - NULL, 0, - program, program_size, - &c->prog_data, - &brw->wm.prog_data ); + brw->wm.prog_bo = brw_upload_cache_with_auxdata(&brw->cache, BRW_WM_PROG, + &c->key, sizeof(c->key), + NULL, 0, + program, program_size, + &c->prog_data, + sizeof(c->prog_data), + &brw->wm.prog_data); } diff --git a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c index ad267a4e6a..87387b1e2d 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c @@ -326,8 +326,7 @@ static void upload_wm_samplers( struct brw_context *brw ) brw->wm.sampler_bo = brw_upload_cache(&brw->cache, BRW_SAMPLER, &key, sizeof(key), brw->wm.sdc_bo, key.sampler_count, - &sampler, sizeof(sampler), - NULL, NULL); + &sampler, sizeof(sampler)); /* Emit SDC relocations */ for (i = 0; i < BRW_MAX_TEX_UNIT; i++) { diff --git a/src/mesa/drivers/dri/i965/brw_wm_state.c b/src/mesa/drivers/dri/i965/brw_wm_state.c index d3373ea79e..a7f80db554 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_state.c @@ -210,8 +210,7 @@ wm_unit_create_from_key(struct brw_context *brw, struct brw_wm_unit_key *key, bo = brw_upload_cache(&brw->cache, BRW_WM_UNIT, key, sizeof(*key), reloc_bufs, 3, - &wm, sizeof(wm), - NULL, NULL); + &wm, sizeof(wm)); /* Emit WM program relocation */ dri_bo_emit_reloc(bo, diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index f26cfabb7d..357c8c90de 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -256,8 +256,7 @@ brw_create_texture_surface( struct brw_context *brw, bo = brw_upload_cache(&brw->surface_cache, BRW_SS_SURFACE, key, sizeof(*key), &key->bo, key->bo ? 1 : 0, - &surf, sizeof(surf), - NULL, NULL); + &surf, sizeof(surf)); if (key->bo) { /* Emit relocation to surface contents */ @@ -351,8 +350,7 @@ brw_create_constant_surface( struct brw_context *brw, bo = brw_upload_cache(&brw->surface_cache, BRW_SS_SURFACE, key, sizeof(*key), &key->bo, key->bo ? 1 : 0, - &surf, sizeof(surf), - NULL, NULL); + &surf, sizeof(surf)); if (key->bo) { /* Emit relocation to surface contents. Section 5.1.1 of the gen4 @@ -653,8 +651,7 @@ brw_update_renderbuffer_surface(struct brw_context *brw, BRW_SS_SURFACE, &key, sizeof(key), ®ion_bo, 1, - &surf, sizeof(surf), - NULL, NULL); + &surf, sizeof(surf)); if (region_bo != NULL) { /* We might sample from it, and we might render to it, so flag * them both. We might be able to figure out from other state @@ -701,8 +698,7 @@ brw_wm_get_binding_table(struct brw_context *brw) bind_bo = brw_upload_cache( &brw->surface_cache, BRW_SS_SURF_BIND, NULL, 0, brw->wm.surf_bo, brw->wm.nr_surfaces, - data, data_size, - NULL, NULL); + data, data_size); /* Emit binding table relocations to surface state */ for (i = 0; i < BRW_WM_MAX_SURF; i++) { -- cgit v1.2.3 From fb4901593c9495714d3f54920a28c271852e2112 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 18 Jan 2010 15:12:40 -0800 Subject: i965: Upload as many VS constants as possible through the push constants. The pull constants require sending out to an overworked shared unit and waiting for a response, while push constants are nicely loaded in for us at thread dispatch time. By putting things we access in every VS invocation there, ETQW performance improved by 2.5% +/- 1.6% (n=6). --- src/mesa/drivers/dri/i965/brw_context.h | 1 + src/mesa/drivers/dri/i965/brw_curbe.c | 25 ++++++++++++----- src/mesa/drivers/dri/i965/brw_vs.c | 20 +++++++++++++- src/mesa/drivers/dri/i965/brw_vs.h | 1 + src/mesa/drivers/dri/i965/brw_vs_emit.c | 49 ++++++++++++++++++++++++++++++--- 5 files changed, 84 insertions(+), 12 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 21d82977b7..cbf022ca0c 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -582,6 +582,7 @@ struct brw_context struct { struct brw_vs_prog_data *prog_data; + int8_t *constant_map; /* variable array following prog_data */ dri_bo *prog_bo; dri_bo *state_bo; diff --git a/src/mesa/drivers/dri/i965/brw_curbe.c b/src/mesa/drivers/dri/i965/brw_curbe.c index 190310afbb..22e3e732f4 100644 --- a/src/mesa/drivers/dri/i965/brw_curbe.c +++ b/src/mesa/drivers/dri/i965/brw_curbe.c @@ -256,13 +256,24 @@ static void prepare_constant_buffer(struct brw_context *brw) */ _mesa_load_state_parameters(ctx, vp->program.Base.Parameters); - /* XXX just use a memcpy here */ - for (i = 0; i < nr; i++) { - const GLfloat *value = vp->program.Base.Parameters->ParameterValues[i]; - buf[offset + i * 4 + 0] = value[0]; - buf[offset + i * 4 + 1] = value[1]; - buf[offset + i * 4 + 2] = value[2]; - buf[offset + i * 4 + 3] = value[3]; + if (vp->use_const_buffer) { + /* Load the subset of push constants that will get used when + * we also have a pull constant buffer. + */ + for (i = 0; i < vp->program.Base.Parameters->NumParameters; i++) { + if (brw->vs.constant_map[i] != -1) { + assert(brw->vs.constant_map[i] <= nr); + memcpy(buf + offset + brw->vs.constant_map[i] * 4, + vp->program.Base.Parameters->ParameterValues[i], + 4 * sizeof(float)); + } + } + } else { + for (i = 0; i < nr; i++) { + memcpy(buf + offset + i * 4, + vp->program.Base.Parameters->ParameterValues[i], + 4 * sizeof(float)); + } } } diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c index a66927235e..44b085e214 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.c +++ b/src/mesa/drivers/dri/i965/brw_vs.c @@ -35,6 +35,7 @@ #include "brw_util.h" #include "brw_state.h" #include "shader/prog_print.h" +#include "shader/prog_parameter.h" @@ -42,9 +43,11 @@ static void do_vs_prog( struct brw_context *brw, struct brw_vertex_program *vp, struct brw_vs_prog_key *key ) { + GLcontext *ctx = &brw->intel.ctx; GLuint program_size; const GLuint *program; struct brw_vs_compile c; + int aux_size; memset(&c, 0, sizeof(c)); memcpy(&c.key, key, sizeof(*key)); @@ -73,13 +76,26 @@ static void do_vs_prog( struct brw_context *brw, */ program = brw_get_program(&c.func, &program_size); + /* We upload from &c.prog_data including the constant_map assuming + * they're packed together. It would be nice to have a + * compile-time assert macro here. + */ + assert(c.constant_map == (int8_t *)&c.prog_data + + sizeof(c.prog_data)); + assert(ctx->Const.VertexProgram.MaxNativeParameters == + ARRAY_SIZE(c.constant_map)); + + aux_size = sizeof(c.prog_data); + if (c.vp->use_const_buffer) + aux_size += c.vp->program.Base.Parameters->NumParameters; + dri_bo_unreference(brw->vs.prog_bo); brw->vs.prog_bo = brw_upload_cache_with_auxdata(&brw->cache, BRW_VS_PROG, &c.key, sizeof(c.key), NULL, 0, program, program_size, &c.prog_data, - sizeof(c.prog_data), + aux_size, &brw->vs.prog_data); } @@ -110,6 +126,8 @@ static void brw_upload_vs_prog(struct brw_context *brw) &brw->vs.prog_data); if (brw->vs.prog_bo == NULL) do_vs_prog(brw, vp, &key); + brw->vs.constant_map = ((int8_t *)brw->vs.prog_data + + sizeof(*brw->vs.prog_data)); } diff --git a/src/mesa/drivers/dri/i965/brw_vs.h b/src/mesa/drivers/dri/i965/brw_vs.h index 249d48bc18..95e0501b1e 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.h +++ b/src/mesa/drivers/dri/i965/brw_vs.h @@ -51,6 +51,7 @@ struct brw_vs_compile { struct brw_compile func; struct brw_vs_prog_key key; struct brw_vs_prog_data prog_data; + int8_t constant_map[1024]; struct brw_vertex_program *vp; diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c index 7a252dde6c..52cc04fee8 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c @@ -104,9 +104,47 @@ static void brw_vs_alloc_regs( struct brw_vs_compile *c ) /* Vertex program parameters from curbe: */ if (c->vp->use_const_buffer) { - /* get constants from a real constant buffer */ - c->prog_data.curb_read_length = 0; - c->prog_data.nr_params = 4; /* XXX 0 causes a bug elsewhere... */ + int max_constant = BRW_MAX_GRF - 20 - c->vp->program.Base.NumTemporaries; + int constant = 0; + + /* We've got more constants than we can load with the push + * mechanism. This is often correlated with reladdr loads where + * we should probably be using a pull mechanism anyway to avoid + * excessive reading. However, the pull mechanism is slow in + * general. So, we try to allocate as many non-reladdr-loaded + * constants through the push buffer as we can before giving up. + */ + memset(c->constant_map, -1, c->vp->program.Base.Parameters->NumParameters); + for (i = 0; + i < c->vp->program.Base.NumInstructions && constant < max_constant; + i++) { + struct prog_instruction *inst = &c->vp->program.Base.Instructions[i]; + int arg; + + for (arg = 0; arg < 3 && constant < max_constant; arg++) { + if ((inst->SrcReg[arg].File != PROGRAM_STATE_VAR && + inst->SrcReg[arg].File != PROGRAM_CONSTANT && + inst->SrcReg[arg].File != PROGRAM_UNIFORM && + inst->SrcReg[arg].File != PROGRAM_ENV_PARAM && + inst->SrcReg[arg].File != PROGRAM_LOCAL_PARAM) || + inst->SrcReg[arg].RelAddr) + continue; + + if (c->constant_map[inst->SrcReg[arg].Index] == -1) { + c->constant_map[inst->SrcReg[arg].Index] = constant++; + } + } + } + + for (i = 0; i < constant; i++) { + c->regs[PROGRAM_STATE_VAR][i] = stride( brw_vec4_grf(reg+i/2, + (i%2) * 4), + 0, 4, 1); + } + reg += (constant + 1) / 2; + c->prog_data.curb_read_length = reg - 1; + /* XXX 0 causes a bug elsewhere... */ + c->prog_data.nr_params = MAX2(constant * 4, 4); } else { /* use a section of the GRF for constants */ @@ -955,7 +993,10 @@ get_src_reg( struct brw_vs_compile *c, case PROGRAM_ENV_PARAM: case PROGRAM_LOCAL_PARAM: if (c->vp->use_const_buffer) { - if (relAddr) + if (!relAddr && c->constant_map[index] != -1) { + assert(c->regs[PROGRAM_STATE_VAR][c->constant_map[index]].nr != 0); + return c->regs[PROGRAM_STATE_VAR][c->constant_map[index]]; + } else if (relAddr) return get_reladdr_constant(c, inst, argIndex); else return get_constant(c, inst, argIndex); -- cgit v1.2.3 From d1cefabf98ac25832a420b245549492cc3bc6b4d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 22 Nov 2009 04:30:01 +0100 Subject: i965: Remove obsolete comment about the state atoms. --- src/mesa/drivers/dri/i965/brw_state_upload.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c index af8dfb4c15..d7d4d876de 100644 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c @@ -36,13 +36,7 @@ #include "intel_batchbuffer.h" #include "intel_buffers.h" -/* This is used to initialize brw->state.atoms[]. We could use this - * list directly except for a single atom, brw_constant_buffer, which - * has a .dirty value which changes according to the parameters of the - * current fragment and vertex programs, and so cannot be a static - * value. - */ -const struct brw_tracked_state *atoms[] = +static const struct brw_tracked_state *atoms[] = { &brw_check_fallback, -- cgit v1.2.3 From a45f24c0a407980b906394d2cfc1e1dc2fdf43cd Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 23 Nov 2009 19:09:48 -0800 Subject: i965: Improve the hashing of brw_state_cache keys to include the cache_id. No measurable difference on cairoperf. --- src/mesa/drivers/dri/i965/brw_state_cache.c | 86 ++++++++++++++++++----------- 1 file changed, 54 insertions(+), 32 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_state_cache.c b/src/mesa/drivers/dri/i965/brw_state_cache.c index 502ad0bd6c..5fc47b0420 100644 --- a/src/mesa/drivers/dri/i965/brw_state_cache.c +++ b/src/mesa/drivers/dri/i965/brw_state_cache.c @@ -71,25 +71,23 @@ static GLuint -hash_key(const void *key, GLuint key_size, - dri_bo **reloc_bufs, GLuint nr_reloc_bufs) +hash_key(struct brw_cache_item *item) { - GLuint *ikey = (GLuint *)key; - GLuint hash = 0, i; + GLuint *ikey = (GLuint *)item->key; + GLuint hash = item->cache_id, i; - assert(key_size % 4 == 0); + assert(item->key_size % 4 == 0); /* I'm sure this can be improved on: */ - for (i = 0; i < key_size/4; i++) { + for (i = 0; i < item->key_size/4; i++) { hash ^= ikey[i]; hash = (hash << 5) | (hash >> 27); } /* Include the BO pointers as key data as well */ - ikey = (GLuint *)reloc_bufs; - key_size = nr_reloc_bufs * sizeof(dri_bo *); - for (i = 0; i < key_size/4; i++) { + ikey = (GLuint *)item->reloc_bufs; + for (i = 0; i < item->nr_reloc_bufs * sizeof(drm_intel_bo *) / 4; i++) { hash ^= ikey[i]; hash = (hash << 5) | (hash >> 27); } @@ -114,11 +112,22 @@ update_cache_last(struct brw_cache *cache, enum brw_cache_id cache_id, cache->brw->state.dirty.cache |= 1 << cache_id; } +static int +brw_cache_item_equals(const struct brw_cache_item *a, + const struct brw_cache_item *b) +{ + return a->cache_id == b->cache_id && + a->hash == b->hash && + a->key_size == b->key_size && + (memcmp(a->key, b->key, a->key_size) == 0) && + a->nr_reloc_bufs == b->nr_reloc_bufs && + (memcmp(a->reloc_bufs, b->reloc_bufs, + a->nr_reloc_bufs * sizeof(dri_bo *)) == 0); +} static struct brw_cache_item * -search_cache(struct brw_cache *cache, enum brw_cache_id cache_id, - GLuint hash, const void *key, GLuint key_size, - dri_bo **reloc_bufs, GLuint nr_reloc_bufs) +search_cache(struct brw_cache *cache, GLuint hash, + struct brw_cache_item *lookup) { struct brw_cache_item *c; @@ -133,13 +142,7 @@ search_cache(struct brw_cache *cache, enum brw_cache_id cache_id, #endif for (c = cache->items[hash % cache->size]; c; c = c->next) { - if (c->cache_id == cache_id && - c->hash == hash && - c->key_size == key_size && - memcmp(c->key, key, key_size) == 0 && - c->nr_reloc_bufs == nr_reloc_bufs && - memcmp(c->reloc_bufs, reloc_bufs, - nr_reloc_bufs * sizeof(dri_bo *)) == 0) + if (brw_cache_item_equals(lookup, c)) return c; } @@ -182,10 +185,18 @@ brw_search_cache(struct brw_cache *cache, void *aux_return) { struct brw_cache_item *item; - GLuint hash = hash_key(key, key_size, reloc_bufs, nr_reloc_bufs); + struct brw_cache_item lookup; + GLuint hash; - item = search_cache(cache, cache_id, hash, key, key_size, - reloc_bufs, nr_reloc_bufs); + lookup.cache_id = cache_id; + lookup.key = key; + lookup.key_size = key_size; + lookup.reloc_bufs = reloc_bufs; + lookup.nr_reloc_bufs = nr_reloc_bufs; + hash = hash_key(&lookup); + lookup.hash = hash; + + item = search_cache(cache, hash, &lookup); if (item == NULL) return NULL; @@ -214,12 +225,20 @@ brw_upload_cache_with_auxdata(struct brw_cache *cache, void *aux_return) { struct brw_cache_item *item = CALLOC_STRUCT(brw_cache_item); - GLuint hash = hash_key(key, key_size, reloc_bufs, nr_reloc_bufs); + GLuint hash; GLuint relocs_size = nr_reloc_bufs * sizeof(dri_bo *); void *tmp; dri_bo *bo; int i; + item->cache_id = cache_id; + item->key = key; + item->key_size = key_size; + item->reloc_bufs = reloc_bufs; + item->nr_reloc_bufs = nr_reloc_bufs; + hash = hash_key(item); + item->hash = hash; + /* Create the buffer object to contain the data */ bo = dri_bo_alloc(cache->brw->intel.bufmgr, cache->name[cache_id], data_size, 1 << 6); @@ -236,12 +255,8 @@ brw_upload_cache_with_auxdata(struct brw_cache *cache, dri_bo_reference(reloc_bufs[i]); } - item->cache_id = cache_id; item->key = tmp; - item->hash = hash; - item->key_size = key_size; item->reloc_bufs = tmp + key_size + aux_size; - item->nr_reloc_bufs = nr_reloc_bufs; item->bo = bo; dri_bo_reference(bo); @@ -308,11 +323,18 @@ brw_cache_data(struct brw_cache *cache, GLuint nr_reloc_bufs) { dri_bo *bo; - struct brw_cache_item *item; - GLuint hash = hash_key(data, data_size, reloc_bufs, nr_reloc_bufs); - - item = search_cache(cache, cache_id, hash, data, data_size, - reloc_bufs, nr_reloc_bufs); + struct brw_cache_item *item, lookup; + GLuint hash; + + lookup.cache_id = cache_id; + lookup.key = data; + lookup.key_size = data_size; + lookup.reloc_bufs = reloc_bufs; + lookup.nr_reloc_bufs = nr_reloc_bufs; + hash = hash_key(&lookup); + lookup.hash = hash; + + item = search_cache(cache, hash, &lookup); if (item) { update_cache_last(cache, cache_id, item->bo); dri_bo_reference(item->bo); -- cgit v1.2.3 From 8f7dfe302557eca6a48d03abc38bfc32dbe2ad8f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 20 Nov 2009 03:10:57 +0100 Subject: intel: Remove dead note_fence vtbl hook. --- src/mesa/drivers/dri/i965/brw_context.h | 1 - src/mesa/drivers/dri/i965/brw_state_upload.c | 1 - src/mesa/drivers/dri/i965/brw_vtbl.c | 7 ------- src/mesa/drivers/dri/intel/intel_context.h | 1 - 4 files changed, 10 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index cbf022ca0c..79818b92b7 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -131,7 +131,6 @@ struct brw_context; #define BRW_NEW_WM_INPUT_DIMENSIONS 0x100 #define BRW_NEW_PSP 0x800 #define BRW_NEW_WM_SURFACES 0x1000 -#define BRW_NEW_FENCE 0x2000 #define BRW_NEW_INDICES 0x4000 #define BRW_NEW_VERTICES 0x8000 /** diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c index d7d4d876de..0ecbef1ef9 100644 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c @@ -202,7 +202,6 @@ static struct dirty_bit_map brw_bits[] = { DEFINE_BIT(BRW_NEW_CONTEXT), DEFINE_BIT(BRW_NEW_WM_INPUT_DIMENSIONS), DEFINE_BIT(BRW_NEW_PSP), - DEFINE_BIT(BRW_NEW_FENCE), DEFINE_BIT(BRW_NEW_INDICES), DEFINE_BIT(BRW_NEW_INDEX_BUFFER), DEFINE_BIT(BRW_NEW_VERTICES), diff --git a/src/mesa/drivers/dri/i965/brw_vtbl.c b/src/mesa/drivers/dri/i965/brw_vtbl.c index 72749b3859..bb7a293812 100644 --- a/src/mesa/drivers/dri/i965/brw_vtbl.c +++ b/src/mesa/drivers/dri/i965/brw_vtbl.c @@ -172,12 +172,6 @@ static void brw_new_batch( struct intel_context *intel ) } } - -static void brw_note_fence( struct intel_context *intel, GLuint fence ) -{ - brw_context(&intel->ctx)->state.dirty.brw |= BRW_NEW_FENCE; -} - static void brw_invalidate_state( struct intel_context *intel, GLuint new_state ) { /* nothing */ @@ -193,7 +187,6 @@ void brwInitVtbl( struct brw_context *brw ) brw->intel.vtbl.update_texture_state = 0; brw->intel.vtbl.invalidate_state = brw_invalidate_state; - brw->intel.vtbl.note_fence = brw_note_fence; brw->intel.vtbl.new_batch = brw_new_batch; brw->intel.vtbl.finish_batch = brw_finish_batch; brw->intel.vtbl.destroy = brw_destroy_context; diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h index 07207bfbec..6ba281cc14 100644 --- a/src/mesa/drivers/dri/intel/intel_context.h +++ b/src/mesa/drivers/dri/intel/intel_context.h @@ -107,7 +107,6 @@ struct intel_context void (*finish_batch) (struct intel_context * intel); void (*new_batch) (struct intel_context * intel); void (*emit_invarient_state) (struct intel_context * intel); - void (*note_fence) (struct intel_context *intel, GLuint fence); void (*update_texture_state) (struct intel_context * intel); void (*render_start) (struct intel_context * intel); -- cgit v1.2.3 From c78fe6e050c311a3d53ccb091686a65ee6933a90 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 19 Jan 2010 23:29:56 +0100 Subject: st/xorg: Don't leak BusID buffer --- src/gallium/state_trackers/xorg/xorg_driver.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index ed185d314f..b74953e543 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -209,6 +209,7 @@ drv_init_drm(ScrnInfoPtr pScrn) ms->api = drm_api_create(); ms->fd = drmOpen(ms->api ? ms->api->driver_name : NULL, BusID); + xfree(BusID); if (ms->fd >= 0) return TRUE; -- cgit v1.2.3 From bea9ed4dc6abbcf2b95f5f55554800d4f41da47a Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 19 Jan 2010 22:26:01 +0100 Subject: svga: Do a more propper creation of textures from handles --- src/gallium/drivers/svga/svga_screen_texture.c | 68 +++++++++++++++++++++- src/gallium/drivers/svga/svga_winsys.h | 6 ++ .../winsys/drm/vmware/core/vmw_screen_dri.c | 68 ++++++---------------- 3 files changed, 90 insertions(+), 52 deletions(-) diff --git a/src/gallium/drivers/svga/svga_screen_texture.c b/src/gallium/drivers/svga/svga_screen_texture.c index 1eb03db280..9ad4edafef 100644 --- a/src/gallium/drivers/svga/svga_screen_texture.c +++ b/src/gallium/drivers/svga/svga_screen_texture.c @@ -308,11 +308,19 @@ svga_texture_create(struct pipe_screen *screen, tex->key.numFaces = 1; } + tex->key.cachable = 1; + if(templat->tex_usage & PIPE_TEXTURE_USAGE_SAMPLER) tex->key.flags |= SVGA3D_SURFACE_HINT_TEXTURE; - if(templat->tex_usage & PIPE_TEXTURE_USAGE_PRIMARY) + if(templat->tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) { + tex->key.cachable = 0; + } + + if(templat->tex_usage & PIPE_TEXTURE_USAGE_PRIMARY) { tex->key.flags |= SVGA3D_SURFACE_HINT_SCANOUT; + tex->key.cachable = 0; + } /* * XXX: Never pass the SVGA3D_SURFACE_HINT_RENDERTARGET hint. Mesa cannot @@ -335,8 +343,6 @@ svga_texture_create(struct pipe_screen *screen, if(tex->key.format == SVGA3D_FORMAT_INVALID) goto error2; - tex->key.cachable = 1; - SVGA_DBG(DEBUG_DMA, "surface_create for texture\n", tex->handle); tex->handle = svga_screen_surface_create(svgascreen, &tex->key); if (tex->handle) @@ -418,6 +424,62 @@ svga_texture_blanket(struct pipe_screen * screen, } +struct pipe_texture * +svga_screen_texture_wrap_surface(struct pipe_screen *screen, + struct pipe_texture *base, + enum SVGA3dSurfaceFormat format, + struct svga_winsys_surface *srf) +{ + struct svga_texture *tex; + assert(screen); + + /* Only supports one type */ + if (base->target != PIPE_TEXTURE_2D || + base->last_level != 0 || + base->depth[0] != 1) { + return NULL; + } + + if (!srf) + return NULL; + + if (svga_translate_format(base->format) != format) { + unsigned f1 = svga_translate_format(base->format); + unsigned f2 = format; + + /* It's okay for XRGB and ARGB or depth with/out stencil to get mixed up */ + if ( !( (f1 == SVGA3D_X8R8G8B8 && f2 == SVGA3D_A8R8G8B8) || + (f1 == SVGA3D_A8R8G8B8 && f2 == SVGA3D_X8R8G8B8) || + (f1 == SVGA3D_Z_D24X8 && f2 == SVGA3D_Z_D24S8) ) ) { + debug_printf("%s wrong format %u != %u\n", __FUNCTION__, f1, f2); + return NULL; + } + } + + tex = CALLOC_STRUCT(svga_texture); + if (!tex) + return NULL; + + tex->base = *base; + + + if (format == 1) + tex->base.format = PIPE_FORMAT_X8R8G8B8_UNORM; + else if (format == 2) + tex->base.format = PIPE_FORMAT_A8R8G8B8_UNORM; + + pipe_reference_init(&tex->base.reference, 1); + tex->base.screen = screen; + + SVGA_DBG(DEBUG_DMA, "wrap surface sid %p\n", srf); + + tex->key.cachable = 0; + tex->handle = srf; + + return &tex->base; +} + + static void svga_texture_destroy(struct pipe_texture *pt) { diff --git a/src/gallium/drivers/svga/svga_winsys.h b/src/gallium/drivers/svga/svga_winsys.h index 59f299c185..27b99fe4c1 100644 --- a/src/gallium/drivers/svga/svga_winsys.h +++ b/src/gallium/drivers/svga/svga_winsys.h @@ -296,4 +296,10 @@ svga_screen_buffer_from_texture(struct pipe_texture *texture, struct pipe_buffer **buffer, unsigned *stride); +struct pipe_texture * +svga_screen_texture_wrap_surface(struct pipe_screen *screen, + struct pipe_texture *base, + enum SVGA3dSurfaceFormat format, + struct svga_winsys_surface *srf); + #endif /* SVGA_WINSYS_H_ */ diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c index dbbe1701f1..60491cb519 100644 --- a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c +++ b/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c @@ -237,22 +237,19 @@ vmw_dri1_present_locked(struct pipe_context *locked_pipe, vmw_svga_winsys_surface_reference(&vsrf, NULL); } -/** - * FIXME: We'd probably want to cache these buffers in the - * screen, based on handle. - */ - -static struct pipe_buffer * -vmw_drm_buffer_from_handle(struct drm_api *drm_api, - struct pipe_screen *screen, - const char *name, - unsigned handle) +static struct pipe_texture * +vmw_drm_texture_from_handle(struct drm_api *drm_api, + struct pipe_screen *screen, + struct pipe_texture *templat, + const char *name, + unsigned stride, + unsigned handle) { struct vmw_svga_winsys_surface *vsrf; struct svga_winsys_surface *ssrf; struct vmw_winsys_screen *vws = vmw_winsys_screen(svga_winsys_screen(screen)); - struct pipe_buffer *buf; + struct pipe_texture *tex; union drm_vmw_surface_reference_arg arg; struct drm_vmw_surface_arg *req = &arg.req; struct drm_vmw_surface_create_req *rep = &arg.rep; @@ -299,43 +296,28 @@ vmw_drm_buffer_from_handle(struct drm_api *drm_api, pipe_reference_init(&vsrf->refcnt, 1); p_atomic_set(&vsrf->validated, 0); + vsrf->screen = vws; vsrf->sid = handle; ssrf = svga_winsys_surface(vsrf); - buf = svga_screen_buffer_wrap_surface(screen, rep->format, ssrf); - if (!buf) + tex = svga_screen_texture_wrap_surface(screen, templat, rep->format, ssrf); + if (!tex) vmw_svga_winsys_surface_reference(&vsrf, NULL); - return buf; + return tex; out_mip: vmw_ioctl_surface_destroy(vws, handle); return NULL; } -static struct pipe_texture * -vmw_drm_texture_from_handle(struct drm_api *drm_api, - struct pipe_screen *screen, - struct pipe_texture *templat, - const char *name, - unsigned stride, - unsigned handle) -{ - struct pipe_buffer *buffer; - buffer = vmw_drm_buffer_from_handle(drm_api, screen, name, handle); - - if (!buffer) - return NULL; - - return screen->texture_blanket(screen, templat, &stride, buffer); -} - static boolean -vmw_drm_handle_from_buffer(struct drm_api *drm_api, +vmw_drm_handle_from_texture(struct drm_api *drm_api, struct pipe_screen *screen, - struct pipe_buffer *buffer, + struct pipe_texture *texture, + unsigned *stride, unsigned *handle) { struct svga_winsys_surface *surface = - svga_screen_buffer_get_winsys_surface(buffer); + svga_screen_texture_get_winsys_surface(texture); struct vmw_svga_winsys_surface *vsrf; if (!surface) @@ -343,25 +325,13 @@ vmw_drm_handle_from_buffer(struct drm_api *drm_api, vsrf = vmw_svga_winsys_surface(surface); *handle = vsrf->sid; + *stride = pf_get_nblocksx(&texture->block, texture->width[0]) * + texture->block.size; + vmw_svga_winsys_surface_reference(&vsrf, NULL); return TRUE; } -static boolean -vmw_drm_handle_from_texture(struct drm_api *drm_api, - struct pipe_screen *screen, - struct pipe_texture *texture, - unsigned *stride, - unsigned *handle) -{ - struct pipe_buffer *buffer; - - if (!svga_screen_buffer_from_texture(texture, &buffer, stride)) - return FALSE; - - return vmw_drm_handle_from_buffer(drm_api, screen, buffer, handle); -} - static struct pipe_context* vmw_drm_create_context(struct drm_api *drm_api, struct pipe_screen *screen) -- cgit v1.2.3 From f542fde77effbc3c780940e139fc2572e818a179 Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sun, 10 Jan 2010 14:04:16 +0100 Subject: radeon: add blit function to vtbl --- src/mesa/drivers/dri/radeon/radeon_common_context.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.h b/src/mesa/drivers/dri/radeon/radeon_common_context.h index ab79d2dc0f..e397ee8c22 100644 --- a/src/mesa/drivers/dri/radeon/radeon_common_context.h +++ b/src/mesa/drivers/dri/radeon/radeon_common_context.h @@ -518,6 +518,26 @@ struct radeon_context { void (*free_context)(GLcontext *ctx); void (*emit_query_finish)(radeonContextPtr radeon); void (*update_scissor)(GLcontext *ctx); + unsigned (*blit)(GLcontext *ctx, + struct radeon_bo *src_bo, + intptr_t src_offset, + gl_format src_mesaformat, + unsigned src_pitch, + unsigned src_width, + unsigned src_height, + unsigned src_x_offset, + unsigned src_y_offset, + struct radeon_bo *dst_bo, + intptr_t dst_offset, + gl_format dst_mesaformat, + unsigned dst_pitch, + unsigned dst_width, + unsigned dst_height, + unsigned dst_x_offset, + unsigned dst_y_offset, + unsigned reg_width, + unsigned reg_height, + unsigned flip_y); } vtbl; }; -- cgit v1.2.3 From 9363a813f1393f7c41c7af961ffc26947ad92572 Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sun, 10 Jan 2010 13:59:39 +0100 Subject: r300: prepare for texcopy code sharing --- src/mesa/drivers/dri/r300/r300_blit.c | 54 +++++++++++++++++--------------- src/mesa/drivers/dri/r300/r300_blit.h | 40 +++++++++++------------ src/mesa/drivers/dri/r300/r300_context.c | 2 ++ src/mesa/drivers/dri/r300/r300_texcopy.c | 3 +- 4 files changed, 51 insertions(+), 48 deletions(-) diff --git a/src/mesa/drivers/dri/r300/r300_blit.c b/src/mesa/drivers/dri/r300/r300_blit.c index 2eec27e900..37e3f8aa00 100644 --- a/src/mesa/drivers/dri/r300/r300_blit.c +++ b/src/mesa/drivers/dri/r300/r300_blit.c @@ -519,29 +519,31 @@ static void emit_cb_setup(struct r300_context *r300, * @param[in] height region height * @param[in] flip_y set if y coords of the source image need to be flipped */ -GLboolean r300_blit(struct r300_context *r300, - struct radeon_bo *src_bo, - intptr_t src_offset, - gl_format src_mesaformat, - unsigned src_pitch, - unsigned src_width, - unsigned src_height, - unsigned src_x_offset, - unsigned src_y_offset, - struct radeon_bo *dst_bo, - intptr_t dst_offset, - gl_format dst_mesaformat, - unsigned dst_pitch, - unsigned dst_width, - unsigned dst_height, - unsigned dst_x_offset, - unsigned dst_y_offset, - unsigned reg_width, - unsigned reg_height, - unsigned flip_y) +unsigned r300_blit(GLcontext *ctx, + struct radeon_bo *src_bo, + intptr_t src_offset, + gl_format src_mesaformat, + unsigned src_pitch, + unsigned src_width, + unsigned src_height, + unsigned src_x_offset, + unsigned src_y_offset, + struct radeon_bo *dst_bo, + intptr_t dst_offset, + gl_format dst_mesaformat, + unsigned dst_pitch, + unsigned dst_width, + unsigned dst_height, + unsigned dst_x_offset, + unsigned dst_y_offset, + unsigned reg_width, + unsigned reg_height, + unsigned flip_y) { + r300ContextPtr r300 = R300_CONTEXT(ctx); + if (_mesa_get_format_bits(src_mesaformat, GL_DEPTH_BITS) > 0) - return GL_FALSE; + return 0; /* Make sure that colorbuffer has even width - hw limitation */ if (dst_pitch % 2 > 0) @@ -551,7 +553,7 @@ GLboolean r300_blit(struct r300_context *r300, * Looks like a hw limitation. */ if (dst_pitch < 32) - return GL_FALSE; + return 0; /* Need to clamp the region size to make sure * we don't read outside of the source buffer @@ -567,7 +569,7 @@ GLboolean r300_blit(struct r300_context *r300, reg_height = dst_height - dst_y_offset; if (src_bo == dst_bo) { - return GL_FALSE; + return 0; } if (0) { @@ -587,7 +589,7 @@ GLboolean r300_blit(struct r300_context *r300, radeonFlush(r300->radeon.glCtx); if (!validate_buffers(r300, src_bo, dst_bo)) - return GL_FALSE; + return 0; rcommonEnsureCmdBufSpace(&r300->radeon, 200, __FUNCTION__); @@ -618,5 +620,5 @@ GLboolean r300_blit(struct r300_context *r300, radeonFlush(r300->radeon.glCtx); - return GL_TRUE; -} \ No newline at end of file + return 1; +} diff --git a/src/mesa/drivers/dri/r300/r300_blit.h b/src/mesa/drivers/dri/r300/r300_blit.h index dc21e88098..735acaddd7 100644 --- a/src/mesa/drivers/dri/r300/r300_blit.h +++ b/src/mesa/drivers/dri/r300/r300_blit.h @@ -30,25 +30,25 @@ void r300_blit_init(struct r300_context *r300); -GLboolean r300_blit(struct r300_context *r300, - struct radeon_bo *src_bo, - intptr_t src_offset, - gl_format src_mesaformat, - unsigned src_pitch, - unsigned src_width, - unsigned src_height, - unsigned src_x_offset, - unsigned src_y_offset, - struct radeon_bo *dst_bo, - intptr_t dst_offset, - gl_format dst_mesaformat, - unsigned dst_pitch, - unsigned dst_width, - unsigned dst_height, - unsigned dst_x_offset, - unsigned dst_y_offset, - unsigned width, - unsigned height, - unsigned flip_y); +unsigned r300_blit(GLcontext *ctx, + struct radeon_bo *src_bo, + intptr_t src_offset, + gl_format src_mesaformat, + unsigned src_pitch, + unsigned src_width, + unsigned src_height, + unsigned src_x_offset, + unsigned src_y_offset, + struct radeon_bo *dst_bo, + intptr_t dst_offset, + gl_format dst_mesaformat, + unsigned dst_pitch, + unsigned dst_width, + unsigned dst_height, + unsigned dst_x_offset, + unsigned dst_y_offset, + unsigned reg_width, + unsigned reg_height, + unsigned flip_y); #endif // R300_BLIT_H \ No newline at end of file diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c index 1f6ccf6ddc..e449590fbb 100644 --- a/src/mesa/drivers/dri/r300/r300_context.c +++ b/src/mesa/drivers/dri/r300/r300_context.c @@ -326,6 +326,8 @@ static void r300_init_vtbl(radeonContextPtr radeon) radeon->vtbl.emit_query_finish = rv530_emit_query_finish_single_z; } else radeon->vtbl.emit_query_finish = r300_emit_query_finish; + + radeon->vtbl.blit = r300_blit; } static void r300InitConstValues(GLcontext *ctx, radeonScreenPtr screen) diff --git a/src/mesa/drivers/dri/r300/r300_texcopy.c b/src/mesa/drivers/dri/r300/r300_texcopy.c index ebc9c05b8a..716a38a0a4 100644 --- a/src/mesa/drivers/dri/r300/r300_texcopy.c +++ b/src/mesa/drivers/dri/r300/r300_texcopy.c @@ -34,7 +34,6 @@ #include "drivers/common/meta.h" #include "radeon_mipmap_tree.h" -#include "r300_blit.h" #include
// TODO: @@ -84,7 +83,7 @@ do_copy_texsubimage(GLcontext *ctx, } /* blit from src buffer to texture */ - return r300_blit(r300, rrb->bo, src_offset, rrb->base.Format, rrb->pitch/rrb->cpp, + return r300->radeon.vtbl.blit(ctx, rrb->bo, src_offset, rrb->base.Format, rrb->pitch/rrb->cpp, rrb->base.Width, rrb->base.Height, x, y, timg->mt->bo, dst_offset, timg->base.TexFormat, timg->base.Width, timg->base.Width, timg->base.Height, -- cgit v1.2.3 From 11affafc75525c50a2b4ffc9f91c1fe620d328fb Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sun, 10 Jan 2010 14:17:20 +0100 Subject: radeon: use mesa provided _mesa_tex_target_to_face function --- src/mesa/drivers/dri/radeon/radeon_texture.c | 21 +++------------------ src/mesa/drivers/dri/radeon/radeon_texture.h | 1 - 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c index 03178116c1..20a27ad9a7 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texture.c +++ b/src/mesa/drivers/dri/radeon/radeon_texture.c @@ -197,21 +197,6 @@ void radeonUnmapTexture(GLcontext *ctx, struct gl_texture_object *texObj) radeon_bo_unmap(t->mt->bo); } -GLuint radeon_face_for_target(GLenum target) -{ - switch (target) { - case GL_TEXTURE_CUBE_MAP_POSITIVE_X: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: - case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: - case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: - return (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X; - default: - return 0; - } -} - /** * Wraps Mesa's implementation to ensure that the base level image is mapped. * @@ -248,7 +233,7 @@ static void radeon_generate_mipmap(GLcontext *ctx, GLenum target, void radeonGenerateMipmap(GLcontext* ctx, GLenum target, struct gl_texture_object *texObj) { - GLuint face = radeon_face_for_target(target); + GLuint face = _mesa_tex_target_to_face(target); radeon_texture_image *baseimage = get_radeon_texture_image(texObj->Image[face][texObj->BaseLevel]); radeon_teximage_map(baseimage, GL_FALSE); @@ -710,7 +695,7 @@ static void radeon_teximage( radeon_texture_image* image = get_radeon_texture_image(texImage); GLint postConvWidth = width; GLint postConvHeight = height; - GLuint face = radeon_face_for_target(target); + GLuint face = _mesa_tex_target_to_face(target); { struct radeon_bo *bo; @@ -863,7 +848,7 @@ static void radeon_texsubimage(GLcontext* ctx, int dims, GLenum target, int leve if (RADEON_DEBUG & RADEON_TEXTURE) { fprintf(stderr, "radeon_texsubimage%dd: texObj %p, texImage %p, face %d, level %d\n", - dims, texObj, texImage, radeon_face_for_target(target), level); + dims, texObj, texImage, _mesa_tex_target_to_face(target), level); } t->validated = GL_FALSE; diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.h b/src/mesa/drivers/dri/radeon/radeon_texture.h index 906daf12d0..4ec6a2945f 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texture.h +++ b/src/mesa/drivers/dri/radeon/radeon_texture.h @@ -44,7 +44,6 @@ void radeonMapTexture(GLcontext *ctx, struct gl_texture_object *texObj); void radeonUnmapTexture(GLcontext *ctx, struct gl_texture_object *texObj); void radeonGenerateMipmap(GLcontext* ctx, GLenum target, struct gl_texture_object *texObj); int radeon_validate_texture_miptree(GLcontext * ctx, struct gl_texture_object *texObj); -GLuint radeon_face_for_target(GLenum target); gl_format radeonChooseTextureFormat_mesa(GLcontext * ctx, GLint internalFormat, -- cgit v1.2.3 From f2fea26269ac6b386f78fb68168fade4ae3290df Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sat, 16 Jan 2010 14:53:07 +0100 Subject: r300: fix Y coord flipping in accelerated blits --- src/mesa/drivers/dri/r300/r300_blit.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/mesa/drivers/dri/r300/r300_blit.c b/src/mesa/drivers/dri/r300/r300_blit.c index 37e3f8aa00..8a9c1c8beb 100644 --- a/src/mesa/drivers/dri/r300/r300_blit.c +++ b/src/mesa/drivers/dri/r300/r300_blit.c @@ -403,9 +403,8 @@ static void calc_tex_coords(float img_width, float img_height, buf[3] = buf[2] + reg_height / img_height; if (flip_y) { - float tmp = buf[2]; - buf[2] = 1.0 - buf[3]; - buf[3] = 1.0 - tmp; + buf[2] = 1.0 - buf[2]; + buf[3] = 1.0 - buf[3]; } } @@ -424,13 +423,13 @@ static void emit_draw_packet(struct r300_context *r300, flip_y, texcoords); float verts[] = { dst_x_offset, dst_y_offset, - texcoords[0], texcoords[3], - dst_x_offset, dst_y_offset + reg_height, texcoords[0], texcoords[2], + dst_x_offset, dst_y_offset + reg_height, + texcoords[0], texcoords[3], dst_x_offset + reg_width, dst_y_offset + reg_height, - texcoords[1], texcoords[2], + texcoords[1], texcoords[3], dst_x_offset + reg_width, dst_y_offset, - texcoords[1], texcoords[3] }; + texcoords[1], texcoords[2] }; BATCH_LOCALS(&r300->radeon); -- cgit v1.2.3 From acac99e35ac28e3d7209b6891dd197bf94055793 Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sat, 16 Jan 2010 15:21:52 +0100 Subject: r300: use nearest texture filtering for accelerated blits --- src/mesa/drivers/dri/r300/r300_blit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/r300/r300_blit.c b/src/mesa/drivers/dri/r300/r300_blit.c index 8a9c1c8beb..4f89a31472 100644 --- a/src/mesa/drivers/dri/r300/r300_blit.c +++ b/src/mesa/drivers/dri/r300/r300_blit.c @@ -150,8 +150,8 @@ static void r300_emit_tx_setup(struct r300_context *r300, (R300_TX_CLAMP_TO_EDGE << R300_TX_WRAP_T_SHIFT) | (R300_TX_CLAMP_TO_EDGE << R300_TX_WRAP_R_SHIFT) | R300_TX_MIN_FILTER_MIP_NONE | - R300_TX_MIN_FILTER_LINEAR | - R300_TX_MAG_FILTER_LINEAR | + R300_TX_MIN_FILTER_NEAREST | + R300_TX_MAG_FILTER_NEAREST | (0 << 28)); OUT_BATCH_REGVAL(R300_TX_FILTER1_0, 0); OUT_BATCH_REGVAL(R300_TX_SIZE_0, -- cgit v1.2.3 From f54e96c5976f0997dd3163ef027a44a3d79c43e2 Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Sat, 16 Jan 2010 22:44:30 +0100 Subject: r300: check if blitting for given format is supported earlier Prevents failing assertions at later stage. --- src/mesa/drivers/dri/r300/r300_blit.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/r300/r300_blit.c b/src/mesa/drivers/dri/r300/r300_blit.c index 4f89a31472..99068886b7 100644 --- a/src/mesa/drivers/dri/r300/r300_blit.c +++ b/src/mesa/drivers/dri/r300/r300_blit.c @@ -494,6 +494,27 @@ static void emit_cb_setup(struct r300_context *r300, END_BATCH(); } +static unsigned is_blit_supported(gl_format dst_format) +{ + switch (dst_format) { + case MESA_FORMAT_RGB565: + case MESA_FORMAT_ARGB1555: + case MESA_FORMAT_RGBA8888: + case MESA_FORMAT_RGBA8888_REV: + case MESA_FORMAT_ARGB8888: + case MESA_FORMAT_ARGB8888_REV: + case MESA_FORMAT_XRGB8888: + break; + default: + return 0; + } + + if (_mesa_get_format_bits(dst_format, GL_DEPTH_BITS) > 0) + return 0; + + return 1; +} + /** * Copy a region of [@a width x @a height] pixels from source buffer * to destination buffer. @@ -541,7 +562,7 @@ unsigned r300_blit(GLcontext *ctx, { r300ContextPtr r300 = R300_CONTEXT(ctx); - if (_mesa_get_format_bits(src_mesaformat, GL_DEPTH_BITS) > 0) + if (!is_blit_supported(dst_mesaformat)) return 0; /* Make sure that colorbuffer has even width - hw limitation */ -- cgit v1.2.3 From ac8afd401fa5840cf726184329dac75197a50c2e Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Mon, 18 Jan 2010 22:50:06 +0100 Subject: r600: prepare for some code sharing --- src/mesa/drivers/dri/r600/r600_blit.c | 3 ++- src/mesa/drivers/dri/r600/r600_blit.h | 2 +- src/mesa/drivers/dri/r600/r600_texcopy.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r600_blit.c b/src/mesa/drivers/dri/r600/r600_blit.c index 418544a08d..68324766c3 100644 --- a/src/mesa/drivers/dri/r600/r600_blit.c +++ b/src/mesa/drivers/dri/r600/r600_blit.c @@ -1559,7 +1559,7 @@ static GLboolean validate_buffers(context_t *rmesa, return GL_TRUE; } -GLboolean r600_blit(context_t *context, +GLboolean r600_blit(GLcontext *ctx, struct radeon_bo *src_bo, intptr_t src_offset, gl_format src_mesaformat, @@ -1580,6 +1580,7 @@ GLboolean r600_blit(context_t *context, unsigned h, unsigned flip_y) { + context_t *context = R700_CONTEXT(ctx); int id = 0; if (!is_blit_supported(dst_mesaformat)) diff --git a/src/mesa/drivers/dri/r600/r600_blit.h b/src/mesa/drivers/dri/r600/r600_blit.h index f30c13c288..97dc2e57ff 100644 --- a/src/mesa/drivers/dri/r600/r600_blit.h +++ b/src/mesa/drivers/dri/r600/r600_blit.h @@ -1,4 +1,4 @@ -GLboolean r600_blit(context_t *context, +GLboolean r600_blit(GLcontext *ctx, struct radeon_bo *src_bo, intptr_t src_offset, gl_format src_mesaformat, diff --git a/src/mesa/drivers/dri/r600/r600_texcopy.c b/src/mesa/drivers/dri/r600/r600_texcopy.c index 287a82ea8f..dcea6c06e4 100644 --- a/src/mesa/drivers/dri/r600/r600_texcopy.c +++ b/src/mesa/drivers/dri/r600/r600_texcopy.c @@ -85,7 +85,7 @@ do_copy_texsubimage(GLcontext *ctx, /* blit from src buffer to texture */ - return r600_blit(context, rrb->bo, src_offset, rrb->base.Format, rrb->pitch, + return r600_blit(ctx, rrb->bo, src_offset, rrb->base.Format, rrb->pitch, rrb->base.Width, rrb->base.Height, x, y, timg->mt->bo, dst_offset, timg->base.TexFormat, timg->mt->levels[level].rowstride, timg->base.Width, timg->base.Height, -- cgit v1.2.3 From 0174dac5f3bd47c0a2dcd40319bff288c83ee96a Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Mon, 18 Jan 2010 22:52:40 +0100 Subject: r300/r600: move some bo offsets checking to blit code In preperation for texcopy code sharing. --- src/mesa/drivers/dri/r300/r300_blit.c | 4 ++++ src/mesa/drivers/dri/r300/r300_texcopy.c | 4 ---- src/mesa/drivers/dri/r600/r600_blit.c | 4 ++++ src/mesa/drivers/dri/r600/r600_texcopy.c | 4 ---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mesa/drivers/dri/r300/r300_blit.c b/src/mesa/drivers/dri/r300/r300_blit.c index 99068886b7..e24c7955d4 100644 --- a/src/mesa/drivers/dri/r300/r300_blit.c +++ b/src/mesa/drivers/dri/r300/r300_blit.c @@ -592,6 +592,10 @@ unsigned r300_blit(GLcontext *ctx, return 0; } + if (src_offset % 32 || dst_offset % 32) { + return GL_FALSE; + } + if (0) { fprintf(stderr, "src: size [%d x %d], pitch %d, " "offset [%d x %d], format %s, bo %p\n", diff --git a/src/mesa/drivers/dri/r300/r300_texcopy.c b/src/mesa/drivers/dri/r300/r300_texcopy.c index 716a38a0a4..c7d57fb5de 100644 --- a/src/mesa/drivers/dri/r300/r300_texcopy.c +++ b/src/mesa/drivers/dri/r300/r300_texcopy.c @@ -68,10 +68,6 @@ do_copy_texsubimage(GLcontext *ctx, intptr_t src_offset = rrb->draw_offset; intptr_t dst_offset = radeon_miptree_image_offset(timg->mt, _mesa_tex_target_to_face(target), level); - if (src_offset % 32 || dst_offset % 32) { - return GL_FALSE; - } - if (0) { fprintf(stderr, "%s: copying to face %d, level %d\n", __FUNCTION__, _mesa_tex_target_to_face(target), level); diff --git a/src/mesa/drivers/dri/r600/r600_blit.c b/src/mesa/drivers/dri/r600/r600_blit.c index 68324766c3..58eb91ec61 100644 --- a/src/mesa/drivers/dri/r600/r600_blit.c +++ b/src/mesa/drivers/dri/r600/r600_blit.c @@ -1590,6 +1590,10 @@ GLboolean r600_blit(GLcontext *ctx, return GL_FALSE; } + if (src_offset % 256 || dst_offset % 256) { + return GL_FALSE; + } + if (0) { fprintf(stderr, "src: width %d, height %d, pitch %d vs %d, format %s\n", src_width, src_height, src_pitch, diff --git a/src/mesa/drivers/dri/r600/r600_texcopy.c b/src/mesa/drivers/dri/r600/r600_texcopy.c index dcea6c06e4..12b3403051 100644 --- a/src/mesa/drivers/dri/r600/r600_texcopy.c +++ b/src/mesa/drivers/dri/r600/r600_texcopy.c @@ -69,10 +69,6 @@ do_copy_texsubimage(GLcontext *ctx, intptr_t src_offset = rrb->draw_offset; intptr_t dst_offset = radeon_miptree_image_offset(timg->mt, _mesa_tex_target_to_face(target), level); - if (src_offset % 256 || dst_offset % 256) { - return GL_FALSE; - } - if (0) { fprintf(stderr, "%s: copying to face %d, level %d\n", __FUNCTION__, _mesa_tex_target_to_face(target), level); -- cgit v1.2.3 From 0aed44f8a36d4974d42f643c5065f2a4d96fc619 Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Mon, 18 Jan 2010 23:00:36 +0100 Subject: r600: align to r300 changes in the blit code Pitch here means aligned width, not aligned width * bpp. --- src/mesa/drivers/dri/r600/r600_blit.c | 11 ++++------- src/mesa/drivers/dri/r600/r600_texcopy.c | 5 +++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r600_blit.c b/src/mesa/drivers/dri/r600/r600_blit.c index 58eb91ec61..0205a438cc 100644 --- a/src/mesa/drivers/dri/r600/r600_blit.c +++ b/src/mesa/drivers/dri/r600/r600_blit.c @@ -90,16 +90,15 @@ static unsigned is_blit_supported(gl_format mesa_format) static inline void set_render_target(context_t *context, struct radeon_bo *bo, gl_format mesa_format, - int pitch, int w, int h, intptr_t dst_offset) + int nPitchInPixel, int w, int h, intptr_t dst_offset) { uint32_t cb_color0_base, cb_color0_size = 0, cb_color0_info = 0, cb_color0_view = 0; - int nPitchInPixel, id = 0; - uint32_t comp_swap, format, bpp = _mesa_get_format_bytes(mesa_format); + int id = 0; + uint32_t comp_swap, format; BATCH_LOCALS(&context->radeon); cb_color0_base = dst_offset / 256; - nPitchInPixel = pitch/bpp; SETfield(cb_color0_size, (nPitchInPixel / 8) - 1, PITCH_TILE_MAX_shift, PITCH_TILE_MAX_mask); SETfield(cb_color0_size, ((nPitchInPixel * h) / 64) - 1, @@ -556,11 +555,9 @@ set_vtx_resource(context_t *context) static inline void set_tex_resource(context_t * context, gl_format mesa_format, struct radeon_bo *bo, int w, int h, - int pitch, intptr_t src_offset) + int TexelPitch, intptr_t src_offset) { uint32_t sq_tex_resource0, sq_tex_resource1, sq_tex_resource2, sq_tex_resource4, sq_tex_resource6; - int bpp = _mesa_get_format_bytes(mesa_format); - int TexelPitch = pitch/bpp; sq_tex_resource0 = sq_tex_resource1 = sq_tex_resource2 = sq_tex_resource4 = sq_tex_resource6 = 0; BATCH_LOCALS(&context->radeon); diff --git a/src/mesa/drivers/dri/r600/r600_texcopy.c b/src/mesa/drivers/dri/r600/r600_texcopy.c index 12b3403051..21bf840e86 100644 --- a/src/mesa/drivers/dri/r600/r600_texcopy.c +++ b/src/mesa/drivers/dri/r600/r600_texcopy.c @@ -81,10 +81,11 @@ do_copy_texsubimage(GLcontext *ctx, /* blit from src buffer to texture */ - return r600_blit(ctx, rrb->bo, src_offset, rrb->base.Format, rrb->pitch, + return r600_blit(ctx, rrb->bo, src_offset, rrb->base.Format, rrb->pitch/rrb->cpp, rrb->base.Width, rrb->base.Height, x, y, timg->mt->bo, dst_offset, timg->base.TexFormat, - timg->mt->levels[level].rowstride, timg->base.Width, timg->base.Height, + timg->mt->levels[level].rowstride / _mesa_get_format_bytes(timg->base.TexFormat), + timg->base.Width, timg->base.Height, dstx, dsty, width, height, 1); } -- cgit v1.2.3 From 8a4d7393bd8a752eba2ee687c1c3e2df5c82745d Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Tue, 19 Jan 2010 23:34:56 +0100 Subject: radeon/r300/r600: share common glCopyTex(Sub)Image code --- src/mesa/drivers/dri/r300/Makefile | 4 +- src/mesa/drivers/dri/r300/r300_context.c | 8 +- src/mesa/drivers/dri/r300/r300_context.h | 2 - src/mesa/drivers/dri/r300/r300_tex.c | 7 +- src/mesa/drivers/dri/r300/r300_tex.h | 2 +- src/mesa/drivers/dri/r300/r300_texcopy.c | 163 ------------------------- src/mesa/drivers/dri/r300/radeon_tex_copy.c | 1 + src/mesa/drivers/dri/r600/Makefile | 4 +- src/mesa/drivers/dri/r600/r600_blit.c | 46 +++---- src/mesa/drivers/dri/r600/r600_blit.h | 40 +++---- src/mesa/drivers/dri/r600/r600_context.c | 8 +- src/mesa/drivers/dri/r600/r600_context.h | 1 - src/mesa/drivers/dri/r600/r600_tex.c | 7 +- src/mesa/drivers/dri/r600/r600_tex.h | 2 +- src/mesa/drivers/dri/r600/r600_texcopy.c | 166 -------------------------- src/mesa/drivers/dri/r600/radeon_tex_copy.c | 1 + src/mesa/drivers/dri/radeon/radeon_tex_copy.c | 155 ++++++++++++++++++++++++ src/mesa/drivers/dri/radeon/radeon_texture.h | 10 ++ 18 files changed, 232 insertions(+), 395 deletions(-) delete mode 100644 src/mesa/drivers/dri/r300/r300_texcopy.c create mode 120000 src/mesa/drivers/dri/r300/radeon_tex_copy.c delete mode 100644 src/mesa/drivers/dri/r600/r600_texcopy.c create mode 120000 src/mesa/drivers/dri/r600/radeon_tex_copy.c create mode 100644 src/mesa/drivers/dri/radeon/radeon_tex_copy.c diff --git a/src/mesa/drivers/dri/r300/Makefile b/src/mesa/drivers/dri/r300/Makefile index be005bd164..0d0fbcc408 100644 --- a/src/mesa/drivers/dri/r300/Makefile +++ b/src/mesa/drivers/dri/r300/Makefile @@ -39,7 +39,8 @@ RADEON_COMMON_SOURCES = \ radeon_mipmap_tree.c \ radeon_span.c \ radeon_queryobj.c \ - radeon_texture.c + radeon_texture.c \ + radeon_tex_copy.c DRIVER_SOURCES = \ radeon_screen.c \ @@ -50,7 +51,6 @@ DRIVER_SOURCES = \ r300_state.c \ r300_render.c \ r300_tex.c \ - r300_texcopy.c \ r300_texstate.c \ r300_vertprog.c \ r300_fragprog_common.c \ diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c index e449590fbb..bb0e6db313 100644 --- a/src/mesa/drivers/dri/r300/r300_context.c +++ b/src/mesa/drivers/dri/r300/r300_context.c @@ -93,8 +93,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/remap_helper.h" -void r300_init_texcopy_functions(struct dd_function_table *table); - static const struct dri_extension card_extensions[] = { /* *INDENT-OFF* */ {"GL_ARB_depth_texture", NULL}, @@ -490,15 +488,11 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual, _mesa_init_driver_functions(&functions); r300InitIoctlFuncs(&functions); r300InitStateFuncs(&functions); - r300InitTextureFuncs(&functions); + r300InitTextureFuncs(&r300->radeon, &functions); r300InitShaderFuncs(&functions); radeonInitQueryObjFunctions(&functions); radeonInitBufferObjectFuncs(&functions); - if (r300->radeon.radeonScreen->kernel_mm) { - r300_init_texcopy_functions(&functions); - } - if (!radeonInitContext(&r300->radeon, &functions, glVisual, driContextPriv, sharedContextPrivate)) { diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index 546cd8ddde..78ab43a99f 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -554,8 +554,6 @@ extern void r300InitShaderFunctions(r300ContextPtr r300); extern void r300InitDraw(GLcontext *ctx); -extern void r300_init_texcopy_functions(struct dd_function_table *table); - #define r300PackFloat32 radeonPackFloat32 #define r300PackFloat24 radeonPackFloat24 diff --git a/src/mesa/drivers/dri/r300/r300_tex.c b/src/mesa/drivers/dri/r300/r300_tex.c index 963f648cb1..eb5d2d5004 100644 --- a/src/mesa/drivers/dri/r300/r300_tex.c +++ b/src/mesa/drivers/dri/r300/r300_tex.c @@ -312,7 +312,7 @@ static struct gl_texture_object *r300NewTextureObject(GLcontext * ctx, return &t->base; } -void r300InitTextureFuncs(struct dd_function_table *functions) +void r300InitTextureFuncs(radeonContextPtr radeon, struct dd_function_table *functions) { /* Note: we only plug in the functions we implement in the driver * since _mesa_init_driver_functions() was already called. @@ -340,6 +340,11 @@ void r300InitTextureFuncs(struct dd_function_table *functions) functions->CompressedTexImage2D = radeonCompressedTexImage2D; functions->CompressedTexSubImage2D = radeonCompressedTexSubImage2D; + if (radeon->radeonScreen->kernel_mm) { + functions->CopyTexImage2D = radeonCopyTexImage2D; + functions->CopyTexSubImage2D = radeonCopyTexSubImage2D; + } + functions->GenerateMipmap = radeonGenerateMipmap; driInitTextureFormats(); diff --git a/src/mesa/drivers/dri/r300/r300_tex.h b/src/mesa/drivers/dri/r300/r300_tex.h index 6ede0fe25c..9694e703b8 100644 --- a/src/mesa/drivers/dri/r300/r300_tex.h +++ b/src/mesa/drivers/dri/r300/r300_tex.h @@ -49,7 +49,7 @@ extern void r300SetTexOffset(__DRIcontext *pDRICtx, GLint texname, extern GLboolean r300ValidateBuffers(GLcontext * ctx); -extern void r300InitTextureFuncs(struct dd_function_table *functions); +extern void r300InitTextureFuncs(radeonContextPtr radeon, struct dd_function_table *functions); int32_t r300TranslateTexFormat(gl_format mesaFormat); diff --git a/src/mesa/drivers/dri/r300/r300_texcopy.c b/src/mesa/drivers/dri/r300/r300_texcopy.c deleted file mode 100644 index c7d57fb5de..0000000000 --- a/src/mesa/drivers/dri/r300/r300_texcopy.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (C) 2009 Maciej Cencora - * - * All Rights Reserved. - * - * 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 COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS 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. - * - */ - -#include "radeon_common.h" -#include "r300_context.h" - -#include "main/image.h" -#include "main/teximage.h" -#include "main/texstate.h" -#include "drivers/common/meta.h" - -#include "radeon_mipmap_tree.h" -#include
- -// TODO: -// need to pass correct pitch for small dst textures! -static GLboolean -do_copy_texsubimage(GLcontext *ctx, - GLenum target, GLint level, - struct radeon_tex_obj *tobj, - radeon_texture_image *timg, - GLint dstx, GLint dsty, - GLint x, GLint y, - GLsizei width, GLsizei height) -{ - struct r300_context *r300 = R300_CONTEXT(ctx); - struct radeon_renderbuffer *rrb; - - if (_mesa_get_format_bits(timg->base.TexFormat, GL_DEPTH_BITS) > 0) { - rrb = radeon_get_depthbuffer(&r300->radeon); - } else { - rrb = radeon_get_colorbuffer(&r300->radeon); - } - - if (!timg->mt) { - radeon_validate_texture_miptree(ctx, &tobj->base); - } - - assert(rrb && rrb->bo); - assert(timg->mt->bo); - assert(timg->base.Width >= dstx + width); - assert(timg->base.Height >= dsty + height); - - intptr_t src_offset = rrb->draw_offset; - intptr_t dst_offset = radeon_miptree_image_offset(timg->mt, _mesa_tex_target_to_face(target), level); - - if (0) { - fprintf(stderr, "%s: copying to face %d, level %d\n", - __FUNCTION__, _mesa_tex_target_to_face(target), level); - fprintf(stderr, "to: x %d, y %d, offset %d\n", dstx, dsty, (uint32_t) dst_offset); - fprintf(stderr, "from (%dx%d) width %d, height %d, offset %d, pitch %d\n", - x, y, rrb->base.Width, rrb->base.Height, (uint32_t) src_offset, rrb->pitch/rrb->cpp); - fprintf(stderr, "src size %d, dst size %d\n", rrb->bo->size, timg->mt->bo->size); - - } - - /* blit from src buffer to texture */ - return r300->radeon.vtbl.blit(ctx, rrb->bo, src_offset, rrb->base.Format, rrb->pitch/rrb->cpp, - rrb->base.Width, rrb->base.Height, x, y, - timg->mt->bo, dst_offset, timg->base.TexFormat, - timg->base.Width, timg->base.Width, timg->base.Height, - dstx, dsty, width, height, 1); -} - -static void -r300CopyTexImage2D(GLcontext *ctx, GLenum target, GLint level, - GLenum internalFormat, - GLint x, GLint y, GLsizei width, GLsizei height, - GLint border) -{ - struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); - struct gl_texture_object *texObj = - _mesa_select_tex_object(ctx, texUnit, target); - struct gl_texture_image *texImage = - _mesa_select_tex_image(ctx, texObj, target, level); - int srcx, srcy, dstx, dsty; - - if (border) - goto fail; - - /* Setup or redefine the texture object, mipmap tree and texture - * image. Don't populate yet. - */ - ctx->Driver.TexImage2D(ctx, target, level, internalFormat, - width, height, border, - GL_RGBA, GL_UNSIGNED_BYTE, NULL, - &ctx->DefaultPacking, texObj, texImage); - - srcx = x; - srcy = y; - dstx = 0; - dsty = 0; - if (!_mesa_clip_copytexsubimage(ctx, - &dstx, &dsty, - &srcx, &srcy, - &width, &height)) { - return; - } - - if (!do_copy_texsubimage(ctx, target, level, - radeon_tex_obj(texObj), (radeon_texture_image *)texImage, - 0, 0, x, y, width, height)) { - goto fail; - } - - return; - -fail: - _mesa_meta_CopyTexImage2D(ctx, target, level, internalFormat, x, y, - width, height, border); -} - -static void -r300CopyTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, - GLsizei width, GLsizei height) -{ - struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); - struct gl_texture_object *texObj = _mesa_select_tex_object(ctx, texUnit, target); - struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texObj, target, level); - - if (!do_copy_texsubimage(ctx, target, level, - radeon_tex_obj(texObj), (radeon_texture_image *)texImage, - xoffset, yoffset, x, y, width, height)) { - - //DEBUG_FALLBACKS - - _mesa_meta_CopyTexSubImage2D(ctx, target, level, - xoffset, yoffset, x, y, width, height); - } -} - - -void r300_init_texcopy_functions(struct dd_function_table *table) -{ - table->CopyTexImage2D = r300CopyTexImage2D; - table->CopyTexSubImage2D = r300CopyTexSubImage2D; -} \ No newline at end of file diff --git a/src/mesa/drivers/dri/r300/radeon_tex_copy.c b/src/mesa/drivers/dri/r300/radeon_tex_copy.c new file mode 120000 index 0000000000..dfa5ba34e6 --- /dev/null +++ b/src/mesa/drivers/dri/r300/radeon_tex_copy.c @@ -0,0 +1 @@ +../radeon/radeon_tex_copy.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/r600/Makefile b/src/mesa/drivers/dri/r600/Makefile index b90efce17a..e55d0babd8 100644 --- a/src/mesa/drivers/dri/r600/Makefile +++ b/src/mesa/drivers/dri/r600/Makefile @@ -39,7 +39,8 @@ RADEON_COMMON_SOURCES = \ radeon_mipmap_tree.c \ radeon_span.c \ radeon_texture.c \ - radeon_queryobj.c + radeon_queryobj.c \ + radeon_tex_copy.c DRIVER_SOURCES = \ radeon_screen.c \ @@ -60,7 +61,6 @@ DRIVER_SOURCES = \ r600_tex.c \ r600_texstate.c \ r600_blit.c \ - r600_texcopy.c \ r700_debug.c \ $(RADEON_COMMON_SOURCES) \ $(EGL_SOURCES) \ diff --git a/src/mesa/drivers/dri/r600/r600_blit.c b/src/mesa/drivers/dri/r600/r600_blit.c index 0205a438cc..d7cd59ade6 100644 --- a/src/mesa/drivers/dri/r600/r600_blit.c +++ b/src/mesa/drivers/dri/r600/r600_blit.c @@ -1556,32 +1556,32 @@ static GLboolean validate_buffers(context_t *rmesa, return GL_TRUE; } -GLboolean r600_blit(GLcontext *ctx, - struct radeon_bo *src_bo, - intptr_t src_offset, - gl_format src_mesaformat, - unsigned src_pitch, - unsigned src_width, - unsigned src_height, - unsigned src_x, - unsigned src_y, - struct radeon_bo *dst_bo, - intptr_t dst_offset, - gl_format dst_mesaformat, - unsigned dst_pitch, - unsigned dst_width, - unsigned dst_height, - unsigned dst_x, - unsigned dst_y, - unsigned w, - unsigned h, - unsigned flip_y) +unsigned r600_blit(GLcontext *ctx, + struct radeon_bo *src_bo, + intptr_t src_offset, + gl_format src_mesaformat, + unsigned src_pitch, + unsigned src_width, + unsigned src_height, + unsigned src_x, + unsigned src_y, + struct radeon_bo *dst_bo, + intptr_t dst_offset, + gl_format dst_mesaformat, + unsigned dst_pitch, + unsigned dst_width, + unsigned dst_height, + unsigned dst_x, + unsigned dst_y, + unsigned w, + unsigned h, + unsigned flip_y) { context_t *context = R700_CONTEXT(ctx); int id = 0; if (!is_blit_supported(dst_mesaformat)) - return GL_FALSE; + return GL_FALSE; if (src_bo == dst_bo) { return GL_FALSE; @@ -1603,7 +1603,7 @@ GLboolean r600_blit(GLcontext *ctx, } /* Flush is needed to make sure that source buffer has correct data */ - radeonFlush(context->radeon.glCtx); + radeonFlush(ctx); rcommonEnsureCmdBufSpace(&context->radeon, 304, __FUNCTION__); @@ -1654,7 +1654,7 @@ GLboolean r600_blit(GLcontext *ctx, /* 5 */ r700WaitForIdleClean(context); - radeonFlush(context->radeon.glCtx); + radeonFlush(ctx); return GL_TRUE; } diff --git a/src/mesa/drivers/dri/r600/r600_blit.h b/src/mesa/drivers/dri/r600/r600_blit.h index 97dc2e57ff..f280e23489 100644 --- a/src/mesa/drivers/dri/r600/r600_blit.h +++ b/src/mesa/drivers/dri/r600/r600_blit.h @@ -1,21 +1,21 @@ -GLboolean r600_blit(GLcontext *ctx, - struct radeon_bo *src_bo, - intptr_t src_offset, - gl_format src_mesaformat, - unsigned src_pitch, - unsigned src_width, - unsigned src_height, - unsigned src_x_offset, - unsigned src_y_offset, - struct radeon_bo *dst_bo, - intptr_t dst_offset, - gl_format dst_mesaformat, - unsigned dst_pitch, - unsigned dst_width, - unsigned dst_height, - unsigned dst_x_offset, - unsigned dst_y_offset, - unsigned w, - unsigned h, - unsigned flip_y); +unsigned r600_blit(GLcontext *ctx, + struct radeon_bo *src_bo, + intptr_t src_offset, + gl_format src_mesaformat, + unsigned src_pitch, + unsigned src_width, + unsigned src_height, + unsigned src_x_offset, + unsigned src_y_offset, + struct radeon_bo *dst_bo, + intptr_t dst_offset, + gl_format dst_mesaformat, + unsigned dst_pitch, + unsigned dst_width, + unsigned dst_height, + unsigned dst_x_offset, + unsigned dst_y_offset, + unsigned w, + unsigned h, + unsigned flip_y); diff --git a/src/mesa/drivers/dri/r600/r600_context.c b/src/mesa/drivers/dri/r600/r600_context.c index 55680fad32..68112c49dc 100644 --- a/src/mesa/drivers/dri/r600/r600_context.c +++ b/src/mesa/drivers/dri/r600/r600_context.c @@ -65,6 +65,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r600_emit.h" #include "radeon_bocs_wrapper.h" #include "radeon_queryobj.h" +#include "r600_blit.h" #include "r700_state.h" #include "r700_ioctl.h" @@ -240,6 +241,7 @@ static void r600_init_vtbl(radeonContextPtr radeon) radeon->vtbl.pre_emit_atoms = r600_vtbl_pre_emit_atoms; radeon->vtbl.fallback = r600_fallback; radeon->vtbl.emit_query_finish = r600_emit_query_finish; + radeon->vtbl.blit = r600_blit; } static void r600InitConstValues(GLcontext *ctx, radeonScreenPtr screen) @@ -378,16 +380,12 @@ GLboolean r600CreateContext(const __GLcontextModes * glVisual, _mesa_init_driver_functions(&functions); r700InitStateFuncs(&functions); - r600InitTextureFuncs(&functions); + r600InitTextureFuncs(&r600->radeon, &functions); r700InitShaderFuncs(&functions); radeonInitQueryObjFunctions(&functions); r700InitIoctlFuncs(&functions); radeonInitBufferObjectFuncs(&functions); - if (r600->radeon.radeonScreen->kernel_mm) { - r600_init_texcopy_functions(&functions); - } - if (!radeonInitContext(&r600->radeon, &functions, glVisual, driContextPriv, sharedContextPrivate)) { diff --git a/src/mesa/drivers/dri/r600/r600_context.h b/src/mesa/drivers/dri/r600/r600_context.h index 1f7cd4096b..72c8c869b7 100644 --- a/src/mesa/drivers/dri/r600/r600_context.h +++ b/src/mesa/drivers/dri/r600/r600_context.h @@ -185,7 +185,6 @@ extern void r700WaitForIdleClean(context_t *context); extern void r700Start3D(context_t *context); extern void r600InitAtoms(context_t *context); extern void r700InitDraw(GLcontext *ctx); -extern void r600_init_texcopy_functions(struct dd_function_table *table); #define RADEON_D_CAPTURE 0 #define RADEON_D_PLAYBACK 1 diff --git a/src/mesa/drivers/dri/r600/r600_tex.c b/src/mesa/drivers/dri/r600/r600_tex.c index f745fe3e8a..71dfd7e059 100644 --- a/src/mesa/drivers/dri/r600/r600_tex.c +++ b/src/mesa/drivers/dri/r600/r600_tex.c @@ -396,7 +396,7 @@ static struct gl_texture_object *r600NewTextureObject(GLcontext * ctx, return &t->base; } -void r600InitTextureFuncs(struct dd_function_table *functions) +void r600InitTextureFuncs(radeonContextPtr radeon, struct dd_function_table *functions) { /* Note: we only plug in the functions we implement in the driver * since _mesa_init_driver_functions() was already called. @@ -424,6 +424,11 @@ void r600InitTextureFuncs(struct dd_function_table *functions) functions->CompressedTexImage2D = radeonCompressedTexImage2D; functions->CompressedTexSubImage2D = radeonCompressedTexSubImage2D; + if (radeon->radeonScreen->kernel_mm) { + functions->CopyTexImage2D = radeonCopyTexImage2D; + functions->CopyTexSubImage2D = radeonCopyTexSubImage2D; + } + functions->GenerateMipmap = radeonGenerateMipmap; driInitTextureFormats(); diff --git a/src/mesa/drivers/dri/r600/r600_tex.h b/src/mesa/drivers/dri/r600/r600_tex.h index fb0e1a023e..c2141ef5e5 100644 --- a/src/mesa/drivers/dri/r600/r600_tex.h +++ b/src/mesa/drivers/dri/r600/r600_tex.h @@ -58,6 +58,6 @@ extern void r600SetTexOffset(__DRIcontext *pDRICtx, GLint texname, extern GLboolean r600ValidateBuffers(GLcontext * ctx); -extern void r600InitTextureFuncs(struct dd_function_table *functions); +extern void r600InitTextureFuncs(radeonContextPtr radeon, struct dd_function_table *functions); #endif /* __r600_TEX_H__ */ diff --git a/src/mesa/drivers/dri/r600/r600_texcopy.c b/src/mesa/drivers/dri/r600/r600_texcopy.c deleted file mode 100644 index 21bf840e86..0000000000 --- a/src/mesa/drivers/dri/r600/r600_texcopy.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (C) 2009 Maciej Cencora - * - * All Rights Reserved. - * - * 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 COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS 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. - * - */ - -#include "radeon_common.h" -#include "r600_context.h" - -#include "main/image.h" -#include "main/teximage.h" -#include "main/texstate.h" -#include "drivers/common/meta.h" - -#include "radeon_mipmap_tree.h" -#include "r600_blit.h" -#include
- -// TODO: -// need to pass correct pitch for small dst textures! -static GLboolean -do_copy_texsubimage(GLcontext *ctx, - GLenum target, GLint level, - struct radeon_tex_obj *tobj, - radeon_texture_image *timg, - GLint dstx, GLint dsty, - GLint x, GLint y, - GLsizei width, GLsizei height) -{ - context_t *context = R700_CONTEXT(ctx); - struct radeon_renderbuffer *rrb; - - if (_mesa_get_format_bits(timg->base.TexFormat, GL_DEPTH_BITS) > 0) { - rrb = radeon_get_depthbuffer(&context->radeon); - } else { - rrb = radeon_get_colorbuffer(&context->radeon); - } - - if (!timg->mt) { - radeon_validate_texture_miptree(ctx, &tobj->base); - } - - assert(rrb && rrb->bo); - assert(timg->mt->bo); - assert(timg->base.Width >= dstx + width); - assert(timg->base.Height >= dsty + height); - - intptr_t src_offset = rrb->draw_offset; - intptr_t dst_offset = radeon_miptree_image_offset(timg->mt, _mesa_tex_target_to_face(target), level); - - if (0) { - fprintf(stderr, "%s: copying to face %d, level %d\n", - __FUNCTION__, _mesa_tex_target_to_face(target), level); - fprintf(stderr, "to: x %d, y %d, offset %d\n", dstx, dsty, (uint32_t) dst_offset); - fprintf(stderr, "from (%dx%d) width %d, height %d, offset %d, pitch %d\n", - x, y, rrb->base.Width, rrb->base.Height, (uint32_t) src_offset, rrb->pitch/rrb->cpp); - fprintf(stderr, "src size %d, dst size %d\n", rrb->bo->size, timg->mt->bo->size); - - } - - - /* blit from src buffer to texture */ - return r600_blit(ctx, rrb->bo, src_offset, rrb->base.Format, rrb->pitch/rrb->cpp, - rrb->base.Width, rrb->base.Height, x, y, - timg->mt->bo, dst_offset, timg->base.TexFormat, - timg->mt->levels[level].rowstride / _mesa_get_format_bytes(timg->base.TexFormat), - timg->base.Width, timg->base.Height, - dstx, dsty, width, height, 1); -} - -static void -r600CopyTexImage2D(GLcontext *ctx, GLenum target, GLint level, - GLenum internalFormat, - GLint x, GLint y, GLsizei width, GLsizei height, - GLint border) -{ - struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); - struct gl_texture_object *texObj = - _mesa_select_tex_object(ctx, texUnit, target); - struct gl_texture_image *texImage = - _mesa_select_tex_image(ctx, texObj, target, level); - int srcx, srcy, dstx, dsty; - - if (border) - goto fail; - - /* Setup or redefine the texture object, mipmap tree and texture - * image. Don't populate yet. - */ - ctx->Driver.TexImage2D(ctx, target, level, internalFormat, - width, height, border, - GL_RGBA, GL_UNSIGNED_BYTE, NULL, - &ctx->DefaultPacking, texObj, texImage); - - srcx = x; - srcy = y; - dstx = 0; - dsty = 0; - if (!_mesa_clip_copytexsubimage(ctx, - &dstx, &dsty, - &srcx, &srcy, - &width, &height)) { - return; - } - - if (!do_copy_texsubimage(ctx, target, level, - radeon_tex_obj(texObj), (radeon_texture_image *)texImage, - 0, 0, x, y, width, height)) { - goto fail; - } - - return; - -fail: - _mesa_meta_CopyTexImage2D(ctx, target, level, internalFormat, x, y, - width, height, border); -} - -static void -r600CopyTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, - GLsizei width, GLsizei height) -{ - struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); - struct gl_texture_object *texObj = _mesa_select_tex_object(ctx, texUnit, target); - struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texObj, target, level); - - if (!do_copy_texsubimage(ctx, target, level, - radeon_tex_obj(texObj), (radeon_texture_image *)texImage, - xoffset, yoffset, x, y, width, height)) { - - //DEBUG_FALLBACKS - - _mesa_meta_CopyTexSubImage2D(ctx, target, level, - xoffset, yoffset, x, y, width, height); - } -} - - -void r600_init_texcopy_functions(struct dd_function_table *table) -{ - table->CopyTexImage2D = r600CopyTexImage2D; - table->CopyTexSubImage2D = r600CopyTexSubImage2D; -} diff --git a/src/mesa/drivers/dri/r600/radeon_tex_copy.c b/src/mesa/drivers/dri/r600/radeon_tex_copy.c new file mode 120000 index 0000000000..dfa5ba34e6 --- /dev/null +++ b/src/mesa/drivers/dri/r600/radeon_tex_copy.c @@ -0,0 +1 @@ +../radeon/radeon_tex_copy.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/radeon/radeon_tex_copy.c b/src/mesa/drivers/dri/radeon/radeon_tex_copy.c new file mode 100644 index 0000000000..44e144c80f --- /dev/null +++ b/src/mesa/drivers/dri/radeon/radeon_tex_copy.c @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2009 Maciej Cencora + * + * All Rights Reserved. + * + * 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 COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS 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. + * + */ + +#include "radeon_common.h" +#include "radeon_texture.h" + +#include "main/image.h" +#include "main/teximage.h" +#include "main/texstate.h" +#include "drivers/common/meta.h" + +#include "radeon_mipmap_tree.h" +#include
+ +static GLboolean +do_copy_texsubimage(GLcontext *ctx, + GLenum target, GLint level, + struct radeon_tex_obj *tobj, + radeon_texture_image *timg, + GLint dstx, GLint dsty, + GLint x, GLint y, + GLsizei width, GLsizei height) +{ + radeonContextPtr radeon = RADEON_CONTEXT(ctx); + struct radeon_renderbuffer *rrb; + + if (_mesa_get_format_bits(timg->base.TexFormat, GL_DEPTH_BITS) > 0) { + rrb = radeon_get_depthbuffer(radeon); + } else { + rrb = radeon_get_colorbuffer(radeon); + } + + if (!timg->mt) { + radeon_validate_texture_miptree(ctx, &tobj->base); + } + + assert(rrb && rrb->bo); + assert(timg->mt->bo); + assert(timg->base.Width >= dstx + width); + assert(timg->base.Height >= dsty + height); + + intptr_t src_offset = rrb->draw_offset; + intptr_t dst_offset = radeon_miptree_image_offset(timg->mt, _mesa_tex_target_to_face(target), level); + + if (0) { + fprintf(stderr, "%s: copying to face %d, level %d\n", + __FUNCTION__, _mesa_tex_target_to_face(target), level); + fprintf(stderr, "to: x %d, y %d, offset %d\n", dstx, dsty, (uint32_t) dst_offset); + fprintf(stderr, "from (%dx%d) width %d, height %d, offset %d, pitch %d\n", + x, y, rrb->base.Width, rrb->base.Height, (uint32_t) src_offset, rrb->pitch/rrb->cpp); + fprintf(stderr, "src size %d, dst size %d\n", rrb->bo->size, timg->mt->bo->size); + + } + + /* blit from src buffer to texture */ + return radeon->vtbl.blit(ctx, rrb->bo, src_offset, rrb->base.Format, rrb->pitch/rrb->cpp, + rrb->base.Width, rrb->base.Height, x, y, + timg->mt->bo, dst_offset, timg->base.TexFormat, + timg->mt->levels[level].rowstride / _mesa_get_format_bytes(timg->base.TexFormat), + timg->base.Width, timg->base.Height, + dstx, dsty, width, height, 1); +} + +void +radeonCopyTexImage2D(GLcontext *ctx, GLenum target, GLint level, + GLenum internalFormat, + GLint x, GLint y, GLsizei width, GLsizei height, + GLint border) +{ + struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); + struct gl_texture_object *texObj = + _mesa_select_tex_object(ctx, texUnit, target); + struct gl_texture_image *texImage = + _mesa_select_tex_image(ctx, texObj, target, level); + int srcx, srcy, dstx, dsty; + + if (border) + goto fail; + + /* Setup or redefine the texture object, mipmap tree and texture + * image. Don't populate yet. + */ + ctx->Driver.TexImage2D(ctx, target, level, internalFormat, + width, height, border, + GL_RGBA, GL_UNSIGNED_BYTE, NULL, + &ctx->DefaultPacking, texObj, texImage); + + srcx = x; + srcy = y; + dstx = 0; + dsty = 0; + if (!_mesa_clip_copytexsubimage(ctx, + &dstx, &dsty, + &srcx, &srcy, + &width, &height)) { + return; + } + + if (!do_copy_texsubimage(ctx, target, level, + radeon_tex_obj(texObj), (radeon_texture_image *)texImage, + 0, 0, x, y, width, height)) { + goto fail; + } + + return; + +fail: + _mesa_meta_CopyTexImage2D(ctx, target, level, internalFormat, x, y, + width, height, border); +} + +void +radeonCopyTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLsizei height) +{ + struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); + struct gl_texture_object *texObj = _mesa_select_tex_object(ctx, texUnit, target); + struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texObj, target, level); + + if (!do_copy_texsubimage(ctx, target, level, + radeon_tex_obj(texObj), (radeon_texture_image *)texImage, + xoffset, yoffset, x, y, width, height)) { + + //DEBUG_FALLBACKS + + _mesa_meta_CopyTexSubImage2D(ctx, target, level, + xoffset, yoffset, x, y, width, height); + } +} diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.h b/src/mesa/drivers/dri/radeon/radeon_texture.h index 4ec6a2945f..f09dd65214 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texture.h +++ b/src/mesa/drivers/dri/radeon/radeon_texture.h @@ -125,4 +125,14 @@ void radeonGetCompressedTexImage(GLcontext *ctx, GLenum target, GLint level, struct gl_texture_object *texObj, struct gl_texture_image *texImage); +void radeonCopyTexImage2D(GLcontext *ctx, GLenum target, GLint level, + GLenum internalFormat, + GLint x, GLint y, GLsizei width, GLsizei height, + GLint border); + +void radeonCopyTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLsizei height); + #endif -- cgit v1.2.3 From 5170d2452beafc4a6f5859792d6c6b267c549e46 Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Tue, 19 Jan 2010 23:12:12 +0100 Subject: r100: use common glCopyTex(Sub)Image code --- src/mesa/drivers/dri/radeon/Makefile | 4 +- src/mesa/drivers/dri/radeon/radeon_blit.c | 50 ++++---- src/mesa/drivers/dri/radeon/radeon_blit.h | 40 +++---- src/mesa/drivers/dri/radeon/radeon_context.c | 8 +- src/mesa/drivers/dri/radeon/radeon_context.h | 1 - src/mesa/drivers/dri/radeon/radeon_tex.c | 7 +- src/mesa/drivers/dri/radeon/radeon_tex.h | 2 +- src/mesa/drivers/dri/radeon/radeon_texcopy.c | 168 --------------------------- 8 files changed, 60 insertions(+), 220 deletions(-) delete mode 100644 src/mesa/drivers/dri/radeon/radeon_texcopy.c diff --git a/src/mesa/drivers/dri/radeon/Makefile b/src/mesa/drivers/dri/radeon/Makefile index 70b946b2fd..c776be0e60 100644 --- a/src/mesa/drivers/dri/radeon/Makefile +++ b/src/mesa/drivers/dri/radeon/Makefile @@ -26,7 +26,8 @@ RADEON_COMMON_SOURCES = \ radeon_mipmap_tree.c \ radeon_queryobj.c \ radeon_span.c \ - radeon_texture.c + radeon_texture.c \ + radeon_tex_copy.c DRIVER_SOURCES = \ radeon_context.c \ @@ -41,7 +42,6 @@ DRIVER_SOURCES = \ radeon_maos.c \ radeon_sanity.c \ radeon_blit.c \ - radeon_texcopy.c \ $(RADEON_COMMON_SOURCES) C_SOURCES = \ diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.c b/src/mesa/drivers/dri/radeon/radeon_blit.c index 1ccfa4e78e..c1bb51a6ef 100644 --- a/src/mesa/drivers/dri/radeon/radeon_blit.c +++ b/src/mesa/drivers/dri/radeon/radeon_blit.c @@ -307,27 +307,29 @@ static inline void emit_draw_packet(struct r100_context *r100, * @param[in] height region height * @param[in] flip_y set if y coords of the source image need to be flipped */ -GLboolean r100_blit(struct r100_context *r100, - struct radeon_bo *src_bo, - intptr_t src_offset, - gl_format src_mesaformat, - unsigned src_pitch, - unsigned src_width, - unsigned src_height, - unsigned src_x_offset, - unsigned src_y_offset, - struct radeon_bo *dst_bo, - intptr_t dst_offset, - gl_format dst_mesaformat, - unsigned dst_pitch, - unsigned dst_width, - unsigned dst_height, - unsigned dst_x_offset, - unsigned dst_y_offset, - unsigned reg_width, - unsigned reg_height, - unsigned flip_y) +unsigned r100_blit(GLcontext *ctx, + struct radeon_bo *src_bo, + intptr_t src_offset, + gl_format src_mesaformat, + unsigned src_pitch, + unsigned src_width, + unsigned src_height, + unsigned src_x_offset, + unsigned src_y_offset, + struct radeon_bo *dst_bo, + intptr_t dst_offset, + gl_format dst_mesaformat, + unsigned dst_pitch, + unsigned dst_width, + unsigned dst_height, + unsigned dst_x_offset, + unsigned dst_y_offset, + unsigned reg_width, + unsigned reg_height, + unsigned flip_y) { + struct r100_context *r100 = R100_CONTEXT(ctx); + if (!is_blit_supported(dst_mesaformat)) return GL_FALSE; @@ -358,6 +360,10 @@ GLboolean r100_blit(struct r100_context *r100, return GL_FALSE; } + if (src_offset % 32 || dst_offset % 32) { + return GL_FALSE; + } + if (0) { fprintf(stderr, "src: size [%d x %d], pitch %d, " "offset [%d x %d], format %s, bo %p\n", @@ -372,7 +378,7 @@ GLboolean r100_blit(struct r100_context *r100, } /* Flush is needed to make sure that source buffer has correct data */ - radeonFlush(r100->radeon.glCtx); + radeonFlush(ctx); rcommonEnsureCmdBufSpace(&r100->radeon, 59, __FUNCTION__); @@ -392,7 +398,7 @@ GLboolean r100_blit(struct r100_context *r100, reg_width, reg_height, flip_y); - radeonFlush(r100->radeon.glCtx); + radeonFlush(ctx); return GL_TRUE; } diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.h b/src/mesa/drivers/dri/radeon/radeon_blit.h index c0203d0a54..d36366ff79 100644 --- a/src/mesa/drivers/dri/radeon/radeon_blit.h +++ b/src/mesa/drivers/dri/radeon/radeon_blit.h @@ -30,25 +30,25 @@ void r100_blit_init(struct r100_context *r100); -GLboolean r100_blit(struct r100_context *r100, - struct radeon_bo *src_bo, - intptr_t src_offset, - gl_format src_mesaformat, - unsigned src_pitch, - unsigned src_width, - unsigned src_height, - unsigned src_x_offset, - unsigned src_y_offset, - struct radeon_bo *dst_bo, - intptr_t dst_offset, - gl_format dst_mesaformat, - unsigned dst_pitch, - unsigned dst_width, - unsigned dst_height, - unsigned dst_x_offset, - unsigned dst_y_offset, - unsigned width, - unsigned height, - unsigned flip_y); +unsigned r100_blit(GLcontext *ctx, + struct radeon_bo *src_bo, + intptr_t src_offset, + gl_format src_mesaformat, + unsigned src_pitch, + unsigned src_width, + unsigned src_height, + unsigned src_x_offset, + unsigned src_y_offset, + struct radeon_bo *dst_bo, + intptr_t dst_offset, + gl_format dst_mesaformat, + unsigned dst_pitch, + unsigned dst_width, + unsigned dst_height, + unsigned dst_x_offset, + unsigned dst_y_offset, + unsigned width, + unsigned height, + unsigned flip_y); #endif // RADEON_BLIT_H diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c index 1182fc7f0d..6c08a90bbd 100644 --- a/src/mesa/drivers/dri/radeon/radeon_context.c +++ b/src/mesa/drivers/dri/radeon/radeon_context.c @@ -63,6 +63,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "radeon_tcl.h" #include "radeon_maos.h" #include "radeon_queryobj.h" +#include "radeon_blit.h" #define need_GL_ARB_occlusion_query #define need_GL_EXT_blend_minmax @@ -202,6 +203,7 @@ static void r100_init_vtbl(radeonContextPtr radeon) radeon->vtbl.fallback = radeonFallback; radeon->vtbl.free_context = r100_vtbl_free_context; radeon->vtbl.emit_query_finish = r100_emit_query_finish; + radeon->vtbl.blit = r100_blit; } /* Create the device specific context. @@ -258,13 +260,9 @@ r100CreateContext( const __GLcontextModes *glVisual, * (the texture functions are especially important) */ _mesa_init_driver_functions( &functions ); - radeonInitTextureFuncs( &functions ); + radeonInitTextureFuncs( &rmesa->radeon, &functions ); radeonInitQueryObjFunctions(&functions); - if (rmesa->radeon.radeonScreen->kernel_mm) { - r100_init_texcopy_functions(&functions); - } - if (!radeonInitContext(&rmesa->radeon, &functions, glVisual, driContextPriv, sharedContextPrivate)) { diff --git a/src/mesa/drivers/dri/radeon/radeon_context.h b/src/mesa/drivers/dri/radeon/radeon_context.h index c52eff855f..d84760bf74 100644 --- a/src/mesa/drivers/dri/radeon/radeon_context.h +++ b/src/mesa/drivers/dri/radeon/radeon_context.h @@ -453,7 +453,6 @@ struct r100_context { extern GLboolean r100CreateContext( const __GLcontextModes *glVisual, __DRIcontext *driContextPriv, void *sharedContextPrivate); -extern void r100_init_texcopy_functions(struct dd_function_table *table); #endif /* __RADEON_CONTEXT_H__ */ diff --git a/src/mesa/drivers/dri/radeon/radeon_tex.c b/src/mesa/drivers/dri/radeon/radeon_tex.c index 14163f13af..882ee5c194 100644 --- a/src/mesa/drivers/dri/radeon/radeon_tex.c +++ b/src/mesa/drivers/dri/radeon/radeon_tex.c @@ -434,7 +434,7 @@ radeonNewTextureObject( GLcontext *ctx, GLuint name, GLenum target ) -void radeonInitTextureFuncs( struct dd_function_table *functions ) +void radeonInitTextureFuncs( radeonContextPtr radeon, struct dd_function_table *functions ) { functions->ChooseTextureFormat = radeonChooseTextureFormat_mesa; functions->TexImage1D = radeonTexImage1D; @@ -455,6 +455,11 @@ void radeonInitTextureFuncs( struct dd_function_table *functions ) functions->CompressedTexImage2D = radeonCompressedTexImage2D; functions->CompressedTexSubImage2D = radeonCompressedTexSubImage2D; + if (radeon->radeonScreen->kernel_mm) { + functions->CopyTexImage2D = radeonCopyTexImage2D; + functions->CopyTexSubImage2D = radeonCopyTexSubImage2D; + } + functions->GenerateMipmap = radeonGenerateMipmap; functions->NewTextureImage = radeonNewTextureImage; diff --git a/src/mesa/drivers/dri/radeon/radeon_tex.h b/src/mesa/drivers/dri/radeon/radeon_tex.h index a4aaddc74f..0113ffd3da 100644 --- a/src/mesa/drivers/dri/radeon/radeon_tex.h +++ b/src/mesa/drivers/dri/radeon/radeon_tex.h @@ -52,6 +52,6 @@ extern int radeonUploadTexImages( r100ContextPtr rmesa, radeonTexObjPtr t, extern void radeonDestroyTexObj( r100ContextPtr rmesa, radeonTexObjPtr t ); -extern void radeonInitTextureFuncs( struct dd_function_table *functions ); +extern void radeonInitTextureFuncs( radeonContextPtr radeon, struct dd_function_table *functions ); #endif /* __RADEON_TEX_H__ */ diff --git a/src/mesa/drivers/dri/radeon/radeon_texcopy.c b/src/mesa/drivers/dri/radeon/radeon_texcopy.c deleted file mode 100644 index d4328982c3..0000000000 --- a/src/mesa/drivers/dri/radeon/radeon_texcopy.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (C) 2009 Maciej Cencora - * - * All Rights Reserved. - * - * 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 COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS 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. - * - */ - -#include "radeon_common.h" -#include "radeon_context.h" - -#include "main/image.h" -#include "main/teximage.h" -#include "main/texstate.h" -#include "drivers/common/meta.h" - -#include "radeon_mipmap_tree.h" -#include "radeon_blit.h" -#include
- -// TODO: -// need to pass correct pitch for small dst textures! -static GLboolean -do_copy_texsubimage(GLcontext *ctx, - GLenum target, GLint level, - struct radeon_tex_obj *tobj, - radeon_texture_image *timg, - GLint dstx, GLint dsty, - GLint x, GLint y, - GLsizei width, GLsizei height) -{ - struct r100_context *r100 = R100_CONTEXT(ctx); - struct radeon_renderbuffer *rrb; - - if (_mesa_get_format_bits(timg->base.TexFormat, GL_DEPTH_BITS) > 0) { - rrb = radeon_get_depthbuffer(&r100->radeon); - } else { - rrb = radeon_get_colorbuffer(&r100->radeon); - } - - if (!timg->mt) { - radeon_validate_texture_miptree(ctx, &tobj->base); - } - - assert(rrb && rrb->bo); - assert(timg->mt->bo); - assert(timg->base.Width >= dstx + width); - assert(timg->base.Height >= dsty + height); - - intptr_t src_offset = rrb->draw_offset; - intptr_t dst_offset = radeon_miptree_image_offset(timg->mt, _mesa_tex_target_to_face(target), level); - - if (src_offset % 32 || dst_offset % 32) { - return GL_FALSE; - } - - if (0) { - fprintf(stderr, "%s: copying to face %d, level %d\n", - __FUNCTION__, _mesa_tex_target_to_face(target), level); - fprintf(stderr, "to: x %d, y %d, offset %d\n", dstx, dsty, (uint32_t) dst_offset); - fprintf(stderr, "from (%dx%d) width %d, height %d, offset %d, pitch %d\n", - x, y, rrb->base.Width, rrb->base.Height, (uint32_t) src_offset, rrb->pitch/rrb->cpp); - fprintf(stderr, "src size %d, dst size %d\n", rrb->bo->size, timg->mt->bo->size); - - } - - /* blit from src buffer to texture */ - return r100_blit(r100, rrb->bo, src_offset, rrb->base.Format, rrb->pitch, - rrb->base.Width, rrb->base.Height, x, y, - timg->mt->bo, dst_offset, timg->base.TexFormat, - timg->base.Width, timg->base.Width, timg->base.Height, - dstx, dsty, width, height, 1); -} - -static void -r100CopyTexImage2D(GLcontext *ctx, GLenum target, GLint level, - GLenum internalFormat, - GLint x, GLint y, GLsizei width, GLsizei height, - GLint border) -{ - struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); - struct gl_texture_object *texObj = - _mesa_select_tex_object(ctx, texUnit, target); - struct gl_texture_image *texImage = - _mesa_select_tex_image(ctx, texObj, target, level); - int srcx, srcy, dstx, dsty; - - if (border) - goto fail; - - /* Setup or redefine the texture object, mipmap tree and texture - * image. Don't populate yet. - */ - ctx->Driver.TexImage2D(ctx, target, level, internalFormat, - width, height, border, - GL_RGBA, GL_UNSIGNED_BYTE, NULL, - &ctx->DefaultPacking, texObj, texImage); - - srcx = x; - srcy = y; - dstx = 0; - dsty = 0; - if (!_mesa_clip_copytexsubimage(ctx, - &dstx, &dsty, - &srcx, &srcy, - &width, &height)) { - return; - } - - if (!do_copy_texsubimage(ctx, target, level, - radeon_tex_obj(texObj), (radeon_texture_image *)texImage, - 0, 0, x, y, width, height)) { - goto fail; - } - - return; - -fail: - _mesa_meta_CopyTexImage2D(ctx, target, level, internalFormat, x, y, - width, height, border); -} - -static void -r100CopyTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, - GLsizei width, GLsizei height) -{ - struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); - struct gl_texture_object *texObj = _mesa_select_tex_object(ctx, texUnit, target); - struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texObj, target, level); - - if (!do_copy_texsubimage(ctx, target, level, - radeon_tex_obj(texObj), (radeon_texture_image *)texImage, - xoffset, yoffset, x, y, width, height)) { - - //DEBUG_FALLBACKS - - _mesa_meta_CopyTexSubImage2D(ctx, target, level, - xoffset, yoffset, x, y, width, height); - } -} - - -void r100_init_texcopy_functions(struct dd_function_table *table) -{ - table->CopyTexImage2D = r100CopyTexImage2D; - table->CopyTexSubImage2D = r100CopyTexSubImage2D; -} -- cgit v1.2.3 From 2706bc6a8898c7d7e155440cfa793035e56186b8 Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Tue, 19 Jan 2010 23:20:44 +0100 Subject: r200: use common glCopyTex(Sub)Image code --- src/mesa/drivers/dri/r200/Makefile | 5 +- src/mesa/drivers/dri/r200/r200_blit.c | 44 ++++---- src/mesa/drivers/dri/r200/r200_blit.h | 40 ++++---- src/mesa/drivers/dri/r200/r200_context.c | 4 +- src/mesa/drivers/dri/r200/r200_tex.c | 7 +- src/mesa/drivers/dri/r200/r200_tex.h | 2 +- src/mesa/drivers/dri/r200/r200_texcopy.c | 168 ------------------------------- 7 files changed, 55 insertions(+), 215 deletions(-) delete mode 100644 src/mesa/drivers/dri/r200/r200_texcopy.c diff --git a/src/mesa/drivers/dri/r200/Makefile b/src/mesa/drivers/dri/r200/Makefile index 2155ece216..ca33faff87 100644 --- a/src/mesa/drivers/dri/r200/Makefile +++ b/src/mesa/drivers/dri/r200/Makefile @@ -29,8 +29,8 @@ RADEON_COMMON_SOURCES = \ radeon_mipmap_tree.c \ radeon_queryobj.c \ radeon_span.c \ - radeon_texture.c - + radeon_texture.c \ + radeon_tex_copy.c DRIVER_SOURCES = r200_context.c \ r200_ioctl.c \ @@ -47,7 +47,6 @@ DRIVER_SOURCES = r200_context.c \ r200_fragshader.c \ r200_vertprog.c \ r200_blit.c \ - r200_texcopy.c \ radeon_screen.c \ $(EGL_SOURCES) \ $(RADEON_COMMON_SOURCES) \ diff --git a/src/mesa/drivers/dri/r200/r200_blit.c b/src/mesa/drivers/dri/r200/r200_blit.c index 081218b3a5..2122584363 100644 --- a/src/mesa/drivers/dri/r200/r200_blit.c +++ b/src/mesa/drivers/dri/r200/r200_blit.c @@ -311,27 +311,29 @@ static inline void emit_draw_packet(struct r200_context *r200, * @param[in] height region height * @param[in] flip_y set if y coords of the source image need to be flipped */ -GLboolean r200_blit(struct r200_context *r200, - struct radeon_bo *src_bo, - intptr_t src_offset, - gl_format src_mesaformat, - unsigned src_pitch, - unsigned src_width, - unsigned src_height, - unsigned src_x_offset, - unsigned src_y_offset, - struct radeon_bo *dst_bo, - intptr_t dst_offset, - gl_format dst_mesaformat, - unsigned dst_pitch, - unsigned dst_width, - unsigned dst_height, - unsigned dst_x_offset, - unsigned dst_y_offset, - unsigned reg_width, - unsigned reg_height, - unsigned flip_y) +unsigned r200_blit(GLcontext *ctx, + struct radeon_bo *src_bo, + intptr_t src_offset, + gl_format src_mesaformat, + unsigned src_pitch, + unsigned src_width, + unsigned src_height, + unsigned src_x_offset, + unsigned src_y_offset, + struct radeon_bo *dst_bo, + intptr_t dst_offset, + gl_format dst_mesaformat, + unsigned dst_pitch, + unsigned dst_width, + unsigned dst_height, + unsigned dst_x_offset, + unsigned dst_y_offset, + unsigned reg_width, + unsigned reg_height, + unsigned flip_y) { + struct r200_context *r200 = R200_CONTEXT(ctx); + if (!is_blit_supported(dst_mesaformat)) return GL_FALSE; @@ -396,7 +398,7 @@ GLboolean r200_blit(struct r200_context *r200, reg_width, reg_height, flip_y); - radeonFlush(r200->radeon.glCtx); + radeonFlush(ctx); return GL_TRUE; } diff --git a/src/mesa/drivers/dri/r200/r200_blit.h b/src/mesa/drivers/dri/r200/r200_blit.h index 2d0e893623..38487266ae 100644 --- a/src/mesa/drivers/dri/r200/r200_blit.h +++ b/src/mesa/drivers/dri/r200/r200_blit.h @@ -30,25 +30,25 @@ void r200_blit_init(struct r200_context *r200); -GLboolean r200_blit(struct r200_context *r200, - struct radeon_bo *src_bo, - intptr_t src_offset, - gl_format src_mesaformat, - unsigned src_pitch, - unsigned src_width, - unsigned src_height, - unsigned src_x_offset, - unsigned src_y_offset, - struct radeon_bo *dst_bo, - intptr_t dst_offset, - gl_format dst_mesaformat, - unsigned dst_pitch, - unsigned dst_width, - unsigned dst_height, - unsigned dst_x_offset, - unsigned dst_y_offset, - unsigned width, - unsigned height, - unsigned flip_y); +unsigned r200_blit(GLcontext *ctx, + struct radeon_bo *src_bo, + intptr_t src_offset, + gl_format src_mesaformat, + unsigned src_pitch, + unsigned src_width, + unsigned src_height, + unsigned src_x_offset, + unsigned src_y_offset, + struct radeon_bo *dst_bo, + intptr_t dst_offset, + gl_format dst_mesaformat, + unsigned dst_pitch, + unsigned dst_width, + unsigned dst_height, + unsigned dst_x_offset, + unsigned dst_y_offset, + unsigned width, + unsigned height, + unsigned flip_y); #endif // R200_BLIT_H diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c index 217004c265..3d6d0f5ec0 100644 --- a/src/mesa/drivers/dri/r200/r200_context.c +++ b/src/mesa/drivers/dri/r200/r200_context.c @@ -61,6 +61,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r200_maos.h" #include "r200_vertprog.h" #include "radeon_queryobj.h" +#include "r200_blit.h" #include "radeon_span.h" @@ -268,6 +269,7 @@ static void r200_init_vtbl(radeonContextPtr radeon) radeon->vtbl.fallback = r200Fallback; radeon->vtbl.update_scissor = r200_vtbl_update_scissor; radeon->vtbl.emit_query_finish = r200_emit_query_finish; + radeon->vtbl.blit = r200_blit; } @@ -327,7 +329,7 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, r200InitDriverFuncs(&functions); r200InitIoctlFuncs(&functions); r200InitStateFuncs(&functions); - r200InitTextureFuncs(&functions); + r200InitTextureFuncs(&rmesa->radeon, &functions); r200InitShaderFuncs(&functions); radeonInitQueryObjFunctions(&functions); diff --git a/src/mesa/drivers/dri/r200/r200_tex.c b/src/mesa/drivers/dri/r200/r200_tex.c index 5b87ba6ccd..0916df6476 100644 --- a/src/mesa/drivers/dri/r200/r200_tex.c +++ b/src/mesa/drivers/dri/r200/r200_tex.c @@ -477,7 +477,7 @@ static struct gl_texture_object *r200NewTextureObject(GLcontext * ctx, -void r200InitTextureFuncs( struct dd_function_table *functions ) +void r200InitTextureFuncs( radeonContextPtr radeon, struct dd_function_table *functions ) { /* Note: we only plug in the functions we implement in the driver * since _mesa_init_driver_functions() was already called. @@ -511,6 +511,11 @@ void r200InitTextureFuncs( struct dd_function_table *functions ) functions->CompressedTexImage2D = radeonCompressedTexImage2D; functions->CompressedTexSubImage2D = radeonCompressedTexSubImage2D; + if (radeon->radeonScreen->kernel_mm) { + functions->CopyTexImage2D = radeonCopyTexImage2D; + functions->CopyTexSubImage2D = radeonCopyTexSubImage2D; + } + functions->GenerateMipmap = radeonGenerateMipmap; functions->NewTextureImage = radeonNewTextureImage; diff --git a/src/mesa/drivers/dri/r200/r200_tex.h b/src/mesa/drivers/dri/r200/r200_tex.h index e122de6e5e..1a1e7038df 100644 --- a/src/mesa/drivers/dri/r200/r200_tex.h +++ b/src/mesa/drivers/dri/r200/r200_tex.h @@ -48,7 +48,7 @@ extern int r200UploadTexImages( r200ContextPtr rmesa, radeonTexObjPtr t, GLuint extern void r200DestroyTexObj( r200ContextPtr rmesa, radeonTexObjPtr t ); -extern void r200InitTextureFuncs( struct dd_function_table *functions ); +extern void r200InitTextureFuncs( radeonContextPtr radeon, struct dd_function_table *functions ); extern void r200UpdateFragmentShader( GLcontext *ctx ); diff --git a/src/mesa/drivers/dri/r200/r200_texcopy.c b/src/mesa/drivers/dri/r200/r200_texcopy.c deleted file mode 100644 index cdb6cd7bdf..0000000000 --- a/src/mesa/drivers/dri/r200/r200_texcopy.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (C) 2009 Maciej Cencora - * - * All Rights Reserved. - * - * 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 COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS 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. - * - */ - -#include "radeon_common.h" -#include "r200_context.h" - -#include "main/image.h" -#include "main/teximage.h" -#include "main/texstate.h" -#include "drivers/common/meta.h" - -#include "radeon_mipmap_tree.h" -#include "r200_blit.h" -#include
- -// TODO: -// need to pass correct pitch for small dst textures! -static GLboolean -do_copy_texsubimage(GLcontext *ctx, - GLenum target, GLint level, - struct radeon_tex_obj *tobj, - radeon_texture_image *timg, - GLint dstx, GLint dsty, - GLint x, GLint y, - GLsizei width, GLsizei height) -{ - struct r200_context *r200 = R200_CONTEXT(ctx); - struct radeon_renderbuffer *rrb; - - if (_mesa_get_format_bits(timg->base.TexFormat, GL_DEPTH_BITS) > 0) { - rrb = radeon_get_depthbuffer(&r200->radeon); - } else { - rrb = radeon_get_colorbuffer(&r200->radeon); - } - - if (!timg->mt) { - radeon_validate_texture_miptree(ctx, &tobj->base); - } - - assert(rrb && rrb->bo); - assert(timg->mt->bo); - assert(timg->base.Width >= dstx + width); - assert(timg->base.Height >= dsty + height); - - intptr_t src_offset = rrb->draw_offset; - intptr_t dst_offset = radeon_miptree_image_offset(timg->mt, _mesa_tex_target_to_face(target), level); - - if (src_offset % 32 || dst_offset % 32) { - return GL_FALSE; - } - - if (0) { - fprintf(stderr, "%s: copying to face %d, level %d\n", - __FUNCTION__, _mesa_tex_target_to_face(target), level); - fprintf(stderr, "to: x %d, y %d, offset %d\n", dstx, dsty, (uint32_t) dst_offset); - fprintf(stderr, "from (%dx%d) width %d, height %d, offset %d, pitch %d\n", - x, y, rrb->base.Width, rrb->base.Height, (uint32_t) src_offset, rrb->pitch/rrb->cpp); - fprintf(stderr, "src size %d, dst size %d\n", rrb->bo->size, timg->mt->bo->size); - - } - - /* blit from src buffer to texture */ - return r200_blit(r200, rrb->bo, src_offset, rrb->base.Format, rrb->pitch, - rrb->base.Width, rrb->base.Height, x, y, - timg->mt->bo, dst_offset, timg->base.TexFormat, - timg->base.Width, timg->base.Width, timg->base.Height, - dstx, dsty, width, height, 1); -} - -static void -r200CopyTexImage2D(GLcontext *ctx, GLenum target, GLint level, - GLenum internalFormat, - GLint x, GLint y, GLsizei width, GLsizei height, - GLint border) -{ - struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); - struct gl_texture_object *texObj = - _mesa_select_tex_object(ctx, texUnit, target); - struct gl_texture_image *texImage = - _mesa_select_tex_image(ctx, texObj, target, level); - int srcx, srcy, dstx, dsty; - - if (border) - goto fail; - - /* Setup or redefine the texture object, mipmap tree and texture - * image. Don't populate yet. - */ - ctx->Driver.TexImage2D(ctx, target, level, internalFormat, - width, height, border, - GL_RGBA, GL_UNSIGNED_BYTE, NULL, - &ctx->DefaultPacking, texObj, texImage); - - srcx = x; - srcy = y; - dstx = 0; - dsty = 0; - if (!_mesa_clip_copytexsubimage(ctx, - &dstx, &dsty, - &srcx, &srcy, - &width, &height)) { - return; - } - - if (!do_copy_texsubimage(ctx, target, level, - radeon_tex_obj(texObj), (radeon_texture_image *)texImage, - 0, 0, x, y, width, height)) { - goto fail; - } - - return; - -fail: - _mesa_meta_CopyTexImage2D(ctx, target, level, internalFormat, x, y, - width, height, border); -} - -static void -r200CopyTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, - GLsizei width, GLsizei height) -{ - struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx); - struct gl_texture_object *texObj = _mesa_select_tex_object(ctx, texUnit, target); - struct gl_texture_image *texImage = _mesa_select_tex_image(ctx, texObj, target, level); - - if (!do_copy_texsubimage(ctx, target, level, - radeon_tex_obj(texObj), (radeon_texture_image *)texImage, - xoffset, yoffset, x, y, width, height)) { - - //DEBUG_FALLBACKS - - _mesa_meta_CopyTexSubImage2D(ctx, target, level, - xoffset, yoffset, x, y, width, height); - } -} - - -void r200_init_texcopy_functions(struct dd_function_table *table) -{ - table->CopyTexImage2D = r200CopyTexImage2D; - table->CopyTexSubImage2D = r200CopyTexSubImage2D; -} -- cgit v1.2.3 From 1f0709fd8f69bf8cc3e9502bad8d3e7296d935fb Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Wed, 20 Jan 2010 00:09:11 +0100 Subject: r100/r200: align to pitch updates in blit interface --- src/mesa/drivers/dri/r200/r200_blit.c | 4 ++-- src/mesa/drivers/dri/radeon/radeon_blit.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/r200/r200_blit.c b/src/mesa/drivers/dri/r200/r200_blit.c index 2122584363..8b9bad1c78 100644 --- a/src/mesa/drivers/dri/r200/r200_blit.c +++ b/src/mesa/drivers/dri/r200/r200_blit.c @@ -146,7 +146,7 @@ static void inline emit_tx_setup(struct r200_context *r200, OUT_BATCH_REGVAL(R200_PP_TXFORMAT_X_0, 0); OUT_BATCH_REGVAL(R200_PP_TXSIZE_0, ((width - 1) | ((height - 1) << RADEON_TEX_VSIZE_SHIFT))); - OUT_BATCH_REGVAL(R200_PP_TXPITCH_0, pitch - 32); + OUT_BATCH_REGVAL(R200_PP_TXPITCH_0, pitch * _mesa_get_format_bytes(mesa_format) - 32); OUT_BATCH_REGSEQ(R200_PP_TXOFFSET_0, 1); OUT_BATCH_RELOC(0, bo, 0, RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0); @@ -162,7 +162,7 @@ static inline void emit_cb_setup(struct r200_context *r200, unsigned width, unsigned height) { - uint32_t dst_pitch = pitch; + uint32_t dst_pitch = pitch * _mesa_get_format_bytes(mesa_format); uint32_t dst_format = 0; BATCH_LOCALS(&r200->radeon); diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.c b/src/mesa/drivers/dri/radeon/radeon_blit.c index c1bb51a6ef..ff32b7d69e 100644 --- a/src/mesa/drivers/dri/radeon/radeon_blit.c +++ b/src/mesa/drivers/dri/radeon/radeon_blit.c @@ -141,7 +141,7 @@ static void inline emit_tx_setup(struct r100_context *r100, OUT_BATCH_REGVAL(RADEON_PP_TXFORMAT_0, txformat); OUT_BATCH_REGVAL(RADEON_PP_TEX_SIZE_0, ((width - 1) | ((height - 1) << RADEON_TEX_VSIZE_SHIFT))); - OUT_BATCH_REGVAL(RADEON_PP_TEX_PITCH_0, pitch - 32); + OUT_BATCH_REGVAL(RADEON_PP_TEX_PITCH_0, pitch * _mesa_get_format_bytes(mesa_format) - 32); OUT_BATCH_REGSEQ(RADEON_PP_TXOFFSET_0, 1); OUT_BATCH_RELOC(0, bo, 0, RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0); @@ -157,7 +157,7 @@ static inline void emit_cb_setup(struct r100_context *r100, unsigned width, unsigned height) { - uint32_t dst_pitch = pitch; + uint32_t dst_pitch = pitch * _mesa_get_format_bytes(mesa_format); uint32_t dst_format = 0; BATCH_LOCALS(&r100->radeon); -- cgit v1.2.3 From f965345ea54a46cd9fcfd3bf24d078defd128425 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Tue, 19 Jan 2010 18:48:36 -0500 Subject: r200: add missing symlink to radeon_tex_copy.c --- src/mesa/drivers/dri/r200/radeon_tex_copy.c | 1 + 1 file changed, 1 insertion(+) create mode 120000 src/mesa/drivers/dri/r200/radeon_tex_copy.c diff --git a/src/mesa/drivers/dri/r200/radeon_tex_copy.c b/src/mesa/drivers/dri/r200/radeon_tex_copy.c new file mode 120000 index 0000000000..dfa5ba34e6 --- /dev/null +++ b/src/mesa/drivers/dri/r200/radeon_tex_copy.c @@ -0,0 +1 @@ +../radeon/radeon_tex_copy.c \ No newline at end of file -- cgit v1.2.3 From 1bb6b1d9dbabafdb864ee112526b1212744ac614 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Tue, 19 Jan 2010 18:52:19 -0500 Subject: r100/r200: fix dst pitch in blit code --- src/mesa/drivers/dri/r200/r200_blit.c | 2 +- src/mesa/drivers/dri/radeon/radeon_blit.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/r200/r200_blit.c b/src/mesa/drivers/dri/r200/r200_blit.c index 8b9bad1c78..8d9c976916 100644 --- a/src/mesa/drivers/dri/r200/r200_blit.c +++ b/src/mesa/drivers/dri/r200/r200_blit.c @@ -162,7 +162,7 @@ static inline void emit_cb_setup(struct r200_context *r200, unsigned width, unsigned height) { - uint32_t dst_pitch = pitch * _mesa_get_format_bytes(mesa_format); + uint32_t dst_pitch = pitch; uint32_t dst_format = 0; BATCH_LOCALS(&r200->radeon); diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.c b/src/mesa/drivers/dri/radeon/radeon_blit.c index ff32b7d69e..c40f21c774 100644 --- a/src/mesa/drivers/dri/radeon/radeon_blit.c +++ b/src/mesa/drivers/dri/radeon/radeon_blit.c @@ -157,7 +157,7 @@ static inline void emit_cb_setup(struct r100_context *r100, unsigned width, unsigned height) { - uint32_t dst_pitch = pitch * _mesa_get_format_bytes(mesa_format); + uint32_t dst_pitch = pitch; uint32_t dst_format = 0; BATCH_LOCALS(&r100->radeon); -- cgit v1.2.3 From 76cf2618327a7f008dcfd0d91d64d6d9e01f9a9c Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Tue, 19 Jan 2010 19:13:26 -0500 Subject: r100/r200: fix Y coord flipping in accelerated blits --- src/mesa/drivers/dri/r200/r200_blit.c | 11 +++++------ src/mesa/drivers/dri/radeon/radeon_blit.c | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/mesa/drivers/dri/r200/r200_blit.c b/src/mesa/drivers/dri/r200/r200_blit.c index 8d9c976916..f899f7efdc 100644 --- a/src/mesa/drivers/dri/r200/r200_blit.c +++ b/src/mesa/drivers/dri/r200/r200_blit.c @@ -241,9 +241,8 @@ static inline void calc_tex_coords(float img_width, float img_height, buf[3] = buf[2] + reg_height / img_height; if (flip_y) { - float tmp = buf[2]; - buf[2] = 1.0 - buf[3]; - buf[3] = 1.0 - tmp; + buf[2] = 1.0 - buf[1]; + buf[3] = 1.0 - buf[3]; } } @@ -266,17 +265,17 @@ static inline void emit_draw_packet(struct r200_context *r200, verts[0] = dst_x_offset; verts[1] = dst_y_offset + reg_height; verts[2] = texcoords[0]; - verts[3] = texcoords[2]; + verts[3] = texcoords[3]; verts[4] = dst_x_offset + reg_width; verts[5] = dst_y_offset + reg_height; verts[6] = texcoords[1]; - verts[7] = texcoords[2]; + verts[7] = texcoords[3]; verts[8] = dst_x_offset + reg_width; verts[9] = dst_y_offset; verts[10] = texcoords[1]; - verts[11] = texcoords[3]; + verts[11] = texcoords[2]; BEGIN_BATCH(14); OUT_BATCH(R200_CP_CMD_3D_DRAW_IMMD_2 | (12 << 16)); diff --git a/src/mesa/drivers/dri/radeon/radeon_blit.c b/src/mesa/drivers/dri/radeon/radeon_blit.c index c40f21c774..0df4fbb33c 100644 --- a/src/mesa/drivers/dri/radeon/radeon_blit.c +++ b/src/mesa/drivers/dri/radeon/radeon_blit.c @@ -234,9 +234,8 @@ static inline void calc_tex_coords(float img_width, float img_height, buf[3] = buf[2] + reg_height / img_height; if (flip_y) { - float tmp = buf[2]; - buf[2] = 1.0 - buf[3]; - buf[3] = 1.0 - tmp; + buf[2] = 1.0 - buf[2]; + buf[3] = 1.0 - buf[3]; } } @@ -259,17 +258,17 @@ static inline void emit_draw_packet(struct r100_context *r100, verts[0] = dst_x_offset; verts[1] = dst_y_offset + reg_height; verts[2] = texcoords[0]; - verts[3] = texcoords[2]; + verts[3] = texcoords[3]; verts[4] = dst_x_offset + reg_width; verts[5] = dst_y_offset + reg_height; verts[6] = texcoords[1]; - verts[7] = texcoords[2]; + verts[7] = texcoords[3]; verts[8] = dst_x_offset + reg_width; verts[9] = dst_y_offset; verts[10] = texcoords[1]; - verts[11] = texcoords[3]; + verts[11] = texcoords[2]; BEGIN_BATCH(15); OUT_BATCH(RADEON_CP_PACKET3_3D_DRAW_IMMD | (13 << 16)); -- cgit v1.2.3 From cd232ae22f9590976d0fabd1eb0e75c4d58d96bf Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Wed, 6 Jan 2010 14:27:50 +0100 Subject: st/mesa: enable EXT_framebuffer_multisample Signed-off-by: Brian Paul --- src/mesa/state_tracker/st_extensions.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 35e08749df..a94236b522 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -168,6 +168,7 @@ void st_init_extensions(struct st_context *st) ctx->Extensions.EXT_blend_subtract = GL_TRUE; ctx->Extensions.EXT_framebuffer_blit = GL_TRUE; ctx->Extensions.EXT_framebuffer_object = GL_TRUE; + ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE; ctx->Extensions.EXT_fog_coord = GL_TRUE; ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE; ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE; -- cgit v1.2.3 From 031f23ac3a3a9219f93268fb4517ab0f80d9be42 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 19 Jan 2010 17:59:50 -0700 Subject: mesa: added comment about future FBO formats --- src/mesa/main/fbobject.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 7b3599f932..4da245ab49 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -861,6 +861,9 @@ _mesa_GenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers) * * \return one of GL_RGB, GL_RGBA, GL_STENCIL_INDEX, GL_DEPTH_COMPONENT * GL_DEPTH_STENCIL_EXT or zero if error. + * + * XXX in the future when we support red-only and red-green formats + * we'll also return GL_RED and GL_RG. */ GLenum _mesa_base_fbo_format(GLcontext *ctx, GLenum internalFormat) -- cgit v1.2.3 From 1658f80153b84d7d7f0bebeaaf89f9850f782923 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 19 Jan 2010 18:00:26 -0700 Subject: util/blit: document params to util_blit_pixels_writemask() --- src/gallium/auxiliary/util/u_blit.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index 3f74e2aa8b..9725890bd4 100644 --- a/src/gallium/auxiliary/util/u_blit.c +++ b/src/gallium/auxiliary/util/u_blit.c @@ -262,6 +262,10 @@ regions_overlap(int srcX0, int srcY0, * Copy pixel block from src surface to dst surface. * Overlapping regions are acceptable. * Flipping and stretching are supported. + * \param filter one of PIPE_TEX_MIPFILTER_NEAREST/LINEAR + * \param writemask controls which channels in the dest surface are sourced + * from the src surface. Disabled channels are sourced + * from (0,0,0,1). * XXX what about clipping??? * XXX need some control over blitting Z and/or stencil. */ -- cgit v1.2.3 From fcbd285e421903ee0a65f19f5d633b25b5923c24 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Tue, 19 Jan 2010 17:56:12 -0800 Subject: r300g: Make invariant state into an atom. --- src/gallium/drivers/r300/r300_context.c | 3 ++- src/gallium/drivers/r300/r300_context.h | 3 +++ src/gallium/drivers/r300/r300_flush.c | 1 - src/gallium/drivers/r300/r300_state_invariant.c | 2 +- src/gallium/drivers/r300/r300_state_invariant.h | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 94a9ab3ef3..67ddec140a 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -129,6 +129,7 @@ static void r300_setup_atoms(struct r300_context* r300) * an upper bound on each atom, to keep the emission machinery from * underallocating space. */ make_empty_list(&r300->atom_list); + R300_INIT_ATOM(invariant, 73); R300_INIT_ATOM(ztop, 2); R300_INIT_ATOM(blend, 8); R300_INIT_ATOM(blend_color, 3); @@ -208,7 +209,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, r300_init_state_functions(r300); - r300_emit_invariant_state(r300); + r300->invariant_state.dirty = TRUE; r300->winsys->set_flush_cb(r300->winsys, r300_flush_cb, r300); r300->dirty_state = R300_NEW_KITCHEN_SINK; diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 5e33dc042a..ec8940f420 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -313,6 +313,9 @@ struct r300_context { /* ZTOP state. */ struct r300_atom ztop_state; + /* Invariant state. This must be emitted to get the engine started. */ + struct r300_atom invariant_state; + /* Vertex buffers for Gallium. */ struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; int vertex_buffer_count; diff --git a/src/gallium/drivers/r300/r300_flush.c b/src/gallium/drivers/r300/r300_flush.c index 59819cb106..15e612d8a6 100644 --- a/src/gallium/drivers/r300/r300_flush.c +++ b/src/gallium/drivers/r300/r300_flush.c @@ -53,7 +53,6 @@ static void r300_flush(struct pipe_context* pipe, if (r300->dirty_hw) { FLUSH_CS; - r300_emit_invariant_state(r300); r300->dirty_state = R300_NEW_KITCHEN_SINK; r300->dirty_hw = 0; diff --git a/src/gallium/drivers/r300/r300_state_invariant.c b/src/gallium/drivers/r300/r300_state_invariant.c index 47d7e60a40..f31b2e30df 100644 --- a/src/gallium/drivers/r300/r300_state_invariant.c +++ b/src/gallium/drivers/r300/r300_state_invariant.c @@ -38,7 +38,7 @@ struct pipe_viewport_state r300_viewport_identity = { * * Note that eventually this should be empty, but it's useful for development * and general unduplication of code. */ -void r300_emit_invariant_state(struct r300_context* r300) +void r300_emit_invariant_state(struct r300_context* r300, void* state) { struct r300_capabilities* caps = r300_screen(r300->context.screen)->caps; CS_LOCALS(r300); diff --git a/src/gallium/drivers/r300/r300_state_invariant.h b/src/gallium/drivers/r300/r300_state_invariant.h index 05cff0d6df..5d1a963654 100644 --- a/src/gallium/drivers/r300/r300_state_invariant.h +++ b/src/gallium/drivers/r300/r300_state_invariant.h @@ -25,6 +25,6 @@ struct r300_context; -void r300_emit_invariant_state(struct r300_context* r300); +void r300_emit_invariant_state(struct r300_context* r300, void* state); #endif /* R300_STATE_INVARIANT_H */ -- cgit v1.2.3 From d4a3f7d3ca377b77aa8c268037740a5372a2bdbd Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Tue, 19 Jan 2010 18:09:28 -0800 Subject: r300g: Move GB_AA_CONFIG to its eventual new home. --- src/gallium/drivers/r300/r300_context.c | 4 ++-- src/gallium/drivers/r300/r300_context.h | 1 + src/gallium/drivers/r300/r300_emit.c | 5 ++++- src/gallium/drivers/r300/r300_state_invariant.c | 4 +--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 67ddec140a..3bf9c8b18d 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -129,13 +129,13 @@ static void r300_setup_atoms(struct r300_context* r300) * an upper bound on each atom, to keep the emission machinery from * underallocating space. */ make_empty_list(&r300->atom_list); - R300_INIT_ATOM(invariant, 73); + R300_INIT_ATOM(invariant, 71); R300_INIT_ATOM(ztop, 2); R300_INIT_ATOM(blend, 8); R300_INIT_ATOM(blend_color, 3); R300_INIT_ATOM(clip, 29); R300_INIT_ATOM(dsa, 8); - R300_INIT_ATOM(rs, 22); + R300_INIT_ATOM(rs, 25); R300_INIT_ATOM(scissor, 3); R300_INIT_ATOM(viewport, 9); } diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index ec8940f420..48c86fdad7 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -84,6 +84,7 @@ struct r300_rs_state { struct pipe_rasterizer_state rs; uint32_t vap_control_status; /* R300_VAP_CNTL_STATUS: 0x2140 */ + uint32_t antialiasing_config; /* R300_GB_AA_CONFIG: 0x4020 */ uint32_t point_size; /* R300_GA_POINT_SIZE: 0x421c */ uint32_t point_minmax; /* R300_GA_POINT_MINMAX: 0x4230 */ uint32_t line_control; /* R300_GA_LINE_CNTL: 0x4234 */ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 2ea9fab015..921170aef1 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -587,8 +587,11 @@ void r300_emit_rs_state(struct r300_context* r300, void* state) float scale, offset; CS_LOCALS(r300); - BEGIN_CS(18 + (rs->polygon_offset_enable ? 5 : 0)); + BEGIN_CS(20 + (rs->polygon_offset_enable ? 5 : 0)); OUT_CS_REG(R300_VAP_CNTL_STATUS, rs->vap_control_status); + + OUT_CS_REG(R300_GB_AA_CONFIG, rs->antialiasing_config); + OUT_CS_REG(R300_GA_POINT_SIZE, rs->point_size); OUT_CS_REG_SEQ(R300_GA_POINT_MINMAX, 2); OUT_CS(rs->point_minmax); diff --git a/src/gallium/drivers/r300/r300_state_invariant.c b/src/gallium/drivers/r300/r300_state_invariant.c index f31b2e30df..97927acf1b 100644 --- a/src/gallium/drivers/r300/r300_state_invariant.c +++ b/src/gallium/drivers/r300/r300_state_invariant.c @@ -43,7 +43,7 @@ void r300_emit_invariant_state(struct r300_context* r300, void* state) struct r300_capabilities* caps = r300_screen(r300->context.screen)->caps; CS_LOCALS(r300); - BEGIN_CS(16 + (caps->has_tcl ? 2: 0)); + BEGIN_CS(14 + (caps->has_tcl ? 2: 0)); /*** Graphics Backend (GB) ***/ /* Various GB enables */ @@ -58,8 +58,6 @@ void r300_emit_invariant_state(struct r300_context* r300, void* state) */ /* Source of fog depth */ OUT_CS_REG(R300_GB_SELECT, R300_GB_FOG_SELECT_1_1_W); - /* AA enable */ - OUT_CS_REG(R300_GB_AA_CONFIG, 0x0); /*** Fog (FG) ***/ OUT_CS_REG(R300_FG_FOG_BLEND, 0x0); -- cgit v1.2.3 From 917b6d2a4b0e330e34e06b3c37ebc906f974b26b Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Mon, 5 Oct 2009 12:56:03 -0700 Subject: Remove hardcoded -Wall from Radeon DRI makefiles Signed-off-by: Alan Coopersmith Signed-off-by: Brian Paul --- src/mesa/drivers/dri/r200/Makefile | 2 +- src/mesa/drivers/dri/r300/Makefile | 1 - src/mesa/drivers/dri/r600/Makefile | 3 +-- src/mesa/drivers/dri/radeon/Makefile | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/r200/Makefile b/src/mesa/drivers/dri/r200/Makefile index ca33faff87..a93dbaee91 100644 --- a/src/mesa/drivers/dri/r200/Makefile +++ b/src/mesa/drivers/dri/r200/Makefile @@ -56,7 +56,7 @@ C_SOURCES = $(COMMON_SOURCES) $(DRIVER_SOURCES) X86_SOURCES = -DRIVER_DEFINES = -DRADEON_R200 -Wall +DRIVER_DEFINES = -DRADEON_R200 DRI_LIB_DEPS += $(RADEON_LDFLAGS) diff --git a/src/mesa/drivers/dri/r300/Makefile b/src/mesa/drivers/dri/r300/Makefile index 0d0fbcc408..acc4d4d8b1 100644 --- a/src/mesa/drivers/dri/r300/Makefile +++ b/src/mesa/drivers/dri/r300/Makefile @@ -66,7 +66,6 @@ C_SOURCES = $(COMMON_SOURCES) $(DRIVER_SOURCES) DRIVER_DEFINES = -DRADEON_R300 # -DRADEON_BO_TRACK \ - -Wall DRI_LIB_DEPS += $(RADEON_LDFLAGS) diff --git a/src/mesa/drivers/dri/r600/Makefile b/src/mesa/drivers/dri/r600/Makefile index e55d0babd8..8a45fc51b3 100644 --- a/src/mesa/drivers/dri/r600/Makefile +++ b/src/mesa/drivers/dri/r600/Makefile @@ -68,9 +68,8 @@ DRIVER_SOURCES = \ C_SOURCES = $(COMMON_SOURCES) $(DRIVER_SOURCES) -DRIVER_DEFINES = -DRADEON_R600 \ +DRIVER_DEFINES = -DRADEON_R600 # -DRADEON_BO_TRACK \ - -Wall DRI_LIB_DEPS += $(RADEON_LDFLAGS) diff --git a/src/mesa/drivers/dri/radeon/Makefile b/src/mesa/drivers/dri/radeon/Makefile index c776be0e60..a54ea16ec6 100644 --- a/src/mesa/drivers/dri/radeon/Makefile +++ b/src/mesa/drivers/dri/radeon/Makefile @@ -49,7 +49,7 @@ C_SOURCES = \ $(DRIVER_SOURCES) \ $(CS_SOURCES) -DRIVER_DEFINES = -DRADEON_R100 -Wall +DRIVER_DEFINES = -DRADEON_R100 DRI_LIB_DEPS += $(RADEON_LDFLAGS) -- cgit v1.2.3 From 77c08003819e8e2c922271c859bceb2b9c9234b7 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Tue, 19 Jan 2010 18:13:14 -0800 Subject: mklib: Fix static library generation/installation on Solaris Change ar flag from -v (-verbose) to -c (silence console output) so that it stops causing make_ar_static_lib() to return a bunch of output other than the resulting library file. Signed-off-by: Alan Coopersmith --- bin/mklib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/mklib b/bin/mklib index 9799a4ed27..9e6e46de8b 100755 --- a/bin/mklib +++ b/bin/mklib @@ -441,7 +441,7 @@ case $ARCH in if [ $STATIC = 1 ] ; then LIBNAME="lib${LIBNAME}.a" echo "mklib: Making SunOS static library: " ${LIBNAME} - FINAL_LIBS=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}` + FINAL_LIBS=`make_ar_static_lib -ruc 0 ${LIBNAME} ${OBJECTS}` else if [ $NOPREFIX = 0 ] ; then LIBNAME="lib${LIBNAME}.so" -- cgit v1.2.3 From f291200a4bbc0b701cfe831bdeeb79f90efd866f Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 20 Jan 2010 13:24:42 +0800 Subject: st/egl_g3d: Do not reuse the pipe transfer in ximage. A pipe transfer is supposed to be temporary. It should be created before X*PutImage and destroyed afterwards. --- .../state_trackers/egl_g3d/x11/native_ximage.c | 40 ++++++++++++---------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c b/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c index d76107c47f..dfa8df2223 100644 --- a/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c +++ b/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c @@ -66,7 +66,6 @@ struct ximage_buffer { XImage *ximage; struct pipe_texture *texture; - struct pipe_transfer *transfer; XShmSegmentInfo *shm_info; boolean xshm_attached; }; @@ -115,12 +114,7 @@ ximage_surface_free_buffer(struct native_surface *nsurf, { struct ximage_surface *xsurf = ximage_surface(nsurf); struct ximage_buffer *xbuf = &xsurf->buffers[which]; - struct pipe_screen *screen = xsurf->xdpy->base.screen; - if (xbuf->transfer) { - screen->tex_transfer_destroy(xbuf->transfer); - xbuf->transfer = NULL; - } pipe_texture_reference(&xbuf->texture, NULL); if (xbuf->shm_info) { @@ -193,13 +187,6 @@ ximage_surface_alloc_buffer(struct native_surface *nsurf, xbuf->texture = screen->texture_create(screen, &templ); } - if (xbuf->texture) { - xbuf->transfer = screen->get_tex_transfer(screen, xbuf->texture, - 0, 0, 0, PIPE_TRANSFER_READ, 0, 0, xsurf->width, xsurf->height); - if (!xbuf->transfer) - pipe_texture_reference(&xbuf->texture, NULL); - } - /* clean up the buffer if allocation failed */ if (!xbuf->texture) ximage_surface_free_buffer(&xsurf->base, which); @@ -214,13 +201,25 @@ ximage_surface_draw_buffer(struct native_surface *nsurf, struct ximage_surface *xsurf = ximage_surface(nsurf); struct ximage_buffer *xbuf = &xsurf->buffers[which]; struct pipe_screen *screen = xsurf->xdpy->base.screen; + struct pipe_transfer *transfer; if (xsurf->type == XIMAGE_SURFACE_TYPE_PBUFFER) return TRUE; assert(xsurf->drawable && xbuf->ximage && xbuf->texture); - xbuf->ximage->data = screen->transfer_map(screen, xbuf->transfer); + transfer = screen->get_tex_transfer(screen, xbuf->texture, + 0, 0, 0, PIPE_TRANSFER_READ, 0, 0, xsurf->width, xsurf->height); + if (!transfer) + return FALSE; + + xbuf->ximage->bytes_per_line = transfer->stride; + xbuf->ximage->data = screen->transfer_map(screen, transfer); + if (!xbuf->ximage->data) { + screen->tex_transfer_destroy(transfer); + return FALSE; + } + if (xbuf->shm_info) XShmPutImage(xsurf->xdpy->dpy, xsurf->drawable, xsurf->gc, @@ -230,7 +229,13 @@ ximage_surface_draw_buffer(struct native_surface *nsurf, xbuf->ximage, 0, 0, 0, 0, xsurf->width, xsurf->height); xbuf->ximage->data = NULL; - screen->transfer_unmap(screen, xbuf->transfer); + screen->transfer_unmap(screen, transfer); + + /* + * softpipe allows the pipe transfer to be re-used, but we don't want to + * rely on that behavior. + */ + screen->tex_transfer_destroy(transfer); XSync(xsurf->xdpy->dpy, FALSE); @@ -314,9 +319,8 @@ ximage_surface_validate(struct native_surface *nsurf, uint attachment_mask, if (ximage_surface_alloc_buffer(&xsurf->base, att)) { /* update ximage */ if (xbuf->ximage) { - xbuf->ximage->width = xbuf->transfer->width; - xbuf->ximage->height = xbuf->transfer->height; - xbuf->ximage->bytes_per_line = xbuf->transfer->stride; + xbuf->ximage->width = xsurf->width; + xbuf->ximage->height = xsurf->height; } } } -- cgit v1.2.3 From ac2a665fd75249e02838ec63ef4a5b3db093ceb1 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Tue, 19 Jan 2010 22:47:03 -0800 Subject: i915g: Remove unnecessary headers. --- src/gallium/drivers/i915/i915_clear.c | 1 - src/gallium/drivers/i915/i915_context.c | 3 --- src/gallium/drivers/i915/i915_debug.c | 1 - src/gallium/drivers/i915/i915_debug_fp.c | 1 - src/gallium/drivers/i915/i915_state.c | 2 -- src/gallium/drivers/i915/i915_state_derived.c | 1 - src/gallium/drivers/i915/i915_state_sampler.c | 1 - src/gallium/drivers/i915/i915_surface.c | 5 ----- src/gallium/drivers/i915/i915_texture.c | 2 -- 9 files changed, 17 deletions(-) diff --git a/src/gallium/drivers/i915/i915_clear.c b/src/gallium/drivers/i915/i915_clear.c index 90530f2826..0d0859f8f3 100644 --- a/src/gallium/drivers/i915/i915_clear.c +++ b/src/gallium/drivers/i915/i915_clear.c @@ -32,7 +32,6 @@ #include "util/u_clear.h" #include "i915_context.h" -#include "i915_state.h" /** diff --git a/src/gallium/drivers/i915/i915_context.c b/src/gallium/drivers/i915/i915_context.c index 94c8aee30f..16ca638119 100644 --- a/src/gallium/drivers/i915/i915_context.c +++ b/src/gallium/drivers/i915/i915_context.c @@ -29,12 +29,9 @@ #include "i915_state.h" #include "i915_screen.h" #include "i915_batch.h" -#include "i915_texture.h" -#include "i915_reg.h" #include "draw/draw_context.h" #include "pipe/p_defines.h" -#include "pipe/internal/p_winsys_screen.h" #include "pipe/p_inlines.h" #include "util/u_memory.h" #include "pipe/p_screen.h" diff --git a/src/gallium/drivers/i915/i915_debug.c b/src/gallium/drivers/i915/i915_debug.c index c6e6d6fd31..237654d26b 100644 --- a/src/gallium/drivers/i915/i915_debug.c +++ b/src/gallium/drivers/i915/i915_debug.c @@ -29,7 +29,6 @@ #include "i915_context.h" #include "i915_debug.h" #include "i915_batch.h" -#include "pipe/internal/p_winsys_screen.h" #include "util/u_debug.h" diff --git a/src/gallium/drivers/i915/i915_debug_fp.c b/src/gallium/drivers/i915/i915_debug_fp.c index 9c5b117b6d..f9c40d8a11 100644 --- a/src/gallium/drivers/i915/i915_debug_fp.c +++ b/src/gallium/drivers/i915/i915_debug_fp.c @@ -29,7 +29,6 @@ #include "i915_reg.h" #include "i915_debug.h" #include "pipe/internal/p_winsys_screen.h" -#include "util/u_memory.h" static void diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c index a04668d32f..1c8cb91525 100644 --- a/src/gallium/drivers/i915/i915_state.c +++ b/src/gallium/drivers/i915/i915_state.c @@ -30,7 +30,6 @@ #include "draw/draw_context.h" -#include "pipe/internal/p_winsys_screen.h" #include "pipe/p_inlines.h" #include "util/u_math.h" #include "util/u_memory.h" @@ -38,7 +37,6 @@ #include "i915_context.h" #include "i915_reg.h" -#include "i915_state.h" #include "i915_state_inlines.h" #include "i915_fpc.h" diff --git a/src/gallium/drivers/i915/i915_state_derived.c b/src/gallium/drivers/i915/i915_state_derived.c index 178d4e8781..1373f9e097 100644 --- a/src/gallium/drivers/i915/i915_state_derived.c +++ b/src/gallium/drivers/i915/i915_state_derived.c @@ -33,7 +33,6 @@ #include "i915_context.h" #include "i915_state.h" #include "i915_reg.h" -#include "i915_fpc.h" diff --git a/src/gallium/drivers/i915/i915_state_sampler.c b/src/gallium/drivers/i915/i915_state_sampler.c index c5e9084d12..86a019d250 100644 --- a/src/gallium/drivers/i915/i915_state_sampler.c +++ b/src/gallium/drivers/i915/i915_state_sampler.c @@ -27,7 +27,6 @@ #include "pipe/p_context.h" #include "pipe/p_state.h" -#include "util/u_memory.h" #include "i915_state_inlines.h" #include "i915_context.h" diff --git a/src/gallium/drivers/i915/i915_surface.c b/src/gallium/drivers/i915/i915_surface.c index ab8331f3e6..9b4366daff 100644 --- a/src/gallium/drivers/i915/i915_surface.c +++ b/src/gallium/drivers/i915/i915_surface.c @@ -27,13 +27,8 @@ #include "i915_context.h" #include "i915_blit.h" -#include "i915_state.h" #include "pipe/p_defines.h" #include "pipe/p_inlines.h" -#include "pipe/p_inlines.h" -#include "pipe/internal/p_winsys_screen.h" -#include "util/u_tile.h" -#include "util/u_rect.h" /* Assumes all values are within bounds -- no checking at this level - diff --git a/src/gallium/drivers/i915/i915_texture.c b/src/gallium/drivers/i915/i915_texture.c index 286c9ace8e..9c0de8fa5f 100644 --- a/src/gallium/drivers/i915/i915_texture.c +++ b/src/gallium/drivers/i915/i915_texture.c @@ -34,13 +34,11 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_inlines.h" -#include "pipe/internal/p_winsys_screen.h" #include "util/u_math.h" #include "util/u_memory.h" #include "i915_context.h" #include "i915_texture.h" -#include "i915_debug.h" #include "i915_screen.h" #include "intel_winsys.h" -- cgit v1.2.3 From e3cb614f932ac417d446c84bd54f86d01b1cdcd9 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Wed, 20 Jan 2010 00:08:54 -0800 Subject: softpipe: Remove unnecessary headers. --- src/gallium/drivers/softpipe/sp_context.c | 1 - src/gallium/drivers/softpipe/sp_flush.c | 2 -- src/gallium/drivers/softpipe/sp_quad_blend.c | 1 - src/gallium/drivers/softpipe/sp_quad_depth_test.c | 1 - src/gallium/drivers/softpipe/sp_quad_fs.c | 2 -- src/gallium/drivers/softpipe/sp_setup.c | 1 - src/gallium/drivers/softpipe/sp_state_surface.c | 1 - src/gallium/drivers/softpipe/sp_state_vertex.c | 1 - src/gallium/drivers/softpipe/sp_tex_tile_cache.c | 1 - src/gallium/drivers/softpipe/sp_texture.c | 1 - 10 files changed, 12 deletions(-) diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index 5f60139968..beeb6f6b45 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -43,7 +43,6 @@ #include "sp_surface.h" #include "sp_tile_cache.h" #include "sp_tex_tile_cache.h" -#include "sp_texture.h" #include "sp_winsys.h" #include "sp_query.h" diff --git a/src/gallium/drivers/softpipe/sp_flush.c b/src/gallium/drivers/softpipe/sp_flush.c index e38b767cf2..db293a51a9 100644 --- a/src/gallium/drivers/softpipe/sp_flush.c +++ b/src/gallium/drivers/softpipe/sp_flush.c @@ -34,11 +34,9 @@ #include "draw/draw_context.h" #include "sp_flush.h" #include "sp_context.h" -#include "sp_surface.h" #include "sp_state.h" #include "sp_tile_cache.h" #include "sp_tex_tile_cache.h" -#include "sp_winsys.h" void diff --git a/src/gallium/drivers/softpipe/sp_quad_blend.c b/src/gallium/drivers/softpipe/sp_quad_blend.c index d9babe81da..3b8c2d5789 100644 --- a/src/gallium/drivers/softpipe/sp_quad_blend.c +++ b/src/gallium/drivers/softpipe/sp_quad_blend.c @@ -35,7 +35,6 @@ #include "util/u_memory.h" #include "sp_context.h" #include "sp_quad.h" -#include "sp_surface.h" #include "sp_tile_cache.h" #include "sp_quad_pipe.h" diff --git a/src/gallium/drivers/softpipe/sp_quad_depth_test.c b/src/gallium/drivers/softpipe/sp_quad_depth_test.c index 03f569d466..5cb17c5ae7 100644 --- a/src/gallium/drivers/softpipe/sp_quad_depth_test.c +++ b/src/gallium/drivers/softpipe/sp_quad_depth_test.c @@ -34,7 +34,6 @@ #include "tgsi/tgsi_scan.h" #include "sp_context.h" #include "sp_quad.h" -#include "sp_surface.h" #include "sp_quad_pipe.h" #include "sp_tile_cache.h" #include "sp_state.h" /* for sp_fragment_shader */ diff --git a/src/gallium/drivers/softpipe/sp_quad_fs.c b/src/gallium/drivers/softpipe/sp_quad_fs.c index 1e7533d0f9..e799df136e 100644 --- a/src/gallium/drivers/softpipe/sp_quad_fs.c +++ b/src/gallium/drivers/softpipe/sp_quad_fs.c @@ -45,8 +45,6 @@ #include "sp_state.h" #include "sp_quad.h" #include "sp_quad_pipe.h" -#include "sp_texture.h" -#include "sp_tex_sample.h" struct quad_shade_stage diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c index 615581b95f..478d8efd1b 100644 --- a/src/gallium/drivers/softpipe/sp_setup.c +++ b/src/gallium/drivers/softpipe/sp_setup.c @@ -41,7 +41,6 @@ #include "draw/draw_private.h" #include "draw/draw_vertex.h" #include "pipe/p_shader_tokens.h" -#include "pipe/p_thread.h" #include "util/u_math.h" #include "util/u_memory.h" diff --git a/src/gallium/drivers/softpipe/sp_state_surface.c b/src/gallium/drivers/softpipe/sp_state_surface.c index bc0e201130..794a9225b8 100644 --- a/src/gallium/drivers/softpipe/sp_state_surface.c +++ b/src/gallium/drivers/softpipe/sp_state_surface.c @@ -30,7 +30,6 @@ #include "sp_context.h" #include "sp_state.h" -#include "sp_surface.h" #include "sp_tile_cache.h" #include "draw/draw_context.h" diff --git a/src/gallium/drivers/softpipe/sp_state_vertex.c b/src/gallium/drivers/softpipe/sp_state_vertex.c index 46b6991195..b491d92ed1 100644 --- a/src/gallium/drivers/softpipe/sp_state_vertex.c +++ b/src/gallium/drivers/softpipe/sp_state_vertex.c @@ -31,7 +31,6 @@ #include "sp_context.h" #include "sp_state.h" -#include "sp_surface.h" #include "draw/draw_context.h" diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c index 407a22a9f4..0312a31460 100644 --- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c @@ -36,7 +36,6 @@ #include "util/u_memory.h" #include "util/u_tile.h" #include "sp_context.h" -#include "sp_surface.h" #include "sp_texture.h" #include "sp_tex_tile_cache.h" diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index 7caf2928b4..64a70bf44b 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -36,7 +36,6 @@ #include "util/u_memory.h" #include "sp_context.h" -#include "sp_state.h" #include "sp_texture.h" #include "sp_screen.h" #include "sp_winsys.h" -- cgit v1.2.3 From b3bcd33f7a8b32ce4ea6e979e9cc764d0f903ae9 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 19 Jan 2010 18:13:50 +0800 Subject: egl: Add _eglPreloadDrivers. It can be used to load the user driver specified by EGL_DRIVER, or a set of drivers specified by EGL_DISPLAY, or the default driver, and in that order. --- src/egl/main/Makefile | 5 ++ src/egl/main/egldriver.c | 211 +++++++++++++++++++++++++++++++++++++++++++++-- src/egl/main/egldriver.h | 6 +- 3 files changed, 215 insertions(+), 7 deletions(-) diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index ec326a845d..7386f6ea73 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -49,6 +49,11 @@ OBJECTS = $(SOURCES:.c=.o) # use dl*() to load drivers LOCAL_CFLAGS = -D_EGL_PLATFORM_X=1 +EGL_DEFAULT_DISPLAY = $(word 1, $(EGL_DISPLAYS)) + +LOCAL_CFLAGS += \ + -D_EGL_DEFAULT_DISPLAY=\"$(EGL_DEFAULT_DISPLAY)\" \ + -D_EGL_DRIVER_SEARCH_DIR=\"$(DRI_DRIVER_SEARCH_DIR)\" .c.o: $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $(LOCAL_CFLAGS) $< -o $@ diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 018b06d3be..5d603419a8 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -22,6 +22,8 @@ #if defined(_EGL_PLATFORM_X) #include +#include +#include #endif @@ -49,6 +51,13 @@ close_library(HMODULE lib) } +static const char * +library_suffix(void) +{ + return "dll"; +} + + #elif defined(_EGL_PLATFORM_X) @@ -68,6 +77,14 @@ close_library(void *lib) dlclose(lib); } + +static const char * +library_suffix(void) +{ + return "so"; +} + + #else /* _EGL_PLATFORM_NO_OS */ static const char DefaultDriverName[] = "builtin"; @@ -86,6 +103,13 @@ close_library(void *lib) } +static const char * +library_suffix(void) +{ + return NULL; +} + + #endif @@ -208,11 +232,10 @@ _eglOpenLibrary(const char *driverPath, lib_handle *handle) /** - * Load the named driver. The path and args passed will be - * owned by the driver and freed. + * Load the named driver. */ static _EGLDriver * -_eglLoadDriver(char *path, char *args) +_eglLoadDriver(const char *path, const char *args) { _EGLMain_t mainFunc; lib_handle lib; @@ -234,8 +257,19 @@ _eglLoadDriver(char *path, char *args) drv->Name = "UNNAMED"; } - drv->Path = path; - drv->Args = args; + drv->Path = _eglstrdup(path); + drv->Args = (args) ? _eglstrdup(args) : NULL; + if (!drv->Path || (args && !drv->Args)) { + if (drv->Path) + free((char *) drv->Path); + if (drv->Args) + free((char *) drv->Args); + drv->Unload(drv); + if (lib) + close_library(lib); + return NULL; + } + drv->LibHandle = lib; return drv; @@ -300,8 +334,12 @@ _eglPreloadDriver(_EGLDisplay *dpy) } drv = _eglLoadDriver(path, args); - if (!drv) + if (!drv) { + free(path); + if (args) + free(args); return NULL; + } _eglGlobal.Drivers[_eglGlobal.NumDrivers++] = drv; @@ -330,6 +368,167 @@ _eglCloseDriver(_EGLDriver *drv, _EGLDisplay *dpy) } +/** + * Preload a user driver. + * + * A user driver can be specified by EGL_DRIVER. + */ +static EGLBoolean +_eglPreloadUserDriver(void) +{ +#if defined(_EGL_PLATFORM_X) || defined(_EGL_PLATFORM_WINDOWS) + _EGLDriver *drv; + char *env, *path; + const char *suffix, *p; + + env = getenv("EGL_DRIVER"); + if (!env) + return EGL_FALSE; + + path = env; + suffix = library_suffix(); + + /* append suffix if there isn't */ + p = strrchr(path, '.'); + if (!p && suffix) { + size_t len = strlen(path); + char *tmp = malloc(len + strlen(suffix) + 2); + if (tmp) { + memcpy(tmp, path, len); + tmp[len++] = '.'; + tmp[len] = '\0'; + strcat(tmp + len, suffix); + + path = tmp; + } + } + + drv = _eglLoadDriver(path, NULL); + if (path != env) + free(path); + if (!drv) + return EGL_FALSE; + + _eglGlobal.Drivers[_eglGlobal.NumDrivers++] = drv; + + return EGL_TRUE; +#else /* _EGL_PLATFORM_X || _EGL_PLATFORM_WINDOWS */ + return EGL_FALSE; +#endif +} + + +/** + * Preload display drivers. + * + * Display drivers are a set of drivers that support a certain display system. + * The display system may be specified by EGL_DISPLAY. + * + * FIXME This makes libEGL a memory hog if an user driver is not specified and + * there are many display drivers. + */ +static EGLBoolean +_eglPreloadDisplayDrivers(void) +{ +#if defined(_EGL_PLATFORM_X) + const char *dpy, *suffix; + char path[1024], prefix[32]; + DIR *dirp; + struct dirent *dirent; + + dpy = getenv("EGL_DISPLAY"); + if (!dpy || !dpy[0]) + dpy = _EGL_DEFAULT_DISPLAY; + if (!dpy || !dpy[0]) + return EGL_FALSE; + + snprintf(prefix, sizeof(prefix), "egl_%s_", dpy); + suffix = library_suffix(); + + dirp = opendir(_EGL_DRIVER_SEARCH_DIR); + if (!dirp) + return EGL_FALSE; + + while ((dirent = readdir(dirp))) { + _EGLDriver *drv; + const char *p; + + /* match the prefix */ + if (strncmp(dirent->d_name, prefix, strlen(prefix)) != 0) + continue; + + /* match the suffix */ + p = strrchr(dirent->d_name, '.'); + if ((p && !suffix) || (!p && suffix)) + continue; + else if (p && suffix && strcmp(p + 1, suffix) != 0) + continue; + + snprintf(path, sizeof(path), + _EGL_DRIVER_SEARCH_DIR"/%s", dirent->d_name); + + drv = _eglLoadDriver(path, NULL); + if (drv) + _eglGlobal.Drivers[_eglGlobal.NumDrivers++] = drv; + } + + closedir(dirp); + + return (_eglGlobal.NumDrivers > 0); +#else /* _EGL_PLATFORM_X */ + return EGL_FALSE; +#endif +} + + +/** + * Preload the default driver. + */ +static EGLBoolean +_eglPreloadDefaultDriver(void) +{ + _EGLDriver *drv; + char path[1024]; + const char *suffix = library_suffix(); + + if (suffix) + snprintf(path, sizeof(path), "%s.%s", DefaultDriverName, suffix); + else + snprintf(path, sizeof(path), DefaultDriverName); + + drv = _eglLoadDriver(path, NULL); + if (!drv) + return EGL_FALSE; + + _eglGlobal.Drivers[_eglGlobal.NumDrivers++] = drv; + + return EGL_TRUE; +} + + +/** + * Preload drivers. + * + * This function loads the driver modules and creates the corresponding + * _EGLDriver objects. + */ +EGLBoolean +_eglPreloadDrivers(void) +{ + EGLBoolean loaded; + + /* already preloaded */ + if (_eglGlobal.NumDrivers) + return EGL_TRUE; + + loaded = (_eglPreloadUserDriver() || + _eglPreloadDisplayDrivers() || + _eglPreloadDefaultDriver()); + + return loaded; +} + + /** * Unload preloaded drivers. */ diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index 59bd1954aa..a474fa6871 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -41,7 +41,11 @@ extern EGLBoolean _eglCloseDriver(_EGLDriver *drv, _EGLDisplay *dpy); -void +extern EGLBoolean +_eglPreloadDrivers(void); + + +extern void _eglUnloadDrivers(void); -- cgit v1.2.3 From 57929eda3e876dc60be7060237a669f042be2376 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 19 Jan 2010 18:29:21 +0800 Subject: egl: Use _eglPreloadDrivers. Replace the use of _eglPreloadDriver by _eglPreloadDrivers. The latter supports EGL_DISPLAY which have a better chance to "just work". --- src/egl/main/eglapi.c | 6 +++--- src/egl/main/egldisplay.c | 6 ------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 26e0602453..6e8f444d7f 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -101,6 +101,8 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) drv = disp->Driver; if (!drv) { + _eglPreloadDrivers(); + drv = _eglOpenDriver(disp); if (!drv) return _eglError(EGL_NOT_INITIALIZED, __FUNCTION__); @@ -710,9 +712,7 @@ void (* EGLAPIENTRY eglGetProcAddress(const char *procname))() } } - /* preload a driver if there isn't one */ - if (!_eglGlobal.NumDrivers) - _eglPreloadDriver(NULL); + _eglPreloadDrivers(); /* now loop over drivers to query their procs */ for (i = 0; i < _eglGlobal.NumDrivers; i++) { diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index 896d60dbe1..a65ac6e969 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -81,12 +81,6 @@ _eglNewDisplay(NativeDisplayType nativeDisplay) _EGLDisplay *dpy = (_EGLDisplay *) calloc(1, sizeof(_EGLDisplay)); if (dpy) { dpy->NativeDisplay = nativeDisplay; - - dpy->DriverName = _eglPreloadDriver(dpy); - if (!dpy->DriverName) { - free(dpy); - return NULL; - } } return dpy; } -- cgit v1.2.3 From f0c2871bf4f6fa89339347bb9767bb2c19fda6d0 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 19 Jan 2010 17:39:34 +0800 Subject: egl: Remove unused driver and display functions. Remove _eglPreloadDriver, _eglLookupDriver, and _eglSplitDisplayString. --- src/egl/main/egldisplay.c | 30 ------------ src/egl/main/egldisplay.h | 4 -- src/egl/main/egldriver.c | 114 ---------------------------------------------- src/egl/main/egldriver.h | 8 ---- 4 files changed, 156 deletions(-) diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index a65ac6e969..eb82af4884 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -39,36 +39,6 @@ _eglFiniDisplay(void) } -/** - * If the first character is '!' we interpret it as specific driver name - * (i.e. "!r200" or "!i830"). Whatever follows ':' is interpreted as - * arguments. - * - * The caller may free() the returned driver name. - */ -char * -_eglSplitDisplayString(const char *dpyString, const char **args) -{ - char *drv, *p; - - if (!dpyString || dpyString[0] != '!') - return NULL; - drv = _eglstrdup(dpyString + 1); - if (!drv) - return NULL; - - p = strchr(dpyString, ':'); - if (p) { - drv[p - dpyString] = '\0'; - p++; - } - if (args) - *args = p; - - return drv; -} - - /** * Allocate a new _EGLDisplay object for the given nativeDisplay handle. * We'll also try to determine the device driver name at this time. diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 4f619e5371..ddd9806985 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -58,10 +58,6 @@ extern void _eglFiniDisplay(void); -extern char * -_eglSplitDisplayString(const char *dpyString, const char **args); - - extern _EGLDisplay * _eglNewDisplay(NativeDisplayType displayName); diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 5d603419a8..873dac02bf 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -113,66 +113,6 @@ library_suffix(void) #endif -/** - * Choose a driver for a given display. - * The caller may free() the returned strings. - */ -static char * -_eglChooseDriver(_EGLDisplay *dpy, char **argsRet) -{ - char *path = NULL; - const char *args = NULL; - const char *suffix = NULL; - const char *p; - - path = getenv("EGL_DRIVER"); - if (path) - path = _eglstrdup(path); - -#if defined(_EGL_PLATFORM_X) - if (!path && dpy && dpy->NativeDisplay) { - /* assume (wrongly!) that the native display is a display string */ - path = _eglSplitDisplayString((const char *) dpy->NativeDisplay, &args); - } - suffix = "so"; -#elif defined(_EGL_PLATFORM_WINDOWS) - suffix = "dll"; -#else /* _EGL_PLATFORM_NO_OS */ - if (path) { - /* force the use of the default driver */ - _eglLog(_EGL_DEBUG, "ignore EGL_DRIVER"); - free(path); - path = NULL; - } - suffix = NULL; -#endif - - if (!path) - path = _eglstrdup(DefaultDriverName); - - /* append suffix if there isn't */ - p = strrchr(path, '.'); - if (!p && suffix) { - size_t len = strlen(path); - char *tmp = malloc(len + strlen(suffix) + 2); - if (tmp) { - memcpy(tmp, path, len); - tmp[len++] = '.'; - tmp[len] = '\0'; - strcat(tmp + len, suffix); - - free(path); - path = tmp; - } - } - - if (argsRet) - *argsRet = (args) ? _eglstrdup(args) : NULL; - - return path; -} - - /** * Open the named driver and find its bootstrap function: _eglMain(). */ @@ -307,46 +247,6 @@ _eglMatchDriver(_EGLDisplay *dpy) } -/** - * Load a driver and save it. - */ -const char * -_eglPreloadDriver(_EGLDisplay *dpy) -{ - char *path, *args; - _EGLDriver *drv; - EGLint i; - - path = _eglChooseDriver(dpy, &args); - if (!path) - return NULL; - - for (i = 0; i < _eglGlobal.NumDrivers; i++) { - drv = _eglGlobal.Drivers[i]; - if (strcmp(drv->Path, path) == 0) { - _eglLog(_EGL_DEBUG, "Driver %s is already preloaded", - drv->Name); - free(path); - if (args) - free(args); - return drv->Name; - } - } - - drv = _eglLoadDriver(path, args); - if (!drv) { - free(path); - if (args) - free(args); - return NULL; - } - - _eglGlobal.Drivers[_eglGlobal.NumDrivers++] = drv; - - return drv->Name; -} - - /** * Open a preloaded driver. */ @@ -558,20 +458,6 @@ _eglUnloadDrivers(void) } -/** - * Given a display handle, return the _EGLDriver for that display. - */ -_EGLDriver * -_eglLookupDriver(EGLDisplay dpy) -{ - _EGLDisplay *d = _eglLookupDisplay(dpy); - if (d) - return d->Driver; - else - return NULL; -} - - /** * Plug all the available fallback routines into the given driver's * dispatch table. diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index a474fa6871..eca96fce61 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -29,10 +29,6 @@ PUBLIC _EGLDriver * _eglMain(const char *args); -extern const char * -_eglPreloadDriver(_EGLDisplay *dpy); - - extern _EGLDriver * _eglOpenDriver(_EGLDisplay *dpy); @@ -49,10 +45,6 @@ extern void _eglUnloadDrivers(void); -extern _EGLDriver * -_eglLookupDriver(EGLDisplay d); - - PUBLIC void _eglInitDriverFallbacks(_EGLDriver *drv); -- cgit v1.2.3 From 925f8113beba03e956351cee6780b1c7ab76add8 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 20 Jan 2010 17:42:33 +0800 Subject: egl: Rename _EGL_PLATFORM_X to _EGL_PLATFORM_POSIX. The macro is used to determine if dlfcn.h or dirent.h is available. POSIX is a better name than X in such case. --- src/egl/main/Makefile | 2 +- src/egl/main/egldriver.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index 7386f6ea73..66f8f01b8e 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -47,7 +47,7 @@ OBJECTS = $(SOURCES:.c=.o) # use dl*() to load drivers -LOCAL_CFLAGS = -D_EGL_PLATFORM_X=1 +LOCAL_CFLAGS = -D_EGL_PLATFORM_POSIX=1 EGL_DEFAULT_DISPLAY = $(word 1, $(EGL_DISPLAYS)) diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 873dac02bf..dd363a18f4 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -20,7 +20,7 @@ #include "eglstring.h" #include "eglsurface.h" -#if defined(_EGL_PLATFORM_X) +#if defined(_EGL_PLATFORM_POSIX) #include #include #include @@ -58,7 +58,7 @@ library_suffix(void) } -#elif defined(_EGL_PLATFORM_X) +#elif defined(_EGL_PLATFORM_POSIX) static const char DefaultDriverName[] = "egl_softpipe"; @@ -132,7 +132,7 @@ _eglOpenLibrary(const char *driverPath, lib_handle *handle) /* XXX untested */ if (lib) mainFunc = (_EGLMain_t) GetProcAddress(lib, "_eglMain"); -#elif defined(_EGL_PLATFORM_X) +#elif defined(_EGL_PLATFORM_POSIX) if (lib) { mainFunc = (_EGLMain_t) dlsym(lib, "_eglMain"); if (!mainFunc) @@ -276,7 +276,7 @@ _eglCloseDriver(_EGLDriver *drv, _EGLDisplay *dpy) static EGLBoolean _eglPreloadUserDriver(void) { -#if defined(_EGL_PLATFORM_X) || defined(_EGL_PLATFORM_WINDOWS) +#if defined(_EGL_PLATFORM_POSIX) || defined(_EGL_PLATFORM_WINDOWS) _EGLDriver *drv; char *env, *path; const char *suffix, *p; @@ -312,7 +312,7 @@ _eglPreloadUserDriver(void) _eglGlobal.Drivers[_eglGlobal.NumDrivers++] = drv; return EGL_TRUE; -#else /* _EGL_PLATFORM_X || _EGL_PLATFORM_WINDOWS */ +#else /* _EGL_PLATFORM_POSIX || _EGL_PLATFORM_WINDOWS */ return EGL_FALSE; #endif } @@ -330,7 +330,7 @@ _eglPreloadUserDriver(void) static EGLBoolean _eglPreloadDisplayDrivers(void) { -#if defined(_EGL_PLATFORM_X) +#if defined(_EGL_PLATFORM_POSIX) const char *dpy, *suffix; char path[1024], prefix[32]; DIR *dirp; @@ -375,7 +375,7 @@ _eglPreloadDisplayDrivers(void) closedir(dirp); return (_eglGlobal.NumDrivers > 0); -#else /* _EGL_PLATFORM_X */ +#else /* _EGL_PLATFORM_POSIX */ return EGL_FALSE; #endif } @@ -532,7 +532,7 @@ _eglFindAPIs(void) const char *es2_libname = "libGLESv2.dll"; const char *gl_libname = "OpenGL32.dll"; const char *vg_libname = "libOpenVG.dll"; -#elif defined(_EGL_PLATFORM_X) +#elif defined(_EGL_PLATFORM_POSIX) const char *es1_libname = "libGLESv1_CM.so"; const char *es2_libname = "libGLESv2.so"; const char *gl_libname = "libGL.so"; -- cgit v1.2.3 From cf22fd5e5b13ccdb02ba0368ea722ede3bbc6de0 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 19 Jan 2010 18:39:59 +0800 Subject: egl: Improve driver matching. Make drv->Probe return a score so that the matching can be done by finding the driver with the highest score. --- src/egl/main/egldisplay.h | 1 - src/egl/main/egldriver.c | 35 +++++++++++++++++++---------------- src/egl/main/egldriver.h | 19 ++++++++++++++++--- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index ddd9806985..a69813196f 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -26,7 +26,6 @@ struct _egl_display EGLNativeDisplayType NativeDisplay; - const char *DriverName; _EGLDriver *Driver; void *DriverData; /* private to driver */ diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index dd363a18f4..ef1c366b30 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -218,32 +218,35 @@ _eglLoadDriver(const char *path, const char *args) /** * Match a display to a preloaded driver. + * + * The matching is done by finding the driver with the highest score. */ static _EGLDriver * _eglMatchDriver(_EGLDisplay *dpy) { - _EGLDriver *defaultDriver = NULL; - EGLint i; + _EGLDriver *best_drv = NULL; + EGLint best_score = -1, i; for (i = 0; i < _eglGlobal.NumDrivers; i++) { _EGLDriver *drv = _eglGlobal.Drivers[i]; - - /* display specifies a driver */ - if (dpy->DriverName) { - if (strcmp(dpy->DriverName, drv->Name) == 0) - return drv; - } - else if (drv->Probe) { - if (drv->Probe(drv, dpy)) - return drv; - } - else { - if (!defaultDriver) - defaultDriver = drv; + EGLint score; + + score = (drv->Probe) ? drv->Probe(drv, dpy) : 0; + if (score > best_score) { + if (best_drv) { + _eglLog(_EGL_DEBUG, "driver %s has higher score than %s", + drv->Name, best_drv->Name); + } + + best_drv = drv; + best_score = score; + /* perfect match */ + if (score >= 100) + break; } } - return defaultDriver; + return best_drv; } diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index eca96fce61..808b1c3fb7 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -16,9 +16,22 @@ struct _egl_driver const char *Args; /**< args to load this driver */ const char *Name; /**< name of this driver */ - /**< probe a display to see if it is supported */ - EGLBoolean (*Probe)(_EGLDriver *drv, _EGLDisplay *dpy); - /**< called before dlclose to release this driver */ + + /** + * Probe a display and return a score. + * + * Roughly, + * 50 means the driver supports the display; + * 90 means the driver can accelerate the display; + * 100 means a perfect match. + */ + EGLint (*Probe)(_EGLDriver *drv, _EGLDisplay *dpy); + + /** + * Release the driver resource. + * + * It is called before dlclose(). + */ void (*Unload)(_EGLDriver *drv); _EGLAPI API; /**< EGL API dispatch table */ -- cgit v1.2.3 From c5766c4ae39b4190965abd65eaf67b478a9ad028 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 20 Jan 2010 14:35:50 +0800 Subject: egl: Add a simple cache for driver probe. In current design, multiple drivers will probe the same display and the best driver is determined. The cache can be used by the drivers to store and share the probed data. --- src/egl/main/egldriver.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ src/egl/main/egldriver.h | 8 ++++++++ 2 files changed, 56 insertions(+) diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index ef1c366b30..0574f83f45 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -113,6 +113,13 @@ library_suffix(void) #endif +#define NUM_PROBE_CACHE_SLOTS 8 +static struct { + EGLint keys[NUM_PROBE_CACHE_SLOTS]; + const void *values[NUM_PROBE_CACHE_SLOTS]; +} _eglProbeCache; + + /** * Open the named driver and find its bootstrap function: _eglMain(). */ @@ -569,3 +576,44 @@ _eglFindAPIs(void) return mask; } + + +/** + * Set the probe cache at the given key. + * + * A key, instead of a _EGLDriver, is used to allow the probe cache to be share + * by multiple drivers. + */ +void +_eglSetProbeCache(EGLint key, const void *val) +{ + EGLint idx; + + for (idx = 0; idx < NUM_PROBE_CACHE_SLOTS; idx++) { + if (!_eglProbeCache.keys[idx] || _eglProbeCache.keys[idx] == key) + break; + } + assert(key > 0); + assert(idx < NUM_PROBE_CACHE_SLOTS); + + _eglProbeCache.keys[idx] = key; + _eglProbeCache.values[idx] = val; +} + + +/** + * Return the probe cache at the given key. + */ +const void * +_eglGetProbeCache(EGLint key) +{ + EGLint idx; + + for (idx = 0; idx < NUM_PROBE_CACHE_SLOTS; idx++) { + if (!_eglProbeCache.keys[idx] || _eglProbeCache.keys[idx] == key) + break; + } + + return (idx < NUM_PROBE_CACHE_SLOTS && _eglProbeCache.keys[idx] == key) ? + _eglProbeCache.values[idx] : NULL; +} diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index 808b1c3fb7..d9d61297c1 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -66,4 +66,12 @@ PUBLIC EGLint _eglFindAPIs(void); +PUBLIC void +_eglSetProbeCache(EGLint key, const void *val); + + +PUBLIC const void * +_eglGetProbeCache(EGLint key); + + #endif /* EGLDRIVER_INCLUDED */ -- cgit v1.2.3 From 11f4360f2e915f236558da22efe5bdabd81446f3 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 20 Jan 2010 15:52:50 +0800 Subject: st/egl_g3d: Add support for probe to native displays. The functions can be used to check if a display is supported without creating a struct native_display. It uses a probe object that can be shared across drivers. --- src/gallium/state_trackers/egl_g3d/common/native.h | 37 +++++++++++ .../state_trackers/egl_g3d/kms/native_kms.c | 12 ++++ .../state_trackers/egl_g3d/x11/native_x11.c | 76 ++++++++++++++++++++++ .../state_trackers/egl_g3d/x11/x11_screen.c | 25 +++++-- .../state_trackers/egl_g3d/x11/x11_screen.h | 3 + 5 files changed, 146 insertions(+), 7 deletions(-) diff --git a/src/gallium/state_trackers/egl_g3d/common/native.h b/src/gallium/state_trackers/egl_g3d/common/native.h index f374f2e4a6..72a9cec7ef 100644 --- a/src/gallium/state_trackers/egl_g3d/common/native.h +++ b/src/gallium/state_trackers/egl_g3d/common/native.h @@ -47,6 +47,27 @@ enum native_attachment { NUM_NATIVE_ATTACHMENTS }; +/** + * Enumerations for probe results. + */ +enum native_probe_result { + NATIVE_PROBE_UNKNOWN, + NATIVE_PROBE_FALLBACK, + NATIVE_PROBE_SUPPORTED, + NATIVE_PROBE_EXACT, +}; + +/** + * A probe object for display probe. + */ +struct native_probe { + int magic; + EGLNativeDisplayType display; + void *data; + + void (*destroy)(struct native_probe *nprobe); +}; + struct native_surface { void (*destroy)(struct native_surface *nsurf); @@ -231,6 +252,22 @@ native_attachment_mask_test(uint mask, enum native_attachment att) return !!(mask & (1 << att)); } +/** + * Return a probe object for the given display. + * + * Note that the returned object may be cached and used by different native + * display modules. It allows fast probing when multiple modules probe the + * same display. + */ +struct native_probe * +native_create_probe(EGLNativeDisplayType dpy); + +/** + * Probe the probe object. + */ +enum native_probe_result +native_get_probe_result(struct native_probe *nprobe); + const char * native_get_name(void); diff --git a/src/gallium/state_trackers/egl_g3d/kms/native_kms.c b/src/gallium/state_trackers/egl_g3d/kms/native_kms.c index dc66436630..d5baf2c2f0 100644 --- a/src/gallium/state_trackers/egl_g3d/kms/native_kms.c +++ b/src/gallium/state_trackers/egl_g3d/kms/native_kms.c @@ -820,6 +820,18 @@ kms_create_display(EGLNativeDisplayType dpy, struct drm_api *api) return &kdpy->base; } +struct native_probe * +native_create_probe(EGLNativeDisplayType dpy) +{ + return NULL; +} + +enum native_probe_result +native_get_probe_result(struct native_probe *nprobe) +{ + return NATIVE_PROBE_UNKNOWN; +} + /* the api is destroyed with the native display */ static struct drm_api *drm_api; diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_x11.c b/src/gallium/state_trackers/egl_g3d/x11/native_x11.c index 583ce3d329..695ab88010 100644 --- a/src/gallium/state_trackers/egl_g3d/x11/native_x11.c +++ b/src/gallium/state_trackers/egl_g3d/x11/native_x11.c @@ -24,13 +24,89 @@ #include #include "util/u_debug.h" +#include "util/u_memory.h" #include "state_tracker/drm_api.h" #include "egllog.h" #include "native_x11.h" +#include "x11_screen.h" + +#define X11_PROBE_MAGIC 0x11980BE /* "X11PROBE" */ static struct drm_api *api; +static void +x11_probe_destroy(struct native_probe *nprobe) +{ + if (nprobe->data) + free(nprobe->data); + free(nprobe); +} + +struct native_probe * +native_create_probe(EGLNativeDisplayType dpy) +{ + struct native_probe *nprobe; + struct x11_screen *xscr; + int scr; + const char *driver_name = NULL; + Display *xdpy; + + nprobe = CALLOC_STRUCT(native_probe); + if (!nprobe) + return NULL; + + xdpy = dpy; + if (!xdpy) { + xdpy = XOpenDisplay(NULL); + if (!xdpy) { + free(nprobe); + return NULL; + } + } + + scr = DefaultScreen(xdpy); + xscr = x11_screen_create(xdpy, scr); + if (xscr) { + if (x11_screen_support(xscr, X11_SCREEN_EXTENSION_DRI2)) { + driver_name = x11_screen_probe_dri2(xscr); + nprobe->data = strdup(driver_name); + } + + x11_screen_destroy(xscr); + } + + if (xdpy != dpy) + XCloseDisplay(xdpy); + + nprobe->magic = X11_PROBE_MAGIC; + nprobe->display = dpy; + + nprobe->destroy = x11_probe_destroy; + + return nprobe; +} + +enum native_probe_result +native_get_probe_result(struct native_probe *nprobe) +{ + if (!nprobe || nprobe->magic != X11_PROBE_MAGIC) + return NATIVE_PROBE_UNKNOWN; + + if (!api) + api = drm_api_create(); + + /* this is a software driver */ + if (!api) + return NATIVE_PROBE_SUPPORTED; + + /* the display does not support DRI2 or the driver mismatches */ + if (!nprobe->data || strcmp(api->name, (const char *) nprobe->data) != 0) + return NATIVE_PROBE_FALLBACK; + + return NATIVE_PROBE_EXACT; +} + const char * native_get_name(void) { diff --git a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c index 4d68a88d2e..fef7878ab9 100644 --- a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c +++ b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c @@ -249,6 +249,22 @@ x11_screen_is_driver_equal(struct x11_screen *xscr, const char *driver) return (strcmp(xscr->dri_driver, driver) == 0); } +/** + * Probe the screen for the DRI2 driver name. + */ +const char * +x11_screen_probe_dri2(struct x11_screen *xscr) +{ + /* get the driver name and the device name */ + if (!xscr->dri_driver) { + if (!DRI2Connect(xscr->dpy, RootWindow(xscr->dpy, xscr->number), + &xscr->dri_driver, &xscr->dri_device)) + xscr->dri_driver = xscr->dri_device = NULL; + } + + return xscr->dri_driver; +} + /** * Enable DRI2 and returns the file descriptor of the DRM device. The file * descriptor will be closed automatically when the screen is destoryed. @@ -261,13 +277,8 @@ x11_screen_enable_dri2(struct x11_screen *xscr, const char *driver) drm_magic_t magic; /* get the driver name and the device name first */ - if (!xscr->dri_driver) { - if (!DRI2Connect(xscr->dpy, RootWindow(xscr->dpy, xscr->number), - &xscr->dri_driver, &xscr->dri_device)) { - xscr->dri_driver = xscr->dri_device = NULL; - return -1; - } - } + if (!x11_screen_probe_dri2(xscr)) + return -1; if (!x11_screen_is_driver_equal(xscr, driver)) { _eglLog(_EGL_WARNING, "Driver mismatch: %s != %s", diff --git a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h index bf48218905..5432858ac3 100644 --- a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h +++ b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h @@ -70,6 +70,9 @@ x11_screen_get_glx_configs(struct x11_screen *xscr); const __GLcontextModes * x11_screen_get_glx_visuals(struct x11_screen *xscr); +const char * +x11_screen_probe_dri2(struct x11_screen *xscr); + int x11_screen_enable_dri2(struct x11_screen *xscr, const char *driver); -- cgit v1.2.3 From c8b694b2c2f451235270a3442254379caea3f57d Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 20 Jan 2010 13:55:57 +0800 Subject: st/egl_g3d: Add support for driver probe. Hook the drv->Probe callback to allow the drivers to probe displays. The loading of state trackers is delayed to avoid unnecessary loading. --- .../state_trackers/egl_g3d/common/egl_g3d.c | 117 +++++++++++++++++++-- .../state_trackers/egl_g3d/common/egl_g3d.h | 2 + 2 files changed, 108 insertions(+), 11 deletions(-) diff --git a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c index 042e9518c2..2ac6215646 100644 --- a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c @@ -294,6 +294,71 @@ egl_g3d_choose_st(_EGLDriver *drv, _EGLContext *ctx) return stapi; } +/** + * Initialize the state trackers. + */ +static void +egl_g3d_init_st(_EGLDriver *drv) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + EGLint i; + + /* already initialized */ + if (gdrv->api_mask) + return; + + for (i = 0; i < NUM_EGL_G3D_STS; i++) { + gdrv->stapis[i] = egl_g3d_get_st(i); + if (gdrv->stapis[i]) + gdrv->api_mask |= gdrv->stapis[i]->api_bit; + } + + if (gdrv->api_mask) + _eglLog(_EGL_DEBUG, "Driver API mask: 0x%x", gdrv->api_mask); + else + _eglLog(_EGL_WARNING, "No supported client API"); +} + +/** + * Get the probe object of the display. + * + * Note that this function may be called before the display is initialized. + */ +static struct native_probe * +egl_g3d_get_probe(_EGLDriver *drv, _EGLDisplay *dpy) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + struct native_probe *nprobe; + + nprobe = (struct native_probe *) _eglGetProbeCache(gdrv->probe_key); + if (!nprobe || nprobe->display != dpy->NativeDisplay) { + if (nprobe) + nprobe->destroy(nprobe); + nprobe = native_create_probe(dpy->NativeDisplay); + _eglSetProbeCache(gdrv->probe_key, (void *) nprobe); + } + + return nprobe; +} + +/** + * Destroy the probe object of the display. The display may be NULL. + * + * Note that this function may be called before the display is initialized. + */ +static void +egl_g3d_destroy_probe(_EGLDriver *drv, _EGLDisplay *dpy) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + struct native_probe *nprobe; + + nprobe = (struct native_probe *) _eglGetProbeCache(gdrv->probe_key); + if (nprobe && (!dpy || nprobe->display == dpy->NativeDisplay)) { + nprobe->destroy(nprobe); + _eglSetProbeCache(gdrv->probe_key, NULL); + } +} + /** * Return an API mask that consists of the state trackers that supports the * given mode. @@ -515,6 +580,9 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy, struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); struct egl_g3d_display *gdpy; + /* the probe object is unlikely to be needed again */ + egl_g3d_destroy_probe(drv, dpy); + gdpy = CALLOC_STRUCT(egl_g3d_display); if (!gdpy) { _eglError(EGL_BAD_ALLOC, "eglInitialize"); @@ -531,6 +599,7 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy, gdpy->native->screen->flush_frontbuffer = egl_g3d_flush_frontbuffer; gdpy->native->screen->update_buffer = egl_g3d_update_buffer; + egl_g3d_init_st(&gdrv->base); dpy->ClientAPIsMask = gdrv->api_mask; if (egl_g3d_add_configs(drv, dpy, 1) == 1) { @@ -987,6 +1056,9 @@ egl_g3d_get_proc_address(_EGLDriver *drv, const char *procname) _EGLProc proc; EGLint i; + /* in case this is called before a display is initialized */ + egl_g3d_init_st(&gdrv->base); + for (i = 0; i < NUM_EGL_G3D_STS; i++) { const struct egl_g3d_st *stapi = gdrv->stapis[i]; if (stapi) { @@ -1177,10 +1249,41 @@ egl_g3d_show_screen_surface(_EGLDriver *drv, _EGLDisplay *dpy, #endif /* EGL_MESA_screen_surface */ +static EGLint +egl_g3d_probe(_EGLDriver *drv, _EGLDisplay *dpy) +{ + struct native_probe *nprobe; + enum native_probe_result res; + EGLint score; + + nprobe = egl_g3d_get_probe(drv, dpy); + res = native_get_probe_result(nprobe); + + switch (res) { + case NATIVE_PROBE_UNKNOWN: + default: + score = 0; + break; + case NATIVE_PROBE_FALLBACK: + score = 40; + break; + case NATIVE_PROBE_SUPPORTED: + score = 50; + break; + case NATIVE_PROBE_EXACT: + score = 100; + break; + } + + return score; +} + static void egl_g3d_unload(_EGLDriver *drv) { struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + + egl_g3d_destroy_probe(drv, NULL); free(gdrv); } @@ -1189,7 +1292,6 @@ _eglMain(const char *args) { static char driver_name[64]; struct egl_g3d_driver *gdrv; - EGLint i; snprintf(driver_name, sizeof(driver_name), "Gallium/%s", native_get_name()); @@ -1224,18 +1326,11 @@ _eglMain(const char *args) #endif gdrv->base.Name = driver_name; + gdrv->base.Probe = egl_g3d_probe; gdrv->base.Unload = egl_g3d_unload; - for (i = 0; i < NUM_EGL_G3D_STS; i++) { - gdrv->stapis[i] = egl_g3d_get_st(i); - if (gdrv->stapis[i]) - gdrv->api_mask |= gdrv->stapis[i]->api_bit; - } - - if (gdrv->api_mask) - _eglLog(_EGL_DEBUG, "Driver API mask: 0x%x", gdrv->api_mask); - else - _eglLog(_EGL_WARNING, "No supported client API"); + /* the key is " EGL G3D" */ + gdrv->probe_key = 0x0E61063D; return &gdrv->base; } diff --git a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.h b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.h index 1da8af495b..3dae8c4052 100644 --- a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.h +++ b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.h @@ -44,6 +44,8 @@ struct egl_g3d_driver { _EGLDriver base; const struct egl_g3d_st *stapis[NUM_EGL_G3D_STS]; EGLint api_mask; + + EGLint probe_key; }; struct egl_g3d_display { -- cgit v1.2.3 From 5a99ca490fee65d37a4c7469888680b412d27f7f Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Wed, 20 Jan 2010 09:06:49 -0500 Subject: r200: fix typo in 76cf2618327a7f008dcfd0d91d64d6d9e01f9a9c noticed by Maciej on IRC. --- src/mesa/drivers/dri/r200/r200_blit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/r200/r200_blit.c b/src/mesa/drivers/dri/r200/r200_blit.c index f899f7efdc..b6fcc6e20c 100644 --- a/src/mesa/drivers/dri/r200/r200_blit.c +++ b/src/mesa/drivers/dri/r200/r200_blit.c @@ -241,7 +241,7 @@ static inline void calc_tex_coords(float img_width, float img_height, buf[3] = buf[2] + reg_height / img_height; if (flip_y) { - buf[2] = 1.0 - buf[1]; + buf[2] = 1.0 - buf[2]; buf[3] = 1.0 - buf[3]; } } -- cgit v1.2.3 From 9f728ed1c9c7255554109299508a78b9fbb1cdb6 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 20 Jan 2010 14:53:38 +0000 Subject: st/xorg: Fic bug and close drm_api at proper place --- src/gallium/state_trackers/xorg/xorg_driver.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index b74953e543..2714fba999 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -214,7 +214,7 @@ drv_init_drm(ScrnInfoPtr pScrn) if (ms->fd >= 0) return TRUE; - if (ms->api->destroy) + if (ms->api && ms->api->destroy) ms->api->destroy(ms->api); ms->api = NULL; @@ -225,6 +225,21 @@ drv_init_drm(ScrnInfoPtr pScrn) return TRUE; } +static Bool +drv_close_drm(ScrnInfoPtr pScrn) +{ + modesettingPtr ms = modesettingPTR(pScrn); + + if (ms->api && ms->api->destroy) + ms->api->destroy(ms->api); + ms->api = NULL; + + drmClose(ms->fd); + ms->fd = -1; + + return TRUE; +} + static Bool drv_init_resource_management(ScrnInfoPtr pScrn) { @@ -278,10 +293,6 @@ drv_close_resource_management(ScrnInfoPtr pScrn) } ms->screen = NULL; - if (ms->api && ms->api->destroy) - ms->api->destroy(ms->api); - ms->api = NULL; - #ifdef HAVE_LIBKMS if (ms->kms) kms_destroy(&ms->kms); @@ -832,8 +843,7 @@ drv_close_screen(int scrnIndex, ScreenPtr pScreen) drv_close_resource_management(pScrn); - drmClose(ms->fd); - ms->fd = -1; + drv_close_drm(pScrn); pScrn->vtSema = FALSE; pScreen->CloseScreen = ms->CloseScreen; -- cgit v1.2.3 From 67aa70411249cf0f8c39eedaf8432ad537c166ca Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Wed, 20 Jan 2010 10:00:50 -0500 Subject: r200: fix some breakage after move to common blit code --- src/mesa/drivers/dri/r200/r200_context.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c index 3d6d0f5ec0..453c8de220 100644 --- a/src/mesa/drivers/dri/r200/r200_context.c +++ b/src/mesa/drivers/dri/r200/r200_context.c @@ -333,10 +333,6 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, r200InitShaderFuncs(&functions); radeonInitQueryObjFunctions(&functions); - if (rmesa->radeon.radeonScreen->kernel_mm) { - r200_init_texcopy_functions(&functions); - } - if (!radeonInitContext(&rmesa->radeon, &functions, glVisual, driContextPriv, sharedContextPrivate)) { -- cgit v1.2.3 From 4e34c5d0b5ef36d4a107e93653937f7715ce2c5a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 19 Jan 2010 16:42:43 -0700 Subject: docs: updated Mesa mailing list info --- docs/lists.html | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/docs/lists.html b/docs/lists.html index 5227fbd055..9c17a9f354 100644 --- a/docs/lists.html +++ b/docs/lists.html @@ -13,36 +13,41 @@

    -
  • mesa3d-announce - announcements of new Mesa -versions are sent to this list. -
  • -
  • mesa3d-users - intended for users of the Mesa and DRI. -Newbie questions are appropriate, but please try the general OpenGL +target="_parent">mesa3d-users - intended for end-users of Mesa and DRI +drivers. Newbie questions are OK, but please try the general OpenGL resources and Mesa/DRI documentation first.

  • mesa3d-dev - for discussion of Mesa and Direct Rendering -Infrastructure development. Not for beginners. +target="_parent">mesa3d-dev - for Mesa, Gallium and DRI development +discussion. Not for beginners.

  • mesa-commit - relays git check-in messages (for developers). +In general, people should not post to this list. +

  • -Note: the old mesa3d-cvs list is no longer in use. +
  • mesa3d-announce - announcements of new Mesa +versions are sent to this list. Very low traffic.
+

+Follow the links above for list archives. +

+

For mailing lists about Direct Rendering Modules (drm) in Linux/BSD -kernels, see wiki. +kernels, see the + +DRI wiki. +

-Notice: non-member posts to any of these lists will be automatically -rejected. +Notice: You must subscribe to these lists in order to post to them.

-- cgit v1.2.3 From 65d2a266375cf32fd90c7fb77fb87993d3a652ea Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 20 Jan 2010 08:03:46 -0700 Subject: st/mesa: fix format logic in compatible_src_dst_formats() We need to consider the user-requested formats, not the actual device- chosen formats. See code comments for more details. --- src/mesa/state_tracker/st_cb_texture.c | 56 ++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index e9c30cb5de..a0dc016b33 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -31,6 +31,7 @@ #include "main/convolve.h" #endif #include "main/enums.h" +#include "main/fbobject.h" #include "main/formats.h" #include "main/image.h" #include "main/imports.h" @@ -1352,33 +1353,64 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level, } + +/** + * If the format of the src renderbuffer and the format of the dest + * texture are compatible (in terms of blitting), return a TGSI writemask + * to be used during the blit. + * If the src/dest are incompatible, return 0. + */ static unsigned -compatible_src_dst_formats(const struct gl_renderbuffer *src, +compatible_src_dst_formats(GLcontext *ctx, + const struct gl_renderbuffer *src, const struct gl_texture_image *dst) { - const GLenum srcFormat = _mesa_get_format_base_format(src->Format); - const GLenum dstLogicalFormat = _mesa_get_format_base_format(dst->TexFormat); + /* Get logical base formats for the src and dest. + * That is, use the user-requested formats and not the actual, device- + * chosen formats. + * For example, the user may have requested an A8 texture but the + * driver may actually be using an RGBA texture format. When we + * copy/blit to that texture, we only want to copy the Alpha channel + * and not the RGB channels. + * + * Similarly, when the src FBO was created an RGB format may have been + * requested but the driver actually chose an RGBA format. In that case, + * we don't want to copy the undefined Alpha channel to the dest texture + * (it should be 1.0). + */ + const GLenum srcFormat = _mesa_base_fbo_format(ctx, src->InternalFormat); + const GLenum dstFormat = _mesa_base_tex_format(ctx, dst->InternalFormat); - if (srcFormat == dstLogicalFormat) { + /** + * XXX when we have red-only and red/green renderbuffers we'll need + * to add more cases here (or implement a general-purpose routine that + * queries the existance of the R,G,B,A channels in the src and dest). + */ + if (srcFormat == dstFormat) { /* This is the same as matching_base_formats, which should * always pass, as it did previously. */ return TGSI_WRITEMASK_XYZW; } - else if (srcFormat == GL_RGBA && - dstLogicalFormat == GL_RGB) { - /* Add a single special case to cope with RGBA->RGB transfers, - * setting A to 1.0 to cope with situations where the RGB - * destination is actually stored as RGBA. + else if (srcFormat == GL_RGB && dstFormat == GL_RGBA) { + /* Make sure that A in the dest is 1. The actual src format + * may be RGBA and have undefined A values. + */ + return TGSI_WRITEMASK_XYZ; + } + else if (srcFormat == GL_RGBA && dstFormat == GL_RGB) { + /* Make sure that A in the dest is 1. The actual dst format + * may be RGBA and will need A=1 to provide proper alpha values + * when sampled later. */ - return TGSI_WRITEMASK_XYZ; /* A ==> 1.0 */ + return TGSI_WRITEMASK_XYZ; } else { if (ST_DEBUG & DEBUG_FALLBACK) debug_printf("%s failed for src %s, dst %s\n", __FUNCTION__, _mesa_lookup_enum_by_nr(srcFormat), - _mesa_lookup_enum_by_nr(dstLogicalFormat)); + _mesa_lookup_enum_by_nr(dstFormat)); /* Otherwise fail. */ @@ -1489,7 +1521,7 @@ st_copy_texsubimage(GLcontext *ctx, matching_base_formats = (_mesa_get_format_base_format(strb->Base.Format) == _mesa_get_format_base_format(texImage->TexFormat)); - format_writemask = compatible_src_dst_formats(&strb->Base, texImage); + format_writemask = compatible_src_dst_formats(ctx, &strb->Base, texImage); if (ctx->_ImageTransferState == 0x0) { -- cgit v1.2.3 From 506e27b9724e7f11350fc2454d263bea2df8ea39 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Tue, 19 Jan 2010 19:02:13 -0800 Subject: Copy __FUNCTION__ portability #defines from mesa/compiler.h to eglcompiler.h Signed-off-by: Alan Coopersmith Signed-off-by: Brian Paul --- src/egl/main/eglcompiler.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/egl/main/eglcompiler.h b/src/egl/main/eglcompiler.h index 5a3fb49ac2..d844fbb0ef 100644 --- a/src/egl/main/eglcompiler.h +++ b/src/egl/main/eglcompiler.h @@ -71,5 +71,23 @@ # define PUBLIC #endif +/** + * The __FUNCTION__ gcc variable is generally only used for debugging. + * If we're not using gcc, define __FUNCTION__ as a cpp symbol here. + * Don't define it if using a newer Windows compiler. + */ +#ifndef __FUNCTION__ +# if defined(__VMS) +# define __FUNCTION__ "VMS$NL:" +# elif ((!defined __GNUC__) || (__GNUC__ < 2)) && (!defined __xlC__) && \ + (!defined(_MSC_VER) || _MSC_VER < 1300) +# if (__STDC_VERSION__ >= 199901L) /* C99 */ || \ + (defined(__SUNPRO_C) && defined(__C99FEATURES__)) +# define __FUNCTION__ __func__ +# else +# define __FUNCTION__ "" +# endif +# endif +#endif #endif /* EGLCOMPILER_INCLUDED */ -- cgit v1.2.3 From 05208b298d218071bae75a52a16e4483ca64c94d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 20 Jan 2010 08:02:59 -0700 Subject: mesa: replace questionable CPU_TO_LE32 macro with function --- src/mesa/main/compiler.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h index 9eab1ead24..9cef99f67a 100644 --- a/src/mesa/main/compiler.h +++ b/src/mesa/main/compiler.h @@ -223,8 +223,8 @@ extern "C" { /** - * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN. - * Do not use them unless absolutely necessary! + * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN, and CPU_TO_LE32. + * Do not use these unless absolutely necessary! * Try to use a runtime test instead. * For now, only used by some DRI hardware drivers for color/texel packing. */ @@ -236,10 +236,13 @@ extern "C" { #include #define CPU_TO_LE32( x ) CFSwapInt32HostToLittle( x ) #elif (defined(_AIX) || defined(__blrts)) -#define CPU_TO_LE32( x ) x = ((x & 0x000000ff) << 24) | \ - ((x & 0x0000ff00) << 8) | \ - ((x & 0x00ff0000) >> 8) | \ - ((x & 0xff000000) >> 24); +static INLINE GLuint CPU_TO_LE32(GLuint x) +{ + return (((x & 0x000000ff) << 24) | + ((x & 0x0000ff00) << 8) | + ((x & 0x00ff0000) >> 8) | + ((x & 0xff000000) >> 24)); +} #else /*__linux__ */ #include #define CPU_TO_LE32( x ) bswap32( x ) -- cgit v1.2.3 From 156c90e5c3289fda8290bdd04c5cb5041a65113d Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Wed, 20 Jan 2010 11:18:25 -0500 Subject: r200: re-adding missing pitch alignment check in blit code lost after switch to common code --- src/mesa/drivers/dri/r200/r200_blit.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mesa/drivers/dri/r200/r200_blit.c b/src/mesa/drivers/dri/r200/r200_blit.c index b6fcc6e20c..e446d532cf 100644 --- a/src/mesa/drivers/dri/r200/r200_blit.c +++ b/src/mesa/drivers/dri/r200/r200_blit.c @@ -363,6 +363,10 @@ unsigned r200_blit(GLcontext *ctx, return GL_FALSE; } + if (src_offset % 32 || dst_offset % 32) { + return GL_FALSE; + } + if (0) { fprintf(stderr, "src: size [%d x %d], pitch %d, " "offset [%d x %d], format %s, bo %p\n", -- cgit v1.2.3 From bef610f693266c338b99511b4d1eea5d5b97644e Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 20 Jan 2010 18:26:49 +0100 Subject: gallium: prepare for per-rendertarget blend enables, writemasks, blend funcs GL 3.0 (EXT_draw_buffers2) and other APIs allow independent blend enables and write masks per render target, ARB_draw_buffers_blend (and other APIs) also allow independent blend functions. Things like dithering, logic ops however are not extended to be per rendertarget, that might be conceptually possible however it doesn't look like any API wants to expose this. --- src/gallium/auxiliary/cso_cache/cso_context.c | 13 +++++++----- src/gallium/include/pipe/p_state.h | 11 +++++++--- src/mesa/state_tracker/st_atom_blend.c | 30 +++++++++++++-------------- src/mesa/state_tracker/st_cb_clear.c | 16 +++++++------- 4 files changed, 39 insertions(+), 31 deletions(-) diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index fdfb5faa59..c8fdfc8124 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -310,18 +310,21 @@ void cso_destroy_context( struct cso_context *ctx ) enum pipe_error cso_set_blend(struct cso_context *ctx, const struct pipe_blend_state *templ) { - unsigned hash_key = cso_construct_key((void*)templ, sizeof(struct pipe_blend_state)); - struct cso_hash_iter iter = cso_find_state_template(ctx->cache, - hash_key, CSO_BLEND, - (void*)templ); + unsigned key_size, hash_key; + struct cso_hash_iter iter; void *handle; + key_size = templ->independent_blend_enable ? sizeof(struct pipe_blend_state) : + (void *)&(templ->rt[1]) - (void *)templ; + hash_key = cso_construct_key((void*)templ, key_size); + iter = cso_find_state_template(ctx->cache, hash_key, CSO_BLEND, (void*)templ); + if (cso_hash_iter_is_null(iter)) { struct cso_blend *cso = MALLOC(sizeof(struct cso_blend)); if (!cso) return PIPE_ERROR_OUT_OF_MEMORY; - memcpy(&cso->state, templ, sizeof(*templ)); + memcpy(&cso->state, templ, key_size); cso->data = ctx->pipe->create_blend_state(ctx->pipe, &cso->state); cso->delete_state = (cso_state_callback)ctx->pipe->delete_blend_state; cso->context = ctx->pipe; diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index fdd29ed449..3c217645ab 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -217,7 +217,7 @@ struct pipe_depth_stencil_alpha_state }; -struct pipe_blend_state +struct pipe_rt_blend_state { unsigned blend_enable:1; @@ -229,11 +229,16 @@ struct pipe_blend_state unsigned alpha_src_factor:5; /**< PIPE_BLENDFACTOR_x */ unsigned alpha_dst_factor:5; /**< PIPE_BLENDFACTOR_x */ + unsigned colormask:4; /**< bitmask of PIPE_MASK_R/G/B/A */ +}; + +struct pipe_blend_state +{ + unsigned independent_blend_enable:1; unsigned logicop_enable:1; unsigned logicop_func:4; /**< PIPE_LOGICOP_x */ - - unsigned colormask:4; /**< bitmask of PIPE_MASK_R/G/B/A */ unsigned dither:1; + struct pipe_rt_blend_state rt[PIPE_MAX_COLOR_BUFS]; }; diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c index 43e62c29f3..75c1418335 100644 --- a/src/mesa/state_tracker/st_atom_blend.c +++ b/src/mesa/state_tracker/st_atom_blend.c @@ -169,30 +169,30 @@ update_blend( struct st_context *st ) } else if (st->ctx->Color.BlendEnabled) { /* blending enabled */ - blend->blend_enable = 1; + blend->rt[0].blend_enable = 1; - blend->rgb_func = translate_blend(st->ctx->Color.BlendEquationRGB); + blend->rt[0].rgb_func = translate_blend(st->ctx->Color.BlendEquationRGB); if (st->ctx->Color.BlendEquationRGB == GL_MIN || st->ctx->Color.BlendEquationRGB == GL_MAX) { /* Min/max are special */ - blend->rgb_src_factor = PIPE_BLENDFACTOR_ONE; - blend->rgb_dst_factor = PIPE_BLENDFACTOR_ONE; + blend->rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; + blend->rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ONE; } else { - blend->rgb_src_factor = translate_blend(st->ctx->Color.BlendSrcRGB); - blend->rgb_dst_factor = translate_blend(st->ctx->Color.BlendDstRGB); + blend->rt[0].rgb_src_factor = translate_blend(st->ctx->Color.BlendSrcRGB); + blend->rt[0].rgb_dst_factor = translate_blend(st->ctx->Color.BlendDstRGB); } - blend->alpha_func = translate_blend(st->ctx->Color.BlendEquationA); + blend->rt[0].alpha_func = translate_blend(st->ctx->Color.BlendEquationA); if (st->ctx->Color.BlendEquationA == GL_MIN || st->ctx->Color.BlendEquationA == GL_MAX) { /* Min/max are special */ - blend->alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend->alpha_dst_factor = PIPE_BLENDFACTOR_ONE; + blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ONE; } else { - blend->alpha_src_factor = translate_blend(st->ctx->Color.BlendSrcA); - blend->alpha_dst_factor = translate_blend(st->ctx->Color.BlendDstA); + blend->rt[0].alpha_src_factor = translate_blend(st->ctx->Color.BlendSrcA); + blend->rt[0].alpha_dst_factor = translate_blend(st->ctx->Color.BlendDstA); } } else { @@ -201,13 +201,13 @@ update_blend( struct st_context *st ) /* Colormask - maybe reverse these bits? */ if (st->ctx->Color.ColorMask[0][0]) - blend->colormask |= PIPE_MASK_R; + blend->rt[0].colormask |= PIPE_MASK_R; if (st->ctx->Color.ColorMask[0][1]) - blend->colormask |= PIPE_MASK_G; + blend->rt[0].colormask |= PIPE_MASK_G; if (st->ctx->Color.ColorMask[0][2]) - blend->colormask |= PIPE_MASK_B; + blend->rt[0].colormask |= PIPE_MASK_B; if (st->ctx->Color.ColorMask[0][3]) - blend->colormask |= PIPE_MASK_A; + blend->rt[0].colormask |= PIPE_MASK_A; if (st->ctx->Color.DitherFlag) blend->dither = 1; diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 192d765f45..2c1be41ad8 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -227,19 +227,19 @@ clear_with_quad(GLcontext *ctx, { struct pipe_blend_state blend; memset(&blend, 0, sizeof(blend)); - blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE; - blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; if (color) { if (ctx->Color.ColorMask[0][0]) - blend.colormask |= PIPE_MASK_R; + blend.rt[0].colormask |= PIPE_MASK_R; if (ctx->Color.ColorMask[0][1]) - blend.colormask |= PIPE_MASK_G; + blend.rt[0].colormask |= PIPE_MASK_G; if (ctx->Color.ColorMask[0][2]) - blend.colormask |= PIPE_MASK_B; + blend.rt[0].colormask |= PIPE_MASK_B; if (ctx->Color.ColorMask[0][3]) - blend.colormask |= PIPE_MASK_A; + blend.rt[0].colormask |= PIPE_MASK_A; if (st->ctx->Color.DitherFlag) blend.dither = 1; } -- cgit v1.2.3 From 04cb5dfb1e0968300204980b08748a140e5e7918 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 20 Jan 2010 18:27:53 +0100 Subject: llvmpipe: adapt to per-rendertarget blend changes --- src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c | 19 +++++++++++-------- src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c | 12 ++++++------ src/gallium/drivers/llvmpipe/lp_state_fs.c | 20 ++++++++++---------- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c index ced7b9c11d..ad1dbbc9b1 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c @@ -314,9 +314,10 @@ lp_build_blend_aos(LLVMBuilderRef builder, LLVMValueRef dst_term; /* FIXME */ - assert(blend->colormask == 0xf); + assert(blend->independent_blend_enable == 0); + assert(blend->rt[0].colormask == 0xf); - if(!blend->blend_enable) + if(!blend->rt[0].blend_enable) return src; /* It makes no sense to blend unless values are normalized */ @@ -333,14 +334,16 @@ lp_build_blend_aos(LLVMBuilderRef builder, * combinations it is possible to reorder the operations and therefore saving * some instructions. */ - src_term = lp_build_blend_factor(&bld, src, blend->rgb_src_factor, blend->alpha_src_factor, alpha_swizzle); - dst_term = lp_build_blend_factor(&bld, dst, blend->rgb_dst_factor, blend->alpha_dst_factor, alpha_swizzle); + src_term = lp_build_blend_factor(&bld, src, blend->rt[0].rgb_src_factor, + blend->rt[0].alpha_src_factor, alpha_swizzle); + dst_term = lp_build_blend_factor(&bld, dst, blend->rt[0].rgb_dst_factor, + blend->rt[0].alpha_dst_factor, alpha_swizzle); lp_build_name(src_term, "src_term"); lp_build_name(dst_term, "dst_term"); - if(blend->rgb_func == blend->alpha_func) { - return lp_build_blend_func(&bld.base, blend->rgb_func, src_term, dst_term); + if(blend->rt[0].rgb_func == blend->rt[0].alpha_func) { + return lp_build_blend_func(&bld.base, blend->rt[0].rgb_func, src_term, dst_term); } else { /* Seperate RGB / A functions */ @@ -348,8 +351,8 @@ lp_build_blend_aos(LLVMBuilderRef builder, LLVMValueRef rgb; LLVMValueRef alpha; - rgb = lp_build_blend_func(&bld.base, blend->rgb_func, src_term, dst_term); - alpha = lp_build_blend_func(&bld.base, blend->alpha_func, src_term, dst_term); + rgb = lp_build_blend_func(&bld.base, blend->rt[0].rgb_func, src_term, dst_term); + alpha = lp_build_blend_func(&bld.base, blend->rt[0].alpha_func, src_term, dst_term); return lp_build_blend_swizzle(&bld, rgb, alpha, LP_BUILD_BLEND_SWIZZLE_RGBA, alpha_swizzle); } diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c b/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c index 9511299d55..284977b7c3 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c @@ -218,7 +218,7 @@ lp_build_blend_soa(LLVMBuilderRef builder, } for (i = 0; i < 4; ++i) { - if (blend->colormask & (1 << i)) { + if (blend->rt[0].colormask & (1 << i)) { if (blend->logicop_enable) { if(!type.floating) { res[i] = lp_build_logicop(builder, blend->logicop_func, src[i], dst[i]); @@ -226,10 +226,10 @@ lp_build_blend_soa(LLVMBuilderRef builder, else res[i] = dst[i]; } - else if (blend->blend_enable) { - unsigned src_factor = i < 3 ? blend->rgb_src_factor : blend->alpha_src_factor; - unsigned dst_factor = i < 3 ? blend->rgb_dst_factor : blend->alpha_dst_factor; - unsigned func = i < 3 ? blend->rgb_func : blend->alpha_func; + else if (blend->rt[0].blend_enable) { + unsigned src_factor = i < 3 ? blend->rt[0].rgb_src_factor : blend->rt[0].alpha_src_factor; + unsigned dst_factor = i < 3 ? blend->rt[0].rgb_dst_factor : blend->rt[0].alpha_dst_factor; + unsigned func = i < 3 ? blend->rt[0].rgb_func : blend->rt[0].alpha_func; boolean func_commutative = lp_build_blend_func_commutative(func); /* It makes no sense to blend unless values are normalized */ @@ -270,7 +270,7 @@ lp_build_blend_soa(LLVMBuilderRef builder, /* See if this function has been previously applied */ for(j = 0; j < i; ++j) { - unsigned prev_func = j < 3 ? blend->rgb_func : blend->alpha_func; + unsigned prev_func = j < 3 ? blend->rt[0].rgb_func : blend->rt[0].alpha_func; unsigned func_reverse = lp_build_blend_func_reverse(func, prev_func); if((!func_reverse && diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 9f4bbef73f..c6d97bb3e9 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -354,7 +354,7 @@ generate_blend(const struct pipe_blend_state *blend, lp_build_blend_soa(builder, blend, type, src, dst, con, res); for(chan = 0; chan < 4; ++chan) { - if(blend->colormask & (1 << chan)) { + if(blend->rt[0].colormask & (1 << chan)) { LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), chan, 0); lp_build_name(res[chan], "res.%c", "rgba"[chan]); res[chan] = lp_build_select(&bld, mask, res[chan], dst[chan]); @@ -423,15 +423,15 @@ generate_fragment(struct llvmpipe_context *lp, if(key->blend.logicop_enable) { debug_printf("blend.logicop_func = %u\n", key->blend.logicop_func); } - else if(key->blend.blend_enable) { - debug_printf("blend.rgb_func = %s\n", debug_dump_blend_func (key->blend.rgb_func, TRUE)); - debug_printf("rgb_src_factor = %s\n", debug_dump_blend_factor(key->blend.rgb_src_factor, TRUE)); - debug_printf("rgb_dst_factor = %s\n", debug_dump_blend_factor(key->blend.rgb_dst_factor, TRUE)); - debug_printf("alpha_func = %s\n", debug_dump_blend_func (key->blend.alpha_func, TRUE)); - debug_printf("alpha_src_factor = %s\n", debug_dump_blend_factor(key->blend.alpha_src_factor, TRUE)); - debug_printf("alpha_dst_factor = %s\n", debug_dump_blend_factor(key->blend.alpha_dst_factor, TRUE)); + else if(key->blend.rt[0].blend_enable) { + debug_printf("blend.rgb_func = %s\n", debug_dump_blend_func (key->blend.rt[0].rgb_func, TRUE)); + debug_printf("rgb_src_factor = %s\n", debug_dump_blend_factor(key->blend.rt[0].rgb_src_factor, TRUE)); + debug_printf("rgb_dst_factor = %s\n", debug_dump_blend_factor(key->blend.rt[0].rgb_dst_factor, TRUE)); + debug_printf("alpha_func = %s\n", debug_dump_blend_func (key->blend.rt[0].alpha_func, TRUE)); + debug_printf("alpha_src_factor = %s\n", debug_dump_blend_factor(key->blend.rt[0].alpha_src_factor, TRUE)); + debug_printf("alpha_dst_factor = %s\n", debug_dump_blend_factor(key->blend.rt[0].alpha_dst_factor, TRUE)); } - debug_printf("blend.colormask = 0x%x\n", key->blend.colormask); + debug_printf("blend.colormask = 0x%x\n", key->blend.rt[0].colormask); for(i = 0; i < PIPE_MAX_SAMPLERS; ++i) { if(key->sampler[i].format) { debug_printf("sampler[%u] = \n", i); @@ -782,7 +782,7 @@ make_variant_key(struct llvmpipe_context *lp, for(chan = 0; chan < 4; ++chan) { enum util_format_swizzle swizzle = format_desc->swizzle[chan]; if(swizzle > 4) - key->blend.colormask &= ~(1 << chan); + key->blend.rt[0].colormask &= ~(1 << chan); } } -- cgit v1.2.3 From a416123f5b0f05d95eb334473473f660c22b439e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 20 Jan 2010 10:32:13 -0700 Subject: xlib/softpipe: fix buffer memory leak Fixes leak caused by window resize. --- src/gallium/winsys/xlib/xlib_softpipe.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/gallium/winsys/xlib/xlib_softpipe.c b/src/gallium/winsys/xlib/xlib_softpipe.c index 260b39e2a0..da2484c981 100644 --- a/src/gallium/winsys/xlib/xlib_softpipe.c +++ b/src/gallium/winsys/xlib/xlib_softpipe.c @@ -203,6 +203,14 @@ xm_buffer_destroy(struct pipe_buffer *buf) { struct xm_buffer *oldBuf = xm_buffer(buf); + /* + * Note oldBuf->data may point to one of three things: + * 1. XShm shared memory image data + * 2. User-provided (wrapped) memory, see xm_user_buffer_create() + * 3. Regular, malloc'd memory + * We need to be careful with freeing that data now. + */ + if (oldBuf->data) { #ifdef USE_XSHM if (oldBuf->shminfo.shmid >= 0) { @@ -212,12 +220,19 @@ xm_buffer_destroy(struct pipe_buffer *buf) oldBuf->shminfo.shmid = -1; oldBuf->shminfo.shmaddr = (char *) -1; } - else -#endif - { - if (!oldBuf->userBuffer) { - align_free(oldBuf->data); + + if (oldBuf->tempImage) { + if (oldBuf->data == oldBuf->tempImage->data) { + /* oldBuf->data points at the xshm memory which we'll now free */ + oldBuf->data = NULL; } + XDestroyImage(oldBuf->tempImage); + } +#endif + + if (oldBuf->data && !oldBuf->userBuffer) { + /* this was regular malloc'd memory */ + align_free(oldBuf->data); } oldBuf->data = NULL; -- cgit v1.2.3 From 1ffb72a6bf2de0d1044eacb0b72ad6a27c2198c4 Mon Sep 17 00:00:00 2001 From: Tomas Chvatal Date: Wed, 20 Jan 2010 21:14:32 +0100 Subject: Fix touching live system during install. --- src/gallium/winsys/drm/radeon/egl/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/winsys/drm/radeon/egl/Makefile b/src/gallium/winsys/drm/radeon/egl/Makefile index 2bd05a8175..c5fdc9a5c0 100644 --- a/src/gallium/winsys/drm/radeon/egl/Makefile +++ b/src/gallium/winsys/drm/radeon/egl/Makefile @@ -35,4 +35,4 @@ depend: symlinks: install: $(LIBNAME) - $(MINSTALL) -m 755 $(LIBNAME) $(INSTALL_DIR)/$(LIB_DIR) + $(MINSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) -- cgit v1.2.3 From c1334ce23550a8321023c0b8fa58ad266199afa1 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 20 Jan 2010 12:21:21 -0800 Subject: radeong: Fix EGL driver names. Using "radeon" instead of "radeong" because we don't have classic EGL. --- src/gallium/winsys/drm/radeon/egl/Makefile | 2 +- src/gallium/winsys/drm/radeon/egl_g3d/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/winsys/drm/radeon/egl/Makefile b/src/gallium/winsys/drm/radeon/egl/Makefile index c5fdc9a5c0..fcbfd09786 100644 --- a/src/gallium/winsys/drm/radeon/egl/Makefile +++ b/src/gallium/winsys/drm/radeon/egl/Makefile @@ -2,7 +2,7 @@ TOP = ../../../../../.. GALLIUMDIR = ../../../.. include $(TOP)/configs/current -LIBNAME = egl_r300.so +LIBNAME = egl_radeon.so PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/egl/libegldrm.a \ diff --git a/src/gallium/winsys/drm/radeon/egl_g3d/Makefile b/src/gallium/winsys/drm/radeon/egl_g3d/Makefile index 9027a5ff46..e0de68c678 100644 --- a/src/gallium/winsys/drm/radeon/egl_g3d/Makefile +++ b/src/gallium/winsys/drm/radeon/egl_g3d/Makefile @@ -1,7 +1,7 @@ TOP = ../../../../../.. include $(TOP)/configs/current -EGL_DRIVER_NAME = r300 +EGL_DRIVER_NAME = radeon EGL_DRIVER_SOURCES = dummy.c EGL_DRIVER_LIBS = -ldrm_radeon -- cgit v1.2.3 From 0bc2cbf82a20c0fa5b160605eb7e8118791f5fdd Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Wed, 20 Jan 2010 16:27:44 -0800 Subject: ffb: Remove unnecessary headers. --- src/mesa/drivers/dri/ffb/ffb_bitmap.c | 1 - src/mesa/drivers/dri/ffb/ffb_clear.c | 3 --- src/mesa/drivers/dri/ffb/ffb_dd.c | 4 ---- src/mesa/drivers/dri/ffb/ffb_depth.c | 1 - src/mesa/drivers/dri/ffb/ffb_lines.c | 4 ---- src/mesa/drivers/dri/ffb/ffb_points.c | 2 -- src/mesa/drivers/dri/ffb/ffb_span.c | 2 -- src/mesa/drivers/dri/ffb/ffb_state.c | 5 ----- src/mesa/drivers/dri/ffb/ffb_stencil.c | 2 -- src/mesa/drivers/dri/ffb/ffb_vb.c | 2 -- src/mesa/drivers/dri/ffb/ffb_xmesa.c | 2 -- 11 files changed, 28 deletions(-) diff --git a/src/mesa/drivers/dri/ffb/ffb_bitmap.c b/src/mesa/drivers/dri/ffb/ffb_bitmap.c index f89c0412df..1240f1c9c7 100644 --- a/src/mesa/drivers/dri/ffb/ffb_bitmap.c +++ b/src/mesa/drivers/dri/ffb/ffb_bitmap.c @@ -30,7 +30,6 @@ #include "ffb_lock.h" #include "ffb_bitmap.h" #include "swrast/swrast.h" -#include "main/image.h" #include "main/macros.h" /* Compute ceiling of integer quotient of A divided by B: */ diff --git a/src/mesa/drivers/dri/ffb/ffb_clear.c b/src/mesa/drivers/dri/ffb/ffb_clear.c index 776fb487f8..6239a4e01a 100644 --- a/src/mesa/drivers/dri/ffb/ffb_clear.c +++ b/src/mesa/drivers/dri/ffb/ffb_clear.c @@ -26,15 +26,12 @@ */ #include "main/mtypes.h" -#include "main/extensions.h" #include "main/mm.h" #include "ffb_dd.h" #include "ffb_span.h" -#include "ffb_depth.h" #include "ffb_context.h" #include "ffb_vb.h" -#include "ffb_tris.h" #include "ffb_clear.h" #include "ffb_lock.h" diff --git a/src/mesa/drivers/dri/ffb/ffb_dd.c b/src/mesa/drivers/dri/ffb/ffb_dd.c index cf83b91f0d..91b6d3153a 100644 --- a/src/mesa/drivers/dri/ffb/ffb_dd.c +++ b/src/mesa/drivers/dri/ffb/ffb_dd.c @@ -27,13 +27,9 @@ #include "main/mtypes.h" #include "main/mm.h" -#include "main/extensions.h" #include "ffb_dd.h" #include "ffb_span.h" -#include "ffb_depth.h" #include "ffb_context.h" -#include "ffb_vb.h" -#include "ffb_tris.h" #include "ffb_clear.h" #include "ffb_lock.h" diff --git a/src/mesa/drivers/dri/ffb/ffb_depth.c b/src/mesa/drivers/dri/ffb/ffb_depth.c index 71f204d21e..e82c2416eb 100644 --- a/src/mesa/drivers/dri/ffb/ffb_depth.c +++ b/src/mesa/drivers/dri/ffb/ffb_depth.c @@ -26,7 +26,6 @@ */ #include "main/mtypes.h" -#include "swrast/swrast.h" #include "ffb_dd.h" #include "ffb_span.h" #include "ffb_context.h" diff --git a/src/mesa/drivers/dri/ffb/ffb_lines.c b/src/mesa/drivers/dri/ffb/ffb_lines.c index 19dff50935..6dca4edd29 100644 --- a/src/mesa/drivers/dri/ffb/ffb_lines.c +++ b/src/mesa/drivers/dri/ffb/ffb_lines.c @@ -27,15 +27,11 @@ #include "main/mtypes.h" #include "main/mm.h" -#include "main/extensions.h" #include "ffb_dd.h" #include "ffb_span.h" -#include "ffb_depth.h" #include "ffb_context.h" #include "ffb_vb.h" #include "ffb_lines.h" -#include "ffb_tris.h" -#include "ffb_lock.h" #undef FFB_LINE_TRACE diff --git a/src/mesa/drivers/dri/ffb/ffb_points.c b/src/mesa/drivers/dri/ffb/ffb_points.c index 9c37a47aeb..5bf4f8f070 100644 --- a/src/mesa/drivers/dri/ffb/ffb_points.c +++ b/src/mesa/drivers/dri/ffb/ffb_points.c @@ -30,8 +30,6 @@ #include "ffb_context.h" #include "ffb_vb.h" #include "ffb_points.h" -#include "ffb_tris.h" -#include "ffb_lock.h" #undef FFB_POINT_TRACE diff --git a/src/mesa/drivers/dri/ffb/ffb_span.c b/src/mesa/drivers/dri/ffb/ffb_span.c index 0d3d604095..c4cb386f48 100644 --- a/src/mesa/drivers/dri/ffb/ffb_span.c +++ b/src/mesa/drivers/dri/ffb/ffb_span.c @@ -31,8 +31,6 @@ #include "ffb_context.h" #include "ffb_lock.h" -#include "swrast/swrast.h" - #define DBG 0 #define HW_LOCK() \ diff --git a/src/mesa/drivers/dri/ffb/ffb_state.c b/src/mesa/drivers/dri/ffb/ffb_state.c index 5eb8f417ff..81341cb36f 100644 --- a/src/mesa/drivers/dri/ffb/ffb_state.c +++ b/src/mesa/drivers/dri/ffb/ffb_state.c @@ -27,8 +27,6 @@ #include "main/mtypes.h" #include "main/colormac.h" -#include "main/mm.h" -#include "main/extensions.h" #include "main/enums.h" #include "vbo/vbo.h" @@ -39,12 +37,9 @@ #include "ffb_dd.h" #include "ffb_span.h" -#include "ffb_depth.h" #include "ffb_context.h" -#include "ffb_vb.h" #include "ffb_tris.h" #include "ffb_state.h" -#include "ffb_lock.h" #undef STATE_TRACE diff --git a/src/mesa/drivers/dri/ffb/ffb_stencil.c b/src/mesa/drivers/dri/ffb/ffb_stencil.c index 921a83d274..2be5a40a89 100644 --- a/src/mesa/drivers/dri/ffb/ffb_stencil.c +++ b/src/mesa/drivers/dri/ffb/ffb_stencil.c @@ -32,8 +32,6 @@ #include "ffb_stencil.h" #include "ffb_lock.h" -#include "swrast/swrast.h" - #undef STENCIL_TRACE static void FFBWriteStencilSpan( GLcontext *ctx, diff --git a/src/mesa/drivers/dri/ffb/ffb_vb.c b/src/mesa/drivers/dri/ffb/ffb_vb.c index f9c6fd1f31..ca8ffb2721 100644 --- a/src/mesa/drivers/dri/ffb/ffb_vb.c +++ b/src/mesa/drivers/dri/ffb/ffb_vb.c @@ -30,8 +30,6 @@ #include "ffb_vb.h" #include "main/imports.h" #include "tnl/t_context.h" -#include "swrast_setup/swrast_setup.h" -#include "math/m_translate.h" #undef VB_DEBUG diff --git a/src/mesa/drivers/dri/ffb/ffb_xmesa.c b/src/mesa/drivers/dri/ffb/ffb_xmesa.c index 09cc26d09e..28f8e53f10 100644 --- a/src/mesa/drivers/dri/ffb/ffb_xmesa.c +++ b/src/mesa/drivers/dri/ffb/ffb_xmesa.c @@ -28,7 +28,6 @@ #include "ffb_xmesa.h" #include "main/context.h" #include "main/framebuffer.h" -#include "main/matrix.h" #include "main/renderbuffer.h" #include "main/simple_list.h" #include "main/imports.h" @@ -52,7 +51,6 @@ #include "ffb_lines.h" #include "ffb_points.h" #include "ffb_state.h" -#include "ffb_tex.h" #include "ffb_lock.h" #include "ffb_vtxfmt.h" #include "ffb_bitmap.h" -- cgit v1.2.3 From 208e815c888d5267d146ac3a89a70d733728826c Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Tue, 19 Jan 2010 18:59:39 -0800 Subject: gallium/i965: Make brw_batchbuffer prototypes match in source & header Signed-off-by: Alan Coopersmith Signed-off-by: Brian Paul --- src/gallium/drivers/i965/brw_batchbuffer.c | 2 +- src/gallium/drivers/i965/brw_batchbuffer.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/i965/brw_batchbuffer.c b/src/gallium/drivers/i965/brw_batchbuffer.c index 22607dc608..003b1fd5bf 100644 --- a/src/gallium/drivers/i965/brw_batchbuffer.c +++ b/src/gallium/drivers/i965/brw_batchbuffer.c @@ -155,7 +155,7 @@ _brw_batchbuffer_flush(struct brw_batchbuffer *batch, enum pipe_error brw_batchbuffer_emit_reloc(struct brw_batchbuffer *batch, struct brw_winsys_buffer *buffer, - uint32_t usage, + enum brw_buffer_usage usage, uint32_t delta) { int ret; diff --git a/src/gallium/drivers/i965/brw_batchbuffer.h b/src/gallium/drivers/i965/brw_batchbuffer.h index 7473f5bea4..6ca9f617f5 100644 --- a/src/gallium/drivers/i965/brw_batchbuffer.h +++ b/src/gallium/drivers/i965/brw_batchbuffer.h @@ -64,12 +64,12 @@ brw_batchbuffer_reset(struct brw_batchbuffer *batch); * Consider it a convenience function wrapping multple * intel_buffer_dword() calls. */ -int brw_batchbuffer_data(struct brw_batchbuffer *batch, +enum pipe_error brw_batchbuffer_data(struct brw_batchbuffer *batch, const void *data, GLuint bytes, enum cliprect_mode cliprect_mode); -int brw_batchbuffer_emit_reloc(struct brw_batchbuffer *batch, +enum pipe_error brw_batchbuffer_emit_reloc(struct brw_batchbuffer *batch, struct brw_winsys_buffer *buffer, enum brw_buffer_usage usage, uint32_t offset); -- cgit v1.2.3 From 7c66211b7dcf302685b8cc3f80a4d90b73d7d62d Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Wed, 20 Jan 2010 22:02:51 -0800 Subject: i810: Remove unnecessary headers. --- src/mesa/drivers/dri/i810/i810context.c | 3 --- src/mesa/drivers/dri/i810/i810render.c | 1 - src/mesa/drivers/dri/i810/i810screen.c | 4 ---- src/mesa/drivers/dri/i810/i810state.c | 2 -- src/mesa/drivers/dri/i810/i810tex.c | 2 -- src/mesa/drivers/dri/i810/i810texmem.c | 1 - src/mesa/drivers/dri/i810/i810vb.c | 1 - 7 files changed, 14 deletions(-) diff --git a/src/mesa/drivers/dri/i810/i810context.c b/src/mesa/drivers/dri/i810/i810context.c index 7311b2e765..350c2e3e3b 100644 --- a/src/mesa/drivers/dri/i810/i810context.c +++ b/src/mesa/drivers/dri/i810/i810context.c @@ -34,10 +34,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/glheader.h" #include "main/context.h" -#include "main/matrix.h" #include "main/simple_list.h" -#include "main/extensions.h" -#include "main/framebuffer.h" #include "main/imports.h" #include "main/points.h" diff --git a/src/mesa/drivers/dri/i810/i810render.c b/src/mesa/drivers/dri/i810/i810render.c index 1d98e00688..b543d4f012 100644 --- a/src/mesa/drivers/dri/i810/i810render.c +++ b/src/mesa/drivers/dri/i810/i810render.c @@ -44,7 +44,6 @@ #include "i810context.h" #include "i810tris.h" -#include "i810state.h" #include "i810vb.h" #include "i810ioctl.h" diff --git a/src/mesa/drivers/dri/i810/i810screen.c b/src/mesa/drivers/dri/i810/i810screen.c index 2f6b8631ff..b65395831a 100644 --- a/src/mesa/drivers/dri/i810/i810screen.c +++ b/src/mesa/drivers/dri/i810/i810screen.c @@ -36,8 +36,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/imports.h" #include "main/context.h" #include "main/framebuffer.h" -#include "main/fbobject.h" -#include "main/matrix.h" #include "main/renderbuffer.h" #include "main/simple_list.h" #include "utils.h" @@ -48,8 +46,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "i810state.h" #include "i810tex.h" #include "i810span.h" -#include "i810tris.h" -#include "i810ioctl.h" #include "GL/internal/dri_interface.h" diff --git a/src/mesa/drivers/dri/i810/i810state.c b/src/mesa/drivers/dri/i810/i810state.c index 1e7a6cfe47..a4b1477b61 100644 --- a/src/mesa/drivers/dri/i810/i810state.c +++ b/src/mesa/drivers/dri/i810/i810state.c @@ -20,8 +20,6 @@ #include "i810context.h" #include "i810state.h" #include "i810tex.h" -#include "i810vb.h" -#include "i810tris.h" #include "i810ioctl.h" diff --git a/src/mesa/drivers/dri/i810/i810tex.c b/src/mesa/drivers/dri/i810/i810tex.c index 2f6978f5aa..5c530325c9 100644 --- a/src/mesa/drivers/dri/i810/i810tex.c +++ b/src/mesa/drivers/dri/i810/i810tex.c @@ -33,7 +33,6 @@ #include "main/colormac.h" #include "main/texobj.h" #include "main/mm.h" -#include "swrast/swrast.h" #include "texmem.h" @@ -42,7 +41,6 @@ #include "i810context.h" #include "i810tex.h" -#include "i810state.h" #include "i810ioctl.h" diff --git a/src/mesa/drivers/dri/i810/i810texmem.c b/src/mesa/drivers/dri/i810/i810texmem.c index d93afbf9ef..bb426a4112 100644 --- a/src/mesa/drivers/dri/i810/i810texmem.c +++ b/src/mesa/drivers/dri/i810/i810texmem.c @@ -35,7 +35,6 @@ #include "i810_dri.h" #include "i810context.h" #include "i810tex.h" -#include "i810state.h" #include "i810ioctl.h" diff --git a/src/mesa/drivers/dri/i810/i810vb.c b/src/mesa/drivers/dri/i810/i810vb.c index 30890dc9b7..09a772258c 100644 --- a/src/mesa/drivers/dri/i810/i810vb.c +++ b/src/mesa/drivers/dri/i810/i810vb.c @@ -38,7 +38,6 @@ #include "i810context.h" #include "i810vb.h" #include "i810ioctl.h" -#include "i810tris.h" #include "i810state.h" -- cgit v1.2.3 From e19b3c01f4442e2c85c6df19847368ecb7b2451f Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Wed, 20 Jan 2010 22:52:49 -0800 Subject: mach64: Remove unnecessary headers. --- src/mesa/drivers/dri/mach64/mach64_context.c | 2 -- src/mesa/drivers/dri/mach64/mach64_dd.c | 3 --- src/mesa/drivers/dri/mach64/mach64_lock.c | 1 - src/mesa/drivers/dri/mach64/mach64_screen.c | 2 -- src/mesa/drivers/dri/mach64/mach64_span.c | 1 - src/mesa/drivers/dri/mach64/mach64_state.c | 3 --- src/mesa/drivers/dri/mach64/mach64_tex.c | 5 ----- src/mesa/drivers/dri/mach64/mach64_texmem.c | 3 --- src/mesa/drivers/dri/mach64/mach64_texstate.c | 2 -- src/mesa/drivers/dri/mach64/mach64_vb.c | 1 - 10 files changed, 23 deletions(-) diff --git a/src/mesa/drivers/dri/mach64/mach64_context.c b/src/mesa/drivers/dri/mach64/mach64_context.c index 2bca293b3c..37cea9dd44 100644 --- a/src/mesa/drivers/dri/mach64/mach64_context.c +++ b/src/mesa/drivers/dri/mach64/mach64_context.c @@ -33,8 +33,6 @@ #include "main/context.h" #include "main/simple_list.h" #include "main/imports.h" -#include "main/matrix.h" -#include "main/extensions.h" #include "swrast/swrast.h" #include "swrast_setup/swrast_setup.h" diff --git a/src/mesa/drivers/dri/mach64/mach64_dd.c b/src/mesa/drivers/dri/mach64/mach64_dd.c index e400e9a918..ca713e2de5 100644 --- a/src/mesa/drivers/dri/mach64/mach64_dd.c +++ b/src/mesa/drivers/dri/mach64/mach64_dd.c @@ -31,12 +31,9 @@ #include "mach64_context.h" #include "mach64_ioctl.h" -#include "mach64_state.h" -#include "mach64_vb.h" #include "mach64_dd.h" #include "main/context.h" -#include "main/framebuffer.h" #include "utils.h" diff --git a/src/mesa/drivers/dri/mach64/mach64_lock.c b/src/mesa/drivers/dri/mach64/mach64_lock.c index d018ba4174..f7ef4da853 100644 --- a/src/mesa/drivers/dri/mach64/mach64_lock.c +++ b/src/mesa/drivers/dri/mach64/mach64_lock.c @@ -32,7 +32,6 @@ #include "mach64_context.h" #include "mach64_state.h" #include "mach64_lock.h" -#include "mach64_tex.h" #include "drirenderbuffer.h" #if DEBUG_LOCKING diff --git a/src/mesa/drivers/dri/mach64/mach64_screen.c b/src/mesa/drivers/dri/mach64/mach64_screen.c index 3b19cf5333..61e174533d 100644 --- a/src/mesa/drivers/dri/mach64/mach64_screen.c +++ b/src/mesa/drivers/dri/mach64/mach64_screen.c @@ -31,8 +31,6 @@ #include "mach64_context.h" #include "mach64_ioctl.h" -#include "mach64_tris.h" -#include "mach64_vb.h" #include "mach64_span.h" #include "main/context.h" diff --git a/src/mesa/drivers/dri/mach64/mach64_span.c b/src/mesa/drivers/dri/mach64/mach64_span.c index 500319e0e3..d9d1244a9f 100644 --- a/src/mesa/drivers/dri/mach64/mach64_span.c +++ b/src/mesa/drivers/dri/mach64/mach64_span.c @@ -31,7 +31,6 @@ #include "mach64_context.h" #include "mach64_ioctl.h" -#include "mach64_state.h" #include "mach64_span.h" #include "swrast/swrast.h" diff --git a/src/mesa/drivers/dri/mach64/mach64_state.c b/src/mesa/drivers/dri/mach64/mach64_state.c index 3a023187ce..754ed86e59 100644 --- a/src/mesa/drivers/dri/mach64/mach64_state.c +++ b/src/mesa/drivers/dri/mach64/mach64_state.c @@ -36,7 +36,6 @@ #include "mach64_vb.h" #include "mach64_tex.h" -#include "main/context.h" #include "main/enums.h" #include "main/colormac.h" #include "swrast/swrast.h" @@ -44,8 +43,6 @@ #include "tnl/tnl.h" #include "swrast_setup/swrast_setup.h" -#include "tnl/t_pipeline.h" - /* ============================================================= * Alpha blending diff --git a/src/mesa/drivers/dri/mach64/mach64_tex.c b/src/mesa/drivers/dri/mach64/mach64_tex.c index a757362b11..2e85336c4f 100644 --- a/src/mesa/drivers/dri/mach64/mach64_tex.c +++ b/src/mesa/drivers/dri/mach64/mach64_tex.c @@ -31,13 +31,8 @@ #include "mach64_context.h" #include "mach64_ioctl.h" -#include "mach64_state.h" -#include "mach64_vb.h" -#include "mach64_tris.h" #include "mach64_tex.h" -#include "main/context.h" -#include "main/macros.h" #include "main/simple_list.h" #include "main/enums.h" #include "main/texstore.h" diff --git a/src/mesa/drivers/dri/mach64/mach64_texmem.c b/src/mesa/drivers/dri/mach64/mach64_texmem.c index b97e9eec25..46cee4320d 100644 --- a/src/mesa/drivers/dri/mach64/mach64_texmem.c +++ b/src/mesa/drivers/dri/mach64/mach64_texmem.c @@ -37,10 +37,7 @@ #include "main/imports.h" #include "mach64_context.h" -#include "mach64_state.h" #include "mach64_ioctl.h" -#include "mach64_vb.h" -#include "mach64_tris.h" #include "mach64_tex.h" diff --git a/src/mesa/drivers/dri/mach64/mach64_texstate.c b/src/mesa/drivers/dri/mach64/mach64_texstate.c index df0a09a5c1..adf774ec19 100644 --- a/src/mesa/drivers/dri/mach64/mach64_texstate.c +++ b/src/mesa/drivers/dri/mach64/mach64_texstate.c @@ -36,8 +36,6 @@ #include "mach64_context.h" #include "mach64_ioctl.h" -#include "mach64_state.h" -#include "mach64_vb.h" #include "mach64_tris.h" #include "mach64_tex.h" diff --git a/src/mesa/drivers/dri/mach64/mach64_vb.c b/src/mesa/drivers/dri/mach64/mach64_vb.c index e58812e902..00da835376 100644 --- a/src/mesa/drivers/dri/mach64/mach64_vb.c +++ b/src/mesa/drivers/dri/mach64/mach64_vb.c @@ -42,7 +42,6 @@ #include "mach64_vb.h" #include "mach64_ioctl.h" #include "mach64_tris.h" -#include "mach64_state.h" #define MACH64_TEX1_BIT 0x1 -- cgit v1.2.3 From ada46053a4b37967cc53355b9baf712aa5a8bafd Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 21 Jan 2010 15:29:14 +0800 Subject: docs: Add documentation for EGL. This is a short guide to EGL. The drivers that are to be removed soon are not mentioned in the guide. --- docs/egl.html | 224 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 docs/egl.html diff --git a/docs/egl.html b/docs/egl.html new file mode 100644 index 0000000000..ccc233fca9 --- /dev/null +++ b/docs/egl.html @@ -0,0 +1,224 @@ + + +Mesa EGL + + + + + +

Mesa EGL

+ +

The current version of EGL in Mesa implements EGL 1.4. More information +about EGL can be found at +http://www.khronos.org/egl/.

+ +

The Mesa's implementation of EGL uses a driver architecture. The main +library (libEGL) is window system neutral. It provides the EGL +API entry points and helper functions for use by the drivers. Drivers are +dynamically loaded by the main library and most of the EGL API calls are +directly dispatched to the drivers.

+ +

The driver in use decides the window system to support. For drivers that +support hardware rendering, there are usually multiple drivers supporting the +same window system. Each one of of them supports a certain range of graphics +cards.

+ +

Build EGL

+ +
    +
  1. +

    Run configure with the desired state trackers and and enable +the Gallium driver for your hardware. For example

    + +
    +  $ ./configure --with-state-trackers=egl_g3d,es,vega --enable-gallium-intel
    +
    + +

    The main library will be enabled by default. The egl_g3d state +tracker is needed by a number of EGL drivers. EGL drivers will be covered +later. The es state tracker provides OpenGL ES 1.x +and 2.x and the vega state tracker provides OpenVG +1.x.

    +
  2. + +
  3. Build and install Mesa as usual.
  4. +
+ +

In the given example, it will build and install libEGL, +libGLESv1_CM, libGLESv2, libOpenVG, and +one or more EGL drivers.

+ +

Configure Options

+ +

There are several options that control the build of EGL at configuration +time

+ +
    +
  • --enable-egl + +

    By default, EGL is enabled. When disabled, the main library and the drivers +will not be built.

    + +
  • + +
  • --with-egl-displays + +

    List the window system(s) to support. It is by default x11, +which supports the X Window System. Its argument is a comma separated string +like, for example, --with-egl-displays=x11,kms. Because an EGL +driver decides which window system to support, this example will enable two +(sets of) EGL drivers. One supports the X window system and the other supports +bare KMS (kernel modesetting).

    + +
  • + +
  • --with-state-trackers + +

    The argument is a comma separated string. It is usually used to specify the +rendering APIs, like OpenGL ES or OpenVG, to build. But it should be noted +that a number of EGL drivers depend on the egl_g3d state tracker. +They will not be built without the egl_g3d state +tracker.

    + +
  • +
+ +

OpenGL

+ +

The OpenGL state tracker is not built in the above example. It should be +noted that the classic libGL is not a state tracker and cannot be +used with EGL (unless the EGL driver in use is egl_glx). To build +the OpenGL state tracker, one may append glx to +--with-state-trackers and manually build +src/gallium/winsys/xlib/.

+ +

Use EGL

+ +

The demos for OpenGL ES and OpenVG can be found in progs/es1/, +progs/es2/ and progs/openvg/. You can use them to +test your build. For example,

+ +
+  $ cd progs/es1/xegl
+  $ make
+  $ ./torus
+
+ +

Environment Variables

+ +

There are several environment variables that control the behavior of EGL at +runtime

+ +
    +
  • EGL_DRIVER + +

    This variable forces the specified EGL driver to be loaded. It comes in +handy when one wants to test a specific driver.

    + +
  • + +
  • EGL_DISPLAY + +

    When EGL_DRIVER is not set, the main library loads all +EGL drivers that support a certain window system. EGL_DISPLAY can +be used to specify the window system and the valid values are, for example, +x11 or kms. When the variable is not set, the main +library defaults the value to the first window system listed in +--with-egl-displays at configuration time. + +

  • + +
  • EGL_LOG_LEVEL + +

    This changes the log level of the main library and the drivers. The valid +values are: debug, info, warning, and +fatal.

    + +
  • + +
  • EGL_SOFTWARE + +

    For drivers that support both hardware and software rendering, setting this +variable to true forces the use of software rendering.

    + +
  • +
+ +

EGL Drivers

+ +

There are two categories of EGL drivers: Gallium and classic.

+ +

Gallium EGL drivers supports all rendering APIs specified in EGL 1.4. The +support for optional EGL functions and EGL extensions is usually more complete +than the classic ones. These drivers depend on the egl_g3d state +tracker to build. The available drivers are

+ +
    +
  • egl_<dpy>_i915
  • +
  • egl_<dpy>_i965
  • +
  • egl_<dpy>_radeon
  • +
  • egl_<dpy>_nouveau
  • +
  • egl_<dpy>_vmwgfx
  • +
+ +

<dpy> is given by --with-egl-displays at +configuration time. There will be one EGL driver for each combination of the +displays listed and the hardware drivers enabled.

+ +

Classic EGL drivers, on the other hand, supports only OpenGL as its +rendering API. They can be found under src/egl/drivers/. There +are 3 of them

+ +
    +
  • egl_glx + +

    This driver provides a wrapper to GLX. It uses exclusively GLX to implement +the EGL API. It supports both direct and indirect rendering when the GLX does. +It is accelerated when the GLX is. As such, it cannot provide functions that +is not available in GLX or GLX extensions.

    +
  • + +
  • egl_xdri + +

    This driver supports the X Window System as its window system. It functions +as a DRI driver loader. Unlike egl_glx, it has no dependency on +libGL. It talks to the X server directly using DRI or DRI2 +protocols. It also talks minimal GLX protocol for things like available +visuals or fbconfigs. With direct access to the DRI drivers, it has the +potential to support more EGL functions that are not possible with +egl_glx

    + +
  • +
  • egl_dri + +

    This driver lacks maintenance and does not build. It is similiar +to egl_xdri in that it functions as a DRI driver loader. But +unlike egl_xdri, it supports Linux framebuffer devices as its +window system and supports EGL_MESA_screen_surface extension. It loads only +DRI1 drivers. As DRI1 drivers is phasing out, it might be better to rewrite +the driver to support KMS and DRI2.

    + +
  • +
+ +

To use the classic drivers, one must manually set EGL_DRIVER at +runtime.

+ +

Developers

+ +The sources of the main library and the classic drivers can be found at +src/egl/. The sources of the egl_g3d state tracker +can be found at src/gallium/state_trackers/egl_g3d/. + +

TODOs

+ +
    +
  • Thread safety
  • +
  • Pass the conformance tests
  • +
  • Better automatic driver selection: EGL_DISPLAY loads all +drivers and might eat too much memory.
  • + +
+ + + -- cgit v1.2.3 From 1af67195b31f66c725293c916b794fbdb633aec9 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 21 Jan 2010 15:29:28 +0800 Subject: docs: Update documentation for OpenVG and OpenGL ES. Update the instructions and add references to egl.html. --- docs/opengles.html | 4 ++-- docs/openvg.html | 19 ++++++------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/docs/opengles.html b/docs/opengles.html index d460bccf6c..8665a9c353 100644 --- a/docs/opengles.html +++ b/docs/opengles.html @@ -13,7 +13,8 @@ More informations about OpenGL ES can be found at http://www.khronos.org/opengles/.

The OpenGL ES state trackers depends on the Gallium architecture and a -working EGL implementation.

+working EGL implementation. Please refer to Mesa EGL +for more information about EGL.

Build the Libraries

@@ -28,7 +29,6 @@ working EGL implementation.

There are some demos in progs/es1/ and progs/es2/. You can use them to test your build. For example,

-  $ export EGL_DRIVER=/usr/local/lib/dri/egl_x11_i915.so # specify the EGL driver
   $ cd progs/es1/xegl
   $ make
   $ ./torus
diff --git a/docs/openvg.html b/docs/openvg.html
index 442ee522f1..cd39b133c4 100644
--- a/docs/openvg.html
+++ b/docs/openvg.html
@@ -1,6 +1,6 @@
 
 
-Mesa Release Notes
+OpenVG State Tracker
 
 
 
@@ -20,12 +20,13 @@ http://www.khronos.org/openvg/ .
 

The OpenVG state tracker depends on the Gallium architecture and a working EGL implementation. +Please refer to Mesa EGL for more information about EGL.

Building the library

    -
  1. Build Mesa3D with Gallium3D. Any build that builds Gallium3D libraries and EGL will suffice
  2. +
  3. Build Mesa3D with Gallium3D. Any build that builds Gallium3D libraries, EGL, and Gallium EGL drivers will suffice
  4. cd src/gallium/state_trackers/vega; make
  5. The last step will build libOpenVG library. You can add the libdir to LD_LIBRARY_PATH or install libOpenVG
@@ -33,12 +34,9 @@ The OpenVG state tracker depends on the Gallium architecture and a working EGL i

Sample build

A sample build looks as follows:
-  make linux-x86-64-debug
-  cd src/gallium/state_trackers/vega
-  make
-  cd ../../../..
-  export LD_LIBRARY_PATH=$PWD/lib64
-  export EGL_DRIVER="egl_softpipe"
+  $ ./configure --with-state-trackers=egl_g3d,vega --enable-gallium-intel
+  $ make
+  $ make install
 

OpenVG Demos

@@ -59,10 +57,5 @@ To run a demo:
-

Notes

-
    -
  • EGL_DRIVER environmental variable: forces usage of a specific EGL driver. Unless you force egl_softpipe the implementation will look for a DRI hardware accelerate driver and unless you have a Gallium driver that supports it, you'll see crashes
  • -
- -- cgit v1.2.3 From bdd250080593c6d0d5addcaff0b2a5c880d7a3b2 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 21 Jan 2010 17:13:42 +0800 Subject: Do not include glapi/dispatch.h outside Mesa core. Include the glapi*.h directly instead. glapi/dispatch.h became a Mesa core header since 22884db174b9fb0736cec1c6a192f8b9a97500c1. --- src/gallium/winsys/xlib/xlib.c | 3 ++- src/glx/x11/indirect.c | 3 ++- src/glx/x11/single2.c | 3 ++- src/glx/x11/singlepix.c | 3 ++- src/mesa/drivers/x11/glxapi.c | 3 ++- src/mesa/glapi/Makefile | 1 - 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/gallium/winsys/xlib/xlib.c b/src/gallium/winsys/xlib/xlib.c index 541ea7ae35..67617a470d 100644 --- a/src/gallium/winsys/xlib/xlib.c +++ b/src/gallium/winsys/xlib/xlib.c @@ -116,7 +116,8 @@ extern void (*linker_foo(const unsigned char *procName))() #define GL_GLEXT_PROTOTYPES #include "GL/gl.h" #include "glapi/glapi.h" -#include "glapi/dispatch.h" +#include "glapi/glapitable.h" +#include "glapi/glapidispatch.h" #if defined(USE_MGL_NAMESPACE) #define NAME(func) mgl##func diff --git a/src/glx/x11/indirect.c b/src/glx/x11/indirect.c index 262637a947..48bae1478f 100644 --- a/src/glx/x11/indirect.c +++ b/src/glx/x11/indirect.c @@ -30,7 +30,8 @@ #include "indirect.h" #include "glxclient.h" #include "indirect_size.h" -#include "dispatch.h" +#include "glapitable.h" +#include "glapidispatch.h" #include "glapi.h" #include "glthread.h" #include diff --git a/src/glx/x11/single2.c b/src/glx/x11/single2.c index d128ba2053..9ecf589fff 100644 --- a/src/glx/x11/single2.c +++ b/src/glx/x11/single2.c @@ -35,7 +35,8 @@ #include "glxextensions.h" #include "indirect.h" #include "indirect_vertex_array.h" -#include "dispatch.h" +#include "glapitable.h" +#include "glapidispatch.h" #include "glapi.h" #ifdef USE_XCB #include diff --git a/src/glx/x11/singlepix.c b/src/glx/x11/singlepix.c index fa12ac3bbc..f5ebf4dfdb 100644 --- a/src/glx/x11/singlepix.c +++ b/src/glx/x11/singlepix.c @@ -30,7 +30,8 @@ #include "packsingle.h" #include "indirect.h" -#include "dispatch.h" +#include "glapitable.h" +#include "glapidispatch.h" #include "glapi.h" #include "glthread.h" #include "glapioffsets.h" diff --git a/src/mesa/drivers/x11/glxapi.c b/src/mesa/drivers/x11/glxapi.c index 5c7e8eb90c..e11aff1a84 100644 --- a/src/mesa/drivers/x11/glxapi.c +++ b/src/mesa/drivers/x11/glxapi.c @@ -57,7 +57,8 @@ struct display_dispatch { */ #ifdef GLX_INDIRECT_RENDERING -#include "glapi/dispatch.h" +#include "glapi/glapitable.h" +#include "glapi/glapidispatch.h" #define KEYWORD1 PUBLIC diff --git a/src/mesa/glapi/Makefile b/src/mesa/glapi/Makefile index 4db0ff1425..846c041cde 100644 --- a/src/mesa/glapi/Makefile +++ b/src/mesa/glapi/Makefile @@ -43,7 +43,6 @@ SERVER_OUTPUTS = \ $(GLX_DIR)/glapioffsets.h \ $(GLX_DIR)/glapidispatch.h \ $(GLX_DIR)/glprocs.h \ - $(GLX_DIR)/dispatch.h \ $(SERVER_GLAPI_FILES) API_XML = gl_API.xml \ -- cgit v1.2.3 From 4736e1cbbd4e2cf7fa4c67a728d520edc67e920f Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 21 Jan 2010 17:15:46 +0800 Subject: dri: Remove unnecessary glapi headers. They are not used at all. --- src/mesa/drivers/dri/common/utils.c | 1 - src/mesa/drivers/dri/i915/i830_vtbl.c | 2 -- src/mesa/drivers/dri/i915/i915_vtbl.c | 2 -- src/mesa/drivers/dri/i965/brw_fallback.c | 2 -- src/mesa/drivers/dri/intel/intel_pixel_bitmap.c | 1 - src/mesa/drivers/dri/radeon/radeon_ioctl.c | 1 - 6 files changed, 9 deletions(-) diff --git a/src/mesa/drivers/dri/common/utils.c b/src/mesa/drivers/dri/common/utils.c index b272eb74ea..81d026a697 100644 --- a/src/mesa/drivers/dri/common/utils.c +++ b/src/mesa/drivers/dri/common/utils.c @@ -34,7 +34,6 @@ #include "main/mtypes.h" #include "main/cpuinfo.h" #include "main/extensions.h" -#include "glapi/dispatch.h" #include "utils.h" diff --git a/src/mesa/drivers/dri/i915/i830_vtbl.c b/src/mesa/drivers/dri/i915/i830_vtbl.c index 4471ca2bbb..3767712d19 100644 --- a/src/mesa/drivers/dri/i915/i830_vtbl.c +++ b/src/mesa/drivers/dri/i915/i830_vtbl.c @@ -25,8 +25,6 @@ * **************************************************************************/ -#include "glapi/glapi.h" - #include "i830_context.h" #include "i830_reg.h" #include "intel_batchbuffer.h" diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c b/src/mesa/drivers/dri/i915/i915_vtbl.c index 266e6848c3..df82d7e8be 100644 --- a/src/mesa/drivers/dri/i915/i915_vtbl.c +++ b/src/mesa/drivers/dri/i915/i915_vtbl.c @@ -46,8 +46,6 @@ #include "i915_reg.h" #include "i915_context.h" -#include "glapi/glapi.h" - static void i915_render_prevalidate(struct intel_context *intel) { diff --git a/src/mesa/drivers/dri/i965/brw_fallback.c b/src/mesa/drivers/dri/i965/brw_fallback.c index fe5c1ae279..b4e4e8df20 100644 --- a/src/mesa/drivers/dri/i965/brw_fallback.c +++ b/src/mesa/drivers/dri/i965/brw_fallback.c @@ -41,8 +41,6 @@ #include "intel_fbo.h" #include "intel_regions.h" -#include "glapi/glapi.h" - #define FILE_DEBUG_FLAG DEBUG_FALLBACKS static GLboolean do_check_fallback(struct brw_context *brw) diff --git a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c index 85e5ad2cdd..eeebba9443 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c @@ -46,7 +46,6 @@ #include "main/enable.h" #include "main/viewport.h" #include "shader/arbprogram.h" -#include "glapi/dispatch.h" #include "swrast/swrast.h" #include "intel_screen.h" diff --git a/src/mesa/drivers/dri/radeon/radeon_ioctl.c b/src/mesa/drivers/dri/radeon/radeon_ioctl.c index a9d50c5d07..afe3d9f12e 100644 --- a/src/mesa/drivers/dri/radeon/radeon_ioctl.c +++ b/src/mesa/drivers/dri/radeon/radeon_ioctl.c @@ -46,7 +46,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/shaders.h" #include "main/texstate.h" #include "main/varray.h" -#include "glapi/dispatch.h" #include "swrast/swrast.h" #include "main/stencil.h" #include "main/matrix.h" -- cgit v1.2.3 From ed9bd82656eec8ee2e85e828a7b05d93702da6ed Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 20 Jan 2010 08:58:46 -0700 Subject: docs: new Mesa source tree overview page. This has been sitting around for a while. Incomplete, but a good start. --- docs/contents.html | 1 + docs/sourcetree.html | 165 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 docs/sourcetree.html diff --git a/docs/contents.html b/docs/contents.html index d15e6c1e33..674bbae3b0 100644 --- a/docs/contents.html +++ b/docs/contents.html @@ -65,6 +65,7 @@ a:visited {
  • SourceForge homepage
  • Source Code Repository +
  • Source Code Tree
  • DRI Memory Management
  • Shading Language
  • SGI's GLU diff --git a/docs/sourcetree.html b/docs/sourcetree.html new file mode 100644 index 0000000000..bc4ce71bee --- /dev/null +++ b/docs/sourcetree.html @@ -0,0 +1,165 @@ + + +Mesa Source Tree + + + + + +

    Mesa source code tree overview

    + +

    +This is a brief summary of Mesa's directory tree and what's contained in +each directory. +

    + + +
      +
    • docs - Documentation +
    • include - Public OpenGL header files +
    • src +
        +
      • egl - EGL library sources +
          +
        • docs - EGL documentation +
        • drivers - EGL drivers +
        • main - main EGL library implementation. This is where all + the EGL API functions are implemented, like eglCreateContext(). +
        +
      • mesa - Main Mesa sources +
          +
        • glapi - OpenGL API dispatch layer. This is where all the + GL entrypoints like glClear, glBegin, etc. are generated, as well as + the GL dispatch table. All GL function calls jump through the + dispatch table to functions found in main/. +
        • main - The core Mesa code (mainly state management) +
        • drivers - Mesa drivers (not used with Gallium) +
            +
          • common - code which may be shared by all drivers +
          • dri - Direct Rendering Infrastructure drivers +
              +
            • common - code shared by all DRI drivers +
            • i915 - driver for Intel i915/i945 +
            • i965 - driver for Intel i965 +
            • XXX more +
            +
          • x11 - Xlib-based software driver +
          • osmesa - off-screen software driver +
          • glslcompiler - a stand-alone GLSL compiler driver +
          • XXX more +
          +
        • math - vertex array translation and transformation code + (not used with Gallium) +
        • ppc - Assembly code/optimizations for PPC systems + (not used with Gallium) +
        • shader - Vertex/fragment shader and GLSL compiler code +
        • sparc - Assembly code/optimizations for SPARC systems + (not used with Gallium) +
        • state_tracker - State tracker / driver for Gallium. This + is basically a Mesa device driver that speaks to Gallium. This + directory may be moved to src/mesa/drivers/gallium at some point. +
        • swrast - Software rasterization module. For drawing points, + lines, triangles, bitmaps, images, etc. in software. + (not used with Gallium) +
        • swrast_setup - Software primitive setup. Does things like + polygon culling, glPolygonMode, polygon offset, etc. + (not used with Gallium) +
        • tnl - Software vertex Transformation 'n Lighting. + (not used with Gallium) +
        • tnl_dd - TNL code for device drivers. + (not used with Gallium) +
        • vbo - Vertex Buffer Object code. All drawing with + glBegin/glEnd, glDrawArrays, display lists, etc. goes through this + module. The results is a well-defined set of vertex arrays which + are passed to the device driver (or tnl module) for rendering. +
        • vf - vertex format conversion (currently unused) +
        • x86 - Assembly code/optimizations for 32-bit x86 systems + (not used with Gallium) +
        • x86-64 - Assembly code/optimizations for 64-bit x86 systems + (not used with Gallium) +
        +
      • gallium - Gallium3D source code +
          +
        • include - Gallium3D header files which define the Gallium3D + interfaces +
        • drivers - Gallium3D device drivers +
            +
          • cell - Driver for Cell processor. +
          • i915 - Driver for Intel i915/i945. +
          • i965 - Driver for Intel i965. +
          • llvmpipe - Software driver using LLVM for runtime code generation. +
          • nv* - Drivers for NVIDIA GPUs. +
          • r300 - Driver for ATI/AMD R300. +
          • softpipe - Software reference driver. +
          • svga - Driver for VMware's SVGA virtual GPU. +
          • trace - Driver for tracing Gallium calls. +
          • XXX more +
          +
        • auxiliary - Gallium support code +
            +
          • draw - Software vertex processing and primitive assembly + module. This includes vertex program execution, clipping, culling + and optional stages for drawing wide lines, stippled lines, + polygon stippling, two-sided lighting, etc. + Intended for use by drivers for hardware that does not have + vertex shaders. + Geometry shaders will also be implemented in this module. +
          • cso_cache - Constant State Objects Cache. Used to filter out + redundant state changes between state trackers and drivers. +
          • gallivm - LLVM module for Gallium. For LLVM-based + compilation, optimization and code generation for TGSI shaders. + Incomplete. +
          • pipebuffer - utility module for managing buffers +
          • rbug - Gallium remote debug utility +
          • rtasm - run-time assembly/machine code generation. + Currently there's run-time code generation for x86/SSE, PowerPC + and Cell SPU. +
          • tgsi - TG Shader Infrastructure. Code for encoding, + manipulating and interpretting GPU programs. +
          • translate - module for translating vertex data from one format + to another. +
          • util - assorted utilities for arithmetic, hashing, surface + creation, memory management, 2D blitting, simple rendering, etc. +
          +
        • state_trackers - +
            +
          • dri - +
          • egl - +
          • es - +
          • g3dvl - +
          • glx - +
          • python - +
          • vega - +
          • wgl - +
          • xorg - +
          +
        • winsys - +
            +
          • drm - +
          • egl_xlib - +
          • g3dvl - +
          • gdi - +
          • xlib - +
          +
        +
      +
        +
      • glu - The OpenGL Utility library +
          +
        • sgi - GLU from SGI +
        • mesa - Mesa version of GLU (deprecated) +
        +
      • glut - Mark Kilgard's OpenGL OpenGL Utility Toolkit library +
      • glx - The GLX library code for building libGL. This is used for + direct rendering drivers. It will dynamically load one of the + xxx_dri.so drivers. +
      • glw - Widgets for Xt/Motif. +
      • glew - OpenGL Extension Wrangler library (used by demo programs) +
      +
    • progs - OpenGL test and demonstration programs +
    • lib - where the GL libraries are placed +
    + + + + -- cgit v1.2.3 From 074abd889f7f5d2c7805a2c0fe118f463101a63d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 20 Jan 2010 17:40:48 -0700 Subject: softpipe: added region assertions in softpipe_get_tex_transfer() --- src/gallium/drivers/softpipe/sp_texture.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index fae72c81aa..45e80c5447 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -291,6 +291,10 @@ softpipe_get_tex_transfer(struct pipe_screen *screen, assert(texture); assert(level <= texture->last_level); + /* make sure the requested region is in the image bounds */ + assert(x + w <= u_minify(texture->width0, level)); + assert(y + h <= u_minify(texture->height0, level)); + spt = CALLOC_STRUCT(softpipe_transfer); if (spt) { struct pipe_transfer *pt = &spt->base; -- cgit v1.2.3 From 656834a871f4bc0f7a1725e59263fb3412d605ca Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 21 Jan 2010 08:14:22 -0700 Subject: docs: add links to the egl, openvg, opengles pages And move the GLSL link up the use User Topics section. --- docs/contents.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/contents.html b/docs/contents.html index 674bbae3b0..938cd82cc4 100644 --- a/docs/contents.html +++ b/docs/contents.html @@ -52,6 +52,10 @@ a:visited { User Topics
      +
    • Shading Language +
    • EGL +
    • OpenGL ES +
    • OpenVG / Vega
    • Environment Variables
    • Off-Screen Rendering
    • Pbuffer Rendering @@ -67,7 +71,6 @@ a:visited {
    • Source Code Repository
    • Source Code Tree
    • DRI Memory Management -
    • Shading Language
    • SGI's GLU
    • Utilities
    • Help Wanted -- cgit v1.2.3 From aeff9f9725daffe06514f31d7005fd6d3f6b6550 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 21 Jan 2010 08:13:32 -0700 Subject: docs: added target attribute to external URLs --- docs/egl.html | 3 ++- docs/opengles.html | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/egl.html b/docs/egl.html index ccc233fca9..9bbce83d4b 100644 --- a/docs/egl.html +++ b/docs/egl.html @@ -10,7 +10,8 @@

      The current version of EGL in Mesa implements EGL 1.4. More information about EGL can be found at -http://www.khronos.org/egl/.

      + +http://www.khronos.org/egl/.

      The Mesa's implementation of EGL uses a driver architecture. The main library (libEGL) is window system neutral. It provides the EGL diff --git a/docs/opengles.html b/docs/opengles.html index 8665a9c353..a871e85d0b 100644 --- a/docs/opengles.html +++ b/docs/opengles.html @@ -10,7 +10,8 @@

      The current version of the OpenGL ES state trackers implement OpenGL ES 1.1 and OpenGL ES 2.0. More informations about OpenGL ES can be found at -http://www.khronos.org/opengles/.

      + +http://www.khronos.org/opengles/.

      The OpenGL ES state trackers depends on the Gallium architecture and a working EGL implementation. Please refer to Mesa EGL -- cgit v1.2.3 From 24d3a7a251b091be1da5c8c4ef03d1b187ffd39c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 21 Jan 2010 08:16:54 -0700 Subject: docs: remove old pbuffer info --- docs/contents.html | 1 - docs/pbuffers.html | 54 ------------------------------------------------------ 2 files changed, 55 deletions(-) delete mode 100644 docs/pbuffers.html diff --git a/docs/contents.html b/docs/contents.html index 938cd82cc4..f0646ffb40 100644 --- a/docs/contents.html +++ b/docs/contents.html @@ -58,7 +58,6 @@ a:visited {

    • OpenVG / Vega
    • Environment Variables
    • Off-Screen Rendering -
    • Pbuffer Rendering
    • Debugging Tips
    • Performance Tips
    • Mesa Extensions diff --git a/docs/pbuffers.html b/docs/pbuffers.html deleted file mode 100644 index 2599101555..0000000000 --- a/docs/pbuffers.html +++ /dev/null @@ -1,54 +0,0 @@ - - -PBuffer Rendering - - - - - -

      PBuffer Rendering

      - -

      -Basically, FBconfigs and PBuffers allow you to do off-screen rendering -with OpenGL. The OSMesa interface does basically the same thing, but -fbconfigs and pbuffers are supported by more vendors. -PBuffer rendering may also be hardware accelerated. -

      - -

      -PBuffers are getting more use nowadays, though they've actually been -around for a long time on IRIX systems and other workstations. -

      - -

      -The -GL_SGIX_fbconfig -and - -GL_SGIX_pbuffer extensions describe the functionality. -More recently, these extensions have been promoted to ARB extensions (on -Windows at least). -

      - -

      -The Mesa/progs/xdemos/ directory has some useful code for working -with pbuffers: -

      - -
        -
      • pbinfo.c - like glxinfo, it prints a list of available - fbconfigs and whether each supports pbuffers. -
      • pbutil.c - a few utility functions for dealing with - fbconfigs and pbuffers. -
      • pbdemo.c - a demonstration of off-screen rendering with pbuffers. -
      - -

      -Mesa 4.1 and later support GL_SGIX_fbconfig and GL_SGIX_pbuffer (software -rendering only). -

      - - - -- cgit v1.2.3 From 1ca22855119508457b2cbd9a0a3b840e47a61eff Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 21 Jan 2010 09:38:50 -0700 Subject: progs/fp: testcases for GL_ARB_fragment_coord_conventions Based on a patch from Luca Barbieri but moved the comments after the !!ARBfp1.0 header --- progs/fp/position-frc-integer.txt | 7 +++++++ progs/fp/position-frc.txt | 6 ++++++ progs/fp/position-upper-left.txt | 7 +++++++ progs/fp/position.txt | 2 ++ 4 files changed, 22 insertions(+) create mode 100644 progs/fp/position-frc-integer.txt create mode 100644 progs/fp/position-frc.txt create mode 100644 progs/fp/position-upper-left.txt diff --git a/progs/fp/position-frc-integer.txt b/progs/fp/position-frc-integer.txt new file mode 100644 index 0000000000..3a634c9b3b --- /dev/null +++ b/progs/fp/position-frc-integer.txt @@ -0,0 +1,7 @@ +!!ARBfp1.0 +# expected: black triangle +# brown means the wrong pixel center convention is being used +OPTION ARB_fragment_coord_pixel_center_integer; +MOV result.color, {0}.x; +FRC result.color.xy, fragment.position; +END diff --git a/progs/fp/position-frc.txt b/progs/fp/position-frc.txt new file mode 100644 index 0000000000..35ae3efa10 --- /dev/null +++ b/progs/fp/position-frc.txt @@ -0,0 +1,6 @@ +!!ARBfp1.0 +# expected: brown triangle +# black means the wrong pixel center convention is being used +MOV result.color, {0}.x; +FRC result.color.xy, fragment.position; +END diff --git a/progs/fp/position-upper-left.txt b/progs/fp/position-upper-left.txt new file mode 100644 index 0000000000..ac632dbfb7 --- /dev/null +++ b/progs/fp/position-upper-left.txt @@ -0,0 +1,7 @@ +!!ARBfp1.0 +# expected: the yellow vertex is the bottom one +# if it is the top one, the wrong origin convention is being used +OPTION ARB_fragment_coord_origin_upper_left; +MOV result.color, {0}.x; +MUL result.color.xy, fragment.position, {.005}.x; +END diff --git a/progs/fp/position.txt b/progs/fp/position.txt index 1875897d78..f59d0259c7 100644 --- a/progs/fp/position.txt +++ b/progs/fp/position.txt @@ -1,4 +1,6 @@ !!ARBfp1.0 +# expected: the yellow vertex is the top one +# if it is the bottom one, the wrong origin convention is being used MOV result.color, {0}.x; MUL result.color.xy, fragment.position, {.005}.x; END -- cgit v1.2.3 From e59353f592ef587d34279f0735f06053e289a7b4 Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Wed, 20 Jan 2010 22:38:39 -0800 Subject: mesa: support for GL_ARB_fragment_coord_conventions Signed-off-by: Brian Paul --- src/mesa/main/extensions.c | 1 + src/mesa/main/mtypes.h | 3 +++ src/mesa/shader/arbprogparse.c | 2 ++ src/mesa/shader/program_parse_extra.c | 12 ++++++++++++ src/mesa/shader/program_parser.h | 2 ++ 5 files changed, 20 insertions(+) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 00427aa580..ac7ff26b50 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -50,6 +50,7 @@ static const struct { { OFF, "GL_ARB_depth_clamp", F(ARB_depth_clamp) }, { ON, "GL_ARB_draw_buffers", F(ARB_draw_buffers) }, { OFF, "GL_ARB_draw_elements_base_vertex", F(ARB_draw_elements_base_vertex) }, + { OFF, "GL_ARB_fragment_coord_conventions", F(ARB_fragment_coord_conventions) }, { OFF, "GL_ARB_fragment_program", F(ARB_fragment_program) }, { OFF, "GL_ARB_fragment_program_shadow", F(ARB_fragment_program_shadow) }, { OFF, "GL_ARB_fragment_shader", F(ARB_fragment_shader) }, diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 7eff5cadd0..919ddd7a29 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1762,6 +1762,8 @@ struct gl_fragment_program struct gl_program Base; /**< base class */ GLenum FogOption; GLboolean UsesKill; /**< shader uses KIL instruction */ + GLboolean OriginUpperLeft; + GLboolean PixelCenterInteger; }; @@ -2395,6 +2397,7 @@ struct gl_extensions GLboolean ARB_depth_clamp; GLboolean ARB_draw_buffers; GLboolean ARB_draw_elements_base_vertex; + GLboolean ARB_fragment_coord_conventions; GLboolean ARB_fragment_program; GLboolean ARB_fragment_program_shadow; GLboolean ARB_fragment_shader; diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index a09be71020..3e22a8a305 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -123,6 +123,8 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target, case OPTION_FOG_LINEAR: program->FogOption = GL_LINEAR; break; default: program->FogOption = GL_NONE; break; } + program->OriginUpperLeft = state.option.OriginUpperLeft; + program->PixelCenterInteger = state.option.PixelCenterInteger; program->UsesKill = state.fragment.UsesKill; diff --git a/src/mesa/shader/program_parse_extra.c b/src/mesa/shader/program_parse_extra.c index 0656c5eaa8..ae98b782b7 100644 --- a/src/mesa/shader/program_parse_extra.c +++ b/src/mesa/shader/program_parse_extra.c @@ -216,6 +216,18 @@ _mesa_ARBfp_parse_option(struct asm_parser_state *state, const char *option) state->option.Shadow = 1; return 1; } + } else if (strncmp(option, "fragment_coord_", 15) == 0) { + option += 15; + if (state->ctx->Extensions.ARB_fragment_coord_conventions) { + if (strcmp(option, "origin_upper_left") == 0) { + state->option.OriginUpperLeft = 1; + return 1; + } + else if (strcmp(option, "pixel_center_integer") == 0) { + state->option.PixelCenterInteger = 1; + return 1; + } + } } } else if (strncmp(option, "NV_fragment_program", 19) == 0) { option += 19; diff --git a/src/mesa/shader/program_parser.h b/src/mesa/shader/program_parser.h index 69396ca2c0..730466c30f 100644 --- a/src/mesa/shader/program_parser.h +++ b/src/mesa/shader/program_parser.h @@ -209,6 +209,8 @@ struct asm_parser_state { unsigned TexRect:1; unsigned TexArray:1; unsigned NV_fragment:1; + unsigned OriginUpperLeft:1; + unsigned PixelCenterInteger:1; } option; struct { -- cgit v1.2.3 From dc2914ab2645d2947898f96f9535f557c7c188cf Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 21 Jan 2010 09:44:42 -0700 Subject: mesa: minor whitespace fix --- src/mesa/main/extensions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index ac7ff26b50..b6c7a02a7c 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -50,7 +50,7 @@ static const struct { { OFF, "GL_ARB_depth_clamp", F(ARB_depth_clamp) }, { ON, "GL_ARB_draw_buffers", F(ARB_draw_buffers) }, { OFF, "GL_ARB_draw_elements_base_vertex", F(ARB_draw_elements_base_vertex) }, - { OFF, "GL_ARB_fragment_coord_conventions", F(ARB_fragment_coord_conventions) }, + { OFF, "GL_ARB_fragment_coord_conventions", F(ARB_fragment_coord_conventions) }, { OFF, "GL_ARB_fragment_program", F(ARB_fragment_program) }, { OFF, "GL_ARB_fragment_program_shadow", F(ARB_fragment_program_shadow) }, { OFF, "GL_ARB_fragment_shader", F(ARB_fragment_shader) }, -- cgit v1.2.3 From 6d4805b36390e5625735dd348e8bd011bf489836 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 21 Jan 2010 11:35:33 -0700 Subject: gallium: updated comments, whitespace fixes --- src/gallium/include/pipe/p_context.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index 0b8f6da2f4..50678c4b21 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -271,30 +271,30 @@ struct pipe_context { /** * Check whether a texture is referenced by an unflushed hw command. - * The state-tracker uses this function to optimize away unnecessary - * flushes. It is safe (but wasteful) to always return. + * The state-tracker uses this function to avoid unnecessary flushes. + * It is safe (but wasteful) to always return * PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE. - * \param pipe The pipe context whose unflushed hw commands will be - * checked. - * \param level mipmap level. + * \param pipe context whose unflushed hw commands will be checked. * \param texture texture to check. * \param face cubemap face. Use 0 for non-cubemap texture. + * \param level mipmap level. + * \return mask of PIPE_REFERENCED_FOR_READ/WRITE or PIPE_UNREFERENCED */ - unsigned int (*is_texture_referenced) (struct pipe_context *pipe, - struct pipe_texture *texture, - unsigned face, unsigned level); + unsigned int (*is_texture_referenced)(struct pipe_context *pipe, + struct pipe_texture *texture, + unsigned face, unsigned level); /** * Check whether a buffer is referenced by an unflushed hw command. - * The state-tracker uses this function to optimize away unnecessary - * flushes. It is safe (but wasteful) to always return + * The state-tracker uses this function to avoid unnecessary flushes. + * It is safe (but wasteful) to always return * PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE. - * \param pipe The pipe context whose unflushed hw commands will be - * checked. - * \param buf Buffer to check. + * \param pipe context whose unflushed hw commands will be checked. + * \param buf buffer to check. + * \return mask of PIPE_REFERENCED_FOR_READ/WRITE or PIPE_UNREFERENCED */ - unsigned int (*is_buffer_referenced) (struct pipe_context *pipe, - struct pipe_buffer *buf); + unsigned int (*is_buffer_referenced)(struct pipe_context *pipe, + struct pipe_buffer *buf); }; -- cgit v1.2.3 From 41667a9a3e2c809d7d7e65f81782df8c89790bc6 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 21 Jan 2010 19:45:43 +0100 Subject: gallium: new PIPE_CAP bits for the independent blend functionality --- src/gallium/include/pipe/p_defines.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 35f3830ebc..185ab6a711 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -405,6 +405,8 @@ enum pipe_transfer_usage { #define PIPE_CAP_MAX_PREDICATE_REGISTERS 30 #define PIPE_CAP_MAX_COMBINED_SAMPLERS 31 /*< Maximum texture image units accessible from vertex and fragment shaders combined */ +#define PIPE_CAP_INDEP_BLEND_ENABLE 32 /*< blend enables and write masks per rendertarget */ +#define PIPE_CAP_INDEP_BLEND_FUNC 33 /*< different blend funcs per rendertarget */ /** -- cgit v1.2.3 From 6c1549a77dd76dc737e40c417fd3b4f9802a33d8 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 21 Jan 2010 11:52:36 -0700 Subject: gallium/docs: document conditional rendering --- src/gallium/docs/source/context.rst | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst index d394f5b4f1..b7b625d25e 100644 --- a/src/gallium/docs/source/context.rst +++ b/src/gallium/docs/source/context.rst @@ -149,6 +149,42 @@ Queries can be created with ``create_query`` and deleted with use ``end_query`` to stop the query. Finally, ``get_query_result`` is used to retrieve the results. +A common type of query is the occlusion query which counts the number of +fragments/pixels which are written to the framebuffer (and not culled by +Z/stencil/alpha testing or shader KILL instructions). + + +Conditional Rendering +^^^^^^^^^^^^^^^^^^^^^ + +A drawing command can be skipped depending on the outcome of a query +(typically an occlusion query). The ``render_condition`` function specifies +the query which should be checked prior to rendering anything. + +If ``render_condition`` is called with ``query`` = NULL, conditional +rendering is disabled and drawing takes place normally. + +If ``render_condition`` is called with a non-null ``query`` subsequent +drawing commands will be predicated on the outcome of the query. If +the query result is zero subsequent drawing commands will be skipped. + +If ``mode`` is PIPE_RENDER_COND_WAIT the driver will wait for the +query to complete before deciding whether to render. + +If ``mode`` is PIPE_RENDER_COND_NO_WAIT and the query has not yet +completed, the drawing command will be executed normally. If the query +has completed, drawing will be predicated on the outcome of the query. + +If ``mode`` is PIPE_RENDER_COND_BY_REGION_WAIT or +PIPE_RENDER_COND_BY_REGION_NO_WAIT rendering will be predicated as above +for the non-REGION modes but in the case that an occulusion query returns +a non-zero result, regions which were occluded may be ommitted by subsequent +drawing commands. This can result in better performance with some GPUs. +Normally, if the occlusion query returned a non-zero result subsequent +drawing happens normally so fragments may be generated, shaded and +processed even where they're known to be obscured. + + Flushing ^^^^^^^^ -- cgit v1.2.3 From d65d5d299357ea77051c86ac81515b37c6ccf97f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 21 Jan 2010 11:52:54 -0700 Subject: gallium: fix conditional rendering comment --- src/gallium/include/pipe/p_context.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index 50678c4b21..f3ee095448 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -103,7 +103,7 @@ struct pipe_context { /** * Predicate subsequent rendering on occlusion query result * \param query the query predicate, or NULL if no predicate - * \param mode one of PIPE_COND_RENDER_x + * \param mode one of PIPE_RENDER_COND_x */ void (*render_condition)( struct pipe_context *pipe, struct pipe_query *query, -- cgit v1.2.3 From eba1e2a44718bea398e49d496a78ee002c9922b8 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 21 Jan 2010 19:56:29 +0100 Subject: gallium: adapt util code to blend changes --- src/gallium/auxiliary/util/u_blit.c | 2 +- src/gallium/auxiliary/util/u_blitter.c | 2 +- src/gallium/auxiliary/util/u_gen_mipmap.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index 9725890bd4..ebc9d3415f 100644 --- a/src/gallium/auxiliary/util/u_blit.c +++ b/src/gallium/auxiliary/util/u_blit.c @@ -92,7 +92,7 @@ util_create_blit(struct pipe_context *pipe, struct cso_context *cso) /* disabled blending/masking */ memset(&ctx->blend, 0, sizeof(ctx->blend)); - ctx->blend.colormask = PIPE_MASK_RGBA; + ctx->blend.rt[0].colormask = PIPE_MASK_RGBA; /* no-op depth/stencil/alpha */ memset(&ctx->depthstencil, 0, sizeof(ctx->depthstencil)); diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 249a0375fc..935e11c5d8 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -125,7 +125,7 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) memset(&blend, 0, sizeof(blend)); ctx->blend_keep_color = pipe->create_blend_state(pipe, &blend); - blend.colormask = PIPE_MASK_RGBA; + blend.rt[0].colormask = PIPE_MASK_RGBA; ctx->blend_write_color = pipe->create_blend_state(pipe, &blend); /* depth stencil alpha state objects */ diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index 76023794dc..67027ec1a5 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -1287,7 +1287,7 @@ util_create_gen_mipmap(struct pipe_context *pipe, /* disabled blending/masking */ memset(&ctx->blend, 0, sizeof(ctx->blend)); - ctx->blend.colormask = PIPE_MASK_RGBA; + ctx->blend.rt[0].colormask = PIPE_MASK_RGBA; /* no-op depth/stencil/alpha */ memset(&ctx->depthstencil, 0, sizeof(ctx->depthstencil)); -- cgit v1.2.3 From c6c9d3b0914e2c3d8585123055c97d8ac3452fe5 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 21 Jan 2010 20:22:24 +0100 Subject: docs: clean up sampler description --- src/gallium/docs/source/cso/sampler.rst | 10 +++++++--- src/gallium/include/pipe/p_state.h | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gallium/docs/source/cso/sampler.rst b/src/gallium/docs/source/cso/sampler.rst index e3f1757f57..8b67ca57f1 100644 --- a/src/gallium/docs/source/cso/sampler.rst +++ b/src/gallium/docs/source/cso/sampler.rst @@ -12,8 +12,6 @@ with the traditional (S, T, R, Q) notation. Members ------- -XXX undocumented compare_mode, compare_func - wrap_s How to wrap the S coordinate. One of PIPE_TEX_WRAP. wrap_t @@ -27,12 +25,18 @@ min_mip_filter PIPE_TEX_FILTER. mag_img_filter The filter to use when magnifying texels. One of PIPE_TEX_FILTER. +compare_mode + If set to PIPE_TEX_COMPARE_R_TO_TEXTURE, texture output is computed + according to compare_func, using r coord and the texture value as operands. + If set to PIPE_TEX_COMPARE_NONE, no comparison calculation is performed. +compare_func + How the comparison is computed. One of PIPE_FUNC. normalized_coords Whether the texture coordinates are normalized. If normalized, they will always be in [0, 1]. If not, they will be in the range of each dimension of the loaded texture. prefilter - XXX From the Doxy, "weird sampling state exposed by some APIs." Refine. + Cylindrical texcoord wrap enable per coord. Not exposed by most APIs. lod_bias The bias to apply to the level of detail. min_lod diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index 3c217645ab..b9ac2db591 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -274,7 +274,7 @@ struct pipe_sampler_state unsigned compare_mode:1; /**< PIPE_TEX_COMPARE_x */ unsigned compare_func:3; /**< PIPE_FUNC_x */ unsigned normalized_coords:1; /**< Are coords normalized to [0,1]? */ - unsigned prefilter:4; /**< Wierd sampling state exposed by some api's */ + unsigned prefilter:4; /**< Cylindrical texcoord wrap, per coord, exposed by some api's */ float lod_bias; /**< LOD/lambda bias */ float min_lod, max_lod; /**< LOD clamp range, after bias */ float border_color[4]; -- cgit v1.2.3 From 629bb3fa32f6ca1f8cf43222f4b4c399c91b3b6a Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 21 Jan 2010 20:48:13 +0100 Subject: docs: enhance blend documentation --- src/gallium/docs/source/cso/blend.rst | 39 ++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/src/gallium/docs/source/cso/blend.rst b/src/gallium/docs/source/cso/blend.rst index fd9e4a1e2d..3fc573054e 100644 --- a/src/gallium/docs/source/cso/blend.rst +++ b/src/gallium/docs/source/cso/blend.rst @@ -6,9 +6,42 @@ Blend This state controls blending of the final fragments into the target rendering buffers. -XXX it is unresolved what behavior should result if blend_enable is off. - Members ------- -XXX undocumented members +independent_blend_enable + If enabled, blend state is different for each render target, and + for each render target set in the respective member of the rt array. + If disabled, blend state is the same for all render targets, and only + the first member of the rt array contains valid data. +logicop_enable + Enables logic ops. Cannot be enabled at the same time as blending, and + is always the same for all render targets. +logicop_func + The logic operation to use if logic ops are enabled. One of PIPE_LOGICOP. +dither + Whether dithering is enabled. +rt + Contains the per rendertarget blend state. + +per rendertarget members +------------------------ + +blend_enable + If blending is enabled, perform a blend calculation according to blend + functions and source/destination factors. Otherwise, the incoming fragment + color gets passed unmodified (but colormask still applies). +rgb_func + The blend function to use for rgb channels. One of PIPE_BLEND. +rgb_src_factor + The blend source factor to use for rgb channels. One of PIPE_BLENDFACTOR. +rgb_dst_factor + The blend destination factor to use for rgb channels. One of PIPE_BLENDFACTOR. +alpha_func + The blend function to use for the alpha channel. One of PIPE_BLEND. +alpha_src_factor + The blend source factor to use for the alpha channel. One of PIPE_BLENDFACTOR. +alpha_dst_factor + The blend destination factor to use for alpha channel. One of PIPE_BLENDFACTOR. +colormask + Bitmask of which channels to write. Combination of PIPE_MASK bits. -- cgit v1.2.3 From c50fe2c55cfe9c858b7b7859da79edb0693ee8bd Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 21 Jan 2010 12:12:11 -0800 Subject: svga: Remove unnecessary headers. --- src/gallium/drivers/svga/svga_draw_arrays.c | 1 - src/gallium/drivers/svga/svga_draw_elements.c | 1 - src/gallium/drivers/svga/svga_pipe_blend.c | 1 - src/gallium/drivers/svga/svga_pipe_constants.c | 3 --- src/gallium/drivers/svga/svga_pipe_depthstencil.c | 1 - src/gallium/drivers/svga/svga_pipe_draw.c | 1 - src/gallium/drivers/svga/svga_pipe_flush.c | 5 ----- src/gallium/drivers/svga/svga_pipe_fs.c | 2 -- src/gallium/drivers/svga/svga_pipe_misc.c | 6 ------ src/gallium/drivers/svga/svga_pipe_query.c | 1 - src/gallium/drivers/svga/svga_pipe_rasterizer.c | 1 - src/gallium/drivers/svga/svga_pipe_sampler.c | 3 --- src/gallium/drivers/svga/svga_pipe_vertex.c | 4 ---- src/gallium/drivers/svga/svga_pipe_vs.c | 1 - src/gallium/drivers/svga/svga_screen.c | 2 -- src/gallium/drivers/svga/svga_state_framebuffer.c | 2 -- src/gallium/drivers/svga/svga_state_rss.c | 3 --- src/gallium/drivers/svga/svga_state_tss.c | 2 -- src/gallium/drivers/svga/svga_swtnl_backend.c | 1 - src/gallium/drivers/svga/svga_swtnl_draw.c | 1 - src/gallium/drivers/svga/svga_swtnl_state.c | 1 - src/gallium/drivers/svga/svga_tgsi_decl_sm20.c | 3 --- src/gallium/drivers/svga/svga_tgsi_decl_sm30.c | 1 - 23 files changed, 47 deletions(-) diff --git a/src/gallium/drivers/svga/svga_draw_arrays.c b/src/gallium/drivers/svga/svga_draw_arrays.c index 75492dffca..6b6ebc9b58 100644 --- a/src/gallium/drivers/svga/svga_draw_arrays.c +++ b/src/gallium/drivers/svga/svga_draw_arrays.c @@ -26,7 +26,6 @@ #include "svga_cmd.h" #include "pipe/p_inlines.h" -#include "util/u_prim.h" #include "indices/u_indices.h" #include "svga_hw_reg.h" diff --git a/src/gallium/drivers/svga/svga_draw_elements.c b/src/gallium/drivers/svga/svga_draw_elements.c index 167d817831..022b444eb9 100644 --- a/src/gallium/drivers/svga/svga_draw_elements.c +++ b/src/gallium/drivers/svga/svga_draw_elements.c @@ -24,7 +24,6 @@ **********************************************************/ #include "pipe/p_inlines.h" -#include "util/u_prim.h" #include "util/u_upload_mgr.h" #include "indices/u_indices.h" diff --git a/src/gallium/drivers/svga/svga_pipe_blend.c b/src/gallium/drivers/svga/svga_pipe_blend.c index 855d228755..3ad3f97816 100644 --- a/src/gallium/drivers/svga/svga_pipe_blend.c +++ b/src/gallium/drivers/svga/svga_pipe_blend.c @@ -29,7 +29,6 @@ #include "util/u_memory.h" #include "svga_context.h" -#include "svga_state.h" #include "svga_hw_reg.h" diff --git a/src/gallium/drivers/svga/svga_pipe_constants.c b/src/gallium/drivers/svga/svga_pipe_constants.c index 10e7a12189..a6dc344bdd 100644 --- a/src/gallium/drivers/svga/svga_pipe_constants.c +++ b/src/gallium/drivers/svga/svga_pipe_constants.c @@ -30,9 +30,6 @@ #include "tgsi/tgsi_parse.h" #include "svga_context.h" -#include "svga_state.h" -#include "svga_hw_reg.h" -#include "svga_cmd.h" /*********************************************************************** * Constant buffers diff --git a/src/gallium/drivers/svga/svga_pipe_depthstencil.c b/src/gallium/drivers/svga/svga_pipe_depthstencil.c index df636c08a0..34e60cb341 100644 --- a/src/gallium/drivers/svga/svga_pipe_depthstencil.c +++ b/src/gallium/drivers/svga/svga_pipe_depthstencil.c @@ -29,7 +29,6 @@ #include "util/u_memory.h" #include "svga_context.h" -#include "svga_state.h" #include "svga_hw_reg.h" diff --git a/src/gallium/drivers/svga/svga_pipe_draw.c b/src/gallium/drivers/svga/svga_pipe_draw.c index 71a552862e..719b3419f8 100644 --- a/src/gallium/drivers/svga/svga_pipe_draw.c +++ b/src/gallium/drivers/svga/svga_pipe_draw.c @@ -33,7 +33,6 @@ #include "svga_hw_reg.h" #include "svga_context.h" #include "svga_screen.h" -#include "svga_winsys.h" #include "svga_draw.h" #include "svga_state.h" #include "svga_swtnl.h" diff --git a/src/gallium/drivers/svga/svga_pipe_flush.c b/src/gallium/drivers/svga/svga_pipe_flush.c index 0becb0765a..3eb10336c4 100644 --- a/src/gallium/drivers/svga/svga_pipe_flush.c +++ b/src/gallium/drivers/svga/svga_pipe_flush.c @@ -28,13 +28,8 @@ #include "svga_screen_texture.h" #include "svga_context.h" #include "svga_winsys.h" -#include "svga_draw.h" #include "svga_debug.h" -#include "svga_hw_reg.h" - - - static void svga_flush( struct pipe_context *pipe, unsigned flags, diff --git a/src/gallium/drivers/svga/svga_pipe_fs.c b/src/gallium/drivers/svga/svga_pipe_fs.c index 5f1213e46a..32f07fb261 100644 --- a/src/gallium/drivers/svga/svga_pipe_fs.c +++ b/src/gallium/drivers/svga/svga_pipe_fs.c @@ -32,11 +32,9 @@ #include "svga_screen.h" #include "svga_context.h" -#include "svga_state.h" #include "svga_tgsi.h" #include "svga_hw_reg.h" #include "svga_cmd.h" -#include "svga_draw.h" #include "svga_debug.h" diff --git a/src/gallium/drivers/svga/svga_pipe_misc.c b/src/gallium/drivers/svga/svga_pipe_misc.c index 58cb1e6e23..8cf1f2e083 100644 --- a/src/gallium/drivers/svga/svga_pipe_misc.c +++ b/src/gallium/drivers/svga/svga_pipe_misc.c @@ -27,12 +27,6 @@ #include "svga_context.h" #include "svga_screen_texture.h" -#include "svga_state.h" -#include "svga_winsys.h" - -#include "svga_hw_reg.h" - - static void svga_set_scissor_state( struct pipe_context *pipe, diff --git a/src/gallium/drivers/svga/svga_pipe_query.c b/src/gallium/drivers/svga/svga_pipe_query.c index 01336b0a2c..08283e3731 100644 --- a/src/gallium/drivers/svga/svga_pipe_query.c +++ b/src/gallium/drivers/svga/svga_pipe_query.c @@ -32,7 +32,6 @@ #include "svga_screen.h" #include "svga_screen_buffer.h" #include "svga_winsys.h" -#include "svga_draw.h" #include "svga_debug.h" diff --git a/src/gallium/drivers/svga/svga_pipe_rasterizer.c b/src/gallium/drivers/svga/svga_pipe_rasterizer.c index b03f8eb9cf..9ea11aad9a 100644 --- a/src/gallium/drivers/svga/svga_pipe_rasterizer.c +++ b/src/gallium/drivers/svga/svga_pipe_rasterizer.c @@ -30,7 +30,6 @@ #include "util/u_memory.h" #include "svga_context.h" -#include "svga_state.h" #include "svga_hw_reg.h" diff --git a/src/gallium/drivers/svga/svga_pipe_sampler.c b/src/gallium/drivers/svga/svga_pipe_sampler.c index 3eeca6b784..9cc69c8266 100644 --- a/src/gallium/drivers/svga/svga_pipe_sampler.c +++ b/src/gallium/drivers/svga/svga_pipe_sampler.c @@ -32,9 +32,6 @@ #include "svga_context.h" #include "svga_screen_texture.h" -#include "svga_state.h" - -#include "svga_hw_reg.h" #include "svga_debug.h" diff --git a/src/gallium/drivers/svga/svga_pipe_vertex.c b/src/gallium/drivers/svga/svga_pipe_vertex.c index 28e2787e0d..87ac9231d5 100644 --- a/src/gallium/drivers/svga/svga_pipe_vertex.c +++ b/src/gallium/drivers/svga/svga_pipe_vertex.c @@ -32,10 +32,6 @@ #include "svga_screen.h" #include "svga_screen_buffer.h" #include "svga_context.h" -#include "svga_state.h" -#include "svga_winsys.h" - -#include "svga_hw_reg.h" static void svga_set_vertex_buffers(struct pipe_context *pipe, diff --git a/src/gallium/drivers/svga/svga_pipe_vs.c b/src/gallium/drivers/svga/svga_pipe_vs.c index fd9864c51a..7f2b2bce79 100644 --- a/src/gallium/drivers/svga/svga_pipe_vs.c +++ b/src/gallium/drivers/svga/svga_pipe_vs.c @@ -33,7 +33,6 @@ #include "svga_screen.h" #include "svga_context.h" -#include "svga_state.h" #include "svga_tgsi.h" #include "svga_hw_reg.h" #include "svga_cmd.h" diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index fc1b3c980e..68c09e80af 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -33,10 +33,8 @@ #include "svga_screen.h" #include "svga_screen_texture.h" #include "svga_screen_buffer.h" -#include "svga_cmd.h" #include "svga_debug.h" -#include "svga_hw_reg.h" #include "svga3d_shaderdefs.h" diff --git a/src/gallium/drivers/svga/svga_state_framebuffer.c b/src/gallium/drivers/svga/svga_state_framebuffer.c index cfdcae4ee4..eda1aefd67 100644 --- a/src/gallium/drivers/svga/svga_state_framebuffer.c +++ b/src/gallium/drivers/svga/svga_state_framebuffer.c @@ -32,8 +32,6 @@ #include "svga_cmd.h" #include "svga_debug.h" -#include "svga_hw_reg.h" - /*********************************************************************** * Hardware state update diff --git a/src/gallium/drivers/svga/svga_state_rss.c b/src/gallium/drivers/svga/svga_state_rss.c index 8b6803a285..2f9adaeb56 100644 --- a/src/gallium/drivers/svga/svga_state_rss.c +++ b/src/gallium/drivers/svga/svga_state_rss.c @@ -31,9 +31,6 @@ #include "svga_state.h" #include "svga_cmd.h" -#include "svga_hw_reg.h" - - struct rs_queue { unsigned rs_count; diff --git a/src/gallium/drivers/svga/svga_state_tss.c b/src/gallium/drivers/svga/svga_state_tss.c index b313794520..b3c9687b1a 100644 --- a/src/gallium/drivers/svga/svga_state_tss.c +++ b/src/gallium/drivers/svga/svga_state_tss.c @@ -33,8 +33,6 @@ #include "svga_state.h" #include "svga_cmd.h" -#include "svga_hw_reg.h" - void svga_cleanup_tss_binding(struct svga_context *svga) { diff --git a/src/gallium/drivers/svga/svga_swtnl_backend.c b/src/gallium/drivers/svga/svga_swtnl_backend.c index 3d82e4f880..cfbdcf2554 100644 --- a/src/gallium/drivers/svga/svga_swtnl_backend.c +++ b/src/gallium/drivers/svga/svga_swtnl_backend.c @@ -31,7 +31,6 @@ #include "pipe/p_inlines.h" #include "util/u_math.h" #include "util/u_memory.h" -#include "util/u_simple_shaders.h" #include "svga_context.h" #include "svga_state.h" diff --git a/src/gallium/drivers/svga/svga_swtnl_draw.c b/src/gallium/drivers/svga/svga_swtnl_draw.c index 8b14c913f7..6729cc7381 100644 --- a/src/gallium/drivers/svga/svga_swtnl_draw.c +++ b/src/gallium/drivers/svga/svga_swtnl_draw.c @@ -27,7 +27,6 @@ #include "draw/draw_vbuf.h" #include "pipe/p_inlines.h" #include "pipe/p_state.h" -#include "util/u_memory.h" #include "svga_context.h" #include "svga_swtnl.h" diff --git a/src/gallium/drivers/svga/svga_swtnl_state.c b/src/gallium/drivers/svga/svga_swtnl_state.c index 1616312113..d57ed82866 100644 --- a/src/gallium/drivers/svga/svga_swtnl_state.c +++ b/src/gallium/drivers/svga/svga_swtnl_state.c @@ -27,7 +27,6 @@ #include "draw/draw_vbuf.h" #include "pipe/p_inlines.h" #include "pipe/p_state.h" -#include "util/u_memory.h" #include "svga_context.h" #include "svga_swtnl.h" diff --git a/src/gallium/drivers/svga/svga_tgsi_decl_sm20.c b/src/gallium/drivers/svga/svga_tgsi_decl_sm20.c index 54457082a0..0c3430127a 100644 --- a/src/gallium/drivers/svga/svga_tgsi_decl_sm20.c +++ b/src/gallium/drivers/svga/svga_tgsi_decl_sm20.c @@ -29,9 +29,6 @@ #include "util/u_memory.h" #include "svga_tgsi_emit.h" -#include "svga_context.h" - - static boolean ps20_input( struct svga_shader_emitter *emit, diff --git a/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c b/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c index 08e7dfb117..2291cf116d 100644 --- a/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c +++ b/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c @@ -29,7 +29,6 @@ #include "util/u_memory.h" #include "svga_tgsi_emit.h" -#include "svga_context.h" static boolean translate_vs_ps_semantic( struct tgsi_declaration_semantic semantic, unsigned *usage, -- cgit v1.2.3 From 4222bf3d3c7c85112f2e21bd3ea29b1f496ed8bb Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 21 Jan 2010 14:31:15 -0800 Subject: llvmpipe: Remove unnecessary headers. --- src/gallium/drivers/llvmpipe/lp_bld_alpha.c | 1 - src/gallium/drivers/llvmpipe/lp_bld_arit.c | 1 - src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c | 1 - src/gallium/drivers/llvmpipe/lp_bld_conv.c | 2 -- src/gallium/drivers/llvmpipe/lp_bld_format_aos.c | 1 - src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c | 2 -- src/gallium/drivers/llvmpipe/lp_draw_arrays.c | 2 -- src/gallium/drivers/llvmpipe/lp_flush.c | 2 -- src/gallium/drivers/llvmpipe/lp_jit.c | 1 - src/gallium/drivers/llvmpipe/lp_setup.c | 1 - src/gallium/drivers/llvmpipe/lp_state_fs.c | 2 -- src/gallium/drivers/llvmpipe/lp_state_surface.c | 1 - src/gallium/drivers/llvmpipe/lp_state_vertex.c | 1 - src/gallium/drivers/llvmpipe/lp_test_blend.c | 1 - src/gallium/drivers/llvmpipe/lp_tex_cache.c | 1 - src/gallium/drivers/llvmpipe/lp_tex_sample_c.c | 1 - src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c | 1 - src/gallium/drivers/llvmpipe/lp_texture.c | 2 -- src/gallium/drivers/llvmpipe/lp_tile_cache.c | 2 -- 19 files changed, 26 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_bld_alpha.c b/src/gallium/drivers/llvmpipe/lp_bld_alpha.c index 2b4bc5c819..7245730350 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_alpha.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_alpha.c @@ -35,7 +35,6 @@ #include "lp_bld_type.h" #include "lp_bld_const.h" -#include "lp_bld_arit.h" #include "lp_bld_logic.h" #include "lp_bld_flow.h" #include "lp_bld_debug.h" diff --git a/src/gallium/drivers/llvmpipe/lp_bld_arit.c b/src/gallium/drivers/llvmpipe/lp_bld_arit.c index 9c59677a74..f5d9db70fb 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_arit.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_arit.c @@ -56,7 +56,6 @@ #include "lp_bld_intr.h" #include "lp_bld_logic.h" #include "lp_bld_pack.h" -#include "lp_bld_debug.h" #include "lp_bld_arit.h" diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c b/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c index 9511299d55..5d5ca7a5d4 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_blend_soa.c @@ -71,7 +71,6 @@ #include "pipe/p_state.h" #include "lp_bld_type.h" -#include "lp_bld_const.h" #include "lp_bld_arit.h" #include "lp_bld_blend.h" diff --git a/src/gallium/drivers/llvmpipe/lp_bld_conv.c b/src/gallium/drivers/llvmpipe/lp_bld_conv.c index 9935209437..ebf554cd04 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_conv.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_conv.c @@ -63,11 +63,9 @@ #include "util/u_debug.h" #include "util/u_math.h" -#include "util/u_cpu_detect.h" #include "lp_bld_type.h" #include "lp_bld_const.h" -#include "lp_bld_intr.h" #include "lp_bld_arit.h" #include "lp_bld_pack.h" #include "lp_bld_conv.h" diff --git a/src/gallium/drivers/llvmpipe/lp_bld_format_aos.c b/src/gallium/drivers/llvmpipe/lp_bld_format_aos.c index 10e82f120b..dfa080b853 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_format_aos.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_format_aos.c @@ -38,7 +38,6 @@ #include "lp_bld_type.h" #include "lp_bld_const.h" -#include "lp_bld_logic.h" #include "lp_bld_swizzle.h" #include "lp_bld_format.h" diff --git a/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c b/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c index 0dea2cd4c8..e722bca1a6 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c @@ -47,13 +47,11 @@ #include "tgsi/tgsi_exec.h" #include "lp_bld_type.h" #include "lp_bld_const.h" -#include "lp_bld_intr.h" #include "lp_bld_arit.h" #include "lp_bld_logic.h" #include "lp_bld_swizzle.h" #include "lp_bld_flow.h" #include "lp_bld_tgsi.h" -#include "lp_bld_debug.h" #define LP_MAX_TEMPS 256 diff --git a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c index 0aa13a1fc6..a43e438064 100644 --- a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c +++ b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c @@ -33,8 +33,6 @@ #include "pipe/p_defines.h" #include "pipe/p_context.h" -#include "pipe/internal/p_winsys_screen.h" -#include "pipe/p_inlines.h" #include "util/u_prim.h" #include "lp_buffer.h" diff --git a/src/gallium/drivers/llvmpipe/lp_flush.c b/src/gallium/drivers/llvmpipe/lp_flush.c index cd8381fe30..6c81012e84 100644 --- a/src/gallium/drivers/llvmpipe/lp_flush.c +++ b/src/gallium/drivers/llvmpipe/lp_flush.c @@ -37,8 +37,6 @@ #include "lp_surface.h" #include "lp_state.h" #include "lp_tile_cache.h" -#include "lp_tex_cache.h" -#include "lp_winsys.h" void diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index 13535dd638..b5aa7d680f 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -39,7 +39,6 @@ #include "util/u_cpu_detect.h" #include "lp_screen.h" #include "lp_bld_intr.h" -#include "lp_bld_misc.h" #include "lp_jit.h" diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index ffcbc9a379..95bc66e624 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -40,7 +40,6 @@ #include "draw/draw_private.h" #include "draw/draw_vertex.h" #include "pipe/p_shader_tokens.h" -#include "pipe/p_thread.h" #include "util/u_math.h" #include "util/u_memory.h" #include "lp_bld_debug.h" diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 8e2aae40af..2297cbb76f 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -62,7 +62,6 @@ #include "util/u_memory.h" #include "util/u_format.h" #include "util/u_debug_dump.h" -#include "pipe/internal/p_winsys_screen.h" #include "pipe/p_shader_tokens.h" #include "draw/draw_context.h" #include "tgsi/tgsi_dump.h" @@ -85,7 +84,6 @@ #include "lp_context.h" #include "lp_buffer.h" #include "lp_state.h" -#include "lp_quad.h" #include "lp_tex_sample.h" diff --git a/src/gallium/drivers/llvmpipe/lp_state_surface.c b/src/gallium/drivers/llvmpipe/lp_state_surface.c index c06ce8b75c..9f74585674 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_surface.c +++ b/src/gallium/drivers/llvmpipe/lp_state_surface.c @@ -30,7 +30,6 @@ #include "lp_context.h" #include "lp_state.h" -#include "lp_surface.h" #include "lp_tile_cache.h" #include "draw/draw_context.h" diff --git a/src/gallium/drivers/llvmpipe/lp_state_vertex.c b/src/gallium/drivers/llvmpipe/lp_state_vertex.c index 1a17631a4c..57ac25ea0c 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_vertex.c +++ b/src/gallium/drivers/llvmpipe/lp_state_vertex.c @@ -31,7 +31,6 @@ #include "lp_context.h" #include "lp_state.h" -#include "lp_surface.h" #include "draw/draw_context.h" diff --git a/src/gallium/drivers/llvmpipe/lp_test_blend.c b/src/gallium/drivers/llvmpipe/lp_test_blend.c index 29fff91981..411e99d06c 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_blend.c +++ b/src/gallium/drivers/llvmpipe/lp_test_blend.c @@ -38,7 +38,6 @@ #include "lp_bld_type.h" -#include "lp_bld_arit.h" #include "lp_bld_blend.h" #include "lp_bld_debug.h" #include "lp_test.h" diff --git a/src/gallium/drivers/llvmpipe/lp_tex_cache.c b/src/gallium/drivers/llvmpipe/lp_tex_cache.c index 773e848242..b28f8dc5da 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_cache.c +++ b/src/gallium/drivers/llvmpipe/lp_tex_cache.c @@ -37,7 +37,6 @@ #include "util/u_tile.h" #include "util/u_format.h" #include "lp_context.h" -#include "lp_surface.h" #include "lp_texture.h" #include "lp_tex_cache.h" diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample_c.c b/src/gallium/drivers/llvmpipe/lp_tex_sample_c.c index 699394c0de..d1f5d9505d 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample_c.c +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample_c.c @@ -35,7 +35,6 @@ #include "lp_context.h" #include "lp_quad.h" -#include "lp_surface.h" #include "lp_texture.h" #include "lp_tex_sample.h" #include "lp_tex_cache.h" diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c b/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c index d2a6ae21f5..5138ccf7c9 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c @@ -44,7 +44,6 @@ #include "pipe/p_shader_tokens.h" #include "lp_bld_debug.h" #include "lp_bld_type.h" -#include "lp_bld_intr.h" #include "lp_bld_sample.h" #include "lp_bld_tgsi.h" #include "lp_state.h" diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index a00f2495df..948e3de34d 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -33,14 +33,12 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_inlines.h" -#include "pipe/internal/p_winsys_screen.h" #include "util/u_math.h" #include "util/u_memory.h" #include "lp_context.h" #include "lp_state.h" #include "lp_texture.h" -#include "lp_tex_cache.h" #include "lp_screen.h" #include "lp_winsys.h" diff --git a/src/gallium/drivers/llvmpipe/lp_tile_cache.c b/src/gallium/drivers/llvmpipe/lp_tile_cache.c index ec3e002d62..a555149730 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_cache.c +++ b/src/gallium/drivers/llvmpipe/lp_tile_cache.c @@ -38,8 +38,6 @@ #include "util/u_tile.h" #include "util/u_rect.h" #include "lp_context.h" -#include "lp_surface.h" -#include "lp_texture.h" #include "lp_tile_soa.h" #include "lp_tile_cache.h" -- cgit v1.2.3 From 2cf8164065b8704e2f32d77af14cde9e7979435c Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 21 Jan 2010 17:30:16 -0500 Subject: r200: fix CS section size mismatch Partial fix for fdo bug 25544 The tex handling will still need CS drm changes, see bug 25544 for more. --- src/mesa/drivers/dri/r200/r200_state_init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/r200/r200_state_init.c b/src/mesa/drivers/dri/r200/r200_state_init.c index 6c5a0b79ee..80b08dcc99 100644 --- a/src/mesa/drivers/dri/r200/r200_state_init.c +++ b/src/mesa/drivers/dri/r200/r200_state_init.c @@ -698,7 +698,8 @@ static void tex_emit_mm(GLcontext *ctx, struct radeon_state_atom *atom) uint32_t dwords = atom->check(ctx, atom); int i = atom->idx; radeonTexObj *t = r200->state.texture.unit[i].texobj; - if (!r200->state.texture.unit[i].unitneeded) + + if (!r200->state.texture.unit[i].unitneeded && !(dwords <= atom->cmd_size)) dwords -= 4; BEGIN_BATCH_NO_AUTOSTATE(dwords); -- cgit v1.2.3 From efc08bddb7622e4acfa795b58e1264b64b78ab4f Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 21 Jan 2010 15:05:21 -0800 Subject: st/xorg: Remove unnecessary headers. --- src/gallium/state_trackers/xorg/xorg_composite.c | 3 --- src/gallium/state_trackers/xorg/xorg_dri2.c | 1 - src/gallium/state_trackers/xorg/xorg_driver.c | 1 - src/gallium/state_trackers/xorg/xorg_exa.c | 1 - src/gallium/state_trackers/xorg/xorg_exa_tgsi.c | 2 -- src/gallium/state_trackers/xorg/xorg_output.c | 2 -- src/gallium/state_trackers/xorg/xorg_xv.c | 1 - 7 files changed, 11 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c index a5975aad51..89d462d9d6 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.c +++ b/src/gallium/state_trackers/xorg/xorg_composite.c @@ -4,10 +4,7 @@ #include "xorg_exa_tgsi.h" #include "cso_cache/cso_context.h" -#include "util/u_draw_quad.h" -#include "util/u_math.h" -#include "pipe/p_inlines.h" /*XXX also in Xrender.h but the including it here breaks compilition */ #define XFixedToDouble(f) (((double) (f)) / 65536.) diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c index 8267da309f..468563e34c 100644 --- a/src/gallium/state_trackers/xorg/xorg_dri2.c +++ b/src/gallium/state_trackers/xorg/xorg_dri2.c @@ -40,7 +40,6 @@ #include "pipe/p_state.h" #include "pipe/p_inlines.h" -#include "util/u_rect.h" /* Make all the #if cases in the code esier to read */ #ifndef DRI2INFOREC_VERSION diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index 2714fba999..41bfcd0f5e 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -45,7 +45,6 @@ #include "miscstruct.h" #include "dixstruct.h" #include "xf86xv.h" -#include #ifndef XSERVER_LIBPCIACCESS #error "libpciaccess needed" #endif diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index 4e7882551d..6d89fcaa9f 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -41,7 +41,6 @@ #include "pipe/p_format.h" #include "pipe/p_context.h" #include "pipe/p_state.h" -#include "pipe/p_inlines.h" #include "util/u_rect.h" #include "util/u_math.h" diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c index bed17caab7..3e5e6bd6a6 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c +++ b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c @@ -6,11 +6,9 @@ #include "pipe/p_format.h" #include "pipe/p_context.h" #include "pipe/p_state.h" -#include "pipe/p_inlines.h" #include "pipe/p_shader_tokens.h" #include "util/u_memory.h" -#include "util/u_simple_shaders.h" #include "tgsi/tgsi_ureg.h" diff --git a/src/gallium/state_trackers/xorg/xorg_output.c b/src/gallium/state_trackers/xorg/xorg_output.c index 251f331ea7..13c3fb97e3 100644 --- a/src/gallium/state_trackers/xorg/xorg_output.c +++ b/src/gallium/state_trackers/xorg/xorg_output.c @@ -49,8 +49,6 @@ #include #endif -#include "X11/Xatom.h" - #include "xorg_tracker.h" static char *output_enum_list[] = { diff --git a/src/gallium/state_trackers/xorg/xorg_xv.c b/src/gallium/state_trackers/xorg/xorg_xv.c index a437370525..5f6d74943f 100644 --- a/src/gallium/state_trackers/xorg/xorg_xv.c +++ b/src/gallium/state_trackers/xorg/xorg_xv.c @@ -11,7 +11,6 @@ #include "cso_cache/cso_context.h" #include "pipe/p_screen.h" -#include "pipe/p_inlines.h" /*XXX get these from pipe's texture limits */ #define IMAGE_MAX_WIDTH 2048 -- cgit v1.2.3 From 0ae076bf40782c48b1b26ca63ed2c349532dd81e Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 21 Jan 2010 12:12:33 -0800 Subject: svga: Follow buffer usage semantics properly. It's necessary to download buffers from the host always, except if the buffer is undefined, because: - just PIPE_BUFFER_USAGE_CPU_WRITE doesn't guarantee all data is written -- old contents may still pierce through - PIPE_BUFFER_USAGE_DISCARD refers to a range, not the whole buffer, so unless we track which parts have been modified and not we still need to download the data. --- src/gallium/drivers/svga/svga_screen_buffer.c | 10 ++++++---- src/gallium/drivers/svga/svga_screen_buffer.h | 5 +++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/svga/svga_screen_buffer.c b/src/gallium/drivers/svga/svga_screen_buffer.c index c014f2ee20..cc2d3cd9e9 100644 --- a/src/gallium/drivers/svga/svga_screen_buffer.c +++ b/src/gallium/drivers/svga/svga_screen_buffer.c @@ -355,6 +355,8 @@ svga_buffer_upload_flush(struct svga_context *svga, sbuf->hw.svga = NULL; sbuf->hw.boxes = NULL; + sbuf->host_written = TRUE; + /* Decrement reference count */ pipe_buffer_reference((struct pipe_buffer **)&sbuf, NULL); } @@ -436,17 +438,17 @@ svga_buffer_map_range( struct pipe_screen *screen, } else { if(!sbuf->hw.buf) { - struct svga_winsys_surface *handle = sbuf->handle; - if(svga_buffer_create_hw_storage(ss, sbuf) != PIPE_OK) return NULL; /* Populate the hardware storage if the host surface pre-existed */ - if((usage & PIPE_BUFFER_USAGE_CPU_READ) && handle) { + if(sbuf->host_written) { SVGA3dSurfaceDMAFlags flags; enum pipe_error ret; struct pipe_fence_handle *fence = NULL; + assert(sbuf->handle); + SVGA_DBG(DEBUG_DMA|DEBUG_PERF, "dma from sid %p (buffer), bytes %u - %u\n", sbuf->handle, 0, sbuf->base.size); @@ -478,7 +480,7 @@ svga_buffer_map_range( struct pipe_screen *screen, } } else { - if((usage & PIPE_BUFFER_USAGE_CPU_READ) && !sbuf->needs_flush) { + if(!(usage & PIPE_BUFFER_USAGE_DISCARD) && !sbuf->needs_flush) { /* We already had the hardware storage but we would have to issue * a download if we hadn't, so move the buffer to the begginning * of the LRU list. diff --git a/src/gallium/drivers/svga/svga_screen_buffer.h b/src/gallium/drivers/svga/svga_screen_buffer.h index 5d7af5a7c5..c9bbe37f32 100644 --- a/src/gallium/drivers/svga/svga_screen_buffer.h +++ b/src/gallium/drivers/svga/svga_screen_buffer.h @@ -135,6 +135,11 @@ struct svga_buffer */ struct svga_winsys_surface *handle; + /** + * Whether the host has been ever written. + */ + boolean host_written; + struct { unsigned count; boolean writing; -- cgit v1.2.3 From 13c2475339d502644464041fcaac3890770d3abd Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 21 Jan 2010 09:13:15 -0800 Subject: gallium: Remove temporary hack for the absence of a discard flag. PIPE_BUFFER_USAGE_DISCARD flag now exists. --- src/gallium/include/pipe/p_inlines.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/gallium/include/pipe/p_inlines.h b/src/gallium/include/pipe/p_inlines.h index 5fbd62a03d..6949f56574 100644 --- a/src/gallium/include/pipe/p_inlines.h +++ b/src/gallium/include/pipe/p_inlines.h @@ -63,13 +63,6 @@ pipe_buffer_map(struct pipe_screen *screen, if(screen->buffer_map_range) { unsigned offset = 0; unsigned length = buf->size; - - /* XXX: Actually we should be using/detecting DISCARD - * instead of assuming that WRITE implies discard */ - if((usage & PIPE_BUFFER_USAGE_CPU_WRITE) && - !(usage & PIPE_BUFFER_USAGE_DISCARD)) - usage |= PIPE_BUFFER_USAGE_CPU_READ; - return screen->buffer_map_range(screen, buf, offset, length, usage); } else -- cgit v1.2.3 From 707b28136f7b7dea49bce23b0fcd0a757646ff7a Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 21 Jan 2010 09:19:25 -0800 Subject: gallium: Set PIPE_BUFFER_USAGE_DISCARD flag in pipe_buffer_write. --- src/gallium/include/pipe/p_inlines.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/include/pipe/p_inlines.h b/src/gallium/include/pipe/p_inlines.h index 6949f56574..11ed46c7e7 100644 --- a/src/gallium/include/pipe/p_inlines.h +++ b/src/gallium/include/pipe/p_inlines.h @@ -119,7 +119,8 @@ pipe_buffer_write(struct pipe_screen *screen, map = pipe_buffer_map_range(screen, buf, offset, size, PIPE_BUFFER_USAGE_CPU_WRITE | - PIPE_BUFFER_USAGE_FLUSH_EXPLICIT); + PIPE_BUFFER_USAGE_FLUSH_EXPLICIT | + PIPE_BUFFER_USAGE_DISCARD); assert(map); if(map) { memcpy((uint8_t *)map + offset, data, size); -- cgit v1.2.3 From a8477fb00c1a7b8bfefb5779bc05c51cdb29cdb5 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 21 Jan 2010 09:30:22 -0800 Subject: gallium: New inline to write buffers which avoids synchronization. --- src/gallium/include/pipe/p_inlines.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/gallium/include/pipe/p_inlines.h b/src/gallium/include/pipe/p_inlines.h index 11ed46c7e7..72f5c1dc2a 100644 --- a/src/gallium/include/pipe/p_inlines.h +++ b/src/gallium/include/pipe/p_inlines.h @@ -129,6 +129,37 @@ pipe_buffer_write(struct pipe_screen *screen, } } +/** + * Special case for writing non-overlapping ranges. + * + * We can avoid GPU/CPU synchronization when writing range that has never + * been written before. + */ +static INLINE void +pipe_buffer_write_nooverlap(struct pipe_screen *screen, + struct pipe_buffer *buf, + unsigned offset, unsigned size, + const void *data) +{ + void *map; + + assert(offset < buf->size); + assert(offset + size <= buf->size); + assert(size); + + map = pipe_buffer_map_range(screen, buf, offset, size, + PIPE_BUFFER_USAGE_CPU_WRITE | + PIPE_BUFFER_USAGE_FLUSH_EXPLICIT | + PIPE_BUFFER_USAGE_DISCARD | + PIPE_BUFFER_USAGE_UNSYNCHRONIZED); + assert(map); + if(map) { + memcpy((uint8_t *)map + offset, data, size); + pipe_buffer_flush_mapped_range(screen, buf, offset, size); + pipe_buffer_unmap(screen, buf); + } +} + static INLINE void pipe_buffer_read(struct pipe_screen *screen, struct pipe_buffer *buf, -- cgit v1.2.3 From 17974949464b75f25f635443067b4495bb451248 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 21 Jan 2010 09:32:17 -0800 Subject: util: Use pipe_buffer_write_nooverlap in blits / mipmap generation. --- src/gallium/auxiliary/util/u_blit.c | 4 ++-- src/gallium/auxiliary/util/u_gen_mipmap.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index 5038642599..cf35d3d5df 100644 --- a/src/gallium/auxiliary/util/u_blit.c +++ b/src/gallium/auxiliary/util/u_blit.c @@ -224,8 +224,8 @@ setup_vertex_data_tex(struct blit_state *ctx, offset = get_next_slot( ctx ); - pipe_buffer_write(ctx->pipe->screen, ctx->vbuf, - offset, sizeof(ctx->vertices), ctx->vertices); + pipe_buffer_write_nooverlap(ctx->pipe->screen, ctx->vbuf, + offset, sizeof(ctx->vertices), ctx->vertices); return offset; } diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index aa823aa218..e47928b439 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -1457,8 +1457,8 @@ set_vertex_data(struct gen_mipmap_state *ctx, offset = get_next_slot( ctx ); - pipe_buffer_write(ctx->pipe->screen, ctx->vbuf, - offset, sizeof(ctx->vertices), ctx->vertices); + pipe_buffer_write_nooverlap(ctx->pipe->screen, ctx->vbuf, + offset, sizeof(ctx->vertices), ctx->vertices); return offset; } -- cgit v1.2.3 From 37246f854b49101b5a112cd5a0bd93bab1b78f7a Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 21 Jan 2010 09:38:47 -0800 Subject: util: Set DISCARD & UNSYNCHRONIZED when uploading vertices sequentially. --- src/gallium/auxiliary/util/u_upload_mgr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/util/u_upload_mgr.c b/src/gallium/auxiliary/util/u_upload_mgr.c index 975ee89c45..55a65375c8 100644 --- a/src/gallium/auxiliary/util/u_upload_mgr.c +++ b/src/gallium/auxiliary/util/u_upload_mgr.c @@ -85,7 +85,9 @@ my_buffer_write(struct pipe_screen *screen, map = pipe_buffer_map_range(screen, buf, offset, size, PIPE_BUFFER_USAGE_CPU_WRITE | - PIPE_BUFFER_USAGE_FLUSH_EXPLICIT); + PIPE_BUFFER_USAGE_FLUSH_EXPLICIT | + PIPE_BUFFER_USAGE_DISCARD | + PIPE_BUFFER_USAGE_UNSYNCHRONIZED); if (map == NULL) return PIPE_ERROR_OUT_OF_MEMORY; -- cgit v1.2.3 From 8410f7cde30cc1170ae266cf3a0eb7e0e37c454a Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 21 Jan 2010 09:42:05 -0800 Subject: mesa: Use pipe_buffer_write_nooverlap where appropriate. --- src/mesa/state_tracker/st_cb_bitmap.c | 10 +++++----- src/mesa/state_tracker/st_cb_clear.c | 8 ++++---- src/mesa/state_tracker/st_inlines.h | 10 ++++++++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index 4b85bf2e16..8602f6d32b 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -386,11 +386,11 @@ setup_bitmap_vertex_data(struct st_context *st, } /* put vertex data into vbuf */ - st_no_flush_pipe_buffer_write(st, - st->bitmap.vbuf, - st->bitmap.vbuf_slot * sizeof st->bitmap.vertices, - sizeof st->bitmap.vertices, - st->bitmap.vertices); + st_no_flush_pipe_buffer_write_nooverlap(st, + st->bitmap.vbuf, + st->bitmap.vbuf_slot * sizeof st->bitmap.vertices, + sizeof st->bitmap.vertices, + st->bitmap.vertices); return st->bitmap.vbuf_slot++ * sizeof st->bitmap.vertices; } diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 7c0d74acb5..3aa4b03159 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -162,10 +162,10 @@ draw_quad(GLcontext *ctx, } /* put vertex data into vbuf */ - st_no_flush_pipe_buffer_write(st, st->clear.vbuf, - st->clear.vbuf_slot * sizeof(st->clear.vertices), - sizeof(st->clear.vertices), - st->clear.vertices); + st_no_flush_pipe_buffer_write_nooverlap(st, st->clear.vbuf, + st->clear.vbuf_slot * sizeof(st->clear.vertices), + sizeof(st->clear.vertices), + st->clear.vertices); /* draw */ util_draw_vertex_buffer(pipe, diff --git a/src/mesa/state_tracker/st_inlines.h b/src/mesa/state_tracker/st_inlines.h index a41cfeb96f..dccc46f12d 100644 --- a/src/mesa/state_tracker/st_inlines.h +++ b/src/mesa/state_tracker/st_inlines.h @@ -125,6 +125,16 @@ st_no_flush_pipe_buffer_write(struct st_context *st, pipe_buffer_write(st->pipe->screen, buf, offset, size, data); } +static INLINE void +st_no_flush_pipe_buffer_write_nooverlap(struct st_context *st, + struct pipe_buffer *buf, + unsigned int offset, + unsigned int size, + const void * data) +{ + pipe_buffer_write_nooverlap(st->pipe->screen, buf, offset, size, data); +} + static INLINE void st_cond_flush_pipe_buffer_read(struct st_context *st, struct pipe_buffer *buf, -- cgit v1.2.3 From 0bc885188464446dd94542e0af15f3985dcdf684 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 21 Jan 2010 12:13:27 -0800 Subject: svga: Avoid synchronization issues when doing SW TNL. --- src/gallium/drivers/svga/svga_swtnl_backend.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/svga/svga_swtnl_backend.c b/src/gallium/drivers/svga/svga_swtnl_backend.c index cfbdcf2554..aafb3e26b0 100644 --- a/src/gallium/drivers/svga/svga_swtnl_backend.c +++ b/src/gallium/drivers/svga/svga_swtnl_backend.c @@ -122,7 +122,9 @@ svga_vbuf_render_map_vertices( struct vbuf_render *render ) char *ptr = (char*)pipe_buffer_map(screen, svga_render->vbuf, PIPE_BUFFER_USAGE_CPU_WRITE | - PIPE_BUFFER_USAGE_FLUSH_EXPLICIT); + PIPE_BUFFER_USAGE_FLUSH_EXPLICIT | + PIPE_BUFFER_USAGE_DISCARD | + PIPE_BUFFER_USAGE_UNSYNCHRONIZED); return ptr + svga_render->vbuf_offset; } @@ -264,8 +266,8 @@ svga_vbuf_render_draw( struct vbuf_render *render, svga_render->ibuf_offset = 0; } - pipe_buffer_write(screen, svga_render->ibuf, - svga_render->ibuf_offset, 2 * nr_indices, indices); + pipe_buffer_write_nooverlap(screen, svga_render->ibuf, + svga_render->ibuf_offset, 2 * nr_indices, indices); /* off to hardware */ -- cgit v1.2.3 From 3498616b03f4b1da7a2a74ed83e95aee77204a2f Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 20 Jan 2010 03:43:53 -0800 Subject: pipebuffer: Swap buffers out to system memory when running out of memory. --- src/gallium/auxiliary/pipebuffer/Makefile | 1 - src/gallium/auxiliary/pipebuffer/SConscript | 1 - .../auxiliary/pipebuffer/pb_buffer_fenced.c | 1002 ++++++++++++++------ .../auxiliary/pipebuffer/pb_buffer_fenced.h | 37 - src/gallium/auxiliary/pipebuffer/pb_bufmgr.h | 4 +- .../auxiliary/pipebuffer/pb_bufmgr_fenced.c | 152 --- 6 files changed, 706 insertions(+), 491 deletions(-) delete mode 100644 src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c diff --git a/src/gallium/auxiliary/pipebuffer/Makefile b/src/gallium/auxiliary/pipebuffer/Makefile index 1c00ba8d98..21d25d2474 100644 --- a/src/gallium/auxiliary/pipebuffer/Makefile +++ b/src/gallium/auxiliary/pipebuffer/Makefile @@ -9,7 +9,6 @@ C_SOURCES = \ pb_bufmgr_alt.c \ pb_bufmgr_cache.c \ pb_bufmgr_debug.c \ - pb_bufmgr_fenced.c \ pb_bufmgr_mm.c \ pb_bufmgr_ondemand.c \ pb_bufmgr_pool.c \ diff --git a/src/gallium/auxiliary/pipebuffer/SConscript b/src/gallium/auxiliary/pipebuffer/SConscript index 8e9f06abe4..a074a55471 100644 --- a/src/gallium/auxiliary/pipebuffer/SConscript +++ b/src/gallium/auxiliary/pipebuffer/SConscript @@ -8,7 +8,6 @@ pipebuffer = env.ConvenienceLibrary( 'pb_bufmgr_alt.c', 'pb_bufmgr_cache.c', 'pb_bufmgr_debug.c', - 'pb_bufmgr_fenced.c', 'pb_bufmgr_mm.c', 'pb_bufmgr_ondemand.c', 'pb_bufmgr_pool.c', diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c index 2ef4293d4d..600b236921 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c @@ -1,6 +1,6 @@ /************************************************************************** * - * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * Copyright 2007-2010 VMware, Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -18,7 +18,7 @@ * 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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. @@ -28,9 +28,9 @@ /** * \file * Implementation of fenced buffers. - * - * \author Jose Fonseca - * \author Thomas Hellström + * + * \author Jose Fonseca + * \author Thomas Hellström */ @@ -50,6 +50,7 @@ #include "pb_buffer.h" #include "pb_buffer_fenced.h" +#include "pb_bufmgr.h" @@ -59,32 +60,79 @@ #define SUPER(__derived) (&(__derived)->base) -struct fenced_buffer_list +struct fenced_manager { - pipe_mutex mutex; - + struct pb_manager base; + struct pb_manager *provider; struct pb_fence_ops *ops; - - pb_size numDelayed; - struct list_head delayed; - -#ifdef DEBUG - pb_size numUnfenced; + + /** + * Maximum buffer size that can be safely allocated. + */ + pb_size max_buffer_size; + + /** + * Maximum cpu memory we can allocate before we start waiting for the + * GPU to idle. + */ + pb_size max_cpu_total_size; + + /** + * Following members are mutable and protected by this mutex. + */ + pipe_mutex mutex; + + /** + * Fenced buffer list. + * + * All fenced buffers are placed in this listed, ordered from the oldest + * fence to the newest fence. + */ + struct list_head fenced; + pb_size num_fenced; + struct list_head unfenced; -#endif + pb_size num_unfenced; + + /** + * How much temporary CPU memory is being used to hold unvalidated buffers. + */ + pb_size cpu_total_size; }; /** + * Fenced buffer. + * * Wrapper around a pipe buffer which adds fencing and reference counting. */ struct fenced_buffer { + /* + * Immutable members. + */ + struct pb_buffer base; - + struct fenced_manager *mgr; + + /* + * Following members are mutable and protected by fenced_manager::mutex. + */ + + struct list_head head; + + /** + * Buffer with storage. + */ struct pb_buffer *buffer; + pb_size size; + struct pb_desc desc; - /* FIXME: protect access with mutex */ + /** + * Temporary CPU storage data. Used when there isn't enough GPU memory to + * store the buffer. + */ + void *data; /** * A bitmask of PIPE_BUFFER_USAGE_CPU/GPU_READ/WRITE describing the current @@ -93,15 +141,22 @@ struct fenced_buffer unsigned flags; unsigned mapcount; + struct pb_validate *vl; unsigned validation_flags; - struct pipe_fence_handle *fence; - struct list_head head; - struct fenced_buffer_list *list; + struct pipe_fence_handle *fence; }; +static INLINE struct fenced_manager * +fenced_manager(struct pb_manager *mgr) +{ + assert(mgr); + return (struct fenced_manager *)mgr; +} + + static INLINE struct fenced_buffer * fenced_buffer(struct pb_buffer *buf) { @@ -110,220 +165,508 @@ fenced_buffer(struct pb_buffer *buf) } -static INLINE void -_fenced_buffer_add(struct fenced_buffer *fenced_buf) -{ - struct fenced_buffer_list *fenced_list = fenced_buf->list; +static void +fenced_buffer_destroy_cpu_storage_locked(struct fenced_buffer *fenced_buf); - assert(pipe_is_referenced(&fenced_buf->base.base.reference)); - assert(fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE); - assert(fenced_buf->fence); +static enum pipe_error +fenced_buffer_create_cpu_storage_locked(struct fenced_buffer *fenced_buf); +static void +fenced_buffer_destroy_gpu_storage_locked(struct fenced_buffer *fenced_buf); + +static enum pipe_error +fenced_buffer_create_gpu_storage_locked(struct fenced_manager *fenced_mgr, + struct fenced_buffer *fenced_buf, + boolean wait); + +static enum pipe_error +fenced_buffer_copy_storage_to_gpu_locked(struct fenced_buffer *fenced_buf); + +static enum pipe_error +fenced_buffer_copy_storage_to_cpu_locked(struct fenced_buffer *fenced_buf); + + +/** + * Dump the fenced buffer list. + * + * Useful to understand failures to allocate buffers. + */ +static void +fenced_manager_dump_locked(struct fenced_manager *fenced_mgr) +{ #ifdef DEBUG - LIST_DEL(&fenced_buf->head); - assert(fenced_list->numUnfenced); - --fenced_list->numUnfenced; + struct pb_fence_ops *ops = fenced_mgr->ops; + struct list_head *curr, *next; + struct fenced_buffer *fenced_buf; + + debug_printf("%10s %7s %7s %10s %s\n", + "buffer", "size", "refcount", "fence", "signalled"); + + curr = fenced_mgr->unfenced.next; + next = curr->next; + while(curr != &fenced_mgr->unfenced) { + fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); + assert(!fenced_buf->fence); + debug_printf("%10p %7u %7u\n", + (void *) fenced_buf, + fenced_buf->base.base.size, + p_atomic_read(&fenced_buf->base.base.reference.count)); + curr = next; + next = curr->next; + } + + curr = fenced_mgr->fenced.next; + next = curr->next; + while(curr != &fenced_mgr->fenced) { + int signaled; + fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); + signaled = ops->fence_signalled(ops, fenced_buf->fence, 0); + debug_printf("%10p %7u %7u %10p %s\n", + (void *) fenced_buf, + fenced_buf->base.base.size, + p_atomic_read(&fenced_buf->base.base.reference.count), + (void *) fenced_buf->fence, + signaled == 0 ? "y" : "n"); + curr = next; + next = curr->next; + } +#else + (void)fenced_mgr; #endif - LIST_ADDTAIL(&fenced_buf->head, &fenced_list->delayed); - ++fenced_list->numDelayed; } /** - * Actually destroy the buffer. + * Add the buffer to the fenced list. + * + * Reference count should be incremented before calling this function. */ static INLINE void -_fenced_buffer_destroy(struct fenced_buffer *fenced_buf) +fenced_buffer_add_locked(struct fenced_manager *fenced_mgr, + struct fenced_buffer *fenced_buf) { - struct fenced_buffer_list *fenced_list = fenced_buf->list; - - assert(!pipe_is_referenced(&fenced_buf->base.base.reference)); - assert(!fenced_buf->fence); -#ifdef DEBUG - assert(fenced_buf->head.prev); - assert(fenced_buf->head.next); + assert(pipe_is_referenced(&fenced_buf->base.base.reference)); + assert(fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE); + assert(fenced_buf->fence); + + /* TODO: Move the reference count increment here */ + LIST_DEL(&fenced_buf->head); - assert(fenced_list->numUnfenced); - --fenced_list->numUnfenced; -#else - (void)fenced_list; -#endif - pb_reference(&fenced_buf->buffer, NULL); - FREE(fenced_buf); + assert(fenced_mgr->num_unfenced); + --fenced_mgr->num_unfenced; + LIST_ADDTAIL(&fenced_buf->head, &fenced_mgr->fenced); + ++fenced_mgr->num_fenced; } +/** + * Remove the buffer from the fenced list. + * + * Reference count should be decremented after calling this function. + */ static INLINE void -_fenced_buffer_remove(struct fenced_buffer_list *fenced_list, - struct fenced_buffer *fenced_buf) +fenced_buffer_remove_locked(struct fenced_manager *fenced_mgr, + struct fenced_buffer *fenced_buf) { - struct pb_fence_ops *ops = fenced_list->ops; + struct pb_fence_ops *ops = fenced_mgr->ops; assert(fenced_buf->fence); - assert(fenced_buf->list == fenced_list); - + assert(fenced_buf->mgr == fenced_mgr); + ops->fence_reference(ops, &fenced_buf->fence, NULL); fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE; - + assert(fenced_buf->head.prev); assert(fenced_buf->head.next); - + LIST_DEL(&fenced_buf->head); - assert(fenced_list->numDelayed); - --fenced_list->numDelayed; - -#ifdef DEBUG - LIST_ADDTAIL(&fenced_buf->head, &fenced_list->unfenced); - ++fenced_list->numUnfenced; -#endif - - /** - * FIXME!!! - */ + assert(fenced_mgr->num_fenced); + --fenced_mgr->num_fenced; - if(!pipe_is_referenced(&fenced_buf->base.base.reference)) - _fenced_buffer_destroy(fenced_buf); + LIST_ADDTAIL(&fenced_buf->head, &fenced_mgr->unfenced); + ++fenced_mgr->num_unfenced; + + /* TODO: Move the reference count decrement and destruction here */ } +/** + * Wait for the fence to expire, and remove it from the fenced list. + */ static INLINE enum pipe_error -_fenced_buffer_finish(struct fenced_buffer *fenced_buf) +fenced_buffer_finish_locked(struct fenced_manager *fenced_mgr, + struct fenced_buffer *fenced_buf) { - struct fenced_buffer_list *fenced_list = fenced_buf->list; - struct pb_fence_ops *ops = fenced_list->ops; + struct pb_fence_ops *ops = fenced_mgr->ops; + enum pipe_error ret = PIPE_ERROR; #if 0 debug_warning("waiting for GPU"); #endif + assert(pipe_is_referenced(&fenced_buf->base.base.reference)); assert(fenced_buf->fence); + if(fenced_buf->fence) { - if(ops->fence_finish(ops, fenced_buf->fence, 0) != 0) { - return PIPE_ERROR; + if(ops->fence_finish(ops, fenced_buf->fence, 0) == 0) { + /* + * Remove from the fenced list + */ + fenced_buffer_remove_locked(fenced_mgr, fenced_buf); + + /* TODO: remove consequents buffers with the same fence? */ + + p_atomic_dec(&fenced_buf->base.base.reference.count); + assert(pipe_is_referenced(&fenced_buf->base.base.reference)); + + fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE; + + ret = PIPE_OK; } - /* Remove from the fenced list */ - /* TODO: remove consequents */ - _fenced_buffer_remove(fenced_list, fenced_buf); } - fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE; - return PIPE_OK; + return ret; } /** - * Free as many fenced buffers from the list head as possible. + * Remove as many fenced buffers from the fenced list as possible. + * + * Returns TRUE if at least one buffer was removed. */ -static void -_fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list, - int wait) +static boolean +fenced_manager_check_signalled_locked(struct fenced_manager *fenced_mgr, + boolean wait) { - struct pb_fence_ops *ops = fenced_list->ops; + struct pb_fence_ops *ops = fenced_mgr->ops; struct list_head *curr, *next; struct fenced_buffer *fenced_buf; struct pipe_fence_handle *prev_fence = NULL; + boolean ret = FALSE; - curr = fenced_list->delayed.next; + curr = fenced_mgr->fenced.next; next = curr->next; - while(curr != &fenced_list->delayed) { + while(curr != &fenced_mgr->fenced) { fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); if(fenced_buf->fence != prev_fence) { int signaled; - if (wait) + + if (wait) { signaled = ops->fence_finish(ops, fenced_buf->fence, 0); - else + + /* + * Don't return just now. Instead preemptively check if the + * following buffers' fences already expired, without further waits. + */ + wait = FALSE; + } + else { signaled = ops->fence_signalled(ops, fenced_buf->fence, 0); - if (signaled != 0) - break; + } + + if (signaled != 0) { + return ret; + } + prev_fence = fenced_buf->fence; } else { + /* This buffer's fence object is identical to the previous buffer's + * fence object, so no need to check the fence again. + */ assert(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0); } - _fenced_buffer_remove(fenced_list, fenced_buf); + fenced_buffer_remove_locked(fenced_mgr, fenced_buf); + + pb_reference((struct pb_buffer **)&fenced_buf, NULL); + + ret = TRUE; + + curr = next; + next = curr->next; + } + + return ret; +} + + +/** + * Try to free some GPU memory by backing it up into CPU memory. + * + * Returns TRUE if at least one buffer was freed. + */ +static boolean +fenced_manager_free_gpu_storage_locked(struct fenced_manager *fenced_mgr) +{ + struct list_head *curr, *next; + struct fenced_buffer *fenced_buf; - curr = next; + curr = fenced_mgr->unfenced.next; + next = curr->next; + while(curr != &fenced_mgr->unfenced) { + fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); + + /* + * We can only move storage if the buffer is not mapped and not + * validated. + */ + if(fenced_buf->buffer && + !fenced_buf->mapcount && + !fenced_buf->vl) { + enum pipe_error ret; + + ret = fenced_buffer_create_cpu_storage_locked(fenced_buf); + if(ret == PIPE_OK) { + ret = fenced_buffer_copy_storage_to_cpu_locked(fenced_buf); + if(ret == PIPE_OK) { + fenced_buffer_destroy_gpu_storage_locked(fenced_buf); + return TRUE; + } + fenced_buffer_destroy_cpu_storage_locked(fenced_buf); + } + } + + curr = next; next = curr->next; } + + return FALSE; } +/** + * Destroy CPU storage for this buffer. + */ static void -fenced_buffer_destroy(struct pb_buffer *buf) +fenced_buffer_destroy_cpu_storage_locked(struct fenced_buffer *fenced_buf) { - struct fenced_buffer *fenced_buf = fenced_buffer(buf); - struct fenced_buffer_list *fenced_list = fenced_buf->list; + if(fenced_buf->data) { + align_free(fenced_buf->data); + fenced_buf->data = NULL; + fenced_buf->mgr->cpu_total_size -= fenced_buf->size; + } +} - pipe_mutex_lock(fenced_list->mutex); - assert(!pipe_is_referenced(&fenced_buf->base.base.reference)); - if (fenced_buf->fence) { - struct pb_fence_ops *ops = fenced_list->ops; - if(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) { - struct list_head *curr, *prev; - curr = &fenced_buf->head; - prev = curr->prev; - do { - fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); - assert(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0); - _fenced_buffer_remove(fenced_list, fenced_buf); - curr = prev; - prev = curr->prev; - } while (curr != &fenced_list->delayed); - } - else { - /* delay destruction */ + +/** + * Create CPU storage for this buffer. + */ +static enum pipe_error +fenced_buffer_create_cpu_storage_locked(struct fenced_buffer *fenced_buf) +{ + assert(!fenced_buf->data); + if(fenced_buf->data) + return PIPE_OK; + + fenced_buf->data = align_malloc(fenced_buf->size, fenced_buf->desc.alignment); + if(!fenced_buf->data) + return PIPE_ERROR_OUT_OF_MEMORY; + + fenced_buf->mgr->cpu_total_size += fenced_buf->size; + debug_printf("%s: cpu_total_size = %lu\n", + __FUNCTION__, + (unsigned long)fenced_buf->mgr->cpu_total_size); + + return PIPE_OK; +} + + +/** + * Destroy the GPU storage. + */ +static void +fenced_buffer_destroy_gpu_storage_locked(struct fenced_buffer *fenced_buf) +{ + if(fenced_buf->buffer) { + pb_reference(&fenced_buf->buffer, NULL); + } +} + + +/** + * Try to create GPU storage for this buffer. + * + * This function is a shorthand around pb_manager::create_buffer for + * fenced_buffer_create_gpu_storage_locked()'s benefit. + */ +static INLINE boolean +fenced_buffer_try_create_gpu_storage_locked(struct fenced_manager *fenced_mgr, + struct fenced_buffer *fenced_buf) +{ + struct pb_manager *provider = fenced_mgr->provider; + + assert(!fenced_buf->buffer); + + fenced_buf->buffer = provider->create_buffer(fenced_mgr->provider, + fenced_buf->size, + &fenced_buf->desc); + return fenced_buf->buffer ? TRUE : FALSE; +} + + +/** + * Create GPU storage for this buffer. + */ +static enum pipe_error +fenced_buffer_create_gpu_storage_locked(struct fenced_manager *fenced_mgr, + struct fenced_buffer *fenced_buf, + boolean wait) +{ + assert(!fenced_buf->buffer); + + /* + * Check for signaled buffers before trying to allocate. + */ + fenced_manager_check_signalled_locked(fenced_mgr, FALSE); + + fenced_buffer_try_create_gpu_storage_locked(fenced_mgr, fenced_buf); + + /* + * Keep trying while there is some sort of progress: + * - fences are expiring, + * - or buffers are being being swapped out from GPU memory into CPU memory. + */ + while(!fenced_buf->buffer && + (fenced_manager_check_signalled_locked(fenced_mgr, FALSE) || + fenced_manager_free_gpu_storage_locked(fenced_mgr))) { + fenced_buffer_try_create_gpu_storage_locked(fenced_mgr, fenced_buf); + } + + if(!fenced_buf->buffer && wait) { + /* + * Same as before, but this time around, wait to free buffers if + * necessary. + */ + while(!fenced_buf->buffer && + (fenced_manager_check_signalled_locked(fenced_mgr, TRUE) || + fenced_manager_free_gpu_storage_locked(fenced_mgr))) { + fenced_buffer_try_create_gpu_storage_locked(fenced_mgr, fenced_buf); } } - else { - _fenced_buffer_destroy(fenced_buf); + + if(!fenced_buf->buffer) { + if(0) + fenced_manager_dump_locked(fenced_mgr); + + /* give up */ + return PIPE_ERROR_OUT_OF_MEMORY; } - pipe_mutex_unlock(fenced_list->mutex); + + return PIPE_OK; +} + + +static enum pipe_error +fenced_buffer_copy_storage_to_gpu_locked(struct fenced_buffer *fenced_buf) +{ + uint8_t *map; + + assert(fenced_buf->data); + assert(fenced_buf->buffer); + + map = pb_map(fenced_buf->buffer, PIPE_BUFFER_USAGE_CPU_WRITE); + if(!map) + return PIPE_ERROR; + + memcpy(map, fenced_buf->data, fenced_buf->size); + + pb_unmap(fenced_buf->buffer); + + return PIPE_OK; +} + + +static enum pipe_error +fenced_buffer_copy_storage_to_cpu_locked(struct fenced_buffer *fenced_buf) +{ + const uint8_t *map; + + assert(fenced_buf->data); + assert(fenced_buf->buffer); + + map = pb_map(fenced_buf->buffer, PIPE_BUFFER_USAGE_CPU_READ); + if(!map) + return PIPE_ERROR; + + memcpy(fenced_buf->data, map, fenced_buf->size); + + pb_unmap(fenced_buf->buffer); + + return PIPE_OK; +} + + +static void +fenced_buffer_destroy(struct pb_buffer *buf) +{ + struct fenced_buffer *fenced_buf = fenced_buffer(buf); + struct fenced_manager *fenced_mgr = fenced_buf->mgr; + + assert(!pipe_is_referenced(&fenced_buf->base.base.reference)); + + pipe_mutex_lock(fenced_mgr->mutex); + + assert(!fenced_buf->fence); + assert(fenced_buf->head.prev); + assert(fenced_buf->head.next); + LIST_DEL(&fenced_buf->head); + assert(fenced_mgr->num_unfenced); + --fenced_mgr->num_unfenced; + + fenced_buffer_destroy_gpu_storage_locked(fenced_buf); + fenced_buffer_destroy_cpu_storage_locked(fenced_buf); + + pipe_mutex_unlock(fenced_mgr->mutex); + + FREE(fenced_buf); } static void * -fenced_buffer_map(struct pb_buffer *buf, +fenced_buffer_map(struct pb_buffer *buf, unsigned flags) { struct fenced_buffer *fenced_buf = fenced_buffer(buf); - struct fenced_buffer_list *fenced_list = fenced_buf->list; - struct pb_fence_ops *ops = fenced_list->ops; - void *map; + struct fenced_manager *fenced_mgr = fenced_buf->mgr; + struct pb_fence_ops *ops = fenced_mgr->ops; + void *map = NULL; + + pipe_mutex_lock(fenced_mgr->mutex); assert(!(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE)); - + /* Serialize writes */ if((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_WRITE) || ((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ) && (flags & PIPE_BUFFER_USAGE_CPU_WRITE))) { - if(flags & PIPE_BUFFER_USAGE_DONTBLOCK) { + + if((flags & PIPE_BUFFER_USAGE_DONTBLOCK) && + ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) { /* Don't wait for the GPU to finish writing */ - if(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) - _fenced_buffer_remove(fenced_list, fenced_buf); - else - return NULL; - } - else { - /* Wait for the GPU to finish writing */ - _fenced_buffer_finish(fenced_buf); + goto done; } + + /* Wait for the GPU to finish writing */ + fenced_buffer_finish_locked(fenced_mgr, fenced_buf); } -#if 0 - /* Check for CPU write access (read is OK) */ - if(fenced_buf->flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE) { - /* this is legal -- just for debugging */ - debug_warning("concurrent CPU writes"); + if(fenced_buf->buffer) { + map = pb_map(fenced_buf->buffer, flags); } -#endif - - map = pb_map(fenced_buf->buffer, flags); + else { + assert(fenced_buf->data); + map = fenced_buf->data; + } + if(map) { ++fenced_buf->mapcount; fenced_buf->flags |= flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE; } +done: + pipe_mutex_unlock(fenced_mgr->mutex); + return map; } @@ -332,13 +675,20 @@ static void fenced_buffer_unmap(struct pb_buffer *buf) { struct fenced_buffer *fenced_buf = fenced_buffer(buf); + struct fenced_manager *fenced_mgr = fenced_buf->mgr; + + pipe_mutex_lock(fenced_mgr->mutex); + assert(fenced_buf->mapcount); if(fenced_buf->mapcount) { - pb_unmap(fenced_buf->buffer); + if (fenced_buf->buffer) + pb_unmap(fenced_buf->buffer); --fenced_buf->mapcount; if(!fenced_buf->mapcount) fenced_buf->flags &= ~PIPE_BUFFER_USAGE_CPU_READ_WRITE; } + + pipe_mutex_unlock(fenced_mgr->mutex); } @@ -348,48 +698,72 @@ fenced_buffer_validate(struct pb_buffer *buf, unsigned flags) { struct fenced_buffer *fenced_buf = fenced_buffer(buf); + struct fenced_manager *fenced_mgr = fenced_buf->mgr; enum pipe_error ret; - + + pipe_mutex_lock(fenced_mgr->mutex); + if(!vl) { /* invalidate */ fenced_buf->vl = NULL; fenced_buf->validation_flags = 0; - return PIPE_OK; + ret = PIPE_OK; + goto done; } - + assert(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE); assert(!(flags & ~PIPE_BUFFER_USAGE_GPU_READ_WRITE)); flags &= PIPE_BUFFER_USAGE_GPU_READ_WRITE; - /* Buffer cannot be validated in two different lists */ - if(fenced_buf->vl && fenced_buf->vl != vl) - return PIPE_ERROR_RETRY; - -#if 0 - /* Do not validate if buffer is still mapped */ - if(fenced_buf->flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE) { - /* TODO: wait for the thread that mapped the buffer to unmap it */ - return PIPE_ERROR_RETRY; + /* Buffer cannot be validated in two different lists */ + if(fenced_buf->vl && fenced_buf->vl != vl) { + ret = PIPE_ERROR_RETRY; + goto done; } - /* Final sanity checking */ - assert(!(fenced_buf->flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE)); - assert(!fenced_buf->mapcount); -#endif if(fenced_buf->vl == vl && (fenced_buf->validation_flags & flags) == flags) { /* Nothing to do -- buffer already validated */ - return PIPE_OK; + ret = PIPE_OK; + goto done; } - + + /* + * Create and update GPU storage. + */ + if(!fenced_buf->buffer) { + assert(!fenced_buf->mapcount); + + ret = fenced_buffer_create_gpu_storage_locked(fenced_mgr, fenced_buf, TRUE); + if(ret != PIPE_OK) { + goto done; + } + + ret = fenced_buffer_copy_storage_to_gpu_locked(fenced_buf); + if(ret != PIPE_OK) { + fenced_buffer_destroy_gpu_storage_locked(fenced_buf); + goto done; + } + + if(fenced_buf->mapcount) { + debug_printf("warning: validating a buffer while it is still mapped\n"); + } + else { + fenced_buffer_destroy_cpu_storage_locked(fenced_buf); + } + } + ret = pb_validate(fenced_buf->buffer, vl, flags); if (ret != PIPE_OK) - return ret; - + goto done; + fenced_buf->vl = vl; fenced_buf->validation_flags |= flags; - - return PIPE_OK; + +done: + pipe_mutex_unlock(fenced_mgr->mutex); + + return ret; } @@ -397,36 +771,38 @@ static void fenced_buffer_fence(struct pb_buffer *buf, struct pipe_fence_handle *fence) { - struct fenced_buffer *fenced_buf; - struct fenced_buffer_list *fenced_list; - struct pb_fence_ops *ops; + struct fenced_buffer *fenced_buf = fenced_buffer(buf); + struct fenced_manager *fenced_mgr = fenced_buf->mgr; + struct pb_fence_ops *ops = fenced_mgr->ops; - fenced_buf = fenced_buffer(buf); - fenced_list = fenced_buf->list; - ops = fenced_list->ops; - - if(fence == fenced_buf->fence) { - /* Nothing to do */ - return; - } + pipe_mutex_lock(fenced_mgr->mutex); - assert(fenced_buf->vl); - assert(fenced_buf->validation_flags); - - pipe_mutex_lock(fenced_list->mutex); - if (fenced_buf->fence) - _fenced_buffer_remove(fenced_list, fenced_buf); - if (fence) { - ops->fence_reference(ops, &fenced_buf->fence, fence); - fenced_buf->flags |= fenced_buf->validation_flags; - _fenced_buffer_add(fenced_buf); + assert(pipe_is_referenced(&fenced_buf->base.base.reference)); + assert(fenced_buf->buffer); + + if(fence != fenced_buf->fence) { + assert(fenced_buf->vl); + assert(fenced_buf->validation_flags); + + if (fenced_buf->fence) { + fenced_buffer_remove_locked(fenced_mgr, fenced_buf); + p_atomic_dec(&fenced_buf->base.base.reference.count); + assert(pipe_is_referenced(&fenced_buf->base.base.reference)); + } + if (fence) { + ops->fence_reference(ops, &fenced_buf->fence, fence); + fenced_buf->flags |= fenced_buf->validation_flags; + p_atomic_inc(&fenced_buf->base.base.reference.count); + fenced_buffer_add_locked(fenced_mgr, fenced_buf); + } + + pb_fence(fenced_buf->buffer, fence); + + fenced_buf->vl = NULL; + fenced_buf->validation_flags = 0; } - pipe_mutex_unlock(fenced_list->mutex); - - pb_fence(fenced_buf->buffer, fence); - fenced_buf->vl = NULL; - fenced_buf->validation_flags = 0; + pipe_mutex_unlock(fenced_mgr->mutex); } @@ -436,11 +812,29 @@ fenced_buffer_get_base_buffer(struct pb_buffer *buf, pb_size *offset) { struct fenced_buffer *fenced_buf = fenced_buffer(buf); - pb_get_base_buffer(fenced_buf->buffer, base_buf, offset); + struct fenced_manager *fenced_mgr = fenced_buf->mgr; + + pipe_mutex_lock(fenced_mgr->mutex); + + /* + * This should only be called when the buffer is validated. Typically + * when processing relocations. + */ + assert(fenced_buf->vl); + assert(fenced_buf->buffer); + + if(fenced_buf->buffer) + pb_get_base_buffer(fenced_buf->buffer, base_buf, offset); + else { + *base_buf = buf; + *offset = 0; + } + + pipe_mutex_unlock(fenced_mgr->mutex); } -static const struct pb_vtbl +static const struct pb_vtbl fenced_buffer_vtbl = { fenced_buffer_destroy, fenced_buffer_map, @@ -451,147 +845,157 @@ fenced_buffer_vtbl = { }; -struct pb_buffer * -fenced_buffer_create(struct fenced_buffer_list *fenced_list, - struct pb_buffer *buffer) +/** + * Wrap a buffer in a fenced buffer. + */ +static struct pb_buffer * +fenced_bufmgr_create_buffer(struct pb_manager *mgr, + pb_size size, + const struct pb_desc *desc) { - struct fenced_buffer *buf; - - if(!buffer) - return NULL; - - buf = CALLOC_STRUCT(fenced_buffer); - if(!buf) { - pb_reference(&buffer, NULL); - return NULL; - } - - pipe_reference_init(&buf->base.base.reference, 1); - buf->base.base.alignment = buffer->base.alignment; - buf->base.base.usage = buffer->base.usage; - buf->base.base.size = buffer->base.size; - - buf->base.vtbl = &fenced_buffer_vtbl; - buf->buffer = buffer; - buf->list = fenced_list; - -#ifdef DEBUG - pipe_mutex_lock(fenced_list->mutex); - LIST_ADDTAIL(&buf->head, &fenced_list->unfenced); - ++fenced_list->numUnfenced; - pipe_mutex_unlock(fenced_list->mutex); -#endif + struct fenced_manager *fenced_mgr = fenced_manager(mgr); + struct fenced_buffer *fenced_buf; + enum pipe_error ret; - return &buf->base; -} + fenced_buf = CALLOC_STRUCT(fenced_buffer); + if(!fenced_buf) + goto no_buffer; + pipe_reference_init(&fenced_buf->base.base.reference, 1); + fenced_buf->base.base.alignment = desc->alignment; + fenced_buf->base.base.usage = desc->usage; + fenced_buf->base.base.size = size; + fenced_buf->size = size; + fenced_buf->desc = *desc; -struct fenced_buffer_list * -fenced_buffer_list_create(struct pb_fence_ops *ops) -{ - struct fenced_buffer_list *fenced_list; + fenced_buf->base.vtbl = &fenced_buffer_vtbl; + fenced_buf->mgr = fenced_mgr; - fenced_list = CALLOC_STRUCT(fenced_buffer_list); - if (!fenced_list) - return NULL; + pipe_mutex_lock(fenced_mgr->mutex); - fenced_list->ops = ops; + /* + * Try to create GPU storage without stalling, + */ + ret = fenced_buffer_create_gpu_storage_locked(fenced_mgr, fenced_buf, 0); + if(ret != PIPE_OK) { + /* + * Don't stall the GPU or waste memory trying to create a buffer that will + * most likely never fit into the graphics aperture. + */ + if(size > fenced_mgr->max_buffer_size) { + goto no_storage; + } - LIST_INITHEAD(&fenced_list->delayed); - fenced_list->numDelayed = 0; - -#ifdef DEBUG - LIST_INITHEAD(&fenced_list->unfenced); - fenced_list->numUnfenced = 0; -#endif + if(fenced_mgr->cpu_total_size + size <= fenced_mgr->max_cpu_total_size) { + /* Use CPU memory to avoid stalling the GPU */ + ret = fenced_buffer_create_cpu_storage_locked(fenced_buf); + } + else { + /* Create GPU storage, waiting for some to be available */ + ret = fenced_buffer_create_gpu_storage_locked(fenced_mgr, fenced_buf, 1); + } + if(ret != PIPE_OK) { + goto no_storage; + } + } - pipe_mutex_init(fenced_list->mutex); + assert(fenced_buf->buffer || fenced_buf->data); - return fenced_list; -} + LIST_ADDTAIL(&fenced_buf->head, &fenced_mgr->unfenced); + ++fenced_mgr->num_unfenced; + pipe_mutex_unlock(fenced_mgr->mutex); + return &fenced_buf->base; -void -fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list, - int wait) -{ - pipe_mutex_lock(fenced_list->mutex); - _fenced_buffer_list_check_free(fenced_list, wait); - pipe_mutex_unlock(fenced_list->mutex); +no_storage: + pipe_mutex_unlock(fenced_mgr->mutex); + FREE(fenced_buf); +no_buffer: + return NULL; } -#ifdef DEBUG -void -fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list) +static void +fenced_bufmgr_flush(struct pb_manager *mgr) { - struct pb_fence_ops *ops = fenced_list->ops; - struct list_head *curr, *next; - struct fenced_buffer *fenced_buf; + struct fenced_manager *fenced_mgr = fenced_manager(mgr); - pipe_mutex_lock(fenced_list->mutex); + pipe_mutex_lock(fenced_mgr->mutex); + while(fenced_manager_check_signalled_locked(fenced_mgr, TRUE)) + ; + pipe_mutex_unlock(fenced_mgr->mutex); - debug_printf("%10s %7s %7s %10s %s\n", - "buffer", "size", "refcount", "fence", "signalled"); - - curr = fenced_list->unfenced.next; - next = curr->next; - while(curr != &fenced_list->unfenced) { - fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); - assert(!fenced_buf->fence); - debug_printf("%10p %7u %7u\n", - (void *) fenced_buf, - fenced_buf->base.base.size, - p_atomic_read(&fenced_buf->base.base.reference.count)); - curr = next; - next = curr->next; - } - - curr = fenced_list->delayed.next; - next = curr->next; - while(curr != &fenced_list->delayed) { - int signaled; - fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); - signaled = ops->fence_signalled(ops, fenced_buf->fence, 0); - debug_printf("%10p %7u %7u %10p %s\n", - (void *) fenced_buf, - fenced_buf->base.base.size, - p_atomic_read(&fenced_buf->base.base.reference.count), - (void *) fenced_buf->fence, - signaled == 0 ? "y" : "n"); - curr = next; - next = curr->next; - } - - pipe_mutex_unlock(fenced_list->mutex); + assert(fenced_mgr->provider->flush); + if(fenced_mgr->provider->flush) + fenced_mgr->provider->flush(fenced_mgr->provider); } -#endif -void -fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list) +static void +fenced_bufmgr_destroy(struct pb_manager *mgr) { - pipe_mutex_lock(fenced_list->mutex); + struct fenced_manager *fenced_mgr = fenced_manager(mgr); + + pipe_mutex_lock(fenced_mgr->mutex); /* Wait on outstanding fences */ - while (fenced_list->numDelayed) { - pipe_mutex_unlock(fenced_list->mutex); + while (fenced_mgr->num_fenced) { + pipe_mutex_unlock(fenced_mgr->mutex); #if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) sched_yield(); #endif - _fenced_buffer_list_check_free(fenced_list, 1); - pipe_mutex_lock(fenced_list->mutex); + pipe_mutex_lock(fenced_mgr->mutex); + while(fenced_manager_check_signalled_locked(fenced_mgr, TRUE)) + ; } #ifdef DEBUG - /*assert(!fenced_list->numUnfenced);*/ + /*assert(!fenced_mgr->num_unfenced);*/ #endif - - pipe_mutex_unlock(fenced_list->mutex); - - fenced_list->ops->destroy(fenced_list->ops); - - FREE(fenced_list); + + pipe_mutex_unlock(fenced_mgr->mutex); + pipe_mutex_destroy(fenced_mgr->mutex); + + if(fenced_mgr->provider) + fenced_mgr->provider->destroy(fenced_mgr->provider); + + fenced_mgr->ops->destroy(fenced_mgr->ops); + + FREE(fenced_mgr); } +struct pb_manager * +fenced_bufmgr_create(struct pb_manager *provider, + struct pb_fence_ops *ops, + pb_size max_buffer_size, + pb_size max_cpu_total_size) +{ + struct fenced_manager *fenced_mgr; + + if(!provider) + return NULL; + + fenced_mgr = CALLOC_STRUCT(fenced_manager); + if (!fenced_mgr) + return NULL; + + fenced_mgr->base.destroy = fenced_bufmgr_destroy; + fenced_mgr->base.create_buffer = fenced_bufmgr_create_buffer; + fenced_mgr->base.flush = fenced_bufmgr_flush; + + fenced_mgr->provider = provider; + fenced_mgr->ops = ops; + fenced_mgr->max_buffer_size = max_buffer_size; + fenced_mgr->max_cpu_total_size = max_cpu_total_size; + + LIST_INITHEAD(&fenced_mgr->fenced); + fenced_mgr->num_fenced = 0; + + LIST_INITHEAD(&fenced_mgr->unfenced); + fenced_mgr->num_unfenced = 0; + + pipe_mutex_init(fenced_mgr->mutex); + + return &fenced_mgr->base; +} diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h index 034ca1e024..0372f81d0a 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h @@ -98,43 +98,6 @@ struct pb_fence_ops }; -/** - * Create a fenced buffer list. - * - * See also fenced_bufmgr_create for a more convenient way to use this. - */ -struct fenced_buffer_list * -fenced_buffer_list_create(struct pb_fence_ops *ops); - - -/** - * Walk the fenced buffer list to check and free signalled buffers. - */ -void -fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list, - int wait); - - -#ifdef DEBUG -void -fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list); -#endif - - -void -fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list); - - -/** - * Wrap a buffer in a fenced buffer. - * - * NOTE: this will not increase the buffer reference count. - */ -struct pb_buffer * -fenced_buffer_create(struct fenced_buffer_list *fenced, - struct pb_buffer *buffer); - - #ifdef __cplusplus } #endif diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h index 8c8d713078..06669917ff 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h @@ -175,7 +175,9 @@ struct pb_fence_ops; */ struct pb_manager * fenced_bufmgr_create(struct pb_manager *provider, - struct pb_fence_ops *ops); + struct pb_fence_ops *ops, + pb_size max_buffer_size, + pb_size max_cpu_total_size); struct pb_manager * diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c deleted file mode 100644 index 97dd1427fd..0000000000 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c +++ /dev/null @@ -1,152 +0,0 @@ -/************************************************************************** - * - * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA - * All Rights Reserved. - * - * 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, sub license, 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 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 NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ - -/** - * \file - * A buffer manager that wraps buffers in fenced buffers. - * - * \author Jose Fonseca - */ - - -#include "util/u_debug.h" -#include "util/u_memory.h" - -#include "pb_buffer.h" -#include "pb_buffer_fenced.h" -#include "pb_bufmgr.h" - - -struct fenced_pb_manager -{ - struct pb_manager base; - - struct pb_manager *provider; - - struct fenced_buffer_list *fenced_list; -}; - - -static INLINE struct fenced_pb_manager * -fenced_pb_manager(struct pb_manager *mgr) -{ - assert(mgr); - return (struct fenced_pb_manager *)mgr; -} - - -static struct pb_buffer * -fenced_bufmgr_create_buffer(struct pb_manager *mgr, - pb_size size, - const struct pb_desc *desc) -{ - struct fenced_pb_manager *fenced_mgr = fenced_pb_manager(mgr); - struct pb_buffer *buf; - struct pb_buffer *fenced_buf; - - /* check for free buffers before allocating new ones */ - fenced_buffer_list_check_free(fenced_mgr->fenced_list, 0); - - buf = fenced_mgr->provider->create_buffer(fenced_mgr->provider, size, desc); - if(!buf) { - /* try harder to get a buffer */ - fenced_buffer_list_check_free(fenced_mgr->fenced_list, 1); - - buf = fenced_mgr->provider->create_buffer(fenced_mgr->provider, size, desc); - if(!buf) { -#if 0 - fenced_buffer_list_dump(fenced_mgr->fenced_list); -#endif - - /* give up */ - return NULL; - } - } - - fenced_buf = fenced_buffer_create(fenced_mgr->fenced_list, buf); - if(!fenced_buf) { - pb_reference(&buf, NULL); - } - - return fenced_buf; -} - - -static void -fenced_bufmgr_flush(struct pb_manager *mgr) -{ - struct fenced_pb_manager *fenced_mgr = fenced_pb_manager(mgr); - - fenced_buffer_list_check_free(fenced_mgr->fenced_list, TRUE); - - assert(fenced_mgr->provider->flush); - if(fenced_mgr->provider->flush) - fenced_mgr->provider->flush(fenced_mgr->provider); -} - - -static void -fenced_bufmgr_destroy(struct pb_manager *mgr) -{ - struct fenced_pb_manager *fenced_mgr = fenced_pb_manager(mgr); - - fenced_buffer_list_destroy(fenced_mgr->fenced_list); - - if(fenced_mgr->provider) - fenced_mgr->provider->destroy(fenced_mgr->provider); - - FREE(fenced_mgr); -} - - -struct pb_manager * -fenced_bufmgr_create(struct pb_manager *provider, - struct pb_fence_ops *ops) -{ - struct fenced_pb_manager *fenced_mgr; - - if(!provider) - return NULL; - - fenced_mgr = CALLOC_STRUCT(fenced_pb_manager); - if (!fenced_mgr) - return NULL; - - fenced_mgr->base.destroy = fenced_bufmgr_destroy; - fenced_mgr->base.create_buffer = fenced_bufmgr_create_buffer; - fenced_mgr->base.flush = fenced_bufmgr_flush; - - fenced_mgr->provider = provider; - fenced_mgr->fenced_list = fenced_buffer_list_create(ops); - if(!fenced_mgr->fenced_list) { - FREE(fenced_mgr); - return NULL; - } - - return &fenced_mgr->base; -} -- cgit v1.2.3 From c4ceba114161c029ecd2812eb075654b4411b59c Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 21 Jan 2010 12:43:40 -0800 Subject: pipebuffer: Release the lock during map wait. Cleanups. --- .../auxiliary/pipebuffer/pb_buffer_fenced.c | 194 ++++++++++++++------- 1 file changed, 131 insertions(+), 63 deletions(-) diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c index 600b236921..ba087ac0f3 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c @@ -169,7 +169,8 @@ static void fenced_buffer_destroy_cpu_storage_locked(struct fenced_buffer *fenced_buf); static enum pipe_error -fenced_buffer_create_cpu_storage_locked(struct fenced_buffer *fenced_buf); +fenced_buffer_create_cpu_storage_locked(struct fenced_manager *fenced_mgr, + struct fenced_buffer *fenced_buf); static void fenced_buffer_destroy_gpu_storage_locked(struct fenced_buffer *fenced_buf); @@ -199,18 +200,19 @@ fenced_manager_dump_locked(struct fenced_manager *fenced_mgr) struct list_head *curr, *next; struct fenced_buffer *fenced_buf; - debug_printf("%10s %7s %7s %10s %s\n", - "buffer", "size", "refcount", "fence", "signalled"); + debug_printf("%10s %7s %8s %7s %10s %s\n", + "buffer", "size", "refcount", "storage", "fence", "signalled"); curr = fenced_mgr->unfenced.next; next = curr->next; while(curr != &fenced_mgr->unfenced) { fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); assert(!fenced_buf->fence); - debug_printf("%10p %7u %7u\n", + debug_printf("%10p %7u %8u %7s\n", (void *) fenced_buf, fenced_buf->base.base.size, - p_atomic_read(&fenced_buf->base.base.reference.count)); + p_atomic_read(&fenced_buf->base.base.reference.count), + fenced_buf->buffer ? "gpu" : (fenced_buf->data ? "cpu" : "none")); curr = next; next = curr->next; } @@ -220,11 +222,13 @@ fenced_manager_dump_locked(struct fenced_manager *fenced_mgr) while(curr != &fenced_mgr->fenced) { int signaled; fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); + assert(fenced_buf->buffer); signaled = ops->fence_signalled(ops, fenced_buf->fence, 0); - debug_printf("%10p %7u %7u %10p %s\n", + debug_printf("%10p %7u %8u %7s %10p %s\n", (void *) fenced_buf, fenced_buf->base.base.size, p_atomic_read(&fenced_buf->base.base.reference.count), + "gpu", (void *) fenced_buf->fence, signaled == 0 ? "y" : "n"); curr = next; @@ -236,6 +240,26 @@ fenced_manager_dump_locked(struct fenced_manager *fenced_mgr) } +static INLINE void +fenced_buffer_destroy_locked(struct fenced_manager *fenced_mgr, + struct fenced_buffer *fenced_buf) +{ + assert(!pipe_is_referenced(&fenced_buf->base.base.reference)); + + assert(!fenced_buf->fence); + assert(fenced_buf->head.prev); + assert(fenced_buf->head.next); + LIST_DEL(&fenced_buf->head); + assert(fenced_mgr->num_unfenced); + --fenced_mgr->num_unfenced; + + fenced_buffer_destroy_gpu_storage_locked(fenced_buf); + fenced_buffer_destroy_cpu_storage_locked(fenced_buf); + + FREE(fenced_buf); +} + + /** * Add the buffer to the fenced list. * @@ -249,7 +273,7 @@ fenced_buffer_add_locked(struct fenced_manager *fenced_mgr, assert(fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE); assert(fenced_buf->fence); - /* TODO: Move the reference count increment here */ + p_atomic_inc(&fenced_buf->base.base.reference.count); LIST_DEL(&fenced_buf->head); assert(fenced_mgr->num_unfenced); @@ -260,11 +284,12 @@ fenced_buffer_add_locked(struct fenced_manager *fenced_mgr, /** - * Remove the buffer from the fenced list. + * Remove the buffer from the fenced list, and potentially destroy the buffer + * if the reference count reaches zero. * - * Reference count should be decremented after calling this function. + * Returns TRUE if the buffer was detroyed. */ -static INLINE void +static INLINE boolean fenced_buffer_remove_locked(struct fenced_manager *fenced_mgr, struct fenced_buffer *fenced_buf) { @@ -286,16 +311,24 @@ fenced_buffer_remove_locked(struct fenced_manager *fenced_mgr, LIST_ADDTAIL(&fenced_buf->head, &fenced_mgr->unfenced); ++fenced_mgr->num_unfenced; - /* TODO: Move the reference count decrement and destruction here */ + if (p_atomic_dec_zero(&fenced_buf->base.base.reference.count)) { + fenced_buffer_destroy_locked(fenced_mgr, fenced_buf); + return TRUE; + } + + return FALSE; } /** * Wait for the fence to expire, and remove it from the fenced list. + * + * This function will release and re-aquire the mutex, so any copy of mutable + * state must be discarded after calling it. */ static INLINE enum pipe_error fenced_buffer_finish_locked(struct fenced_manager *fenced_mgr, - struct fenced_buffer *fenced_buf) + struct fenced_buffer *fenced_buf) { struct pb_fence_ops *ops = fenced_mgr->ops; enum pipe_error ret = PIPE_ERROR; @@ -308,16 +341,41 @@ fenced_buffer_finish_locked(struct fenced_manager *fenced_mgr, assert(fenced_buf->fence); if(fenced_buf->fence) { - if(ops->fence_finish(ops, fenced_buf->fence, 0) == 0) { + struct pipe_fence_handle *fence = NULL; + int finished; + boolean proceed; + + ops->fence_reference(ops, &fence, fenced_buf->fence); + + pipe_mutex_unlock(fenced_mgr->mutex); + + finished = ops->fence_finish(ops, fenced_buf->fence, 0); + + pipe_mutex_lock(fenced_mgr->mutex); + + assert(pipe_is_referenced(&fenced_buf->base.base.reference)); + + /* + * Only proceed if the fence object didn't change in the meanwhile. + * Otherwise assume the work has been already carried out by another + * thread that re-aquired the lock before us. + */ + proceed = fence == fenced_buf->fence ? TRUE : FALSE; + + ops->fence_reference(ops, &fence, NULL); + + if(proceed && finished == 0) { /* * Remove from the fenced list */ - fenced_buffer_remove_locked(fenced_mgr, fenced_buf); + + boolean destroyed; + + destroyed = fenced_buffer_remove_locked(fenced_mgr, fenced_buf); /* TODO: remove consequents buffers with the same fence? */ - p_atomic_dec(&fenced_buf->base.base.reference.count); - assert(pipe_is_referenced(&fenced_buf->base.base.reference)); + assert(!destroyed); fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE; @@ -380,8 +438,6 @@ fenced_manager_check_signalled_locked(struct fenced_manager *fenced_mgr, fenced_buffer_remove_locked(fenced_mgr, fenced_buf); - pb_reference((struct pb_buffer **)&fenced_buf, NULL); - ret = TRUE; curr = next; @@ -417,7 +473,7 @@ fenced_manager_free_gpu_storage_locked(struct fenced_manager *fenced_mgr) !fenced_buf->vl) { enum pipe_error ret; - ret = fenced_buffer_create_cpu_storage_locked(fenced_buf); + ret = fenced_buffer_create_cpu_storage_locked(fenced_mgr, fenced_buf); if(ret == PIPE_OK) { ret = fenced_buffer_copy_storage_to_cpu_locked(fenced_buf); if(ret == PIPE_OK) { @@ -445,6 +501,7 @@ fenced_buffer_destroy_cpu_storage_locked(struct fenced_buffer *fenced_buf) if(fenced_buf->data) { align_free(fenced_buf->data); fenced_buf->data = NULL; + assert(fenced_buf->mgr->cpu_total_size >= fenced_buf->size); fenced_buf->mgr->cpu_total_size -= fenced_buf->size; } } @@ -454,20 +511,21 @@ fenced_buffer_destroy_cpu_storage_locked(struct fenced_buffer *fenced_buf) * Create CPU storage for this buffer. */ static enum pipe_error -fenced_buffer_create_cpu_storage_locked(struct fenced_buffer *fenced_buf) +fenced_buffer_create_cpu_storage_locked(struct fenced_manager *fenced_mgr, + struct fenced_buffer *fenced_buf) { assert(!fenced_buf->data); if(fenced_buf->data) return PIPE_OK; + if (fenced_mgr->cpu_total_size + fenced_buf->size > fenced_mgr->max_cpu_total_size) + return PIPE_ERROR_OUT_OF_MEMORY; + fenced_buf->data = align_malloc(fenced_buf->size, fenced_buf->desc.alignment); if(!fenced_buf->data) return PIPE_ERROR_OUT_OF_MEMORY; - fenced_buf->mgr->cpu_total_size += fenced_buf->size; - debug_printf("%s: cpu_total_size = %lu\n", - __FUNCTION__, - (unsigned long)fenced_buf->mgr->cpu_total_size); + fenced_mgr->cpu_total_size += fenced_buf->size; return PIPE_OK; } @@ -608,19 +666,9 @@ fenced_buffer_destroy(struct pb_buffer *buf) pipe_mutex_lock(fenced_mgr->mutex); - assert(!fenced_buf->fence); - assert(fenced_buf->head.prev); - assert(fenced_buf->head.next); - LIST_DEL(&fenced_buf->head); - assert(fenced_mgr->num_unfenced); - --fenced_mgr->num_unfenced; - - fenced_buffer_destroy_gpu_storage_locked(fenced_buf); - fenced_buffer_destroy_cpu_storage_locked(fenced_buf); + fenced_buffer_destroy_locked(fenced_mgr, fenced_buf); pipe_mutex_unlock(fenced_mgr->mutex); - - FREE(fenced_buf); } @@ -637,17 +685,29 @@ fenced_buffer_map(struct pb_buffer *buf, assert(!(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE)); - /* Serialize writes */ - if((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_WRITE) || - ((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ) && (flags & PIPE_BUFFER_USAGE_CPU_WRITE))) { + /* + * Serialize writes. + */ + while((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_WRITE) || + ((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ) && + (flags & PIPE_BUFFER_USAGE_CPU_WRITE))) { + /* + * Don't wait for the GPU to finish accessing it, if blocking is forbidden. + */ if((flags & PIPE_BUFFER_USAGE_DONTBLOCK) && ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) { - /* Don't wait for the GPU to finish writing */ goto done; } - /* Wait for the GPU to finish writing */ + if (flags & PIPE_BUFFER_USAGE_UNSYNCHRONIZED) { + break; + } + + /* + * Wait for the GPU to finish accessing. This will release and re-acquire + * the mutex, so all copies of mutable state must be discarded. + */ fenced_buffer_finish_locked(fenced_mgr, fenced_buf); } @@ -785,14 +845,13 @@ fenced_buffer_fence(struct pb_buffer *buf, assert(fenced_buf->validation_flags); if (fenced_buf->fence) { - fenced_buffer_remove_locked(fenced_mgr, fenced_buf); - p_atomic_dec(&fenced_buf->base.base.reference.count); - assert(pipe_is_referenced(&fenced_buf->base.base.reference)); + boolean destroyed; + destroyed = fenced_buffer_remove_locked(fenced_mgr, fenced_buf); + assert(!destroyed); } if (fence) { ops->fence_reference(ops, &fenced_buf->fence, fence); fenced_buf->flags |= fenced_buf->validation_flags; - p_atomic_inc(&fenced_buf->base.base.reference.count); fenced_buffer_add_locked(fenced_mgr, fenced_buf); } @@ -857,6 +916,15 @@ fenced_bufmgr_create_buffer(struct pb_manager *mgr, struct fenced_buffer *fenced_buf; enum pipe_error ret; + /* + * Don't stall the GPU, waste time evicting buffers, or waste memory + * trying to create a buffer that will most likely never fit into the + * graphics aperture. + */ + if(size > fenced_mgr->max_buffer_size) { + goto no_buffer; + } + fenced_buf = CALLOC_STRUCT(fenced_buffer); if(!fenced_buf) goto no_buffer; @@ -876,27 +944,27 @@ fenced_bufmgr_create_buffer(struct pb_manager *mgr, /* * Try to create GPU storage without stalling, */ - ret = fenced_buffer_create_gpu_storage_locked(fenced_mgr, fenced_buf, 0); + ret = fenced_buffer_create_gpu_storage_locked(fenced_mgr, fenced_buf, FALSE); + + /* + * Attempt to use CPU memory to avoid stalling the GPU. + */ if(ret != PIPE_OK) { - /* - * Don't stall the GPU or waste memory trying to create a buffer that will - * most likely never fit into the graphics aperture. - */ - if(size > fenced_mgr->max_buffer_size) { - goto no_storage; - } + ret = fenced_buffer_create_cpu_storage_locked(fenced_mgr, fenced_buf); + } - if(fenced_mgr->cpu_total_size + size <= fenced_mgr->max_cpu_total_size) { - /* Use CPU memory to avoid stalling the GPU */ - ret = fenced_buffer_create_cpu_storage_locked(fenced_buf); - } - else { - /* Create GPU storage, waiting for some to be available */ - ret = fenced_buffer_create_gpu_storage_locked(fenced_mgr, fenced_buf, 1); - } - if(ret != PIPE_OK) { - goto no_storage; - } + /* + * Create GPU storage, waiting for some to be available. + */ + if(ret != PIPE_OK) { + ret = fenced_buffer_create_gpu_storage_locked(fenced_mgr, fenced_buf, TRUE); + } + + /* + * Give up. + */ + if(ret != PIPE_OK) { + goto no_storage; } assert(fenced_buf->buffer || fenced_buf->data); -- cgit v1.2.3 From 9782d7cdf39c141d816efc48333d6a70ed3f2ac6 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 20 Jan 2010 03:45:17 -0800 Subject: svga: Don't swap buffers to system memory -- winsys' responsibility. --- src/gallium/drivers/svga/svga_screen_buffer.c | 60 --------------------------- src/gallium/drivers/svga/svga_screen_buffer.h | 3 -- 2 files changed, 63 deletions(-) diff --git a/src/gallium/drivers/svga/svga_screen_buffer.c b/src/gallium/drivers/svga/svga_screen_buffer.c index cc2d3cd9e9..fa1fd1367e 100644 --- a/src/gallium/drivers/svga/svga_screen_buffer.c +++ b/src/gallium/drivers/svga/svga_screen_buffer.c @@ -121,60 +121,6 @@ svga_buffer_destroy_hw_storage(struct svga_screen *ss, struct svga_buffer *sbuf) } } -static INLINE enum pipe_error -svga_buffer_backup(struct svga_screen *ss, struct svga_buffer *sbuf) -{ - if (sbuf->hw.buf && sbuf->hw.num_ranges) { - void *src; - - if (!sbuf->swbuf) - sbuf->swbuf = align_malloc(sbuf->base.size, sbuf->base.alignment); - if (!sbuf->swbuf) - return PIPE_ERROR_OUT_OF_MEMORY; - - src = ss->sws->buffer_map(ss->sws, sbuf->hw.buf, - PIPE_BUFFER_USAGE_CPU_READ); - if (!src) - return PIPE_ERROR; - - memcpy(sbuf->swbuf, src, sbuf->base.size); - ss->sws->buffer_unmap(ss->sws, sbuf->hw.buf); - } - - return PIPE_OK; -} - -/** - * Try to make GMR space available by freeing the hardware storage of - * unmapped - */ -boolean -svga_buffer_free_cached_hw_storage(struct svga_screen *ss) -{ - struct list_head *curr; - struct svga_buffer *sbuf; - enum pipe_error ret = PIPE_OK; - - curr = ss->cached_buffers.prev; - - /* free the least recently used buffer's hw storage which is not mapped */ - do { - if(curr == &ss->cached_buffers) - return FALSE; - - sbuf = LIST_ENTRY(struct svga_buffer, curr, head); - - curr = curr->prev; - if (sbuf->map.count == 0) - ret = svga_buffer_backup(ss, sbuf); - - } while(sbuf->map.count != 0 || ret != PIPE_OK); - - svga_buffer_destroy_hw_storage(ss, sbuf); - - return TRUE; -} - struct svga_winsys_buffer * svga_winsys_buffer_create( struct svga_screen *ss, unsigned alignment, @@ -195,12 +141,6 @@ svga_winsys_buffer_create( struct svga_screen *ss, svga_screen_flush(ss, NULL); buf = sws->buffer_create(sws, alignment, usage, size); - SVGA_DBG(DEBUG_DMA|DEBUG_PERF, "evicting buffers to find %d bytes GMR\n", - size); - - /* Try evicing all buffer storage */ - while(!buf && svga_buffer_free_cached_hw_storage(ss)) - buf = sws->buffer_create(sws, alignment, usage, size); } return buf; diff --git a/src/gallium/drivers/svga/svga_screen_buffer.h b/src/gallium/drivers/svga/svga_screen_buffer.h index c9bbe37f32..448ac107c7 100644 --- a/src/gallium/drivers/svga/svga_screen_buffer.h +++ b/src/gallium/drivers/svga/svga_screen_buffer.h @@ -183,9 +183,6 @@ svga_buffer_handle(struct svga_context *svga, void svga_context_flush_buffers(struct svga_context *svga); -boolean -svga_buffer_free_cached_hw_storage(struct svga_screen *ss); - struct svga_winsys_buffer * svga_winsys_buffer_create(struct svga_screen *ss, unsigned alignment, -- cgit v1.2.3 From 50edefec2dd5ec2990ab2cd699478139173d5fd2 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 21 Jan 2010 14:24:53 -0800 Subject: svga: Remove unused code. --- src/gallium/drivers/svga/svga_screen.c | 2 -- src/gallium/drivers/svga/svga_screen.h | 6 ------ src/gallium/drivers/svga/svga_screen_buffer.c | 26 ++++---------------------- 3 files changed, 4 insertions(+), 30 deletions(-) diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index 68c09e80af..cd1ed7bac8 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -391,8 +391,6 @@ svga_screen_create(struct svga_winsys_screen *sws) pipe_mutex_init(svgascreen->tex_mutex); pipe_mutex_init(svgascreen->swc_mutex); - LIST_INITHEAD(&svgascreen->cached_buffers); - svga_screen_cache_init(svgascreen); return screen; diff --git a/src/gallium/drivers/svga/svga_screen.h b/src/gallium/drivers/svga/svga_screen.h index b94ca7fc1c..a009b60720 100644 --- a/src/gallium/drivers/svga/svga_screen.h +++ b/src/gallium/drivers/svga/svga_screen.h @@ -68,12 +68,6 @@ struct svga_screen pipe_mutex tex_mutex; pipe_mutex swc_mutex; /* Protects the use of swc and dirty_buffers */ - /** - * List of buffers with cached GMR. Ordered from the most recently used to - * the least recently used - */ - struct list_head cached_buffers; - struct svga_host_surface_cache cache; }; diff --git a/src/gallium/drivers/svga/svga_screen_buffer.c b/src/gallium/drivers/svga/svga_screen_buffer.c index fa1fd1367e..cc4109dfe8 100644 --- a/src/gallium/drivers/svga/svga_screen_buffer.c +++ b/src/gallium/drivers/svga/svga_screen_buffer.c @@ -113,11 +113,6 @@ svga_buffer_destroy_hw_storage(struct svga_screen *ss, struct svga_buffer *sbuf) if(sbuf->hw.buf) { sws->buffer_destroy(sws, sbuf->hw.buf); sbuf->hw.buf = NULL; - assert(sbuf->head.prev && sbuf->head.next); - LIST_DEL(&sbuf->head); -#ifdef DEBUG - sbuf->head.next = sbuf->head.prev = NULL; -#endif } } @@ -166,8 +161,6 @@ svga_buffer_create_hw_storage(struct svga_screen *ss, return PIPE_ERROR_OUT_OF_MEMORY; assert(!sbuf->needs_flush); - assert(!sbuf->head.prev && !sbuf->head.next); - LIST_ADD(&sbuf->head, &ss->cached_buffers); } return PIPE_OK; @@ -288,9 +281,10 @@ svga_buffer_upload_flush(struct svga_context *svga, assert(sbuf->head.prev && sbuf->head.next); LIST_DEL(&sbuf->head); +#ifdef DEBUG + sbuf->head.next = sbuf->head.prev = NULL; +#endif sbuf->needs_flush = FALSE; - /* XXX: do we care about cached_buffers any more ?*/ - LIST_ADD(&sbuf->head, &ss->cached_buffers); sbuf->hw.svga = NULL; sbuf->hw.boxes = NULL; @@ -419,17 +413,6 @@ svga_buffer_map_range( struct pipe_screen *screen, sws->fence_reference(sws, &fence, NULL); } } - else { - if(!(usage & PIPE_BUFFER_USAGE_DISCARD) && !sbuf->needs_flush) { - /* We already had the hardware storage but we would have to issue - * a download if we hadn't, so move the buffer to the begginning - * of the LRU list. - */ - assert(sbuf->head.prev && sbuf->head.next); - LIST_DEL(&sbuf->head); - LIST_ADD(&sbuf->head, &ss->cached_buffers); - } - } map = sws->buffer_map(sws, sbuf->hw.buf, usage); } @@ -699,8 +682,7 @@ svga_buffer_handle(struct svga_context *svga, assert(sbuf->hw.svga == svga); sbuf->needs_flush = TRUE; - assert(sbuf->head.prev && sbuf->head.next); - LIST_DEL(&sbuf->head); + assert(!sbuf->head.prev && !sbuf->head.next); LIST_ADDTAIL(&sbuf->head, &svga->dirty_buffers); } -- cgit v1.2.3 From 31e49dc54ee2d8b2c50ed1d19ab973f72a60f8d8 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 21 Jan 2010 12:12:47 -0800 Subject: svga: Remove duplicate code. --- src/gallium/drivers/svga/svga_screen_buffer.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/svga/svga_screen_buffer.c b/src/gallium/drivers/svga/svga_screen_buffer.c index cc4109dfe8..727fd180c1 100644 --- a/src/gallium/drivers/svga/svga_screen_buffer.c +++ b/src/gallium/drivers/svga/svga_screen_buffer.c @@ -496,10 +496,8 @@ svga_buffer_destroy( struct pipe_buffer *buf ) assert(!sbuf->needs_flush); - if(sbuf->handle) { - SVGA_DBG(DEBUG_DMA, "release sid %p sz %d\n", sbuf->handle, sbuf->base.size); - svga_screen_surface_destroy(ss, &sbuf->key, &sbuf->handle); - } + if(sbuf->handle) + svga_buffer_destroy_host_surface(ss, sbuf); if(sbuf->hw.buf) svga_buffer_destroy_hw_storage(ss, sbuf); -- cgit v1.2.3 From e45579e50ba3b9736465f68377b3f5d0afb7c1da Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 21 Jan 2010 15:27:26 -0800 Subject: vmw/wgl: Update for pipebuffer changes. This is a minimum change to keep things building and running minimally -- it might cause applications to fail to allocate buffers due to out of GMR memory. A proper update will be commited later. --- src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c index b1c24b0cb6..542746b2a3 100644 --- a/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c +++ b/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c @@ -60,7 +60,9 @@ vmw_pools_init(struct vmw_winsys_screen *vws) vws->pools.gmr_fenced = fenced_bufmgr_create( vws->pools.gmr_mm, - vmw_fence_ops_create(vws)); + vmw_fence_ops_create(vws), + 0, + 0); #ifdef DEBUG vws->pools.gmr_fenced = pb_debug_manager_create(vws->pools.gmr_fenced, -- cgit v1.2.3 From beb8e8f2f2de0c1221090554159129665a79a292 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 21 Jan 2010 15:47:52 -0800 Subject: vmware/core: Put GMR pool size in a define. --- src/gallium/winsys/drm/vmware/core/vmw_screen.h | 4 ++++ src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen.h b/src/gallium/winsys/drm/vmware/core/vmw_screen.h index a875107370..f1d69865e7 100644 --- a/src/gallium/winsys/drm/vmware/core/vmw_screen.h +++ b/src/gallium/winsys/drm/vmware/core/vmw_screen.h @@ -40,6 +40,10 @@ #include "svga_winsys.h" + +#define VMW_GMR_POOL_SIZE (16*1024*1024) + + struct pb_manager; struct vmw_region; diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c index 542746b2a3..78cfa78691 100644 --- a/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c +++ b/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c @@ -53,7 +53,7 @@ vmw_pools_init(struct vmw_winsys_screen *vws) goto error; vws->pools.gmr_mm = mm_bufmgr_create(vws->pools.gmr, - 16*1024*1024, + VMW_GMR_POOL_SIZE, 12 /* 4096 alignment */); if(!vws->pools.gmr_mm) goto error; -- cgit v1.2.3 From a626565178fb810f439fbdfdaf6cc28a973a6a81 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 21 Jan 2010 15:51:37 -0800 Subject: vmware/core: Flush preemptively the FIFO commands to keep the GMR working set within reasonable bounds. --- src/gallium/winsys/drm/vmware/core/vmw_context.c | 38 +++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/gallium/winsys/drm/vmware/core/vmw_context.c b/src/gallium/winsys/drm/vmware/core/vmw_context.c index b6997588de..87a3df923f 100644 --- a/src/gallium/winsys/drm/vmware/core/vmw_context.c +++ b/src/gallium/winsys/drm/vmware/core/vmw_context.c @@ -73,6 +73,19 @@ struct vmw_svga_winsys_context struct pb_validate *validate; uint32_t last_fence; + + /** + * The amount of GMR that is referred by the commands currently batched + * in the context. + */ + uint32_t seen_regions; + + /** + * Whether this context should fail to reserve more commands, not because it + * ran out of command space, but because a substantial ammount of GMR was + * referred. + */ + boolean preemptive_flush; }; @@ -124,6 +137,8 @@ vmw_swc_flush(struct svga_winsys_context *swc, #ifdef DEBUG vswc->must_flush = FALSE; #endif + vswc->preemptive_flush = FALSE; + vswc->seen_regions = 0; if(pfence) *pfence = fence; @@ -151,7 +166,8 @@ vmw_swc_reserve(struct svga_winsys_context *swc, if(nr_bytes > vswc->command.size) return NULL; - if(vswc->command.used + nr_bytes > vswc->command.size || + if(vswc->preemptive_flush || + vswc->command.used + nr_bytes > vswc->command.size || vswc->surface.used + nr_relocs > vswc->surface.size) { #ifdef DEBUG vswc->must_flush = TRUE; @@ -220,6 +236,26 @@ vmw_swc_region_relocation(struct svga_winsys_context *swc, ret = pb_validate_add_buffer(vswc->validate, buf, flags); /* TODO: Update pipebuffer to reserve buffers and not fail here */ assert(ret == PIPE_OK); + + /* + * Flush preemptively the FIFO commands to keep the GMR working set within + * the GMR pool size. + * + * This is necessary for applications like SPECviewperf that generate huge + * amounts of immediate vertex data, so that we don't pile up too much of + * that vertex data neither in the guest nor in the host. + * + * Note that in the current implementation if a region is referred twice in + * a command stream, it will be accounted twice. We could detect repeated + * regions and count only once, but there is no incentive to do that, since + * regions are typically short-lived; always referred in a single command; + * and at the worst we just flush the commands a bit sooner, which for the + * SVGA virtual device it's not a performance issue since flushing commands + * to the FIFO won't cause flushing in the host. + */ + vswc->seen_regions += buf->base.size; + if(vswc->seen_regions >= VMW_GMR_POOL_SIZE/2) + vswc->preemptive_flush = TRUE; } -- cgit v1.2.3 From f8107a45ce92a7b0aedc2ae562ca609308b096a8 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Thu, 21 Jan 2010 16:42:58 -0800 Subject: Fix typo in configure message for gcc -fvisibility=hidden Need to use $CC for a shell variable, not $(CC) for a make variable which the shell interprets as running the command "CC". Signed-off-by: Alan Coopersmith --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 6ae526d5e1..619ed47bcb 100644 --- a/configure.ac +++ b/configure.ac @@ -100,7 +100,7 @@ if test "x$GCC" = xyes; then # Enable -fvisibility=hidden if using a gcc that supports it save_CFLAGS="$CFLAGS" - AC_MSG_CHECKING([whether $(CC) supports -fvisibility=hidden]) + AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden]) CFLAGS="$CFLAGS -fvisibility=hidden" AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]), [CFLAGS="$save_CFLAGS" ; AC_MSG_RESULT([no])]); -- cgit v1.2.3 From e8b5203fbb7657980a4ba421e14d656b42d2a35f Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 21 Jan 2010 17:24:07 -0800 Subject: svga: Remove unused variable. --- src/gallium/drivers/svga/svga_screen_buffer.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gallium/drivers/svga/svga_screen_buffer.c b/src/gallium/drivers/svga/svga_screen_buffer.c index 727fd180c1..719adde27e 100644 --- a/src/gallium/drivers/svga/svga_screen_buffer.c +++ b/src/gallium/drivers/svga/svga_screen_buffer.c @@ -244,7 +244,6 @@ static void svga_buffer_upload_flush(struct svga_context *svga, struct svga_buffer *sbuf) { - struct svga_screen *ss = svga_screen(svga->pipe.screen); SVGA3dCopyBox *boxes; unsigned i; -- cgit v1.2.3 From 883b57e66c8adc800d56080706c04cda4ffede11 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 Jan 2010 11:11:48 +0800 Subject: winsys/drm: Update Makefile.template. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mainly to respect LDFLAGS and remove unused target $(LIBNAME_EGL). This is based on the patch by Tomáš Chvátal . --- src/gallium/winsys/drm/Makefile.template | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/gallium/winsys/drm/Makefile.template b/src/gallium/winsys/drm/Makefile.template index 9635c3c50e..960353a73d 100644 --- a/src/gallium/winsys/drm/Makefile.template +++ b/src/gallium/winsys/drm/Makefile.template @@ -82,18 +82,11 @@ SHARED_INCLUDES = \ default: depend symlinks $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME) $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) $(WINOBJ) Makefile $(TOP)/src/mesa/drivers/dri/Makefile.template - $(MKLIB) -noprefix -o $@ \ + $(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ $(OBJECTS) $(PIPE_DRIVERS) \ -Wl,--start-group $(MESA_MODULES) -Wl,--end-group \ $(WINOBJ) $(DRI_LIB_DEPS) $(DRIVER_EXTRAS) -$(LIBNAME_EGL): $(WINSYS_OBJECTS) $(LIBS) - $(MKLIB) -o $(LIBNAME_EGL) \ - -linker "$(CC)" \ - -noprefix \ - $(OBJECTS) $(MKLIB_OPTIONS) $(WINSYS_OBJECTS) $(PIPE_DRIVERS) $(WINOBJ) $(DRI_LIB_DEPS) \ - --whole-archive $(LIBS) $(GALLIUM_AUXILIARIES) --no-whole-archive $(DRIVER_EXTRAS) - $(TOP)/$(LIB_DIR)/gallium: mkdir -p $@ -- cgit v1.2.3 From e63272050f5775a28ab699c804a34f33940a900d Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 Jan 2010 12:02:00 +0800 Subject: egl: Add Makefile.template for EGL drivers. --- src/egl/drivers/Makefile.template | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/egl/drivers/Makefile.template diff --git a/src/egl/drivers/Makefile.template b/src/egl/drivers/Makefile.template new file mode 100644 index 0000000000..02a65b094a --- /dev/null +++ b/src/egl/drivers/Makefile.template @@ -0,0 +1,51 @@ +# src/egl/drivers/Makefile.template +# +# Drivers should define +# +# EGL_DRIVER, the driver name +# EGL_SOURCES, the driver sources +# EGL_INCLUDES, the include pathes +# EGL_CFLAGS, additional CFLAGS +# EGL_LIBS, additional LIBS +# +# before including this template. +# + + +EGL_DRIVER_PATH = $(TOP)/$(LIB_DIR)/$(EGL_DRIVER) +EGL_OBJECTS = $(EGL_SOURCES:.c=.o) + + +default: depend $(EGL_DRIVER_PATH) + +$(EGL_DRIVER_PATH): $(EGL_DRIVER) + $(INSTALL) $< $(TOP)/$(LIB_DIR) + +$(EGL_DRIVER): $(EGL_OBJECTS) Makefile $(TOP)/src/egl/drivers/Makefile.template + @$(MKLIB) -o $(EGL_DRIVER) -noprefix \ + -linker '$(CC)' -ldflags '$(LDFLAGS)' \ + -L$(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \ + $(EGL_OBJECTS) $(EGL_LIBS) + +.c.o: + $(CC) -c $(EGL_INCLUDES) $(CFLAGS) $(EGL_CFLAGS) $< -o $@ + + +install: $(EGL_DRIVER_PATH) + $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) + $(MINSTALL) $(EGL_DRIVER_PATH) $(DESTDIR)$(INSTALL_LIB_DIR) + +clean: + rm -f $(EGL_DRIVER) + rm -f $(EGL_OBJECTS) + rm -f depend depend.bak + +depend: $(EGL_SOURCES) + @ echo "running $(MKDEP)" + @ rm -f depend + @ touch depend + $(MKDEP) $(MKDEP_OPTIONS) $(EGL_INCLUDES) $(EGL_SOURCES) \ + >/dev/null 2>/dev/null + +sinclude depend +# DO NOT DELETE -- cgit v1.2.3 From 2279fa3c065bcc2dcc02d462668792138f7d2e7b Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 Jan 2010 13:29:10 +0800 Subject: egl: Update driver Makefiles. Update to use the new Makefile.template. --- src/egl/drivers/glx/Makefile | 75 ++++----------------------------------- src/egl/drivers/xdri/Makefile | 82 +++++++++---------------------------------- 2 files changed, 23 insertions(+), 134 deletions(-) diff --git a/src/egl/drivers/glx/Makefile b/src/egl/drivers/glx/Makefile index 20ef0352ad..634638f538 100644 --- a/src/egl/drivers/glx/Makefile +++ b/src/egl/drivers/glx/Makefile @@ -1,77 +1,16 @@ # src/egl/drivers/glx/Makefile -# Build XEGL DRI driver loader library: egl_glx.so - - TOP = ../../../.. include $(TOP)/configs/current +EGL_DRIVER = egl_glx.so +EGL_SOURCES = egl_glx.c -EXTRA_DEFINES = -DDEFAULT_DRIVER_DIR=\"$(DRI_DRIVER_SEARCH_DIR)\" - -DRIVER_NAME = egl_glx.so - - -INCLUDE_DIRS = \ - -I. \ - -I/usr/include \ - $(shell pkg-config --cflags-only-I libdrm) \ +EGL_INCLUDES = \ -I$(TOP)/include \ - -I$(TOP)/include/GL/internal \ - -I$(TOP)/src/mesa/glapi \ - -I$(TOP)/src/mesa/drivers/dri/common \ - -I$(TOP)/src/mesa/main \ - -I$(TOP)/src/mesa \ - -I$(TOP)/src/egl/main \ - -I$(TOP)/src/glx/x11 - -SOURCES = egl_glx.c - -OBJECTS = $(SOURCES:.c=.o) - -DRM_LIB = `pkg-config --libs libdrm` - -MISC_LIBS = -ldl -lXext -lGL - - -.c.o: - $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $(EXTRA_DEFINES) $< -o $@ - - -.PHONY: library - - -default: depend library Makefile - - -library: $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) - - -# Make the egl_glx.so library -$(TOP)/$(LIB_DIR)/$(DRIVER_NAME): $(OBJECTS) - $(TOP)/bin/mklib -o $(DRIVER_NAME) \ - -noprefix \ - -major 1 -minor 0 \ - -L$(TOP)/$(LIB_DIR) \ - -install $(TOP)/$(LIB_DIR) \ - $(OBJECTS) $(DRM_LIB) $(MISC_LIBS) - -install: - $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) - $(MINSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(DESTDIR)$(INSTALL_LIB_DIR) - -clean: - rm -f *.o - rm -f *.so - rm -f depend depend.bak - + -I$(TOP)/src/egl/main -depend: $(SOURCES) $(HEADERS) - @ echo "running $(MKDEP)" - @ rm -f depend - @ touch depend - $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) \ - $(SOURCES) $(HEADERS) >/dev/null 2>/dev/null +EGL_CFLAGS = +EGL_LIBS = -lX11 -lGL -include depend -# DO NOT DELETE +include ../Makefile.template diff --git a/src/egl/drivers/xdri/Makefile b/src/egl/drivers/xdri/Makefile index 4c1fc9071c..8e748b71cd 100644 --- a/src/egl/drivers/xdri/Makefile +++ b/src/egl/drivers/xdri/Makefile @@ -1,78 +1,28 @@ # src/egl/drivers/xdri/Makefile -# Build XEGL DRI driver loader library: egl_xdri.so - - TOP = ../../../.. include $(TOP)/configs/current +EGL_DRIVER = egl_xdri.so -DRIVER_NAME = egl_xdri.so - - -INCLUDE_DIRS = \ - -I. \ - -I/usr/include \ +# steal sources from GLX +GLX_SOURCES = dri_common.c XF86dri.c dri2.c dri2_glx.c dri_glx.c +GLX_SOURCES := $(addprefix ../../../glx/x11/,$(GLX_SOURCES)) +GLX_INCLUDES = \ $(shell pkg-config --cflags-only-I libdrm) \ - -I$(TOP)/include \ -I$(TOP)/include/GL/internal \ - -I$(TOP)/src/mesa \ + -I$(TOP)/src/glx/x11 \ -I$(TOP)/src/mesa/glapi \ - -I$(TOP)/src/egl/main \ - -I$(TOP)/src/glx/x11 - -HEADERS = glxinit.h driinit.h -SOURCES = egl_xdri.c glxinit.c driinit.c - -DRI_SOURCES = dri_common.c XF86dri.c dri2.c dri2_glx.c dri_glx.c -DRI_SOURCES := $(addprefix ../../../glx/x11/,$(DRI_SOURCES)) - -SOURCES += $(DRI_SOURCES) - -OBJECTS = $(SOURCES:.c=.o) - -DRM_LIB = `pkg-config --libs libdrm` - -CFLAGS += -DGLX_DIRECT_RENDERING - -.c.o: - $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ - - -.PHONY: library - - -default: depend library Makefile - - -library: $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) - - -# Make the egl_xdri.so library -$(TOP)/$(LIB_DIR)/$(DRIVER_NAME): $(OBJECTS) - $(TOP)/bin/mklib -o $(DRIVER_NAME) \ - -noprefix \ - -major 1 -minor 0 \ - -L$(TOP)/$(LIB_DIR) \ - -install $(TOP)/$(LIB_DIR) \ - $(OBJECTS) $(DRM_LIB) $(GL_LIB_DEPS) - -install: - $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) - $(MINSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(DESTDIR)$(INSTALL_LIB_DIR) - -clean: - rm -f *.o - rm -f *.so - rm -f depend depend.bak + -I$(TOP)/src/mesa +GLX_CFLAGS = -DGLX_DIRECT_RENDERING +EGL_SOURCES = egl_xdri.c glxinit.c driinit.c $(GLX_SOURCES) +EGL_INCLUDES = \ + -I$(TOP)/include \ + -I$(TOP)/src/egl/main \ + $(GLX_INCLUDES) -depend: $(SOURCES) $(HEADERS) - @ echo "running $(MKDEP)" - @ rm -f depend - @ touch depend - $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) \ - $(SOURCES) $(HEADERS) >/dev/null 2>/dev/null +EGL_CFLAGS = $(GLX_CFLAGS) +EGL_LIBS = -lX11 -lGL -include depend -# DO NOT DELETE +include ../Makefile.template -- cgit v1.2.3 From 0e54f9c529c0c015b3d227afff21da1f7b452991 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 Jan 2010 14:23:22 +0800 Subject: egl_glx: Report only OpenGL support. It reported OpenGL ES support because some demos did not set EGL_RENDERABLE_TYPE correctly. The demos are fixed. --- src/egl/drivers/glx/egl_glx.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c index 7c6e8637a1..6d2815888b 100644 --- a/src/egl/drivers/glx/egl_glx.c +++ b/src/egl/drivers/glx/egl_glx.c @@ -54,13 +54,6 @@ #error "GL/glx.h must be equal to or greater than GLX 1.4" #endif -/* - * report OpenGL ES bits because apps usually forget to specify - * EGL_RENDERABLE_TYPE when choosing configs - */ -#define GLX_EGL_APIS (EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT) - - /** subclass of _EGLDriver */ struct GLX_egl_driver { @@ -244,7 +237,7 @@ convert_fbconfig(Display *dpy, GLXFBConfig fbconfig, GLX_conf->double_buffered = (mode.doubleBufferMode != 0); return _eglConfigFromContextModesRec(&GLX_conf->Base, &mode, - GLX_EGL_APIS, GLX_EGL_APIS); + EGL_OPENGL_BIT, EGL_OPENGL_BIT); } @@ -364,7 +357,7 @@ convert_visual(Display *dpy, XVisualInfo *vinfo, GLX_conf->double_buffered = (mode.doubleBufferMode != 0); return _eglConfigFromContextModesRec(&GLX_conf->Base, &mode, - GLX_EGL_APIS, GLX_EGL_APIS); + EGL_OPENGL_BIT, EGL_OPENGL_BIT); } @@ -559,7 +552,7 @@ GLX_eglInitialize(_EGLDriver *drv, _EGLDisplay *disp, } disp->DriverData = (void *) GLX_dpy; - disp->ClientAPIsMask = GLX_EGL_APIS; + disp->ClientAPIsMask = EGL_OPENGL_BIT; /* we're supporting EGL 1.4 */ *major = 1; -- cgit v1.2.3 From fe0e35aba8bb2472630a18edb232d7379ef17eaf Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 Jan 2010 14:13:25 +0800 Subject: egl_xdri: Do not reinitialize in __glXInitialize. __glXInitialize should return the same GLX display for the same X display. This issue is triggered by a35f6bb207efe3c959bbd16a37f2049e5aceeea9. --- src/egl/drivers/xdri/egl_xdri.c | 1 - src/egl/drivers/xdri/glxinit.c | 99 ++++++++++++++++++++++++++++++++--------- src/egl/drivers/xdri/glxinit.h | 3 -- 3 files changed, 78 insertions(+), 25 deletions(-) diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index 8425b3d11e..e0761146da 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -342,7 +342,6 @@ xdri_eglTerminate(_EGLDriver *drv, _EGLDisplay *dpy) } xdri_dpy->driDisplay->destroyDisplay(xdri_dpy->driDisplay); - __glXRelease(xdri_dpy->dpyPriv); free(xdri_dpy); dpy->DriverData = NULL; diff --git a/src/egl/drivers/xdri/glxinit.c b/src/egl/drivers/xdri/glxinit.c index 7775009394..5c0fbc6b3c 100644 --- a/src/egl/drivers/xdri/glxinit.c +++ b/src/egl/drivers/xdri/glxinit.c @@ -1,8 +1,10 @@ /** * GLX initialization. Code based on glxext.c, glx_query.c, and - * glcontextmodes.c under src/glx/x11/. The major difference is that no DRI - * related code here. + * glcontextmodes.c under src/glx/x11/. The major difference is that DRI + * related code is stripped out. * + * If the maintenance of this file takes too much time, we should consider + * refactoring glxext.c. */ #include @@ -31,7 +33,26 @@ typedef struct GLXGenericGetString static char *__glXExtensionName = GLX_EXTENSION_NAME; static XExtensionInfo *__glXExtensionInfo = NULL; -static /* const */ XExtensionHooks __glXExtensionHooks = { NULL }; +static int +__glXCloseDisplay(Display * dpy, XExtCodes * codes) +{ + return XextRemoveDisplay(__glXExtensionInfo, dpy); +} + +static /* const */ XExtensionHooks __glXExtensionHooks = { + NULL, /* create_gc */ + NULL, /* copy_gc */ + NULL, /* flush_gc */ + NULL, /* free_gc */ + NULL, /* create_font */ + NULL, /* free_font */ + __glXCloseDisplay, /* close_display */ + NULL, /* wire_to_event */ + NULL, /* event_to_wire */ + NULL, /* error */ + NULL, /* error_string */ +}; + static XEXT_GENERATE_FIND_DISPLAY(__glXFindDisplay, __glXExtensionInfo, __glXExtensionName, &__glXExtensionHooks, @@ -180,6 +201,30 @@ FreeScreenConfigs(__GLXdisplayPrivate * priv) priv->screenConfigs = NULL; } +/* +** Release the private memory referred to in a display private +** structure. The caller will free the extension structure. +*/ +static int +__glXFreeDisplayPrivate(XExtData * extension) +{ + __GLXdisplayPrivate *priv; + + priv = (__GLXdisplayPrivate *) extension->private_data; + FreeScreenConfigs(priv); + if (priv->serverGLXvendor) { + Xfree((char *) priv->serverGLXvendor); + priv->serverGLXvendor = 0x0; /* to protect against double free's */ + } + if (priv->serverGLXversion) { + Xfree((char *) priv->serverGLXversion); + priv->serverGLXversion = 0x0; /* to protect against double free's */ + } + + Xfree((char *) priv); + return 0; +} + /************************************************************************/ /* @@ -570,40 +615,40 @@ AllocAndFetchScreenConfigs(Display * dpy, __GLXdisplayPrivate * priv) return GL_TRUE; } -_X_HIDDEN void -__glXRelease(__GLXdisplayPrivate *dpyPriv) -{ - FreeScreenConfigs(dpyPriv); - - if (dpyPriv->serverGLXvendor) { - Xfree((char *) dpyPriv->serverGLXvendor); - dpyPriv->serverGLXvendor = NULL; - } - if (dpyPriv->serverGLXversion) { - Xfree((char *) dpyPriv->serverGLXversion); - dpyPriv->serverGLXversion = NULL; - } - - Xfree(dpyPriv); -} - _X_HIDDEN __GLXdisplayPrivate * __glXInitialize(Display * dpy) { XExtDisplayInfo *info = __glXFindDisplay(dpy); + XExtData **privList, *private, *found; __GLXdisplayPrivate *dpyPriv; + XEDataObject dataObj; int major, minor; if (!XextHasExtension(info)) return NULL; + /* See if a display private already exists. If so, return it */ + dataObj.display = dpy; + privList = XEHeadOfExtensionList(dataObj); + found = XFindOnExtensionList(privList, info->codes->extension); + if (found) + return (__GLXdisplayPrivate *) found->private_data; + /* See if the versions are compatible */ if (!QueryVersion(dpy, info->codes->major_opcode, &major, &minor)) return NULL; + /* + ** Allocate memory for all the pieces needed for this buffer. + */ + private = (XExtData *) Xmalloc(sizeof(XExtData)); + if (!private) + return NULL; dpyPriv = (__GLXdisplayPrivate *) Xcalloc(1, sizeof(__GLXdisplayPrivate)); - if (!dpyPriv) + if (!dpyPriv) { + Xfree(private); return NULL; + } /* ** Init the display private and then read in the screen config @@ -619,8 +664,20 @@ __glXInitialize(Display * dpy) if (!AllocAndFetchScreenConfigs(dpy, dpyPriv)) { Xfree(dpyPriv); + Xfree(private); return NULL; } + /* + ** Fill in the private structure. This is the actual structure that + ** hangs off of the Display structure. Our private structure is + ** referred to by this structure. Got that? + */ + private->number = info->codes->extension; + private->next = 0; + private->free_private = __glXFreeDisplayPrivate; + private->private_data = (char *) dpyPriv; + XAddToExtensionList(privList, private); + return dpyPriv; } diff --git a/src/egl/drivers/xdri/glxinit.h b/src/egl/drivers/xdri/glxinit.h index 57206e627b..1cc7c460fe 100644 --- a/src/egl/drivers/xdri/glxinit.h +++ b/src/egl/drivers/xdri/glxinit.h @@ -8,7 +8,4 @@ extern void _gl_context_modes_destroy(__GLcontextModes * modes); -extern void -__glXRelease(__GLXdisplayPrivate *dpyPriv); - #endif /* GLXINIT_INCLUDED */ -- cgit v1.2.3 From 3c9bf648ac8f837f49f426af791aadb6a2589f08 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 Jan 2010 14:53:31 +0800 Subject: egl_xdri: Report only OpenGL support. It reported OpenGL ES support because some demos did not set EGL_RENDERABLE_TYPE correctly. The demos are fixed. --- src/egl/drivers/xdri/egl_xdri.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index e0761146da..7602df11a4 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -167,14 +167,10 @@ get_drawable_size(Display *dpy, Drawable d, uint *width, uint *height) static EGLBoolean convert_config(_EGLConfig *conf, EGLint id, const __GLcontextModes *m) { - static const EGLint all_apis = (EGL_OPENGL_ES_BIT | - EGL_OPENGL_ES2_BIT | - EGL_OPENVG_BIT | - EGL_OPENGL_BIT); EGLint val; _eglInitConfig(conf, id); - if (!_eglConfigFromContextModesRec(conf, m, all_apis, all_apis)) + if (!_eglConfigFromContextModesRec(conf, m, EGL_OPENGL_BIT, EGL_OPENGL_BIT)) return EGL_FALSE; if (m->doubleBufferMode) { @@ -302,10 +298,7 @@ xdri_eglInitialize(_EGLDriver *drv, _EGLDisplay *dpy, create_configs(dpy, psc->configs, first_id); dpy->DriverData = xdri_dpy; - dpy->ClientAPIsMask = (EGL_OPENGL_BIT | - EGL_OPENGL_ES_BIT | - EGL_OPENGL_ES2_BIT | - EGL_OPENVG_BIT); + dpy->ClientAPIsMask = EGL_OPENGL_BIT; /* we're supporting EGL 1.4 */ *minor = 1; -- cgit v1.2.3 From caa75a7ce07e4a5d89b0d7cf8823fe02034c1b3b Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 Jan 2010 14:28:23 +0800 Subject: egl_xdri: Flush commands on context switch and buffer swap. The corresponding DRI functions does not flush for us. --- src/egl/drivers/xdri/egl_xdri.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index 7602df11a4..f83da6652f 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -62,6 +62,7 @@ struct xdri_egl_driver { _EGLDriver Base; /**< base class */ + void (*FlushCurrentContext)(void); }; @@ -433,13 +434,23 @@ static EGLBoolean xdri_eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *d, _EGLSurface *r, _EGLContext *context) { + struct xdri_egl_driver *xdri_driver = xdri_egl_driver(drv); struct xdri_egl_context *xdri_ctx = lookup_context(context); struct xdri_egl_surface *draw = lookup_surface(d); struct xdri_egl_surface *read = lookup_surface(r); + _EGLContext *old = _eglGetCurrentContext(); + + /* an unlinked context will be invalid after context switch */ + if (!_eglIsContextLinked(old)) + old = NULL; if (!_eglMakeCurrent(drv, dpy, d, r, context)) return EGL_FALSE; + /* flush before context switch */ + if (old && old != context && xdri_driver->FlushCurrentContext) + xdri_driver->FlushCurrentContext(); + /* the symbol is defined in libGL.so */ _glapi_check_multithread(); @@ -450,12 +461,9 @@ xdri_eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *d, return EGL_FALSE; } } - else { - _EGLContext *old = _eglGetCurrentContext(); - if (old) { - xdri_ctx = lookup_context(old); - xdri_ctx->driContext->unbindContext(xdri_ctx->driContext); - } + else if (old) { + xdri_ctx = lookup_context(old); + xdri_ctx->driContext->unbindContext(xdri_ctx->driContext); } return EGL_TRUE; @@ -551,9 +559,15 @@ xdri_eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, static EGLBoolean xdri_eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw) { + struct xdri_egl_driver *xdri_driver = xdri_egl_driver(drv); struct xdri_egl_display *xdri_dpy = lookup_display(dpy); struct xdri_egl_surface *xdri_surf = lookup_surface(draw); + /* swapBuffers does not flush commands */ + if (draw == _eglGetCurrentSurface(EGL_DRAW) && + xdri_driver->FlushCurrentContext) + xdri_driver->FlushCurrentContext(); + xdri_dpy->psc->driScreen->swapBuffers(xdri_surf->driDrawable, 0, 0, 0); return EGL_TRUE; @@ -598,5 +612,9 @@ _eglMain(const char *args) xdri_drv->Base.Name = "X/DRI"; xdri_drv->Base.Unload = xdri_Unload; + /* we need a way to flush commands */ + xdri_drv->FlushCurrentContext = + (void (*)(void)) xdri_eglGetProcAddress(&xdri_drv->Base, "glFlush"); + return &xdri_drv->Base; } -- cgit v1.2.3 From dc544ad9c6e6e24fd2f19dfe83aa294d218f7310 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 21 Jan 2010 22:57:12 -0800 Subject: draw: Remove unnecessary headers. --- src/gallium/auxiliary/draw/draw_context.c | 3 --- src/gallium/auxiliary/draw/draw_pt.c | 1 - src/gallium/auxiliary/draw/draw_pt_fetch.c | 1 - src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c | 1 - src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c | 1 - src/gallium/auxiliary/draw/draw_pt_post_vs.c | 1 - src/gallium/auxiliary/draw/draw_vs_varient.c | 1 - 7 files changed, 9 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index a4f1fcddc1..b814ecb87a 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -34,10 +34,7 @@ #include "util/u_memory.h" #include "util/u_math.h" #include "draw_context.h" -#include "draw_vbuf.h" #include "draw_vs.h" -#include "draw_pt.h" -#include "draw_pipe.h" struct draw_context *draw_create( void ) diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c index 4865a2d854..ae9ee539fb 100644 --- a/src/gallium/auxiliary/draw/draw_pt.c +++ b/src/gallium/auxiliary/draw/draw_pt.c @@ -33,7 +33,6 @@ #include "draw/draw_context.h" #include "draw/draw_private.h" #include "draw/draw_pt.h" -#include "draw/draw_vs.h" #include "tgsi/tgsi_dump.h" #include "util/u_math.h" #include "util/u_prim.h" diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch.c b/src/gallium/auxiliary/draw/draw_pt_fetch.c index 65c3a34c34..2bd88a23fd 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch.c @@ -30,7 +30,6 @@ #include "draw/draw_context.h" #include "draw/draw_private.h" #include "draw/draw_vbuf.h" -#include "draw/draw_vertex.h" #include "draw/draw_pt.h" #include "translate/translate.h" #include "translate/translate_cache.h" diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c index 734c05f068..c5dfbcfa3c 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c @@ -40,7 +40,6 @@ #include "draw/draw_pt.h" #include "draw/draw_vs.h" -#include "translate/translate.h" struct fetch_shade_emit; diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c index df6c265b7e..18483acabf 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c @@ -32,7 +32,6 @@ #include "draw/draw_vertex.h" #include "draw/draw_pt.h" #include "draw/draw_vs.h" -#include "translate/translate.h" struct fetch_pipeline_middle_end { diff --git a/src/gallium/auxiliary/draw/draw_pt_post_vs.c b/src/gallium/auxiliary/draw/draw_pt_post_vs.c index 6c1cb48e8b..360eb86419 100644 --- a/src/gallium/auxiliary/draw/draw_pt_post_vs.c +++ b/src/gallium/auxiliary/draw/draw_pt_post_vs.c @@ -30,7 +30,6 @@ #include "draw/draw_context.h" #include "draw/draw_private.h" #include "draw/draw_vbuf.h" -#include "draw/draw_vertex.h" #include "draw/draw_pt.h" struct pt_post_vs { diff --git a/src/gallium/auxiliary/draw/draw_vs_varient.c b/src/gallium/auxiliary/draw/draw_vs_varient.c index 7ee567d478..7ae043f5a4 100644 --- a/src/gallium/auxiliary/draw/draw_vs_varient.c +++ b/src/gallium/auxiliary/draw/draw_vs_varient.c @@ -38,7 +38,6 @@ #include "draw/draw_vertex.h" #include "draw/draw_vs.h" #include "translate/translate.h" -#include "translate/translate_cache.h" /* A first pass at incorporating vertex fetch/emit functionality into */ -- cgit v1.2.3 From 18b63b55d5626dec86e3470bdf8c9996faf28384 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 Jan 2010 14:15:14 +0800 Subject: egl_xdri: Add support for DRISW. Try DRISW if both DRI2 and DRI fail. It can also be forced by setting EGL_SOFTWARE. When DRISW is used, single-buffered modes are ignored. --- src/egl/drivers/xdri/Makefile | 2 +- src/egl/drivers/xdri/driinit.c | 34 ++++++++++++++++++++++++++-------- src/egl/drivers/xdri/egl_xdri.c | 21 +++++++++++++++------ 3 files changed, 42 insertions(+), 15 deletions(-) diff --git a/src/egl/drivers/xdri/Makefile b/src/egl/drivers/xdri/Makefile index 8e748b71cd..9120620dc5 100644 --- a/src/egl/drivers/xdri/Makefile +++ b/src/egl/drivers/xdri/Makefile @@ -6,7 +6,7 @@ include $(TOP)/configs/current EGL_DRIVER = egl_xdri.so # steal sources from GLX -GLX_SOURCES = dri_common.c XF86dri.c dri2.c dri2_glx.c dri_glx.c +GLX_SOURCES = dri_common.c XF86dri.c dri2.c dri2_glx.c dri_glx.c drisw_glx.c GLX_SOURCES := $(addprefix ../../../glx/x11/,$(GLX_SOURCES)) GLX_INCLUDES = \ $(shell pkg-config --cflags-only-I libdrm) \ diff --git a/src/egl/drivers/xdri/driinit.c b/src/egl/drivers/xdri/driinit.c index 12da1bcd24..3e54f0bd4d 100644 --- a/src/egl/drivers/xdri/driinit.c +++ b/src/egl/drivers/xdri/driinit.c @@ -2,6 +2,7 @@ * DRI initialization. The DRI loaders are defined in src/glx/x11/. */ +#include #include #include "glxclient.h" @@ -42,18 +43,26 @@ __glXEnableDirectExtension(__GLXscreenConfigs * psc, const char *name) _X_HIDDEN __GLXDRIdisplay * __driCreateDisplay(__GLXdisplayPrivate *dpyPriv, int *version) { - __GLXDRIdisplay *driDisplay; + __GLXDRIdisplay *driDisplay = NULL; int ver = 0; + char *env; + int force_sw; + + env = getenv("EGL_SOFTWARE"); + force_sw = (env && *env != '0'); /* try DRI2 first */ - driDisplay = dri2CreateDisplay(dpyPriv->dpy); - if (driDisplay) { - /* fill in the required field */ - dpyPriv->dri2Display = driDisplay; - ver = 2; + if (!force_sw) { + driDisplay = dri2CreateDisplay(dpyPriv->dpy); + if (driDisplay) { + /* fill in the required field */ + dpyPriv->dri2Display = driDisplay; + ver = 2; + } } - else { - /* try DRI */ + + /* and then DRI */ + if (!force_sw && !driDisplay) { driDisplay = driCreateDisplay(dpyPriv->dpy); if (driDisplay) { dpyPriv->driDisplay = driDisplay; @@ -61,6 +70,15 @@ __driCreateDisplay(__GLXdisplayPrivate *dpyPriv, int *version) } } + /* and then DRISW */ + if (!driDisplay) { + driDisplay = driswCreateDisplay(dpyPriv->dpy); + if (driDisplay) { + dpyPriv->driDisplay = driDisplay; + ver = 0; + } + } + if (version) *version = ver; return driDisplay; diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index f83da6652f..b133939155 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -72,6 +72,7 @@ struct xdri_egl_display Display *dpy; __GLXdisplayPrivate *dpyPriv; __GLXDRIdisplay *driDisplay; + int driVersion; __GLXscreenConfigs *psc; EGLint scr; @@ -212,6 +213,7 @@ convert_config(_EGLConfig *conf, EGLint id, const __GLcontextModes *m) static EGLint create_configs(_EGLDisplay *disp, const __GLcontextModes *m, EGLint first_id) { + struct xdri_egl_display *xdri_dpy = lookup_display(disp); int id = first_id; for (; m; m = m->next) { @@ -221,8 +223,15 @@ create_configs(_EGLDisplay *disp, const __GLcontextModes *m, EGLint first_id) if (!convert_config(&conf, id, m)) continue; - - rb = (m->doubleBufferMode) ? EGL_BACK_BUFFER : EGL_SINGLE_BUFFER; + if (m->doubleBufferMode) { + rb = EGL_BACK_BUFFER; + } + else { + /* ignore single-buffered mode for DRISW */ + if (xdri_dpy->driVersion == 0) + continue; + rb = EGL_SINGLE_BUFFER; + } xdri_conf = CALLOC_STRUCT(xdri_egl_config); if (xdri_conf) { @@ -272,7 +281,7 @@ xdri_eglInitialize(_EGLDriver *drv, _EGLDisplay *dpy, return _eglError(EGL_NOT_INITIALIZED, "eglInitialize"); } - driDisplay = __driCreateDisplay(dpyPriv, NULL); + driDisplay = __driCreateDisplay(dpyPriv, &xdri_dpy->driVersion); if (!driDisplay) { _eglLog(_EGL_WARNING, "failed to create DRI display"); free(xdri_dpy); @@ -294,13 +303,13 @@ xdri_eglInitialize(_EGLDriver *drv, _EGLDisplay *dpy, return _eglError(EGL_NOT_INITIALIZED, "eglInitialize"); } + dpy->DriverData = xdri_dpy; + dpy->ClientAPIsMask = EGL_OPENGL_BIT; + /* add visuals and fbconfigs */ first_id = create_configs(dpy, psc->visuals, first_id); create_configs(dpy, psc->configs, first_id); - dpy->DriverData = xdri_dpy; - dpy->ClientAPIsMask = EGL_OPENGL_BIT; - /* we're supporting EGL 1.4 */ *minor = 1; *major = 4; -- cgit v1.2.3 From 29732f982cb0ad3bd9c81da2ba9f64b9205ff6b0 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 Jan 2010 15:05:31 +0800 Subject: docs: Update the status of egl_xdri. Mention that it also supports DRISW. --- docs/egl.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/egl.html b/docs/egl.html index 9bbce83d4b..5561d1a4b8 100644 --- a/docs/egl.html +++ b/docs/egl.html @@ -182,12 +182,12 @@ is not available in GLX or GLX extensions.

    • egl_xdri

      This driver supports the X Window System as its window system. It functions -as a DRI driver loader. Unlike egl_glx, it has no dependency on -libGL. It talks to the X server directly using DRI or DRI2 -protocols. It also talks minimal GLX protocol for things like available -visuals or fbconfigs. With direct access to the DRI drivers, it has the -potential to support more EGL functions that are not possible with -egl_glx

      +as a DRI driver loader and can load DRI/DRI2/DRISW drivers. Unlike +egl_glx, it has no dependency on libGL. It talks to +the X server directly using DRI or DRI2 protocols. It also talks minimal GLX +protocol for things like available visuals or fbconfigs. With direct access to +the DRI drivers, it has the potential to support more EGL functions that are +not possible with egl_glx.

    • egl_dri -- cgit v1.2.3 From cfb1ed39771c7f3876a8231ab1c8a8d6f7b5deae Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 Jan 2010 14:41:00 +0800 Subject: st/egl_g3d: Use glxinit.c from egl_xdri. It is used to fetch the GLX visuals/fbconfigs. Use egl_xdri's version to avoid duplication. It might be better to rewrite that part though. --- src/gallium/state_trackers/egl_g3d/Makefile | 5 +- src/gallium/state_trackers/egl_g3d/x11/glxinit.c | 573 --------------------- src/gallium/state_trackers/egl_g3d/x11/glxinit.h | 14 - .../state_trackers/egl_g3d/x11/x11_screen.c | 8 +- 4 files changed, 10 insertions(+), 590 deletions(-) delete mode 100644 src/gallium/state_trackers/egl_g3d/x11/glxinit.c delete mode 100644 src/gallium/state_trackers/egl_g3d/x11/glxinit.h diff --git a/src/gallium/state_trackers/egl_g3d/Makefile b/src/gallium/state_trackers/egl_g3d/Makefile index 213eb3e815..b696f2fae9 100644 --- a/src/gallium/state_trackers/egl_g3d/Makefile +++ b/src/gallium/state_trackers/egl_g3d/Makefile @@ -15,10 +15,13 @@ common_OBJECTS = $(common_SOURCES:.c=.o) x11_INCLUDES = \ -I$(TOP)/src/gallium/drivers \ -I$(TOP)/src/glx/x11 \ + -I$(TOP)/src/egl/drivers/xdri \ -I$(TOP)/src/mesa \ $(shell pkg-config --cflags-only-I libdrm) -x11_SOURCES = $(wildcard x11/*.c) $(TOP)/src/glx/x11/dri2.c +x11_SOURCES = $(wildcard x11/*.c) \ + $(TOP)/src/glx/x11/dri2.c \ + $(TOP)/src/egl/drivers/xdri/glxinit.c x11_OBJECTS = $(x11_SOURCES:.c=.o) diff --git a/src/gallium/state_trackers/egl_g3d/x11/glxinit.c b/src/gallium/state_trackers/egl_g3d/x11/glxinit.c deleted file mode 100644 index c955a908b9..0000000000 --- a/src/gallium/state_trackers/egl_g3d/x11/glxinit.c +++ /dev/null @@ -1,573 +0,0 @@ -/** - * GLX initialization. Code based on glxext.c, glx_query.c, and - * glcontextmodes.c under src/glx/x11/. The major difference is that no DRI - * related code here. - * - */ - -#include -#include -#include -#include -#include -#include - -#include "x11_screen.h" -#include "glxinit.h" - -typedef struct GLXGenericGetString -{ - CARD8 reqType; - CARD8 glxCode; - CARD16 length B16; - CARD32 for_whom B32; - CARD32 name B32; -} xGLXGenericGetStringReq; - -#define sz_xGLXGenericGetStringReq 12 -#define X_GLXGenericGetString 0 - -/* Extension required boiler plate */ - -static char *__glXExtensionName = GLX_EXTENSION_NAME; -static XExtensionInfo *__glXExtensionInfo = NULL; - -static /* const */ XExtensionHooks __glXExtensionHooks = { NULL }; -static -XEXT_GENERATE_FIND_DISPLAY(__glXFindDisplay, __glXExtensionInfo, - __glXExtensionName, &__glXExtensionHooks, - __GLX_NUMBER_EVENTS, NULL) - -static GLint -_gl_convert_from_x_visual_type(int visualType) -{ -#define NUM_VISUAL_TYPES 6 - static const int glx_visual_types[NUM_VISUAL_TYPES] = { - GLX_STATIC_GRAY, GLX_GRAY_SCALE, - GLX_STATIC_COLOR, GLX_PSEUDO_COLOR, - GLX_TRUE_COLOR, GLX_DIRECT_COLOR - }; - - return ((unsigned) visualType < NUM_VISUAL_TYPES) - ? glx_visual_types[visualType] : GLX_NONE; -} - -_X_HIDDEN char * -__glXQueryServerString(Display * dpy, int opcode, CARD32 screen, CARD32 name) -{ - xGLXGenericGetStringReq *req; - xGLXSingleReply reply; - int length; - int numbytes; - char *buf; - CARD32 for_whom = screen; - CARD32 glxCode = X_GLXQueryServerString; - - - LockDisplay(dpy); - - - /* All of the GLX protocol requests for getting a string from the server - * look the same. The exact meaning of the for_whom field is usually - * either the screen number (for glXQueryServerString) or the context tag - * (for GLXSingle). - */ - - GetReq(GLXGenericGetString, req); - req->reqType = opcode; - req->glxCode = glxCode; - req->for_whom = for_whom; - req->name = name; - - _XReply(dpy, (xReply *) & reply, 0, False); - - length = reply.length * 4; - numbytes = reply.size; - - buf = (char *) Xmalloc(numbytes); - if (buf != NULL) { - _XRead(dpy, buf, numbytes); - length -= numbytes; - } - - _XEatData(dpy, length); - - UnlockDisplay(dpy); - SyncHandle(); - - return buf; -} - -/************************************************************************/ -/* -** Free the per screen configs data as well as the array of -** __glXScreenConfigs. -*/ -static void -FreeScreenConfigs(__GLXdisplayPrivate * priv) -{ - __GLXscreenConfigs *psc; - GLint i, screens; - - /* Free screen configuration information */ - psc = priv->screenConfigs; - screens = ScreenCount(priv->dpy); - for (i = 0; i < screens; i++, psc++) { - if (psc->configs) { - x11_context_modes_destroy(psc->configs); - psc->configs = NULL; /* NOTE: just for paranoia */ - } - if (psc->visuals) { - x11_context_modes_destroy(psc->visuals); - psc->visuals = NULL; /* NOTE: just for paranoia */ - } - Xfree((char *) psc->serverGLXexts); - } - XFree((char *) priv->screenConfigs); - priv->screenConfigs = NULL; -} - -/************************************************************************/ - -/* -** Query the version of the GLX extension. This procedure works even if -** the client extension is not completely set up. -*/ -static Bool -QueryVersion(Display * dpy, int opcode, int *major, int *minor) -{ - xGLXQueryVersionReq *req; - xGLXQueryVersionReply reply; - - /* Send the glXQueryVersion request */ - LockDisplay(dpy); - GetReq(GLXQueryVersion, req); - req->reqType = opcode; - req->glxCode = X_GLXQueryVersion; - req->majorVersion = GLX_MAJOR_VERSION; - req->minorVersion = GLX_MINOR_VERSION; - _XReply(dpy, (xReply *) & reply, 0, False); - UnlockDisplay(dpy); - SyncHandle(); - - if (reply.majorVersion != GLX_MAJOR_VERSION) { - /* - ** The server does not support the same major release as this - ** client. - */ - return GL_FALSE; - } - *major = reply.majorVersion; - *minor = min(reply.minorVersion, GLX_MINOR_VERSION); - return GL_TRUE; -} - -_X_HIDDEN void -__glXInitializeVisualConfigFromTags(__GLcontextModes * config, int count, - const INT32 * bp, Bool tagged_only, - Bool fbconfig_style_tags) -{ - int i; - - if (!tagged_only) { - /* Copy in the first set of properties */ - config->visualID = *bp++; - - config->visualType = _gl_convert_from_x_visual_type(*bp++); - - config->rgbMode = *bp++; - - config->redBits = *bp++; - config->greenBits = *bp++; - config->blueBits = *bp++; - config->alphaBits = *bp++; - config->accumRedBits = *bp++; - config->accumGreenBits = *bp++; - config->accumBlueBits = *bp++; - config->accumAlphaBits = *bp++; - - config->doubleBufferMode = *bp++; - config->stereoMode = *bp++; - - config->rgbBits = *bp++; - config->depthBits = *bp++; - config->stencilBits = *bp++; - config->numAuxBuffers = *bp++; - config->level = *bp++; - - count -= __GLX_MIN_CONFIG_PROPS; - } - - /* - ** Additional properties may be in a list at the end - ** of the reply. They are in pairs of property type - ** and property value. - */ - -#define FETCH_OR_SET(tag) \ - config-> tag = ( fbconfig_style_tags ) ? *bp++ : 1 - - for (i = 0; i < count; i += 2) { - switch (*bp++) { - case GLX_RGBA: - FETCH_OR_SET(rgbMode); - break; - case GLX_BUFFER_SIZE: - config->rgbBits = *bp++; - break; - case GLX_LEVEL: - config->level = *bp++; - break; - case GLX_DOUBLEBUFFER: - FETCH_OR_SET(doubleBufferMode); - break; - case GLX_STEREO: - FETCH_OR_SET(stereoMode); - break; - case GLX_AUX_BUFFERS: - config->numAuxBuffers = *bp++; - break; - case GLX_RED_SIZE: - config->redBits = *bp++; - break; - case GLX_GREEN_SIZE: - config->greenBits = *bp++; - break; - case GLX_BLUE_SIZE: - config->blueBits = *bp++; - break; - case GLX_ALPHA_SIZE: - config->alphaBits = *bp++; - break; - case GLX_DEPTH_SIZE: - config->depthBits = *bp++; - break; - case GLX_STENCIL_SIZE: - config->stencilBits = *bp++; - break; - case GLX_ACCUM_RED_SIZE: - config->accumRedBits = *bp++; - break; - case GLX_ACCUM_GREEN_SIZE: - config->accumGreenBits = *bp++; - break; - case GLX_ACCUM_BLUE_SIZE: - config->accumBlueBits = *bp++; - break; - case GLX_ACCUM_ALPHA_SIZE: - config->accumAlphaBits = *bp++; - break; - case GLX_VISUAL_CAVEAT_EXT: - config->visualRating = *bp++; - break; - case GLX_X_VISUAL_TYPE: - config->visualType = *bp++; - break; - case GLX_TRANSPARENT_TYPE: - config->transparentPixel = *bp++; - break; - case GLX_TRANSPARENT_INDEX_VALUE: - config->transparentIndex = *bp++; - break; - case GLX_TRANSPARENT_RED_VALUE: - config->transparentRed = *bp++; - break; - case GLX_TRANSPARENT_GREEN_VALUE: - config->transparentGreen = *bp++; - break; - case GLX_TRANSPARENT_BLUE_VALUE: - config->transparentBlue = *bp++; - break; - case GLX_TRANSPARENT_ALPHA_VALUE: - config->transparentAlpha = *bp++; - break; - case GLX_VISUAL_ID: - config->visualID = *bp++; - break; - case GLX_DRAWABLE_TYPE: - config->drawableType = *bp++; - break; - case GLX_RENDER_TYPE: - config->renderType = *bp++; - break; - case GLX_X_RENDERABLE: - config->xRenderable = *bp++; - break; - case GLX_FBCONFIG_ID: - config->fbconfigID = *bp++; - break; - case GLX_MAX_PBUFFER_WIDTH: - config->maxPbufferWidth = *bp++; - break; - case GLX_MAX_PBUFFER_HEIGHT: - config->maxPbufferHeight = *bp++; - break; - case GLX_MAX_PBUFFER_PIXELS: - config->maxPbufferPixels = *bp++; - break; - case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX: - config->optimalPbufferWidth = *bp++; - break; - case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX: - config->optimalPbufferHeight = *bp++; - break; - case GLX_VISUAL_SELECT_GROUP_SGIX: - config->visualSelectGroup = *bp++; - break; - case GLX_SWAP_METHOD_OML: - config->swapMethod = *bp++; - break; - case GLX_SAMPLE_BUFFERS_SGIS: - config->sampleBuffers = *bp++; - break; - case GLX_SAMPLES_SGIS: - config->samples = *bp++; - break; - case GLX_BIND_TO_TEXTURE_RGB_EXT: - config->bindToTextureRgb = *bp++; - break; - case GLX_BIND_TO_TEXTURE_RGBA_EXT: - config->bindToTextureRgba = *bp++; - break; - case GLX_BIND_TO_MIPMAP_TEXTURE_EXT: - config->bindToMipmapTexture = *bp++; - break; - case GLX_BIND_TO_TEXTURE_TARGETS_EXT: - config->bindToTextureTargets = *bp++; - break; - case GLX_Y_INVERTED_EXT: - config->yInverted = *bp++; - break; - case None: - i = count; - break; - default: - break; - } - } - - config->renderType = - (config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT; - - config->haveAccumBuffer = ((config->accumRedBits + - config->accumGreenBits + - config->accumBlueBits + - config->accumAlphaBits) > 0); - config->haveDepthBuffer = (config->depthBits > 0); - config->haveStencilBuffer = (config->stencilBits > 0); -} - -static __GLcontextModes * -createConfigsFromProperties(Display * dpy, int nvisuals, int nprops, - int screen, GLboolean tagged_only) -{ - INT32 buf[__GLX_TOTAL_CONFIG], *props; - unsigned prop_size; - __GLcontextModes *modes, *m; - int i; - - if (nprops == 0) - return NULL; - - /* FIXME: Is the __GLX_MIN_CONFIG_PROPS test correct for FBconfigs? */ - - /* Check number of properties */ - if (nprops < __GLX_MIN_CONFIG_PROPS || nprops > __GLX_MAX_CONFIG_PROPS) - return NULL; - - /* Allocate memory for our config structure */ - modes = x11_context_modes_create(nvisuals); - if (!modes) - return NULL; - - prop_size = nprops * __GLX_SIZE_INT32; - if (prop_size <= sizeof(buf)) - props = buf; - else - props = Xmalloc(prop_size); - - /* Read each config structure and convert it into our format */ - m = modes; - for (i = 0; i < nvisuals; i++) { - _XRead(dpy, (char *) props, prop_size); - /* Older X servers don't send this so we default it here. */ - m->drawableType = GLX_WINDOW_BIT; - __glXInitializeVisualConfigFromTags(m, nprops, props, - tagged_only, GL_TRUE); - m->screen = screen; - m = m->next; - } - - if (props != buf) - Xfree(props); - - return modes; -} - -static GLboolean -getVisualConfigs(Display * dpy, __GLXdisplayPrivate * priv, int screen) -{ - xGLXGetVisualConfigsReq *req; - __GLXscreenConfigs *psc; - xGLXGetVisualConfigsReply reply; - - LockDisplay(dpy); - - psc = priv->screenConfigs + screen; - psc->visuals = NULL; - GetReq(GLXGetVisualConfigs, req); - req->reqType = priv->majorOpcode; - req->glxCode = X_GLXGetVisualConfigs; - req->screen = screen; - - if (!_XReply(dpy, (xReply *) & reply, 0, False)) - goto out; - - psc->visuals = createConfigsFromProperties(dpy, - reply.numVisuals, - reply.numProps, - screen, GL_FALSE); - - out: - UnlockDisplay(dpy); - return psc->visuals != NULL; -} - -static GLboolean -getFBConfigs(Display * dpy, __GLXdisplayPrivate * priv, int screen) -{ - xGLXGetFBConfigsReq *fb_req; - xGLXGetFBConfigsSGIXReq *sgi_req; - xGLXVendorPrivateWithReplyReq *vpreq; - xGLXGetFBConfigsReply reply; - __GLXscreenConfigs *psc; - - psc = priv->screenConfigs + screen; - psc->serverGLXexts = - __glXQueryServerString(dpy, priv->majorOpcode, screen, GLX_EXTENSIONS); - - LockDisplay(dpy); - - psc->configs = NULL; - if (atof(priv->serverGLXversion) >= 1.3) { - GetReq(GLXGetFBConfigs, fb_req); - fb_req->reqType = priv->majorOpcode; - fb_req->glxCode = X_GLXGetFBConfigs; - fb_req->screen = screen; - } - else if (strstr(psc->serverGLXexts, "GLX_SGIX_fbconfig") != NULL) { - GetReqExtra(GLXVendorPrivateWithReply, - sz_xGLXGetFBConfigsSGIXReq + - sz_xGLXVendorPrivateWithReplyReq, vpreq); - sgi_req = (xGLXGetFBConfigsSGIXReq *) vpreq; - sgi_req->reqType = priv->majorOpcode; - sgi_req->glxCode = X_GLXVendorPrivateWithReply; - sgi_req->vendorCode = X_GLXvop_GetFBConfigsSGIX; - sgi_req->screen = screen; - } - else - goto out; - - if (!_XReply(dpy, (xReply *) & reply, 0, False)) - goto out; - - psc->configs = createConfigsFromProperties(dpy, - reply.numFBConfigs, - reply.numAttribs * 2, - screen, GL_TRUE); - - out: - UnlockDisplay(dpy); - return psc->configs != NULL; -} - -static GLboolean -AllocAndFetchScreenConfigs(Display * dpy, __GLXdisplayPrivate * priv) -{ - __GLXscreenConfigs *psc; - GLint i, screens; - - /* - ** First allocate memory for the array of per screen configs. - */ - screens = ScreenCount(dpy); - psc = (__GLXscreenConfigs *) Xmalloc(screens * sizeof(__GLXscreenConfigs)); - if (!psc) { - return GL_FALSE; - } - memset(psc, 0, screens * sizeof(__GLXscreenConfigs)); - priv->screenConfigs = psc; - - priv->serverGLXversion = - __glXQueryServerString(dpy, priv->majorOpcode, 0, GLX_VERSION); - if (priv->serverGLXversion == NULL) { - FreeScreenConfigs(priv); - return GL_FALSE; - } - - for (i = 0; i < screens; i++, psc++) { - getFBConfigs(dpy, priv, i); - getVisualConfigs(dpy, priv, i); - psc->scr = i; - psc->dpy = dpy; - } - - SyncHandle(); - - return GL_TRUE; -} - -_X_HIDDEN void -__glXRelease(__GLXdisplayPrivate *dpyPriv) -{ - FreeScreenConfigs(dpyPriv); - - if (dpyPriv->serverGLXvendor) { - Xfree((char *) dpyPriv->serverGLXvendor); - dpyPriv->serverGLXvendor = NULL; - } - if (dpyPriv->serverGLXversion) { - Xfree((char *) dpyPriv->serverGLXversion); - dpyPriv->serverGLXversion = NULL; - } - - Xfree(dpyPriv); -} - -_X_HIDDEN __GLXdisplayPrivate * -__glXInitialize(Display * dpy) -{ - XExtDisplayInfo *info = __glXFindDisplay(dpy); - __GLXdisplayPrivate *dpyPriv; - int major, minor; - - if (!XextHasExtension(info)) - return NULL; - - /* See if the versions are compatible */ - if (!QueryVersion(dpy, info->codes->major_opcode, &major, &minor)) - return NULL; - - dpyPriv = (__GLXdisplayPrivate *) Xcalloc(1, sizeof(__GLXdisplayPrivate)); - if (!dpyPriv) - return NULL; - - /* - ** Init the display private and then read in the screen config - ** structures from the server. - */ - dpyPriv->majorOpcode = info->codes->major_opcode; - dpyPriv->majorVersion = major; - dpyPriv->minorVersion = minor; - dpyPriv->dpy = dpy; - - dpyPriv->serverGLXvendor = NULL; - dpyPriv->serverGLXversion = NULL; - - if (!AllocAndFetchScreenConfigs(dpy, dpyPriv)) { - Xfree(dpyPriv); - return NULL; - } - - return dpyPriv; -} diff --git a/src/gallium/state_trackers/egl_g3d/x11/glxinit.h b/src/gallium/state_trackers/egl_g3d/x11/glxinit.h deleted file mode 100644 index 515a825222..0000000000 --- a/src/gallium/state_trackers/egl_g3d/x11/glxinit.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef GLXINIT_INCLUDED -#define GLXINIT_INCLUDED - -#include - -#ifndef GLX_DIRECT_RENDERING -#define GLX_DIRECT_RENDERING -#endif -#include "glxclient.h" - -extern void -__glXRelease(__GLXdisplayPrivate *dpyPriv); - -#endif /* GLXINIT_INCLUDED */ diff --git a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c index fef7878ab9..76ce45ee57 100644 --- a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c +++ b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c @@ -42,6 +42,10 @@ struct x11_screen { Display *dpy; int number; + /* + * This is used to fetch GLX visuals/fbconfigs. It uses code from egl_xdri. + * It might be better to rewrite the part in Xlib or XCB. + */ __GLXdisplayPrivate *glx_dpy; int dri_major, dri_minor; @@ -93,8 +97,8 @@ x11_screen_destroy(struct x11_screen *xscr) if (xscr->dri_device) Xfree(xscr->dri_device); - if (xscr->glx_dpy) - __glXRelease(xscr->glx_dpy); + /* xscr->glx_dpy will be destroyed with the X display */ + if (xscr->visuals) XFree(xscr->visuals); free(xscr); -- cgit v1.2.3 From cea9250ff0fc8bfa0408b635ae2ef36bc0616e2e Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 21 Jan 2010 23:07:29 -0800 Subject: pipebuffer: Remove unnecessary header. --- src/gallium/auxiliary/pipebuffer/pb_validate.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gallium/auxiliary/pipebuffer/pb_validate.c b/src/gallium/auxiliary/pipebuffer/pb_validate.c index ce40c0cf0e..903afc749d 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_validate.c +++ b/src/gallium/auxiliary/pipebuffer/pb_validate.c @@ -39,7 +39,6 @@ #include "util/u_debug.h" #include "pb_buffer.h" -#include "pb_buffer_fenced.h" #include "pb_validate.h" -- cgit v1.2.3 From a1c5d8f61df9d9e22bcb0fc37a602ab712958151 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 21 Jan 2010 23:09:06 -0800 Subject: i915g: Remove unnecessary header. --- src/gallium/drivers/i915/i915_surface.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gallium/drivers/i915/i915_surface.c b/src/gallium/drivers/i915/i915_surface.c index 9b4366daff..793613be7b 100644 --- a/src/gallium/drivers/i915/i915_surface.c +++ b/src/gallium/drivers/i915/i915_surface.c @@ -28,7 +28,6 @@ #include "i915_context.h" #include "i915_blit.h" #include "pipe/p_defines.h" -#include "pipe/p_inlines.h" /* Assumes all values are within bounds -- no checking at this level - -- cgit v1.2.3 From 324fdf736453fbdcbc904c38ff383b540fb815c7 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 Jan 2010 15:07:58 +0800 Subject: egl: Remove the demo driver. The demo driver has outdated. It is suggested to look at any of the drivers that is functioning. --- configs/default | 2 +- configs/linux-dri | 2 +- src/egl/drivers/demo/Makefile | 32 ----- src/egl/drivers/demo/demo.c | 289 ------------------------------------------ 4 files changed, 2 insertions(+), 323 deletions(-) delete mode 100644 src/egl/drivers/demo/Makefile delete mode 100644 src/egl/drivers/demo/demo.c diff --git a/configs/default b/configs/default index ec9670dd63..6863495be3 100644 --- a/configs/default +++ b/configs/default @@ -93,7 +93,7 @@ DRIVER_DIRS = x11 osmesa PROGRAM_DIRS = demos redbook samples glsl objviewer xdemos # EGL drivers to build -EGL_DRIVERS_DIRS = demo +EGL_DRIVERS_DIRS = glx # Gallium directories and GALLIUM_DIRS = auxiliary drivers state_trackers diff --git a/configs/linux-dri b/configs/linux-dri index ff9bcc9396..95f77ade1d 100644 --- a/configs/linux-dri +++ b/configs/linux-dri @@ -55,7 +55,7 @@ SRC_DIRS := glx/x11 egl $(SRC_DIRS) PROGRAM_DIRS := egl $(PROGRAM_DIRS) # EGL directories -EGL_DRIVERS_DIRS = demo glx +EGL_DRIVERS_DIRS = glx DRIVER_DIRS = dri WINDOW_SYSTEM = dri diff --git a/src/egl/drivers/demo/Makefile b/src/egl/drivers/demo/Makefile deleted file mode 100644 index 444dfb35bd..0000000000 --- a/src/egl/drivers/demo/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -# src/egl/drivers/demo/Makefile - -TOP = ../../../.. -include $(TOP)/configs/current - - -INCLUDE_DIRS = -I$(TOP)/include -I$(TOP)/src/egl/main $(X11_INCLUDES) - - -SOURCES = demo.c - -OBJECTS = $(SOURCES:.c=.o) - - -.c.o: - $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ - - - -default: $(TOP)/$(LIB_DIR)/demodriver.so - - -$(TOP)/$(LIB_DIR)/demodriver.so: $(OBJECTS) - $(MKLIB) -o demodriver.so -noprefix -linker '$(CC)' \ - -ldflags '$(LDFLAGS)' -install $(TOP)/$(LIB_DIR) \ - $(OBJECTS) - -install: - -clean: - -rm -f *.o - -rm -f *.so diff --git a/src/egl/drivers/demo/demo.c b/src/egl/drivers/demo/demo.c deleted file mode 100644 index 0933c0bdaa..0000000000 --- a/src/egl/drivers/demo/demo.c +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Sample driver: Demo - */ - -#include -#include -#include -#include "eglconfig.h" -#include "eglcontext.h" -#include "egldisplay.h" -#include "egldriver.h" -#include "eglglobals.h" -#include "eglmode.h" -#include "eglscreen.h" -#include "eglsurface.h" - - -/** - * Demo driver-specific driver class derived from _EGLDriver - */ -typedef struct demo_driver -{ - _EGLDriver Base; /* base class/object */ - unsigned DemoStuff; -} DemoDriver; - -#define DEMO_DRIVER(D) ((DemoDriver *) (D)) - - -/** - * Demo driver-specific surface class derived from _EGLSurface - */ -typedef struct demo_surface -{ - _EGLSurface Base; /* base class/object */ - unsigned DemoStuff; -} DemoSurface; - - -/** - * Demo driver-specific context class derived from _EGLContext - */ -typedef struct demo_context -{ - _EGLContext Base; /* base class/object */ - unsigned DemoStuff; -} DemoContext; - - - -static EGLBoolean -demoInitialize(_EGLDriver *drv, _EGLDisplay *disp, EGLint *major, EGLint *minor) -{ - _EGLScreen *scrn; - EGLint i; - - /* Create a screen */ - scrn = calloc(1, sizeof(*scrn)); - _eglAddScreen(disp, scrn); - - /* Create the screen's modes - silly example */ - _eglAddNewMode(scrn, 1600, 1200, 72 * 1000, "1600x1200-72"); - _eglAddNewMode(scrn, 1280, 1024, 72 * 1000, "1280x1024-70"); - _eglAddNewMode(scrn, 1280, 1024, 70 * 1000, "1280x1024-70"); - _eglAddNewMode(scrn, 1024, 768, 72 * 1000, "1024x768-72"); - - /* Create the display's visual configs - silly example */ - for (i = 0; i < 4; i++) { - _EGLConfig *config = calloc(1, sizeof(_EGLConfig)); - _eglInitConfig(config, i + 1); - _eglSetConfigAttrib(config, EGL_RED_SIZE, 8); - _eglSetConfigAttrib(config, EGL_GREEN_SIZE, 8); - _eglSetConfigAttrib(config, EGL_BLUE_SIZE, 8); - _eglSetConfigAttrib(config, EGL_ALPHA_SIZE, 8); - _eglSetConfigAttrib(config, EGL_BUFFER_SIZE, 32); - if (i & 1) { - _eglSetConfigAttrib(config, EGL_DEPTH_SIZE, 32); - } - if (i & 2) { - _eglSetConfigAttrib(config, EGL_STENCIL_SIZE, 8); - } - _eglSetConfigAttrib(config, EGL_SURFACE_TYPE, - (EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT)); - _eglAddConfig(disp, config); - } - - /* enable supported extensions */ - disp->Extensions.MESA_screen_surface = EGL_TRUE; - disp->Extensions.MESA_copy_context = EGL_TRUE; - - *major = 1; - *minor = 0; - - return EGL_TRUE; -} - - -static EGLBoolean -demoTerminate(_EGLDriver *drv, _EGLDisplay *dpy) -{ - /*DemoDriver *demo = DEMO_DRIVER(dpy);*/ - return EGL_TRUE; -} - - -static DemoContext * -LookupDemoContext(_EGLContext *c) -{ - return (DemoContext *) c; -} - - -static DemoSurface * -LookupDemoSurface(_EGLSurface *s) -{ - return (DemoSurface *) s; -} - - -static _EGLContext * -demoCreateContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, _EGLContext *share_list, const EGLint *attrib_list) -{ - DemoContext *c; - int i; - - for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { - switch (attrib_list[i]) { - /* no attribs defined for now */ - default: - _eglError(EGL_BAD_ATTRIBUTE, "eglCreateContext"); - return NULL; - } - } - - c = (DemoContext *) calloc(1, sizeof(DemoContext)); - if (!c) - return NULL; - - _eglInitContext(drv, &c->Base, conf, attrib_list); - c->DemoStuff = 1; - printf("demoCreateContext\n"); - - return &c->Base; -} - - -static _EGLSurface * -demoCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, NativeWindowType window, const EGLint *attrib_list) -{ - int i; - for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { - switch (attrib_list[i]) { - /* no attribs at this time */ - default: - _eglError(EGL_BAD_ATTRIBUTE, "eglCreateWindowSurface"); - return NULL; - } - } - printf("eglCreateWindowSurface()\n"); - /* XXX unfinished */ - - return NULL; -} - - -static _EGLSurface * -demoCreatePixmapSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, NativePixmapType pixmap, const EGLint *attrib_list) -{ - EGLint i; - - for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { - switch (attrib_list[i]) { - /* no attribs at this time */ - default: - _eglError(EGL_BAD_ATTRIBUTE, "eglCreatePixmapSurface"); - return NULL; - } - } - - if (GET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE) == 0) { - _eglError(EGL_BAD_MATCH, "eglCreatePixmapSurface"); - return NULL; - } - - printf("eglCreatePixmapSurface()\n"); - return NULL; -} - - -static _EGLSurface * -demoCreatePbufferSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, - const EGLint *attrib_list) -{ - DemoSurface *surf = (DemoSurface *) calloc(1, sizeof(DemoSurface)); - - if (!surf) - return NULL; - - if (!_eglInitSurface(drv, &surf->Base, EGL_PBUFFER_BIT, - conf, attrib_list)) { - free(surf); - return NULL; - } - - /* a real driver would allocate the pbuffer memory here */ - - return &surf->Base; -} - - -static EGLBoolean -demoDestroySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface) -{ - DemoSurface *fs = LookupDemoSurface(surface); - if (!_eglIsSurfaceBound(&fs->Base)) - free(fs); - return EGL_TRUE; -} - - -static EGLBoolean -demoDestroyContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *context) -{ - DemoContext *fc = LookupDemoContext(context); - if (!_eglIsContextBound(&fc->Base)) - free(fc); - return EGL_TRUE; -} - - -static EGLBoolean -demoMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *drawSurf, _EGLSurface *readSurf, _EGLContext *ctx) -{ - /*DemoDriver *demo = DEMO_DRIVER(dpy);*/ - EGLBoolean b; - - b = _eglMakeCurrent(drv, dpy, drawSurf, readSurf, ctx); - if (!b) - return EGL_FALSE; - - /* XXX this is where we'd do the hardware context switch */ - (void) drawSurf; - (void) readSurf; - (void) ctx; - - printf("eglMakeCurrent()\n"); - return EGL_TRUE; -} - - -static void -demoUnload(_EGLDriver *drv) -{ - free(drv); -} - - -/** - * The bootstrap function. Return a new DemoDriver object and - * plug in API functions. - */ -_EGLDriver * -_eglMain(const char *args) -{ - DemoDriver *demo; - - demo = (DemoDriver *) calloc(1, sizeof(DemoDriver)); - if (!demo) { - return NULL; - } - - /* First fill in the dispatch table with defaults */ - _eglInitDriverFallbacks(&demo->Base); - /* then plug in our Demo-specific functions */ - demo->Base.API.Initialize = demoInitialize; - demo->Base.API.Terminate = demoTerminate; - demo->Base.API.CreateContext = demoCreateContext; - demo->Base.API.MakeCurrent = demoMakeCurrent; - demo->Base.API.CreateWindowSurface = demoCreateWindowSurface; - demo->Base.API.CreatePixmapSurface = demoCreatePixmapSurface; - demo->Base.API.CreatePbufferSurface = demoCreatePbufferSurface; - demo->Base.API.DestroySurface = demoDestroySurface; - demo->Base.API.DestroyContext = demoDestroyContext; - - demo->Base.Name = "egl/demo"; - demo->Base.Unload = demoUnload; - - return &demo->Base; -} -- cgit v1.2.3 From 2a928899e345e400c4266910b4e33b36a20575e2 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 Jan 2010 15:12:19 +0800 Subject: egl: Remove USING_EGL and the related drivers. They do not build for a long while and there seems to be no active users. It might be better for them to live in the git histroy. --- configs/autoconf.in | 1 - configs/linux-dri-xcb | 13 - configs/linux-egl | 6 - configure.ac | 8 - src/mesa/drivers/dri/fb/Makefile | 3 - src/mesa/drivers/dri/fb/fb_egl.c | 881 ------------------ src/mesa/drivers/dri/r200/Makefile | 4 - src/mesa/drivers/dri/r200/server/radeon_egl.c | 1 - src/mesa/drivers/dri/r300/Makefile | 4 - src/mesa/drivers/dri/r300/server/radeon_egl.c | 1 - src/mesa/drivers/dri/r600/Makefile | 4 - src/mesa/drivers/dri/r600/server/radeon_egl.c | 1 - src/mesa/drivers/dri/radeon/server/radeon_egl.c | 1088 ----------------------- 13 files changed, 2015 deletions(-) delete mode 100644 src/mesa/drivers/dri/fb/fb_egl.c delete mode 120000 src/mesa/drivers/dri/r200/server/radeon_egl.c delete mode 120000 src/mesa/drivers/dri/r300/server/radeon_egl.c delete mode 120000 src/mesa/drivers/dri/r600/server/radeon_egl.c delete mode 100644 src/mesa/drivers/dri/radeon/server/radeon_egl.c diff --git a/configs/autoconf.in b/configs/autoconf.in index c6d315e4d2..d9fa2dafe9 100644 --- a/configs/autoconf.in +++ b/configs/autoconf.in @@ -85,7 +85,6 @@ PROGRAM_DIRS = @PROGRAM_DIRS@ DRI_DIRS = @DRI_DIRS@ WINDOW_SYSTEM = @WINDOW_SYSTEM@ EGL_DISPLAYS = @EGL_DISPLAYS@ -USING_EGL = @USING_EGL@ # Dependencies X11_INCLUDES = @X11_INCLUDES@ diff --git a/configs/linux-dri-xcb b/configs/linux-dri-xcb index 827fb97330..7b99dccdb8 100644 --- a/configs/linux-dri-xcb +++ b/configs/linux-dri-xcb @@ -47,21 +47,8 @@ DRI_LIB_DEPS = $(EXTRA_LIB_PATH) -lm -lpthread -lexpat -ldl $(LIBDRM_LIB) GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lm -lpthread -ldl \ $(LIBDRM_LIB) $(shell pkg-config --libs xcb) $(shell pkg-config --libs x11-xcb) $(shell pkg-config --libs xcb-glx) - -# This is now 0 by default since it seems to confuse the hell out of people -# and generate a lot of extra noise on bugzilla. If you need to build with -# EGL, do 'make linux-dri USING_EGL=1' - -USING_EGL=0 - -# Directories -ifeq ($(USING_EGL), 1) -SRC_DIRS = egl glx/x11 gallium mesa glu glut/glx glew glw -PROGRAM_DIRS = egl -else SRC_DIRS = glx/x11 gallium mesa glu glut/glx glew glw PROGRAM_DIRS = xdemos -endif DRIVER_DIRS = dri WINDOW_SYSTEM=dri diff --git a/configs/linux-egl b/configs/linux-egl index e906806f4b..6494a68aeb 100644 --- a/configs/linux-egl +++ b/configs/linux-egl @@ -46,12 +46,6 @@ GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lXdamage -lXfixes \ $(LIBDRM_LIB) -# This is now 0 by default since it seems to confuse the hell out of people -# and generate a lot of extra noise on bugzilla. If you need to build with -# EGL, do 'make linux-dri USING_EGL=1' - -USING_EGL=0 - # Directories SRC_DIRS = gallium mesa gallium/winsys glu egl PROGRAM_DIRS = egl diff --git a/configure.ac b/configure.ac index 619ed47bcb..e5c2386320 100644 --- a/configure.ac +++ b/configure.ac @@ -699,10 +699,6 @@ yes) ;; esac -dnl Just default to no EGL for now -USING_EGL=0 -AC_SUBST([USING_EGL]) - dnl Set DRI_DIRS, DEFINES and LIB_DEPS if test "$mesa_driver" = dri; then # Use TLS in GLX? @@ -710,10 +706,6 @@ if test "$mesa_driver" = dri; then DEFINES="$DEFINES -DGLX_USE_TLS -DPTHREADS" fi - if test "x$USING_EGL" = x1; then - PROGRAM_DIRS="egl" - fi - # Platform specific settings and drivers to build case "$host_os" in linux*) diff --git a/src/mesa/drivers/dri/fb/Makefile b/src/mesa/drivers/dri/fb/Makefile index cf9b3a8556..848e2041e2 100644 --- a/src/mesa/drivers/dri/fb/Makefile +++ b/src/mesa/drivers/dri/fb/Makefile @@ -5,9 +5,6 @@ include $(TOP)/configs/current LIBNAME = fb_dri.so -ifeq ($(USING_EGL), 1) -EGL_SOURCES = server/radeon_egl.c -endif DRIVER_SOURCES = \ fb_dri.c \ diff --git a/src/mesa/drivers/dri/fb/fb_egl.c b/src/mesa/drivers/dri/fb/fb_egl.c deleted file mode 100644 index 02e44bb8ee..0000000000 --- a/src/mesa/drivers/dri/fb/fb_egl.c +++ /dev/null @@ -1,881 +0,0 @@ -/* - * Test egl driver for fb_dri.so - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "utils.h" -#include "buffers.h" -#include "main/extensions.h" -#include "main/framebuffer.h" -#include "main/renderbuffer.h" -#include "vbo/vbo.h" -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/tnl.h" -#include "tnl/tcontext.h" -#include "tnl/t_pipeline.h" -#include "drivers/common/driverfuncs.h" -#include "drirenderbuffer.h" - -#include "eglconfig.h" -#include "eglmain/context.h" -#include "egldisplay.h" -#include "egldriver.h" -#include "eglglobals.h" -#include "eglmode.h" -#include "eglscreen.h" -#include "eglsurface.h" - -extern void -fbSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis); - -/** - * fb driver-specific driver class derived from _EGLDriver - */ -typedef struct fb_driver -{ - _EGLDriver Base; /* base class/object */ - GLuint fbStuff; -} fbDriver; - -/** - * fb display-specific driver class derived from _EGLDisplay - */ -typedef struct fb_display -{ - _EGLDisplay Base; /* base class/object */ - void *pFB; -} fbDisplay; - -/** - * fb driver-specific screen class derived from _EGLScreen - */ -typedef struct fb_screen -{ - _EGLScreen Base; - char fb[NAME_MAX]; -} fbScreen; - - -/** - * fb driver-specific surface class derived from _EGLSurface - */ -typedef struct fb_surface -{ - _EGLSurface Base; /* base class/object */ - struct gl_framebuffer *mesa_framebuffer; -} fbSurface; - - -/** - * fb driver-specific context class derived from _EGLContext - */ -typedef struct fb_context -{ - _EGLContext Base; /* base class/object */ - GLcontext *glCtx; - struct { - __DRIcontext *context; - __DRIscreen *screen; - __DRIdrawable *drawable; /* drawable bound to this ctx */ - } dri; -} fbContext, *fbContextPtr; - -#define FB_CONTEXT(ctx) ((fbContextPtr)(ctx->DriverCtx)) - - -static EGLBoolean -fbFillInConfigs(_EGLDisplay *disp, unsigned pixel_bits, unsigned depth_bits, - unsigned stencil_bits, GLboolean have_back_buffer) { - _EGLConfig *configs; - _EGLConfig *c; - unsigned int i, num_configs; - unsigned int depth_buffer_factor; - unsigned int back_buffer_factor; - GLenum fb_format; - GLenum fb_type; - - /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy - * enough to add support. Basically, if a context is created with an - * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping - * will never be used. - */ - static const GLenum back_buffer_modes[] = { - GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */ - }; - - uint8_t depth_bits_array[2]; - uint8_t stencil_bits_array[2]; - - depth_bits_array[0] = 0; - depth_bits_array[1] = depth_bits; - - /* Just like with the accumulation buffer, always provide some modes - * with a stencil buffer. It will be a sw fallback, but some apps won't - * care about that. - */ - stencil_bits_array[0] = 0; - stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits; - - depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1; - back_buffer_factor = (have_back_buffer) ? 2 : 1; - - num_configs = depth_buffer_factor * back_buffer_factor * 2; - - if (pixel_bits == 16) { - fb_format = GL_RGB; - fb_type = GL_UNSIGNED_SHORT_5_6_5; - } else { - fb_format = GL_RGBA; - fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; - } - - configs = calloc(sizeof(*configs), num_configs); - c = configs; - if (!_eglFillInConfigs(c, fb_format, fb_type, - depth_bits_array, stencil_bits_array, depth_buffer_factor, - back_buffer_modes, back_buffer_factor, - GLX_TRUE_COLOR)) { - fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", - __func__, __LINE__); - return EGL_FALSE; - } - - /* Mark the visual as slow if there are "fake" stencil bits. - */ - for (i = 0, c = configs; i < num_configs; i++, c++) { - int stencil = GET_CONFIG_ATTRIB(c, EGL_STENCIL_SIZE); - if ((stencil != 0) && (stencil != stencil_bits)) { - SET_CONFIG_ATTRIB(c, EGL_CONFIG_CAVEAT, EGL_SLOW_CONFIG); - } - } - - for (i = 0, c = configs; i < num_configs; i++, c++) - _eglAddConfig(disp, c); - - free(configs); - - return EGL_TRUE; -} - -static EGLBoolean -fbSetupFramebuffer(fbDisplay *disp, char *fbdev) -{ - int fd; - char dev[20]; - struct fb_var_screeninfo varInfo; - struct fb_fix_screeninfo fixedInfo; - - snprintf(dev, sizeof(dev), "/dev/%s", fbdev); - - /* open the framebuffer device */ - fd = open(dev, O_RDWR); - if (fd < 0) { - fprintf(stderr, "Error opening %s: %s\n", fbdev, strerror(errno)); - return EGL_FALSE; - } - - /* get the original variable screen info */ - if (ioctl(fd, FBIOGET_VSCREENINFO, &varInfo)) { - fprintf(stderr, "error: ioctl(FBIOGET_VSCREENINFO) failed: %s\n", - strerror(errno)); - return EGL_FALSE; - } - - /* Turn off hw accels (otherwise mmap of mmio region will be - * refused) - */ - if (varInfo.accel_flags) { - varInfo.accel_flags = 0; - if (ioctl(fd, FBIOPUT_VSCREENINFO, &varInfo)) { - fprintf(stderr, "error: ioctl(FBIOPUT_VSCREENINFO) failed: %s\n", - strerror(errno)); - return EGL_FALSE; - } - } - - /* Get the fixed screen info */ - if (ioctl(fd, FBIOGET_FSCREENINFO, &fixedInfo)) { - fprintf(stderr, "error: ioctl(FBIOGET_FSCREENINFO) failed: %s\n", - strerror(errno)); - return EGL_FALSE; - } - - if (fixedInfo.visual == FB_VISUAL_DIRECTCOLOR) { - struct fb_cmap cmap; - unsigned short red[256], green[256], blue[256]; - int rcols = 1 << varInfo.red.length; - int gcols = 1 << varInfo.green.length; - int bcols = 1 << varInfo.blue.length; - int i; - - cmap.start = 0; - cmap.len = gcols; - cmap.red = red; - cmap.green = green; - cmap.blue = blue; - cmap.transp = NULL; - - for (i = 0; i < rcols ; i++) - red[i] = (65536/(rcols-1)) * i; - - for (i = 0; i < gcols ; i++) - green[i] = (65536/(gcols-1)) * i; - - for (i = 0; i < bcols ; i++) - blue[i] = (65536/(bcols-1)) * i; - - if (ioctl(fd, FBIOPUTCMAP, (void *) &cmap) < 0) { - fprintf(stderr, "ioctl(FBIOPUTCMAP) failed [%d]\n", i); - exit(1); - } - } - - /* mmap the framebuffer into our address space */ - if (!disp->pFB) - disp->pFB = (caddr_t)mmap(0, /* start */ - fixedInfo.smem_len, /* bytes */ - PROT_READ | PROT_WRITE, /* prot */ - MAP_SHARED, /* flags */ - fd, /* fd */ - 0); /* offset */ - if (disp->pFB == (caddr_t)-1) { - fprintf(stderr, "error: unable to mmap framebuffer: %s\n", - strerror(errno)); - return EGL_FALSE; - } - - return EGL_TRUE; -} - -const char *sysfs = "/sys/class/graphics"; - -static EGLBoolean -fbInitialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor) -{ - _EGLDisplay *disp = _eglLookupDisplay(dpy); - fbDisplay *display; - fbScreen *s; - _EGLScreen *scrn; - char c; - unsigned int x, y, r; - DIR *dir; - FILE *file; - struct dirent *dirent; - char path[NAME_MAX]; - - /* Switch display structure to one with our private fields */ - display = calloc(1, sizeof(*display)); - display->Base = *disp; - _eglHashInsert(_eglGlobal.Displays, disp->Handle, display); - free(disp); - - *major = 1; - *minor = 0; - - dir = opendir(sysfs); - if (!dir) { - printf("EGL - %s framebuffer device not found.", sysfs); - return EGL_FALSE; - } - - while ((dirent = readdir(dir))) { /* assignment! */ - - if (dirent->d_name[0] != 'f') - continue; - if (dirent->d_name[1] != 'b') - continue; - - if (fbSetupFramebuffer(display, dirent->d_name) == EGL_FALSE) - continue; - - /* Create a screen */ - s = (fbScreen *) calloc(1, sizeof(fbScreen)); - if (!s) - return EGL_FALSE; - - strncpy(s->fb, dirent->d_name, NAME_MAX); - scrn = &s->Base; - _eglInitScreen(scrn); - _eglAddScreen(&display->Base, scrn); - - snprintf(path, sizeof(path), "%s/%s/modes", sysfs, s->fb); - file = fopen(path, "r"); - while (fgets(path, sizeof(path), file)) { - sscanf(path, "%c:%ux%u-%u", &c, &x, &y, &r); - _eglAddMode(scrn, x, y, r * 1000, path); - } - fclose(file); - - fbFillInConfigs(&display->Base, 32, 24, 8, 1); - - } - closedir(dir); - - drv->Initialized = EGL_TRUE; - return EGL_TRUE; -} - - -static fbDisplay * -Lookup_fbDisplay(EGLDisplay dpy) -{ - _EGLDisplay *d = _eglLookupDisplay(dpy); - return (fbDisplay *) d; -} - - -static fbScreen * -Lookup_fbScreen(EGLDisplay dpy, EGLScreenMESA screen) -{ - _EGLScreen *s = _eglLookupScreen(dpy, screen); - return (fbScreen *) s; -} - - -static fbContext * -Lookup_fbContext(EGLContext ctx) -{ - _EGLContext *c = _eglLookupContext(ctx); - return (fbContext *) c; -} - - -static fbSurface * -Lookup_fbSurface(EGLSurface surf) -{ - _EGLSurface *s = _eglLookupSurface(surf); - return (fbSurface *) s; -} - - -static EGLBoolean -fbTerminate(_EGLDriver *drv, EGLDisplay dpy) -{ - fbDisplay *display = Lookup_fbDisplay(dpy); - _eglCleanupDisplay(&display->Base); - free(display); - free(drv); - return EGL_TRUE; -} - - -static const GLubyte * -get_string(GLcontext *ctx, GLenum pname) -{ - (void) ctx; - switch (pname) { - case GL_RENDERER: - return (const GLubyte *) "Mesa dumb framebuffer"; - default: - return NULL; - } -} - - -static void -update_state( GLcontext *ctx, GLuint new_state ) -{ - /* not much to do here - pass it on */ - _swrast_InvalidateState( ctx, new_state ); - _swsetup_InvalidateState( ctx, new_state ); - _vbo_InvalidateState( ctx, new_state ); - _tnl_InvalidateState( ctx, new_state ); -} - - -/** - * Called by ctx->Driver.GetBufferSize from in core Mesa to query the - * current framebuffer size. - */ -static void -get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height ) -{ - *width = buffer->Width; - *height = buffer->Height; -} - - -static void -updateFramebufferSize(GLcontext *ctx) -{ - fbContextPtr fbmesa = FB_CONTEXT(ctx); - struct gl_framebuffer *fb = ctx->WinSysDrawBuffer; - if (fbmesa->dri.drawable->w != fb->Width || - fbmesa->dri.drawable->h != fb->Height) { - driUpdateFramebufferSize(ctx, fbmesa->dri.drawable); - } -} - -static void -viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) -{ - /* XXX this should be called after we acquire the DRI lock, not here */ - updateFramebufferSize(ctx); -} - - -static void -init_core_functions( struct dd_function_table *functions ) -{ - functions->GetString = get_string; - functions->UpdateState = update_state; - functions->GetBufferSize = get_buffer_size; - functions->Viewport = viewport; - - functions->Clear = _swrast_Clear; /* could accelerate with blits */ -} - - -static EGLContext -fbCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list) -{ - GLcontext *ctx; - _EGLConfig *conf; - fbContext *c; - _EGLDisplay *disp = _eglLookupDisplay(dpy); - struct dd_function_table functions; - GLvisual vis; - int i; - - conf = _eglLookupConfig(drv, dpy, config); - if (!conf) { - _eglError(EGL_BAD_CONFIG, "eglCreateContext"); - return EGL_NO_CONTEXT; - } - - for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { - switch (attrib_list[i]) { - /* no attribs defined for now */ - default: - _eglError(EGL_BAD_ATTRIBUTE, "eglCreateContext"); - return EGL_NO_CONTEXT; - } - } - - c = (fbContext *) calloc(1, sizeof(fbContext)); - if (!c) - return EGL_NO_CONTEXT; - - _eglInitContext(&c->Base); - c->Base.Display = disp; - c->Base.Config = conf; - c->Base.DrawSurface = EGL_NO_SURFACE; - c->Base.ReadSurface = EGL_NO_SURFACE; - - /* link to display */ - _eglLinkContext(&c->Base, disp); - assert(c->Base.Handle); - - /* Init default driver functions then plug in our FBdev-specific functions - */ - _mesa_init_driver_functions(&functions); - init_core_functions(&functions); - - _eglConfigToContextModesRec(conf, &vis); - - ctx = c->glCtx = _mesa_create_context(&vis, NULL, &functions, (void *)c); - if (!c->glCtx) { - _mesa_free(c); - return GL_FALSE; - } - - /* Create module contexts */ - _swrast_CreateContext( ctx ); - _vbo_CreateContext( ctx ); - _tnl_CreateContext( ctx ); - _swsetup_CreateContext( ctx ); - _swsetup_Wakeup( ctx ); - - - /* use default TCL pipeline */ - { - TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl->Driver.RunPipeline = _tnl_run_pipeline; - } - - _mesa_enable_sw_extensions(ctx); - - return c->Base.Handle; -} - - -static EGLSurface -fbCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list) -{ - int i; - for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { - switch (attrib_list[i]) { - /* no attribs at this time */ - default: - _eglError(EGL_BAD_ATTRIBUTE, "eglCreateWindowSurface"); - return EGL_NO_SURFACE; - } - } - printf("eglCreateWindowSurface()\n"); - /* XXX unfinished */ - - return EGL_NO_SURFACE; -} - - -static EGLSurface -fbCreatePixmapSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, NativePixmapType pixmap, const EGLint *attrib_list) -{ - _EGLConfig *conf; - EGLint i; - - conf = _eglLookupConfig(drv, dpy, config); - if (!conf) { - _eglError(EGL_BAD_CONFIG, "eglCreatePixmapSurface"); - return EGL_NO_SURFACE; - } - - for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { - switch (attrib_list[i]) { - /* no attribs at this time */ - default: - _eglError(EGL_BAD_ATTRIBUTE, "eglCreatePixmapSurface"); - return EGL_NO_SURFACE; - } - } - - if (conf->Attrib[EGL_SURFACE_TYPE - FIRST_ATTRIB] == 0) { - _eglError(EGL_BAD_MATCH, "eglCreatePixmapSurface"); - return EGL_NO_SURFACE; - } - - printf("eglCreatePixmapSurface()\n"); - return EGL_NO_SURFACE; -} - - -static EGLSurface -fbCreatePbufferSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list) -{ - fbSurface *surf; - - surf = (fbSurface *) calloc(1, sizeof(fbSurface)); - if (!surf) { - return EGL_NO_SURFACE; - } - - if (_eglInitPbufferSurface(&surf->Base, drv, dpy, config, attrib_list) == EGL_NO_SURFACE) { - free(surf); - return EGL_NO_SURFACE; - } - - /* create software-based pbuffer */ - { - GLcontext *ctx = NULL; /* this _should_ be OK */ - GLvisual vis; - _EGLConfig *conf = _eglLookupConfig(drv, dpy, config); - assert(conf); /* bad config should be caught earlier */ - _eglConfigToContextModesRec(conf, &vis); - - surf->mesa_framebuffer = _mesa_create_framebuffer(&vis); - _mesa_add_soft_renderbuffers(surf->mesa_framebuffer, - GL_TRUE, /* color bufs */ - vis.haveDepthBuffer, - vis.haveStencilBuffer, - vis.haveAccumBuffer, - GL_FALSE, /* alpha */ - GL_FALSE /* aux */ ); - - /* set pbuffer/framebuffer size */ - _mesa_resize_framebuffer(ctx, surf->mesa_framebuffer, - surf->Base.Width, surf->Base.Height); - } - - return surf->Base.Handle; -} - - -static EGLBoolean -fbDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface) -{ - fbSurface *fs = Lookup_fbSurface(surface); - _eglUnlinkSurface(&fs->Base); - if (!_eglIsSurfaceBound(&fs->Base)) - free(fs); - return EGL_TRUE; -} - - -static EGLBoolean -fbDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext context) -{ - fbContext *fc = Lookup_fbContext(context); - _eglUnlinkContext(&fc->Base); - if (!_eglIsContextBound(&fc->Base)) - free(fc); - return EGL_TRUE; -} - - -static EGLBoolean -fbMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext context) -{ - fbSurface *readSurf = Lookup_fbSurface(read); - fbSurface *drawSurf = Lookup_fbSurface(draw); - fbContext *ctx = Lookup_fbContext(context); - EGLBoolean b; - - b = _eglMakeCurrent(drv, dpy, draw, read, context); - if (!b) - return EGL_FALSE; - - if (ctx) { - _mesa_make_current( ctx->glCtx, - drawSurf->mesa_framebuffer, - readSurf->mesa_framebuffer); - } else - _mesa_make_current( NULL, NULL, NULL ); - - return EGL_TRUE; -} - - -/** - * Create a drawing surface which can be directly displayed on a screen. - */ -static EGLSurface -fbCreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig cfg, - const EGLint *attrib_list) -{ - _EGLConfig *config = _eglLookupConfig(drv, dpy, cfg); - fbDisplay *display = Lookup_fbDisplay(dpy); - fbSurface *surface; - EGLSurface surf; - GLvisual vis; - GLcontext *ctx = NULL; /* this should be OK */ - int origin, bytesPerPixel; - int width, height, stride; - - surface = (fbSurface *) malloc(sizeof(*surface)); - if (!surface) { - return EGL_NO_SURFACE; - } - - /* init base class, error check, etc. */ - surf = _eglInitScreenSurface(&surface->Base, drv, dpy, cfg, attrib_list); - if (surf == EGL_NO_SURFACE) { - free(surface); - return EGL_NO_SURFACE; - } - - /* convert EGLConfig to GLvisual */ - _eglConfigToContextModesRec(config, &vis); - - /* create Mesa framebuffer */ - surface->mesa_framebuffer = _mesa_create_framebuffer(&vis); - if (!surface->mesa_framebuffer) { - free(surface); - _eglUnlinkSurface(&surface->Base); - return EGL_NO_SURFACE; - } - - width = surface->Base.Width; - height = surface->Base.Height; - bytesPerPixel = vis.rgbBits / 8; - stride = width * bytesPerPixel; - origin = 0; - - /* front color renderbuffer */ - { - driRenderbuffer *drb = driNewRenderbuffer(MESA_FORMAT_ARGB8888, display->pFB, - bytesPerPixel, - origin, stride, NULL); - fbSetSpanFunctions(drb, &vis); - _mesa_add_renderbuffer(surface->mesa_framebuffer, - BUFFER_FRONT_LEFT, &drb->Base); - } - - /* back color renderbuffer */ - if (vis.doubleBufferMode) { - GLubyte *backBuf = _mesa_malloc(stride * height); - driRenderbuffer *drb = driNewRenderbuffer(MESA_FORMAT_ARGB8888, backBuf, - bytesPerPixel, - origin, stride, NULL); - fbSetSpanFunctions(drb, &vis); - _mesa_add_renderbuffer(surface->mesa_framebuffer, - BUFFER_BACK_LEFT, &drb->Base); - } - - /* other renderbuffers- software based */ - _mesa_add_soft_renderbuffers(surface->mesa_framebuffer, - GL_FALSE, /* color */ - vis.haveDepthBuffer, - vis.haveStencilBuffer, - vis.haveAccumBuffer, - GL_FALSE, /* alpha */ - GL_FALSE /* aux */); - - _mesa_resize_framebuffer(ctx, surface->mesa_framebuffer, width, height); - - return surf; -} - - -/** - * Show the given surface on the named screen. - * If surface is EGL_NO_SURFACE, disable the screen's output. - */ -static EGLBoolean -fbShowSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, - EGLSurface surface, EGLModeMESA m) -{ - fbDisplay *display = Lookup_fbDisplay(dpy); - fbScreen *scrn = Lookup_fbScreen(dpy, screen); - fbSurface *surf = Lookup_fbSurface(surface); - FILE *file; - char buffer[NAME_MAX]; - _EGLMode *mode = _eglLookupMode(dpy, m); - int bits; - - if (!_eglShowSurfaceMESA(drv, dpy, screen, surface, m)) - return EGL_FALSE; - - snprintf(buffer, sizeof(buffer), "%s/%s/blank", sysfs, scrn->fb); - - file = fopen(buffer, "r+"); - if (!file) { -err: - printf("chown all fb sysfs attrib to allow write - %s\n", buffer); - return EGL_FALSE; - } - snprintf(buffer, sizeof(buffer), "%d", (m == EGL_NO_MODE_MESA ? VESA_POWERDOWN : VESA_VSYNC_SUSPEND)); - fputs(buffer, file); - fclose(file); - - if (m == EGL_NO_MODE_MESA) - return EGL_TRUE; - - snprintf(buffer, sizeof(buffer), "%s/%s/mode", sysfs, scrn->fb); - - file = fopen(buffer, "r+"); - if (!file) - goto err; - fputs(mode->Name, file); - fclose(file); - - snprintf(buffer, sizeof(buffer), "%s/%s/bits_per_pixel", sysfs, scrn->fb); - - file = fopen(buffer, "r+"); - if (!file) - goto err; - bits = GET_CONFIG_ATTRIB(surf->Base.Config, EGL_BUFFER_SIZE); - snprintf(buffer, sizeof(buffer), "%d", bits); - fputs(buffer, file); - fclose(file); - - fbSetupFramebuffer(display, scrn->fb); - - snprintf(buffer, sizeof(buffer), "%s/%s/blank", sysfs, scrn->fb); - - file = fopen(buffer, "r+"); - if (!file) - goto err; - - snprintf(buffer, sizeof(buffer), "%d", VESA_NO_BLANKING); - fputs(buffer, file); - fclose(file); - - return EGL_TRUE; -} - - -/* If the backbuffer is on a videocard, this is extraordinarily slow! - */ -static EGLBoolean -fbSwapBuffers(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw) -{ - fbContext *context = (fbContext *)_eglGetCurrentContext(); - fbSurface *fs = Lookup_fbSurface(draw); - struct gl_renderbuffer * front_renderbuffer = fs->mesa_framebuffer->Attachment[BUFFER_FRONT_LEFT].Renderbuffer; - void *frontBuffer = front_renderbuffer->Data; - int currentPitch = ((driRenderbuffer *)front_renderbuffer)->pitch; - void *backBuffer = fs->mesa_framebuffer->Attachment[BUFFER_BACK_LEFT].Renderbuffer->Data; - - if (!_eglSwapBuffers(drv, dpy, draw)) - return EGL_FALSE; - - if (context) { - GLcontext *ctx = context->glCtx; - - if (ctx->Visual.doubleBufferMode) { - int i; - int offset = 0; - char *tmp = _mesa_malloc(currentPitch); - - _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */ - - ASSERT(frontBuffer); - ASSERT(backBuffer); - - for (i = 0; i < fs->Base.Height; i++) { - _mesa_memcpy(tmp, (char *) backBuffer + offset, - currentPitch); - _mesa_memcpy((char *) frontBuffer + offset, tmp, - currentPitch); - offset += currentPitch; - } - - _mesa_free(tmp); - } - } - else { - /* XXX this shouldn't be an error but we can't handle it for now */ - _mesa_problem(NULL, "fbSwapBuffers: drawable has no context!\n"); - return EGL_FALSE; - } - return EGL_TRUE; -} - - -/** - * The bootstrap function. Return a new fbDriver object and - * plug in API functions. - */ -_EGLDriver * -_eglMain(_EGLDisplay *dpy) -{ - fbDriver *fb; - - fb = (fbDriver *) calloc(1, sizeof(fbDriver)); - if (!fb) { - return NULL; - } - - /* First fill in the dispatch table with defaults */ - _eglInitDriverFallbacks(&fb->Base); - - /* then plug in our fb-specific functions */ - fb->Base.Initialize = fbInitialize; - fb->Base.Terminate = fbTerminate; - fb->Base.CreateContext = fbCreateContext; - fb->Base.MakeCurrent = fbMakeCurrent; - fb->Base.CreateWindowSurface = fbCreateWindowSurface; - fb->Base.CreatePixmapSurface = fbCreatePixmapSurface; - fb->Base.CreatePbufferSurface = fbCreatePbufferSurface; - fb->Base.DestroySurface = fbDestroySurface; - fb->Base.DestroyContext = fbDestroyContext; - fb->Base.CreateScreenSurfaceMESA = fbCreateScreenSurfaceMESA; - fb->Base.ShowSurfaceMESA = fbShowSurfaceMESA; - fb->Base.SwapBuffers = fbSwapBuffers; - - /* enable supported extensions */ - fb->Base.MESA_screen_surface = EGL_TRUE; - fb->Base.MESA_copy_context = EGL_TRUE; - - return &fb->Base; -} diff --git a/src/mesa/drivers/dri/r200/Makefile b/src/mesa/drivers/dri/r200/Makefile index a93dbaee91..14eb96c1ba 100644 --- a/src/mesa/drivers/dri/r200/Makefile +++ b/src/mesa/drivers/dri/r200/Makefile @@ -9,10 +9,6 @@ LIBNAME = r200_dri.so MINIGLX_SOURCES = server/radeon_dri.c -ifeq ($(USING_EGL), 1) -EGL_SOURCES = server/radeon_egl.c -endif - ifeq ($(RADEON_LDFLAGS),) CS_SOURCES = radeon_cs_space_drm.c radeon_bo.c radeon_cs.c endif diff --git a/src/mesa/drivers/dri/r200/server/radeon_egl.c b/src/mesa/drivers/dri/r200/server/radeon_egl.c deleted file mode 120000 index d7735a7643..0000000000 --- a/src/mesa/drivers/dri/r200/server/radeon_egl.c +++ /dev/null @@ -1 +0,0 @@ -../../radeon/server/radeon_egl.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/r300/Makefile b/src/mesa/drivers/dri/r300/Makefile index acc4d4d8b1..04459c2ddf 100644 --- a/src/mesa/drivers/dri/r300/Makefile +++ b/src/mesa/drivers/dri/r300/Makefile @@ -9,10 +9,6 @@ LIBNAME = r300_dri.so MINIGLX_SOURCES = server/radeon_dri.c -ifeq ($(USING_EGL), 1) -EGL_SOURCES = server/radeon_egl.c -endif - ifeq ($(RADEON_LDFLAGS),) CS_SOURCES = radeon_cs_space_drm.c radeon_bo.c radeon_cs.c endif diff --git a/src/mesa/drivers/dri/r300/server/radeon_egl.c b/src/mesa/drivers/dri/r300/server/radeon_egl.c deleted file mode 120000 index d7735a7643..0000000000 --- a/src/mesa/drivers/dri/r300/server/radeon_egl.c +++ /dev/null @@ -1 +0,0 @@ -../../radeon/server/radeon_egl.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/r600/Makefile b/src/mesa/drivers/dri/r600/Makefile index 8a45fc51b3..5d50941539 100644 --- a/src/mesa/drivers/dri/r600/Makefile +++ b/src/mesa/drivers/dri/r600/Makefile @@ -9,10 +9,6 @@ LIBNAME = r600_dri.so MINIGLX_SOURCES = server/radeon_dri.c -ifeq ($(USING_EGL), 1) -EGL_SOURCES = server/radeon_egl.c -endif - ifeq ($(RADEON_LDFLAGS),) CS_SOURCES = radeon_cs_space_drm.c radeon_bo.c radeon_cs.c endif diff --git a/src/mesa/drivers/dri/r600/server/radeon_egl.c b/src/mesa/drivers/dri/r600/server/radeon_egl.c deleted file mode 120000 index d7735a7643..0000000000 --- a/src/mesa/drivers/dri/r600/server/radeon_egl.c +++ /dev/null @@ -1 +0,0 @@ -../../radeon/server/radeon_egl.c \ No newline at end of file diff --git a/src/mesa/drivers/dri/radeon/server/radeon_egl.c b/src/mesa/drivers/dri/radeon/server/radeon_egl.c deleted file mode 100644 index c16d66e4ec..0000000000 --- a/src/mesa/drivers/dri/radeon/server/radeon_egl.c +++ /dev/null @@ -1,1088 +0,0 @@ -/* - * EGL driver for radeon_dri.so - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "eglconfig.h" -#include "eglcontext.h" -#include "egldisplay.h" -#include "egldriver.h" -#include "eglglobals.h" -#include "egllog.h" -#include "eglmode.h" -#include "eglscreen.h" -#include "eglsurface.h" -#include "egldri.h" - -#include "mtypes.h" -#include "memops.h" -#include "drm.h" -#include "drm_sarea.h" -#include "radeon_drm.h" -#include "radeon_dri.h" -#include "radeon.h" - -static size_t radeon_drm_page_size; - -/** - * radeon driver-specific driver class derived from _EGLDriver - */ -typedef struct radeon_driver -{ - _EGLDriver Base; /* base class/object */ - GLuint radeonStuff; -} radeonDriver; - -static int -RADEONSetParam(driDisplay *disp, int param, int value) -{ - drm_radeon_setparam_t sp; - int ret; - - memset(&sp, 0, sizeof(sp)); - sp.param = param; - sp.value = value; - - if ((ret=drmCommandWrite(disp->drmFD, DRM_RADEON_SETPARAM, &sp, sizeof(sp)))) { - fprintf(stderr,"Set param failed\n", ret); - return -1; - } - - return 0; -} - -static int -RADEONCheckDRMVersion(driDisplay *disp, RADEONInfoPtr info) -{ - drmVersionPtr version; - - version = drmGetVersion(disp->drmFD); - if (version) { - int req_minor, req_patch; - - /* Need 1.21.x for card type detection getparam - */ - req_minor = 21; - req_patch = 0; - - if (version->version_major != 1 || - version->version_minor < req_minor || - (version->version_minor == req_minor && - version->version_patchlevel < req_patch)) { - /* Incompatible drm version */ - fprintf(stderr, - "[dri] RADEONDRIScreenInit failed because of a version " - "mismatch.\n" - "[dri] radeon.o kernel module version is %d.%d.%d " - "but version 1.%d.%d or newer is needed.\n" - "[dri] Disabling DRI.\n", - version->version_major, - version->version_minor, - version->version_patchlevel, - req_minor, - req_patch); - drmFreeVersion(version); - return 0; - } - - info->drmMinor = version->version_minor; - drmFreeVersion(version); - } - - return 1; -} - - -/** - * \brief Compute base 2 logarithm. - * - * \param val value. - * - * \return base 2 logarithm of \p val. - */ -static int RADEONMinBits(int val) -{ - int bits; - - if (!val) return 1; - for (bits = 0; val; val >>= 1, ++bits); - return bits; -} - - -/* Initialize the PCI GART state. Request memory for use in PCI space, - * and initialize the Radeon registers to point to that memory. - */ -static int RADEONDRIPciInit(driDisplay *disp, RADEONInfoPtr info) -{ - int ret; - int flags = DRM_READ_ONLY | DRM_LOCKED | DRM_KERNEL; - int s, l; - - ret = drmScatterGatherAlloc(disp->drmFD, info->gartSize*1024*1024, - &info->gartMemHandle); - if (ret < 0) { - fprintf(stderr, "[pci] Out of memory (%d)\n", ret); - return 0; - } - fprintf(stderr, - "[pci] %d kB allocated with handle 0x%04lx\n", - info->gartSize*1024, (long) info->gartMemHandle); - - info->gartOffset = 0; - - /* Initialize the CP ring buffer data */ - info->ringStart = info->gartOffset; - info->ringMapSize = info->ringSize*1024*1024 + radeon_drm_page_size; - - info->ringReadOffset = info->ringStart + info->ringMapSize; - info->ringReadMapSize = radeon_drm_page_size; - - /* Reserve space for vertex/indirect buffers */ - info->bufStart = info->ringReadOffset + info->ringReadMapSize; - info->bufMapSize = info->bufSize*1024*1024; - - /* Reserve the rest for AGP textures */ - info->gartTexStart = info->bufStart + info->bufMapSize; - s = (info->gartSize*1024*1024 - info->gartTexStart); - l = RADEONMinBits((s-1) / RADEON_NR_TEX_REGIONS); - if (l < RADEON_LOG_TEX_GRANULARITY) l = RADEON_LOG_TEX_GRANULARITY; - info->gartTexMapSize = (s >> l) << l; - info->log2GARTTexGran = l; - - if (drmAddMap(disp->drmFD, info->ringStart, info->ringMapSize, - DRM_SCATTER_GATHER, flags, &info->ringHandle) < 0) { - fprintf(stderr, - "[pci] Could not add ring mapping\n"); - return 0; - } - fprintf(stderr, - "[pci] ring handle = 0x%08lx\n", info->ringHandle); - - if (drmAddMap(disp->drmFD, info->ringReadOffset, info->ringReadMapSize, - DRM_SCATTER_GATHER, flags, &info->ringReadPtrHandle) < 0) { - fprintf(stderr, - "[pci] Could not add ring read ptr mapping\n"); - return 0; - } - fprintf(stderr, - "[pci] ring read ptr handle = 0x%08lx\n", - info->ringReadPtrHandle); - - if (drmAddMap(disp->drmFD, info->bufStart, info->bufMapSize, - DRM_SCATTER_GATHER, 0, &info->bufHandle) < 0) { - fprintf(stderr, - "[pci] Could not add vertex/indirect buffers mapping\n"); - return 0; - } - fprintf(stderr, - "[pci] vertex/indirect buffers handle = 0x%08lx\n", - info->bufHandle); - - if (drmAddMap(disp->drmFD, info->gartTexStart, info->gartTexMapSize, - DRM_SCATTER_GATHER, 0, &info->gartTexHandle) < 0) { - fprintf(stderr, - "[pci] Could not add GART texture map mapping\n"); - return 0; - } - fprintf(stderr, - "[pci] GART texture map handle = 0x%08lx\n", - info->gartTexHandle); - - return 1; -} - - -/** - * \brief Initialize the AGP state - * - * \param ctx display handle. - * \param info driver private data. - * - * \return one on success, or zero on failure. - * - * Acquires and enables the AGP device. Reserves memory in the AGP space for - * the ring buffer, vertex buffers and textures. Initialize the Radeon - * registers to point to that memory and add client mappings. - */ -static int RADEONDRIAgpInit( driDisplay *disp, RADEONInfoPtr info) -{ - int mode, ret; - int s, l; - int agpmode = 1; - - if (drmAgpAcquire(disp->drmFD) < 0) { - fprintf(stderr, "[gart] AGP not available\n"); - return 0; - } - - mode = drmAgpGetMode(disp->drmFD); /* Default mode */ - /* Disable fast write entirely - too many lockups. - */ - mode &= ~RADEON_AGP_MODE_MASK; - switch (agpmode) { - case 4: mode |= RADEON_AGP_4X_MODE; - case 2: mode |= RADEON_AGP_2X_MODE; - case 1: default: mode |= RADEON_AGP_1X_MODE; - } - - if (drmAgpEnable(disp->drmFD, mode) < 0) { - fprintf(stderr, "[gart] AGP not enabled\n"); - drmAgpRelease(disp->drmFD); - return 0; - } - -#if 0 - /* Workaround for some hardware bugs */ - if (info->ChipFamily < CHIP_FAMILY_R200) - OUTREG(RADEON_AGP_CNTL, INREG(RADEON_AGP_CNTL) | 0x000e0000); -#endif - info->gartOffset = 0; - - if ((ret = drmAgpAlloc(disp->drmFD, info->gartSize*1024*1024, 0, NULL, - &info->gartMemHandle)) < 0) { - fprintf(stderr, "[gart] Out of memory (%d)\n", ret); - drmAgpRelease(disp->drmFD); - return 0; - } - fprintf(stderr, - "[gart] %d kB allocated with handle 0x%08x\n", - info->gartSize*1024, (unsigned)info->gartMemHandle); - - if (drmAgpBind(disp->drmFD, - info->gartMemHandle, info->gartOffset) < 0) { - fprintf(stderr, "[gart] Could not bind\n"); - drmAgpFree(disp->drmFD, info->gartMemHandle); - drmAgpRelease(disp->drmFD); - return 0; - } - - /* Initialize the CP ring buffer data */ - info->ringStart = info->gartOffset; - info->ringMapSize = info->ringSize*1024*1024 + radeon_drm_page_size; - - info->ringReadOffset = info->ringStart + info->ringMapSize; - info->ringReadMapSize = radeon_drm_page_size; - - /* Reserve space for vertex/indirect buffers */ - info->bufStart = info->ringReadOffset + info->ringReadMapSize; - info->bufMapSize = info->bufSize*1024*1024; - - /* Reserve the rest for AGP textures */ - info->gartTexStart = info->bufStart + info->bufMapSize; - s = (info->gartSize*1024*1024 - info->gartTexStart); - l = RADEONMinBits((s-1) / RADEON_NR_TEX_REGIONS); - if (l < RADEON_LOG_TEX_GRANULARITY) l = RADEON_LOG_TEX_GRANULARITY; - info->gartTexMapSize = (s >> l) << l; - info->log2GARTTexGran = l; - - if (drmAddMap(disp->drmFD, info->ringStart, info->ringMapSize, - DRM_AGP, DRM_READ_ONLY, &info->ringHandle) < 0) { - fprintf(stderr, "[gart] Could not add ring mapping\n"); - return 0; - } - fprintf(stderr, "[gart] ring handle = 0x%08lx\n", info->ringHandle); - - - if (drmAddMap(disp->drmFD, info->ringReadOffset, info->ringReadMapSize, - DRM_AGP, DRM_READ_ONLY, &info->ringReadPtrHandle) < 0) { - fprintf(stderr, - "[gart] Could not add ring read ptr mapping\n"); - return 0; - } - - fprintf(stderr, - "[gart] ring read ptr handle = 0x%08lx\n", - info->ringReadPtrHandle); - - if (drmAddMap(disp->drmFD, info->bufStart, info->bufMapSize, - DRM_AGP, 0, &info->bufHandle) < 0) { - fprintf(stderr, - "[gart] Could not add vertex/indirect buffers mapping\n"); - return 0; - } - fprintf(stderr, - "[gart] vertex/indirect buffers handle = 0x%08lx\n", - info->bufHandle); - - if (drmAddMap(disp->drmFD, info->gartTexStart, info->gartTexMapSize, - DRM_AGP, 0, &info->gartTexHandle) < 0) { - fprintf(stderr, - "[gart] Could not add AGP texture map mapping\n"); - return 0; - } - fprintf(stderr, - "[gart] AGP texture map handle = 0x%08lx\n", - info->gartTexHandle); - - return 1; -} - - -/** - * Initialize all the memory-related fields of the RADEONInfo object. - * This includes the various 'offset' and 'size' fields. - */ -static int -RADEONMemoryInit(driDisplay *disp, RADEONInfoPtr info) -{ - int width_bytes = disp->virtualWidth * disp->cpp; - int cpp = disp->cpp; - int bufferSize = ((disp->virtualHeight * width_bytes - + RADEON_BUFFER_ALIGN) - & ~RADEON_BUFFER_ALIGN); - int depthSize = ((((disp->virtualHeight+15) & ~15) * width_bytes - + RADEON_BUFFER_ALIGN) - & ~RADEON_BUFFER_ALIGN); - int l; - int pcie_gart_table_size = 0; - - info->frontOffset = 0; - info->frontPitch = disp->virtualWidth; - - if (disp->card_type==RADEON_CARD_PCIE) - pcie_gart_table_size = RADEON_PCIGART_TABLE_SIZE; - - /* Front, back and depth buffers - everything else texture?? - */ - info->textureSize = disp->fbSize - pcie_gart_table_size - 2 * bufferSize - depthSize; - - if (info->textureSize < 0) - return 0; - - l = RADEONMinBits((info->textureSize-1) / RADEON_NR_TEX_REGIONS); - if (l < RADEON_LOG_TEX_GRANULARITY) l = RADEON_LOG_TEX_GRANULARITY; - - /* Round the texture size up to the nearest whole number of - * texture regions. Again, be greedy about this, don't - * round down. - */ - info->log2TexGran = l; - info->textureSize = (info->textureSize >> l) << l; - - /* Set a minimum usable local texture heap size. This will fit - * two 256x256x32bpp textures. - */ - if (info->textureSize < 512 * 1024) { - info->textureOffset = 0; - info->textureSize = 0; - } - - /* Reserve space for textures */ - info->textureOffset = ((disp->fbSize - pcie_gart_table_size - info->textureSize + - RADEON_BUFFER_ALIGN) & - ~RADEON_BUFFER_ALIGN); - - /* Reserve space for the shared depth - * buffer. - */ - info->depthOffset = ((info->textureOffset - depthSize + - RADEON_BUFFER_ALIGN) & - ~RADEON_BUFFER_ALIGN); - info->depthPitch = disp->virtualWidth; - - info->backOffset = ((info->depthOffset - bufferSize + - RADEON_BUFFER_ALIGN) & - ~RADEON_BUFFER_ALIGN); - info->backPitch = disp->virtualWidth; - - if (pcie_gart_table_size) - info->pcieGartTableOffset = disp->fbSize - pcie_gart_table_size; - - fprintf(stderr, - "Will use back buffer at offset 0x%x, pitch %d\n", - info->backOffset, info->backPitch); - fprintf(stderr, - "Will use depth buffer at offset 0x%x, pitch %d\n", - info->depthOffset, info->depthPitch); - fprintf(stderr, - "Will use %d kb for textures at offset 0x%x\n", - info->textureSize/1024, info->textureOffset); - if (pcie_gart_table_size) - { - fprintf(stderr, - "Will use %d kb for PCIE GART Table at offset 0x%x\n", - pcie_gart_table_size/1024, info->pcieGartTableOffset); - } - - /* XXX I don't think these are needed. */ -#if 0 - info->frontPitchOffset = (((info->frontPitch * cpp / 64) << 22) | - (info->frontOffset >> 10)); - - info->backPitchOffset = (((info->backPitch * cpp / 64) << 22) | - (info->backOffset >> 10)); - - info->depthPitchOffset = (((info->depthPitch * cpp / 64) << 22) | - (info->depthOffset >> 10)); -#endif - - if (pcie_gart_table_size) - RADEONSetParam(disp, RADEON_SETPARAM_PCIGART_LOCATION, info->pcieGartTableOffset); - - return 1; -} - - -/** - * \brief Initialize the kernel data structures and enable the CP engine. - * - * \param ctx display handle. - * \param info driver private data. - * - * \return non-zero on success, or zero on failure. - * - * This function is a wrapper around the DRM_RADEON_CP_INIT command, passing - * all the parameters in a drm_radeon_init_t structure. - */ -static int RADEONDRIKernelInit( driDisplay *disp, - RADEONInfoPtr info) -{ - int cpp = disp->bpp / 8; - drm_radeon_init_t drmInfo; - int ret; - - memset(&drmInfo, 0, sizeof(drmInfo)); - - if ( (info->ChipFamily >= CHIP_FAMILY_R300) ) - drmInfo.func = RADEON_INIT_R300_CP; - else if ( (info->ChipFamily == CHIP_FAMILY_R200) || - (info->ChipFamily == CHIP_FAMILY_RV250) || - (info->ChipFamily == CHIP_FAMILY_M9) || - (info->ChipFamily == CHIP_FAMILY_RV280) ) - drmInfo.func = RADEON_INIT_R200_CP; - else - drmInfo.func = RADEON_INIT_CP; - - /* This is the struct passed to the kernel module for its initialization */ - /* XXX problem here: - * The front/back/depth_offset/pitch fields may change depending upon - * which drawing surface we're using!!! They can't be set just once - * during initialization. - * Looks like we'll need a new ioctl to update these fields for drawing - * to other surfaces... - */ - drmInfo.sarea_priv_offset = sizeof(drm_sarea_t); - drmInfo.cp_mode = RADEON_DEFAULT_CP_BM_MODE; - drmInfo.gart_size = info->gartSize*1024*1024; - drmInfo.ring_size = info->ringSize*1024*1024; - drmInfo.usec_timeout = 1000; - drmInfo.fb_bpp = disp->bpp; - drmInfo.depth_bpp = disp->bpp; - drmInfo.front_offset = info->frontOffset; - drmInfo.front_pitch = info->frontPitch * cpp; - drmInfo.back_offset = info->backOffset; - drmInfo.back_pitch = info->backPitch * cpp; - drmInfo.depth_offset = info->depthOffset; - drmInfo.depth_pitch = info->depthPitch * cpp; - drmInfo.ring_offset = info->ringHandle; - drmInfo.ring_rptr_offset = info->ringReadPtrHandle; - drmInfo.buffers_offset = info->bufHandle; - drmInfo.gart_textures_offset = info->gartTexHandle; - - ret = drmCommandWrite(disp->drmFD, DRM_RADEON_CP_INIT, &drmInfo, - sizeof(drm_radeon_init_t)); - - return ret >= 0; -} - - -/** - * \brief Add a map for the vertex buffers that will be accessed by any - * DRI-based clients. - * - * \param ctx display handle. - * \param info driver private data. - * - * \return one on success, or zero on failure. - * - * Calls drmAddBufs() with the previously allocated vertex buffers. - */ -static int RADEONDRIBufInit( driDisplay *disp, RADEONInfoPtr info ) -{ - /* Initialize vertex buffers */ - info->bufNumBufs = drmAddBufs(disp->drmFD, - info->bufMapSize / RADEON_BUFFER_SIZE, - RADEON_BUFFER_SIZE, - (disp->card_type!=RADEON_CARD_AGP) ? DRM_SG_BUFFER : DRM_AGP_BUFFER, - info->bufStart); - - if (info->bufNumBufs <= 0) { - fprintf(stderr, - "[drm] Could not create vertex/indirect buffers list\n"); - return 0; - } - fprintf(stderr, - "[drm] Added %d %d byte vertex/indirect buffers\n", - info->bufNumBufs, RADEON_BUFFER_SIZE); - - return 1; -} - - -/** - * \brief Install an IRQ handler. - * - * \param disp display handle. - * \param info driver private data. - * - * Attempts to install an IRQ handler via drmCtlInstHandler(), falling back to - * IRQ-free operation on failure. - */ -static void RADEONDRIIrqInit(driDisplay *disp, RADEONInfoPtr info) -{ - if ((drmCtlInstHandler(disp->drmFD, 0)) != 0) - fprintf(stderr, "[drm] failure adding irq handler, " - "there is a device already using that irq\n" - "[drm] falling back to irq-free operation\n"); -} - - -/** - * \brief Initialize the AGP heap. - * - * \param disp display handle. - * \param info driver private data. - * - * This function is a wrapper around the DRM_RADEON_INIT_HEAP command, passing - * all the parameters in a drm_radeon_mem_init_heap structure. - */ -static void RADEONDRIAgpHeapInit(driDisplay *disp, - RADEONInfoPtr info) -{ - drm_radeon_mem_init_heap_t drmHeap; - - /* Start up the simple memory manager for gart space */ - drmHeap.region = RADEON_MEM_REGION_GART; - drmHeap.start = 0; - drmHeap.size = info->gartTexMapSize; - - if (drmCommandWrite(disp->drmFD, DRM_RADEON_INIT_HEAP, - &drmHeap, sizeof(drmHeap))) { - fprintf(stderr, - "[drm] Failed to initialized gart heap manager\n"); - } else { - fprintf(stderr, - "[drm] Initialized kernel gart heap manager, %d\n", - info->gartTexMapSize); - } -} - -static int RADEONGetCardType(driDisplay *disp, RADEONInfoPtr info) -{ - drm_radeon_getparam_t gp; - int ret; - - gp.param = RADEON_PARAM_CARD_TYPE; - gp.value = &disp->card_type; - - ret=drmCommandWriteRead(disp->drmFD, DRM_RADEON_GETPARAM, &gp, sizeof(gp)); - if (ret) { - fprintf(stderr, "drm_radeon_getparam_t (RADEON_PARAM_CARD_TYPE) : %d\n", ret); - return -1; - } - - return disp->card_type; -} - -/** - * Called at the start of each server generation. - * - * \param disp display handle. - * \param info driver private data. - * - * \return non-zero on success, or zero on failure. - * - * Performs static frame buffer allocation. Opens the DRM device and add maps - * to the SAREA, framebuffer and MMIO regions. Fills in \p info with more - * information. Creates a \e server context to grab the lock for the - * initialization ioctls and calls the other initilization functions in this - * file. Starts the CP engine via the DRM_RADEON_CP_START command. - * - * Setups a RADEONDRIRec structure to be passed to radeon_dri.so for its - * initialization. - */ -static int -RADEONScreenInit( driDisplay *disp, RADEONInfoPtr info, - RADEONDRIPtr pRADEONDRI) -{ - int i, err; - - /* XXX this probably isn't needed here */ - { - int width_bytes = (disp->virtualWidth * disp->cpp); - int maxy = disp->fbSize / width_bytes; - - if (maxy <= disp->virtualHeight * 3) { - _eglLog(_EGL_WARNING, - "Static buffer allocation failed -- " - "need at least %d kB video memory (have %d kB)\n", - (disp->virtualWidth * disp->virtualHeight * - disp->cpp * 3 + 1023) / 1024, - disp->fbSize / 1024); - return 0; - } - } - - /* Memory manager setup */ - if (!RADEONMemoryInit(disp, info)) { - return 0; - } - - /* Create a 'server' context so we can grab the lock for - * initialization ioctls. - */ - if ((err = drmCreateContext(disp->drmFD, &disp->serverContext)) != 0) { - _eglLog(_EGL_WARNING, "%s: drmCreateContext failed %d\n", - __FUNCTION__, err); - return 0; - } - - DRM_LOCK(disp->drmFD, disp->pSAREA, disp->serverContext, 0); - - /* Initialize the kernel data structures */ - if (!RADEONDRIKernelInit(disp, info)) { - _eglLog(_EGL_WARNING, "RADEONDRIKernelInit failed\n"); - DRM_UNLOCK(disp->drmFD, disp->pSAREA, disp->serverContext); - return 0; - } - - /* Initialize the vertex buffers list */ - if (!RADEONDRIBufInit(disp, info)) { - fprintf(stderr, "RADEONDRIBufInit failed\n"); - DRM_UNLOCK(disp->drmFD, disp->pSAREA, disp->serverContext); - return 0; - } - - /* Initialize IRQ */ - RADEONDRIIrqInit(disp, info); - - /* Initialize kernel gart memory manager */ - RADEONDRIAgpHeapInit(disp, info); - - /* Initialize the SAREA private data structure */ - { - drm_radeon_sarea_t *pSAREAPriv; - pSAREAPriv = (drm_radeon_sarea_t *)(((char*)disp->pSAREA) + - sizeof(drm_sarea_t)); - memset(pSAREAPriv, 0, sizeof(*pSAREAPriv)); - pSAREAPriv->pfState = info->page_flip_enable; - } - - for ( i = 0;; i++ ) { - drmMapType type; - drmMapFlags flags; - drm_handle_t handle, offset; - drmSize size; - int rc, mtrr; - - if ( ( rc = drmGetMap( disp->drmFD, i, &offset, &size, &type, &flags, &handle, &mtrr ) ) != 0 ) - break; - if ( type == DRM_REGISTERS ) { - pRADEONDRI->registerHandle = offset; - pRADEONDRI->registerSize = size; - break; - } - } - /* Quick hack to clear the front & back buffers. Could also use - * the clear ioctl to do this, but would need to setup hw state - * first. - */ - drimemsetio((char *)disp->pFB + info->frontOffset, - 0xEE, - info->frontPitch * disp->cpp * disp->virtualHeight ); - - drimemsetio((char *)disp->pFB + info->backOffset, - 0x30, - info->backPitch * disp->cpp * disp->virtualHeight ); - - - /* This is the struct passed to radeon_dri.so for its initialization */ - pRADEONDRI->deviceID = info->Chipset; - pRADEONDRI->width = disp->virtualWidth; - pRADEONDRI->height = disp->virtualHeight; - pRADEONDRI->depth = disp->bpp; /* XXX: depth */ - pRADEONDRI->bpp = disp->bpp; - pRADEONDRI->IsPCI = (disp->card_type != RADEON_CARD_AGP);; - pRADEONDRI->frontOffset = info->frontOffset; - pRADEONDRI->frontPitch = info->frontPitch; - pRADEONDRI->backOffset = info->backOffset; - pRADEONDRI->backPitch = info->backPitch; - pRADEONDRI->depthOffset = info->depthOffset; - pRADEONDRI->depthPitch = info->depthPitch; - pRADEONDRI->textureOffset = info->textureOffset; - pRADEONDRI->textureSize = info->textureSize; - pRADEONDRI->log2TexGran = info->log2TexGran; - pRADEONDRI->statusHandle = info->ringReadPtrHandle; - pRADEONDRI->statusSize = info->ringReadMapSize; - pRADEONDRI->gartTexHandle = info->gartTexHandle; - pRADEONDRI->gartTexMapSize = info->gartTexMapSize; - pRADEONDRI->log2GARTTexGran = info->log2GARTTexGran; - pRADEONDRI->gartTexOffset = info->gartTexStart; - pRADEONDRI->sarea_priv_offset = sizeof(drm_sarea_t); - - /* Don't release the lock now - let the VT switch handler do it. */ - - return 1; -} - - -/** - * \brief Get Radeon chip family from chipset number. - * - * \param info driver private data. - * - * \return non-zero on success, or zero on failure. - * - * Called by radeonInitFBDev() to set RADEONInfoRec::ChipFamily - * according to the value of RADEONInfoRec::Chipset. Fails if the - * chipset is unrecognized or not appropriate for this driver (i.e., not - * an r100 style radeon) - */ -static int get_chipfamily_from_chipset( RADEONInfoPtr info ) -{ - switch (info->Chipset) { - case PCI_CHIP_RADEON_LY: - case PCI_CHIP_RADEON_LZ: - info->ChipFamily = CHIP_FAMILY_M6; - break; - - case PCI_CHIP_RADEON_QY: - case PCI_CHIP_RADEON_QZ: - info->ChipFamily = CHIP_FAMILY_VE; - break; - - case PCI_CHIP_R200_QL: - case PCI_CHIP_R200_QN: - case PCI_CHIP_R200_QO: - case PCI_CHIP_R200_Ql: - case PCI_CHIP_R200_BB: - info->ChipFamily = CHIP_FAMILY_R200; - break; - - case PCI_CHIP_RV200_QW: /* RV200 desktop */ - case PCI_CHIP_RV200_QX: - info->ChipFamily = CHIP_FAMILY_RV200; - break; - - case PCI_CHIP_RADEON_LW: - case PCI_CHIP_RADEON_LX: - info->ChipFamily = CHIP_FAMILY_M7; - break; - - case PCI_CHIP_RV250_Id: - case PCI_CHIP_RV250_Ie: - case PCI_CHIP_RV250_If: - case PCI_CHIP_RV250_Ig: - info->ChipFamily = CHIP_FAMILY_RV250; - break; - - case PCI_CHIP_RV250_Ld: - case PCI_CHIP_RV250_Le: - case PCI_CHIP_RV250_Lf: - case PCI_CHIP_RV250_Lg: - info->ChipFamily = CHIP_FAMILY_M9; - break; - - case PCI_CHIP_RV280_Y_: - case PCI_CHIP_RV280_Ya: - case PCI_CHIP_RV280_Yb: - case PCI_CHIP_RV280_Yc: - info->ChipFamily = CHIP_FAMILY_RV280; - break; - - case PCI_CHIP_R300_ND: - case PCI_CHIP_R300_NE: - case PCI_CHIP_R300_NF: - case PCI_CHIP_R300_NG: - info->ChipFamily = CHIP_FAMILY_R300; - break; - - case PCI_CHIP_RV370_5460: - info->ChipFamily = CHIP_FAMILY_RV380; - break; - - default: - /* Original Radeon/7200 */ - info->ChipFamily = CHIP_FAMILY_RADEON; - } - - return 1; -} - - -/** - * \brief Initialize the framebuffer device mode - * - * \param disp display handle. - * - * \return one on success, or zero on failure. - * - * Fills in \p info with some default values and some information from \p disp - * and then calls RADEONScreenInit() for the screen initialization. - * - * Before exiting clears the framebuffer memory accessing it directly. - */ -static int radeonInitFBDev( driDisplay *disp, RADEONDRIPtr pRADEONDRI ) -{ - int err; - RADEONInfoPtr info = calloc(1, sizeof(*info)); - - disp->driverPrivate = (void *)info; - - info->gartFastWrite = RADEON_DEFAULT_AGP_FAST_WRITE; - info->gartSize = RADEON_DEFAULT_AGP_SIZE; - info->gartTexSize = RADEON_DEFAULT_AGP_TEX_SIZE; - info->bufSize = RADEON_DEFAULT_BUFFER_SIZE; - info->ringSize = RADEON_DEFAULT_RING_SIZE; - info->page_flip_enable = RADEON_DEFAULT_PAGE_FLIP; - - fprintf(stderr, - "Using %d MB AGP aperture\n", info->gartSize); - fprintf(stderr, - "Using %d MB for the ring buffer\n", info->ringSize); - fprintf(stderr, - "Using %d MB for vertex/indirect buffers\n", info->bufSize); - fprintf(stderr, - "Using %d MB for AGP textures\n", info->gartTexSize); - fprintf(stderr, - "page flipping %sabled\n", info->page_flip_enable?"en":"dis"); - - info->Chipset = disp->chipset; - - if (!get_chipfamily_from_chipset( info )) { - fprintf(stderr, "Unknown or non-radeon chipset -- cannot continue\n"); - fprintf(stderr, "==> Verify PCI BusID is correct in miniglx.conf\n"); - return 0; - } -#if 0 - if (info->ChipFamily >= CHIP_FAMILY_R300) { - fprintf(stderr, - "Direct rendering not yet supported on " - "Radeon 9700 and newer cards\n"); - return 0; - } -#endif - -#if 00 - /* don't seem to need this here */ - info->frontPitch = disp->virtualWidth; -#endif - - /* Check the radeon DRM version */ - if (!RADEONCheckDRMVersion(disp, info)) { - return 0; - } - - if (RADEONGetCardType(disp, info)<0) - return 0; - - if (disp->card_type!=RADEON_CARD_AGP) { - /* Initialize PCI */ - if (!RADEONDRIPciInit(disp, info)) - return 0; - } - else { - /* Initialize AGP */ - if (!RADEONDRIAgpInit(disp, info)) - return 0; - } - - if (!RADEONScreenInit( disp, info, pRADEONDRI)) - return 0; - - /* Initialize and start the CP if required */ - if ((err = drmCommandNone(disp->drmFD, DRM_RADEON_CP_START)) != 0) { - fprintf(stderr, "%s: CP start %d\n", __FUNCTION__, err); - return 0; - } - - return 1; -} - - -/** - * Create list of all supported surface configs, attach list to the display. - */ -static EGLBoolean -radeonFillInConfigs(_EGLDisplay *disp, unsigned pixel_bits, - unsigned depth_bits, - unsigned stencil_bits, GLboolean have_back_buffer) -{ - _EGLConfig *configs; - _EGLConfig *c; - unsigned int i, num_configs; - unsigned int depth_buffer_factor; - unsigned int back_buffer_factor; - GLenum fb_format; - GLenum fb_type; - - /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy - * enough to add support. Basically, if a context is created with an - * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping - * will never be used. - */ - static const GLenum back_buffer_modes[] = { - GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */ - }; - - uint8_t depth_bits_array[2]; - uint8_t stencil_bits_array[2]; - - depth_bits_array[0] = depth_bits; - depth_bits_array[1] = depth_bits; - - /* Just like with the accumulation buffer, always provide some modes - * with a stencil buffer. It will be a sw fallback, but some apps won't - * care about that. - */ - stencil_bits_array[0] = 0; - stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits; - - depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1; - back_buffer_factor = (have_back_buffer) ? 2 : 1; - - num_configs = depth_buffer_factor * back_buffer_factor * 2; - - if (pixel_bits == 16) { - fb_format = GL_RGB; - fb_type = GL_UNSIGNED_SHORT_5_6_5; - } else { - fb_format = GL_RGBA; - fb_type = GL_UNSIGNED_INT_8_8_8_8_REV; - } - - configs = calloc(sizeof(*configs), num_configs); - c = configs; - if (!_eglFillInConfigs(c, fb_format, fb_type, - depth_bits_array, stencil_bits_array, - depth_buffer_factor, - back_buffer_modes, back_buffer_factor, - GLX_TRUE_COLOR)) { - fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", - __func__, __LINE__); - return EGL_FALSE; - } - - /* Mark the visual as slow if there are "fake" stencil bits. - */ - for (i = 0, c = configs; i < num_configs; i++, c++) { - int stencil = GET_CONFIG_ATTRIB(c, EGL_STENCIL_SIZE); - if ((stencil != 0) && (stencil != stencil_bits)) { - SET_CONFIG_ATTRIB(c, EGL_CONFIG_CAVEAT, EGL_SLOW_CONFIG); - } - } - - for (i = 0, c = configs; i < num_configs; i++, c++) - _eglAddConfig(disp, c); - - free(configs); - - return EGL_TRUE; -} - - -/** - * Show the given surface on the named screen. - * If surface is EGL_NO_SURFACE, disable the screen's output. - */ -static EGLBoolean -radeonShowScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, - EGLSurface surface, EGLModeMESA m) -{ - EGLBoolean b = _eglDRIShowScreenSurfaceMESA(drv, dpy, screen, surface, m); - return b; -} - - -/** - * Called via eglInitialize() by user. - */ -static EGLBoolean -radeonInitialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor) -{ - __DRIframebuffer framebuffer; - driDisplay *display; - - /* one-time init */ - radeon_drm_page_size = getpagesize(); - - if (!_eglDRIInitialize(drv, dpy, major, minor)) - return EGL_FALSE; - - display = Lookup_driDisplay(dpy); - - framebuffer.dev_priv_size = sizeof(RADEONDRIRec); - framebuffer.dev_priv = malloc(sizeof(RADEONDRIRec)); - - /* XXX we shouldn't hard-code values here! */ - /* we won't know the screen surface size until the user calls - * eglCreateScreenSurfaceMESA(). - */ -#if 0 - display->virtualWidth = 1024; - display->virtualHeight = 768; -#else - display->virtualWidth = 1280; - display->virtualHeight = 1024; -#endif - display->bpp = 32; - display->cpp = 4; - - if (!_eglDRIGetDisplayInfo(display)) - return EGL_FALSE; - - framebuffer.base = display->pFB; - framebuffer.width = display->virtualWidth; - framebuffer.height = display->virtualHeight; - framebuffer.stride = display->virtualWidth; - framebuffer.size = display->fbSize; - radeonInitFBDev( display, framebuffer.dev_priv ); - - if (!_eglDRICreateDisplay(display, &framebuffer)) - return EGL_FALSE; - - if (!_eglDRICreateScreens(display)) - return EGL_FALSE; - - /* create a variety of both 32 and 16-bit configurations */ - radeonFillInConfigs(&display->Base, 32, 24, 8, GL_TRUE); - radeonFillInConfigs(&display->Base, 16, 16, 0, GL_TRUE); - - drv->Initialized = EGL_TRUE; - return EGL_TRUE; -} - - -/** - * The bootstrap function. Return a new radeonDriver object and - * plug in API functions. - */ -_EGLDriver * -_eglMain(_EGLDisplay *dpy) -{ - radeonDriver *radeon; - - radeon = (radeonDriver *) calloc(1, sizeof(*radeon)); - if (!radeon) { - return NULL; - } - - /* First fill in the dispatch table with defaults */ - _eglDRIInitDriverFallbacks(&radeon->Base); - - /* then plug in our radeon-specific functions */ - radeon->Base.API.Initialize = radeonInitialize; - radeon->Base.API.ShowScreenSurfaceMESA = radeonShowScreenSurfaceMESA; - - return &radeon->Base; -} -- cgit v1.2.3 From 8bc3c06d86b9c4b440402f1ca419da3045d2ed25 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 21 Jan 2010 23:24:40 -0800 Subject: progs/trivial: Remove unnecessary header from tri-fbo-tex-mip.c. --- progs/trivial/tri-fbo-tex-mip.c | 1 - 1 file changed, 1 deletion(-) diff --git a/progs/trivial/tri-fbo-tex-mip.c b/progs/trivial/tri-fbo-tex-mip.c index df4725c7b4..2e8fb74a00 100644 --- a/progs/trivial/tri-fbo-tex-mip.c +++ b/progs/trivial/tri-fbo-tex-mip.c @@ -6,7 +6,6 @@ #include #include #include -#include /* For debug */ -- cgit v1.2.3 From 52d7b2cedee44fbd9a0e6405b974c62898bed169 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 Jan 2010 15:18:45 +0800 Subject: st/egl: Remove the egl state tracker. The egl_g3d state tracker has support for KMS, and the support is based on the egl state tracker. As egl_g3d provides more features, it should be better to keep only egl_g3d to unify the efforts. --- configs/linux-dri | 2 +- configs/linux-opengl-es | 5 +- configure.ac | 6 +- src/gallium/state_trackers/egl/Makefile | 19 -- src/gallium/state_trackers/egl/egl_context.c | 105 ------- src/gallium/state_trackers/egl/egl_surface.c | 443 --------------------------- src/gallium/state_trackers/egl/egl_tracker.c | 272 ---------------- src/gallium/state_trackers/egl/egl_tracker.h | 195 ------------ src/gallium/state_trackers/egl/egl_visual.c | 85 ----- src/gallium/winsys/drm/i965/egl/Makefile | 29 -- src/gallium/winsys/drm/intel/egl/Makefile | 38 --- src/gallium/winsys/drm/intel/egl/dummy.c | 1 - src/gallium/winsys/drm/radeon/egl/Makefile | 38 --- src/gallium/winsys/drm/radeon/egl/dummy.c | 1 - src/gallium/winsys/drm/vmware/egl/Makefile | 18 -- 15 files changed, 8 insertions(+), 1249 deletions(-) delete mode 100644 src/gallium/state_trackers/egl/Makefile delete mode 100644 src/gallium/state_trackers/egl/egl_context.c delete mode 100644 src/gallium/state_trackers/egl/egl_surface.c delete mode 100644 src/gallium/state_trackers/egl/egl_tracker.c delete mode 100644 src/gallium/state_trackers/egl/egl_tracker.h delete mode 100644 src/gallium/state_trackers/egl/egl_visual.c delete mode 100644 src/gallium/winsys/drm/i965/egl/Makefile delete mode 100644 src/gallium/winsys/drm/intel/egl/Makefile delete mode 100644 src/gallium/winsys/drm/intel/egl/dummy.c delete mode 100644 src/gallium/winsys/drm/radeon/egl/Makefile delete mode 100644 src/gallium/winsys/drm/radeon/egl/dummy.c delete mode 100644 src/gallium/winsys/drm/vmware/egl/Makefile diff --git a/configs/linux-dri b/configs/linux-dri index 95f77ade1d..feb2bba3a0 100644 --- a/configs/linux-dri +++ b/configs/linux-dri @@ -61,7 +61,7 @@ DRIVER_DIRS = dri WINDOW_SYSTEM = dri GALLIUM_WINSYS_DIRS = drm GALLIUM_WINSYS_DRM_DIRS = vmware intel i965 -GALLIUM_STATE_TRACKERS_DIRS = egl +GALLIUM_STATE_TRACKERS_DIRS = egl_g3d DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon \ savage sis tdfx unichrome ffb swrast diff --git a/configs/linux-opengl-es b/configs/linux-opengl-es index 566cd758e3..e013658716 100644 --- a/configs/linux-opengl-es +++ b/configs/linux-opengl-es @@ -9,6 +9,9 @@ LIB_DIR = lib SRC_DIRS = egl glsl mesa/es gallium gallium/winsys PROGRAM_DIRS = es1/screen es1/xegl es2/xegl +# egl_g3d needs this +DEFINES += -DGLX_DIRECT_RENDERING + # no mesa or egl drivers DRIVER_DIRS = EGL_DRIVERS_DIRS = @@ -22,6 +25,6 @@ GALLIUM_STATE_TRACKERS_DIRS = es # build egl_i915.so GALLIUM_DRIVERS_DIRS += trace i915 -GALLIUM_STATE_TRACKERS_DIRS += egl +GALLIUM_STATE_TRACKERS_DIRS += egl_g3d GALLIUM_WINSYS_DIRS += drm GALLIUM_WINSYS_DRM_DIRS = intel diff --git a/configure.ac b/configure.ac index e5c2386320..bb011abff2 100644 --- a/configure.ac +++ b/configure.ac @@ -1165,7 +1165,7 @@ yes) dri) GALLIUM_STATE_TRACKERS_DIRS="dri" if test "x$enable_egl" = xyes; then - GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl egl_g3d" + GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl_g3d" fi # Have only tested st/xorg on 1.6.0 servers PKG_CHECK_MODULES(XORG, [xorg-server >= 1.6.0], @@ -1182,9 +1182,9 @@ yes) AC_MSG_ERROR([state tracker '$tracker' doesn't exist]) case "$tracker" in - egl) + egl_g3d) if test "x$enable_egl" != xyes; then - AC_MSG_ERROR([cannot build egl state tracker without EGL library]) + AC_MSG_ERROR([cannot build egl_g3d state tracker without EGL library]) fi ;; xorg) diff --git a/src/gallium/state_trackers/egl/Makefile b/src/gallium/state_trackers/egl/Makefile deleted file mode 100644 index e825aa718b..0000000000 --- a/src/gallium/state_trackers/egl/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -TOP = ../../../.. -include $(TOP)/configs/current - -LIBNAME = egldrm - -LIBRARY_INCLUDES = \ - -I$(TOP)/src/gallium/include \ - -I$(TOP)/src/gallium/auxiliary \ - -I$(TOP)/src/mesa/drivers/dri/common \ - -I$(TOP)/src/mesa \ - -I$(TOP)/include \ - -I$(TOP)/src/egl/main \ - $(shell pkg-config --cflags-only-I libdrm) - - -C_SOURCES = $(wildcard ./*.c) - - -include ../../Makefile.template diff --git a/src/gallium/state_trackers/egl/egl_context.c b/src/gallium/state_trackers/egl/egl_context.c deleted file mode 100644 index fee186c601..0000000000 --- a/src/gallium/state_trackers/egl/egl_context.c +++ /dev/null @@ -1,105 +0,0 @@ - -#include "utils.h" -#include -#include -#include -#include "egl_tracker.h" - -#include "egllog.h" - - -#include "pipe/p_context.h" -#include "pipe/p_screen.h" - -#include "state_tracker/st_public.h" -#include "state_tracker/drm_api.h" - -#include "GL/internal/glcore.h" - -_EGLContext * -drm_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, _EGLContext *share_list, const EGLint *attrib_list) -{ - struct drm_device *dev = lookup_drm_device(dpy); - struct drm_context *ctx; - struct drm_context *share = NULL; - struct st_context *st_share = NULL; - int i; - __GLcontextModes *visual; - - for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { - switch (attrib_list[i]) { - /* no attribs defined for now */ - default: - _eglError(EGL_BAD_ATTRIBUTE, "eglCreateContext"); - return EGL_NO_CONTEXT; - } - } - - ctx = (struct drm_context *) calloc(1, sizeof(struct drm_context)); - if (!ctx) - goto err_c; - - _eglInitContext(drv, &ctx->base, conf, attrib_list); - - ctx->pipe = dev->api->create_context(dev->api, dev->screen); - if (!ctx->pipe) - goto err_pipe; - - if (share) - st_share = share->st; - - visual = drm_visual_from_config(conf); - ctx->st = st_create_context(ctx->pipe, visual, st_share); - drm_visual_modes_destroy(visual); - - if (!ctx->st) - goto err_gl; - - return &ctx->base; - -err_gl: - ctx->pipe->destroy(ctx->pipe); -err_pipe: - free(ctx); -err_c: - return NULL; -} - -EGLBoolean -drm_destroy_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *context) -{ - struct drm_context *c = lookup_drm_context(context); - if (!_eglIsContextBound(&c->base)) { - st_destroy_context(c->st); - free(c); - } - return EGL_TRUE; -} - -EGLBoolean -drm_make_current(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, _EGLSurface *read, _EGLContext *context) -{ - struct drm_surface *readSurf = lookup_drm_surface(read); - struct drm_surface *drawSurf = lookup_drm_surface(draw); - struct drm_context *ctx = lookup_drm_context(context); - EGLBoolean b; - - b = _eglMakeCurrent(drv, dpy, draw, read, context); - if (!b) - return EGL_FALSE; - - if (ctx) { - if (!drawSurf || !readSurf) - return EGL_FALSE; - - st_make_current(ctx->st, drawSurf->stfb, readSurf->stfb); - - /* st_resize_framebuffer needs a bound context to work */ - st_resize_framebuffer(drawSurf->stfb, drawSurf->w, drawSurf->h); - st_resize_framebuffer(readSurf->stfb, readSurf->w, readSurf->h); - } else { - st_make_current(NULL, NULL, NULL); - } - - return EGL_TRUE; -} diff --git a/src/gallium/state_trackers/egl/egl_surface.c b/src/gallium/state_trackers/egl/egl_surface.c deleted file mode 100644 index d55aa51b82..0000000000 --- a/src/gallium/state_trackers/egl/egl_surface.c +++ /dev/null @@ -1,443 +0,0 @@ - -#include -#include -#include -#include "egl_tracker.h" - -#include "egllog.h" - -#include "pipe/p_inlines.h" -#include "pipe/p_screen.h" -#include "pipe/p_context.h" - -#include "state_tracker/drm_api.h" - -#include "util/u_format.h" -#include "util/u_rect.h" - -/* - * Util functions - */ - -static drmModeModeInfoPtr -drm_find_mode(drmModeConnectorPtr connector, _EGLMode *mode) -{ - int i; - drmModeModeInfoPtr m = NULL; - - for (i = 0; i < connector->count_modes; i++) { - m = &connector->modes[i]; - if (m->hdisplay == mode->Width && m->vdisplay == mode->Height && m->vrefresh == mode->RefreshRate) - break; - m = &connector->modes[0]; /* if we can't find one, return first */ - } - - return m; -} - -static struct st_framebuffer * -drm_create_framebuffer(struct pipe_screen *screen, - const __GLcontextModes *visual, - unsigned width, - unsigned height, - void *priv) -{ - enum pipe_format color_format, depth_stencil_format; - boolean d_depth_bits_last; - boolean ds_depth_bits_last; - - d_depth_bits_last = - screen->is_format_supported(screen, PIPE_FORMAT_X8Z24_UNORM, - PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); - ds_depth_bits_last = - screen->is_format_supported(screen, PIPE_FORMAT_S8Z24_UNORM, - PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); - - if (visual->redBits == 8) { - if (visual->alphaBits == 8) - color_format = PIPE_FORMAT_A8R8G8B8_UNORM; - else - color_format = PIPE_FORMAT_X8R8G8B8_UNORM; - } else { - color_format = PIPE_FORMAT_R5G6B5_UNORM; - } - - switch(visual->depthBits) { - default: - case 0: - depth_stencil_format = PIPE_FORMAT_NONE; - break; - case 16: - depth_stencil_format = PIPE_FORMAT_Z16_UNORM; - break; - case 24: - if (visual->stencilBits == 0) { - depth_stencil_format = (d_depth_bits_last) ? - PIPE_FORMAT_X8Z24_UNORM: - PIPE_FORMAT_Z24X8_UNORM; - } else { - depth_stencil_format = (ds_depth_bits_last) ? - PIPE_FORMAT_S8Z24_UNORM: - PIPE_FORMAT_Z24S8_UNORM; - } - break; - case 32: - depth_stencil_format = PIPE_FORMAT_Z32_UNORM; - break; - } - - return st_create_framebuffer(visual, - color_format, - depth_stencil_format, - depth_stencil_format, - width, - height, - priv); -} - -static void -drm_create_texture(_EGLDisplay *dpy, - struct drm_screen *scrn, - unsigned w, unsigned h) -{ - struct drm_device *dev = lookup_drm_device(dpy); - struct pipe_screen *screen = dev->screen; - struct pipe_surface *surface; - struct pipe_texture *texture; - struct pipe_texture templat; - struct pipe_buffer *buf = NULL; - unsigned pitch = 0; - - memset(&templat, 0, sizeof(templat)); - templat.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; - templat.tex_usage |= PIPE_TEXTURE_USAGE_PRIMARY; - templat.target = PIPE_TEXTURE_2D; - templat.last_level = 0; - templat.depth0 = 1; - templat.format = PIPE_FORMAT_A8R8G8B8_UNORM; - templat.width0 = w; - templat.height0 = h; - - texture = screen->texture_create(dev->screen, - &templat); - - if (!texture) - goto err_tex; - - surface = screen->get_tex_surface(screen, - texture, - 0, - 0, - 0, - PIPE_BUFFER_USAGE_GPU_WRITE); - - if (!surface) - goto err_surf; - - scrn->tex = texture; - scrn->surface = surface; - scrn->front.width = w; - scrn->front.height = h; - scrn->front.pitch = pitch; - dev->api->local_handle_from_texture(dev->api, screen, texture, - &scrn->front.pitch, &scrn->front.handle); - if (0) - goto err_handle; - - return; - -err_handle: - pipe_surface_reference(&surface, NULL); -err_surf: - pipe_texture_reference(&texture, NULL); -err_tex: - pipe_buffer_reference(&buf, NULL); - return; -} - -/* - * Exported functions - */ - -void -drm_takedown_shown_screen(_EGLDisplay *dpy, struct drm_screen *screen) -{ - struct drm_device *dev = lookup_drm_device(dpy); - - screen->surf = NULL; - - drmModeSetCrtc( - dev->drmFD, - screen->crtcID, - 0, /* FD */ - 0, 0, - NULL, 0, /* List of output ids */ - NULL); - - drmModeRmFB(dev->drmFD, screen->fbID); - drmModeFreeFB(screen->fb); - screen->fb = NULL; - - pipe_surface_reference(&screen->surface, NULL); - pipe_texture_reference(&screen->tex, NULL); - - screen->shown = 0; -} - -/** - * Called by libEGL's eglCreateWindowSurface(). - */ -_EGLSurface * -drm_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, NativeWindowType window, const EGLint *attrib_list) -{ - return NULL; -} - - -/** - * Called by libEGL's eglCreatePixmapSurface(). - */ -_EGLSurface * -drm_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, NativePixmapType pixmap, const EGLint *attrib_list) -{ - return NULL; -} - - -/** - * Called by libEGL's eglCreatePbufferSurface(). - */ -_EGLSurface * -drm_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, - const EGLint *attrib_list) -{ - struct drm_device *dev = lookup_drm_device(dpy); - int i; - int width = -1; - int height = -1; - struct drm_surface *surf = NULL; - __GLcontextModes *visual; - - for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { - switch (attrib_list[i]) { - case EGL_WIDTH: - width = attrib_list[++i]; - break; - case EGL_HEIGHT: - height = attrib_list[++i]; - break; - default: - _eglError(EGL_BAD_ATTRIBUTE, "eglCreatePbufferSurface"); - return EGL_NO_SURFACE; - } - } - - if (width < 1 || height < 1) { - _eglError(EGL_BAD_ATTRIBUTE, "eglCreatePbufferSurface"); - return NULL; - } - - surf = (struct drm_surface *) calloc(1, sizeof(struct drm_surface)); - if (!surf) - goto err; - - if (!_eglInitSurface(drv, &surf->base, EGL_PBUFFER_BIT, conf, attrib_list)) - goto err_surf; - - surf->w = width; - surf->h = height; - - visual = drm_visual_from_config(conf); - surf->stfb = drm_create_framebuffer(dev->screen, visual, - width, height, - (void*)surf); - drm_visual_modes_destroy(visual); - - return &surf->base; - -err_surf: - free(surf); -err: - return NULL; -} - -/** - * Called by libEGL's eglCreateScreenSurfaceMESA(). - */ -_EGLSurface * -drm_create_screen_surface_mesa(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *cfg, - const EGLint *attrib_list) -{ - EGLSurface surf = drm_create_pbuffer_surface(drv, dpy, cfg, attrib_list); - - return surf; -} - -/** - * Called by libEGL's eglShowScreenSurfaceMESA(). - */ -EGLBoolean -drm_show_screen_surface_mesa(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLScreen *screen, - _EGLSurface *surface, _EGLMode *mode) -{ - struct drm_device *dev = lookup_drm_device(dpy); - struct drm_surface *surf = lookup_drm_surface(surface); - struct drm_screen *scrn = lookup_drm_screen(screen); - int ret; - unsigned int i, k; - - if (scrn->shown) - drm_takedown_shown_screen(dpy, scrn); - - - drm_create_texture(dpy, scrn, mode->Width, mode->Height); - if (!scrn->tex) - goto err_tex; - - ret = drmModeAddFB(dev->drmFD, - scrn->front.width, scrn->front.height, - 32, 32, scrn->front.pitch, - scrn->front.handle, - &scrn->fbID); - - if (ret) - goto err_bo; - - scrn->fb = drmModeGetFB(dev->drmFD, scrn->fbID); - if (!scrn->fb) - goto err_bo; - - /* find a fitting crtc */ - { - drmModeConnector *con = scrn->connector; - - scrn->mode = drm_find_mode(con, mode); - if (!scrn->mode) - goto err_fb; - - for (k = 0; k < con->count_encoders; k++) { - drmModeEncoder *enc = drmModeGetEncoder(dev->drmFD, con->encoders[k]); - for (i = 0; i < dev->res->count_crtcs; i++) { - if (enc->possible_crtcs & (1<crtcID = dev->res->crtcs[i]; - - /* skip the rest */ - i = dev->res->count_crtcs; - k = dev->res->count_encoders; - } - } - drmModeFreeEncoder(enc); - } - } - - ret = drmModeSetCrtc(dev->drmFD, - scrn->crtcID, - scrn->fbID, - 0, 0, - &scrn->connectorID, 1, - scrn->mode); - - if (ret) - goto err_crtc; - - - if (scrn->dpms) - drmModeConnectorSetProperty(dev->drmFD, - scrn->connectorID, - scrn->dpms->prop_id, - DRM_MODE_DPMS_ON); - - surf->screen = scrn; - - scrn->surf = surf; - scrn->shown = 1; - - return EGL_TRUE; - -err_crtc: - scrn->crtcID = 0; - -err_fb: - drmModeRmFB(dev->drmFD, scrn->fbID); - drmModeFreeFB(scrn->fb); - scrn->fb = NULL; - -err_bo: - pipe_surface_reference(&scrn->surface, NULL); - pipe_texture_reference(&scrn->tex, NULL); - -err_tex: - return EGL_FALSE; -} - -/** - * Called by libEGL's eglDestroySurface(). - */ -EGLBoolean -drm_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface) -{ - struct drm_surface *surf = lookup_drm_surface(surface); - if (!_eglIsSurfaceBound(&surf->base)) { - if (surf->screen) - drm_takedown_shown_screen(dpy, surf->screen); - st_unreference_framebuffer(surf->stfb); - free(surf); - } - return EGL_TRUE; -} - -/** - * Called by libEGL's eglSwapBuffers(). - */ -EGLBoolean -drm_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw) -{ - struct drm_device *dev = lookup_drm_device(dpy); - struct drm_surface *surf = lookup_drm_surface(draw); - struct pipe_surface *back_surf; - - if (!surf) - return EGL_FALSE; - - st_get_framebuffer_surface(surf->stfb, ST_SURFACE_BACK_LEFT, &back_surf); - - if (back_surf) { - struct drm_context *ctx = lookup_drm_context(draw->Binding); - - st_notify_swapbuffers(surf->stfb); - - if (ctx && surf->screen) { - if (ctx->pipe->surface_copy) { - ctx->pipe->surface_copy(ctx->pipe, - surf->screen->surface, - 0, 0, - back_surf, - 0, 0, - surf->w, surf->h); - } else { - util_surface_copy(ctx->pipe, FALSE, - surf->screen->surface, - 0, 0, - back_surf, - 0, 0, - surf->w, surf->h); - } - ctx->pipe->flush(ctx->pipe, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_TEXTURE_CACHE, NULL); - -#ifdef DRM_MODE_FEATURE_DIRTYFB - /* TODO query connector property to see if this is needed */ - drmModeDirtyFB(dev->drmFD, surf->screen->fbID, NULL, 0); -#else - (void)dev; -#endif - - /* TODO more stuff here */ - } - } - - return EGL_TRUE; -} diff --git a/src/gallium/state_trackers/egl/egl_tracker.c b/src/gallium/state_trackers/egl/egl_tracker.c deleted file mode 100644 index 11583ec41c..0000000000 --- a/src/gallium/state_trackers/egl/egl_tracker.c +++ /dev/null @@ -1,272 +0,0 @@ - -#include "utils.h" - -#include -#include -#include -#include "egl_tracker.h" - -#include - -#include "egllog.h" -#include "state_tracker/drm_api.h" - -#include "pipe/p_screen.h" -#include "pipe/internal/p_winsys_screen.h" - -/** HACK */ -void* driDriverAPI; - - -/* - * Exported functions - */ - -/** Called by libEGL just prior to unloading/closing the driver. - */ -static void -drm_unload(_EGLDriver *drv) -{ - free(drv); -} - -/** - * The bootstrap function. Return a new drm_driver object and - * plug in API functions. - * libEGL finds this function with dlopen()/dlsym() and calls it from - * "load driver" function. - */ -_EGLDriver * -_eglMain(const char *args) -{ - _EGLDriver *drv; - - drv = (_EGLDriver *) calloc(1, sizeof(_EGLDriver)); - if (!drv) { - return NULL; - } - - /* First fill in the dispatch table with defaults */ - _eglInitDriverFallbacks(drv); - /* then plug in our Drm-specific functions */ - drv->API.Initialize = drm_initialize; - drv->API.Terminate = drm_terminate; - drv->API.CreateContext = drm_create_context; - drv->API.MakeCurrent = drm_make_current; - drv->API.CreateWindowSurface = drm_create_window_surface; - drv->API.CreatePixmapSurface = drm_create_pixmap_surface; - drv->API.CreatePbufferSurface = drm_create_pbuffer_surface; - drv->API.DestroySurface = drm_destroy_surface; - drv->API.DestroyContext = drm_destroy_context; - drv->API.CreateScreenSurfaceMESA = drm_create_screen_surface_mesa; - drv->API.ShowScreenSurfaceMESA = drm_show_screen_surface_mesa; - drv->API.SwapBuffers = drm_swap_buffers; - - drv->Name = "DRM/Gallium/Win"; - drv->Unload = drm_unload; - - return drv; -} - -static void -drm_get_device_id(struct drm_device *device) -{ - char path[512]; - FILE *file; - char *ret; - - /* TODO get the real minor */ - int minor = 0; - - device->deviceID = 0; - - snprintf(path, sizeof(path), "/sys/class/drm/card%d/device/device", minor); - file = fopen(path, "r"); - if (!file) { - _eglLog(_EGL_WARNING, "Could not retrive device ID\n"); - return; - } - - ret = fgets(path, sizeof( path ), file); - fclose(file); - if (!ret) - return; - - sscanf(path, "%x", &device->deviceID); -} - -static void -drm_update_res(struct drm_device *dev) -{ - drmModeFreeResources(dev->res); - dev->res = drmModeGetResources(dev->drmFD); -} - -static void -drm_add_modes_from_connector(_EGLScreen *screen, drmModeConnectorPtr connector) -{ - drmModeModeInfoPtr m = NULL; - int i; - - for (i = 0; i < connector->count_modes; i++) { - m = &connector->modes[i]; - _eglAddNewMode(screen, m->hdisplay, m->vdisplay, m->vrefresh, m->name); - } -} - -static void -drm_find_dpms(struct drm_device *dev, struct drm_screen *screen) -{ - drmModeConnectorPtr c = screen->connector; - drmModePropertyPtr p; - int i; - - for (i = 0; i < c->count_props; i++) { - p = drmModeGetProperty(dev->drmFD, c->props[i]); - if (!strcmp(p->name, "DPMS")) - break; - - drmModeFreeProperty(p); - p = NULL; - } - - screen->dpms = p; -} - -static int drm_open_minor(int minor) -{ - char buf[64]; - - sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, minor); - return open(buf, O_RDWR, 0); -} - -EGLBoolean -drm_initialize(_EGLDriver *drv, _EGLDisplay *disp, EGLint *major, EGLint *minor) -{ - struct drm_device *dev; - struct drm_screen *screen = NULL; - drmModeConnectorPtr connector = NULL; - drmModeResPtr res = NULL; - unsigned count_connectors = 0; - int num_screens = 0; - EGLint i; - int fd; - _EGLConfig *config; - - dev = (struct drm_device *) calloc(1, sizeof(struct drm_device)); - if (!dev) - return EGL_FALSE; - dev->api = drm_api_create(); - - /* try the first node */ - fd = drm_open_minor(0); - if (fd < 0) - goto err_fd; - - dev->drmFD = fd; - drm_get_device_id(dev); - - dev->screen = dev->api->create_screen(dev->api, dev->drmFD, NULL); - if (!dev->screen) - goto err_screen; - dev->winsys = dev->screen->winsys; - - drm_update_res(dev); - res = dev->res; - if (res) - count_connectors = res->count_connectors; - else - _eglLog(_EGL_WARNING, "Could not retrive kms information\n"); - - for(i = 0; i < count_connectors && i < MAX_SCREENS; i++) { - connector = drmModeGetConnector(fd, res->connectors[i]); - - if (!connector) - continue; - - if (connector->connection != DRM_MODE_CONNECTED) { - drmModeFreeConnector(connector); - continue; - } - - screen = malloc(sizeof(struct drm_screen)); - memset(screen, 0, sizeof(*screen)); - screen->connector = connector; - screen->connectorID = connector->connector_id; - _eglInitScreen(&screen->base); - _eglAddScreen(disp, &screen->base); - drm_add_modes_from_connector(&screen->base, connector); - drm_find_dpms(dev, screen); - dev->screens[num_screens++] = screen; - } - dev->count_screens = num_screens; - - disp->DriverData = dev; - - /* for now we only have one config */ - config = calloc(1, sizeof(*config)); - memset(config, 1, sizeof(*config)); - _eglInitConfig(config, 1); - _eglSetConfigAttrib(config, EGL_RED_SIZE, 8); - _eglSetConfigAttrib(config, EGL_GREEN_SIZE, 8); - _eglSetConfigAttrib(config, EGL_BLUE_SIZE, 8); - _eglSetConfigAttrib(config, EGL_ALPHA_SIZE, 8); - _eglSetConfigAttrib(config, EGL_BUFFER_SIZE, 32); - _eglSetConfigAttrib(config, EGL_DEPTH_SIZE, 24); - _eglSetConfigAttrib(config, EGL_STENCIL_SIZE, 8); - _eglSetConfigAttrib(config, EGL_SURFACE_TYPE, EGL_PBUFFER_BIT); - _eglAddConfig(disp, config); - - disp->ClientAPIsMask = EGL_OPENGL_BIT /*| EGL_OPENGL_ES_BIT*/; - /* enable supported extensions */ - disp->Extensions.MESA_screen_surface = EGL_TRUE; - disp->Extensions.MESA_copy_context = EGL_TRUE; - - *major = 1; - *minor = 4; - - return EGL_TRUE; - -err_screen: - drmClose(fd); -err_fd: - free(dev); - return EGL_FALSE; -} - -EGLBoolean -drm_terminate(_EGLDriver *drv, _EGLDisplay *dpy) -{ - struct drm_device *dev = lookup_drm_device(dpy); - struct drm_screen *screen; - int i = 0; - - _eglReleaseDisplayResources(drv, dpy); - _eglCleanupDisplay(dpy); - - drmFreeVersion(dev->version); - - for (i = 0; i < dev->count_screens; i++) { - screen = dev->screens[i]; - - if (screen->shown) - drm_takedown_shown_screen(dpy, screen); - - drmModeFreeProperty(screen->dpms); - drmModeFreeConnector(screen->connector); - _eglDestroyScreen(&screen->base); - dev->screens[i] = NULL; - } - - dev->screen->destroy(dev->screen); - dev->winsys = NULL; - - drmClose(dev->drmFD); - - dev->api->destroy(dev->api); - free(dev); - dpy->DriverData = NULL; - - return EGL_TRUE; -} diff --git a/src/gallium/state_trackers/egl/egl_tracker.h b/src/gallium/state_trackers/egl/egl_tracker.h deleted file mode 100644 index 73eb1a1226..0000000000 --- a/src/gallium/state_trackers/egl/egl_tracker.h +++ /dev/null @@ -1,195 +0,0 @@ - -#ifndef _EGL_TRACKER_H_ -#define _EGL_TRACKER_H_ - -#include - -#include "eglconfig.h" -#include "eglcontext.h" -#include "egldisplay.h" -#include "egldriver.h" -#include "eglglobals.h" -#include "eglmode.h" -#include "eglscreen.h" -#include "eglsurface.h" - -#include "xf86drm.h" -#include "xf86drmMode.h" - -#include "pipe/p_compiler.h" - -#include "state_tracker/st_public.h" - -#define MAX_SCREENS 16 - -struct pipe_winsys; -struct pipe_screen; -struct pipe_context; -struct state_tracker; - -struct drm_screen; -struct drm_context; - -struct drm_device -{ - /* - * pipe - */ - - struct drm_api *api; - struct pipe_winsys *winsys; - struct pipe_screen *screen; - - /* - * drm - */ - - int drmFD; - drmVersionPtr version; - int deviceID; - - drmModeResPtr res; - - struct drm_screen *screens[MAX_SCREENS]; - size_t count_screens; -}; - -struct drm_surface -{ - _EGLSurface base; /* base class/object */ - - /* - * pipe - */ - - - struct st_framebuffer *stfb; - - /* - * drm - */ - - struct drm_screen *screen; - - int w; - int h; -}; - -struct drm_context -{ - _EGLContext base; /* base class/object */ - - /* pipe */ - - struct pipe_context *pipe; - struct st_context *st; -}; - -struct drm_screen -{ - _EGLScreen base; - - /* - * pipe - */ - - struct pipe_texture *tex; - struct pipe_surface *surface; - - /* - * drm - */ - - struct { - unsigned height; - unsigned width; - unsigned pitch; - unsigned handle; - } front; - - /* currently only support one connector */ - drmModeConnectorPtr connector; - uint32_t connectorID; - - /* dpms property */ - drmModePropertyPtr dpms; - - /* Has this screen been shown */ - int shown; - - /* Surface that is currently attached to this screen */ - struct drm_surface *surf; - - /* framebuffer */ - drmModeFBPtr fb; - uint32_t fbID; - - /* crtc and mode used */ - /*drmModeCrtcPtr crtc;*/ - uint32_t crtcID; - - drmModeModeInfoPtr mode; -}; - - -static INLINE struct drm_device * -lookup_drm_device(_EGLDisplay *d) -{ - return (struct drm_device *) d->DriverData; -} - - -static INLINE struct drm_context * -lookup_drm_context(_EGLContext *c) -{ - return (struct drm_context *) c; -} - - -static INLINE struct drm_surface * -lookup_drm_surface(_EGLSurface *s) -{ - return (struct drm_surface *) s; -} - -static INLINE struct drm_screen * -lookup_drm_screen(_EGLScreen *s) -{ - return (struct drm_screen *) s; -} - -/** - * egl_visual.h - */ -/*@{*/ -void drm_visual_modes_destroy(__GLcontextModes *modes); -__GLcontextModes* drm_visual_modes_create(unsigned count, size_t minimum_size); -__GLcontextModes* drm_visual_from_config(_EGLConfig *conf); -/*@}*/ - -/** - * egl_surface.h - */ -/*@{*/ -void drm_takedown_shown_screen(_EGLDisplay *dpy, struct drm_screen *screen); -/*@}*/ - -/** - * All function exported to the egl side. - */ -/*@{*/ -EGLBoolean drm_initialize(_EGLDriver *drv, _EGLDisplay *dpy, EGLint *major, EGLint *minor); -EGLBoolean drm_terminate(_EGLDriver *drv, _EGLDisplay *dpy); -_EGLContext *drm_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, _EGLContext *share_list, const EGLint *attrib_list); -EGLBoolean drm_destroy_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *context); -_EGLSurface *drm_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, NativeWindowType window, const EGLint *attrib_list); -_EGLSurface *drm_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, NativePixmapType pixmap, const EGLint *attrib_list); -_EGLSurface *drm_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, const EGLint *attrib_list); -_EGLSurface *drm_create_screen_surface_mesa(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, const EGLint *attrib_list); -EGLBoolean drm_show_screen_surface_mesa(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *screen, _EGLSurface *surface, _EGLMode *mode); -EGLBoolean drm_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface); -EGLBoolean drm_make_current(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, _EGLSurface *read, _EGLContext *context); -EGLBoolean drm_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw); -/*@}*/ - -#endif diff --git a/src/gallium/state_trackers/egl/egl_visual.c b/src/gallium/state_trackers/egl/egl_visual.c deleted file mode 100644 index e59f893851..0000000000 --- a/src/gallium/state_trackers/egl/egl_visual.c +++ /dev/null @@ -1,85 +0,0 @@ - -#include "egl_tracker.h" - -#include "egllog.h" - -void -drm_visual_modes_destroy(__GLcontextModes *modes) -{ - _eglLog(_EGL_DEBUG, "%s", __FUNCTION__); - - while (modes) { - __GLcontextModes * const next = modes->next; - free(modes); - modes = next; - } -} - -__GLcontextModes * -drm_visual_modes_create(unsigned count, size_t minimum_size) -{ - /* This code copied from libGLX, and modified */ - const size_t size = (minimum_size > sizeof(__GLcontextModes)) - ? minimum_size : sizeof(__GLcontextModes); - __GLcontextModes * head = NULL; - __GLcontextModes ** next; - unsigned i; - - _eglLog(_EGL_DEBUG, "%s %d %d", __FUNCTION__, count, minimum_size); - - next = & head; - for (i = 0 ; i < count ; i++) { - *next = (__GLcontextModes *) calloc(1, size); - if (*next == NULL) { - drm_visual_modes_destroy(head); - head = NULL; - break; - } - - (*next)->doubleBufferMode = 1; - (*next)->visualID = GLX_DONT_CARE; - (*next)->visualType = GLX_DONT_CARE; - (*next)->visualRating = GLX_NONE; - (*next)->transparentPixel = GLX_NONE; - (*next)->transparentRed = GLX_DONT_CARE; - (*next)->transparentGreen = GLX_DONT_CARE; - (*next)->transparentBlue = GLX_DONT_CARE; - (*next)->transparentAlpha = GLX_DONT_CARE; - (*next)->transparentIndex = GLX_DONT_CARE; - (*next)->xRenderable = GLX_DONT_CARE; - (*next)->fbconfigID = GLX_DONT_CARE; - (*next)->swapMethod = GLX_SWAP_UNDEFINED_OML; - (*next)->bindToTextureRgb = GLX_DONT_CARE; - (*next)->bindToTextureRgba = GLX_DONT_CARE; - (*next)->bindToMipmapTexture = GLX_DONT_CARE; - (*next)->bindToTextureTargets = 0; - (*next)->yInverted = GLX_DONT_CARE; - - next = & ((*next)->next); - } - - return head; -} - -__GLcontextModes * -drm_visual_from_config(_EGLConfig *conf) -{ - __GLcontextModes *visual; - (void)conf; - - visual = drm_visual_modes_create(1, sizeof(*visual)); - visual->redBits = 8; - visual->greenBits = 8; - visual->blueBits = 8; - visual->alphaBits = 8; - - visual->rgbBits = 32; - visual->doubleBufferMode = 1; - - visual->depthBits = 24; - visual->haveDepthBuffer = visual->depthBits > 0; - visual->stencilBits = 8; - visual->haveStencilBuffer = visual->stencilBits > 0; - - return visual; -} diff --git a/src/gallium/winsys/drm/i965/egl/Makefile b/src/gallium/winsys/drm/i965/egl/Makefile deleted file mode 100644 index a1b32eb2a7..0000000000 --- a/src/gallium/winsys/drm/i965/egl/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -TOP = ../../../../../.. -GALLIUMDIR = ../../../.. -include $(TOP)/configs/current - -LIBNAME = EGL_i965.so - -PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/egl/libegldrm.a \ - $(GALLIUMDIR)/winsys/drm/i965/gem/libi965drm.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ - $(TOP)/src/gallium/drivers/trace/libtrace.a \ - $(TOP)/src/gallium/drivers/i965/libi965.a - -DRIVER_SOURCES = - -C_SOURCES = \ - $(COMMON_GALLIUM_SOURCES) \ - $(DRIVER_SOURCES) - -DRIVER_EXTRAS = -ldrm_intel - -ASM_SOURCES = - -DRIVER_DEFINES = -I../gem $(shell pkg-config libdrm --atleast-version=2.3.1 \ - && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP") - -include ../../Makefile.template - -symlinks: diff --git a/src/gallium/winsys/drm/intel/egl/Makefile b/src/gallium/winsys/drm/intel/egl/Makefile deleted file mode 100644 index c9c92b69b6..0000000000 --- a/src/gallium/winsys/drm/intel/egl/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -TOP = ../../../../../.. -GALLIUMDIR = ../../../.. -include $(TOP)/configs/current - -LIBNAME = egl_i915.so - -PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/egl/libegldrm.a \ - $(GALLIUMDIR)/winsys/drm/intel/gem/libinteldrm.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ - $(TOP)/src/gallium/drivers/trace/libtrace.a \ - $(TOP)/src/gallium/drivers/i915/libi915.a - -DRIVER_EXTRAS = -lm -lpthread -ldrm_intel - -OBJECTS = dummy.o - -default: $(TOP)/$(LIB_DIR)/$(LIBNAME) - -$(TOP)/$(LIB_DIR)/$(LIBNAME): $(LIBNAME) - @mkdir -p $(TOP)/$(LIB_DIR) - $(INSTALL) $(LIBNAME) $(TOP)/$(LIB_DIR) - -$(LIBNAME): $(OBJECTS) $(GALLIUM_AUXILIARIES) $(PIPE_DRIVERS) Makefile - $(MKLIB) -noprefix -o $@ $(OBJECTS) \ - -Wl,--whole-archive $(PIPE_DRIVERS) -Wl,--no-whole-archive \ - -Wl,--start-group $(GALLIUM_AUXILIARIES) -Wl,--end-group \ - $(DRI_LIB_DEPS) $(DRIVER_EXTRAS) - -clean: - -rm -f *.o *.so *~ - -depend: - -symlinks: - -install: $(LIBNAME) - $(MINSTALL) -m 755 $(LIBNAME) $(INSTALL_DIR)/$(LIB_DIR) diff --git a/src/gallium/winsys/drm/intel/egl/dummy.c b/src/gallium/winsys/drm/intel/egl/dummy.c deleted file mode 100644 index 58c7af84e0..0000000000 --- a/src/gallium/winsys/drm/intel/egl/dummy.c +++ /dev/null @@ -1 +0,0 @@ -/* mklib expects at least one .o is given */ diff --git a/src/gallium/winsys/drm/radeon/egl/Makefile b/src/gallium/winsys/drm/radeon/egl/Makefile deleted file mode 100644 index fcbfd09786..0000000000 --- a/src/gallium/winsys/drm/radeon/egl/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -TOP = ../../../../../.. -GALLIUMDIR = ../../../.. -include $(TOP)/configs/current - -LIBNAME = egl_radeon.so - -PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/egl/libegldrm.a \ - $(GALLIUMDIR)/winsys/drm/radeon/core/libradeonwinsys.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ - $(TOP)/src/gallium/drivers/trace/libtrace.a \ - $(TOP)/src/gallium/drivers/r300/libr300.a - -DRIVER_EXTRAS = -lm -lpthread -ldrm_radeon - -OBJECTS = dummy.o - -default: $(TOP)/$(LIB_DIR)/$(LIBNAME) - -$(TOP)/$(LIB_DIR)/$(LIBNAME): $(LIBNAME) - @mkdir -p $(TOP)/$(LIB_DIR) - $(INSTALL) $(LIBNAME) $(TOP)/$(LIB_DIR) - -$(LIBNAME): $(OBJECTS) $(GALLIUM_AUXILIARIES) $(PIPE_DRIVERS) Makefile - $(MKLIB) -noprefix -o $@ $(OBJECTS) \ - -Wl,--whole-archive $(PIPE_DRIVERS) -Wl,--no-whole-archive \ - -Wl,--start-group $(GALLIUM_AUXILIARIES) -Wl,--end-group \ - $(DRI_LIB_DEPS) $(DRIVER_EXTRAS) - -clean: - -rm -f *.o *.so *~ - -depend: - -symlinks: - -install: $(LIBNAME) - $(MINSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) diff --git a/src/gallium/winsys/drm/radeon/egl/dummy.c b/src/gallium/winsys/drm/radeon/egl/dummy.c deleted file mode 100644 index 58c7af84e0..0000000000 --- a/src/gallium/winsys/drm/radeon/egl/dummy.c +++ /dev/null @@ -1 +0,0 @@ -/* mklib expects at least one .o is given */ diff --git a/src/gallium/winsys/drm/vmware/egl/Makefile b/src/gallium/winsys/drm/vmware/egl/Makefile deleted file mode 100644 index 8e2980c318..0000000000 --- a/src/gallium/winsys/drm/vmware/egl/Makefile +++ /dev/null @@ -1,18 +0,0 @@ - -TOP = ../../../../../.. -include $(TOP)/configs/current - -LIBNAME = EGL_svga.so - -PIPE_DRIVERS = \ - $(TOP)/src/gallium/state_trackers/egl/libegldrm.a \ - $(TOP)/src/gallium/winsys/drm/vmware/core/libsvgadrm.a \ - $(TOP)/src/gallium/drivers/trace/libtrace.a \ - $(TOP)/src/gallium/drivers/svga/libsvga.a - -C_SOURCES = \ - $(COMMON_GALLIUM_SOURCES) - -include ../../Makefile.template - -symlinks: -- cgit v1.2.3 From 3f6d732bfbe36b87f735d4f2287b21ad2ddd7535 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 21 Jan 2010 23:41:57 -0800 Subject: st/mesa: Remove unnecessary header from st_cb_viewport.c. --- src/mesa/state_tracker/st_cb_viewport.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/state_tracker/st_cb_viewport.c b/src/mesa/state_tracker/st_cb_viewport.c index d8bd24405c..b29191abef 100644 --- a/src/mesa/state_tracker/st_cb_viewport.c +++ b/src/mesa/state_tracker/st_cb_viewport.c @@ -32,7 +32,6 @@ #include "pipe/p_context.h" #include "pipe/p_state.h" #include "pipe/p_defines.h" -#include "pipe/internal/p_winsys_screen.h" static void st_viewport(GLcontext * ctx, GLint x, GLint y, -- cgit v1.2.3 From 383f460cf7472af4a526668c2412ab08ea30c0ec Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 21 Jan 2010 21:18:25 -0800 Subject: vmware/core: Update for pipebuffer changes. In particular, delay patching GMR relocations until the buffers are validated, since the buffers relative offset can only be established then. --- src/gallium/winsys/drm/vmware/core/vmw_context.c | 78 ++++++++++++++++++---- .../winsys/drm/vmware/core/vmw_screen_pools.c | 20 +++++- 2 files changed, 84 insertions(+), 14 deletions(-) diff --git a/src/gallium/winsys/drm/vmware/core/vmw_context.c b/src/gallium/winsys/drm/vmware/core/vmw_context.c index 87a3df923f..b5fd4f5a6a 100644 --- a/src/gallium/winsys/drm/vmware/core/vmw_context.c +++ b/src/gallium/winsys/drm/vmware/core/vmw_context.c @@ -41,9 +41,18 @@ #define VMW_COMMAND_SIZE (64*1024) #define VMW_SURFACE_RELOCS (1024) +#define VMW_REGION_RELOCS (512) #define VMW_MUST_FLUSH_STACK 8 +struct vmw_region_relocation +{ + struct SVGAGuestPtr *where; + struct pb_buffer *buffer; + /* TODO: put offset info inside where */ + uint32 offset; +}; + struct vmw_svga_winsys_context { struct svga_winsys_context base; @@ -69,6 +78,14 @@ struct vmw_svga_winsys_context uint32_t staged; uint32_t reserved; } surface; + + struct { + struct vmw_region_relocation relocs[VMW_REGION_RELOCS]; + uint32_t size; + uint32_t used; + uint32_t staged; + uint32_t reserved; + } region; struct pb_validate *validate; @@ -109,6 +126,19 @@ vmw_swc_flush(struct svga_winsys_context *swc, ret = pb_validate_validate(vswc->validate); assert(ret == PIPE_OK); if(ret == PIPE_OK) { + + /* Apply relocations */ + for(i = 0; i < vswc->region.used; ++i) { + struct vmw_region_relocation *reloc = &vswc->region.relocs[i]; + struct SVGAGuestPtr ptr; + + if(!vmw_gmr_bufmgr_region_ptr(reloc->buffer, &ptr)) + assert(0); + + ptr.offset += reloc->offset; + + *reloc->where = ptr; + } if (vswc->command.used) vmw_ioctl_command(vswc->vws, @@ -134,6 +164,13 @@ vmw_swc_flush(struct svga_winsys_context *swc, vswc->surface.used = 0; vswc->surface.reserved = 0; + for(i = 0; i < vswc->region.used + vswc->region.staged; ++i) { + pb_reference(&vswc->region.relocs[i].buffer, NULL); + } + + vswc->region.used = 0; + vswc->region.reserved = 0; + #ifdef DEBUG vswc->must_flush = FALSE; #endif @@ -168,7 +205,8 @@ vmw_swc_reserve(struct svga_winsys_context *swc, if(vswc->preemptive_flush || vswc->command.used + nr_bytes > vswc->command.size || - vswc->surface.used + nr_relocs > vswc->surface.size) { + vswc->surface.used + nr_relocs > vswc->surface.size || + vswc->region.used + nr_relocs > vswc->region.size) { #ifdef DEBUG vswc->must_flush = TRUE; debug_backtrace_capture(vswc->must_flush_stack, 1, @@ -179,11 +217,14 @@ vmw_swc_reserve(struct svga_winsys_context *swc, assert(vswc->command.used + nr_bytes <= vswc->command.size); assert(vswc->surface.used + nr_relocs <= vswc->surface.size); - + assert(vswc->region.used + nr_relocs <= vswc->region.size); + vswc->command.reserved = nr_bytes; vswc->surface.reserved = nr_relocs; vswc->surface.staged = 0; - + vswc->region.reserved = nr_relocs; + vswc->region.staged = 0; + return vswc->command.buffer + vswc->command.used; } @@ -222,18 +263,19 @@ vmw_swc_region_relocation(struct svga_winsys_context *swc, unsigned flags) { struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc); - struct SVGAGuestPtr ptr; - struct pb_buffer *buf = vmw_pb_buffer(buffer); + struct vmw_region_relocation *reloc; enum pipe_error ret; + + assert(vswc->region.staged < vswc->region.reserved); - if(!vmw_gmr_bufmgr_region_ptr(buf, &ptr)) - assert(0); + reloc = &vswc->region.relocs[vswc->region.used + vswc->region.staged]; + reloc->where = where; + pb_reference(&reloc->buffer, vmw_pb_buffer(buffer)); + reloc->offset = offset; - ptr.offset += offset; + ++vswc->region.staged; - *where = ptr; - - ret = pb_validate_add_buffer(vswc->validate, buf, flags); + ret = pb_validate_add_buffer(vswc->validate, reloc->buffer, flags); /* TODO: Update pipebuffer to reserve buffers and not fail here */ assert(ret == PIPE_OK); @@ -253,7 +295,7 @@ vmw_swc_region_relocation(struct svga_winsys_context *swc, * SVGA virtual device it's not a performance issue since flushing commands * to the FIFO won't cause flushing in the host. */ - vswc->seen_regions += buf->base.size; + vswc->seen_regions += reloc->buffer->base.size; if(vswc->seen_regions >= VMW_GMR_POOL_SIZE/2) vswc->preemptive_flush = TRUE; } @@ -274,6 +316,12 @@ vmw_swc_commit(struct svga_winsys_context *swc) vswc->surface.used += vswc->surface.staged; vswc->surface.staged = 0; vswc->surface.reserved = 0; + + assert(vswc->region.staged <= vswc->region.reserved); + assert(vswc->region.used + vswc->region.staged <= vswc->region.size); + vswc->region.used += vswc->region.staged; + vswc->region.staged = 0; + vswc->region.reserved = 0; } @@ -282,6 +330,11 @@ vmw_swc_destroy(struct svga_winsys_context *swc) { struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc); unsigned i; + + for(i = 0; i < vswc->region.used; ++i) { + pb_reference(&vswc->region.relocs[i].buffer, NULL); + } + for(i = 0; i < vswc->surface.used; ++i) { p_atomic_dec(&vswc->surface.handles[i]->validated); vmw_svga_winsys_surface_reference(&vswc->surface.handles[i], NULL); @@ -315,6 +368,7 @@ vmw_svga_winsys_context_create(struct svga_winsys_screen *sws) vswc->command.size = VMW_COMMAND_SIZE; vswc->surface.size = VMW_SURFACE_RELOCS; + vswc->region.size = VMW_REGION_RELOCS; vswc->validate = pb_validate_create(); if(!vswc->validate) { diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c index 78cfa78691..b9823d7857 100644 --- a/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c +++ b/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c @@ -58,11 +58,27 @@ vmw_pools_init(struct vmw_winsys_screen *vws) if(!vws->pools.gmr_mm) goto error; + /* + * GMR buffers are typically shortlived, but it's possible that at a given + * instance a buffer is mapped. So to avoid stalling we tell pipebuffer to + * forbid creation of buffers beyond half the GMR pool size, + * + * XXX: It is unclear weather we want to limit the total amount of temporary + * malloc memory used to backup unvalidated GMR buffers. On one hand it is + * preferrable to fail an allocation than exhausting the guest memory with + * temporary data, but on the other hand it is possible that a stupid + * application creates large vertex buffers and does not use them for a long + * time -- since the svga pipe driver only emits the DMA uploads when a + * buffer is used for drawing this would effectively disabling swapping GMR + * buffers to memory. So far, the preemptively flush already seems to keep + * total allocated memory within relatively small numbers, so we don't + * limit. + */ vws->pools.gmr_fenced = fenced_bufmgr_create( vws->pools.gmr_mm, vmw_fence_ops_create(vws), - 0, - 0); + VMW_GMR_POOL_SIZE/2, + ~0); #ifdef DEBUG vws->pools.gmr_fenced = pb_debug_manager_create(vws->pools.gmr_fenced, -- cgit v1.2.3 From a1306f4ef6f83a86d03720641f3cdc5e13485fa6 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 Jan 2010 15:51:51 +0800 Subject: winsys/drm: Add swrast. The swrast winsys always returns NULL when drm_api_create is called. --- configs/default | 4 ++-- configure.ac | 12 ++++++++++++ docs/egl.html | 10 ++++++++++ src/gallium/winsys/drm/swrast/Makefile | 12 ++++++++++++ src/gallium/winsys/drm/swrast/core/Makefile | 10 ++++++++++ src/gallium/winsys/drm/swrast/core/swrast_drm_api.c | 13 +++++++++++++ src/gallium/winsys/drm/swrast/egl_g3d/Makefile | 12 ++++++++++++ src/gallium/winsys/drm/swrast/egl_g3d/dummy.c | 1 + 8 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 src/gallium/winsys/drm/swrast/Makefile create mode 100644 src/gallium/winsys/drm/swrast/core/Makefile create mode 100644 src/gallium/winsys/drm/swrast/core/swrast_drm_api.c create mode 100644 src/gallium/winsys/drm/swrast/egl_g3d/Makefile create mode 100644 src/gallium/winsys/drm/swrast/egl_g3d/dummy.c diff --git a/configs/default b/configs/default index 6863495be3..2665f5296a 100644 --- a/configs/default +++ b/configs/default @@ -100,8 +100,8 @@ GALLIUM_DIRS = auxiliary drivers state_trackers GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a GALLIUM_DRIVERS_DIRS = softpipe failover svga i915 i965 r300 trace identity GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a) -GALLIUM_WINSYS_DIRS = xlib egl_xlib -GALLIUM_WINSYS_DRM_DIRS = +GALLIUM_WINSYS_DIRS = drm xlib egl_xlib +GALLIUM_WINSYS_DRM_DIRS = swrast GALLIUM_STATE_TRACKERS_DIRS = glx # native displays EGL should support diff --git a/configure.ac b/configure.ac index bb011abff2..d6e32f590a 100644 --- a/configure.ac +++ b/configure.ac @@ -1311,6 +1311,18 @@ if test "x$enable_gallium_nouveau" = xyes; then GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nv04 nv10 nv20 nv30 nv40 nv50" fi +dnl +dnl Gallium swrast configuration +dnl +AC_ARG_ENABLE([gallium-swrast], + [AS_HELP_STRING([--enable-gallium-swrast], + [build gallium swrast @<:@default=disabled@:>@])], + [enable_gallium_swrast="$enableval"], + [enable_gallium_swrast=auto]) +if test "x$enable_gallium_swrast" = xyes; then + GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS swrast" +fi + dnl prepend CORE_DIRS to SRC_DIRS SRC_DIRS="$CORE_DIRS $SRC_DIRS" diff --git a/docs/egl.html b/docs/egl.html index 5561d1a4b8..efc7b1ed3a 100644 --- a/docs/egl.html +++ b/docs/egl.html @@ -81,6 +81,15 @@ that a number of EGL drivers depend on the egl_g3d state tracker. They will not be built without the egl_g3d state tracker.

      +
    • + +
    • --enable-gallium-swrast + +

      This option is not specific to EGL. But if there is no driver for your +hardware, or you are experiencing problems with the hardware driver, you can +enable the swrast DRM driver. It is a dummy driver and EGL will fallback to +software rendering automatically.

      +
    @@ -159,6 +168,7 @@ tracker to build. The available drivers are

  • egl_<dpy>_i965
  • egl_<dpy>_radeon
  • egl_<dpy>_nouveau
  • +
  • egl_<dpy>_swrast
  • egl_<dpy>_vmwgfx
diff --git a/src/gallium/winsys/drm/swrast/Makefile b/src/gallium/winsys/drm/swrast/Makefile new file mode 100644 index 0000000000..363b89584f --- /dev/null +++ b/src/gallium/winsys/drm/swrast/Makefile @@ -0,0 +1,12 @@ +# src/gallium/winsys/drm/swrast/Makefile +TOP = ../../../../.. +include $(TOP)/configs/current + +SUBDIRS = core $(GALLIUM_STATE_TRACKERS_DIRS) + +default install clean: + @for dir in $(SUBDIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir && $(MAKE) $@) || exit 1; \ + fi \ + done diff --git a/src/gallium/winsys/drm/swrast/core/Makefile b/src/gallium/winsys/drm/swrast/core/Makefile new file mode 100644 index 0000000000..93931ae22b --- /dev/null +++ b/src/gallium/winsys/drm/swrast/core/Makefile @@ -0,0 +1,10 @@ +# src/gallium/winsys/drm/swrast/core/Makefile + +TOP = ../../../../../.. +include $(TOP)/configs/current + +LIBNAME = swrastdrm + +C_SOURCES = swrast_drm_api.c + +include ../../../../Makefile.template diff --git a/src/gallium/winsys/drm/swrast/core/swrast_drm_api.c b/src/gallium/winsys/drm/swrast/core/swrast_drm_api.c new file mode 100644 index 0000000000..8c9f80e2c1 --- /dev/null +++ b/src/gallium/winsys/drm/swrast/core/swrast_drm_api.c @@ -0,0 +1,13 @@ +#include "state_tracker/drm_api.h" + +static struct drm_api swrast_drm_api = +{ + .name = "swrast", +}; + +struct drm_api * +drm_api_create() +{ + (void) swrast_drm_api; + return NULL; +} diff --git a/src/gallium/winsys/drm/swrast/egl_g3d/Makefile b/src/gallium/winsys/drm/swrast/egl_g3d/Makefile new file mode 100644 index 0000000000..f0d051ea0e --- /dev/null +++ b/src/gallium/winsys/drm/swrast/egl_g3d/Makefile @@ -0,0 +1,12 @@ +TOP = ../../../../../.. +include $(TOP)/configs/current + +EGL_DRIVER_NAME = swrast +EGL_DRIVER_SOURCES = dummy.c +EGL_DRIVER_LIBS = + +EGL_DRIVER_PIPES = \ + $(TOP)/src/gallium/winsys/drm/swrast/core/libswrastdrm.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a + +include ../../Makefile.egl_g3d diff --git a/src/gallium/winsys/drm/swrast/egl_g3d/dummy.c b/src/gallium/winsys/drm/swrast/egl_g3d/dummy.c new file mode 100644 index 0000000000..4a1bc28b0b --- /dev/null +++ b/src/gallium/winsys/drm/swrast/egl_g3d/dummy.c @@ -0,0 +1 @@ +/* mklib expects at least one object file */ -- cgit v1.2.3 From 3b0ffd5a36c4626b44eafc43f5eaebb7c758bfbd Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 Jan 2010 16:02:39 +0800 Subject: egl: Remove egl_softpipe. With the addition egl_x11_swrast, egl_softpipe is sort of deprecated. The new driver serves the same purpose as egl_softpipe does. It is based on egl_g3d and provides more features. --- configs/default | 2 +- configs/linux-opengl-es | 8 +- docs/sourcetree.html | 1 - src/egl/main/egldriver.c | 2 +- src/gallium/winsys/egl_xlib/Makefile | 84 ---- src/gallium/winsys/egl_xlib/egl_xlib.c | 853 -------------------------------- src/gallium/winsys/egl_xlib/sw_winsys.c | 231 --------- src/gallium/winsys/egl_xlib/sw_winsys.h | 40 -- 8 files changed, 5 insertions(+), 1216 deletions(-) delete mode 100644 src/gallium/winsys/egl_xlib/Makefile delete mode 100644 src/gallium/winsys/egl_xlib/egl_xlib.c delete mode 100644 src/gallium/winsys/egl_xlib/sw_winsys.c delete mode 100644 src/gallium/winsys/egl_xlib/sw_winsys.h diff --git a/configs/default b/configs/default index 2665f5296a..3aa136b9c5 100644 --- a/configs/default +++ b/configs/default @@ -100,7 +100,7 @@ GALLIUM_DIRS = auxiliary drivers state_trackers GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a GALLIUM_DRIVERS_DIRS = softpipe failover svga i915 i965 r300 trace identity GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a) -GALLIUM_WINSYS_DIRS = drm xlib egl_xlib +GALLIUM_WINSYS_DIRS = drm xlib GALLIUM_WINSYS_DRM_DIRS = swrast GALLIUM_STATE_TRACKERS_DIRS = glx diff --git a/configs/linux-opengl-es b/configs/linux-opengl-es index e013658716..af784551a7 100644 --- a/configs/linux-opengl-es +++ b/configs/linux-opengl-es @@ -18,13 +18,11 @@ EGL_DRIVERS_DIRS = GALLIUM_DRIVERS_DIRS = softpipe -# build egl_softpipe.so -GALLIUM_WINSYS_DIRS = egl_xlib -# and libGLES*.so +# build libGLES*.so GALLIUM_STATE_TRACKERS_DIRS = es -# build egl_i915.so +# build egl_x11_{swrast,i915}.so GALLIUM_DRIVERS_DIRS += trace i915 GALLIUM_STATE_TRACKERS_DIRS += egl_g3d GALLIUM_WINSYS_DIRS += drm -GALLIUM_WINSYS_DRM_DIRS = intel +GALLIUM_WINSYS_DRM_DIRS += intel swrast diff --git a/docs/sourcetree.html b/docs/sourcetree.html index bc4ce71bee..41f40351eb 100644 --- a/docs/sourcetree.html +++ b/docs/sourcetree.html @@ -136,7 +136,6 @@ each directory.
  • winsys -
    • drm - -
    • egl_xlib -
    • g3dvl -
    • gdi -
    • xlib - diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 0574f83f45..f890df1bb1 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -61,7 +61,7 @@ library_suffix(void) #elif defined(_EGL_PLATFORM_POSIX) -static const char DefaultDriverName[] = "egl_softpipe"; +static const char DefaultDriverName[] = "egl_glx"; typedef void * lib_handle; diff --git a/src/gallium/winsys/egl_xlib/Makefile b/src/gallium/winsys/egl_xlib/Makefile deleted file mode 100644 index 06c1fb0b91..0000000000 --- a/src/gallium/winsys/egl_xlib/Makefile +++ /dev/null @@ -1,84 +0,0 @@ -# src/gallium/winsys/egl_xlib/Makefile - -# Build softpipe/xlib/EGL driver library/object: "egl_softpipe.so" - - -TOP = ../../../.. -include $(TOP)/configs/current - - -DRIVER_NAME = egl_softpipe.so - - -INCLUDE_DIRS = \ - -I$(TOP)/include \ - -I$(TOP)/src/egl/main \ - -I$(TOP)/src/mesa \ - -I$(TOP)/src/mesa/main \ - -I$(TOP)/src/gallium/include \ - -I$(TOP)/src/gallium/drivers \ - -I$(TOP)/src/gallium/auxiliary - -WINSYS_SOURCES = \ - egl_xlib.c \ - sw_winsys.c - -WINSYS_OBJECTS = $(WINSYS_SOURCES:.c=.o) - - -LIBS = \ - $(GALLIUM_DRIVERS) \ - $(GALLIUM_AUXILIARIES) -LIB_DEPS = $(EGL_LIB_DEPS) -lm -lX11 - -LOCAL_CFLAGS = - - -.c.o: - $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $(LOCAL_CFLAGS) $< -o $@ - - -.PHONY: library - - -default: depend library Makefile - - -library: $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) - - -# Make the egl_softpipe.so library -$(TOP)/$(LIB_DIR)/$(DRIVER_NAME): $(WINSYS_OBJECTS) $(LIBS) - $(TOP)/bin/mklib -o $(DRIVER_NAME) \ - -linker "$(CC)" \ - -noprefix \ - -install $(TOP)/$(LIB_DIR) \ - $(MKLIB_OPTIONS) $(WINSYS_OBJECTS) \ - -Wl,--whole-archive $(LIBS) -Wl,--no-whole-archive \ - $(LIB_DEPS) - - -depend: $(WINSYS_SOURCES) - @ echo "running $(MKDEP)" - @ rm -f depend # workaround oops on gutsy?!? - @ touch depend - @ $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(WINSYS_SOURCES) \ - > /dev/null 2>/dev/null - - -install: default - $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR) - @if [ -e $(TOP)/$(LIB_DIR) ]; then \ - $(MINSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(INSTALL_DIR)/$(LIB_DIR); \ - fi - - -# Emacs tags -tags: - etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h - -clean: - -rm -f *.o *~ *.bak - - -include depend diff --git a/src/gallium/winsys/egl_xlib/egl_xlib.c b/src/gallium/winsys/egl_xlib/egl_xlib.c deleted file mode 100644 index 1d9bac3871..0000000000 --- a/src/gallium/winsys/egl_xlib/egl_xlib.c +++ /dev/null @@ -1,853 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * 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, sub license, 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. - * - **************************************************************************/ - -/** - * EGL / softpipe / xlib winsys module - * - * Authors: Brian Paul - */ - - -#include -#include -#include - -#include "pipe/p_compiler.h" -#include "pipe/p_format.h" -#include "pipe/p_state.h" -#include "pipe/internal/p_winsys_screen.h" -#include "util/u_memory.h" -#include "util/u_math.h" -#include "softpipe/sp_winsys.h" -#include "softpipe/sp_texture.h" - -#include "eglconfig.h" -#include "eglconfigutil.h" -#include "eglcontext.h" -#include "egldisplay.h" -#include "egldriver.h" -#include "eglglobals.h" -#include "egllog.h" -#include "eglsurface.h" - -#include "state_tracker/st_public.h" - -#include "sw_winsys.h" - - -/** subclass of _EGLDriver */ -struct xlib_egl_driver -{ - _EGLDriver Base; /**< base class */ - EGLint apis; -}; - - -/** driver data of _EGLDisplay */ -struct xlib_egl_display -{ - Display *Dpy; - - struct pipe_winsys *winsys; - struct pipe_screen *screen; -}; - - -/** subclass of _EGLContext */ -struct xlib_egl_context -{ - _EGLContext Base; /**< base class */ - - struct pipe_context *pipe; /**< Gallium driver context */ - struct st_context *Context; /**< Mesa/gallium state tracker context */ -}; - - -/** subclass of _EGLSurface */ -struct xlib_egl_surface -{ - _EGLSurface Base; /**< base class */ - - /* These are set for window surface */ - Display *Dpy; /**< The X Display of the window */ - Window Win; /**< The user-created window ID */ - GC Gc; - XVisualInfo VisInfo; - - struct pipe_winsys *winsys; - - struct st_framebuffer *Framebuffer; -}; - - -static void -flush_frontbuffer(struct pipe_winsys *pws, - struct pipe_surface *psurf, - void *context_private); - - -/** cast wrapper */ -static INLINE struct xlib_egl_driver * -xlib_egl_driver(_EGLDriver *drv) -{ - return (struct xlib_egl_driver *) drv; -} - - -static INLINE struct xlib_egl_display * -xlib_egl_display(_EGLDisplay *dpy) -{ - return (struct xlib_egl_display *) dpy->DriverData; -} - - -static INLINE struct xlib_egl_surface * -lookup_surface(_EGLSurface *surf) -{ - return (struct xlib_egl_surface *) surf; -} - - -static INLINE struct xlib_egl_context * -lookup_context(_EGLContext *ctx) -{ - return (struct xlib_egl_context *) ctx; -} - - -/** - * Create the EGLConfigs. (one per X visual) - */ -static void -create_configs(struct xlib_egl_display *xdpy, _EGLDisplay *disp) -{ - static const EGLint all_apis = (EGL_OPENGL_ES_BIT | - EGL_OPENGL_ES2_BIT | - EGL_OPENVG_BIT | - EGL_OPENGL_BIT); - XVisualInfo *visInfo, visTemplate; - int num_visuals, i; - - /* get list of all X visuals, create an EGL config for each */ - visTemplate.screen = DefaultScreen(xdpy->Dpy); - visInfo = XGetVisualInfo(xdpy->Dpy, VisualScreenMask, - &visTemplate, &num_visuals); - if (!visInfo) { - printf("egl_xlib.c: couldn't get any X visuals\n"); - abort(); - } - - for (i = 0; i < num_visuals; i++) { - _EGLConfig *config = calloc(1, sizeof(_EGLConfig)); - int id = i + 1; - int rbits = util_bitcount(visInfo[i].red_mask); - int gbits = util_bitcount(visInfo[i].green_mask); - int bbits = util_bitcount(visInfo[i].blue_mask); - int abits = bbits == 8 ? 8 : 0; - int zbits = 24; - int sbits = 8; - int visid = visInfo[i].visualid; -#if defined(__cplusplus) || defined(c_plusplus) - int vistype = visInfo[i].c_class; -#else - int vistype = visInfo[i].class; -#endif - - _eglInitConfig(config, id); - SET_CONFIG_ATTRIB(config, EGL_BUFFER_SIZE, rbits + gbits + bbits + abits); - SET_CONFIG_ATTRIB(config, EGL_RED_SIZE, rbits); - SET_CONFIG_ATTRIB(config, EGL_GREEN_SIZE, gbits); - SET_CONFIG_ATTRIB(config, EGL_BLUE_SIZE, bbits); - SET_CONFIG_ATTRIB(config, EGL_ALPHA_SIZE, abits); - SET_CONFIG_ATTRIB(config, EGL_DEPTH_SIZE, zbits); - SET_CONFIG_ATTRIB(config, EGL_STENCIL_SIZE, sbits); - SET_CONFIG_ATTRIB(config, EGL_NATIVE_VISUAL_ID, visid); - SET_CONFIG_ATTRIB(config, EGL_NATIVE_VISUAL_TYPE, vistype); - SET_CONFIG_ATTRIB(config, EGL_NATIVE_RENDERABLE, EGL_FALSE); - SET_CONFIG_ATTRIB(config, EGL_CONFORMANT, all_apis); - SET_CONFIG_ATTRIB(config, EGL_RENDERABLE_TYPE, all_apis); - SET_CONFIG_ATTRIB(config, EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT); - SET_CONFIG_ATTRIB(config, EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE); - SET_CONFIG_ATTRIB(config, EGL_BIND_TO_TEXTURE_RGB, EGL_TRUE); - - _eglAddConfig(disp, config); - } - - XFree(visInfo); -} - - -/** - * Called via eglInitialize(), drv->API.Initialize(). - */ -static EGLBoolean -xlib_eglInitialize(_EGLDriver *drv, _EGLDisplay *dpy, - EGLint *major, EGLint *minor) -{ - struct xlib_egl_driver *xdrv = xlib_egl_driver(drv); - struct xlib_egl_display *xdpy; - - xdpy = CALLOC_STRUCT(xlib_egl_display); - if (!xdpy) - return _eglError(EGL_BAD_ALLOC, "eglInitialize"); - - xdpy->Dpy = (Display *) dpy->NativeDisplay; - if (!xdpy->Dpy) { - xdpy->Dpy = XOpenDisplay(NULL); - if (!xdpy->Dpy) { - free(xdpy); - return EGL_FALSE; - } - } - - /* create winsys and pipe screen */ - xdpy->winsys = create_sw_winsys(); - if (!xdpy->winsys) { - free(xdpy); - return _eglError(EGL_BAD_ALLOC, "eglInitialize"); - } - xdpy->winsys->flush_frontbuffer = flush_frontbuffer; - xdpy->screen = softpipe_create_screen(xdpy->winsys); - if (!xdpy->screen) { - free(xdpy->winsys); - free(xdpy); - return _eglError(EGL_BAD_ALLOC, "eglInitialize"); - } - - dpy->DriverData = (void *) xdpy; - dpy->ClientAPIsMask = xdrv->apis; - - create_configs(xdpy, dpy); - - /* we're supporting EGL 1.4 */ - *major = 1; - *minor = 4; - - return EGL_TRUE; -} - - -/** - * Called via eglTerminate(), drv->API.Terminate(). - */ -static EGLBoolean -xlib_eglTerminate(_EGLDriver *drv, _EGLDisplay *dpy) -{ - struct xlib_egl_display *xdpy = xlib_egl_display(dpy); - - _eglReleaseDisplayResources(drv, dpy); - _eglCleanupDisplay(dpy); - - xdpy->screen->destroy(xdpy->screen); - free(xdpy->winsys); - - if (!dpy->NativeDisplay) - XCloseDisplay(xdpy->Dpy); - free(xdpy); - - return EGL_TRUE; -} - - -static _EGLProc -xlib_eglGetProcAddress(_EGLDriver *drv, const char *procname) -{ - return (_EGLProc) st_get_proc_address(procname); -} - - -static void -get_drawable_visual_info(Display *dpy, Drawable d, XVisualInfo *visInfo) -{ - XWindowAttributes attr; - XVisualInfo visTemp, *vis; - int num_visuals; - - XGetWindowAttributes(dpy, d, &attr); - - visTemp.screen = DefaultScreen(dpy); - visTemp.visualid = attr.visual->visualid; - vis = XGetVisualInfo(dpy, - (VisualScreenMask | VisualIDMask), - &visTemp, &num_visuals); - if (vis) - *visInfo = *vis; - - XFree(vis); -} - - - -/** Get size of given window */ -static Status -get_drawable_size(Display *dpy, Drawable d, uint *width, uint *height) -{ - Window root; - Status stat; - int xpos, ypos; - unsigned int w, h, bw, depth; - stat = XGetGeometry(dpy, d, &root, &xpos, &ypos, &w, &h, &bw, &depth); - *width = w; - *height = h; - return stat; -} - - -static void -check_and_update_buffer_size(struct xlib_egl_surface *surface) -{ - uint width, height; - if (surface->Base.Type == EGL_PBUFFER_BIT) { - width = surface->Base.Width; - height = surface->Base.Height; - } - else { - get_drawable_size(surface->Dpy, surface->Win, &width, &height); - } - st_resize_framebuffer(surface->Framebuffer, width, height); - surface->Base.Width = width; - surface->Base.Height = height; -} - - - -static void -display_surface(struct pipe_winsys *pws, - struct pipe_surface *psurf, - struct xlib_egl_surface *xsurf) -{ - struct softpipe_texture *spt = softpipe_texture(psurf->texture); - XImage *ximage; - void *data; - - if (xsurf->Base.Type == EGL_PBUFFER_BIT) - return; - - ximage = XCreateImage(xsurf->Dpy, - xsurf->VisInfo.visual, - xsurf->VisInfo.depth, - ZPixmap, 0, /* format, offset */ - NULL, /* data */ - 0, 0, /* size */ - 32, /* bitmap_pad */ - 0); /* bytes_per_line */ - - - assert(ximage->format); - assert(ximage->bitmap_unit); - - data = pws->buffer_map(pws, spt->buffer, 0); - - /* update XImage's fields */ - ximage->data = data; - ximage->width = psurf->width; - ximage->height = psurf->height; - ximage->bytes_per_line = spt->stride[psurf->level]; - - XPutImage(xsurf->Dpy, xsurf->Win, xsurf->Gc, - ximage, 0, 0, 0, 0, psurf->width, psurf->height); - - XSync(xsurf->Dpy, 0); - - ximage->data = NULL; - XDestroyImage(ximage); - - pws->buffer_unmap(pws, spt->buffer); -} - - - -/** Display gallium surface in X window */ -static void -flush_frontbuffer(struct pipe_winsys *pws, - struct pipe_surface *psurf, - void *context_private) -{ - struct xlib_egl_surface *xsurf = (struct xlib_egl_surface *) context_private; - display_surface(pws, psurf, xsurf); -} - - - -/** - * Called via eglCreateContext(), drv->API.CreateContext(). - */ -static _EGLContext * -xlib_eglCreateContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, - _EGLContext *share_list, const EGLint *attrib_list) -{ - struct xlib_egl_display *xdpy = xlib_egl_display(dpy); - struct xlib_egl_context *ctx; - struct st_context *share_ctx = NULL; /* XXX fix */ - __GLcontextModes visual; - - ctx = CALLOC_STRUCT(xlib_egl_context); - if (!ctx) - return NULL; - - /* let EGL lib init the common stuff */ - if (!_eglInitContext(drv, &ctx->Base, conf, attrib_list)) { - free(ctx); - return NULL; - } - - /* API-dependent context creation */ - switch (ctx->Base.ClientAPI) { - case EGL_OPENVG_API: - case EGL_OPENGL_ES_API: - _eglLog(_EGL_DEBUG, "Create Context for ES version %d\n", - ctx->Base.ClientVersion); - /* fall-through */ - case EGL_OPENGL_API: - /* create a softpipe context */ - ctx->pipe = softpipe_create(xdpy->screen); - /* Now do xlib / state tracker inits here */ - _eglConfigToContextModesRec(conf, &visual); - ctx->Context = st_create_context(ctx->pipe, &visual, share_ctx); - break; - default: - _eglError(EGL_BAD_MATCH, "eglCreateContext(unsupported API)"); - free(ctx); - return NULL; - } - - return &ctx->Base; -} - - -static EGLBoolean -xlib_eglDestroyContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) -{ - struct xlib_egl_context *context = lookup_context(ctx); - - if (!_eglIsContextBound(&context->Base)) { - /* API-dependent clean-up */ - switch (context->Base.ClientAPI) { - case EGL_OPENGL_ES_API: - case EGL_OPENVG_API: - /* fall-through */ - case EGL_OPENGL_API: - st_destroy_context(context->Context); - break; - default: - assert(0); - } - free(context); - } - return EGL_TRUE; -} - - -/** - * Called via eglMakeCurrent(), drv->API.MakeCurrent(). - */ -static EGLBoolean -xlib_eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLSurface *draw, _EGLSurface *read, _EGLContext *ctx) -{ - struct xlib_egl_context *context = lookup_context(ctx); - struct xlib_egl_surface *draw_surf = lookup_surface(draw); - struct xlib_egl_surface *read_surf = lookup_surface(read); - struct st_context *oldcontext = NULL; - _EGLContext *oldctx; - - oldctx = _eglGetCurrentContext(); - if (oldctx && _eglIsContextLinked(oldctx)) - oldcontext = st_get_current(); - - if (!_eglMakeCurrent(drv, dpy, draw, read, ctx)) - return EGL_FALSE; - - /* Flush before switching context. Check client API? */ - if (oldcontext) - st_flush(oldcontext, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); - st_make_current((context ? context->Context : NULL), - (draw_surf ? draw_surf->Framebuffer : NULL), - (read_surf ? read_surf->Framebuffer : NULL)); - - if (draw_surf) - check_and_update_buffer_size(draw_surf); - if (read_surf && read_surf != draw_surf) - check_and_update_buffer_size(draw_surf); - - return EGL_TRUE; -} - - -static enum pipe_format -choose_color_format(const __GLcontextModes *visual) -{ - if (visual->redBits == 8 && - visual->greenBits == 8 && - visual->blueBits == 8 && - visual->alphaBits == 8) { - /* XXX this really also depends on the ordering of R,G,B,A */ - return PIPE_FORMAT_A8R8G8B8_UNORM; - } - else { - assert(0); - return PIPE_FORMAT_NONE; - } -} - - -static enum pipe_format -choose_depth_format(const __GLcontextModes *visual) -{ - if (visual->depthBits > 0) - return PIPE_FORMAT_S8Z24_UNORM; - else - return PIPE_FORMAT_NONE; -} - - -static enum pipe_format -choose_stencil_format(const __GLcontextModes *visual) -{ - if (visual->stencilBits > 0) - return PIPE_FORMAT_S8Z24_UNORM; - else - return PIPE_FORMAT_NONE; -} - - -/** - * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface(). - */ -static _EGLSurface * -xlib_eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, - NativeWindowType window, const EGLint *attrib_list) -{ - struct xlib_egl_display *xdpy = xlib_egl_display(disp); - struct xlib_egl_surface *surf; - __GLcontextModes visual; - uint width, height; - - surf = CALLOC_STRUCT(xlib_egl_surface); - if (!surf) - return NULL; - - /* Let EGL lib init the common stuff */ - if (!_eglInitSurface(drv, &surf->Base, EGL_WINDOW_BIT, - conf, attrib_list)) { - free(surf); - return NULL; - } - - /* - * Now init the Xlib and gallium stuff - */ - surf->Win = (Window) window; /* The X window ID */ - surf->Dpy = xdpy->Dpy; /* The X display */ - surf->Gc = XCreateGC(surf->Dpy, surf->Win, 0, NULL); - - surf->winsys = xdpy->winsys; - - _eglConfigToContextModesRec(conf, &visual); - get_drawable_size(surf->Dpy, surf->Win, &width, &height); - get_drawable_visual_info(surf->Dpy, surf->Win, &surf->VisInfo); - - surf->Base.Width = width; - surf->Base.Height = height; - - /* Create GL statetracker framebuffer */ - surf->Framebuffer = st_create_framebuffer(&visual, - choose_color_format(&visual), - choose_depth_format(&visual), - choose_stencil_format(&visual), - width, height, - (void *) surf); - - st_resize_framebuffer(surf->Framebuffer, width, height); - - return &surf->Base; -} - - -static _EGLSurface * -xlib_eglCreatePbufferSurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, - const EGLint *attrib_list) -{ - struct xlib_egl_display *xdpy = xlib_egl_display(disp); - struct xlib_egl_surface *surf; - __GLcontextModes visual; - uint width, height; - EGLBoolean bind_texture; - - surf = CALLOC_STRUCT(xlib_egl_surface); - if (!surf) { - _eglError(EGL_BAD_ALLOC, "eglCreatePbufferSurface"); - return NULL; - } - - if (!_eglInitSurface(drv, &surf->Base, EGL_PBUFFER_BIT, - conf, attrib_list)) { - free(surf); - return NULL; - } - if (surf->Base.Width < 0 || surf->Base.Height < 0) { - _eglError(EGL_BAD_PARAMETER, "eglCreatePbufferSurface"); - free(surf); - return NULL; - } - - bind_texture = (surf->Base.TextureFormat != EGL_NO_TEXTURE); - width = (uint) surf->Base.Width; - height = (uint) surf->Base.Height; - if ((surf->Base.TextureTarget == EGL_NO_TEXTURE && bind_texture) || - (surf->Base.TextureTarget != EGL_NO_TEXTURE && !bind_texture)) { - _eglError(EGL_BAD_MATCH, "eglCreatePbufferSurface"); - free(surf); - return NULL; - } - /* a framebuffer of zero width or height confuses st */ - if (width == 0 || height == 0) { - _eglError(EGL_BAD_MATCH, "eglCreatePbufferSurface"); - free(surf); - return NULL; - } - /* no mipmap generation */ - if (surf->Base.MipmapTexture) { - _eglError(EGL_BAD_MATCH, "eglCreatePbufferSurface"); - free(surf); - return NULL; - } - - surf->winsys = xdpy->winsys; - - _eglConfigToContextModesRec(conf, &visual); - - /* Create GL statetracker framebuffer */ - surf->Framebuffer = st_create_framebuffer(&visual, - choose_color_format(&visual), - choose_depth_format(&visual), - choose_stencil_format(&visual), - width, height, - (void *) surf); - st_resize_framebuffer(surf->Framebuffer, width, height); - - return &surf->Base; -} - - -static EGLBoolean -xlib_eglDestroySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface) -{ - struct xlib_egl_surface *surf = lookup_surface(surface); - if (!_eglIsSurfaceBound(&surf->Base)) { - if (surf->Base.Type != EGL_PBUFFER_BIT) - XFreeGC(surf->Dpy, surf->Gc); - st_unreference_framebuffer(surf->Framebuffer); - free(surf); - } - return EGL_TRUE; -} - - -static EGLBoolean -xlib_eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLSurface *surface, EGLint buffer) -{ - struct xlib_egl_surface *xsurf = lookup_surface(surface); - struct xlib_egl_context *xctx; - struct pipe_surface *psurf; - enum pipe_format format; - int target; - - if (!xsurf || xsurf->Base.Type != EGL_PBUFFER_BIT) - return _eglError(EGL_BAD_SURFACE, "eglBindTexImage"); - if (buffer != EGL_BACK_BUFFER) - return _eglError(EGL_BAD_PARAMETER, "eglBindTexImage"); - if (xsurf->Base.BoundToTexture) - return _eglError(EGL_BAD_ACCESS, "eglBindTexImage"); - - /* this should be updated when choose_color_format is */ - switch (xsurf->Base.TextureFormat) { - case EGL_TEXTURE_RGB: - format = PIPE_FORMAT_R8G8B8_UNORM; - break; - case EGL_TEXTURE_RGBA: - format = PIPE_FORMAT_A8R8G8B8_UNORM; - break; - default: - return _eglError(EGL_BAD_MATCH, "eglBindTexImage"); - } - - switch (xsurf->Base.TextureTarget) { - case EGL_TEXTURE_2D: - target = ST_TEXTURE_2D; - break; - default: - return _eglError(EGL_BAD_MATCH, "eglBindTexImage"); - } - - /* flush properly */ - if (eglGetCurrentSurface(EGL_DRAW) == surface) { - xctx = lookup_context(_eglGetCurrentContext()); - st_flush(xctx->Context, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, - NULL); - } - else if (_eglIsSurfaceBound(&xsurf->Base)) { - xctx = lookup_context(xsurf->Base.Binding); - if (xctx) - st_finish(xctx->Context); - } - - st_get_framebuffer_surface(xsurf->Framebuffer, ST_SURFACE_BACK_LEFT, - &psurf); - st_bind_texture_surface(psurf, target, xsurf->Base.MipmapLevel, format); - xsurf->Base.BoundToTexture = EGL_TRUE; - - return EGL_TRUE; -} - - -static EGLBoolean -xlib_eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, - EGLint buffer) -{ - struct xlib_egl_surface *xsurf = lookup_surface(surface); - struct pipe_surface *psurf; - - if (!xsurf || xsurf->Base.Type != EGL_PBUFFER_BIT || - !xsurf->Base.BoundToTexture) - return _eglError(EGL_BAD_SURFACE, "eglReleaseTexImage"); - if (buffer != EGL_BACK_BUFFER) - return _eglError(EGL_BAD_PARAMETER, "eglReleaseTexImage"); - - st_get_framebuffer_surface(xsurf->Framebuffer, ST_SURFACE_BACK_LEFT, - &psurf); - st_unbind_texture_surface(psurf, ST_TEXTURE_2D, xsurf->Base.MipmapLevel); - xsurf->Base.BoundToTexture = EGL_FALSE; - - return EGL_TRUE; -} - - -static EGLBoolean -xlib_eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw) -{ - struct xlib_egl_surface *xsurf = lookup_surface(draw); - struct pipe_winsys *pws = xsurf->winsys; - struct pipe_surface *psurf; - - st_get_framebuffer_surface(xsurf->Framebuffer, ST_SURFACE_BACK_LEFT, - &psurf); - - st_notify_swapbuffers(xsurf->Framebuffer); - - display_surface(pws, psurf, xsurf); - - check_and_update_buffer_size(xsurf); - - return EGL_TRUE; -} - - -/** - * Determine which API(s) is(are) present by looking for some specific - * global symbols. - */ -static EGLint -find_supported_apis(void) -{ - EGLint mask = 0; - void *handle; - - handle = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL); - if(!handle) - return mask; - - if (dlsym(handle, "st_api_OpenGL_ES1")) - mask |= EGL_OPENGL_ES_BIT; - - if (dlsym(handle, "st_api_OpenGL_ES2")) - mask |= EGL_OPENGL_ES2_BIT; - - if (dlsym(handle, "st_api_OpenGL")) - mask |= EGL_OPENGL_BIT; - - if (dlsym(handle, "st_api_OpenVG")) - mask |= EGL_OPENVG_BIT; - - dlclose(handle); - - return mask; -} - - -static void -xlib_Unload(_EGLDriver *drv) -{ - struct xlib_egl_driver *xdrv = xlib_egl_driver(drv); - free(xdrv); -} - - -/** - * This is the main entrypoint into the driver. - * Called by libEGL to instantiate an _EGLDriver object. - */ -_EGLDriver * -_eglMain(const char *args) -{ - struct xlib_egl_driver *xdrv; - - _eglLog(_EGL_INFO, "Entering EGL/Xlib _eglMain(%s)", args); - - xdrv = CALLOC_STRUCT(xlib_egl_driver); - if (!xdrv) - return NULL; - - _eglInitDriverFallbacks(&xdrv->Base); - xdrv->Base.API.Initialize = xlib_eglInitialize; - xdrv->Base.API.Terminate = xlib_eglTerminate; - xdrv->Base.API.GetProcAddress = xlib_eglGetProcAddress; - xdrv->Base.API.CreateContext = xlib_eglCreateContext; - xdrv->Base.API.DestroyContext = xlib_eglDestroyContext; - xdrv->Base.API.CreateWindowSurface = xlib_eglCreateWindowSurface; - xdrv->Base.API.CreatePbufferSurface = xlib_eglCreatePbufferSurface; - xdrv->Base.API.DestroySurface = xlib_eglDestroySurface; - xdrv->Base.API.BindTexImage = xlib_eglBindTexImage; - xdrv->Base.API.ReleaseTexImage = xlib_eglReleaseTexImage; - xdrv->Base.API.MakeCurrent = xlib_eglMakeCurrent; - xdrv->Base.API.SwapBuffers = xlib_eglSwapBuffers; - - xdrv->apis = find_supported_apis(); - if (xdrv->apis == 0x0) { - /* the app isn't directly linked with any EGL-supprted APIs - * (such as libGLESv2.so) so use an EGL utility to see what - * APIs might be loaded dynamically on this system. - */ - xdrv->apis = _eglFindAPIs(); - } - - xdrv->Base.Name = "Xlib/softpipe"; - xdrv->Base.Unload = xlib_Unload; - - return &xdrv->Base; -} diff --git a/src/gallium/winsys/egl_xlib/sw_winsys.c b/src/gallium/winsys/egl_xlib/sw_winsys.c deleted file mode 100644 index 6ee3ede38c..0000000000 --- a/src/gallium/winsys/egl_xlib/sw_winsys.c +++ /dev/null @@ -1,231 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * 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, sub license, 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. - * - **************************************************************************/ - -/** - * Totally software-based winsys layer. - * Note that the one winsys function that we can't implement here - * is flush_frontbuffer(). - * Whoever uses this code will have to provide that. - * - * Authors: Brian Paul - */ - - -#include "pipe/internal/p_winsys_screen.h" -#include "pipe/p_state.h" -#include "pipe/p_inlines.h" -#include "util/u_format.h" -#include "util/u_math.h" -#include "util/u_memory.h" - -#include "sw_winsys.h" - - - -/** Subclass of pipe_winsys */ -struct sw_pipe_winsys -{ - struct pipe_winsys Base; - /* no extra fields for now */ -}; - - -/** subclass of pipe_buffer */ -struct sw_pipe_buffer -{ - struct pipe_buffer Base; - boolean UserBuffer; /** Is this a user-space buffer? */ - void *Data; - void *Mapped; -}; - - -/** cast wrapper */ -static INLINE struct sw_pipe_buffer * -sw_pipe_buffer(struct pipe_buffer *b) -{ - return (struct sw_pipe_buffer *) b; -} - - -static const char * -get_name(struct pipe_winsys *pws) -{ - return "software"; -} - - -/** Create new pipe_buffer and allocate storage of given size */ -static struct pipe_buffer * -buffer_create(struct pipe_winsys *pws, - unsigned alignment, - unsigned usage, - unsigned size) -{ - struct sw_pipe_buffer *buffer = CALLOC_STRUCT(sw_pipe_buffer); - if (!buffer) - return NULL; - - pipe_reference_init(&buffer->Base.reference, 1); - buffer->Base.alignment = alignment; - buffer->Base.usage = usage; - buffer->Base.size = size; - - /* align to 16-byte multiple for Cell */ - buffer->Data = align_malloc(size, MAX2(alignment, 16)); - - return &buffer->Base; -} - - -/** - * Create buffer which wraps user-space data. - */ -static struct pipe_buffer * -user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes) -{ - struct sw_pipe_buffer *buffer = CALLOC_STRUCT(sw_pipe_buffer); - if (!buffer) - return NULL; - - pipe_reference_init(&buffer->Base.reference, 1); - buffer->Base.size = bytes; - buffer->UserBuffer = TRUE; - buffer->Data = ptr; - - return &buffer->Base; -} - - -static void * -buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buf, unsigned flags) -{ - struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); - buffer->Mapped = buffer->Data; - return buffer->Mapped; -} - - -static void -buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf) -{ - struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); - buffer->Mapped = NULL; -} - - -static void -buffer_destroy(struct pipe_buffer *buf) -{ - struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); - - if (buffer->Data && !buffer->UserBuffer) { - align_free(buffer->Data); - buffer->Data = NULL; - } - - free(buffer); -} - - -static struct pipe_buffer * -surface_buffer_create(struct pipe_winsys *winsys, - unsigned width, unsigned height, - enum pipe_format format, - unsigned usage, - unsigned tex_usage, - unsigned *stride) -{ - const unsigned alignment = 64; - unsigned nblocksy; - - nblocksy = util_format_get_nblocksy(format, height); - *stride = align(util_format_get_stride(format, width), alignment); - - return winsys->buffer_create(winsys, alignment, - usage, - *stride * nblocksy); -} - - -static void -fence_reference(struct pipe_winsys *sws, struct pipe_fence_handle **ptr, - struct pipe_fence_handle *fence) -{ - /* no-op */ -} - - -static int -fence_signalled(struct pipe_winsys *sws, struct pipe_fence_handle *fence, - unsigned flag) -{ - /* no-op */ - return 0; -} - - -static int -fence_finish(struct pipe_winsys *sws, struct pipe_fence_handle *fence, - unsigned flag) -{ - /* no-op */ - return 0; -} - - -/** - * Create/return a new pipe_winsys object. - */ -struct pipe_winsys * -create_sw_winsys(void) -{ - struct sw_pipe_winsys *ws = CALLOC_STRUCT(sw_pipe_winsys); - if (!ws) - return NULL; - - /* Fill in this struct with callbacks that pipe will need to - * communicate with the window system, buffer manager, etc. - */ - ws->Base.buffer_create = buffer_create; - ws->Base.user_buffer_create = user_buffer_create; - ws->Base.buffer_map = buffer_map; - ws->Base.buffer_unmap = buffer_unmap; - ws->Base.buffer_destroy = buffer_destroy; - - ws->Base.surface_buffer_create = surface_buffer_create; - - ws->Base.fence_reference = fence_reference; - ws->Base.fence_signalled = fence_signalled; - ws->Base.fence_finish = fence_finish; - - ws->Base.flush_frontbuffer = NULL; /* not implemented here! */ - - ws->Base.get_name = get_name; - - return &ws->Base; -} diff --git a/src/gallium/winsys/egl_xlib/sw_winsys.h b/src/gallium/winsys/egl_xlib/sw_winsys.h deleted file mode 100644 index f96c5a14b0..0000000000 --- a/src/gallium/winsys/egl_xlib/sw_winsys.h +++ /dev/null @@ -1,40 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * 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, sub license, 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. - * - **************************************************************************/ - - -#ifndef SW_WINSYS_H -#define SW_WINSYS_H - - -struct pipe_winsys; - - -extern struct pipe_winsys * -create_sw_winsys(void); - - -#endif /* SW_WINSYS_H */ -- cgit v1.2.3 From 3a4b7d3071c7377d8fbe37a0a2f486b919ff53cb Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 Jan 2010 16:25:11 +0800 Subject: winsys/drm: Update the options of mklib in Makefile.egl_g3d. Pass -linker, -ldflags, and $(MKLIB_OPTIONS) to mklib. --- src/gallium/winsys/drm/Makefile.egl_g3d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/winsys/drm/Makefile.egl_g3d b/src/gallium/winsys/drm/Makefile.egl_g3d index 3ce2725852..d8f47396d1 100644 --- a/src/gallium/winsys/drm/Makefile.egl_g3d +++ b/src/gallium/winsys/drm/Makefile.egl_g3d @@ -39,7 +39,8 @@ $(EGL_DISPLAY_LIBS): $(LIB_GALLIUM_DIR)/%.so: %.so $(INSTALL) $^ $(LIB_GALLIUM_DIR) define mklib-egl -$(MKLIB) -noprefix -o $@ $(EGL_DRIVER_OBJECTS) \ +$(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ + $(MKLIB_OPTIONS) $(EGL_DRIVER_OBJECTS) \ -Wl,--whole-archive $($(1)_ST) -Wl,--no-whole-archive \ $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) $($(1)_LIBS) $(EGL_DRIVER_LIBS) endef -- cgit v1.2.3 From 3c967a920718c2a74996ac23b8c1964915db88c2 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 Jan 2010 16:31:43 +0800 Subject: st/egl_g3d: Rename to st/egl. Simply the name to egl. --- configs/linux-dri | 2 +- configs/linux-opengl-es | 4 +- configure.ac | 8 +- docs/egl.html | 15 +- docs/opengles.html | 2 +- docs/openvg.html | 2 +- src/gallium/state_trackers/egl/Makefile | 75 ++ src/gallium/state_trackers/egl/common/egl_g3d.c | 1336 ++++++++++++++++++++ src/gallium/state_trackers/egl/common/egl_g3d.h | 127 ++ src/gallium/state_trackers/egl/common/egl_st.c | 131 ++ src/gallium/state_trackers/egl/common/egl_st.h | 73 ++ src/gallium/state_trackers/egl/common/native.h | 277 ++++ .../state_trackers/egl/common/st_public_tmp.h | 20 + src/gallium/state_trackers/egl/kms/native_kms.c | 866 +++++++++++++ src/gallium/state_trackers/egl/kms/native_kms.h | 139 ++ src/gallium/state_trackers/egl/x11/native_dri2.c | 705 +++++++++++ src/gallium/state_trackers/egl/x11/native_x11.c | 148 +++ src/gallium/state_trackers/egl/x11/native_x11.h | 37 + src/gallium/state_trackers/egl/x11/native_ximage.c | 694 ++++++++++ src/gallium/state_trackers/egl/x11/sw_winsys.c | 231 ++++ src/gallium/state_trackers/egl/x11/sw_winsys.h | 40 + src/gallium/state_trackers/egl/x11/x11_screen.c | 453 +++++++ src/gallium/state_trackers/egl/x11/x11_screen.h | 105 ++ src/gallium/state_trackers/egl_g3d/Makefile | 75 -- .../state_trackers/egl_g3d/common/egl_g3d.c | 1336 -------------------- .../state_trackers/egl_g3d/common/egl_g3d.h | 127 -- src/gallium/state_trackers/egl_g3d/common/egl_st.c | 131 -- src/gallium/state_trackers/egl_g3d/common/egl_st.h | 73 -- src/gallium/state_trackers/egl_g3d/common/native.h | 277 ---- .../state_trackers/egl_g3d/common/st_public_tmp.h | 20 - .../state_trackers/egl_g3d/kms/native_kms.c | 866 ------------- .../state_trackers/egl_g3d/kms/native_kms.h | 139 -- .../state_trackers/egl_g3d/x11/native_dri2.c | 705 ----------- .../state_trackers/egl_g3d/x11/native_x11.c | 148 --- .../state_trackers/egl_g3d/x11/native_x11.h | 37 - .../state_trackers/egl_g3d/x11/native_ximage.c | 694 ---------- src/gallium/state_trackers/egl_g3d/x11/sw_winsys.c | 231 ---- src/gallium/state_trackers/egl_g3d/x11/sw_winsys.h | 40 - .../state_trackers/egl_g3d/x11/x11_screen.c | 453 ------- .../state_trackers/egl_g3d/x11/x11_screen.h | 105 -- src/gallium/winsys/drm/Makefile.egl | 65 + src/gallium/winsys/drm/Makefile.egl_g3d | 65 - src/gallium/winsys/drm/i965/egl/Makefile | 14 + src/gallium/winsys/drm/i965/egl/dummy.c | 1 + src/gallium/winsys/drm/i965/egl_g3d/Makefile | 14 - src/gallium/winsys/drm/i965/egl_g3d/dummy.c | 1 - src/gallium/winsys/drm/intel/egl/Makefile | 14 + src/gallium/winsys/drm/intel/egl/dummy.c | 1 + src/gallium/winsys/drm/intel/egl_g3d/Makefile | 14 - src/gallium/winsys/drm/intel/egl_g3d/dummy.c | 1 - src/gallium/winsys/drm/nouveau/egl/Makefile | 19 + src/gallium/winsys/drm/nouveau/egl/dummy.c | 1 + src/gallium/winsys/drm/nouveau/egl_g3d/Makefile | 19 - src/gallium/winsys/drm/nouveau/egl_g3d/dummy.c | 1 - src/gallium/winsys/drm/radeon/egl/Makefile | 14 + src/gallium/winsys/drm/radeon/egl/dummy.c | 1 + src/gallium/winsys/drm/radeon/egl_g3d/Makefile | 14 - src/gallium/winsys/drm/radeon/egl_g3d/dummy.c | 1 - src/gallium/winsys/drm/swrast/egl/Makefile | 12 + src/gallium/winsys/drm/swrast/egl/dummy.c | 1 + src/gallium/winsys/drm/swrast/egl_g3d/Makefile | 12 - src/gallium/winsys/drm/swrast/egl_g3d/dummy.c | 1 - src/gallium/winsys/drm/vmware/egl/Makefile | 14 + src/gallium/winsys/drm/vmware/egl/dummy.c | 1 + src/gallium/winsys/drm/vmware/egl_g3d/Makefile | 14 - src/gallium/winsys/drm/vmware/egl_g3d/dummy.c | 1 - 66 files changed, 5631 insertions(+), 5632 deletions(-) create mode 100644 src/gallium/state_trackers/egl/Makefile create mode 100644 src/gallium/state_trackers/egl/common/egl_g3d.c create mode 100644 src/gallium/state_trackers/egl/common/egl_g3d.h create mode 100644 src/gallium/state_trackers/egl/common/egl_st.c create mode 100644 src/gallium/state_trackers/egl/common/egl_st.h create mode 100644 src/gallium/state_trackers/egl/common/native.h create mode 100644 src/gallium/state_trackers/egl/common/st_public_tmp.h create mode 100644 src/gallium/state_trackers/egl/kms/native_kms.c create mode 100644 src/gallium/state_trackers/egl/kms/native_kms.h create mode 100644 src/gallium/state_trackers/egl/x11/native_dri2.c create mode 100644 src/gallium/state_trackers/egl/x11/native_x11.c create mode 100644 src/gallium/state_trackers/egl/x11/native_x11.h create mode 100644 src/gallium/state_trackers/egl/x11/native_ximage.c create mode 100644 src/gallium/state_trackers/egl/x11/sw_winsys.c create mode 100644 src/gallium/state_trackers/egl/x11/sw_winsys.h create mode 100644 src/gallium/state_trackers/egl/x11/x11_screen.c create mode 100644 src/gallium/state_trackers/egl/x11/x11_screen.h delete mode 100644 src/gallium/state_trackers/egl_g3d/Makefile delete mode 100644 src/gallium/state_trackers/egl_g3d/common/egl_g3d.c delete mode 100644 src/gallium/state_trackers/egl_g3d/common/egl_g3d.h delete mode 100644 src/gallium/state_trackers/egl_g3d/common/egl_st.c delete mode 100644 src/gallium/state_trackers/egl_g3d/common/egl_st.h delete mode 100644 src/gallium/state_trackers/egl_g3d/common/native.h delete mode 100644 src/gallium/state_trackers/egl_g3d/common/st_public_tmp.h delete mode 100644 src/gallium/state_trackers/egl_g3d/kms/native_kms.c delete mode 100644 src/gallium/state_trackers/egl_g3d/kms/native_kms.h delete mode 100644 src/gallium/state_trackers/egl_g3d/x11/native_dri2.c delete mode 100644 src/gallium/state_trackers/egl_g3d/x11/native_x11.c delete mode 100644 src/gallium/state_trackers/egl_g3d/x11/native_x11.h delete mode 100644 src/gallium/state_trackers/egl_g3d/x11/native_ximage.c delete mode 100644 src/gallium/state_trackers/egl_g3d/x11/sw_winsys.c delete mode 100644 src/gallium/state_trackers/egl_g3d/x11/sw_winsys.h delete mode 100644 src/gallium/state_trackers/egl_g3d/x11/x11_screen.c delete mode 100644 src/gallium/state_trackers/egl_g3d/x11/x11_screen.h create mode 100644 src/gallium/winsys/drm/Makefile.egl delete mode 100644 src/gallium/winsys/drm/Makefile.egl_g3d create mode 100644 src/gallium/winsys/drm/i965/egl/Makefile create mode 100644 src/gallium/winsys/drm/i965/egl/dummy.c delete mode 100644 src/gallium/winsys/drm/i965/egl_g3d/Makefile delete mode 100644 src/gallium/winsys/drm/i965/egl_g3d/dummy.c create mode 100644 src/gallium/winsys/drm/intel/egl/Makefile create mode 100644 src/gallium/winsys/drm/intel/egl/dummy.c delete mode 100644 src/gallium/winsys/drm/intel/egl_g3d/Makefile delete mode 100644 src/gallium/winsys/drm/intel/egl_g3d/dummy.c create mode 100644 src/gallium/winsys/drm/nouveau/egl/Makefile create mode 100644 src/gallium/winsys/drm/nouveau/egl/dummy.c delete mode 100644 src/gallium/winsys/drm/nouveau/egl_g3d/Makefile delete mode 100644 src/gallium/winsys/drm/nouveau/egl_g3d/dummy.c create mode 100644 src/gallium/winsys/drm/radeon/egl/Makefile create mode 100644 src/gallium/winsys/drm/radeon/egl/dummy.c delete mode 100644 src/gallium/winsys/drm/radeon/egl_g3d/Makefile delete mode 100644 src/gallium/winsys/drm/radeon/egl_g3d/dummy.c create mode 100644 src/gallium/winsys/drm/swrast/egl/Makefile create mode 100644 src/gallium/winsys/drm/swrast/egl/dummy.c delete mode 100644 src/gallium/winsys/drm/swrast/egl_g3d/Makefile delete mode 100644 src/gallium/winsys/drm/swrast/egl_g3d/dummy.c create mode 100644 src/gallium/winsys/drm/vmware/egl/Makefile create mode 100644 src/gallium/winsys/drm/vmware/egl/dummy.c delete mode 100644 src/gallium/winsys/drm/vmware/egl_g3d/Makefile delete mode 100644 src/gallium/winsys/drm/vmware/egl_g3d/dummy.c diff --git a/configs/linux-dri b/configs/linux-dri index feb2bba3a0..95f77ade1d 100644 --- a/configs/linux-dri +++ b/configs/linux-dri @@ -61,7 +61,7 @@ DRIVER_DIRS = dri WINDOW_SYSTEM = dri GALLIUM_WINSYS_DIRS = drm GALLIUM_WINSYS_DRM_DIRS = vmware intel i965 -GALLIUM_STATE_TRACKERS_DIRS = egl_g3d +GALLIUM_STATE_TRACKERS_DIRS = egl DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon \ savage sis tdfx unichrome ffb swrast diff --git a/configs/linux-opengl-es b/configs/linux-opengl-es index af784551a7..259c26a931 100644 --- a/configs/linux-opengl-es +++ b/configs/linux-opengl-es @@ -9,7 +9,7 @@ LIB_DIR = lib SRC_DIRS = egl glsl mesa/es gallium gallium/winsys PROGRAM_DIRS = es1/screen es1/xegl es2/xegl -# egl_g3d needs this +# egl st needs this DEFINES += -DGLX_DIRECT_RENDERING # no mesa or egl drivers @@ -23,6 +23,6 @@ GALLIUM_STATE_TRACKERS_DIRS = es # build egl_x11_{swrast,i915}.so GALLIUM_DRIVERS_DIRS += trace i915 -GALLIUM_STATE_TRACKERS_DIRS += egl_g3d +GALLIUM_STATE_TRACKERS_DIRS += egl GALLIUM_WINSYS_DIRS += drm GALLIUM_WINSYS_DRM_DIRS += intel swrast diff --git a/configure.ac b/configure.ac index d6e32f590a..370bd1b9b7 100644 --- a/configure.ac +++ b/configure.ac @@ -1165,7 +1165,7 @@ yes) dri) GALLIUM_STATE_TRACKERS_DIRS="dri" if test "x$enable_egl" = xyes; then - GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl_g3d" + GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl" fi # Have only tested st/xorg on 1.6.0 servers PKG_CHECK_MODULES(XORG, [xorg-server >= 1.6.0], @@ -1182,9 +1182,9 @@ yes) AC_MSG_ERROR([state tracker '$tracker' doesn't exist]) case "$tracker" in - egl_g3d) + egl) if test "x$enable_egl" != xyes; then - AC_MSG_ERROR([cannot build egl_g3d state tracker without EGL library]) + AC_MSG_ERROR([cannot build egl state tracker without EGL library]) fi ;; xorg) @@ -1223,7 +1223,7 @@ yes) # verify the requested driver directories exist egl_displays=`IFS=', '; echo $with_egl_displays` for dpy in $egl_displays; do - test -d "$srcdir/src/gallium/state_trackers/egl_g3d/$dpy" || \ + test -d "$srcdir/src/gallium/state_trackers/egl/$dpy" || \ AC_MSG_ERROR([EGL display '$dpy' does't exist]) done EGL_DISPLAYS="$egl_displays" diff --git a/docs/egl.html b/docs/egl.html index efc7b1ed3a..0882598966 100644 --- a/docs/egl.html +++ b/docs/egl.html @@ -32,10 +32,10 @@ cards.

      the Gallium driver for your hardware. For example

      -  $ ./configure --with-state-trackers=egl_g3d,es,vega --enable-gallium-intel
      +  $ ./configure --with-state-trackers=egl,es,vega --enable-gallium-intel
       
      -

      The main library will be enabled by default. The egl_g3d state +

      The main library will be enabled by default. The egl state tracker is needed by a number of EGL drivers. EGL drivers will be covered later. The es state tracker provides OpenGL ES 1.x and 2.x and the vega state tracker provides OpenVG @@ -77,9 +77,8 @@ bare KMS (kernel modesetting).

      The argument is a comma separated string. It is usually used to specify the rendering APIs, like OpenGL ES or OpenVG, to build. But it should be noted -that a number of EGL drivers depend on the egl_g3d state tracker. -They will not be built without the egl_g3d state -tracker.

      +that a number of EGL drivers depend on the egl state tracker. +They will not be built without the egl state tracker.

    • @@ -160,7 +159,7 @@ variable to true forces the use of software rendering.

      Gallium EGL drivers supports all rendering APIs specified in EGL 1.4. The support for optional EGL functions and EGL extensions is usually more complete -than the classic ones. These drivers depend on the egl_g3d state +than the classic ones. These drivers depend on the egl state tracker to build. The available drivers are

        @@ -218,8 +217,8 @@ runtime.

        Developers

        The sources of the main library and the classic drivers can be found at -src/egl/. The sources of the egl_g3d state tracker -can be found at src/gallium/state_trackers/egl_g3d/. +src/egl/. The sources of the egl state tracker can +be found at src/gallium/state_trackers/egl/.

        TODOs

        diff --git a/docs/opengles.html b/docs/opengles.html index a871e85d0b..fc41e6771c 100644 --- a/docs/opengles.html +++ b/docs/opengles.html @@ -20,7 +20,7 @@ for more information about EGL.

        Build the Libraries

          -
        1. Run configure with --with-state-trackers=egl_g3d,es and enable the Gallium driver for your hardware.
        2. +
        3. Run configure with --with-state-trackers=egl,es and enable the Gallium driver for your hardware.
        4. Build and install Mesa as usual.
        diff --git a/docs/openvg.html b/docs/openvg.html index cd39b133c4..cdf6b57e0f 100644 --- a/docs/openvg.html +++ b/docs/openvg.html @@ -34,7 +34,7 @@ Please refer to Mesa EGL for more information about EGL.

        Sample build

        A sample build looks as follows:
        -  $ ./configure --with-state-trackers=egl_g3d,vega --enable-gallium-intel
        +  $ ./configure --with-state-trackers=egl,vega --enable-gallium-intel
           $ make
           $ make install
         
        diff --git a/src/gallium/state_trackers/egl/Makefile b/src/gallium/state_trackers/egl/Makefile new file mode 100644 index 0000000000..b696f2fae9 --- /dev/null +++ b/src/gallium/state_trackers/egl/Makefile @@ -0,0 +1,75 @@ +TOP = ../../../.. +include $(TOP)/configs/current + +common_INCLUDES = \ + -I. \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/auxiliary \ + -I$(TOP)/src/egl/main \ + -I$(TOP)/include + +common_SOURCES = $(wildcard common/*.c) +common_OBJECTS = $(common_SOURCES:.c=.o) + + +x11_INCLUDES = \ + -I$(TOP)/src/gallium/drivers \ + -I$(TOP)/src/glx/x11 \ + -I$(TOP)/src/egl/drivers/xdri \ + -I$(TOP)/src/mesa \ + $(shell pkg-config --cflags-only-I libdrm) + +x11_SOURCES = $(wildcard x11/*.c) \ + $(TOP)/src/glx/x11/dri2.c \ + $(TOP)/src/egl/drivers/xdri/glxinit.c +x11_OBJECTS = $(x11_SOURCES:.c=.o) + + +kms_INCLUDES = $(shell pkg-config --cflags-only-I libdrm) +kms_SOURCES = $(wildcard kms/*.c) +kms_OBJECTS = $(kms_SOURCES:.c=.o) + + +ALL_INCLUDES = $(common_INCLUDES) $(x11_INCLUDES) $(kms_INCLUDES) +ALL_SOURCES = $(common_SOURCES) $(x11_SOURCES) $(kms_SOURCES) +ALL_OBJECTS = $(common_OBJECTS) $(x11_OBJECTS) $(kms_OBJECTS) + +##### TARGETS ##### + +EGL_DISPLAYS_MODS = $(foreach dpy, $(EGL_DISPLAYS), libegl$(dpy).a) + +default: depend $(EGL_DISPLAYS_MODS) + + +libeglx11.a: $(x11_OBJECTS) $(common_OBJECTS) Makefile + $(MKLIB) -o eglx11 -static $(x11_OBJECTS) $(common_OBJECTS) + +libeglkms.a: $(kms_OBJECTS) $(common_OBJECTS) Makefile + $(MKLIB) -o eglkms -static $(kms_OBJECTS) $(common_OBJECTS) + +depend: + rm -f depend + touch depend + $(MKDEP) $(MKDEP_OPTIONS) $(ALL_INCLUDES) $(ALL_SOURCES) 2> /dev/null + +clean: + rm -f $(ALL_OBJECTS) + rm -f $(EGL_DISPLAYS_MODS) + rm -f depend depend.bak + +# Dummy target +install: + @echo -n "" + +##### RULES ##### + +$(common_OBJECTS): %.o: %.c + $(CC) -c $(common_INCLUDES) $(DEFINES) $(CFLAGS) $< -o $@ + +$(x11_OBJECTS): %.o: %.c + $(CC) -c $(common_INCLUDES) $(x11_INCLUDES) $(DEFINES) $(CFLAGS) $< -o $@ + +$(kms_OBJECTS): %.o: %.c + $(CC) -c $(common_INCLUDES) $(kms_INCLUDES) $(DEFINES) $(CFLAGS) $< -o $@ + +sinclude depend diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c new file mode 100644 index 0000000000..2ac6215646 --- /dev/null +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -0,0 +1,1336 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL 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. + */ + +#include +#include +#include "pipe/p_screen.h" +#include "util/u_memory.h" +#include "util/u_rect.h" +#include "egldriver.h" +#include "eglcurrent.h" +#include "eglconfigutil.h" +#include "egllog.h" + +#include "native.h" +#include "egl_g3d.h" +#include "egl_st.h" + +/** + * Validate the draw/read surfaces of the context. + */ +static void +egl_g3d_validate_context(_EGLDisplay *dpy, _EGLContext *ctx) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct pipe_screen *screen = gdpy->native->screen; + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + const uint st_att_map[NUM_NATIVE_ATTACHMENTS] = { + ST_SURFACE_FRONT_LEFT, + ST_SURFACE_BACK_LEFT, + ST_SURFACE_FRONT_RIGHT, + ST_SURFACE_BACK_RIGHT, + }; + EGLint num_surfaces, s; + + /* validate draw and/or read buffers */ + num_surfaces = (gctx->base.ReadSurface == gctx->base.DrawSurface) ? 1 : 2; + for (s = 0; s < num_surfaces; s++) { + struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS]; + struct egl_g3d_surface *gsurf; + struct egl_g3d_buffer *gbuf; + EGLint att; + + if (s == 0) { + gsurf = egl_g3d_surface(gctx->base.DrawSurface); + gbuf = &gctx->draw; + } + else { + gsurf = egl_g3d_surface(gctx->base.ReadSurface); + gbuf = &gctx->read; + } + + if (!gctx->force_validate) { + unsigned int seq_num; + + gsurf->native->validate(gsurf->native, gbuf->attachment_mask, + &seq_num, NULL, NULL, NULL); + /* skip validation */ + if (gsurf->sequence_number == seq_num) + continue; + } + + pipe_surface_reference(&gsurf->render_surface, NULL); + memset(textures, 0, sizeof(textures)); + + gsurf->native->validate(gsurf->native, gbuf->attachment_mask, + &gsurf->sequence_number, textures, + &gsurf->base.Width, &gsurf->base.Height); + for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { + struct pipe_texture *pt = textures[att]; + struct pipe_surface *ps; + + if (native_attachment_mask_test(gbuf->attachment_mask, att) && pt) { + ps = screen->get_tex_surface(screen, pt, 0, 0, 0, + PIPE_BUFFER_USAGE_GPU_READ | + PIPE_BUFFER_USAGE_GPU_WRITE); + gctx->stapi->st_set_framebuffer_surface(gbuf->st_fb, + st_att_map[att], ps); + + if (gsurf->render_att == att) + pipe_surface_reference(&gsurf->render_surface, ps); + + pipe_surface_reference(&ps, NULL); + pipe_texture_reference(&pt, NULL); + } + } + + gctx->stapi->st_resize_framebuffer(gbuf->st_fb, + gsurf->base.Width, gsurf->base.Height); + } + + gctx->force_validate = EGL_FALSE; + +} + +/** + * Create a st_framebuffer. + */ +static struct st_framebuffer * +create_framebuffer(_EGLContext *ctx, _EGLSurface *surf) +{ + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + struct egl_g3d_config *gconf = egl_g3d_config(gsurf->base.Config); + + return gctx->stapi->st_create_framebuffer(&gconf->native->mode, + gconf->native->color_format, gconf->native->depth_format, + gconf->native->stencil_format, + gsurf->base.Width, gsurf->base.Height, &gsurf->base); +} + +/** + * Update the attachments of draw/read surfaces. + */ +static void +egl_g3d_route_context(_EGLDisplay *dpy, _EGLContext *ctx) +{ + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + EGLint s; + + /* route draw and read buffers' attachments */ + for (s = 0; s < 2; s++) { + struct egl_g3d_surface *gsurf; + struct egl_g3d_buffer *gbuf; + + if (s == 0) { + gsurf = egl_g3d_surface(gctx->base.DrawSurface); + gbuf = &gctx->draw; + } + else { + gsurf = egl_g3d_surface(gctx->base.ReadSurface); + gbuf = &gctx->read; + } + + gbuf->attachment_mask = (1 << gsurf->render_att); + + /* FIXME OpenGL defaults to draw the front or back buffer when the + * context is single-buffered or double-buffered respectively. In EGL, + * however, the buffer to be drawn is determined by the surface, instead + * of the context. As a result, rendering to a pixmap surface with a + * double-buffered context does not work as expected. + * + * gctx->stapi->st_draw_front_buffer(gctx->st_ctx, natt == + * NATIVE_ATTACHMENT_FRONT_LEFT); + */ + + /* + * FIXME If the back buffer is asked for here, and the front buffer is + * later needed by the client API (e.g. glDrawBuffer is called to draw + * the front buffer), it will create a new pipe texture and draw there. + * One fix is to ask for both buffers here, but it would be a waste if + * the front buffer is never used. A better fix is to add a callback to + * the pipe screen with context private (just like flush_frontbuffer). + */ + } +} + +/** + * Reallocate the context's framebuffers after draw/read surfaces change. + */ +static EGLBoolean +egl_g3d_realloc_context(_EGLDisplay *dpy, _EGLContext *ctx) +{ + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + struct egl_g3d_surface *gdraw = egl_g3d_surface(gctx->base.DrawSurface); + struct egl_g3d_surface *gread = egl_g3d_surface(gctx->base.ReadSurface); + + /* unreference the old framebuffers */ + if (gctx->draw.st_fb) { + EGLBoolean is_equal = (gctx->draw.st_fb == gctx->read.st_fb); + void *priv; + + priv = gctx->stapi->st_framebuffer_private(gctx->draw.st_fb); + if (!gdraw || priv != (void *) &gdraw->base) { + gctx->stapi->st_unreference_framebuffer(gctx->draw.st_fb); + gctx->draw.st_fb = NULL; + gctx->draw.attachment_mask = 0x0; + } + + if (is_equal) { + gctx->read.st_fb = NULL; + gctx->draw.attachment_mask = 0x0; + } + else { + priv = gctx->stapi->st_framebuffer_private(gctx->read.st_fb); + if (!gread || priv != (void *) &gread->base) { + gctx->stapi->st_unreference_framebuffer(gctx->read.st_fb); + gctx->read.st_fb = NULL; + gctx->draw.attachment_mask = 0x0; + } + } + } + + if (!gdraw) + return EGL_TRUE; + + /* create the draw fb */ + if (!gctx->draw.st_fb) { + gctx->draw.st_fb = create_framebuffer(&gctx->base, &gdraw->base); + if (!gctx->draw.st_fb) + return EGL_FALSE; + } + + /* create the read fb */ + if (!gctx->read.st_fb) { + if (gread != gdraw) { + gctx->read.st_fb = create_framebuffer(&gctx->base, &gread->base); + if (!gctx->read.st_fb) { + gctx->stapi->st_unreference_framebuffer(gctx->draw.st_fb); + gctx->draw.st_fb = NULL; + return EGL_FALSE; + } + } + else { + /* there is no st_reference_framebuffer... */ + gctx->read.st_fb = gctx->draw.st_fb; + } + } + + egl_g3d_route_context(dpy, &gctx->base); + gctx->force_validate = EGL_TRUE; + + return EGL_TRUE; +} + +/** + * Return the current context of the given API. + */ +static struct egl_g3d_context * +egl_g3d_get_current_context(EGLint api) +{ + _EGLThreadInfo *t = _eglGetCurrentThread(); + EGLint api_index = _eglConvertApiToIndex(api); + return egl_g3d_context(t->CurrentContexts[api_index]); +} + +/** + * Return the state tracker for the given context. + */ +static const struct egl_g3d_st * +egl_g3d_choose_st(_EGLDriver *drv, _EGLContext *ctx) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + const struct egl_g3d_st *stapi; + EGLint idx = -1; + + switch (ctx->ClientAPI) { + case EGL_OPENGL_ES_API: + switch (ctx->ClientVersion) { + case 1: + idx = EGL_G3D_ST_OPENGL_ES; + break; + case 2: + idx = EGL_G3D_ST_OPENGL_ES2; + break; + default: + _eglLog(_EGL_WARNING, "unknown client version %d", + ctx->ClientVersion); + break; + } + break; + case EGL_OPENVG_API: + idx = EGL_G3D_ST_OPENVG; + break; + case EGL_OPENGL_API: + idx = EGL_G3D_ST_OPENGL; + break; + default: + _eglLog(_EGL_WARNING, "unknown client API 0x%04x", ctx->ClientAPI); + break; + } + + stapi = (idx >= 0) ? gdrv->stapis[idx] : NULL; + return stapi; +} + +/** + * Initialize the state trackers. + */ +static void +egl_g3d_init_st(_EGLDriver *drv) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + EGLint i; + + /* already initialized */ + if (gdrv->api_mask) + return; + + for (i = 0; i < NUM_EGL_G3D_STS; i++) { + gdrv->stapis[i] = egl_g3d_get_st(i); + if (gdrv->stapis[i]) + gdrv->api_mask |= gdrv->stapis[i]->api_bit; + } + + if (gdrv->api_mask) + _eglLog(_EGL_DEBUG, "Driver API mask: 0x%x", gdrv->api_mask); + else + _eglLog(_EGL_WARNING, "No supported client API"); +} + +/** + * Get the probe object of the display. + * + * Note that this function may be called before the display is initialized. + */ +static struct native_probe * +egl_g3d_get_probe(_EGLDriver *drv, _EGLDisplay *dpy) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + struct native_probe *nprobe; + + nprobe = (struct native_probe *) _eglGetProbeCache(gdrv->probe_key); + if (!nprobe || nprobe->display != dpy->NativeDisplay) { + if (nprobe) + nprobe->destroy(nprobe); + nprobe = native_create_probe(dpy->NativeDisplay); + _eglSetProbeCache(gdrv->probe_key, (void *) nprobe); + } + + return nprobe; +} + +/** + * Destroy the probe object of the display. The display may be NULL. + * + * Note that this function may be called before the display is initialized. + */ +static void +egl_g3d_destroy_probe(_EGLDriver *drv, _EGLDisplay *dpy) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + struct native_probe *nprobe; + + nprobe = (struct native_probe *) _eglGetProbeCache(gdrv->probe_key); + if (nprobe && (!dpy || nprobe->display == dpy->NativeDisplay)) { + nprobe->destroy(nprobe); + _eglSetProbeCache(gdrv->probe_key, NULL); + } +} + +/** + * Return an API mask that consists of the state trackers that supports the + * given mode. + * + * FIXME add st_is_mode_supported()? + */ +static EGLint +get_mode_api_mask(const __GLcontextModes *mode, EGLint api_mask) +{ + EGLint check; + + /* OpenGL ES 1.x and 2.x are checked together */ + check = EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT; + if (api_mask & check) { + /* this is required by EGL, not by OpenGL ES */ + if (mode->drawableType & GLX_WINDOW_BIT && !mode->doubleBufferMode) + api_mask &= ~check; + } + + check = EGL_OPENVG_BIT; + if (api_mask & check) { + /* vega st needs the depth/stencil rb */ + if (!mode->depthBits && !mode->stencilBits) + api_mask &= ~check; + } + + return api_mask; +} + +#ifdef EGL_MESA_screen_surface + +static void +egl_g3d_add_screens(_EGLDriver *drv, _EGLDisplay *dpy) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + const struct native_connector **native_connectors; + EGLint num_connectors, i; + + native_connectors = + gdpy->native->modeset->get_connectors(gdpy->native, &num_connectors, NULL); + if (!num_connectors) { + if (native_connectors) + free(native_connectors); + return; + } + + for (i = 0; i < num_connectors; i++) { + const struct native_connector *nconn = native_connectors[i]; + struct egl_g3d_screen *gscr; + const struct native_mode **native_modes; + EGLint num_modes, j; + + /* TODO support for hotplug */ + native_modes = + gdpy->native->modeset->get_modes(gdpy->native, nconn, &num_modes); + if (!num_modes) { + if (native_modes) + free(native_modes); + continue; + } + + gscr = CALLOC_STRUCT(egl_g3d_screen); + if (!gscr) { + free(native_modes); + continue; + } + + _eglInitScreen(&gscr->base); + + for (j = 0; j < num_modes; j++) { + const struct native_mode *nmode = native_modes[j]; + _EGLMode *mode; + + mode = _eglAddNewMode(&gscr->base, nmode->width, nmode->height, + nmode->refresh_rate, nmode->desc); + if (!mode) + break; + /* gscr->native_modes and gscr->base.Modes should be consistent */ + assert(mode == &gscr->base.Modes[j]); + } + + gscr->native = nconn; + gscr->native_modes = native_modes; + + _eglAddScreen(dpy, &gscr->base); + } + + free(native_connectors); +} + +#endif /* EGL_MESA_screen_surface */ + +/** + * Add configs to display and return the next config ID. + */ +static EGLint +egl_g3d_add_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint id) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + const struct native_config **native_configs; + int num_configs, i; + + native_configs = gdpy->native->get_configs(gdpy->native, + &num_configs); + if (!num_configs) { + if (native_configs) + free(native_configs); + return id; + } + + for (i = 0; i < num_configs; i++) { + EGLint api_mask; + struct egl_g3d_config *gconf; + EGLBoolean valid; + + api_mask = get_mode_api_mask(&native_configs[i]->mode, gdrv->api_mask); + if (!api_mask) { + _eglLog(_EGL_DEBUG, "no state tracker supports config 0x%x", + native_configs[i]->mode.visualID); + continue; + } + + gconf = CALLOC_STRUCT(egl_g3d_config); + if (!gconf) + continue; + + _eglInitConfig(&gconf->base, id); + valid = _eglConfigFromContextModesRec(&gconf->base, + &native_configs[i]->mode, api_mask, api_mask); + if (valid) { +#ifdef EGL_MESA_screen_surface + /* check if scanout surface bit is set */ + if (native_configs[i]->scanout_bit) { + EGLint val = GET_CONFIG_ATTRIB(&gconf->base, EGL_SURFACE_TYPE); + val |= EGL_SCREEN_BIT_MESA; + SET_CONFIG_ATTRIB(&gconf->base, EGL_SURFACE_TYPE, val); + } +#endif + valid = _eglValidateConfig(&gconf->base, EGL_FALSE); + } + if (!valid) { + _eglLog(_EGL_DEBUG, "skip invalid config 0x%x", + native_configs[i]->mode.visualID); + free(gconf); + continue; + } + + gconf->native = native_configs[i]; + _eglAddConfig(dpy, &gconf->base); + id++; + } + + free(native_configs); + return id; +} + +/** + * Flush the front buffer of the context's draw surface. + */ +static void +egl_g3d_flush_frontbuffer(struct pipe_screen *screen, + struct pipe_surface *surf, void *context_private) +{ + struct egl_g3d_context *gctx = egl_g3d_context(context_private); + struct egl_g3d_surface *gsurf = egl_g3d_surface(gctx->base.DrawSurface); + + if (gsurf) + gsurf->native->flush_frontbuffer(gsurf->native); +} + +/** + * Re-validate the context. + */ +static void +egl_g3d_update_buffer(struct pipe_screen *screen, void *context_private) +{ + struct egl_g3d_context *gctx = egl_g3d_context(context_private); + + /** + * It is likely that the surface has changed when this function is called. + * Set force_validate to skip an unnecessary check. + */ + gctx->force_validate = EGL_TRUE; + egl_g3d_validate_context(gctx->base.Display, &gctx->base); +} + +static EGLBoolean +egl_g3d_terminate(_EGLDriver *drv, _EGLDisplay *dpy) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + EGLint i; + + _eglReleaseDisplayResources(drv, dpy); + _eglCleanupDisplay(dpy); + + if (dpy->Screens) { + for (i = 0; i < dpy->NumScreens; i++) { + struct egl_g3d_screen *gscr = egl_g3d_screen(dpy->Screens[i]); + free(gscr->native_modes); + free(gscr); + } + free(dpy->Screens); + } + + if (gdpy->native) + gdpy->native->destroy(gdpy->native); + + free(gdpy); + dpy->DriverData = NULL; + + return EGL_TRUE; +} + +static EGLBoolean +egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy, + EGLint *major, EGLint *minor) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + struct egl_g3d_display *gdpy; + + /* the probe object is unlikely to be needed again */ + egl_g3d_destroy_probe(drv, dpy); + + gdpy = CALLOC_STRUCT(egl_g3d_display); + if (!gdpy) { + _eglError(EGL_BAD_ALLOC, "eglInitialize"); + goto fail; + } + dpy->DriverData = gdpy; + + gdpy->native = native_create_display(dpy->NativeDisplay); + if (!gdpy->native) { + _eglError(EGL_NOT_INITIALIZED, "eglInitialize(no usable display)"); + goto fail; + } + + gdpy->native->screen->flush_frontbuffer = egl_g3d_flush_frontbuffer; + gdpy->native->screen->update_buffer = egl_g3d_update_buffer; + + egl_g3d_init_st(&gdrv->base); + dpy->ClientAPIsMask = gdrv->api_mask; + + if (egl_g3d_add_configs(drv, dpy, 1) == 1) { + _eglError(EGL_NOT_INITIALIZED, "eglInitialize(unable to add configs)"); + goto fail; + } + +#ifdef EGL_MESA_screen_surface + /* enable MESA_screen_surface */ + if (gdpy->native->modeset) { + dpy->Extensions.MESA_screen_surface = EGL_TRUE; + egl_g3d_add_screens(drv, dpy); + } +#endif + + *major = 1; + *minor = 4; + + return EGL_TRUE; + +fail: + if (gdpy) + egl_g3d_terminate(drv, dpy); + return EGL_FALSE; +} + +static _EGLContext * +egl_g3d_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, + _EGLContext *share, const EGLint *attribs) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_context *gshare = egl_g3d_context(share); + struct egl_g3d_config *gconf = egl_g3d_config(conf); + struct egl_g3d_context *gctx; + const __GLcontextModes *mode; + + gctx = CALLOC_STRUCT(egl_g3d_context); + if (!gctx) { + _eglError(EGL_BAD_ALLOC, "eglCreateContext"); + return NULL; + } + + if (!_eglInitContext(drv, &gctx->base, conf, attribs)) { + free(gctx); + return NULL; + } + + gctx->stapi = egl_g3d_choose_st(drv, &gctx->base); + if (!gctx->stapi) { + free(gctx); + return NULL; + } + + mode = &gconf->native->mode; + gctx->pipe = + gdpy->native->create_context(gdpy->native, (void *) &gctx->base); + if (!gctx->pipe) { + free(gctx); + return NULL; + } + + gctx->st_ctx = gctx->stapi->st_create_context(gctx->pipe, mode, + (gshare) ? gshare->st_ctx : NULL); + if (!gctx->st_ctx) { + gctx->pipe->destroy(gctx->pipe); + free(gctx); + return NULL; + } + + return &gctx->base; +} + +static EGLBoolean +egl_g3d_destroy_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) +{ + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + + if (_eglIsContextBound(&gctx->base)) + return EGL_TRUE; + + egl_g3d_realloc_context(dpy, &gctx->base); + + /* it will destroy pipe context */ + gctx->stapi->st_destroy_context(gctx->st_ctx); + + free(gctx); + + return EGL_TRUE; +} + +static EGLBoolean +init_surface_geometry(_EGLSurface *surf) +{ + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + + return gsurf->native->validate(gsurf->native, 0x0, + &gsurf->sequence_number, NULL, + &gsurf->base.Width, &gsurf->base.Height); +} + +static _EGLSurface * +egl_g3d_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLConfig *conf, EGLNativeWindowType win, + const EGLint *attribs) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_config *gconf = egl_g3d_config(conf); + struct egl_g3d_surface *gsurf; + + gsurf = CALLOC_STRUCT(egl_g3d_surface); + if (!gsurf) { + _eglError(EGL_BAD_ALLOC, "eglCreateWindowSurface"); + return NULL; + } + + if (!_eglInitSurface(drv, &gsurf->base, EGL_WINDOW_BIT, conf, attribs)) { + free(gsurf); + return NULL; + } + + gsurf->native = + gdpy->native->create_window_surface(gdpy->native, win, gconf->native); + if (!gsurf->native) { + free(gsurf); + return NULL; + } + + if (!init_surface_geometry(&gsurf->base)) { + gsurf->native->destroy(gsurf->native); + free(gsurf); + return NULL; + } + + gsurf->render_att = (gsurf->base.RenderBuffer == EGL_SINGLE_BUFFER || + !gconf->native->mode.doubleBufferMode) ? + NATIVE_ATTACHMENT_FRONT_LEFT : NATIVE_ATTACHMENT_BACK_LEFT; + + return &gsurf->base; +} + +static _EGLSurface * +egl_g3d_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLConfig *conf, EGLNativePixmapType pix, + const EGLint *attribs) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_config *gconf = egl_g3d_config(conf); + struct egl_g3d_surface *gsurf; + + gsurf = CALLOC_STRUCT(egl_g3d_surface); + if (!gsurf) { + _eglError(EGL_BAD_ALLOC, "eglCreatePixmapSurface"); + return NULL; + } + + if (!_eglInitSurface(drv, &gsurf->base, EGL_PIXMAP_BIT, conf, attribs)) { + free(gsurf); + return NULL; + } + + gsurf->native = + gdpy->native->create_pixmap_surface(gdpy->native, pix, gconf->native); + if (!gsurf->native) { + free(gsurf); + return NULL; + } + + if (!init_surface_geometry(&gsurf->base)) { + gsurf->native->destroy(gsurf->native); + free(gsurf); + return NULL; + } + + gsurf->render_att = NATIVE_ATTACHMENT_FRONT_LEFT; + + return &gsurf->base; +} + +static _EGLSurface * +egl_g3d_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLConfig *conf, const EGLint *attribs) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_config *gconf = egl_g3d_config(conf); + struct egl_g3d_surface *gsurf; + + gsurf = CALLOC_STRUCT(egl_g3d_surface); + if (!gsurf) { + _eglError(EGL_BAD_ALLOC, "eglCreatePbufferSurface"); + return NULL; + } + + if (!_eglInitSurface(drv, &gsurf->base, EGL_PBUFFER_BIT, conf, attribs)) { + free(gsurf); + return NULL; + } + + gsurf->native = + gdpy->native->create_pbuffer_surface(gdpy->native, gconf->native, + gsurf->base.Width, gsurf->base.Height); + if (!gsurf->native) { + free(gsurf); + return NULL; + } + + if (!init_surface_geometry(&gsurf->base)) { + gsurf->native->destroy(gsurf->native); + free(gsurf); + return NULL; + } + + gsurf->render_att = (!gconf->native->mode.doubleBufferMode) ? + NATIVE_ATTACHMENT_FRONT_LEFT : NATIVE_ATTACHMENT_BACK_LEFT; + + return &gsurf->base; +} + +static EGLBoolean +egl_g3d_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) +{ + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + + if (_eglIsSurfaceBound(&gsurf->base)) + return EGL_TRUE; + + pipe_surface_reference(&gsurf->render_surface, NULL); + gsurf->native->destroy(gsurf->native); + free(gsurf); + return EGL_TRUE; +} + +static EGLBoolean +egl_g3d_make_current(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLSurface *draw, _EGLSurface *read, _EGLContext *ctx) +{ + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + struct egl_g3d_context *old_gctx; + EGLint api; + EGLBoolean ok = EGL_TRUE; + + /* find the old context */ + api = (gctx) ? gctx->base.ClientAPI : eglQueryAPI(); + old_gctx = egl_g3d_get_current_context(api); + if (old_gctx && !_eglIsContextLinked(&old_gctx->base)) + old_gctx = NULL; + + if (!_eglMakeCurrent(drv, dpy, draw, read, ctx)) + return EGL_FALSE; + + if (old_gctx) { + /* flush old context */ + old_gctx->stapi->st_flush(old_gctx->st_ctx, + PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); + + /* + * The old context is no longer current, and egl_g3d_realloc_context() + * should be called to destroy the framebuffers. However, it is possible + * that it will be made current again with the same draw/read surfaces. + * It might be better to keep it around. + */ + } + + if (gctx) { + struct egl_g3d_surface *gdraw = egl_g3d_surface(draw); + + ok = egl_g3d_realloc_context(dpy, &gctx->base); + if (ok) { + ok = gctx->stapi->st_make_current(gctx->st_ctx, + gctx->draw.st_fb, gctx->read.st_fb); + if (ok) { + egl_g3d_validate_context(dpy, &gctx->base); + if (gdraw->base.Type == EGL_WINDOW_BIT) { + gctx->base.WindowRenderBuffer = + (gdraw->render_att == NATIVE_ATTACHMENT_FRONT_LEFT) ? + EGL_SINGLE_BUFFER : EGL_BACK_BUFFER; + } + } + } + } + else if (old_gctx) { + ok = old_gctx->stapi->st_make_current(NULL, NULL, NULL); + old_gctx->base.WindowRenderBuffer = EGL_NONE; + } + + return ok; +} + +static EGLBoolean +egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) +{ + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + _EGLContext *ctx = _eglGetCurrentContext(); + struct egl_g3d_context *gctx = NULL; + + /* no-op for pixmap or pbuffer surface */ + if (gsurf->base.Type == EGL_PIXMAP_BIT || + gsurf->base.Type == EGL_PBUFFER_BIT) + return EGL_TRUE; + + /* or when the surface is single-buffered */ + if (gsurf->render_att == NATIVE_ATTACHMENT_FRONT_LEFT) + return EGL_TRUE; + + if (ctx && ctx->DrawSurface == surf) + gctx = egl_g3d_context(ctx); + + /* flush if the surface is current */ + if (gctx) + gctx->stapi->st_notify_swapbuffers(gctx->draw.st_fb); + + /* + * We drew on the back buffer, unless there was no back buffer. + * In that case, we drew on the front buffer. Either case, we call + * swap_buffers. + */ + if (!gsurf->native->swap_buffers(gsurf->native)) + return EGL_FALSE; + + if (gctx) { + struct egl_g3d_config *gconf = egl_g3d_config(gsurf->base.Config); + + /* force validation if the swap method is not copy */ + if (gconf->native->mode.swapMethod != GLX_SWAP_COPY_OML) { + gctx->force_validate = EGL_TRUE; + egl_g3d_validate_context(dpy, &gctx->base); + } + } + + return EGL_TRUE; +} + +/** + * Find a config that supports the pixmap. + */ +static _EGLConfig * +find_pixmap_config(_EGLDisplay *dpy, EGLNativePixmapType pix) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_config *gconf; + EGLint i; + + for (i = 0; i < dpy->NumConfigs; i++) { + gconf = egl_g3d_config(dpy->Configs[i]); + if (gdpy->native->is_pixmap_supported(gdpy->native, pix, gconf->native)) + break; + } + + return (i < dpy->NumConfigs) ? &gconf->base : NULL; +} + +/** + * Get the pipe surface of the given attachment of the native surface. + */ +static struct pipe_surface * +get_pipe_surface(struct native_display *ndpy, struct native_surface *nsurf, + enum native_attachment natt) +{ + struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS]; + struct pipe_surface *psurf; + + textures[natt] = NULL; + nsurf->validate(nsurf, 1 << natt, NULL, textures, NULL, NULL); + if (!textures[natt]) + return NULL; + + psurf = ndpy->screen->get_tex_surface(ndpy->screen, textures[natt], + 0, 0, 0, PIPE_BUFFER_USAGE_CPU_WRITE); + pipe_texture_reference(&textures[natt], NULL); + + return psurf; +} + +static EGLBoolean +egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, + NativePixmapType target) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + _EGLContext *ctx = _eglGetCurrentContext(); + struct egl_g3d_config *gconf; + struct native_surface *nsurf; + struct pipe_screen *screen = gdpy->native->screen; + struct pipe_surface *psurf; + + if (!gsurf->render_surface) + return EGL_TRUE; + + gconf = egl_g3d_config(find_pixmap_config(dpy, target)); + if (!gconf) + return _eglError(EGL_BAD_NATIVE_PIXMAP, "eglCopyBuffers"); + + nsurf = gdpy->native->create_pixmap_surface(gdpy->native, + target, gconf->native); + if (!nsurf) + return _eglError(EGL_BAD_NATIVE_PIXMAP, "eglCopyBuffers"); + + /* flush if the surface is current */ + if (ctx && ctx->DrawSurface == &gsurf->base) { + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + gctx->stapi->st_flush(gctx->st_ctx, + PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); + } + + psurf = get_pipe_surface(gdpy->native, nsurf, NATIVE_ATTACHMENT_FRONT_LEFT); + if (psurf) { + struct pipe_context pipe; + + /** + * XXX This is hacky. If we might allow the EGLDisplay to create a pipe + * context of its own and use the blitter context for this. + */ + memset(&pipe, 0, sizeof(pipe)); + pipe.screen = screen; + + util_surface_copy(&pipe, FALSE, psurf, 0, 0, + gsurf->render_surface, 0, 0, psurf->width, psurf->height); + + pipe_surface_reference(&psurf, NULL); + nsurf->flush_frontbuffer(nsurf); + } + + nsurf->destroy(nsurf); + + return EGL_TRUE; +} + +static EGLBoolean +egl_g3d_wait_client(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) +{ + struct egl_g3d_context *gctx = egl_g3d_context(ctx); + gctx->stapi->st_finish(gctx->st_ctx); + return EGL_TRUE; +} + +static EGLBoolean +egl_g3d_wait_native(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine) +{ + _EGLSurface *surf = _eglGetCurrentSurface(EGL_DRAW); + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + + if (engine != EGL_CORE_NATIVE_ENGINE) + return _eglError(EGL_BAD_PARAMETER, "eglWaitNative"); + + if (gsurf) + gsurf->native->wait(gsurf->native); + + return EGL_TRUE; +} + +static _EGLProc +egl_g3d_get_proc_address(_EGLDriver *drv, const char *procname) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + _EGLProc proc; + EGLint i; + + /* in case this is called before a display is initialized */ + egl_g3d_init_st(&gdrv->base); + + for (i = 0; i < NUM_EGL_G3D_STS; i++) { + const struct egl_g3d_st *stapi = gdrv->stapis[i]; + if (stapi) { + proc = (_EGLProc) stapi->st_get_proc_address(procname); + if (proc) + return proc; + } + } + + return (_EGLProc) NULL; +} + +static EGLBoolean +egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLSurface *surf, EGLint buffer) +{ + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + struct egl_g3d_context *gctx; + enum pipe_format target_format; + int target; + + if (!gsurf || gsurf->base.Type != EGL_PBUFFER_BIT) + return _eglError(EGL_BAD_SURFACE, "eglBindTexImage"); + if (buffer != EGL_BACK_BUFFER) + return _eglError(EGL_BAD_PARAMETER, "eglBindTexImage"); + if (gsurf->base.BoundToTexture) + return _eglError(EGL_BAD_ACCESS, "eglBindTexImage"); + + switch (gsurf->base.TextureFormat) { + case EGL_TEXTURE_RGB: + target_format = PIPE_FORMAT_R8G8B8_UNORM; + break; + case EGL_TEXTURE_RGBA: + target_format = PIPE_FORMAT_A8R8G8B8_UNORM; + break; + default: + return _eglError(EGL_BAD_MATCH, "eglBindTexImage"); + } + + switch (gsurf->base.TextureTarget) { + case EGL_TEXTURE_2D: + target = ST_TEXTURE_2D; + break; + default: + return _eglError(EGL_BAD_MATCH, "eglBindTexImage"); + } + + /* flush properly if the surface is bound */ + if (gsurf->base.Binding) { + gctx = egl_g3d_context(gsurf->base.Binding); + gctx->stapi->st_flush(gctx->st_ctx, + PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); + } + + /* XXX change to EGL_OPENGL_ES_API once OpenGL ES is merged */ + gctx = egl_g3d_get_current_context(EGL_OPENGL_API); + if (gctx) { + if (!gsurf->render_surface) + return EGL_FALSE; + + gctx->stapi->st_bind_texture_surface(gsurf->render_surface, + target, gsurf->base.MipmapLevel, target_format); + gsurf->base.BoundToTexture = EGL_TRUE; + } + + return EGL_TRUE; +} + +static EGLBoolean +egl_g3d_release_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLSurface *surf, EGLint buffer) +{ + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + + if (!gsurf || gsurf->base.Type != EGL_PBUFFER_BIT || + !gsurf->base.BoundToTexture) + return _eglError(EGL_BAD_SURFACE, "eglReleaseTexImage"); + if (buffer != EGL_BACK_BUFFER) + return _eglError(EGL_BAD_PARAMETER, "eglReleaseTexImage"); + + if (gsurf->render_surface) { + _EGLThreadInfo *t = _eglGetCurrentThread(); + /* XXX change to EGL_OPENGL_ES_API once OpenGL ES is merged */ + struct egl_g3d_context *gctx = egl_g3d_context( + t->CurrentContexts[_eglConvertApiToIndex(EGL_OPENGL_API)]); + + /* what if the context the surface binds to is no longer current? */ + if (gctx) + gctx->stapi->st_unbind_texture_surface(gsurf->render_surface, + ST_TEXTURE_2D, gsurf->base.MipmapLevel); + } + + gsurf->base.BoundToTexture = EGL_FALSE; + + return EGL_TRUE; +} + +#ifdef EGL_MESA_screen_surface + +static _EGLSurface * +egl_g3d_create_screen_surface(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLConfig *conf, const EGLint *attribs) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_config *gconf = egl_g3d_config(conf); + struct egl_g3d_surface *gsurf; + + gsurf = CALLOC_STRUCT(egl_g3d_surface); + if (!gsurf) { + _eglError(EGL_BAD_ALLOC, "eglCreatePbufferSurface"); + return NULL; + } + + if (!_eglInitSurface(drv, &gsurf->base, + EGL_SCREEN_BIT_MESA, conf, attribs)) { + free(gsurf); + return NULL; + } + + gsurf->native = + gdpy->native->modeset->create_scanout_surface(gdpy->native, + gconf->native, gsurf->base.Width, gsurf->base.Height); + if (!gsurf->native) { + free(gsurf); + return NULL; + } + + gsurf->render_att = (!gconf->native->mode.doubleBufferMode) ? + NATIVE_ATTACHMENT_FRONT_LEFT : NATIVE_ATTACHMENT_BACK_LEFT; + + return &gsurf->base; +} + +static EGLBoolean +egl_g3d_show_screen_surface(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLScreen *scr, _EGLSurface *surf, + _EGLMode *mode) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_screen *gscr = egl_g3d_screen(scr); + struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + struct native_surface *nsurf; + const struct native_mode *nmode; + EGLBoolean changed; + + if (gsurf) { + EGLint idx; + + if (!mode) + return _eglError(EGL_BAD_MATCH, "eglShowSurfaceMESA"); + if (gsurf->base.Type != EGL_SCREEN_BIT_MESA) + return _eglError(EGL_BAD_SURFACE, "eglShowScreenSurfaceMESA"); + if (gsurf->base.Width < mode->Width || gsurf->base.Height < mode->Height) + return _eglError(EGL_BAD_MATCH, + "eglShowSurfaceMESA(surface smaller than mode size)"); + + /* find the index of the mode */ + for (idx = 0; idx < gscr->base.NumModes; idx++) + if (mode == &gscr->base.Modes[idx]) + break; + if (idx >= gscr->base.NumModes) { + return _eglError(EGL_BAD_MODE_MESA, + "eglShowSurfaceMESA(unknown mode)"); + } + + nsurf = gsurf->native; + nmode = gscr->native_modes[idx]; + } + else { + if (mode) + return _eglError(EGL_BAD_MATCH, "eglShowSurfaceMESA"); + + /* disable the screen */ + nsurf = NULL; + nmode = NULL; + } + + /* TODO surface panning by CRTC choosing */ + changed = gdpy->native->modeset->program(gdpy->native, 0, nsurf, + gscr->base.OriginX, gscr->base.OriginY, &gscr->native, 1, nmode); + if (changed) { + gscr->base.CurrentSurface = &gsurf->base; + gscr->base.CurrentMode = mode; + } + + return changed; +} + +#endif /* EGL_MESA_screen_surface */ + +static EGLint +egl_g3d_probe(_EGLDriver *drv, _EGLDisplay *dpy) +{ + struct native_probe *nprobe; + enum native_probe_result res; + EGLint score; + + nprobe = egl_g3d_get_probe(drv, dpy); + res = native_get_probe_result(nprobe); + + switch (res) { + case NATIVE_PROBE_UNKNOWN: + default: + score = 0; + break; + case NATIVE_PROBE_FALLBACK: + score = 40; + break; + case NATIVE_PROBE_SUPPORTED: + score = 50; + break; + case NATIVE_PROBE_EXACT: + score = 100; + break; + } + + return score; +} + +static void +egl_g3d_unload(_EGLDriver *drv) +{ + struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); + + egl_g3d_destroy_probe(drv, NULL); + free(gdrv); +} + +_EGLDriver * +_eglMain(const char *args) +{ + static char driver_name[64]; + struct egl_g3d_driver *gdrv; + + snprintf(driver_name, sizeof(driver_name), + "Gallium/%s", native_get_name()); + + gdrv = CALLOC_STRUCT(egl_g3d_driver); + if (!gdrv) + return NULL; + + _eglInitDriverFallbacks(&gdrv->base); + + gdrv->base.API.Initialize = egl_g3d_initialize; + gdrv->base.API.Terminate = egl_g3d_terminate; + gdrv->base.API.CreateContext = egl_g3d_create_context; + gdrv->base.API.DestroyContext = egl_g3d_destroy_context; + gdrv->base.API.CreateWindowSurface = egl_g3d_create_window_surface; + gdrv->base.API.CreatePixmapSurface = egl_g3d_create_pixmap_surface; + gdrv->base.API.CreatePbufferSurface = egl_g3d_create_pbuffer_surface; + gdrv->base.API.DestroySurface = egl_g3d_destroy_surface; + gdrv->base.API.MakeCurrent = egl_g3d_make_current; + gdrv->base.API.SwapBuffers = egl_g3d_swap_buffers; + gdrv->base.API.CopyBuffers = egl_g3d_copy_buffers; + gdrv->base.API.WaitClient = egl_g3d_wait_client; + gdrv->base.API.WaitNative = egl_g3d_wait_native; + gdrv->base.API.GetProcAddress = egl_g3d_get_proc_address; + + gdrv->base.API.BindTexImage = egl_g3d_bind_tex_image; + gdrv->base.API.ReleaseTexImage = egl_g3d_release_tex_image; + +#ifdef EGL_MESA_screen_surface + gdrv->base.API.CreateScreenSurfaceMESA = egl_g3d_create_screen_surface; + gdrv->base.API.ShowScreenSurfaceMESA = egl_g3d_show_screen_surface; +#endif + + gdrv->base.Name = driver_name; + gdrv->base.Probe = egl_g3d_probe; + gdrv->base.Unload = egl_g3d_unload; + + /* the key is " EGL G3D" */ + gdrv->probe_key = 0x0E61063D; + + return &gdrv->base; +} diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.h b/src/gallium/state_trackers/egl/common/egl_g3d.h new file mode 100644 index 0000000000..3dae8c4052 --- /dev/null +++ b/src/gallium/state_trackers/egl/common/egl_g3d.h @@ -0,0 +1,127 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL 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. + */ + +#ifndef _EGL_G3D_H_ +#define _EGL_G3D_H_ + +#include "pipe/p_compiler.h" +#include "pipe/p_screen.h" +#include "pipe/p_context.h" +#include "pipe/p_format.h" +#include "egldriver.h" +#include "egldisplay.h" +#include "eglcontext.h" +#include "eglsurface.h" +#include "eglconfig.h" +#include "eglscreen.h" +#include "eglmode.h" + +#include "native.h" +#include "egl_st.h" + +struct egl_g3d_driver { + _EGLDriver base; + const struct egl_g3d_st *stapis[NUM_EGL_G3D_STS]; + EGLint api_mask; + + EGLint probe_key; +}; + +struct egl_g3d_display { + struct native_display *native; +}; + +struct egl_g3d_buffer { + struct st_framebuffer *st_fb; + uint attachment_mask; +}; + +struct egl_g3d_context { + _EGLContext base; + + const struct egl_g3d_st *stapi; + struct pipe_context *pipe; + + struct st_context *st_ctx; + EGLBoolean force_validate; + struct egl_g3d_buffer draw, read; +}; + +struct egl_g3d_surface { + _EGLSurface base; + struct native_surface *native; + enum native_attachment render_att; + struct pipe_surface *render_surface; + unsigned int sequence_number; +}; + +struct egl_g3d_config { + _EGLConfig base; + const struct native_config *native; +}; + +struct egl_g3d_screen { + _EGLScreen base; + const struct native_connector *native; + const struct native_mode **native_modes; +}; + +static INLINE struct egl_g3d_driver * +egl_g3d_driver(_EGLDriver *drv) +{ + return (struct egl_g3d_driver *) drv; +} + +static INLINE struct egl_g3d_display * +egl_g3d_display(_EGLDisplay *dpy) +{ + /* note that it is not direct casting */ + return (struct egl_g3d_display *) dpy->DriverData; +} + +static INLINE struct egl_g3d_context * +egl_g3d_context(_EGLContext *ctx) +{ + return (struct egl_g3d_context *) ctx; +} + +static INLINE struct egl_g3d_surface * +egl_g3d_surface(_EGLSurface *surf) +{ + return (struct egl_g3d_surface *) surf; +} + +static INLINE struct egl_g3d_config * +egl_g3d_config(_EGLConfig *conf) +{ + return (struct egl_g3d_config *) conf; +} + +static INLINE struct egl_g3d_screen * +egl_g3d_screen(_EGLScreen *scr) +{ + return (struct egl_g3d_screen *) scr; +} + +#endif /* _EGL_G3D_H_ */ diff --git a/src/gallium/state_trackers/egl/common/egl_st.c b/src/gallium/state_trackers/egl/common/egl_st.c new file mode 100644 index 0000000000..a88ff911cd --- /dev/null +++ b/src/gallium/state_trackers/egl/common/egl_st.c @@ -0,0 +1,131 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL 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. + */ + +#include +#include "pipe/p_compiler.h" +#include "util/u_memory.h" +#include "egllog.h" +#include "EGL/egl.h" /* for EGL_api_BIT */ + +#include "egl_st.h" + +#ifndef HAVE_DLADDR +#define HAVE_DLADDR 1 +#endif + +#if HAVE_DLADDR + +static const char * +egl_g3d_st_names[] = { +#define ST_PUBLIC(name, ...) #name, +#include "st_public_tmp.h" + NULL +}; + +static boolean +egl_g3d_fill_st(struct egl_g3d_st *stapi, void *sym) +{ + st_proc *procs = (st_proc *) stapi; + void *handle; + Dl_info info; + const char **name; + + if (!dladdr(sym, &info)) + return FALSE; + handle = dlopen(info.dli_fname, RTLD_LAZY | RTLD_LOCAL | RTLD_NODELETE); + if (!handle) + return FALSE; + + for (name = egl_g3d_st_names; *name; name++) { + st_proc proc = (st_proc) dlsym(handle, *name); + if (!proc) { + _eglLog(_EGL_WARNING, "%s is missing in %s", *name, info.dli_fname); + memset(stapi, 0, sizeof(*stapi)); + dlclose(handle); + return FALSE; + } + *procs++ = proc; + } + + dlclose(handle); + return TRUE; +} + +#else /* HAVE_DLADDR */ + +static boolean +egl_g3d_fill_st(struct egl_g3d_st *stapi, void *sym) +{ +#define ST_PUBLIC(name, ...) stapi->name = name; +#include "st_public_tmp.h" + return TRUE; +} + +#endif /* HAVE_DLADDR */ + +static boolean +egl_g3d_init_st(struct egl_g3d_st *stapi, const char *api) +{ + void *handle, *sym; + boolean res = FALSE; + + /* already initialized */ + if (stapi->st_notify_swapbuffers != NULL) + return TRUE; + + handle = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL); + if (!handle) + return FALSE; + + sym = dlsym(handle, api); + if (sym && egl_g3d_fill_st(stapi, sym)) + res = TRUE; + + dlclose(handle); + return res; +} + +static struct { + const char *symbol; + EGLint api_bit; +} egl_g3d_st_info[NUM_EGL_G3D_STS] = { + { "st_api_OpenGL_ES1", EGL_OPENGL_ES_BIT }, + { "st_api_OpenVG", EGL_OPENVG_BIT }, + { "st_api_OpenGL_ES2", EGL_OPENGL_ES2_BIT }, + { "st_api_OpenGL", EGL_OPENGL_BIT }, +}; + +const struct egl_g3d_st * +egl_g3d_get_st(enum egl_g3d_st_api api) +{ + static struct egl_g3d_st all_trackers[NUM_EGL_G3D_STS]; + + if (egl_g3d_init_st(&all_trackers[api], egl_g3d_st_info[api].symbol)) { + all_trackers[api].api_bit = egl_g3d_st_info[api].api_bit; + return &all_trackers[api]; + } + else { + return NULL; + } +} diff --git a/src/gallium/state_trackers/egl/common/egl_st.h b/src/gallium/state_trackers/egl/common/egl_st.h new file mode 100644 index 0000000000..8fb464bd3d --- /dev/null +++ b/src/gallium/state_trackers/egl/common/egl_st.h @@ -0,0 +1,73 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL 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. + */ + +#ifndef _EGL_ST_H_ +#define _EGL_ST_H_ + +#include "GL/gl.h" /* for GL types */ +#include "GL/internal/glcore.h" /* for __GLcontextModes */ + +#include "pipe/p_compiler.h" +#include "pipe/p_format.h" +#include "pipe/p_context.h" + +/* avoid calling st functions directly */ +#if 1 + +#define ST_SURFACE_FRONT_LEFT 0 +#define ST_SURFACE_BACK_LEFT 1 +#define ST_SURFACE_FRONT_RIGHT 2 +#define ST_SURFACE_BACK_RIGHT 3 + +#define ST_TEXTURE_2D 0x2 + +struct st_context; +struct st_framebuffer; +typedef void (*st_proc)(); + +#else +#include "state_tracker/st_public.h" +#endif + +/* remember to update egl_g3d_get_st() when update the enums */ +enum egl_g3d_st_api { + EGL_G3D_ST_OPENGL_ES = 0, + EGL_G3D_ST_OPENVG, + EGL_G3D_ST_OPENGL_ES2, + EGL_G3D_ST_OPENGL, + + NUM_EGL_G3D_STS +}; + +struct egl_g3d_st { +#define ST_PUBLIC(name, ret, ...) ret (*name)(__VA_ARGS__); +#include "st_public_tmp.h" + /* fields must be added here */ + EGLint api_bit; +}; + +const struct egl_g3d_st * +egl_g3d_get_st(enum egl_g3d_st_api api); + +#endif /* _EGL_ST_H_ */ diff --git a/src/gallium/state_trackers/egl/common/native.h b/src/gallium/state_trackers/egl/common/native.h new file mode 100644 index 0000000000..72a9cec7ef --- /dev/null +++ b/src/gallium/state_trackers/egl/common/native.h @@ -0,0 +1,277 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL 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. + */ + +#ifndef _NATIVE_H_ +#define _NATIVE_H_ + +#include "EGL/egl.h" /* for EGL native types */ +#include "GL/gl.h" /* for GL types needed by __GLcontextModes */ +#include "GL/internal/glcore.h" /* for __GLcontextModes */ + +#include "pipe/p_compiler.h" +#include "pipe/p_screen.h" +#include "pipe/p_context.h" +#include "pipe/p_state.h" + +/** + * Only color buffers are listed. The others are allocated privately through, + * for example, st_renderbuffer_alloc_storage(). + */ +enum native_attachment { + NATIVE_ATTACHMENT_FRONT_LEFT, + NATIVE_ATTACHMENT_BACK_LEFT, + NATIVE_ATTACHMENT_FRONT_RIGHT, + NATIVE_ATTACHMENT_BACK_RIGHT, + + NUM_NATIVE_ATTACHMENTS +}; + +/** + * Enumerations for probe results. + */ +enum native_probe_result { + NATIVE_PROBE_UNKNOWN, + NATIVE_PROBE_FALLBACK, + NATIVE_PROBE_SUPPORTED, + NATIVE_PROBE_EXACT, +}; + +/** + * A probe object for display probe. + */ +struct native_probe { + int magic; + EGLNativeDisplayType display; + void *data; + + void (*destroy)(struct native_probe *nprobe); +}; + +struct native_surface { + void (*destroy)(struct native_surface *nsurf); + + /** + * Swap the front and back buffers so that the back buffer is visible. It + * is no-op if the surface is single-buffered. The contents of the back + * buffer after swapping may or may not be preserved. + */ + boolean (*swap_buffers)(struct native_surface *nsurf); + + /** + * Make the front buffer visible. In some native displays, changes to the + * front buffer might not be visible immediately and require manual flush. + */ + boolean (*flush_frontbuffer)(struct native_surface *nsurf); + + /** + * Validate the buffers of the surface. textures, if not NULL, points to an + * array of size NUM_NATIVE_ATTACHMENTS and the returned textures are owned + * by the caller. A sequence number is also returned. The caller can use + * it to check if anything has changed since the last call. Any of the + * pointers may be NULL and it indicates the caller has no interest in those + * values. + * + * If this function is called multiple times with different attachment + * masks, those not listed in the latest call might be destroyed. This + * behavior might change in the future. + */ + boolean (*validate)(struct native_surface *nsurf, uint attachment_mask, + unsigned int *seq_num, struct pipe_texture **textures, + int *width, int *height); + + /** + * Wait until all native commands affecting the surface has been executed. + */ + void (*wait)(struct native_surface *nsurf); +}; + +struct native_config { + /* __GLcontextModes should go away some day */ + __GLcontextModes mode; + enum pipe_format color_format; + enum pipe_format depth_format; + enum pipe_format stencil_format; + + /* treat it as an additional flag to mode.drawableType */ + boolean scanout_bit; +}; + +struct native_connector { + int dummy; +}; + +struct native_mode { + const char *desc; + int width, height; + int refresh_rate; +}; + +struct native_display_modeset; + +/** + * A pipe winsys abstracts the OS. A pipe screen abstracts the graphcis + * hardware. A native display consists of a pipe winsys, a pipe screen, and + * the native display server. + */ +struct native_display { + /** + * The pipe screen of the native display. + * + * Note that the "flush_frontbuffer" and "update_buffer" callbacks will be + * overridden. + */ + struct pipe_screen *screen; + + void (*destroy)(struct native_display *ndpy); + + /** + * Get the supported configs. The configs are owned by the display, but + * the returned array should be free()ed. + * + * The configs will be converted to EGL config by + * _eglConfigFromContextModesRec and validated by _eglValidateConfig. + * Those failing to pass the test will be skipped. + */ + const struct native_config **(*get_configs)(struct native_display *ndpy, + int *num_configs); + + /** + * Test if a pixmap is supported by the given config. Required unless no + * config has GLX_PIXMAP_BIT set. + * + * This function is usually called to find a config that supports a given + * pixmap. Thus, it is usually called with the same pixmap in a row. + */ + boolean (*is_pixmap_supported)(struct native_display *ndpy, + EGLNativePixmapType pix, + const struct native_config *nconf); + + /** + * Create a pipe context. + */ + struct pipe_context *(*create_context)(struct native_display *ndpy, + void *context_private); + + /** + * Create a window surface. Required unless no config has GLX_WINDOW_BIT + * set. + */ + struct native_surface *(*create_window_surface)(struct native_display *ndpy, + EGLNativeWindowType win, + const struct native_config *nconf); + + /** + * Create a pixmap surface. Required unless no config has GLX_PIXMAP_BIT + * set. + */ + struct native_surface *(*create_pixmap_surface)(struct native_display *ndpy, + EGLNativePixmapType pix, + const struct native_config *nconf); + + /** + * Create a pbuffer surface. Required unless no config has GLX_PBUFFER_BIT + * set. + */ + struct native_surface *(*create_pbuffer_surface)(struct native_display *ndpy, + const struct native_config *nconf, + uint width, uint height); + + const struct native_display_modeset *modeset; +}; + +/** + * Mode setting interface of the native display. It exposes the mode setting + * capabilities of the underlying graphics hardware. + */ +struct native_display_modeset { + /** + * Get the available physical connectors and the number of CRTCs. + */ + const struct native_connector **(*get_connectors)(struct native_display *ndpy, + int *num_connectors, + int *num_crtcs); + + /** + * Get the current supported modes of a connector. The returned modes may + * change every time this function is called and those from previous calls + * might become invalid. + */ + const struct native_mode **(*get_modes)(struct native_display *ndpy, + const struct native_connector *nconn, + int *num_modes); + + /** + * Create a scan-out surface. Required unless no config has + * GLX_SCREEN_BIT_MESA set. + */ + struct native_surface *(*create_scanout_surface)(struct native_display *ndpy, + const struct native_config *nconf, + uint width, uint height); + + /** + * Program the CRTC to output the surface to the given connectors with the + * given mode. When surface is not given, the CRTC is disabled. + * + * This interface does not export a way to query capabilities of the CRTCs. + * The native display usually needs to dynamically map the index to a CRTC + * that supports the given connectors. + */ + boolean (*program)(struct native_display *ndpy, int crtc_idx, + struct native_surface *nsurf, uint x, uint y, + const struct native_connector **nconns, int num_nconns, + const struct native_mode *nmode); +}; + +/** + * Test whether an attachment is set in the mask. + */ +static INLINE boolean +native_attachment_mask_test(uint mask, enum native_attachment att) +{ + return !!(mask & (1 << att)); +} + +/** + * Return a probe object for the given display. + * + * Note that the returned object may be cached and used by different native + * display modules. It allows fast probing when multiple modules probe the + * same display. + */ +struct native_probe * +native_create_probe(EGLNativeDisplayType dpy); + +/** + * Probe the probe object. + */ +enum native_probe_result +native_get_probe_result(struct native_probe *nprobe); + +const char * +native_get_name(void); + +struct native_display * +native_create_display(EGLNativeDisplayType dpy); + +#endif /* _NATIVE_H_ */ diff --git a/src/gallium/state_trackers/egl/common/st_public_tmp.h b/src/gallium/state_trackers/egl/common/st_public_tmp.h new file mode 100644 index 0000000000..507a0ec402 --- /dev/null +++ b/src/gallium/state_trackers/egl/common/st_public_tmp.h @@ -0,0 +1,20 @@ +ST_PUBLIC(st_create_context, struct st_context *, struct pipe_context *pipe, const __GLcontextModes *visual, struct st_context *share) +ST_PUBLIC(st_destroy_context, void, struct st_context *st) +ST_PUBLIC(st_copy_context_state, void, struct st_context *dst, struct st_context *src, uint mask) +ST_PUBLIC(st_create_framebuffer, struct st_framebuffer *, const __GLcontextModes *visual, enum pipe_format colorFormat, enum pipe_format depthFormat, enum pipe_format stencilFormat, uint width, uint height, void *privateData) +ST_PUBLIC(st_resize_framebuffer, void, struct st_framebuffer *stfb, uint width, uint height) +ST_PUBLIC(st_set_framebuffer_surface, void, struct st_framebuffer *stfb, uint surfIndex, struct pipe_surface *surf) +ST_PUBLIC(st_get_framebuffer_dimensions, void, struct st_framebuffer *stfb, uint *width, uint *height) +ST_PUBLIC(st_get_framebuffer_surface, int, struct st_framebuffer *stfb, uint surfIndex, struct pipe_surface **surface) +ST_PUBLIC(st_get_framebuffer_texture, int, struct st_framebuffer *stfb, uint surfIndex, struct pipe_texture **texture) +ST_PUBLIC(st_framebuffer_private, void *, struct st_framebuffer *stfb) +ST_PUBLIC(st_unreference_framebuffer, void, struct st_framebuffer *stfb) +ST_PUBLIC(st_make_current, GLboolean, struct st_context *st, struct st_framebuffer *draw, struct st_framebuffer *read) +ST_PUBLIC(st_get_current, struct st_context *, void) +ST_PUBLIC(st_flush, void, struct st_context *st, uint pipeFlushFlags, struct pipe_fence_handle **fence) +ST_PUBLIC(st_finish, void, struct st_context *st) +ST_PUBLIC(st_notify_swapbuffers, void, struct st_framebuffer *stfb) +ST_PUBLIC(st_bind_texture_surface, int, struct pipe_surface *ps, int target, int level, enum pipe_format format) +ST_PUBLIC(st_unbind_texture_surface, int, struct pipe_surface *ps, int target, int level) +ST_PUBLIC(st_get_proc_address, st_proc, const char *procname) +#undef ST_PUBLIC diff --git a/src/gallium/state_trackers/egl/kms/native_kms.c b/src/gallium/state_trackers/egl/kms/native_kms.c new file mode 100644 index 0000000000..d5baf2c2f0 --- /dev/null +++ b/src/gallium/state_trackers/egl/kms/native_kms.c @@ -0,0 +1,866 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL 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. + */ + +#include + +#include "pipe/p_screen.h" +#include "pipe/p_context.h" +#include "util/u_debug.h" +#include "util/u_memory.h" +#include "egllog.h" + +#include "native_kms.h" + +static boolean +kms_surface_validate(struct native_surface *nsurf, uint attachment_mask, + unsigned int *seq_num, struct pipe_texture **textures, + int *width, int *height) +{ + struct kms_surface *ksurf = kms_surface(nsurf); + struct kms_display *kdpy = ksurf->kdpy; + struct pipe_screen *screen = kdpy->base.screen; + struct pipe_texture templ, *ptex; + int att; + + if (attachment_mask) { + memset(&templ, 0, sizeof(templ)); + templ.target = PIPE_TEXTURE_2D; + templ.last_level = 0; + templ.width0 = ksurf->width; + templ.height0 = ksurf->height; + templ.depth0 = 1; + templ.format = ksurf->color_format; + templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; + if (ksurf->type == KMS_SURFACE_TYPE_SCANOUT) + templ.tex_usage |= PIPE_TEXTURE_USAGE_PRIMARY; + } + + /* create textures */ + for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { + /* delay the allocation */ + if (!native_attachment_mask_test(attachment_mask, att)) + continue; + + ptex = ksurf->textures[att]; + if (!ptex) { + ptex = screen->texture_create(screen, &templ); + ksurf->textures[att] = ptex; + } + + if (textures) { + textures[att] = NULL; + pipe_texture_reference(&textures[att], ptex); + } + } + + if (seq_num) + *seq_num = ksurf->sequence_number; + if (width) + *width = ksurf->width; + if (height) + *height = ksurf->height; + + return TRUE; +} + +/** + * Add textures as DRM framebuffers. + */ +static boolean +kms_surface_init_framebuffers(struct native_surface *nsurf, boolean need_back) +{ + struct kms_surface *ksurf = kms_surface(nsurf); + struct kms_display *kdpy = ksurf->kdpy; + int num_framebuffers = (need_back) ? 2 : 1; + int i, err; + + for (i = 0; i < num_framebuffers; i++) { + struct kms_framebuffer *fb; + enum native_attachment natt; + unsigned int handle, stride; + uint block_bits; + + if (i == 0) { + fb = &ksurf->front_fb; + natt = NATIVE_ATTACHMENT_FRONT_LEFT; + } + else { + fb = &ksurf->back_fb; + natt = NATIVE_ATTACHMENT_BACK_LEFT; + } + + if (!fb->texture) { + /* make sure the texture has been allocated */ + kms_surface_validate(&ksurf->base, 1 << natt, NULL, NULL, NULL, NULL); + if (!ksurf->textures[natt]) + return FALSE; + + pipe_texture_reference(&fb->texture, ksurf->textures[natt]); + } + + /* already initialized */ + if (fb->buffer_id) + continue; + + /* TODO detect the real value */ + fb->is_passive = TRUE; + + if (!kdpy->api->local_handle_from_texture(kdpy->api, + kdpy->base.screen, fb->texture, &stride, &handle)) + return FALSE; + + block_bits = util_format_get_blocksizebits(ksurf->color_format); + err = drmModeAddFB(kdpy->fd, ksurf->width, ksurf->height, + block_bits, block_bits, stride, handle, &fb->buffer_id); + if (err) { + fb->buffer_id = 0; + return FALSE; + } + } + + return TRUE; +} + +static boolean +kms_surface_flush_frontbuffer(struct native_surface *nsurf) +{ +#ifdef DRM_MODE_FEATURE_DIRTYFB + struct kms_surface *ksurf = kms_surface(nsurf); + struct kms_display *kdpy = ksurf->kdpy; + + /* pbuffer is private */ + if (ksurf->type == KMS_SURFACE_TYPE_PBUFFER) + return TRUE; + + if (ksurf->front_fb.is_passive) + drmModeDirtyFB(kdpy->fd, ksurf->front_fb.buffer_id, NULL, 0); +#endif + + return TRUE; +} + +static boolean +kms_surface_swap_buffers(struct native_surface *nsurf) +{ + struct kms_surface *ksurf = kms_surface(nsurf); + struct kms_crtc *kcrtc = &ksurf->current_crtc; + struct kms_display *kdpy = ksurf->kdpy; + struct kms_framebuffer tmp_fb; + struct pipe_texture *tmp_texture; + int err; + + /* pbuffer is private */ + if (ksurf->type == KMS_SURFACE_TYPE_PBUFFER) + return TRUE; + + if (!ksurf->back_fb.buffer_id) { + if (!kms_surface_init_framebuffers(&ksurf->base, TRUE)) + return FALSE; + } + + if (ksurf->is_shown && kcrtc->crtc) { + err = drmModeSetCrtc(kdpy->fd, kcrtc->crtc->crtc_id, + ksurf->back_fb.buffer_id, kcrtc->crtc->x, kcrtc->crtc->y, + kcrtc->connectors, kcrtc->num_connectors, &kcrtc->crtc->mode); + if (err) + return FALSE; + } + + /* swap the buffers */ + tmp_fb = ksurf->front_fb; + ksurf->front_fb = ksurf->back_fb; + ksurf->back_fb = tmp_fb; + + tmp_texture = ksurf->textures[NATIVE_ATTACHMENT_FRONT_LEFT]; + ksurf->textures[NATIVE_ATTACHMENT_FRONT_LEFT] = + ksurf->textures[NATIVE_ATTACHMENT_BACK_LEFT]; + ksurf->textures[NATIVE_ATTACHMENT_BACK_LEFT] = tmp_texture; + + /* the front/back textures are swapped */ + ksurf->sequence_number++; + + return TRUE; +} + +static void +kms_surface_wait(struct native_surface *nsurf) +{ + /* no-op */ +} + +static void +kms_surface_destroy(struct native_surface *nsurf) +{ + struct kms_surface *ksurf = kms_surface(nsurf); + int i; + + if (ksurf->current_crtc.crtc) + drmModeFreeCrtc(ksurf->current_crtc.crtc); + + if (ksurf->front_fb.buffer_id) + drmModeRmFB(ksurf->kdpy->fd, ksurf->front_fb.buffer_id); + pipe_texture_reference(&ksurf->front_fb.texture, NULL); + + if (ksurf->back_fb.buffer_id) + drmModeRmFB(ksurf->kdpy->fd, ksurf->back_fb.buffer_id); + pipe_texture_reference(&ksurf->back_fb.texture, NULL); + + for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { + struct pipe_texture *ptex = ksurf->textures[i]; + pipe_texture_reference(&ptex, NULL); + } + + free(ksurf); +} + +static struct kms_surface * +kms_display_create_surface(struct native_display *ndpy, + enum kms_surface_type type, + const struct native_config *nconf, + uint width, uint height) +{ + struct kms_display *kdpy = kms_display(ndpy); + struct kms_config *kconf = kms_config(nconf); + struct kms_surface *ksurf; + + ksurf = CALLOC_STRUCT(kms_surface); + if (!ksurf) + return NULL; + + ksurf->kdpy = kdpy; + ksurf->type = type; + ksurf->color_format = kconf->base.color_format; + ksurf->width = width; + ksurf->height = height; + + ksurf->base.destroy = kms_surface_destroy; + ksurf->base.swap_buffers = kms_surface_swap_buffers; + ksurf->base.flush_frontbuffer = kms_surface_flush_frontbuffer; + ksurf->base.validate = kms_surface_validate; + ksurf->base.wait = kms_surface_wait; + + return ksurf; +} + +/** + * Choose a CRTC that supports all given connectors. + */ +static uint32_t +kms_display_choose_crtc(struct native_display *ndpy, + uint32_t *connectors, int num_connectors) +{ + struct kms_display *kdpy = kms_display(ndpy); + int idx; + + for (idx = 0; idx < kdpy->resources->count_crtcs; idx++) { + boolean found_crtc = TRUE; + int i, j; + + for (i = 0; i < num_connectors; i++) { + drmModeConnectorPtr connector; + int encoder_idx = -1; + + connector = drmModeGetConnector(kdpy->fd, connectors[i]); + if (!connector) { + found_crtc = FALSE; + break; + } + + /* find an encoder the CRTC supports */ + for (j = 0; j < connector->count_encoders; j++) { + drmModeEncoderPtr encoder = + drmModeGetEncoder(kdpy->fd, connector->encoders[j]); + if (encoder->possible_crtcs & (1 << idx)) { + encoder_idx = j; + break; + } + drmModeFreeEncoder(encoder); + } + + drmModeFreeConnector(connector); + if (encoder_idx < 0) { + found_crtc = FALSE; + break; + } + } + + if (found_crtc) + break; + } + + if (idx >= kdpy->resources->count_crtcs) { + _eglLog(_EGL_WARNING, + "failed to find a CRTC that supports the given %d connectors", + num_connectors); + return 0; + } + + return kdpy->resources->crtcs[idx]; +} + +/** + * Remember the original CRTC status and set the CRTC + */ +static boolean +kms_display_set_crtc(struct native_display *ndpy, int crtc_idx, + uint32_t buffer_id, uint32_t x, uint32_t y, + uint32_t *connectors, int num_connectors, + drmModeModeInfoPtr mode) +{ + struct kms_display *kdpy = kms_display(ndpy); + struct kms_crtc *kcrtc = &kdpy->saved_crtcs[crtc_idx]; + uint32_t crtc_id; + int err; + + if (kcrtc->crtc) { + crtc_id = kcrtc->crtc->crtc_id; + } + else { + int count = 0, i; + + /* + * Choose the CRTC once. It could be more dynamic, but let's keep it + * simple for now. + */ + crtc_id = kms_display_choose_crtc(&kdpy->base, + connectors, num_connectors); + + /* save the original CRTC status */ + kcrtc->crtc = drmModeGetCrtc(kdpy->fd, crtc_id); + if (!kcrtc->crtc) + return FALSE; + + for (i = 0; i < kdpy->num_connectors; i++) { + struct kms_connector *kconn = &kdpy->connectors[i]; + drmModeConnectorPtr connector = kconn->connector; + drmModeEncoderPtr encoder; + + encoder = drmModeGetEncoder(kdpy->fd, connector->encoder_id); + if (encoder) { + if (encoder->crtc_id == crtc_id) { + kcrtc->connectors[count++] = connector->connector_id; + if (count >= Elements(kcrtc->connectors)) + break; + } + drmModeFreeEncoder(encoder); + } + } + + kcrtc->num_connectors = count; + } + + err = drmModeSetCrtc(kdpy->fd, crtc_id, buffer_id, x, y, + connectors, num_connectors, mode); + if (err) { + drmModeFreeCrtc(kcrtc->crtc); + kcrtc->crtc = NULL; + kcrtc->num_connectors = 0; + + return FALSE; + } + + return TRUE; +} + +static boolean +kms_display_program(struct native_display *ndpy, int crtc_idx, + struct native_surface *nsurf, uint x, uint y, + const struct native_connector **nconns, int num_nconns, + const struct native_mode *nmode) +{ + struct kms_display *kdpy = kms_display(ndpy); + struct kms_surface *ksurf = kms_surface(nsurf); + const struct kms_mode *kmode = kms_mode(nmode); + uint32_t connector_ids[32]; + uint32_t buffer_id; + drmModeModeInfo mode_tmp, *mode; + int i; + + if (num_nconns > Elements(connector_ids)) { + _eglLog(_EGL_WARNING, "too many connectors (%d)", num_nconns); + num_nconns = Elements(connector_ids); + } + + if (ksurf) { + if (!kms_surface_init_framebuffers(&ksurf->base, FALSE)) + return FALSE; + + buffer_id = ksurf->front_fb.buffer_id; + /* the mode argument of drmModeSetCrtc is not constified */ + mode_tmp = kmode->mode; + mode = &mode_tmp; + } + else { + /* disable the CRTC */ + buffer_id = 0; + mode = NULL; + num_nconns = 0; + } + + for (i = 0; i < num_nconns; i++) { + struct kms_connector *kconn = kms_connector(nconns[i]); + connector_ids[i] = kconn->connector->connector_id; + } + + if (!kms_display_set_crtc(&kdpy->base, crtc_idx, buffer_id, x, y, + connector_ids, num_nconns, mode)) { + _eglLog(_EGL_WARNING, "failed to set CRTC %d", crtc_idx); + + return FALSE; + } + + if (kdpy->shown_surfaces[crtc_idx]) + kdpy->shown_surfaces[crtc_idx]->is_shown = FALSE; + kdpy->shown_surfaces[crtc_idx] = ksurf; + + /* remember the settings for buffer swapping */ + if (ksurf) { + uint32_t crtc_id = kdpy->saved_crtcs[crtc_idx].crtc->crtc_id; + struct kms_crtc *kcrtc = &ksurf->current_crtc; + + if (kcrtc->crtc) + drmModeFreeCrtc(kcrtc->crtc); + kcrtc->crtc = drmModeGetCrtc(kdpy->fd, crtc_id); + + assert(num_nconns < Elements(kcrtc->connectors)); + memcpy(kcrtc->connectors, connector_ids, + sizeof(*connector_ids) * num_nconns); + kcrtc->num_connectors = num_nconns; + + ksurf->is_shown = TRUE; + } + + return TRUE; +} + +static const struct native_mode ** +kms_display_get_modes(struct native_display *ndpy, + const struct native_connector *nconn, + int *num_modes) +{ + struct kms_display *kdpy = kms_display(ndpy); + struct kms_connector *kconn = kms_connector(nconn); + const struct native_mode **nmodes_return; + int count, i; + + /* delete old data */ + if (kconn->connector) { + drmModeFreeConnector(kconn->connector); + free(kconn->kms_modes); + + kconn->connector = NULL; + kconn->kms_modes = NULL; + kconn->num_modes = 0; + } + + /* detect again */ + kconn->connector = drmModeGetConnector(kdpy->fd, kconn->connector_id); + if (!kconn->connector) + return NULL; + + count = kconn->connector->count_modes; + kconn->kms_modes = calloc(count, sizeof(*kconn->kms_modes)); + if (!kconn->kms_modes) { + drmModeFreeConnector(kconn->connector); + kconn->connector = NULL; + + return NULL; + } + + for (i = 0; i < count; i++) { + struct kms_mode *kmode = &kconn->kms_modes[i]; + drmModeModeInfoPtr mode = &kconn->connector->modes[i]; + + kmode->mode = *mode; + + kmode->base.desc = kmode->mode.name; + kmode->base.width = kmode->mode.hdisplay; + kmode->base.height = kmode->mode.vdisplay; + kmode->base.refresh_rate = kmode->mode.vrefresh / 1000; + } + + nmodes_return = malloc(count * sizeof(*nmodes_return)); + if (nmodes_return) { + for (i = 0; i < count; i++) + nmodes_return[i] = &kconn->kms_modes[i].base; + if (num_modes) + *num_modes = count; + } + + return nmodes_return; +} + +static const struct native_connector ** +kms_display_get_connectors(struct native_display *ndpy, int *num_connectors, + int *num_crtc) +{ + struct kms_display *kdpy = kms_display(ndpy); + const struct native_connector **connectors; + int i; + + if (!kdpy->connectors) { + kdpy->connectors = + calloc(kdpy->resources->count_connectors, sizeof(*kdpy->connectors)); + if (!kdpy->connectors) + return NULL; + + for (i = 0; i < kdpy->resources->count_connectors; i++) { + struct kms_connector *kconn = &kdpy->connectors[i]; + + kconn->connector_id = kdpy->resources->connectors[i]; + /* kconn->connector is allocated when the modes are asked */ + } + + kdpy->num_connectors = kdpy->resources->count_connectors; + } + + connectors = malloc(kdpy->num_connectors * sizeof(*connectors)); + if (connectors) { + for (i = 0; i < kdpy->num_connectors; i++) + connectors[i] = &kdpy->connectors[i].base; + if (num_connectors) + *num_connectors = kdpy->num_connectors; + } + + if (num_crtc) + *num_crtc = kdpy->resources->count_crtcs; + + return connectors; +} + +static struct native_surface * +kms_display_create_scanout_surface(struct native_display *ndpy, + const struct native_config *nconf, + uint width, uint height) +{ + struct kms_surface *ksurf; + + ksurf = kms_display_create_surface(ndpy, + KMS_SURFACE_TYPE_SCANOUT, nconf, width, height); + return &ksurf->base; +} + +static struct native_surface * +kms_display_create_pbuffer_surface(struct native_display *ndpy, + const struct native_config *nconf, + uint width, uint height) +{ + struct kms_surface *ksurf; + + ksurf = kms_display_create_surface(ndpy, + KMS_SURFACE_TYPE_PBUFFER, nconf, width, height); + return &ksurf->base; +} + +static struct pipe_context * +kms_display_create_context(struct native_display *ndpy, void *context_private) +{ + struct kms_display *kdpy = kms_display(ndpy); + struct pipe_context *pctx; + + pctx = kdpy->api->create_context(kdpy->api, kdpy->base.screen); + if (pctx) + pctx->priv = context_private; + return pctx; +} + +static boolean +kms_display_is_format_supported(struct native_display *ndpy, + enum pipe_format fmt, boolean is_color) +{ + return ndpy->screen->is_format_supported(ndpy->screen, + fmt, PIPE_TEXTURE_2D, + (is_color) ? PIPE_TEXTURE_USAGE_RENDER_TARGET : + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); +} + +static const struct native_config ** +kms_display_get_configs(struct native_display *ndpy, int *num_configs) +{ + struct kms_display *kdpy = kms_display(ndpy); + const struct native_config **configs; + + /* first time */ + if (!kdpy->config) { + struct native_config *nconf; + enum pipe_format format; + + kdpy->config = calloc(1, sizeof(*kdpy->config)); + if (!kdpy->config) + return NULL; + + nconf = &kdpy->config->base; + + /* always double-buffered */ + nconf->mode.doubleBufferMode = TRUE; + + format = PIPE_FORMAT_A8R8G8B8_UNORM; + if (!kms_display_is_format_supported(&kdpy->base, format, TRUE)) { + format = PIPE_FORMAT_B8G8R8A8_UNORM; + if (!kms_display_is_format_supported(&kdpy->base, format, TRUE)) + format = PIPE_FORMAT_NONE; + } + if (format == PIPE_FORMAT_NONE) + return NULL; + + nconf->color_format = format; + nconf->mode.redBits = 8; + nconf->mode.greenBits = 8; + nconf->mode.blueBits = 8; + nconf->mode.alphaBits = 8; + nconf->mode.rgbBits = 32; + + format = PIPE_FORMAT_S8Z24_UNORM; + if (!kms_display_is_format_supported(&kdpy->base, format, FALSE)) { + format = PIPE_FORMAT_Z24S8_UNORM; + if (!kms_display_is_format_supported(&kdpy->base, format, FALSE)) + format = PIPE_FORMAT_NONE; + } + if (format != PIPE_FORMAT_NONE) { + nconf->depth_format = format; + nconf->stencil_format = format; + + nconf->mode.depthBits = 24; + nconf->mode.stencilBits = 8; + nconf->mode.haveDepthBuffer = TRUE; + nconf->mode.haveStencilBuffer = TRUE; + } + + nconf->scanout_bit = TRUE; + nconf->mode.drawableType = GLX_PBUFFER_BIT; + nconf->mode.swapMethod = GLX_SWAP_EXCHANGE_OML; + + nconf->mode.visualID = 0; + nconf->mode.visualType = EGL_NONE; + + nconf->mode.renderType = GLX_RGBA_BIT; + nconf->mode.rgbMode = TRUE; + nconf->mode.xRenderable = FALSE; + } + + configs = malloc(sizeof(*configs)); + if (configs) { + configs[0] = &kdpy->config->base; + if (num_configs) + *num_configs = 1; + } + + return configs; +} + +static void +kms_display_destroy(struct native_display *ndpy) +{ + struct kms_display *kdpy = kms_display(ndpy); + int i; + + if (kdpy->config) + free(kdpy->config); + + if (kdpy->connectors) { + for (i = 0; i < kdpy->num_connectors; i++) { + struct kms_connector *kconn = &kdpy->connectors[i]; + if (kconn->connector) { + drmModeFreeConnector(kconn->connector); + free(kconn->kms_modes); + } + } + free(kdpy->connectors); + } + + if (kdpy->shown_surfaces) + free(kdpy->shown_surfaces); + + if (kdpy->saved_crtcs) { + for (i = 0; i < kdpy->resources->count_crtcs; i++) { + struct kms_crtc *kcrtc = &kdpy->saved_crtcs[i]; + + if (kcrtc->crtc) { + /* restore crtc */ + drmModeSetCrtc(kdpy->fd, kcrtc->crtc->crtc_id, + kcrtc->crtc->buffer_id, kcrtc->crtc->x, kcrtc->crtc->y, + kcrtc->connectors, kcrtc->num_connectors, + &kcrtc->crtc->mode); + + drmModeFreeCrtc(kcrtc->crtc); + } + } + free(kdpy->saved_crtcs); + } + + if (kdpy->resources) + drmModeFreeResources(kdpy->resources); + + if (kdpy->base.screen) + kdpy->base.screen->destroy(kdpy->base.screen); + + if (kdpy->fd >= 0) + drmClose(kdpy->fd); + + if (kdpy->api) + kdpy->api->destroy(kdpy->api); + free(kdpy); +} + +/** + * Initialize KMS and pipe screen. + */ +static boolean +kms_display_init_screen(struct native_display *ndpy) +{ + struct kms_display *kdpy = kms_display(ndpy); + struct drm_create_screen_arg arg; + int fd; + + fd = drmOpen(kdpy->api->name, NULL); + if (fd < 0) { + _eglLog(_EGL_WARNING, "failed to open DRM device"); + return FALSE; + } + +#if 0 + if (drmSetMaster(fd)) { + _eglLog(_EGL_WARNING, "failed to become DRM master"); + return FALSE; + } +#endif + + memset(&arg, 0, sizeof(arg)); + arg.mode = DRM_CREATE_NORMAL; + kdpy->base.screen = kdpy->api->create_screen(kdpy->api, fd, &arg); + if (!kdpy->base.screen) { + _eglLog(_EGL_WARNING, "failed to create DRM screen"); + drmClose(fd); + return FALSE; + } + + kdpy->fd = fd; + + return TRUE; +} + +static struct native_display_modeset kms_display_modeset = { + .get_connectors = kms_display_get_connectors, + .get_modes = kms_display_get_modes, + .create_scanout_surface = kms_display_create_scanout_surface, + .program = kms_display_program +}; + +static struct native_display * +kms_create_display(EGLNativeDisplayType dpy, struct drm_api *api) +{ + struct kms_display *kdpy; + + kdpy = CALLOC_STRUCT(kms_display); + if (!kdpy) + return NULL; + + kdpy->api = api; + if (!kdpy->api) { + _eglLog(_EGL_WARNING, "failed to create DRM API"); + free(kdpy); + return NULL; + } + + kdpy->fd = -1; + if (!kms_display_init_screen(&kdpy->base)) { + kms_display_destroy(&kdpy->base); + return NULL; + } + + /* resources are fixed, unlike crtc, connector, or encoder */ + kdpy->resources = drmModeGetResources(kdpy->fd); + if (!kdpy->resources) { + kms_display_destroy(&kdpy->base); + return NULL; + } + + kdpy->saved_crtcs = + calloc(kdpy->resources->count_crtcs, sizeof(*kdpy->saved_crtcs)); + if (!kdpy->saved_crtcs) { + kms_display_destroy(&kdpy->base); + return NULL; + } + + kdpy->shown_surfaces = + calloc(kdpy->resources->count_crtcs, sizeof(*kdpy->shown_surfaces)); + if (!kdpy->shown_surfaces) { + kms_display_destroy(&kdpy->base); + return NULL; + } + + kdpy->base.destroy = kms_display_destroy; + kdpy->base.get_configs = kms_display_get_configs; + kdpy->base.create_context = kms_display_create_context; + kdpy->base.create_pbuffer_surface = kms_display_create_pbuffer_surface; + + kdpy->base.modeset = &kms_display_modeset; + + return &kdpy->base; +} + +struct native_probe * +native_create_probe(EGLNativeDisplayType dpy) +{ + return NULL; +} + +enum native_probe_result +native_get_probe_result(struct native_probe *nprobe) +{ + return NATIVE_PROBE_UNKNOWN; +} + +/* the api is destroyed with the native display */ +static struct drm_api *drm_api; + +const char * +native_get_name(void) +{ + static char kms_name[32]; + + if (!drm_api) + drm_api = drm_api_create(); + + if (drm_api) + snprintf(kms_name, sizeof(kms_name), "KMS/%s", drm_api->name); + else + snprintf(kms_name, sizeof(kms_name), "KMS"); + + return kms_name; +} + +struct native_display * +native_create_display(EGLNativeDisplayType dpy) +{ + struct native_display *ndpy = NULL; + + if (!drm_api) + drm_api = drm_api_create(); + + if (drm_api) + ndpy = kms_create_display(dpy, drm_api); + + return ndpy; +} diff --git a/src/gallium/state_trackers/egl/kms/native_kms.h b/src/gallium/state_trackers/egl/kms/native_kms.h new file mode 100644 index 0000000000..095186e3cf --- /dev/null +++ b/src/gallium/state_trackers/egl/kms/native_kms.h @@ -0,0 +1,139 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL 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. + */ + +#ifndef _NATIVE_KMS_H_ +#define _NATIVE_KMS_H_ + +#include +#include + +#include "pipe/p_compiler.h" +#include "util/u_format.h" +#include "pipe/p_state.h" +#include "state_tracker/drm_api.h" + +#include "common/native.h" + +enum kms_surface_type { + KMS_SURFACE_TYPE_PBUFFER, + KMS_SURFACE_TYPE_SCANOUT +}; + +struct kms_config; +struct kms_connector; +struct kms_mode; + +struct kms_crtc { + drmModeCrtcPtr crtc; + uint32_t connectors[32]; + int num_connectors; +}; + +struct kms_display { + struct native_display base; + + int fd; + struct drm_api *api; + drmModeResPtr resources; + struct kms_config *config; + + struct kms_connector *connectors; + int num_connectors; + + struct kms_surface **shown_surfaces; + /* save the original settings of the CRTCs */ + struct kms_crtc *saved_crtcs; +}; + +struct kms_framebuffer { + struct pipe_texture *texture; + boolean is_passive; + + uint32_t buffer_id; +}; + +struct kms_surface { + struct native_surface base; + enum kms_surface_type type; + enum pipe_format color_format; + struct kms_display *kdpy; + int width, height; + + struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS]; + unsigned int sequence_number; + struct kms_framebuffer front_fb, back_fb; + + boolean is_shown; + struct kms_crtc current_crtc; +}; + +struct kms_config { + struct native_config base; +}; + +struct kms_connector { + struct native_connector base; + + uint32_t connector_id; + drmModeConnectorPtr connector; + struct kms_mode *kms_modes; + int num_modes; +}; + +struct kms_mode { + struct native_mode base; + drmModeModeInfo mode; +}; + +static INLINE struct kms_display * +kms_display(const struct native_display *ndpy) +{ + return (struct kms_display *) ndpy; +} + +static INLINE struct kms_surface * +kms_surface(const struct native_surface *nsurf) +{ + return (struct kms_surface *) nsurf; +} + +static INLINE struct kms_config * +kms_config(const struct native_config *nconf) +{ + return (struct kms_config *) nconf; +} + +static INLINE struct kms_connector * +kms_connector(const struct native_connector *nconn) +{ + return (struct kms_connector *) nconn; +} + +static INLINE struct kms_mode * +kms_mode(const struct native_mode *nmode) +{ + return (struct kms_mode *) nmode; +} + +#endif /* _NATIVE_KMS_H_ */ diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c new file mode 100644 index 0000000000..07f82d878c --- /dev/null +++ b/src/gallium/state_trackers/egl/x11/native_dri2.c @@ -0,0 +1,705 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL 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. + */ + +#include "util/u_memory.h" +#include "util/u_math.h" +#include "util/u_format.h" +#include "pipe/p_compiler.h" +#include "pipe/p_screen.h" +#include "pipe/p_context.h" +#include "pipe/p_state.h" +#include "state_tracker/drm_api.h" +#include "egllog.h" + +#include "native_x11.h" +#include "x11_screen.h" + +enum dri2_surface_type { + DRI2_SURFACE_TYPE_WINDOW, + DRI2_SURFACE_TYPE_PIXMAP, + DRI2_SURFACE_TYPE_PBUFFER +}; + +struct dri2_display { + struct native_display base; + Display *dpy; + boolean own_dpy; + + struct drm_api *api; + struct x11_screen *xscr; + int xscr_number; + + struct dri2_config *configs; + int num_configs; +}; + +struct dri2_surface { + struct native_surface base; + Drawable drawable; + enum dri2_surface_type type; + enum pipe_format color_format; + struct dri2_display *dri2dpy; + + struct pipe_texture *pbuffer_textures[NUM_NATIVE_ATTACHMENTS]; + boolean have_back, have_fake; + int width, height; + unsigned int sequence_number; +}; + +struct dri2_config { + struct native_config base; +}; + +static INLINE struct dri2_display * +dri2_display(const struct native_display *ndpy) +{ + return (struct dri2_display *) ndpy; +} + +static INLINE struct dri2_surface * +dri2_surface(const struct native_surface *nsurf) +{ + return (struct dri2_surface *) nsurf; +} + +static INLINE struct dri2_config * +dri2_config(const struct native_config *nconf) +{ + return (struct dri2_config *) nconf; +} + +static boolean +dri2_surface_flush_frontbuffer(struct native_surface *nsurf) +{ + struct dri2_surface *dri2surf = dri2_surface(nsurf); + struct dri2_display *dri2dpy = dri2surf->dri2dpy; + + /* pbuffer is private */ + if (dri2surf->type == DRI2_SURFACE_TYPE_PBUFFER) + return TRUE; + + /* copy to real front buffer */ + if (dri2surf->have_fake) + x11_drawable_copy_buffers(dri2dpy->xscr, dri2surf->drawable, + 0, 0, dri2surf->width, dri2surf->height, + DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft); + + return TRUE; +} + +static boolean +dri2_surface_swap_buffers(struct native_surface *nsurf) +{ + struct dri2_surface *dri2surf = dri2_surface(nsurf); + struct dri2_display *dri2dpy = dri2surf->dri2dpy; + + /* pbuffer is private */ + if (dri2surf->type == DRI2_SURFACE_TYPE_PBUFFER) + return TRUE; + + /* copy to front buffer */ + if (dri2surf->have_back) + x11_drawable_copy_buffers(dri2dpy->xscr, dri2surf->drawable, + 0, 0, dri2surf->width, dri2surf->height, + DRI2BufferBackLeft, DRI2BufferFrontLeft); + + /* and update fake front buffer */ + if (dri2surf->have_fake) + x11_drawable_copy_buffers(dri2dpy->xscr, dri2surf->drawable, + 0, 0, dri2surf->width, dri2surf->height, + DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft); + + return TRUE; +} + +static boolean +dri2_surface_validate(struct native_surface *nsurf, uint attachment_mask, + unsigned int *seq_num, struct pipe_texture **textures, + int *width, int *height) +{ + struct dri2_surface *dri2surf = dri2_surface(nsurf); + struct dri2_display *dri2dpy = dri2surf->dri2dpy; + unsigned int dri2atts[NUM_NATIVE_ATTACHMENTS]; + struct pipe_texture templ; + struct x11_drawable_buffer *xbufs; + int num_ins, num_outs, att, i; + + if (attachment_mask) { + memset(&templ, 0, sizeof(templ)); + templ.target = PIPE_TEXTURE_2D; + templ.last_level = 0; + templ.width0 = dri2surf->width; + templ.height0 = dri2surf->height; + templ.depth0 = 1; + templ.format = dri2surf->color_format; + templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; + + if (textures) + memset(textures, 0, sizeof(*textures) * NUM_NATIVE_ATTACHMENTS); + } + + /* create textures for pbuffer */ + if (dri2surf->type == DRI2_SURFACE_TYPE_PBUFFER) { + struct pipe_screen *screen = dri2dpy->base.screen; + + for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { + struct pipe_texture *ptex = dri2surf->pbuffer_textures[att]; + + /* delay the allocation */ + if (!native_attachment_mask_test(attachment_mask, att)) + continue; + + if (!ptex) { + ptex = screen->texture_create(screen, &templ); + dri2surf->pbuffer_textures[att] = ptex; + } + + if (textures) + pipe_texture_reference(&textures[att], ptex); + } + + if (seq_num) + *seq_num = dri2surf->sequence_number; + if (width) + *width = dri2surf->width; + if (height) + *height = dri2surf->height; + + return TRUE; + } + + /* prepare the attachments */ + num_ins = 0; + for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { + if (native_attachment_mask_test(attachment_mask, att)) { + unsigned int dri2att; + + switch (att) { + case NATIVE_ATTACHMENT_FRONT_LEFT: + dri2att = DRI2BufferFrontLeft; + break; + case NATIVE_ATTACHMENT_BACK_LEFT: + dri2att = DRI2BufferBackLeft; + break; + case NATIVE_ATTACHMENT_FRONT_RIGHT: + dri2att = DRI2BufferFrontRight; + break; + case NATIVE_ATTACHMENT_BACK_RIGHT: + dri2att = DRI2BufferBackRight; + break; + default: + assert(0); + dri2att = 0; + break; + } + + dri2atts[num_ins] = dri2att; + num_ins++; + } + } + + dri2surf->have_back = FALSE; + dri2surf->have_fake = FALSE; + + /* remember old geometry */ + templ.width0 = dri2surf->width; + templ.height0 = dri2surf->height; + + xbufs = x11_drawable_get_buffers(dri2dpy->xscr, dri2surf->drawable, + &dri2surf->width, &dri2surf->height, + dri2atts, FALSE, num_ins, &num_outs); + if (!xbufs) + return FALSE; + + if (templ.width0 != dri2surf->width || templ.height0 != dri2surf->height) { + /* are there cases where the buffers change and the geometry doesn't? */ + dri2surf->sequence_number++; + + templ.width0 = dri2surf->width; + templ.height0 = dri2surf->height; + } + + for (i = 0; i < num_outs; i++) { + struct x11_drawable_buffer *xbuf = &xbufs[i]; + const char *desc; + enum native_attachment natt; + + switch (xbuf->attachment) { + case DRI2BufferFrontLeft: + natt = NATIVE_ATTACHMENT_FRONT_LEFT; + desc = "DRI2 Front Buffer"; + break; + case DRI2BufferFakeFrontLeft: + natt = NATIVE_ATTACHMENT_FRONT_LEFT; + desc = "DRI2 Fake Front Buffer"; + dri2surf->have_fake = TRUE; + break; + case DRI2BufferBackLeft: + natt = NATIVE_ATTACHMENT_BACK_LEFT; + desc = "DRI2 Back Buffer"; + dri2surf->have_back = TRUE; + break; + default: + desc = NULL; + break; + } + + if (!desc || !native_attachment_mask_test(attachment_mask, natt) || + (textures && textures[natt])) { + if (!desc) + _eglLog(_EGL_WARNING, "unknown buffer %d", xbuf->attachment); + else if (!native_attachment_mask_test(attachment_mask, natt)) + _eglLog(_EGL_WARNING, "unexpected buffer %d", xbuf->attachment); + else + _eglLog(_EGL_WARNING, "both real and fake front buffers are listed"); + continue; + } + + if (textures) { + struct pipe_texture *ptex = + dri2dpy->api->texture_from_shared_handle(dri2dpy->api, + dri2dpy->base.screen, &templ, + desc, xbuf->pitch, xbuf->name); + if (ptex) { + /* the caller owns the textures */ + textures[natt] = ptex; + } + } + } + + free(xbufs); + + if (seq_num) + *seq_num = dri2surf->sequence_number; + if (width) + *width = dri2surf->width; + if (height) + *height = dri2surf->height; + + return TRUE; +} + +static void +dri2_surface_wait(struct native_surface *nsurf) +{ + struct dri2_surface *dri2surf = dri2_surface(nsurf); + struct dri2_display *dri2dpy = dri2surf->dri2dpy; + + if (dri2surf->have_fake) { + x11_drawable_copy_buffers(dri2dpy->xscr, dri2surf->drawable, + 0, 0, dri2surf->width, dri2surf->height, + DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft); + } +} + +static void +dri2_surface_destroy(struct native_surface *nsurf) +{ + struct dri2_surface *dri2surf = dri2_surface(nsurf); + int i; + + for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { + struct pipe_texture *ptex = dri2surf->pbuffer_textures[i]; + pipe_texture_reference(&ptex, NULL); + } + + if (dri2surf->drawable) + x11_drawable_enable_dri2(dri2surf->dri2dpy->xscr, + dri2surf->drawable, FALSE); + free(dri2surf); +} + +static struct dri2_surface * +dri2_display_create_surface(struct native_display *ndpy, + enum dri2_surface_type type, + Drawable drawable, + const struct native_config *nconf) +{ + struct dri2_display *dri2dpy = dri2_display(ndpy); + struct dri2_config *dri2conf = dri2_config(nconf); + struct dri2_surface *dri2surf; + + dri2surf = CALLOC_STRUCT(dri2_surface); + if (!dri2surf) + return NULL; + + if (drawable) + x11_drawable_enable_dri2(dri2dpy->xscr, drawable, TRUE); + + dri2surf->dri2dpy = dri2dpy; + dri2surf->type = type; + dri2surf->drawable = drawable; + dri2surf->color_format = dri2conf->base.color_format; + + dri2surf->base.destroy = dri2_surface_destroy; + dri2surf->base.swap_buffers = dri2_surface_swap_buffers; + dri2surf->base.flush_frontbuffer = dri2_surface_flush_frontbuffer; + dri2surf->base.validate = dri2_surface_validate; + dri2surf->base.wait = dri2_surface_wait; + + return dri2surf; +} + +static struct native_surface * +dri2_display_create_window_surface(struct native_display *ndpy, + EGLNativeWindowType win, + const struct native_config *nconf) +{ + struct dri2_surface *dri2surf; + + dri2surf = dri2_display_create_surface(ndpy, DRI2_SURFACE_TYPE_WINDOW, + (Drawable) win, nconf); + return (dri2surf) ? &dri2surf->base : NULL; +} + +static struct native_surface * +dri2_display_create_pixmap_surface(struct native_display *ndpy, + EGLNativePixmapType pix, + const struct native_config *nconf) +{ + struct dri2_surface *dri2surf; + + dri2surf = dri2_display_create_surface(ndpy, DRI2_SURFACE_TYPE_PIXMAP, + (Drawable) pix, nconf); + return (dri2surf) ? &dri2surf->base : NULL; +} + +static struct native_surface * +dri2_display_create_pbuffer_surface(struct native_display *ndpy, + const struct native_config *nconf, + uint width, uint height) +{ + struct dri2_surface *dri2surf; + + dri2surf = dri2_display_create_surface(ndpy, DRI2_SURFACE_TYPE_PBUFFER, + (Drawable) None, nconf); + if (dri2surf) { + dri2surf->width = width; + dri2surf->height = height; + } + return (dri2surf) ? &dri2surf->base : NULL; +} + +static struct pipe_context * +dri2_display_create_context(struct native_display *ndpy, void *context_private) +{ + struct dri2_display *dri2dpy = dri2_display(ndpy); + struct pipe_context *pctx; + + pctx = dri2dpy->api->create_context(dri2dpy->api, dri2dpy->base.screen); + if (pctx) + pctx->priv = context_private; + return pctx; +} + +static int +choose_color_format(const __GLcontextModes *mode, enum pipe_format formats[32]) +{ + int count = 0; + + switch (mode->rgbBits) { + case 32: + formats[count++] = PIPE_FORMAT_A8R8G8B8_UNORM; + formats[count++] = PIPE_FORMAT_B8G8R8A8_UNORM; + break; + case 24: + formats[count++] = PIPE_FORMAT_X8R8G8B8_UNORM; + formats[count++] = PIPE_FORMAT_B8G8R8X8_UNORM; + formats[count++] = PIPE_FORMAT_A8R8G8B8_UNORM; + formats[count++] = PIPE_FORMAT_B8G8R8A8_UNORM; + break; + case 16: + formats[count++] = PIPE_FORMAT_R5G6B5_UNORM; + break; + default: + break; + } + + return count; +} + +static int +choose_depth_stencil_format(const __GLcontextModes *mode, + enum pipe_format formats[32]) +{ + int count = 0; + + switch (mode->depthBits) { + case 32: + formats[count++] = PIPE_FORMAT_Z32_UNORM; + break; + case 24: + if (mode->stencilBits) { + formats[count++] = PIPE_FORMAT_S8Z24_UNORM; + formats[count++] = PIPE_FORMAT_Z24S8_UNORM; + } + else { + formats[count++] = PIPE_FORMAT_X8Z24_UNORM; + formats[count++] = PIPE_FORMAT_Z24X8_UNORM; + } + break; + case 16: + formats[count++] = PIPE_FORMAT_Z16_UNORM; + break; + default: + break; + } + + return count; +} + +static boolean +is_format_supported(struct pipe_screen *screen, + enum pipe_format fmt, boolean is_color) +{ + return screen->is_format_supported(screen, fmt, PIPE_TEXTURE_2D, + (is_color) ? PIPE_TEXTURE_USAGE_RENDER_TARGET : + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); +} + +static boolean +dri2_display_convert_config(struct native_display *ndpy, + const __GLcontextModes *mode, + struct native_config *nconf) +{ + enum pipe_format formats[32]; + int num_formats, i; + + if (!(mode->renderType & GLX_RGBA_BIT) || !mode->rgbMode) + return FALSE; + + /* skip single-buffered configs */ + if (!mode->doubleBufferMode) + return FALSE; + + nconf->mode = *mode; + nconf->mode.renderType = GLX_RGBA_BIT; + nconf->mode.rgbMode = TRUE; + /* pbuffer is allocated locally and is always supported */ + nconf->mode.drawableType |= GLX_PBUFFER_BIT; + /* the swap method is always copy */ + nconf->mode.swapMethod = GLX_SWAP_COPY_OML; + + /* fix up */ + nconf->mode.rgbBits = + nconf->mode.redBits + nconf->mode.greenBits + + nconf->mode.blueBits + nconf->mode.alphaBits; + if (!(nconf->mode.drawableType & GLX_WINDOW_BIT)) { + nconf->mode.visualID = 0; + nconf->mode.visualType = GLX_NONE; + } + if (!(nconf->mode.drawableType & GLX_PBUFFER_BIT)) { + nconf->mode.bindToTextureRgb = FALSE; + nconf->mode.bindToTextureRgba = FALSE; + } + + nconf->color_format = PIPE_FORMAT_NONE; + nconf->depth_format = PIPE_FORMAT_NONE; + nconf->stencil_format = PIPE_FORMAT_NONE; + + /* choose color format */ + num_formats = choose_color_format(mode, formats); + for (i = 0; i < num_formats; i++) { + if (is_format_supported(ndpy->screen, formats[i], TRUE)) { + nconf->color_format = formats[i]; + break; + } + } + if (nconf->color_format == PIPE_FORMAT_NONE) + return FALSE; + + /* choose depth/stencil format */ + num_formats = choose_depth_stencil_format(mode, formats); + for (i = 0; i < num_formats; i++) { + if (is_format_supported(ndpy->screen, formats[i], FALSE)) { + nconf->depth_format = formats[i]; + nconf->stencil_format = formats[i]; + break; + } + } + if ((nconf->mode.depthBits && nconf->depth_format == PIPE_FORMAT_NONE) || + (nconf->mode.stencilBits && nconf->stencil_format == PIPE_FORMAT_NONE)) + return FALSE; + + return TRUE; +} + +static const struct native_config ** +dri2_display_get_configs(struct native_display *ndpy, int *num_configs) +{ + struct dri2_display *dri2dpy = dri2_display(ndpy); + const struct native_config **configs; + int i; + + /* first time */ + if (!dri2dpy->configs) { + const __GLcontextModes *modes; + int num_modes, count; + + modes = x11_screen_get_glx_configs(dri2dpy->xscr); + if (!modes) + return NULL; + num_modes = x11_context_modes_count(modes); + + dri2dpy->configs = calloc(num_modes, sizeof(*dri2dpy->configs)); + if (!dri2dpy->configs) + return NULL; + + count = 0; + for (i = 0; i < num_modes; i++) { + struct native_config *nconf = &dri2dpy->configs[count].base; + if (dri2_display_convert_config(&dri2dpy->base, modes, nconf)) + count++; + modes = modes->next; + } + + dri2dpy->num_configs = count; + } + + configs = malloc(dri2dpy->num_configs * sizeof(*configs)); + if (configs) { + for (i = 0; i < dri2dpy->num_configs; i++) + configs[i] = (const struct native_config *) &dri2dpy->configs[i]; + if (num_configs) + *num_configs = dri2dpy->num_configs; + } + + return configs; +} + +static boolean +dri2_display_is_pixmap_supported(struct native_display *ndpy, + EGLNativePixmapType pix, + const struct native_config *nconf) +{ + struct dri2_display *dri2dpy = dri2_display(ndpy); + uint depth, nconf_depth; + + depth = x11_drawable_get_depth(dri2dpy->xscr, (Drawable) pix); + nconf_depth = util_format_get_blocksizebits(nconf->color_format); + + /* simple depth match for now */ + return (depth == nconf_depth || (depth == 24 && depth + 8 == nconf_depth)); +} + +static void +dri2_display_destroy(struct native_display *ndpy) +{ + struct dri2_display *dri2dpy = dri2_display(ndpy); + + if (dri2dpy->configs) + free(dri2dpy->configs); + + if (dri2dpy->base.screen) + dri2dpy->base.screen->destroy(dri2dpy->base.screen); + + if (dri2dpy->xscr) + x11_screen_destroy(dri2dpy->xscr); + if (dri2dpy->own_dpy) + XCloseDisplay(dri2dpy->dpy); + if (dri2dpy->api && dri2dpy->api->destroy) + dri2dpy->api->destroy(dri2dpy->api); + free(dri2dpy); +} + +/** + * Initialize DRI2 and pipe screen. + */ +static boolean +dri2_display_init_screen(struct native_display *ndpy) +{ + struct dri2_display *dri2dpy = dri2_display(ndpy); + const char *driver = dri2dpy->api->name; + struct drm_create_screen_arg arg; + int fd; + + if (!x11_screen_support(dri2dpy->xscr, X11_SCREEN_EXTENSION_DRI2) || + !x11_screen_support(dri2dpy->xscr, X11_SCREEN_EXTENSION_GLX)) { + _eglLog(_EGL_WARNING, "GLX/DRI2 is not supported"); + return FALSE; + } + + fd = x11_screen_enable_dri2(dri2dpy->xscr, driver); + if (fd < 0) + return FALSE; + + memset(&arg, 0, sizeof(arg)); + arg.mode = DRM_CREATE_NORMAL; + dri2dpy->base.screen = dri2dpy->api->create_screen(dri2dpy->api, fd, &arg); + if (!dri2dpy->base.screen) { + _eglLog(_EGL_WARNING, "failed to create DRM screen"); + return FALSE; + } + + return TRUE; +} + +struct native_display * +x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api) +{ + struct dri2_display *dri2dpy; + + dri2dpy = CALLOC_STRUCT(dri2_display); + if (!dri2dpy) + return NULL; + + dri2dpy->api = api; + if (!dri2dpy->api) { + _eglLog(_EGL_WARNING, "failed to create DRM API"); + free(dri2dpy); + return NULL; + } + + dri2dpy->dpy = dpy; + if (!dri2dpy->dpy) { + dri2dpy->dpy = XOpenDisplay(NULL); + if (!dri2dpy->dpy) { + dri2_display_destroy(&dri2dpy->base); + return NULL; + } + dri2dpy->own_dpy = TRUE; + } + + dri2dpy->xscr_number = DefaultScreen(dri2dpy->dpy); + dri2dpy->xscr = x11_screen_create(dri2dpy->dpy, dri2dpy->xscr_number); + if (!dri2dpy->xscr) { + dri2_display_destroy(&dri2dpy->base); + return NULL; + } + + if (!dri2_display_init_screen(&dri2dpy->base)) { + dri2_display_destroy(&dri2dpy->base); + return NULL; + } + + dri2dpy->base.destroy = dri2_display_destroy; + dri2dpy->base.get_configs = dri2_display_get_configs; + dri2dpy->base.is_pixmap_supported = dri2_display_is_pixmap_supported; + dri2dpy->base.create_context = dri2_display_create_context; + dri2dpy->base.create_window_surface = dri2_display_create_window_surface; + dri2dpy->base.create_pixmap_surface = dri2_display_create_pixmap_surface; + dri2dpy->base.create_pbuffer_surface = dri2_display_create_pbuffer_surface; + + return &dri2dpy->base; +} diff --git a/src/gallium/state_trackers/egl/x11/native_x11.c b/src/gallium/state_trackers/egl/x11/native_x11.c new file mode 100644 index 0000000000..695ab88010 --- /dev/null +++ b/src/gallium/state_trackers/egl/x11/native_x11.c @@ -0,0 +1,148 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL 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. + */ + +#include +#include "util/u_debug.h" +#include "util/u_memory.h" +#include "state_tracker/drm_api.h" +#include "egllog.h" + +#include "native_x11.h" +#include "x11_screen.h" + +#define X11_PROBE_MAGIC 0x11980BE /* "X11PROBE" */ + +static struct drm_api *api; + +static void +x11_probe_destroy(struct native_probe *nprobe) +{ + if (nprobe->data) + free(nprobe->data); + free(nprobe); +} + +struct native_probe * +native_create_probe(EGLNativeDisplayType dpy) +{ + struct native_probe *nprobe; + struct x11_screen *xscr; + int scr; + const char *driver_name = NULL; + Display *xdpy; + + nprobe = CALLOC_STRUCT(native_probe); + if (!nprobe) + return NULL; + + xdpy = dpy; + if (!xdpy) { + xdpy = XOpenDisplay(NULL); + if (!xdpy) { + free(nprobe); + return NULL; + } + } + + scr = DefaultScreen(xdpy); + xscr = x11_screen_create(xdpy, scr); + if (xscr) { + if (x11_screen_support(xscr, X11_SCREEN_EXTENSION_DRI2)) { + driver_name = x11_screen_probe_dri2(xscr); + nprobe->data = strdup(driver_name); + } + + x11_screen_destroy(xscr); + } + + if (xdpy != dpy) + XCloseDisplay(xdpy); + + nprobe->magic = X11_PROBE_MAGIC; + nprobe->display = dpy; + + nprobe->destroy = x11_probe_destroy; + + return nprobe; +} + +enum native_probe_result +native_get_probe_result(struct native_probe *nprobe) +{ + if (!nprobe || nprobe->magic != X11_PROBE_MAGIC) + return NATIVE_PROBE_UNKNOWN; + + if (!api) + api = drm_api_create(); + + /* this is a software driver */ + if (!api) + return NATIVE_PROBE_SUPPORTED; + + /* the display does not support DRI2 or the driver mismatches */ + if (!nprobe->data || strcmp(api->name, (const char *) nprobe->data) != 0) + return NATIVE_PROBE_FALLBACK; + + return NATIVE_PROBE_EXACT; +} + +const char * +native_get_name(void) +{ + static char x11_name[32]; + + if (!api) + api = drm_api_create(); + + if (api) + snprintf(x11_name, sizeof(x11_name), "X11/%s", api->name); + else + snprintf(x11_name, sizeof(x11_name), "X11"); + + return x11_name; +} + +struct native_display * +native_create_display(EGLNativeDisplayType dpy) +{ + struct native_display *ndpy = NULL; + boolean force_sw; + + if (!api) + api = drm_api_create(); + + force_sw = debug_get_bool_option("EGL_SOFTWARE", FALSE); + if (api && !force_sw) { + ndpy = x11_create_dri2_display(dpy, api); + } + + if (!ndpy) { + EGLint level = (force_sw) ? _EGL_INFO : _EGL_WARNING; + + _eglLog(level, "use software fallback"); + ndpy = x11_create_ximage_display(dpy, TRUE); + } + + return ndpy; +} diff --git a/src/gallium/state_trackers/egl/x11/native_x11.h b/src/gallium/state_trackers/egl/x11/native_x11.h new file mode 100644 index 0000000000..622ddac5df --- /dev/null +++ b/src/gallium/state_trackers/egl/x11/native_x11.h @@ -0,0 +1,37 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL 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. + */ + +#ifndef _NATIVE_X11_H_ +#define _NATIVE_X11_H_ + +#include "state_tracker/drm_api.h" +#include "common/native.h" + +struct native_display * +x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm); + +struct native_display * +x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api); + +#endif /* _NATIVE_X11_H_ */ diff --git a/src/gallium/state_trackers/egl/x11/native_ximage.c b/src/gallium/state_trackers/egl/x11/native_ximage.c new file mode 100644 index 0000000000..dfa8df2223 --- /dev/null +++ b/src/gallium/state_trackers/egl/x11/native_ximage.c @@ -0,0 +1,694 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "util/u_memory.h" +#include "util/u_math.h" +#include "util/u_format.h" +#include "pipe/p_compiler.h" +#include "pipe/internal/p_winsys_screen.h" +#include "softpipe/sp_winsys.h" +#include "egllog.h" + +#include "sw_winsys.h" +#include "native_x11.h" +#include "x11_screen.h" + +enum ximage_surface_type { + XIMAGE_SURFACE_TYPE_WINDOW, + XIMAGE_SURFACE_TYPE_PIXMAP, + XIMAGE_SURFACE_TYPE_PBUFFER +}; + +struct ximage_display { + struct native_display base; + Display *dpy; + boolean own_dpy; + + struct x11_screen *xscr; + int xscr_number; + + boolean use_xshm; + + struct pipe_winsys *winsys; + struct ximage_config *configs; + int num_configs; +}; + +struct ximage_buffer { + XImage *ximage; + + struct pipe_texture *texture; + XShmSegmentInfo *shm_info; + boolean xshm_attached; +}; + +struct ximage_surface { + struct native_surface base; + Drawable drawable; + enum ximage_surface_type type; + enum pipe_format color_format; + XVisualInfo visual; + struct ximage_display *xdpy; + + int width, height; + GC gc; + + struct ximage_buffer buffers[NUM_NATIVE_ATTACHMENTS]; + unsigned int sequence_number; +}; + +struct ximage_config { + struct native_config base; + const XVisualInfo *visual; +}; + +static INLINE struct ximage_display * +ximage_display(const struct native_display *ndpy) +{ + return (struct ximage_display *) ndpy; +} + +static INLINE struct ximage_surface * +ximage_surface(const struct native_surface *nsurf) +{ + return (struct ximage_surface *) nsurf; +} + +static INLINE struct ximage_config * +ximage_config(const struct native_config *nconf) +{ + return (struct ximage_config *) nconf; +} + +static void +ximage_surface_free_buffer(struct native_surface *nsurf, + enum native_attachment which) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + struct ximage_buffer *xbuf = &xsurf->buffers[which]; + + pipe_texture_reference(&xbuf->texture, NULL); + + if (xbuf->shm_info) { + if (xbuf->xshm_attached) + XShmDetach(xsurf->xdpy->dpy, xbuf->shm_info); + if (xbuf->shm_info->shmaddr != (void *) -1) + shmdt(xbuf->shm_info->shmaddr); + if (xbuf->shm_info->shmid != -1) + shmctl(xbuf->shm_info->shmid, IPC_RMID, 0); + + xbuf->shm_info->shmaddr = (void *) -1; + xbuf->shm_info->shmid = -1; + } +} + +static boolean +ximage_surface_alloc_buffer(struct native_surface *nsurf, + enum native_attachment which) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + struct ximage_buffer *xbuf = &xsurf->buffers[which]; + struct pipe_screen *screen = xsurf->xdpy->base.screen; + struct pipe_texture templ; + + /* free old data */ + if (xbuf->texture) + ximage_surface_free_buffer(&xsurf->base, which); + + memset(&templ, 0, sizeof(templ)); + templ.target = PIPE_TEXTURE_2D; + templ.format = xsurf->color_format; + templ.width0 = xsurf->width; + templ.height0 = xsurf->height; + templ.depth0 = 1; + templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; + + if (xbuf->shm_info) { + struct pipe_buffer *pbuf; + unsigned stride, size; + void *addr = NULL; + + stride = util_format_get_stride(xsurf->color_format, xsurf->width); + /* alignment should depend on visual? */ + stride = align(stride, 4); + size = stride * xsurf->height; + + /* create and attach shm object */ + xbuf->shm_info->shmid = shmget(IPC_PRIVATE, size, 0755); + if (xbuf->shm_info->shmid != -1) { + xbuf->shm_info->shmaddr = + shmat(xbuf->shm_info->shmid, NULL, 0); + if (xbuf->shm_info->shmaddr != (void *) -1) { + if (XShmAttach(xsurf->xdpy->dpy, xbuf->shm_info)) { + addr = xbuf->shm_info->shmaddr; + xbuf->xshm_attached = TRUE; + } + } + } + + if (addr) { + pbuf = screen->user_buffer_create(screen, addr, size); + if (pbuf) { + xbuf->texture = + screen->texture_blanket(screen, &templ, &stride, pbuf); + pipe_buffer_reference(&pbuf, NULL); + } + } + } + else { + xbuf->texture = screen->texture_create(screen, &templ); + } + + /* clean up the buffer if allocation failed */ + if (!xbuf->texture) + ximage_surface_free_buffer(&xsurf->base, which); + + return (xbuf->texture != NULL); +} + +static boolean +ximage_surface_draw_buffer(struct native_surface *nsurf, + enum native_attachment which) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + struct ximage_buffer *xbuf = &xsurf->buffers[which]; + struct pipe_screen *screen = xsurf->xdpy->base.screen; + struct pipe_transfer *transfer; + + if (xsurf->type == XIMAGE_SURFACE_TYPE_PBUFFER) + return TRUE; + + assert(xsurf->drawable && xbuf->ximage && xbuf->texture); + + transfer = screen->get_tex_transfer(screen, xbuf->texture, + 0, 0, 0, PIPE_TRANSFER_READ, 0, 0, xsurf->width, xsurf->height); + if (!transfer) + return FALSE; + + xbuf->ximage->bytes_per_line = transfer->stride; + xbuf->ximage->data = screen->transfer_map(screen, transfer); + if (!xbuf->ximage->data) { + screen->tex_transfer_destroy(transfer); + return FALSE; + } + + + if (xbuf->shm_info) + XShmPutImage(xsurf->xdpy->dpy, xsurf->drawable, xsurf->gc, + xbuf->ximage, 0, 0, 0, 0, xsurf->width, xsurf->height, False); + else + XPutImage(xsurf->xdpy->dpy, xsurf->drawable, xsurf->gc, + xbuf->ximage, 0, 0, 0, 0, xsurf->width, xsurf->height); + + xbuf->ximage->data = NULL; + screen->transfer_unmap(screen, transfer); + + /* + * softpipe allows the pipe transfer to be re-used, but we don't want to + * rely on that behavior. + */ + screen->tex_transfer_destroy(transfer); + + XSync(xsurf->xdpy->dpy, FALSE); + + return TRUE; +} + +static boolean +ximage_surface_flush_frontbuffer(struct native_surface *nsurf) +{ + return ximage_surface_draw_buffer(nsurf, NATIVE_ATTACHMENT_FRONT_LEFT); +} + +static boolean +ximage_surface_swap_buffers(struct native_surface *nsurf) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + struct ximage_buffer *xfront, *xback, xtmp; + + xfront = &xsurf->buffers[NATIVE_ATTACHMENT_FRONT_LEFT]; + xback = &xsurf->buffers[NATIVE_ATTACHMENT_BACK_LEFT]; + + /* draw the back buffer directly if there is no front buffer */ + if (!xfront->texture) + return ximage_surface_draw_buffer(nsurf, NATIVE_ATTACHMENT_BACK_LEFT); + + /* swap the buffers */ + xtmp = *xfront; + *xfront = *xback; + *xback = xtmp; + + /* the front/back textures are swapped */ + xsurf->sequence_number++; + + return ximage_surface_draw_buffer(nsurf, NATIVE_ATTACHMENT_FRONT_LEFT); +} + +static void +ximage_surface_update_geometry(struct native_surface *nsurf) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + Status ok; + Window root; + int x, y; + unsigned int w, h, border, depth; + + /* pbuffer has fixed geometry */ + if (xsurf->type == XIMAGE_SURFACE_TYPE_PBUFFER) + return; + + ok = XGetGeometry(xsurf->xdpy->dpy, xsurf->drawable, + &root, &x, &y, &w, &h, &border, &depth); + if (ok) { + xsurf->width = w; + xsurf->height = h; + } +} + +static boolean +ximage_surface_validate(struct native_surface *nsurf, uint attachment_mask, + unsigned int *seq_num, struct pipe_texture **textures, + int *width, int *height) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + boolean new_buffers = FALSE; + int att; + + ximage_surface_update_geometry(&xsurf->base); + + for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { + struct ximage_buffer *xbuf = &xsurf->buffers[att]; + + /* delay the allocation */ + if (!native_attachment_mask_test(attachment_mask, att)) + continue; + + /* reallocate the texture */ + if (!xbuf->texture || + xsurf->width != xbuf->texture->width0 || + xsurf->height != xbuf->texture->height0) { + new_buffers = TRUE; + if (ximage_surface_alloc_buffer(&xsurf->base, att)) { + /* update ximage */ + if (xbuf->ximage) { + xbuf->ximage->width = xsurf->width; + xbuf->ximage->height = xsurf->height; + } + } + } + + if (textures) { + textures[att] = NULL; + pipe_texture_reference(&textures[att], xbuf->texture); + } + } + + /* increase the sequence number so that caller knows */ + if (new_buffers) + xsurf->sequence_number++; + + if (seq_num) + *seq_num = xsurf->sequence_number; + if (width) + *width = xsurf->width; + if (height) + *height = xsurf->height; + + return TRUE; +} + +static void +ximage_surface_wait(struct native_surface *nsurf) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + XSync(xsurf->xdpy->dpy, FALSE); + /* TODO XGetImage and update the front texture */ +} + +static void +ximage_surface_destroy(struct native_surface *nsurf) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + int i; + + for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { + struct ximage_buffer *xbuf = &xsurf->buffers[i]; + ximage_surface_free_buffer(&xsurf->base, i); + /* xbuf->shm_info is owned by xbuf->ximage? */ + if (xbuf->ximage) { + XDestroyImage(xbuf->ximage); + xbuf->ximage = NULL; + } + } + + if (xsurf->type != XIMAGE_SURFACE_TYPE_PBUFFER) + XFreeGC(xsurf->xdpy->dpy, xsurf->gc); + free(xsurf); +} + +static struct ximage_surface * +ximage_display_create_surface(struct native_display *ndpy, + enum ximage_surface_type type, + Drawable drawable, + const struct native_config *nconf) +{ + struct ximage_display *xdpy = ximage_display(ndpy); + struct ximage_config *xconf = ximage_config(nconf); + struct ximage_surface *xsurf; + int i; + + xsurf = CALLOC_STRUCT(ximage_surface); + if (!xsurf) + return NULL; + + xsurf->xdpy = xdpy; + xsurf->type = type; + xsurf->color_format = xconf->base.color_format; + xsurf->drawable = drawable; + + if (xsurf->type != XIMAGE_SURFACE_TYPE_PBUFFER) { + xsurf->drawable = drawable; + xsurf->visual = *xconf->visual; + + xsurf->gc = XCreateGC(xdpy->dpy, xsurf->drawable, 0, NULL); + if (!xsurf->gc) { + free(xsurf); + return NULL; + } + + for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { + struct ximage_buffer *xbuf = &xsurf->buffers[i]; + + if (xdpy->use_xshm) { + xbuf->shm_info = calloc(1, sizeof(*xbuf->shm_info)); + if (xbuf->shm_info) { + /* initialize shm info */ + xbuf->shm_info->shmid = -1; + xbuf->shm_info->shmaddr = (void *) -1; + xbuf->shm_info->readOnly = TRUE; + + xbuf->ximage = XShmCreateImage(xsurf->xdpy->dpy, + xsurf->visual.visual, + xsurf->visual.depth, + ZPixmap, NULL, + xbuf->shm_info, + 0, 0); + } + } + else { + xbuf->ximage = XCreateImage(xsurf->xdpy->dpy, + xsurf->visual.visual, + xsurf->visual.depth, + ZPixmap, 0, /* format, offset */ + NULL, /* data */ + 0, 0, /* size */ + 8, /* bitmap_pad */ + 0); /* bytes_per_line */ + } + + if (!xbuf->ximage) { + XFreeGC(xdpy->dpy, xsurf->gc); + free(xsurf); + return NULL; + } + } + } + + xsurf->base.destroy = ximage_surface_destroy; + xsurf->base.swap_buffers = ximage_surface_swap_buffers; + xsurf->base.flush_frontbuffer = ximage_surface_flush_frontbuffer; + xsurf->base.validate = ximage_surface_validate; + xsurf->base.wait = ximage_surface_wait; + + return xsurf; +} + +static struct native_surface * +ximage_display_create_window_surface(struct native_display *ndpy, + EGLNativeWindowType win, + const struct native_config *nconf) +{ + struct ximage_surface *xsurf; + + xsurf = ximage_display_create_surface(ndpy, XIMAGE_SURFACE_TYPE_WINDOW, + (Drawable) win, nconf); + return (xsurf) ? &xsurf->base : NULL; +} + +static struct native_surface * +ximage_display_create_pixmap_surface(struct native_display *ndpy, + EGLNativePixmapType pix, + const struct native_config *nconf) +{ + struct ximage_surface *xsurf; + + xsurf = ximage_display_create_surface(ndpy, XIMAGE_SURFACE_TYPE_PIXMAP, + (Drawable) pix, nconf); + return (xsurf) ? &xsurf->base : NULL; +} + +static struct native_surface * +ximage_display_create_pbuffer_surface(struct native_display *ndpy, + const struct native_config *nconf, + uint width, uint height) +{ + struct ximage_surface *xsurf; + + xsurf = ximage_display_create_surface(ndpy, XIMAGE_SURFACE_TYPE_PBUFFER, + (Drawable) None, nconf); + if (xsurf) { + xsurf->width = width; + xsurf->height = height; + } + return (xsurf) ? &xsurf->base : NULL; +} + +static struct pipe_context * +ximage_display_create_context(struct native_display *ndpy, + void *context_private) +{ + struct pipe_context *pctx = softpipe_create(ndpy->screen); + if (pctx) + pctx->priv = context_private; + return pctx; +} + +static enum pipe_format +choose_format(const XVisualInfo *vinfo) +{ + enum pipe_format fmt; + /* TODO elaborate the formats */ + switch (vinfo->depth) { + case 32: + fmt = PIPE_FORMAT_A8R8G8B8_UNORM; + break; + case 24: + fmt = PIPE_FORMAT_X8R8G8B8_UNORM; + break; + case 16: + fmt = PIPE_FORMAT_R5G6B5_UNORM; + break; + default: + fmt = PIPE_FORMAT_NONE; + break; + } + + return fmt; +} + +static const struct native_config ** +ximage_display_get_configs(struct native_display *ndpy, int *num_configs) +{ + struct ximage_display *xdpy = ximage_display(ndpy); + const struct native_config **configs; + int i; + + /* first time */ + if (!xdpy->configs) { + const XVisualInfo *visuals; + int num_visuals, count, j; + + visuals = x11_screen_get_visuals(xdpy->xscr, &num_visuals); + if (!visuals) + return NULL; + + /* + * Create two configs for each visual. + * One with depth/stencil buffer; one without + */ + xdpy->configs = calloc(num_visuals * 2, sizeof(*xdpy->configs)); + if (!xdpy->configs) + return NULL; + + count = 0; + for (i = 0; i < num_visuals; i++) { + for (j = 0; j < 2; j++) { + struct ximage_config *xconf = &xdpy->configs[count]; + __GLcontextModes *mode = &xconf->base.mode; + + xconf->visual = &visuals[i]; + xconf->base.color_format = choose_format(xconf->visual); + if (xconf->base.color_format == PIPE_FORMAT_NONE) + continue; + + x11_screen_convert_visual(xdpy->xscr, xconf->visual, mode); + /* support double buffer mode */ + mode->doubleBufferMode = TRUE; + + xconf->base.depth_format = PIPE_FORMAT_NONE; + xconf->base.stencil_format = PIPE_FORMAT_NONE; + /* create the second config with depth/stencil buffer */ + if (j == 1) { + xconf->base.depth_format = PIPE_FORMAT_S8Z24_UNORM; + xconf->base.stencil_format = PIPE_FORMAT_S8Z24_UNORM; + mode->depthBits = 24; + mode->stencilBits = 8; + mode->haveDepthBuffer = TRUE; + mode->haveStencilBuffer = TRUE; + } + + mode->maxPbufferWidth = 4096; + mode->maxPbufferHeight = 4096; + mode->maxPbufferPixels = 4096 * 4096; + mode->drawableType = + GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT; + mode->swapMethod = GLX_SWAP_EXCHANGE_OML; + + if (mode->alphaBits) + mode->bindToTextureRgba = TRUE; + else + mode->bindToTextureRgb = TRUE; + + count++; + } + } + + xdpy->num_configs = count; + } + + configs = malloc(xdpy->num_configs * sizeof(*configs)); + if (configs) { + for (i = 0; i < xdpy->num_configs; i++) + configs[i] = (const struct native_config *) &xdpy->configs[i]; + if (num_configs) + *num_configs = xdpy->num_configs; + } + return configs; +} + +static boolean +ximage_display_is_pixmap_supported(struct native_display *ndpy, + EGLNativePixmapType pix, + const struct native_config *nconf) +{ + struct ximage_display *xdpy = ximage_display(ndpy); + enum pipe_format fmt; + uint depth; + + depth = x11_drawable_get_depth(xdpy->xscr, (Drawable) pix); + switch (depth) { + case 32: + fmt = PIPE_FORMAT_A8R8G8B8_UNORM; + break; + case 24: + fmt = PIPE_FORMAT_X8R8G8B8_UNORM; + break; + case 16: + fmt = PIPE_FORMAT_R5G6B5_UNORM; + break; + default: + fmt = PIPE_FORMAT_NONE; + break; + } + + return (fmt == nconf->color_format); +} + +static void +ximage_display_destroy(struct native_display *ndpy) +{ + struct ximage_display *xdpy = ximage_display(ndpy); + + if (xdpy->configs) + free(xdpy->configs); + + xdpy->base.screen->destroy(xdpy->base.screen); + free(xdpy->winsys); + + x11_screen_destroy(xdpy->xscr); + if (xdpy->own_dpy) + XCloseDisplay(xdpy->dpy); + free(xdpy); +} + +struct native_display * +x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm) +{ + struct ximage_display *xdpy; + + xdpy = CALLOC_STRUCT(ximage_display); + if (!xdpy) + return NULL; + + xdpy->dpy = dpy; + if (!xdpy->dpy) { + xdpy->dpy = XOpenDisplay(NULL); + if (!xdpy->dpy) { + free(xdpy); + return NULL; + } + xdpy->own_dpy = TRUE; + } + + xdpy->xscr_number = DefaultScreen(xdpy->dpy); + xdpy->xscr = x11_screen_create(xdpy->dpy, xdpy->xscr_number); + if (!xdpy->xscr) { + free(xdpy); + return NULL; + } + + xdpy->use_xshm = + (use_xshm && x11_screen_support(xdpy->xscr, X11_SCREEN_EXTENSION_XSHM)); + + xdpy->winsys = create_sw_winsys(); + xdpy->base.screen = softpipe_create_screen(xdpy->winsys); + + xdpy->base.destroy = ximage_display_destroy; + + xdpy->base.get_configs = ximage_display_get_configs; + xdpy->base.is_pixmap_supported = ximage_display_is_pixmap_supported; + xdpy->base.create_context = ximage_display_create_context; + xdpy->base.create_window_surface = ximage_display_create_window_surface; + xdpy->base.create_pixmap_surface = ximage_display_create_pixmap_surface; + xdpy->base.create_pbuffer_surface = ximage_display_create_pbuffer_surface; + + return &xdpy->base; +} diff --git a/src/gallium/state_trackers/egl/x11/sw_winsys.c b/src/gallium/state_trackers/egl/x11/sw_winsys.c new file mode 100644 index 0000000000..6ee3ede38c --- /dev/null +++ b/src/gallium/state_trackers/egl/x11/sw_winsys.c @@ -0,0 +1,231 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * 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, sub license, 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ + +/** + * Totally software-based winsys layer. + * Note that the one winsys function that we can't implement here + * is flush_frontbuffer(). + * Whoever uses this code will have to provide that. + * + * Authors: Brian Paul + */ + + +#include "pipe/internal/p_winsys_screen.h" +#include "pipe/p_state.h" +#include "pipe/p_inlines.h" +#include "util/u_format.h" +#include "util/u_math.h" +#include "util/u_memory.h" + +#include "sw_winsys.h" + + + +/** Subclass of pipe_winsys */ +struct sw_pipe_winsys +{ + struct pipe_winsys Base; + /* no extra fields for now */ +}; + + +/** subclass of pipe_buffer */ +struct sw_pipe_buffer +{ + struct pipe_buffer Base; + boolean UserBuffer; /** Is this a user-space buffer? */ + void *Data; + void *Mapped; +}; + + +/** cast wrapper */ +static INLINE struct sw_pipe_buffer * +sw_pipe_buffer(struct pipe_buffer *b) +{ + return (struct sw_pipe_buffer *) b; +} + + +static const char * +get_name(struct pipe_winsys *pws) +{ + return "software"; +} + + +/** Create new pipe_buffer and allocate storage of given size */ +static struct pipe_buffer * +buffer_create(struct pipe_winsys *pws, + unsigned alignment, + unsigned usage, + unsigned size) +{ + struct sw_pipe_buffer *buffer = CALLOC_STRUCT(sw_pipe_buffer); + if (!buffer) + return NULL; + + pipe_reference_init(&buffer->Base.reference, 1); + buffer->Base.alignment = alignment; + buffer->Base.usage = usage; + buffer->Base.size = size; + + /* align to 16-byte multiple for Cell */ + buffer->Data = align_malloc(size, MAX2(alignment, 16)); + + return &buffer->Base; +} + + +/** + * Create buffer which wraps user-space data. + */ +static struct pipe_buffer * +user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes) +{ + struct sw_pipe_buffer *buffer = CALLOC_STRUCT(sw_pipe_buffer); + if (!buffer) + return NULL; + + pipe_reference_init(&buffer->Base.reference, 1); + buffer->Base.size = bytes; + buffer->UserBuffer = TRUE; + buffer->Data = ptr; + + return &buffer->Base; +} + + +static void * +buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buf, unsigned flags) +{ + struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); + buffer->Mapped = buffer->Data; + return buffer->Mapped; +} + + +static void +buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf) +{ + struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); + buffer->Mapped = NULL; +} + + +static void +buffer_destroy(struct pipe_buffer *buf) +{ + struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); + + if (buffer->Data && !buffer->UserBuffer) { + align_free(buffer->Data); + buffer->Data = NULL; + } + + free(buffer); +} + + +static struct pipe_buffer * +surface_buffer_create(struct pipe_winsys *winsys, + unsigned width, unsigned height, + enum pipe_format format, + unsigned usage, + unsigned tex_usage, + unsigned *stride) +{ + const unsigned alignment = 64; + unsigned nblocksy; + + nblocksy = util_format_get_nblocksy(format, height); + *stride = align(util_format_get_stride(format, width), alignment); + + return winsys->buffer_create(winsys, alignment, + usage, + *stride * nblocksy); +} + + +static void +fence_reference(struct pipe_winsys *sws, struct pipe_fence_handle **ptr, + struct pipe_fence_handle *fence) +{ + /* no-op */ +} + + +static int +fence_signalled(struct pipe_winsys *sws, struct pipe_fence_handle *fence, + unsigned flag) +{ + /* no-op */ + return 0; +} + + +static int +fence_finish(struct pipe_winsys *sws, struct pipe_fence_handle *fence, + unsigned flag) +{ + /* no-op */ + return 0; +} + + +/** + * Create/return a new pipe_winsys object. + */ +struct pipe_winsys * +create_sw_winsys(void) +{ + struct sw_pipe_winsys *ws = CALLOC_STRUCT(sw_pipe_winsys); + if (!ws) + return NULL; + + /* Fill in this struct with callbacks that pipe will need to + * communicate with the window system, buffer manager, etc. + */ + ws->Base.buffer_create = buffer_create; + ws->Base.user_buffer_create = user_buffer_create; + ws->Base.buffer_map = buffer_map; + ws->Base.buffer_unmap = buffer_unmap; + ws->Base.buffer_destroy = buffer_destroy; + + ws->Base.surface_buffer_create = surface_buffer_create; + + ws->Base.fence_reference = fence_reference; + ws->Base.fence_signalled = fence_signalled; + ws->Base.fence_finish = fence_finish; + + ws->Base.flush_frontbuffer = NULL; /* not implemented here! */ + + ws->Base.get_name = get_name; + + return &ws->Base; +} diff --git a/src/gallium/state_trackers/egl/x11/sw_winsys.h b/src/gallium/state_trackers/egl/x11/sw_winsys.h new file mode 100644 index 0000000000..f96c5a14b0 --- /dev/null +++ b/src/gallium/state_trackers/egl/x11/sw_winsys.h @@ -0,0 +1,40 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * 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, sub license, 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 NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. + * + **************************************************************************/ + + +#ifndef SW_WINSYS_H +#define SW_WINSYS_H + + +struct pipe_winsys; + + +extern struct pipe_winsys * +create_sw_winsys(void); + + +#endif /* SW_WINSYS_H */ diff --git a/src/gallium/state_trackers/egl/x11/x11_screen.c b/src/gallium/state_trackers/egl/x11/x11_screen.c new file mode 100644 index 0000000000..76ce45ee57 --- /dev/null +++ b/src/gallium/state_trackers/egl/x11/x11_screen.c @@ -0,0 +1,453 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL 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. + */ + +#include +#include +#include +#include +#include +#include +#include "util/u_memory.h" +#include "util/u_math.h" +#include "util/u_format.h" +#include "xf86drm.h" +#include "egllog.h" + +#include "x11_screen.h" +#include "dri2.h" +#include "glxinit.h" + +struct x11_screen { + Display *dpy; + int number; + + /* + * This is used to fetch GLX visuals/fbconfigs. It uses code from egl_xdri. + * It might be better to rewrite the part in Xlib or XCB. + */ + __GLXdisplayPrivate *glx_dpy; + + int dri_major, dri_minor; + char *dri_driver; + char *dri_device; + int dri_fd; + + XVisualInfo *visuals; + int num_visuals; + + /* cached values for x11_drawable_get_depth */ + Drawable last_drawable; + unsigned int last_depth; +}; + + +/** + * Create a X11 screen. + */ +struct x11_screen * +x11_screen_create(Display *dpy, int screen) +{ + struct x11_screen *xscr; + + if (screen >= ScreenCount(dpy)) + return NULL; + + xscr = CALLOC_STRUCT(x11_screen); + if (xscr) { + xscr->dpy = dpy; + xscr->number = screen; + + xscr->dri_major = -1; + xscr->dri_fd = -1; + } + return xscr; +} + +/** + * Destroy a X11 screen. + */ +void +x11_screen_destroy(struct x11_screen *xscr) +{ + if (xscr->dri_fd >= 0) + close(xscr->dri_fd); + if (xscr->dri_driver) + Xfree(xscr->dri_driver); + if (xscr->dri_device) + Xfree(xscr->dri_device); + + /* xscr->glx_dpy will be destroyed with the X display */ + + if (xscr->visuals) + XFree(xscr->visuals); + free(xscr); +} + +static boolean +x11_screen_init_dri2(struct x11_screen *xscr) +{ + if (xscr->dri_major < 0) { + int eventBase, errorBase; + + if (!DRI2QueryExtension(xscr->dpy, &eventBase, &errorBase) || + !DRI2QueryVersion(xscr->dpy, &xscr->dri_major, &xscr->dri_minor)) + xscr->dri_major = -1; + } + return (xscr->dri_major >= 0); +} + +static boolean +x11_screen_init_glx(struct x11_screen *xscr) +{ + if (!xscr->glx_dpy) + xscr->glx_dpy = __glXInitialize(xscr->dpy); + return (xscr->glx_dpy != NULL); +} + +/** + * Return true if the screen supports the extension. + */ +boolean +x11_screen_support(struct x11_screen *xscr, enum x11_screen_extension ext) +{ + boolean supported = FALSE; + + switch (ext) { + case X11_SCREEN_EXTENSION_XSHM: + supported = XShmQueryExtension(xscr->dpy); + break; + case X11_SCREEN_EXTENSION_GLX: + supported = x11_screen_init_glx(xscr); + break; + case X11_SCREEN_EXTENSION_DRI2: + supported = x11_screen_init_dri2(xscr); + break; + default: + break; + } + + return supported; +} + +/** + * Return the X visuals. + */ +const XVisualInfo * +x11_screen_get_visuals(struct x11_screen *xscr, int *num_visuals) +{ + if (!xscr->visuals) { + XVisualInfo vinfo_template; + vinfo_template.screen = xscr->number; + xscr->visuals = XGetVisualInfo(xscr->dpy, VisualScreenMask, + &vinfo_template, &xscr->num_visuals); + } + + if (num_visuals) + *num_visuals = xscr->num_visuals; + return xscr->visuals; +} + +void +x11_screen_convert_visual(struct x11_screen *xscr, const XVisualInfo *visual, + __GLcontextModes *mode) +{ + int r, g, b, a; + int visual_type; + + r = util_bitcount(visual->red_mask); + g = util_bitcount(visual->green_mask); + b = util_bitcount(visual->blue_mask); + a = visual->depth - (r + g + b); +#if defined(__cplusplus) || defined(c_plusplus) + visual_type = visual->c_class; +#else + visual_type = visual->class; +#endif + + /* convert to GLX visual type */ + switch (visual_type) { + case TrueColor: + visual_type = GLX_TRUE_COLOR; + break; + case DirectColor: + visual_type = GLX_DIRECT_COLOR; + break; + case PseudoColor: + visual_type = GLX_PSEUDO_COLOR; + break; + case StaticColor: + visual_type = GLX_STATIC_COLOR; + break; + case GrayScale: + visual_type = GLX_GRAY_SCALE; + break; + case StaticGray: + visual_type = GLX_STATIC_GRAY; + break; + default: + visual_type = GLX_NONE; + break; + } + + mode->rgbBits = r + g + b + a; + mode->redBits = r; + mode->greenBits = g; + mode->blueBits = b; + mode->alphaBits = a; + mode->visualID = visual->visualid; + mode->visualType = visual_type; + + /* sane defaults */ + mode->renderType = GLX_RGBA_BIT; + mode->rgbMode = TRUE; + mode->visualRating = GLX_SLOW_CONFIG; + mode->xRenderable = TRUE; +} + +/** + * Return the GLX fbconfigs. + */ +const __GLcontextModes * +x11_screen_get_glx_configs(struct x11_screen *xscr) +{ + return (x11_screen_init_glx(xscr)) + ? xscr->glx_dpy->screenConfigs[xscr->number].configs + : NULL; +} + +/** + * Return the GLX visuals. + */ +const __GLcontextModes * +x11_screen_get_glx_visuals(struct x11_screen *xscr) +{ + return (x11_screen_init_glx(xscr)) + ? xscr->glx_dpy->screenConfigs[xscr->number].visuals + : NULL; +} + +static boolean +x11_screen_is_driver_equal(struct x11_screen *xscr, const char *driver) +{ + return (strcmp(xscr->dri_driver, driver) == 0); +} + +/** + * Probe the screen for the DRI2 driver name. + */ +const char * +x11_screen_probe_dri2(struct x11_screen *xscr) +{ + /* get the driver name and the device name */ + if (!xscr->dri_driver) { + if (!DRI2Connect(xscr->dpy, RootWindow(xscr->dpy, xscr->number), + &xscr->dri_driver, &xscr->dri_device)) + xscr->dri_driver = xscr->dri_device = NULL; + } + + return xscr->dri_driver; +} + +/** + * Enable DRI2 and returns the file descriptor of the DRM device. The file + * descriptor will be closed automatically when the screen is destoryed. + */ +int +x11_screen_enable_dri2(struct x11_screen *xscr, const char *driver) +{ + if (xscr->dri_fd < 0) { + int fd; + drm_magic_t magic; + + /* get the driver name and the device name first */ + if (!x11_screen_probe_dri2(xscr)) + return -1; + + if (!x11_screen_is_driver_equal(xscr, driver)) { + _eglLog(_EGL_WARNING, "Driver mismatch: %s != %s", + xscr->dri_driver, driver); + return -1; + } + + fd = open(xscr->dri_device, O_RDWR); + if (fd < 0) { + _eglLog(_EGL_WARNING, "failed to open %s", xscr->dri_device); + return -1; + } + + memset(&magic, 0, sizeof(magic)); + if (drmGetMagic(fd, &magic)) { + _eglLog(_EGL_WARNING, "failed to get magic"); + close(fd); + return -1; + } + + if (!DRI2Authenticate(xscr->dpy, + RootWindow(xscr->dpy, xscr->number), magic)) { + _eglLog(_EGL_WARNING, "failed to authenticate magic"); + close(fd); + return -1; + } + + xscr->dri_fd = fd; + } + + return xscr->dri_fd; +} + +/** + * Create/Destroy the DRI drawable. + */ +void +x11_drawable_enable_dri2(struct x11_screen *xscr, + Drawable drawable, boolean on) +{ + if (on) + DRI2CreateDrawable(xscr->dpy, drawable); + else + DRI2DestroyDrawable(xscr->dpy, drawable); +} + +/** + * Copy between buffers of the DRI2 drawable. + */ +void +x11_drawable_copy_buffers(struct x11_screen *xscr, Drawable drawable, + int x, int y, int width, int height, + int src_buf, int dst_buf) +{ + XRectangle rect; + XserverRegion region; + + rect.x = x; + rect.y = y; + rect.width = width; + rect.height = height; + + region = XFixesCreateRegion(xscr->dpy, &rect, 1); + DRI2CopyRegion(xscr->dpy, drawable, region, dst_buf, src_buf); + XFixesDestroyRegion(xscr->dpy, region); +} + +/** + * Get the buffers of the DRI2 drawable. The returned array should be freed. + */ +struct x11_drawable_buffer * +x11_drawable_get_buffers(struct x11_screen *xscr, Drawable drawable, + int *width, int *height, unsigned int *attachments, + boolean with_format, int num_ins, int *num_outs) +{ + DRI2Buffer *dri2bufs; + + if (with_format) + dri2bufs = DRI2GetBuffersWithFormat(xscr->dpy, drawable, width, height, + attachments, num_ins, num_outs); + else + dri2bufs = DRI2GetBuffers(xscr->dpy, drawable, width, height, + attachments, num_ins, num_outs); + + return (struct x11_drawable_buffer *) dri2bufs; +} + +/** + * Return the depth of a drawable. + * + * Unlike other drawable functions, the drawable needs not be a DRI2 drawable. + */ +uint +x11_drawable_get_depth(struct x11_screen *xscr, Drawable drawable) +{ + unsigned int depth; + + if (drawable != xscr->last_drawable) { + Window root; + int x, y; + unsigned int w, h, border; + Status ok; + + ok = XGetGeometry(xscr->dpy, drawable, &root, + &x, &y, &w, &h, &border, &depth); + if (!ok) + depth = 0; + + xscr->last_drawable = drawable; + xscr->last_depth = depth; + } + else { + depth = xscr->last_depth; + } + + return depth; +} + +/** + * Create a mode list of the given size. + */ +__GLcontextModes * +x11_context_modes_create(unsigned count) +{ + const size_t size = sizeof(__GLcontextModes); + __GLcontextModes *base = NULL; + __GLcontextModes **next; + unsigned i; + + next = &base; + for (i = 0; i < count; i++) { + *next = (__GLcontextModes *) calloc(1, size); + if (*next == NULL) { + x11_context_modes_destroy(base); + base = NULL; + break; + } + next = &((*next)->next); + } + + return base; +} + +/** + * Destroy a mode list. + */ +void +x11_context_modes_destroy(__GLcontextModes *modes) +{ + while (modes != NULL) { + __GLcontextModes *next = modes->next; + free(modes); + modes = next; + } +} + +/** + * Return the number of the modes in the mode list. + */ +unsigned +x11_context_modes_count(const __GLcontextModes *modes) +{ + const __GLcontextModes *mode; + int count = 0; + for (mode = modes; mode; mode = mode->next) + count++; + return count; +} diff --git a/src/gallium/state_trackers/egl/x11/x11_screen.h b/src/gallium/state_trackers/egl/x11/x11_screen.h new file mode 100644 index 0000000000..5432858ac3 --- /dev/null +++ b/src/gallium/state_trackers/egl/x11/x11_screen.h @@ -0,0 +1,105 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL 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. + */ + +#ifndef _X11_SCREEN_H_ +#define _X11_SCREEN_H_ + +#include +#include +#include +#include "pipe/p_compiler.h" +#include "common/native.h" + +enum x11_screen_extension { + X11_SCREEN_EXTENSION_XSHM, + X11_SCREEN_EXTENSION_GLX, + X11_SCREEN_EXTENSION_DRI2, +}; + +/* the same as DRI2Buffer */ +struct x11_drawable_buffer { + unsigned int attachment; + unsigned int name; + unsigned int pitch; + unsigned int cpp; + unsigned int flags; +}; + +struct x11_screen; + +struct x11_screen * +x11_screen_create(Display *dpy, int screen); + +void +x11_screen_destroy(struct x11_screen *xscr); + +boolean +x11_screen_support(struct x11_screen *xscr, enum x11_screen_extension ext); + +const XVisualInfo * +x11_screen_get_visuals(struct x11_screen *xscr, int *num_visuals); + +void +x11_screen_convert_visual(struct x11_screen *xscr, const XVisualInfo *visual, + __GLcontextModes *mode); + +const __GLcontextModes * +x11_screen_get_glx_configs(struct x11_screen *xscr); + +const __GLcontextModes * +x11_screen_get_glx_visuals(struct x11_screen *xscr); + +const char * +x11_screen_probe_dri2(struct x11_screen *xscr); + +int +x11_screen_enable_dri2(struct x11_screen *xscr, const char *driver); + +__GLcontextModes * +x11_context_modes_create(unsigned count); + +void +x11_context_modes_destroy(__GLcontextModes *modes); + +unsigned +x11_context_modes_count(const __GLcontextModes *modes); + +void +x11_drawable_enable_dri2(struct x11_screen *xscr, + Drawable drawable, boolean on); + +void +x11_drawable_copy_buffers(struct x11_screen *xscr, Drawable drawable, + int x, int y, int width, int height, + int src_buf, int dst_buf); + +struct x11_drawable_buffer * +x11_drawable_get_buffers(struct x11_screen *xscr, Drawable drawable, + int *width, int *height, unsigned int *attachments, + boolean with_format, int num_ins, int *num_outs); + +uint +x11_drawable_get_depth(struct x11_screen *xscr, Drawable drawable); + +#endif /* _X11_SCREEN_H_ */ diff --git a/src/gallium/state_trackers/egl_g3d/Makefile b/src/gallium/state_trackers/egl_g3d/Makefile deleted file mode 100644 index b696f2fae9..0000000000 --- a/src/gallium/state_trackers/egl_g3d/Makefile +++ /dev/null @@ -1,75 +0,0 @@ -TOP = ../../../.. -include $(TOP)/configs/current - -common_INCLUDES = \ - -I. \ - -I$(TOP)/src/gallium/include \ - -I$(TOP)/src/gallium/auxiliary \ - -I$(TOP)/src/egl/main \ - -I$(TOP)/include - -common_SOURCES = $(wildcard common/*.c) -common_OBJECTS = $(common_SOURCES:.c=.o) - - -x11_INCLUDES = \ - -I$(TOP)/src/gallium/drivers \ - -I$(TOP)/src/glx/x11 \ - -I$(TOP)/src/egl/drivers/xdri \ - -I$(TOP)/src/mesa \ - $(shell pkg-config --cflags-only-I libdrm) - -x11_SOURCES = $(wildcard x11/*.c) \ - $(TOP)/src/glx/x11/dri2.c \ - $(TOP)/src/egl/drivers/xdri/glxinit.c -x11_OBJECTS = $(x11_SOURCES:.c=.o) - - -kms_INCLUDES = $(shell pkg-config --cflags-only-I libdrm) -kms_SOURCES = $(wildcard kms/*.c) -kms_OBJECTS = $(kms_SOURCES:.c=.o) - - -ALL_INCLUDES = $(common_INCLUDES) $(x11_INCLUDES) $(kms_INCLUDES) -ALL_SOURCES = $(common_SOURCES) $(x11_SOURCES) $(kms_SOURCES) -ALL_OBJECTS = $(common_OBJECTS) $(x11_OBJECTS) $(kms_OBJECTS) - -##### TARGETS ##### - -EGL_DISPLAYS_MODS = $(foreach dpy, $(EGL_DISPLAYS), libegl$(dpy).a) - -default: depend $(EGL_DISPLAYS_MODS) - - -libeglx11.a: $(x11_OBJECTS) $(common_OBJECTS) Makefile - $(MKLIB) -o eglx11 -static $(x11_OBJECTS) $(common_OBJECTS) - -libeglkms.a: $(kms_OBJECTS) $(common_OBJECTS) Makefile - $(MKLIB) -o eglkms -static $(kms_OBJECTS) $(common_OBJECTS) - -depend: - rm -f depend - touch depend - $(MKDEP) $(MKDEP_OPTIONS) $(ALL_INCLUDES) $(ALL_SOURCES) 2> /dev/null - -clean: - rm -f $(ALL_OBJECTS) - rm -f $(EGL_DISPLAYS_MODS) - rm -f depend depend.bak - -# Dummy target -install: - @echo -n "" - -##### RULES ##### - -$(common_OBJECTS): %.o: %.c - $(CC) -c $(common_INCLUDES) $(DEFINES) $(CFLAGS) $< -o $@ - -$(x11_OBJECTS): %.o: %.c - $(CC) -c $(common_INCLUDES) $(x11_INCLUDES) $(DEFINES) $(CFLAGS) $< -o $@ - -$(kms_OBJECTS): %.o: %.c - $(CC) -c $(common_INCLUDES) $(kms_INCLUDES) $(DEFINES) $(CFLAGS) $< -o $@ - -sinclude depend diff --git a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c deleted file mode 100644 index 2ac6215646..0000000000 --- a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.c +++ /dev/null @@ -1,1336 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009-2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL 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. - */ - -#include -#include -#include "pipe/p_screen.h" -#include "util/u_memory.h" -#include "util/u_rect.h" -#include "egldriver.h" -#include "eglcurrent.h" -#include "eglconfigutil.h" -#include "egllog.h" - -#include "native.h" -#include "egl_g3d.h" -#include "egl_st.h" - -/** - * Validate the draw/read surfaces of the context. - */ -static void -egl_g3d_validate_context(_EGLDisplay *dpy, _EGLContext *ctx) -{ - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - struct pipe_screen *screen = gdpy->native->screen; - struct egl_g3d_context *gctx = egl_g3d_context(ctx); - const uint st_att_map[NUM_NATIVE_ATTACHMENTS] = { - ST_SURFACE_FRONT_LEFT, - ST_SURFACE_BACK_LEFT, - ST_SURFACE_FRONT_RIGHT, - ST_SURFACE_BACK_RIGHT, - }; - EGLint num_surfaces, s; - - /* validate draw and/or read buffers */ - num_surfaces = (gctx->base.ReadSurface == gctx->base.DrawSurface) ? 1 : 2; - for (s = 0; s < num_surfaces; s++) { - struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS]; - struct egl_g3d_surface *gsurf; - struct egl_g3d_buffer *gbuf; - EGLint att; - - if (s == 0) { - gsurf = egl_g3d_surface(gctx->base.DrawSurface); - gbuf = &gctx->draw; - } - else { - gsurf = egl_g3d_surface(gctx->base.ReadSurface); - gbuf = &gctx->read; - } - - if (!gctx->force_validate) { - unsigned int seq_num; - - gsurf->native->validate(gsurf->native, gbuf->attachment_mask, - &seq_num, NULL, NULL, NULL); - /* skip validation */ - if (gsurf->sequence_number == seq_num) - continue; - } - - pipe_surface_reference(&gsurf->render_surface, NULL); - memset(textures, 0, sizeof(textures)); - - gsurf->native->validate(gsurf->native, gbuf->attachment_mask, - &gsurf->sequence_number, textures, - &gsurf->base.Width, &gsurf->base.Height); - for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { - struct pipe_texture *pt = textures[att]; - struct pipe_surface *ps; - - if (native_attachment_mask_test(gbuf->attachment_mask, att) && pt) { - ps = screen->get_tex_surface(screen, pt, 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_GPU_WRITE); - gctx->stapi->st_set_framebuffer_surface(gbuf->st_fb, - st_att_map[att], ps); - - if (gsurf->render_att == att) - pipe_surface_reference(&gsurf->render_surface, ps); - - pipe_surface_reference(&ps, NULL); - pipe_texture_reference(&pt, NULL); - } - } - - gctx->stapi->st_resize_framebuffer(gbuf->st_fb, - gsurf->base.Width, gsurf->base.Height); - } - - gctx->force_validate = EGL_FALSE; - -} - -/** - * Create a st_framebuffer. - */ -static struct st_framebuffer * -create_framebuffer(_EGLContext *ctx, _EGLSurface *surf) -{ - struct egl_g3d_context *gctx = egl_g3d_context(ctx); - struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - struct egl_g3d_config *gconf = egl_g3d_config(gsurf->base.Config); - - return gctx->stapi->st_create_framebuffer(&gconf->native->mode, - gconf->native->color_format, gconf->native->depth_format, - gconf->native->stencil_format, - gsurf->base.Width, gsurf->base.Height, &gsurf->base); -} - -/** - * Update the attachments of draw/read surfaces. - */ -static void -egl_g3d_route_context(_EGLDisplay *dpy, _EGLContext *ctx) -{ - struct egl_g3d_context *gctx = egl_g3d_context(ctx); - EGLint s; - - /* route draw and read buffers' attachments */ - for (s = 0; s < 2; s++) { - struct egl_g3d_surface *gsurf; - struct egl_g3d_buffer *gbuf; - - if (s == 0) { - gsurf = egl_g3d_surface(gctx->base.DrawSurface); - gbuf = &gctx->draw; - } - else { - gsurf = egl_g3d_surface(gctx->base.ReadSurface); - gbuf = &gctx->read; - } - - gbuf->attachment_mask = (1 << gsurf->render_att); - - /* FIXME OpenGL defaults to draw the front or back buffer when the - * context is single-buffered or double-buffered respectively. In EGL, - * however, the buffer to be drawn is determined by the surface, instead - * of the context. As a result, rendering to a pixmap surface with a - * double-buffered context does not work as expected. - * - * gctx->stapi->st_draw_front_buffer(gctx->st_ctx, natt == - * NATIVE_ATTACHMENT_FRONT_LEFT); - */ - - /* - * FIXME If the back buffer is asked for here, and the front buffer is - * later needed by the client API (e.g. glDrawBuffer is called to draw - * the front buffer), it will create a new pipe texture and draw there. - * One fix is to ask for both buffers here, but it would be a waste if - * the front buffer is never used. A better fix is to add a callback to - * the pipe screen with context private (just like flush_frontbuffer). - */ - } -} - -/** - * Reallocate the context's framebuffers after draw/read surfaces change. - */ -static EGLBoolean -egl_g3d_realloc_context(_EGLDisplay *dpy, _EGLContext *ctx) -{ - struct egl_g3d_context *gctx = egl_g3d_context(ctx); - struct egl_g3d_surface *gdraw = egl_g3d_surface(gctx->base.DrawSurface); - struct egl_g3d_surface *gread = egl_g3d_surface(gctx->base.ReadSurface); - - /* unreference the old framebuffers */ - if (gctx->draw.st_fb) { - EGLBoolean is_equal = (gctx->draw.st_fb == gctx->read.st_fb); - void *priv; - - priv = gctx->stapi->st_framebuffer_private(gctx->draw.st_fb); - if (!gdraw || priv != (void *) &gdraw->base) { - gctx->stapi->st_unreference_framebuffer(gctx->draw.st_fb); - gctx->draw.st_fb = NULL; - gctx->draw.attachment_mask = 0x0; - } - - if (is_equal) { - gctx->read.st_fb = NULL; - gctx->draw.attachment_mask = 0x0; - } - else { - priv = gctx->stapi->st_framebuffer_private(gctx->read.st_fb); - if (!gread || priv != (void *) &gread->base) { - gctx->stapi->st_unreference_framebuffer(gctx->read.st_fb); - gctx->read.st_fb = NULL; - gctx->draw.attachment_mask = 0x0; - } - } - } - - if (!gdraw) - return EGL_TRUE; - - /* create the draw fb */ - if (!gctx->draw.st_fb) { - gctx->draw.st_fb = create_framebuffer(&gctx->base, &gdraw->base); - if (!gctx->draw.st_fb) - return EGL_FALSE; - } - - /* create the read fb */ - if (!gctx->read.st_fb) { - if (gread != gdraw) { - gctx->read.st_fb = create_framebuffer(&gctx->base, &gread->base); - if (!gctx->read.st_fb) { - gctx->stapi->st_unreference_framebuffer(gctx->draw.st_fb); - gctx->draw.st_fb = NULL; - return EGL_FALSE; - } - } - else { - /* there is no st_reference_framebuffer... */ - gctx->read.st_fb = gctx->draw.st_fb; - } - } - - egl_g3d_route_context(dpy, &gctx->base); - gctx->force_validate = EGL_TRUE; - - return EGL_TRUE; -} - -/** - * Return the current context of the given API. - */ -static struct egl_g3d_context * -egl_g3d_get_current_context(EGLint api) -{ - _EGLThreadInfo *t = _eglGetCurrentThread(); - EGLint api_index = _eglConvertApiToIndex(api); - return egl_g3d_context(t->CurrentContexts[api_index]); -} - -/** - * Return the state tracker for the given context. - */ -static const struct egl_g3d_st * -egl_g3d_choose_st(_EGLDriver *drv, _EGLContext *ctx) -{ - struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); - const struct egl_g3d_st *stapi; - EGLint idx = -1; - - switch (ctx->ClientAPI) { - case EGL_OPENGL_ES_API: - switch (ctx->ClientVersion) { - case 1: - idx = EGL_G3D_ST_OPENGL_ES; - break; - case 2: - idx = EGL_G3D_ST_OPENGL_ES2; - break; - default: - _eglLog(_EGL_WARNING, "unknown client version %d", - ctx->ClientVersion); - break; - } - break; - case EGL_OPENVG_API: - idx = EGL_G3D_ST_OPENVG; - break; - case EGL_OPENGL_API: - idx = EGL_G3D_ST_OPENGL; - break; - default: - _eglLog(_EGL_WARNING, "unknown client API 0x%04x", ctx->ClientAPI); - break; - } - - stapi = (idx >= 0) ? gdrv->stapis[idx] : NULL; - return stapi; -} - -/** - * Initialize the state trackers. - */ -static void -egl_g3d_init_st(_EGLDriver *drv) -{ - struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); - EGLint i; - - /* already initialized */ - if (gdrv->api_mask) - return; - - for (i = 0; i < NUM_EGL_G3D_STS; i++) { - gdrv->stapis[i] = egl_g3d_get_st(i); - if (gdrv->stapis[i]) - gdrv->api_mask |= gdrv->stapis[i]->api_bit; - } - - if (gdrv->api_mask) - _eglLog(_EGL_DEBUG, "Driver API mask: 0x%x", gdrv->api_mask); - else - _eglLog(_EGL_WARNING, "No supported client API"); -} - -/** - * Get the probe object of the display. - * - * Note that this function may be called before the display is initialized. - */ -static struct native_probe * -egl_g3d_get_probe(_EGLDriver *drv, _EGLDisplay *dpy) -{ - struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); - struct native_probe *nprobe; - - nprobe = (struct native_probe *) _eglGetProbeCache(gdrv->probe_key); - if (!nprobe || nprobe->display != dpy->NativeDisplay) { - if (nprobe) - nprobe->destroy(nprobe); - nprobe = native_create_probe(dpy->NativeDisplay); - _eglSetProbeCache(gdrv->probe_key, (void *) nprobe); - } - - return nprobe; -} - -/** - * Destroy the probe object of the display. The display may be NULL. - * - * Note that this function may be called before the display is initialized. - */ -static void -egl_g3d_destroy_probe(_EGLDriver *drv, _EGLDisplay *dpy) -{ - struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); - struct native_probe *nprobe; - - nprobe = (struct native_probe *) _eglGetProbeCache(gdrv->probe_key); - if (nprobe && (!dpy || nprobe->display == dpy->NativeDisplay)) { - nprobe->destroy(nprobe); - _eglSetProbeCache(gdrv->probe_key, NULL); - } -} - -/** - * Return an API mask that consists of the state trackers that supports the - * given mode. - * - * FIXME add st_is_mode_supported()? - */ -static EGLint -get_mode_api_mask(const __GLcontextModes *mode, EGLint api_mask) -{ - EGLint check; - - /* OpenGL ES 1.x and 2.x are checked together */ - check = EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT; - if (api_mask & check) { - /* this is required by EGL, not by OpenGL ES */ - if (mode->drawableType & GLX_WINDOW_BIT && !mode->doubleBufferMode) - api_mask &= ~check; - } - - check = EGL_OPENVG_BIT; - if (api_mask & check) { - /* vega st needs the depth/stencil rb */ - if (!mode->depthBits && !mode->stencilBits) - api_mask &= ~check; - } - - return api_mask; -} - -#ifdef EGL_MESA_screen_surface - -static void -egl_g3d_add_screens(_EGLDriver *drv, _EGLDisplay *dpy) -{ - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - const struct native_connector **native_connectors; - EGLint num_connectors, i; - - native_connectors = - gdpy->native->modeset->get_connectors(gdpy->native, &num_connectors, NULL); - if (!num_connectors) { - if (native_connectors) - free(native_connectors); - return; - } - - for (i = 0; i < num_connectors; i++) { - const struct native_connector *nconn = native_connectors[i]; - struct egl_g3d_screen *gscr; - const struct native_mode **native_modes; - EGLint num_modes, j; - - /* TODO support for hotplug */ - native_modes = - gdpy->native->modeset->get_modes(gdpy->native, nconn, &num_modes); - if (!num_modes) { - if (native_modes) - free(native_modes); - continue; - } - - gscr = CALLOC_STRUCT(egl_g3d_screen); - if (!gscr) { - free(native_modes); - continue; - } - - _eglInitScreen(&gscr->base); - - for (j = 0; j < num_modes; j++) { - const struct native_mode *nmode = native_modes[j]; - _EGLMode *mode; - - mode = _eglAddNewMode(&gscr->base, nmode->width, nmode->height, - nmode->refresh_rate, nmode->desc); - if (!mode) - break; - /* gscr->native_modes and gscr->base.Modes should be consistent */ - assert(mode == &gscr->base.Modes[j]); - } - - gscr->native = nconn; - gscr->native_modes = native_modes; - - _eglAddScreen(dpy, &gscr->base); - } - - free(native_connectors); -} - -#endif /* EGL_MESA_screen_surface */ - -/** - * Add configs to display and return the next config ID. - */ -static EGLint -egl_g3d_add_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint id) -{ - struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - const struct native_config **native_configs; - int num_configs, i; - - native_configs = gdpy->native->get_configs(gdpy->native, - &num_configs); - if (!num_configs) { - if (native_configs) - free(native_configs); - return id; - } - - for (i = 0; i < num_configs; i++) { - EGLint api_mask; - struct egl_g3d_config *gconf; - EGLBoolean valid; - - api_mask = get_mode_api_mask(&native_configs[i]->mode, gdrv->api_mask); - if (!api_mask) { - _eglLog(_EGL_DEBUG, "no state tracker supports config 0x%x", - native_configs[i]->mode.visualID); - continue; - } - - gconf = CALLOC_STRUCT(egl_g3d_config); - if (!gconf) - continue; - - _eglInitConfig(&gconf->base, id); - valid = _eglConfigFromContextModesRec(&gconf->base, - &native_configs[i]->mode, api_mask, api_mask); - if (valid) { -#ifdef EGL_MESA_screen_surface - /* check if scanout surface bit is set */ - if (native_configs[i]->scanout_bit) { - EGLint val = GET_CONFIG_ATTRIB(&gconf->base, EGL_SURFACE_TYPE); - val |= EGL_SCREEN_BIT_MESA; - SET_CONFIG_ATTRIB(&gconf->base, EGL_SURFACE_TYPE, val); - } -#endif - valid = _eglValidateConfig(&gconf->base, EGL_FALSE); - } - if (!valid) { - _eglLog(_EGL_DEBUG, "skip invalid config 0x%x", - native_configs[i]->mode.visualID); - free(gconf); - continue; - } - - gconf->native = native_configs[i]; - _eglAddConfig(dpy, &gconf->base); - id++; - } - - free(native_configs); - return id; -} - -/** - * Flush the front buffer of the context's draw surface. - */ -static void -egl_g3d_flush_frontbuffer(struct pipe_screen *screen, - struct pipe_surface *surf, void *context_private) -{ - struct egl_g3d_context *gctx = egl_g3d_context(context_private); - struct egl_g3d_surface *gsurf = egl_g3d_surface(gctx->base.DrawSurface); - - if (gsurf) - gsurf->native->flush_frontbuffer(gsurf->native); -} - -/** - * Re-validate the context. - */ -static void -egl_g3d_update_buffer(struct pipe_screen *screen, void *context_private) -{ - struct egl_g3d_context *gctx = egl_g3d_context(context_private); - - /** - * It is likely that the surface has changed when this function is called. - * Set force_validate to skip an unnecessary check. - */ - gctx->force_validate = EGL_TRUE; - egl_g3d_validate_context(gctx->base.Display, &gctx->base); -} - -static EGLBoolean -egl_g3d_terminate(_EGLDriver *drv, _EGLDisplay *dpy) -{ - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - EGLint i; - - _eglReleaseDisplayResources(drv, dpy); - _eglCleanupDisplay(dpy); - - if (dpy->Screens) { - for (i = 0; i < dpy->NumScreens; i++) { - struct egl_g3d_screen *gscr = egl_g3d_screen(dpy->Screens[i]); - free(gscr->native_modes); - free(gscr); - } - free(dpy->Screens); - } - - if (gdpy->native) - gdpy->native->destroy(gdpy->native); - - free(gdpy); - dpy->DriverData = NULL; - - return EGL_TRUE; -} - -static EGLBoolean -egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy, - EGLint *major, EGLint *minor) -{ - struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); - struct egl_g3d_display *gdpy; - - /* the probe object is unlikely to be needed again */ - egl_g3d_destroy_probe(drv, dpy); - - gdpy = CALLOC_STRUCT(egl_g3d_display); - if (!gdpy) { - _eglError(EGL_BAD_ALLOC, "eglInitialize"); - goto fail; - } - dpy->DriverData = gdpy; - - gdpy->native = native_create_display(dpy->NativeDisplay); - if (!gdpy->native) { - _eglError(EGL_NOT_INITIALIZED, "eglInitialize(no usable display)"); - goto fail; - } - - gdpy->native->screen->flush_frontbuffer = egl_g3d_flush_frontbuffer; - gdpy->native->screen->update_buffer = egl_g3d_update_buffer; - - egl_g3d_init_st(&gdrv->base); - dpy->ClientAPIsMask = gdrv->api_mask; - - if (egl_g3d_add_configs(drv, dpy, 1) == 1) { - _eglError(EGL_NOT_INITIALIZED, "eglInitialize(unable to add configs)"); - goto fail; - } - -#ifdef EGL_MESA_screen_surface - /* enable MESA_screen_surface */ - if (gdpy->native->modeset) { - dpy->Extensions.MESA_screen_surface = EGL_TRUE; - egl_g3d_add_screens(drv, dpy); - } -#endif - - *major = 1; - *minor = 4; - - return EGL_TRUE; - -fail: - if (gdpy) - egl_g3d_terminate(drv, dpy); - return EGL_FALSE; -} - -static _EGLContext * -egl_g3d_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, - _EGLContext *share, const EGLint *attribs) -{ - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - struct egl_g3d_context *gshare = egl_g3d_context(share); - struct egl_g3d_config *gconf = egl_g3d_config(conf); - struct egl_g3d_context *gctx; - const __GLcontextModes *mode; - - gctx = CALLOC_STRUCT(egl_g3d_context); - if (!gctx) { - _eglError(EGL_BAD_ALLOC, "eglCreateContext"); - return NULL; - } - - if (!_eglInitContext(drv, &gctx->base, conf, attribs)) { - free(gctx); - return NULL; - } - - gctx->stapi = egl_g3d_choose_st(drv, &gctx->base); - if (!gctx->stapi) { - free(gctx); - return NULL; - } - - mode = &gconf->native->mode; - gctx->pipe = - gdpy->native->create_context(gdpy->native, (void *) &gctx->base); - if (!gctx->pipe) { - free(gctx); - return NULL; - } - - gctx->st_ctx = gctx->stapi->st_create_context(gctx->pipe, mode, - (gshare) ? gshare->st_ctx : NULL); - if (!gctx->st_ctx) { - gctx->pipe->destroy(gctx->pipe); - free(gctx); - return NULL; - } - - return &gctx->base; -} - -static EGLBoolean -egl_g3d_destroy_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) -{ - struct egl_g3d_context *gctx = egl_g3d_context(ctx); - - if (_eglIsContextBound(&gctx->base)) - return EGL_TRUE; - - egl_g3d_realloc_context(dpy, &gctx->base); - - /* it will destroy pipe context */ - gctx->stapi->st_destroy_context(gctx->st_ctx); - - free(gctx); - - return EGL_TRUE; -} - -static EGLBoolean -init_surface_geometry(_EGLSurface *surf) -{ - struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - - return gsurf->native->validate(gsurf->native, 0x0, - &gsurf->sequence_number, NULL, - &gsurf->base.Width, &gsurf->base.Height); -} - -static _EGLSurface * -egl_g3d_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLConfig *conf, EGLNativeWindowType win, - const EGLint *attribs) -{ - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - struct egl_g3d_config *gconf = egl_g3d_config(conf); - struct egl_g3d_surface *gsurf; - - gsurf = CALLOC_STRUCT(egl_g3d_surface); - if (!gsurf) { - _eglError(EGL_BAD_ALLOC, "eglCreateWindowSurface"); - return NULL; - } - - if (!_eglInitSurface(drv, &gsurf->base, EGL_WINDOW_BIT, conf, attribs)) { - free(gsurf); - return NULL; - } - - gsurf->native = - gdpy->native->create_window_surface(gdpy->native, win, gconf->native); - if (!gsurf->native) { - free(gsurf); - return NULL; - } - - if (!init_surface_geometry(&gsurf->base)) { - gsurf->native->destroy(gsurf->native); - free(gsurf); - return NULL; - } - - gsurf->render_att = (gsurf->base.RenderBuffer == EGL_SINGLE_BUFFER || - !gconf->native->mode.doubleBufferMode) ? - NATIVE_ATTACHMENT_FRONT_LEFT : NATIVE_ATTACHMENT_BACK_LEFT; - - return &gsurf->base; -} - -static _EGLSurface * -egl_g3d_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLConfig *conf, EGLNativePixmapType pix, - const EGLint *attribs) -{ - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - struct egl_g3d_config *gconf = egl_g3d_config(conf); - struct egl_g3d_surface *gsurf; - - gsurf = CALLOC_STRUCT(egl_g3d_surface); - if (!gsurf) { - _eglError(EGL_BAD_ALLOC, "eglCreatePixmapSurface"); - return NULL; - } - - if (!_eglInitSurface(drv, &gsurf->base, EGL_PIXMAP_BIT, conf, attribs)) { - free(gsurf); - return NULL; - } - - gsurf->native = - gdpy->native->create_pixmap_surface(gdpy->native, pix, gconf->native); - if (!gsurf->native) { - free(gsurf); - return NULL; - } - - if (!init_surface_geometry(&gsurf->base)) { - gsurf->native->destroy(gsurf->native); - free(gsurf); - return NULL; - } - - gsurf->render_att = NATIVE_ATTACHMENT_FRONT_LEFT; - - return &gsurf->base; -} - -static _EGLSurface * -egl_g3d_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLConfig *conf, const EGLint *attribs) -{ - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - struct egl_g3d_config *gconf = egl_g3d_config(conf); - struct egl_g3d_surface *gsurf; - - gsurf = CALLOC_STRUCT(egl_g3d_surface); - if (!gsurf) { - _eglError(EGL_BAD_ALLOC, "eglCreatePbufferSurface"); - return NULL; - } - - if (!_eglInitSurface(drv, &gsurf->base, EGL_PBUFFER_BIT, conf, attribs)) { - free(gsurf); - return NULL; - } - - gsurf->native = - gdpy->native->create_pbuffer_surface(gdpy->native, gconf->native, - gsurf->base.Width, gsurf->base.Height); - if (!gsurf->native) { - free(gsurf); - return NULL; - } - - if (!init_surface_geometry(&gsurf->base)) { - gsurf->native->destroy(gsurf->native); - free(gsurf); - return NULL; - } - - gsurf->render_att = (!gconf->native->mode.doubleBufferMode) ? - NATIVE_ATTACHMENT_FRONT_LEFT : NATIVE_ATTACHMENT_BACK_LEFT; - - return &gsurf->base; -} - -static EGLBoolean -egl_g3d_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) -{ - struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - - if (_eglIsSurfaceBound(&gsurf->base)) - return EGL_TRUE; - - pipe_surface_reference(&gsurf->render_surface, NULL); - gsurf->native->destroy(gsurf->native); - free(gsurf); - return EGL_TRUE; -} - -static EGLBoolean -egl_g3d_make_current(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLSurface *draw, _EGLSurface *read, _EGLContext *ctx) -{ - struct egl_g3d_context *gctx = egl_g3d_context(ctx); - struct egl_g3d_context *old_gctx; - EGLint api; - EGLBoolean ok = EGL_TRUE; - - /* find the old context */ - api = (gctx) ? gctx->base.ClientAPI : eglQueryAPI(); - old_gctx = egl_g3d_get_current_context(api); - if (old_gctx && !_eglIsContextLinked(&old_gctx->base)) - old_gctx = NULL; - - if (!_eglMakeCurrent(drv, dpy, draw, read, ctx)) - return EGL_FALSE; - - if (old_gctx) { - /* flush old context */ - old_gctx->stapi->st_flush(old_gctx->st_ctx, - PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); - - /* - * The old context is no longer current, and egl_g3d_realloc_context() - * should be called to destroy the framebuffers. However, it is possible - * that it will be made current again with the same draw/read surfaces. - * It might be better to keep it around. - */ - } - - if (gctx) { - struct egl_g3d_surface *gdraw = egl_g3d_surface(draw); - - ok = egl_g3d_realloc_context(dpy, &gctx->base); - if (ok) { - ok = gctx->stapi->st_make_current(gctx->st_ctx, - gctx->draw.st_fb, gctx->read.st_fb); - if (ok) { - egl_g3d_validate_context(dpy, &gctx->base); - if (gdraw->base.Type == EGL_WINDOW_BIT) { - gctx->base.WindowRenderBuffer = - (gdraw->render_att == NATIVE_ATTACHMENT_FRONT_LEFT) ? - EGL_SINGLE_BUFFER : EGL_BACK_BUFFER; - } - } - } - } - else if (old_gctx) { - ok = old_gctx->stapi->st_make_current(NULL, NULL, NULL); - old_gctx->base.WindowRenderBuffer = EGL_NONE; - } - - return ok; -} - -static EGLBoolean -egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) -{ - struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - _EGLContext *ctx = _eglGetCurrentContext(); - struct egl_g3d_context *gctx = NULL; - - /* no-op for pixmap or pbuffer surface */ - if (gsurf->base.Type == EGL_PIXMAP_BIT || - gsurf->base.Type == EGL_PBUFFER_BIT) - return EGL_TRUE; - - /* or when the surface is single-buffered */ - if (gsurf->render_att == NATIVE_ATTACHMENT_FRONT_LEFT) - return EGL_TRUE; - - if (ctx && ctx->DrawSurface == surf) - gctx = egl_g3d_context(ctx); - - /* flush if the surface is current */ - if (gctx) - gctx->stapi->st_notify_swapbuffers(gctx->draw.st_fb); - - /* - * We drew on the back buffer, unless there was no back buffer. - * In that case, we drew on the front buffer. Either case, we call - * swap_buffers. - */ - if (!gsurf->native->swap_buffers(gsurf->native)) - return EGL_FALSE; - - if (gctx) { - struct egl_g3d_config *gconf = egl_g3d_config(gsurf->base.Config); - - /* force validation if the swap method is not copy */ - if (gconf->native->mode.swapMethod != GLX_SWAP_COPY_OML) { - gctx->force_validate = EGL_TRUE; - egl_g3d_validate_context(dpy, &gctx->base); - } - } - - return EGL_TRUE; -} - -/** - * Find a config that supports the pixmap. - */ -static _EGLConfig * -find_pixmap_config(_EGLDisplay *dpy, EGLNativePixmapType pix) -{ - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - struct egl_g3d_config *gconf; - EGLint i; - - for (i = 0; i < dpy->NumConfigs; i++) { - gconf = egl_g3d_config(dpy->Configs[i]); - if (gdpy->native->is_pixmap_supported(gdpy->native, pix, gconf->native)) - break; - } - - return (i < dpy->NumConfigs) ? &gconf->base : NULL; -} - -/** - * Get the pipe surface of the given attachment of the native surface. - */ -static struct pipe_surface * -get_pipe_surface(struct native_display *ndpy, struct native_surface *nsurf, - enum native_attachment natt) -{ - struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS]; - struct pipe_surface *psurf; - - textures[natt] = NULL; - nsurf->validate(nsurf, 1 << natt, NULL, textures, NULL, NULL); - if (!textures[natt]) - return NULL; - - psurf = ndpy->screen->get_tex_surface(ndpy->screen, textures[natt], - 0, 0, 0, PIPE_BUFFER_USAGE_CPU_WRITE); - pipe_texture_reference(&textures[natt], NULL); - - return psurf; -} - -static EGLBoolean -egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, - NativePixmapType target) -{ - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - _EGLContext *ctx = _eglGetCurrentContext(); - struct egl_g3d_config *gconf; - struct native_surface *nsurf; - struct pipe_screen *screen = gdpy->native->screen; - struct pipe_surface *psurf; - - if (!gsurf->render_surface) - return EGL_TRUE; - - gconf = egl_g3d_config(find_pixmap_config(dpy, target)); - if (!gconf) - return _eglError(EGL_BAD_NATIVE_PIXMAP, "eglCopyBuffers"); - - nsurf = gdpy->native->create_pixmap_surface(gdpy->native, - target, gconf->native); - if (!nsurf) - return _eglError(EGL_BAD_NATIVE_PIXMAP, "eglCopyBuffers"); - - /* flush if the surface is current */ - if (ctx && ctx->DrawSurface == &gsurf->base) { - struct egl_g3d_context *gctx = egl_g3d_context(ctx); - gctx->stapi->st_flush(gctx->st_ctx, - PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); - } - - psurf = get_pipe_surface(gdpy->native, nsurf, NATIVE_ATTACHMENT_FRONT_LEFT); - if (psurf) { - struct pipe_context pipe; - - /** - * XXX This is hacky. If we might allow the EGLDisplay to create a pipe - * context of its own and use the blitter context for this. - */ - memset(&pipe, 0, sizeof(pipe)); - pipe.screen = screen; - - util_surface_copy(&pipe, FALSE, psurf, 0, 0, - gsurf->render_surface, 0, 0, psurf->width, psurf->height); - - pipe_surface_reference(&psurf, NULL); - nsurf->flush_frontbuffer(nsurf); - } - - nsurf->destroy(nsurf); - - return EGL_TRUE; -} - -static EGLBoolean -egl_g3d_wait_client(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) -{ - struct egl_g3d_context *gctx = egl_g3d_context(ctx); - gctx->stapi->st_finish(gctx->st_ctx); - return EGL_TRUE; -} - -static EGLBoolean -egl_g3d_wait_native(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine) -{ - _EGLSurface *surf = _eglGetCurrentSurface(EGL_DRAW); - struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - - if (engine != EGL_CORE_NATIVE_ENGINE) - return _eglError(EGL_BAD_PARAMETER, "eglWaitNative"); - - if (gsurf) - gsurf->native->wait(gsurf->native); - - return EGL_TRUE; -} - -static _EGLProc -egl_g3d_get_proc_address(_EGLDriver *drv, const char *procname) -{ - struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); - _EGLProc proc; - EGLint i; - - /* in case this is called before a display is initialized */ - egl_g3d_init_st(&gdrv->base); - - for (i = 0; i < NUM_EGL_G3D_STS; i++) { - const struct egl_g3d_st *stapi = gdrv->stapis[i]; - if (stapi) { - proc = (_EGLProc) stapi->st_get_proc_address(procname); - if (proc) - return proc; - } - } - - return (_EGLProc) NULL; -} - -static EGLBoolean -egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLSurface *surf, EGLint buffer) -{ - struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - struct egl_g3d_context *gctx; - enum pipe_format target_format; - int target; - - if (!gsurf || gsurf->base.Type != EGL_PBUFFER_BIT) - return _eglError(EGL_BAD_SURFACE, "eglBindTexImage"); - if (buffer != EGL_BACK_BUFFER) - return _eglError(EGL_BAD_PARAMETER, "eglBindTexImage"); - if (gsurf->base.BoundToTexture) - return _eglError(EGL_BAD_ACCESS, "eglBindTexImage"); - - switch (gsurf->base.TextureFormat) { - case EGL_TEXTURE_RGB: - target_format = PIPE_FORMAT_R8G8B8_UNORM; - break; - case EGL_TEXTURE_RGBA: - target_format = PIPE_FORMAT_A8R8G8B8_UNORM; - break; - default: - return _eglError(EGL_BAD_MATCH, "eglBindTexImage"); - } - - switch (gsurf->base.TextureTarget) { - case EGL_TEXTURE_2D: - target = ST_TEXTURE_2D; - break; - default: - return _eglError(EGL_BAD_MATCH, "eglBindTexImage"); - } - - /* flush properly if the surface is bound */ - if (gsurf->base.Binding) { - gctx = egl_g3d_context(gsurf->base.Binding); - gctx->stapi->st_flush(gctx->st_ctx, - PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); - } - - /* XXX change to EGL_OPENGL_ES_API once OpenGL ES is merged */ - gctx = egl_g3d_get_current_context(EGL_OPENGL_API); - if (gctx) { - if (!gsurf->render_surface) - return EGL_FALSE; - - gctx->stapi->st_bind_texture_surface(gsurf->render_surface, - target, gsurf->base.MipmapLevel, target_format); - gsurf->base.BoundToTexture = EGL_TRUE; - } - - return EGL_TRUE; -} - -static EGLBoolean -egl_g3d_release_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLSurface *surf, EGLint buffer) -{ - struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - - if (!gsurf || gsurf->base.Type != EGL_PBUFFER_BIT || - !gsurf->base.BoundToTexture) - return _eglError(EGL_BAD_SURFACE, "eglReleaseTexImage"); - if (buffer != EGL_BACK_BUFFER) - return _eglError(EGL_BAD_PARAMETER, "eglReleaseTexImage"); - - if (gsurf->render_surface) { - _EGLThreadInfo *t = _eglGetCurrentThread(); - /* XXX change to EGL_OPENGL_ES_API once OpenGL ES is merged */ - struct egl_g3d_context *gctx = egl_g3d_context( - t->CurrentContexts[_eglConvertApiToIndex(EGL_OPENGL_API)]); - - /* what if the context the surface binds to is no longer current? */ - if (gctx) - gctx->stapi->st_unbind_texture_surface(gsurf->render_surface, - ST_TEXTURE_2D, gsurf->base.MipmapLevel); - } - - gsurf->base.BoundToTexture = EGL_FALSE; - - return EGL_TRUE; -} - -#ifdef EGL_MESA_screen_surface - -static _EGLSurface * -egl_g3d_create_screen_surface(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLConfig *conf, const EGLint *attribs) -{ - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - struct egl_g3d_config *gconf = egl_g3d_config(conf); - struct egl_g3d_surface *gsurf; - - gsurf = CALLOC_STRUCT(egl_g3d_surface); - if (!gsurf) { - _eglError(EGL_BAD_ALLOC, "eglCreatePbufferSurface"); - return NULL; - } - - if (!_eglInitSurface(drv, &gsurf->base, - EGL_SCREEN_BIT_MESA, conf, attribs)) { - free(gsurf); - return NULL; - } - - gsurf->native = - gdpy->native->modeset->create_scanout_surface(gdpy->native, - gconf->native, gsurf->base.Width, gsurf->base.Height); - if (!gsurf->native) { - free(gsurf); - return NULL; - } - - gsurf->render_att = (!gconf->native->mode.doubleBufferMode) ? - NATIVE_ATTACHMENT_FRONT_LEFT : NATIVE_ATTACHMENT_BACK_LEFT; - - return &gsurf->base; -} - -static EGLBoolean -egl_g3d_show_screen_surface(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLScreen *scr, _EGLSurface *surf, - _EGLMode *mode) -{ - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - struct egl_g3d_screen *gscr = egl_g3d_screen(scr); - struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - struct native_surface *nsurf; - const struct native_mode *nmode; - EGLBoolean changed; - - if (gsurf) { - EGLint idx; - - if (!mode) - return _eglError(EGL_BAD_MATCH, "eglShowSurfaceMESA"); - if (gsurf->base.Type != EGL_SCREEN_BIT_MESA) - return _eglError(EGL_BAD_SURFACE, "eglShowScreenSurfaceMESA"); - if (gsurf->base.Width < mode->Width || gsurf->base.Height < mode->Height) - return _eglError(EGL_BAD_MATCH, - "eglShowSurfaceMESA(surface smaller than mode size)"); - - /* find the index of the mode */ - for (idx = 0; idx < gscr->base.NumModes; idx++) - if (mode == &gscr->base.Modes[idx]) - break; - if (idx >= gscr->base.NumModes) { - return _eglError(EGL_BAD_MODE_MESA, - "eglShowSurfaceMESA(unknown mode)"); - } - - nsurf = gsurf->native; - nmode = gscr->native_modes[idx]; - } - else { - if (mode) - return _eglError(EGL_BAD_MATCH, "eglShowSurfaceMESA"); - - /* disable the screen */ - nsurf = NULL; - nmode = NULL; - } - - /* TODO surface panning by CRTC choosing */ - changed = gdpy->native->modeset->program(gdpy->native, 0, nsurf, - gscr->base.OriginX, gscr->base.OriginY, &gscr->native, 1, nmode); - if (changed) { - gscr->base.CurrentSurface = &gsurf->base; - gscr->base.CurrentMode = mode; - } - - return changed; -} - -#endif /* EGL_MESA_screen_surface */ - -static EGLint -egl_g3d_probe(_EGLDriver *drv, _EGLDisplay *dpy) -{ - struct native_probe *nprobe; - enum native_probe_result res; - EGLint score; - - nprobe = egl_g3d_get_probe(drv, dpy); - res = native_get_probe_result(nprobe); - - switch (res) { - case NATIVE_PROBE_UNKNOWN: - default: - score = 0; - break; - case NATIVE_PROBE_FALLBACK: - score = 40; - break; - case NATIVE_PROBE_SUPPORTED: - score = 50; - break; - case NATIVE_PROBE_EXACT: - score = 100; - break; - } - - return score; -} - -static void -egl_g3d_unload(_EGLDriver *drv) -{ - struct egl_g3d_driver *gdrv = egl_g3d_driver(drv); - - egl_g3d_destroy_probe(drv, NULL); - free(gdrv); -} - -_EGLDriver * -_eglMain(const char *args) -{ - static char driver_name[64]; - struct egl_g3d_driver *gdrv; - - snprintf(driver_name, sizeof(driver_name), - "Gallium/%s", native_get_name()); - - gdrv = CALLOC_STRUCT(egl_g3d_driver); - if (!gdrv) - return NULL; - - _eglInitDriverFallbacks(&gdrv->base); - - gdrv->base.API.Initialize = egl_g3d_initialize; - gdrv->base.API.Terminate = egl_g3d_terminate; - gdrv->base.API.CreateContext = egl_g3d_create_context; - gdrv->base.API.DestroyContext = egl_g3d_destroy_context; - gdrv->base.API.CreateWindowSurface = egl_g3d_create_window_surface; - gdrv->base.API.CreatePixmapSurface = egl_g3d_create_pixmap_surface; - gdrv->base.API.CreatePbufferSurface = egl_g3d_create_pbuffer_surface; - gdrv->base.API.DestroySurface = egl_g3d_destroy_surface; - gdrv->base.API.MakeCurrent = egl_g3d_make_current; - gdrv->base.API.SwapBuffers = egl_g3d_swap_buffers; - gdrv->base.API.CopyBuffers = egl_g3d_copy_buffers; - gdrv->base.API.WaitClient = egl_g3d_wait_client; - gdrv->base.API.WaitNative = egl_g3d_wait_native; - gdrv->base.API.GetProcAddress = egl_g3d_get_proc_address; - - gdrv->base.API.BindTexImage = egl_g3d_bind_tex_image; - gdrv->base.API.ReleaseTexImage = egl_g3d_release_tex_image; - -#ifdef EGL_MESA_screen_surface - gdrv->base.API.CreateScreenSurfaceMESA = egl_g3d_create_screen_surface; - gdrv->base.API.ShowScreenSurfaceMESA = egl_g3d_show_screen_surface; -#endif - - gdrv->base.Name = driver_name; - gdrv->base.Probe = egl_g3d_probe; - gdrv->base.Unload = egl_g3d_unload; - - /* the key is " EGL G3D" */ - gdrv->probe_key = 0x0E61063D; - - return &gdrv->base; -} diff --git a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.h b/src/gallium/state_trackers/egl_g3d/common/egl_g3d.h deleted file mode 100644 index 3dae8c4052..0000000000 --- a/src/gallium/state_trackers/egl_g3d/common/egl_g3d.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009-2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL 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. - */ - -#ifndef _EGL_G3D_H_ -#define _EGL_G3D_H_ - -#include "pipe/p_compiler.h" -#include "pipe/p_screen.h" -#include "pipe/p_context.h" -#include "pipe/p_format.h" -#include "egldriver.h" -#include "egldisplay.h" -#include "eglcontext.h" -#include "eglsurface.h" -#include "eglconfig.h" -#include "eglscreen.h" -#include "eglmode.h" - -#include "native.h" -#include "egl_st.h" - -struct egl_g3d_driver { - _EGLDriver base; - const struct egl_g3d_st *stapis[NUM_EGL_G3D_STS]; - EGLint api_mask; - - EGLint probe_key; -}; - -struct egl_g3d_display { - struct native_display *native; -}; - -struct egl_g3d_buffer { - struct st_framebuffer *st_fb; - uint attachment_mask; -}; - -struct egl_g3d_context { - _EGLContext base; - - const struct egl_g3d_st *stapi; - struct pipe_context *pipe; - - struct st_context *st_ctx; - EGLBoolean force_validate; - struct egl_g3d_buffer draw, read; -}; - -struct egl_g3d_surface { - _EGLSurface base; - struct native_surface *native; - enum native_attachment render_att; - struct pipe_surface *render_surface; - unsigned int sequence_number; -}; - -struct egl_g3d_config { - _EGLConfig base; - const struct native_config *native; -}; - -struct egl_g3d_screen { - _EGLScreen base; - const struct native_connector *native; - const struct native_mode **native_modes; -}; - -static INLINE struct egl_g3d_driver * -egl_g3d_driver(_EGLDriver *drv) -{ - return (struct egl_g3d_driver *) drv; -} - -static INLINE struct egl_g3d_display * -egl_g3d_display(_EGLDisplay *dpy) -{ - /* note that it is not direct casting */ - return (struct egl_g3d_display *) dpy->DriverData; -} - -static INLINE struct egl_g3d_context * -egl_g3d_context(_EGLContext *ctx) -{ - return (struct egl_g3d_context *) ctx; -} - -static INLINE struct egl_g3d_surface * -egl_g3d_surface(_EGLSurface *surf) -{ - return (struct egl_g3d_surface *) surf; -} - -static INLINE struct egl_g3d_config * -egl_g3d_config(_EGLConfig *conf) -{ - return (struct egl_g3d_config *) conf; -} - -static INLINE struct egl_g3d_screen * -egl_g3d_screen(_EGLScreen *scr) -{ - return (struct egl_g3d_screen *) scr; -} - -#endif /* _EGL_G3D_H_ */ diff --git a/src/gallium/state_trackers/egl_g3d/common/egl_st.c b/src/gallium/state_trackers/egl_g3d/common/egl_st.c deleted file mode 100644 index a88ff911cd..0000000000 --- a/src/gallium/state_trackers/egl_g3d/common/egl_st.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009-2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL 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. - */ - -#include -#include "pipe/p_compiler.h" -#include "util/u_memory.h" -#include "egllog.h" -#include "EGL/egl.h" /* for EGL_api_BIT */ - -#include "egl_st.h" - -#ifndef HAVE_DLADDR -#define HAVE_DLADDR 1 -#endif - -#if HAVE_DLADDR - -static const char * -egl_g3d_st_names[] = { -#define ST_PUBLIC(name, ...) #name, -#include "st_public_tmp.h" - NULL -}; - -static boolean -egl_g3d_fill_st(struct egl_g3d_st *stapi, void *sym) -{ - st_proc *procs = (st_proc *) stapi; - void *handle; - Dl_info info; - const char **name; - - if (!dladdr(sym, &info)) - return FALSE; - handle = dlopen(info.dli_fname, RTLD_LAZY | RTLD_LOCAL | RTLD_NODELETE); - if (!handle) - return FALSE; - - for (name = egl_g3d_st_names; *name; name++) { - st_proc proc = (st_proc) dlsym(handle, *name); - if (!proc) { - _eglLog(_EGL_WARNING, "%s is missing in %s", *name, info.dli_fname); - memset(stapi, 0, sizeof(*stapi)); - dlclose(handle); - return FALSE; - } - *procs++ = proc; - } - - dlclose(handle); - return TRUE; -} - -#else /* HAVE_DLADDR */ - -static boolean -egl_g3d_fill_st(struct egl_g3d_st *stapi, void *sym) -{ -#define ST_PUBLIC(name, ...) stapi->name = name; -#include "st_public_tmp.h" - return TRUE; -} - -#endif /* HAVE_DLADDR */ - -static boolean -egl_g3d_init_st(struct egl_g3d_st *stapi, const char *api) -{ - void *handle, *sym; - boolean res = FALSE; - - /* already initialized */ - if (stapi->st_notify_swapbuffers != NULL) - return TRUE; - - handle = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL); - if (!handle) - return FALSE; - - sym = dlsym(handle, api); - if (sym && egl_g3d_fill_st(stapi, sym)) - res = TRUE; - - dlclose(handle); - return res; -} - -static struct { - const char *symbol; - EGLint api_bit; -} egl_g3d_st_info[NUM_EGL_G3D_STS] = { - { "st_api_OpenGL_ES1", EGL_OPENGL_ES_BIT }, - { "st_api_OpenVG", EGL_OPENVG_BIT }, - { "st_api_OpenGL_ES2", EGL_OPENGL_ES2_BIT }, - { "st_api_OpenGL", EGL_OPENGL_BIT }, -}; - -const struct egl_g3d_st * -egl_g3d_get_st(enum egl_g3d_st_api api) -{ - static struct egl_g3d_st all_trackers[NUM_EGL_G3D_STS]; - - if (egl_g3d_init_st(&all_trackers[api], egl_g3d_st_info[api].symbol)) { - all_trackers[api].api_bit = egl_g3d_st_info[api].api_bit; - return &all_trackers[api]; - } - else { - return NULL; - } -} diff --git a/src/gallium/state_trackers/egl_g3d/common/egl_st.h b/src/gallium/state_trackers/egl_g3d/common/egl_st.h deleted file mode 100644 index 8fb464bd3d..0000000000 --- a/src/gallium/state_trackers/egl_g3d/common/egl_st.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009-2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL 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. - */ - -#ifndef _EGL_ST_H_ -#define _EGL_ST_H_ - -#include "GL/gl.h" /* for GL types */ -#include "GL/internal/glcore.h" /* for __GLcontextModes */ - -#include "pipe/p_compiler.h" -#include "pipe/p_format.h" -#include "pipe/p_context.h" - -/* avoid calling st functions directly */ -#if 1 - -#define ST_SURFACE_FRONT_LEFT 0 -#define ST_SURFACE_BACK_LEFT 1 -#define ST_SURFACE_FRONT_RIGHT 2 -#define ST_SURFACE_BACK_RIGHT 3 - -#define ST_TEXTURE_2D 0x2 - -struct st_context; -struct st_framebuffer; -typedef void (*st_proc)(); - -#else -#include "state_tracker/st_public.h" -#endif - -/* remember to update egl_g3d_get_st() when update the enums */ -enum egl_g3d_st_api { - EGL_G3D_ST_OPENGL_ES = 0, - EGL_G3D_ST_OPENVG, - EGL_G3D_ST_OPENGL_ES2, - EGL_G3D_ST_OPENGL, - - NUM_EGL_G3D_STS -}; - -struct egl_g3d_st { -#define ST_PUBLIC(name, ret, ...) ret (*name)(__VA_ARGS__); -#include "st_public_tmp.h" - /* fields must be added here */ - EGLint api_bit; -}; - -const struct egl_g3d_st * -egl_g3d_get_st(enum egl_g3d_st_api api); - -#endif /* _EGL_ST_H_ */ diff --git a/src/gallium/state_trackers/egl_g3d/common/native.h b/src/gallium/state_trackers/egl_g3d/common/native.h deleted file mode 100644 index 72a9cec7ef..0000000000 --- a/src/gallium/state_trackers/egl_g3d/common/native.h +++ /dev/null @@ -1,277 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009-2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL 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. - */ - -#ifndef _NATIVE_H_ -#define _NATIVE_H_ - -#include "EGL/egl.h" /* for EGL native types */ -#include "GL/gl.h" /* for GL types needed by __GLcontextModes */ -#include "GL/internal/glcore.h" /* for __GLcontextModes */ - -#include "pipe/p_compiler.h" -#include "pipe/p_screen.h" -#include "pipe/p_context.h" -#include "pipe/p_state.h" - -/** - * Only color buffers are listed. The others are allocated privately through, - * for example, st_renderbuffer_alloc_storage(). - */ -enum native_attachment { - NATIVE_ATTACHMENT_FRONT_LEFT, - NATIVE_ATTACHMENT_BACK_LEFT, - NATIVE_ATTACHMENT_FRONT_RIGHT, - NATIVE_ATTACHMENT_BACK_RIGHT, - - NUM_NATIVE_ATTACHMENTS -}; - -/** - * Enumerations for probe results. - */ -enum native_probe_result { - NATIVE_PROBE_UNKNOWN, - NATIVE_PROBE_FALLBACK, - NATIVE_PROBE_SUPPORTED, - NATIVE_PROBE_EXACT, -}; - -/** - * A probe object for display probe. - */ -struct native_probe { - int magic; - EGLNativeDisplayType display; - void *data; - - void (*destroy)(struct native_probe *nprobe); -}; - -struct native_surface { - void (*destroy)(struct native_surface *nsurf); - - /** - * Swap the front and back buffers so that the back buffer is visible. It - * is no-op if the surface is single-buffered. The contents of the back - * buffer after swapping may or may not be preserved. - */ - boolean (*swap_buffers)(struct native_surface *nsurf); - - /** - * Make the front buffer visible. In some native displays, changes to the - * front buffer might not be visible immediately and require manual flush. - */ - boolean (*flush_frontbuffer)(struct native_surface *nsurf); - - /** - * Validate the buffers of the surface. textures, if not NULL, points to an - * array of size NUM_NATIVE_ATTACHMENTS and the returned textures are owned - * by the caller. A sequence number is also returned. The caller can use - * it to check if anything has changed since the last call. Any of the - * pointers may be NULL and it indicates the caller has no interest in those - * values. - * - * If this function is called multiple times with different attachment - * masks, those not listed in the latest call might be destroyed. This - * behavior might change in the future. - */ - boolean (*validate)(struct native_surface *nsurf, uint attachment_mask, - unsigned int *seq_num, struct pipe_texture **textures, - int *width, int *height); - - /** - * Wait until all native commands affecting the surface has been executed. - */ - void (*wait)(struct native_surface *nsurf); -}; - -struct native_config { - /* __GLcontextModes should go away some day */ - __GLcontextModes mode; - enum pipe_format color_format; - enum pipe_format depth_format; - enum pipe_format stencil_format; - - /* treat it as an additional flag to mode.drawableType */ - boolean scanout_bit; -}; - -struct native_connector { - int dummy; -}; - -struct native_mode { - const char *desc; - int width, height; - int refresh_rate; -}; - -struct native_display_modeset; - -/** - * A pipe winsys abstracts the OS. A pipe screen abstracts the graphcis - * hardware. A native display consists of a pipe winsys, a pipe screen, and - * the native display server. - */ -struct native_display { - /** - * The pipe screen of the native display. - * - * Note that the "flush_frontbuffer" and "update_buffer" callbacks will be - * overridden. - */ - struct pipe_screen *screen; - - void (*destroy)(struct native_display *ndpy); - - /** - * Get the supported configs. The configs are owned by the display, but - * the returned array should be free()ed. - * - * The configs will be converted to EGL config by - * _eglConfigFromContextModesRec and validated by _eglValidateConfig. - * Those failing to pass the test will be skipped. - */ - const struct native_config **(*get_configs)(struct native_display *ndpy, - int *num_configs); - - /** - * Test if a pixmap is supported by the given config. Required unless no - * config has GLX_PIXMAP_BIT set. - * - * This function is usually called to find a config that supports a given - * pixmap. Thus, it is usually called with the same pixmap in a row. - */ - boolean (*is_pixmap_supported)(struct native_display *ndpy, - EGLNativePixmapType pix, - const struct native_config *nconf); - - /** - * Create a pipe context. - */ - struct pipe_context *(*create_context)(struct native_display *ndpy, - void *context_private); - - /** - * Create a window surface. Required unless no config has GLX_WINDOW_BIT - * set. - */ - struct native_surface *(*create_window_surface)(struct native_display *ndpy, - EGLNativeWindowType win, - const struct native_config *nconf); - - /** - * Create a pixmap surface. Required unless no config has GLX_PIXMAP_BIT - * set. - */ - struct native_surface *(*create_pixmap_surface)(struct native_display *ndpy, - EGLNativePixmapType pix, - const struct native_config *nconf); - - /** - * Create a pbuffer surface. Required unless no config has GLX_PBUFFER_BIT - * set. - */ - struct native_surface *(*create_pbuffer_surface)(struct native_display *ndpy, - const struct native_config *nconf, - uint width, uint height); - - const struct native_display_modeset *modeset; -}; - -/** - * Mode setting interface of the native display. It exposes the mode setting - * capabilities of the underlying graphics hardware. - */ -struct native_display_modeset { - /** - * Get the available physical connectors and the number of CRTCs. - */ - const struct native_connector **(*get_connectors)(struct native_display *ndpy, - int *num_connectors, - int *num_crtcs); - - /** - * Get the current supported modes of a connector. The returned modes may - * change every time this function is called and those from previous calls - * might become invalid. - */ - const struct native_mode **(*get_modes)(struct native_display *ndpy, - const struct native_connector *nconn, - int *num_modes); - - /** - * Create a scan-out surface. Required unless no config has - * GLX_SCREEN_BIT_MESA set. - */ - struct native_surface *(*create_scanout_surface)(struct native_display *ndpy, - const struct native_config *nconf, - uint width, uint height); - - /** - * Program the CRTC to output the surface to the given connectors with the - * given mode. When surface is not given, the CRTC is disabled. - * - * This interface does not export a way to query capabilities of the CRTCs. - * The native display usually needs to dynamically map the index to a CRTC - * that supports the given connectors. - */ - boolean (*program)(struct native_display *ndpy, int crtc_idx, - struct native_surface *nsurf, uint x, uint y, - const struct native_connector **nconns, int num_nconns, - const struct native_mode *nmode); -}; - -/** - * Test whether an attachment is set in the mask. - */ -static INLINE boolean -native_attachment_mask_test(uint mask, enum native_attachment att) -{ - return !!(mask & (1 << att)); -} - -/** - * Return a probe object for the given display. - * - * Note that the returned object may be cached and used by different native - * display modules. It allows fast probing when multiple modules probe the - * same display. - */ -struct native_probe * -native_create_probe(EGLNativeDisplayType dpy); - -/** - * Probe the probe object. - */ -enum native_probe_result -native_get_probe_result(struct native_probe *nprobe); - -const char * -native_get_name(void); - -struct native_display * -native_create_display(EGLNativeDisplayType dpy); - -#endif /* _NATIVE_H_ */ diff --git a/src/gallium/state_trackers/egl_g3d/common/st_public_tmp.h b/src/gallium/state_trackers/egl_g3d/common/st_public_tmp.h deleted file mode 100644 index 507a0ec402..0000000000 --- a/src/gallium/state_trackers/egl_g3d/common/st_public_tmp.h +++ /dev/null @@ -1,20 +0,0 @@ -ST_PUBLIC(st_create_context, struct st_context *, struct pipe_context *pipe, const __GLcontextModes *visual, struct st_context *share) -ST_PUBLIC(st_destroy_context, void, struct st_context *st) -ST_PUBLIC(st_copy_context_state, void, struct st_context *dst, struct st_context *src, uint mask) -ST_PUBLIC(st_create_framebuffer, struct st_framebuffer *, const __GLcontextModes *visual, enum pipe_format colorFormat, enum pipe_format depthFormat, enum pipe_format stencilFormat, uint width, uint height, void *privateData) -ST_PUBLIC(st_resize_framebuffer, void, struct st_framebuffer *stfb, uint width, uint height) -ST_PUBLIC(st_set_framebuffer_surface, void, struct st_framebuffer *stfb, uint surfIndex, struct pipe_surface *surf) -ST_PUBLIC(st_get_framebuffer_dimensions, void, struct st_framebuffer *stfb, uint *width, uint *height) -ST_PUBLIC(st_get_framebuffer_surface, int, struct st_framebuffer *stfb, uint surfIndex, struct pipe_surface **surface) -ST_PUBLIC(st_get_framebuffer_texture, int, struct st_framebuffer *stfb, uint surfIndex, struct pipe_texture **texture) -ST_PUBLIC(st_framebuffer_private, void *, struct st_framebuffer *stfb) -ST_PUBLIC(st_unreference_framebuffer, void, struct st_framebuffer *stfb) -ST_PUBLIC(st_make_current, GLboolean, struct st_context *st, struct st_framebuffer *draw, struct st_framebuffer *read) -ST_PUBLIC(st_get_current, struct st_context *, void) -ST_PUBLIC(st_flush, void, struct st_context *st, uint pipeFlushFlags, struct pipe_fence_handle **fence) -ST_PUBLIC(st_finish, void, struct st_context *st) -ST_PUBLIC(st_notify_swapbuffers, void, struct st_framebuffer *stfb) -ST_PUBLIC(st_bind_texture_surface, int, struct pipe_surface *ps, int target, int level, enum pipe_format format) -ST_PUBLIC(st_unbind_texture_surface, int, struct pipe_surface *ps, int target, int level) -ST_PUBLIC(st_get_proc_address, st_proc, const char *procname) -#undef ST_PUBLIC diff --git a/src/gallium/state_trackers/egl_g3d/kms/native_kms.c b/src/gallium/state_trackers/egl_g3d/kms/native_kms.c deleted file mode 100644 index d5baf2c2f0..0000000000 --- a/src/gallium/state_trackers/egl_g3d/kms/native_kms.c +++ /dev/null @@ -1,866 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL 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. - */ - -#include - -#include "pipe/p_screen.h" -#include "pipe/p_context.h" -#include "util/u_debug.h" -#include "util/u_memory.h" -#include "egllog.h" - -#include "native_kms.h" - -static boolean -kms_surface_validate(struct native_surface *nsurf, uint attachment_mask, - unsigned int *seq_num, struct pipe_texture **textures, - int *width, int *height) -{ - struct kms_surface *ksurf = kms_surface(nsurf); - struct kms_display *kdpy = ksurf->kdpy; - struct pipe_screen *screen = kdpy->base.screen; - struct pipe_texture templ, *ptex; - int att; - - if (attachment_mask) { - memset(&templ, 0, sizeof(templ)); - templ.target = PIPE_TEXTURE_2D; - templ.last_level = 0; - templ.width0 = ksurf->width; - templ.height0 = ksurf->height; - templ.depth0 = 1; - templ.format = ksurf->color_format; - templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; - if (ksurf->type == KMS_SURFACE_TYPE_SCANOUT) - templ.tex_usage |= PIPE_TEXTURE_USAGE_PRIMARY; - } - - /* create textures */ - for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { - /* delay the allocation */ - if (!native_attachment_mask_test(attachment_mask, att)) - continue; - - ptex = ksurf->textures[att]; - if (!ptex) { - ptex = screen->texture_create(screen, &templ); - ksurf->textures[att] = ptex; - } - - if (textures) { - textures[att] = NULL; - pipe_texture_reference(&textures[att], ptex); - } - } - - if (seq_num) - *seq_num = ksurf->sequence_number; - if (width) - *width = ksurf->width; - if (height) - *height = ksurf->height; - - return TRUE; -} - -/** - * Add textures as DRM framebuffers. - */ -static boolean -kms_surface_init_framebuffers(struct native_surface *nsurf, boolean need_back) -{ - struct kms_surface *ksurf = kms_surface(nsurf); - struct kms_display *kdpy = ksurf->kdpy; - int num_framebuffers = (need_back) ? 2 : 1; - int i, err; - - for (i = 0; i < num_framebuffers; i++) { - struct kms_framebuffer *fb; - enum native_attachment natt; - unsigned int handle, stride; - uint block_bits; - - if (i == 0) { - fb = &ksurf->front_fb; - natt = NATIVE_ATTACHMENT_FRONT_LEFT; - } - else { - fb = &ksurf->back_fb; - natt = NATIVE_ATTACHMENT_BACK_LEFT; - } - - if (!fb->texture) { - /* make sure the texture has been allocated */ - kms_surface_validate(&ksurf->base, 1 << natt, NULL, NULL, NULL, NULL); - if (!ksurf->textures[natt]) - return FALSE; - - pipe_texture_reference(&fb->texture, ksurf->textures[natt]); - } - - /* already initialized */ - if (fb->buffer_id) - continue; - - /* TODO detect the real value */ - fb->is_passive = TRUE; - - if (!kdpy->api->local_handle_from_texture(kdpy->api, - kdpy->base.screen, fb->texture, &stride, &handle)) - return FALSE; - - block_bits = util_format_get_blocksizebits(ksurf->color_format); - err = drmModeAddFB(kdpy->fd, ksurf->width, ksurf->height, - block_bits, block_bits, stride, handle, &fb->buffer_id); - if (err) { - fb->buffer_id = 0; - return FALSE; - } - } - - return TRUE; -} - -static boolean -kms_surface_flush_frontbuffer(struct native_surface *nsurf) -{ -#ifdef DRM_MODE_FEATURE_DIRTYFB - struct kms_surface *ksurf = kms_surface(nsurf); - struct kms_display *kdpy = ksurf->kdpy; - - /* pbuffer is private */ - if (ksurf->type == KMS_SURFACE_TYPE_PBUFFER) - return TRUE; - - if (ksurf->front_fb.is_passive) - drmModeDirtyFB(kdpy->fd, ksurf->front_fb.buffer_id, NULL, 0); -#endif - - return TRUE; -} - -static boolean -kms_surface_swap_buffers(struct native_surface *nsurf) -{ - struct kms_surface *ksurf = kms_surface(nsurf); - struct kms_crtc *kcrtc = &ksurf->current_crtc; - struct kms_display *kdpy = ksurf->kdpy; - struct kms_framebuffer tmp_fb; - struct pipe_texture *tmp_texture; - int err; - - /* pbuffer is private */ - if (ksurf->type == KMS_SURFACE_TYPE_PBUFFER) - return TRUE; - - if (!ksurf->back_fb.buffer_id) { - if (!kms_surface_init_framebuffers(&ksurf->base, TRUE)) - return FALSE; - } - - if (ksurf->is_shown && kcrtc->crtc) { - err = drmModeSetCrtc(kdpy->fd, kcrtc->crtc->crtc_id, - ksurf->back_fb.buffer_id, kcrtc->crtc->x, kcrtc->crtc->y, - kcrtc->connectors, kcrtc->num_connectors, &kcrtc->crtc->mode); - if (err) - return FALSE; - } - - /* swap the buffers */ - tmp_fb = ksurf->front_fb; - ksurf->front_fb = ksurf->back_fb; - ksurf->back_fb = tmp_fb; - - tmp_texture = ksurf->textures[NATIVE_ATTACHMENT_FRONT_LEFT]; - ksurf->textures[NATIVE_ATTACHMENT_FRONT_LEFT] = - ksurf->textures[NATIVE_ATTACHMENT_BACK_LEFT]; - ksurf->textures[NATIVE_ATTACHMENT_BACK_LEFT] = tmp_texture; - - /* the front/back textures are swapped */ - ksurf->sequence_number++; - - return TRUE; -} - -static void -kms_surface_wait(struct native_surface *nsurf) -{ - /* no-op */ -} - -static void -kms_surface_destroy(struct native_surface *nsurf) -{ - struct kms_surface *ksurf = kms_surface(nsurf); - int i; - - if (ksurf->current_crtc.crtc) - drmModeFreeCrtc(ksurf->current_crtc.crtc); - - if (ksurf->front_fb.buffer_id) - drmModeRmFB(ksurf->kdpy->fd, ksurf->front_fb.buffer_id); - pipe_texture_reference(&ksurf->front_fb.texture, NULL); - - if (ksurf->back_fb.buffer_id) - drmModeRmFB(ksurf->kdpy->fd, ksurf->back_fb.buffer_id); - pipe_texture_reference(&ksurf->back_fb.texture, NULL); - - for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { - struct pipe_texture *ptex = ksurf->textures[i]; - pipe_texture_reference(&ptex, NULL); - } - - free(ksurf); -} - -static struct kms_surface * -kms_display_create_surface(struct native_display *ndpy, - enum kms_surface_type type, - const struct native_config *nconf, - uint width, uint height) -{ - struct kms_display *kdpy = kms_display(ndpy); - struct kms_config *kconf = kms_config(nconf); - struct kms_surface *ksurf; - - ksurf = CALLOC_STRUCT(kms_surface); - if (!ksurf) - return NULL; - - ksurf->kdpy = kdpy; - ksurf->type = type; - ksurf->color_format = kconf->base.color_format; - ksurf->width = width; - ksurf->height = height; - - ksurf->base.destroy = kms_surface_destroy; - ksurf->base.swap_buffers = kms_surface_swap_buffers; - ksurf->base.flush_frontbuffer = kms_surface_flush_frontbuffer; - ksurf->base.validate = kms_surface_validate; - ksurf->base.wait = kms_surface_wait; - - return ksurf; -} - -/** - * Choose a CRTC that supports all given connectors. - */ -static uint32_t -kms_display_choose_crtc(struct native_display *ndpy, - uint32_t *connectors, int num_connectors) -{ - struct kms_display *kdpy = kms_display(ndpy); - int idx; - - for (idx = 0; idx < kdpy->resources->count_crtcs; idx++) { - boolean found_crtc = TRUE; - int i, j; - - for (i = 0; i < num_connectors; i++) { - drmModeConnectorPtr connector; - int encoder_idx = -1; - - connector = drmModeGetConnector(kdpy->fd, connectors[i]); - if (!connector) { - found_crtc = FALSE; - break; - } - - /* find an encoder the CRTC supports */ - for (j = 0; j < connector->count_encoders; j++) { - drmModeEncoderPtr encoder = - drmModeGetEncoder(kdpy->fd, connector->encoders[j]); - if (encoder->possible_crtcs & (1 << idx)) { - encoder_idx = j; - break; - } - drmModeFreeEncoder(encoder); - } - - drmModeFreeConnector(connector); - if (encoder_idx < 0) { - found_crtc = FALSE; - break; - } - } - - if (found_crtc) - break; - } - - if (idx >= kdpy->resources->count_crtcs) { - _eglLog(_EGL_WARNING, - "failed to find a CRTC that supports the given %d connectors", - num_connectors); - return 0; - } - - return kdpy->resources->crtcs[idx]; -} - -/** - * Remember the original CRTC status and set the CRTC - */ -static boolean -kms_display_set_crtc(struct native_display *ndpy, int crtc_idx, - uint32_t buffer_id, uint32_t x, uint32_t y, - uint32_t *connectors, int num_connectors, - drmModeModeInfoPtr mode) -{ - struct kms_display *kdpy = kms_display(ndpy); - struct kms_crtc *kcrtc = &kdpy->saved_crtcs[crtc_idx]; - uint32_t crtc_id; - int err; - - if (kcrtc->crtc) { - crtc_id = kcrtc->crtc->crtc_id; - } - else { - int count = 0, i; - - /* - * Choose the CRTC once. It could be more dynamic, but let's keep it - * simple for now. - */ - crtc_id = kms_display_choose_crtc(&kdpy->base, - connectors, num_connectors); - - /* save the original CRTC status */ - kcrtc->crtc = drmModeGetCrtc(kdpy->fd, crtc_id); - if (!kcrtc->crtc) - return FALSE; - - for (i = 0; i < kdpy->num_connectors; i++) { - struct kms_connector *kconn = &kdpy->connectors[i]; - drmModeConnectorPtr connector = kconn->connector; - drmModeEncoderPtr encoder; - - encoder = drmModeGetEncoder(kdpy->fd, connector->encoder_id); - if (encoder) { - if (encoder->crtc_id == crtc_id) { - kcrtc->connectors[count++] = connector->connector_id; - if (count >= Elements(kcrtc->connectors)) - break; - } - drmModeFreeEncoder(encoder); - } - } - - kcrtc->num_connectors = count; - } - - err = drmModeSetCrtc(kdpy->fd, crtc_id, buffer_id, x, y, - connectors, num_connectors, mode); - if (err) { - drmModeFreeCrtc(kcrtc->crtc); - kcrtc->crtc = NULL; - kcrtc->num_connectors = 0; - - return FALSE; - } - - return TRUE; -} - -static boolean -kms_display_program(struct native_display *ndpy, int crtc_idx, - struct native_surface *nsurf, uint x, uint y, - const struct native_connector **nconns, int num_nconns, - const struct native_mode *nmode) -{ - struct kms_display *kdpy = kms_display(ndpy); - struct kms_surface *ksurf = kms_surface(nsurf); - const struct kms_mode *kmode = kms_mode(nmode); - uint32_t connector_ids[32]; - uint32_t buffer_id; - drmModeModeInfo mode_tmp, *mode; - int i; - - if (num_nconns > Elements(connector_ids)) { - _eglLog(_EGL_WARNING, "too many connectors (%d)", num_nconns); - num_nconns = Elements(connector_ids); - } - - if (ksurf) { - if (!kms_surface_init_framebuffers(&ksurf->base, FALSE)) - return FALSE; - - buffer_id = ksurf->front_fb.buffer_id; - /* the mode argument of drmModeSetCrtc is not constified */ - mode_tmp = kmode->mode; - mode = &mode_tmp; - } - else { - /* disable the CRTC */ - buffer_id = 0; - mode = NULL; - num_nconns = 0; - } - - for (i = 0; i < num_nconns; i++) { - struct kms_connector *kconn = kms_connector(nconns[i]); - connector_ids[i] = kconn->connector->connector_id; - } - - if (!kms_display_set_crtc(&kdpy->base, crtc_idx, buffer_id, x, y, - connector_ids, num_nconns, mode)) { - _eglLog(_EGL_WARNING, "failed to set CRTC %d", crtc_idx); - - return FALSE; - } - - if (kdpy->shown_surfaces[crtc_idx]) - kdpy->shown_surfaces[crtc_idx]->is_shown = FALSE; - kdpy->shown_surfaces[crtc_idx] = ksurf; - - /* remember the settings for buffer swapping */ - if (ksurf) { - uint32_t crtc_id = kdpy->saved_crtcs[crtc_idx].crtc->crtc_id; - struct kms_crtc *kcrtc = &ksurf->current_crtc; - - if (kcrtc->crtc) - drmModeFreeCrtc(kcrtc->crtc); - kcrtc->crtc = drmModeGetCrtc(kdpy->fd, crtc_id); - - assert(num_nconns < Elements(kcrtc->connectors)); - memcpy(kcrtc->connectors, connector_ids, - sizeof(*connector_ids) * num_nconns); - kcrtc->num_connectors = num_nconns; - - ksurf->is_shown = TRUE; - } - - return TRUE; -} - -static const struct native_mode ** -kms_display_get_modes(struct native_display *ndpy, - const struct native_connector *nconn, - int *num_modes) -{ - struct kms_display *kdpy = kms_display(ndpy); - struct kms_connector *kconn = kms_connector(nconn); - const struct native_mode **nmodes_return; - int count, i; - - /* delete old data */ - if (kconn->connector) { - drmModeFreeConnector(kconn->connector); - free(kconn->kms_modes); - - kconn->connector = NULL; - kconn->kms_modes = NULL; - kconn->num_modes = 0; - } - - /* detect again */ - kconn->connector = drmModeGetConnector(kdpy->fd, kconn->connector_id); - if (!kconn->connector) - return NULL; - - count = kconn->connector->count_modes; - kconn->kms_modes = calloc(count, sizeof(*kconn->kms_modes)); - if (!kconn->kms_modes) { - drmModeFreeConnector(kconn->connector); - kconn->connector = NULL; - - return NULL; - } - - for (i = 0; i < count; i++) { - struct kms_mode *kmode = &kconn->kms_modes[i]; - drmModeModeInfoPtr mode = &kconn->connector->modes[i]; - - kmode->mode = *mode; - - kmode->base.desc = kmode->mode.name; - kmode->base.width = kmode->mode.hdisplay; - kmode->base.height = kmode->mode.vdisplay; - kmode->base.refresh_rate = kmode->mode.vrefresh / 1000; - } - - nmodes_return = malloc(count * sizeof(*nmodes_return)); - if (nmodes_return) { - for (i = 0; i < count; i++) - nmodes_return[i] = &kconn->kms_modes[i].base; - if (num_modes) - *num_modes = count; - } - - return nmodes_return; -} - -static const struct native_connector ** -kms_display_get_connectors(struct native_display *ndpy, int *num_connectors, - int *num_crtc) -{ - struct kms_display *kdpy = kms_display(ndpy); - const struct native_connector **connectors; - int i; - - if (!kdpy->connectors) { - kdpy->connectors = - calloc(kdpy->resources->count_connectors, sizeof(*kdpy->connectors)); - if (!kdpy->connectors) - return NULL; - - for (i = 0; i < kdpy->resources->count_connectors; i++) { - struct kms_connector *kconn = &kdpy->connectors[i]; - - kconn->connector_id = kdpy->resources->connectors[i]; - /* kconn->connector is allocated when the modes are asked */ - } - - kdpy->num_connectors = kdpy->resources->count_connectors; - } - - connectors = malloc(kdpy->num_connectors * sizeof(*connectors)); - if (connectors) { - for (i = 0; i < kdpy->num_connectors; i++) - connectors[i] = &kdpy->connectors[i].base; - if (num_connectors) - *num_connectors = kdpy->num_connectors; - } - - if (num_crtc) - *num_crtc = kdpy->resources->count_crtcs; - - return connectors; -} - -static struct native_surface * -kms_display_create_scanout_surface(struct native_display *ndpy, - const struct native_config *nconf, - uint width, uint height) -{ - struct kms_surface *ksurf; - - ksurf = kms_display_create_surface(ndpy, - KMS_SURFACE_TYPE_SCANOUT, nconf, width, height); - return &ksurf->base; -} - -static struct native_surface * -kms_display_create_pbuffer_surface(struct native_display *ndpy, - const struct native_config *nconf, - uint width, uint height) -{ - struct kms_surface *ksurf; - - ksurf = kms_display_create_surface(ndpy, - KMS_SURFACE_TYPE_PBUFFER, nconf, width, height); - return &ksurf->base; -} - -static struct pipe_context * -kms_display_create_context(struct native_display *ndpy, void *context_private) -{ - struct kms_display *kdpy = kms_display(ndpy); - struct pipe_context *pctx; - - pctx = kdpy->api->create_context(kdpy->api, kdpy->base.screen); - if (pctx) - pctx->priv = context_private; - return pctx; -} - -static boolean -kms_display_is_format_supported(struct native_display *ndpy, - enum pipe_format fmt, boolean is_color) -{ - return ndpy->screen->is_format_supported(ndpy->screen, - fmt, PIPE_TEXTURE_2D, - (is_color) ? PIPE_TEXTURE_USAGE_RENDER_TARGET : - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); -} - -static const struct native_config ** -kms_display_get_configs(struct native_display *ndpy, int *num_configs) -{ - struct kms_display *kdpy = kms_display(ndpy); - const struct native_config **configs; - - /* first time */ - if (!kdpy->config) { - struct native_config *nconf; - enum pipe_format format; - - kdpy->config = calloc(1, sizeof(*kdpy->config)); - if (!kdpy->config) - return NULL; - - nconf = &kdpy->config->base; - - /* always double-buffered */ - nconf->mode.doubleBufferMode = TRUE; - - format = PIPE_FORMAT_A8R8G8B8_UNORM; - if (!kms_display_is_format_supported(&kdpy->base, format, TRUE)) { - format = PIPE_FORMAT_B8G8R8A8_UNORM; - if (!kms_display_is_format_supported(&kdpy->base, format, TRUE)) - format = PIPE_FORMAT_NONE; - } - if (format == PIPE_FORMAT_NONE) - return NULL; - - nconf->color_format = format; - nconf->mode.redBits = 8; - nconf->mode.greenBits = 8; - nconf->mode.blueBits = 8; - nconf->mode.alphaBits = 8; - nconf->mode.rgbBits = 32; - - format = PIPE_FORMAT_S8Z24_UNORM; - if (!kms_display_is_format_supported(&kdpy->base, format, FALSE)) { - format = PIPE_FORMAT_Z24S8_UNORM; - if (!kms_display_is_format_supported(&kdpy->base, format, FALSE)) - format = PIPE_FORMAT_NONE; - } - if (format != PIPE_FORMAT_NONE) { - nconf->depth_format = format; - nconf->stencil_format = format; - - nconf->mode.depthBits = 24; - nconf->mode.stencilBits = 8; - nconf->mode.haveDepthBuffer = TRUE; - nconf->mode.haveStencilBuffer = TRUE; - } - - nconf->scanout_bit = TRUE; - nconf->mode.drawableType = GLX_PBUFFER_BIT; - nconf->mode.swapMethod = GLX_SWAP_EXCHANGE_OML; - - nconf->mode.visualID = 0; - nconf->mode.visualType = EGL_NONE; - - nconf->mode.renderType = GLX_RGBA_BIT; - nconf->mode.rgbMode = TRUE; - nconf->mode.xRenderable = FALSE; - } - - configs = malloc(sizeof(*configs)); - if (configs) { - configs[0] = &kdpy->config->base; - if (num_configs) - *num_configs = 1; - } - - return configs; -} - -static void -kms_display_destroy(struct native_display *ndpy) -{ - struct kms_display *kdpy = kms_display(ndpy); - int i; - - if (kdpy->config) - free(kdpy->config); - - if (kdpy->connectors) { - for (i = 0; i < kdpy->num_connectors; i++) { - struct kms_connector *kconn = &kdpy->connectors[i]; - if (kconn->connector) { - drmModeFreeConnector(kconn->connector); - free(kconn->kms_modes); - } - } - free(kdpy->connectors); - } - - if (kdpy->shown_surfaces) - free(kdpy->shown_surfaces); - - if (kdpy->saved_crtcs) { - for (i = 0; i < kdpy->resources->count_crtcs; i++) { - struct kms_crtc *kcrtc = &kdpy->saved_crtcs[i]; - - if (kcrtc->crtc) { - /* restore crtc */ - drmModeSetCrtc(kdpy->fd, kcrtc->crtc->crtc_id, - kcrtc->crtc->buffer_id, kcrtc->crtc->x, kcrtc->crtc->y, - kcrtc->connectors, kcrtc->num_connectors, - &kcrtc->crtc->mode); - - drmModeFreeCrtc(kcrtc->crtc); - } - } - free(kdpy->saved_crtcs); - } - - if (kdpy->resources) - drmModeFreeResources(kdpy->resources); - - if (kdpy->base.screen) - kdpy->base.screen->destroy(kdpy->base.screen); - - if (kdpy->fd >= 0) - drmClose(kdpy->fd); - - if (kdpy->api) - kdpy->api->destroy(kdpy->api); - free(kdpy); -} - -/** - * Initialize KMS and pipe screen. - */ -static boolean -kms_display_init_screen(struct native_display *ndpy) -{ - struct kms_display *kdpy = kms_display(ndpy); - struct drm_create_screen_arg arg; - int fd; - - fd = drmOpen(kdpy->api->name, NULL); - if (fd < 0) { - _eglLog(_EGL_WARNING, "failed to open DRM device"); - return FALSE; - } - -#if 0 - if (drmSetMaster(fd)) { - _eglLog(_EGL_WARNING, "failed to become DRM master"); - return FALSE; - } -#endif - - memset(&arg, 0, sizeof(arg)); - arg.mode = DRM_CREATE_NORMAL; - kdpy->base.screen = kdpy->api->create_screen(kdpy->api, fd, &arg); - if (!kdpy->base.screen) { - _eglLog(_EGL_WARNING, "failed to create DRM screen"); - drmClose(fd); - return FALSE; - } - - kdpy->fd = fd; - - return TRUE; -} - -static struct native_display_modeset kms_display_modeset = { - .get_connectors = kms_display_get_connectors, - .get_modes = kms_display_get_modes, - .create_scanout_surface = kms_display_create_scanout_surface, - .program = kms_display_program -}; - -static struct native_display * -kms_create_display(EGLNativeDisplayType dpy, struct drm_api *api) -{ - struct kms_display *kdpy; - - kdpy = CALLOC_STRUCT(kms_display); - if (!kdpy) - return NULL; - - kdpy->api = api; - if (!kdpy->api) { - _eglLog(_EGL_WARNING, "failed to create DRM API"); - free(kdpy); - return NULL; - } - - kdpy->fd = -1; - if (!kms_display_init_screen(&kdpy->base)) { - kms_display_destroy(&kdpy->base); - return NULL; - } - - /* resources are fixed, unlike crtc, connector, or encoder */ - kdpy->resources = drmModeGetResources(kdpy->fd); - if (!kdpy->resources) { - kms_display_destroy(&kdpy->base); - return NULL; - } - - kdpy->saved_crtcs = - calloc(kdpy->resources->count_crtcs, sizeof(*kdpy->saved_crtcs)); - if (!kdpy->saved_crtcs) { - kms_display_destroy(&kdpy->base); - return NULL; - } - - kdpy->shown_surfaces = - calloc(kdpy->resources->count_crtcs, sizeof(*kdpy->shown_surfaces)); - if (!kdpy->shown_surfaces) { - kms_display_destroy(&kdpy->base); - return NULL; - } - - kdpy->base.destroy = kms_display_destroy; - kdpy->base.get_configs = kms_display_get_configs; - kdpy->base.create_context = kms_display_create_context; - kdpy->base.create_pbuffer_surface = kms_display_create_pbuffer_surface; - - kdpy->base.modeset = &kms_display_modeset; - - return &kdpy->base; -} - -struct native_probe * -native_create_probe(EGLNativeDisplayType dpy) -{ - return NULL; -} - -enum native_probe_result -native_get_probe_result(struct native_probe *nprobe) -{ - return NATIVE_PROBE_UNKNOWN; -} - -/* the api is destroyed with the native display */ -static struct drm_api *drm_api; - -const char * -native_get_name(void) -{ - static char kms_name[32]; - - if (!drm_api) - drm_api = drm_api_create(); - - if (drm_api) - snprintf(kms_name, sizeof(kms_name), "KMS/%s", drm_api->name); - else - snprintf(kms_name, sizeof(kms_name), "KMS"); - - return kms_name; -} - -struct native_display * -native_create_display(EGLNativeDisplayType dpy) -{ - struct native_display *ndpy = NULL; - - if (!drm_api) - drm_api = drm_api_create(); - - if (drm_api) - ndpy = kms_create_display(dpy, drm_api); - - return ndpy; -} diff --git a/src/gallium/state_trackers/egl_g3d/kms/native_kms.h b/src/gallium/state_trackers/egl_g3d/kms/native_kms.h deleted file mode 100644 index 095186e3cf..0000000000 --- a/src/gallium/state_trackers/egl_g3d/kms/native_kms.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL 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. - */ - -#ifndef _NATIVE_KMS_H_ -#define _NATIVE_KMS_H_ - -#include -#include - -#include "pipe/p_compiler.h" -#include "util/u_format.h" -#include "pipe/p_state.h" -#include "state_tracker/drm_api.h" - -#include "common/native.h" - -enum kms_surface_type { - KMS_SURFACE_TYPE_PBUFFER, - KMS_SURFACE_TYPE_SCANOUT -}; - -struct kms_config; -struct kms_connector; -struct kms_mode; - -struct kms_crtc { - drmModeCrtcPtr crtc; - uint32_t connectors[32]; - int num_connectors; -}; - -struct kms_display { - struct native_display base; - - int fd; - struct drm_api *api; - drmModeResPtr resources; - struct kms_config *config; - - struct kms_connector *connectors; - int num_connectors; - - struct kms_surface **shown_surfaces; - /* save the original settings of the CRTCs */ - struct kms_crtc *saved_crtcs; -}; - -struct kms_framebuffer { - struct pipe_texture *texture; - boolean is_passive; - - uint32_t buffer_id; -}; - -struct kms_surface { - struct native_surface base; - enum kms_surface_type type; - enum pipe_format color_format; - struct kms_display *kdpy; - int width, height; - - struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS]; - unsigned int sequence_number; - struct kms_framebuffer front_fb, back_fb; - - boolean is_shown; - struct kms_crtc current_crtc; -}; - -struct kms_config { - struct native_config base; -}; - -struct kms_connector { - struct native_connector base; - - uint32_t connector_id; - drmModeConnectorPtr connector; - struct kms_mode *kms_modes; - int num_modes; -}; - -struct kms_mode { - struct native_mode base; - drmModeModeInfo mode; -}; - -static INLINE struct kms_display * -kms_display(const struct native_display *ndpy) -{ - return (struct kms_display *) ndpy; -} - -static INLINE struct kms_surface * -kms_surface(const struct native_surface *nsurf) -{ - return (struct kms_surface *) nsurf; -} - -static INLINE struct kms_config * -kms_config(const struct native_config *nconf) -{ - return (struct kms_config *) nconf; -} - -static INLINE struct kms_connector * -kms_connector(const struct native_connector *nconn) -{ - return (struct kms_connector *) nconn; -} - -static INLINE struct kms_mode * -kms_mode(const struct native_mode *nmode) -{ - return (struct kms_mode *) nmode; -} - -#endif /* _NATIVE_KMS_H_ */ diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c b/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c deleted file mode 100644 index 07f82d878c..0000000000 --- a/src/gallium/state_trackers/egl_g3d/x11/native_dri2.c +++ /dev/null @@ -1,705 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009-2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL 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. - */ - -#include "util/u_memory.h" -#include "util/u_math.h" -#include "util/u_format.h" -#include "pipe/p_compiler.h" -#include "pipe/p_screen.h" -#include "pipe/p_context.h" -#include "pipe/p_state.h" -#include "state_tracker/drm_api.h" -#include "egllog.h" - -#include "native_x11.h" -#include "x11_screen.h" - -enum dri2_surface_type { - DRI2_SURFACE_TYPE_WINDOW, - DRI2_SURFACE_TYPE_PIXMAP, - DRI2_SURFACE_TYPE_PBUFFER -}; - -struct dri2_display { - struct native_display base; - Display *dpy; - boolean own_dpy; - - struct drm_api *api; - struct x11_screen *xscr; - int xscr_number; - - struct dri2_config *configs; - int num_configs; -}; - -struct dri2_surface { - struct native_surface base; - Drawable drawable; - enum dri2_surface_type type; - enum pipe_format color_format; - struct dri2_display *dri2dpy; - - struct pipe_texture *pbuffer_textures[NUM_NATIVE_ATTACHMENTS]; - boolean have_back, have_fake; - int width, height; - unsigned int sequence_number; -}; - -struct dri2_config { - struct native_config base; -}; - -static INLINE struct dri2_display * -dri2_display(const struct native_display *ndpy) -{ - return (struct dri2_display *) ndpy; -} - -static INLINE struct dri2_surface * -dri2_surface(const struct native_surface *nsurf) -{ - return (struct dri2_surface *) nsurf; -} - -static INLINE struct dri2_config * -dri2_config(const struct native_config *nconf) -{ - return (struct dri2_config *) nconf; -} - -static boolean -dri2_surface_flush_frontbuffer(struct native_surface *nsurf) -{ - struct dri2_surface *dri2surf = dri2_surface(nsurf); - struct dri2_display *dri2dpy = dri2surf->dri2dpy; - - /* pbuffer is private */ - if (dri2surf->type == DRI2_SURFACE_TYPE_PBUFFER) - return TRUE; - - /* copy to real front buffer */ - if (dri2surf->have_fake) - x11_drawable_copy_buffers(dri2dpy->xscr, dri2surf->drawable, - 0, 0, dri2surf->width, dri2surf->height, - DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft); - - return TRUE; -} - -static boolean -dri2_surface_swap_buffers(struct native_surface *nsurf) -{ - struct dri2_surface *dri2surf = dri2_surface(nsurf); - struct dri2_display *dri2dpy = dri2surf->dri2dpy; - - /* pbuffer is private */ - if (dri2surf->type == DRI2_SURFACE_TYPE_PBUFFER) - return TRUE; - - /* copy to front buffer */ - if (dri2surf->have_back) - x11_drawable_copy_buffers(dri2dpy->xscr, dri2surf->drawable, - 0, 0, dri2surf->width, dri2surf->height, - DRI2BufferBackLeft, DRI2BufferFrontLeft); - - /* and update fake front buffer */ - if (dri2surf->have_fake) - x11_drawable_copy_buffers(dri2dpy->xscr, dri2surf->drawable, - 0, 0, dri2surf->width, dri2surf->height, - DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft); - - return TRUE; -} - -static boolean -dri2_surface_validate(struct native_surface *nsurf, uint attachment_mask, - unsigned int *seq_num, struct pipe_texture **textures, - int *width, int *height) -{ - struct dri2_surface *dri2surf = dri2_surface(nsurf); - struct dri2_display *dri2dpy = dri2surf->dri2dpy; - unsigned int dri2atts[NUM_NATIVE_ATTACHMENTS]; - struct pipe_texture templ; - struct x11_drawable_buffer *xbufs; - int num_ins, num_outs, att, i; - - if (attachment_mask) { - memset(&templ, 0, sizeof(templ)); - templ.target = PIPE_TEXTURE_2D; - templ.last_level = 0; - templ.width0 = dri2surf->width; - templ.height0 = dri2surf->height; - templ.depth0 = 1; - templ.format = dri2surf->color_format; - templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; - - if (textures) - memset(textures, 0, sizeof(*textures) * NUM_NATIVE_ATTACHMENTS); - } - - /* create textures for pbuffer */ - if (dri2surf->type == DRI2_SURFACE_TYPE_PBUFFER) { - struct pipe_screen *screen = dri2dpy->base.screen; - - for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { - struct pipe_texture *ptex = dri2surf->pbuffer_textures[att]; - - /* delay the allocation */ - if (!native_attachment_mask_test(attachment_mask, att)) - continue; - - if (!ptex) { - ptex = screen->texture_create(screen, &templ); - dri2surf->pbuffer_textures[att] = ptex; - } - - if (textures) - pipe_texture_reference(&textures[att], ptex); - } - - if (seq_num) - *seq_num = dri2surf->sequence_number; - if (width) - *width = dri2surf->width; - if (height) - *height = dri2surf->height; - - return TRUE; - } - - /* prepare the attachments */ - num_ins = 0; - for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { - if (native_attachment_mask_test(attachment_mask, att)) { - unsigned int dri2att; - - switch (att) { - case NATIVE_ATTACHMENT_FRONT_LEFT: - dri2att = DRI2BufferFrontLeft; - break; - case NATIVE_ATTACHMENT_BACK_LEFT: - dri2att = DRI2BufferBackLeft; - break; - case NATIVE_ATTACHMENT_FRONT_RIGHT: - dri2att = DRI2BufferFrontRight; - break; - case NATIVE_ATTACHMENT_BACK_RIGHT: - dri2att = DRI2BufferBackRight; - break; - default: - assert(0); - dri2att = 0; - break; - } - - dri2atts[num_ins] = dri2att; - num_ins++; - } - } - - dri2surf->have_back = FALSE; - dri2surf->have_fake = FALSE; - - /* remember old geometry */ - templ.width0 = dri2surf->width; - templ.height0 = dri2surf->height; - - xbufs = x11_drawable_get_buffers(dri2dpy->xscr, dri2surf->drawable, - &dri2surf->width, &dri2surf->height, - dri2atts, FALSE, num_ins, &num_outs); - if (!xbufs) - return FALSE; - - if (templ.width0 != dri2surf->width || templ.height0 != dri2surf->height) { - /* are there cases where the buffers change and the geometry doesn't? */ - dri2surf->sequence_number++; - - templ.width0 = dri2surf->width; - templ.height0 = dri2surf->height; - } - - for (i = 0; i < num_outs; i++) { - struct x11_drawable_buffer *xbuf = &xbufs[i]; - const char *desc; - enum native_attachment natt; - - switch (xbuf->attachment) { - case DRI2BufferFrontLeft: - natt = NATIVE_ATTACHMENT_FRONT_LEFT; - desc = "DRI2 Front Buffer"; - break; - case DRI2BufferFakeFrontLeft: - natt = NATIVE_ATTACHMENT_FRONT_LEFT; - desc = "DRI2 Fake Front Buffer"; - dri2surf->have_fake = TRUE; - break; - case DRI2BufferBackLeft: - natt = NATIVE_ATTACHMENT_BACK_LEFT; - desc = "DRI2 Back Buffer"; - dri2surf->have_back = TRUE; - break; - default: - desc = NULL; - break; - } - - if (!desc || !native_attachment_mask_test(attachment_mask, natt) || - (textures && textures[natt])) { - if (!desc) - _eglLog(_EGL_WARNING, "unknown buffer %d", xbuf->attachment); - else if (!native_attachment_mask_test(attachment_mask, natt)) - _eglLog(_EGL_WARNING, "unexpected buffer %d", xbuf->attachment); - else - _eglLog(_EGL_WARNING, "both real and fake front buffers are listed"); - continue; - } - - if (textures) { - struct pipe_texture *ptex = - dri2dpy->api->texture_from_shared_handle(dri2dpy->api, - dri2dpy->base.screen, &templ, - desc, xbuf->pitch, xbuf->name); - if (ptex) { - /* the caller owns the textures */ - textures[natt] = ptex; - } - } - } - - free(xbufs); - - if (seq_num) - *seq_num = dri2surf->sequence_number; - if (width) - *width = dri2surf->width; - if (height) - *height = dri2surf->height; - - return TRUE; -} - -static void -dri2_surface_wait(struct native_surface *nsurf) -{ - struct dri2_surface *dri2surf = dri2_surface(nsurf); - struct dri2_display *dri2dpy = dri2surf->dri2dpy; - - if (dri2surf->have_fake) { - x11_drawable_copy_buffers(dri2dpy->xscr, dri2surf->drawable, - 0, 0, dri2surf->width, dri2surf->height, - DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft); - } -} - -static void -dri2_surface_destroy(struct native_surface *nsurf) -{ - struct dri2_surface *dri2surf = dri2_surface(nsurf); - int i; - - for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { - struct pipe_texture *ptex = dri2surf->pbuffer_textures[i]; - pipe_texture_reference(&ptex, NULL); - } - - if (dri2surf->drawable) - x11_drawable_enable_dri2(dri2surf->dri2dpy->xscr, - dri2surf->drawable, FALSE); - free(dri2surf); -} - -static struct dri2_surface * -dri2_display_create_surface(struct native_display *ndpy, - enum dri2_surface_type type, - Drawable drawable, - const struct native_config *nconf) -{ - struct dri2_display *dri2dpy = dri2_display(ndpy); - struct dri2_config *dri2conf = dri2_config(nconf); - struct dri2_surface *dri2surf; - - dri2surf = CALLOC_STRUCT(dri2_surface); - if (!dri2surf) - return NULL; - - if (drawable) - x11_drawable_enable_dri2(dri2dpy->xscr, drawable, TRUE); - - dri2surf->dri2dpy = dri2dpy; - dri2surf->type = type; - dri2surf->drawable = drawable; - dri2surf->color_format = dri2conf->base.color_format; - - dri2surf->base.destroy = dri2_surface_destroy; - dri2surf->base.swap_buffers = dri2_surface_swap_buffers; - dri2surf->base.flush_frontbuffer = dri2_surface_flush_frontbuffer; - dri2surf->base.validate = dri2_surface_validate; - dri2surf->base.wait = dri2_surface_wait; - - return dri2surf; -} - -static struct native_surface * -dri2_display_create_window_surface(struct native_display *ndpy, - EGLNativeWindowType win, - const struct native_config *nconf) -{ - struct dri2_surface *dri2surf; - - dri2surf = dri2_display_create_surface(ndpy, DRI2_SURFACE_TYPE_WINDOW, - (Drawable) win, nconf); - return (dri2surf) ? &dri2surf->base : NULL; -} - -static struct native_surface * -dri2_display_create_pixmap_surface(struct native_display *ndpy, - EGLNativePixmapType pix, - const struct native_config *nconf) -{ - struct dri2_surface *dri2surf; - - dri2surf = dri2_display_create_surface(ndpy, DRI2_SURFACE_TYPE_PIXMAP, - (Drawable) pix, nconf); - return (dri2surf) ? &dri2surf->base : NULL; -} - -static struct native_surface * -dri2_display_create_pbuffer_surface(struct native_display *ndpy, - const struct native_config *nconf, - uint width, uint height) -{ - struct dri2_surface *dri2surf; - - dri2surf = dri2_display_create_surface(ndpy, DRI2_SURFACE_TYPE_PBUFFER, - (Drawable) None, nconf); - if (dri2surf) { - dri2surf->width = width; - dri2surf->height = height; - } - return (dri2surf) ? &dri2surf->base : NULL; -} - -static struct pipe_context * -dri2_display_create_context(struct native_display *ndpy, void *context_private) -{ - struct dri2_display *dri2dpy = dri2_display(ndpy); - struct pipe_context *pctx; - - pctx = dri2dpy->api->create_context(dri2dpy->api, dri2dpy->base.screen); - if (pctx) - pctx->priv = context_private; - return pctx; -} - -static int -choose_color_format(const __GLcontextModes *mode, enum pipe_format formats[32]) -{ - int count = 0; - - switch (mode->rgbBits) { - case 32: - formats[count++] = PIPE_FORMAT_A8R8G8B8_UNORM; - formats[count++] = PIPE_FORMAT_B8G8R8A8_UNORM; - break; - case 24: - formats[count++] = PIPE_FORMAT_X8R8G8B8_UNORM; - formats[count++] = PIPE_FORMAT_B8G8R8X8_UNORM; - formats[count++] = PIPE_FORMAT_A8R8G8B8_UNORM; - formats[count++] = PIPE_FORMAT_B8G8R8A8_UNORM; - break; - case 16: - formats[count++] = PIPE_FORMAT_R5G6B5_UNORM; - break; - default: - break; - } - - return count; -} - -static int -choose_depth_stencil_format(const __GLcontextModes *mode, - enum pipe_format formats[32]) -{ - int count = 0; - - switch (mode->depthBits) { - case 32: - formats[count++] = PIPE_FORMAT_Z32_UNORM; - break; - case 24: - if (mode->stencilBits) { - formats[count++] = PIPE_FORMAT_S8Z24_UNORM; - formats[count++] = PIPE_FORMAT_Z24S8_UNORM; - } - else { - formats[count++] = PIPE_FORMAT_X8Z24_UNORM; - formats[count++] = PIPE_FORMAT_Z24X8_UNORM; - } - break; - case 16: - formats[count++] = PIPE_FORMAT_Z16_UNORM; - break; - default: - break; - } - - return count; -} - -static boolean -is_format_supported(struct pipe_screen *screen, - enum pipe_format fmt, boolean is_color) -{ - return screen->is_format_supported(screen, fmt, PIPE_TEXTURE_2D, - (is_color) ? PIPE_TEXTURE_USAGE_RENDER_TARGET : - PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); -} - -static boolean -dri2_display_convert_config(struct native_display *ndpy, - const __GLcontextModes *mode, - struct native_config *nconf) -{ - enum pipe_format formats[32]; - int num_formats, i; - - if (!(mode->renderType & GLX_RGBA_BIT) || !mode->rgbMode) - return FALSE; - - /* skip single-buffered configs */ - if (!mode->doubleBufferMode) - return FALSE; - - nconf->mode = *mode; - nconf->mode.renderType = GLX_RGBA_BIT; - nconf->mode.rgbMode = TRUE; - /* pbuffer is allocated locally and is always supported */ - nconf->mode.drawableType |= GLX_PBUFFER_BIT; - /* the swap method is always copy */ - nconf->mode.swapMethod = GLX_SWAP_COPY_OML; - - /* fix up */ - nconf->mode.rgbBits = - nconf->mode.redBits + nconf->mode.greenBits + - nconf->mode.blueBits + nconf->mode.alphaBits; - if (!(nconf->mode.drawableType & GLX_WINDOW_BIT)) { - nconf->mode.visualID = 0; - nconf->mode.visualType = GLX_NONE; - } - if (!(nconf->mode.drawableType & GLX_PBUFFER_BIT)) { - nconf->mode.bindToTextureRgb = FALSE; - nconf->mode.bindToTextureRgba = FALSE; - } - - nconf->color_format = PIPE_FORMAT_NONE; - nconf->depth_format = PIPE_FORMAT_NONE; - nconf->stencil_format = PIPE_FORMAT_NONE; - - /* choose color format */ - num_formats = choose_color_format(mode, formats); - for (i = 0; i < num_formats; i++) { - if (is_format_supported(ndpy->screen, formats[i], TRUE)) { - nconf->color_format = formats[i]; - break; - } - } - if (nconf->color_format == PIPE_FORMAT_NONE) - return FALSE; - - /* choose depth/stencil format */ - num_formats = choose_depth_stencil_format(mode, formats); - for (i = 0; i < num_formats; i++) { - if (is_format_supported(ndpy->screen, formats[i], FALSE)) { - nconf->depth_format = formats[i]; - nconf->stencil_format = formats[i]; - break; - } - } - if ((nconf->mode.depthBits && nconf->depth_format == PIPE_FORMAT_NONE) || - (nconf->mode.stencilBits && nconf->stencil_format == PIPE_FORMAT_NONE)) - return FALSE; - - return TRUE; -} - -static const struct native_config ** -dri2_display_get_configs(struct native_display *ndpy, int *num_configs) -{ - struct dri2_display *dri2dpy = dri2_display(ndpy); - const struct native_config **configs; - int i; - - /* first time */ - if (!dri2dpy->configs) { - const __GLcontextModes *modes; - int num_modes, count; - - modes = x11_screen_get_glx_configs(dri2dpy->xscr); - if (!modes) - return NULL; - num_modes = x11_context_modes_count(modes); - - dri2dpy->configs = calloc(num_modes, sizeof(*dri2dpy->configs)); - if (!dri2dpy->configs) - return NULL; - - count = 0; - for (i = 0; i < num_modes; i++) { - struct native_config *nconf = &dri2dpy->configs[count].base; - if (dri2_display_convert_config(&dri2dpy->base, modes, nconf)) - count++; - modes = modes->next; - } - - dri2dpy->num_configs = count; - } - - configs = malloc(dri2dpy->num_configs * sizeof(*configs)); - if (configs) { - for (i = 0; i < dri2dpy->num_configs; i++) - configs[i] = (const struct native_config *) &dri2dpy->configs[i]; - if (num_configs) - *num_configs = dri2dpy->num_configs; - } - - return configs; -} - -static boolean -dri2_display_is_pixmap_supported(struct native_display *ndpy, - EGLNativePixmapType pix, - const struct native_config *nconf) -{ - struct dri2_display *dri2dpy = dri2_display(ndpy); - uint depth, nconf_depth; - - depth = x11_drawable_get_depth(dri2dpy->xscr, (Drawable) pix); - nconf_depth = util_format_get_blocksizebits(nconf->color_format); - - /* simple depth match for now */ - return (depth == nconf_depth || (depth == 24 && depth + 8 == nconf_depth)); -} - -static void -dri2_display_destroy(struct native_display *ndpy) -{ - struct dri2_display *dri2dpy = dri2_display(ndpy); - - if (dri2dpy->configs) - free(dri2dpy->configs); - - if (dri2dpy->base.screen) - dri2dpy->base.screen->destroy(dri2dpy->base.screen); - - if (dri2dpy->xscr) - x11_screen_destroy(dri2dpy->xscr); - if (dri2dpy->own_dpy) - XCloseDisplay(dri2dpy->dpy); - if (dri2dpy->api && dri2dpy->api->destroy) - dri2dpy->api->destroy(dri2dpy->api); - free(dri2dpy); -} - -/** - * Initialize DRI2 and pipe screen. - */ -static boolean -dri2_display_init_screen(struct native_display *ndpy) -{ - struct dri2_display *dri2dpy = dri2_display(ndpy); - const char *driver = dri2dpy->api->name; - struct drm_create_screen_arg arg; - int fd; - - if (!x11_screen_support(dri2dpy->xscr, X11_SCREEN_EXTENSION_DRI2) || - !x11_screen_support(dri2dpy->xscr, X11_SCREEN_EXTENSION_GLX)) { - _eglLog(_EGL_WARNING, "GLX/DRI2 is not supported"); - return FALSE; - } - - fd = x11_screen_enable_dri2(dri2dpy->xscr, driver); - if (fd < 0) - return FALSE; - - memset(&arg, 0, sizeof(arg)); - arg.mode = DRM_CREATE_NORMAL; - dri2dpy->base.screen = dri2dpy->api->create_screen(dri2dpy->api, fd, &arg); - if (!dri2dpy->base.screen) { - _eglLog(_EGL_WARNING, "failed to create DRM screen"); - return FALSE; - } - - return TRUE; -} - -struct native_display * -x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api) -{ - struct dri2_display *dri2dpy; - - dri2dpy = CALLOC_STRUCT(dri2_display); - if (!dri2dpy) - return NULL; - - dri2dpy->api = api; - if (!dri2dpy->api) { - _eglLog(_EGL_WARNING, "failed to create DRM API"); - free(dri2dpy); - return NULL; - } - - dri2dpy->dpy = dpy; - if (!dri2dpy->dpy) { - dri2dpy->dpy = XOpenDisplay(NULL); - if (!dri2dpy->dpy) { - dri2_display_destroy(&dri2dpy->base); - return NULL; - } - dri2dpy->own_dpy = TRUE; - } - - dri2dpy->xscr_number = DefaultScreen(dri2dpy->dpy); - dri2dpy->xscr = x11_screen_create(dri2dpy->dpy, dri2dpy->xscr_number); - if (!dri2dpy->xscr) { - dri2_display_destroy(&dri2dpy->base); - return NULL; - } - - if (!dri2_display_init_screen(&dri2dpy->base)) { - dri2_display_destroy(&dri2dpy->base); - return NULL; - } - - dri2dpy->base.destroy = dri2_display_destroy; - dri2dpy->base.get_configs = dri2_display_get_configs; - dri2dpy->base.is_pixmap_supported = dri2_display_is_pixmap_supported; - dri2dpy->base.create_context = dri2_display_create_context; - dri2dpy->base.create_window_surface = dri2_display_create_window_surface; - dri2dpy->base.create_pixmap_surface = dri2_display_create_pixmap_surface; - dri2dpy->base.create_pbuffer_surface = dri2_display_create_pbuffer_surface; - - return &dri2dpy->base; -} diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_x11.c b/src/gallium/state_trackers/egl_g3d/x11/native_x11.c deleted file mode 100644 index 695ab88010..0000000000 --- a/src/gallium/state_trackers/egl_g3d/x11/native_x11.c +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009-2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL 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. - */ - -#include -#include "util/u_debug.h" -#include "util/u_memory.h" -#include "state_tracker/drm_api.h" -#include "egllog.h" - -#include "native_x11.h" -#include "x11_screen.h" - -#define X11_PROBE_MAGIC 0x11980BE /* "X11PROBE" */ - -static struct drm_api *api; - -static void -x11_probe_destroy(struct native_probe *nprobe) -{ - if (nprobe->data) - free(nprobe->data); - free(nprobe); -} - -struct native_probe * -native_create_probe(EGLNativeDisplayType dpy) -{ - struct native_probe *nprobe; - struct x11_screen *xscr; - int scr; - const char *driver_name = NULL; - Display *xdpy; - - nprobe = CALLOC_STRUCT(native_probe); - if (!nprobe) - return NULL; - - xdpy = dpy; - if (!xdpy) { - xdpy = XOpenDisplay(NULL); - if (!xdpy) { - free(nprobe); - return NULL; - } - } - - scr = DefaultScreen(xdpy); - xscr = x11_screen_create(xdpy, scr); - if (xscr) { - if (x11_screen_support(xscr, X11_SCREEN_EXTENSION_DRI2)) { - driver_name = x11_screen_probe_dri2(xscr); - nprobe->data = strdup(driver_name); - } - - x11_screen_destroy(xscr); - } - - if (xdpy != dpy) - XCloseDisplay(xdpy); - - nprobe->magic = X11_PROBE_MAGIC; - nprobe->display = dpy; - - nprobe->destroy = x11_probe_destroy; - - return nprobe; -} - -enum native_probe_result -native_get_probe_result(struct native_probe *nprobe) -{ - if (!nprobe || nprobe->magic != X11_PROBE_MAGIC) - return NATIVE_PROBE_UNKNOWN; - - if (!api) - api = drm_api_create(); - - /* this is a software driver */ - if (!api) - return NATIVE_PROBE_SUPPORTED; - - /* the display does not support DRI2 or the driver mismatches */ - if (!nprobe->data || strcmp(api->name, (const char *) nprobe->data) != 0) - return NATIVE_PROBE_FALLBACK; - - return NATIVE_PROBE_EXACT; -} - -const char * -native_get_name(void) -{ - static char x11_name[32]; - - if (!api) - api = drm_api_create(); - - if (api) - snprintf(x11_name, sizeof(x11_name), "X11/%s", api->name); - else - snprintf(x11_name, sizeof(x11_name), "X11"); - - return x11_name; -} - -struct native_display * -native_create_display(EGLNativeDisplayType dpy) -{ - struct native_display *ndpy = NULL; - boolean force_sw; - - if (!api) - api = drm_api_create(); - - force_sw = debug_get_bool_option("EGL_SOFTWARE", FALSE); - if (api && !force_sw) { - ndpy = x11_create_dri2_display(dpy, api); - } - - if (!ndpy) { - EGLint level = (force_sw) ? _EGL_INFO : _EGL_WARNING; - - _eglLog(level, "use software fallback"); - ndpy = x11_create_ximage_display(dpy, TRUE); - } - - return ndpy; -} diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_x11.h b/src/gallium/state_trackers/egl_g3d/x11/native_x11.h deleted file mode 100644 index 622ddac5df..0000000000 --- a/src/gallium/state_trackers/egl_g3d/x11/native_x11.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009-2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL 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. - */ - -#ifndef _NATIVE_X11_H_ -#define _NATIVE_X11_H_ - -#include "state_tracker/drm_api.h" -#include "common/native.h" - -struct native_display * -x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm); - -struct native_display * -x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api); - -#endif /* _NATIVE_X11_H_ */ diff --git a/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c b/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c deleted file mode 100644 index dfa8df2223..0000000000 --- a/src/gallium/state_trackers/egl_g3d/x11/native_ximage.c +++ /dev/null @@ -1,694 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009-2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL 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. - */ - -#include -#include -#include -#include -#include -#include -#include -#include "util/u_memory.h" -#include "util/u_math.h" -#include "util/u_format.h" -#include "pipe/p_compiler.h" -#include "pipe/internal/p_winsys_screen.h" -#include "softpipe/sp_winsys.h" -#include "egllog.h" - -#include "sw_winsys.h" -#include "native_x11.h" -#include "x11_screen.h" - -enum ximage_surface_type { - XIMAGE_SURFACE_TYPE_WINDOW, - XIMAGE_SURFACE_TYPE_PIXMAP, - XIMAGE_SURFACE_TYPE_PBUFFER -}; - -struct ximage_display { - struct native_display base; - Display *dpy; - boolean own_dpy; - - struct x11_screen *xscr; - int xscr_number; - - boolean use_xshm; - - struct pipe_winsys *winsys; - struct ximage_config *configs; - int num_configs; -}; - -struct ximage_buffer { - XImage *ximage; - - struct pipe_texture *texture; - XShmSegmentInfo *shm_info; - boolean xshm_attached; -}; - -struct ximage_surface { - struct native_surface base; - Drawable drawable; - enum ximage_surface_type type; - enum pipe_format color_format; - XVisualInfo visual; - struct ximage_display *xdpy; - - int width, height; - GC gc; - - struct ximage_buffer buffers[NUM_NATIVE_ATTACHMENTS]; - unsigned int sequence_number; -}; - -struct ximage_config { - struct native_config base; - const XVisualInfo *visual; -}; - -static INLINE struct ximage_display * -ximage_display(const struct native_display *ndpy) -{ - return (struct ximage_display *) ndpy; -} - -static INLINE struct ximage_surface * -ximage_surface(const struct native_surface *nsurf) -{ - return (struct ximage_surface *) nsurf; -} - -static INLINE struct ximage_config * -ximage_config(const struct native_config *nconf) -{ - return (struct ximage_config *) nconf; -} - -static void -ximage_surface_free_buffer(struct native_surface *nsurf, - enum native_attachment which) -{ - struct ximage_surface *xsurf = ximage_surface(nsurf); - struct ximage_buffer *xbuf = &xsurf->buffers[which]; - - pipe_texture_reference(&xbuf->texture, NULL); - - if (xbuf->shm_info) { - if (xbuf->xshm_attached) - XShmDetach(xsurf->xdpy->dpy, xbuf->shm_info); - if (xbuf->shm_info->shmaddr != (void *) -1) - shmdt(xbuf->shm_info->shmaddr); - if (xbuf->shm_info->shmid != -1) - shmctl(xbuf->shm_info->shmid, IPC_RMID, 0); - - xbuf->shm_info->shmaddr = (void *) -1; - xbuf->shm_info->shmid = -1; - } -} - -static boolean -ximage_surface_alloc_buffer(struct native_surface *nsurf, - enum native_attachment which) -{ - struct ximage_surface *xsurf = ximage_surface(nsurf); - struct ximage_buffer *xbuf = &xsurf->buffers[which]; - struct pipe_screen *screen = xsurf->xdpy->base.screen; - struct pipe_texture templ; - - /* free old data */ - if (xbuf->texture) - ximage_surface_free_buffer(&xsurf->base, which); - - memset(&templ, 0, sizeof(templ)); - templ.target = PIPE_TEXTURE_2D; - templ.format = xsurf->color_format; - templ.width0 = xsurf->width; - templ.height0 = xsurf->height; - templ.depth0 = 1; - templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; - - if (xbuf->shm_info) { - struct pipe_buffer *pbuf; - unsigned stride, size; - void *addr = NULL; - - stride = util_format_get_stride(xsurf->color_format, xsurf->width); - /* alignment should depend on visual? */ - stride = align(stride, 4); - size = stride * xsurf->height; - - /* create and attach shm object */ - xbuf->shm_info->shmid = shmget(IPC_PRIVATE, size, 0755); - if (xbuf->shm_info->shmid != -1) { - xbuf->shm_info->shmaddr = - shmat(xbuf->shm_info->shmid, NULL, 0); - if (xbuf->shm_info->shmaddr != (void *) -1) { - if (XShmAttach(xsurf->xdpy->dpy, xbuf->shm_info)) { - addr = xbuf->shm_info->shmaddr; - xbuf->xshm_attached = TRUE; - } - } - } - - if (addr) { - pbuf = screen->user_buffer_create(screen, addr, size); - if (pbuf) { - xbuf->texture = - screen->texture_blanket(screen, &templ, &stride, pbuf); - pipe_buffer_reference(&pbuf, NULL); - } - } - } - else { - xbuf->texture = screen->texture_create(screen, &templ); - } - - /* clean up the buffer if allocation failed */ - if (!xbuf->texture) - ximage_surface_free_buffer(&xsurf->base, which); - - return (xbuf->texture != NULL); -} - -static boolean -ximage_surface_draw_buffer(struct native_surface *nsurf, - enum native_attachment which) -{ - struct ximage_surface *xsurf = ximage_surface(nsurf); - struct ximage_buffer *xbuf = &xsurf->buffers[which]; - struct pipe_screen *screen = xsurf->xdpy->base.screen; - struct pipe_transfer *transfer; - - if (xsurf->type == XIMAGE_SURFACE_TYPE_PBUFFER) - return TRUE; - - assert(xsurf->drawable && xbuf->ximage && xbuf->texture); - - transfer = screen->get_tex_transfer(screen, xbuf->texture, - 0, 0, 0, PIPE_TRANSFER_READ, 0, 0, xsurf->width, xsurf->height); - if (!transfer) - return FALSE; - - xbuf->ximage->bytes_per_line = transfer->stride; - xbuf->ximage->data = screen->transfer_map(screen, transfer); - if (!xbuf->ximage->data) { - screen->tex_transfer_destroy(transfer); - return FALSE; - } - - - if (xbuf->shm_info) - XShmPutImage(xsurf->xdpy->dpy, xsurf->drawable, xsurf->gc, - xbuf->ximage, 0, 0, 0, 0, xsurf->width, xsurf->height, False); - else - XPutImage(xsurf->xdpy->dpy, xsurf->drawable, xsurf->gc, - xbuf->ximage, 0, 0, 0, 0, xsurf->width, xsurf->height); - - xbuf->ximage->data = NULL; - screen->transfer_unmap(screen, transfer); - - /* - * softpipe allows the pipe transfer to be re-used, but we don't want to - * rely on that behavior. - */ - screen->tex_transfer_destroy(transfer); - - XSync(xsurf->xdpy->dpy, FALSE); - - return TRUE; -} - -static boolean -ximage_surface_flush_frontbuffer(struct native_surface *nsurf) -{ - return ximage_surface_draw_buffer(nsurf, NATIVE_ATTACHMENT_FRONT_LEFT); -} - -static boolean -ximage_surface_swap_buffers(struct native_surface *nsurf) -{ - struct ximage_surface *xsurf = ximage_surface(nsurf); - struct ximage_buffer *xfront, *xback, xtmp; - - xfront = &xsurf->buffers[NATIVE_ATTACHMENT_FRONT_LEFT]; - xback = &xsurf->buffers[NATIVE_ATTACHMENT_BACK_LEFT]; - - /* draw the back buffer directly if there is no front buffer */ - if (!xfront->texture) - return ximage_surface_draw_buffer(nsurf, NATIVE_ATTACHMENT_BACK_LEFT); - - /* swap the buffers */ - xtmp = *xfront; - *xfront = *xback; - *xback = xtmp; - - /* the front/back textures are swapped */ - xsurf->sequence_number++; - - return ximage_surface_draw_buffer(nsurf, NATIVE_ATTACHMENT_FRONT_LEFT); -} - -static void -ximage_surface_update_geometry(struct native_surface *nsurf) -{ - struct ximage_surface *xsurf = ximage_surface(nsurf); - Status ok; - Window root; - int x, y; - unsigned int w, h, border, depth; - - /* pbuffer has fixed geometry */ - if (xsurf->type == XIMAGE_SURFACE_TYPE_PBUFFER) - return; - - ok = XGetGeometry(xsurf->xdpy->dpy, xsurf->drawable, - &root, &x, &y, &w, &h, &border, &depth); - if (ok) { - xsurf->width = w; - xsurf->height = h; - } -} - -static boolean -ximage_surface_validate(struct native_surface *nsurf, uint attachment_mask, - unsigned int *seq_num, struct pipe_texture **textures, - int *width, int *height) -{ - struct ximage_surface *xsurf = ximage_surface(nsurf); - boolean new_buffers = FALSE; - int att; - - ximage_surface_update_geometry(&xsurf->base); - - for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { - struct ximage_buffer *xbuf = &xsurf->buffers[att]; - - /* delay the allocation */ - if (!native_attachment_mask_test(attachment_mask, att)) - continue; - - /* reallocate the texture */ - if (!xbuf->texture || - xsurf->width != xbuf->texture->width0 || - xsurf->height != xbuf->texture->height0) { - new_buffers = TRUE; - if (ximage_surface_alloc_buffer(&xsurf->base, att)) { - /* update ximage */ - if (xbuf->ximage) { - xbuf->ximage->width = xsurf->width; - xbuf->ximage->height = xsurf->height; - } - } - } - - if (textures) { - textures[att] = NULL; - pipe_texture_reference(&textures[att], xbuf->texture); - } - } - - /* increase the sequence number so that caller knows */ - if (new_buffers) - xsurf->sequence_number++; - - if (seq_num) - *seq_num = xsurf->sequence_number; - if (width) - *width = xsurf->width; - if (height) - *height = xsurf->height; - - return TRUE; -} - -static void -ximage_surface_wait(struct native_surface *nsurf) -{ - struct ximage_surface *xsurf = ximage_surface(nsurf); - XSync(xsurf->xdpy->dpy, FALSE); - /* TODO XGetImage and update the front texture */ -} - -static void -ximage_surface_destroy(struct native_surface *nsurf) -{ - struct ximage_surface *xsurf = ximage_surface(nsurf); - int i; - - for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { - struct ximage_buffer *xbuf = &xsurf->buffers[i]; - ximage_surface_free_buffer(&xsurf->base, i); - /* xbuf->shm_info is owned by xbuf->ximage? */ - if (xbuf->ximage) { - XDestroyImage(xbuf->ximage); - xbuf->ximage = NULL; - } - } - - if (xsurf->type != XIMAGE_SURFACE_TYPE_PBUFFER) - XFreeGC(xsurf->xdpy->dpy, xsurf->gc); - free(xsurf); -} - -static struct ximage_surface * -ximage_display_create_surface(struct native_display *ndpy, - enum ximage_surface_type type, - Drawable drawable, - const struct native_config *nconf) -{ - struct ximage_display *xdpy = ximage_display(ndpy); - struct ximage_config *xconf = ximage_config(nconf); - struct ximage_surface *xsurf; - int i; - - xsurf = CALLOC_STRUCT(ximage_surface); - if (!xsurf) - return NULL; - - xsurf->xdpy = xdpy; - xsurf->type = type; - xsurf->color_format = xconf->base.color_format; - xsurf->drawable = drawable; - - if (xsurf->type != XIMAGE_SURFACE_TYPE_PBUFFER) { - xsurf->drawable = drawable; - xsurf->visual = *xconf->visual; - - xsurf->gc = XCreateGC(xdpy->dpy, xsurf->drawable, 0, NULL); - if (!xsurf->gc) { - free(xsurf); - return NULL; - } - - for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { - struct ximage_buffer *xbuf = &xsurf->buffers[i]; - - if (xdpy->use_xshm) { - xbuf->shm_info = calloc(1, sizeof(*xbuf->shm_info)); - if (xbuf->shm_info) { - /* initialize shm info */ - xbuf->shm_info->shmid = -1; - xbuf->shm_info->shmaddr = (void *) -1; - xbuf->shm_info->readOnly = TRUE; - - xbuf->ximage = XShmCreateImage(xsurf->xdpy->dpy, - xsurf->visual.visual, - xsurf->visual.depth, - ZPixmap, NULL, - xbuf->shm_info, - 0, 0); - } - } - else { - xbuf->ximage = XCreateImage(xsurf->xdpy->dpy, - xsurf->visual.visual, - xsurf->visual.depth, - ZPixmap, 0, /* format, offset */ - NULL, /* data */ - 0, 0, /* size */ - 8, /* bitmap_pad */ - 0); /* bytes_per_line */ - } - - if (!xbuf->ximage) { - XFreeGC(xdpy->dpy, xsurf->gc); - free(xsurf); - return NULL; - } - } - } - - xsurf->base.destroy = ximage_surface_destroy; - xsurf->base.swap_buffers = ximage_surface_swap_buffers; - xsurf->base.flush_frontbuffer = ximage_surface_flush_frontbuffer; - xsurf->base.validate = ximage_surface_validate; - xsurf->base.wait = ximage_surface_wait; - - return xsurf; -} - -static struct native_surface * -ximage_display_create_window_surface(struct native_display *ndpy, - EGLNativeWindowType win, - const struct native_config *nconf) -{ - struct ximage_surface *xsurf; - - xsurf = ximage_display_create_surface(ndpy, XIMAGE_SURFACE_TYPE_WINDOW, - (Drawable) win, nconf); - return (xsurf) ? &xsurf->base : NULL; -} - -static struct native_surface * -ximage_display_create_pixmap_surface(struct native_display *ndpy, - EGLNativePixmapType pix, - const struct native_config *nconf) -{ - struct ximage_surface *xsurf; - - xsurf = ximage_display_create_surface(ndpy, XIMAGE_SURFACE_TYPE_PIXMAP, - (Drawable) pix, nconf); - return (xsurf) ? &xsurf->base : NULL; -} - -static struct native_surface * -ximage_display_create_pbuffer_surface(struct native_display *ndpy, - const struct native_config *nconf, - uint width, uint height) -{ - struct ximage_surface *xsurf; - - xsurf = ximage_display_create_surface(ndpy, XIMAGE_SURFACE_TYPE_PBUFFER, - (Drawable) None, nconf); - if (xsurf) { - xsurf->width = width; - xsurf->height = height; - } - return (xsurf) ? &xsurf->base : NULL; -} - -static struct pipe_context * -ximage_display_create_context(struct native_display *ndpy, - void *context_private) -{ - struct pipe_context *pctx = softpipe_create(ndpy->screen); - if (pctx) - pctx->priv = context_private; - return pctx; -} - -static enum pipe_format -choose_format(const XVisualInfo *vinfo) -{ - enum pipe_format fmt; - /* TODO elaborate the formats */ - switch (vinfo->depth) { - case 32: - fmt = PIPE_FORMAT_A8R8G8B8_UNORM; - break; - case 24: - fmt = PIPE_FORMAT_X8R8G8B8_UNORM; - break; - case 16: - fmt = PIPE_FORMAT_R5G6B5_UNORM; - break; - default: - fmt = PIPE_FORMAT_NONE; - break; - } - - return fmt; -} - -static const struct native_config ** -ximage_display_get_configs(struct native_display *ndpy, int *num_configs) -{ - struct ximage_display *xdpy = ximage_display(ndpy); - const struct native_config **configs; - int i; - - /* first time */ - if (!xdpy->configs) { - const XVisualInfo *visuals; - int num_visuals, count, j; - - visuals = x11_screen_get_visuals(xdpy->xscr, &num_visuals); - if (!visuals) - return NULL; - - /* - * Create two configs for each visual. - * One with depth/stencil buffer; one without - */ - xdpy->configs = calloc(num_visuals * 2, sizeof(*xdpy->configs)); - if (!xdpy->configs) - return NULL; - - count = 0; - for (i = 0; i < num_visuals; i++) { - for (j = 0; j < 2; j++) { - struct ximage_config *xconf = &xdpy->configs[count]; - __GLcontextModes *mode = &xconf->base.mode; - - xconf->visual = &visuals[i]; - xconf->base.color_format = choose_format(xconf->visual); - if (xconf->base.color_format == PIPE_FORMAT_NONE) - continue; - - x11_screen_convert_visual(xdpy->xscr, xconf->visual, mode); - /* support double buffer mode */ - mode->doubleBufferMode = TRUE; - - xconf->base.depth_format = PIPE_FORMAT_NONE; - xconf->base.stencil_format = PIPE_FORMAT_NONE; - /* create the second config with depth/stencil buffer */ - if (j == 1) { - xconf->base.depth_format = PIPE_FORMAT_S8Z24_UNORM; - xconf->base.stencil_format = PIPE_FORMAT_S8Z24_UNORM; - mode->depthBits = 24; - mode->stencilBits = 8; - mode->haveDepthBuffer = TRUE; - mode->haveStencilBuffer = TRUE; - } - - mode->maxPbufferWidth = 4096; - mode->maxPbufferHeight = 4096; - mode->maxPbufferPixels = 4096 * 4096; - mode->drawableType = - GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT; - mode->swapMethod = GLX_SWAP_EXCHANGE_OML; - - if (mode->alphaBits) - mode->bindToTextureRgba = TRUE; - else - mode->bindToTextureRgb = TRUE; - - count++; - } - } - - xdpy->num_configs = count; - } - - configs = malloc(xdpy->num_configs * sizeof(*configs)); - if (configs) { - for (i = 0; i < xdpy->num_configs; i++) - configs[i] = (const struct native_config *) &xdpy->configs[i]; - if (num_configs) - *num_configs = xdpy->num_configs; - } - return configs; -} - -static boolean -ximage_display_is_pixmap_supported(struct native_display *ndpy, - EGLNativePixmapType pix, - const struct native_config *nconf) -{ - struct ximage_display *xdpy = ximage_display(ndpy); - enum pipe_format fmt; - uint depth; - - depth = x11_drawable_get_depth(xdpy->xscr, (Drawable) pix); - switch (depth) { - case 32: - fmt = PIPE_FORMAT_A8R8G8B8_UNORM; - break; - case 24: - fmt = PIPE_FORMAT_X8R8G8B8_UNORM; - break; - case 16: - fmt = PIPE_FORMAT_R5G6B5_UNORM; - break; - default: - fmt = PIPE_FORMAT_NONE; - break; - } - - return (fmt == nconf->color_format); -} - -static void -ximage_display_destroy(struct native_display *ndpy) -{ - struct ximage_display *xdpy = ximage_display(ndpy); - - if (xdpy->configs) - free(xdpy->configs); - - xdpy->base.screen->destroy(xdpy->base.screen); - free(xdpy->winsys); - - x11_screen_destroy(xdpy->xscr); - if (xdpy->own_dpy) - XCloseDisplay(xdpy->dpy); - free(xdpy); -} - -struct native_display * -x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm) -{ - struct ximage_display *xdpy; - - xdpy = CALLOC_STRUCT(ximage_display); - if (!xdpy) - return NULL; - - xdpy->dpy = dpy; - if (!xdpy->dpy) { - xdpy->dpy = XOpenDisplay(NULL); - if (!xdpy->dpy) { - free(xdpy); - return NULL; - } - xdpy->own_dpy = TRUE; - } - - xdpy->xscr_number = DefaultScreen(xdpy->dpy); - xdpy->xscr = x11_screen_create(xdpy->dpy, xdpy->xscr_number); - if (!xdpy->xscr) { - free(xdpy); - return NULL; - } - - xdpy->use_xshm = - (use_xshm && x11_screen_support(xdpy->xscr, X11_SCREEN_EXTENSION_XSHM)); - - xdpy->winsys = create_sw_winsys(); - xdpy->base.screen = softpipe_create_screen(xdpy->winsys); - - xdpy->base.destroy = ximage_display_destroy; - - xdpy->base.get_configs = ximage_display_get_configs; - xdpy->base.is_pixmap_supported = ximage_display_is_pixmap_supported; - xdpy->base.create_context = ximage_display_create_context; - xdpy->base.create_window_surface = ximage_display_create_window_surface; - xdpy->base.create_pixmap_surface = ximage_display_create_pixmap_surface; - xdpy->base.create_pbuffer_surface = ximage_display_create_pbuffer_surface; - - return &xdpy->base; -} diff --git a/src/gallium/state_trackers/egl_g3d/x11/sw_winsys.c b/src/gallium/state_trackers/egl_g3d/x11/sw_winsys.c deleted file mode 100644 index 6ee3ede38c..0000000000 --- a/src/gallium/state_trackers/egl_g3d/x11/sw_winsys.c +++ /dev/null @@ -1,231 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * 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, sub license, 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. - * - **************************************************************************/ - -/** - * Totally software-based winsys layer. - * Note that the one winsys function that we can't implement here - * is flush_frontbuffer(). - * Whoever uses this code will have to provide that. - * - * Authors: Brian Paul - */ - - -#include "pipe/internal/p_winsys_screen.h" -#include "pipe/p_state.h" -#include "pipe/p_inlines.h" -#include "util/u_format.h" -#include "util/u_math.h" -#include "util/u_memory.h" - -#include "sw_winsys.h" - - - -/** Subclass of pipe_winsys */ -struct sw_pipe_winsys -{ - struct pipe_winsys Base; - /* no extra fields for now */ -}; - - -/** subclass of pipe_buffer */ -struct sw_pipe_buffer -{ - struct pipe_buffer Base; - boolean UserBuffer; /** Is this a user-space buffer? */ - void *Data; - void *Mapped; -}; - - -/** cast wrapper */ -static INLINE struct sw_pipe_buffer * -sw_pipe_buffer(struct pipe_buffer *b) -{ - return (struct sw_pipe_buffer *) b; -} - - -static const char * -get_name(struct pipe_winsys *pws) -{ - return "software"; -} - - -/** Create new pipe_buffer and allocate storage of given size */ -static struct pipe_buffer * -buffer_create(struct pipe_winsys *pws, - unsigned alignment, - unsigned usage, - unsigned size) -{ - struct sw_pipe_buffer *buffer = CALLOC_STRUCT(sw_pipe_buffer); - if (!buffer) - return NULL; - - pipe_reference_init(&buffer->Base.reference, 1); - buffer->Base.alignment = alignment; - buffer->Base.usage = usage; - buffer->Base.size = size; - - /* align to 16-byte multiple for Cell */ - buffer->Data = align_malloc(size, MAX2(alignment, 16)); - - return &buffer->Base; -} - - -/** - * Create buffer which wraps user-space data. - */ -static struct pipe_buffer * -user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes) -{ - struct sw_pipe_buffer *buffer = CALLOC_STRUCT(sw_pipe_buffer); - if (!buffer) - return NULL; - - pipe_reference_init(&buffer->Base.reference, 1); - buffer->Base.size = bytes; - buffer->UserBuffer = TRUE; - buffer->Data = ptr; - - return &buffer->Base; -} - - -static void * -buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buf, unsigned flags) -{ - struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); - buffer->Mapped = buffer->Data; - return buffer->Mapped; -} - - -static void -buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf) -{ - struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); - buffer->Mapped = NULL; -} - - -static void -buffer_destroy(struct pipe_buffer *buf) -{ - struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); - - if (buffer->Data && !buffer->UserBuffer) { - align_free(buffer->Data); - buffer->Data = NULL; - } - - free(buffer); -} - - -static struct pipe_buffer * -surface_buffer_create(struct pipe_winsys *winsys, - unsigned width, unsigned height, - enum pipe_format format, - unsigned usage, - unsigned tex_usage, - unsigned *stride) -{ - const unsigned alignment = 64; - unsigned nblocksy; - - nblocksy = util_format_get_nblocksy(format, height); - *stride = align(util_format_get_stride(format, width), alignment); - - return winsys->buffer_create(winsys, alignment, - usage, - *stride * nblocksy); -} - - -static void -fence_reference(struct pipe_winsys *sws, struct pipe_fence_handle **ptr, - struct pipe_fence_handle *fence) -{ - /* no-op */ -} - - -static int -fence_signalled(struct pipe_winsys *sws, struct pipe_fence_handle *fence, - unsigned flag) -{ - /* no-op */ - return 0; -} - - -static int -fence_finish(struct pipe_winsys *sws, struct pipe_fence_handle *fence, - unsigned flag) -{ - /* no-op */ - return 0; -} - - -/** - * Create/return a new pipe_winsys object. - */ -struct pipe_winsys * -create_sw_winsys(void) -{ - struct sw_pipe_winsys *ws = CALLOC_STRUCT(sw_pipe_winsys); - if (!ws) - return NULL; - - /* Fill in this struct with callbacks that pipe will need to - * communicate with the window system, buffer manager, etc. - */ - ws->Base.buffer_create = buffer_create; - ws->Base.user_buffer_create = user_buffer_create; - ws->Base.buffer_map = buffer_map; - ws->Base.buffer_unmap = buffer_unmap; - ws->Base.buffer_destroy = buffer_destroy; - - ws->Base.surface_buffer_create = surface_buffer_create; - - ws->Base.fence_reference = fence_reference; - ws->Base.fence_signalled = fence_signalled; - ws->Base.fence_finish = fence_finish; - - ws->Base.flush_frontbuffer = NULL; /* not implemented here! */ - - ws->Base.get_name = get_name; - - return &ws->Base; -} diff --git a/src/gallium/state_trackers/egl_g3d/x11/sw_winsys.h b/src/gallium/state_trackers/egl_g3d/x11/sw_winsys.h deleted file mode 100644 index f96c5a14b0..0000000000 --- a/src/gallium/state_trackers/egl_g3d/x11/sw_winsys.h +++ /dev/null @@ -1,40 +0,0 @@ -/************************************************************************** - * - * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * 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, sub license, 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. - * - **************************************************************************/ - - -#ifndef SW_WINSYS_H -#define SW_WINSYS_H - - -struct pipe_winsys; - - -extern struct pipe_winsys * -create_sw_winsys(void); - - -#endif /* SW_WINSYS_H */ diff --git a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c deleted file mode 100644 index 76ce45ee57..0000000000 --- a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.c +++ /dev/null @@ -1,453 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009-2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL 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. - */ - -#include -#include -#include -#include -#include -#include -#include "util/u_memory.h" -#include "util/u_math.h" -#include "util/u_format.h" -#include "xf86drm.h" -#include "egllog.h" - -#include "x11_screen.h" -#include "dri2.h" -#include "glxinit.h" - -struct x11_screen { - Display *dpy; - int number; - - /* - * This is used to fetch GLX visuals/fbconfigs. It uses code from egl_xdri. - * It might be better to rewrite the part in Xlib or XCB. - */ - __GLXdisplayPrivate *glx_dpy; - - int dri_major, dri_minor; - char *dri_driver; - char *dri_device; - int dri_fd; - - XVisualInfo *visuals; - int num_visuals; - - /* cached values for x11_drawable_get_depth */ - Drawable last_drawable; - unsigned int last_depth; -}; - - -/** - * Create a X11 screen. - */ -struct x11_screen * -x11_screen_create(Display *dpy, int screen) -{ - struct x11_screen *xscr; - - if (screen >= ScreenCount(dpy)) - return NULL; - - xscr = CALLOC_STRUCT(x11_screen); - if (xscr) { - xscr->dpy = dpy; - xscr->number = screen; - - xscr->dri_major = -1; - xscr->dri_fd = -1; - } - return xscr; -} - -/** - * Destroy a X11 screen. - */ -void -x11_screen_destroy(struct x11_screen *xscr) -{ - if (xscr->dri_fd >= 0) - close(xscr->dri_fd); - if (xscr->dri_driver) - Xfree(xscr->dri_driver); - if (xscr->dri_device) - Xfree(xscr->dri_device); - - /* xscr->glx_dpy will be destroyed with the X display */ - - if (xscr->visuals) - XFree(xscr->visuals); - free(xscr); -} - -static boolean -x11_screen_init_dri2(struct x11_screen *xscr) -{ - if (xscr->dri_major < 0) { - int eventBase, errorBase; - - if (!DRI2QueryExtension(xscr->dpy, &eventBase, &errorBase) || - !DRI2QueryVersion(xscr->dpy, &xscr->dri_major, &xscr->dri_minor)) - xscr->dri_major = -1; - } - return (xscr->dri_major >= 0); -} - -static boolean -x11_screen_init_glx(struct x11_screen *xscr) -{ - if (!xscr->glx_dpy) - xscr->glx_dpy = __glXInitialize(xscr->dpy); - return (xscr->glx_dpy != NULL); -} - -/** - * Return true if the screen supports the extension. - */ -boolean -x11_screen_support(struct x11_screen *xscr, enum x11_screen_extension ext) -{ - boolean supported = FALSE; - - switch (ext) { - case X11_SCREEN_EXTENSION_XSHM: - supported = XShmQueryExtension(xscr->dpy); - break; - case X11_SCREEN_EXTENSION_GLX: - supported = x11_screen_init_glx(xscr); - break; - case X11_SCREEN_EXTENSION_DRI2: - supported = x11_screen_init_dri2(xscr); - break; - default: - break; - } - - return supported; -} - -/** - * Return the X visuals. - */ -const XVisualInfo * -x11_screen_get_visuals(struct x11_screen *xscr, int *num_visuals) -{ - if (!xscr->visuals) { - XVisualInfo vinfo_template; - vinfo_template.screen = xscr->number; - xscr->visuals = XGetVisualInfo(xscr->dpy, VisualScreenMask, - &vinfo_template, &xscr->num_visuals); - } - - if (num_visuals) - *num_visuals = xscr->num_visuals; - return xscr->visuals; -} - -void -x11_screen_convert_visual(struct x11_screen *xscr, const XVisualInfo *visual, - __GLcontextModes *mode) -{ - int r, g, b, a; - int visual_type; - - r = util_bitcount(visual->red_mask); - g = util_bitcount(visual->green_mask); - b = util_bitcount(visual->blue_mask); - a = visual->depth - (r + g + b); -#if defined(__cplusplus) || defined(c_plusplus) - visual_type = visual->c_class; -#else - visual_type = visual->class; -#endif - - /* convert to GLX visual type */ - switch (visual_type) { - case TrueColor: - visual_type = GLX_TRUE_COLOR; - break; - case DirectColor: - visual_type = GLX_DIRECT_COLOR; - break; - case PseudoColor: - visual_type = GLX_PSEUDO_COLOR; - break; - case StaticColor: - visual_type = GLX_STATIC_COLOR; - break; - case GrayScale: - visual_type = GLX_GRAY_SCALE; - break; - case StaticGray: - visual_type = GLX_STATIC_GRAY; - break; - default: - visual_type = GLX_NONE; - break; - } - - mode->rgbBits = r + g + b + a; - mode->redBits = r; - mode->greenBits = g; - mode->blueBits = b; - mode->alphaBits = a; - mode->visualID = visual->visualid; - mode->visualType = visual_type; - - /* sane defaults */ - mode->renderType = GLX_RGBA_BIT; - mode->rgbMode = TRUE; - mode->visualRating = GLX_SLOW_CONFIG; - mode->xRenderable = TRUE; -} - -/** - * Return the GLX fbconfigs. - */ -const __GLcontextModes * -x11_screen_get_glx_configs(struct x11_screen *xscr) -{ - return (x11_screen_init_glx(xscr)) - ? xscr->glx_dpy->screenConfigs[xscr->number].configs - : NULL; -} - -/** - * Return the GLX visuals. - */ -const __GLcontextModes * -x11_screen_get_glx_visuals(struct x11_screen *xscr) -{ - return (x11_screen_init_glx(xscr)) - ? xscr->glx_dpy->screenConfigs[xscr->number].visuals - : NULL; -} - -static boolean -x11_screen_is_driver_equal(struct x11_screen *xscr, const char *driver) -{ - return (strcmp(xscr->dri_driver, driver) == 0); -} - -/** - * Probe the screen for the DRI2 driver name. - */ -const char * -x11_screen_probe_dri2(struct x11_screen *xscr) -{ - /* get the driver name and the device name */ - if (!xscr->dri_driver) { - if (!DRI2Connect(xscr->dpy, RootWindow(xscr->dpy, xscr->number), - &xscr->dri_driver, &xscr->dri_device)) - xscr->dri_driver = xscr->dri_device = NULL; - } - - return xscr->dri_driver; -} - -/** - * Enable DRI2 and returns the file descriptor of the DRM device. The file - * descriptor will be closed automatically when the screen is destoryed. - */ -int -x11_screen_enable_dri2(struct x11_screen *xscr, const char *driver) -{ - if (xscr->dri_fd < 0) { - int fd; - drm_magic_t magic; - - /* get the driver name and the device name first */ - if (!x11_screen_probe_dri2(xscr)) - return -1; - - if (!x11_screen_is_driver_equal(xscr, driver)) { - _eglLog(_EGL_WARNING, "Driver mismatch: %s != %s", - xscr->dri_driver, driver); - return -1; - } - - fd = open(xscr->dri_device, O_RDWR); - if (fd < 0) { - _eglLog(_EGL_WARNING, "failed to open %s", xscr->dri_device); - return -1; - } - - memset(&magic, 0, sizeof(magic)); - if (drmGetMagic(fd, &magic)) { - _eglLog(_EGL_WARNING, "failed to get magic"); - close(fd); - return -1; - } - - if (!DRI2Authenticate(xscr->dpy, - RootWindow(xscr->dpy, xscr->number), magic)) { - _eglLog(_EGL_WARNING, "failed to authenticate magic"); - close(fd); - return -1; - } - - xscr->dri_fd = fd; - } - - return xscr->dri_fd; -} - -/** - * Create/Destroy the DRI drawable. - */ -void -x11_drawable_enable_dri2(struct x11_screen *xscr, - Drawable drawable, boolean on) -{ - if (on) - DRI2CreateDrawable(xscr->dpy, drawable); - else - DRI2DestroyDrawable(xscr->dpy, drawable); -} - -/** - * Copy between buffers of the DRI2 drawable. - */ -void -x11_drawable_copy_buffers(struct x11_screen *xscr, Drawable drawable, - int x, int y, int width, int height, - int src_buf, int dst_buf) -{ - XRectangle rect; - XserverRegion region; - - rect.x = x; - rect.y = y; - rect.width = width; - rect.height = height; - - region = XFixesCreateRegion(xscr->dpy, &rect, 1); - DRI2CopyRegion(xscr->dpy, drawable, region, dst_buf, src_buf); - XFixesDestroyRegion(xscr->dpy, region); -} - -/** - * Get the buffers of the DRI2 drawable. The returned array should be freed. - */ -struct x11_drawable_buffer * -x11_drawable_get_buffers(struct x11_screen *xscr, Drawable drawable, - int *width, int *height, unsigned int *attachments, - boolean with_format, int num_ins, int *num_outs) -{ - DRI2Buffer *dri2bufs; - - if (with_format) - dri2bufs = DRI2GetBuffersWithFormat(xscr->dpy, drawable, width, height, - attachments, num_ins, num_outs); - else - dri2bufs = DRI2GetBuffers(xscr->dpy, drawable, width, height, - attachments, num_ins, num_outs); - - return (struct x11_drawable_buffer *) dri2bufs; -} - -/** - * Return the depth of a drawable. - * - * Unlike other drawable functions, the drawable needs not be a DRI2 drawable. - */ -uint -x11_drawable_get_depth(struct x11_screen *xscr, Drawable drawable) -{ - unsigned int depth; - - if (drawable != xscr->last_drawable) { - Window root; - int x, y; - unsigned int w, h, border; - Status ok; - - ok = XGetGeometry(xscr->dpy, drawable, &root, - &x, &y, &w, &h, &border, &depth); - if (!ok) - depth = 0; - - xscr->last_drawable = drawable; - xscr->last_depth = depth; - } - else { - depth = xscr->last_depth; - } - - return depth; -} - -/** - * Create a mode list of the given size. - */ -__GLcontextModes * -x11_context_modes_create(unsigned count) -{ - const size_t size = sizeof(__GLcontextModes); - __GLcontextModes *base = NULL; - __GLcontextModes **next; - unsigned i; - - next = &base; - for (i = 0; i < count; i++) { - *next = (__GLcontextModes *) calloc(1, size); - if (*next == NULL) { - x11_context_modes_destroy(base); - base = NULL; - break; - } - next = &((*next)->next); - } - - return base; -} - -/** - * Destroy a mode list. - */ -void -x11_context_modes_destroy(__GLcontextModes *modes) -{ - while (modes != NULL) { - __GLcontextModes *next = modes->next; - free(modes); - modes = next; - } -} - -/** - * Return the number of the modes in the mode list. - */ -unsigned -x11_context_modes_count(const __GLcontextModes *modes) -{ - const __GLcontextModes *mode; - int count = 0; - for (mode = modes; mode; mode = mode->next) - count++; - return count; -} diff --git a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h b/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h deleted file mode 100644 index 5432858ac3..0000000000 --- a/src/gallium/state_trackers/egl_g3d/x11/x11_screen.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.8 - * - * Copyright (C) 2009-2010 Chia-I Wu - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL 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. - */ - -#ifndef _X11_SCREEN_H_ -#define _X11_SCREEN_H_ - -#include -#include -#include -#include "pipe/p_compiler.h" -#include "common/native.h" - -enum x11_screen_extension { - X11_SCREEN_EXTENSION_XSHM, - X11_SCREEN_EXTENSION_GLX, - X11_SCREEN_EXTENSION_DRI2, -}; - -/* the same as DRI2Buffer */ -struct x11_drawable_buffer { - unsigned int attachment; - unsigned int name; - unsigned int pitch; - unsigned int cpp; - unsigned int flags; -}; - -struct x11_screen; - -struct x11_screen * -x11_screen_create(Display *dpy, int screen); - -void -x11_screen_destroy(struct x11_screen *xscr); - -boolean -x11_screen_support(struct x11_screen *xscr, enum x11_screen_extension ext); - -const XVisualInfo * -x11_screen_get_visuals(struct x11_screen *xscr, int *num_visuals); - -void -x11_screen_convert_visual(struct x11_screen *xscr, const XVisualInfo *visual, - __GLcontextModes *mode); - -const __GLcontextModes * -x11_screen_get_glx_configs(struct x11_screen *xscr); - -const __GLcontextModes * -x11_screen_get_glx_visuals(struct x11_screen *xscr); - -const char * -x11_screen_probe_dri2(struct x11_screen *xscr); - -int -x11_screen_enable_dri2(struct x11_screen *xscr, const char *driver); - -__GLcontextModes * -x11_context_modes_create(unsigned count); - -void -x11_context_modes_destroy(__GLcontextModes *modes); - -unsigned -x11_context_modes_count(const __GLcontextModes *modes); - -void -x11_drawable_enable_dri2(struct x11_screen *xscr, - Drawable drawable, boolean on); - -void -x11_drawable_copy_buffers(struct x11_screen *xscr, Drawable drawable, - int x, int y, int width, int height, - int src_buf, int dst_buf); - -struct x11_drawable_buffer * -x11_drawable_get_buffers(struct x11_screen *xscr, Drawable drawable, - int *width, int *height, unsigned int *attachments, - boolean with_format, int num_ins, int *num_outs); - -uint -x11_drawable_get_depth(struct x11_screen *xscr, Drawable drawable); - -#endif /* _X11_SCREEN_H_ */ diff --git a/src/gallium/winsys/drm/Makefile.egl b/src/gallium/winsys/drm/Makefile.egl new file mode 100644 index 0000000000..1b10f1115c --- /dev/null +++ b/src/gallium/winsys/drm/Makefile.egl @@ -0,0 +1,65 @@ +# src/gallium/winsys/drm/Makefile.egl + +# The driver Makefile should define +# +# EGL_DRIVER_NAME, the name of the driver +# EGL_DRIVER_SOURCES, the sources of the driver +# EGL_DRIVER_LIBS, extra libraries needed by the driver +# EGL_DRIVER_PIPES, the pipe drivers of the driver +# +# before including this file. + +EGL_DRIVER_OBJECTS = $(EGL_DRIVER_SOURCES:.c=.o) + +common_LIBS = -ldrm -lm -ldl + +x11_ST = $(TOP)/src/gallium/state_trackers/egl/libeglx11.a +x11_LIBS = $(common_LIBS) -lX11 -lXext -lXfixes + +kms_ST = $(TOP)/src/gallium/state_trackers/egl/libeglkms.a +kms_LIBS = $(common_LIBS) + +##### RULES ##### + +.c.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ + + +##### TARGETS ##### + +EGL_DISPLAY_DRIVERS = $(foreach dpy, $(EGL_DISPLAYS), egl_$(dpy)_$(EGL_DRIVER_NAME).so) + +LIB_GALLIUM_DIR = $(TOP)/$(LIB_DIR)/gallium +EGL_DISPLAY_LIBS = $(foreach drv, $(EGL_DISPLAY_DRIVERS), $(LIB_GALLIUM_DIR)/$(drv)) + +default: $(EGL_DISPLAY_LIBS) + +$(EGL_DISPLAY_LIBS): $(LIB_GALLIUM_DIR)/%.so: %.so + @mkdir -p $(LIB_GALLIUM_DIR) + $(INSTALL) $^ $(LIB_GALLIUM_DIR) + +define mklib-egl +$(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ + $(MKLIB_OPTIONS) $(EGL_DRIVER_OBJECTS) \ + -Wl,--whole-archive $($(1)_ST) -Wl,--no-whole-archive \ + $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) $($(1)_LIBS) $(EGL_DRIVER_LIBS) +endef + +egl_x11_$(EGL_DRIVER_NAME).so: $(EGL_DRIVER_OBJECTS) $(x11_ST) $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) Makefile + $(call mklib-egl,x11) + +egl_kms_$(EGL_DRIVER_NAME).so: $(EGL_DRIVER_OBJECTS) $(kms_ST) $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) Makefile + $(call mklib-egl,kms) + +clean: + -rm -f $(EGL_DRIVER_OBJECTS) + -rm -f $(EGL_DISPLAY_DRIVERS) + +install: $(EGL_DISPLAY_LIBS) + @$(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) + @echo "Install $(EGL_DISPLAY_DRIVERS)" + @for lib in "$(EGL_DISPLAY_LIBS)"; do \ + $(MINSTALL) -m 755 "$$lib" $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR); \ + done + +depend: diff --git a/src/gallium/winsys/drm/Makefile.egl_g3d b/src/gallium/winsys/drm/Makefile.egl_g3d deleted file mode 100644 index d8f47396d1..0000000000 --- a/src/gallium/winsys/drm/Makefile.egl_g3d +++ /dev/null @@ -1,65 +0,0 @@ -# src/gallium/winsys/drm/Makefile.egl_g3d - -# The driver Makefile should define -# -# EGL_DRIVER_NAME, the name of the driver -# EGL_DRIVER_SOURCES, the sources of the driver -# EGL_DRIVER_LIBS, extra libraries needed by the driver -# EGL_DRIVER_PIPES, the pipe drivers of the driver -# -# before including this file. - -EGL_DRIVER_OBJECTS = $(EGL_DRIVER_SOURCES:.c=.o) - -common_LIBS = -ldrm -lm -ldl - -x11_ST = $(TOP)/src/gallium/state_trackers/egl_g3d/libeglx11.a -x11_LIBS = $(common_LIBS) -lX11 -lXext -lXfixes - -kms_ST = $(TOP)/src/gallium/state_trackers/egl_g3d/libeglkms.a -kms_LIBS = $(common_LIBS) - -##### RULES ##### - -.c.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@ - - -##### TARGETS ##### - -EGL_DISPLAY_DRIVERS = $(foreach dpy, $(EGL_DISPLAYS), egl_$(dpy)_$(EGL_DRIVER_NAME).so) - -LIB_GALLIUM_DIR = $(TOP)/$(LIB_DIR)/gallium -EGL_DISPLAY_LIBS = $(foreach drv, $(EGL_DISPLAY_DRIVERS), $(LIB_GALLIUM_DIR)/$(drv)) - -default: $(EGL_DISPLAY_LIBS) - -$(EGL_DISPLAY_LIBS): $(LIB_GALLIUM_DIR)/%.so: %.so - @mkdir -p $(LIB_GALLIUM_DIR) - $(INSTALL) $^ $(LIB_GALLIUM_DIR) - -define mklib-egl -$(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ - $(MKLIB_OPTIONS) $(EGL_DRIVER_OBJECTS) \ - -Wl,--whole-archive $($(1)_ST) -Wl,--no-whole-archive \ - $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) $($(1)_LIBS) $(EGL_DRIVER_LIBS) -endef - -egl_x11_$(EGL_DRIVER_NAME).so: $(EGL_DRIVER_OBJECTS) $(x11_ST) $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) Makefile - $(call mklib-egl,x11) - -egl_kms_$(EGL_DRIVER_NAME).so: $(EGL_DRIVER_OBJECTS) $(kms_ST) $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) Makefile - $(call mklib-egl,kms) - -clean: - -rm -f $(EGL_DRIVER_OBJECTS) - -rm -f $(EGL_DISPLAY_DRIVERS) - -install: $(EGL_DISPLAY_LIBS) - @$(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) - @echo "Install $(EGL_DISPLAY_DRIVERS)" - @for lib in "$(EGL_DISPLAY_LIBS)"; do \ - $(MINSTALL) -m 755 "$$lib" $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR); \ - done - -depend: diff --git a/src/gallium/winsys/drm/i965/egl/Makefile b/src/gallium/winsys/drm/i965/egl/Makefile new file mode 100644 index 0000000000..1c13258200 --- /dev/null +++ b/src/gallium/winsys/drm/i965/egl/Makefile @@ -0,0 +1,14 @@ +TOP = ../../../../../.. +include $(TOP)/configs/current + +EGL_DRIVER_NAME = i965 +EGL_DRIVER_SOURCES = dummy.c +EGL_DRIVER_LIBS = -ldrm_intel + +EGL_DRIVER_PIPES = \ + $(TOP)/src/gallium/winsys/drm/i965/gem/libi965drm.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/i965/libi965.a + +include ../../Makefile.egl diff --git a/src/gallium/winsys/drm/i965/egl/dummy.c b/src/gallium/winsys/drm/i965/egl/dummy.c new file mode 100644 index 0000000000..4a1bc28b0b --- /dev/null +++ b/src/gallium/winsys/drm/i965/egl/dummy.c @@ -0,0 +1 @@ +/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/i965/egl_g3d/Makefile b/src/gallium/winsys/drm/i965/egl_g3d/Makefile deleted file mode 100644 index dd2efe2485..0000000000 --- a/src/gallium/winsys/drm/i965/egl_g3d/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -TOP = ../../../../../.. -include $(TOP)/configs/current - -EGL_DRIVER_NAME = i965 -EGL_DRIVER_SOURCES = dummy.c -EGL_DRIVER_LIBS = -ldrm_intel - -EGL_DRIVER_PIPES = \ - $(TOP)/src/gallium/winsys/drm/i965/gem/libi965drm.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ - $(TOP)/src/gallium/drivers/trace/libtrace.a \ - $(TOP)/src/gallium/drivers/i965/libi965.a - -include ../../Makefile.egl_g3d diff --git a/src/gallium/winsys/drm/i965/egl_g3d/dummy.c b/src/gallium/winsys/drm/i965/egl_g3d/dummy.c deleted file mode 100644 index 4a1bc28b0b..0000000000 --- a/src/gallium/winsys/drm/i965/egl_g3d/dummy.c +++ /dev/null @@ -1 +0,0 @@ -/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/intel/egl/Makefile b/src/gallium/winsys/drm/intel/egl/Makefile new file mode 100644 index 0000000000..60d675ca73 --- /dev/null +++ b/src/gallium/winsys/drm/intel/egl/Makefile @@ -0,0 +1,14 @@ +TOP = ../../../../../.. +include $(TOP)/configs/current + +EGL_DRIVER_NAME = i915 +EGL_DRIVER_SOURCES = dummy.c +EGL_DRIVER_LIBS = -ldrm_intel + +EGL_DRIVER_PIPES = \ + $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/i915/libi915.a + +include ../../Makefile.egl diff --git a/src/gallium/winsys/drm/intel/egl/dummy.c b/src/gallium/winsys/drm/intel/egl/dummy.c new file mode 100644 index 0000000000..4a1bc28b0b --- /dev/null +++ b/src/gallium/winsys/drm/intel/egl/dummy.c @@ -0,0 +1 @@ +/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/intel/egl_g3d/Makefile b/src/gallium/winsys/drm/intel/egl_g3d/Makefile deleted file mode 100644 index cdbb680773..0000000000 --- a/src/gallium/winsys/drm/intel/egl_g3d/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -TOP = ../../../../../.. -include $(TOP)/configs/current - -EGL_DRIVER_NAME = i915 -EGL_DRIVER_SOURCES = dummy.c -EGL_DRIVER_LIBS = -ldrm_intel - -EGL_DRIVER_PIPES = \ - $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ - $(TOP)/src/gallium/drivers/trace/libtrace.a \ - $(TOP)/src/gallium/drivers/i915/libi915.a - -include ../../Makefile.egl_g3d diff --git a/src/gallium/winsys/drm/intel/egl_g3d/dummy.c b/src/gallium/winsys/drm/intel/egl_g3d/dummy.c deleted file mode 100644 index 4a1bc28b0b..0000000000 --- a/src/gallium/winsys/drm/intel/egl_g3d/dummy.c +++ /dev/null @@ -1 +0,0 @@ -/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/nouveau/egl/Makefile b/src/gallium/winsys/drm/nouveau/egl/Makefile new file mode 100644 index 0000000000..8e812acc86 --- /dev/null +++ b/src/gallium/winsys/drm/nouveau/egl/Makefile @@ -0,0 +1,19 @@ +TOP = ../../../../../.. +include $(TOP)/configs/current + +EGL_DRIVER_NAME = nouveau +EGL_DRIVER_SOURCES = dummy.c +EGL_DRIVER_LIBS = -ldrm_nouveau + +EGL_DRIVER_PIPES = \ + $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \ + $(TOP)/src/gallium/drivers/nv04/libnv04.a \ + $(TOP)/src/gallium/drivers/nv10/libnv10.a \ + $(TOP)/src/gallium/drivers/nv20/libnv20.a \ + $(TOP)/src/gallium/drivers/nv30/libnv30.a \ + $(TOP)/src/gallium/drivers/nv40/libnv40.a \ + $(TOP)/src/gallium/drivers/nv50/libnv50.a \ + $(TOP)/src/gallium/drivers/nouveau/libnouveau.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a + +include ../../Makefile.egl diff --git a/src/gallium/winsys/drm/nouveau/egl/dummy.c b/src/gallium/winsys/drm/nouveau/egl/dummy.c new file mode 100644 index 0000000000..4a1bc28b0b --- /dev/null +++ b/src/gallium/winsys/drm/nouveau/egl/dummy.c @@ -0,0 +1 @@ +/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/nouveau/egl_g3d/Makefile b/src/gallium/winsys/drm/nouveau/egl_g3d/Makefile deleted file mode 100644 index 865a5d56a9..0000000000 --- a/src/gallium/winsys/drm/nouveau/egl_g3d/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -TOP = ../../../../../.. -include $(TOP)/configs/current - -EGL_DRIVER_NAME = nouveau -EGL_DRIVER_SOURCES = dummy.c -EGL_DRIVER_LIBS = -ldrm_nouveau - -EGL_DRIVER_PIPES = \ - $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \ - $(TOP)/src/gallium/drivers/nv04/libnv04.a \ - $(TOP)/src/gallium/drivers/nv10/libnv10.a \ - $(TOP)/src/gallium/drivers/nv20/libnv20.a \ - $(TOP)/src/gallium/drivers/nv30/libnv30.a \ - $(TOP)/src/gallium/drivers/nv40/libnv40.a \ - $(TOP)/src/gallium/drivers/nv50/libnv50.a \ - $(TOP)/src/gallium/drivers/nouveau/libnouveau.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a - -include ../../Makefile.egl_g3d diff --git a/src/gallium/winsys/drm/nouveau/egl_g3d/dummy.c b/src/gallium/winsys/drm/nouveau/egl_g3d/dummy.c deleted file mode 100644 index 4a1bc28b0b..0000000000 --- a/src/gallium/winsys/drm/nouveau/egl_g3d/dummy.c +++ /dev/null @@ -1 +0,0 @@ -/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/radeon/egl/Makefile b/src/gallium/winsys/drm/radeon/egl/Makefile new file mode 100644 index 0000000000..cd4f9b20f0 --- /dev/null +++ b/src/gallium/winsys/drm/radeon/egl/Makefile @@ -0,0 +1,14 @@ +TOP = ../../../../../.. +include $(TOP)/configs/current + +EGL_DRIVER_NAME = radeon +EGL_DRIVER_SOURCES = dummy.c +EGL_DRIVER_LIBS = -ldrm_radeon + +EGL_DRIVER_PIPES = \ + $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/r300/libr300.a + +include ../../Makefile.egl diff --git a/src/gallium/winsys/drm/radeon/egl/dummy.c b/src/gallium/winsys/drm/radeon/egl/dummy.c new file mode 100644 index 0000000000..4a1bc28b0b --- /dev/null +++ b/src/gallium/winsys/drm/radeon/egl/dummy.c @@ -0,0 +1 @@ +/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/radeon/egl_g3d/Makefile b/src/gallium/winsys/drm/radeon/egl_g3d/Makefile deleted file mode 100644 index e0de68c678..0000000000 --- a/src/gallium/winsys/drm/radeon/egl_g3d/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -TOP = ../../../../../.. -include $(TOP)/configs/current - -EGL_DRIVER_NAME = radeon -EGL_DRIVER_SOURCES = dummy.c -EGL_DRIVER_LIBS = -ldrm_radeon - -EGL_DRIVER_PIPES = \ - $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ - $(TOP)/src/gallium/drivers/trace/libtrace.a \ - $(TOP)/src/gallium/drivers/r300/libr300.a - -include ../../Makefile.egl_g3d diff --git a/src/gallium/winsys/drm/radeon/egl_g3d/dummy.c b/src/gallium/winsys/drm/radeon/egl_g3d/dummy.c deleted file mode 100644 index 4a1bc28b0b..0000000000 --- a/src/gallium/winsys/drm/radeon/egl_g3d/dummy.c +++ /dev/null @@ -1 +0,0 @@ -/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/swrast/egl/Makefile b/src/gallium/winsys/drm/swrast/egl/Makefile new file mode 100644 index 0000000000..26fe2d2805 --- /dev/null +++ b/src/gallium/winsys/drm/swrast/egl/Makefile @@ -0,0 +1,12 @@ +TOP = ../../../../../.. +include $(TOP)/configs/current + +EGL_DRIVER_NAME = swrast +EGL_DRIVER_SOURCES = dummy.c +EGL_DRIVER_LIBS = + +EGL_DRIVER_PIPES = \ + $(TOP)/src/gallium/winsys/drm/swrast/core/libswrastdrm.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a + +include ../../Makefile.egl diff --git a/src/gallium/winsys/drm/swrast/egl/dummy.c b/src/gallium/winsys/drm/swrast/egl/dummy.c new file mode 100644 index 0000000000..4a1bc28b0b --- /dev/null +++ b/src/gallium/winsys/drm/swrast/egl/dummy.c @@ -0,0 +1 @@ +/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/swrast/egl_g3d/Makefile b/src/gallium/winsys/drm/swrast/egl_g3d/Makefile deleted file mode 100644 index f0d051ea0e..0000000000 --- a/src/gallium/winsys/drm/swrast/egl_g3d/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -TOP = ../../../../../.. -include $(TOP)/configs/current - -EGL_DRIVER_NAME = swrast -EGL_DRIVER_SOURCES = dummy.c -EGL_DRIVER_LIBS = - -EGL_DRIVER_PIPES = \ - $(TOP)/src/gallium/winsys/drm/swrast/core/libswrastdrm.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a - -include ../../Makefile.egl_g3d diff --git a/src/gallium/winsys/drm/swrast/egl_g3d/dummy.c b/src/gallium/winsys/drm/swrast/egl_g3d/dummy.c deleted file mode 100644 index 4a1bc28b0b..0000000000 --- a/src/gallium/winsys/drm/swrast/egl_g3d/dummy.c +++ /dev/null @@ -1 +0,0 @@ -/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/vmware/egl/Makefile b/src/gallium/winsys/drm/vmware/egl/Makefile new file mode 100644 index 0000000000..a3e73131c3 --- /dev/null +++ b/src/gallium/winsys/drm/vmware/egl/Makefile @@ -0,0 +1,14 @@ +TOP = ../../../../../.. +include $(TOP)/configs/current + +EGL_DRIVER_NAME = vmwgfx +EGL_DRIVER_SOURCES = dummy.c +EGL_DRIVER_LIBS = + +EGL_DRIVER_PIPES = \ + $(TOP)/src/gallium/winsys/drm/vmware/core/libsvgadrm.a \ + $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ + $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/svga/libsvga.a + +include ../../Makefile.egl diff --git a/src/gallium/winsys/drm/vmware/egl/dummy.c b/src/gallium/winsys/drm/vmware/egl/dummy.c new file mode 100644 index 0000000000..4a1bc28b0b --- /dev/null +++ b/src/gallium/winsys/drm/vmware/egl/dummy.c @@ -0,0 +1 @@ +/* mklib expects at least one object file */ diff --git a/src/gallium/winsys/drm/vmware/egl_g3d/Makefile b/src/gallium/winsys/drm/vmware/egl_g3d/Makefile deleted file mode 100644 index 3cf79924e0..0000000000 --- a/src/gallium/winsys/drm/vmware/egl_g3d/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -TOP = ../../../../../.. -include $(TOP)/configs/current - -EGL_DRIVER_NAME = vmwgfx -EGL_DRIVER_SOURCES = dummy.c -EGL_DRIVER_LIBS = - -EGL_DRIVER_PIPES = \ - $(TOP)/src/gallium/winsys/drm/vmware/core/libsvgadrm.a \ - $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \ - $(TOP)/src/gallium/drivers/trace/libtrace.a \ - $(TOP)/src/gallium/drivers/svga/libsvga.a - -include ../../Makefile.egl_g3d diff --git a/src/gallium/winsys/drm/vmware/egl_g3d/dummy.c b/src/gallium/winsys/drm/vmware/egl_g3d/dummy.c deleted file mode 100644 index 4a1bc28b0b..0000000000 --- a/src/gallium/winsys/drm/vmware/egl_g3d/dummy.c +++ /dev/null @@ -1 +0,0 @@ -/* mklib expects at least one object file */ -- cgit v1.2.3 From cec2eeb33ef2d59484e00bb2a2ff97a4a7cd4239 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 22 Jan 2010 17:10:28 +0800 Subject: docs: Update sourcetree.html for EGL and the state trackers. --- docs/sourcetree.html | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/sourcetree.html b/docs/sourcetree.html index 41f40351eb..00dc4e7c9f 100644 --- a/docs/sourcetree.html +++ b/docs/sourcetree.html @@ -48,6 +48,7 @@ each directory.
      • glslcompiler - a stand-alone GLSL compiler driver
      • XXX more
      +
    • es - OpenGL ES overlay, parallelly buildable with the core Mesa
    • math - vertex array translation and transformation code (not used with Gallium)
    • ppc - Assembly code/optimizations for PPC systems @@ -123,15 +124,15 @@ each directory.
  • state_trackers -
      -
    • dri - -
    • egl - -
    • es - +
    • dri - Meta state tracker for DRI drivers +
    • egl - Meta state tracker for EGL drivers +
    • es - OpenGL ES 1.x and 2.x state trackers
    • g3dvl - -
    • glx - +
    • glx - Meta state tracker for GLX
    • python - -
    • vega - +
    • vega - OpenVG 1.x state tracker
    • wgl - -
    • xorg - +
    • xorg - Meta state tracker for Xorg video drivers
  • winsys -
      -- cgit v1.2.3 From defd45e95e1a9df29d2e72be671cc2e096093e36 Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Fri, 22 Jan 2010 12:31:24 +0200 Subject: r600: enable draw_offset fixes some fbo cases (mipmaps, cube textures ..) --- src/mesa/drivers/dri/r600/r700_chip.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r700_chip.c b/src/mesa/drivers/dri/r600/r700_chip.c index 1a1a87c3cf..ef25cd93fe 100644 --- a/src/mesa/drivers/dri/r600/r700_chip.c +++ b/src/mesa/drivers/dri/r600/r700_chip.c @@ -303,14 +303,13 @@ static void r700SetRenderTarget(context_t *context, int id) R600_STATECHANGE(context, cb_target); /* color buffer */ - r700->render_target[id].CB_COLOR0_BASE.u32All = context->radeon.state.color.draw_offset; + r700->render_target[id].CB_COLOR0_BASE.u32All = context->radeon.state.color.draw_offset / 256; nPitchInPixel = rrb->pitch/rrb->cpp; SETfield(r700->render_target[id].CB_COLOR0_SIZE.u32All, (nPitchInPixel/8)-1, PITCH_TILE_MAX_shift, PITCH_TILE_MAX_mask); SETfield(r700->render_target[id].CB_COLOR0_SIZE.u32All, ( (nPitchInPixel * context->radeon.radeonScreen->driScreen->fbHeight)/64 )-1, SLICE_TILE_MAX_shift, SLICE_TILE_MAX_mask); - r700->render_target[id].CB_COLOR0_BASE.u32All = 0; SETfield(r700->render_target[id].CB_COLOR0_INFO.u32All, ENDIAN_NONE, ENDIAN_shift, ENDIAN_mask); SETfield(r700->render_target[id].CB_COLOR0_INFO.u32All, ARRAY_LINEAR_GENERAL, CB_COLOR0_INFO__ARRAY_MODE_shift, CB_COLOR0_INFO__ARRAY_MODE_mask); -- cgit v1.2.3 From 7c6f51cdccdd0ed6370ce86ba21549991f4f4293 Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Mon, 4 Jan 2010 09:26:46 +0200 Subject: radeon/fbo: use correct depth texture offset for depth textures --- src/mesa/drivers/dri/radeon/radeon_fbo.c | 7 +++---- src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c | 21 +-------------------- src/mesa/drivers/dri/radeon/radeon_mipmap_tree.h | 2 -- 3 files changed, 4 insertions(+), 26 deletions(-) diff --git a/src/mesa/drivers/dri/radeon/radeon_fbo.c b/src/mesa/drivers/dri/radeon/radeon_fbo.c index 7b1f84a715..e780b9eef1 100644 --- a/src/mesa/drivers/dri/radeon/radeon_fbo.c +++ b/src/mesa/drivers/dri/radeon/radeon_fbo.c @@ -531,10 +531,9 @@ radeon_render_texture(GLcontext * ctx, att->TextureLevel); if (att->Texture->Target == GL_TEXTURE_3D) { - GLuint offsets[6]; - radeon_miptree_depth_offsets(radeon_image->mt, att->TextureLevel, - offsets); - imageOffset += offsets[att->Zoffset]; + imageOffset += radeon_image->mt->levels[att->TextureLevel].rowstride * + radeon_image->mt->levels[att->TextureLevel].height * + att->Zoffset; } /* store that offset in the region, along with the correct pitch for diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c index 033f26db2a..3a3658c314 100644 --- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c +++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c @@ -380,25 +380,6 @@ void radeon_try_alloc_miptree(radeonContextPtr rmesa, radeonTexObj *t) texImg->Depth, t->tile_bits); } -/* Although we use the image_offset[] array to store relative offsets - * to cube faces, Mesa doesn't know anything about this and expects - * each cube face to be treated as a separate image. - * - * These functions present that view to mesa: - */ -void -radeon_miptree_depth_offsets(radeon_mipmap_tree *mt, GLuint level, GLuint *offsets) -{ - if (mt->target != GL_TEXTURE_3D || mt->faces == 1) { - offsets[0] = 0; - } else { - int i; - for (i = 0; i < 6; i++) { - offsets[i] = mt->levels[level].faces[i].offset; - } - } -} - GLuint radeon_miptree_image_offset(radeon_mipmap_tree *mt, GLuint face, GLuint level) @@ -619,4 +600,4 @@ uint32_t get_base_teximage_offset(radeonTexObj *texObj) } else { return radeon_miptree_image_offset(texObj->mt, 0, texObj->minLod); } -} \ No newline at end of file +} diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.h b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.h index a10649b5ae..c911688c1a 100644 --- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.h +++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.h @@ -88,7 +88,5 @@ GLboolean radeon_miptree_matches_image(radeon_mipmap_tree *mt, void radeon_try_alloc_miptree(radeonContextPtr rmesa, radeonTexObj *t); GLuint radeon_miptree_image_offset(radeon_mipmap_tree *mt, GLuint face, GLuint level); -void radeon_miptree_depth_offsets(radeon_mipmap_tree *mt, GLuint level, GLuint *offsets); - uint32_t get_base_teximage_offset(radeonTexObj *texObj); #endif /* __RADEON_MIPMAP_TREE_H_ */ -- cgit v1.2.3 From 278ad74fe060ab8ba21d21b675a40f6758edaeca Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Fri, 22 Jan 2010 12:57:01 +0200 Subject: radeon/fbo: flush rendering before generating mipmaps or maybe should flush(also) in finish_render_texture... --- src/mesa/drivers/dri/radeon/radeon_texture.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c index 20a27ad9a7..4538e74eea 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texture.c +++ b/src/mesa/drivers/dri/radeon/radeon_texture.c @@ -233,8 +233,15 @@ static void radeon_generate_mipmap(GLcontext *ctx, GLenum target, void radeonGenerateMipmap(GLcontext* ctx, GLenum target, struct gl_texture_object *texObj) { + radeonContextPtr rmesa = RADEON_CONTEXT(ctx); + struct radeon_bo *bo; GLuint face = _mesa_tex_target_to_face(target); radeon_texture_image *baseimage = get_radeon_texture_image(texObj->Image[face][texObj->BaseLevel]); + bo = !baseimage->mt ? baseimage->bo : baseimage->mt->bo; + + if (bo && radeon_bo_is_referenced_by_cs(bo, rmesa->cmdbuf.cs)) { + radeon_firevertices(rmesa); + } radeon_teximage_map(baseimage, GL_FALSE); radeon_generate_mipmap(ctx, target, texObj); -- cgit v1.2.3 From 714d9c21ecc97134a0f9fd58075152acd55cde32 Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Fri, 22 Jan 2010 13:32:04 +0200 Subject: r600: cubemap levels seem to be aligned to 8 images --- src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c index 3a3658c314..5ea213dc5f 100644 --- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c +++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c @@ -177,6 +177,12 @@ static void calculate_miptree_layout_r300(radeonContextPtr rmesa, radeon_mipmap_ for(face = 0; face < mt->faces; face++) compute_tex_image_offset(rmesa, mt, face, level, &curOffset); + /* r600 cube levels seems to be aligned to 8 faces but + * we have separate register for 1'st level offset so add + * 2 image alignment after 1'st mip level */ + if(rmesa->radeonScreen->chip_family >= CHIP_FAMILY_R600 && + level >= 1) + curOffset += 2 * mt->levels[level].size; } /* Note the required size in memory */ -- cgit v1.2.3 From 9bf40cea00b2f509074bba3ace39c4ffbabdf047 Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Fri, 22 Jan 2010 13:47:31 +0200 Subject: r600: fix brownbag, only align if we are dealing with cubemap --- src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c index 5ea213dc5f..a1a523931f 100644 --- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c +++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c @@ -181,7 +181,7 @@ static void calculate_miptree_layout_r300(radeonContextPtr rmesa, radeon_mipmap_ * we have separate register for 1'st level offset so add * 2 image alignment after 1'st mip level */ if(rmesa->radeonScreen->chip_family >= CHIP_FAMILY_R600 && - level >= 1) + mt->target == GL_TEXTURE_CUBE_MAP && level >= 1) curOffset += 2 * mt->levels[level].size; } -- cgit v1.2.3 From 70ccca42515e01f8e6c01b39128721f31edba041 Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Fri, 22 Jan 2010 14:06:10 +0200 Subject: r600: update vport z & clipping when depth_clamp is changed fixes piglit depth_clamp --- src/mesa/drivers/dri/r600/r700_state.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mesa/drivers/dri/r600/r700_state.c b/src/mesa/drivers/dri/r600/r700_state.c index 3c8cb579f9..a795f62ab7 100644 --- a/src/mesa/drivers/dri/r600/r700_state.c +++ b/src/mesa/drivers/dri/r600/r700_state.c @@ -59,6 +59,7 @@ static void r700SetClipPlaneState(GLcontext * ctx, GLenum cap, GLboolean state); static void r700UpdatePolygonMode(GLcontext * ctx); static void r700SetPolygonOffsetState(GLcontext * ctx, GLboolean state); static void r700SetStencilState(GLcontext * ctx, GLboolean state); +static void r700UpdateWindow(GLcontext * ctx, int id); void r700UpdateShaders(GLcontext * ctx) { @@ -780,6 +781,9 @@ static void r700Enable(GLcontext * ctx, GLenum cap, GLboolean state) //--------- case GL_LINE_STIPPLE: r700UpdateLineStipple(ctx); break; + case GL_DEPTH_CLAMP: + r700UpdateWindow(ctx, 0); + break; default: break; } -- cgit v1.2.3 From 69e26a08c6d108366e8507d9d3d55036dc81cce7 Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Fri, 22 Jan 2010 16:55:47 +0200 Subject: r600: enable sampler lod* bits bits, settings derived from testing, might contain some errors... --- src/mesa/drivers/dri/r600/r600_texstate.c | 36 ++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r600_texstate.c b/src/mesa/drivers/dri/r600/r600_texstate.c index b8466bdd75..124365b400 100644 --- a/src/mesa/drivers/dri/r600/r600_texstate.c +++ b/src/mesa/drivers/dri/r600/r600_texstate.c @@ -651,6 +651,12 @@ static GLuint r600_translate_shadow_func(GLenum func) } } +static INLINE uint32_t +S_FIXED(float value, uint32_t frac_bits) +{ + return value * (1 << frac_bits); +} + void r600SetDepthTexMode(struct gl_texture_object *tObj) { radeonTexObjPtr t; @@ -670,8 +676,9 @@ void r600SetDepthTexMode(struct gl_texture_object *tObj) * \param rmesa Context pointer * \param t the r300 texture object */ -static void setup_hardware_state(context_t *rmesa, struct gl_texture_object *texObj) +static void setup_hardware_state(GLcontext * ctx, struct gl_texture_object *texObj, int unit) { + context_t *rmesa = R700_CONTEXT(ctx); radeonTexObj *t = radeon_tex_obj(texObj); const struct gl_texture_image *firstImage; GLuint uTexelPitch, row_align; @@ -733,11 +740,21 @@ static void setup_hardware_state(context_t *rmesa, struct gl_texture_object *tex t->SQ_TEX_RESOURCE2 = get_base_teximage_offset(t) / 256; - if ((t->maxLod - t->minLod) > 0) { - t->SQ_TEX_RESOURCE3 = radeon_miptree_image_offset(t->mt, 0, t->minLod + 1) / 256; - SETfield(t->SQ_TEX_RESOURCE4, 0, BASE_LEVEL_shift, BASE_LEVEL_mask); - SETfield(t->SQ_TEX_RESOURCE5, t->maxLod - t->minLod, LAST_LEVEL_shift, LAST_LEVEL_mask); - } + t->SQ_TEX_RESOURCE3 = radeon_miptree_image_offset(t->mt, 0, t->minLod + 1) / 256; + + SETfield(t->SQ_TEX_RESOURCE4, 0, BASE_LEVEL_shift, BASE_LEVEL_mask); + SETfield(t->SQ_TEX_RESOURCE5, t->maxLod - t->minLod, LAST_LEVEL_shift, LAST_LEVEL_mask); + + SETfield(t->SQ_TEX_SAMPLER1, + S_FIXED(CLAMP(t->base.MinLod - t->minLod, 0, 15), 6), + MIN_LOD_shift, MIN_LOD_mask); + SETfield(t->SQ_TEX_SAMPLER1, + S_FIXED(CLAMP(t->base.MaxLod - t->minLod, 0, 15), 6), + MAX_LOD_shift, MAX_LOD_mask); + SETfield(t->SQ_TEX_SAMPLER1, + S_FIXED(CLAMP(ctx->Texture.Unit[unit].LodBias + t->base.LodBias, -16, 16), 6), + SQ_TEX_SAMPLER_WORD1_0__LOD_BIAS_shift, SQ_TEX_SAMPLER_WORD1_0__LOD_BIAS_mask); + if(texObj->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB) { SETfield(t->SQ_TEX_SAMPLER0, r600_translate_shadow_func(texObj->CompareFunc), DEPTH_COMPARE_FUNCTION_shift, DEPTH_COMPARE_FUNCTION_mask); @@ -754,9 +771,8 @@ static void setup_hardware_state(context_t *rmesa, struct gl_texture_object *tex * * Mostly this means populating the texture object's mipmap tree. */ -static GLboolean r600_validate_texture(GLcontext * ctx, struct gl_texture_object *texObj) +static GLboolean r600_validate_texture(GLcontext * ctx, struct gl_texture_object *texObj, int unit) { - context_t *rmesa = R700_CONTEXT(ctx); radeonTexObj *t = radeon_tex_obj(texObj); if (!radeon_validate_texture_miptree(ctx, texObj)) @@ -764,7 +780,7 @@ static GLboolean r600_validate_texture(GLcontext * ctx, struct gl_texture_object /* Configure the hardware registers (more precisely, the cached version * of the hardware registers). */ - setup_hardware_state(rmesa, texObj); + setup_hardware_state(ctx, texObj, unit); t->validated = GL_TRUE; return GL_TRUE; @@ -805,7 +821,7 @@ GLboolean r600ValidateBuffers(GLcontext * ctx) if (!ctx->Texture.Unit[i]._ReallyEnabled) continue; - if (!r600_validate_texture(ctx, ctx->Texture.Unit[i]._Current)) { + if (!r600_validate_texture(ctx, ctx->Texture.Unit[i]._Current, i)) { radeon_warning("failed to validate texture for unit %d.\n", i); } t = radeon_tex_obj(ctx->Texture.Unit[i]._Current); -- cgit v1.2.3 From 96280c2a41e5fda570ba37ff5fca87f2cde59234 Mon Sep 17 00:00:00 2001 From: Ruediger Oertel Date: Fri, 22 Jan 2010 06:53:27 -0800 Subject: Fix PowerPC related typo in spantmp2.h Signed-off-by: Matthias Hopf Signed-off-by: Brian Paul --- src/mesa/drivers/dri/common/spantmp2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/common/spantmp2.h b/src/mesa/drivers/dri/common/spantmp2.h index 447f3d15b9..c152226902 100644 --- a/src/mesa/drivers/dri/common/spantmp2.h +++ b/src/mesa/drivers/dri/common/spantmp2.h @@ -400,7 +400,7 @@ # define READ_RGBA( rgba, _x, _y ) \ do { \ GLuint p = GET_VALUE(_x, _y); \ - *((uint32_t *) rgba) = (t << 8) | 0xff; \ + *((uint32_t *) rgba) = (p << 8) | 0xff; \ } while (0) # else # define READ_RGBA( rgba, _x, _y ) \ -- cgit v1.2.3 From 3c31b1b6d15dc5424babd5b4b54cd380d88be84a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 21 Jan 2010 13:02:56 -0700 Subject: gallium/draw: replace int with boolean --- src/gallium/auxiliary/draw/draw_pipe_validate.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_pipe_validate.c b/src/gallium/auxiliary/draw/draw_pipe_validate.c index bea90e50d3..a69e2633be 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_validate.c +++ b/src/gallium/auxiliary/draw/draw_pipe_validate.c @@ -151,8 +151,8 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage ) { struct draw_context *draw = stage->draw; struct draw_stage *next = draw->pipeline.rasterize; - int need_det = 0; - int precalc_flat = 0; + boolean need_det = FALSE; + boolean precalc_flat = FALSE; boolean wide_lines, wide_points; /* Set the validate's next stage to the rasterize stage, so that it @@ -194,7 +194,7 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage ) if (wide_lines) { draw->pipeline.wide_line->next = next; next = draw->pipeline.wide_line; - precalc_flat = 1; + precalc_flat = TRUE; } if (wide_points || draw->rasterizer->point_sprite) { @@ -205,7 +205,7 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage ) if (draw->rasterizer->line_stipple_enable && draw->pipeline.line_stipple) { draw->pipeline.stipple->next = next; next = draw->pipeline.stipple; - precalc_flat = 1; /* only needed for lines really */ + precalc_flat = TRUE; /* only needed for lines really */ } if (draw->rasterizer->poly_stipple_enable @@ -218,8 +218,8 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage ) draw->rasterizer->fill_ccw != PIPE_POLYGON_MODE_FILL) { draw->pipeline.unfilled->next = next; next = draw->pipeline.unfilled; - precalc_flat = 1; /* only needed for triangles really */ - need_det = 1; + precalc_flat = TRUE; /* only needed for triangles really */ + need_det = TRUE; } if (draw->rasterizer->flatshade && precalc_flat) { @@ -231,13 +231,13 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage ) draw->rasterizer->offset_ccw) { draw->pipeline.offset->next = next; next = draw->pipeline.offset; - need_det = 1; + need_det = TRUE; } if (draw->rasterizer->light_twoside) { draw->pipeline.twoside->next = next; next = draw->pipeline.twoside; - need_det = 1; + need_det = TRUE; } /* Always run the cull stage as we calculate determinant there -- cgit v1.2.3 From 5023a7f53f4b11cdea1ed90d7e856b6eda6dd68e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 21 Jan 2010 13:08:21 -0700 Subject: gallium/draw: fix-up comments, whitespace --- src/gallium/auxiliary/draw/draw_pipe_cull.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_pipe_cull.c b/src/gallium/auxiliary/draw/draw_pipe_cull.c index 11b39db599..dc66c65a56 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_cull.c +++ b/src/gallium/auxiliary/draw/draw_pipe_cull.c @@ -50,8 +50,6 @@ static INLINE struct cull_stage *cull_stage( struct draw_stage *stage ) } - - static void cull_tri( struct draw_stage *stage, struct prim_header *header ) { @@ -62,7 +60,7 @@ static void cull_tri( struct draw_stage *stage, const float *v1 = header->v[1]->data[pos]; const float *v2 = header->v[2]->data[pos]; - /* edge vectors e = v0 - v2, f = v1 - v2 */ + /* edge vectors: e = v0 - v2, f = v1 - v2 */ const float ex = v0[0] - v2[0]; const float ey = v0[1] - v2[1]; const float fx = v1[0] - v2[0]; @@ -72,7 +70,7 @@ static void cull_tri( struct draw_stage *stage, header->det = ex * fy - ey * fx; if (header->det != 0) { - /* if (det < 0 then Z points toward camera and triangle is + /* if det < 0 then Z points toward the camera and the triangle is * counter-clockwise winding. */ unsigned winding = (header->det < 0) ? PIPE_WINDING_CCW : PIPE_WINDING_CW; @@ -84,6 +82,7 @@ static void cull_tri( struct draw_stage *stage, } } + static void cull_first_tri( struct draw_stage *stage, struct prim_header *header ) { @@ -96,13 +95,13 @@ static void cull_first_tri( struct draw_stage *stage, } - static void cull_flush( struct draw_stage *stage, unsigned flags ) { stage->tri = cull_first_tri; stage->next->flush( stage->next, flags ); } + static void cull_reset_stipple_counter( struct draw_stage *stage ) { stage->next->reset_stipple_counter( stage->next ); @@ -140,7 +139,7 @@ struct draw_stage *draw_cull_stage( struct draw_context *draw ) return &cull->stage; - fail: +fail: if (cull) cull->stage.destroy( &cull->stage ); -- cgit v1.2.3 From 2f1a49e335837bdb03b5ce7818d83989c743935a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 21 Jan 2010 13:46:53 -0700 Subject: progs/xdemos: add z/Z keys for scaling the rendering --- progs/xdemos/offset.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/progs/xdemos/offset.c b/progs/xdemos/offset.c index 314a4fcdd1..3858a5b802 100644 --- a/progs/xdemos/offset.c +++ b/progs/xdemos/offset.c @@ -94,6 +94,9 @@ static int attributeList[] = { GLX_RGBA, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, static int dimension = 3; +static float Scale = 1.0; + + int main(int argc, char** argv) { Display *dpy; XVisualInfo *vi; @@ -182,6 +185,7 @@ draw_scene(int mx, int my) { #else glEnable(GL_POLYGON_OFFSET_FILL); #endif + glScalef(Scale, Scale, Scale); cubes(mx, my, HIDDEN_LINE); #ifdef GL_EXT_polygon_offset glDisable(GL_POLYGON_OFFSET_EXT); @@ -289,6 +293,12 @@ process_input(Display *dpy, Window win) { case KeyPress: (void) XLookupString(&event.xkey, buf, sizeof(buf), &keysym, NULL); switch (keysym) { + case 'Z': + Scale *= 1.1; + break; + case 'z': + Scale *= 0.9; + break; case XK_Escape: exit(EXIT_SUCCESS); default: -- cgit v1.2.3 From ea5918be0e8bc75086a7e6d4a8c0fa04585028ee Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 Jan 2010 08:15:14 -0700 Subject: glapi: fix int->pointer conversions warnings in no-op functions --- src/mesa/glapi/glapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index adb47f9fec..35b8df2adf 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -121,7 +121,7 @@ warn(const char *func) warn(#func); #define RETURN_DISPATCH(func, args, msg) \ - return warn(#func); + warn(#func); return 0 #define TABLE_ENTRY(name) (_glapi_proc) NoOp##name -- cgit v1.2.3 From 126aff18aaf7512dfe07e4fd43e21a2ecd3a96ff Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 Jan 2010 09:32:12 -0700 Subject: glapi: split the no-op dispatch code into new glapi_nop.c file This unclutters the glapi.c file a bit. --- src/mesa/SConscript | 1 + src/mesa/glapi/Makefile | 1 + src/mesa/glapi/gl_apitemp.py | 4 +- src/mesa/glapi/glapi.c | 81 +---------------------------- src/mesa/glapi/glapi_nop.c | 119 +++++++++++++++++++++++++++++++++++++++++++ src/mesa/glapi/glapitemp.h | 4 +- src/mesa/sources.mak | 1 + 7 files changed, 127 insertions(+), 84 deletions(-) create mode 100644 src/mesa/glapi/glapi_nop.c diff --git a/src/mesa/SConscript b/src/mesa/SConscript index bdcfffed4b..ea5bad2825 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -251,6 +251,7 @@ if env['platform'] != 'winddk': 'main/dispatch.c', 'glapi/glapi.c', 'glapi/glapi_getproc.c', + 'glapi/glapi_nop.c', 'glapi/glthread.c', ] diff --git a/src/mesa/glapi/Makefile b/src/mesa/glapi/Makefile index 846c041cde..bfc3db4313 100644 --- a/src/mesa/glapi/Makefile +++ b/src/mesa/glapi/Makefile @@ -25,6 +25,7 @@ GLX_DIR = $(XORG_BASE)/glx SERVER_GLAPI_FILES = \ $(GLX_DIR)/glapi.h \ $(GLX_DIR)/glapi.c \ + $(GLX_DIR)/glapi_nop.c \ $(GLX_DIR)/glthread.c \ $(GLX_DIR)/glthread.h diff --git a/src/mesa/glapi/gl_apitemp.py b/src/mesa/glapi/gl_apitemp.py index 09b0d364ce..41a40fbeb6 100644 --- a/src/mesa/glapi/gl_apitemp.py +++ b/src/mesa/glapi/gl_apitemp.py @@ -180,7 +180,7 @@ class PrintGlOffsets(gl_XML.gl_print_base): #error _GLAPI_SKIP_NORMAL_ENTRY_POINTS must not be defined #endif -static _glapi_proc DISPATCH_TABLE_NAME[] = {""" +_glapi_proc DISPATCH_TABLE_NAME[] = {""" for f in api.functionIterateByOffset(): print ' TABLE_ENTRY(%s),' % (f.dispatch_name()) @@ -204,7 +204,7 @@ static _glapi_proc DISPATCH_TABLE_NAME[] = {""" * We list the functions which are not otherwise used. */ #ifdef UNUSED_TABLE_NAME -static _glapi_proc UNUSED_TABLE_NAME[] = {""" +_glapi_proc UNUSED_TABLE_NAME[] = {""" normal_entries = [] proto_entries = [] diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index 35b8df2adf..469523d57c 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -73,85 +73,7 @@ #include "glapi/glapioffsets.h" #include "glapi/glapitable.h" -/***** BEGIN NO-OP DISPATCH *****/ - -static GLboolean WarnFlag = GL_FALSE; -static _glapi_warning_func warning_func; - -/* - * Enable/disable printing of warning messages. - */ -PUBLIC void -_glapi_noop_enable_warnings(GLboolean enable) -{ - WarnFlag = enable; -} - -/* - * Register a callback function for reporting errors. - */ -PUBLIC void -_glapi_set_warning_func( _glapi_warning_func func ) -{ - warning_func = func; -} - -static int -warn(const char *func) -{ -#if !defined(_WIN32_WCE) - if ((WarnFlag || getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) - && warning_func) { - warning_func(NULL, "GL User Error: called without context: %s", func); - } -#endif - return 0; -} - -#ifdef DEBUG - -#define KEYWORD1 static -#define KEYWORD1_ALT static -#define KEYWORD2 GLAPIENTRY -#define NAME(func) NoOp##func - -#define F NULL - -#define DISPATCH(func, args, msg) \ - warn(#func); - -#define RETURN_DISPATCH(func, args, msg) \ - warn(#func); return 0 - -#define TABLE_ENTRY(name) (_glapi_proc) NoOp##name - -#else - -static void -NoOpGeneric(void) -{ - if ((WarnFlag || getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) - && warning_func) { - warning_func(NULL, "GL User Error: calling GL function"); - } -} - -#define TABLE_ENTRY(name) (_glapi_proc) NoOpGeneric - -#endif - -#define DISPATCH_TABLE_NAME __glapi_noop_table -#define UNUSED_TABLE_NAME __unused_noop_functions - -static GLint NoOpUnused(void) -{ - return warn("extension function"); -} - -#include "glapi/glapitemp.h" - -/***** END NO-OP DISPATCH *****/ - +extern _glapi_proc __glapi_noop_table[]; /** @@ -278,7 +200,6 @@ _glapi_check_multithread(void) PUBLIC void _glapi_set_context(void *context) { - (void) __unused_noop_functions; /* silence a warning */ #if defined(GLX_USE_TLS) _glapi_tls_Context = context; #elif defined(THREADS) diff --git a/src/mesa/glapi/glapi_nop.c b/src/mesa/glapi/glapi_nop.c new file mode 100644 index 0000000000..a0d4b65f55 --- /dev/null +++ b/src/mesa/glapi/glapi_nop.c @@ -0,0 +1,119 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2010 VMWare, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS 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. + */ + + +/** + * No-op dispatch table. + * + * This file defines a special dispatch table which is loaded with no-op + * functions. + * + * When there's no current rendering context, calling a GL function like + * glBegin() is a no-op. Apps should never normally do this. So as a + * debugging aid, each of the no-op functions will emit a warning to + * stderr if the MESA_DEBUG or LIBGL_DEBUG env var is set. + */ + + + +#include "main/compiler.h" +#include "glapi/glapi.h" + + +static GLboolean WarnFlag = GL_FALSE; +static _glapi_warning_func warning_func; + +/* + * Enable/disable printing of warning messages. + */ +PUBLIC void +_glapi_noop_enable_warnings(GLboolean enable) +{ + WarnFlag = enable; +} + +/* + * Register a callback function for reporting errors. + */ +PUBLIC void +_glapi_set_warning_func( _glapi_warning_func func ) +{ + warning_func = func; +} + + +static int +warn(const char *func) +{ +#if !defined(_WIN32_WCE) + if ((WarnFlag || getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) + && warning_func) { + warning_func(NULL, "GL User Error: called without context: %s", func); + } +#endif + return 0; +} + +#ifdef DEBUG + +#define KEYWORD1 static +#define KEYWORD1_ALT static +#define KEYWORD2 GLAPIENTRY +#define NAME(func) NoOp##func +#define F NULL + +#define DISPATCH(func, args, msg) \ + warn(#func); + +#define RETURN_DISPATCH(func, args, msg) \ + warn(#func); return 0 + +#define TABLE_ENTRY(name) (_glapi_proc) NoOp##name + +#else + +static void +NoOpGeneric(void) +{ + if ((WarnFlag || getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) + && warning_func) { + warning_func(NULL, "GL User Error: calling GL function"); + } +} + + +#define TABLE_ENTRY(name) (_glapi_proc) NoOpGeneric + +#endif + +#define DISPATCH_TABLE_NAME __glapi_noop_table +#define UNUSED_TABLE_NAME __unused_noop_functions + +static int NoOpUnused(void) +{ + return warn("extension function"); +} + +#include "glapi/glapitemp.h" diff --git a/src/mesa/glapi/glapitemp.h b/src/mesa/glapi/glapitemp.h index b8bfcc1a16..2540ef6465 100644 --- a/src/mesa/glapi/glapitemp.h +++ b/src/mesa/glapi/glapitemp.h @@ -5764,7 +5764,7 @@ KEYWORD1_ALT void KEYWORD2 NAME(_dispatch_stub_366)(GLenum target, GLenum pname, #error _GLAPI_SKIP_NORMAL_ENTRY_POINTS must not be defined #endif -static _glapi_proc DISPATCH_TABLE_NAME[] = { +_glapi_proc DISPATCH_TABLE_NAME[] = { TABLE_ENTRY(NewList), TABLE_ENTRY(EndList), TABLE_ENTRY(CallList), @@ -6680,7 +6680,7 @@ static _glapi_proc DISPATCH_TABLE_NAME[] = { * We list the functions which are not otherwise used. */ #ifdef UNUSED_TABLE_NAME -static _glapi_proc UNUSED_TABLE_NAME[] = { +_glapi_proc UNUSED_TABLE_NAME[] = { #ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS TABLE_ENTRY(ArrayElementEXT), TABLE_ENTRY(BindTextureEXT), diff --git a/src/mesa/sources.mak b/src/mesa/sources.mak index a4d09c75bb..12d4c2831d 100644 --- a/src/mesa/sources.mak +++ b/src/mesa/sources.mak @@ -89,6 +89,7 @@ GLAPI_SOURCES = \ main/dispatch.c \ glapi/glapi.c \ glapi/glapi_getproc.c \ + glapi/glapi_nop.c \ glapi/glthread.c MATH_SOURCES = \ -- cgit v1.2.3 From e4f168a6f4911a096be97d2e83ef8ad9c5862ec0 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 Jan 2010 09:35:12 -0700 Subject: glapi: clean-up and simplify glapi_nop.c code Removed _glapi_noop_enable_warnings() and _glapi_set_warning_func(). Just check the DEBUG env vars and call fprintf(stderr) with a warning message instead. --- src/mesa/glapi/glapi.h | 8 ----- src/mesa/glapi/glapi_nop.c | 79 +++++++++++++++------------------------------- src/mesa/main/context.c | 8 ----- 3 files changed, 25 insertions(+), 70 deletions(-) diff --git a/src/mesa/glapi/glapi.h b/src/mesa/glapi/glapi.h index 5fb5401229..47ea23e92b 100644 --- a/src/mesa/glapi/glapi.h +++ b/src/mesa/glapi/glapi.h @@ -55,8 +55,6 @@ struct _glapi_table; typedef void (*_glapi_proc)(void); /* generic function pointer */ -typedef void (*_glapi_warning_func)(void *ctx, const char *str, ...); - #if defined(USE_MGL_NAMESPACE) #define _glapi_set_dispatch _mglapi_set_dispatch @@ -106,12 +104,6 @@ extern struct _glapi_table *_glapi_Dispatch; ** GL API public functions **/ -extern void -_glapi_noop_enable_warnings(GLboolean enable); - -extern void -_glapi_set_warning_func(_glapi_warning_func func); - extern void _glapi_check_multithread(void); diff --git a/src/mesa/glapi/glapi_nop.c b/src/mesa/glapi/glapi_nop.c index a0d4b65f55..e45faef72d 100644 --- a/src/mesa/glapi/glapi_nop.c +++ b/src/mesa/glapi/glapi_nop.c @@ -42,78 +42,49 @@ #include "glapi/glapi.h" -static GLboolean WarnFlag = GL_FALSE; -static _glapi_warning_func warning_func; - -/* - * Enable/disable printing of warning messages. - */ -PUBLIC void -_glapi_noop_enable_warnings(GLboolean enable) -{ - WarnFlag = enable; -} - -/* - * Register a callback function for reporting errors. +/** + * Called by each of the no-op GL entrypoints. */ -PUBLIC void -_glapi_set_warning_func( _glapi_warning_func func ) -{ - warning_func = func; -} - - static int -warn(const char *func) +Warn(const char *func) { #if !defined(_WIN32_WCE) - if ((WarnFlag || getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) - && warning_func) { - warning_func(NULL, "GL User Error: called without context: %s", func); + if (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) { + fprintf(stderr, "GL User Error: gl%s called without a rendering context\n", + func); } #endif - return 0; + return 0; +} + + +/** + * This is called if the user somehow calls an unassigned GL dispatch function. + */ +static GLint +NoOpUnused(void) +{ + return Warn(" function"); } -#ifdef DEBUG +/* + * Defines for the glapitemp.h functions. + */ #define KEYWORD1 static #define KEYWORD1_ALT static #define KEYWORD2 GLAPIENTRY #define NAME(func) NoOp##func -#define F NULL - -#define DISPATCH(func, args, msg) \ - warn(#func); +#define DISPATCH(func, args, msg) Warn(#func); +#define RETURN_DISPATCH(func, args, msg) Warn(#func); return 0 -#define RETURN_DISPATCH(func, args, msg) \ - warn(#func); return 0 +/* + * Defines for the table of no-op entry points. + */ #define TABLE_ENTRY(name) (_glapi_proc) NoOp##name - -#else - -static void -NoOpGeneric(void) -{ - if ((WarnFlag || getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) - && warning_func) { - warning_func(NULL, "GL User Error: calling GL function"); - } -} - - -#define TABLE_ENTRY(name) (_glapi_proc) NoOpGeneric - -#endif - #define DISPATCH_TABLE_NAME __glapi_noop_table #define UNUSED_TABLE_NAME __unused_noop_functions -static int NoOpUnused(void) -{ - return warn("extension function"); -} #include "glapi/glapitemp.h" diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 320c59068c..a570506d57 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -415,14 +415,6 @@ one_time_init( GLcontext *ctx ) _mesa_ubyte_to_float_color_tab[i] = (float) i / 255.0F; } - if (_mesa_getenv("MESA_DEBUG")) { - _glapi_noop_enable_warnings(GL_TRUE); - _glapi_set_warning_func( (_glapi_warning_func) _mesa_warning ); - } - else { - _glapi_noop_enable_warnings(GL_FALSE); - } - #if defined(DEBUG) && defined(__DATE__) && defined(__TIME__) _mesa_debug(ctx, "Mesa %s DEBUG build %s %s\n", MESA_VERSION_STRING, __DATE__, __TIME__); -- cgit v1.2.3 From 2b20b604277e3cdf7afb2431b50dbb05da12ff1c Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Fri, 22 Jan 2010 10:38:06 -0700 Subject: mesa: Add "shader/" path to #include statements in shader parser/lexer sources Signed-off-by: Alan Coopersmith Note sure why the compiler's -I paths aren't doing the job, but this is OK. Signed-off-by: Brian Paul --- src/mesa/shader/lex.yy.c | 10 +++++----- src/mesa/shader/program_lexer.l | 10 +++++----- src/mesa/shader/program_parse.tab.c | 16 ++++++++-------- src/mesa/shader/program_parse.y | 16 ++++++++-------- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/mesa/shader/lex.yy.c b/src/mesa/shader/lex.yy.c index 68543ae2e1..d1af35fedb 100644 --- a/src/mesa/shader/lex.yy.c +++ b/src/mesa/shader/lex.yy.c @@ -1043,12 +1043,12 @@ static yyconst flex_int16_t yy_chk[1368] = */ #include "main/glheader.h" #include "main/imports.h" -#include "prog_instruction.h" -#include "prog_statevars.h" +#include "shader/prog_instruction.h" +#include "shader/prog_statevars.h" -#include "symbol_table.h" -#include "program_parser.h" -#include "program_parse.tab.h" +#include "shader/symbol_table.h" +#include "shader/program_parser.h" +#include "shader/program_parse.tab.h" #define require_ARB_vp (yyextra->mode == ARB_vertex) #define require_ARB_fp (yyextra->mode == ARB_fragment) diff --git a/src/mesa/shader/program_lexer.l b/src/mesa/shader/program_lexer.l index e2acb3c0c9..83bc5089d9 100644 --- a/src/mesa/shader/program_lexer.l +++ b/src/mesa/shader/program_lexer.l @@ -23,12 +23,12 @@ */ #include "main/glheader.h" #include "main/imports.h" -#include "prog_instruction.h" -#include "prog_statevars.h" +#include "shader/prog_instruction.h" +#include "shader/prog_statevars.h" -#include "symbol_table.h" -#include "program_parser.h" -#include "program_parse.tab.h" +#include "shader/symbol_table.h" +#include "shader/program_parser.h" +#include "shader/program_parse.tab.h" #define require_ARB_vp (yyextra->mode == ARB_vertex) #define require_ARB_fp (yyextra->mode == ARB_fragment) diff --git a/src/mesa/shader/program_parse.tab.c b/src/mesa/shader/program_parse.tab.c index b12dcee9df..2adfb40973 100644 --- a/src/mesa/shader/program_parse.tab.c +++ b/src/mesa/shader/program_parse.tab.c @@ -98,14 +98,14 @@ #include "main/mtypes.h" #include "main/imports.h" -#include "program.h" -#include "prog_parameter.h" -#include "prog_parameter_layout.h" -#include "prog_statevars.h" -#include "prog_instruction.h" - -#include "symbol_table.h" -#include "program_parser.h" +#include "shader/program.h" +#include "shader/prog_parameter.h" +#include "shader/prog_parameter_layout.h" +#include "shader/prog_statevars.h" +#include "shader/prog_instruction.h" + +#include "shader/symbol_table.h" +#include "shader/program_parser.h" extern void *yy_scan_string(char *); extern void yy_delete_buffer(void *); diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y index 5c5d8d7590..3880d54917 100644 --- a/src/mesa/shader/program_parse.y +++ b/src/mesa/shader/program_parse.y @@ -27,14 +27,14 @@ #include "main/mtypes.h" #include "main/imports.h" -#include "program.h" -#include "prog_parameter.h" -#include "prog_parameter_layout.h" -#include "prog_statevars.h" -#include "prog_instruction.h" - -#include "symbol_table.h" -#include "program_parser.h" +#include "shader/program.h" +#include "shader/prog_parameter.h" +#include "shader/prog_parameter_layout.h" +#include "shader/prog_statevars.h" +#include "shader/prog_instruction.h" + +#include "shader/symbol_table.h" +#include "shader/program_parser.h" extern void *yy_scan_string(char *); extern void yy_delete_buffer(void *); -- cgit v1.2.3 From 5ab0d49a07fb81b7545463310c91ada596e26e72 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 Jan 2010 11:39:19 -0700 Subject: gallium/draw: added comments, whitespace fixes --- src/gallium/auxiliary/draw/draw_pipe.c | 38 +++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_pipe.c b/src/gallium/auxiliary/draw/draw_pipe.c index 1c6d657297..c9fd1a793a 100644 --- a/src/gallium/auxiliary/draw/draw_pipe.c +++ b/src/gallium/auxiliary/draw/draw_pipe.c @@ -106,10 +106,9 @@ void draw_pipeline_destroy( struct draw_context *draw ) - - - - +/** + * Build primitive to render a point with vertex at v0. + */ static void do_point( struct draw_context *draw, const char *v0 ) { @@ -123,6 +122,10 @@ static void do_point( struct draw_context *draw, } +/** + * Build primitive to render a line with vertices at v0, v1. + * \param flags bitmask of DRAW_PIPE_EDGE_x, DRAW_PIPE_RESET_STIPPLE + */ static void do_line( struct draw_context *draw, ushort flags, const char *v0, @@ -139,6 +142,10 @@ static void do_line( struct draw_context *draw, } +/** + * Build primitive to render a triangle with vertices at v0, v1, v2. + * \param flags bitmask of DRAW_PIPE_EDGE_x, DRAW_PIPE_RESET_STIPPLE + */ static void do_triangle( struct draw_context *draw, ushort flags, char *v0, @@ -157,7 +164,10 @@ static void do_triangle( struct draw_context *draw, } - +/* + * Set up macros for draw_pt_decompose.h template code. + * This code uses vertex indexes / elements. + */ #define QUAD(i0,i1,i2,i3) \ do_triangle( draw, \ ( DRAW_PIPE_RESET_STIPPLE | \ @@ -175,14 +185,14 @@ static void do_triangle( struct draw_context *draw, #define TRIANGLE(flags,i0,i1,i2) \ do_triangle( draw, \ - elts[i0], /* flags */ \ + elts[i0], /* flags */ \ verts + stride * (elts[i0] & ~DRAW_PIPE_FLAG_MASK), \ verts + stride * elts[i1], \ verts + stride * elts[i2]) #define LINE(flags,i0,i1) \ do_line( draw, \ - elts[i0], \ + elts[i0], \ verts + stride * (elts[i0] & ~DRAW_PIPE_FLAG_MASK), \ verts + stride * elts[i1]) @@ -213,7 +223,9 @@ static void do_triangle( struct draw_context *draw, -/* Code to run the pipeline on a fairly arbitary collection of vertices. +/** + * Code to run the pipeline on a fairly arbitary collection of vertices. + * For drawing indexed primitives. * * Vertex headers must be pre-initialized with the * UNDEFINED_VERTEX_ID, this code will cause that id to become @@ -243,6 +255,12 @@ void draw_pipeline_run( struct draw_context *draw, draw->pipeline.vertex_count = 0; } + + +/* + * Set up macros for draw_pt_decompose.h template code. + * This code is for non-indexed rendering (no elts). + */ #define QUAD(i0,i1,i2,i3) \ do_triangle( draw, \ ( DRAW_PIPE_RESET_STIPPLE | \ @@ -293,6 +311,10 @@ void draw_pipeline_run( struct draw_context *draw, #include "draw_pt_decompose.h" + +/* + * For drawing non-indexed primitives. + */ void draw_pipeline_run_linear( struct draw_context *draw, unsigned prim, struct vertex_header *vertices, -- cgit v1.2.3 From 64871747bb7b611ffe429fbf1724bd98ee25dd84 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 Jan 2010 11:45:40 -0700 Subject: gallium/draw: apply DRAW_PIPE_FLAG_MASK to all vertex elements Depending on first/last provoking vertex either the first or last element/index may have the extra DRAW_PIPE_x flags. Mask off those bits for all vertex elements to be safe (esp. for the quad case). This may be overly cautious, but it's a cheap operation. Fixes a segfault caused by large/bogus vertex indexes otherwise. --- src/gallium/auxiliary/draw/draw_pipe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_pipe.c b/src/gallium/auxiliary/draw/draw_pipe.c index c9fd1a793a..11d6485dcf 100644 --- a/src/gallium/auxiliary/draw/draw_pipe.c +++ b/src/gallium/auxiliary/draw/draw_pipe.c @@ -187,14 +187,14 @@ static void do_triangle( struct draw_context *draw, do_triangle( draw, \ elts[i0], /* flags */ \ verts + stride * (elts[i0] & ~DRAW_PIPE_FLAG_MASK), \ - verts + stride * elts[i1], \ - verts + stride * elts[i2]) + verts + stride * (elts[i1] & ~DRAW_PIPE_FLAG_MASK), \ + verts + stride * (elts[i2] & ~DRAW_PIPE_FLAG_MASK) ); #define LINE(flags,i0,i1) \ do_line( draw, \ elts[i0], \ verts + stride * (elts[i0] & ~DRAW_PIPE_FLAG_MASK), \ - verts + stride * elts[i1]) + verts + stride * (elts[i1] & ~DRAW_PIPE_FLAG_MASK) ); #define POINT(i0) \ do_point( draw, \ -- cgit v1.2.3 From 1e4b81267c77567ec9dfb687ccd8f02086053777 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 Jan 2010 12:27:25 -0700 Subject: gallium/aux: re-add pb_buffer_fenced.[ch] accidentally remove during merge --- .../auxiliary/pipebuffer/pb_buffer_fenced.c | 1065 ++++++-------------- .../auxiliary/pipebuffer/pb_buffer_fenced.h | 37 + 2 files changed, 333 insertions(+), 769 deletions(-) diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c index 1ac424d678..a4b78f1494 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c @@ -1,7 +1,6 @@ /************************************************************************** * * Copyright 2007-2009 VMware, Inc. - * Copyright 2007-2010 VMware, Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -29,9 +28,9 @@ /** * \file * Implementation of fenced buffers. - * - * \author Jose Fonseca - * \author Thomas Hellström + * + * \author Jose Fonseca + * \author Thomas Hellström */ @@ -51,7 +50,6 @@ #include "pb_buffer.h" #include "pb_buffer_fenced.h" -#include "pb_bufmgr.h" @@ -61,79 +59,32 @@ #define SUPER(__derived) (&(__derived)->base) -struct fenced_manager +struct fenced_buffer_list { - struct pb_manager base; - struct pb_manager *provider; - struct pb_fence_ops *ops; - - /** - * Maximum buffer size that can be safely allocated. - */ - pb_size max_buffer_size; - - /** - * Maximum cpu memory we can allocate before we start waiting for the - * GPU to idle. - */ - pb_size max_cpu_total_size; - - /** - * Following members are mutable and protected by this mutex. - */ pipe_mutex mutex; - - /** - * Fenced buffer list. - * - * All fenced buffers are placed in this listed, ordered from the oldest - * fence to the newest fence. - */ - struct list_head fenced; - pb_size num_fenced; - + + struct pb_fence_ops *ops; + + pb_size numDelayed; + struct list_head delayed; + +#ifdef DEBUG + pb_size numUnfenced; struct list_head unfenced; - pb_size num_unfenced; - - /** - * How much temporary CPU memory is being used to hold unvalidated buffers. - */ - pb_size cpu_total_size; +#endif }; /** - * Fenced buffer. - * * Wrapper around a pipe buffer which adds fencing and reference counting. */ struct fenced_buffer { - /* - * Immutable members. - */ - struct pb_buffer base; - struct fenced_manager *mgr; - - /* - * Following members are mutable and protected by fenced_manager::mutex. - */ - - struct list_head head; - - /** - * Buffer with storage. - */ + struct pb_buffer *buffer; - pb_size size; - struct pb_desc desc; - /** - * Temporary CPU storage data. Used when there isn't enough GPU memory to - * store the buffer. - */ - void *data; + /* FIXME: protect access with mutex */ /** * A bitmask of PIPE_BUFFER_USAGE_CPU/GPU_READ/WRITE describing the current @@ -142,20 +93,13 @@ struct fenced_buffer unsigned flags; unsigned mapcount; - struct pb_validate *vl; unsigned validation_flags; - struct pipe_fence_handle *fence; -}; - -static INLINE struct fenced_manager * -fenced_manager(struct pb_manager *mgr) -{ - assert(mgr); - return (struct fenced_manager *)mgr; -} + struct list_head head; + struct fenced_buffer_list *list; +}; static INLINE struct fenced_buffer * @@ -166,569 +110,221 @@ fenced_buffer(struct pb_buffer *buf) } -static void -fenced_buffer_destroy_cpu_storage_locked(struct fenced_buffer *fenced_buf); - -static enum pipe_error -fenced_buffer_create_cpu_storage_locked(struct fenced_manager *fenced_mgr, - struct fenced_buffer *fenced_buf); - -static void -fenced_buffer_destroy_gpu_storage_locked(struct fenced_buffer *fenced_buf); - -static enum pipe_error -fenced_buffer_create_gpu_storage_locked(struct fenced_manager *fenced_mgr, - struct fenced_buffer *fenced_buf, - boolean wait); - -static enum pipe_error -fenced_buffer_copy_storage_to_gpu_locked(struct fenced_buffer *fenced_buf); - -static enum pipe_error -fenced_buffer_copy_storage_to_cpu_locked(struct fenced_buffer *fenced_buf); - - -/** - * Dump the fenced buffer list. - * - * Useful to understand failures to allocate buffers. - */ -static void -fenced_manager_dump_locked(struct fenced_manager *fenced_mgr) +static INLINE void +_fenced_buffer_add(struct fenced_buffer *fenced_buf) { -#ifdef DEBUG - struct pb_fence_ops *ops = fenced_mgr->ops; - struct list_head *curr, *next; - struct fenced_buffer *fenced_buf; - - debug_printf("%10s %7s %8s %7s %10s %s\n", - "buffer", "size", "refcount", "storage", "fence", "signalled"); + struct fenced_buffer_list *fenced_list = fenced_buf->list; - curr = fenced_mgr->unfenced.next; - next = curr->next; - while(curr != &fenced_mgr->unfenced) { - fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); - assert(!fenced_buf->fence); - debug_printf("%10p %7u %8u %7s\n", - (void *) fenced_buf, - fenced_buf->base.base.size, - p_atomic_read(&fenced_buf->base.base.reference.count), - fenced_buf->buffer ? "gpu" : (fenced_buf->data ? "cpu" : "none")); - curr = next; - next = curr->next; - } + assert(pipe_is_referenced(&fenced_buf->base.base.reference)); + assert(fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE); + assert(fenced_buf->fence); - curr = fenced_mgr->fenced.next; - next = curr->next; - while(curr != &fenced_mgr->fenced) { - int signaled; - fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); - assert(fenced_buf->buffer); - signaled = ops->fence_signalled(ops, fenced_buf->fence, 0); - debug_printf("%10p %7u %8u %7s %10p %s\n", - (void *) fenced_buf, - fenced_buf->base.base.size, - p_atomic_read(&fenced_buf->base.base.reference.count), - "gpu", - (void *) fenced_buf->fence, - signaled == 0 ? "y" : "n"); - curr = next; - next = curr->next; - } -#else - (void)fenced_mgr; +#ifdef DEBUG + LIST_DEL(&fenced_buf->head); + assert(fenced_list->numUnfenced); + --fenced_list->numUnfenced; #endif + LIST_ADDTAIL(&fenced_buf->head, &fenced_list->delayed); + ++fenced_list->numDelayed; } +/** + * Actually destroy the buffer. + */ static INLINE void -fenced_buffer_destroy_locked(struct fenced_manager *fenced_mgr, - struct fenced_buffer *fenced_buf) +_fenced_buffer_destroy(struct fenced_buffer *fenced_buf) { + struct fenced_buffer_list *fenced_list = fenced_buf->list; + assert(!pipe_is_referenced(&fenced_buf->base.base.reference)); - assert(!fenced_buf->fence); +#ifdef DEBUG assert(fenced_buf->head.prev); assert(fenced_buf->head.next); LIST_DEL(&fenced_buf->head); - assert(fenced_mgr->num_unfenced); - --fenced_mgr->num_unfenced; - - fenced_buffer_destroy_gpu_storage_locked(fenced_buf); - fenced_buffer_destroy_cpu_storage_locked(fenced_buf); - + assert(fenced_list->numUnfenced); + --fenced_list->numUnfenced; +#else + (void)fenced_list; +#endif + pb_reference(&fenced_buf->buffer, NULL); FREE(fenced_buf); } -/** - * Add the buffer to the fenced list. - * - * Reference count should be incremented before calling this function. - */ static INLINE void -fenced_buffer_add_locked(struct fenced_manager *fenced_mgr, - struct fenced_buffer *fenced_buf) -{ - assert(pipe_is_referenced(&fenced_buf->base.base.reference)); - assert(fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE); - assert(fenced_buf->fence); - - p_atomic_inc(&fenced_buf->base.base.reference.count); - - LIST_DEL(&fenced_buf->head); - assert(fenced_mgr->num_unfenced); - --fenced_mgr->num_unfenced; - LIST_ADDTAIL(&fenced_buf->head, &fenced_mgr->fenced); - ++fenced_mgr->num_fenced; -} - - -/** - * Remove the buffer from the fenced list, and potentially destroy the buffer - * if the reference count reaches zero. - * - * Returns TRUE if the buffer was detroyed. - */ -static INLINE boolean -fenced_buffer_remove_locked(struct fenced_manager *fenced_mgr, - struct fenced_buffer *fenced_buf) +_fenced_buffer_remove(struct fenced_buffer_list *fenced_list, + struct fenced_buffer *fenced_buf) { - struct pb_fence_ops *ops = fenced_mgr->ops; + struct pb_fence_ops *ops = fenced_list->ops; assert(fenced_buf->fence); - assert(fenced_buf->mgr == fenced_mgr); - + assert(fenced_buf->list == fenced_list); + ops->fence_reference(ops, &fenced_buf->fence, NULL); fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE; - + assert(fenced_buf->head.prev); assert(fenced_buf->head.next); - + LIST_DEL(&fenced_buf->head); - assert(fenced_mgr->num_fenced); - --fenced_mgr->num_fenced; - - LIST_ADDTAIL(&fenced_buf->head, &fenced_mgr->unfenced); - ++fenced_mgr->num_unfenced; - - if (p_atomic_dec_zero(&fenced_buf->base.base.reference.count)) { - fenced_buffer_destroy_locked(fenced_mgr, fenced_buf); - return TRUE; - } + assert(fenced_list->numDelayed); + --fenced_list->numDelayed; + +#ifdef DEBUG + LIST_ADDTAIL(&fenced_buf->head, &fenced_list->unfenced); + ++fenced_list->numUnfenced; +#endif + + /** + * FIXME!!! + */ - return FALSE; + if(!pipe_is_referenced(&fenced_buf->base.base.reference)) + _fenced_buffer_destroy(fenced_buf); } -/** - * Wait for the fence to expire, and remove it from the fenced list. - * - * This function will release and re-aquire the mutex, so any copy of mutable - * state must be discarded after calling it. - */ static INLINE enum pipe_error -fenced_buffer_finish_locked(struct fenced_manager *fenced_mgr, - struct fenced_buffer *fenced_buf) +_fenced_buffer_finish(struct fenced_buffer *fenced_buf) { - struct pb_fence_ops *ops = fenced_mgr->ops; - enum pipe_error ret = PIPE_ERROR; + struct fenced_buffer_list *fenced_list = fenced_buf->list; + struct pb_fence_ops *ops = fenced_list->ops; #if 0 debug_warning("waiting for GPU"); #endif - assert(pipe_is_referenced(&fenced_buf->base.base.reference)); assert(fenced_buf->fence); - if(fenced_buf->fence) { - struct pipe_fence_handle *fence = NULL; - int finished; - boolean proceed; - - ops->fence_reference(ops, &fence, fenced_buf->fence); - - pipe_mutex_unlock(fenced_mgr->mutex); - - finished = ops->fence_finish(ops, fenced_buf->fence, 0); - - pipe_mutex_lock(fenced_mgr->mutex); - - assert(pipe_is_referenced(&fenced_buf->base.base.reference)); - - /* - * Only proceed if the fence object didn't change in the meanwhile. - * Otherwise assume the work has been already carried out by another - * thread that re-aquired the lock before us. - */ - proceed = fence == fenced_buf->fence ? TRUE : FALSE; - - ops->fence_reference(ops, &fence, NULL); - - if(proceed && finished == 0) { - /* - * Remove from the fenced list - */ - - boolean destroyed; - - destroyed = fenced_buffer_remove_locked(fenced_mgr, fenced_buf); - - /* TODO: remove consequents buffers with the same fence? */ - - assert(!destroyed); - - fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE; - - ret = PIPE_OK; + if(ops->fence_finish(ops, fenced_buf->fence, 0) != 0) { + return PIPE_ERROR; } + /* Remove from the fenced list */ + /* TODO: remove consequents */ + _fenced_buffer_remove(fenced_list, fenced_buf); } - return ret; + fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE; + return PIPE_OK; } /** - * Remove as many fenced buffers from the fenced list as possible. - * - * Returns TRUE if at least one buffer was removed. + * Free as many fenced buffers from the list head as possible. */ -static boolean -fenced_manager_check_signalled_locked(struct fenced_manager *fenced_mgr, - boolean wait) +static void +_fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list, + int wait) { - struct pb_fence_ops *ops = fenced_mgr->ops; + struct pb_fence_ops *ops = fenced_list->ops; struct list_head *curr, *next; struct fenced_buffer *fenced_buf; struct pb_buffer *pb_buf; struct pipe_fence_handle *prev_fence = NULL; - boolean ret = FALSE; - curr = fenced_mgr->fenced.next; + curr = fenced_list->delayed.next; next = curr->next; - while(curr != &fenced_mgr->fenced) { + while(curr != &fenced_list->delayed) { fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); if(fenced_buf->fence != prev_fence) { int signaled; - - if (wait) { + if (wait) signaled = ops->fence_finish(ops, fenced_buf->fence, 0); - - /* - * Don't return just now. Instead preemptively check if the - * following buffers' fences already expired, without further waits. - */ - wait = FALSE; - } - else { + else signaled = ops->fence_signalled(ops, fenced_buf->fence, 0); - } - - if (signaled != 0) { - return ret; - } - + if (signaled != 0) + break; prev_fence = fenced_buf->fence; } else { - /* This buffer's fence object is identical to the previous buffer's - * fence object, so no need to check the fence again. - */ assert(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0); } - fenced_buffer_remove_locked(fenced_mgr, fenced_buf); - - ret = TRUE; - - curr = next; - next = curr->next; - } - - return ret; -} - - -/** - * Try to free some GPU memory by backing it up into CPU memory. - * - * Returns TRUE if at least one buffer was freed. - */ -static boolean -fenced_manager_free_gpu_storage_locked(struct fenced_manager *fenced_mgr) -{ - struct list_head *curr, *next; - struct fenced_buffer *fenced_buf; + _fenced_buffer_remove(fenced_list, fenced_buf); - curr = fenced_mgr->unfenced.next; - next = curr->next; - while(curr != &fenced_mgr->unfenced) { - fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); - - /* - * We can only move storage if the buffer is not mapped and not - * validated. - */ - if(fenced_buf->buffer && - !fenced_buf->mapcount && - !fenced_buf->vl) { - enum pipe_error ret; - - ret = fenced_buffer_create_cpu_storage_locked(fenced_mgr, fenced_buf); - if(ret == PIPE_OK) { - ret = fenced_buffer_copy_storage_to_cpu_locked(fenced_buf); - if(ret == PIPE_OK) { - fenced_buffer_destroy_gpu_storage_locked(fenced_buf); - return TRUE; - } - fenced_buffer_destroy_cpu_storage_locked(fenced_buf); - } - } - - curr = next; + curr = next; next = curr->next; } - - return FALSE; -} - - -/** - * Destroy CPU storage for this buffer. - */ -static void -fenced_buffer_destroy_cpu_storage_locked(struct fenced_buffer *fenced_buf) -{ - if(fenced_buf->data) { - align_free(fenced_buf->data); - fenced_buf->data = NULL; - assert(fenced_buf->mgr->cpu_total_size >= fenced_buf->size); - fenced_buf->mgr->cpu_total_size -= fenced_buf->size; - } -} - - -/** - * Create CPU storage for this buffer. - */ -static enum pipe_error -fenced_buffer_create_cpu_storage_locked(struct fenced_manager *fenced_mgr, - struct fenced_buffer *fenced_buf) -{ - assert(!fenced_buf->data); - if(fenced_buf->data) - return PIPE_OK; - - if (fenced_mgr->cpu_total_size + fenced_buf->size > fenced_mgr->max_cpu_total_size) - return PIPE_ERROR_OUT_OF_MEMORY; - - fenced_buf->data = align_malloc(fenced_buf->size, fenced_buf->desc.alignment); - if(!fenced_buf->data) - return PIPE_ERROR_OUT_OF_MEMORY; - - fenced_mgr->cpu_total_size += fenced_buf->size; - - return PIPE_OK; } -/** - * Destroy the GPU storage. - */ static void -fenced_buffer_destroy_gpu_storage_locked(struct fenced_buffer *fenced_buf) -{ - if(fenced_buf->buffer) { - pb_reference(&fenced_buf->buffer, NULL); - } -} - - -/** - * Try to create GPU storage for this buffer. - * - * This function is a shorthand around pb_manager::create_buffer for - * fenced_buffer_create_gpu_storage_locked()'s benefit. - */ -static INLINE boolean -fenced_buffer_try_create_gpu_storage_locked(struct fenced_manager *fenced_mgr, - struct fenced_buffer *fenced_buf) -{ - struct pb_manager *provider = fenced_mgr->provider; - - assert(!fenced_buf->buffer); - - fenced_buf->buffer = provider->create_buffer(fenced_mgr->provider, - fenced_buf->size, - &fenced_buf->desc); - return fenced_buf->buffer ? TRUE : FALSE; -} - - -/** - * Create GPU storage for this buffer. - */ -static enum pipe_error -fenced_buffer_create_gpu_storage_locked(struct fenced_manager *fenced_mgr, - struct fenced_buffer *fenced_buf, - boolean wait) +fenced_buffer_destroy(struct pb_buffer *buf) { - assert(!fenced_buf->buffer); - - /* - * Check for signaled buffers before trying to allocate. - */ - fenced_manager_check_signalled_locked(fenced_mgr, FALSE); - - fenced_buffer_try_create_gpu_storage_locked(fenced_mgr, fenced_buf); - - /* - * Keep trying while there is some sort of progress: - * - fences are expiring, - * - or buffers are being being swapped out from GPU memory into CPU memory. - */ - while(!fenced_buf->buffer && - (fenced_manager_check_signalled_locked(fenced_mgr, FALSE) || - fenced_manager_free_gpu_storage_locked(fenced_mgr))) { - fenced_buffer_try_create_gpu_storage_locked(fenced_mgr, fenced_buf); - } + struct fenced_buffer *fenced_buf = fenced_buffer(buf); + struct fenced_buffer_list *fenced_list = fenced_buf->list; - if(!fenced_buf->buffer && wait) { - /* - * Same as before, but this time around, wait to free buffers if - * necessary. - */ - while(!fenced_buf->buffer && - (fenced_manager_check_signalled_locked(fenced_mgr, TRUE) || - fenced_manager_free_gpu_storage_locked(fenced_mgr))) { - fenced_buffer_try_create_gpu_storage_locked(fenced_mgr, fenced_buf); + pipe_mutex_lock(fenced_list->mutex); + assert(!pipe_is_referenced(&fenced_buf->base.base.reference)); + if (fenced_buf->fence) { + struct pb_fence_ops *ops = fenced_list->ops; + if(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) { + struct list_head *curr, *prev; + curr = &fenced_buf->head; + prev = curr->prev; + do { + fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); + assert(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0); + _fenced_buffer_remove(fenced_list, fenced_buf); + curr = prev; + prev = curr->prev; + } while (curr != &fenced_list->delayed); + } + else { + /* delay destruction */ } } - - if(!fenced_buf->buffer) { - if(0) - fenced_manager_dump_locked(fenced_mgr); - - /* give up */ - return PIPE_ERROR_OUT_OF_MEMORY; + else { + _fenced_buffer_destroy(fenced_buf); } - - return PIPE_OK; -} - - -static enum pipe_error -fenced_buffer_copy_storage_to_gpu_locked(struct fenced_buffer *fenced_buf) -{ - uint8_t *map; - - assert(fenced_buf->data); - assert(fenced_buf->buffer); - - map = pb_map(fenced_buf->buffer, PIPE_BUFFER_USAGE_CPU_WRITE); - if(!map) - return PIPE_ERROR; - - memcpy(map, fenced_buf->data, fenced_buf->size); - - pb_unmap(fenced_buf->buffer); - - return PIPE_OK; -} - - -static enum pipe_error -fenced_buffer_copy_storage_to_cpu_locked(struct fenced_buffer *fenced_buf) -{ - const uint8_t *map; - - assert(fenced_buf->data); - assert(fenced_buf->buffer); - - map = pb_map(fenced_buf->buffer, PIPE_BUFFER_USAGE_CPU_READ); - if(!map) - return PIPE_ERROR; - - memcpy(fenced_buf->data, map, fenced_buf->size); - - pb_unmap(fenced_buf->buffer); - - return PIPE_OK; -} - - -static void -fenced_buffer_destroy(struct pb_buffer *buf) -{ - struct fenced_buffer *fenced_buf = fenced_buffer(buf); - struct fenced_manager *fenced_mgr = fenced_buf->mgr; - - assert(!pipe_is_referenced(&fenced_buf->base.base.reference)); - - pipe_mutex_lock(fenced_mgr->mutex); - - fenced_buffer_destroy_locked(fenced_mgr, fenced_buf); - - pipe_mutex_unlock(fenced_mgr->mutex); + pipe_mutex_unlock(fenced_list->mutex); } static void * -fenced_buffer_map(struct pb_buffer *buf, +fenced_buffer_map(struct pb_buffer *buf, unsigned flags) { struct fenced_buffer *fenced_buf = fenced_buffer(buf); - struct fenced_manager *fenced_mgr = fenced_buf->mgr; - struct pb_fence_ops *ops = fenced_mgr->ops; - void *map = NULL; - - pipe_mutex_lock(fenced_mgr->mutex); + struct fenced_buffer_list *fenced_list = fenced_buf->list; + struct pb_fence_ops *ops = fenced_list->ops; + void *map; assert(!(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE)); - - /* - * Serialize writes. - */ - while((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_WRITE) || - ((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ) && - (flags & PIPE_BUFFER_USAGE_CPU_WRITE))) { - - /* - * Don't wait for the GPU to finish accessing it, if blocking is forbidden. - */ - if((flags & PIPE_BUFFER_USAGE_DONTBLOCK) && - ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) { - goto done; + + /* Serialize writes */ + if((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_WRITE) || + ((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ) && (flags & PIPE_BUFFER_USAGE_CPU_WRITE))) { + if(flags & PIPE_BUFFER_USAGE_DONTBLOCK) { + /* Don't wait for the GPU to finish writing */ + if(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) + _fenced_buffer_remove(fenced_list, fenced_buf); + else + return NULL; } - - if (flags & PIPE_BUFFER_USAGE_UNSYNCHRONIZED) { - break; + else { + /* Wait for the GPU to finish writing */ + _fenced_buffer_finish(fenced_buf); } - - /* - * Wait for the GPU to finish accessing. This will release and re-acquire - * the mutex, so all copies of mutable state must be discarded. - */ - fenced_buffer_finish_locked(fenced_mgr, fenced_buf); } - if(fenced_buf->buffer) { - map = pb_map(fenced_buf->buffer, flags); - } - else { - assert(fenced_buf->data); - map = fenced_buf->data; +#if 0 + /* Check for CPU write access (read is OK) */ + if(fenced_buf->flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE) { + /* this is legal -- just for debugging */ + debug_warning("concurrent CPU writes"); } - +#endif + + map = pb_map(fenced_buf->buffer, flags); if(map) { ++fenced_buf->mapcount; fenced_buf->flags |= flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE; } -done: - pipe_mutex_unlock(fenced_mgr->mutex); - return map; } @@ -737,20 +333,13 @@ static void fenced_buffer_unmap(struct pb_buffer *buf) { struct fenced_buffer *fenced_buf = fenced_buffer(buf); - struct fenced_manager *fenced_mgr = fenced_buf->mgr; - - pipe_mutex_lock(fenced_mgr->mutex); - assert(fenced_buf->mapcount); if(fenced_buf->mapcount) { - if (fenced_buf->buffer) - pb_unmap(fenced_buf->buffer); + pb_unmap(fenced_buf->buffer); --fenced_buf->mapcount; if(!fenced_buf->mapcount) fenced_buf->flags &= ~PIPE_BUFFER_USAGE_CPU_READ_WRITE; } - - pipe_mutex_unlock(fenced_mgr->mutex); } @@ -760,72 +349,48 @@ fenced_buffer_validate(struct pb_buffer *buf, unsigned flags) { struct fenced_buffer *fenced_buf = fenced_buffer(buf); - struct fenced_manager *fenced_mgr = fenced_buf->mgr; enum pipe_error ret; - - pipe_mutex_lock(fenced_mgr->mutex); - + if(!vl) { /* invalidate */ fenced_buf->vl = NULL; fenced_buf->validation_flags = 0; - ret = PIPE_OK; - goto done; + return PIPE_OK; } - + assert(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE); assert(!(flags & ~PIPE_BUFFER_USAGE_GPU_READ_WRITE)); flags &= PIPE_BUFFER_USAGE_GPU_READ_WRITE; - /* Buffer cannot be validated in two different lists */ - if(fenced_buf->vl && fenced_buf->vl != vl) { - ret = PIPE_ERROR_RETRY; - goto done; + /* Buffer cannot be validated in two different lists */ + if(fenced_buf->vl && fenced_buf->vl != vl) + return PIPE_ERROR_RETRY; + +#if 0 + /* Do not validate if buffer is still mapped */ + if(fenced_buf->flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE) { + /* TODO: wait for the thread that mapped the buffer to unmap it */ + return PIPE_ERROR_RETRY; } + /* Final sanity checking */ + assert(!(fenced_buf->flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE)); + assert(!fenced_buf->mapcount); +#endif if(fenced_buf->vl == vl && (fenced_buf->validation_flags & flags) == flags) { /* Nothing to do -- buffer already validated */ - ret = PIPE_OK; - goto done; - } - - /* - * Create and update GPU storage. - */ - if(!fenced_buf->buffer) { - assert(!fenced_buf->mapcount); - - ret = fenced_buffer_create_gpu_storage_locked(fenced_mgr, fenced_buf, TRUE); - if(ret != PIPE_OK) { - goto done; - } - - ret = fenced_buffer_copy_storage_to_gpu_locked(fenced_buf); - if(ret != PIPE_OK) { - fenced_buffer_destroy_gpu_storage_locked(fenced_buf); - goto done; - } - - if(fenced_buf->mapcount) { - debug_printf("warning: validating a buffer while it is still mapped\n"); - } - else { - fenced_buffer_destroy_cpu_storage_locked(fenced_buf); - } + return PIPE_OK; } - + ret = pb_validate(fenced_buf->buffer, vl, flags); if (ret != PIPE_OK) - goto done; - + return ret; + fenced_buf->vl = vl; fenced_buf->validation_flags |= flags; - -done: - pipe_mutex_unlock(fenced_mgr->mutex); - - return ret; + + return PIPE_OK; } @@ -833,37 +398,36 @@ static void fenced_buffer_fence(struct pb_buffer *buf, struct pipe_fence_handle *fence) { - struct fenced_buffer *fenced_buf = fenced_buffer(buf); - struct fenced_manager *fenced_mgr = fenced_buf->mgr; - struct pb_fence_ops *ops = fenced_mgr->ops; - - pipe_mutex_lock(fenced_mgr->mutex); - - assert(pipe_is_referenced(&fenced_buf->base.base.reference)); - assert(fenced_buf->buffer); - - if(fence != fenced_buf->fence) { - assert(fenced_buf->vl); - assert(fenced_buf->validation_flags); - - if (fenced_buf->fence) { - boolean destroyed; - destroyed = fenced_buffer_remove_locked(fenced_mgr, fenced_buf); - assert(!destroyed); - } - if (fence) { - ops->fence_reference(ops, &fenced_buf->fence, fence); - fenced_buf->flags |= fenced_buf->validation_flags; - fenced_buffer_add_locked(fenced_mgr, fenced_buf); - } + struct fenced_buffer *fenced_buf; + struct fenced_buffer_list *fenced_list; + struct pb_fence_ops *ops; - pb_fence(fenced_buf->buffer, fence); + fenced_buf = fenced_buffer(buf); + fenced_list = fenced_buf->list; + ops = fenced_list->ops; + + if(fence == fenced_buf->fence) { + /* Nothing to do */ + return; + } - fenced_buf->vl = NULL; - fenced_buf->validation_flags = 0; + assert(fenced_buf->vl); + assert(fenced_buf->validation_flags); + + pipe_mutex_lock(fenced_list->mutex); + if (fenced_buf->fence) + _fenced_buffer_remove(fenced_list, fenced_buf); + if (fence) { + ops->fence_reference(ops, &fenced_buf->fence, fence); + fenced_buf->flags |= fenced_buf->validation_flags; + _fenced_buffer_add(fenced_buf); } + pipe_mutex_unlock(fenced_list->mutex); + + pb_fence(fenced_buf->buffer, fence); - pipe_mutex_unlock(fenced_mgr->mutex); + fenced_buf->vl = NULL; + fenced_buf->validation_flags = 0; } @@ -873,29 +437,11 @@ fenced_buffer_get_base_buffer(struct pb_buffer *buf, pb_size *offset) { struct fenced_buffer *fenced_buf = fenced_buffer(buf); - struct fenced_manager *fenced_mgr = fenced_buf->mgr; - - pipe_mutex_lock(fenced_mgr->mutex); - - /* - * This should only be called when the buffer is validated. Typically - * when processing relocations. - */ - assert(fenced_buf->vl); - assert(fenced_buf->buffer); - - if(fenced_buf->buffer) - pb_get_base_buffer(fenced_buf->buffer, base_buf, offset); - else { - *base_buf = buf; - *offset = 0; - } - - pipe_mutex_unlock(fenced_mgr->mutex); + pb_get_base_buffer(fenced_buf->buffer, base_buf, offset); } -static const struct pb_vtbl +static const struct pb_vtbl fenced_buffer_vtbl = { fenced_buffer_destroy, fenced_buffer_map, @@ -906,166 +452,147 @@ fenced_buffer_vtbl = { }; -/** - * Wrap a buffer in a fenced buffer. - */ -static struct pb_buffer * -fenced_bufmgr_create_buffer(struct pb_manager *mgr, - pb_size size, - const struct pb_desc *desc) +struct pb_buffer * +fenced_buffer_create(struct fenced_buffer_list *fenced_list, + struct pb_buffer *buffer) { - struct fenced_manager *fenced_mgr = fenced_manager(mgr); - struct fenced_buffer *fenced_buf; - enum pipe_error ret; - - /* - * Don't stall the GPU, waste time evicting buffers, or waste memory - * trying to create a buffer that will most likely never fit into the - * graphics aperture. - */ - if(size > fenced_mgr->max_buffer_size) { - goto no_buffer; + struct fenced_buffer *buf; + + if(!buffer) + return NULL; + + buf = CALLOC_STRUCT(fenced_buffer); + if(!buf) { + pb_reference(&buffer, NULL); + return NULL; } + + pipe_reference_init(&buf->base.base.reference, 1); + buf->base.base.alignment = buffer->base.alignment; + buf->base.base.usage = buffer->base.usage; + buf->base.base.size = buffer->base.size; + + buf->base.vtbl = &fenced_buffer_vtbl; + buf->buffer = buffer; + buf->list = fenced_list; + +#ifdef DEBUG + pipe_mutex_lock(fenced_list->mutex); + LIST_ADDTAIL(&buf->head, &fenced_list->unfenced); + ++fenced_list->numUnfenced; + pipe_mutex_unlock(fenced_list->mutex); +#endif - fenced_buf = CALLOC_STRUCT(fenced_buffer); - if(!fenced_buf) - goto no_buffer; - - pipe_reference_init(&fenced_buf->base.base.reference, 1); - fenced_buf->base.base.alignment = desc->alignment; - fenced_buf->base.base.usage = desc->usage; - fenced_buf->base.base.size = size; - fenced_buf->size = size; - fenced_buf->desc = *desc; - - fenced_buf->base.vtbl = &fenced_buffer_vtbl; - fenced_buf->mgr = fenced_mgr; + return &buf->base; +} - pipe_mutex_lock(fenced_mgr->mutex); - /* - * Try to create GPU storage without stalling, - */ - ret = fenced_buffer_create_gpu_storage_locked(fenced_mgr, fenced_buf, FALSE); +struct fenced_buffer_list * +fenced_buffer_list_create(struct pb_fence_ops *ops) +{ + struct fenced_buffer_list *fenced_list; - /* - * Attempt to use CPU memory to avoid stalling the GPU. - */ - if(ret != PIPE_OK) { - ret = fenced_buffer_create_cpu_storage_locked(fenced_mgr, fenced_buf); - } + fenced_list = CALLOC_STRUCT(fenced_buffer_list); + if (!fenced_list) + return NULL; - /* - * Create GPU storage, waiting for some to be available. - */ - if(ret != PIPE_OK) { - ret = fenced_buffer_create_gpu_storage_locked(fenced_mgr, fenced_buf, TRUE); - } + fenced_list->ops = ops; - /* - * Give up. - */ - if(ret != PIPE_OK) { - goto no_storage; - } + LIST_INITHEAD(&fenced_list->delayed); + fenced_list->numDelayed = 0; + +#ifdef DEBUG + LIST_INITHEAD(&fenced_list->unfenced); + fenced_list->numUnfenced = 0; +#endif - assert(fenced_buf->buffer || fenced_buf->data); + pipe_mutex_init(fenced_list->mutex); - LIST_ADDTAIL(&fenced_buf->head, &fenced_mgr->unfenced); - ++fenced_mgr->num_unfenced; - pipe_mutex_unlock(fenced_mgr->mutex); + return fenced_list; +} - return &fenced_buf->base; -no_storage: - pipe_mutex_unlock(fenced_mgr->mutex); - FREE(fenced_buf); -no_buffer: - return NULL; +void +fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list, + int wait) +{ + pipe_mutex_lock(fenced_list->mutex); + _fenced_buffer_list_check_free(fenced_list, wait); + pipe_mutex_unlock(fenced_list->mutex); } -static void -fenced_bufmgr_flush(struct pb_manager *mgr) +#ifdef DEBUG +void +fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list) { - struct fenced_manager *fenced_mgr = fenced_manager(mgr); + struct pb_fence_ops *ops = fenced_list->ops; + struct list_head *curr, *next; + struct fenced_buffer *fenced_buf; - pipe_mutex_lock(fenced_mgr->mutex); - while(fenced_manager_check_signalled_locked(fenced_mgr, TRUE)) - ; - pipe_mutex_unlock(fenced_mgr->mutex); + pipe_mutex_lock(fenced_list->mutex); - assert(fenced_mgr->provider->flush); - if(fenced_mgr->provider->flush) - fenced_mgr->provider->flush(fenced_mgr->provider); + debug_printf("%10s %7s %7s %10s %s\n", + "buffer", "size", "refcount", "fence", "signalled"); + + curr = fenced_list->unfenced.next; + next = curr->next; + while(curr != &fenced_list->unfenced) { + fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); + assert(!fenced_buf->fence); + debug_printf("%10p %7u %7u\n", + (void *) fenced_buf, + fenced_buf->base.base.size, + p_atomic_read(&fenced_buf->base.base.reference.count)); + curr = next; + next = curr->next; + } + + curr = fenced_list->delayed.next; + next = curr->next; + while(curr != &fenced_list->delayed) { + int signaled; + fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); + signaled = ops->fence_signalled(ops, fenced_buf->fence, 0); + debug_printf("%10p %7u %7u %10p %s\n", + (void *) fenced_buf, + fenced_buf->base.base.size, + p_atomic_read(&fenced_buf->base.base.reference.count), + (void *) fenced_buf->fence, + signaled == 0 ? "y" : "n"); + curr = next; + next = curr->next; + } + + pipe_mutex_unlock(fenced_list->mutex); } +#endif -static void -fenced_bufmgr_destroy(struct pb_manager *mgr) +void +fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list) { - struct fenced_manager *fenced_mgr = fenced_manager(mgr); - - pipe_mutex_lock(fenced_mgr->mutex); + pipe_mutex_lock(fenced_list->mutex); /* Wait on outstanding fences */ - while (fenced_mgr->num_fenced) { - pipe_mutex_unlock(fenced_mgr->mutex); + while (fenced_list->numDelayed) { + pipe_mutex_unlock(fenced_list->mutex); #if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) sched_yield(); #endif - pipe_mutex_lock(fenced_mgr->mutex); - while(fenced_manager_check_signalled_locked(fenced_mgr, TRUE)) - ; + _fenced_buffer_list_check_free(fenced_list, 1); + pipe_mutex_lock(fenced_list->mutex); } #ifdef DEBUG - /*assert(!fenced_mgr->num_unfenced);*/ + /*assert(!fenced_list->numUnfenced);*/ #endif - - pipe_mutex_unlock(fenced_mgr->mutex); - pipe_mutex_destroy(fenced_mgr->mutex); - - if(fenced_mgr->provider) - fenced_mgr->provider->destroy(fenced_mgr->provider); - - fenced_mgr->ops->destroy(fenced_mgr->ops); - - FREE(fenced_mgr); + + pipe_mutex_unlock(fenced_list->mutex); + + fenced_list->ops->destroy(fenced_list->ops); + + FREE(fenced_list); } -struct pb_manager * -fenced_bufmgr_create(struct pb_manager *provider, - struct pb_fence_ops *ops, - pb_size max_buffer_size, - pb_size max_cpu_total_size) -{ - struct fenced_manager *fenced_mgr; - - if(!provider) - return NULL; - - fenced_mgr = CALLOC_STRUCT(fenced_manager); - if (!fenced_mgr) - return NULL; - - fenced_mgr->base.destroy = fenced_bufmgr_destroy; - fenced_mgr->base.create_buffer = fenced_bufmgr_create_buffer; - fenced_mgr->base.flush = fenced_bufmgr_flush; - - fenced_mgr->provider = provider; - fenced_mgr->ops = ops; - fenced_mgr->max_buffer_size = max_buffer_size; - fenced_mgr->max_cpu_total_size = max_cpu_total_size; - - LIST_INITHEAD(&fenced_mgr->fenced); - fenced_mgr->num_fenced = 0; - - LIST_INITHEAD(&fenced_mgr->unfenced); - fenced_mgr->num_unfenced = 0; - - pipe_mutex_init(fenced_mgr->mutex); - - return &fenced_mgr->base; -} diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h index 0372f81d0a..034ca1e024 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h @@ -98,6 +98,43 @@ struct pb_fence_ops }; +/** + * Create a fenced buffer list. + * + * See also fenced_bufmgr_create for a more convenient way to use this. + */ +struct fenced_buffer_list * +fenced_buffer_list_create(struct pb_fence_ops *ops); + + +/** + * Walk the fenced buffer list to check and free signalled buffers. + */ +void +fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list, + int wait); + + +#ifdef DEBUG +void +fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list); +#endif + + +void +fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list); + + +/** + * Wrap a buffer in a fenced buffer. + * + * NOTE: this will not increase the buffer reference count. + */ +struct pb_buffer * +fenced_buffer_create(struct fenced_buffer_list *fenced, + struct pb_buffer *buffer); + + #ifdef __cplusplus } #endif -- cgit v1.2.3 From d88b219cf37c488f57e18850c843078ff918b55d Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Fri, 22 Jan 2010 19:32:12 +0000 Subject: Remove obsolete file --- src/gallium/auxiliary/SConscript | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript index f957090b5f..3aa782f81e 100644 --- a/src/gallium/auxiliary/SConscript +++ b/src/gallium/auxiliary/SConscript @@ -87,7 +87,6 @@ source = [ 'pipebuffer/pb_bufmgr_alt.c', 'pipebuffer/pb_bufmgr_cache.c', 'pipebuffer/pb_bufmgr_debug.c', - 'pipebuffer/pb_bufmgr_fenced.c', 'pipebuffer/pb_bufmgr_mm.c', 'pipebuffer/pb_bufmgr_ondemand.c', 'pipebuffer/pb_bufmgr_pool.c', -- cgit v1.2.3 From efde2df114c2c15212198cb196b50cd29bd75f70 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 Jan 2010 13:07:04 -0700 Subject: xlib/softpipe: more buffer free fixes The previous memory leak fix didn't always work properly. Now check the xm_buffer::smh field (now documented!) to see if the buffer points to shared memory. --- src/gallium/winsys/xlib/xlib_softpipe.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/gallium/winsys/xlib/xlib_softpipe.c b/src/gallium/winsys/xlib/xlib_softpipe.c index da2484c981..9769eb0030 100644 --- a/src/gallium/winsys/xlib/xlib_softpipe.c +++ b/src/gallium/winsys/xlib/xlib_softpipe.c @@ -62,7 +62,7 @@ struct xm_buffer XImage *tempImage; #ifdef USE_XSHM - int shm; + boolean shm; /** Is this a shared memory buffer? */ XShmSegmentInfo shminfo; #endif }; @@ -151,7 +151,7 @@ alloc_shm_ximage(struct xm_buffer *b, struct xmesa_buffer *xmb, &b->shminfo, width, height); if (b->tempImage == NULL) { - b->shm = 0; + b->shm = FALSE; return; } @@ -168,12 +168,12 @@ alloc_shm_ximage(struct xm_buffer *b, struct xmesa_buffer *xmb, mesaXErrorFlag = 0; XDestroyImage(b->tempImage); b->tempImage = NULL; - b->shm = 0; + b->shm = FALSE; (void) XSetErrorHandler(old_handler); return; } - b->shm = 1; + b->shm = TRUE; } #endif /* USE_XSHM */ @@ -221,12 +221,13 @@ xm_buffer_destroy(struct pipe_buffer *buf) oldBuf->shminfo.shmaddr = (char *) -1; } + if (oldBuf->shm) { + oldBuf->data = NULL; + } + if (oldBuf->tempImage) { - if (oldBuf->data == oldBuf->tempImage->data) { - /* oldBuf->data points at the xshm memory which we'll now free */ - oldBuf->data = NULL; - } XDestroyImage(oldBuf->tempImage); + oldBuf->tempImage = NULL; } #endif @@ -341,10 +342,8 @@ xm_buffer_create(struct pipe_winsys *pws, buffer->base.usage = usage; buffer->base.size = size; - if (buffer->data == NULL) { - /* align to 16-byte multiple for Cell */ - buffer->data = align_malloc(size, max(alignment, 16)); - } + /* align to 16-byte multiple for Cell */ + buffer->data = align_malloc(size, max(alignment, 16)); return &buffer->base; } -- cgit v1.2.3 From 8d1a01d37039a76ecbb8fdb4c10ff8d11aa02dfb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 Jan 2010 15:36:28 -0700 Subject: mesa: use new fetch_vector1ui() function for 'unpack' GPU instructions The UP2H, UP2US, UP4B and UP4UB instructions interpret the float registers as integers. With gcc -O3 some bits were getting mixed up somewhere. This is part of the fix for the piglit fp-unpack-01 test failure (bug 25973). --- src/mesa/shader/prog_execute.c | 66 +++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/src/mesa/shader/prog_execute.c b/src/mesa/shader/prog_execute.c index 1ef801a17d..fb29768935 100644 --- a/src/mesa/shader/prog_execute.c +++ b/src/mesa/shader/prog_execute.c @@ -341,6 +341,28 @@ fetch_vector1(const struct prog_src_register *source, } +static GLuint +fetch_vector1ui(const struct prog_src_register *source, + const struct gl_program_machine *machine) +{ + const GLuint *src = (GLuint *) get_src_register_pointer(source, machine); + GLuint result; + + ASSERT(src); + + result = src[GET_SWZ(source->Swizzle, 0)]; + + if (source->Abs) { + result = FABSF(result); + } + if (source->Negate) { + result = -result; + } + + return result; +} + + /** * Fetch texel from texture. Use partial derivatives when possible. */ @@ -1633,12 +1655,11 @@ _mesa_execute_program(GLcontext * ctx, break; case OPCODE_UP2H: /* unpack two 16-bit floats */ { - GLfloat a[4], result[4]; - const GLuint *rawBits = (const GLuint *) a; + const GLuint raw = fetch_vector1ui(&inst->SrcReg[0], machine); + GLfloat result[4]; GLhalfNV hx, hy; - fetch_vector1(&inst->SrcReg[0], machine, a); - hx = rawBits[0] & 0xffff; - hy = rawBits[0] >> 16; + hx = raw & 0xffff; + hy = raw >> 16; result[0] = result[2] = _mesa_half_to_float(hx); result[1] = result[3] = _mesa_half_to_float(hy); store_vector4(inst, machine, result); @@ -1646,12 +1667,11 @@ _mesa_execute_program(GLcontext * ctx, break; case OPCODE_UP2US: /* unpack two GLushorts */ { - GLfloat a[4], result[4]; - const GLuint *rawBits = (const GLuint *) a; + const GLuint raw = fetch_vector1ui(&inst->SrcReg[0], machine); + GLfloat result[4]; GLushort usx, usy; - fetch_vector1(&inst->SrcReg[0], machine, a); - usx = rawBits[0] & 0xffff; - usy = rawBits[0] >> 16; + usx = raw & 0xffff; + usy = raw >> 16; result[0] = result[2] = usx * (1.0f / 65535.0f); result[1] = result[3] = usy * (1.0f / 65535.0f); store_vector4(inst, machine, result); @@ -1659,25 +1679,23 @@ _mesa_execute_program(GLcontext * ctx, break; case OPCODE_UP4B: /* unpack four GLbytes */ { - GLfloat a[4], result[4]; - const GLuint *rawBits = (const GLuint *) a; - fetch_vector1(&inst->SrcReg[0], machine, a); - result[0] = (((rawBits[0] >> 0) & 0xff) - 128) / 127.0F; - result[1] = (((rawBits[0] >> 8) & 0xff) - 128) / 127.0F; - result[2] = (((rawBits[0] >> 16) & 0xff) - 128) / 127.0F; - result[3] = (((rawBits[0] >> 24) & 0xff) - 128) / 127.0F; + const GLuint raw = fetch_vector1ui(&inst->SrcReg[0], machine); + GLfloat result[4]; + result[0] = (((raw >> 0) & 0xff) - 128) / 127.0F; + result[1] = (((raw >> 8) & 0xff) - 128) / 127.0F; + result[2] = (((raw >> 16) & 0xff) - 128) / 127.0F; + result[3] = (((raw >> 24) & 0xff) - 128) / 127.0F; store_vector4(inst, machine, result); } break; case OPCODE_UP4UB: /* unpack four GLubytes */ { - GLfloat a[4], result[4]; - const GLuint *rawBits = (const GLuint *) a; - fetch_vector1(&inst->SrcReg[0], machine, a); - result[0] = ((rawBits[0] >> 0) & 0xff) / 255.0F; - result[1] = ((rawBits[0] >> 8) & 0xff) / 255.0F; - result[2] = ((rawBits[0] >> 16) & 0xff) / 255.0F; - result[3] = ((rawBits[0] >> 24) & 0xff) / 255.0F; + const GLuint raw = fetch_vector1ui(&inst->SrcReg[0], machine); + GLfloat result[4]; + result[0] = ((raw >> 0) & 0xff) / 255.0F; + result[1] = ((raw >> 8) & 0xff) / 255.0F; + result[2] = ((raw >> 16) & 0xff) / 255.0F; + result[3] = ((raw >> 24) & 0xff) / 255.0F; store_vector4(inst, machine, result); } break; -- cgit v1.2.3 From 099e8ec54d4f7b9cd9ae3a481d6a6ae60f4590be Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 Jan 2010 15:41:08 -0700 Subject: mesa: re-implement _mesa_ProgramEnvParameter4fvARB() with memcpy() This is faster and ensures that NaN floats get stored properly. Before, NaN values (which might be used with UP2H, UP2US, UP4B and UP4UB) weren't getting stored properly with gcc -O3. This is the second part of the fix for the piglit fp-unpack-01 failure (bug 25973). --- src/mesa/shader/arbprogram.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/mesa/shader/arbprogram.c b/src/mesa/shader/arbprogram.c index eb537cd1b9..3cb2610950 100644 --- a/src/mesa/shader/arbprogram.c +++ b/src/mesa/shader/arbprogram.c @@ -561,6 +561,8 @@ _mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index, } } + + /** * Set a program env parameter register. * \note Called from the GL API dispatcher. @@ -569,10 +571,35 @@ _mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index, */ void GLAPIENTRY _mesa_ProgramEnvParameter4fvARB(GLenum target, GLuint index, - const GLfloat *params) + const GLfloat *params) { - _mesa_ProgramEnvParameter4fARB(target, index, params[0], params[1], - params[2], params[3]); + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); + + if (target == GL_FRAGMENT_PROGRAM_ARB + && ctx->Extensions.ARB_fragment_program) { + if (index >= ctx->Const.FragmentProgram.MaxEnvParams) { + _mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameter4fv(index)"); + return; + } + memcpy(ctx->FragmentProgram.Parameters[index], params, + 4 * sizeof(GLfloat)); + } + else if (target == GL_VERTEX_PROGRAM_ARB /* == GL_VERTEX_PROGRAM_NV */ + && (ctx->Extensions.ARB_vertex_program || ctx->Extensions.NV_vertex_program)) { + if (index >= ctx->Const.VertexProgram.MaxEnvParams) { + _mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameter4fv(index)"); + return; + } + memcpy(ctx->VertexProgram.Parameters[index], params, + 4 * sizeof(GLfloat)); + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glProgramEnvParameter4fv(target)"); + return; + } } -- cgit v1.2.3 From ffe4e2a6677beecf1e724f4a64100b24e0b05970 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 Jan 2010 16:18:56 -0700 Subject: mesa: use switch in _mesa_DeletePrograms() --- src/mesa/shader/arbprogram.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/mesa/shader/arbprogram.c b/src/mesa/shader/arbprogram.c index 3cb2610950..b1915f096e 100644 --- a/src/mesa/shader/arbprogram.c +++ b/src/mesa/shader/arbprogram.c @@ -180,23 +180,24 @@ _mesa_DeletePrograms(GLsizei n, const GLuint *ids) } else if (prog) { /* Unbind program if necessary */ - if (prog->Target == GL_VERTEX_PROGRAM_ARB || /* == GL_VERTEX_PROGRAM_NV */ - prog->Target == GL_VERTEX_STATE_PROGRAM_NV) { + switch (prog->Target) { + case GL_VERTEX_PROGRAM_ARB: /* == GL_VERTEX_PROGRAM_NV */ + case GL_VERTEX_STATE_PROGRAM_NV: if (ctx->VertexProgram.Current && ctx->VertexProgram.Current->Base.Id == ids[i]) { /* unbind this currently bound program */ _mesa_BindProgram(prog->Target, 0); } - } - else if (prog->Target == GL_FRAGMENT_PROGRAM_NV || - prog->Target == GL_FRAGMENT_PROGRAM_ARB) { + break; + case GL_FRAGMENT_PROGRAM_NV: + case GL_FRAGMENT_PROGRAM_ARB: if (ctx->FragmentProgram.Current && ctx->FragmentProgram.Current->Base.Id == ids[i]) { /* unbind this currently bound program */ _mesa_BindProgram(prog->Target, 0); } - } - else { + break; + default: _mesa_problem(ctx, "bad target in glDeleteProgramsNV"); return; } -- cgit v1.2.3 From b23b13b69061d419b6f4e006dc5ca836a6b1e2be Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 Jan 2010 16:23:50 -0700 Subject: mesa: use memcpy() in _mesa_ProgramEnv/LocalParameters4fvEXT() --- src/mesa/shader/arbprogram.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/mesa/shader/arbprogram.c b/src/mesa/shader/arbprogram.c index b1915f096e..746138071e 100644 --- a/src/mesa/shader/arbprogram.c +++ b/src/mesa/shader/arbprogram.c @@ -609,7 +609,6 @@ _mesa_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count, const GLfloat *params) { GET_CURRENT_CONTEXT(ctx); - GLint i; GLfloat * dest; ASSERT_OUTSIDE_BEGIN_END(ctx); @@ -640,11 +639,7 @@ _mesa_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count, return; } - for ( i = 0 ; i < count ; i++ ) { - COPY_4V(dest, params); - params += 4; - dest += 4; - } + memcpy(dest, params, count * 4 * sizeof(GLfloat)); } @@ -757,8 +752,7 @@ _mesa_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count, const GLfloat *params) { GET_CURRENT_CONTEXT(ctx); - struct gl_program *prog; - GLint i; + GLfloat *dest; ASSERT_OUTSIDE_BEGIN_END(ctx); FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS); @@ -773,7 +767,7 @@ _mesa_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count, _mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameters4fvEXT(index + count)"); return; } - prog = &(ctx->FragmentProgram.Current->Base); + dest = ctx->FragmentProgram.Current->Base.LocalParams[index]; } else if (target == GL_VERTEX_PROGRAM_ARB && ctx->Extensions.ARB_vertex_program) { @@ -781,18 +775,14 @@ _mesa_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count, _mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameters4fvEXT(index + count)"); return; } - prog = &(ctx->VertexProgram.Current->Base); + dest = ctx->VertexProgram.Current->Base.LocalParams[index]; } else { _mesa_error(ctx, GL_INVALID_ENUM, "glProgramLocalParameters4fvEXT(target)"); return; } - for (i = 0; i < count; i++) { - ASSERT((index + i) < MAX_PROGRAM_LOCAL_PARAMS); - COPY_4V(prog->LocalParams[index + i], params); - params += 4; - } + memcpy(dest, params, count * 4 * sizeof(GLfloat)); } -- cgit v1.2.3 From 5e78903952961fc207b8da1f7b2d0c6ddfd49881 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 Jan 2010 17:17:01 -0700 Subject: gallium/util: fix incorrect shift in a4r4g4b4_put_tile_rgba() Fixes fd.o bug 23313. --- src/gallium/auxiliary/util/u_tile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c index 8a22f584be..7b0680b5d0 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -341,7 +341,7 @@ a4r4g4b4_put_tile_rgba(ushort *dst, g >>= 4; b >>= 4; a >>= 4; - *dst++ = (a << 12) | (r << 16) | (g << 4) | b; + *dst++ = (a << 12) | (r << 8) | (g << 4) | b; } p += src_stride; } -- cgit v1.2.3 From dd618a006aae870643049d191223c0dbc7ebc106 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 Jan 2010 17:20:37 -0700 Subject: gallium/util: add missing util/u_bitmask.c to Makefile --- src/gallium/auxiliary/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile index 9b6babce33..da1fb6b299 100644 --- a/src/gallium/auxiliary/Makefile +++ b/src/gallium/auxiliary/Makefile @@ -90,6 +90,7 @@ C_SOURCES = \ util/u_debug_dump.c \ util/u_debug_symbol.c \ util/u_debug_stack.c \ + util/u_bitmask.c \ util/u_blit.c \ util/u_blitter.c \ util/u_cache.c \ -- cgit v1.2.3 From 46c7cd665c9bc93e7254771b16b010fb10ce3707 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 Jan 2010 17:56:35 -0700 Subject: st/mesa: fix incorrect freeing of drawpixels vertex shaders These shaders are not st_vertex_shaders, but tgsi ureg shaders. Fixes fd.o bug 25959. --- src/mesa/state_tracker/st_cb_drawpixels.c | 6 ++++-- src/mesa/state_tracker/st_context.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 4cec259844..7afdc31ede 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -1132,6 +1132,8 @@ st_destroy_drawpix(struct st_context *st) { st_reference_fragprog(st, &st->drawpix.z_shader, NULL); st_reference_fragprog(st, &st->pixel_xfer.combined_prog, NULL); - st_reference_vertprog(st, &st->drawpix.vert_shaders[0], NULL); - st_reference_vertprog(st, &st->drawpix.vert_shaders[1], NULL); + if (st->drawpix.vert_shaders[0]) + free(st->drawpix.vert_shaders[0]); + if (st->drawpix.vert_shaders[1]) + free(st->drawpix.vert_shaders[1]); } diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 2c4943cfb0..50e98d7146 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -159,7 +159,7 @@ struct st_context /** for glDraw/CopyPixels */ struct { struct st_fragment_program *z_shader; - struct st_vertex_program *vert_shaders[2]; + void *vert_shaders[2]; /**< ureg shaders */ } drawpix; /** for glClear */ -- cgit v1.2.3 From f6a49ac21721353948b03cf3ca3b5aa5c87e59e6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 Jan 2010 18:35:36 -0700 Subject: svga: fix up breakage from earlier 7.7 merge --- src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c index 8be9d74bde..d9abde3079 100644 --- a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c +++ b/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c @@ -325,8 +325,8 @@ vmw_drm_handle_from_texture(struct drm_api *drm_api, vsrf = vmw_svga_winsys_surface(surface); *handle = vsrf->sid; - *stride = pf_get_nblocksx(&texture->block, texture->width[0]) * - texture->block.size; + *stride = util_format_get_nblocksx(texture->format, texture->width0) * + util_format_get_blocksize(texture->format); vmw_svga_winsys_surface_reference(&vsrf, NULL); return TRUE; -- cgit v1.2.3 From 2292c93bc0f703d1ebdc2b79b5f525efebe21f1c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 Jan 2010 18:47:23 -0700 Subject: glapi: define GLfixed, GLclampx types for ES 1 I'm not 100% sure this is the best fix, but it seems OK. --- src/mesa/glapi/glapi_nop.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/mesa/glapi/glapi_nop.c b/src/mesa/glapi/glapi_nop.c index e45faef72d..0c53bd8a3f 100644 --- a/src/mesa/glapi/glapi_nop.c +++ b/src/mesa/glapi/glapi_nop.c @@ -87,4 +87,11 @@ NoOpUnused(void) #define UNUSED_TABLE_NAME __unused_noop_functions +/* + * Types needed when generating ES 1 functions. + */ +typedef int GLfixed; +typedef int GLclampx; + + #include "glapi/glapitemp.h" -- cgit v1.2.3 From fe33b7083b0081b91ee338acbe966400c6b9a7b9 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 23 Jan 2010 00:11:48 +0800 Subject: add segl --- progs/egl/segl/Makefile | 21 ++++++ progs/egl/segl/segl.c | 167 ++++++++++++++++++++++++++++++++++++++++++++++ progs/egl/segl/segl.h | 60 +++++++++++++++++ progs/egl/segl/segl_kms.c | 59 ++++++++++++++++ progs/egl/segl/segl_x11.c | 117 ++++++++++++++++++++++++++++++++ 5 files changed, 424 insertions(+) create mode 100644 progs/egl/segl/Makefile create mode 100644 progs/egl/segl/segl.c create mode 100644 progs/egl/segl/segl.h create mode 100644 progs/egl/segl/segl_kms.c create mode 100644 progs/egl/segl/segl_x11.c diff --git a/progs/egl/segl/Makefile b/progs/egl/segl/Makefile new file mode 100644 index 0000000000..c5f13f69c1 --- /dev/null +++ b/progs/egl/segl/Makefile @@ -0,0 +1,21 @@ +# progs/egl/segl/Makefile + +TOP = ../../.. +include $(TOP)/configs/current + +SEGL_LIBS := $(foreach dpy, $(EGL_DISPLAYS), libsegl-$(dpy).a) + +all: $(SEGL_LIBS) + +x11_OBJECTS := segl.o segl_x11.o +kms_OBJECTS := segl.o segl_kms.o + +libsegl-x11.a: $(x11_OBJECTS) + $(MKLIB) -o segl-x11 -static $(x11_OBJECTS) + +libsegl-kms.a: $(kms_OBJECTS) + $(MKLIB) -o segl-kms -static $(kms_OBJECTS) + +clean: + rm -f $(sort $(x11_OBJECTS) $(kms_OBJECTS)) + rm -f $(SEGL_LIBS) diff --git a/progs/egl/segl/segl.c b/progs/egl/segl/segl.c new file mode 100644 index 0000000000..b1df71a5b5 --- /dev/null +++ b/progs/egl/segl/segl.c @@ -0,0 +1,167 @@ +#include +#include +#include +#include +#include + +#include "segl.h" + +static void +segl_log(struct segl *segl, const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + + if (segl->winsys->vlog) + segl->winsys->vlog(segl->winsys, format, ap); + else + vfprintf(stdout, format, ap); + + va_end(ap); +} + +static EGLBoolean +segl_init_egl(struct segl *segl, const EGLint *attribs) +{ + EGLint num_conf; + + segl->dpy = eglGetDisplay(segl->winsys->dpy); + if (!segl->dpy) + return EGL_FALSE; + + if (!eglInitialize(segl->dpy, &segl->major, &segl->minor)) + return EGL_FALSE; + + if (segl->verbose) { + const char *ver = eglQueryString(segl->dpy, EGL_VERSION); + segl_log(segl, "EGL_VERSION = %s\n", ver); + } + + if (!eglChooseConfig(segl->dpy, attribs, &segl->conf, 1, &num_conf) || + !num_conf) { + segl_log(segl, "failed to choose a config\n"); + eglTerminate(segl->dpy); + return EGL_FALSE; + } + + return EGL_TRUE; +} + +struct segl * +segl_new(struct segl_winsys *winsys, const EGLint *attribs) +{ + struct segl *segl; + + segl = calloc(1, sizeof(*segl)); + if (segl) { + segl->verbose = EGL_TRUE; + segl->winsys = winsys; + + if (!segl_init_egl(segl, attribs)) { + free(segl); + return NULL; + } + } + + return segl; +} + +void +segl_destroy(struct segl *segl) +{ + free(segl); +} + +EGLBoolean +segl_create_window(struct segl *segl, const char *name, + EGLint width, EGLint height, const EGLint *attribs, + EGLNativeWindowType *win_ret, EGLSurface *surf_ret) +{ + EGLNativeWindowType win; + EGLSurface surf; + EGLint visual; + + if (!win_ret) { + if (surf_ret) + *surf_ret = EGL_NO_SURFACE; + return EGL_TRUE; + } + + if (!eglGetConfigAttrib(segl->dpy, segl->conf, EGL_NATIVE_VISUAL_ID, &visual)) + return EGL_FALSE; + + win = segl->winsys->create_window(segl->winsys, + name, width, height, visual); + if (surf_ret) { + surf = eglCreateWindowSurface(segl->dpy, segl->conf, win, attribs); + if (!surf) { + segl_log(segl, "failed to create a window surface\n"); + segl->winsys->destroy_window(segl->winsys, win); + return EGL_FALSE; + } + + *surf_ret = surf; + } + + *win_ret = win; + + return EGL_TRUE; +} + +EGLBoolean +segl_create_pixmap(struct segl *segl, + EGLint width, EGLint height, const EGLint *attribs, + EGLNativePixmapType *pix_ret, EGLSurface *surf_ret) +{ + EGLNativePixmapType pix; + EGLSurface surf; + EGLint depth; + + if (!pix_ret) { + if (surf_ret) + *surf_ret = EGL_NO_SURFACE; + return EGL_TRUE; + } + + if (!eglGetConfigAttrib(segl->dpy, segl->conf, EGL_BUFFER_SIZE, &depth)) + return EGL_FALSE; + + pix = segl->winsys->create_pixmap(segl->winsys, width, height, depth); + if (surf_ret) { + surf = eglCreatePixmapSurface(segl->dpy, segl->conf, pix, attribs); + if (!surf) { + segl_log(segl, "failed to create a pixmap surface\n"); + segl->winsys->destroy_pixmap(segl->winsys, pix); + return EGL_FALSE; + } + + *surf_ret = surf; + } + + *pix_ret = pix; + + return EGL_TRUE; +} + +void +segl_benchmark(struct segl *segl, double seconds, + void (*draw_frame)(void *), void *draw_data) +{ + double begin, end, last_frame, duration; + EGLint num_frames = 0; + + begin = segl->winsys->now(segl->winsys); + end = begin + seconds; + + last_frame = begin; + while (last_frame < end) { + draw_frame(draw_data); + last_frame = segl->winsys->now(segl->winsys); + num_frames++; + } + + duration = last_frame - begin; + segl_log(segl, "%d frames in %3.1f seconds = %6.3f FPS\n", + num_frames, duration, (double) num_frames / duration); +} diff --git a/progs/egl/segl/segl.h b/progs/egl/segl/segl.h new file mode 100644 index 0000000000..20faf6ef02 --- /dev/null +++ b/progs/egl/segl/segl.h @@ -0,0 +1,60 @@ +#ifndef _SEGL_H_ +#define _SEGL_H_ + +#include +#include + +struct segl_winsys { + EGLNativeDisplayType dpy; + + EGLNativeWindowType (*create_window)(struct segl_winsys *winsys, + const char *name, + EGLint width, EGLint height, + EGLint visual); + void (*destroy_window)(struct segl_winsys *winsys, EGLNativeWindowType win); + + EGLNativePixmapType (*create_pixmap)(struct segl_winsys *winsys, + EGLint width, EGLint height, + EGLint depth); + void (*destroy_pixmap)(struct segl_winsys *winsys, EGLNativePixmapType pix); + + /* get current time in seconds */ + double (*now)(struct segl_winsys *winsys); + /* log a message. OPTIONAL */ + void (*vlog)(struct segl_winsys *winsys, const char *format, va_list ap); +}; + +struct segl { + EGLBoolean verbose; + + struct segl_winsys *winsys; + + EGLint major, minor; + EGLDisplay dpy; + EGLConfig conf; +}; + +struct segl_winsys * +segl_get_winsys(EGLNativeDisplayType dpy); + +struct segl * +segl_new(struct segl_winsys *winsys, const EGLint *attribs); + +void +segl_destroy(struct segl *segl); + +EGLBoolean +segl_create_window(struct segl *segl, const char *name, + EGLint width, EGLint height, const EGLint *attribs, + EGLNativeWindowType *win_ret, EGLSurface *surf_ret); + +EGLBoolean +segl_create_pixmap(struct segl *segl, + EGLint width, EGLint height, const EGLint *attribs, + EGLNativePixmapType *pix_ret, EGLSurface *surf_ret); + +void +segl_benchmark(struct segl *segl, double seconds, + void (*draw_frame)(void *), void *draw_data); + +#endif /* _SEGL_H_ */ diff --git a/progs/egl/segl/segl_kms.c b/progs/egl/segl/segl_kms.c new file mode 100644 index 0000000000..bb4fcfca65 --- /dev/null +++ b/progs/egl/segl/segl_kms.c @@ -0,0 +1,59 @@ +#include +#include + +#include "segl.h" + +static EGLNativeWindowType +kms_create_window(struct segl_winsys *winsys, const char *name, + EGLint width, EGLint height, EGLint visual) +{ + return 0; +} + +static void +kms_destroy_window(struct segl_winsys *winsys, EGLNativeWindowType win) +{ +} + + +static EGLNativePixmapType +kms_create_pixmap(struct segl_winsys *winsys, EGLint width, EGLint height, + EGLint depth) +{ + return 0; +} + +static void +kms_destroy_pixmap(struct segl_winsys *winsys, EGLNativePixmapType pix) +{ +} + +static double +kms_now(struct segl_winsys *winsys) +{ + struct timeval tv; + + gettimeofday(&tv, NULL); + + return (double) tv.tv_sec + tv.tv_usec / 1000000.0; +} + +struct segl_winsys * +segl_get_winsys(EGLNativeDisplayType dpy) +{ + struct segl_winsys *winsys; + + winsys = calloc(1, sizeof(*winsys)); + if (winsys) { + winsys->dpy = dpy; + + winsys->create_window = kms_create_window; + winsys->destroy_window = kms_destroy_window; + winsys->create_pixmap = kms_create_pixmap; + winsys->destroy_pixmap = kms_destroy_pixmap; + + winsys->now = kms_now; + } + + return winsys; +} diff --git a/progs/egl/segl/segl_x11.c b/progs/egl/segl/segl_x11.c new file mode 100644 index 0000000000..7b26917460 --- /dev/null +++ b/progs/egl/segl/segl_x11.c @@ -0,0 +1,117 @@ +#include +#include +#include +#include + +#include "segl.h" + +static Window +x11_create_window(struct segl_winsys *winsys, const char *name, + EGLint width, EGLint height, EGLint visual) +{ + XVisualInfo vinfo_template, *vinfo = NULL; + EGLint val, num_vinfo; + Window root, win; + XSetWindowAttributes attrs; + unsigned long mask; + EGLint x = 0, y = 0; + + vinfo_template.visualid = (VisualID) val; + vinfo = XGetVisualInfo(winsys->dpy, VisualIDMask, &vinfo_template, &num_vinfo); + if (!num_vinfo) { + if (vinfo) + XFree(vinfo); + return None; + } + + root = DefaultRootWindow(winsys->dpy); + + /* window attributes */ + attrs.background_pixel = 0; + attrs.border_pixel = 0; + attrs.colormap = XCreateColormap(winsys->dpy, root, vinfo->visual, AllocNone); + attrs.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; + attrs.override_redirect = False; + mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect; + + win = XCreateWindow(winsys->dpy, root, x, y, width, height, 0, + vinfo->depth, InputOutput, vinfo->visual, mask, &attrs); + XFree(vinfo); + + if (!win) + return None; + + /* set hints and properties */ + { + XSizeHints sizehints; + sizehints.x = x; + sizehints.y = y; + sizehints.width = width; + sizehints.height = height; + sizehints.flags = USSize | USPosition; + XSetNormalHints(winsys->dpy, win, &sizehints); + XSetStandardProperties(winsys->dpy, win, name, name, + None, (char **)NULL, 0, &sizehints); + } + + XMapWindow(winsys->dpy, win); + + return win; +} + +static void +x11_destroy_window(struct segl_winsys *winsys, Window win) +{ + if (win) + XDestroyWindow(winsys->dpy, win); +} + + +static Pixmap +x11_create_pixmap(struct segl_winsys *winsys, EGLint width, EGLint height, + EGLint depth) +{ + Window root = DefaultRootWindow(winsys->dpy); + Pixmap pix; + + pix = XCreatePixmap(winsys->dpy, (Drawable) root, width, height, depth); + + return pix; +} + +static void +x11_destroy_pixmap(struct segl_winsys *winsys, Pixmap pix) +{ + if (pix) + XFreePixmap(winsys->dpy, pix); +} + +static double +x11_now(struct segl_winsys *winsys) +{ + struct timeval tv; + + gettimeofday(&tv, NULL); + + return (double) tv.tv_sec + tv.tv_usec / 1000000.0; +} + +struct segl_winsys * +segl_get_winsys(EGLNativeDisplayType dpy) +{ + struct segl_winsys *winsys; + + winsys = calloc(1, sizeof(*winsys)); + if (winsys) { + winsys->dpy = dpy; + + winsys->create_window = x11_create_window; + winsys->destroy_window = x11_destroy_window; + winsys->create_pixmap = x11_create_pixmap; + winsys->destroy_pixmap = x11_destroy_pixmap; + + winsys->now = x11_now; + } + + return winsys; +} -- cgit v1.2.3 From 4b770d1a11c289914bf54f4b3365f21615661c29 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 23 Jan 2010 10:23:37 +0800 Subject: glapi: Include glheader.h in glapi_nop.c. In addition to OpenGL headers, glheader.h also defines OpenGL ES types that are used in core Mesa or ES overlay. --- src/mesa/glapi/glapi_nop.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/mesa/glapi/glapi_nop.c b/src/mesa/glapi/glapi_nop.c index 0c53bd8a3f..5d2769c073 100644 --- a/src/mesa/glapi/glapi_nop.c +++ b/src/mesa/glapi/glapi_nop.c @@ -39,6 +39,7 @@ #include "main/compiler.h" +#include "main/glheader.h" #include "glapi/glapi.h" @@ -87,11 +88,4 @@ NoOpUnused(void) #define UNUSED_TABLE_NAME __unused_noop_functions -/* - * Types needed when generating ES 1 functions. - */ -typedef int GLfixed; -typedef int GLclampx; - - #include "glapi/glapitemp.h" -- cgit v1.2.3 From dcaf6687e8b27f2f988da757665ca922071db47f Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 18 Jan 2010 16:25:30 +1000 Subject: progs: add trivial ARB_half_float_vertex support. This is just a trivial port of vp-array.c Signed-off-by: Dave Airlie --- progs/trivial/Makefile | 1 + progs/trivial/vp-array-hf.c | 215 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 216 insertions(+) create mode 100644 progs/trivial/vp-array-hf.c diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index 5e08d60389..207215dee9 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -160,6 +160,7 @@ SOURCES = \ vbo-drawelements.c \ vbo-drawrange.c \ vp-array.c \ + vp-array-hf.c \ vp-array-int.c \ vp-clip.c \ vp-line-clip.c \ diff --git a/progs/trivial/vp-array-hf.c b/progs/trivial/vp-array-hf.c new file mode 100644 index 0000000000..f812436437 --- /dev/null +++ b/progs/trivial/vp-array-hf.c @@ -0,0 +1,215 @@ +/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */ + +#include +#include +#include +#include +#include +#include +#include + +typedef union { GLfloat f; GLint i; } fi_type; +/** + * Convert a 4-byte float to a 2-byte half float. + * Based on code from: + * http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/008786.html + */ +static GLhalf +_mesa_float_to_half(GLfloat val) +{ + + const fi_type fi = {val}; + const int flt_m = fi.i & 0x7fffff; + const int flt_e = (fi.i >> 23) & 0xff; + const int flt_s = (fi.i >> 31) & 0x1; + int s, e, m = 0; + GLhalf result; + + /* sign bit */ + s = flt_s; + + /* handle special cases */ + if ((flt_e == 0) && (flt_m == 0)) { + /* zero */ + /* m = 0; - already set */ + e = 0; + } + else if ((flt_e == 0) && (flt_m != 0)) { + /* denorm -- denorm float maps to 0 half */ + /* m = 0; - already set */ + e = 0; + } + else if ((flt_e == 0xff) && (flt_m == 0)) { + /* infinity */ + /* m = 0; - already set */ + e = 31; + } + else if ((flt_e == 0xff) && (flt_m != 0)) { + /* NaN */ + m = 1; + e = 31; + } + else { + /* regular number */ + const int new_exp = flt_e - 127; + if (new_exp < -24) { + /* this maps to 0 */ + /* m = 0; - already set */ + e = 0; + } + else if (new_exp < -14) { + /* this maps to a denorm */ + unsigned int exp_val = (unsigned int) (-14 - new_exp); /* 2^-exp_val*/ + e = 0; + switch (exp_val) { + case 0: + /* m = 0; - already set */ + break; + case 1: m = 512 + (flt_m >> 14); break; + case 2: m = 256 + (flt_m >> 15); break; + case 3: m = 128 + (flt_m >> 16); break; + case 4: m = 64 + (flt_m >> 17); break; + case 5: m = 32 + (flt_m >> 18); break; + case 6: m = 16 + (flt_m >> 19); break; + case 7: m = 8 + (flt_m >> 20); break; + case 8: m = 4 + (flt_m >> 21); break; + case 9: m = 2 + (flt_m >> 22); break; + case 10: m = 1; break; + } + } + else if (new_exp > 15) { + /* map this value to infinity */ + /* m = 0; - already set */ + e = 31; + } + else { + /* regular */ + e = new_exp + 15; + m = flt_m >> 13; + } + } + + result = (s << 15) | (e << 10) | m; + return result; +} + + +GLfloat verts[][4] = { + { 0.9, -0.9, 0.0, 1.0 }, + { 0.9, 0.9, 0.0, 1.0 }, + { -0.9, 0.9, 0.0, 1.0 }, + { -0.9, -0.9, 0.0, 1.0 }, +}; + +GLhalf hverts[16]; + +GLubyte color[][4] = { + { 0x00, 0x00, 0xff, 0x00 }, + { 0x00, 0xff, 0x00, 0x00 }, + { 0xff, 0x00, 0x00, 0x00 }, + { 0xff, 0xff, 0xff, 0x00 }, +}; + +GLuint indices[] = { 0, 1, 2, 3 }; + +static void Init( void ) +{ + GLint errno; + GLuint prognum; + GLuint i, j; + + static const char *prog1 = + "!!ARBvp1.0\n" + "MOV result.color, vertex.color;\n" + "MOV result.position, vertex.position;\n" + "END\n"; + + if (!glutExtensionSupported("GL_ARB_half_float_vertex")) { + printf("GL_ARB_half_float_vertex not found!\n"); + exit(0); + } + + glGenProgramsARB(1, &prognum); + glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum); + glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(prog1), (const GLubyte *) prog1); + + assert(glIsProgramARB(prognum)); + errno = glGetError(); + printf("glGetError = %d\n", errno); + if (errno != GL_NO_ERROR) + { + GLint errorpos; + + glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos); + printf("errorpos: %d\n", errorpos); + printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + } + + for (i = 0; i < 4; i++) + for (j = 0; j < 4; j++) + hverts[i * 4 + j] = _mesa_float_to_half(verts[i][j]); + + glEnableClientState( GL_VERTEX_ARRAY ); + glEnableClientState( GL_COLOR_ARRAY ); + glVertexPointer( 4, GL_HALF_FLOAT, 8, hverts ); + glColorPointer( 4, GL_UNSIGNED_BYTE, 0, color ); + +} + + + +static void Display( void ) +{ + glClearColor(0.3, 0.3, 0.3, 1); + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glEnable(GL_VERTEX_PROGRAM_NV); + glDrawElements( GL_TRIANGLES, 3, GL_UNSIGNED_INT, indices ); + + glFlush(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + /*glTranslatef( 0.0, 0.0, -15.0 );*/ +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 250, 250 ); + glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH ); + glutCreateWindow(argv[0]); + glewInit(); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From 1ac5fd594a00d83f9b103ac6261bedabdb7e6b32 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 18 Jan 2010 16:27:27 +1000 Subject: glapi: add GL_HALF_FLOAT enum support. Regenerate enums files and GLX indirect. Signed-off-by: Dave Airlie --- src/glx/x11/indirect_size.c | 1 + src/mesa/glapi/gl_API.xml | 3 + src/mesa/main/enums.c | 4459 ++++++++++++++++++++++--------------------- 3 files changed, 2235 insertions(+), 2228 deletions(-) diff --git a/src/glx/x11/indirect_size.c b/src/glx/x11/indirect_size.c index f8541b5758..6356ddd49b 100644 --- a/src/glx/x11/indirect_size.c +++ b/src/glx/x11/indirect_size.c @@ -73,6 +73,7 @@ __glCallLists_size(GLenum e) case GL_SHORT: case GL_UNSIGNED_SHORT: case GL_2_BYTES: + case GL_HALF_FLOAT: return 2; case GL_3_BYTES: return 3; diff --git a/src/mesa/glapi/gl_API.xml b/src/mesa/glapi/gl_API.xml index 75d2f3c438..fbf8b0c3e4 100644 --- a/src/mesa/glapi/gl_API.xml +++ b/src/mesa/glapi/gl_API.xml @@ -866,6 +866,9 @@ + + + diff --git a/src/mesa/main/enums.c b/src/mesa/main/enums.c index aaf17aafdd..1d495b7ae5 100644 --- a/src/mesa/main/enums.c +++ b/src/mesa/main/enums.c @@ -640,6 +640,7 @@ LONGSTRING static const char enum_string_table[] = "GL_GREEN_BIAS\0" "GL_GREEN_BITS\0" "GL_GREEN_SCALE\0" + "GL_HALF_FLOAT\0" "GL_HINT_BIT\0" "GL_HISTOGRAM\0" "GL_HISTOGRAM_ALPHA_SIZE\0" @@ -1922,7 +1923,7 @@ LONGSTRING static const char enum_string_table[] = "GL_ZOOM_Y\0" ; -static const enum_elt all_enums[1884] = +static const enum_elt all_enums[1885] = { { 0, 0x00000600 }, /* GL_2D */ { 6, 0x00001407 }, /* GL_2_BYTES */ @@ -2528,1365 +2529,1366 @@ static const enum_elt all_enums[1884] = { 12769, 0x00000D19 }, /* GL_GREEN_BIAS */ { 12783, 0x00000D53 }, /* GL_GREEN_BITS */ { 12797, 0x00000D18 }, /* GL_GREEN_SCALE */ - { 12812, 0x00008000 }, /* GL_HINT_BIT */ - { 12824, 0x00008024 }, /* GL_HISTOGRAM */ - { 12837, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE */ - { 12861, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE_EXT */ - { 12889, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE */ - { 12912, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE_EXT */ - { 12939, 0x00008024 }, /* GL_HISTOGRAM_EXT */ - { 12956, 0x00008027 }, /* GL_HISTOGRAM_FORMAT */ - { 12976, 0x00008027 }, /* GL_HISTOGRAM_FORMAT_EXT */ - { 13000, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE */ - { 13024, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE_EXT */ - { 13052, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE */ - { 13080, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE_EXT */ - { 13112, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE */ - { 13134, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE_EXT */ - { 13160, 0x0000802D }, /* GL_HISTOGRAM_SINK */ - { 13178, 0x0000802D }, /* GL_HISTOGRAM_SINK_EXT */ - { 13200, 0x00008026 }, /* GL_HISTOGRAM_WIDTH */ - { 13219, 0x00008026 }, /* GL_HISTOGRAM_WIDTH_EXT */ - { 13242, 0x0000862A }, /* GL_IDENTITY_NV */ - { 13257, 0x00008150 }, /* GL_IGNORE_BORDER_HP */ - { 13277, 0x00008B9B }, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */ - { 13317, 0x00008B9A }, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */ - { 13355, 0x00001E02 }, /* GL_INCR */ - { 13363, 0x00008507 }, /* GL_INCR_WRAP */ - { 13376, 0x00008507 }, /* GL_INCR_WRAP_EXT */ - { 13393, 0x00008222 }, /* GL_INDEX */ - { 13402, 0x00008077 }, /* GL_INDEX_ARRAY */ - { 13417, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING */ - { 13447, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING_ARB */ - { 13481, 0x00008091 }, /* GL_INDEX_ARRAY_POINTER */ - { 13504, 0x00008086 }, /* GL_INDEX_ARRAY_STRIDE */ - { 13526, 0x00008085 }, /* GL_INDEX_ARRAY_TYPE */ - { 13546, 0x00000D51 }, /* GL_INDEX_BITS */ - { 13560, 0x00000C20 }, /* GL_INDEX_CLEAR_VALUE */ - { 13581, 0x00000BF1 }, /* GL_INDEX_LOGIC_OP */ - { 13599, 0x00000C30 }, /* GL_INDEX_MODE */ - { 13613, 0x00000D13 }, /* GL_INDEX_OFFSET */ - { 13629, 0x00000D12 }, /* GL_INDEX_SHIFT */ - { 13644, 0x00000C21 }, /* GL_INDEX_WRITEMASK */ - { 13663, 0x00008B84 }, /* GL_INFO_LOG_LENGTH */ - { 13682, 0x00001404 }, /* GL_INT */ - { 13689, 0x00008049 }, /* GL_INTENSITY */ - { 13702, 0x0000804C }, /* GL_INTENSITY12 */ - { 13717, 0x0000804C }, /* GL_INTENSITY12_EXT */ - { 13736, 0x0000804D }, /* GL_INTENSITY16 */ - { 13751, 0x0000804D }, /* GL_INTENSITY16_EXT */ - { 13770, 0x0000804A }, /* GL_INTENSITY4 */ - { 13784, 0x0000804A }, /* GL_INTENSITY4_EXT */ - { 13802, 0x0000804B }, /* GL_INTENSITY8 */ - { 13816, 0x0000804B }, /* GL_INTENSITY8_EXT */ - { 13834, 0x00008049 }, /* GL_INTENSITY_EXT */ - { 13851, 0x00008575 }, /* GL_INTERPOLATE */ - { 13866, 0x00008575 }, /* GL_INTERPOLATE_ARB */ - { 13885, 0x00008575 }, /* GL_INTERPOLATE_EXT */ - { 13904, 0x00008B53 }, /* GL_INT_VEC2 */ - { 13916, 0x00008B53 }, /* GL_INT_VEC2_ARB */ - { 13932, 0x00008B54 }, /* GL_INT_VEC3 */ - { 13944, 0x00008B54 }, /* GL_INT_VEC3_ARB */ - { 13960, 0x00008B55 }, /* GL_INT_VEC4 */ - { 13972, 0x00008B55 }, /* GL_INT_VEC4_ARB */ - { 13988, 0x00000500 }, /* GL_INVALID_ENUM */ - { 14004, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION */ - { 14037, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION_EXT */ - { 14074, 0x00000502 }, /* GL_INVALID_OPERATION */ - { 14095, 0x00000501 }, /* GL_INVALID_VALUE */ - { 14112, 0x0000862B }, /* GL_INVERSE_NV */ - { 14126, 0x0000862D }, /* GL_INVERSE_TRANSPOSE_NV */ - { 14150, 0x0000150A }, /* GL_INVERT */ - { 14160, 0x00001E00 }, /* GL_KEEP */ - { 14168, 0x00008E4E }, /* GL_LAST_VERTEX_CONVENTION */ - { 14194, 0x00008E4E }, /* GL_LAST_VERTEX_CONVENTION_EXT */ - { 14224, 0x00000406 }, /* GL_LEFT */ - { 14232, 0x00000203 }, /* GL_LEQUAL */ - { 14242, 0x00000201 }, /* GL_LESS */ - { 14250, 0x00004000 }, /* GL_LIGHT0 */ - { 14260, 0x00004001 }, /* GL_LIGHT1 */ - { 14270, 0x00004002 }, /* GL_LIGHT2 */ - { 14280, 0x00004003 }, /* GL_LIGHT3 */ - { 14290, 0x00004004 }, /* GL_LIGHT4 */ - { 14300, 0x00004005 }, /* GL_LIGHT5 */ - { 14310, 0x00004006 }, /* GL_LIGHT6 */ - { 14320, 0x00004007 }, /* GL_LIGHT7 */ - { 14330, 0x00000B50 }, /* GL_LIGHTING */ - { 14342, 0x00000040 }, /* GL_LIGHTING_BIT */ - { 14358, 0x00000B53 }, /* GL_LIGHT_MODEL_AMBIENT */ - { 14381, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL */ - { 14410, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL_EXT */ - { 14443, 0x00000B51 }, /* GL_LIGHT_MODEL_LOCAL_VIEWER */ - { 14471, 0x00000B52 }, /* GL_LIGHT_MODEL_TWO_SIDE */ - { 14495, 0x00001B01 }, /* GL_LINE */ - { 14503, 0x00002601 }, /* GL_LINEAR */ - { 14513, 0x00001208 }, /* GL_LINEAR_ATTENUATION */ - { 14535, 0x00008170 }, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */ - { 14565, 0x0000844F }, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */ - { 14596, 0x00002703 }, /* GL_LINEAR_MIPMAP_LINEAR */ - { 14620, 0x00002701 }, /* GL_LINEAR_MIPMAP_NEAREST */ - { 14645, 0x00000001 }, /* GL_LINES */ - { 14654, 0x00000004 }, /* GL_LINE_BIT */ - { 14666, 0x00000002 }, /* GL_LINE_LOOP */ - { 14679, 0x00000707 }, /* GL_LINE_RESET_TOKEN */ - { 14699, 0x00000B20 }, /* GL_LINE_SMOOTH */ - { 14714, 0x00000C52 }, /* GL_LINE_SMOOTH_HINT */ - { 14734, 0x00000B24 }, /* GL_LINE_STIPPLE */ - { 14750, 0x00000B25 }, /* GL_LINE_STIPPLE_PATTERN */ - { 14774, 0x00000B26 }, /* GL_LINE_STIPPLE_REPEAT */ - { 14797, 0x00000003 }, /* GL_LINE_STRIP */ - { 14811, 0x00000702 }, /* GL_LINE_TOKEN */ - { 14825, 0x00000B21 }, /* GL_LINE_WIDTH */ - { 14839, 0x00000B23 }, /* GL_LINE_WIDTH_GRANULARITY */ - { 14865, 0x00000B22 }, /* GL_LINE_WIDTH_RANGE */ - { 14885, 0x00008B82 }, /* GL_LINK_STATUS */ - { 14900, 0x00000B32 }, /* GL_LIST_BASE */ - { 14913, 0x00020000 }, /* GL_LIST_BIT */ - { 14925, 0x00000B33 }, /* GL_LIST_INDEX */ - { 14939, 0x00000B30 }, /* GL_LIST_MODE */ - { 14952, 0x00000101 }, /* GL_LOAD */ - { 14960, 0x00000BF1 }, /* GL_LOGIC_OP */ - { 14972, 0x00000BF0 }, /* GL_LOGIC_OP_MODE */ - { 14989, 0x00008CA1 }, /* GL_LOWER_LEFT */ - { 15003, 0x00001909 }, /* GL_LUMINANCE */ - { 15016, 0x00008041 }, /* GL_LUMINANCE12 */ - { 15031, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12 */ - { 15054, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12_EXT */ - { 15081, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4 */ - { 15103, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4_EXT */ - { 15129, 0x00008041 }, /* GL_LUMINANCE12_EXT */ - { 15148, 0x00008042 }, /* GL_LUMINANCE16 */ - { 15163, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16 */ - { 15186, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16_EXT */ - { 15213, 0x00008042 }, /* GL_LUMINANCE16_EXT */ - { 15232, 0x0000803F }, /* GL_LUMINANCE4 */ - { 15246, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4 */ - { 15267, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4_EXT */ - { 15292, 0x0000803F }, /* GL_LUMINANCE4_EXT */ - { 15310, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2 */ - { 15331, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2_EXT */ - { 15356, 0x00008040 }, /* GL_LUMINANCE8 */ - { 15370, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8 */ - { 15391, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8_EXT */ - { 15416, 0x00008040 }, /* GL_LUMINANCE8_EXT */ - { 15434, 0x0000190A }, /* GL_LUMINANCE_ALPHA */ - { 15453, 0x00000D90 }, /* GL_MAP1_COLOR_4 */ - { 15469, 0x00000DD0 }, /* GL_MAP1_GRID_DOMAIN */ - { 15489, 0x00000DD1 }, /* GL_MAP1_GRID_SEGMENTS */ - { 15511, 0x00000D91 }, /* GL_MAP1_INDEX */ - { 15525, 0x00000D92 }, /* GL_MAP1_NORMAL */ - { 15540, 0x00000D93 }, /* GL_MAP1_TEXTURE_COORD_1 */ - { 15564, 0x00000D94 }, /* GL_MAP1_TEXTURE_COORD_2 */ - { 15588, 0x00000D95 }, /* GL_MAP1_TEXTURE_COORD_3 */ - { 15612, 0x00000D96 }, /* GL_MAP1_TEXTURE_COORD_4 */ - { 15636, 0x00000D97 }, /* GL_MAP1_VERTEX_3 */ - { 15653, 0x00000D98 }, /* GL_MAP1_VERTEX_4 */ - { 15670, 0x00008660 }, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */ - { 15698, 0x0000866A }, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */ - { 15727, 0x0000866B }, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */ - { 15756, 0x0000866C }, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */ - { 15785, 0x0000866D }, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */ - { 15814, 0x0000866E }, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */ - { 15843, 0x0000866F }, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */ - { 15872, 0x00008661 }, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */ - { 15900, 0x00008662 }, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */ - { 15928, 0x00008663 }, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */ - { 15956, 0x00008664 }, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */ - { 15984, 0x00008665 }, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */ - { 16012, 0x00008666 }, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */ - { 16040, 0x00008667 }, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */ - { 16068, 0x00008668 }, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */ - { 16096, 0x00008669 }, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */ - { 16124, 0x00000DB0 }, /* GL_MAP2_COLOR_4 */ - { 16140, 0x00000DD2 }, /* GL_MAP2_GRID_DOMAIN */ - { 16160, 0x00000DD3 }, /* GL_MAP2_GRID_SEGMENTS */ - { 16182, 0x00000DB1 }, /* GL_MAP2_INDEX */ - { 16196, 0x00000DB2 }, /* GL_MAP2_NORMAL */ - { 16211, 0x00000DB3 }, /* GL_MAP2_TEXTURE_COORD_1 */ - { 16235, 0x00000DB4 }, /* GL_MAP2_TEXTURE_COORD_2 */ - { 16259, 0x00000DB5 }, /* GL_MAP2_TEXTURE_COORD_3 */ - { 16283, 0x00000DB6 }, /* GL_MAP2_TEXTURE_COORD_4 */ - { 16307, 0x00000DB7 }, /* GL_MAP2_VERTEX_3 */ - { 16324, 0x00000DB8 }, /* GL_MAP2_VERTEX_4 */ - { 16341, 0x00008670 }, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */ - { 16369, 0x0000867A }, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */ - { 16398, 0x0000867B }, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */ - { 16427, 0x0000867C }, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */ - { 16456, 0x0000867D }, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */ - { 16485, 0x0000867E }, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */ - { 16514, 0x0000867F }, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */ - { 16543, 0x00008671 }, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */ - { 16571, 0x00008672 }, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */ - { 16599, 0x00008673 }, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */ - { 16627, 0x00008674 }, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */ - { 16655, 0x00008675 }, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */ - { 16683, 0x00008676 }, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */ - { 16711, 0x00008677 }, /* GL_MAP2_VERTEX_ATTRIB7_4_NV */ - { 16739, 0x00008678 }, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */ - { 16767, 0x00008679 }, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */ - { 16795, 0x00000D10 }, /* GL_MAP_COLOR */ - { 16808, 0x00000010 }, /* GL_MAP_FLUSH_EXPLICIT_BIT */ - { 16834, 0x00000008 }, /* GL_MAP_INVALIDATE_BUFFER_BIT */ - { 16863, 0x00000004 }, /* GL_MAP_INVALIDATE_RANGE_BIT */ - { 16891, 0x00000001 }, /* GL_MAP_READ_BIT */ - { 16907, 0x00000D11 }, /* GL_MAP_STENCIL */ - { 16922, 0x00000020 }, /* GL_MAP_UNSYNCHRONIZED_BIT */ - { 16948, 0x00000002 }, /* GL_MAP_WRITE_BIT */ - { 16965, 0x000088C0 }, /* GL_MATRIX0_ARB */ - { 16980, 0x00008630 }, /* GL_MATRIX0_NV */ - { 16994, 0x000088CA }, /* GL_MATRIX10_ARB */ - { 17010, 0x000088CB }, /* GL_MATRIX11_ARB */ - { 17026, 0x000088CC }, /* GL_MATRIX12_ARB */ - { 17042, 0x000088CD }, /* GL_MATRIX13_ARB */ - { 17058, 0x000088CE }, /* GL_MATRIX14_ARB */ - { 17074, 0x000088CF }, /* GL_MATRIX15_ARB */ - { 17090, 0x000088D0 }, /* GL_MATRIX16_ARB */ - { 17106, 0x000088D1 }, /* GL_MATRIX17_ARB */ - { 17122, 0x000088D2 }, /* GL_MATRIX18_ARB */ - { 17138, 0x000088D3 }, /* GL_MATRIX19_ARB */ - { 17154, 0x000088C1 }, /* GL_MATRIX1_ARB */ - { 17169, 0x00008631 }, /* GL_MATRIX1_NV */ - { 17183, 0x000088D4 }, /* GL_MATRIX20_ARB */ - { 17199, 0x000088D5 }, /* GL_MATRIX21_ARB */ - { 17215, 0x000088D6 }, /* GL_MATRIX22_ARB */ - { 17231, 0x000088D7 }, /* GL_MATRIX23_ARB */ - { 17247, 0x000088D8 }, /* GL_MATRIX24_ARB */ - { 17263, 0x000088D9 }, /* GL_MATRIX25_ARB */ - { 17279, 0x000088DA }, /* GL_MATRIX26_ARB */ - { 17295, 0x000088DB }, /* GL_MATRIX27_ARB */ - { 17311, 0x000088DC }, /* GL_MATRIX28_ARB */ - { 17327, 0x000088DD }, /* GL_MATRIX29_ARB */ - { 17343, 0x000088C2 }, /* GL_MATRIX2_ARB */ - { 17358, 0x00008632 }, /* GL_MATRIX2_NV */ - { 17372, 0x000088DE }, /* GL_MATRIX30_ARB */ - { 17388, 0x000088DF }, /* GL_MATRIX31_ARB */ - { 17404, 0x000088C3 }, /* GL_MATRIX3_ARB */ - { 17419, 0x00008633 }, /* GL_MATRIX3_NV */ - { 17433, 0x000088C4 }, /* GL_MATRIX4_ARB */ - { 17448, 0x00008634 }, /* GL_MATRIX4_NV */ - { 17462, 0x000088C5 }, /* GL_MATRIX5_ARB */ - { 17477, 0x00008635 }, /* GL_MATRIX5_NV */ - { 17491, 0x000088C6 }, /* GL_MATRIX6_ARB */ - { 17506, 0x00008636 }, /* GL_MATRIX6_NV */ - { 17520, 0x000088C7 }, /* GL_MATRIX7_ARB */ - { 17535, 0x00008637 }, /* GL_MATRIX7_NV */ - { 17549, 0x000088C8 }, /* GL_MATRIX8_ARB */ - { 17564, 0x000088C9 }, /* GL_MATRIX9_ARB */ - { 17579, 0x00008844 }, /* GL_MATRIX_INDEX_ARRAY_ARB */ - { 17605, 0x00008849 }, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */ - { 17639, 0x00008846 }, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */ - { 17670, 0x00008848 }, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */ - { 17703, 0x00008847 }, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */ - { 17734, 0x00000BA0 }, /* GL_MATRIX_MODE */ - { 17749, 0x00008840 }, /* GL_MATRIX_PALETTE_ARB */ - { 17771, 0x00008008 }, /* GL_MAX */ - { 17778, 0x00008073 }, /* GL_MAX_3D_TEXTURE_SIZE */ - { 17801, 0x000088FF }, /* GL_MAX_ARRAY_TEXTURE_LAYERS_EXT */ - { 17833, 0x00000D35 }, /* GL_MAX_ATTRIB_STACK_DEPTH */ - { 17859, 0x00000D3B }, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */ - { 17892, 0x00008177 }, /* GL_MAX_CLIPMAP_DEPTH_SGIX */ - { 17918, 0x00008178 }, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */ - { 17952, 0x00000D32 }, /* GL_MAX_CLIP_PLANES */ - { 17971, 0x00008CDF }, /* GL_MAX_COLOR_ATTACHMENTS */ - { 17996, 0x00008CDF }, /* GL_MAX_COLOR_ATTACHMENTS_EXT */ - { 18025, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */ - { 18057, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI */ - { 18093, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */ - { 18129, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB */ - { 18169, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT */ - { 18195, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT_EXT */ - { 18225, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH */ - { 18250, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH_EXT */ - { 18279, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */ - { 18308, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB */ - { 18341, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS */ - { 18361, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ARB */ - { 18385, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ATI */ - { 18409, 0x000080E9 }, /* GL_MAX_ELEMENTS_INDICES */ - { 18433, 0x000080E8 }, /* GL_MAX_ELEMENTS_VERTICES */ - { 18458, 0x00000D30 }, /* GL_MAX_EVAL_ORDER */ - { 18476, 0x00008008 }, /* GL_MAX_EXT */ - { 18487, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */ - { 18522, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB */ - { 18561, 0x00000D31 }, /* GL_MAX_LIGHTS */ - { 18575, 0x00000B31 }, /* GL_MAX_LIST_NESTING */ - { 18595, 0x00008841 }, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */ - { 18633, 0x00000D36 }, /* GL_MAX_MODELVIEW_STACK_DEPTH */ - { 18662, 0x00000D37 }, /* GL_MAX_NAME_STACK_DEPTH */ - { 18686, 0x00008842 }, /* GL_MAX_PALETTE_MATRICES_ARB */ - { 18714, 0x00000D34 }, /* GL_MAX_PIXEL_MAP_TABLE */ - { 18737, 0x000088B1 }, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */ - { 18774, 0x0000880B }, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */ - { 18810, 0x000088AD }, /* GL_MAX_PROGRAM_ATTRIBS_ARB */ - { 18837, 0x000088F5 }, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */ - { 18866, 0x000088B5 }, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */ - { 18900, 0x000088F4 }, /* GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ - { 18936, 0x000088F6 }, /* GL_MAX_PROGRAM_IF_DEPTH_NV */ - { 18963, 0x000088A1 }, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */ - { 18995, 0x000088B4 }, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */ - { 19031, 0x000088F8 }, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */ - { 19060, 0x000088F7 }, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */ - { 19089, 0x0000862F }, /* GL_MAX_PROGRAM_MATRICES_ARB */ - { 19117, 0x0000862E }, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */ - { 19155, 0x000088B3 }, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ - { 19199, 0x0000880E }, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ - { 19242, 0x000088AF }, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */ - { 19276, 0x000088A3 }, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ - { 19315, 0x000088AB }, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */ - { 19352, 0x000088A7 }, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */ - { 19390, 0x00008810 }, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ - { 19433, 0x0000880F }, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ - { 19476, 0x000088A9 }, /* GL_MAX_PROGRAM_PARAMETERS_ARB */ - { 19506, 0x000088A5 }, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */ - { 19537, 0x0000880D }, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */ - { 19573, 0x0000880C }, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */ - { 19609, 0x00000D38 }, /* GL_MAX_PROJECTION_STACK_DEPTH */ - { 19639, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */ - { 19673, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_NV */ - { 19706, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE */ - { 19731, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE_EXT */ - { 19760, 0x00008D57 }, /* GL_MAX_SAMPLES */ - { 19775, 0x00008D57 }, /* GL_MAX_SAMPLES_EXT */ - { 19794, 0x00009111 }, /* GL_MAX_SERVER_WAIT_TIMEOUT */ - { 19821, 0x00008504 }, /* GL_MAX_SHININESS_NV */ - { 19841, 0x00008505 }, /* GL_MAX_SPOT_EXPONENT_NV */ - { 19865, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS */ - { 19887, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS_ARB */ - { 19913, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS */ - { 19940, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS_ARB */ - { 19971, 0x000084FD }, /* GL_MAX_TEXTURE_LOD_BIAS */ - { 19995, 0x000084FF }, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */ - { 20029, 0x00000D33 }, /* GL_MAX_TEXTURE_SIZE */ - { 20049, 0x00000D39 }, /* GL_MAX_TEXTURE_STACK_DEPTH */ - { 20076, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS */ - { 20097, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS_ARB */ - { 20122, 0x0000862F }, /* GL_MAX_TRACK_MATRICES_NV */ - { 20147, 0x0000862E }, /* GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */ - { 20182, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS */ - { 20204, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS_ARB */ - { 20230, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS */ - { 20252, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS_ARB */ - { 20278, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */ - { 20312, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ - { 20350, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */ - { 20383, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB */ - { 20420, 0x000086A4 }, /* GL_MAX_VERTEX_UNITS_ARB */ - { 20444, 0x00000D3A }, /* GL_MAX_VIEWPORT_DIMS */ - { 20465, 0x00008007 }, /* GL_MIN */ - { 20472, 0x0000802E }, /* GL_MINMAX */ - { 20482, 0x0000802E }, /* GL_MINMAX_EXT */ - { 20496, 0x0000802F }, /* GL_MINMAX_FORMAT */ - { 20513, 0x0000802F }, /* GL_MINMAX_FORMAT_EXT */ - { 20534, 0x00008030 }, /* GL_MINMAX_SINK */ - { 20549, 0x00008030 }, /* GL_MINMAX_SINK_EXT */ - { 20568, 0x00008007 }, /* GL_MIN_EXT */ - { 20579, 0x00008370 }, /* GL_MIRRORED_REPEAT */ - { 20598, 0x00008370 }, /* GL_MIRRORED_REPEAT_ARB */ - { 20621, 0x00008370 }, /* GL_MIRRORED_REPEAT_IBM */ - { 20644, 0x00008742 }, /* GL_MIRROR_CLAMP_ATI */ - { 20664, 0x00008742 }, /* GL_MIRROR_CLAMP_EXT */ - { 20684, 0x00008912 }, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */ - { 20714, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_ATI */ - { 20742, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */ - { 20770, 0x00001700 }, /* GL_MODELVIEW */ - { 20783, 0x00001700 }, /* GL_MODELVIEW0_ARB */ - { 20801, 0x0000872A }, /* GL_MODELVIEW10_ARB */ - { 20820, 0x0000872B }, /* GL_MODELVIEW11_ARB */ - { 20839, 0x0000872C }, /* GL_MODELVIEW12_ARB */ - { 20858, 0x0000872D }, /* GL_MODELVIEW13_ARB */ - { 20877, 0x0000872E }, /* GL_MODELVIEW14_ARB */ - { 20896, 0x0000872F }, /* GL_MODELVIEW15_ARB */ - { 20915, 0x00008730 }, /* GL_MODELVIEW16_ARB */ - { 20934, 0x00008731 }, /* GL_MODELVIEW17_ARB */ - { 20953, 0x00008732 }, /* GL_MODELVIEW18_ARB */ - { 20972, 0x00008733 }, /* GL_MODELVIEW19_ARB */ - { 20991, 0x0000850A }, /* GL_MODELVIEW1_ARB */ - { 21009, 0x00008734 }, /* GL_MODELVIEW20_ARB */ - { 21028, 0x00008735 }, /* GL_MODELVIEW21_ARB */ - { 21047, 0x00008736 }, /* GL_MODELVIEW22_ARB */ - { 21066, 0x00008737 }, /* GL_MODELVIEW23_ARB */ - { 21085, 0x00008738 }, /* GL_MODELVIEW24_ARB */ - { 21104, 0x00008739 }, /* GL_MODELVIEW25_ARB */ - { 21123, 0x0000873A }, /* GL_MODELVIEW26_ARB */ - { 21142, 0x0000873B }, /* GL_MODELVIEW27_ARB */ - { 21161, 0x0000873C }, /* GL_MODELVIEW28_ARB */ - { 21180, 0x0000873D }, /* GL_MODELVIEW29_ARB */ - { 21199, 0x00008722 }, /* GL_MODELVIEW2_ARB */ - { 21217, 0x0000873E }, /* GL_MODELVIEW30_ARB */ - { 21236, 0x0000873F }, /* GL_MODELVIEW31_ARB */ - { 21255, 0x00008723 }, /* GL_MODELVIEW3_ARB */ - { 21273, 0x00008724 }, /* GL_MODELVIEW4_ARB */ - { 21291, 0x00008725 }, /* GL_MODELVIEW5_ARB */ - { 21309, 0x00008726 }, /* GL_MODELVIEW6_ARB */ - { 21327, 0x00008727 }, /* GL_MODELVIEW7_ARB */ - { 21345, 0x00008728 }, /* GL_MODELVIEW8_ARB */ - { 21363, 0x00008729 }, /* GL_MODELVIEW9_ARB */ - { 21381, 0x00000BA6 }, /* GL_MODELVIEW_MATRIX */ - { 21401, 0x00008629 }, /* GL_MODELVIEW_PROJECTION_NV */ - { 21428, 0x00000BA3 }, /* GL_MODELVIEW_STACK_DEPTH */ - { 21453, 0x00002100 }, /* GL_MODULATE */ - { 21465, 0x00008744 }, /* GL_MODULATE_ADD_ATI */ - { 21485, 0x00008745 }, /* GL_MODULATE_SIGNED_ADD_ATI */ - { 21512, 0x00008746 }, /* GL_MODULATE_SUBTRACT_ATI */ - { 21537, 0x00000103 }, /* GL_MULT */ - { 21545, 0x0000809D }, /* GL_MULTISAMPLE */ - { 21560, 0x000086B2 }, /* GL_MULTISAMPLE_3DFX */ - { 21580, 0x0000809D }, /* GL_MULTISAMPLE_ARB */ - { 21599, 0x20000000 }, /* GL_MULTISAMPLE_BIT */ - { 21618, 0x20000000 }, /* GL_MULTISAMPLE_BIT_3DFX */ - { 21642, 0x20000000 }, /* GL_MULTISAMPLE_BIT_ARB */ - { 21665, 0x00008534 }, /* GL_MULTISAMPLE_FILTER_HINT_NV */ - { 21695, 0x00002A25 }, /* GL_N3F_V3F */ - { 21706, 0x00000D70 }, /* GL_NAME_STACK_DEPTH */ - { 21726, 0x0000150E }, /* GL_NAND */ - { 21734, 0x00002600 }, /* GL_NEAREST */ - { 21745, 0x0000844E }, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */ - { 21776, 0x0000844D }, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */ - { 21808, 0x00002702 }, /* GL_NEAREST_MIPMAP_LINEAR */ - { 21833, 0x00002700 }, /* GL_NEAREST_MIPMAP_NEAREST */ - { 21859, 0x00000200 }, /* GL_NEVER */ - { 21868, 0x00001102 }, /* GL_NICEST */ - { 21878, 0x00000000 }, /* GL_NONE */ - { 21886, 0x00001505 }, /* GL_NOOP */ - { 21894, 0x00001508 }, /* GL_NOR */ - { 21901, 0x00000BA1 }, /* GL_NORMALIZE */ - { 21914, 0x00008075 }, /* GL_NORMAL_ARRAY */ - { 21930, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING */ - { 21961, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING_ARB */ - { 21996, 0x0000808F }, /* GL_NORMAL_ARRAY_POINTER */ - { 22020, 0x0000807F }, /* GL_NORMAL_ARRAY_STRIDE */ - { 22043, 0x0000807E }, /* GL_NORMAL_ARRAY_TYPE */ - { 22064, 0x00008511 }, /* GL_NORMAL_MAP */ - { 22078, 0x00008511 }, /* GL_NORMAL_MAP_ARB */ - { 22096, 0x00008511 }, /* GL_NORMAL_MAP_NV */ - { 22113, 0x00000205 }, /* GL_NOTEQUAL */ - { 22125, 0x00000000 }, /* GL_NO_ERROR */ - { 22137, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */ - { 22171, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB */ - { 22209, 0x00008B89 }, /* GL_OBJECT_ACTIVE_ATTRIBUTES_ARB */ - { 22241, 0x00008B8A }, /* GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB */ - { 22283, 0x00008B86 }, /* GL_OBJECT_ACTIVE_UNIFORMS_ARB */ - { 22313, 0x00008B87 }, /* GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB */ - { 22353, 0x00008B85 }, /* GL_OBJECT_ATTACHED_OBJECTS_ARB */ - { 22384, 0x00008B81 }, /* GL_OBJECT_COMPILE_STATUS_ARB */ - { 22413, 0x00008B80 }, /* GL_OBJECT_DELETE_STATUS_ARB */ - { 22441, 0x00008B84 }, /* GL_OBJECT_INFO_LOG_LENGTH_ARB */ - { 22471, 0x00002401 }, /* GL_OBJECT_LINEAR */ - { 22488, 0x00008B82 }, /* GL_OBJECT_LINK_STATUS_ARB */ - { 22514, 0x00002501 }, /* GL_OBJECT_PLANE */ - { 22530, 0x00008B88 }, /* GL_OBJECT_SHADER_SOURCE_LENGTH_ARB */ - { 22565, 0x00008B4F }, /* GL_OBJECT_SUBTYPE_ARB */ - { 22587, 0x00009112 }, /* GL_OBJECT_TYPE */ - { 22602, 0x00008B4E }, /* GL_OBJECT_TYPE_ARB */ - { 22621, 0x00008B83 }, /* GL_OBJECT_VALIDATE_STATUS_ARB */ - { 22651, 0x00008165 }, /* GL_OCCLUSION_TEST_HP */ - { 22672, 0x00008166 }, /* GL_OCCLUSION_TEST_RESULT_HP */ - { 22700, 0x00000001 }, /* GL_ONE */ - { 22707, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA */ - { 22735, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA_EXT */ - { 22767, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR */ - { 22795, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR_EXT */ - { 22827, 0x00000305 }, /* GL_ONE_MINUS_DST_ALPHA */ - { 22850, 0x00000307 }, /* GL_ONE_MINUS_DST_COLOR */ - { 22873, 0x00000303 }, /* GL_ONE_MINUS_SRC_ALPHA */ - { 22896, 0x00000301 }, /* GL_ONE_MINUS_SRC_COLOR */ - { 22919, 0x00008598 }, /* GL_OPERAND0_ALPHA */ - { 22937, 0x00008598 }, /* GL_OPERAND0_ALPHA_ARB */ - { 22959, 0x00008598 }, /* GL_OPERAND0_ALPHA_EXT */ - { 22981, 0x00008590 }, /* GL_OPERAND0_RGB */ - { 22997, 0x00008590 }, /* GL_OPERAND0_RGB_ARB */ - { 23017, 0x00008590 }, /* GL_OPERAND0_RGB_EXT */ - { 23037, 0x00008599 }, /* GL_OPERAND1_ALPHA */ - { 23055, 0x00008599 }, /* GL_OPERAND1_ALPHA_ARB */ - { 23077, 0x00008599 }, /* GL_OPERAND1_ALPHA_EXT */ - { 23099, 0x00008591 }, /* GL_OPERAND1_RGB */ - { 23115, 0x00008591 }, /* GL_OPERAND1_RGB_ARB */ - { 23135, 0x00008591 }, /* GL_OPERAND1_RGB_EXT */ - { 23155, 0x0000859A }, /* GL_OPERAND2_ALPHA */ - { 23173, 0x0000859A }, /* GL_OPERAND2_ALPHA_ARB */ - { 23195, 0x0000859A }, /* GL_OPERAND2_ALPHA_EXT */ - { 23217, 0x00008592 }, /* GL_OPERAND2_RGB */ - { 23233, 0x00008592 }, /* GL_OPERAND2_RGB_ARB */ - { 23253, 0x00008592 }, /* GL_OPERAND2_RGB_EXT */ - { 23273, 0x0000859B }, /* GL_OPERAND3_ALPHA_NV */ - { 23294, 0x00008593 }, /* GL_OPERAND3_RGB_NV */ - { 23313, 0x00001507 }, /* GL_OR */ - { 23319, 0x00000A01 }, /* GL_ORDER */ - { 23328, 0x0000150D }, /* GL_OR_INVERTED */ - { 23343, 0x0000150B }, /* GL_OR_REVERSE */ - { 23357, 0x00000505 }, /* GL_OUT_OF_MEMORY */ - { 23374, 0x00000D05 }, /* GL_PACK_ALIGNMENT */ - { 23392, 0x0000806C }, /* GL_PACK_IMAGE_HEIGHT */ - { 23413, 0x00008758 }, /* GL_PACK_INVERT_MESA */ - { 23433, 0x00000D01 }, /* GL_PACK_LSB_FIRST */ - { 23451, 0x00000D02 }, /* GL_PACK_ROW_LENGTH */ - { 23470, 0x0000806B }, /* GL_PACK_SKIP_IMAGES */ - { 23490, 0x00000D04 }, /* GL_PACK_SKIP_PIXELS */ - { 23510, 0x00000D03 }, /* GL_PACK_SKIP_ROWS */ - { 23528, 0x00000D00 }, /* GL_PACK_SWAP_BYTES */ - { 23547, 0x00008B92 }, /* GL_PALETTE4_R5_G6_B5_OES */ - { 23572, 0x00008B94 }, /* GL_PALETTE4_RGB5_A1_OES */ - { 23596, 0x00008B90 }, /* GL_PALETTE4_RGB8_OES */ - { 23617, 0x00008B93 }, /* GL_PALETTE4_RGBA4_OES */ - { 23639, 0x00008B91 }, /* GL_PALETTE4_RGBA8_OES */ - { 23661, 0x00008B97 }, /* GL_PALETTE8_R5_G6_B5_OES */ - { 23686, 0x00008B99 }, /* GL_PALETTE8_RGB5_A1_OES */ - { 23710, 0x00008B95 }, /* GL_PALETTE8_RGB8_OES */ - { 23731, 0x00008B98 }, /* GL_PALETTE8_RGBA4_OES */ - { 23753, 0x00008B96 }, /* GL_PALETTE8_RGBA8_OES */ - { 23775, 0x00000700 }, /* GL_PASS_THROUGH_TOKEN */ - { 23797, 0x00000C50 }, /* GL_PERSPECTIVE_CORRECTION_HINT */ - { 23828, 0x00000C79 }, /* GL_PIXEL_MAP_A_TO_A */ - { 23848, 0x00000CB9 }, /* GL_PIXEL_MAP_A_TO_A_SIZE */ - { 23873, 0x00000C78 }, /* GL_PIXEL_MAP_B_TO_B */ - { 23893, 0x00000CB8 }, /* GL_PIXEL_MAP_B_TO_B_SIZE */ - { 23918, 0x00000C77 }, /* GL_PIXEL_MAP_G_TO_G */ - { 23938, 0x00000CB7 }, /* GL_PIXEL_MAP_G_TO_G_SIZE */ - { 23963, 0x00000C75 }, /* GL_PIXEL_MAP_I_TO_A */ - { 23983, 0x00000CB5 }, /* GL_PIXEL_MAP_I_TO_A_SIZE */ - { 24008, 0x00000C74 }, /* GL_PIXEL_MAP_I_TO_B */ - { 24028, 0x00000CB4 }, /* GL_PIXEL_MAP_I_TO_B_SIZE */ - { 24053, 0x00000C73 }, /* GL_PIXEL_MAP_I_TO_G */ - { 24073, 0x00000CB3 }, /* GL_PIXEL_MAP_I_TO_G_SIZE */ - { 24098, 0x00000C70 }, /* GL_PIXEL_MAP_I_TO_I */ - { 24118, 0x00000CB0 }, /* GL_PIXEL_MAP_I_TO_I_SIZE */ - { 24143, 0x00000C72 }, /* GL_PIXEL_MAP_I_TO_R */ - { 24163, 0x00000CB2 }, /* GL_PIXEL_MAP_I_TO_R_SIZE */ - { 24188, 0x00000C76 }, /* GL_PIXEL_MAP_R_TO_R */ - { 24208, 0x00000CB6 }, /* GL_PIXEL_MAP_R_TO_R_SIZE */ - { 24233, 0x00000C71 }, /* GL_PIXEL_MAP_S_TO_S */ - { 24253, 0x00000CB1 }, /* GL_PIXEL_MAP_S_TO_S_SIZE */ - { 24278, 0x00000020 }, /* GL_PIXEL_MODE_BIT */ - { 24296, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER */ - { 24317, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING */ - { 24346, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING_EXT */ - { 24379, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER_EXT */ - { 24404, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER */ - { 24427, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING */ - { 24458, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING_EXT */ - { 24493, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER_EXT */ - { 24520, 0x00001B00 }, /* GL_POINT */ - { 24529, 0x00000000 }, /* GL_POINTS */ - { 24539, 0x00000002 }, /* GL_POINT_BIT */ - { 24552, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION */ - { 24582, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_ARB */ - { 24616, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_EXT */ - { 24650, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_SGIS */ - { 24685, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE */ - { 24714, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_ARB */ - { 24747, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_EXT */ - { 24780, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_SGIS */ - { 24814, 0x00000B11 }, /* GL_POINT_SIZE */ - { 24828, 0x00000B13 }, /* GL_POINT_SIZE_GRANULARITY */ - { 24854, 0x00008127 }, /* GL_POINT_SIZE_MAX */ - { 24872, 0x00008127 }, /* GL_POINT_SIZE_MAX_ARB */ - { 24894, 0x00008127 }, /* GL_POINT_SIZE_MAX_EXT */ - { 24916, 0x00008127 }, /* GL_POINT_SIZE_MAX_SGIS */ - { 24939, 0x00008126 }, /* GL_POINT_SIZE_MIN */ - { 24957, 0x00008126 }, /* GL_POINT_SIZE_MIN_ARB */ - { 24979, 0x00008126 }, /* GL_POINT_SIZE_MIN_EXT */ - { 25001, 0x00008126 }, /* GL_POINT_SIZE_MIN_SGIS */ - { 25024, 0x00000B12 }, /* GL_POINT_SIZE_RANGE */ - { 25044, 0x00000B10 }, /* GL_POINT_SMOOTH */ - { 25060, 0x00000C51 }, /* GL_POINT_SMOOTH_HINT */ - { 25081, 0x00008861 }, /* GL_POINT_SPRITE */ - { 25097, 0x00008861 }, /* GL_POINT_SPRITE_ARB */ - { 25117, 0x00008CA0 }, /* GL_POINT_SPRITE_COORD_ORIGIN */ - { 25146, 0x00008861 }, /* GL_POINT_SPRITE_NV */ - { 25165, 0x00008863 }, /* GL_POINT_SPRITE_R_MODE_NV */ - { 25191, 0x00000701 }, /* GL_POINT_TOKEN */ - { 25206, 0x00000009 }, /* GL_POLYGON */ - { 25217, 0x00000008 }, /* GL_POLYGON_BIT */ - { 25232, 0x00000B40 }, /* GL_POLYGON_MODE */ - { 25248, 0x00008039 }, /* GL_POLYGON_OFFSET_BIAS */ - { 25271, 0x00008038 }, /* GL_POLYGON_OFFSET_FACTOR */ - { 25296, 0x00008037 }, /* GL_POLYGON_OFFSET_FILL */ - { 25319, 0x00002A02 }, /* GL_POLYGON_OFFSET_LINE */ - { 25342, 0x00002A01 }, /* GL_POLYGON_OFFSET_POINT */ - { 25366, 0x00002A00 }, /* GL_POLYGON_OFFSET_UNITS */ - { 25390, 0x00000B41 }, /* GL_POLYGON_SMOOTH */ - { 25408, 0x00000C53 }, /* GL_POLYGON_SMOOTH_HINT */ - { 25431, 0x00000B42 }, /* GL_POLYGON_STIPPLE */ - { 25450, 0x00000010 }, /* GL_POLYGON_STIPPLE_BIT */ - { 25473, 0x00000703 }, /* GL_POLYGON_TOKEN */ - { 25490, 0x00001203 }, /* GL_POSITION */ - { 25502, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */ - { 25534, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI */ - { 25570, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */ - { 25603, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI */ - { 25640, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */ - { 25671, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI */ - { 25706, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */ - { 25738, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI */ - { 25774, 0x000080D2 }, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */ - { 25807, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */ - { 25839, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI */ - { 25875, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */ - { 25908, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI */ - { 25945, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS */ - { 25975, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS_SGI */ - { 26009, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE */ - { 26040, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE_SGI */ - { 26075, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS */ - { 26106, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS_EXT */ - { 26141, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE */ - { 26173, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE_EXT */ - { 26209, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS */ - { 26239, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS_EXT */ - { 26273, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE */ - { 26304, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE_EXT */ - { 26339, 0x000080D1 }, /* GL_POST_CONVOLUTION_COLOR_TABLE */ - { 26371, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS */ - { 26402, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS_EXT */ - { 26437, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE */ - { 26469, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE_EXT */ - { 26505, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS */ - { 26534, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS_EXT */ - { 26567, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE */ - { 26597, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE_EXT */ - { 26631, 0x0000817B }, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */ - { 26670, 0x00008179 }, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */ - { 26703, 0x0000817C }, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */ - { 26743, 0x0000817A }, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */ - { 26777, 0x00008578 }, /* GL_PREVIOUS */ - { 26789, 0x00008578 }, /* GL_PREVIOUS_ARB */ - { 26805, 0x00008578 }, /* GL_PREVIOUS_EXT */ - { 26821, 0x00008577 }, /* GL_PRIMARY_COLOR */ - { 26838, 0x00008577 }, /* GL_PRIMARY_COLOR_ARB */ - { 26859, 0x00008577 }, /* GL_PRIMARY_COLOR_EXT */ - { 26880, 0x000088B0 }, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */ - { 26913, 0x00008805 }, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */ - { 26945, 0x000088AC }, /* GL_PROGRAM_ATTRIBS_ARB */ - { 26968, 0x00008677 }, /* GL_PROGRAM_BINDING_ARB */ - { 26991, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_ARB */ - { 27021, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_NV */ - { 27050, 0x00008874 }, /* GL_PROGRAM_ERROR_STRING_ARB */ - { 27078, 0x00008876 }, /* GL_PROGRAM_FORMAT_ARB */ - { 27100, 0x00008875 }, /* GL_PROGRAM_FORMAT_ASCII_ARB */ - { 27128, 0x000088A0 }, /* GL_PROGRAM_INSTRUCTIONS_ARB */ - { 27156, 0x00008627 }, /* GL_PROGRAM_LENGTH_ARB */ - { 27178, 0x00008627 }, /* GL_PROGRAM_LENGTH_NV */ - { 27199, 0x000088B2 }, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ - { 27239, 0x00008808 }, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ - { 27278, 0x000088AE }, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */ - { 27308, 0x000088A2 }, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ - { 27343, 0x000088AA }, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */ - { 27376, 0x000088A6 }, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */ - { 27410, 0x0000880A }, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ - { 27449, 0x00008809 }, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ - { 27488, 0x00008B40 }, /* GL_PROGRAM_OBJECT_ARB */ - { 27510, 0x000088A8 }, /* GL_PROGRAM_PARAMETERS_ARB */ - { 27536, 0x00008644 }, /* GL_PROGRAM_PARAMETER_NV */ - { 27560, 0x00008647 }, /* GL_PROGRAM_RESIDENT_NV */ - { 27583, 0x00008628 }, /* GL_PROGRAM_STRING_ARB */ - { 27605, 0x00008628 }, /* GL_PROGRAM_STRING_NV */ - { 27626, 0x00008646 }, /* GL_PROGRAM_TARGET_NV */ - { 27647, 0x000088A4 }, /* GL_PROGRAM_TEMPORARIES_ARB */ - { 27674, 0x00008807 }, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */ - { 27706, 0x00008806 }, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */ - { 27738, 0x000088B6 }, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */ - { 27773, 0x00001701 }, /* GL_PROJECTION */ - { 27787, 0x00000BA7 }, /* GL_PROJECTION_MATRIX */ - { 27808, 0x00000BA4 }, /* GL_PROJECTION_STACK_DEPTH */ - { 27834, 0x00008E4F }, /* GL_PROVOKING_VERTEX */ - { 27854, 0x00008E4F }, /* GL_PROVOKING_VERTEX_EXT */ - { 27878, 0x000080D3 }, /* GL_PROXY_COLOR_TABLE */ - { 27899, 0x00008025 }, /* GL_PROXY_HISTOGRAM */ - { 27918, 0x00008025 }, /* GL_PROXY_HISTOGRAM_EXT */ - { 27941, 0x000080D5 }, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */ - { 27980, 0x000080D4 }, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */ - { 28018, 0x00008063 }, /* GL_PROXY_TEXTURE_1D */ - { 28038, 0x00008C19 }, /* GL_PROXY_TEXTURE_1D_ARRAY_EXT */ - { 28068, 0x00008063 }, /* GL_PROXY_TEXTURE_1D_EXT */ - { 28092, 0x00008064 }, /* GL_PROXY_TEXTURE_2D */ - { 28112, 0x00008C1B }, /* GL_PROXY_TEXTURE_2D_ARRAY_EXT */ - { 28142, 0x00008064 }, /* GL_PROXY_TEXTURE_2D_EXT */ - { 28166, 0x00008070 }, /* GL_PROXY_TEXTURE_3D */ - { 28186, 0x000080BD }, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */ - { 28219, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP */ - { 28245, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP_ARB */ - { 28275, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */ - { 28306, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_NV */ - { 28336, 0x00002003 }, /* GL_Q */ - { 28341, 0x00001209 }, /* GL_QUADRATIC_ATTENUATION */ - { 28366, 0x00000007 }, /* GL_QUADS */ - { 28375, 0x00008E4C }, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ - { 28419, 0x00008E4C }, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT */ - { 28467, 0x00008614 }, /* GL_QUAD_MESH_SUN */ - { 28484, 0x00000008 }, /* GL_QUAD_STRIP */ - { 28498, 0x00008E16 }, /* GL_QUERY_BY_REGION_NO_WAIT_NV */ - { 28528, 0x00008E15 }, /* GL_QUERY_BY_REGION_WAIT_NV */ - { 28555, 0x00008864 }, /* GL_QUERY_COUNTER_BITS */ - { 28577, 0x00008864 }, /* GL_QUERY_COUNTER_BITS_ARB */ - { 28603, 0x00008E14 }, /* GL_QUERY_NO_WAIT_NV */ - { 28623, 0x00008866 }, /* GL_QUERY_RESULT */ - { 28639, 0x00008866 }, /* GL_QUERY_RESULT_ARB */ - { 28659, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE */ - { 28685, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE_ARB */ - { 28715, 0x00008E13 }, /* GL_QUERY_WAIT_NV */ - { 28732, 0x00002002 }, /* GL_R */ - { 28737, 0x00002A10 }, /* GL_R3_G3_B2 */ - { 28749, 0x00019262 }, /* GL_RASTER_POSITION_UNCLIPPED_IBM */ - { 28782, 0x00000C02 }, /* GL_READ_BUFFER */ - { 28797, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER */ - { 28817, 0x00008CAA }, /* GL_READ_FRAMEBUFFER_BINDING */ - { 28845, 0x00008CAA }, /* GL_READ_FRAMEBUFFER_BINDING_EXT */ - { 28877, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER_EXT */ - { 28901, 0x000088B8 }, /* GL_READ_ONLY */ - { 28914, 0x000088B8 }, /* GL_READ_ONLY_ARB */ - { 28931, 0x000088BA }, /* GL_READ_WRITE */ - { 28945, 0x000088BA }, /* GL_READ_WRITE_ARB */ - { 28963, 0x00001903 }, /* GL_RED */ - { 28970, 0x00008016 }, /* GL_REDUCE */ - { 28980, 0x00008016 }, /* GL_REDUCE_EXT */ - { 28994, 0x00000D15 }, /* GL_RED_BIAS */ - { 29006, 0x00000D52 }, /* GL_RED_BITS */ - { 29018, 0x00000D14 }, /* GL_RED_SCALE */ - { 29031, 0x00008512 }, /* GL_REFLECTION_MAP */ - { 29049, 0x00008512 }, /* GL_REFLECTION_MAP_ARB */ - { 29071, 0x00008512 }, /* GL_REFLECTION_MAP_NV */ - { 29092, 0x00001C00 }, /* GL_RENDER */ - { 29102, 0x00008D41 }, /* GL_RENDERBUFFER */ - { 29118, 0x00008D53 }, /* GL_RENDERBUFFER_ALPHA_SIZE */ - { 29145, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING */ - { 29169, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING_EXT */ - { 29197, 0x00008D52 }, /* GL_RENDERBUFFER_BLUE_SIZE */ - { 29223, 0x00008D54 }, /* GL_RENDERBUFFER_DEPTH_SIZE */ - { 29250, 0x00008D41 }, /* GL_RENDERBUFFER_EXT */ - { 29270, 0x00008D51 }, /* GL_RENDERBUFFER_GREEN_SIZE */ - { 29297, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT */ - { 29320, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT_EXT */ - { 29347, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT */ - { 29379, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT_EXT */ - { 29415, 0x00008D50 }, /* GL_RENDERBUFFER_RED_SIZE */ - { 29440, 0x00008CAB }, /* GL_RENDERBUFFER_SAMPLES */ - { 29464, 0x00008CAB }, /* GL_RENDERBUFFER_SAMPLES_EXT */ - { 29492, 0x00008D55 }, /* GL_RENDERBUFFER_STENCIL_SIZE */ - { 29521, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH */ - { 29543, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH_EXT */ - { 29569, 0x00001F01 }, /* GL_RENDERER */ - { 29581, 0x00000C40 }, /* GL_RENDER_MODE */ - { 29596, 0x00002901 }, /* GL_REPEAT */ - { 29606, 0x00001E01 }, /* GL_REPLACE */ - { 29617, 0x00008062 }, /* GL_REPLACE_EXT */ - { 29632, 0x00008153 }, /* GL_REPLICATE_BORDER_HP */ - { 29655, 0x0000803A }, /* GL_RESCALE_NORMAL */ - { 29673, 0x0000803A }, /* GL_RESCALE_NORMAL_EXT */ - { 29695, 0x00000102 }, /* GL_RETURN */ - { 29705, 0x00001907 }, /* GL_RGB */ - { 29712, 0x00008052 }, /* GL_RGB10 */ - { 29721, 0x00008059 }, /* GL_RGB10_A2 */ - { 29733, 0x00008059 }, /* GL_RGB10_A2_EXT */ - { 29749, 0x00008052 }, /* GL_RGB10_EXT */ - { 29762, 0x00008053 }, /* GL_RGB12 */ - { 29771, 0x00008053 }, /* GL_RGB12_EXT */ - { 29784, 0x00008054 }, /* GL_RGB16 */ - { 29793, 0x00008054 }, /* GL_RGB16_EXT */ - { 29806, 0x0000804E }, /* GL_RGB2_EXT */ - { 29818, 0x0000804F }, /* GL_RGB4 */ - { 29826, 0x0000804F }, /* GL_RGB4_EXT */ - { 29838, 0x000083A1 }, /* GL_RGB4_S3TC */ - { 29851, 0x00008050 }, /* GL_RGB5 */ - { 29859, 0x00008057 }, /* GL_RGB5_A1 */ - { 29870, 0x00008057 }, /* GL_RGB5_A1_EXT */ - { 29885, 0x00008050 }, /* GL_RGB5_EXT */ - { 29897, 0x00008051 }, /* GL_RGB8 */ - { 29905, 0x00008051 }, /* GL_RGB8_EXT */ - { 29917, 0x00001908 }, /* GL_RGBA */ - { 29925, 0x0000805A }, /* GL_RGBA12 */ - { 29935, 0x0000805A }, /* GL_RGBA12_EXT */ - { 29949, 0x0000805B }, /* GL_RGBA16 */ - { 29959, 0x0000805B }, /* GL_RGBA16_EXT */ - { 29973, 0x00008055 }, /* GL_RGBA2 */ - { 29982, 0x00008055 }, /* GL_RGBA2_EXT */ - { 29995, 0x00008056 }, /* GL_RGBA4 */ - { 30004, 0x000083A5 }, /* GL_RGBA4_DXT5_S3TC */ - { 30023, 0x00008056 }, /* GL_RGBA4_EXT */ - { 30036, 0x000083A3 }, /* GL_RGBA4_S3TC */ - { 30050, 0x00008058 }, /* GL_RGBA8 */ - { 30059, 0x00008058 }, /* GL_RGBA8_EXT */ - { 30072, 0x00008F97 }, /* GL_RGBA8_SNORM */ - { 30087, 0x000083A4 }, /* GL_RGBA_DXT5_S3TC */ - { 30105, 0x00000C31 }, /* GL_RGBA_MODE */ - { 30118, 0x000083A2 }, /* GL_RGBA_S3TC */ - { 30131, 0x00008F93 }, /* GL_RGBA_SNORM */ - { 30145, 0x000083A0 }, /* GL_RGB_S3TC */ - { 30157, 0x00008573 }, /* GL_RGB_SCALE */ - { 30170, 0x00008573 }, /* GL_RGB_SCALE_ARB */ - { 30187, 0x00008573 }, /* GL_RGB_SCALE_EXT */ - { 30204, 0x00000407 }, /* GL_RIGHT */ - { 30213, 0x00002000 }, /* GL_S */ - { 30218, 0x00008B5D }, /* GL_SAMPLER_1D */ - { 30232, 0x00008B61 }, /* GL_SAMPLER_1D_SHADOW */ - { 30253, 0x00008B5E }, /* GL_SAMPLER_2D */ - { 30267, 0x00008B62 }, /* GL_SAMPLER_2D_SHADOW */ - { 30288, 0x00008B5F }, /* GL_SAMPLER_3D */ - { 30302, 0x00008B60 }, /* GL_SAMPLER_CUBE */ - { 30318, 0x000080A9 }, /* GL_SAMPLES */ - { 30329, 0x000086B4 }, /* GL_SAMPLES_3DFX */ - { 30345, 0x000080A9 }, /* GL_SAMPLES_ARB */ - { 30360, 0x00008914 }, /* GL_SAMPLES_PASSED */ - { 30378, 0x00008914 }, /* GL_SAMPLES_PASSED_ARB */ - { 30400, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE */ - { 30428, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE_ARB */ - { 30460, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE */ - { 30483, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE_ARB */ - { 30510, 0x000080A8 }, /* GL_SAMPLE_BUFFERS */ - { 30528, 0x000086B3 }, /* GL_SAMPLE_BUFFERS_3DFX */ - { 30551, 0x000080A8 }, /* GL_SAMPLE_BUFFERS_ARB */ - { 30573, 0x000080A0 }, /* GL_SAMPLE_COVERAGE */ - { 30592, 0x000080A0 }, /* GL_SAMPLE_COVERAGE_ARB */ - { 30615, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT */ - { 30641, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT_ARB */ - { 30671, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE */ - { 30696, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE_ARB */ - { 30725, 0x00080000 }, /* GL_SCISSOR_BIT */ - { 30740, 0x00000C10 }, /* GL_SCISSOR_BOX */ - { 30755, 0x00000C11 }, /* GL_SCISSOR_TEST */ - { 30771, 0x0000845E }, /* GL_SECONDARY_COLOR_ARRAY */ - { 30796, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */ - { 30836, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB */ - { 30880, 0x0000845D }, /* GL_SECONDARY_COLOR_ARRAY_POINTER */ - { 30913, 0x0000845A }, /* GL_SECONDARY_COLOR_ARRAY_SIZE */ - { 30943, 0x0000845C }, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */ - { 30975, 0x0000845B }, /* GL_SECONDARY_COLOR_ARRAY_TYPE */ - { 31005, 0x00001C02 }, /* GL_SELECT */ - { 31015, 0x00000DF3 }, /* GL_SELECTION_BUFFER_POINTER */ - { 31043, 0x00000DF4 }, /* GL_SELECTION_BUFFER_SIZE */ - { 31068, 0x00008012 }, /* GL_SEPARABLE_2D */ - { 31084, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR */ - { 31111, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR_EXT */ - { 31142, 0x0000150F }, /* GL_SET */ - { 31149, 0x00008B48 }, /* GL_SHADER_OBJECT_ARB */ - { 31170, 0x00008B88 }, /* GL_SHADER_SOURCE_LENGTH */ - { 31194, 0x00008B4F }, /* GL_SHADER_TYPE */ - { 31209, 0x00000B54 }, /* GL_SHADE_MODEL */ - { 31224, 0x00008B8C }, /* GL_SHADING_LANGUAGE_VERSION */ - { 31252, 0x000080BF }, /* GL_SHADOW_AMBIENT_SGIX */ - { 31275, 0x000081FB }, /* GL_SHARED_TEXTURE_PALETTE_EXT */ - { 31305, 0x00001601 }, /* GL_SHININESS */ - { 31318, 0x00001402 }, /* GL_SHORT */ - { 31327, 0x00009119 }, /* GL_SIGNALED */ - { 31339, 0x00008F9C }, /* GL_SIGNED_NORMALIZED */ - { 31360, 0x000081F9 }, /* GL_SINGLE_COLOR */ - { 31376, 0x000081F9 }, /* GL_SINGLE_COLOR_EXT */ - { 31396, 0x000085CC }, /* GL_SLICE_ACCUM_SUN */ - { 31415, 0x00008C46 }, /* GL_SLUMINANCE */ - { 31429, 0x00008C47 }, /* GL_SLUMINANCE8 */ - { 31444, 0x00008C45 }, /* GL_SLUMINANCE8_ALPHA8 */ - { 31466, 0x00008C44 }, /* GL_SLUMINANCE_ALPHA */ - { 31486, 0x00001D01 }, /* GL_SMOOTH */ - { 31496, 0x00000B23 }, /* GL_SMOOTH_LINE_WIDTH_GRANULARITY */ - { 31529, 0x00000B22 }, /* GL_SMOOTH_LINE_WIDTH_RANGE */ - { 31556, 0x00000B13 }, /* GL_SMOOTH_POINT_SIZE_GRANULARITY */ - { 31589, 0x00000B12 }, /* GL_SMOOTH_POINT_SIZE_RANGE */ - { 31616, 0x00008588 }, /* GL_SOURCE0_ALPHA */ - { 31633, 0x00008588 }, /* GL_SOURCE0_ALPHA_ARB */ - { 31654, 0x00008588 }, /* GL_SOURCE0_ALPHA_EXT */ - { 31675, 0x00008580 }, /* GL_SOURCE0_RGB */ - { 31690, 0x00008580 }, /* GL_SOURCE0_RGB_ARB */ - { 31709, 0x00008580 }, /* GL_SOURCE0_RGB_EXT */ - { 31728, 0x00008589 }, /* GL_SOURCE1_ALPHA */ - { 31745, 0x00008589 }, /* GL_SOURCE1_ALPHA_ARB */ - { 31766, 0x00008589 }, /* GL_SOURCE1_ALPHA_EXT */ - { 31787, 0x00008581 }, /* GL_SOURCE1_RGB */ - { 31802, 0x00008581 }, /* GL_SOURCE1_RGB_ARB */ - { 31821, 0x00008581 }, /* GL_SOURCE1_RGB_EXT */ - { 31840, 0x0000858A }, /* GL_SOURCE2_ALPHA */ - { 31857, 0x0000858A }, /* GL_SOURCE2_ALPHA_ARB */ - { 31878, 0x0000858A }, /* GL_SOURCE2_ALPHA_EXT */ - { 31899, 0x00008582 }, /* GL_SOURCE2_RGB */ - { 31914, 0x00008582 }, /* GL_SOURCE2_RGB_ARB */ - { 31933, 0x00008582 }, /* GL_SOURCE2_RGB_EXT */ - { 31952, 0x0000858B }, /* GL_SOURCE3_ALPHA_NV */ - { 31972, 0x00008583 }, /* GL_SOURCE3_RGB_NV */ - { 31990, 0x00001202 }, /* GL_SPECULAR */ - { 32002, 0x00002402 }, /* GL_SPHERE_MAP */ - { 32016, 0x00001206 }, /* GL_SPOT_CUTOFF */ - { 32031, 0x00001204 }, /* GL_SPOT_DIRECTION */ - { 32049, 0x00001205 }, /* GL_SPOT_EXPONENT */ - { 32066, 0x00008588 }, /* GL_SRC0_ALPHA */ - { 32080, 0x00008580 }, /* GL_SRC0_RGB */ - { 32092, 0x00008589 }, /* GL_SRC1_ALPHA */ - { 32106, 0x00008581 }, /* GL_SRC1_RGB */ - { 32118, 0x0000858A }, /* GL_SRC2_ALPHA */ - { 32132, 0x00008582 }, /* GL_SRC2_RGB */ - { 32144, 0x00000302 }, /* GL_SRC_ALPHA */ - { 32157, 0x00000308 }, /* GL_SRC_ALPHA_SATURATE */ - { 32179, 0x00000300 }, /* GL_SRC_COLOR */ - { 32192, 0x00008C40 }, /* GL_SRGB */ - { 32200, 0x00008C41 }, /* GL_SRGB8 */ - { 32209, 0x00008C43 }, /* GL_SRGB8_ALPHA8 */ - { 32225, 0x00008C42 }, /* GL_SRGB_ALPHA */ - { 32239, 0x00000503 }, /* GL_STACK_OVERFLOW */ - { 32257, 0x00000504 }, /* GL_STACK_UNDERFLOW */ - { 32276, 0x000088E6 }, /* GL_STATIC_COPY */ - { 32291, 0x000088E6 }, /* GL_STATIC_COPY_ARB */ - { 32310, 0x000088E4 }, /* GL_STATIC_DRAW */ - { 32325, 0x000088E4 }, /* GL_STATIC_DRAW_ARB */ - { 32344, 0x000088E5 }, /* GL_STATIC_READ */ - { 32359, 0x000088E5 }, /* GL_STATIC_READ_ARB */ - { 32378, 0x00001802 }, /* GL_STENCIL */ - { 32389, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT */ - { 32411, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT_EXT */ - { 32437, 0x00008801 }, /* GL_STENCIL_BACK_FAIL */ - { 32458, 0x00008801 }, /* GL_STENCIL_BACK_FAIL_ATI */ - { 32483, 0x00008800 }, /* GL_STENCIL_BACK_FUNC */ - { 32504, 0x00008800 }, /* GL_STENCIL_BACK_FUNC_ATI */ - { 32529, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */ - { 32561, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI */ - { 32597, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */ - { 32629, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI */ - { 32665, 0x00008CA3 }, /* GL_STENCIL_BACK_REF */ - { 32685, 0x00008CA4 }, /* GL_STENCIL_BACK_VALUE_MASK */ - { 32712, 0x00008CA5 }, /* GL_STENCIL_BACK_WRITEMASK */ - { 32738, 0x00000D57 }, /* GL_STENCIL_BITS */ - { 32754, 0x00000400 }, /* GL_STENCIL_BUFFER_BIT */ - { 32776, 0x00000B91 }, /* GL_STENCIL_CLEAR_VALUE */ - { 32799, 0x00000B94 }, /* GL_STENCIL_FAIL */ - { 32815, 0x00000B92 }, /* GL_STENCIL_FUNC */ - { 32831, 0x00001901 }, /* GL_STENCIL_INDEX */ - { 32848, 0x00008D46 }, /* GL_STENCIL_INDEX1 */ - { 32866, 0x00008D49 }, /* GL_STENCIL_INDEX16 */ - { 32885, 0x00008D49 }, /* GL_STENCIL_INDEX16_EXT */ - { 32908, 0x00008D46 }, /* GL_STENCIL_INDEX1_EXT */ - { 32930, 0x00008D47 }, /* GL_STENCIL_INDEX4 */ - { 32948, 0x00008D47 }, /* GL_STENCIL_INDEX4_EXT */ - { 32970, 0x00008D48 }, /* GL_STENCIL_INDEX8 */ - { 32988, 0x00008D48 }, /* GL_STENCIL_INDEX8_EXT */ - { 33010, 0x00008D45 }, /* GL_STENCIL_INDEX_EXT */ - { 33031, 0x00000B95 }, /* GL_STENCIL_PASS_DEPTH_FAIL */ - { 33058, 0x00000B96 }, /* GL_STENCIL_PASS_DEPTH_PASS */ - { 33085, 0x00000B97 }, /* GL_STENCIL_REF */ - { 33100, 0x00000B90 }, /* GL_STENCIL_TEST */ - { 33116, 0x00008910 }, /* GL_STENCIL_TEST_TWO_SIDE_EXT */ - { 33145, 0x00000B93 }, /* GL_STENCIL_VALUE_MASK */ - { 33167, 0x00000B98 }, /* GL_STENCIL_WRITEMASK */ - { 33188, 0x00000C33 }, /* GL_STEREO */ - { 33198, 0x000085BE }, /* GL_STORAGE_CACHED_APPLE */ - { 33222, 0x000085BD }, /* GL_STORAGE_PRIVATE_APPLE */ - { 33247, 0x000085BF }, /* GL_STORAGE_SHARED_APPLE */ - { 33271, 0x000088E2 }, /* GL_STREAM_COPY */ - { 33286, 0x000088E2 }, /* GL_STREAM_COPY_ARB */ - { 33305, 0x000088E0 }, /* GL_STREAM_DRAW */ - { 33320, 0x000088E0 }, /* GL_STREAM_DRAW_ARB */ - { 33339, 0x000088E1 }, /* GL_STREAM_READ */ - { 33354, 0x000088E1 }, /* GL_STREAM_READ_ARB */ - { 33373, 0x00000D50 }, /* GL_SUBPIXEL_BITS */ - { 33390, 0x000084E7 }, /* GL_SUBTRACT */ - { 33402, 0x000084E7 }, /* GL_SUBTRACT_ARB */ - { 33418, 0x00009113 }, /* GL_SYNC_CONDITION */ - { 33436, 0x00009116 }, /* GL_SYNC_FENCE */ - { 33450, 0x00009115 }, /* GL_SYNC_FLAGS */ - { 33464, 0x00000001 }, /* GL_SYNC_FLUSH_COMMANDS_BIT */ - { 33491, 0x00009117 }, /* GL_SYNC_GPU_COMMANDS_COMPLETE */ - { 33521, 0x00009114 }, /* GL_SYNC_STATUS */ - { 33536, 0x00002001 }, /* GL_T */ - { 33541, 0x00002A2A }, /* GL_T2F_C3F_V3F */ - { 33556, 0x00002A2C }, /* GL_T2F_C4F_N3F_V3F */ - { 33575, 0x00002A29 }, /* GL_T2F_C4UB_V3F */ - { 33591, 0x00002A2B }, /* GL_T2F_N3F_V3F */ - { 33606, 0x00002A27 }, /* GL_T2F_V3F */ - { 33617, 0x00002A2D }, /* GL_T4F_C4F_N3F_V4F */ - { 33636, 0x00002A28 }, /* GL_T4F_V4F */ - { 33647, 0x00008031 }, /* GL_TABLE_TOO_LARGE_EXT */ - { 33670, 0x00001702 }, /* GL_TEXTURE */ - { 33681, 0x000084C0 }, /* GL_TEXTURE0 */ - { 33693, 0x000084C0 }, /* GL_TEXTURE0_ARB */ - { 33709, 0x000084C1 }, /* GL_TEXTURE1 */ - { 33721, 0x000084CA }, /* GL_TEXTURE10 */ - { 33734, 0x000084CA }, /* GL_TEXTURE10_ARB */ - { 33751, 0x000084CB }, /* GL_TEXTURE11 */ - { 33764, 0x000084CB }, /* GL_TEXTURE11_ARB */ - { 33781, 0x000084CC }, /* GL_TEXTURE12 */ - { 33794, 0x000084CC }, /* GL_TEXTURE12_ARB */ - { 33811, 0x000084CD }, /* GL_TEXTURE13 */ - { 33824, 0x000084CD }, /* GL_TEXTURE13_ARB */ - { 33841, 0x000084CE }, /* GL_TEXTURE14 */ - { 33854, 0x000084CE }, /* GL_TEXTURE14_ARB */ - { 33871, 0x000084CF }, /* GL_TEXTURE15 */ - { 33884, 0x000084CF }, /* GL_TEXTURE15_ARB */ - { 33901, 0x000084D0 }, /* GL_TEXTURE16 */ - { 33914, 0x000084D0 }, /* GL_TEXTURE16_ARB */ - { 33931, 0x000084D1 }, /* GL_TEXTURE17 */ - { 33944, 0x000084D1 }, /* GL_TEXTURE17_ARB */ - { 33961, 0x000084D2 }, /* GL_TEXTURE18 */ - { 33974, 0x000084D2 }, /* GL_TEXTURE18_ARB */ - { 33991, 0x000084D3 }, /* GL_TEXTURE19 */ - { 34004, 0x000084D3 }, /* GL_TEXTURE19_ARB */ - { 34021, 0x000084C1 }, /* GL_TEXTURE1_ARB */ - { 34037, 0x000084C2 }, /* GL_TEXTURE2 */ - { 34049, 0x000084D4 }, /* GL_TEXTURE20 */ - { 34062, 0x000084D4 }, /* GL_TEXTURE20_ARB */ - { 34079, 0x000084D5 }, /* GL_TEXTURE21 */ - { 34092, 0x000084D5 }, /* GL_TEXTURE21_ARB */ - { 34109, 0x000084D6 }, /* GL_TEXTURE22 */ - { 34122, 0x000084D6 }, /* GL_TEXTURE22_ARB */ - { 34139, 0x000084D7 }, /* GL_TEXTURE23 */ - { 34152, 0x000084D7 }, /* GL_TEXTURE23_ARB */ - { 34169, 0x000084D8 }, /* GL_TEXTURE24 */ - { 34182, 0x000084D8 }, /* GL_TEXTURE24_ARB */ - { 34199, 0x000084D9 }, /* GL_TEXTURE25 */ - { 34212, 0x000084D9 }, /* GL_TEXTURE25_ARB */ - { 34229, 0x000084DA }, /* GL_TEXTURE26 */ - { 34242, 0x000084DA }, /* GL_TEXTURE26_ARB */ - { 34259, 0x000084DB }, /* GL_TEXTURE27 */ - { 34272, 0x000084DB }, /* GL_TEXTURE27_ARB */ - { 34289, 0x000084DC }, /* GL_TEXTURE28 */ - { 34302, 0x000084DC }, /* GL_TEXTURE28_ARB */ - { 34319, 0x000084DD }, /* GL_TEXTURE29 */ - { 34332, 0x000084DD }, /* GL_TEXTURE29_ARB */ - { 34349, 0x000084C2 }, /* GL_TEXTURE2_ARB */ - { 34365, 0x000084C3 }, /* GL_TEXTURE3 */ - { 34377, 0x000084DE }, /* GL_TEXTURE30 */ - { 34390, 0x000084DE }, /* GL_TEXTURE30_ARB */ - { 34407, 0x000084DF }, /* GL_TEXTURE31 */ - { 34420, 0x000084DF }, /* GL_TEXTURE31_ARB */ - { 34437, 0x000084C3 }, /* GL_TEXTURE3_ARB */ - { 34453, 0x000084C4 }, /* GL_TEXTURE4 */ - { 34465, 0x000084C4 }, /* GL_TEXTURE4_ARB */ - { 34481, 0x000084C5 }, /* GL_TEXTURE5 */ - { 34493, 0x000084C5 }, /* GL_TEXTURE5_ARB */ - { 34509, 0x000084C6 }, /* GL_TEXTURE6 */ - { 34521, 0x000084C6 }, /* GL_TEXTURE6_ARB */ - { 34537, 0x000084C7 }, /* GL_TEXTURE7 */ - { 34549, 0x000084C7 }, /* GL_TEXTURE7_ARB */ - { 34565, 0x000084C8 }, /* GL_TEXTURE8 */ - { 34577, 0x000084C8 }, /* GL_TEXTURE8_ARB */ - { 34593, 0x000084C9 }, /* GL_TEXTURE9 */ - { 34605, 0x000084C9 }, /* GL_TEXTURE9_ARB */ - { 34621, 0x00000DE0 }, /* GL_TEXTURE_1D */ - { 34635, 0x00008C18 }, /* GL_TEXTURE_1D_ARRAY_EXT */ - { 34659, 0x00000DE1 }, /* GL_TEXTURE_2D */ - { 34673, 0x00008C1A }, /* GL_TEXTURE_2D_ARRAY_EXT */ - { 34697, 0x0000806F }, /* GL_TEXTURE_3D */ - { 34711, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE */ - { 34733, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE_EXT */ - { 34759, 0x0000813C }, /* GL_TEXTURE_BASE_LEVEL */ - { 34781, 0x00008068 }, /* GL_TEXTURE_BINDING_1D */ - { 34803, 0x00008C1C }, /* GL_TEXTURE_BINDING_1D_ARRAY_EXT */ - { 34835, 0x00008069 }, /* GL_TEXTURE_BINDING_2D */ - { 34857, 0x00008C1D }, /* GL_TEXTURE_BINDING_2D_ARRAY_EXT */ - { 34889, 0x0000806A }, /* GL_TEXTURE_BINDING_3D */ - { 34911, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP */ - { 34939, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP_ARB */ - { 34971, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */ - { 35004, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_NV */ - { 35036, 0x00040000 }, /* GL_TEXTURE_BIT */ - { 35051, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE */ - { 35072, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE_EXT */ - { 35097, 0x00001005 }, /* GL_TEXTURE_BORDER */ - { 35115, 0x00001004 }, /* GL_TEXTURE_BORDER_COLOR */ - { 35139, 0x00008171 }, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */ - { 35170, 0x00008176 }, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */ - { 35200, 0x00008172 }, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */ - { 35230, 0x00008175 }, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */ - { 35265, 0x00008173 }, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */ - { 35296, 0x00008174 }, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */ - { 35334, 0x000080BC }, /* GL_TEXTURE_COLOR_TABLE_SGI */ - { 35361, 0x000081EF }, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */ - { 35393, 0x000080BF }, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */ - { 35427, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC */ - { 35451, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC_ARB */ - { 35479, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE */ - { 35503, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE_ARB */ - { 35531, 0x0000819B }, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */ - { 35564, 0x0000819A }, /* GL_TEXTURE_COMPARE_SGIX */ - { 35588, 0x00001003 }, /* GL_TEXTURE_COMPONENTS */ - { 35610, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED */ - { 35632, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED_ARB */ - { 35658, 0x000086A3 }, /* GL_TEXTURE_COMPRESSED_FORMATS_ARB */ - { 35692, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */ - { 35725, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB */ - { 35762, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT */ - { 35790, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT_ARB */ - { 35822, 0x00008078 }, /* GL_TEXTURE_COORD_ARRAY */ - { 35845, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */ - { 35883, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB */ - { 35925, 0x00008092 }, /* GL_TEXTURE_COORD_ARRAY_POINTER */ - { 35956, 0x00008088 }, /* GL_TEXTURE_COORD_ARRAY_SIZE */ - { 35984, 0x0000808A }, /* GL_TEXTURE_COORD_ARRAY_STRIDE */ - { 36014, 0x00008089 }, /* GL_TEXTURE_COORD_ARRAY_TYPE */ - { 36042, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP */ - { 36062, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP_ARB */ - { 36086, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */ - { 36117, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB */ - { 36152, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */ - { 36183, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB */ - { 36218, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */ - { 36249, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB */ - { 36284, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */ - { 36315, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB */ - { 36350, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */ - { 36381, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB */ - { 36416, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */ - { 36447, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB */ - { 36482, 0x000088F4 }, /* GL_TEXTURE_CUBE_MAP_SEAMLESS */ - { 36511, 0x00008071 }, /* GL_TEXTURE_DEPTH */ - { 36528, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE */ - { 36550, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE_ARB */ - { 36576, 0x00002300 }, /* GL_TEXTURE_ENV */ - { 36591, 0x00002201 }, /* GL_TEXTURE_ENV_COLOR */ - { 36612, 0x00002200 }, /* GL_TEXTURE_ENV_MODE */ - { 36632, 0x00008500 }, /* GL_TEXTURE_FILTER_CONTROL */ - { 36658, 0x00002500 }, /* GL_TEXTURE_GEN_MODE */ - { 36678, 0x00000C63 }, /* GL_TEXTURE_GEN_Q */ - { 36695, 0x00000C62 }, /* GL_TEXTURE_GEN_R */ - { 36712, 0x00000C60 }, /* GL_TEXTURE_GEN_S */ - { 36729, 0x00000C61 }, /* GL_TEXTURE_GEN_T */ - { 36746, 0x0000819D }, /* GL_TEXTURE_GEQUAL_R_SGIX */ - { 36771, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE */ - { 36793, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE_EXT */ - { 36819, 0x00001001 }, /* GL_TEXTURE_HEIGHT */ - { 36837, 0x000080ED }, /* GL_TEXTURE_INDEX_SIZE_EXT */ - { 36863, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE */ - { 36889, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE_EXT */ - { 36919, 0x00001003 }, /* GL_TEXTURE_INTERNAL_FORMAT */ - { 36946, 0x0000819C }, /* GL_TEXTURE_LEQUAL_R_SGIX */ - { 36971, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS */ - { 36991, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS_EXT */ - { 37015, 0x00008190 }, /* GL_TEXTURE_LOD_BIAS_R_SGIX */ - { 37042, 0x0000818E }, /* GL_TEXTURE_LOD_BIAS_S_SGIX */ - { 37069, 0x0000818F }, /* GL_TEXTURE_LOD_BIAS_T_SGIX */ - { 37096, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE */ - { 37122, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE_EXT */ - { 37152, 0x00002800 }, /* GL_TEXTURE_MAG_FILTER */ - { 37174, 0x00000BA8 }, /* GL_TEXTURE_MATRIX */ - { 37192, 0x000084FE }, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */ - { 37222, 0x0000836B }, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */ - { 37250, 0x00008369 }, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */ - { 37278, 0x0000836A }, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */ - { 37306, 0x0000813D }, /* GL_TEXTURE_MAX_LEVEL */ - { 37327, 0x0000813B }, /* GL_TEXTURE_MAX_LOD */ - { 37346, 0x00002801 }, /* GL_TEXTURE_MIN_FILTER */ - { 37368, 0x0000813A }, /* GL_TEXTURE_MIN_LOD */ - { 37387, 0x00008066 }, /* GL_TEXTURE_PRIORITY */ - { 37407, 0x000085B7 }, /* GL_TEXTURE_RANGE_LENGTH_APPLE */ - { 37437, 0x000085B8 }, /* GL_TEXTURE_RANGE_POINTER_APPLE */ - { 37468, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_ARB */ - { 37493, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_NV */ - { 37517, 0x0000805C }, /* GL_TEXTURE_RED_SIZE */ - { 37537, 0x0000805C }, /* GL_TEXTURE_RED_SIZE_EXT */ - { 37561, 0x00008067 }, /* GL_TEXTURE_RESIDENT */ - { 37581, 0x00000BA5 }, /* GL_TEXTURE_STACK_DEPTH */ - { 37604, 0x000088F1 }, /* GL_TEXTURE_STENCIL_SIZE */ - { 37628, 0x000088F1 }, /* GL_TEXTURE_STENCIL_SIZE_EXT */ - { 37656, 0x000085BC }, /* GL_TEXTURE_STORAGE_HINT_APPLE */ - { 37686, 0x00008065 }, /* GL_TEXTURE_TOO_LARGE_EXT */ - { 37711, 0x0000888F }, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */ - { 37745, 0x00001000 }, /* GL_TEXTURE_WIDTH */ - { 37762, 0x00008072 }, /* GL_TEXTURE_WRAP_R */ - { 37780, 0x00002802 }, /* GL_TEXTURE_WRAP_S */ - { 37798, 0x00002803 }, /* GL_TEXTURE_WRAP_T */ - { 37816, 0x0000911B }, /* GL_TIMEOUT_EXPIRED */ - { 37835, 0x000088BF }, /* GL_TIME_ELAPSED_EXT */ - { 37855, 0x00008648 }, /* GL_TRACK_MATRIX_NV */ - { 37874, 0x00008649 }, /* GL_TRACK_MATRIX_TRANSFORM_NV */ - { 37903, 0x00001000 }, /* GL_TRANSFORM_BIT */ - { 37920, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX */ - { 37946, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX_ARB */ - { 37976, 0x000088B7 }, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */ - { 38008, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX */ - { 38038, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX_ARB */ - { 38072, 0x0000862C }, /* GL_TRANSPOSE_NV */ - { 38088, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX */ - { 38119, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX_ARB */ - { 38154, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX */ - { 38182, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX_ARB */ - { 38214, 0x00000004 }, /* GL_TRIANGLES */ - { 38227, 0x00000006 }, /* GL_TRIANGLE_FAN */ - { 38243, 0x00008615 }, /* GL_TRIANGLE_MESH_SUN */ - { 38264, 0x00000005 }, /* GL_TRIANGLE_STRIP */ - { 38282, 0x00000001 }, /* GL_TRUE */ - { 38290, 0x00000CF5 }, /* GL_UNPACK_ALIGNMENT */ - { 38310, 0x0000806E }, /* GL_UNPACK_IMAGE_HEIGHT */ - { 38333, 0x00000CF1 }, /* GL_UNPACK_LSB_FIRST */ - { 38353, 0x00000CF2 }, /* GL_UNPACK_ROW_LENGTH */ - { 38374, 0x0000806D }, /* GL_UNPACK_SKIP_IMAGES */ - { 38396, 0x00000CF4 }, /* GL_UNPACK_SKIP_PIXELS */ - { 38418, 0x00000CF3 }, /* GL_UNPACK_SKIP_ROWS */ - { 38438, 0x00000CF0 }, /* GL_UNPACK_SWAP_BYTES */ - { 38459, 0x00009118 }, /* GL_UNSIGNALED */ - { 38473, 0x00001401 }, /* GL_UNSIGNED_BYTE */ - { 38490, 0x00008362 }, /* GL_UNSIGNED_BYTE_2_3_3_REV */ - { 38517, 0x00008032 }, /* GL_UNSIGNED_BYTE_3_3_2 */ - { 38540, 0x00001405 }, /* GL_UNSIGNED_INT */ - { 38556, 0x00008036 }, /* GL_UNSIGNED_INT_10_10_10_2 */ - { 38583, 0x000084FA }, /* GL_UNSIGNED_INT_24_8 */ - { 38604, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_EXT */ - { 38629, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_NV */ - { 38653, 0x00008368 }, /* GL_UNSIGNED_INT_2_10_10_10_REV */ - { 38684, 0x00008035 }, /* GL_UNSIGNED_INT_8_8_8_8 */ - { 38708, 0x00008367 }, /* GL_UNSIGNED_INT_8_8_8_8_REV */ - { 38736, 0x00008C17 }, /* GL_UNSIGNED_NORMALIZED */ - { 38759, 0x00001403 }, /* GL_UNSIGNED_SHORT */ - { 38777, 0x00008366 }, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */ - { 38807, 0x00008033 }, /* GL_UNSIGNED_SHORT_4_4_4_4 */ - { 38833, 0x00008365 }, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */ - { 38863, 0x00008034 }, /* GL_UNSIGNED_SHORT_5_5_5_1 */ - { 38889, 0x00008363 }, /* GL_UNSIGNED_SHORT_5_6_5 */ - { 38913, 0x00008364 }, /* GL_UNSIGNED_SHORT_5_6_5_REV */ - { 38941, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_APPLE */ - { 38969, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_MESA */ - { 38996, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */ - { 39028, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_MESA */ - { 39059, 0x00008CA2 }, /* GL_UPPER_LEFT */ - { 39073, 0x00002A20 }, /* GL_V2F */ - { 39080, 0x00002A21 }, /* GL_V3F */ - { 39087, 0x00008B83 }, /* GL_VALIDATE_STATUS */ - { 39106, 0x00001F00 }, /* GL_VENDOR */ - { 39116, 0x00001F02 }, /* GL_VERSION */ - { 39127, 0x00008074 }, /* GL_VERTEX_ARRAY */ - { 39143, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING */ - { 39167, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING_APPLE */ - { 39197, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING */ - { 39228, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING_ARB */ - { 39263, 0x0000808E }, /* GL_VERTEX_ARRAY_POINTER */ - { 39287, 0x0000807A }, /* GL_VERTEX_ARRAY_SIZE */ - { 39308, 0x0000807C }, /* GL_VERTEX_ARRAY_STRIDE */ - { 39331, 0x0000807B }, /* GL_VERTEX_ARRAY_TYPE */ - { 39352, 0x00008650 }, /* GL_VERTEX_ATTRIB_ARRAY0_NV */ - { 39379, 0x0000865A }, /* GL_VERTEX_ATTRIB_ARRAY10_NV */ - { 39407, 0x0000865B }, /* GL_VERTEX_ATTRIB_ARRAY11_NV */ - { 39435, 0x0000865C }, /* GL_VERTEX_ATTRIB_ARRAY12_NV */ - { 39463, 0x0000865D }, /* GL_VERTEX_ATTRIB_ARRAY13_NV */ - { 39491, 0x0000865E }, /* GL_VERTEX_ATTRIB_ARRAY14_NV */ - { 39519, 0x0000865F }, /* GL_VERTEX_ATTRIB_ARRAY15_NV */ - { 39547, 0x00008651 }, /* GL_VERTEX_ATTRIB_ARRAY1_NV */ - { 39574, 0x00008652 }, /* GL_VERTEX_ATTRIB_ARRAY2_NV */ - { 39601, 0x00008653 }, /* GL_VERTEX_ATTRIB_ARRAY3_NV */ - { 39628, 0x00008654 }, /* GL_VERTEX_ATTRIB_ARRAY4_NV */ - { 39655, 0x00008655 }, /* GL_VERTEX_ATTRIB_ARRAY5_NV */ - { 39682, 0x00008656 }, /* GL_VERTEX_ATTRIB_ARRAY6_NV */ - { 39709, 0x00008657 }, /* GL_VERTEX_ATTRIB_ARRAY7_NV */ - { 39736, 0x00008658 }, /* GL_VERTEX_ATTRIB_ARRAY8_NV */ - { 39763, 0x00008659 }, /* GL_VERTEX_ATTRIB_ARRAY9_NV */ - { 39790, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */ - { 39828, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB */ - { 39870, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */ - { 39901, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB */ - { 39936, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */ - { 39970, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB */ - { 40008, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */ - { 40039, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB */ - { 40074, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */ - { 40102, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB */ - { 40134, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */ - { 40164, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB */ - { 40198, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */ - { 40226, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB */ - { 40258, 0x000086A7 }, /* GL_VERTEX_BLEND_ARB */ - { 40278, 0x00008620 }, /* GL_VERTEX_PROGRAM_ARB */ - { 40300, 0x0000864A }, /* GL_VERTEX_PROGRAM_BINDING_NV */ - { 40329, 0x00008620 }, /* GL_VERTEX_PROGRAM_NV */ - { 40350, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE */ - { 40379, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_ARB */ - { 40412, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_NV */ - { 40444, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE */ - { 40471, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_ARB */ - { 40502, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_NV */ - { 40532, 0x00008B31 }, /* GL_VERTEX_SHADER */ - { 40549, 0x00008B31 }, /* GL_VERTEX_SHADER_ARB */ - { 40570, 0x00008621 }, /* GL_VERTEX_STATE_PROGRAM_NV */ - { 40597, 0x00000BA2 }, /* GL_VIEWPORT */ - { 40609, 0x00000800 }, /* GL_VIEWPORT_BIT */ - { 40625, 0x0000911D }, /* GL_WAIT_FAILED */ - { 40640, 0x000086AD }, /* GL_WEIGHT_ARRAY_ARB */ - { 40660, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */ - { 40691, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB */ - { 40726, 0x000086AC }, /* GL_WEIGHT_ARRAY_POINTER_ARB */ - { 40754, 0x000086AB }, /* GL_WEIGHT_ARRAY_SIZE_ARB */ - { 40779, 0x000086AA }, /* GL_WEIGHT_ARRAY_STRIDE_ARB */ - { 40806, 0x000086A9 }, /* GL_WEIGHT_ARRAY_TYPE_ARB */ - { 40831, 0x000086A6 }, /* GL_WEIGHT_SUM_UNITY_ARB */ - { 40855, 0x000081D4 }, /* GL_WRAP_BORDER_SUN */ - { 40874, 0x000088B9 }, /* GL_WRITE_ONLY */ - { 40888, 0x000088B9 }, /* GL_WRITE_ONLY_ARB */ - { 40906, 0x00001506 }, /* GL_XOR */ - { 40913, 0x000085B9 }, /* GL_YCBCR_422_APPLE */ - { 40932, 0x00008757 }, /* GL_YCBCR_MESA */ - { 40946, 0x00000000 }, /* GL_ZERO */ - { 40954, 0x00000D16 }, /* GL_ZOOM_X */ - { 40964, 0x00000D17 }, /* GL_ZOOM_Y */ + { 12812, 0x0000140B }, /* GL_HALF_FLOAT */ + { 12826, 0x00008000 }, /* GL_HINT_BIT */ + { 12838, 0x00008024 }, /* GL_HISTOGRAM */ + { 12851, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE */ + { 12875, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE_EXT */ + { 12903, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE */ + { 12926, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE_EXT */ + { 12953, 0x00008024 }, /* GL_HISTOGRAM_EXT */ + { 12970, 0x00008027 }, /* GL_HISTOGRAM_FORMAT */ + { 12990, 0x00008027 }, /* GL_HISTOGRAM_FORMAT_EXT */ + { 13014, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE */ + { 13038, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE_EXT */ + { 13066, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE */ + { 13094, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE_EXT */ + { 13126, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE */ + { 13148, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE_EXT */ + { 13174, 0x0000802D }, /* GL_HISTOGRAM_SINK */ + { 13192, 0x0000802D }, /* GL_HISTOGRAM_SINK_EXT */ + { 13214, 0x00008026 }, /* GL_HISTOGRAM_WIDTH */ + { 13233, 0x00008026 }, /* GL_HISTOGRAM_WIDTH_EXT */ + { 13256, 0x0000862A }, /* GL_IDENTITY_NV */ + { 13271, 0x00008150 }, /* GL_IGNORE_BORDER_HP */ + { 13291, 0x00008B9B }, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */ + { 13331, 0x00008B9A }, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */ + { 13369, 0x00001E02 }, /* GL_INCR */ + { 13377, 0x00008507 }, /* GL_INCR_WRAP */ + { 13390, 0x00008507 }, /* GL_INCR_WRAP_EXT */ + { 13407, 0x00008222 }, /* GL_INDEX */ + { 13416, 0x00008077 }, /* GL_INDEX_ARRAY */ + { 13431, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING */ + { 13461, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING_ARB */ + { 13495, 0x00008091 }, /* GL_INDEX_ARRAY_POINTER */ + { 13518, 0x00008086 }, /* GL_INDEX_ARRAY_STRIDE */ + { 13540, 0x00008085 }, /* GL_INDEX_ARRAY_TYPE */ + { 13560, 0x00000D51 }, /* GL_INDEX_BITS */ + { 13574, 0x00000C20 }, /* GL_INDEX_CLEAR_VALUE */ + { 13595, 0x00000BF1 }, /* GL_INDEX_LOGIC_OP */ + { 13613, 0x00000C30 }, /* GL_INDEX_MODE */ + { 13627, 0x00000D13 }, /* GL_INDEX_OFFSET */ + { 13643, 0x00000D12 }, /* GL_INDEX_SHIFT */ + { 13658, 0x00000C21 }, /* GL_INDEX_WRITEMASK */ + { 13677, 0x00008B84 }, /* GL_INFO_LOG_LENGTH */ + { 13696, 0x00001404 }, /* GL_INT */ + { 13703, 0x00008049 }, /* GL_INTENSITY */ + { 13716, 0x0000804C }, /* GL_INTENSITY12 */ + { 13731, 0x0000804C }, /* GL_INTENSITY12_EXT */ + { 13750, 0x0000804D }, /* GL_INTENSITY16 */ + { 13765, 0x0000804D }, /* GL_INTENSITY16_EXT */ + { 13784, 0x0000804A }, /* GL_INTENSITY4 */ + { 13798, 0x0000804A }, /* GL_INTENSITY4_EXT */ + { 13816, 0x0000804B }, /* GL_INTENSITY8 */ + { 13830, 0x0000804B }, /* GL_INTENSITY8_EXT */ + { 13848, 0x00008049 }, /* GL_INTENSITY_EXT */ + { 13865, 0x00008575 }, /* GL_INTERPOLATE */ + { 13880, 0x00008575 }, /* GL_INTERPOLATE_ARB */ + { 13899, 0x00008575 }, /* GL_INTERPOLATE_EXT */ + { 13918, 0x00008B53 }, /* GL_INT_VEC2 */ + { 13930, 0x00008B53 }, /* GL_INT_VEC2_ARB */ + { 13946, 0x00008B54 }, /* GL_INT_VEC3 */ + { 13958, 0x00008B54 }, /* GL_INT_VEC3_ARB */ + { 13974, 0x00008B55 }, /* GL_INT_VEC4 */ + { 13986, 0x00008B55 }, /* GL_INT_VEC4_ARB */ + { 14002, 0x00000500 }, /* GL_INVALID_ENUM */ + { 14018, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION */ + { 14051, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION_EXT */ + { 14088, 0x00000502 }, /* GL_INVALID_OPERATION */ + { 14109, 0x00000501 }, /* GL_INVALID_VALUE */ + { 14126, 0x0000862B }, /* GL_INVERSE_NV */ + { 14140, 0x0000862D }, /* GL_INVERSE_TRANSPOSE_NV */ + { 14164, 0x0000150A }, /* GL_INVERT */ + { 14174, 0x00001E00 }, /* GL_KEEP */ + { 14182, 0x00008E4E }, /* GL_LAST_VERTEX_CONVENTION */ + { 14208, 0x00008E4E }, /* GL_LAST_VERTEX_CONVENTION_EXT */ + { 14238, 0x00000406 }, /* GL_LEFT */ + { 14246, 0x00000203 }, /* GL_LEQUAL */ + { 14256, 0x00000201 }, /* GL_LESS */ + { 14264, 0x00004000 }, /* GL_LIGHT0 */ + { 14274, 0x00004001 }, /* GL_LIGHT1 */ + { 14284, 0x00004002 }, /* GL_LIGHT2 */ + { 14294, 0x00004003 }, /* GL_LIGHT3 */ + { 14304, 0x00004004 }, /* GL_LIGHT4 */ + { 14314, 0x00004005 }, /* GL_LIGHT5 */ + { 14324, 0x00004006 }, /* GL_LIGHT6 */ + { 14334, 0x00004007 }, /* GL_LIGHT7 */ + { 14344, 0x00000B50 }, /* GL_LIGHTING */ + { 14356, 0x00000040 }, /* GL_LIGHTING_BIT */ + { 14372, 0x00000B53 }, /* GL_LIGHT_MODEL_AMBIENT */ + { 14395, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL */ + { 14424, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL_EXT */ + { 14457, 0x00000B51 }, /* GL_LIGHT_MODEL_LOCAL_VIEWER */ + { 14485, 0x00000B52 }, /* GL_LIGHT_MODEL_TWO_SIDE */ + { 14509, 0x00001B01 }, /* GL_LINE */ + { 14517, 0x00002601 }, /* GL_LINEAR */ + { 14527, 0x00001208 }, /* GL_LINEAR_ATTENUATION */ + { 14549, 0x00008170 }, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */ + { 14579, 0x0000844F }, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */ + { 14610, 0x00002703 }, /* GL_LINEAR_MIPMAP_LINEAR */ + { 14634, 0x00002701 }, /* GL_LINEAR_MIPMAP_NEAREST */ + { 14659, 0x00000001 }, /* GL_LINES */ + { 14668, 0x00000004 }, /* GL_LINE_BIT */ + { 14680, 0x00000002 }, /* GL_LINE_LOOP */ + { 14693, 0x00000707 }, /* GL_LINE_RESET_TOKEN */ + { 14713, 0x00000B20 }, /* GL_LINE_SMOOTH */ + { 14728, 0x00000C52 }, /* GL_LINE_SMOOTH_HINT */ + { 14748, 0x00000B24 }, /* GL_LINE_STIPPLE */ + { 14764, 0x00000B25 }, /* GL_LINE_STIPPLE_PATTERN */ + { 14788, 0x00000B26 }, /* GL_LINE_STIPPLE_REPEAT */ + { 14811, 0x00000003 }, /* GL_LINE_STRIP */ + { 14825, 0x00000702 }, /* GL_LINE_TOKEN */ + { 14839, 0x00000B21 }, /* GL_LINE_WIDTH */ + { 14853, 0x00000B23 }, /* GL_LINE_WIDTH_GRANULARITY */ + { 14879, 0x00000B22 }, /* GL_LINE_WIDTH_RANGE */ + { 14899, 0x00008B82 }, /* GL_LINK_STATUS */ + { 14914, 0x00000B32 }, /* GL_LIST_BASE */ + { 14927, 0x00020000 }, /* GL_LIST_BIT */ + { 14939, 0x00000B33 }, /* GL_LIST_INDEX */ + { 14953, 0x00000B30 }, /* GL_LIST_MODE */ + { 14966, 0x00000101 }, /* GL_LOAD */ + { 14974, 0x00000BF1 }, /* GL_LOGIC_OP */ + { 14986, 0x00000BF0 }, /* GL_LOGIC_OP_MODE */ + { 15003, 0x00008CA1 }, /* GL_LOWER_LEFT */ + { 15017, 0x00001909 }, /* GL_LUMINANCE */ + { 15030, 0x00008041 }, /* GL_LUMINANCE12 */ + { 15045, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12 */ + { 15068, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12_EXT */ + { 15095, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4 */ + { 15117, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4_EXT */ + { 15143, 0x00008041 }, /* GL_LUMINANCE12_EXT */ + { 15162, 0x00008042 }, /* GL_LUMINANCE16 */ + { 15177, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16 */ + { 15200, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16_EXT */ + { 15227, 0x00008042 }, /* GL_LUMINANCE16_EXT */ + { 15246, 0x0000803F }, /* GL_LUMINANCE4 */ + { 15260, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4 */ + { 15281, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4_EXT */ + { 15306, 0x0000803F }, /* GL_LUMINANCE4_EXT */ + { 15324, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2 */ + { 15345, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2_EXT */ + { 15370, 0x00008040 }, /* GL_LUMINANCE8 */ + { 15384, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8 */ + { 15405, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8_EXT */ + { 15430, 0x00008040 }, /* GL_LUMINANCE8_EXT */ + { 15448, 0x0000190A }, /* GL_LUMINANCE_ALPHA */ + { 15467, 0x00000D90 }, /* GL_MAP1_COLOR_4 */ + { 15483, 0x00000DD0 }, /* GL_MAP1_GRID_DOMAIN */ + { 15503, 0x00000DD1 }, /* GL_MAP1_GRID_SEGMENTS */ + { 15525, 0x00000D91 }, /* GL_MAP1_INDEX */ + { 15539, 0x00000D92 }, /* GL_MAP1_NORMAL */ + { 15554, 0x00000D93 }, /* GL_MAP1_TEXTURE_COORD_1 */ + { 15578, 0x00000D94 }, /* GL_MAP1_TEXTURE_COORD_2 */ + { 15602, 0x00000D95 }, /* GL_MAP1_TEXTURE_COORD_3 */ + { 15626, 0x00000D96 }, /* GL_MAP1_TEXTURE_COORD_4 */ + { 15650, 0x00000D97 }, /* GL_MAP1_VERTEX_3 */ + { 15667, 0x00000D98 }, /* GL_MAP1_VERTEX_4 */ + { 15684, 0x00008660 }, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */ + { 15712, 0x0000866A }, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */ + { 15741, 0x0000866B }, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */ + { 15770, 0x0000866C }, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */ + { 15799, 0x0000866D }, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */ + { 15828, 0x0000866E }, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */ + { 15857, 0x0000866F }, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */ + { 15886, 0x00008661 }, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */ + { 15914, 0x00008662 }, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */ + { 15942, 0x00008663 }, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */ + { 15970, 0x00008664 }, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */ + { 15998, 0x00008665 }, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */ + { 16026, 0x00008666 }, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */ + { 16054, 0x00008667 }, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */ + { 16082, 0x00008668 }, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */ + { 16110, 0x00008669 }, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */ + { 16138, 0x00000DB0 }, /* GL_MAP2_COLOR_4 */ + { 16154, 0x00000DD2 }, /* GL_MAP2_GRID_DOMAIN */ + { 16174, 0x00000DD3 }, /* GL_MAP2_GRID_SEGMENTS */ + { 16196, 0x00000DB1 }, /* GL_MAP2_INDEX */ + { 16210, 0x00000DB2 }, /* GL_MAP2_NORMAL */ + { 16225, 0x00000DB3 }, /* GL_MAP2_TEXTURE_COORD_1 */ + { 16249, 0x00000DB4 }, /* GL_MAP2_TEXTURE_COORD_2 */ + { 16273, 0x00000DB5 }, /* GL_MAP2_TEXTURE_COORD_3 */ + { 16297, 0x00000DB6 }, /* GL_MAP2_TEXTURE_COORD_4 */ + { 16321, 0x00000DB7 }, /* GL_MAP2_VERTEX_3 */ + { 16338, 0x00000DB8 }, /* GL_MAP2_VERTEX_4 */ + { 16355, 0x00008670 }, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */ + { 16383, 0x0000867A }, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */ + { 16412, 0x0000867B }, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */ + { 16441, 0x0000867C }, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */ + { 16470, 0x0000867D }, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */ + { 16499, 0x0000867E }, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */ + { 16528, 0x0000867F }, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */ + { 16557, 0x00008671 }, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */ + { 16585, 0x00008672 }, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */ + { 16613, 0x00008673 }, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */ + { 16641, 0x00008674 }, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */ + { 16669, 0x00008675 }, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */ + { 16697, 0x00008676 }, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */ + { 16725, 0x00008677 }, /* GL_MAP2_VERTEX_ATTRIB7_4_NV */ + { 16753, 0x00008678 }, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */ + { 16781, 0x00008679 }, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */ + { 16809, 0x00000D10 }, /* GL_MAP_COLOR */ + { 16822, 0x00000010 }, /* GL_MAP_FLUSH_EXPLICIT_BIT */ + { 16848, 0x00000008 }, /* GL_MAP_INVALIDATE_BUFFER_BIT */ + { 16877, 0x00000004 }, /* GL_MAP_INVALIDATE_RANGE_BIT */ + { 16905, 0x00000001 }, /* GL_MAP_READ_BIT */ + { 16921, 0x00000D11 }, /* GL_MAP_STENCIL */ + { 16936, 0x00000020 }, /* GL_MAP_UNSYNCHRONIZED_BIT */ + { 16962, 0x00000002 }, /* GL_MAP_WRITE_BIT */ + { 16979, 0x000088C0 }, /* GL_MATRIX0_ARB */ + { 16994, 0x00008630 }, /* GL_MATRIX0_NV */ + { 17008, 0x000088CA }, /* GL_MATRIX10_ARB */ + { 17024, 0x000088CB }, /* GL_MATRIX11_ARB */ + { 17040, 0x000088CC }, /* GL_MATRIX12_ARB */ + { 17056, 0x000088CD }, /* GL_MATRIX13_ARB */ + { 17072, 0x000088CE }, /* GL_MATRIX14_ARB */ + { 17088, 0x000088CF }, /* GL_MATRIX15_ARB */ + { 17104, 0x000088D0 }, /* GL_MATRIX16_ARB */ + { 17120, 0x000088D1 }, /* GL_MATRIX17_ARB */ + { 17136, 0x000088D2 }, /* GL_MATRIX18_ARB */ + { 17152, 0x000088D3 }, /* GL_MATRIX19_ARB */ + { 17168, 0x000088C1 }, /* GL_MATRIX1_ARB */ + { 17183, 0x00008631 }, /* GL_MATRIX1_NV */ + { 17197, 0x000088D4 }, /* GL_MATRIX20_ARB */ + { 17213, 0x000088D5 }, /* GL_MATRIX21_ARB */ + { 17229, 0x000088D6 }, /* GL_MATRIX22_ARB */ + { 17245, 0x000088D7 }, /* GL_MATRIX23_ARB */ + { 17261, 0x000088D8 }, /* GL_MATRIX24_ARB */ + { 17277, 0x000088D9 }, /* GL_MATRIX25_ARB */ + { 17293, 0x000088DA }, /* GL_MATRIX26_ARB */ + { 17309, 0x000088DB }, /* GL_MATRIX27_ARB */ + { 17325, 0x000088DC }, /* GL_MATRIX28_ARB */ + { 17341, 0x000088DD }, /* GL_MATRIX29_ARB */ + { 17357, 0x000088C2 }, /* GL_MATRIX2_ARB */ + { 17372, 0x00008632 }, /* GL_MATRIX2_NV */ + { 17386, 0x000088DE }, /* GL_MATRIX30_ARB */ + { 17402, 0x000088DF }, /* GL_MATRIX31_ARB */ + { 17418, 0x000088C3 }, /* GL_MATRIX3_ARB */ + { 17433, 0x00008633 }, /* GL_MATRIX3_NV */ + { 17447, 0x000088C4 }, /* GL_MATRIX4_ARB */ + { 17462, 0x00008634 }, /* GL_MATRIX4_NV */ + { 17476, 0x000088C5 }, /* GL_MATRIX5_ARB */ + { 17491, 0x00008635 }, /* GL_MATRIX5_NV */ + { 17505, 0x000088C6 }, /* GL_MATRIX6_ARB */ + { 17520, 0x00008636 }, /* GL_MATRIX6_NV */ + { 17534, 0x000088C7 }, /* GL_MATRIX7_ARB */ + { 17549, 0x00008637 }, /* GL_MATRIX7_NV */ + { 17563, 0x000088C8 }, /* GL_MATRIX8_ARB */ + { 17578, 0x000088C9 }, /* GL_MATRIX9_ARB */ + { 17593, 0x00008844 }, /* GL_MATRIX_INDEX_ARRAY_ARB */ + { 17619, 0x00008849 }, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */ + { 17653, 0x00008846 }, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */ + { 17684, 0x00008848 }, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */ + { 17717, 0x00008847 }, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */ + { 17748, 0x00000BA0 }, /* GL_MATRIX_MODE */ + { 17763, 0x00008840 }, /* GL_MATRIX_PALETTE_ARB */ + { 17785, 0x00008008 }, /* GL_MAX */ + { 17792, 0x00008073 }, /* GL_MAX_3D_TEXTURE_SIZE */ + { 17815, 0x000088FF }, /* GL_MAX_ARRAY_TEXTURE_LAYERS_EXT */ + { 17847, 0x00000D35 }, /* GL_MAX_ATTRIB_STACK_DEPTH */ + { 17873, 0x00000D3B }, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */ + { 17906, 0x00008177 }, /* GL_MAX_CLIPMAP_DEPTH_SGIX */ + { 17932, 0x00008178 }, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */ + { 17966, 0x00000D32 }, /* GL_MAX_CLIP_PLANES */ + { 17985, 0x00008CDF }, /* GL_MAX_COLOR_ATTACHMENTS */ + { 18010, 0x00008CDF }, /* GL_MAX_COLOR_ATTACHMENTS_EXT */ + { 18039, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */ + { 18071, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI */ + { 18107, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */ + { 18143, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB */ + { 18183, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT */ + { 18209, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT_EXT */ + { 18239, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH */ + { 18264, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH_EXT */ + { 18293, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */ + { 18322, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB */ + { 18355, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS */ + { 18375, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ARB */ + { 18399, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ATI */ + { 18423, 0x000080E9 }, /* GL_MAX_ELEMENTS_INDICES */ + { 18447, 0x000080E8 }, /* GL_MAX_ELEMENTS_VERTICES */ + { 18472, 0x00000D30 }, /* GL_MAX_EVAL_ORDER */ + { 18490, 0x00008008 }, /* GL_MAX_EXT */ + { 18501, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */ + { 18536, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB */ + { 18575, 0x00000D31 }, /* GL_MAX_LIGHTS */ + { 18589, 0x00000B31 }, /* GL_MAX_LIST_NESTING */ + { 18609, 0x00008841 }, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */ + { 18647, 0x00000D36 }, /* GL_MAX_MODELVIEW_STACK_DEPTH */ + { 18676, 0x00000D37 }, /* GL_MAX_NAME_STACK_DEPTH */ + { 18700, 0x00008842 }, /* GL_MAX_PALETTE_MATRICES_ARB */ + { 18728, 0x00000D34 }, /* GL_MAX_PIXEL_MAP_TABLE */ + { 18751, 0x000088B1 }, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */ + { 18788, 0x0000880B }, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */ + { 18824, 0x000088AD }, /* GL_MAX_PROGRAM_ATTRIBS_ARB */ + { 18851, 0x000088F5 }, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */ + { 18880, 0x000088B5 }, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */ + { 18914, 0x000088F4 }, /* GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ + { 18950, 0x000088F6 }, /* GL_MAX_PROGRAM_IF_DEPTH_NV */ + { 18977, 0x000088A1 }, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */ + { 19009, 0x000088B4 }, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */ + { 19045, 0x000088F8 }, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */ + { 19074, 0x000088F7 }, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */ + { 19103, 0x0000862F }, /* GL_MAX_PROGRAM_MATRICES_ARB */ + { 19131, 0x0000862E }, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */ + { 19169, 0x000088B3 }, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ + { 19213, 0x0000880E }, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ + { 19256, 0x000088AF }, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */ + { 19290, 0x000088A3 }, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ + { 19329, 0x000088AB }, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */ + { 19366, 0x000088A7 }, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */ + { 19404, 0x00008810 }, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ + { 19447, 0x0000880F }, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ + { 19490, 0x000088A9 }, /* GL_MAX_PROGRAM_PARAMETERS_ARB */ + { 19520, 0x000088A5 }, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */ + { 19551, 0x0000880D }, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */ + { 19587, 0x0000880C }, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */ + { 19623, 0x00000D38 }, /* GL_MAX_PROJECTION_STACK_DEPTH */ + { 19653, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */ + { 19687, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_NV */ + { 19720, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE */ + { 19745, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE_EXT */ + { 19774, 0x00008D57 }, /* GL_MAX_SAMPLES */ + { 19789, 0x00008D57 }, /* GL_MAX_SAMPLES_EXT */ + { 19808, 0x00009111 }, /* GL_MAX_SERVER_WAIT_TIMEOUT */ + { 19835, 0x00008504 }, /* GL_MAX_SHININESS_NV */ + { 19855, 0x00008505 }, /* GL_MAX_SPOT_EXPONENT_NV */ + { 19879, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS */ + { 19901, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS_ARB */ + { 19927, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS */ + { 19954, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS_ARB */ + { 19985, 0x000084FD }, /* GL_MAX_TEXTURE_LOD_BIAS */ + { 20009, 0x000084FF }, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */ + { 20043, 0x00000D33 }, /* GL_MAX_TEXTURE_SIZE */ + { 20063, 0x00000D39 }, /* GL_MAX_TEXTURE_STACK_DEPTH */ + { 20090, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS */ + { 20111, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS_ARB */ + { 20136, 0x0000862F }, /* GL_MAX_TRACK_MATRICES_NV */ + { 20161, 0x0000862E }, /* GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */ + { 20196, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS */ + { 20218, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS_ARB */ + { 20244, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS */ + { 20266, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS_ARB */ + { 20292, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */ + { 20326, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ + { 20364, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */ + { 20397, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB */ + { 20434, 0x000086A4 }, /* GL_MAX_VERTEX_UNITS_ARB */ + { 20458, 0x00000D3A }, /* GL_MAX_VIEWPORT_DIMS */ + { 20479, 0x00008007 }, /* GL_MIN */ + { 20486, 0x0000802E }, /* GL_MINMAX */ + { 20496, 0x0000802E }, /* GL_MINMAX_EXT */ + { 20510, 0x0000802F }, /* GL_MINMAX_FORMAT */ + { 20527, 0x0000802F }, /* GL_MINMAX_FORMAT_EXT */ + { 20548, 0x00008030 }, /* GL_MINMAX_SINK */ + { 20563, 0x00008030 }, /* GL_MINMAX_SINK_EXT */ + { 20582, 0x00008007 }, /* GL_MIN_EXT */ + { 20593, 0x00008370 }, /* GL_MIRRORED_REPEAT */ + { 20612, 0x00008370 }, /* GL_MIRRORED_REPEAT_ARB */ + { 20635, 0x00008370 }, /* GL_MIRRORED_REPEAT_IBM */ + { 20658, 0x00008742 }, /* GL_MIRROR_CLAMP_ATI */ + { 20678, 0x00008742 }, /* GL_MIRROR_CLAMP_EXT */ + { 20698, 0x00008912 }, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */ + { 20728, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_ATI */ + { 20756, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */ + { 20784, 0x00001700 }, /* GL_MODELVIEW */ + { 20797, 0x00001700 }, /* GL_MODELVIEW0_ARB */ + { 20815, 0x0000872A }, /* GL_MODELVIEW10_ARB */ + { 20834, 0x0000872B }, /* GL_MODELVIEW11_ARB */ + { 20853, 0x0000872C }, /* GL_MODELVIEW12_ARB */ + { 20872, 0x0000872D }, /* GL_MODELVIEW13_ARB */ + { 20891, 0x0000872E }, /* GL_MODELVIEW14_ARB */ + { 20910, 0x0000872F }, /* GL_MODELVIEW15_ARB */ + { 20929, 0x00008730 }, /* GL_MODELVIEW16_ARB */ + { 20948, 0x00008731 }, /* GL_MODELVIEW17_ARB */ + { 20967, 0x00008732 }, /* GL_MODELVIEW18_ARB */ + { 20986, 0x00008733 }, /* GL_MODELVIEW19_ARB */ + { 21005, 0x0000850A }, /* GL_MODELVIEW1_ARB */ + { 21023, 0x00008734 }, /* GL_MODELVIEW20_ARB */ + { 21042, 0x00008735 }, /* GL_MODELVIEW21_ARB */ + { 21061, 0x00008736 }, /* GL_MODELVIEW22_ARB */ + { 21080, 0x00008737 }, /* GL_MODELVIEW23_ARB */ + { 21099, 0x00008738 }, /* GL_MODELVIEW24_ARB */ + { 21118, 0x00008739 }, /* GL_MODELVIEW25_ARB */ + { 21137, 0x0000873A }, /* GL_MODELVIEW26_ARB */ + { 21156, 0x0000873B }, /* GL_MODELVIEW27_ARB */ + { 21175, 0x0000873C }, /* GL_MODELVIEW28_ARB */ + { 21194, 0x0000873D }, /* GL_MODELVIEW29_ARB */ + { 21213, 0x00008722 }, /* GL_MODELVIEW2_ARB */ + { 21231, 0x0000873E }, /* GL_MODELVIEW30_ARB */ + { 21250, 0x0000873F }, /* GL_MODELVIEW31_ARB */ + { 21269, 0x00008723 }, /* GL_MODELVIEW3_ARB */ + { 21287, 0x00008724 }, /* GL_MODELVIEW4_ARB */ + { 21305, 0x00008725 }, /* GL_MODELVIEW5_ARB */ + { 21323, 0x00008726 }, /* GL_MODELVIEW6_ARB */ + { 21341, 0x00008727 }, /* GL_MODELVIEW7_ARB */ + { 21359, 0x00008728 }, /* GL_MODELVIEW8_ARB */ + { 21377, 0x00008729 }, /* GL_MODELVIEW9_ARB */ + { 21395, 0x00000BA6 }, /* GL_MODELVIEW_MATRIX */ + { 21415, 0x00008629 }, /* GL_MODELVIEW_PROJECTION_NV */ + { 21442, 0x00000BA3 }, /* GL_MODELVIEW_STACK_DEPTH */ + { 21467, 0x00002100 }, /* GL_MODULATE */ + { 21479, 0x00008744 }, /* GL_MODULATE_ADD_ATI */ + { 21499, 0x00008745 }, /* GL_MODULATE_SIGNED_ADD_ATI */ + { 21526, 0x00008746 }, /* GL_MODULATE_SUBTRACT_ATI */ + { 21551, 0x00000103 }, /* GL_MULT */ + { 21559, 0x0000809D }, /* GL_MULTISAMPLE */ + { 21574, 0x000086B2 }, /* GL_MULTISAMPLE_3DFX */ + { 21594, 0x0000809D }, /* GL_MULTISAMPLE_ARB */ + { 21613, 0x20000000 }, /* GL_MULTISAMPLE_BIT */ + { 21632, 0x20000000 }, /* GL_MULTISAMPLE_BIT_3DFX */ + { 21656, 0x20000000 }, /* GL_MULTISAMPLE_BIT_ARB */ + { 21679, 0x00008534 }, /* GL_MULTISAMPLE_FILTER_HINT_NV */ + { 21709, 0x00002A25 }, /* GL_N3F_V3F */ + { 21720, 0x00000D70 }, /* GL_NAME_STACK_DEPTH */ + { 21740, 0x0000150E }, /* GL_NAND */ + { 21748, 0x00002600 }, /* GL_NEAREST */ + { 21759, 0x0000844E }, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */ + { 21790, 0x0000844D }, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */ + { 21822, 0x00002702 }, /* GL_NEAREST_MIPMAP_LINEAR */ + { 21847, 0x00002700 }, /* GL_NEAREST_MIPMAP_NEAREST */ + { 21873, 0x00000200 }, /* GL_NEVER */ + { 21882, 0x00001102 }, /* GL_NICEST */ + { 21892, 0x00000000 }, /* GL_NONE */ + { 21900, 0x00001505 }, /* GL_NOOP */ + { 21908, 0x00001508 }, /* GL_NOR */ + { 21915, 0x00000BA1 }, /* GL_NORMALIZE */ + { 21928, 0x00008075 }, /* GL_NORMAL_ARRAY */ + { 21944, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING */ + { 21975, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING_ARB */ + { 22010, 0x0000808F }, /* GL_NORMAL_ARRAY_POINTER */ + { 22034, 0x0000807F }, /* GL_NORMAL_ARRAY_STRIDE */ + { 22057, 0x0000807E }, /* GL_NORMAL_ARRAY_TYPE */ + { 22078, 0x00008511 }, /* GL_NORMAL_MAP */ + { 22092, 0x00008511 }, /* GL_NORMAL_MAP_ARB */ + { 22110, 0x00008511 }, /* GL_NORMAL_MAP_NV */ + { 22127, 0x00000205 }, /* GL_NOTEQUAL */ + { 22139, 0x00000000 }, /* GL_NO_ERROR */ + { 22151, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */ + { 22185, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB */ + { 22223, 0x00008B89 }, /* GL_OBJECT_ACTIVE_ATTRIBUTES_ARB */ + { 22255, 0x00008B8A }, /* GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB */ + { 22297, 0x00008B86 }, /* GL_OBJECT_ACTIVE_UNIFORMS_ARB */ + { 22327, 0x00008B87 }, /* GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB */ + { 22367, 0x00008B85 }, /* GL_OBJECT_ATTACHED_OBJECTS_ARB */ + { 22398, 0x00008B81 }, /* GL_OBJECT_COMPILE_STATUS_ARB */ + { 22427, 0x00008B80 }, /* GL_OBJECT_DELETE_STATUS_ARB */ + { 22455, 0x00008B84 }, /* GL_OBJECT_INFO_LOG_LENGTH_ARB */ + { 22485, 0x00002401 }, /* GL_OBJECT_LINEAR */ + { 22502, 0x00008B82 }, /* GL_OBJECT_LINK_STATUS_ARB */ + { 22528, 0x00002501 }, /* GL_OBJECT_PLANE */ + { 22544, 0x00008B88 }, /* GL_OBJECT_SHADER_SOURCE_LENGTH_ARB */ + { 22579, 0x00008B4F }, /* GL_OBJECT_SUBTYPE_ARB */ + { 22601, 0x00009112 }, /* GL_OBJECT_TYPE */ + { 22616, 0x00008B4E }, /* GL_OBJECT_TYPE_ARB */ + { 22635, 0x00008B83 }, /* GL_OBJECT_VALIDATE_STATUS_ARB */ + { 22665, 0x00008165 }, /* GL_OCCLUSION_TEST_HP */ + { 22686, 0x00008166 }, /* GL_OCCLUSION_TEST_RESULT_HP */ + { 22714, 0x00000001 }, /* GL_ONE */ + { 22721, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA */ + { 22749, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA_EXT */ + { 22781, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR */ + { 22809, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR_EXT */ + { 22841, 0x00000305 }, /* GL_ONE_MINUS_DST_ALPHA */ + { 22864, 0x00000307 }, /* GL_ONE_MINUS_DST_COLOR */ + { 22887, 0x00000303 }, /* GL_ONE_MINUS_SRC_ALPHA */ + { 22910, 0x00000301 }, /* GL_ONE_MINUS_SRC_COLOR */ + { 22933, 0x00008598 }, /* GL_OPERAND0_ALPHA */ + { 22951, 0x00008598 }, /* GL_OPERAND0_ALPHA_ARB */ + { 22973, 0x00008598 }, /* GL_OPERAND0_ALPHA_EXT */ + { 22995, 0x00008590 }, /* GL_OPERAND0_RGB */ + { 23011, 0x00008590 }, /* GL_OPERAND0_RGB_ARB */ + { 23031, 0x00008590 }, /* GL_OPERAND0_RGB_EXT */ + { 23051, 0x00008599 }, /* GL_OPERAND1_ALPHA */ + { 23069, 0x00008599 }, /* GL_OPERAND1_ALPHA_ARB */ + { 23091, 0x00008599 }, /* GL_OPERAND1_ALPHA_EXT */ + { 23113, 0x00008591 }, /* GL_OPERAND1_RGB */ + { 23129, 0x00008591 }, /* GL_OPERAND1_RGB_ARB */ + { 23149, 0x00008591 }, /* GL_OPERAND1_RGB_EXT */ + { 23169, 0x0000859A }, /* GL_OPERAND2_ALPHA */ + { 23187, 0x0000859A }, /* GL_OPERAND2_ALPHA_ARB */ + { 23209, 0x0000859A }, /* GL_OPERAND2_ALPHA_EXT */ + { 23231, 0x00008592 }, /* GL_OPERAND2_RGB */ + { 23247, 0x00008592 }, /* GL_OPERAND2_RGB_ARB */ + { 23267, 0x00008592 }, /* GL_OPERAND2_RGB_EXT */ + { 23287, 0x0000859B }, /* GL_OPERAND3_ALPHA_NV */ + { 23308, 0x00008593 }, /* GL_OPERAND3_RGB_NV */ + { 23327, 0x00001507 }, /* GL_OR */ + { 23333, 0x00000A01 }, /* GL_ORDER */ + { 23342, 0x0000150D }, /* GL_OR_INVERTED */ + { 23357, 0x0000150B }, /* GL_OR_REVERSE */ + { 23371, 0x00000505 }, /* GL_OUT_OF_MEMORY */ + { 23388, 0x00000D05 }, /* GL_PACK_ALIGNMENT */ + { 23406, 0x0000806C }, /* GL_PACK_IMAGE_HEIGHT */ + { 23427, 0x00008758 }, /* GL_PACK_INVERT_MESA */ + { 23447, 0x00000D01 }, /* GL_PACK_LSB_FIRST */ + { 23465, 0x00000D02 }, /* GL_PACK_ROW_LENGTH */ + { 23484, 0x0000806B }, /* GL_PACK_SKIP_IMAGES */ + { 23504, 0x00000D04 }, /* GL_PACK_SKIP_PIXELS */ + { 23524, 0x00000D03 }, /* GL_PACK_SKIP_ROWS */ + { 23542, 0x00000D00 }, /* GL_PACK_SWAP_BYTES */ + { 23561, 0x00008B92 }, /* GL_PALETTE4_R5_G6_B5_OES */ + { 23586, 0x00008B94 }, /* GL_PALETTE4_RGB5_A1_OES */ + { 23610, 0x00008B90 }, /* GL_PALETTE4_RGB8_OES */ + { 23631, 0x00008B93 }, /* GL_PALETTE4_RGBA4_OES */ + { 23653, 0x00008B91 }, /* GL_PALETTE4_RGBA8_OES */ + { 23675, 0x00008B97 }, /* GL_PALETTE8_R5_G6_B5_OES */ + { 23700, 0x00008B99 }, /* GL_PALETTE8_RGB5_A1_OES */ + { 23724, 0x00008B95 }, /* GL_PALETTE8_RGB8_OES */ + { 23745, 0x00008B98 }, /* GL_PALETTE8_RGBA4_OES */ + { 23767, 0x00008B96 }, /* GL_PALETTE8_RGBA8_OES */ + { 23789, 0x00000700 }, /* GL_PASS_THROUGH_TOKEN */ + { 23811, 0x00000C50 }, /* GL_PERSPECTIVE_CORRECTION_HINT */ + { 23842, 0x00000C79 }, /* GL_PIXEL_MAP_A_TO_A */ + { 23862, 0x00000CB9 }, /* GL_PIXEL_MAP_A_TO_A_SIZE */ + { 23887, 0x00000C78 }, /* GL_PIXEL_MAP_B_TO_B */ + { 23907, 0x00000CB8 }, /* GL_PIXEL_MAP_B_TO_B_SIZE */ + { 23932, 0x00000C77 }, /* GL_PIXEL_MAP_G_TO_G */ + { 23952, 0x00000CB7 }, /* GL_PIXEL_MAP_G_TO_G_SIZE */ + { 23977, 0x00000C75 }, /* GL_PIXEL_MAP_I_TO_A */ + { 23997, 0x00000CB5 }, /* GL_PIXEL_MAP_I_TO_A_SIZE */ + { 24022, 0x00000C74 }, /* GL_PIXEL_MAP_I_TO_B */ + { 24042, 0x00000CB4 }, /* GL_PIXEL_MAP_I_TO_B_SIZE */ + { 24067, 0x00000C73 }, /* GL_PIXEL_MAP_I_TO_G */ + { 24087, 0x00000CB3 }, /* GL_PIXEL_MAP_I_TO_G_SIZE */ + { 24112, 0x00000C70 }, /* GL_PIXEL_MAP_I_TO_I */ + { 24132, 0x00000CB0 }, /* GL_PIXEL_MAP_I_TO_I_SIZE */ + { 24157, 0x00000C72 }, /* GL_PIXEL_MAP_I_TO_R */ + { 24177, 0x00000CB2 }, /* GL_PIXEL_MAP_I_TO_R_SIZE */ + { 24202, 0x00000C76 }, /* GL_PIXEL_MAP_R_TO_R */ + { 24222, 0x00000CB6 }, /* GL_PIXEL_MAP_R_TO_R_SIZE */ + { 24247, 0x00000C71 }, /* GL_PIXEL_MAP_S_TO_S */ + { 24267, 0x00000CB1 }, /* GL_PIXEL_MAP_S_TO_S_SIZE */ + { 24292, 0x00000020 }, /* GL_PIXEL_MODE_BIT */ + { 24310, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER */ + { 24331, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING */ + { 24360, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING_EXT */ + { 24393, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER_EXT */ + { 24418, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER */ + { 24441, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING */ + { 24472, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING_EXT */ + { 24507, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER_EXT */ + { 24534, 0x00001B00 }, /* GL_POINT */ + { 24543, 0x00000000 }, /* GL_POINTS */ + { 24553, 0x00000002 }, /* GL_POINT_BIT */ + { 24566, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION */ + { 24596, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_ARB */ + { 24630, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_EXT */ + { 24664, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_SGIS */ + { 24699, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE */ + { 24728, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_ARB */ + { 24761, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_EXT */ + { 24794, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_SGIS */ + { 24828, 0x00000B11 }, /* GL_POINT_SIZE */ + { 24842, 0x00000B13 }, /* GL_POINT_SIZE_GRANULARITY */ + { 24868, 0x00008127 }, /* GL_POINT_SIZE_MAX */ + { 24886, 0x00008127 }, /* GL_POINT_SIZE_MAX_ARB */ + { 24908, 0x00008127 }, /* GL_POINT_SIZE_MAX_EXT */ + { 24930, 0x00008127 }, /* GL_POINT_SIZE_MAX_SGIS */ + { 24953, 0x00008126 }, /* GL_POINT_SIZE_MIN */ + { 24971, 0x00008126 }, /* GL_POINT_SIZE_MIN_ARB */ + { 24993, 0x00008126 }, /* GL_POINT_SIZE_MIN_EXT */ + { 25015, 0x00008126 }, /* GL_POINT_SIZE_MIN_SGIS */ + { 25038, 0x00000B12 }, /* GL_POINT_SIZE_RANGE */ + { 25058, 0x00000B10 }, /* GL_POINT_SMOOTH */ + { 25074, 0x00000C51 }, /* GL_POINT_SMOOTH_HINT */ + { 25095, 0x00008861 }, /* GL_POINT_SPRITE */ + { 25111, 0x00008861 }, /* GL_POINT_SPRITE_ARB */ + { 25131, 0x00008CA0 }, /* GL_POINT_SPRITE_COORD_ORIGIN */ + { 25160, 0x00008861 }, /* GL_POINT_SPRITE_NV */ + { 25179, 0x00008863 }, /* GL_POINT_SPRITE_R_MODE_NV */ + { 25205, 0x00000701 }, /* GL_POINT_TOKEN */ + { 25220, 0x00000009 }, /* GL_POLYGON */ + { 25231, 0x00000008 }, /* GL_POLYGON_BIT */ + { 25246, 0x00000B40 }, /* GL_POLYGON_MODE */ + { 25262, 0x00008039 }, /* GL_POLYGON_OFFSET_BIAS */ + { 25285, 0x00008038 }, /* GL_POLYGON_OFFSET_FACTOR */ + { 25310, 0x00008037 }, /* GL_POLYGON_OFFSET_FILL */ + { 25333, 0x00002A02 }, /* GL_POLYGON_OFFSET_LINE */ + { 25356, 0x00002A01 }, /* GL_POLYGON_OFFSET_POINT */ + { 25380, 0x00002A00 }, /* GL_POLYGON_OFFSET_UNITS */ + { 25404, 0x00000B41 }, /* GL_POLYGON_SMOOTH */ + { 25422, 0x00000C53 }, /* GL_POLYGON_SMOOTH_HINT */ + { 25445, 0x00000B42 }, /* GL_POLYGON_STIPPLE */ + { 25464, 0x00000010 }, /* GL_POLYGON_STIPPLE_BIT */ + { 25487, 0x00000703 }, /* GL_POLYGON_TOKEN */ + { 25504, 0x00001203 }, /* GL_POSITION */ + { 25516, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */ + { 25548, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI */ + { 25584, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */ + { 25617, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI */ + { 25654, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */ + { 25685, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI */ + { 25720, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */ + { 25752, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI */ + { 25788, 0x000080D2 }, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */ + { 25821, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */ + { 25853, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI */ + { 25889, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */ + { 25922, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI */ + { 25959, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS */ + { 25989, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS_SGI */ + { 26023, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE */ + { 26054, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE_SGI */ + { 26089, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS */ + { 26120, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS_EXT */ + { 26155, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE */ + { 26187, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE_EXT */ + { 26223, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS */ + { 26253, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS_EXT */ + { 26287, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE */ + { 26318, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE_EXT */ + { 26353, 0x000080D1 }, /* GL_POST_CONVOLUTION_COLOR_TABLE */ + { 26385, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS */ + { 26416, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS_EXT */ + { 26451, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE */ + { 26483, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE_EXT */ + { 26519, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS */ + { 26548, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS_EXT */ + { 26581, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE */ + { 26611, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE_EXT */ + { 26645, 0x0000817B }, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */ + { 26684, 0x00008179 }, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */ + { 26717, 0x0000817C }, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */ + { 26757, 0x0000817A }, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */ + { 26791, 0x00008578 }, /* GL_PREVIOUS */ + { 26803, 0x00008578 }, /* GL_PREVIOUS_ARB */ + { 26819, 0x00008578 }, /* GL_PREVIOUS_EXT */ + { 26835, 0x00008577 }, /* GL_PRIMARY_COLOR */ + { 26852, 0x00008577 }, /* GL_PRIMARY_COLOR_ARB */ + { 26873, 0x00008577 }, /* GL_PRIMARY_COLOR_EXT */ + { 26894, 0x000088B0 }, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */ + { 26927, 0x00008805 }, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */ + { 26959, 0x000088AC }, /* GL_PROGRAM_ATTRIBS_ARB */ + { 26982, 0x00008677 }, /* GL_PROGRAM_BINDING_ARB */ + { 27005, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_ARB */ + { 27035, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_NV */ + { 27064, 0x00008874 }, /* GL_PROGRAM_ERROR_STRING_ARB */ + { 27092, 0x00008876 }, /* GL_PROGRAM_FORMAT_ARB */ + { 27114, 0x00008875 }, /* GL_PROGRAM_FORMAT_ASCII_ARB */ + { 27142, 0x000088A0 }, /* GL_PROGRAM_INSTRUCTIONS_ARB */ + { 27170, 0x00008627 }, /* GL_PROGRAM_LENGTH_ARB */ + { 27192, 0x00008627 }, /* GL_PROGRAM_LENGTH_NV */ + { 27213, 0x000088B2 }, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ + { 27253, 0x00008808 }, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ + { 27292, 0x000088AE }, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */ + { 27322, 0x000088A2 }, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ + { 27357, 0x000088AA }, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */ + { 27390, 0x000088A6 }, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */ + { 27424, 0x0000880A }, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ + { 27463, 0x00008809 }, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ + { 27502, 0x00008B40 }, /* GL_PROGRAM_OBJECT_ARB */ + { 27524, 0x000088A8 }, /* GL_PROGRAM_PARAMETERS_ARB */ + { 27550, 0x00008644 }, /* GL_PROGRAM_PARAMETER_NV */ + { 27574, 0x00008647 }, /* GL_PROGRAM_RESIDENT_NV */ + { 27597, 0x00008628 }, /* GL_PROGRAM_STRING_ARB */ + { 27619, 0x00008628 }, /* GL_PROGRAM_STRING_NV */ + { 27640, 0x00008646 }, /* GL_PROGRAM_TARGET_NV */ + { 27661, 0x000088A4 }, /* GL_PROGRAM_TEMPORARIES_ARB */ + { 27688, 0x00008807 }, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */ + { 27720, 0x00008806 }, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */ + { 27752, 0x000088B6 }, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */ + { 27787, 0x00001701 }, /* GL_PROJECTION */ + { 27801, 0x00000BA7 }, /* GL_PROJECTION_MATRIX */ + { 27822, 0x00000BA4 }, /* GL_PROJECTION_STACK_DEPTH */ + { 27848, 0x00008E4F }, /* GL_PROVOKING_VERTEX */ + { 27868, 0x00008E4F }, /* GL_PROVOKING_VERTEX_EXT */ + { 27892, 0x000080D3 }, /* GL_PROXY_COLOR_TABLE */ + { 27913, 0x00008025 }, /* GL_PROXY_HISTOGRAM */ + { 27932, 0x00008025 }, /* GL_PROXY_HISTOGRAM_EXT */ + { 27955, 0x000080D5 }, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */ + { 27994, 0x000080D4 }, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */ + { 28032, 0x00008063 }, /* GL_PROXY_TEXTURE_1D */ + { 28052, 0x00008C19 }, /* GL_PROXY_TEXTURE_1D_ARRAY_EXT */ + { 28082, 0x00008063 }, /* GL_PROXY_TEXTURE_1D_EXT */ + { 28106, 0x00008064 }, /* GL_PROXY_TEXTURE_2D */ + { 28126, 0x00008C1B }, /* GL_PROXY_TEXTURE_2D_ARRAY_EXT */ + { 28156, 0x00008064 }, /* GL_PROXY_TEXTURE_2D_EXT */ + { 28180, 0x00008070 }, /* GL_PROXY_TEXTURE_3D */ + { 28200, 0x000080BD }, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */ + { 28233, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP */ + { 28259, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP_ARB */ + { 28289, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */ + { 28320, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_NV */ + { 28350, 0x00002003 }, /* GL_Q */ + { 28355, 0x00001209 }, /* GL_QUADRATIC_ATTENUATION */ + { 28380, 0x00000007 }, /* GL_QUADS */ + { 28389, 0x00008E4C }, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ + { 28433, 0x00008E4C }, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT */ + { 28481, 0x00008614 }, /* GL_QUAD_MESH_SUN */ + { 28498, 0x00000008 }, /* GL_QUAD_STRIP */ + { 28512, 0x00008E16 }, /* GL_QUERY_BY_REGION_NO_WAIT_NV */ + { 28542, 0x00008E15 }, /* GL_QUERY_BY_REGION_WAIT_NV */ + { 28569, 0x00008864 }, /* GL_QUERY_COUNTER_BITS */ + { 28591, 0x00008864 }, /* GL_QUERY_COUNTER_BITS_ARB */ + { 28617, 0x00008E14 }, /* GL_QUERY_NO_WAIT_NV */ + { 28637, 0x00008866 }, /* GL_QUERY_RESULT */ + { 28653, 0x00008866 }, /* GL_QUERY_RESULT_ARB */ + { 28673, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE */ + { 28699, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE_ARB */ + { 28729, 0x00008E13 }, /* GL_QUERY_WAIT_NV */ + { 28746, 0x00002002 }, /* GL_R */ + { 28751, 0x00002A10 }, /* GL_R3_G3_B2 */ + { 28763, 0x00019262 }, /* GL_RASTER_POSITION_UNCLIPPED_IBM */ + { 28796, 0x00000C02 }, /* GL_READ_BUFFER */ + { 28811, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER */ + { 28831, 0x00008CAA }, /* GL_READ_FRAMEBUFFER_BINDING */ + { 28859, 0x00008CAA }, /* GL_READ_FRAMEBUFFER_BINDING_EXT */ + { 28891, 0x00008CA8 }, /* GL_READ_FRAMEBUFFER_EXT */ + { 28915, 0x000088B8 }, /* GL_READ_ONLY */ + { 28928, 0x000088B8 }, /* GL_READ_ONLY_ARB */ + { 28945, 0x000088BA }, /* GL_READ_WRITE */ + { 28959, 0x000088BA }, /* GL_READ_WRITE_ARB */ + { 28977, 0x00001903 }, /* GL_RED */ + { 28984, 0x00008016 }, /* GL_REDUCE */ + { 28994, 0x00008016 }, /* GL_REDUCE_EXT */ + { 29008, 0x00000D15 }, /* GL_RED_BIAS */ + { 29020, 0x00000D52 }, /* GL_RED_BITS */ + { 29032, 0x00000D14 }, /* GL_RED_SCALE */ + { 29045, 0x00008512 }, /* GL_REFLECTION_MAP */ + { 29063, 0x00008512 }, /* GL_REFLECTION_MAP_ARB */ + { 29085, 0x00008512 }, /* GL_REFLECTION_MAP_NV */ + { 29106, 0x00001C00 }, /* GL_RENDER */ + { 29116, 0x00008D41 }, /* GL_RENDERBUFFER */ + { 29132, 0x00008D53 }, /* GL_RENDERBUFFER_ALPHA_SIZE */ + { 29159, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING */ + { 29183, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING_EXT */ + { 29211, 0x00008D52 }, /* GL_RENDERBUFFER_BLUE_SIZE */ + { 29237, 0x00008D54 }, /* GL_RENDERBUFFER_DEPTH_SIZE */ + { 29264, 0x00008D41 }, /* GL_RENDERBUFFER_EXT */ + { 29284, 0x00008D51 }, /* GL_RENDERBUFFER_GREEN_SIZE */ + { 29311, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT */ + { 29334, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT_EXT */ + { 29361, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT */ + { 29393, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT_EXT */ + { 29429, 0x00008D50 }, /* GL_RENDERBUFFER_RED_SIZE */ + { 29454, 0x00008CAB }, /* GL_RENDERBUFFER_SAMPLES */ + { 29478, 0x00008CAB }, /* GL_RENDERBUFFER_SAMPLES_EXT */ + { 29506, 0x00008D55 }, /* GL_RENDERBUFFER_STENCIL_SIZE */ + { 29535, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH */ + { 29557, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH_EXT */ + { 29583, 0x00001F01 }, /* GL_RENDERER */ + { 29595, 0x00000C40 }, /* GL_RENDER_MODE */ + { 29610, 0x00002901 }, /* GL_REPEAT */ + { 29620, 0x00001E01 }, /* GL_REPLACE */ + { 29631, 0x00008062 }, /* GL_REPLACE_EXT */ + { 29646, 0x00008153 }, /* GL_REPLICATE_BORDER_HP */ + { 29669, 0x0000803A }, /* GL_RESCALE_NORMAL */ + { 29687, 0x0000803A }, /* GL_RESCALE_NORMAL_EXT */ + { 29709, 0x00000102 }, /* GL_RETURN */ + { 29719, 0x00001907 }, /* GL_RGB */ + { 29726, 0x00008052 }, /* GL_RGB10 */ + { 29735, 0x00008059 }, /* GL_RGB10_A2 */ + { 29747, 0x00008059 }, /* GL_RGB10_A2_EXT */ + { 29763, 0x00008052 }, /* GL_RGB10_EXT */ + { 29776, 0x00008053 }, /* GL_RGB12 */ + { 29785, 0x00008053 }, /* GL_RGB12_EXT */ + { 29798, 0x00008054 }, /* GL_RGB16 */ + { 29807, 0x00008054 }, /* GL_RGB16_EXT */ + { 29820, 0x0000804E }, /* GL_RGB2_EXT */ + { 29832, 0x0000804F }, /* GL_RGB4 */ + { 29840, 0x0000804F }, /* GL_RGB4_EXT */ + { 29852, 0x000083A1 }, /* GL_RGB4_S3TC */ + { 29865, 0x00008050 }, /* GL_RGB5 */ + { 29873, 0x00008057 }, /* GL_RGB5_A1 */ + { 29884, 0x00008057 }, /* GL_RGB5_A1_EXT */ + { 29899, 0x00008050 }, /* GL_RGB5_EXT */ + { 29911, 0x00008051 }, /* GL_RGB8 */ + { 29919, 0x00008051 }, /* GL_RGB8_EXT */ + { 29931, 0x00001908 }, /* GL_RGBA */ + { 29939, 0x0000805A }, /* GL_RGBA12 */ + { 29949, 0x0000805A }, /* GL_RGBA12_EXT */ + { 29963, 0x0000805B }, /* GL_RGBA16 */ + { 29973, 0x0000805B }, /* GL_RGBA16_EXT */ + { 29987, 0x00008055 }, /* GL_RGBA2 */ + { 29996, 0x00008055 }, /* GL_RGBA2_EXT */ + { 30009, 0x00008056 }, /* GL_RGBA4 */ + { 30018, 0x000083A5 }, /* GL_RGBA4_DXT5_S3TC */ + { 30037, 0x00008056 }, /* GL_RGBA4_EXT */ + { 30050, 0x000083A3 }, /* GL_RGBA4_S3TC */ + { 30064, 0x00008058 }, /* GL_RGBA8 */ + { 30073, 0x00008058 }, /* GL_RGBA8_EXT */ + { 30086, 0x00008F97 }, /* GL_RGBA8_SNORM */ + { 30101, 0x000083A4 }, /* GL_RGBA_DXT5_S3TC */ + { 30119, 0x00000C31 }, /* GL_RGBA_MODE */ + { 30132, 0x000083A2 }, /* GL_RGBA_S3TC */ + { 30145, 0x00008F93 }, /* GL_RGBA_SNORM */ + { 30159, 0x000083A0 }, /* GL_RGB_S3TC */ + { 30171, 0x00008573 }, /* GL_RGB_SCALE */ + { 30184, 0x00008573 }, /* GL_RGB_SCALE_ARB */ + { 30201, 0x00008573 }, /* GL_RGB_SCALE_EXT */ + { 30218, 0x00000407 }, /* GL_RIGHT */ + { 30227, 0x00002000 }, /* GL_S */ + { 30232, 0x00008B5D }, /* GL_SAMPLER_1D */ + { 30246, 0x00008B61 }, /* GL_SAMPLER_1D_SHADOW */ + { 30267, 0x00008B5E }, /* GL_SAMPLER_2D */ + { 30281, 0x00008B62 }, /* GL_SAMPLER_2D_SHADOW */ + { 30302, 0x00008B5F }, /* GL_SAMPLER_3D */ + { 30316, 0x00008B60 }, /* GL_SAMPLER_CUBE */ + { 30332, 0x000080A9 }, /* GL_SAMPLES */ + { 30343, 0x000086B4 }, /* GL_SAMPLES_3DFX */ + { 30359, 0x000080A9 }, /* GL_SAMPLES_ARB */ + { 30374, 0x00008914 }, /* GL_SAMPLES_PASSED */ + { 30392, 0x00008914 }, /* GL_SAMPLES_PASSED_ARB */ + { 30414, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE */ + { 30442, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE_ARB */ + { 30474, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE */ + { 30497, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE_ARB */ + { 30524, 0x000080A8 }, /* GL_SAMPLE_BUFFERS */ + { 30542, 0x000086B3 }, /* GL_SAMPLE_BUFFERS_3DFX */ + { 30565, 0x000080A8 }, /* GL_SAMPLE_BUFFERS_ARB */ + { 30587, 0x000080A0 }, /* GL_SAMPLE_COVERAGE */ + { 30606, 0x000080A0 }, /* GL_SAMPLE_COVERAGE_ARB */ + { 30629, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT */ + { 30655, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT_ARB */ + { 30685, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE */ + { 30710, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE_ARB */ + { 30739, 0x00080000 }, /* GL_SCISSOR_BIT */ + { 30754, 0x00000C10 }, /* GL_SCISSOR_BOX */ + { 30769, 0x00000C11 }, /* GL_SCISSOR_TEST */ + { 30785, 0x0000845E }, /* GL_SECONDARY_COLOR_ARRAY */ + { 30810, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */ + { 30850, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB */ + { 30894, 0x0000845D }, /* GL_SECONDARY_COLOR_ARRAY_POINTER */ + { 30927, 0x0000845A }, /* GL_SECONDARY_COLOR_ARRAY_SIZE */ + { 30957, 0x0000845C }, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */ + { 30989, 0x0000845B }, /* GL_SECONDARY_COLOR_ARRAY_TYPE */ + { 31019, 0x00001C02 }, /* GL_SELECT */ + { 31029, 0x00000DF3 }, /* GL_SELECTION_BUFFER_POINTER */ + { 31057, 0x00000DF4 }, /* GL_SELECTION_BUFFER_SIZE */ + { 31082, 0x00008012 }, /* GL_SEPARABLE_2D */ + { 31098, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR */ + { 31125, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR_EXT */ + { 31156, 0x0000150F }, /* GL_SET */ + { 31163, 0x00008B48 }, /* GL_SHADER_OBJECT_ARB */ + { 31184, 0x00008B88 }, /* GL_SHADER_SOURCE_LENGTH */ + { 31208, 0x00008B4F }, /* GL_SHADER_TYPE */ + { 31223, 0x00000B54 }, /* GL_SHADE_MODEL */ + { 31238, 0x00008B8C }, /* GL_SHADING_LANGUAGE_VERSION */ + { 31266, 0x000080BF }, /* GL_SHADOW_AMBIENT_SGIX */ + { 31289, 0x000081FB }, /* GL_SHARED_TEXTURE_PALETTE_EXT */ + { 31319, 0x00001601 }, /* GL_SHININESS */ + { 31332, 0x00001402 }, /* GL_SHORT */ + { 31341, 0x00009119 }, /* GL_SIGNALED */ + { 31353, 0x00008F9C }, /* GL_SIGNED_NORMALIZED */ + { 31374, 0x000081F9 }, /* GL_SINGLE_COLOR */ + { 31390, 0x000081F9 }, /* GL_SINGLE_COLOR_EXT */ + { 31410, 0x000085CC }, /* GL_SLICE_ACCUM_SUN */ + { 31429, 0x00008C46 }, /* GL_SLUMINANCE */ + { 31443, 0x00008C47 }, /* GL_SLUMINANCE8 */ + { 31458, 0x00008C45 }, /* GL_SLUMINANCE8_ALPHA8 */ + { 31480, 0x00008C44 }, /* GL_SLUMINANCE_ALPHA */ + { 31500, 0x00001D01 }, /* GL_SMOOTH */ + { 31510, 0x00000B23 }, /* GL_SMOOTH_LINE_WIDTH_GRANULARITY */ + { 31543, 0x00000B22 }, /* GL_SMOOTH_LINE_WIDTH_RANGE */ + { 31570, 0x00000B13 }, /* GL_SMOOTH_POINT_SIZE_GRANULARITY */ + { 31603, 0x00000B12 }, /* GL_SMOOTH_POINT_SIZE_RANGE */ + { 31630, 0x00008588 }, /* GL_SOURCE0_ALPHA */ + { 31647, 0x00008588 }, /* GL_SOURCE0_ALPHA_ARB */ + { 31668, 0x00008588 }, /* GL_SOURCE0_ALPHA_EXT */ + { 31689, 0x00008580 }, /* GL_SOURCE0_RGB */ + { 31704, 0x00008580 }, /* GL_SOURCE0_RGB_ARB */ + { 31723, 0x00008580 }, /* GL_SOURCE0_RGB_EXT */ + { 31742, 0x00008589 }, /* GL_SOURCE1_ALPHA */ + { 31759, 0x00008589 }, /* GL_SOURCE1_ALPHA_ARB */ + { 31780, 0x00008589 }, /* GL_SOURCE1_ALPHA_EXT */ + { 31801, 0x00008581 }, /* GL_SOURCE1_RGB */ + { 31816, 0x00008581 }, /* GL_SOURCE1_RGB_ARB */ + { 31835, 0x00008581 }, /* GL_SOURCE1_RGB_EXT */ + { 31854, 0x0000858A }, /* GL_SOURCE2_ALPHA */ + { 31871, 0x0000858A }, /* GL_SOURCE2_ALPHA_ARB */ + { 31892, 0x0000858A }, /* GL_SOURCE2_ALPHA_EXT */ + { 31913, 0x00008582 }, /* GL_SOURCE2_RGB */ + { 31928, 0x00008582 }, /* GL_SOURCE2_RGB_ARB */ + { 31947, 0x00008582 }, /* GL_SOURCE2_RGB_EXT */ + { 31966, 0x0000858B }, /* GL_SOURCE3_ALPHA_NV */ + { 31986, 0x00008583 }, /* GL_SOURCE3_RGB_NV */ + { 32004, 0x00001202 }, /* GL_SPECULAR */ + { 32016, 0x00002402 }, /* GL_SPHERE_MAP */ + { 32030, 0x00001206 }, /* GL_SPOT_CUTOFF */ + { 32045, 0x00001204 }, /* GL_SPOT_DIRECTION */ + { 32063, 0x00001205 }, /* GL_SPOT_EXPONENT */ + { 32080, 0x00008588 }, /* GL_SRC0_ALPHA */ + { 32094, 0x00008580 }, /* GL_SRC0_RGB */ + { 32106, 0x00008589 }, /* GL_SRC1_ALPHA */ + { 32120, 0x00008581 }, /* GL_SRC1_RGB */ + { 32132, 0x0000858A }, /* GL_SRC2_ALPHA */ + { 32146, 0x00008582 }, /* GL_SRC2_RGB */ + { 32158, 0x00000302 }, /* GL_SRC_ALPHA */ + { 32171, 0x00000308 }, /* GL_SRC_ALPHA_SATURATE */ + { 32193, 0x00000300 }, /* GL_SRC_COLOR */ + { 32206, 0x00008C40 }, /* GL_SRGB */ + { 32214, 0x00008C41 }, /* GL_SRGB8 */ + { 32223, 0x00008C43 }, /* GL_SRGB8_ALPHA8 */ + { 32239, 0x00008C42 }, /* GL_SRGB_ALPHA */ + { 32253, 0x00000503 }, /* GL_STACK_OVERFLOW */ + { 32271, 0x00000504 }, /* GL_STACK_UNDERFLOW */ + { 32290, 0x000088E6 }, /* GL_STATIC_COPY */ + { 32305, 0x000088E6 }, /* GL_STATIC_COPY_ARB */ + { 32324, 0x000088E4 }, /* GL_STATIC_DRAW */ + { 32339, 0x000088E4 }, /* GL_STATIC_DRAW_ARB */ + { 32358, 0x000088E5 }, /* GL_STATIC_READ */ + { 32373, 0x000088E5 }, /* GL_STATIC_READ_ARB */ + { 32392, 0x00001802 }, /* GL_STENCIL */ + { 32403, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT */ + { 32425, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT_EXT */ + { 32451, 0x00008801 }, /* GL_STENCIL_BACK_FAIL */ + { 32472, 0x00008801 }, /* GL_STENCIL_BACK_FAIL_ATI */ + { 32497, 0x00008800 }, /* GL_STENCIL_BACK_FUNC */ + { 32518, 0x00008800 }, /* GL_STENCIL_BACK_FUNC_ATI */ + { 32543, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */ + { 32575, 0x00008802 }, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI */ + { 32611, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */ + { 32643, 0x00008803 }, /* GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI */ + { 32679, 0x00008CA3 }, /* GL_STENCIL_BACK_REF */ + { 32699, 0x00008CA4 }, /* GL_STENCIL_BACK_VALUE_MASK */ + { 32726, 0x00008CA5 }, /* GL_STENCIL_BACK_WRITEMASK */ + { 32752, 0x00000D57 }, /* GL_STENCIL_BITS */ + { 32768, 0x00000400 }, /* GL_STENCIL_BUFFER_BIT */ + { 32790, 0x00000B91 }, /* GL_STENCIL_CLEAR_VALUE */ + { 32813, 0x00000B94 }, /* GL_STENCIL_FAIL */ + { 32829, 0x00000B92 }, /* GL_STENCIL_FUNC */ + { 32845, 0x00001901 }, /* GL_STENCIL_INDEX */ + { 32862, 0x00008D46 }, /* GL_STENCIL_INDEX1 */ + { 32880, 0x00008D49 }, /* GL_STENCIL_INDEX16 */ + { 32899, 0x00008D49 }, /* GL_STENCIL_INDEX16_EXT */ + { 32922, 0x00008D46 }, /* GL_STENCIL_INDEX1_EXT */ + { 32944, 0x00008D47 }, /* GL_STENCIL_INDEX4 */ + { 32962, 0x00008D47 }, /* GL_STENCIL_INDEX4_EXT */ + { 32984, 0x00008D48 }, /* GL_STENCIL_INDEX8 */ + { 33002, 0x00008D48 }, /* GL_STENCIL_INDEX8_EXT */ + { 33024, 0x00008D45 }, /* GL_STENCIL_INDEX_EXT */ + { 33045, 0x00000B95 }, /* GL_STENCIL_PASS_DEPTH_FAIL */ + { 33072, 0x00000B96 }, /* GL_STENCIL_PASS_DEPTH_PASS */ + { 33099, 0x00000B97 }, /* GL_STENCIL_REF */ + { 33114, 0x00000B90 }, /* GL_STENCIL_TEST */ + { 33130, 0x00008910 }, /* GL_STENCIL_TEST_TWO_SIDE_EXT */ + { 33159, 0x00000B93 }, /* GL_STENCIL_VALUE_MASK */ + { 33181, 0x00000B98 }, /* GL_STENCIL_WRITEMASK */ + { 33202, 0x00000C33 }, /* GL_STEREO */ + { 33212, 0x000085BE }, /* GL_STORAGE_CACHED_APPLE */ + { 33236, 0x000085BD }, /* GL_STORAGE_PRIVATE_APPLE */ + { 33261, 0x000085BF }, /* GL_STORAGE_SHARED_APPLE */ + { 33285, 0x000088E2 }, /* GL_STREAM_COPY */ + { 33300, 0x000088E2 }, /* GL_STREAM_COPY_ARB */ + { 33319, 0x000088E0 }, /* GL_STREAM_DRAW */ + { 33334, 0x000088E0 }, /* GL_STREAM_DRAW_ARB */ + { 33353, 0x000088E1 }, /* GL_STREAM_READ */ + { 33368, 0x000088E1 }, /* GL_STREAM_READ_ARB */ + { 33387, 0x00000D50 }, /* GL_SUBPIXEL_BITS */ + { 33404, 0x000084E7 }, /* GL_SUBTRACT */ + { 33416, 0x000084E7 }, /* GL_SUBTRACT_ARB */ + { 33432, 0x00009113 }, /* GL_SYNC_CONDITION */ + { 33450, 0x00009116 }, /* GL_SYNC_FENCE */ + { 33464, 0x00009115 }, /* GL_SYNC_FLAGS */ + { 33478, 0x00000001 }, /* GL_SYNC_FLUSH_COMMANDS_BIT */ + { 33505, 0x00009117 }, /* GL_SYNC_GPU_COMMANDS_COMPLETE */ + { 33535, 0x00009114 }, /* GL_SYNC_STATUS */ + { 33550, 0x00002001 }, /* GL_T */ + { 33555, 0x00002A2A }, /* GL_T2F_C3F_V3F */ + { 33570, 0x00002A2C }, /* GL_T2F_C4F_N3F_V3F */ + { 33589, 0x00002A29 }, /* GL_T2F_C4UB_V3F */ + { 33605, 0x00002A2B }, /* GL_T2F_N3F_V3F */ + { 33620, 0x00002A27 }, /* GL_T2F_V3F */ + { 33631, 0x00002A2D }, /* GL_T4F_C4F_N3F_V4F */ + { 33650, 0x00002A28 }, /* GL_T4F_V4F */ + { 33661, 0x00008031 }, /* GL_TABLE_TOO_LARGE_EXT */ + { 33684, 0x00001702 }, /* GL_TEXTURE */ + { 33695, 0x000084C0 }, /* GL_TEXTURE0 */ + { 33707, 0x000084C0 }, /* GL_TEXTURE0_ARB */ + { 33723, 0x000084C1 }, /* GL_TEXTURE1 */ + { 33735, 0x000084CA }, /* GL_TEXTURE10 */ + { 33748, 0x000084CA }, /* GL_TEXTURE10_ARB */ + { 33765, 0x000084CB }, /* GL_TEXTURE11 */ + { 33778, 0x000084CB }, /* GL_TEXTURE11_ARB */ + { 33795, 0x000084CC }, /* GL_TEXTURE12 */ + { 33808, 0x000084CC }, /* GL_TEXTURE12_ARB */ + { 33825, 0x000084CD }, /* GL_TEXTURE13 */ + { 33838, 0x000084CD }, /* GL_TEXTURE13_ARB */ + { 33855, 0x000084CE }, /* GL_TEXTURE14 */ + { 33868, 0x000084CE }, /* GL_TEXTURE14_ARB */ + { 33885, 0x000084CF }, /* GL_TEXTURE15 */ + { 33898, 0x000084CF }, /* GL_TEXTURE15_ARB */ + { 33915, 0x000084D0 }, /* GL_TEXTURE16 */ + { 33928, 0x000084D0 }, /* GL_TEXTURE16_ARB */ + { 33945, 0x000084D1 }, /* GL_TEXTURE17 */ + { 33958, 0x000084D1 }, /* GL_TEXTURE17_ARB */ + { 33975, 0x000084D2 }, /* GL_TEXTURE18 */ + { 33988, 0x000084D2 }, /* GL_TEXTURE18_ARB */ + { 34005, 0x000084D3 }, /* GL_TEXTURE19 */ + { 34018, 0x000084D3 }, /* GL_TEXTURE19_ARB */ + { 34035, 0x000084C1 }, /* GL_TEXTURE1_ARB */ + { 34051, 0x000084C2 }, /* GL_TEXTURE2 */ + { 34063, 0x000084D4 }, /* GL_TEXTURE20 */ + { 34076, 0x000084D4 }, /* GL_TEXTURE20_ARB */ + { 34093, 0x000084D5 }, /* GL_TEXTURE21 */ + { 34106, 0x000084D5 }, /* GL_TEXTURE21_ARB */ + { 34123, 0x000084D6 }, /* GL_TEXTURE22 */ + { 34136, 0x000084D6 }, /* GL_TEXTURE22_ARB */ + { 34153, 0x000084D7 }, /* GL_TEXTURE23 */ + { 34166, 0x000084D7 }, /* GL_TEXTURE23_ARB */ + { 34183, 0x000084D8 }, /* GL_TEXTURE24 */ + { 34196, 0x000084D8 }, /* GL_TEXTURE24_ARB */ + { 34213, 0x000084D9 }, /* GL_TEXTURE25 */ + { 34226, 0x000084D9 }, /* GL_TEXTURE25_ARB */ + { 34243, 0x000084DA }, /* GL_TEXTURE26 */ + { 34256, 0x000084DA }, /* GL_TEXTURE26_ARB */ + { 34273, 0x000084DB }, /* GL_TEXTURE27 */ + { 34286, 0x000084DB }, /* GL_TEXTURE27_ARB */ + { 34303, 0x000084DC }, /* GL_TEXTURE28 */ + { 34316, 0x000084DC }, /* GL_TEXTURE28_ARB */ + { 34333, 0x000084DD }, /* GL_TEXTURE29 */ + { 34346, 0x000084DD }, /* GL_TEXTURE29_ARB */ + { 34363, 0x000084C2 }, /* GL_TEXTURE2_ARB */ + { 34379, 0x000084C3 }, /* GL_TEXTURE3 */ + { 34391, 0x000084DE }, /* GL_TEXTURE30 */ + { 34404, 0x000084DE }, /* GL_TEXTURE30_ARB */ + { 34421, 0x000084DF }, /* GL_TEXTURE31 */ + { 34434, 0x000084DF }, /* GL_TEXTURE31_ARB */ + { 34451, 0x000084C3 }, /* GL_TEXTURE3_ARB */ + { 34467, 0x000084C4 }, /* GL_TEXTURE4 */ + { 34479, 0x000084C4 }, /* GL_TEXTURE4_ARB */ + { 34495, 0x000084C5 }, /* GL_TEXTURE5 */ + { 34507, 0x000084C5 }, /* GL_TEXTURE5_ARB */ + { 34523, 0x000084C6 }, /* GL_TEXTURE6 */ + { 34535, 0x000084C6 }, /* GL_TEXTURE6_ARB */ + { 34551, 0x000084C7 }, /* GL_TEXTURE7 */ + { 34563, 0x000084C7 }, /* GL_TEXTURE7_ARB */ + { 34579, 0x000084C8 }, /* GL_TEXTURE8 */ + { 34591, 0x000084C8 }, /* GL_TEXTURE8_ARB */ + { 34607, 0x000084C9 }, /* GL_TEXTURE9 */ + { 34619, 0x000084C9 }, /* GL_TEXTURE9_ARB */ + { 34635, 0x00000DE0 }, /* GL_TEXTURE_1D */ + { 34649, 0x00008C18 }, /* GL_TEXTURE_1D_ARRAY_EXT */ + { 34673, 0x00000DE1 }, /* GL_TEXTURE_2D */ + { 34687, 0x00008C1A }, /* GL_TEXTURE_2D_ARRAY_EXT */ + { 34711, 0x0000806F }, /* GL_TEXTURE_3D */ + { 34725, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE */ + { 34747, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE_EXT */ + { 34773, 0x0000813C }, /* GL_TEXTURE_BASE_LEVEL */ + { 34795, 0x00008068 }, /* GL_TEXTURE_BINDING_1D */ + { 34817, 0x00008C1C }, /* GL_TEXTURE_BINDING_1D_ARRAY_EXT */ + { 34849, 0x00008069 }, /* GL_TEXTURE_BINDING_2D */ + { 34871, 0x00008C1D }, /* GL_TEXTURE_BINDING_2D_ARRAY_EXT */ + { 34903, 0x0000806A }, /* GL_TEXTURE_BINDING_3D */ + { 34925, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP */ + { 34953, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP_ARB */ + { 34985, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */ + { 35018, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_NV */ + { 35050, 0x00040000 }, /* GL_TEXTURE_BIT */ + { 35065, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE */ + { 35086, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE_EXT */ + { 35111, 0x00001005 }, /* GL_TEXTURE_BORDER */ + { 35129, 0x00001004 }, /* GL_TEXTURE_BORDER_COLOR */ + { 35153, 0x00008171 }, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */ + { 35184, 0x00008176 }, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */ + { 35214, 0x00008172 }, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */ + { 35244, 0x00008175 }, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */ + { 35279, 0x00008173 }, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */ + { 35310, 0x00008174 }, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */ + { 35348, 0x000080BC }, /* GL_TEXTURE_COLOR_TABLE_SGI */ + { 35375, 0x000081EF }, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */ + { 35407, 0x000080BF }, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */ + { 35441, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC */ + { 35465, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC_ARB */ + { 35493, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE */ + { 35517, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE_ARB */ + { 35545, 0x0000819B }, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */ + { 35578, 0x0000819A }, /* GL_TEXTURE_COMPARE_SGIX */ + { 35602, 0x00001003 }, /* GL_TEXTURE_COMPONENTS */ + { 35624, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED */ + { 35646, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED_ARB */ + { 35672, 0x000086A3 }, /* GL_TEXTURE_COMPRESSED_FORMATS_ARB */ + { 35706, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */ + { 35739, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB */ + { 35776, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT */ + { 35804, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT_ARB */ + { 35836, 0x00008078 }, /* GL_TEXTURE_COORD_ARRAY */ + { 35859, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */ + { 35897, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB */ + { 35939, 0x00008092 }, /* GL_TEXTURE_COORD_ARRAY_POINTER */ + { 35970, 0x00008088 }, /* GL_TEXTURE_COORD_ARRAY_SIZE */ + { 35998, 0x0000808A }, /* GL_TEXTURE_COORD_ARRAY_STRIDE */ + { 36028, 0x00008089 }, /* GL_TEXTURE_COORD_ARRAY_TYPE */ + { 36056, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP */ + { 36076, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP_ARB */ + { 36100, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */ + { 36131, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB */ + { 36166, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */ + { 36197, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB */ + { 36232, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */ + { 36263, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB */ + { 36298, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */ + { 36329, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB */ + { 36364, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */ + { 36395, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB */ + { 36430, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */ + { 36461, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB */ + { 36496, 0x000088F4 }, /* GL_TEXTURE_CUBE_MAP_SEAMLESS */ + { 36525, 0x00008071 }, /* GL_TEXTURE_DEPTH */ + { 36542, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE */ + { 36564, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE_ARB */ + { 36590, 0x00002300 }, /* GL_TEXTURE_ENV */ + { 36605, 0x00002201 }, /* GL_TEXTURE_ENV_COLOR */ + { 36626, 0x00002200 }, /* GL_TEXTURE_ENV_MODE */ + { 36646, 0x00008500 }, /* GL_TEXTURE_FILTER_CONTROL */ + { 36672, 0x00002500 }, /* GL_TEXTURE_GEN_MODE */ + { 36692, 0x00000C63 }, /* GL_TEXTURE_GEN_Q */ + { 36709, 0x00000C62 }, /* GL_TEXTURE_GEN_R */ + { 36726, 0x00000C60 }, /* GL_TEXTURE_GEN_S */ + { 36743, 0x00000C61 }, /* GL_TEXTURE_GEN_T */ + { 36760, 0x0000819D }, /* GL_TEXTURE_GEQUAL_R_SGIX */ + { 36785, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE */ + { 36807, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE_EXT */ + { 36833, 0x00001001 }, /* GL_TEXTURE_HEIGHT */ + { 36851, 0x000080ED }, /* GL_TEXTURE_INDEX_SIZE_EXT */ + { 36877, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE */ + { 36903, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE_EXT */ + { 36933, 0x00001003 }, /* GL_TEXTURE_INTERNAL_FORMAT */ + { 36960, 0x0000819C }, /* GL_TEXTURE_LEQUAL_R_SGIX */ + { 36985, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS */ + { 37005, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS_EXT */ + { 37029, 0x00008190 }, /* GL_TEXTURE_LOD_BIAS_R_SGIX */ + { 37056, 0x0000818E }, /* GL_TEXTURE_LOD_BIAS_S_SGIX */ + { 37083, 0x0000818F }, /* GL_TEXTURE_LOD_BIAS_T_SGIX */ + { 37110, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE */ + { 37136, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE_EXT */ + { 37166, 0x00002800 }, /* GL_TEXTURE_MAG_FILTER */ + { 37188, 0x00000BA8 }, /* GL_TEXTURE_MATRIX */ + { 37206, 0x000084FE }, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */ + { 37236, 0x0000836B }, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */ + { 37264, 0x00008369 }, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */ + { 37292, 0x0000836A }, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */ + { 37320, 0x0000813D }, /* GL_TEXTURE_MAX_LEVEL */ + { 37341, 0x0000813B }, /* GL_TEXTURE_MAX_LOD */ + { 37360, 0x00002801 }, /* GL_TEXTURE_MIN_FILTER */ + { 37382, 0x0000813A }, /* GL_TEXTURE_MIN_LOD */ + { 37401, 0x00008066 }, /* GL_TEXTURE_PRIORITY */ + { 37421, 0x000085B7 }, /* GL_TEXTURE_RANGE_LENGTH_APPLE */ + { 37451, 0x000085B8 }, /* GL_TEXTURE_RANGE_POINTER_APPLE */ + { 37482, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_ARB */ + { 37507, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_NV */ + { 37531, 0x0000805C }, /* GL_TEXTURE_RED_SIZE */ + { 37551, 0x0000805C }, /* GL_TEXTURE_RED_SIZE_EXT */ + { 37575, 0x00008067 }, /* GL_TEXTURE_RESIDENT */ + { 37595, 0x00000BA5 }, /* GL_TEXTURE_STACK_DEPTH */ + { 37618, 0x000088F1 }, /* GL_TEXTURE_STENCIL_SIZE */ + { 37642, 0x000088F1 }, /* GL_TEXTURE_STENCIL_SIZE_EXT */ + { 37670, 0x000085BC }, /* GL_TEXTURE_STORAGE_HINT_APPLE */ + { 37700, 0x00008065 }, /* GL_TEXTURE_TOO_LARGE_EXT */ + { 37725, 0x0000888F }, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */ + { 37759, 0x00001000 }, /* GL_TEXTURE_WIDTH */ + { 37776, 0x00008072 }, /* GL_TEXTURE_WRAP_R */ + { 37794, 0x00002802 }, /* GL_TEXTURE_WRAP_S */ + { 37812, 0x00002803 }, /* GL_TEXTURE_WRAP_T */ + { 37830, 0x0000911B }, /* GL_TIMEOUT_EXPIRED */ + { 37849, 0x000088BF }, /* GL_TIME_ELAPSED_EXT */ + { 37869, 0x00008648 }, /* GL_TRACK_MATRIX_NV */ + { 37888, 0x00008649 }, /* GL_TRACK_MATRIX_TRANSFORM_NV */ + { 37917, 0x00001000 }, /* GL_TRANSFORM_BIT */ + { 37934, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX */ + { 37960, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX_ARB */ + { 37990, 0x000088B7 }, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */ + { 38022, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX */ + { 38052, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX_ARB */ + { 38086, 0x0000862C }, /* GL_TRANSPOSE_NV */ + { 38102, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX */ + { 38133, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX_ARB */ + { 38168, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX */ + { 38196, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX_ARB */ + { 38228, 0x00000004 }, /* GL_TRIANGLES */ + { 38241, 0x00000006 }, /* GL_TRIANGLE_FAN */ + { 38257, 0x00008615 }, /* GL_TRIANGLE_MESH_SUN */ + { 38278, 0x00000005 }, /* GL_TRIANGLE_STRIP */ + { 38296, 0x00000001 }, /* GL_TRUE */ + { 38304, 0x00000CF5 }, /* GL_UNPACK_ALIGNMENT */ + { 38324, 0x0000806E }, /* GL_UNPACK_IMAGE_HEIGHT */ + { 38347, 0x00000CF1 }, /* GL_UNPACK_LSB_FIRST */ + { 38367, 0x00000CF2 }, /* GL_UNPACK_ROW_LENGTH */ + { 38388, 0x0000806D }, /* GL_UNPACK_SKIP_IMAGES */ + { 38410, 0x00000CF4 }, /* GL_UNPACK_SKIP_PIXELS */ + { 38432, 0x00000CF3 }, /* GL_UNPACK_SKIP_ROWS */ + { 38452, 0x00000CF0 }, /* GL_UNPACK_SWAP_BYTES */ + { 38473, 0x00009118 }, /* GL_UNSIGNALED */ + { 38487, 0x00001401 }, /* GL_UNSIGNED_BYTE */ + { 38504, 0x00008362 }, /* GL_UNSIGNED_BYTE_2_3_3_REV */ + { 38531, 0x00008032 }, /* GL_UNSIGNED_BYTE_3_3_2 */ + { 38554, 0x00001405 }, /* GL_UNSIGNED_INT */ + { 38570, 0x00008036 }, /* GL_UNSIGNED_INT_10_10_10_2 */ + { 38597, 0x000084FA }, /* GL_UNSIGNED_INT_24_8 */ + { 38618, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_EXT */ + { 38643, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_NV */ + { 38667, 0x00008368 }, /* GL_UNSIGNED_INT_2_10_10_10_REV */ + { 38698, 0x00008035 }, /* GL_UNSIGNED_INT_8_8_8_8 */ + { 38722, 0x00008367 }, /* GL_UNSIGNED_INT_8_8_8_8_REV */ + { 38750, 0x00008C17 }, /* GL_UNSIGNED_NORMALIZED */ + { 38773, 0x00001403 }, /* GL_UNSIGNED_SHORT */ + { 38791, 0x00008366 }, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */ + { 38821, 0x00008033 }, /* GL_UNSIGNED_SHORT_4_4_4_4 */ + { 38847, 0x00008365 }, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */ + { 38877, 0x00008034 }, /* GL_UNSIGNED_SHORT_5_5_5_1 */ + { 38903, 0x00008363 }, /* GL_UNSIGNED_SHORT_5_6_5 */ + { 38927, 0x00008364 }, /* GL_UNSIGNED_SHORT_5_6_5_REV */ + { 38955, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_APPLE */ + { 38983, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_MESA */ + { 39010, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */ + { 39042, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_MESA */ + { 39073, 0x00008CA2 }, /* GL_UPPER_LEFT */ + { 39087, 0x00002A20 }, /* GL_V2F */ + { 39094, 0x00002A21 }, /* GL_V3F */ + { 39101, 0x00008B83 }, /* GL_VALIDATE_STATUS */ + { 39120, 0x00001F00 }, /* GL_VENDOR */ + { 39130, 0x00001F02 }, /* GL_VERSION */ + { 39141, 0x00008074 }, /* GL_VERTEX_ARRAY */ + { 39157, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING */ + { 39181, 0x000085B5 }, /* GL_VERTEX_ARRAY_BINDING_APPLE */ + { 39211, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING */ + { 39242, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING_ARB */ + { 39277, 0x0000808E }, /* GL_VERTEX_ARRAY_POINTER */ + { 39301, 0x0000807A }, /* GL_VERTEX_ARRAY_SIZE */ + { 39322, 0x0000807C }, /* GL_VERTEX_ARRAY_STRIDE */ + { 39345, 0x0000807B }, /* GL_VERTEX_ARRAY_TYPE */ + { 39366, 0x00008650 }, /* GL_VERTEX_ATTRIB_ARRAY0_NV */ + { 39393, 0x0000865A }, /* GL_VERTEX_ATTRIB_ARRAY10_NV */ + { 39421, 0x0000865B }, /* GL_VERTEX_ATTRIB_ARRAY11_NV */ + { 39449, 0x0000865C }, /* GL_VERTEX_ATTRIB_ARRAY12_NV */ + { 39477, 0x0000865D }, /* GL_VERTEX_ATTRIB_ARRAY13_NV */ + { 39505, 0x0000865E }, /* GL_VERTEX_ATTRIB_ARRAY14_NV */ + { 39533, 0x0000865F }, /* GL_VERTEX_ATTRIB_ARRAY15_NV */ + { 39561, 0x00008651 }, /* GL_VERTEX_ATTRIB_ARRAY1_NV */ + { 39588, 0x00008652 }, /* GL_VERTEX_ATTRIB_ARRAY2_NV */ + { 39615, 0x00008653 }, /* GL_VERTEX_ATTRIB_ARRAY3_NV */ + { 39642, 0x00008654 }, /* GL_VERTEX_ATTRIB_ARRAY4_NV */ + { 39669, 0x00008655 }, /* GL_VERTEX_ATTRIB_ARRAY5_NV */ + { 39696, 0x00008656 }, /* GL_VERTEX_ATTRIB_ARRAY6_NV */ + { 39723, 0x00008657 }, /* GL_VERTEX_ATTRIB_ARRAY7_NV */ + { 39750, 0x00008658 }, /* GL_VERTEX_ATTRIB_ARRAY8_NV */ + { 39777, 0x00008659 }, /* GL_VERTEX_ATTRIB_ARRAY9_NV */ + { 39804, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */ + { 39842, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB */ + { 39884, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */ + { 39915, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB */ + { 39950, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */ + { 39984, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB */ + { 40022, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */ + { 40053, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB */ + { 40088, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */ + { 40116, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB */ + { 40148, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */ + { 40178, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB */ + { 40212, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */ + { 40240, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB */ + { 40272, 0x000086A7 }, /* GL_VERTEX_BLEND_ARB */ + { 40292, 0x00008620 }, /* GL_VERTEX_PROGRAM_ARB */ + { 40314, 0x0000864A }, /* GL_VERTEX_PROGRAM_BINDING_NV */ + { 40343, 0x00008620 }, /* GL_VERTEX_PROGRAM_NV */ + { 40364, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE */ + { 40393, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_ARB */ + { 40426, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_NV */ + { 40458, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE */ + { 40485, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_ARB */ + { 40516, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_NV */ + { 40546, 0x00008B31 }, /* GL_VERTEX_SHADER */ + { 40563, 0x00008B31 }, /* GL_VERTEX_SHADER_ARB */ + { 40584, 0x00008621 }, /* GL_VERTEX_STATE_PROGRAM_NV */ + { 40611, 0x00000BA2 }, /* GL_VIEWPORT */ + { 40623, 0x00000800 }, /* GL_VIEWPORT_BIT */ + { 40639, 0x0000911D }, /* GL_WAIT_FAILED */ + { 40654, 0x000086AD }, /* GL_WEIGHT_ARRAY_ARB */ + { 40674, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */ + { 40705, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB */ + { 40740, 0x000086AC }, /* GL_WEIGHT_ARRAY_POINTER_ARB */ + { 40768, 0x000086AB }, /* GL_WEIGHT_ARRAY_SIZE_ARB */ + { 40793, 0x000086AA }, /* GL_WEIGHT_ARRAY_STRIDE_ARB */ + { 40820, 0x000086A9 }, /* GL_WEIGHT_ARRAY_TYPE_ARB */ + { 40845, 0x000086A6 }, /* GL_WEIGHT_SUM_UNITY_ARB */ + { 40869, 0x000081D4 }, /* GL_WRAP_BORDER_SUN */ + { 40888, 0x000088B9 }, /* GL_WRITE_ONLY */ + { 40902, 0x000088B9 }, /* GL_WRITE_ONLY_ARB */ + { 40920, 0x00001506 }, /* GL_XOR */ + { 40927, 0x000085B9 }, /* GL_YCBCR_422_APPLE */ + { 40946, 0x00008757 }, /* GL_YCBCR_MESA */ + { 40960, 0x00000000 }, /* GL_ZERO */ + { 40968, 0x00000D16 }, /* GL_ZOOM_X */ + { 40978, 0x00000D17 }, /* GL_ZOOM_Y */ }; -static const unsigned reduced_enums[1350] = +static const unsigned reduced_enums[1351] = { 479, /* GL_FALSE */ - 701, /* GL_LINES */ - 703, /* GL_LINE_LOOP */ - 710, /* GL_LINE_STRIP */ - 1769, /* GL_TRIANGLES */ - 1772, /* GL_TRIANGLE_STRIP */ - 1770, /* GL_TRIANGLE_FAN */ - 1285, /* GL_QUADS */ - 1289, /* GL_QUAD_STRIP */ - 1171, /* GL_POLYGON */ - 1183, /* GL_POLYGON_STIPPLE_BIT */ - 1132, /* GL_PIXEL_MODE_BIT */ - 688, /* GL_LIGHTING_BIT */ + 702, /* GL_LINES */ + 704, /* GL_LINE_LOOP */ + 711, /* GL_LINE_STRIP */ + 1770, /* GL_TRIANGLES */ + 1773, /* GL_TRIANGLE_STRIP */ + 1771, /* GL_TRIANGLE_FAN */ + 1286, /* GL_QUADS */ + 1290, /* GL_QUAD_STRIP */ + 1172, /* GL_POLYGON */ + 1184, /* GL_POLYGON_STIPPLE_BIT */ + 1133, /* GL_PIXEL_MODE_BIT */ + 689, /* GL_LIGHTING_BIT */ 509, /* GL_FOG_BIT */ 8, /* GL_ACCUM */ - 720, /* GL_LOAD */ - 1348, /* GL_RETURN */ - 1004, /* GL_MULT */ + 721, /* GL_LOAD */ + 1349, /* GL_RETURN */ + 1005, /* GL_MULT */ 23, /* GL_ADD */ - 1020, /* GL_NEVER */ - 678, /* GL_LESS */ + 1021, /* GL_NEVER */ + 679, /* GL_LESS */ 469, /* GL_EQUAL */ - 677, /* GL_LEQUAL */ + 678, /* GL_LEQUAL */ 599, /* GL_GREATER */ - 1035, /* GL_NOTEQUAL */ + 1036, /* GL_NOTEQUAL */ 598, /* GL_GEQUAL */ 47, /* GL_ALWAYS */ - 1489, /* GL_SRC_COLOR */ - 1065, /* GL_ONE_MINUS_SRC_COLOR */ - 1487, /* GL_SRC_ALPHA */ - 1064, /* GL_ONE_MINUS_SRC_ALPHA */ + 1490, /* GL_SRC_COLOR */ + 1066, /* GL_ONE_MINUS_SRC_COLOR */ + 1488, /* GL_SRC_ALPHA */ + 1065, /* GL_ONE_MINUS_SRC_ALPHA */ 448, /* GL_DST_ALPHA */ - 1062, /* GL_ONE_MINUS_DST_ALPHA */ + 1063, /* GL_ONE_MINUS_DST_ALPHA */ 449, /* GL_DST_COLOR */ - 1063, /* GL_ONE_MINUS_DST_COLOR */ - 1488, /* GL_SRC_ALPHA_SATURATE */ + 1064, /* GL_ONE_MINUS_DST_COLOR */ + 1489, /* GL_SRC_ALPHA_SATURATE */ 586, /* GL_FRONT_LEFT */ 587, /* GL_FRONT_RIGHT */ 69, /* GL_BACK_LEFT */ 70, /* GL_BACK_RIGHT */ 583, /* GL_FRONT */ 68, /* GL_BACK */ - 676, /* GL_LEFT */ - 1390, /* GL_RIGHT */ + 677, /* GL_LEFT */ + 1391, /* GL_RIGHT */ 584, /* GL_FRONT_AND_BACK */ 63, /* GL_AUX0 */ 64, /* GL_AUX1 */ 65, /* GL_AUX2 */ 66, /* GL_AUX3 */ - 665, /* GL_INVALID_ENUM */ - 669, /* GL_INVALID_VALUE */ - 668, /* GL_INVALID_OPERATION */ - 1494, /* GL_STACK_OVERFLOW */ - 1495, /* GL_STACK_UNDERFLOW */ - 1090, /* GL_OUT_OF_MEMORY */ - 666, /* GL_INVALID_FRAMEBUFFER_OPERATION */ + 666, /* GL_INVALID_ENUM */ + 670, /* GL_INVALID_VALUE */ + 669, /* GL_INVALID_OPERATION */ + 1495, /* GL_STACK_OVERFLOW */ + 1496, /* GL_STACK_UNDERFLOW */ + 1091, /* GL_OUT_OF_MEMORY */ + 667, /* GL_INVALID_FRAMEBUFFER_OPERATION */ 0, /* GL_2D */ 2, /* GL_3D */ 3, /* GL_3D_COLOR */ 4, /* GL_3D_COLOR_TEXTURE */ 6, /* GL_4D_COLOR_TEXTURE */ - 1110, /* GL_PASS_THROUGH_TOKEN */ - 1170, /* GL_POINT_TOKEN */ - 711, /* GL_LINE_TOKEN */ - 1184, /* GL_POLYGON_TOKEN */ + 1111, /* GL_PASS_THROUGH_TOKEN */ + 1171, /* GL_POINT_TOKEN */ + 712, /* GL_LINE_TOKEN */ + 1185, /* GL_POLYGON_TOKEN */ 74, /* GL_BITMAP_TOKEN */ 447, /* GL_DRAW_PIXEL_TOKEN */ 301, /* GL_COPY_PIXEL_TOKEN */ - 704, /* GL_LINE_RESET_TOKEN */ + 705, /* GL_LINE_RESET_TOKEN */ 472, /* GL_EXP */ 473, /* GL_EXP2 */ 337, /* GL_CW */ 125, /* GL_CCW */ 146, /* GL_COEFF */ - 1087, /* GL_ORDER */ + 1088, /* GL_ORDER */ 384, /* GL_DOMAIN */ 311, /* GL_CURRENT_COLOR */ 314, /* GL_CURRENT_INDEX */ @@ -3898,33 +3900,33 @@ static const unsigned reduced_enums[1350] = 328, /* GL_CURRENT_RASTER_POSITION */ 329, /* GL_CURRENT_RASTER_POSITION_VALID */ 326, /* GL_CURRENT_RASTER_DISTANCE */ - 1163, /* GL_POINT_SMOOTH */ - 1152, /* GL_POINT_SIZE */ - 1162, /* GL_POINT_SIZE_RANGE */ - 1153, /* GL_POINT_SIZE_GRANULARITY */ - 705, /* GL_LINE_SMOOTH */ - 712, /* GL_LINE_WIDTH */ - 714, /* GL_LINE_WIDTH_RANGE */ - 713, /* GL_LINE_WIDTH_GRANULARITY */ - 707, /* GL_LINE_STIPPLE */ - 708, /* GL_LINE_STIPPLE_PATTERN */ - 709, /* GL_LINE_STIPPLE_REPEAT */ - 719, /* GL_LIST_MODE */ - 885, /* GL_MAX_LIST_NESTING */ - 716, /* GL_LIST_BASE */ - 718, /* GL_LIST_INDEX */ - 1173, /* GL_POLYGON_MODE */ - 1180, /* GL_POLYGON_SMOOTH */ - 1182, /* GL_POLYGON_STIPPLE */ + 1164, /* GL_POINT_SMOOTH */ + 1153, /* GL_POINT_SIZE */ + 1163, /* GL_POINT_SIZE_RANGE */ + 1154, /* GL_POINT_SIZE_GRANULARITY */ + 706, /* GL_LINE_SMOOTH */ + 713, /* GL_LINE_WIDTH */ + 715, /* GL_LINE_WIDTH_RANGE */ + 714, /* GL_LINE_WIDTH_GRANULARITY */ + 708, /* GL_LINE_STIPPLE */ + 709, /* GL_LINE_STIPPLE_PATTERN */ + 710, /* GL_LINE_STIPPLE_REPEAT */ + 720, /* GL_LIST_MODE */ + 886, /* GL_MAX_LIST_NESTING */ + 717, /* GL_LIST_BASE */ + 719, /* GL_LIST_INDEX */ + 1174, /* GL_POLYGON_MODE */ + 1181, /* GL_POLYGON_SMOOTH */ + 1183, /* GL_POLYGON_STIPPLE */ 458, /* GL_EDGE_FLAG */ 304, /* GL_CULL_FACE */ 305, /* GL_CULL_FACE_MODE */ 585, /* GL_FRONT_FACE */ - 687, /* GL_LIGHTING */ - 692, /* GL_LIGHT_MODEL_LOCAL_VIEWER */ - 693, /* GL_LIGHT_MODEL_TWO_SIDE */ - 689, /* GL_LIGHT_MODEL_AMBIENT */ - 1436, /* GL_SHADE_MODEL */ + 688, /* GL_LIGHTING */ + 693, /* GL_LIGHT_MODEL_LOCAL_VIEWER */ + 694, /* GL_LIGHT_MODEL_TWO_SIDE */ + 690, /* GL_LIGHT_MODEL_AMBIENT */ + 1437, /* GL_SHADE_MODEL */ 193, /* GL_COLOR_MATERIAL_FACE */ 194, /* GL_COLOR_MATERIAL_PARAMETER */ 192, /* GL_COLOR_MATERIAL */ @@ -3941,24 +3943,24 @@ static const unsigned reduced_enums[1350] = 358, /* GL_DEPTH_CLEAR_VALUE */ 369, /* GL_DEPTH_FUNC */ 12, /* GL_ACCUM_CLEAR_VALUE */ - 1534, /* GL_STENCIL_TEST */ - 1518, /* GL_STENCIL_CLEAR_VALUE */ - 1520, /* GL_STENCIL_FUNC */ - 1536, /* GL_STENCIL_VALUE_MASK */ - 1519, /* GL_STENCIL_FAIL */ - 1531, /* GL_STENCIL_PASS_DEPTH_FAIL */ - 1532, /* GL_STENCIL_PASS_DEPTH_PASS */ - 1533, /* GL_STENCIL_REF */ - 1537, /* GL_STENCIL_WRITEMASK */ - 853, /* GL_MATRIX_MODE */ - 1025, /* GL_NORMALIZE */ - 1864, /* GL_VIEWPORT */ - 999, /* GL_MODELVIEW_STACK_DEPTH */ - 1263, /* GL_PROJECTION_STACK_DEPTH */ - 1744, /* GL_TEXTURE_STACK_DEPTH */ - 997, /* GL_MODELVIEW_MATRIX */ - 1262, /* GL_PROJECTION_MATRIX */ - 1727, /* GL_TEXTURE_MATRIX */ + 1535, /* GL_STENCIL_TEST */ + 1519, /* GL_STENCIL_CLEAR_VALUE */ + 1521, /* GL_STENCIL_FUNC */ + 1537, /* GL_STENCIL_VALUE_MASK */ + 1520, /* GL_STENCIL_FAIL */ + 1532, /* GL_STENCIL_PASS_DEPTH_FAIL */ + 1533, /* GL_STENCIL_PASS_DEPTH_PASS */ + 1534, /* GL_STENCIL_REF */ + 1538, /* GL_STENCIL_WRITEMASK */ + 854, /* GL_MATRIX_MODE */ + 1026, /* GL_NORMALIZE */ + 1865, /* GL_VIEWPORT */ + 1000, /* GL_MODELVIEW_STACK_DEPTH */ + 1264, /* GL_PROJECTION_STACK_DEPTH */ + 1745, /* GL_TEXTURE_STACK_DEPTH */ + 998, /* GL_MODELVIEW_MATRIX */ + 1263, /* GL_PROJECTION_MATRIX */ + 1728, /* GL_TEXTURE_MATRIX */ 61, /* GL_ATTRIB_STACK_DEPTH */ 136, /* GL_CLIENT_ATTRIB_STACK_DEPTH */ 43, /* GL_ALPHA_TEST */ @@ -3968,72 +3970,72 @@ static const unsigned reduced_enums[1350] = 78, /* GL_BLEND_DST */ 87, /* GL_BLEND_SRC */ 75, /* GL_BLEND */ - 722, /* GL_LOGIC_OP_MODE */ - 639, /* GL_INDEX_LOGIC_OP */ + 723, /* GL_LOGIC_OP_MODE */ + 640, /* GL_INDEX_LOGIC_OP */ 191, /* GL_COLOR_LOGIC_OP */ 67, /* GL_AUX_BUFFERS */ 394, /* GL_DRAW_BUFFER */ - 1303, /* GL_READ_BUFFER */ - 1417, /* GL_SCISSOR_BOX */ - 1418, /* GL_SCISSOR_TEST */ - 638, /* GL_INDEX_CLEAR_VALUE */ - 643, /* GL_INDEX_WRITEMASK */ + 1304, /* GL_READ_BUFFER */ + 1418, /* GL_SCISSOR_BOX */ + 1419, /* GL_SCISSOR_TEST */ + 639, /* GL_INDEX_CLEAR_VALUE */ + 644, /* GL_INDEX_WRITEMASK */ 188, /* GL_COLOR_CLEAR_VALUE */ 230, /* GL_COLOR_WRITEMASK */ - 640, /* GL_INDEX_MODE */ - 1383, /* GL_RGBA_MODE */ + 641, /* GL_INDEX_MODE */ + 1384, /* GL_RGBA_MODE */ 393, /* GL_DOUBLEBUFFER */ - 1538, /* GL_STEREO */ - 1341, /* GL_RENDER_MODE */ - 1111, /* GL_PERSPECTIVE_CORRECTION_HINT */ - 1164, /* GL_POINT_SMOOTH_HINT */ - 706, /* GL_LINE_SMOOTH_HINT */ - 1181, /* GL_POLYGON_SMOOTH_HINT */ + 1539, /* GL_STEREO */ + 1342, /* GL_RENDER_MODE */ + 1112, /* GL_PERSPECTIVE_CORRECTION_HINT */ + 1165, /* GL_POINT_SMOOTH_HINT */ + 707, /* GL_LINE_SMOOTH_HINT */ + 1182, /* GL_POLYGON_SMOOTH_HINT */ 529, /* GL_FOG_HINT */ - 1708, /* GL_TEXTURE_GEN_S */ - 1709, /* GL_TEXTURE_GEN_T */ - 1707, /* GL_TEXTURE_GEN_R */ - 1706, /* GL_TEXTURE_GEN_Q */ - 1124, /* GL_PIXEL_MAP_I_TO_I */ - 1130, /* GL_PIXEL_MAP_S_TO_S */ - 1126, /* GL_PIXEL_MAP_I_TO_R */ - 1122, /* GL_PIXEL_MAP_I_TO_G */ - 1120, /* GL_PIXEL_MAP_I_TO_B */ - 1118, /* GL_PIXEL_MAP_I_TO_A */ - 1128, /* GL_PIXEL_MAP_R_TO_R */ - 1116, /* GL_PIXEL_MAP_G_TO_G */ - 1114, /* GL_PIXEL_MAP_B_TO_B */ - 1112, /* GL_PIXEL_MAP_A_TO_A */ - 1125, /* GL_PIXEL_MAP_I_TO_I_SIZE */ - 1131, /* GL_PIXEL_MAP_S_TO_S_SIZE */ - 1127, /* GL_PIXEL_MAP_I_TO_R_SIZE */ - 1123, /* GL_PIXEL_MAP_I_TO_G_SIZE */ - 1121, /* GL_PIXEL_MAP_I_TO_B_SIZE */ - 1119, /* GL_PIXEL_MAP_I_TO_A_SIZE */ - 1129, /* GL_PIXEL_MAP_R_TO_R_SIZE */ - 1117, /* GL_PIXEL_MAP_G_TO_G_SIZE */ - 1115, /* GL_PIXEL_MAP_B_TO_B_SIZE */ - 1113, /* GL_PIXEL_MAP_A_TO_A_SIZE */ - 1781, /* GL_UNPACK_SWAP_BYTES */ - 1776, /* GL_UNPACK_LSB_FIRST */ - 1777, /* GL_UNPACK_ROW_LENGTH */ - 1780, /* GL_UNPACK_SKIP_ROWS */ - 1779, /* GL_UNPACK_SKIP_PIXELS */ - 1774, /* GL_UNPACK_ALIGNMENT */ - 1099, /* GL_PACK_SWAP_BYTES */ - 1094, /* GL_PACK_LSB_FIRST */ - 1095, /* GL_PACK_ROW_LENGTH */ - 1098, /* GL_PACK_SKIP_ROWS */ - 1097, /* GL_PACK_SKIP_PIXELS */ - 1091, /* GL_PACK_ALIGNMENT */ - 800, /* GL_MAP_COLOR */ - 805, /* GL_MAP_STENCIL */ - 642, /* GL_INDEX_SHIFT */ - 641, /* GL_INDEX_OFFSET */ - 1317, /* GL_RED_SCALE */ - 1315, /* GL_RED_BIAS */ - 1882, /* GL_ZOOM_X */ - 1883, /* GL_ZOOM_Y */ + 1709, /* GL_TEXTURE_GEN_S */ + 1710, /* GL_TEXTURE_GEN_T */ + 1708, /* GL_TEXTURE_GEN_R */ + 1707, /* GL_TEXTURE_GEN_Q */ + 1125, /* GL_PIXEL_MAP_I_TO_I */ + 1131, /* GL_PIXEL_MAP_S_TO_S */ + 1127, /* GL_PIXEL_MAP_I_TO_R */ + 1123, /* GL_PIXEL_MAP_I_TO_G */ + 1121, /* GL_PIXEL_MAP_I_TO_B */ + 1119, /* GL_PIXEL_MAP_I_TO_A */ + 1129, /* GL_PIXEL_MAP_R_TO_R */ + 1117, /* GL_PIXEL_MAP_G_TO_G */ + 1115, /* GL_PIXEL_MAP_B_TO_B */ + 1113, /* GL_PIXEL_MAP_A_TO_A */ + 1126, /* GL_PIXEL_MAP_I_TO_I_SIZE */ + 1132, /* GL_PIXEL_MAP_S_TO_S_SIZE */ + 1128, /* GL_PIXEL_MAP_I_TO_R_SIZE */ + 1124, /* GL_PIXEL_MAP_I_TO_G_SIZE */ + 1122, /* GL_PIXEL_MAP_I_TO_B_SIZE */ + 1120, /* GL_PIXEL_MAP_I_TO_A_SIZE */ + 1130, /* GL_PIXEL_MAP_R_TO_R_SIZE */ + 1118, /* GL_PIXEL_MAP_G_TO_G_SIZE */ + 1116, /* GL_PIXEL_MAP_B_TO_B_SIZE */ + 1114, /* GL_PIXEL_MAP_A_TO_A_SIZE */ + 1782, /* GL_UNPACK_SWAP_BYTES */ + 1777, /* GL_UNPACK_LSB_FIRST */ + 1778, /* GL_UNPACK_ROW_LENGTH */ + 1781, /* GL_UNPACK_SKIP_ROWS */ + 1780, /* GL_UNPACK_SKIP_PIXELS */ + 1775, /* GL_UNPACK_ALIGNMENT */ + 1100, /* GL_PACK_SWAP_BYTES */ + 1095, /* GL_PACK_LSB_FIRST */ + 1096, /* GL_PACK_ROW_LENGTH */ + 1099, /* GL_PACK_SKIP_ROWS */ + 1098, /* GL_PACK_SKIP_PIXELS */ + 1092, /* GL_PACK_ALIGNMENT */ + 801, /* GL_MAP_COLOR */ + 806, /* GL_MAP_STENCIL */ + 643, /* GL_INDEX_SHIFT */ + 642, /* GL_INDEX_OFFSET */ + 1318, /* GL_RED_SCALE */ + 1316, /* GL_RED_BIAS */ + 1883, /* GL_ZOOM_X */ + 1884, /* GL_ZOOM_Y */ 603, /* GL_GREEN_SCALE */ 601, /* GL_GREEN_BIAS */ 93, /* GL_BLUE_SCALE */ @@ -4042,375 +4044,376 @@ static const unsigned reduced_enums[1350] = 40, /* GL_ALPHA_BIAS */ 371, /* GL_DEPTH_SCALE */ 351, /* GL_DEPTH_BIAS */ - 880, /* GL_MAX_EVAL_ORDER */ - 884, /* GL_MAX_LIGHTS */ - 862, /* GL_MAX_CLIP_PLANES */ - 932, /* GL_MAX_TEXTURE_SIZE */ - 890, /* GL_MAX_PIXEL_MAP_TABLE */ - 858, /* GL_MAX_ATTRIB_STACK_DEPTH */ - 887, /* GL_MAX_MODELVIEW_STACK_DEPTH */ - 888, /* GL_MAX_NAME_STACK_DEPTH */ - 916, /* GL_MAX_PROJECTION_STACK_DEPTH */ - 933, /* GL_MAX_TEXTURE_STACK_DEPTH */ - 947, /* GL_MAX_VIEWPORT_DIMS */ - 859, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */ - 1548, /* GL_SUBPIXEL_BITS */ - 637, /* GL_INDEX_BITS */ - 1316, /* GL_RED_BITS */ + 881, /* GL_MAX_EVAL_ORDER */ + 885, /* GL_MAX_LIGHTS */ + 863, /* GL_MAX_CLIP_PLANES */ + 933, /* GL_MAX_TEXTURE_SIZE */ + 891, /* GL_MAX_PIXEL_MAP_TABLE */ + 859, /* GL_MAX_ATTRIB_STACK_DEPTH */ + 888, /* GL_MAX_MODELVIEW_STACK_DEPTH */ + 889, /* GL_MAX_NAME_STACK_DEPTH */ + 917, /* GL_MAX_PROJECTION_STACK_DEPTH */ + 934, /* GL_MAX_TEXTURE_STACK_DEPTH */ + 948, /* GL_MAX_VIEWPORT_DIMS */ + 860, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */ + 1549, /* GL_SUBPIXEL_BITS */ + 638, /* GL_INDEX_BITS */ + 1317, /* GL_RED_BITS */ 602, /* GL_GREEN_BITS */ 92, /* GL_BLUE_BITS */ 41, /* GL_ALPHA_BITS */ 352, /* GL_DEPTH_BITS */ - 1516, /* GL_STENCIL_BITS */ + 1517, /* GL_STENCIL_BITS */ 14, /* GL_ACCUM_RED_BITS */ 13, /* GL_ACCUM_GREEN_BITS */ 10, /* GL_ACCUM_BLUE_BITS */ 9, /* GL_ACCUM_ALPHA_BITS */ - 1013, /* GL_NAME_STACK_DEPTH */ + 1014, /* GL_NAME_STACK_DEPTH */ 62, /* GL_AUTO_NORMAL */ - 746, /* GL_MAP1_COLOR_4 */ - 749, /* GL_MAP1_INDEX */ - 750, /* GL_MAP1_NORMAL */ - 751, /* GL_MAP1_TEXTURE_COORD_1 */ - 752, /* GL_MAP1_TEXTURE_COORD_2 */ - 753, /* GL_MAP1_TEXTURE_COORD_3 */ - 754, /* GL_MAP1_TEXTURE_COORD_4 */ - 755, /* GL_MAP1_VERTEX_3 */ - 756, /* GL_MAP1_VERTEX_4 */ - 773, /* GL_MAP2_COLOR_4 */ - 776, /* GL_MAP2_INDEX */ - 777, /* GL_MAP2_NORMAL */ - 778, /* GL_MAP2_TEXTURE_COORD_1 */ - 779, /* GL_MAP2_TEXTURE_COORD_2 */ - 780, /* GL_MAP2_TEXTURE_COORD_3 */ - 781, /* GL_MAP2_TEXTURE_COORD_4 */ - 782, /* GL_MAP2_VERTEX_3 */ - 783, /* GL_MAP2_VERTEX_4 */ - 747, /* GL_MAP1_GRID_DOMAIN */ - 748, /* GL_MAP1_GRID_SEGMENTS */ - 774, /* GL_MAP2_GRID_DOMAIN */ - 775, /* GL_MAP2_GRID_SEGMENTS */ - 1631, /* GL_TEXTURE_1D */ - 1633, /* GL_TEXTURE_2D */ + 747, /* GL_MAP1_COLOR_4 */ + 750, /* GL_MAP1_INDEX */ + 751, /* GL_MAP1_NORMAL */ + 752, /* GL_MAP1_TEXTURE_COORD_1 */ + 753, /* GL_MAP1_TEXTURE_COORD_2 */ + 754, /* GL_MAP1_TEXTURE_COORD_3 */ + 755, /* GL_MAP1_TEXTURE_COORD_4 */ + 756, /* GL_MAP1_VERTEX_3 */ + 757, /* GL_MAP1_VERTEX_4 */ + 774, /* GL_MAP2_COLOR_4 */ + 777, /* GL_MAP2_INDEX */ + 778, /* GL_MAP2_NORMAL */ + 779, /* GL_MAP2_TEXTURE_COORD_1 */ + 780, /* GL_MAP2_TEXTURE_COORD_2 */ + 781, /* GL_MAP2_TEXTURE_COORD_3 */ + 782, /* GL_MAP2_TEXTURE_COORD_4 */ + 783, /* GL_MAP2_VERTEX_3 */ + 784, /* GL_MAP2_VERTEX_4 */ + 748, /* GL_MAP1_GRID_DOMAIN */ + 749, /* GL_MAP1_GRID_SEGMENTS */ + 775, /* GL_MAP2_GRID_DOMAIN */ + 776, /* GL_MAP2_GRID_SEGMENTS */ + 1632, /* GL_TEXTURE_1D */ + 1634, /* GL_TEXTURE_2D */ 482, /* GL_FEEDBACK_BUFFER_POINTER */ 483, /* GL_FEEDBACK_BUFFER_SIZE */ 484, /* GL_FEEDBACK_BUFFER_TYPE */ - 1427, /* GL_SELECTION_BUFFER_POINTER */ - 1428, /* GL_SELECTION_BUFFER_SIZE */ - 1750, /* GL_TEXTURE_WIDTH */ - 1713, /* GL_TEXTURE_HEIGHT */ - 1668, /* GL_TEXTURE_COMPONENTS */ - 1652, /* GL_TEXTURE_BORDER_COLOR */ - 1651, /* GL_TEXTURE_BORDER */ + 1428, /* GL_SELECTION_BUFFER_POINTER */ + 1429, /* GL_SELECTION_BUFFER_SIZE */ + 1751, /* GL_TEXTURE_WIDTH */ + 1714, /* GL_TEXTURE_HEIGHT */ + 1669, /* GL_TEXTURE_COMPONENTS */ + 1653, /* GL_TEXTURE_BORDER_COLOR */ + 1652, /* GL_TEXTURE_BORDER */ 385, /* GL_DONT_CARE */ 480, /* GL_FASTEST */ - 1021, /* GL_NICEST */ + 1022, /* GL_NICEST */ 48, /* GL_AMBIENT */ 382, /* GL_DIFFUSE */ - 1476, /* GL_SPECULAR */ - 1185, /* GL_POSITION */ - 1479, /* GL_SPOT_DIRECTION */ - 1480, /* GL_SPOT_EXPONENT */ - 1478, /* GL_SPOT_CUTOFF */ + 1477, /* GL_SPECULAR */ + 1186, /* GL_POSITION */ + 1480, /* GL_SPOT_DIRECTION */ + 1481, /* GL_SPOT_EXPONENT */ + 1479, /* GL_SPOT_CUTOFF */ 275, /* GL_CONSTANT_ATTENUATION */ - 696, /* GL_LINEAR_ATTENUATION */ - 1284, /* GL_QUADRATIC_ATTENUATION */ + 697, /* GL_LINEAR_ATTENUATION */ + 1285, /* GL_QUADRATIC_ATTENUATION */ 244, /* GL_COMPILE */ 245, /* GL_COMPILE_AND_EXECUTE */ 120, /* GL_BYTE */ - 1783, /* GL_UNSIGNED_BYTE */ - 1441, /* GL_SHORT */ - 1795, /* GL_UNSIGNED_SHORT */ - 645, /* GL_INT */ - 1786, /* GL_UNSIGNED_INT */ + 1784, /* GL_UNSIGNED_BYTE */ + 1442, /* GL_SHORT */ + 1796, /* GL_UNSIGNED_SHORT */ + 646, /* GL_INT */ + 1787, /* GL_UNSIGNED_INT */ 489, /* GL_FLOAT */ 1, /* GL_2_BYTES */ 5, /* GL_3_BYTES */ 7, /* GL_4_BYTES */ 392, /* GL_DOUBLE */ + 604, /* GL_HALF_FLOAT */ 132, /* GL_CLEAR */ 50, /* GL_AND */ 52, /* GL_AND_REVERSE */ 299, /* GL_COPY */ 51, /* GL_AND_INVERTED */ - 1023, /* GL_NOOP */ - 1878, /* GL_XOR */ - 1086, /* GL_OR */ - 1024, /* GL_NOR */ + 1024, /* GL_NOOP */ + 1879, /* GL_XOR */ + 1087, /* GL_OR */ + 1025, /* GL_NOR */ 470, /* GL_EQUIV */ - 672, /* GL_INVERT */ - 1089, /* GL_OR_REVERSE */ + 673, /* GL_INVERT */ + 1090, /* GL_OR_REVERSE */ 300, /* GL_COPY_INVERTED */ - 1088, /* GL_OR_INVERTED */ - 1014, /* GL_NAND */ - 1432, /* GL_SET */ + 1089, /* GL_OR_INVERTED */ + 1015, /* GL_NAND */ + 1433, /* GL_SET */ 467, /* GL_EMISSION */ - 1440, /* GL_SHININESS */ + 1441, /* GL_SHININESS */ 49, /* GL_AMBIENT_AND_DIFFUSE */ 190, /* GL_COLOR_INDEXES */ - 964, /* GL_MODELVIEW */ - 1261, /* GL_PROJECTION */ - 1566, /* GL_TEXTURE */ + 965, /* GL_MODELVIEW */ + 1262, /* GL_PROJECTION */ + 1567, /* GL_TEXTURE */ 147, /* GL_COLOR */ 346, /* GL_DEPTH */ - 1502, /* GL_STENCIL */ + 1503, /* GL_STENCIL */ 189, /* GL_COLOR_INDEX */ - 1521, /* GL_STENCIL_INDEX */ + 1522, /* GL_STENCIL_INDEX */ 359, /* GL_DEPTH_COMPONENT */ - 1312, /* GL_RED */ + 1313, /* GL_RED */ 600, /* GL_GREEN */ 90, /* GL_BLUE */ 31, /* GL_ALPHA */ - 1349, /* GL_RGB */ - 1368, /* GL_RGBA */ - 724, /* GL_LUMINANCE */ - 745, /* GL_LUMINANCE_ALPHA */ + 1350, /* GL_RGB */ + 1369, /* GL_RGBA */ + 725, /* GL_LUMINANCE */ + 746, /* GL_LUMINANCE_ALPHA */ 73, /* GL_BITMAP */ - 1141, /* GL_POINT */ - 694, /* GL_LINE */ + 1142, /* GL_POINT */ + 695, /* GL_LINE */ 485, /* GL_FILL */ - 1321, /* GL_RENDER */ + 1322, /* GL_RENDER */ 481, /* GL_FEEDBACK */ - 1426, /* GL_SELECT */ + 1427, /* GL_SELECT */ 488, /* GL_FLAT */ - 1451, /* GL_SMOOTH */ - 673, /* GL_KEEP */ - 1343, /* GL_REPLACE */ - 627, /* GL_INCR */ + 1452, /* GL_SMOOTH */ + 674, /* GL_KEEP */ + 1344, /* GL_REPLACE */ + 628, /* GL_INCR */ 342, /* GL_DECR */ - 1810, /* GL_VENDOR */ - 1340, /* GL_RENDERER */ - 1811, /* GL_VERSION */ + 1811, /* GL_VENDOR */ + 1341, /* GL_RENDERER */ + 1812, /* GL_VERSION */ 474, /* GL_EXTENSIONS */ - 1391, /* GL_S */ - 1557, /* GL_T */ - 1300, /* GL_R */ - 1283, /* GL_Q */ - 1000, /* GL_MODULATE */ + 1392, /* GL_S */ + 1558, /* GL_T */ + 1301, /* GL_R */ + 1284, /* GL_Q */ + 1001, /* GL_MODULATE */ 341, /* GL_DECAL */ - 1703, /* GL_TEXTURE_ENV_MODE */ - 1702, /* GL_TEXTURE_ENV_COLOR */ - 1701, /* GL_TEXTURE_ENV */ + 1704, /* GL_TEXTURE_ENV_MODE */ + 1703, /* GL_TEXTURE_ENV_COLOR */ + 1702, /* GL_TEXTURE_ENV */ 475, /* GL_EYE_LINEAR */ - 1047, /* GL_OBJECT_LINEAR */ - 1477, /* GL_SPHERE_MAP */ - 1705, /* GL_TEXTURE_GEN_MODE */ - 1049, /* GL_OBJECT_PLANE */ + 1048, /* GL_OBJECT_LINEAR */ + 1478, /* GL_SPHERE_MAP */ + 1706, /* GL_TEXTURE_GEN_MODE */ + 1050, /* GL_OBJECT_PLANE */ 476, /* GL_EYE_PLANE */ - 1015, /* GL_NEAREST */ - 695, /* GL_LINEAR */ - 1019, /* GL_NEAREST_MIPMAP_NEAREST */ - 700, /* GL_LINEAR_MIPMAP_NEAREST */ - 1018, /* GL_NEAREST_MIPMAP_LINEAR */ - 699, /* GL_LINEAR_MIPMAP_LINEAR */ - 1726, /* GL_TEXTURE_MAG_FILTER */ - 1734, /* GL_TEXTURE_MIN_FILTER */ - 1752, /* GL_TEXTURE_WRAP_S */ - 1753, /* GL_TEXTURE_WRAP_T */ + 1016, /* GL_NEAREST */ + 696, /* GL_LINEAR */ + 1020, /* GL_NEAREST_MIPMAP_NEAREST */ + 701, /* GL_LINEAR_MIPMAP_NEAREST */ + 1019, /* GL_NEAREST_MIPMAP_LINEAR */ + 700, /* GL_LINEAR_MIPMAP_LINEAR */ + 1727, /* GL_TEXTURE_MAG_FILTER */ + 1735, /* GL_TEXTURE_MIN_FILTER */ + 1753, /* GL_TEXTURE_WRAP_S */ + 1754, /* GL_TEXTURE_WRAP_T */ 126, /* GL_CLAMP */ - 1342, /* GL_REPEAT */ - 1179, /* GL_POLYGON_OFFSET_UNITS */ - 1178, /* GL_POLYGON_OFFSET_POINT */ - 1177, /* GL_POLYGON_OFFSET_LINE */ - 1301, /* GL_R3_G3_B2 */ - 1807, /* GL_V2F */ - 1808, /* GL_V3F */ + 1343, /* GL_REPEAT */ + 1180, /* GL_POLYGON_OFFSET_UNITS */ + 1179, /* GL_POLYGON_OFFSET_POINT */ + 1178, /* GL_POLYGON_OFFSET_LINE */ + 1302, /* GL_R3_G3_B2 */ + 1808, /* GL_V2F */ + 1809, /* GL_V3F */ 123, /* GL_C4UB_V2F */ 124, /* GL_C4UB_V3F */ 121, /* GL_C3F_V3F */ - 1012, /* GL_N3F_V3F */ + 1013, /* GL_N3F_V3F */ 122, /* GL_C4F_N3F_V3F */ - 1562, /* GL_T2F_V3F */ - 1564, /* GL_T4F_V4F */ - 1560, /* GL_T2F_C4UB_V3F */ - 1558, /* GL_T2F_C3F_V3F */ - 1561, /* GL_T2F_N3F_V3F */ - 1559, /* GL_T2F_C4F_N3F_V3F */ - 1563, /* GL_T4F_C4F_N3F_V4F */ + 1563, /* GL_T2F_V3F */ + 1565, /* GL_T4F_V4F */ + 1561, /* GL_T2F_C4UB_V3F */ + 1559, /* GL_T2F_C3F_V3F */ + 1562, /* GL_T2F_N3F_V3F */ + 1560, /* GL_T2F_C4F_N3F_V3F */ + 1564, /* GL_T4F_C4F_N3F_V4F */ 139, /* GL_CLIP_PLANE0 */ 140, /* GL_CLIP_PLANE1 */ 141, /* GL_CLIP_PLANE2 */ 142, /* GL_CLIP_PLANE3 */ 143, /* GL_CLIP_PLANE4 */ 144, /* GL_CLIP_PLANE5 */ - 679, /* GL_LIGHT0 */ - 680, /* GL_LIGHT1 */ - 681, /* GL_LIGHT2 */ - 682, /* GL_LIGHT3 */ - 683, /* GL_LIGHT4 */ - 684, /* GL_LIGHT5 */ - 685, /* GL_LIGHT6 */ - 686, /* GL_LIGHT7 */ - 604, /* GL_HINT_BIT */ + 680, /* GL_LIGHT0 */ + 681, /* GL_LIGHT1 */ + 682, /* GL_LIGHT2 */ + 683, /* GL_LIGHT3 */ + 684, /* GL_LIGHT4 */ + 685, /* GL_LIGHT5 */ + 686, /* GL_LIGHT6 */ + 687, /* GL_LIGHT7 */ + 605, /* GL_HINT_BIT */ 277, /* GL_CONSTANT_COLOR */ - 1060, /* GL_ONE_MINUS_CONSTANT_COLOR */ + 1061, /* GL_ONE_MINUS_CONSTANT_COLOR */ 272, /* GL_CONSTANT_ALPHA */ - 1058, /* GL_ONE_MINUS_CONSTANT_ALPHA */ + 1059, /* GL_ONE_MINUS_CONSTANT_ALPHA */ 76, /* GL_BLEND_COLOR */ 588, /* GL_FUNC_ADD */ - 948, /* GL_MIN */ - 855, /* GL_MAX */ + 949, /* GL_MIN */ + 856, /* GL_MAX */ 81, /* GL_BLEND_EQUATION */ 592, /* GL_FUNC_SUBTRACT */ 590, /* GL_FUNC_REVERSE_SUBTRACT */ 280, /* GL_CONVOLUTION_1D */ 281, /* GL_CONVOLUTION_2D */ - 1429, /* GL_SEPARABLE_2D */ + 1430, /* GL_SEPARABLE_2D */ 284, /* GL_CONVOLUTION_BORDER_MODE */ 288, /* GL_CONVOLUTION_FILTER_SCALE */ 286, /* GL_CONVOLUTION_FILTER_BIAS */ - 1313, /* GL_REDUCE */ + 1314, /* GL_REDUCE */ 290, /* GL_CONVOLUTION_FORMAT */ 294, /* GL_CONVOLUTION_WIDTH */ 292, /* GL_CONVOLUTION_HEIGHT */ - 871, /* GL_MAX_CONVOLUTION_WIDTH */ - 869, /* GL_MAX_CONVOLUTION_HEIGHT */ - 1218, /* GL_POST_CONVOLUTION_RED_SCALE */ - 1214, /* GL_POST_CONVOLUTION_GREEN_SCALE */ - 1209, /* GL_POST_CONVOLUTION_BLUE_SCALE */ - 1205, /* GL_POST_CONVOLUTION_ALPHA_SCALE */ - 1216, /* GL_POST_CONVOLUTION_RED_BIAS */ - 1212, /* GL_POST_CONVOLUTION_GREEN_BIAS */ - 1207, /* GL_POST_CONVOLUTION_BLUE_BIAS */ - 1203, /* GL_POST_CONVOLUTION_ALPHA_BIAS */ - 605, /* GL_HISTOGRAM */ - 1267, /* GL_PROXY_HISTOGRAM */ - 621, /* GL_HISTOGRAM_WIDTH */ - 611, /* GL_HISTOGRAM_FORMAT */ - 617, /* GL_HISTOGRAM_RED_SIZE */ - 613, /* GL_HISTOGRAM_GREEN_SIZE */ - 608, /* GL_HISTOGRAM_BLUE_SIZE */ - 606, /* GL_HISTOGRAM_ALPHA_SIZE */ - 615, /* GL_HISTOGRAM_LUMINANCE_SIZE */ - 619, /* GL_HISTOGRAM_SINK */ - 949, /* GL_MINMAX */ - 951, /* GL_MINMAX_FORMAT */ - 953, /* GL_MINMAX_SINK */ - 1565, /* GL_TABLE_TOO_LARGE_EXT */ - 1785, /* GL_UNSIGNED_BYTE_3_3_2 */ - 1797, /* GL_UNSIGNED_SHORT_4_4_4_4 */ - 1799, /* GL_UNSIGNED_SHORT_5_5_5_1 */ - 1792, /* GL_UNSIGNED_INT_8_8_8_8 */ - 1787, /* GL_UNSIGNED_INT_10_10_10_2 */ - 1176, /* GL_POLYGON_OFFSET_FILL */ - 1175, /* GL_POLYGON_OFFSET_FACTOR */ - 1174, /* GL_POLYGON_OFFSET_BIAS */ - 1346, /* GL_RESCALE_NORMAL */ + 872, /* GL_MAX_CONVOLUTION_WIDTH */ + 870, /* GL_MAX_CONVOLUTION_HEIGHT */ + 1219, /* GL_POST_CONVOLUTION_RED_SCALE */ + 1215, /* GL_POST_CONVOLUTION_GREEN_SCALE */ + 1210, /* GL_POST_CONVOLUTION_BLUE_SCALE */ + 1206, /* GL_POST_CONVOLUTION_ALPHA_SCALE */ + 1217, /* GL_POST_CONVOLUTION_RED_BIAS */ + 1213, /* GL_POST_CONVOLUTION_GREEN_BIAS */ + 1208, /* GL_POST_CONVOLUTION_BLUE_BIAS */ + 1204, /* GL_POST_CONVOLUTION_ALPHA_BIAS */ + 606, /* GL_HISTOGRAM */ + 1268, /* GL_PROXY_HISTOGRAM */ + 622, /* GL_HISTOGRAM_WIDTH */ + 612, /* GL_HISTOGRAM_FORMAT */ + 618, /* GL_HISTOGRAM_RED_SIZE */ + 614, /* GL_HISTOGRAM_GREEN_SIZE */ + 609, /* GL_HISTOGRAM_BLUE_SIZE */ + 607, /* GL_HISTOGRAM_ALPHA_SIZE */ + 616, /* GL_HISTOGRAM_LUMINANCE_SIZE */ + 620, /* GL_HISTOGRAM_SINK */ + 950, /* GL_MINMAX */ + 952, /* GL_MINMAX_FORMAT */ + 954, /* GL_MINMAX_SINK */ + 1566, /* GL_TABLE_TOO_LARGE_EXT */ + 1786, /* GL_UNSIGNED_BYTE_3_3_2 */ + 1798, /* GL_UNSIGNED_SHORT_4_4_4_4 */ + 1800, /* GL_UNSIGNED_SHORT_5_5_5_1 */ + 1793, /* GL_UNSIGNED_INT_8_8_8_8 */ + 1788, /* GL_UNSIGNED_INT_10_10_10_2 */ + 1177, /* GL_POLYGON_OFFSET_FILL */ + 1176, /* GL_POLYGON_OFFSET_FACTOR */ + 1175, /* GL_POLYGON_OFFSET_BIAS */ + 1347, /* GL_RESCALE_NORMAL */ 36, /* GL_ALPHA4 */ 38, /* GL_ALPHA8 */ 32, /* GL_ALPHA12 */ 34, /* GL_ALPHA16 */ - 735, /* GL_LUMINANCE4 */ - 741, /* GL_LUMINANCE8 */ - 725, /* GL_LUMINANCE12 */ - 731, /* GL_LUMINANCE16 */ - 736, /* GL_LUMINANCE4_ALPHA4 */ - 739, /* GL_LUMINANCE6_ALPHA2 */ - 742, /* GL_LUMINANCE8_ALPHA8 */ - 728, /* GL_LUMINANCE12_ALPHA4 */ - 726, /* GL_LUMINANCE12_ALPHA12 */ - 732, /* GL_LUMINANCE16_ALPHA16 */ - 646, /* GL_INTENSITY */ - 651, /* GL_INTENSITY4 */ - 653, /* GL_INTENSITY8 */ - 647, /* GL_INTENSITY12 */ - 649, /* GL_INTENSITY16 */ - 1358, /* GL_RGB2_EXT */ - 1359, /* GL_RGB4 */ - 1362, /* GL_RGB5 */ - 1366, /* GL_RGB8 */ - 1350, /* GL_RGB10 */ - 1354, /* GL_RGB12 */ - 1356, /* GL_RGB16 */ - 1373, /* GL_RGBA2 */ - 1375, /* GL_RGBA4 */ - 1363, /* GL_RGB5_A1 */ - 1379, /* GL_RGBA8 */ - 1351, /* GL_RGB10_A2 */ - 1369, /* GL_RGBA12 */ - 1371, /* GL_RGBA16 */ - 1741, /* GL_TEXTURE_RED_SIZE */ - 1711, /* GL_TEXTURE_GREEN_SIZE */ - 1649, /* GL_TEXTURE_BLUE_SIZE */ - 1636, /* GL_TEXTURE_ALPHA_SIZE */ - 1724, /* GL_TEXTURE_LUMINANCE_SIZE */ - 1715, /* GL_TEXTURE_INTENSITY_SIZE */ - 1344, /* GL_REPLACE_EXT */ - 1271, /* GL_PROXY_TEXTURE_1D */ - 1274, /* GL_PROXY_TEXTURE_2D */ - 1748, /* GL_TEXTURE_TOO_LARGE_EXT */ - 1736, /* GL_TEXTURE_PRIORITY */ - 1743, /* GL_TEXTURE_RESIDENT */ - 1639, /* GL_TEXTURE_BINDING_1D */ - 1641, /* GL_TEXTURE_BINDING_2D */ - 1643, /* GL_TEXTURE_BINDING_3D */ - 1096, /* GL_PACK_SKIP_IMAGES */ - 1092, /* GL_PACK_IMAGE_HEIGHT */ - 1778, /* GL_UNPACK_SKIP_IMAGES */ - 1775, /* GL_UNPACK_IMAGE_HEIGHT */ - 1635, /* GL_TEXTURE_3D */ - 1277, /* GL_PROXY_TEXTURE_3D */ - 1698, /* GL_TEXTURE_DEPTH */ - 1751, /* GL_TEXTURE_WRAP_R */ - 856, /* GL_MAX_3D_TEXTURE_SIZE */ - 1812, /* GL_VERTEX_ARRAY */ - 1026, /* GL_NORMAL_ARRAY */ + 736, /* GL_LUMINANCE4 */ + 742, /* GL_LUMINANCE8 */ + 726, /* GL_LUMINANCE12 */ + 732, /* GL_LUMINANCE16 */ + 737, /* GL_LUMINANCE4_ALPHA4 */ + 740, /* GL_LUMINANCE6_ALPHA2 */ + 743, /* GL_LUMINANCE8_ALPHA8 */ + 729, /* GL_LUMINANCE12_ALPHA4 */ + 727, /* GL_LUMINANCE12_ALPHA12 */ + 733, /* GL_LUMINANCE16_ALPHA16 */ + 647, /* GL_INTENSITY */ + 652, /* GL_INTENSITY4 */ + 654, /* GL_INTENSITY8 */ + 648, /* GL_INTENSITY12 */ + 650, /* GL_INTENSITY16 */ + 1359, /* GL_RGB2_EXT */ + 1360, /* GL_RGB4 */ + 1363, /* GL_RGB5 */ + 1367, /* GL_RGB8 */ + 1351, /* GL_RGB10 */ + 1355, /* GL_RGB12 */ + 1357, /* GL_RGB16 */ + 1374, /* GL_RGBA2 */ + 1376, /* GL_RGBA4 */ + 1364, /* GL_RGB5_A1 */ + 1380, /* GL_RGBA8 */ + 1352, /* GL_RGB10_A2 */ + 1370, /* GL_RGBA12 */ + 1372, /* GL_RGBA16 */ + 1742, /* GL_TEXTURE_RED_SIZE */ + 1712, /* GL_TEXTURE_GREEN_SIZE */ + 1650, /* GL_TEXTURE_BLUE_SIZE */ + 1637, /* GL_TEXTURE_ALPHA_SIZE */ + 1725, /* GL_TEXTURE_LUMINANCE_SIZE */ + 1716, /* GL_TEXTURE_INTENSITY_SIZE */ + 1345, /* GL_REPLACE_EXT */ + 1272, /* GL_PROXY_TEXTURE_1D */ + 1275, /* GL_PROXY_TEXTURE_2D */ + 1749, /* GL_TEXTURE_TOO_LARGE_EXT */ + 1737, /* GL_TEXTURE_PRIORITY */ + 1744, /* GL_TEXTURE_RESIDENT */ + 1640, /* GL_TEXTURE_BINDING_1D */ + 1642, /* GL_TEXTURE_BINDING_2D */ + 1644, /* GL_TEXTURE_BINDING_3D */ + 1097, /* GL_PACK_SKIP_IMAGES */ + 1093, /* GL_PACK_IMAGE_HEIGHT */ + 1779, /* GL_UNPACK_SKIP_IMAGES */ + 1776, /* GL_UNPACK_IMAGE_HEIGHT */ + 1636, /* GL_TEXTURE_3D */ + 1278, /* GL_PROXY_TEXTURE_3D */ + 1699, /* GL_TEXTURE_DEPTH */ + 1752, /* GL_TEXTURE_WRAP_R */ + 857, /* GL_MAX_3D_TEXTURE_SIZE */ + 1813, /* GL_VERTEX_ARRAY */ + 1027, /* GL_NORMAL_ARRAY */ 148, /* GL_COLOR_ARRAY */ - 631, /* GL_INDEX_ARRAY */ - 1676, /* GL_TEXTURE_COORD_ARRAY */ + 632, /* GL_INDEX_ARRAY */ + 1677, /* GL_TEXTURE_COORD_ARRAY */ 459, /* GL_EDGE_FLAG_ARRAY */ - 1818, /* GL_VERTEX_ARRAY_SIZE */ - 1820, /* GL_VERTEX_ARRAY_TYPE */ - 1819, /* GL_VERTEX_ARRAY_STRIDE */ - 1031, /* GL_NORMAL_ARRAY_TYPE */ - 1030, /* GL_NORMAL_ARRAY_STRIDE */ + 1819, /* GL_VERTEX_ARRAY_SIZE */ + 1821, /* GL_VERTEX_ARRAY_TYPE */ + 1820, /* GL_VERTEX_ARRAY_STRIDE */ + 1032, /* GL_NORMAL_ARRAY_TYPE */ + 1031, /* GL_NORMAL_ARRAY_STRIDE */ 152, /* GL_COLOR_ARRAY_SIZE */ 154, /* GL_COLOR_ARRAY_TYPE */ 153, /* GL_COLOR_ARRAY_STRIDE */ - 636, /* GL_INDEX_ARRAY_TYPE */ - 635, /* GL_INDEX_ARRAY_STRIDE */ - 1680, /* GL_TEXTURE_COORD_ARRAY_SIZE */ - 1682, /* GL_TEXTURE_COORD_ARRAY_TYPE */ - 1681, /* GL_TEXTURE_COORD_ARRAY_STRIDE */ + 637, /* GL_INDEX_ARRAY_TYPE */ + 636, /* GL_INDEX_ARRAY_STRIDE */ + 1681, /* GL_TEXTURE_COORD_ARRAY_SIZE */ + 1683, /* GL_TEXTURE_COORD_ARRAY_TYPE */ + 1682, /* GL_TEXTURE_COORD_ARRAY_STRIDE */ 463, /* GL_EDGE_FLAG_ARRAY_STRIDE */ - 1817, /* GL_VERTEX_ARRAY_POINTER */ - 1029, /* GL_NORMAL_ARRAY_POINTER */ + 1818, /* GL_VERTEX_ARRAY_POINTER */ + 1030, /* GL_NORMAL_ARRAY_POINTER */ 151, /* GL_COLOR_ARRAY_POINTER */ - 634, /* GL_INDEX_ARRAY_POINTER */ - 1679, /* GL_TEXTURE_COORD_ARRAY_POINTER */ + 635, /* GL_INDEX_ARRAY_POINTER */ + 1680, /* GL_TEXTURE_COORD_ARRAY_POINTER */ 462, /* GL_EDGE_FLAG_ARRAY_POINTER */ - 1005, /* GL_MULTISAMPLE */ - 1403, /* GL_SAMPLE_ALPHA_TO_COVERAGE */ - 1405, /* GL_SAMPLE_ALPHA_TO_ONE */ - 1410, /* GL_SAMPLE_COVERAGE */ - 1407, /* GL_SAMPLE_BUFFERS */ - 1398, /* GL_SAMPLES */ - 1414, /* GL_SAMPLE_COVERAGE_VALUE */ - 1412, /* GL_SAMPLE_COVERAGE_INVERT */ + 1006, /* GL_MULTISAMPLE */ + 1404, /* GL_SAMPLE_ALPHA_TO_COVERAGE */ + 1406, /* GL_SAMPLE_ALPHA_TO_ONE */ + 1411, /* GL_SAMPLE_COVERAGE */ + 1408, /* GL_SAMPLE_BUFFERS */ + 1399, /* GL_SAMPLES */ + 1415, /* GL_SAMPLE_COVERAGE_VALUE */ + 1413, /* GL_SAMPLE_COVERAGE_INVERT */ 195, /* GL_COLOR_MATRIX */ 197, /* GL_COLOR_MATRIX_STACK_DEPTH */ - 865, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */ - 1201, /* GL_POST_COLOR_MATRIX_RED_SCALE */ - 1197, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */ - 1192, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */ - 1188, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */ - 1199, /* GL_POST_COLOR_MATRIX_RED_BIAS */ - 1195, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */ - 1190, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */ - 1186, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */ - 1659, /* GL_TEXTURE_COLOR_TABLE_SGI */ - 1278, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */ - 1661, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */ + 866, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */ + 1202, /* GL_POST_COLOR_MATRIX_RED_SCALE */ + 1198, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */ + 1193, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */ + 1189, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */ + 1200, /* GL_POST_COLOR_MATRIX_RED_BIAS */ + 1196, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */ + 1191, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */ + 1187, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */ + 1660, /* GL_TEXTURE_COLOR_TABLE_SGI */ + 1279, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */ + 1662, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */ 80, /* GL_BLEND_DST_RGB */ 89, /* GL_BLEND_SRC_RGB */ 79, /* GL_BLEND_DST_ALPHA */ 88, /* GL_BLEND_SRC_ALPHA */ 201, /* GL_COLOR_TABLE */ - 1211, /* GL_POST_CONVOLUTION_COLOR_TABLE */ - 1194, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */ - 1266, /* GL_PROXY_COLOR_TABLE */ - 1270, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */ - 1269, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */ + 1212, /* GL_POST_CONVOLUTION_COLOR_TABLE */ + 1195, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */ + 1267, /* GL_PROXY_COLOR_TABLE */ + 1271, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */ + 1270, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */ 225, /* GL_COLOR_TABLE_SCALE */ 205, /* GL_COLOR_TABLE_BIAS */ 210, /* GL_COLOR_TABLE_FORMAT */ @@ -4423,62 +4426,62 @@ static const unsigned reduced_enums[1350] = 216, /* GL_COLOR_TABLE_INTENSITY_SIZE */ 71, /* GL_BGR */ 72, /* GL_BGRA */ - 879, /* GL_MAX_ELEMENTS_VERTICES */ - 878, /* GL_MAX_ELEMENTS_INDICES */ - 1714, /* GL_TEXTURE_INDEX_SIZE_EXT */ + 880, /* GL_MAX_ELEMENTS_VERTICES */ + 879, /* GL_MAX_ELEMENTS_INDICES */ + 1715, /* GL_TEXTURE_INDEX_SIZE_EXT */ 145, /* GL_CLIP_VOLUME_CLIPPING_HINT_EXT */ - 1158, /* GL_POINT_SIZE_MIN */ - 1154, /* GL_POINT_SIZE_MAX */ - 1148, /* GL_POINT_FADE_THRESHOLD_SIZE */ - 1144, /* GL_POINT_DISTANCE_ATTENUATION */ + 1159, /* GL_POINT_SIZE_MIN */ + 1155, /* GL_POINT_SIZE_MAX */ + 1149, /* GL_POINT_FADE_THRESHOLD_SIZE */ + 1145, /* GL_POINT_DISTANCE_ATTENUATION */ 127, /* GL_CLAMP_TO_BORDER */ 130, /* GL_CLAMP_TO_EDGE */ - 1735, /* GL_TEXTURE_MIN_LOD */ - 1733, /* GL_TEXTURE_MAX_LOD */ - 1638, /* GL_TEXTURE_BASE_LEVEL */ - 1732, /* GL_TEXTURE_MAX_LEVEL */ - 624, /* GL_IGNORE_BORDER_HP */ + 1736, /* GL_TEXTURE_MIN_LOD */ + 1734, /* GL_TEXTURE_MAX_LOD */ + 1639, /* GL_TEXTURE_BASE_LEVEL */ + 1733, /* GL_TEXTURE_MAX_LEVEL */ + 625, /* GL_IGNORE_BORDER_HP */ 276, /* GL_CONSTANT_BORDER_HP */ - 1345, /* GL_REPLICATE_BORDER_HP */ + 1346, /* GL_REPLICATE_BORDER_HP */ 282, /* GL_CONVOLUTION_BORDER_COLOR */ - 1055, /* GL_OCCLUSION_TEST_HP */ - 1056, /* GL_OCCLUSION_TEST_RESULT_HP */ - 697, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */ - 1653, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */ - 1655, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */ - 1657, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */ - 1658, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */ - 1656, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */ - 1654, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */ - 860, /* GL_MAX_CLIPMAP_DEPTH_SGIX */ - 861, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */ - 1221, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */ - 1223, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */ - 1220, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */ - 1222, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */ - 1722, /* GL_TEXTURE_LOD_BIAS_S_SGIX */ - 1723, /* GL_TEXTURE_LOD_BIAS_T_SGIX */ - 1721, /* GL_TEXTURE_LOD_BIAS_R_SGIX */ + 1056, /* GL_OCCLUSION_TEST_HP */ + 1057, /* GL_OCCLUSION_TEST_RESULT_HP */ + 698, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */ + 1654, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */ + 1656, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */ + 1658, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */ + 1659, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */ + 1657, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */ + 1655, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */ + 861, /* GL_MAX_CLIPMAP_DEPTH_SGIX */ + 862, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */ + 1222, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */ + 1224, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */ + 1221, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */ + 1223, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */ + 1723, /* GL_TEXTURE_LOD_BIAS_S_SGIX */ + 1724, /* GL_TEXTURE_LOD_BIAS_T_SGIX */ + 1722, /* GL_TEXTURE_LOD_BIAS_R_SGIX */ 594, /* GL_GENERATE_MIPMAP */ 595, /* GL_GENERATE_MIPMAP_HINT */ 532, /* GL_FOG_OFFSET_SGIX */ 533, /* GL_FOG_OFFSET_VALUE_SGIX */ - 1667, /* GL_TEXTURE_COMPARE_SGIX */ - 1666, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */ - 1718, /* GL_TEXTURE_LEQUAL_R_SGIX */ - 1710, /* GL_TEXTURE_GEQUAL_R_SGIX */ + 1668, /* GL_TEXTURE_COMPARE_SGIX */ + 1667, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */ + 1719, /* GL_TEXTURE_LEQUAL_R_SGIX */ + 1711, /* GL_TEXTURE_GEQUAL_R_SGIX */ 360, /* GL_DEPTH_COMPONENT16 */ 363, /* GL_DEPTH_COMPONENT24 */ 366, /* GL_DEPTH_COMPONENT32 */ 306, /* GL_CULL_VERTEX_EXT */ 308, /* GL_CULL_VERTEX_OBJECT_POSITION_EXT */ 307, /* GL_CULL_VERTEX_EYE_POSITION_EXT */ - 1875, /* GL_WRAP_BORDER_SUN */ - 1660, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */ - 690, /* GL_LIGHT_MODEL_COLOR_CONTROL */ - 1444, /* GL_SINGLE_COLOR */ - 1430, /* GL_SEPARATE_SPECULAR_COLOR */ - 1439, /* GL_SHARED_TEXTURE_PALETTE_EXT */ + 1876, /* GL_WRAP_BORDER_SUN */ + 1661, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */ + 691, /* GL_LIGHT_MODEL_COLOR_CONTROL */ + 1445, /* GL_SINGLE_COLOR */ + 1431, /* GL_SEPARATE_SPECULAR_COLOR */ + 1440, /* GL_SHARED_TEXTURE_PALETTE_EXT */ 543, /* GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ 544, /* GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ 551, /* GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ @@ -4490,31 +4493,31 @@ static const unsigned reduced_enums[1350] = 564, /* GL_FRAMEBUFFER_DEFAULT */ 580, /* GL_FRAMEBUFFER_UNDEFINED */ 373, /* GL_DEPTH_STENCIL_ATTACHMENT */ - 630, /* GL_INDEX */ - 1784, /* GL_UNSIGNED_BYTE_2_3_3_REV */ - 1800, /* GL_UNSIGNED_SHORT_5_6_5 */ - 1801, /* GL_UNSIGNED_SHORT_5_6_5_REV */ - 1798, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */ - 1796, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */ - 1793, /* GL_UNSIGNED_INT_8_8_8_8_REV */ - 1791, /* GL_UNSIGNED_INT_2_10_10_10_REV */ - 1730, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */ - 1731, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */ - 1729, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */ - 956, /* GL_MIRRORED_REPEAT */ - 1386, /* GL_RGB_S3TC */ - 1361, /* GL_RGB4_S3TC */ - 1384, /* GL_RGBA_S3TC */ - 1378, /* GL_RGBA4_S3TC */ - 1382, /* GL_RGBA_DXT5_S3TC */ - 1376, /* GL_RGBA4_DXT5_S3TC */ + 631, /* GL_INDEX */ + 1785, /* GL_UNSIGNED_BYTE_2_3_3_REV */ + 1801, /* GL_UNSIGNED_SHORT_5_6_5 */ + 1802, /* GL_UNSIGNED_SHORT_5_6_5_REV */ + 1799, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */ + 1797, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */ + 1794, /* GL_UNSIGNED_INT_8_8_8_8_REV */ + 1792, /* GL_UNSIGNED_INT_2_10_10_10_REV */ + 1731, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */ + 1732, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */ + 1730, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */ + 957, /* GL_MIRRORED_REPEAT */ + 1387, /* GL_RGB_S3TC */ + 1362, /* GL_RGB4_S3TC */ + 1385, /* GL_RGBA_S3TC */ + 1379, /* GL_RGBA4_S3TC */ + 1383, /* GL_RGBA_DXT5_S3TC */ + 1377, /* GL_RGBA4_DXT5_S3TC */ 264, /* GL_COMPRESSED_RGB_S3TC_DXT1_EXT */ 259, /* GL_COMPRESSED_RGBA_S3TC_DXT1_EXT */ 260, /* GL_COMPRESSED_RGBA_S3TC_DXT3_EXT */ 261, /* GL_COMPRESSED_RGBA_S3TC_DXT5_EXT */ - 1017, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */ - 1016, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */ - 698, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */ + 1018, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */ + 1017, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */ + 699, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */ 519, /* GL_FOG_COORDINATE_SOURCE */ 511, /* GL_FOG_COORD */ 535, /* GL_FRAGMENT_DEPTH */ @@ -4525,278 +4528,278 @@ static const unsigned reduced_enums[1350] = 513, /* GL_FOG_COORDINATE_ARRAY */ 199, /* GL_COLOR_SUM */ 332, /* GL_CURRENT_SECONDARY_COLOR */ - 1423, /* GL_SECONDARY_COLOR_ARRAY_SIZE */ - 1425, /* GL_SECONDARY_COLOR_ARRAY_TYPE */ - 1424, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */ - 1422, /* GL_SECONDARY_COLOR_ARRAY_POINTER */ - 1419, /* GL_SECONDARY_COLOR_ARRAY */ + 1424, /* GL_SECONDARY_COLOR_ARRAY_SIZE */ + 1426, /* GL_SECONDARY_COLOR_ARRAY_TYPE */ + 1425, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */ + 1423, /* GL_SECONDARY_COLOR_ARRAY_POINTER */ + 1420, /* GL_SECONDARY_COLOR_ARRAY */ 330, /* GL_CURRENT_RASTER_SECONDARY_COLOR */ 28, /* GL_ALIASED_POINT_SIZE_RANGE */ 27, /* GL_ALIASED_LINE_WIDTH_RANGE */ - 1567, /* GL_TEXTURE0 */ - 1569, /* GL_TEXTURE1 */ - 1591, /* GL_TEXTURE2 */ - 1613, /* GL_TEXTURE3 */ - 1619, /* GL_TEXTURE4 */ - 1621, /* GL_TEXTURE5 */ - 1623, /* GL_TEXTURE6 */ - 1625, /* GL_TEXTURE7 */ - 1627, /* GL_TEXTURE8 */ - 1629, /* GL_TEXTURE9 */ - 1570, /* GL_TEXTURE10 */ - 1572, /* GL_TEXTURE11 */ - 1574, /* GL_TEXTURE12 */ - 1576, /* GL_TEXTURE13 */ - 1578, /* GL_TEXTURE14 */ - 1580, /* GL_TEXTURE15 */ - 1582, /* GL_TEXTURE16 */ - 1584, /* GL_TEXTURE17 */ - 1586, /* GL_TEXTURE18 */ - 1588, /* GL_TEXTURE19 */ - 1592, /* GL_TEXTURE20 */ - 1594, /* GL_TEXTURE21 */ - 1596, /* GL_TEXTURE22 */ - 1598, /* GL_TEXTURE23 */ - 1600, /* GL_TEXTURE24 */ - 1602, /* GL_TEXTURE25 */ - 1604, /* GL_TEXTURE26 */ - 1606, /* GL_TEXTURE27 */ - 1608, /* GL_TEXTURE28 */ - 1610, /* GL_TEXTURE29 */ - 1614, /* GL_TEXTURE30 */ - 1616, /* GL_TEXTURE31 */ + 1568, /* GL_TEXTURE0 */ + 1570, /* GL_TEXTURE1 */ + 1592, /* GL_TEXTURE2 */ + 1614, /* GL_TEXTURE3 */ + 1620, /* GL_TEXTURE4 */ + 1622, /* GL_TEXTURE5 */ + 1624, /* GL_TEXTURE6 */ + 1626, /* GL_TEXTURE7 */ + 1628, /* GL_TEXTURE8 */ + 1630, /* GL_TEXTURE9 */ + 1571, /* GL_TEXTURE10 */ + 1573, /* GL_TEXTURE11 */ + 1575, /* GL_TEXTURE12 */ + 1577, /* GL_TEXTURE13 */ + 1579, /* GL_TEXTURE14 */ + 1581, /* GL_TEXTURE15 */ + 1583, /* GL_TEXTURE16 */ + 1585, /* GL_TEXTURE17 */ + 1587, /* GL_TEXTURE18 */ + 1589, /* GL_TEXTURE19 */ + 1593, /* GL_TEXTURE20 */ + 1595, /* GL_TEXTURE21 */ + 1597, /* GL_TEXTURE22 */ + 1599, /* GL_TEXTURE23 */ + 1601, /* GL_TEXTURE24 */ + 1603, /* GL_TEXTURE25 */ + 1605, /* GL_TEXTURE26 */ + 1607, /* GL_TEXTURE27 */ + 1609, /* GL_TEXTURE28 */ + 1611, /* GL_TEXTURE29 */ + 1615, /* GL_TEXTURE30 */ + 1617, /* GL_TEXTURE31 */ 18, /* GL_ACTIVE_TEXTURE */ 133, /* GL_CLIENT_ACTIVE_TEXTURE */ - 934, /* GL_MAX_TEXTURE_UNITS */ - 1762, /* GL_TRANSPOSE_MODELVIEW_MATRIX */ - 1765, /* GL_TRANSPOSE_PROJECTION_MATRIX */ - 1767, /* GL_TRANSPOSE_TEXTURE_MATRIX */ - 1759, /* GL_TRANSPOSE_COLOR_MATRIX */ - 1549, /* GL_SUBTRACT */ - 919, /* GL_MAX_RENDERBUFFER_SIZE */ + 935, /* GL_MAX_TEXTURE_UNITS */ + 1763, /* GL_TRANSPOSE_MODELVIEW_MATRIX */ + 1766, /* GL_TRANSPOSE_PROJECTION_MATRIX */ + 1768, /* GL_TRANSPOSE_TEXTURE_MATRIX */ + 1760, /* GL_TRANSPOSE_COLOR_MATRIX */ + 1550, /* GL_SUBTRACT */ + 920, /* GL_MAX_RENDERBUFFER_SIZE */ 247, /* GL_COMPRESSED_ALPHA */ 251, /* GL_COMPRESSED_LUMINANCE */ 252, /* GL_COMPRESSED_LUMINANCE_ALPHA */ 249, /* GL_COMPRESSED_INTENSITY */ 255, /* GL_COMPRESSED_RGB */ 256, /* GL_COMPRESSED_RGBA */ - 1674, /* GL_TEXTURE_COMPRESSION_HINT */ - 1739, /* GL_TEXTURE_RECTANGLE_ARB */ - 1646, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */ - 1281, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */ - 917, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */ + 1675, /* GL_TEXTURE_COMPRESSION_HINT */ + 1740, /* GL_TEXTURE_RECTANGLE_ARB */ + 1647, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */ + 1282, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */ + 918, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */ 372, /* GL_DEPTH_STENCIL */ - 1788, /* GL_UNSIGNED_INT_24_8 */ - 930, /* GL_MAX_TEXTURE_LOD_BIAS */ - 1728, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */ - 931, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */ - 1704, /* GL_TEXTURE_FILTER_CONTROL */ - 1719, /* GL_TEXTURE_LOD_BIAS */ + 1789, /* GL_UNSIGNED_INT_24_8 */ + 931, /* GL_MAX_TEXTURE_LOD_BIAS */ + 1729, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */ + 932, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */ + 1705, /* GL_TEXTURE_FILTER_CONTROL */ + 1720, /* GL_TEXTURE_LOD_BIAS */ 232, /* GL_COMBINE4 */ - 924, /* GL_MAX_SHININESS_NV */ - 925, /* GL_MAX_SPOT_EXPONENT_NV */ - 628, /* GL_INCR_WRAP */ + 925, /* GL_MAX_SHININESS_NV */ + 926, /* GL_MAX_SPOT_EXPONENT_NV */ + 629, /* GL_INCR_WRAP */ 343, /* GL_DECR_WRAP */ - 976, /* GL_MODELVIEW1_ARB */ - 1032, /* GL_NORMAL_MAP */ - 1318, /* GL_REFLECTION_MAP */ - 1683, /* GL_TEXTURE_CUBE_MAP */ - 1644, /* GL_TEXTURE_BINDING_CUBE_MAP */ - 1691, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */ - 1685, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */ - 1693, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */ - 1687, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */ - 1695, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */ - 1689, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */ - 1279, /* GL_PROXY_TEXTURE_CUBE_MAP */ - 873, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */ - 1011, /* GL_MULTISAMPLE_FILTER_HINT_NV */ + 977, /* GL_MODELVIEW1_ARB */ + 1033, /* GL_NORMAL_MAP */ + 1319, /* GL_REFLECTION_MAP */ + 1684, /* GL_TEXTURE_CUBE_MAP */ + 1645, /* GL_TEXTURE_BINDING_CUBE_MAP */ + 1692, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */ + 1686, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */ + 1694, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */ + 1688, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */ + 1696, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */ + 1690, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */ + 1280, /* GL_PROXY_TEXTURE_CUBE_MAP */ + 874, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */ + 1012, /* GL_MULTISAMPLE_FILTER_HINT_NV */ 527, /* GL_FOG_DISTANCE_MODE_NV */ 478, /* GL_EYE_RADIAL_NV */ 477, /* GL_EYE_PLANE_ABSOLUTE_NV */ 231, /* GL_COMBINE */ 238, /* GL_COMBINE_RGB */ 233, /* GL_COMBINE_ALPHA */ - 1387, /* GL_RGB_SCALE */ + 1388, /* GL_RGB_SCALE */ 24, /* GL_ADD_SIGNED */ - 656, /* GL_INTERPOLATE */ + 657, /* GL_INTERPOLATE */ 271, /* GL_CONSTANT */ - 1227, /* GL_PRIMARY_COLOR */ - 1224, /* GL_PREVIOUS */ - 1459, /* GL_SOURCE0_RGB */ - 1465, /* GL_SOURCE1_RGB */ - 1471, /* GL_SOURCE2_RGB */ - 1475, /* GL_SOURCE3_RGB_NV */ - 1456, /* GL_SOURCE0_ALPHA */ - 1462, /* GL_SOURCE1_ALPHA */ - 1468, /* GL_SOURCE2_ALPHA */ - 1474, /* GL_SOURCE3_ALPHA_NV */ - 1069, /* GL_OPERAND0_RGB */ - 1075, /* GL_OPERAND1_RGB */ - 1081, /* GL_OPERAND2_RGB */ - 1085, /* GL_OPERAND3_RGB_NV */ - 1066, /* GL_OPERAND0_ALPHA */ - 1072, /* GL_OPERAND1_ALPHA */ - 1078, /* GL_OPERAND2_ALPHA */ - 1084, /* GL_OPERAND3_ALPHA_NV */ - 1813, /* GL_VERTEX_ARRAY_BINDING */ - 1737, /* GL_TEXTURE_RANGE_LENGTH_APPLE */ - 1738, /* GL_TEXTURE_RANGE_POINTER_APPLE */ - 1879, /* GL_YCBCR_422_APPLE */ - 1802, /* GL_UNSIGNED_SHORT_8_8_APPLE */ - 1804, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */ - 1747, /* GL_TEXTURE_STORAGE_HINT_APPLE */ - 1540, /* GL_STORAGE_PRIVATE_APPLE */ - 1539, /* GL_STORAGE_CACHED_APPLE */ - 1541, /* GL_STORAGE_SHARED_APPLE */ - 1446, /* GL_SLICE_ACCUM_SUN */ - 1288, /* GL_QUAD_MESH_SUN */ - 1771, /* GL_TRIANGLE_MESH_SUN */ - 1852, /* GL_VERTEX_PROGRAM_ARB */ - 1863, /* GL_VERTEX_STATE_PROGRAM_NV */ - 1839, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */ - 1845, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */ - 1847, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */ - 1849, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */ + 1228, /* GL_PRIMARY_COLOR */ + 1225, /* GL_PREVIOUS */ + 1460, /* GL_SOURCE0_RGB */ + 1466, /* GL_SOURCE1_RGB */ + 1472, /* GL_SOURCE2_RGB */ + 1476, /* GL_SOURCE3_RGB_NV */ + 1457, /* GL_SOURCE0_ALPHA */ + 1463, /* GL_SOURCE1_ALPHA */ + 1469, /* GL_SOURCE2_ALPHA */ + 1475, /* GL_SOURCE3_ALPHA_NV */ + 1070, /* GL_OPERAND0_RGB */ + 1076, /* GL_OPERAND1_RGB */ + 1082, /* GL_OPERAND2_RGB */ + 1086, /* GL_OPERAND3_RGB_NV */ + 1067, /* GL_OPERAND0_ALPHA */ + 1073, /* GL_OPERAND1_ALPHA */ + 1079, /* GL_OPERAND2_ALPHA */ + 1085, /* GL_OPERAND3_ALPHA_NV */ + 1814, /* GL_VERTEX_ARRAY_BINDING */ + 1738, /* GL_TEXTURE_RANGE_LENGTH_APPLE */ + 1739, /* GL_TEXTURE_RANGE_POINTER_APPLE */ + 1880, /* GL_YCBCR_422_APPLE */ + 1803, /* GL_UNSIGNED_SHORT_8_8_APPLE */ + 1805, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */ + 1748, /* GL_TEXTURE_STORAGE_HINT_APPLE */ + 1541, /* GL_STORAGE_PRIVATE_APPLE */ + 1540, /* GL_STORAGE_CACHED_APPLE */ + 1542, /* GL_STORAGE_SHARED_APPLE */ + 1447, /* GL_SLICE_ACCUM_SUN */ + 1289, /* GL_QUAD_MESH_SUN */ + 1772, /* GL_TRIANGLE_MESH_SUN */ + 1853, /* GL_VERTEX_PROGRAM_ARB */ + 1864, /* GL_VERTEX_STATE_PROGRAM_NV */ + 1840, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED */ + 1846, /* GL_VERTEX_ATTRIB_ARRAY_SIZE */ + 1848, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE */ + 1850, /* GL_VERTEX_ATTRIB_ARRAY_TYPE */ 334, /* GL_CURRENT_VERTEX_ATTRIB */ - 1240, /* GL_PROGRAM_LENGTH_ARB */ - 1254, /* GL_PROGRAM_STRING_ARB */ - 998, /* GL_MODELVIEW_PROJECTION_NV */ - 623, /* GL_IDENTITY_NV */ - 670, /* GL_INVERSE_NV */ - 1764, /* GL_TRANSPOSE_NV */ - 671, /* GL_INVERSE_TRANSPOSE_NV */ - 903, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */ - 902, /* GL_MAX_PROGRAM_MATRICES_ARB */ - 809, /* GL_MATRIX0_NV */ - 821, /* GL_MATRIX1_NV */ - 833, /* GL_MATRIX2_NV */ - 837, /* GL_MATRIX3_NV */ - 839, /* GL_MATRIX4_NV */ - 841, /* GL_MATRIX5_NV */ - 843, /* GL_MATRIX6_NV */ - 845, /* GL_MATRIX7_NV */ + 1241, /* GL_PROGRAM_LENGTH_ARB */ + 1255, /* GL_PROGRAM_STRING_ARB */ + 999, /* GL_MODELVIEW_PROJECTION_NV */ + 624, /* GL_IDENTITY_NV */ + 671, /* GL_INVERSE_NV */ + 1765, /* GL_TRANSPOSE_NV */ + 672, /* GL_INVERSE_TRANSPOSE_NV */ + 904, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */ + 903, /* GL_MAX_PROGRAM_MATRICES_ARB */ + 810, /* GL_MATRIX0_NV */ + 822, /* GL_MATRIX1_NV */ + 834, /* GL_MATRIX2_NV */ + 838, /* GL_MATRIX3_NV */ + 840, /* GL_MATRIX4_NV */ + 842, /* GL_MATRIX5_NV */ + 844, /* GL_MATRIX6_NV */ + 846, /* GL_MATRIX7_NV */ 318, /* GL_CURRENT_MATRIX_STACK_DEPTH_ARB */ 315, /* GL_CURRENT_MATRIX_ARB */ - 1855, /* GL_VERTEX_PROGRAM_POINT_SIZE */ - 1858, /* GL_VERTEX_PROGRAM_TWO_SIDE */ - 1252, /* GL_PROGRAM_PARAMETER_NV */ - 1843, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */ - 1256, /* GL_PROGRAM_TARGET_NV */ - 1253, /* GL_PROGRAM_RESIDENT_NV */ - 1756, /* GL_TRACK_MATRIX_NV */ - 1757, /* GL_TRACK_MATRIX_TRANSFORM_NV */ - 1853, /* GL_VERTEX_PROGRAM_BINDING_NV */ - 1234, /* GL_PROGRAM_ERROR_POSITION_ARB */ + 1856, /* GL_VERTEX_PROGRAM_POINT_SIZE */ + 1859, /* GL_VERTEX_PROGRAM_TWO_SIDE */ + 1253, /* GL_PROGRAM_PARAMETER_NV */ + 1844, /* GL_VERTEX_ATTRIB_ARRAY_POINTER */ + 1257, /* GL_PROGRAM_TARGET_NV */ + 1254, /* GL_PROGRAM_RESIDENT_NV */ + 1757, /* GL_TRACK_MATRIX_NV */ + 1758, /* GL_TRACK_MATRIX_TRANSFORM_NV */ + 1854, /* GL_VERTEX_PROGRAM_BINDING_NV */ + 1235, /* GL_PROGRAM_ERROR_POSITION_ARB */ 356, /* GL_DEPTH_CLAMP */ - 1821, /* GL_VERTEX_ATTRIB_ARRAY0_NV */ - 1828, /* GL_VERTEX_ATTRIB_ARRAY1_NV */ - 1829, /* GL_VERTEX_ATTRIB_ARRAY2_NV */ - 1830, /* GL_VERTEX_ATTRIB_ARRAY3_NV */ - 1831, /* GL_VERTEX_ATTRIB_ARRAY4_NV */ - 1832, /* GL_VERTEX_ATTRIB_ARRAY5_NV */ - 1833, /* GL_VERTEX_ATTRIB_ARRAY6_NV */ - 1834, /* GL_VERTEX_ATTRIB_ARRAY7_NV */ - 1835, /* GL_VERTEX_ATTRIB_ARRAY8_NV */ - 1836, /* GL_VERTEX_ATTRIB_ARRAY9_NV */ - 1822, /* GL_VERTEX_ATTRIB_ARRAY10_NV */ - 1823, /* GL_VERTEX_ATTRIB_ARRAY11_NV */ - 1824, /* GL_VERTEX_ATTRIB_ARRAY12_NV */ - 1825, /* GL_VERTEX_ATTRIB_ARRAY13_NV */ - 1826, /* GL_VERTEX_ATTRIB_ARRAY14_NV */ - 1827, /* GL_VERTEX_ATTRIB_ARRAY15_NV */ - 757, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */ - 764, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */ - 765, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */ - 766, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */ - 767, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */ - 768, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */ - 769, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */ - 770, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */ - 771, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */ - 772, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */ - 758, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */ - 759, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */ - 760, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */ - 761, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */ - 762, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */ - 763, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */ - 784, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */ - 791, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */ - 792, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */ - 793, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */ - 794, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */ - 795, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */ - 796, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */ - 1233, /* GL_PROGRAM_BINDING_ARB */ - 798, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */ - 799, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */ - 785, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */ - 786, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */ - 787, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */ - 788, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */ - 789, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */ - 790, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */ - 1672, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */ - 1669, /* GL_TEXTURE_COMPRESSED */ - 1037, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */ + 1822, /* GL_VERTEX_ATTRIB_ARRAY0_NV */ + 1829, /* GL_VERTEX_ATTRIB_ARRAY1_NV */ + 1830, /* GL_VERTEX_ATTRIB_ARRAY2_NV */ + 1831, /* GL_VERTEX_ATTRIB_ARRAY3_NV */ + 1832, /* GL_VERTEX_ATTRIB_ARRAY4_NV */ + 1833, /* GL_VERTEX_ATTRIB_ARRAY5_NV */ + 1834, /* GL_VERTEX_ATTRIB_ARRAY6_NV */ + 1835, /* GL_VERTEX_ATTRIB_ARRAY7_NV */ + 1836, /* GL_VERTEX_ATTRIB_ARRAY8_NV */ + 1837, /* GL_VERTEX_ATTRIB_ARRAY9_NV */ + 1823, /* GL_VERTEX_ATTRIB_ARRAY10_NV */ + 1824, /* GL_VERTEX_ATTRIB_ARRAY11_NV */ + 1825, /* GL_VERTEX_ATTRIB_ARRAY12_NV */ + 1826, /* GL_VERTEX_ATTRIB_ARRAY13_NV */ + 1827, /* GL_VERTEX_ATTRIB_ARRAY14_NV */ + 1828, /* GL_VERTEX_ATTRIB_ARRAY15_NV */ + 758, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */ + 765, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */ + 766, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */ + 767, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */ + 768, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */ + 769, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */ + 770, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */ + 771, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */ + 772, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */ + 773, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */ + 759, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */ + 760, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */ + 761, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */ + 762, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */ + 763, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */ + 764, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */ + 785, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */ + 792, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */ + 793, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */ + 794, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */ + 795, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */ + 796, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */ + 797, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */ + 1234, /* GL_PROGRAM_BINDING_ARB */ + 799, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */ + 800, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */ + 786, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */ + 787, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */ + 788, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */ + 789, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */ + 790, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */ + 791, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */ + 1673, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */ + 1670, /* GL_TEXTURE_COMPRESSED */ + 1038, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */ 269, /* GL_COMPRESSED_TEXTURE_FORMATS */ - 946, /* GL_MAX_VERTEX_UNITS_ARB */ + 947, /* GL_MAX_VERTEX_UNITS_ARB */ 22, /* GL_ACTIVE_VERTEX_UNITS_ARB */ - 1874, /* GL_WEIGHT_SUM_UNITY_ARB */ - 1851, /* GL_VERTEX_BLEND_ARB */ + 1875, /* GL_WEIGHT_SUM_UNITY_ARB */ + 1852, /* GL_VERTEX_BLEND_ARB */ 336, /* GL_CURRENT_WEIGHT_ARB */ - 1873, /* GL_WEIGHT_ARRAY_TYPE_ARB */ - 1872, /* GL_WEIGHT_ARRAY_STRIDE_ARB */ - 1871, /* GL_WEIGHT_ARRAY_SIZE_ARB */ - 1870, /* GL_WEIGHT_ARRAY_POINTER_ARB */ - 1867, /* GL_WEIGHT_ARRAY_ARB */ + 1874, /* GL_WEIGHT_ARRAY_TYPE_ARB */ + 1873, /* GL_WEIGHT_ARRAY_STRIDE_ARB */ + 1872, /* GL_WEIGHT_ARRAY_SIZE_ARB */ + 1871, /* GL_WEIGHT_ARRAY_POINTER_ARB */ + 1868, /* GL_WEIGHT_ARRAY_ARB */ 386, /* GL_DOT3_RGB */ 387, /* GL_DOT3_RGBA */ 263, /* GL_COMPRESSED_RGB_FXT1_3DFX */ 258, /* GL_COMPRESSED_RGBA_FXT1_3DFX */ - 1006, /* GL_MULTISAMPLE_3DFX */ - 1408, /* GL_SAMPLE_BUFFERS_3DFX */ - 1399, /* GL_SAMPLES_3DFX */ - 987, /* GL_MODELVIEW2_ARB */ - 990, /* GL_MODELVIEW3_ARB */ - 991, /* GL_MODELVIEW4_ARB */ - 992, /* GL_MODELVIEW5_ARB */ - 993, /* GL_MODELVIEW6_ARB */ - 994, /* GL_MODELVIEW7_ARB */ - 995, /* GL_MODELVIEW8_ARB */ - 996, /* GL_MODELVIEW9_ARB */ - 966, /* GL_MODELVIEW10_ARB */ - 967, /* GL_MODELVIEW11_ARB */ - 968, /* GL_MODELVIEW12_ARB */ - 969, /* GL_MODELVIEW13_ARB */ - 970, /* GL_MODELVIEW14_ARB */ - 971, /* GL_MODELVIEW15_ARB */ - 972, /* GL_MODELVIEW16_ARB */ - 973, /* GL_MODELVIEW17_ARB */ - 974, /* GL_MODELVIEW18_ARB */ - 975, /* GL_MODELVIEW19_ARB */ - 977, /* GL_MODELVIEW20_ARB */ - 978, /* GL_MODELVIEW21_ARB */ - 979, /* GL_MODELVIEW22_ARB */ - 980, /* GL_MODELVIEW23_ARB */ - 981, /* GL_MODELVIEW24_ARB */ - 982, /* GL_MODELVIEW25_ARB */ - 983, /* GL_MODELVIEW26_ARB */ - 984, /* GL_MODELVIEW27_ARB */ - 985, /* GL_MODELVIEW28_ARB */ - 986, /* GL_MODELVIEW29_ARB */ - 988, /* GL_MODELVIEW30_ARB */ - 989, /* GL_MODELVIEW31_ARB */ + 1007, /* GL_MULTISAMPLE_3DFX */ + 1409, /* GL_SAMPLE_BUFFERS_3DFX */ + 1400, /* GL_SAMPLES_3DFX */ + 988, /* GL_MODELVIEW2_ARB */ + 991, /* GL_MODELVIEW3_ARB */ + 992, /* GL_MODELVIEW4_ARB */ + 993, /* GL_MODELVIEW5_ARB */ + 994, /* GL_MODELVIEW6_ARB */ + 995, /* GL_MODELVIEW7_ARB */ + 996, /* GL_MODELVIEW8_ARB */ + 997, /* GL_MODELVIEW9_ARB */ + 967, /* GL_MODELVIEW10_ARB */ + 968, /* GL_MODELVIEW11_ARB */ + 969, /* GL_MODELVIEW12_ARB */ + 970, /* GL_MODELVIEW13_ARB */ + 971, /* GL_MODELVIEW14_ARB */ + 972, /* GL_MODELVIEW15_ARB */ + 973, /* GL_MODELVIEW16_ARB */ + 974, /* GL_MODELVIEW17_ARB */ + 975, /* GL_MODELVIEW18_ARB */ + 976, /* GL_MODELVIEW19_ARB */ + 978, /* GL_MODELVIEW20_ARB */ + 979, /* GL_MODELVIEW21_ARB */ + 980, /* GL_MODELVIEW22_ARB */ + 981, /* GL_MODELVIEW23_ARB */ + 982, /* GL_MODELVIEW24_ARB */ + 983, /* GL_MODELVIEW25_ARB */ + 984, /* GL_MODELVIEW26_ARB */ + 985, /* GL_MODELVIEW27_ARB */ + 986, /* GL_MODELVIEW28_ARB */ + 987, /* GL_MODELVIEW29_ARB */ + 989, /* GL_MODELVIEW30_ARB */ + 990, /* GL_MODELVIEW31_ARB */ 391, /* GL_DOT3_RGB_EXT */ 389, /* GL_DOT3_RGBA_EXT */ - 960, /* GL_MIRROR_CLAMP_EXT */ - 963, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */ - 1001, /* GL_MODULATE_ADD_ATI */ - 1002, /* GL_MODULATE_SIGNED_ADD_ATI */ - 1003, /* GL_MODULATE_SUBTRACT_ATI */ - 1880, /* GL_YCBCR_MESA */ - 1093, /* GL_PACK_INVERT_MESA */ + 961, /* GL_MIRROR_CLAMP_EXT */ + 964, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */ + 1002, /* GL_MODULATE_ADD_ATI */ + 1003, /* GL_MODULATE_SIGNED_ADD_ATI */ + 1004, /* GL_MODULATE_SUBTRACT_ATI */ + 1881, /* GL_YCBCR_MESA */ + 1094, /* GL_PACK_INVERT_MESA */ 339, /* GL_DEBUG_OBJECT_MESA */ 340, /* GL_DEBUG_PRINT_MESA */ 338, /* GL_DEBUG_ASSERT_MESA */ @@ -4810,24 +4813,24 @@ static const unsigned reduced_enums[1350] = 450, /* GL_DU8DV8_ATI */ 114, /* GL_BUMP_ENVMAP_ATI */ 118, /* GL_BUMP_TARGET_ATI */ - 1507, /* GL_STENCIL_BACK_FUNC */ - 1505, /* GL_STENCIL_BACK_FAIL */ - 1509, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */ - 1511, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */ + 1508, /* GL_STENCIL_BACK_FUNC */ + 1506, /* GL_STENCIL_BACK_FAIL */ + 1510, /* GL_STENCIL_BACK_PASS_DEPTH_FAIL */ + 1512, /* GL_STENCIL_BACK_PASS_DEPTH_PASS */ 536, /* GL_FRAGMENT_PROGRAM_ARB */ - 1231, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */ - 1259, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */ - 1258, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */ - 1243, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ - 1249, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ - 1248, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ - 892, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */ - 915, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */ - 914, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */ - 905, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ - 911, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ - 910, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ - 875, /* GL_MAX_DRAW_BUFFERS */ + 1232, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */ + 1260, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */ + 1259, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */ + 1244, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ + 1250, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ + 1249, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ + 893, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */ + 916, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */ + 915, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */ + 906, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */ + 912, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */ + 911, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */ + 876, /* GL_MAX_DRAW_BUFFERS */ 395, /* GL_DRAW_BUFFER0 */ 398, /* GL_DRAW_BUFFER1 */ 419, /* GL_DRAW_BUFFER2 */ @@ -4845,161 +4848,161 @@ static const unsigned reduced_enums[1350] = 411, /* GL_DRAW_BUFFER14 */ 414, /* GL_DRAW_BUFFER15 */ 82, /* GL_BLEND_EQUATION_ALPHA */ - 854, /* GL_MATRIX_PALETTE_ARB */ - 886, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */ - 889, /* GL_MAX_PALETTE_MATRICES_ARB */ + 855, /* GL_MATRIX_PALETTE_ARB */ + 887, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */ + 890, /* GL_MAX_PALETTE_MATRICES_ARB */ 321, /* GL_CURRENT_PALETTE_MATRIX_ARB */ - 848, /* GL_MATRIX_INDEX_ARRAY_ARB */ + 849, /* GL_MATRIX_INDEX_ARRAY_ARB */ 316, /* GL_CURRENT_MATRIX_INDEX_ARB */ - 850, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */ - 852, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */ - 851, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */ - 849, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */ - 1699, /* GL_TEXTURE_DEPTH_SIZE */ + 851, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */ + 853, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */ + 852, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */ + 850, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */ + 1700, /* GL_TEXTURE_DEPTH_SIZE */ 379, /* GL_DEPTH_TEXTURE_MODE */ - 1664, /* GL_TEXTURE_COMPARE_MODE */ - 1662, /* GL_TEXTURE_COMPARE_FUNC */ + 1665, /* GL_TEXTURE_COMPARE_MODE */ + 1663, /* GL_TEXTURE_COMPARE_FUNC */ 242, /* GL_COMPARE_R_TO_TEXTURE */ - 1165, /* GL_POINT_SPRITE */ + 1166, /* GL_POINT_SPRITE */ 296, /* GL_COORD_REPLACE */ - 1169, /* GL_POINT_SPRITE_R_MODE_NV */ - 1292, /* GL_QUERY_COUNTER_BITS */ + 1170, /* GL_POINT_SPRITE_R_MODE_NV */ + 1293, /* GL_QUERY_COUNTER_BITS */ 323, /* GL_CURRENT_QUERY */ - 1295, /* GL_QUERY_RESULT */ - 1297, /* GL_QUERY_RESULT_AVAILABLE */ - 940, /* GL_MAX_VERTEX_ATTRIBS */ - 1841, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */ + 1296, /* GL_QUERY_RESULT */ + 1298, /* GL_QUERY_RESULT_AVAILABLE */ + 941, /* GL_MAX_VERTEX_ATTRIBS */ + 1842, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */ 377, /* GL_DEPTH_STENCIL_TO_RGBA_NV */ 376, /* GL_DEPTH_STENCIL_TO_BGRA_NV */ - 926, /* GL_MAX_TEXTURE_COORDS */ - 928, /* GL_MAX_TEXTURE_IMAGE_UNITS */ - 1236, /* GL_PROGRAM_ERROR_STRING_ARB */ - 1238, /* GL_PROGRAM_FORMAT_ASCII_ARB */ - 1237, /* GL_PROGRAM_FORMAT_ARB */ - 1749, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */ + 927, /* GL_MAX_TEXTURE_COORDS */ + 929, /* GL_MAX_TEXTURE_IMAGE_UNITS */ + 1237, /* GL_PROGRAM_ERROR_STRING_ARB */ + 1239, /* GL_PROGRAM_FORMAT_ASCII_ARB */ + 1238, /* GL_PROGRAM_FORMAT_ARB */ + 1750, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */ 354, /* GL_DEPTH_BOUNDS_TEST_EXT */ 353, /* GL_DEPTH_BOUNDS_EXT */ 53, /* GL_ARRAY_BUFFER */ 464, /* GL_ELEMENT_ARRAY_BUFFER */ 54, /* GL_ARRAY_BUFFER_BINDING */ 465, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */ - 1815, /* GL_VERTEX_ARRAY_BUFFER_BINDING */ - 1027, /* GL_NORMAL_ARRAY_BUFFER_BINDING */ + 1816, /* GL_VERTEX_ARRAY_BUFFER_BINDING */ + 1028, /* GL_NORMAL_ARRAY_BUFFER_BINDING */ 149, /* GL_COLOR_ARRAY_BUFFER_BINDING */ - 632, /* GL_INDEX_ARRAY_BUFFER_BINDING */ - 1677, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */ + 633, /* GL_INDEX_ARRAY_BUFFER_BINDING */ + 1678, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */ 460, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */ - 1420, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */ + 1421, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */ 514, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */ - 1868, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */ - 1837, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */ - 1239, /* GL_PROGRAM_INSTRUCTIONS_ARB */ - 898, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */ - 1245, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ - 907, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ - 1257, /* GL_PROGRAM_TEMPORARIES_ARB */ - 913, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */ - 1247, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */ - 909, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */ - 1251, /* GL_PROGRAM_PARAMETERS_ARB */ - 912, /* GL_MAX_PROGRAM_PARAMETERS_ARB */ - 1246, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */ - 908, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */ - 1232, /* GL_PROGRAM_ATTRIBS_ARB */ - 893, /* GL_MAX_PROGRAM_ATTRIBS_ARB */ - 1244, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */ - 906, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */ - 1230, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */ - 891, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */ - 1242, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ - 904, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ - 899, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */ - 895, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */ - 1260, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */ - 1761, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */ - 1308, /* GL_READ_ONLY */ - 1876, /* GL_WRITE_ONLY */ - 1310, /* GL_READ_WRITE */ + 1869, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */ + 1838, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */ + 1240, /* GL_PROGRAM_INSTRUCTIONS_ARB */ + 899, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */ + 1246, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ + 908, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */ + 1258, /* GL_PROGRAM_TEMPORARIES_ARB */ + 914, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */ + 1248, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */ + 910, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */ + 1252, /* GL_PROGRAM_PARAMETERS_ARB */ + 913, /* GL_MAX_PROGRAM_PARAMETERS_ARB */ + 1247, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */ + 909, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */ + 1233, /* GL_PROGRAM_ATTRIBS_ARB */ + 894, /* GL_MAX_PROGRAM_ATTRIBS_ARB */ + 1245, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */ + 907, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */ + 1231, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */ + 892, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */ + 1243, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ + 905, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */ + 900, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */ + 896, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */ + 1261, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */ + 1762, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */ + 1309, /* GL_READ_ONLY */ + 1877, /* GL_WRITE_ONLY */ + 1311, /* GL_READ_WRITE */ 102, /* GL_BUFFER_ACCESS */ 105, /* GL_BUFFER_MAPPED */ 107, /* GL_BUFFER_MAP_POINTER */ - 1755, /* GL_TIME_ELAPSED_EXT */ - 808, /* GL_MATRIX0_ARB */ - 820, /* GL_MATRIX1_ARB */ - 832, /* GL_MATRIX2_ARB */ - 836, /* GL_MATRIX3_ARB */ - 838, /* GL_MATRIX4_ARB */ - 840, /* GL_MATRIX5_ARB */ - 842, /* GL_MATRIX6_ARB */ - 844, /* GL_MATRIX7_ARB */ - 846, /* GL_MATRIX8_ARB */ - 847, /* GL_MATRIX9_ARB */ - 810, /* GL_MATRIX10_ARB */ - 811, /* GL_MATRIX11_ARB */ - 812, /* GL_MATRIX12_ARB */ - 813, /* GL_MATRIX13_ARB */ - 814, /* GL_MATRIX14_ARB */ - 815, /* GL_MATRIX15_ARB */ - 816, /* GL_MATRIX16_ARB */ - 817, /* GL_MATRIX17_ARB */ - 818, /* GL_MATRIX18_ARB */ - 819, /* GL_MATRIX19_ARB */ - 822, /* GL_MATRIX20_ARB */ - 823, /* GL_MATRIX21_ARB */ - 824, /* GL_MATRIX22_ARB */ - 825, /* GL_MATRIX23_ARB */ - 826, /* GL_MATRIX24_ARB */ - 827, /* GL_MATRIX25_ARB */ - 828, /* GL_MATRIX26_ARB */ - 829, /* GL_MATRIX27_ARB */ - 830, /* GL_MATRIX28_ARB */ - 831, /* GL_MATRIX29_ARB */ - 834, /* GL_MATRIX30_ARB */ - 835, /* GL_MATRIX31_ARB */ - 1544, /* GL_STREAM_DRAW */ - 1546, /* GL_STREAM_READ */ - 1542, /* GL_STREAM_COPY */ - 1498, /* GL_STATIC_DRAW */ - 1500, /* GL_STATIC_READ */ - 1496, /* GL_STATIC_COPY */ + 1756, /* GL_TIME_ELAPSED_EXT */ + 809, /* GL_MATRIX0_ARB */ + 821, /* GL_MATRIX1_ARB */ + 833, /* GL_MATRIX2_ARB */ + 837, /* GL_MATRIX3_ARB */ + 839, /* GL_MATRIX4_ARB */ + 841, /* GL_MATRIX5_ARB */ + 843, /* GL_MATRIX6_ARB */ + 845, /* GL_MATRIX7_ARB */ + 847, /* GL_MATRIX8_ARB */ + 848, /* GL_MATRIX9_ARB */ + 811, /* GL_MATRIX10_ARB */ + 812, /* GL_MATRIX11_ARB */ + 813, /* GL_MATRIX12_ARB */ + 814, /* GL_MATRIX13_ARB */ + 815, /* GL_MATRIX14_ARB */ + 816, /* GL_MATRIX15_ARB */ + 817, /* GL_MATRIX16_ARB */ + 818, /* GL_MATRIX17_ARB */ + 819, /* GL_MATRIX18_ARB */ + 820, /* GL_MATRIX19_ARB */ + 823, /* GL_MATRIX20_ARB */ + 824, /* GL_MATRIX21_ARB */ + 825, /* GL_MATRIX22_ARB */ + 826, /* GL_MATRIX23_ARB */ + 827, /* GL_MATRIX24_ARB */ + 828, /* GL_MATRIX25_ARB */ + 829, /* GL_MATRIX26_ARB */ + 830, /* GL_MATRIX27_ARB */ + 831, /* GL_MATRIX28_ARB */ + 832, /* GL_MATRIX29_ARB */ + 835, /* GL_MATRIX30_ARB */ + 836, /* GL_MATRIX31_ARB */ + 1545, /* GL_STREAM_DRAW */ + 1547, /* GL_STREAM_READ */ + 1543, /* GL_STREAM_COPY */ + 1499, /* GL_STATIC_DRAW */ + 1501, /* GL_STATIC_READ */ + 1497, /* GL_STATIC_COPY */ 454, /* GL_DYNAMIC_DRAW */ 456, /* GL_DYNAMIC_READ */ 452, /* GL_DYNAMIC_COPY */ - 1133, /* GL_PIXEL_PACK_BUFFER */ - 1137, /* GL_PIXEL_UNPACK_BUFFER */ - 1134, /* GL_PIXEL_PACK_BUFFER_BINDING */ - 1138, /* GL_PIXEL_UNPACK_BUFFER_BINDING */ + 1134, /* GL_PIXEL_PACK_BUFFER */ + 1138, /* GL_PIXEL_UNPACK_BUFFER */ + 1135, /* GL_PIXEL_PACK_BUFFER_BINDING */ + 1139, /* GL_PIXEL_UNPACK_BUFFER_BINDING */ 347, /* GL_DEPTH24_STENCIL8 */ - 1745, /* GL_TEXTURE_STENCIL_SIZE */ - 1697, /* GL_TEXTURE_CUBE_MAP_SEAMLESS */ - 894, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */ - 897, /* GL_MAX_PROGRAM_IF_DEPTH_NV */ - 901, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */ - 900, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */ - 857, /* GL_MAX_ARRAY_TEXTURE_LAYERS_EXT */ - 1535, /* GL_STENCIL_TEST_TWO_SIDE_EXT */ + 1746, /* GL_TEXTURE_STENCIL_SIZE */ + 1698, /* GL_TEXTURE_CUBE_MAP_SEAMLESS */ + 895, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */ + 898, /* GL_MAX_PROGRAM_IF_DEPTH_NV */ + 902, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */ + 901, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */ + 858, /* GL_MAX_ARRAY_TEXTURE_LAYERS_EXT */ + 1536, /* GL_STENCIL_TEST_TWO_SIDE_EXT */ 17, /* GL_ACTIVE_STENCIL_FACE_EXT */ - 961, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */ - 1401, /* GL_SAMPLES_PASSED */ + 962, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */ + 1402, /* GL_SAMPLES_PASSED */ 109, /* GL_BUFFER_SERIALIZED_MODIFY_APPLE */ 104, /* GL_BUFFER_FLUSHING_UNMAP_APPLE */ 537, /* GL_FRAGMENT_SHADER */ - 1861, /* GL_VERTEX_SHADER */ - 1250, /* GL_PROGRAM_OBJECT_ARB */ - 1433, /* GL_SHADER_OBJECT_ARB */ - 882, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */ - 944, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */ - 938, /* GL_MAX_VARYING_FLOATS */ - 942, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */ - 867, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */ - 1053, /* GL_OBJECT_TYPE_ARB */ - 1435, /* GL_SHADER_TYPE */ + 1862, /* GL_VERTEX_SHADER */ + 1251, /* GL_PROGRAM_OBJECT_ARB */ + 1434, /* GL_SHADER_OBJECT_ARB */ + 883, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS */ + 945, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */ + 939, /* GL_MAX_VARYING_FLOATS */ + 943, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */ + 868, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS */ + 1054, /* GL_OBJECT_TYPE_ARB */ + 1436, /* GL_SHADER_TYPE */ 502, /* GL_FLOAT_VEC2 */ 504, /* GL_FLOAT_VEC3 */ 506, /* GL_FLOAT_VEC4 */ - 659, /* GL_INT_VEC2 */ - 661, /* GL_INT_VEC3 */ - 663, /* GL_INT_VEC4 */ + 660, /* GL_INT_VEC2 */ + 662, /* GL_INT_VEC3 */ + 664, /* GL_INT_VEC4 */ 94, /* GL_BOOL */ 96, /* GL_BOOL_VEC2 */ 98, /* GL_BOOL_VEC3 */ @@ -5007,12 +5010,12 @@ static const unsigned reduced_enums[1350] = 490, /* GL_FLOAT_MAT2 */ 494, /* GL_FLOAT_MAT3 */ 498, /* GL_FLOAT_MAT4 */ - 1392, /* GL_SAMPLER_1D */ - 1394, /* GL_SAMPLER_2D */ - 1396, /* GL_SAMPLER_3D */ - 1397, /* GL_SAMPLER_CUBE */ - 1393, /* GL_SAMPLER_1D_SHADOW */ - 1395, /* GL_SAMPLER_2D_SHADOW */ + 1393, /* GL_SAMPLER_1D */ + 1395, /* GL_SAMPLER_2D */ + 1397, /* GL_SAMPLER_3D */ + 1398, /* GL_SAMPLER_CUBE */ + 1394, /* GL_SAMPLER_1D_SHADOW */ + 1396, /* GL_SAMPLER_2D_SHADOW */ 492, /* GL_FLOAT_MAT2x3 */ 493, /* GL_FLOAT_MAT2x4 */ 496, /* GL_FLOAT_MAT3x2 */ @@ -5021,61 +5024,61 @@ static const unsigned reduced_enums[1350] = 501, /* GL_FLOAT_MAT4x3 */ 345, /* GL_DELETE_STATUS */ 246, /* GL_COMPILE_STATUS */ - 715, /* GL_LINK_STATUS */ - 1809, /* GL_VALIDATE_STATUS */ - 644, /* GL_INFO_LOG_LENGTH */ + 716, /* GL_LINK_STATUS */ + 1810, /* GL_VALIDATE_STATUS */ + 645, /* GL_INFO_LOG_LENGTH */ 56, /* GL_ATTACHED_SHADERS */ 20, /* GL_ACTIVE_UNIFORMS */ 21, /* GL_ACTIVE_UNIFORM_MAX_LENGTH */ - 1434, /* GL_SHADER_SOURCE_LENGTH */ + 1435, /* GL_SHADER_SOURCE_LENGTH */ 15, /* GL_ACTIVE_ATTRIBUTES */ 16, /* GL_ACTIVE_ATTRIBUTE_MAX_LENGTH */ 539, /* GL_FRAGMENT_SHADER_DERIVATIVE_HINT */ - 1437, /* GL_SHADING_LANGUAGE_VERSION */ + 1438, /* GL_SHADING_LANGUAGE_VERSION */ 322, /* GL_CURRENT_PROGRAM */ - 1102, /* GL_PALETTE4_RGB8_OES */ - 1104, /* GL_PALETTE4_RGBA8_OES */ - 1100, /* GL_PALETTE4_R5_G6_B5_OES */ - 1103, /* GL_PALETTE4_RGBA4_OES */ - 1101, /* GL_PALETTE4_RGB5_A1_OES */ - 1107, /* GL_PALETTE8_RGB8_OES */ - 1109, /* GL_PALETTE8_RGBA8_OES */ - 1105, /* GL_PALETTE8_R5_G6_B5_OES */ - 1108, /* GL_PALETTE8_RGBA4_OES */ - 1106, /* GL_PALETTE8_RGB5_A1_OES */ - 626, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */ - 625, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */ - 1794, /* GL_UNSIGNED_NORMALIZED */ - 1632, /* GL_TEXTURE_1D_ARRAY_EXT */ - 1272, /* GL_PROXY_TEXTURE_1D_ARRAY_EXT */ - 1634, /* GL_TEXTURE_2D_ARRAY_EXT */ - 1275, /* GL_PROXY_TEXTURE_2D_ARRAY_EXT */ - 1640, /* GL_TEXTURE_BINDING_1D_ARRAY_EXT */ - 1642, /* GL_TEXTURE_BINDING_2D_ARRAY_EXT */ - 1490, /* GL_SRGB */ - 1491, /* GL_SRGB8 */ - 1493, /* GL_SRGB_ALPHA */ - 1492, /* GL_SRGB8_ALPHA8 */ - 1450, /* GL_SLUMINANCE_ALPHA */ - 1449, /* GL_SLUMINANCE8_ALPHA8 */ - 1447, /* GL_SLUMINANCE */ - 1448, /* GL_SLUMINANCE8 */ + 1103, /* GL_PALETTE4_RGB8_OES */ + 1105, /* GL_PALETTE4_RGBA8_OES */ + 1101, /* GL_PALETTE4_R5_G6_B5_OES */ + 1104, /* GL_PALETTE4_RGBA4_OES */ + 1102, /* GL_PALETTE4_RGB5_A1_OES */ + 1108, /* GL_PALETTE8_RGB8_OES */ + 1110, /* GL_PALETTE8_RGBA8_OES */ + 1106, /* GL_PALETTE8_R5_G6_B5_OES */ + 1109, /* GL_PALETTE8_RGBA4_OES */ + 1107, /* GL_PALETTE8_RGB5_A1_OES */ + 627, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */ + 626, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */ + 1795, /* GL_UNSIGNED_NORMALIZED */ + 1633, /* GL_TEXTURE_1D_ARRAY_EXT */ + 1273, /* GL_PROXY_TEXTURE_1D_ARRAY_EXT */ + 1635, /* GL_TEXTURE_2D_ARRAY_EXT */ + 1276, /* GL_PROXY_TEXTURE_2D_ARRAY_EXT */ + 1641, /* GL_TEXTURE_BINDING_1D_ARRAY_EXT */ + 1643, /* GL_TEXTURE_BINDING_2D_ARRAY_EXT */ + 1491, /* GL_SRGB */ + 1492, /* GL_SRGB8 */ + 1494, /* GL_SRGB_ALPHA */ + 1493, /* GL_SRGB8_ALPHA8 */ + 1451, /* GL_SLUMINANCE_ALPHA */ + 1450, /* GL_SLUMINANCE8_ALPHA8 */ + 1448, /* GL_SLUMINANCE */ + 1449, /* GL_SLUMINANCE8 */ 267, /* GL_COMPRESSED_SRGB */ 268, /* GL_COMPRESSED_SRGB_ALPHA */ 265, /* GL_COMPRESSED_SLUMINANCE */ 266, /* GL_COMPRESSED_SLUMINANCE_ALPHA */ - 1167, /* GL_POINT_SPRITE_COORD_ORIGIN */ - 723, /* GL_LOWER_LEFT */ - 1806, /* GL_UPPER_LEFT */ - 1513, /* GL_STENCIL_BACK_REF */ - 1514, /* GL_STENCIL_BACK_VALUE_MASK */ - 1515, /* GL_STENCIL_BACK_WRITEMASK */ + 1168, /* GL_POINT_SPRITE_COORD_ORIGIN */ + 724, /* GL_LOWER_LEFT */ + 1807, /* GL_UPPER_LEFT */ + 1514, /* GL_STENCIL_BACK_REF */ + 1515, /* GL_STENCIL_BACK_VALUE_MASK */ + 1516, /* GL_STENCIL_BACK_WRITEMASK */ 444, /* GL_DRAW_FRAMEBUFFER_BINDING */ - 1324, /* GL_RENDERBUFFER_BINDING */ - 1304, /* GL_READ_FRAMEBUFFER */ + 1325, /* GL_RENDERBUFFER_BINDING */ + 1305, /* GL_READ_FRAMEBUFFER */ 443, /* GL_DRAW_FRAMEBUFFER */ - 1305, /* GL_READ_FRAMEBUFFER_BINDING */ - 1335, /* GL_RENDERBUFFER_SAMPLES */ + 1306, /* GL_READ_FRAMEBUFFER_BINDING */ + 1336, /* GL_RENDERBUFFER_SAMPLES */ 549, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ 547, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ 558, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ @@ -5091,7 +5094,7 @@ static const unsigned reduced_enums[1350] = 577, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ 581, /* GL_FRAMEBUFFER_UNSUPPORTED */ 579, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */ - 863, /* GL_MAX_COLOR_ATTACHMENTS */ + 864, /* GL_MAX_COLOR_ATTACHMENTS */ 155, /* GL_COLOR_ATTACHMENT0 */ 157, /* GL_COLOR_ATTACHMENT1 */ 171, /* GL_COLOR_ATTACHMENT2 */ @@ -5109,58 +5112,58 @@ static const unsigned reduced_enums[1350] = 166, /* GL_COLOR_ATTACHMENT14 */ 168, /* GL_COLOR_ATTACHMENT15 */ 349, /* GL_DEPTH_ATTACHMENT */ - 1503, /* GL_STENCIL_ATTACHMENT */ + 1504, /* GL_STENCIL_ATTACHMENT */ 540, /* GL_FRAMEBUFFER */ - 1322, /* GL_RENDERBUFFER */ - 1338, /* GL_RENDERBUFFER_WIDTH */ - 1330, /* GL_RENDERBUFFER_HEIGHT */ - 1332, /* GL_RENDERBUFFER_INTERNAL_FORMAT */ - 1530, /* GL_STENCIL_INDEX_EXT */ - 1522, /* GL_STENCIL_INDEX1 */ - 1526, /* GL_STENCIL_INDEX4 */ - 1528, /* GL_STENCIL_INDEX8 */ - 1523, /* GL_STENCIL_INDEX16 */ - 1334, /* GL_RENDERBUFFER_RED_SIZE */ - 1329, /* GL_RENDERBUFFER_GREEN_SIZE */ - 1326, /* GL_RENDERBUFFER_BLUE_SIZE */ - 1323, /* GL_RENDERBUFFER_ALPHA_SIZE */ - 1327, /* GL_RENDERBUFFER_DEPTH_SIZE */ - 1337, /* GL_RENDERBUFFER_STENCIL_SIZE */ + 1323, /* GL_RENDERBUFFER */ + 1339, /* GL_RENDERBUFFER_WIDTH */ + 1331, /* GL_RENDERBUFFER_HEIGHT */ + 1333, /* GL_RENDERBUFFER_INTERNAL_FORMAT */ + 1531, /* GL_STENCIL_INDEX_EXT */ + 1523, /* GL_STENCIL_INDEX1 */ + 1527, /* GL_STENCIL_INDEX4 */ + 1529, /* GL_STENCIL_INDEX8 */ + 1524, /* GL_STENCIL_INDEX16 */ + 1335, /* GL_RENDERBUFFER_RED_SIZE */ + 1330, /* GL_RENDERBUFFER_GREEN_SIZE */ + 1327, /* GL_RENDERBUFFER_BLUE_SIZE */ + 1324, /* GL_RENDERBUFFER_ALPHA_SIZE */ + 1328, /* GL_RENDERBUFFER_DEPTH_SIZE */ + 1338, /* GL_RENDERBUFFER_STENCIL_SIZE */ 575, /* GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ - 921, /* GL_MAX_SAMPLES */ - 1299, /* GL_QUERY_WAIT_NV */ - 1294, /* GL_QUERY_NO_WAIT_NV */ - 1291, /* GL_QUERY_BY_REGION_WAIT_NV */ - 1290, /* GL_QUERY_BY_REGION_NO_WAIT_NV */ - 1286, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ + 922, /* GL_MAX_SAMPLES */ + 1300, /* GL_QUERY_WAIT_NV */ + 1295, /* GL_QUERY_NO_WAIT_NV */ + 1292, /* GL_QUERY_BY_REGION_WAIT_NV */ + 1291, /* GL_QUERY_BY_REGION_NO_WAIT_NV */ + 1287, /* GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ 486, /* GL_FIRST_VERTEX_CONVENTION */ - 674, /* GL_LAST_VERTEX_CONVENTION */ - 1264, /* GL_PROVOKING_VERTEX */ + 675, /* GL_LAST_VERTEX_CONVENTION */ + 1265, /* GL_PROVOKING_VERTEX */ 302, /* GL_COPY_READ_BUFFER */ 303, /* GL_COPY_WRITE_BUFFER */ - 1385, /* GL_RGBA_SNORM */ - 1381, /* GL_RGBA8_SNORM */ - 1443, /* GL_SIGNED_NORMALIZED */ - 923, /* GL_MAX_SERVER_WAIT_TIMEOUT */ - 1052, /* GL_OBJECT_TYPE */ - 1551, /* GL_SYNC_CONDITION */ - 1556, /* GL_SYNC_STATUS */ - 1553, /* GL_SYNC_FLAGS */ - 1552, /* GL_SYNC_FENCE */ - 1555, /* GL_SYNC_GPU_COMMANDS_COMPLETE */ - 1782, /* GL_UNSIGNALED */ - 1442, /* GL_SIGNALED */ + 1386, /* GL_RGBA_SNORM */ + 1382, /* GL_RGBA8_SNORM */ + 1444, /* GL_SIGNED_NORMALIZED */ + 924, /* GL_MAX_SERVER_WAIT_TIMEOUT */ + 1053, /* GL_OBJECT_TYPE */ + 1552, /* GL_SYNC_CONDITION */ + 1557, /* GL_SYNC_STATUS */ + 1554, /* GL_SYNC_FLAGS */ + 1553, /* GL_SYNC_FENCE */ + 1556, /* GL_SYNC_GPU_COMMANDS_COMPLETE */ + 1783, /* GL_UNSIGNALED */ + 1443, /* GL_SIGNALED */ 46, /* GL_ALREADY_SIGNALED */ - 1754, /* GL_TIMEOUT_EXPIRED */ + 1755, /* GL_TIMEOUT_EXPIRED */ 270, /* GL_CONDITION_SATISFIED */ - 1866, /* GL_WAIT_FAILED */ + 1867, /* GL_WAIT_FAILED */ 471, /* GL_EVAL_BIT */ - 1302, /* GL_RASTER_POSITION_UNCLIPPED_IBM */ - 717, /* GL_LIST_BIT */ - 1648, /* GL_TEXTURE_BIT */ - 1416, /* GL_SCISSOR_BIT */ + 1303, /* GL_RASTER_POSITION_UNCLIPPED_IBM */ + 718, /* GL_LIST_BIT */ + 1649, /* GL_TEXTURE_BIT */ + 1417, /* GL_SCISSOR_BIT */ 29, /* GL_ALL_ATTRIB_BITS */ - 1008, /* GL_MULTISAMPLE_BIT */ + 1009, /* GL_MULTISAMPLE_BIT */ 30, /* GL_ALL_CLIENT_ATTRIB_BITS */ }; -- cgit v1.2.3 From cfe884e2030466df673881da8e830c300dda40db Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 18 Jan 2010 16:29:31 +1000 Subject: mesa: add core support for ARB_half_float_vertex. Adds the extension to the list + support to the APIs. also add t_draw.c support to convert for sw rast. Signed-off-by: Dave Airlie --- src/mesa/main/extensions.c | 2 ++ src/mesa/main/mtypes.h | 1 + src/mesa/main/varray.c | 21 +++++++++++++++++++++ src/mesa/tnl/t_draw.c | 19 +++++++++++++++++++ 4 files changed, 43 insertions(+) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index b6c7a02a7c..73be24d80c 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -56,6 +56,7 @@ static const struct { { OFF, "GL_ARB_fragment_shader", F(ARB_fragment_shader) }, { OFF, "GL_ARB_framebuffer_object", F(ARB_framebuffer_object) }, { OFF, "GL_ARB_half_float_pixel", F(ARB_half_float_pixel) }, + { OFF, "GL_ARB_half_float_vertex", F(ARB_half_float_vertex) }, { OFF, "GL_ARB_imaging", F(ARB_imaging) }, { OFF, "GL_ARB_map_buffer_range", F(ARB_map_buffer_range) }, { ON, "GL_ARB_multisample", F(ARB_multisample) }, @@ -220,6 +221,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx) ctx->Extensions.ARB_framebuffer_object = GL_TRUE; #endif ctx->Extensions.ARB_half_float_pixel = GL_TRUE; + ctx->Extensions.ARB_half_float_vertex = GL_TRUE; ctx->Extensions.ARB_imaging = GL_TRUE; ctx->Extensions.ARB_map_buffer_range = GL_TRUE; ctx->Extensions.ARB_multitexture = GL_TRUE; diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 919ddd7a29..297c5ae878 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2403,6 +2403,7 @@ struct gl_extensions GLboolean ARB_fragment_shader; GLboolean ARB_framebuffer_object; GLboolean ARB_half_float_pixel; + GLboolean ARB_half_float_vertex; GLboolean ARB_imaging; GLboolean ARB_map_buffer_range; GLboolean ARB_multisample; diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index c2193074cd..0b6295d5e1 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -121,6 +121,9 @@ _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) case GL_DOUBLE: elementSize = size * sizeof(GLdouble); break; + case GL_HALF_FLOAT: + elementSize = size * sizeof(GLhalfARB); + break; #if FEATURE_fixedpt case GL_FIXED: elementSize = size * sizeof(GLfixed); @@ -174,6 +177,9 @@ _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr ) case GL_DOUBLE: elementSize = 3 * sizeof(GLdouble); break; + case GL_HALF_FLOAT: + elementSize = 3 * sizeof(GLhalfARB); + break; #if FEATURE_fixedpt case GL_FIXED: elementSize = 3 * sizeof(GLfixed); @@ -250,6 +256,9 @@ _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) case GL_DOUBLE: elementSize = size * sizeof(GLdouble); break; + case GL_HALF_FLOAT: + elementSize = size * sizeof(GLhalfARB); + break; #if FEATURE_fixedpt case GL_FIXED: elementSize = size * sizeof(GLfixed); @@ -285,6 +294,9 @@ _mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr) case GL_DOUBLE: elementSize = sizeof(GLdouble); break; + case GL_HALF_FLOAT: + elementSize = sizeof(GLhalfARB); + break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glFogCoordPointer(type)" ); return; @@ -394,6 +406,9 @@ _mesa_SecondaryColorPointerEXT(GLint size, GLenum type, case GL_DOUBLE: elementSize = size * sizeof(GLdouble); break; + case GL_HALF_FLOAT: + elementSize = size * sizeof(GLhalfARB); + break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glSecondaryColorPointer(type=%s)", _mesa_lookup_enum_by_nr(type)); @@ -441,6 +456,9 @@ _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, case GL_DOUBLE: elementSize = size * sizeof(GLdouble); break; + case GL_HALF_FLOAT: + elementSize = size * sizeof(GLhalfARB); + break; #if FEATURE_fixedpt case GL_FIXED: elementSize = size * sizeof(GLfixed); @@ -670,6 +688,9 @@ _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, case GL_DOUBLE: elementSize = size * sizeof(GLdouble); break; + case GL_HALF_FLOAT: + elementSize = size * sizeof(GLhalfARB); + break; #if FEATURE_fixedpt case GL_FIXED: elementSize = size * sizeof(GLfixed); diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c index 38757a0e28..d8c611031d 100644 --- a/src/mesa/tnl/t_draw.c +++ b/src/mesa/tnl/t_draw.c @@ -108,6 +108,22 @@ convert_bgra_to_float(const struct gl_client_array *input, } } +static void +convert_half_to_float(const struct gl_client_array *input, + const GLubyte *ptr, GLfloat *fptr, + GLuint count, GLuint sz) +{ + GLuint i, j; + + for (i = 0; i < count; i++) { + GLhalfARB *in = (GLhalfARB *)ptr; + + for (j = 0; j < sz; j++) { + *fptr++ = _mesa_half_to_float(in[j]); + } + ptr += input->StrideB; + } +} /* Adjust pointer to point at first requested element, convert to * floating point, populate VB->AttribPtr[]. @@ -155,6 +171,9 @@ static void _tnl_import_array( GLcontext *ctx, case GL_DOUBLE: CONVERT(GLdouble, (GLfloat)); break; + case GL_HALF_FLOAT: + convert_half_to_float(input, ptr, fptr, count, sz); + break; default: assert(0); break; -- cgit v1.2.3 From 96f2f0daeadd5bd2d8433e31a1b122c2bd709390 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 18 Jan 2010 16:30:56 +1000 Subject: i965: add support for ARB_half_float_vertex enables the extension on i965 and adds support to the draw upload for the vertex format. Signed-off-by: Dave Airlie --- src/mesa/drivers/dri/i965/brw_draw_upload.c | 11 +++++++++++ src/mesa/drivers/dri/intel/intel_extensions.c | 1 + 2 files changed, 12 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index c773b71507..6161de8a84 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -59,6 +59,14 @@ static GLuint float_types[5] = { BRW_SURFACEFORMAT_R32G32B32A32_FLOAT }; +static GLuint half_float_types[5] = { + 0, + BRW_SURFACEFORMAT_R16_FLOAT, + BRW_SURFACEFORMAT_R16G16_FLOAT, + 0, /* can't seem to render this one */ + BRW_SURFACEFORMAT_R16G16B16A16_FLOAT +}; + static GLuint uint_types_norm[5] = { 0, BRW_SURFACEFORMAT_R32_UNORM, @@ -172,6 +180,7 @@ static GLuint get_surface_type( GLenum type, GLuint size, switch (type) { case GL_DOUBLE: return double_types[size]; case GL_FLOAT: return float_types[size]; + case GL_HALF_FLOAT: return half_float_types[size]; case GL_INT: return int_types_norm[size]; case GL_SHORT: return short_types_norm[size]; case GL_BYTE: return byte_types_norm[size]; @@ -194,6 +203,7 @@ static GLuint get_surface_type( GLenum type, GLuint size, switch (type) { case GL_DOUBLE: return double_types[size]; case GL_FLOAT: return float_types[size]; + case GL_HALF_FLOAT: return half_float_types[size]; case GL_INT: return int_types_scale[size]; case GL_SHORT: return short_types_scale[size]; case GL_BYTE: return byte_types_scale[size]; @@ -211,6 +221,7 @@ static GLuint get_size( GLenum type ) switch (type) { case GL_DOUBLE: return sizeof(GLdouble); case GL_FLOAT: return sizeof(GLfloat); + case GL_HALF_FLOAT: return sizeof(GLhalfARB); case GL_INT: return sizeof(GLint); case GL_SHORT: return sizeof(GLshort); case GL_BYTE: return sizeof(GLbyte); diff --git a/src/mesa/drivers/dri/intel/intel_extensions.c b/src/mesa/drivers/dri/intel/intel_extensions.c index 5ac5ce10af..6fdd22b9e9 100644 --- a/src/mesa/drivers/dri/intel/intel_extensions.c +++ b/src/mesa/drivers/dri/intel/intel_extensions.c @@ -154,6 +154,7 @@ static const struct dri_extension brw_extensions[] = { { "GL_ARB_fragment_program_shadow", NULL }, { "GL_ARB_fragment_shader", NULL }, { "GL_ARB_framebuffer_object", GL_ARB_framebuffer_object_functions}, + { "GL_ARB_half_float_vertex", NULL }, { "GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions }, { "GL_ARB_point_sprite", NULL }, { "GL_ARB_seamless_cube_map", NULL }, -- cgit v1.2.3 From d82b8038fda47e825cbd093b3ae198a85a163b25 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 23 Jan 2010 07:38:06 +1000 Subject: r300: half float support Signed-off-by: Dave Airlie --- src/mesa/drivers/dri/r300/r300_context.c | 1 + src/mesa/drivers/dri/r300/r300_draw.c | 14 ++++++++++++++ src/mesa/drivers/dri/r300/r300_reg.h | 3 +++ 3 files changed, 18 insertions(+) diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c index bb0e6db313..24c51d4fee 100644 --- a/src/mesa/drivers/dri/r300/r300_context.c +++ b/src/mesa/drivers/dri/r300/r300_context.c @@ -97,6 +97,7 @@ static const struct dri_extension card_extensions[] = { /* *INDENT-OFF* */ {"GL_ARB_depth_texture", NULL}, {"GL_ARB_fragment_program", NULL}, + {"GL_ARB_half_float_vertex", NULL}, {"GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions}, {"GL_ARB_multitexture", NULL}, {"GL_ARB_point_parameters", GL_ARB_point_parameters_functions}, diff --git a/src/mesa/drivers/dri/r300/r300_draw.c b/src/mesa/drivers/dri/r300/r300_draw.c index 3dcd986e22..2219821153 100644 --- a/src/mesa/drivers/dri/r300/r300_draw.c +++ b/src/mesa/drivers/dri/r300/r300_draw.c @@ -56,6 +56,8 @@ static int getTypeSize(GLenum type) switch (type) { case GL_DOUBLE: return sizeof(GLdouble); + case GL_HALF_FLOAT: + return sizeof(GLhalfARB); case GL_FLOAT: return sizeof(GLfloat); case GL_INT: @@ -385,6 +387,18 @@ static void r300TranslateAttrib(GLcontext *ctx, GLuint attr, int count, const st r300_attr._signed = 0; r300_attr.normalize = 0; break; + case GL_HALF_FLOAT: + switch (input->Size) { + case 1: + case 2: + r300_attr.data_type = R300_DATA_TYPE_FLT16_2; + break; + case 3: + case 4: + r300_attr.data_type = R300_DATA_TYPE_FLT16_4; + break; + } + break; case GL_SHORT: r300_attr._signed = 1; r300_attr.normalize = input->Normalized; diff --git a/src/mesa/drivers/dri/r300/r300_reg.h b/src/mesa/drivers/dri/r300/r300_reg.h index ea684e7df1..d18ebab8ff 100644 --- a/src/mesa/drivers/dri/r300/r300_reg.h +++ b/src/mesa/drivers/dri/r300/r300_reg.h @@ -230,6 +230,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. # define R300_DATA_TYPE_SHORT_4 7 # define R300_DATA_TYPE_VECTOR_3_TTT 8 # define R300_DATA_TYPE_VECTOR_3_EET 9 +# define R300_DATA_TYPE_FLT16_2 11 +# define R300_DATA_TYPE_FLT16_4 12 + # define R300_SKIP_DWORDS_SHIFT 4 # define R300_DST_VEC_LOC_SHIFT 8 # define R300_LAST_VEC (1 << 13) -- cgit v1.2.3 From 092841892228c7b71dd5d6d463f1e0a37033eae9 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 23 Jan 2010 10:31:21 +0800 Subject: Revert "add segl" This reverts commit fe33b7083b0081b91ee338acbe966400c6b9a7b9. It was not supposed to be pushed yet. --- progs/egl/segl/Makefile | 21 ------ progs/egl/segl/segl.c | 167 ---------------------------------------------- progs/egl/segl/segl.h | 60 ----------------- progs/egl/segl/segl_kms.c | 59 ---------------- progs/egl/segl/segl_x11.c | 117 -------------------------------- 5 files changed, 424 deletions(-) delete mode 100644 progs/egl/segl/Makefile delete mode 100644 progs/egl/segl/segl.c delete mode 100644 progs/egl/segl/segl.h delete mode 100644 progs/egl/segl/segl_kms.c delete mode 100644 progs/egl/segl/segl_x11.c diff --git a/progs/egl/segl/Makefile b/progs/egl/segl/Makefile deleted file mode 100644 index c5f13f69c1..0000000000 --- a/progs/egl/segl/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# progs/egl/segl/Makefile - -TOP = ../../.. -include $(TOP)/configs/current - -SEGL_LIBS := $(foreach dpy, $(EGL_DISPLAYS), libsegl-$(dpy).a) - -all: $(SEGL_LIBS) - -x11_OBJECTS := segl.o segl_x11.o -kms_OBJECTS := segl.o segl_kms.o - -libsegl-x11.a: $(x11_OBJECTS) - $(MKLIB) -o segl-x11 -static $(x11_OBJECTS) - -libsegl-kms.a: $(kms_OBJECTS) - $(MKLIB) -o segl-kms -static $(kms_OBJECTS) - -clean: - rm -f $(sort $(x11_OBJECTS) $(kms_OBJECTS)) - rm -f $(SEGL_LIBS) diff --git a/progs/egl/segl/segl.c b/progs/egl/segl/segl.c deleted file mode 100644 index b1df71a5b5..0000000000 --- a/progs/egl/segl/segl.c +++ /dev/null @@ -1,167 +0,0 @@ -#include -#include -#include -#include -#include - -#include "segl.h" - -static void -segl_log(struct segl *segl, const char *format, ...) -{ - va_list ap; - - va_start(ap, format); - - if (segl->winsys->vlog) - segl->winsys->vlog(segl->winsys, format, ap); - else - vfprintf(stdout, format, ap); - - va_end(ap); -} - -static EGLBoolean -segl_init_egl(struct segl *segl, const EGLint *attribs) -{ - EGLint num_conf; - - segl->dpy = eglGetDisplay(segl->winsys->dpy); - if (!segl->dpy) - return EGL_FALSE; - - if (!eglInitialize(segl->dpy, &segl->major, &segl->minor)) - return EGL_FALSE; - - if (segl->verbose) { - const char *ver = eglQueryString(segl->dpy, EGL_VERSION); - segl_log(segl, "EGL_VERSION = %s\n", ver); - } - - if (!eglChooseConfig(segl->dpy, attribs, &segl->conf, 1, &num_conf) || - !num_conf) { - segl_log(segl, "failed to choose a config\n"); - eglTerminate(segl->dpy); - return EGL_FALSE; - } - - return EGL_TRUE; -} - -struct segl * -segl_new(struct segl_winsys *winsys, const EGLint *attribs) -{ - struct segl *segl; - - segl = calloc(1, sizeof(*segl)); - if (segl) { - segl->verbose = EGL_TRUE; - segl->winsys = winsys; - - if (!segl_init_egl(segl, attribs)) { - free(segl); - return NULL; - } - } - - return segl; -} - -void -segl_destroy(struct segl *segl) -{ - free(segl); -} - -EGLBoolean -segl_create_window(struct segl *segl, const char *name, - EGLint width, EGLint height, const EGLint *attribs, - EGLNativeWindowType *win_ret, EGLSurface *surf_ret) -{ - EGLNativeWindowType win; - EGLSurface surf; - EGLint visual; - - if (!win_ret) { - if (surf_ret) - *surf_ret = EGL_NO_SURFACE; - return EGL_TRUE; - } - - if (!eglGetConfigAttrib(segl->dpy, segl->conf, EGL_NATIVE_VISUAL_ID, &visual)) - return EGL_FALSE; - - win = segl->winsys->create_window(segl->winsys, - name, width, height, visual); - if (surf_ret) { - surf = eglCreateWindowSurface(segl->dpy, segl->conf, win, attribs); - if (!surf) { - segl_log(segl, "failed to create a window surface\n"); - segl->winsys->destroy_window(segl->winsys, win); - return EGL_FALSE; - } - - *surf_ret = surf; - } - - *win_ret = win; - - return EGL_TRUE; -} - -EGLBoolean -segl_create_pixmap(struct segl *segl, - EGLint width, EGLint height, const EGLint *attribs, - EGLNativePixmapType *pix_ret, EGLSurface *surf_ret) -{ - EGLNativePixmapType pix; - EGLSurface surf; - EGLint depth; - - if (!pix_ret) { - if (surf_ret) - *surf_ret = EGL_NO_SURFACE; - return EGL_TRUE; - } - - if (!eglGetConfigAttrib(segl->dpy, segl->conf, EGL_BUFFER_SIZE, &depth)) - return EGL_FALSE; - - pix = segl->winsys->create_pixmap(segl->winsys, width, height, depth); - if (surf_ret) { - surf = eglCreatePixmapSurface(segl->dpy, segl->conf, pix, attribs); - if (!surf) { - segl_log(segl, "failed to create a pixmap surface\n"); - segl->winsys->destroy_pixmap(segl->winsys, pix); - return EGL_FALSE; - } - - *surf_ret = surf; - } - - *pix_ret = pix; - - return EGL_TRUE; -} - -void -segl_benchmark(struct segl *segl, double seconds, - void (*draw_frame)(void *), void *draw_data) -{ - double begin, end, last_frame, duration; - EGLint num_frames = 0; - - begin = segl->winsys->now(segl->winsys); - end = begin + seconds; - - last_frame = begin; - while (last_frame < end) { - draw_frame(draw_data); - last_frame = segl->winsys->now(segl->winsys); - num_frames++; - } - - duration = last_frame - begin; - segl_log(segl, "%d frames in %3.1f seconds = %6.3f FPS\n", - num_frames, duration, (double) num_frames / duration); -} diff --git a/progs/egl/segl/segl.h b/progs/egl/segl/segl.h deleted file mode 100644 index 20faf6ef02..0000000000 --- a/progs/egl/segl/segl.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef _SEGL_H_ -#define _SEGL_H_ - -#include -#include - -struct segl_winsys { - EGLNativeDisplayType dpy; - - EGLNativeWindowType (*create_window)(struct segl_winsys *winsys, - const char *name, - EGLint width, EGLint height, - EGLint visual); - void (*destroy_window)(struct segl_winsys *winsys, EGLNativeWindowType win); - - EGLNativePixmapType (*create_pixmap)(struct segl_winsys *winsys, - EGLint width, EGLint height, - EGLint depth); - void (*destroy_pixmap)(struct segl_winsys *winsys, EGLNativePixmapType pix); - - /* get current time in seconds */ - double (*now)(struct segl_winsys *winsys); - /* log a message. OPTIONAL */ - void (*vlog)(struct segl_winsys *winsys, const char *format, va_list ap); -}; - -struct segl { - EGLBoolean verbose; - - struct segl_winsys *winsys; - - EGLint major, minor; - EGLDisplay dpy; - EGLConfig conf; -}; - -struct segl_winsys * -segl_get_winsys(EGLNativeDisplayType dpy); - -struct segl * -segl_new(struct segl_winsys *winsys, const EGLint *attribs); - -void -segl_destroy(struct segl *segl); - -EGLBoolean -segl_create_window(struct segl *segl, const char *name, - EGLint width, EGLint height, const EGLint *attribs, - EGLNativeWindowType *win_ret, EGLSurface *surf_ret); - -EGLBoolean -segl_create_pixmap(struct segl *segl, - EGLint width, EGLint height, const EGLint *attribs, - EGLNativePixmapType *pix_ret, EGLSurface *surf_ret); - -void -segl_benchmark(struct segl *segl, double seconds, - void (*draw_frame)(void *), void *draw_data); - -#endif /* _SEGL_H_ */ diff --git a/progs/egl/segl/segl_kms.c b/progs/egl/segl/segl_kms.c deleted file mode 100644 index bb4fcfca65..0000000000 --- a/progs/egl/segl/segl_kms.c +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include - -#include "segl.h" - -static EGLNativeWindowType -kms_create_window(struct segl_winsys *winsys, const char *name, - EGLint width, EGLint height, EGLint visual) -{ - return 0; -} - -static void -kms_destroy_window(struct segl_winsys *winsys, EGLNativeWindowType win) -{ -} - - -static EGLNativePixmapType -kms_create_pixmap(struct segl_winsys *winsys, EGLint width, EGLint height, - EGLint depth) -{ - return 0; -} - -static void -kms_destroy_pixmap(struct segl_winsys *winsys, EGLNativePixmapType pix) -{ -} - -static double -kms_now(struct segl_winsys *winsys) -{ - struct timeval tv; - - gettimeofday(&tv, NULL); - - return (double) tv.tv_sec + tv.tv_usec / 1000000.0; -} - -struct segl_winsys * -segl_get_winsys(EGLNativeDisplayType dpy) -{ - struct segl_winsys *winsys; - - winsys = calloc(1, sizeof(*winsys)); - if (winsys) { - winsys->dpy = dpy; - - winsys->create_window = kms_create_window; - winsys->destroy_window = kms_destroy_window; - winsys->create_pixmap = kms_create_pixmap; - winsys->destroy_pixmap = kms_destroy_pixmap; - - winsys->now = kms_now; - } - - return winsys; -} diff --git a/progs/egl/segl/segl_x11.c b/progs/egl/segl/segl_x11.c deleted file mode 100644 index 7b26917460..0000000000 --- a/progs/egl/segl/segl_x11.c +++ /dev/null @@ -1,117 +0,0 @@ -#include -#include -#include -#include - -#include "segl.h" - -static Window -x11_create_window(struct segl_winsys *winsys, const char *name, - EGLint width, EGLint height, EGLint visual) -{ - XVisualInfo vinfo_template, *vinfo = NULL; - EGLint val, num_vinfo; - Window root, win; - XSetWindowAttributes attrs; - unsigned long mask; - EGLint x = 0, y = 0; - - vinfo_template.visualid = (VisualID) val; - vinfo = XGetVisualInfo(winsys->dpy, VisualIDMask, &vinfo_template, &num_vinfo); - if (!num_vinfo) { - if (vinfo) - XFree(vinfo); - return None; - } - - root = DefaultRootWindow(winsys->dpy); - - /* window attributes */ - attrs.background_pixel = 0; - attrs.border_pixel = 0; - attrs.colormap = XCreateColormap(winsys->dpy, root, vinfo->visual, AllocNone); - attrs.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; - attrs.override_redirect = False; - mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect; - - win = XCreateWindow(winsys->dpy, root, x, y, width, height, 0, - vinfo->depth, InputOutput, vinfo->visual, mask, &attrs); - XFree(vinfo); - - if (!win) - return None; - - /* set hints and properties */ - { - XSizeHints sizehints; - sizehints.x = x; - sizehints.y = y; - sizehints.width = width; - sizehints.height = height; - sizehints.flags = USSize | USPosition; - XSetNormalHints(winsys->dpy, win, &sizehints); - XSetStandardProperties(winsys->dpy, win, name, name, - None, (char **)NULL, 0, &sizehints); - } - - XMapWindow(winsys->dpy, win); - - return win; -} - -static void -x11_destroy_window(struct segl_winsys *winsys, Window win) -{ - if (win) - XDestroyWindow(winsys->dpy, win); -} - - -static Pixmap -x11_create_pixmap(struct segl_winsys *winsys, EGLint width, EGLint height, - EGLint depth) -{ - Window root = DefaultRootWindow(winsys->dpy); - Pixmap pix; - - pix = XCreatePixmap(winsys->dpy, (Drawable) root, width, height, depth); - - return pix; -} - -static void -x11_destroy_pixmap(struct segl_winsys *winsys, Pixmap pix) -{ - if (pix) - XFreePixmap(winsys->dpy, pix); -} - -static double -x11_now(struct segl_winsys *winsys) -{ - struct timeval tv; - - gettimeofday(&tv, NULL); - - return (double) tv.tv_sec + tv.tv_usec / 1000000.0; -} - -struct segl_winsys * -segl_get_winsys(EGLNativeDisplayType dpy) -{ - struct segl_winsys *winsys; - - winsys = calloc(1, sizeof(*winsys)); - if (winsys) { - winsys->dpy = dpy; - - winsys->create_window = x11_create_window; - winsys->destroy_window = x11_destroy_window; - winsys->create_pixmap = x11_create_pixmap; - winsys->destroy_pixmap = x11_destroy_pixmap; - - winsys->now = x11_now; - } - - return winsys; -} -- cgit v1.2.3 From 9a62f0ce3bffd37bad101552b57347e0855d1df1 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 23 Jan 2010 12:57:51 +1000 Subject: r300: only enable half floats on r500s. Thank to MAD for point it out. --- src/mesa/drivers/dri/r300/r300_context.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c index 24c51d4fee..74947a95d2 100644 --- a/src/mesa/drivers/dri/r300/r300_context.c +++ b/src/mesa/drivers/dri/r300/r300_context.c @@ -97,7 +97,6 @@ static const struct dri_extension card_extensions[] = { /* *INDENT-OFF* */ {"GL_ARB_depth_texture", NULL}, {"GL_ARB_fragment_program", NULL}, - {"GL_ARB_half_float_vertex", NULL}, {"GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions}, {"GL_ARB_multitexture", NULL}, {"GL_ARB_point_parameters", GL_ARB_point_parameters_functions}, @@ -452,6 +451,8 @@ static void r300InitGLExtensions(GLcontext *ctx) if (!r300->radeon.radeonScreen->drmSupportsOcclusionQueries) { _mesa_disable_extension(ctx, "GL_ARB_occlusion_query"); } + if (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) + _mesa_enable_extension(ctx, "GL_ARB_half_float_vertex"); } static void r300InitIoctlFuncs(struct dd_function_table *functions) -- cgit v1.2.3 From 329c1b59106cf4ada27eaa4694600dc281d8c0de Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Fri, 22 Jan 2010 23:22:16 -0800 Subject: i915: Remove unnecessary headers. --- src/mesa/drivers/dri/i915/i830_context.c | 3 --- src/mesa/drivers/dri/i915/i915_context.c | 5 ----- src/mesa/drivers/dri/i915/i915_debug_fp.c | 3 --- src/mesa/drivers/dri/i915/i915_vtbl.c | 1 - src/mesa/drivers/dri/i915/intel_tris.c | 1 - 5 files changed, 13 deletions(-) diff --git a/src/mesa/drivers/dri/i915/i830_context.c b/src/mesa/drivers/dri/i915/i830_context.c index 840946f908..7be18cb65a 100644 --- a/src/mesa/drivers/dri/i915/i830_context.c +++ b/src/mesa/drivers/dri/i915/i830_context.c @@ -28,14 +28,11 @@ #include "i830_context.h" #include "main/imports.h" #include "texmem.h" -#include "intel_tex.h" #include "tnl/tnl.h" #include "tnl/t_vertex.h" #include "tnl/t_context.h" #include "tnl/t_pipeline.h" -#include "utils.h" #include "intel_span.h" -#include "intel_pixel.h" #include "intel_tris.h" /*************************************** diff --git a/src/mesa/drivers/dri/i915/i915_context.c b/src/mesa/drivers/dri/i915/i915_context.c index 7d4c7cfbab..4767016487 100644 --- a/src/mesa/drivers/dri/i915/i915_context.c +++ b/src/mesa/drivers/dri/i915/i915_context.c @@ -28,7 +28,6 @@ #include "i915_context.h" #include "main/imports.h" #include "main/macros.h" -#include "intel_tex.h" #include "intel_tris.h" #include "tnl/t_context.h" #include "tnl/t_pipeline.h" @@ -38,15 +37,11 @@ #include "swrast_setup/swrast_setup.h" #include "tnl/tnl.h" -#include "utils.h" #include "i915_reg.h" #include "i915_program.h" -#include "intel_regions.h" -#include "intel_batchbuffer.h" #include "intel_tris.h" #include "intel_span.h" -#include "intel_pixel.h" /*************************************** * Mesa's Driver Functions diff --git a/src/mesa/drivers/dri/i915/i915_debug_fp.c b/src/mesa/drivers/dri/i915/i915_debug_fp.c index 84347a01ef..bf500e54fa 100644 --- a/src/mesa/drivers/dri/i915/i915_debug_fp.c +++ b/src/mesa/drivers/dri/i915/i915_debug_fp.c @@ -30,9 +30,6 @@ #include "i915_reg.h" #include "i915_debug.h" #include "main/imports.h" -#include "shader/program.h" -#include "shader/prog_instruction.h" -#include "shader/prog_print.h" #define PRINTF( ... ) _mesa_printf( __VA_ARGS__ ) diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c b/src/mesa/drivers/dri/i915/i915_vtbl.c index ff97e5a944..668e02ef70 100644 --- a/src/mesa/drivers/dri/i915/i915_vtbl.c +++ b/src/mesa/drivers/dri/i915/i915_vtbl.c @@ -37,7 +37,6 @@ #include "tnl/t_vertex.h" #include "intel_batchbuffer.h" -#include "intel_tex.h" #include "intel_regions.h" #include "intel_tris.h" #include "intel_fbo.h" diff --git a/src/mesa/drivers/dri/i915/intel_tris.c b/src/mesa/drivers/dri/i915/intel_tris.c index bc527aae47..65db947aee 100644 --- a/src/mesa/drivers/dri/i915/intel_tris.c +++ b/src/mesa/drivers/dri/i915/intel_tris.c @@ -52,7 +52,6 @@ #include "intel_buffers.h" #include "intel_reg.h" #include "intel_span.h" -#include "intel_tex.h" #include "intel_chipset.h" #include "i830_context.h" #include "i830_reg.h" -- cgit v1.2.3 From 634ec5c2abf05a9a8c27d9199ded5d1ad91e538a Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Fri, 22 Jan 2010 23:53:39 -0800 Subject: i965: Remove unnecessary headers. --- src/mesa/drivers/dri/i965/brw_cc.c | 2 -- src/mesa/drivers/dri/i965/brw_clip_line.c | 1 - src/mesa/drivers/dri/i965/brw_clip_point.c | 1 - src/mesa/drivers/dri/i965/brw_clip_state.c | 1 - src/mesa/drivers/dri/i965/brw_clip_tri.c | 1 - src/mesa/drivers/dri/i965/brw_clip_unfilled.c | 1 - src/mesa/drivers/dri/i965/brw_clip_util.c | 1 - src/mesa/drivers/dri/i965/brw_context.c | 9 --------- src/mesa/drivers/dri/i965/brw_draw.c | 2 -- src/mesa/drivers/dri/i965/brw_draw_upload.c | 4 ---- src/mesa/drivers/dri/i965/brw_fallback.c | 1 - src/mesa/drivers/dri/i965/brw_gs_emit.c | 1 - src/mesa/drivers/dri/i965/brw_gs_state.c | 1 - src/mesa/drivers/dri/i965/brw_program.c | 1 - src/mesa/drivers/dri/i965/brw_sf_state.c | 1 - src/mesa/drivers/dri/i965/brw_vs_surface_state.c | 1 - src/mesa/drivers/dri/i965/brw_vtbl.c | 1 - src/mesa/drivers/dri/i965/brw_wm.c | 1 - 18 files changed, 31 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_cc.c b/src/mesa/drivers/dri/i965/brw_cc.c index bac1c3a49c..9a38631dfe 100644 --- a/src/mesa/drivers/dri/i965/brw_cc.c +++ b/src/mesa/drivers/dri/i965/brw_cc.c @@ -34,9 +34,7 @@ #include "brw_state.h" #include "brw_defines.h" #include "brw_util.h" -#include "intel_fbo.h" #include "main/macros.h" -#include "main/enums.h" static void prepare_cc_vp( struct brw_context *brw ) { diff --git a/src/mesa/drivers/dri/i965/brw_clip_line.c b/src/mesa/drivers/dri/i965/brw_clip_line.c index fa9648f50f..67861ac670 100644 --- a/src/mesa/drivers/dri/i965/brw_clip_line.c +++ b/src/mesa/drivers/dri/i965/brw_clip_line.c @@ -39,7 +39,6 @@ #include "brw_defines.h" #include "brw_context.h" #include "brw_eu.h" -#include "brw_util.h" #include "brw_clip.h" diff --git a/src/mesa/drivers/dri/i965/brw_clip_point.c b/src/mesa/drivers/dri/i965/brw_clip_point.c index 8458f61c5a..7f47634dca 100644 --- a/src/mesa/drivers/dri/i965/brw_clip_point.c +++ b/src/mesa/drivers/dri/i965/brw_clip_point.c @@ -39,7 +39,6 @@ #include "brw_defines.h" #include "brw_context.h" #include "brw_eu.h" -#include "brw_util.h" #include "brw_clip.h" diff --git a/src/mesa/drivers/dri/i965/brw_clip_state.c b/src/mesa/drivers/dri/i965/brw_clip_state.c index 234b3744bf..79ae5c7bef 100644 --- a/src/mesa/drivers/dri/i965/brw_clip_state.c +++ b/src/mesa/drivers/dri/i965/brw_clip_state.c @@ -32,7 +32,6 @@ #include "brw_context.h" #include "brw_state.h" #include "brw_defines.h" -#include "main/macros.h" struct brw_clip_unit_key { unsigned int total_grf; diff --git a/src/mesa/drivers/dri/i965/brw_clip_tri.c b/src/mesa/drivers/dri/i965/brw_clip_tri.c index cf79224be4..8d5ca41896 100644 --- a/src/mesa/drivers/dri/i965/brw_clip_tri.c +++ b/src/mesa/drivers/dri/i965/brw_clip_tri.c @@ -39,7 +39,6 @@ #include "brw_defines.h" #include "brw_context.h" #include "brw_eu.h" -#include "brw_util.h" #include "brw_clip.h" static void release_tmps( struct brw_clip_compile *c ) diff --git a/src/mesa/drivers/dri/i965/brw_clip_unfilled.c b/src/mesa/drivers/dri/i965/brw_clip_unfilled.c index ad1bfa435f..f36d22fdbf 100644 --- a/src/mesa/drivers/dri/i965/brw_clip_unfilled.c +++ b/src/mesa/drivers/dri/i965/brw_clip_unfilled.c @@ -39,7 +39,6 @@ #include "brw_defines.h" #include "brw_context.h" #include "brw_eu.h" -#include "brw_util.h" #include "brw_clip.h" diff --git a/src/mesa/drivers/dri/i965/brw_clip_util.c b/src/mesa/drivers/dri/i965/brw_clip_util.c index 5a73abdfee..b7f8c25b34 100644 --- a/src/mesa/drivers/dri/i965/brw_clip_util.c +++ b/src/mesa/drivers/dri/i965/brw_clip_util.c @@ -40,7 +40,6 @@ #include "brw_defines.h" #include "brw_context.h" #include "brw_eu.h" -#include "brw_util.h" #include "brw_clip.h" diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 48685c087b..6b5c3becc2 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -33,24 +33,15 @@ #include "main/imports.h" #include "main/api_noop.h" #include "main/macros.h" -#include "main/vtxfmt.h" #include "main/simple_list.h" #include "shader/shader_api.h" #include "brw_context.h" -#include "brw_defines.h" #include "brw_draw.h" #include "brw_state.h" -#include "brw_vs.h" -#include "intel_tex.h" -#include "intel_blit.h" -#include "intel_batchbuffer.h" -#include "intel_pixel.h" #include "intel_span.h" #include "tnl/t_pipeline.h" -#include "utils.h" - /*************************************** * Mesa's Driver Functions diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index 8bcb6083f7..e17680a525 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -39,10 +39,8 @@ #include "brw_defines.h" #include "brw_context.h" #include "brw_state.h" -#include "brw_fallback.h" #include "intel_batchbuffer.h" -#include "intel_buffer_objects.h" #define FILE_DEBUG_FLAG DEBUG_BATCH diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index c66f43abae..16b2529fad 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -29,19 +29,15 @@ #include "main/glheader.h" #include "main/bufferobj.h" #include "main/context.h" -#include "main/state.h" -#include "main/api_validate.h" #include "main/enums.h" #include "brw_draw.h" #include "brw_defines.h" #include "brw_context.h" #include "brw_state.h" -#include "brw_fallback.h" #include "intel_batchbuffer.h" #include "intel_buffer_objects.h" -#include "intel_tex.h" static GLuint double_types[5] = { 0, diff --git a/src/mesa/drivers/dri/i965/brw_fallback.c b/src/mesa/drivers/dri/i965/brw_fallback.c index 562a17844b..1914febf26 100644 --- a/src/mesa/drivers/dri/i965/brw_fallback.c +++ b/src/mesa/drivers/dri/i965/brw_fallback.c @@ -36,7 +36,6 @@ #include "swrast/swrast.h" #include "tnl/tnl.h" #include "brw_context.h" -#include "brw_fallback.h" #include "intel_chipset.h" #include "intel_fbo.h" #include "intel_regions.h" diff --git a/src/mesa/drivers/dri/i965/brw_gs_emit.c b/src/mesa/drivers/dri/i965/brw_gs_emit.c index 0fc5b02c61..e9b71ed0c3 100644 --- a/src/mesa/drivers/dri/i965/brw_gs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_gs_emit.c @@ -40,7 +40,6 @@ #include "brw_defines.h" #include "brw_context.h" #include "brw_eu.h" -#include "brw_util.h" #include "brw_gs.h" static void brw_gs_alloc_regs( struct brw_gs_compile *c, diff --git a/src/mesa/drivers/dri/i965/brw_gs_state.c b/src/mesa/drivers/dri/i965/brw_gs_state.c index ed9d2ffe60..d291f5b595 100644 --- a/src/mesa/drivers/dri/i965/brw_gs_state.c +++ b/src/mesa/drivers/dri/i965/brw_gs_state.c @@ -34,7 +34,6 @@ #include "brw_context.h" #include "brw_state.h" #include "brw_defines.h" -#include "main/macros.h" struct brw_gs_unit_key { unsigned int total_grf; diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c index bac69187c1..e3b6fccc49 100644 --- a/src/mesa/drivers/dri/i965/brw_program.c +++ b/src/mesa/drivers/dri/i965/brw_program.c @@ -37,7 +37,6 @@ #include "tnl/tnl.h" #include "brw_context.h" -#include "brw_util.h" #include "brw_wm.h" static void brwBindProgram( GLcontext *ctx, diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c b/src/mesa/drivers/dri/i965/brw_sf_state.c index bb69435ec0..b76ed98c4b 100644 --- a/src/mesa/drivers/dri/i965/brw_sf_state.c +++ b/src/mesa/drivers/dri/i965/brw_sf_state.c @@ -35,7 +35,6 @@ #include "brw_state.h" #include "brw_defines.h" #include "main/macros.h" -#include "intel_fbo.h" static void upload_sf_vp(struct brw_context *brw) { diff --git a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c index 3bc9840a97..22ff3410ae 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c @@ -35,7 +35,6 @@ #include "brw_context.h" #include "brw_state.h" -#include "brw_defines.h" /* Creates a new VS constant buffer reflecting the current VS program's * constants, if needed by the VS program. diff --git a/src/mesa/drivers/dri/i965/brw_vtbl.c b/src/mesa/drivers/dri/i965/brw_vtbl.c index 34aaea3736..daf1964553 100644 --- a/src/mesa/drivers/dri/i965/brw_vtbl.c +++ b/src/mesa/drivers/dri/i965/brw_vtbl.c @@ -44,7 +44,6 @@ #include "brw_state.h" #include "brw_draw.h" #include "brw_state.h" -#include "brw_fallback.h" #include "brw_vs.h" #include "brw_wm.h" diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c index 6895f64410..802236e8e3 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.c +++ b/src/mesa/drivers/dri/i965/brw_wm.c @@ -30,7 +30,6 @@ */ #include "brw_context.h" -#include "brw_util.h" #include "brw_wm.h" #include "brw_state.h" -- cgit v1.2.3 From ca54a5b92043ba9564aca5af47f8c57a53cc48bc Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 23 Jan 2010 00:19:29 -0800 Subject: mga: Remove unnecessary headers. --- src/mesa/drivers/dri/mga/mga_xmesa.c | 2 -- src/mesa/drivers/dri/mga/mgadd.c | 5 ----- src/mesa/drivers/dri/mga/mgaioctl.c | 3 --- src/mesa/drivers/dri/mga/mgarender.c | 1 - src/mesa/drivers/dri/mga/mgatex.c | 3 --- src/mesa/drivers/dri/mga/mgatris.c | 1 - src/mesa/drivers/dri/mga/mgavb.c | 1 - 7 files changed, 16 deletions(-) diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.c b/src/mesa/drivers/dri/mga/mga_xmesa.c index 2c7f50c498..d0902e565b 100644 --- a/src/mesa/drivers/dri/mga/mga_xmesa.c +++ b/src/mesa/drivers/dri/mga/mga_xmesa.c @@ -35,7 +35,6 @@ #include "mga_drm.h" #include "mga_xmesa.h" #include "main/context.h" -#include "main/matrix.h" #include "main/simple_list.h" #include "main/imports.h" #include "main/framebuffer.h" @@ -64,7 +63,6 @@ #include "utils.h" #include "vblank.h" -#include "main/extensions.h" #include "drirenderbuffer.h" #include "GL/internal/dri_interface.h" diff --git a/src/mesa/drivers/dri/mga/mgadd.c b/src/mesa/drivers/dri/mga/mgadd.c index 3b1ea22b60..2f23c0e514 100644 --- a/src/mesa/drivers/dri/mga/mgadd.c +++ b/src/mesa/drivers/dri/mga/mgadd.c @@ -32,11 +32,6 @@ #include "mgacontext.h" #include "mgadd.h" -#include "mgastate.h" -#include "mgaspan.h" -#include "mgatex.h" -#include "mgatris.h" -#include "mgavb.h" #include "mga_xmesa.h" #include "utils.h" diff --git a/src/mesa/drivers/dri/mga/mgaioctl.c b/src/mesa/drivers/dri/mga/mgaioctl.c index 4438bad920..3eaa7ecf6b 100644 --- a/src/mesa/drivers/dri/mga/mgaioctl.c +++ b/src/mesa/drivers/dri/mga/mgaioctl.c @@ -42,10 +42,7 @@ #include "mgacontext.h" #include "mgadd.h" #include "mgastate.h" -#include "mgatex.h" -#include "mgavb.h" #include "mgaioctl.h" -#include "mgatris.h" #include "vblank.h" diff --git a/src/mesa/drivers/dri/mga/mgarender.c b/src/mesa/drivers/dri/mga/mgarender.c index 517c3b8f82..8b8fc485d3 100644 --- a/src/mesa/drivers/dri/mga/mgarender.c +++ b/src/mesa/drivers/dri/mga/mgarender.c @@ -48,7 +48,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "mgacontext.h" #include "mgatris.h" -#include "mgastate.h" #include "mgaioctl.h" #include "mgavb.h" diff --git a/src/mesa/drivers/dri/mga/mgatex.c b/src/mesa/drivers/dri/mga/mgatex.c index 9163371b33..45f2ccbd9f 100644 --- a/src/mesa/drivers/dri/mga/mgatex.c +++ b/src/mesa/drivers/dri/mga/mgatex.c @@ -40,11 +40,8 @@ #include "mgacontext.h" #include "mgatex.h" #include "mgaregs.h" -#include "mgatris.h" #include "mgaioctl.h" -#include "swrast/swrast.h" - #include "xmlpool.h" /** diff --git a/src/mesa/drivers/dri/mga/mgatris.c b/src/mesa/drivers/dri/mga/mgatris.c index c1bcd4b853..4c58c3bdb0 100644 --- a/src/mesa/drivers/dri/mga/mgatris.c +++ b/src/mesa/drivers/dri/mga/mgatris.c @@ -38,7 +38,6 @@ #include "mgaioctl.h" #include "mgatris.h" #include "mgavb.h" -#include "mgastate.h" static void mgaRenderPrimitive( GLcontext *ctx, GLenum prim ); diff --git a/src/mesa/drivers/dri/mga/mgavb.c b/src/mesa/drivers/dri/mga/mgavb.c index 1c635b23a6..def5109863 100644 --- a/src/mesa/drivers/dri/mga/mgavb.c +++ b/src/mesa/drivers/dri/mga/mgavb.c @@ -39,7 +39,6 @@ #include "main/colormac.h" #include "tnl/t_context.h" -#include "swrast_setup/swrast_setup.h" #include "swrast/swrast.h" -- cgit v1.2.3 From 09a142e5db8dc72407ffb16a1a4e02d6540f6095 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 23 Jan 2010 00:38:14 -0800 Subject: savage: Remove unnecessary headers. --- src/mesa/drivers/dri/savage/savagedd.c | 4 ---- src/mesa/drivers/dri/savage/savageioctl.c | 2 -- src/mesa/drivers/dri/savage/savagerender.c | 1 - src/mesa/drivers/dri/savage/savagespan.c | 1 - src/mesa/drivers/dri/savage/savagetex.c | 2 -- src/mesa/drivers/dri/savage/savagetris.c | 1 - 6 files changed, 11 deletions(-) diff --git a/src/mesa/drivers/dri/savage/savagedd.c b/src/mesa/drivers/dri/savage/savagedd.c index 32ca86de8a..bbf49aec27 100644 --- a/src/mesa/drivers/dri/savage/savagedd.c +++ b/src/mesa/drivers/dri/savage/savagedd.c @@ -29,15 +29,11 @@ #include #include "main/mm.h" -#include "swrast/swrast.h" #include "savagedd.h" #include "savagestate.h" -#include "savagespan.h" #include "savagetex.h" -#include "savagetris.h" #include "savagecontext.h" -#include "main/extensions.h" #include "utils.h" diff --git a/src/mesa/drivers/dri/savage/savageioctl.c b/src/mesa/drivers/dri/savage/savageioctl.c index 77ab8d16e0..624d6af5e8 100644 --- a/src/mesa/drivers/dri/savage/savageioctl.c +++ b/src/mesa/drivers/dri/savage/savageioctl.c @@ -37,12 +37,10 @@ #include "savagecontext.h" #include "savageioctl.h" -#include "savage_bci.h" #include "savagestate.h" #include "savagespan.h" #include "drm.h" -#include #include #define DEPTH_SCALE_16 ((1<<16)-1) diff --git a/src/mesa/drivers/dri/savage/savagerender.c b/src/mesa/drivers/dri/savage/savagerender.c index 32c74f9467..d096dfe92f 100644 --- a/src/mesa/drivers/dri/savage/savagerender.c +++ b/src/mesa/drivers/dri/savage/savagerender.c @@ -36,7 +36,6 @@ #include "tnl/t_context.h" #include "savagecontext.h" -#include "savagetris.h" #include "savagestate.h" #include "savageioctl.h" diff --git a/src/mesa/drivers/dri/savage/savagespan.c b/src/mesa/drivers/dri/savage/savagespan.c index 3bb6fbcc63..c6818d31d6 100644 --- a/src/mesa/drivers/dri/savage/savagespan.c +++ b/src/mesa/drivers/dri/savage/savagespan.c @@ -26,7 +26,6 @@ #include "savagedd.h" #include "savagespan.h" #include "savageioctl.h" -#include "savage_bci.h" #include "savage_3d_reg.h" #include "swrast/swrast.h" diff --git a/src/mesa/drivers/dri/savage/savagetex.c b/src/mesa/drivers/dri/savage/savagetex.c index 6c97bb6c70..e09e52bf00 100644 --- a/src/mesa/drivers/dri/savage/savagetex.c +++ b/src/mesa/drivers/dri/savage/savagetex.c @@ -33,8 +33,6 @@ #include "main/simple_list.h" #include "main/enums.h" -#include "swrast/swrast.h" - #include "savagecontext.h" #include "savagetex.h" #include "savagetris.h" diff --git a/src/mesa/drivers/dri/savage/savagetris.c b/src/mesa/drivers/dri/savage/savagetris.c index 0714101dc0..8646200f7f 100644 --- a/src/mesa/drivers/dri/savage/savagetris.c +++ b/src/mesa/drivers/dri/savage/savagetris.c @@ -52,7 +52,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "savagestate.h" #include "savagetex.h" #include "savageioctl.h" -#include "savage_bci.h" static void savageRasterPrimitive( GLcontext *ctx, GLuint prim ); static void savageRenderPrimitive( GLcontext *ctx, GLenum prim ); -- cgit v1.2.3 From 76bc66b664c7e135aa9c06cedd94ee1961d68c70 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 23 Jan 2010 19:35:42 +1000 Subject: r300g: fix up buffer emission ordering. This fixes the code space checking VBOs, then resetting the space list and space checking other buffers. it fixes demos/ipers Signed-off-by: Dave Airlie --- src/gallium/drivers/r300/r300_emit.c | 50 +++++++++++++++++++--------------- src/gallium/drivers/r300/r300_emit.h | 2 ++ src/gallium/drivers/r300/r300_render.c | 4 +++ 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 921170aef1..cc40abf168 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -1014,32 +1014,12 @@ static void r300_flush_pvs(struct r300_context* r300) END_CS; } -/* Emit all dirty state. */ -void r300_emit_dirty_state(struct r300_context* r300) +void r300_emit_buffer_validate(struct r300_context *r300) { - struct r300_screen* r300screen = r300_screen(r300->context.screen); struct r300_texture* tex; - struct r300_atom* atom; - unsigned i, dwords = 1024; - int dirty_tex = 0; + unsigned i; boolean invalid = FALSE; - /* Check the required number of dwords against the space remaining in the - * current CS object. If we need more, then flush. */ - - foreach(atom, &r300->atom_list) { - if (atom->dirty || atom->always_dirty) { - dwords += atom->size; - } - } - - /* Make sure we have at least 2*1024 spare dwords. */ - /* XXX It would be nice to know the number of dwords we really need to - * XXX emit. */ - if (!r300->winsys->check_cs(r300->winsys, dwords)) { - r300->context.flush(&r300->context, 0, NULL); - } - /* Clean out BOs. */ r300->winsys->reset_bos(r300->winsys); @@ -1103,6 +1083,32 @@ validate: invalid = TRUE; goto validate; } +} + +/* Emit all dirty state. */ +void r300_emit_dirty_state(struct r300_context* r300) +{ + struct r300_screen* r300screen = r300_screen(r300->context.screen); + struct r300_atom* atom; + unsigned i, dwords = 1024; + int dirty_tex = 0; + + /* Check the required number of dwords against the space remaining in the + * current CS object. If we need more, then flush. */ + + foreach(atom, &r300->atom_list) { + if (atom->dirty || atom->always_dirty) { + dwords += atom->size; + } + } + + /* Make sure we have at least 2*1024 spare dwords. */ + /* XXX It would be nice to know the number of dwords we really need to + * XXX emit. */ + if (!r300->winsys->check_cs(r300->winsys, dwords)) { + r300->context.flush(&r300->context, 0, NULL); + r300_emit_buffer_validate(r300); + } if (r300->dirty_state & R300_NEW_QUERY) { r300_emit_query_start(r300); diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index 05a6bfeae8..2f3d013f5e 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -95,4 +95,6 @@ void r300_flush_textures(struct r300_context* r300); /* Emit all dirty state. */ void r300_emit_dirty_state(struct r300_context* r300); +void r300_emit_buffer_validate(struct r300_context *r300); + #endif /* R300_EMIT_H */ diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 90de062bcd..68abfbe208 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -311,6 +311,8 @@ void r300_draw_range_elements(struct pipe_context* pipe, indexSize = 2; } + r300_emit_buffer_validate(r300->winsys); + if (!r300->winsys->add_buffer(r300->winsys, indexBuffer, RADEON_GEM_DOMAIN_GTT, 0)) { goto cleanup; @@ -361,6 +363,8 @@ void r300_draw_arrays(struct pipe_context* pipe, unsigned mode, r300_update_derived_state(r300); + r300_emit_buffer_validate(r300); + if (!r300_setup_vertex_buffers(r300)) { return; } -- cgit v1.2.3 From 283d9565bf18b828e1bc6ed8ef2692132b4e359e Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 23 Jan 2010 01:40:44 -0800 Subject: sis: Remove unnecessary headers. --- src/mesa/drivers/dri/sis/sis6326_state.c | 2 -- src/mesa/drivers/dri/sis/sis_context.c | 3 --- src/mesa/drivers/dri/sis/sis_dd.c | 2 -- src/mesa/drivers/dri/sis/sis_fog.c | 1 - src/mesa/drivers/dri/sis/sis_screen.c | 1 - src/mesa/drivers/dri/sis/sis_state.c | 4 ---- src/mesa/drivers/dri/sis/sis_tex.c | 1 - src/mesa/drivers/dri/sis/sis_texstate.c | 1 - src/mesa/drivers/dri/sis/sis_tris.c | 1 - 9 files changed, 16 deletions(-) diff --git a/src/mesa/drivers/dri/sis/sis6326_state.c b/src/mesa/drivers/dri/sis/sis6326_state.c index 65d4c06466..52008c7ea3 100644 --- a/src/mesa/drivers/dri/sis/sis6326_state.c +++ b/src/mesa/drivers/dri/sis/sis6326_state.c @@ -34,14 +34,12 @@ #include "sis_reg.h" #include "main/context.h" -#include "main/enums.h" #include "main/colormac.h" #include "swrast/swrast.h" #include "vbo/vbo.h" #include "tnl/tnl.h" #include "swrast_setup/swrast_setup.h" -#include "tnl/t_pipeline.h" /* ============================================================= * Alpha blending diff --git a/src/mesa/drivers/dri/sis/sis_context.c b/src/mesa/drivers/dri/sis/sis_context.c index 346e8c5568..b5586b7417 100644 --- a/src/mesa/drivers/dri/sis/sis_context.c +++ b/src/mesa/drivers/dri/sis/sis_context.c @@ -43,8 +43,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "sis_alloc.h" #include "main/imports.h" -#include "main/matrix.h" -#include "main/extensions.h" #include "utils.h" #include "main/framebuffer.h" @@ -55,7 +53,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "vbo/vbo.h" #include "tnl/tnl.h" -#include "tnl/t_pipeline.h" #define need_GL_EXT_fog_coord #define need_GL_EXT_secondary_color diff --git a/src/mesa/drivers/dri/sis/sis_dd.c b/src/mesa/drivers/dri/sis/sis_dd.c index 217d77557f..fe4ade8592 100644 --- a/src/mesa/drivers/dri/sis/sis_dd.c +++ b/src/mesa/drivers/dri/sis/sis_dd.c @@ -40,9 +40,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "sis_state.h" #include "sis_tris.h" -#include "swrast/swrast.h" #include "main/formats.h" -#include "main/framebuffer.h" #include "main/renderbuffer.h" #include "utils.h" diff --git a/src/mesa/drivers/dri/sis/sis_fog.c b/src/mesa/drivers/dri/sis/sis_fog.c index 517d5722e6..6c774e010e 100644 --- a/src/mesa/drivers/dri/sis/sis_fog.c +++ b/src/mesa/drivers/dri/sis/sis_fog.c @@ -33,7 +33,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "sis_context.h" #include "sis_state.h" -#include "swrast/swrast.h" #include "main/macros.h" diff --git a/src/mesa/drivers/dri/sis/sis_screen.c b/src/mesa/drivers/dri/sis/sis_screen.c index fec9158236..f0e4e81a2b 100644 --- a/src/mesa/drivers/dri/sis/sis_screen.c +++ b/src/mesa/drivers/dri/sis/sis_screen.c @@ -39,7 +39,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "sis_context.h" #include "sis_dri.h" #include "sis_lock.h" -#include "sis_span.h" #include "xmlpool.h" diff --git a/src/mesa/drivers/dri/sis/sis_state.c b/src/mesa/drivers/dri/sis/sis_state.c index 98e8d02fab..a22195ccce 100644 --- a/src/mesa/drivers/dri/sis/sis_state.c +++ b/src/mesa/drivers/dri/sis/sis_state.c @@ -35,17 +35,13 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "sis_state.h" #include "sis_tris.h" #include "sis_lock.h" -#include "sis_tex.h" #include "main/context.h" -#include "main/enums.h" -#include "main/colormac.h" #include "swrast/swrast.h" #include "vbo/vbo.h" #include "tnl/tnl.h" #include "swrast_setup/swrast_setup.h" -#include "tnl/t_pipeline.h" /* ============================================================= * Alpha blending diff --git a/src/mesa/drivers/dri/sis/sis_tex.c b/src/mesa/drivers/dri/sis/sis_tex.c index 951c470dad..31709c3af6 100644 --- a/src/mesa/drivers/dri/sis/sis_tex.c +++ b/src/mesa/drivers/dri/sis/sis_tex.c @@ -31,7 +31,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "swrast/swrast.h" #include "main/imports.h" #include "main/texstore.h" -#include "main/teximage.h" #include "main/texobj.h" #include "sis_context.h" diff --git a/src/mesa/drivers/dri/sis/sis_texstate.c b/src/mesa/drivers/dri/sis/sis_texstate.c index a507173b21..e96a2e880c 100644 --- a/src/mesa/drivers/dri/sis/sis_texstate.c +++ b/src/mesa/drivers/dri/sis/sis_texstate.c @@ -38,7 +38,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/macros.h" #include "sis_context.h" -#include "sis_state.h" #include "sis_tex.h" #include "sis_tris.h" #include "sis_alloc.h" diff --git a/src/mesa/drivers/dri/sis/sis_tris.c b/src/mesa/drivers/dri/sis/sis_tris.c index 4fa2e41e44..aaa23db308 100644 --- a/src/mesa/drivers/dri/sis/sis_tris.c +++ b/src/mesa/drivers/dri/sis/sis_tris.c @@ -47,7 +47,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "sis_state.h" #include "sis_lock.h" #include "sis_span.h" -#include "sis_alloc.h" #include "sis_tex.h" /* 6326 and 300-series shared */ -- cgit v1.2.3 From 4bad0aef40b87cf1a2ef8ecb5cd560d8a162d0ec Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 23 Jan 2010 01:54:53 -0800 Subject: tdfx: Remove unnecessary headers. --- src/mesa/drivers/dri/tdfx/tdfx_dd.c | 7 ------- src/mesa/drivers/dri/tdfx/tdfx_lock.c | 1 - src/mesa/drivers/dri/tdfx/tdfx_pixels.c | 1 - src/mesa/drivers/dri/tdfx/tdfx_screen.c | 2 -- src/mesa/drivers/dri/tdfx/tdfx_state.c | 4 ---- src/mesa/drivers/dri/tdfx/tdfx_texman.c | 1 - src/mesa/drivers/dri/tdfx/tdfx_texstate.c | 1 - src/mesa/drivers/dri/tdfx/tdfx_vb.c | 5 ----- 8 files changed, 22 deletions(-) diff --git a/src/mesa/drivers/dri/tdfx/tdfx_dd.c b/src/mesa/drivers/dri/tdfx/tdfx_dd.c index ed8a331549..2cbbeb8114 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_dd.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_dd.c @@ -35,17 +35,10 @@ #include "tdfx_context.h" #include "tdfx_dd.h" #include "tdfx_lock.h" -#include "tdfx_vb.h" #include "tdfx_pixels.h" #include "utils.h" #include "main/context.h" -#include "main/enums.h" -#include "main/framebuffer.h" -#include "swrast/swrast.h" -#if defined(USE_X86_ASM) -#include "x86/common_x86_asm.h" -#endif #define DRIVER_DATE "20061113" diff --git a/src/mesa/drivers/dri/tdfx/tdfx_lock.c b/src/mesa/drivers/dri/tdfx/tdfx_lock.c index 17cdc51ee1..c00f53700e 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_lock.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_lock.c @@ -38,7 +38,6 @@ #include "tdfx_state.h" #include "tdfx_render.h" #include "tdfx_texman.h" -#include "tdfx_tris.h" #include "drirenderbuffer.h" diff --git a/src/mesa/drivers/dri/tdfx/tdfx_pixels.c b/src/mesa/drivers/dri/tdfx/tdfx_pixels.c index 18729d5ae0..c213e67970 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_pixels.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_pixels.c @@ -38,7 +38,6 @@ #include "tdfx_context.h" #include "tdfx_dd.h" #include "tdfx_lock.h" -#include "tdfx_vb.h" #include "tdfx_pixels.h" #include "tdfx_render.h" diff --git a/src/mesa/drivers/dri/tdfx/tdfx_screen.c b/src/mesa/drivers/dri/tdfx/tdfx_screen.c index 2eb0024d40..9e5f2b88ae 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_screen.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_screen.c @@ -36,9 +36,7 @@ #include "tdfx_dri.h" #include "tdfx_context.h" #include "tdfx_lock.h" -#include "tdfx_vb.h" #include "tdfx_span.h" -#include "tdfx_tris.h" #include "main/framebuffer.h" #include "main/renderbuffer.h" diff --git a/src/mesa/drivers/dri/tdfx/tdfx_state.c b/src/mesa/drivers/dri/tdfx/tdfx_state.c index cf2712720f..16b0bfc7c7 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_state.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_state.c @@ -40,8 +40,6 @@ #include "main/mtypes.h" #include "main/colormac.h" -#include "main/texstore.h" -#include "main/teximage.h" #include "swrast/swrast.h" #include "vbo/vbo.h" @@ -51,11 +49,9 @@ #include "tdfx_context.h" #include "tdfx_state.h" -#include "tdfx_vb.h" #include "tdfx_tex.h" #include "tdfx_texman.h" #include "tdfx_texstate.h" -#include "tdfx_tris.h" #include "tdfx_render.h" diff --git a/src/mesa/drivers/dri/tdfx/tdfx_texman.c b/src/mesa/drivers/dri/tdfx/tdfx_texman.c index 35636ee5ef..726cc58a10 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_texman.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_texman.c @@ -35,7 +35,6 @@ */ #include "tdfx_context.h" -#include "tdfx_tex.h" #include "tdfx_texman.h" #include "main/texobj.h" #include "main/hash.h" diff --git a/src/mesa/drivers/dri/tdfx/tdfx_texstate.c b/src/mesa/drivers/dri/tdfx/tdfx_texstate.c index 3f737878ed..6658b4d0c3 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_texstate.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_texstate.c @@ -38,7 +38,6 @@ */ #include "tdfx_state.h" -#include "tdfx_tex.h" #include "tdfx_texman.h" #include "tdfx_texstate.h" diff --git a/src/mesa/drivers/dri/tdfx/tdfx_vb.c b/src/mesa/drivers/dri/tdfx/tdfx_vb.c index 4928802232..d6fcf98661 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_vb.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_vb.c @@ -29,13 +29,8 @@ #include "main/macros.h" #include "main/colormac.h" -#include "math/m_translate.h" -#include "swrast_setup/swrast_setup.h" - #include "tdfx_context.h" #include "tdfx_vb.h" -#include "tdfx_tris.h" -#include "tdfx_state.h" #include "tdfx_render.h" static void copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc ) -- cgit v1.2.3 From 3b002c9f75dd76e41552306516545080719fc065 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 23 Jan 2010 20:07:08 +1000 Subject: r300: fix wrong call in last commit --- src/gallium/drivers/r300/r300_render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 68abfbe208..cb2d8d4537 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -311,7 +311,7 @@ void r300_draw_range_elements(struct pipe_context* pipe, indexSize = 2; } - r300_emit_buffer_validate(r300->winsys); + r300_emit_buffer_validate(r300); if (!r300->winsys->add_buffer(r300->winsys, indexBuffer, RADEON_GEM_DOMAIN_GTT, 0)) { -- cgit v1.2.3 From 146a77af3f68d3a935fad5b143123280049e6c60 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 23 Jan 2010 02:14:56 -0800 Subject: radeon: Remove unused variable. --- src/mesa/drivers/dri/radeon/radeon_cs_legacy.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/drivers/dri/radeon/radeon_cs_legacy.c b/src/mesa/drivers/dri/radeon/radeon_cs_legacy.c index bf46eb8aab..cc951a12cb 100644 --- a/src/mesa/drivers/dri/radeon/radeon_cs_legacy.c +++ b/src/mesa/drivers/dri/radeon/radeon_cs_legacy.c @@ -180,7 +180,6 @@ static int cs_begin(struct radeon_cs_int *cs, if (cs->cdw + ndw > cs->ndw) { uint32_t tmp, *ptr; - int num = (ndw > 0x3FF) ? ndw : 0x3FF; tmp = (cs->cdw + ndw + 0x3ff) & (~0x3ff); ptr = (uint32_t*)realloc(cs->packets, 4 * tmp); -- cgit v1.2.3 From 60cd2449f8f2b698f0adacd4a401db13c5fa46f9 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 23 Jan 2010 20:08:02 +0800 Subject: st/es: Pass -linker and -ldflags to mklib. --- src/gallium/state_trackers/es/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/es/Makefile b/src/gallium/state_trackers/es/Makefile index 095ffbb938..b036551271 100644 --- a/src/gallium/state_trackers/es/Makefile +++ b/src/gallium/state_trackers/es/Makefile @@ -49,7 +49,7 @@ default: $(TOP)/$(LIB_DIR)/$(GLES_1_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLES_2_LIB_NAM # Make the shared libs $(TOP)/$(LIB_DIR)/$(GLES_1_LIB_NAME): $(ES1_OBJECTS) $(ES1_LIBS) $(GALLIUM_AUXILIARIES) - $(MKLIB) -o $(GLES_1_LIB) \ + $(MKLIB) -o $(GLES_1_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ -major $(GLES_1_VERSION_MAJOR) \ -minor $(GLES_1_VERSION_MINOR) \ -patch $(GLES_1_VERSION_PATCH) \ @@ -59,7 +59,7 @@ $(TOP)/$(LIB_DIR)/$(GLES_1_LIB_NAME): $(ES1_OBJECTS) $(ES1_LIBS) $(GALLIUM_AUXIL $(GALLIUM_AUXILIARIES) $(SYS_LIBS) $(TOP)/$(LIB_DIR)/$(GLES_2_LIB_NAME): $(ES2_OBJECTS) $(ES1_LIBS) $(GALLIUM_AUXILIARIES) - $(MKLIB) -o $(GLES_2_LIB) \ + $(MKLIB) -o $(GLES_2_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ -major $(GLES_2_VERSION_MAJOR) \ -minor $(GLES_2_VERSION_MINOR) \ -patch $(GLES_2_VERSION_PATCH) \ -- cgit v1.2.3 From 6c4431c092b06d31eee5ac7ed656ab6d6423c3ef Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 23 Jan 2010 20:09:20 +0800 Subject: st/vega: Clean up Makefile. --- src/gallium/state_trackers/vega/Makefile | 80 +++++++++++--------------------- 1 file changed, 26 insertions(+), 54 deletions(-) diff --git a/src/gallium/state_trackers/vega/Makefile b/src/gallium/state_trackers/vega/Makefile index fc97bf51f8..037d8dc911 100644 --- a/src/gallium/state_trackers/vega/Makefile +++ b/src/gallium/state_trackers/vega/Makefile @@ -1,8 +1,14 @@ -# src/mesa/Makefile +# src/gallium/state_trackers/vega/Makefile TOP = ../../../.. include $(TOP)/configs/current -GALLIUM = $(TOP) + +VG_LIB = OpenVG +VG_LIB_NAME = lib$(VG_LIB).so + +VG_MAJOR = 1 +VG_MINOR = 0 +VG_TINY = 0 ### Lists of source files, included by Makefiles @@ -34,88 +40,54 @@ VG_SOURCES = \ shader.c \ shaders_cache.c +VG_OBJECTS = $(VG_SOURCES:.c=.o) -### All the core C sources - -ALL_SOURCES = \ - $(VG_SOURCES) - - -### Object files -VG_OBJECTS = \ - $(VG_SOURCES:.c=.o) +VG_LIBS = $(GALLIUM_AUXILIARIES) -lm ### Include directories INCLUDE_DIRS = \ -I$(TOP)/include \ - -I$(GALLIUM)/include \ - -I$(GALLIUM)/src/gallium/include \ - -I$(GALLIUM)/src/gallium/auxiliary + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/auxiliary -VG_LIB = OpenVG -VG_LIB_NAME = lib$(VG_LIB).so - -VG_MAJOR = 1 -VG_MINOR = 0 -VG_TINY = 0 - -GALLIUM_LIBS = \ - $(GALLIUM)/src/gallium/auxiliary/libgallium.a - -.SUFFIXES : .cpp .c.o: - $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ + $(CC) -c $(INCLUDE_DIRS) $(DEFINES) $(CFLAGS) $< -o $@ -.cpp.o: - $(CXX) -c $(INCLUDE_DIRS) $(CXXFLAGS) $< -o $@ - -.S.o: - $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ - - -default: depend subdirs $(TOP)/$(LIB_DIR)/$(VG_LIB_NAME) +default: depend $(TOP)/$(LIB_DIR)/$(VG_LIB_NAME) # Make the OpenVG library -$(TOP)/$(LIB_DIR)/$(VG_LIB_NAME): $(VG_OBJECTS) $(GALLIUM_LIBS) - $(TOP)/bin/mklib -o $(VG_LIB) \ +$(TOP)/$(LIB_DIR)/$(VG_LIB_NAME): $(VG_OBJECTS) $(VG_LIBS) + $(MKLIB) -o $(VG_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ -major $(VG_MAJOR) \ -minor $(VG_MINOR) \ -patch $(VG_TINY) \ -install $(TOP)/$(LIB_DIR) \ - $(VG_OBJECTS) $(GALLIUM_LIBS) \ - -Wl,--whole-archive $(LIBS) -Wl,--no-whole-archive $(SYS_LIBS) + $(VG_OBJECTS) $(VG_LIBS) ###################################################################### # Generic stuff -depend: $(ALL_SOURCES) +depend: $(VG_SOURCES) @ echo "running $(MKDEP)" @ rm -f depend # workaround oops on gutsy?!? @ touch depend - @ $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(ALL_SOURCES) \ + @ $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(VG_SOURCES) \ > /dev/null 2>/dev/null - -subdirs: - install: default - $(INSTALL) -d $(INSTALL_DIR)/include/VG - $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR) - $(INSTALL) -m 644 $(TOP)/include/VG/*.h $(INSTALL_DIR)/include/VG - @if [ -e $(TOP)/$(LIB_DIR)/$(VG_LIB_NAME) ]; then \ - $(INSTALL) $(TOP)/$(LIB_DIR)/libOpenVG* $(INSTALL_DIR)/$(LIB_DIR); \ - fi + $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/VG + $(INSTALL) -m 644 $(TOP)/include/VG/*.h $(DESTDIR)$(INSTALL_DIR)/include/VG + $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/libOpenVG* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) # Emacs tags tags: etags `find . -name \*.[ch]` $(TOP)/include/VG/*.h clean: - -rm -f *.o - -rm -f */*.o - -rm -f */*/*.o - -rm -f depend depend.bak + rm -f $(VG_OBJECTS) + rm -f depend depend.bak -include depend +sinclude depend -- cgit v1.2.3 From 28c3e57c8354f988f49bac69a6866418e6009a5d Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 23 Jan 2010 20:18:43 +0800 Subject: egl: Install drivers to ${libdir}/egl. Install EGL drivers to EGL_DRIVER_INSTALL_DIR, which is default to ${libdir}/egl. --- configs/autoconf.in | 3 +++ configs/default | 3 +++ configure.ac | 7 +++++++ src/egl/drivers/Makefile.template | 4 ++-- src/egl/main/Makefile | 2 +- src/gallium/winsys/drm/Makefile.egl | 15 ++++++--------- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/configs/autoconf.in b/configs/autoconf.in index d9fa2dafe9..b0024ec689 100644 --- a/configs/autoconf.in +++ b/configs/autoconf.in @@ -130,6 +130,9 @@ DRI_DRIVER_INSTALL_DIR = @DRI_DRIVER_INSTALL_DIR@ # Where libGL will look for DRI hardware drivers DRI_DRIVER_SEARCH_DIR = @DRI_DRIVER_SEARCH_DIR@ +# EGL driver install directory +EGL_DRIVER_INSTALL_DIR = @EGL_DRIVER_INSTALL_DIR@ + # Xorg driver install directory (for xorg state-tracker) XORG_DRIVER_INSTALL_DIR = @XORG_DRIVER_INSTALL_DIR@ diff --git a/configs/default b/configs/default index 3aa136b9c5..d79039561e 100644 --- a/configs/default +++ b/configs/default @@ -130,6 +130,9 @@ DRI_DRIVER_INSTALL_DIR = $(INSTALL_LIB_DIR)/dri # Where libGL will look for DRI hardware drivers DRI_DRIVER_SEARCH_DIR = $(DRI_DRIVER_INSTALL_DIR) +# EGL driver install directory +EGL_DRIVER_INSTALL_DIR = $(INSTALL_LIB_DIR)/egl + # Xorg driver install directory (for xorg state-tracker) XORG_DRIVER_INSTALL_DIR = $(INSTALL_LIB_DIR)/xorg/modules/drivers diff --git a/configure.ac b/configure.ac index 370bd1b9b7..6f8b76d7ca 100644 --- a/configure.ac +++ b/configure.ac @@ -1231,6 +1231,13 @@ yes) esac AC_SUBST([EGL_DISPLAYS]) +AC_ARG_WITH([egl-driver-dir], + [AS_HELP_STRING([--with-egl-driver-dir=DIR], + [directory for EGL drivers [[default=${libdir}/egl]]])], + [EGL_DRIVER_INSTALL_DIR="$withval"], + [EGL_DRIVER_INSTALL_DIR='${libdir}/egl']) +AC_SUBST([EGL_DRIVER_INSTALL_DIR]) + AC_ARG_WITH([xorg-driver-dir], [AS_HELP_STRING([--with-xorg-driver-dir=DIR], [Default xorg driver directory[[default=${libdir}/xorg/modules/drivers]]])], diff --git a/src/egl/drivers/Makefile.template b/src/egl/drivers/Makefile.template index 02a65b094a..e9a614ce62 100644 --- a/src/egl/drivers/Makefile.template +++ b/src/egl/drivers/Makefile.template @@ -32,8 +32,8 @@ $(EGL_DRIVER): $(EGL_OBJECTS) Makefile $(TOP)/src/egl/drivers/Makefile.template install: $(EGL_DRIVER_PATH) - $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) - $(MINSTALL) $(EGL_DRIVER_PATH) $(DESTDIR)$(INSTALL_LIB_DIR) + $(INSTALL) -d $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR) + $(MINSTALL) $(EGL_DRIVER_PATH) $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR) clean: rm -f $(EGL_DRIVER) diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index 66f8f01b8e..20614d8753 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -53,7 +53,7 @@ EGL_DEFAULT_DISPLAY = $(word 1, $(EGL_DISPLAYS)) LOCAL_CFLAGS += \ -D_EGL_DEFAULT_DISPLAY=\"$(EGL_DEFAULT_DISPLAY)\" \ - -D_EGL_DRIVER_SEARCH_DIR=\"$(DRI_DRIVER_SEARCH_DIR)\" + -D_EGL_DRIVER_SEARCH_DIR=\"$(EGL_DRIVER_INSTALL_DIR)\" .c.o: $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $(LOCAL_CFLAGS) $< -o $@ diff --git a/src/gallium/winsys/drm/Makefile.egl b/src/gallium/winsys/drm/Makefile.egl index 1b10f1115c..d79ceee5b7 100644 --- a/src/gallium/winsys/drm/Makefile.egl +++ b/src/gallium/winsys/drm/Makefile.egl @@ -29,14 +29,12 @@ kms_LIBS = $(common_LIBS) EGL_DISPLAY_DRIVERS = $(foreach dpy, $(EGL_DISPLAYS), egl_$(dpy)_$(EGL_DRIVER_NAME).so) -LIB_GALLIUM_DIR = $(TOP)/$(LIB_DIR)/gallium -EGL_DISPLAY_LIBS = $(foreach drv, $(EGL_DISPLAY_DRIVERS), $(LIB_GALLIUM_DIR)/$(drv)) +EGL_DISPLAY_LIBS = $(foreach drv, $(EGL_DISPLAY_DRIVERS), $(TOP)/$(LIB_DIR)/$(drv)) default: $(EGL_DISPLAY_LIBS) -$(EGL_DISPLAY_LIBS): $(LIB_GALLIUM_DIR)/%.so: %.so - @mkdir -p $(LIB_GALLIUM_DIR) - $(INSTALL) $^ $(LIB_GALLIUM_DIR) +$(EGL_DISPLAY_LIBS): $(TOP)/$(LIB_DIR)/%.so: %.so + $(INSTALL) $< $(TOP)/$(LIB_DIR) define mklib-egl $(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ @@ -56,10 +54,9 @@ clean: -rm -f $(EGL_DISPLAY_DRIVERS) install: $(EGL_DISPLAY_LIBS) - @$(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) - @echo "Install $(EGL_DISPLAY_DRIVERS)" - @for lib in "$(EGL_DISPLAY_LIBS)"; do \ - $(MINSTALL) -m 755 "$$lib" $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR); \ + $(INSTALL) -d $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR) + for lib in "$(EGL_DISPLAY_LIBS)"; do \ + $(MINSTALL) -m 755 "$$lib" $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR); \ done depend: -- cgit v1.2.3 From fb6bff3712d71cfe131fbf70154d326cdf39e7c8 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 23 Jan 2010 14:33:29 -0800 Subject: intel: Remove unnecessary headers. --- src/mesa/drivers/dri/intel/intel_blit.c | 1 - src/mesa/drivers/dri/intel/intel_buffers.c | 2 -- src/mesa/drivers/dri/intel/intel_clear.c | 3 --- src/mesa/drivers/dri/intel/intel_context.c | 1 - src/mesa/drivers/dri/intel/intel_pixel.c | 7 ------- src/mesa/drivers/dri/intel/intel_pixel_bitmap.c | 3 --- src/mesa/drivers/dri/intel/intel_pixel_draw.c | 3 --- src/mesa/drivers/dri/intel/intel_pixel_read.c | 1 - src/mesa/drivers/dri/intel/intel_regions.c | 1 - src/mesa/drivers/dri/intel/intel_screen.c | 3 --- src/mesa/drivers/dri/intel/intel_state.c | 2 -- src/mesa/drivers/dri/intel/intel_swapbuffers.c | 1 - src/mesa/drivers/dri/intel/intel_tex_copy.c | 1 - src/mesa/drivers/dri/intel/intel_tex_image.c | 1 - src/mesa/drivers/dri/intel/intel_tex_validate.c | 2 -- 15 files changed, 32 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c index 9f638b0ef9..5b94d05966 100644 --- a/src/mesa/drivers/dri/intel/intel_blit.c +++ b/src/mesa/drivers/dri/intel/intel_blit.c @@ -38,7 +38,6 @@ #include "intel_reg.h" #include "intel_regions.h" #include "intel_batchbuffer.h" -#include "intel_chipset.h" #define FILE_DEBUG_FLAG DEBUG_BLIT diff --git a/src/mesa/drivers/dri/intel/intel_buffers.c b/src/mesa/drivers/dri/intel/intel_buffers.c index 05643189a2..78ea6ebb6d 100644 --- a/src/mesa/drivers/dri/intel/intel_buffers.c +++ b/src/mesa/drivers/dri/intel/intel_buffers.c @@ -28,10 +28,8 @@ #include "intel_context.h" #include "intel_buffers.h" #include "intel_fbo.h" -#include "intel_regions.h" #include "intel_batchbuffer.h" #include "main/framebuffer.h" -#include "drirenderbuffer.h" /** diff --git a/src/mesa/drivers/dri/intel/intel_clear.c b/src/mesa/drivers/dri/intel/intel_clear.c index f682ee3de5..583976ff89 100644 --- a/src/mesa/drivers/dri/intel/intel_clear.c +++ b/src/mesa/drivers/dri/intel/intel_clear.c @@ -33,12 +33,9 @@ #include "intel_context.h" #include "intel_blit.h" -#include "intel_chipset.h" #include "intel_clear.h" #include "intel_fbo.h" -#include "intel_pixel.h" #include "intel_regions.h" -#include "intel_batchbuffer.h" #define FILE_DEBUG_FLAG DEBUG_BLIT diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 26ff11ba61..6275df322a 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -28,7 +28,6 @@ #include "main/glheader.h" #include "main/context.h" -#include "main/arrayobj.h" #include "main/extensions.h" #include "main/framebuffer.h" #include "main/imports.h" diff --git a/src/mesa/drivers/dri/intel/intel_pixel.c b/src/mesa/drivers/dri/intel/intel_pixel.c index 993e427a99..f4e7d4b56e 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel.c +++ b/src/mesa/drivers/dri/intel/intel_pixel.c @@ -29,14 +29,7 @@ #include "main/state.h" #include "main/bufferobj.h" #include "main/context.h" -#include "main/enable.h" -#include "main/matrix.h" -#include "main/texstate.h" -#include "main/varray.h" -#include "main/viewport.h" #include "swrast/swrast.h" -#include "shader/arbprogram.h" -#include "shader/program.h" #include "intel_context.h" #include "intel_pixel.h" diff --git a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c index 19ca515242..6bb497baa0 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c @@ -37,7 +37,6 @@ #include "main/polygon.h" #include "main/state.h" #include "main/teximage.h" -#include "main/texenv.h" #include "main/texobj.h" #include "main/texstate.h" #include "main/texparam.h" @@ -46,7 +45,6 @@ #include "main/enable.h" #include "main/viewport.h" #include "shader/arbprogram.h" -#include "glapi/dispatch.h" #include "swrast/swrast.h" #include "intel_screen.h" @@ -54,7 +52,6 @@ #include "intel_batchbuffer.h" #include "intel_blit.h" #include "intel_regions.h" -#include "intel_buffer_objects.h" #include "intel_buffers.h" #include "intel_pixel.h" #include "intel_reg.h" diff --git a/src/mesa/drivers/dri/intel/intel_pixel_draw.c b/src/mesa/drivers/dri/intel/intel_pixel_draw.c index 9b382e3622..3a35634db0 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_draw.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_draw.c @@ -46,10 +46,7 @@ #include "drivers/common/meta.h" #include "intel_context.h" -#include "intel_batchbuffer.h" -#include "intel_blit.h" #include "intel_buffers.h" -#include "intel_regions.h" #include "intel_pixel.h" #include "intel_fbo.h" diff --git a/src/mesa/drivers/dri/intel/intel_pixel_read.c b/src/mesa/drivers/dri/intel/intel_pixel_read.c index 20424e2e58..01a057051e 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_read.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_read.c @@ -36,7 +36,6 @@ #include "intel_screen.h" #include "intel_context.h" -#include "intel_batchbuffer.h" #include "intel_blit.h" #include "intel_buffers.h" #include "intel_regions.h" diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c index 80975163d4..d13516ae8e 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.c +++ b/src/mesa/drivers/dri/intel/intel_regions.c @@ -48,7 +48,6 @@ #include "intel_buffer_objects.h" #include "intel_bufmgr.h" #include "intel_batchbuffer.h" -#include "intel_chipset.h" #define FILE_DEBUG_FLAG DEBUG_REGION diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index 789135b49f..f3de7d1464 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -38,12 +38,9 @@ #include "intel_buffers.h" #include "intel_bufmgr.h" #include "intel_chipset.h" -#include "intel_extensions.h" #include "intel_fbo.h" -#include "intel_regions.h" #include "intel_swapbuffers.h" #include "intel_screen.h" -#include "intel_span.h" #include "intel_tex.h" #include "i915_drm.h" diff --git a/src/mesa/drivers/dri/intel/intel_state.c b/src/mesa/drivers/dri/intel/intel_state.c index 4ee742377d..f18e625244 100644 --- a/src/mesa/drivers/dri/intel/intel_state.c +++ b/src/mesa/drivers/dri/intel/intel_state.c @@ -35,8 +35,6 @@ #include "intel_screen.h" #include "intel_context.h" -#include "intel_regions.h" -#include "swrast/swrast.h" int intel_translate_shadow_compare_func(GLenum func) diff --git a/src/mesa/drivers/dri/intel/intel_swapbuffers.c b/src/mesa/drivers/dri/intel/intel_swapbuffers.c index 7d035b9f6e..5af2f5f1ca 100644 --- a/src/mesa/drivers/dri/intel/intel_swapbuffers.c +++ b/src/mesa/drivers/dri/intel/intel_swapbuffers.c @@ -29,7 +29,6 @@ #include "intel_buffers.h" #include "intel_swapbuffers.h" #include "intel_fbo.h" -#include "intel_batchbuffer.h" #include "drirenderbuffer.h" #include "vblank.h" #include "i915_drm.h" diff --git a/src/mesa/drivers/dri/intel/intel_tex_copy.c b/src/mesa/drivers/dri/intel/intel_tex_copy.c index ef5aed32f3..a80cab31f3 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_copy.c +++ b/src/mesa/drivers/dri/intel/intel_tex_copy.c @@ -36,7 +36,6 @@ #include "intel_screen.h" #include "intel_context.h" -#include "intel_batchbuffer.h" #include "intel_buffers.h" #include "intel_mipmap_tree.h" #include "intel_regions.h" diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c index 66d61f93ea..fe4806c00a 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_image.c +++ b/src/mesa/drivers/dri/intel/intel_tex_image.c @@ -7,7 +7,6 @@ #include "main/convolve.h" #include "main/context.h" #include "main/formats.h" -#include "main/image.h" #include "main/texcompress.h" #include "main/texstore.h" #include "main/texgetimage.h" diff --git a/src/mesa/drivers/dri/intel/intel_tex_validate.c b/src/mesa/drivers/dri/intel/intel_tex_validate.c index c9a24ac398..ed5c5d896b 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_validate.c +++ b/src/mesa/drivers/dri/intel/intel_tex_validate.c @@ -2,10 +2,8 @@ #include "main/macros.h" #include "intel_context.h" -#include "intel_batchbuffer.h" #include "intel_mipmap_tree.h" #include "intel_tex.h" -#include "intel_chipset.h" #define FILE_DEBUG_FLAG DEBUG_TEXTURE -- cgit v1.2.3 From b62b524fee5f1b9ec9b53cc8f550a0c9a3d769c2 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 23 Jan 2010 20:43:27 -0800 Subject: r300: Remove unnecessary headers. --- src/mesa/drivers/dri/r300/r300_cmdbuf.c | 3 --- src/mesa/drivers/dri/r300/r300_context.c | 5 ----- src/mesa/drivers/dri/r300/r300_draw.c | 3 --- src/mesa/drivers/dri/r300/r300_emit.c | 6 ------ src/mesa/drivers/dri/r300/r300_fragprog_common.c | 2 -- src/mesa/drivers/dri/r300/r300_ioctl.c | 2 -- src/mesa/drivers/dri/r300/r300_render.c | 6 ------ src/mesa/drivers/dri/r300/r300_state.c | 4 ---- src/mesa/drivers/dri/r300/r300_tex.c | 5 ----- src/mesa/drivers/dri/r300/r300_texstate.c | 2 -- src/mesa/drivers/dri/r300/r300_vertprog.c | 1 - 11 files changed, 39 deletions(-) diff --git a/src/mesa/drivers/dri/r300/r300_cmdbuf.c b/src/mesa/drivers/dri/r300/r300_cmdbuf.c index ad8db6e68e..96c96d8d9a 100644 --- a/src/mesa/drivers/dri/r300/r300_cmdbuf.c +++ b/src/mesa/drivers/dri/r300/r300_cmdbuf.c @@ -39,19 +39,16 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/macros.h" #include "main/context.h" #include "main/simple_list.h" -#include "swrast/swrast.h" #include "drm.h" #include "radeon_drm.h" #include "r300_context.h" -#include "r300_ioctl.h" #include "r300_reg.h" #include "r300_cmdbuf.h" #include "r300_emit.h" #include "radeon_bocs_wrapper.h" #include "radeon_mipmap_tree.h" -#include "r300_state.h" #include "radeon_queryobj.h" /** # of dwords reserved for additional instructions that may need to be written diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c index 5f07b95634..2ad5186384 100644 --- a/src/mesa/drivers/dri/r300/r300_context.c +++ b/src/mesa/drivers/dri/r300/r300_context.c @@ -40,9 +40,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/context.h" #include "main/simple_list.h" #include "main/imports.h" -#include "main/matrix.h" #include "main/extensions.h" -#include "main/state.h" #include "main/bufferobj.h" #include "main/texobj.h" @@ -52,12 +50,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "tnl/tnl.h" #include "tnl/t_pipeline.h" -#include "tnl/t_vp_build.h" #include "drivers/common/driverfuncs.h" #include "r300_context.h" -#include "radeon_context.h" #include "radeon_span.h" #include "r300_cmdbuf.h" #include "r300_state.h" @@ -69,7 +65,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "radeon_buffer_objects.h" #include "radeon_queryobj.h" -#include "vblank.h" #include "utils.h" #include "xmlpool.h" /* for symbolic values of enum-type options */ diff --git a/src/mesa/drivers/dri/r300/r300_draw.c b/src/mesa/drivers/dri/r300/r300_draw.c index e9968f9ffe..1d1d41fc5c 100644 --- a/src/mesa/drivers/dri/r300/r300_draw.c +++ b/src/mesa/drivers/dri/r300/r300_draw.c @@ -29,7 +29,6 @@ #include "main/glheader.h" #include "main/context.h" #include "main/state.h" -#include "main/api_validate.h" #include "main/enums.h" #include "main/simple_list.h" @@ -47,8 +46,6 @@ #include "tnl/tnl.h" #include "tnl/t_vp_build.h" #include "vbo/vbo_context.h" -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" static int getTypeSize(GLenum type) diff --git a/src/mesa/drivers/dri/r300/r300_emit.c b/src/mesa/drivers/dri/r300/r300_emit.c index 07e6223087..71287514ec 100644 --- a/src/mesa/drivers/dri/r300/r300_emit.c +++ b/src/mesa/drivers/dri/r300/r300_emit.c @@ -39,19 +39,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/colormac.h" #include "main/imports.h" #include "main/macros.h" -#include "main/image.h" #include "swrast_setup/swrast_setup.h" -#include "math/m_translate.h" #include "tnl/tnl.h" #include "tnl/t_context.h" #include "r300_context.h" -#include "r300_state.h" #include "r300_emit.h" -#include "r300_ioctl.h" -#include "r300_render.h" -#include "r300_swtcl.h" GLuint r300VAPInputCntl0(GLcontext * ctx, GLuint InputsRead) { diff --git a/src/mesa/drivers/dri/r300/r300_fragprog_common.c b/src/mesa/drivers/dri/r300/r300_fragprog_common.c index 267ee81a7a..d94ed08824 100644 --- a/src/mesa/drivers/dri/r300/r300_fragprog_common.c +++ b/src/mesa/drivers/dri/r300/r300_fragprog_common.c @@ -38,14 +38,12 @@ #include "r300_fragprog_common.h" -#include "shader/program.h" #include "shader/prog_parameter.h" #include "shader/prog_print.h" #include "compiler/radeon_compiler.h" #include "radeon_mesa_to_rc.h" -#include "r300_state.h" static GLuint build_dtm(GLuint depthmode) diff --git a/src/mesa/drivers/dri/r300/r300_ioctl.c b/src/mesa/drivers/dri/r300/r300_ioctl.c index 5cb04e2bb6..bb34efe827 100644 --- a/src/mesa/drivers/dri/r300/r300_ioctl.c +++ b/src/mesa/drivers/dri/r300/r300_ioctl.c @@ -58,8 +58,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r300_emit.h" #include "r300_context.h" -#include "vblank.h" - #define R200_3D_DRAW_IMMD_2 0xC0003500 #define CLEARBUFFER_COLOR 0x1 diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c index 4ae593cbe7..e3e6285784 100644 --- a/src/mesa/drivers/dri/r300/r300_render.c +++ b/src/mesa/drivers/dri/r300/r300_render.c @@ -53,7 +53,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r300_render.h" #include "main/glheader.h" -#include "main/state.h" #include "main/imports.h" #include "main/enums.h" #include "main/macros.h" @@ -65,15 +64,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "swrast_setup/swrast_setup.h" #include "vbo/vbo.h" #include "vbo/vbo_split.h" -#include "tnl/tnl.h" -#include "tnl/t_vp_build.h" #include "r300_context.h" -#include "r300_ioctl.h" #include "r300_state.h" #include "r300_reg.h" -#include "r300_tex.h" #include "r300_emit.h" -#include "r300_fragprog_common.h" #include "r300_swtcl.h" /** diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c index ac20c08e20..66b57e58a7 100644 --- a/src/mesa/drivers/dri/r300/r300_state.c +++ b/src/mesa/drivers/dri/r300/r300_state.c @@ -55,17 +55,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "tnl/t_vp_build.h" #include "r300_context.h" -#include "r300_ioctl.h" #include "r300_state.h" #include "r300_reg.h" #include "r300_emit.h" -#include "r300_tex.h" #include "r300_fragprog_common.h" #include "r300_render.h" #include "r300_vertprog.h" -#include "drirenderbuffer.h" - static void r300BlendColor(GLcontext * ctx, const GLfloat cf[4]) { r300ContextPtr rmesa = R300_CONTEXT(ctx); diff --git a/src/mesa/drivers/dri/r300/r300_tex.c b/src/mesa/drivers/dri/r300/r300_tex.c index 726b3ff98e..de6e6e166a 100644 --- a/src/mesa/drivers/dri/r300/r300_tex.c +++ b/src/mesa/drivers/dri/r300/r300_tex.c @@ -41,19 +41,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/mipmap.h" #include "main/simple_list.h" #include "main/texstore.h" -#include "main/teximage.h" #include "main/texobj.h" #include "texmem.h" #include "r300_context.h" -#include "r300_state.h" -#include "r300_ioctl.h" #include "radeon_mipmap_tree.h" #include "r300_tex.h" -#include "xmlpool.h" - static unsigned int translate_wrap_mode(GLenum wrapmode) { diff --git a/src/mesa/drivers/dri/r300/r300_texstate.c b/src/mesa/drivers/dri/r300/r300_texstate.c index bbe8b1e95f..1dc5f822d9 100644 --- a/src/mesa/drivers/dri/r300/r300_texstate.c +++ b/src/mesa/drivers/dri/r300/r300_texstate.c @@ -45,8 +45,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/simple_list.h" #include "r300_context.h" -#include "r300_state.h" -#include "r300_ioctl.h" #include "radeon_mipmap_tree.h" #include "r300_tex.h" #include "r300_reg.h" diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index c2f96af2c1..bede6e0418 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -34,7 +34,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "shader/program.h" #include "shader/programopt.h" #include "shader/prog_instruction.h" -#include "shader/prog_optimize.h" #include "shader/prog_parameter.h" #include "shader/prog_print.h" #include "shader/prog_statevars.h" -- cgit v1.2.3 From 7f2f42dd8093e585a6edff2b1173cc39fc6391df Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 23 Jan 2010 20:56:49 -0800 Subject: progs/demos: Remove unnecessary header from shadowtex.c. --- progs/demos/Makefile | 7 ------- progs/demos/shadowtex.c | 1 - 2 files changed, 8 deletions(-) diff --git a/progs/demos/Makefile b/progs/demos/Makefile index 65fdbaaad8..f21d916330 100644 --- a/progs/demos/Makefile +++ b/progs/demos/Makefile @@ -124,13 +124,6 @@ reflect.o: reflect.c showbuffer.h $(APP_CC) -c -I$(INCDIR) $(CFLAGS) reflect.c -shadowtex: shadowtex.o showbuffer.o - $(APP_CC) $(CFLAGS) $(LDFLAGS) shadowtex.o showbuffer.o $(LIBS) -o $@ - -shadowtex.o: shadowtex.c showbuffer.h - $(APP_CC) -c -I$(INCDIR) $(CFLAGS) shadowtex.c - - gloss: gloss.o trackball.o readtex.o $(APP_CC) $(CFLAGS) $(LDFLAGS) gloss.o trackball.o readtex.o $(LIBS) -o $@ diff --git a/progs/demos/shadowtex.c b/progs/demos/shadowtex.c index dc5a4bbc48..59d0070a26 100644 --- a/progs/demos/shadowtex.c +++ b/progs/demos/shadowtex.c @@ -38,7 +38,6 @@ #include #include #include -#include "showbuffer.h" #define DEG_TO_RAD (3.14159 / 180.0) -- cgit v1.2.3 From 232ddfec24d2e707c4e374d817c559cc6415d609 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 24 Jan 2010 14:58:45 +1000 Subject: r300g: fix flushing harder. I swear ipers runs here after this commit. After we flush we need to redo the space check --- src/gallium/drivers/r300/r300_emit.c | 3 ++- src/gallium/drivers/r300/r300_render.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index cc40abf168..e08e6c2292 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -1105,9 +1105,10 @@ void r300_emit_dirty_state(struct r300_context* r300) /* Make sure we have at least 2*1024 spare dwords. */ /* XXX It would be nice to know the number of dwords we really need to * XXX emit. */ +again: if (!r300->winsys->check_cs(r300->winsys, dwords)) { r300->context.flush(&r300->context, 0, NULL); - r300_emit_buffer_validate(r300); + goto again; } if (r300->dirty_state & R300_NEW_QUERY) { diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index cb2d8d4537..677031ef04 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -302,6 +302,8 @@ void r300_draw_range_elements(struct pipe_context* pipe, r300_update_derived_state(r300); + r300_emit_buffer_validate(r300); + if (!r300_setup_vertex_buffers(r300)) { return; } @@ -311,8 +313,6 @@ void r300_draw_range_elements(struct pipe_context* pipe, indexSize = 2; } - r300_emit_buffer_validate(r300); - if (!r300->winsys->add_buffer(r300->winsys, indexBuffer, RADEON_GEM_DOMAIN_GTT, 0)) { goto cleanup; -- cgit v1.2.3 From d57ba16ae3943a93071ef1bbab4a13725b8ea20c Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 23 Jan 2010 21:05:58 -0800 Subject: scons: Define _DARWIN_C_SOURCE on Darwin builds. --- SConstruct | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SConstruct b/SConstruct index f43c10cecb..455b4719db 100644 --- a/SConstruct +++ b/SConstruct @@ -110,6 +110,8 @@ if platform in ('posix', 'linux', 'freebsd', 'darwin'): 'PTHREADS', 'HAVE_POSIX_MEMALIGN', ]) + if platform == 'darwin': + env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE']) env.Append(CPPPATH = ['/usr/X11R6/include']) env.Append(LIBPATH = ['/usr/X11R6/lib']) env.Append(LIBS = [ -- cgit v1.2.3 From e9bb06441eb4a50e9927dcc09289ec63b0e2cf0a Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sun, 24 Jan 2010 15:37:23 +1000 Subject: r300g: avoid the use of goto I was being lazy on Sunday morning, Droste on irc called me on it ;-) --- src/gallium/drivers/r300/r300_emit.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index e08e6c2292..e07185b778 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -1105,10 +1105,8 @@ void r300_emit_dirty_state(struct r300_context* r300) /* Make sure we have at least 2*1024 spare dwords. */ /* XXX It would be nice to know the number of dwords we really need to * XXX emit. */ -again: - if (!r300->winsys->check_cs(r300->winsys, dwords)) { + while (!r300->winsys->check_cs(r300->winsys, dwords)) { r300->context.flush(&r300->context, 0, NULL); - goto again; } if (r300->dirty_state & R300_NEW_QUERY) { -- cgit v1.2.3 From 6b55aacccbbc2c86f03eafab23d5d74bc165c9ed Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 23 Jan 2010 21:43:26 -0800 Subject: scons: Do not use ld options start-group and end-group on Darwin. Mac OS X ld does not support these options. --- scons/gallium.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scons/gallium.py b/scons/gallium.py index f4e82e8e0a..2d963a5f9e 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -476,7 +476,10 @@ def generate(env): '-Wl,-Bsymbolic', ] # Handle circular dependencies in the libraries - env['_LIBFLAGS'] = '-Wl,--start-group ' + env['_LIBFLAGS'] + ' -Wl,--end-group' + if env['platform'] in ('darwin'): + pass + else: + env['_LIBFLAGS'] = '-Wl,--start-group ' + env['_LIBFLAGS'] + ' -Wl,--end-group' if msvc: if not env['debug']: # enable Link-time Code Generation -- cgit v1.2.3 From bc75ec0f3824176f3fd7182846b3ec36051945b3 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 23 Jan 2010 22:59:31 -0800 Subject: glapi: Do not use .type pseudo-op on Mac OS X. The .type directive is an unknown pseudo-op on Mac OS X. --- src/mesa/glapi/gl_x86_asm.py | 2 +- src/mesa/x86/glapi_x86.S | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/glapi/gl_x86_asm.py b/src/mesa/glapi/gl_x86_asm.py index 36f0e31fe2..3bc955dfe5 100644 --- a/src/mesa/glapi/gl_x86_asm.py +++ b/src/mesa/glapi/gl_x86_asm.py @@ -73,7 +73,7 @@ class PrintGenericStubs(gl_XML.gl_print_base): print '' print '#define GL_OFFSET(x) CODEPTR(REGOFF(4 * x, EAX))' print '' - print '#if defined(GNU_ASSEMBLER) && !defined(__DJGPP__) && !defined(__MINGW32__)' + print '#if defined(GNU_ASSEMBLER) && !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__)' print '#define GLOBL_FN(x) GLOBL x ; .type x, function' print '#else' print '#define GLOBL_FN(x) GLOBL x' diff --git a/src/mesa/x86/glapi_x86.S b/src/mesa/x86/glapi_x86.S index 0da924c37f..849fbce3b8 100644 --- a/src/mesa/x86/glapi_x86.S +++ b/src/mesa/x86/glapi_x86.S @@ -46,7 +46,7 @@ #define GL_OFFSET(x) CODEPTR(REGOFF(4 * x, EAX)) -#if defined(GNU_ASSEMBLER) && !defined(__DJGPP__) && !defined(__MINGW32__) +#if defined(GNU_ASSEMBLER) && !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__) #define GLOBL_FN(x) GLOBL x ; .type x, function #else #define GLOBL_FN(x) GLOBL x -- cgit v1.2.3 From f429b80fffc57a6165b76e9345cf5b9383edd650 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 23 Jan 2010 23:12:34 -0800 Subject: x86: Do not use .hidden pseudo-op on Mac OS X. The .hidden directive is an unknown pseudo-op on Mac OS X. --- src/mesa/x86/assyntax.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/x86/assyntax.h b/src/mesa/x86/assyntax.h index 524944f73a..de1f6a48de 100644 --- a/src/mesa/x86/assyntax.h +++ b/src/mesa/x86/assyntax.h @@ -1735,9 +1735,9 @@ SECTION _DATA public align=16 class=DATA use32 flat * If we build with gcc's -fvisibility=hidden flag, we'll need to change * the symbol visibility mode to 'default'. */ -#if defined(GNU_ASSEMBLER) && !defined(__DJGPP__) && !defined(__MINGW32__) +#if defined(GNU_ASSEMBLER) && !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__) # define HIDDEN(x) .hidden x -#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 && !defined(__DJGPP__) && !defined(__MINGW32__) +#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 && !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__) # pragma GCC visibility push(default) # define HIDDEN(x) .hidden x #else -- cgit v1.2.3 From e02dc139520fab9f7189e0ae390f72ed674bb7d7 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 23 Jan 2010 23:18:33 -0800 Subject: x86: Do not build read_rgba_span_x86.S on Mac OS X. read_rgba_span_x86.S uses the pseudo-ops .hidden and .type which are not recognized on Mac OS X. --- src/mesa/x86/read_rgba_span_x86.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/x86/read_rgba_span_x86.S b/src/mesa/x86/read_rgba_span_x86.S index 92b1c2d902..3886a510bb 100644 --- a/src/mesa/x86/read_rgba_span_x86.S +++ b/src/mesa/x86/read_rgba_span_x86.S @@ -31,7 +31,7 @@ */ .file "read_rgba_span_x86.S" -#if !defined(__DJGPP__) && !defined(__MINGW32__) /* this one cries for assyntax.h */ +#if !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__) /* this one cries for assyntax.h */ /* Kevin F. Quinn 2nd July 2006 * Replaced data segment constants with text-segment instructions. */ @@ -671,7 +671,7 @@ _generic_read_RGBA_span_RGB565_MMX: emms #endif ret -#endif /* !defined(__DJGPP__) && !defined(__MINGW32__) */ +#endif /* !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__) */ #if defined (__ELF__) && defined (__linux__) .section .note.GNU-stack,"",%progbits -- cgit v1.2.3 From e85cb98a169f83e1a1ad7f17cbbedaee0ea47fe1 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sun, 24 Jan 2010 00:17:00 -0800 Subject: r200: Silence fprintf format warning. --- src/mesa/drivers/dri/r200/r200_vertprog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/r200/r200_vertprog.c b/src/mesa/drivers/dri/r200/r200_vertprog.c index 11405d7cae..4f225a233d 100644 --- a/src/mesa/drivers/dri/r200/r200_vertprog.c +++ b/src/mesa/drivers/dri/r200/r200_vertprog.c @@ -437,7 +437,7 @@ static GLboolean r200_translate_vertex_program(GLcontext *ctx, struct r200_verte (1 << VERT_RESULT_TEX2) | (1 << VERT_RESULT_TEX3) | (1 << VERT_RESULT_TEX4) | (1 << VERT_RESULT_TEX5) | (1 << VERT_RESULT_PSIZ))) != 0) { if (R200_DEBUG & RADEON_FALLBACKS) { - fprintf(stderr, "can't handle vert prog outputs 0x%x\n", + fprintf(stderr, "can't handle vert prog outputs 0x%llx\n", mesa_vp->Base.OutputsWritten); } return GL_FALSE; -- cgit v1.2.3 From 7be4d6b5f7ee8ccf8a5dfc117b348c2a165d4054 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 24 Jan 2010 11:03:20 +0800 Subject: mesa/es: Improve Makefile rules. Make sure glapi headers are cleaned when "make clean". Make sure all sources depend on subdirs-stamp-tmp so that sources/headers are generated first. subdirs-stamp-tmp will be removed after a successful build. It might be a problem when a build fails. But it is much better than where we currently are: glapi headers are never cleaned or re-generated. --- src/mesa/es/Makefile | 32 +++++++++++++++++++------------- src/mesa/es/glapi/Makefile | 6 +----- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/mesa/es/Makefile b/src/mesa/es/Makefile index ca38dc4aed..fbe67445c9 100644 --- a/src/mesa/es/Makefile +++ b/src/mesa/es/Makefile @@ -10,12 +10,14 @@ ES1_LIBS := libes1gallium.a libes1api.a ES2_LIBS := libes2gallium.a libes2api.a # Default rule: create ES1 and ES2 libs -.PHONY: default -default: subdirs depend es1 es2 +.PHONY: default es1 es2 +default: depend es1 es2 es1: $(ES1_LIBS) + @rm -f subdirs-stamp-tmp es2: $(ES2_LIBS) + @rm -f subdirs-stamp-tmp # force the inclusion of es's mfeatures.h ES1_CPPFLAGS := -include main/mfeatures_es1.h -D__GL_EXPORTS @@ -104,24 +106,26 @@ clean: -rm -f $(ES1_LIBS) $(ES2_LIBS) -rm -rf $(ES1_OBJ_DIR) $(ES2_OBJ_DIR) -rm -f $(GENERATED_SOURCES) - -rm -f depend - -rm -f *~ + -rm -f depend depend.bak + -rm -f subdirs-stamp-tmp + @$(MAKE) -C glapi clean # nothing to install install: -glapi/glapi-stamp: - $(MAKE) -C glapi +subdirs-stamp-tmp: + @$(MAKE) -C $(MESA) asm_subdirs + @$(MAKE) -C $(MESA) glsl_builtin + @$(MAKE) -C glapi + @touch subdirs-stamp-tmp -subdirs: glapi/glapi-stamp - $(MAKE) -C $(MESA) asm_subdirs - $(MAKE) -C $(MESA) glsl_builtin +# sort to avoid duplicates +ALL_SOURCES := $(sort $(ES1_ALL_SOURCES) $(ES2_ALL_SOURCES)) -# remove generated sources because "depend" is checked even when "make clean" -DEPEND_SOURCES := $(filter-out $(GENERATED_SOURCES), $(ES1_ALL_SOURCES) $(ES2_ALL_SOURCES)) -DEPEND_SOURCES := $(filter-out glapi/%, $(DEPEND_SOURCES)) +# need to make sure the subdirs are processed first +$(ALL_SOURCES): | subdirs-stamp-tmp -depend: glapi/glapi-stamp $(DEPEND_SOURCES) +depend: $(ALL_SOURCES) @echo "running $(MKDEP)" @touch depend @# MESA is "..", but luckily, directories are longer than 2 characters @@ -132,4 +136,6 @@ depend: glapi/glapi-stamp $(DEPEND_SOURCES) $(ES2_INCLUDES) $(ES2_ALL_SOURCES) 2>/dev/null | \ sed -e 's,^$(ES2_OBJ_DIR)/$(MESA)/,$(ES2_OBJ_DIR)/,' >> depend +ifneq ($(MAKECMDGOALS),clean) -include depend +endif diff --git a/src/mesa/es/glapi/Makefile b/src/mesa/es/glapi/Makefile index 1256be953d..1e32af867d 100644 --- a/src/mesa/es/glapi/Makefile +++ b/src/mesa/es/glapi/Makefile @@ -30,10 +30,7 @@ ES2_DEPS = $(ES2_APIXML) base2_API.xml es2_EXT.xml es_EXT.xml \ ES1_OUTPUTS := $(addprefix $(ES1_OUTPUT_DIR)/, $(OUTPUTS)) ES2_OUTPUTS := $(addprefix $(ES2_OUTPUT_DIR)/, $(OUTPUTS)) -all: glapi-stamp - -glapi-stamp: $(ES1_OUTPUTS) $(ES2_OUTPUTS) - @touch glapi-stamp +all: $(ES1_OUTPUTS) $(ES2_OUTPUTS) $(ES1_OUTPUTS): APIXML := $(ES1_APIXML) $(ES2_OUTPUTS): APIXML := $(ES2_APIXML) @@ -89,6 +86,5 @@ verify_xml: @rm -f tmp.xml clean: - -rm -f glapi-stamp -rm -rf $(ES1_OUTPUT_DIR) $(ES2_OUTPUT_DIR) -rm -f *~ *.pyc *.pyo -- cgit v1.2.3 From 5e66d1893234b3002d71985c05253321d4cdedc4 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 23 Jan 2010 22:53:59 +0800 Subject: egl: Move context functions in egldisplay.[ch] to eglcontext.[ch]. Move functions to where they should be. There should be no real change here. --- src/egl/main/eglcontext.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++ src/egl/main/eglcontext.h | 63 +++++++++++++++++++++++++++++++++++++++++++ src/egl/main/egldisplay.c | 63 ------------------------------------------- src/egl/main/egldisplay.h | 55 ------------------------------------- 4 files changed, 132 insertions(+), 118 deletions(-) diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index ee4b1b59f5..41960f5426 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -251,3 +251,72 @@ _eglCopyContextMESA(_EGLDriver *drv, EGLDisplay dpy, EGLContext source, */ return EGL_FALSE; } + + +/** + * Link a context to a display and return the handle of the link. + * The handle can be passed to client directly. + */ +EGLContext +_eglLinkContext(_EGLContext *ctx, _EGLDisplay *dpy) +{ + ctx->Display = dpy; + ctx->Next = dpy->ContextList; + dpy->ContextList = ctx; + return (EGLContext) ctx; +} + + +/** + * Unlink a linked context from its display. + * Accessing an unlinked context should generate EGL_BAD_CONTEXT error. + */ +void +_eglUnlinkContext(_EGLContext *ctx) +{ + _EGLContext *prev; + + prev = ctx->Display->ContextList; + if (prev != ctx) { + while (prev) { + if (prev->Next == ctx) + break; + prev = prev->Next; + } + assert(prev); + prev->Next = ctx->Next; + } + else { + ctx->Display->ContextList = ctx->Next; + } + + ctx->Next = NULL; + ctx->Display = NULL; +} + + +#ifndef _EGL_SKIP_HANDLE_CHECK + + +/** + * Return EGL_TRUE if the given handle is a valid handle to a context. + */ +EGLBoolean +_eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy) +{ + _EGLContext *cur = NULL; + + if (dpy) + cur = dpy->ContextList; + while (cur) { + if (cur == (_EGLContext *) ctx) { + assert(cur->Display == dpy); + break; + } + cur = cur->Next; + } + return (cur != NULL); +} + + +#endif /* !_EGL_SKIP_HANDLE_CHECK */ diff --git a/src/egl/main/eglcontext.h b/src/egl/main/eglcontext.h index cb9e3f4a89..0dcec92488 100644 --- a/src/egl/main/eglcontext.h +++ b/src/egl/main/eglcontext.h @@ -65,4 +65,67 @@ _eglIsContextBound(_EGLContext *ctx) } +extern EGLContext +_eglLinkContext(_EGLContext *ctx, _EGLDisplay *dpy); + + +extern void +_eglUnlinkContext(_EGLContext *ctx); + + +#ifndef _EGL_SKIP_HANDLE_CHECK + + +extern EGLBoolean +_eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy); + + +#else /* !_EGL_SKIP_HANDLE_CHECK */ + + +static INLINE EGLBoolean +_eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy) +{ + _EGLContext *c = (_EGLContext *) ctx; + return (dpy && c && c->Display == dpy); +} + + +#endif /* _EGL_SKIP_HANDLE_CHECK */ + + +/** + * Lookup a handle to find the linked context. + * Return NULL if the handle has no corresponding linked context. + */ +static INLINE _EGLContext * +_eglLookupContext(EGLContext context, _EGLDisplay *dpy) +{ + _EGLContext *ctx = (_EGLContext *) context; + if (!_eglCheckContextHandle(context, dpy)) + ctx = NULL; + return ctx; +} + + +/** + * Return the handle of a linked context, or EGL_NO_CONTEXT. + */ +static INLINE EGLContext +_eglGetContextHandle(_EGLContext *ctx) +{ + return (EGLContext) ((ctx && ctx->Display) ? ctx : EGL_NO_CONTEXT); +} + + +/** + * Return true if the context is linked to a display. + */ +static INLINE EGLBoolean +_eglIsContextLinked(_EGLContext *ctx) +{ + return (EGLBoolean) (_eglGetContextHandle(ctx) != EGL_NO_CONTEXT); +} + + #endif /* EGLCONTEXT_INCLUDED */ diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index eb82af4884..e14d0c1b63 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -182,48 +182,6 @@ _eglCleanupDisplay(_EGLDisplay *disp) } -/** - * Link a context to a display and return the handle of the link. - * The handle can be passed to client directly. - */ -EGLContext -_eglLinkContext(_EGLContext *ctx, _EGLDisplay *dpy) -{ - ctx->Display = dpy; - ctx->Next = dpy->ContextList; - dpy->ContextList = ctx; - return (EGLContext) ctx; -} - - -/** - * Unlink a linked context from its display. - * Accessing an unlinked context should generate EGL_BAD_CONTEXT error. - */ -void -_eglUnlinkContext(_EGLContext *ctx) -{ - _EGLContext *prev; - - prev = ctx->Display->ContextList; - if (prev != ctx) { - while (prev) { - if (prev->Next == ctx) - break; - prev = prev->Next; - } - assert(prev); - prev->Next = ctx->Next; - } - else { - ctx->Display->ContextList = ctx->Next; - } - - ctx->Next = NULL; - ctx->Display = NULL; -} - - /** * Link a surface to a display and return the handle of the link. * The handle can be passed to client directly. @@ -290,27 +248,6 @@ _eglCheckDisplayHandle(EGLDisplay dpy) } -/** - * Return EGL_TRUE if the given handle is a valid handle to a context. - */ -EGLBoolean -_eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy) -{ - _EGLContext *cur = NULL; - - if (dpy) - cur = dpy->ContextList; - while (cur) { - if (cur == (_EGLContext *) ctx) { - assert(cur->Display == dpy); - break; - } - cur = cur->Next; - } - return (cur != NULL); -} - - /** * Return EGL_TRUE if the given handle is a valid handle to a surface. */ diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index a69813196f..4b9010e76d 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -3,7 +3,6 @@ #include "egltypedefs.h" #include "egldefines.h" -#include "eglcontext.h" #include "eglsurface.h" @@ -81,14 +80,6 @@ PUBLIC void _eglCleanupDisplay(_EGLDisplay *disp); -extern EGLContext -_eglLinkContext(_EGLContext *ctx, _EGLDisplay *dpy); - - -extern void -_eglUnlinkContext(_EGLContext *ctx); - - extern EGLSurface _eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy); @@ -104,10 +95,6 @@ extern EGLBoolean _eglCheckDisplayHandle(EGLDisplay dpy); -extern EGLBoolean -_eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy); - - extern EGLBoolean _eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy); @@ -123,14 +110,6 @@ _eglCheckDisplayHandle(EGLDisplay dpy) } -static INLINE EGLBoolean -_eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy) -{ - _EGLContext *c = (_EGLContext *) ctx; - return (dpy && c && c->Display == dpy); -} - - static INLINE EGLBoolean _eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy) { @@ -176,40 +155,6 @@ _eglIsDisplayLinked(_EGLDisplay *dpy) } -/** - * Lookup a handle to find the linked context. - * Return NULL if the handle has no corresponding linked context. - */ -static INLINE _EGLContext * -_eglLookupContext(EGLContext context, _EGLDisplay *dpy) -{ - _EGLContext *ctx = (_EGLContext *) context; - if (!_eglCheckContextHandle(context, dpy)) - ctx = NULL; - return ctx; -} - - -/** - * Return the handle of a linked context, or EGL_NO_CONTEXT. - */ -static INLINE EGLContext -_eglGetContextHandle(_EGLContext *ctx) -{ - return (EGLContext) ((ctx && ctx->Display) ? ctx : EGL_NO_CONTEXT); -} - - -/** - * Return true if the context is linked to a display. - */ -static INLINE EGLBoolean -_eglIsContextLinked(_EGLContext *ctx) -{ - return (EGLBoolean) (_eglGetContextHandle(ctx) != EGL_NO_CONTEXT); -} - - /** * Lookup a handle to find the linked surface. * Return NULL if the handle has no corresponding linked surface. -- cgit v1.2.3 From b4d2c97a2d2cce92fa638ff74bef7dedf593fd1f Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 23 Jan 2010 22:57:23 +0800 Subject: egl: Move surface functions in egldisplay.[ch] to eglsurface.[ch] Move functions to where they should be. There should be no real change here. --- src/egl/main/egldisplay.c | 64 ------------------------------------------- src/egl/main/egldisplay.h | 55 ------------------------------------- src/egl/main/eglsurface.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++ src/egl/main/eglsurface.h | 63 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 133 insertions(+), 119 deletions(-) diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index e14d0c1b63..79efa8477e 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -182,49 +182,6 @@ _eglCleanupDisplay(_EGLDisplay *disp) } -/** - * Link a surface to a display and return the handle of the link. - * The handle can be passed to client directly. - */ -EGLSurface -_eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy) -{ - surf->Display = dpy; - surf->Next = dpy->SurfaceList; - dpy->SurfaceList = surf; - return (EGLSurface) surf; -} - - -/** - * Unlink a linked surface from its display. - * Accessing an unlinked surface should generate EGL_BAD_SURFACE error. - */ -void -_eglUnlinkSurface(_EGLSurface *surf) -{ - _EGLSurface *prev; - - prev = surf->Display->SurfaceList; - if (prev != surf) { - while (prev) { - if (prev->Next == surf) - break; - prev = prev->Next; - } - assert(prev); - prev->Next = surf->Next; - } - else { - prev = NULL; - surf->Display->SurfaceList = surf->Next; - } - - surf->Next = NULL; - surf->Display = NULL; -} - - #ifndef _EGL_SKIP_HANDLE_CHECK @@ -248,25 +205,4 @@ _eglCheckDisplayHandle(EGLDisplay dpy) } -/** - * Return EGL_TRUE if the given handle is a valid handle to a surface. - */ -EGLBoolean -_eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy) -{ - _EGLSurface *cur = NULL; - - if (dpy) - cur = dpy->SurfaceList; - while (cur) { - if (cur == (_EGLSurface *) surf) { - assert(cur->Display == dpy); - break; - } - cur = cur->Next; - } - return (cur != NULL); -} - - #endif /* !_EGL_SKIP_HANDLE_CHECK */ diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 4b9010e76d..77458cb38d 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -3,7 +3,6 @@ #include "egltypedefs.h" #include "egldefines.h" -#include "eglsurface.h" /** @@ -80,14 +79,6 @@ PUBLIC void _eglCleanupDisplay(_EGLDisplay *disp); -extern EGLSurface -_eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy); - - -extern void -_eglUnlinkSurface(_EGLSurface *surf); - - #ifndef _EGL_SKIP_HANDLE_CHECK @@ -95,10 +86,6 @@ extern EGLBoolean _eglCheckDisplayHandle(EGLDisplay dpy); -extern EGLBoolean -_eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy); - - #else /* !_EGL_SKIP_HANDLE_CHECK */ /* Only do a quick check. This is NOT standard compliant. */ @@ -110,14 +97,6 @@ _eglCheckDisplayHandle(EGLDisplay dpy) } -static INLINE EGLBoolean -_eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy) -{ - _EGLSurface *s = (_EGLSurface *) surf; - return (dpy && s && s->Display == dpy); -} - - #endif /* _EGL_SKIP_HANDLE_CHECK */ @@ -155,40 +134,6 @@ _eglIsDisplayLinked(_EGLDisplay *dpy) } -/** - * Lookup a handle to find the linked surface. - * Return NULL if the handle has no corresponding linked surface. - */ -static INLINE _EGLSurface * -_eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy) -{ - _EGLSurface *surf = (_EGLSurface *) surface; - if (!_eglCheckSurfaceHandle(surf, dpy)) - surf = NULL; - return surf; -} - - -/** - * Return the handle of a linked surface, or EGL_NO_SURFACE. - */ -static INLINE EGLSurface -_eglGetSurfaceHandle(_EGLSurface *surf) -{ - return (EGLSurface) ((surf && surf->Display) ? surf : EGL_NO_SURFACE); -} - - -/** - * Return true if the surface is linked to a display. - */ -static INLINE EGLBoolean -_eglIsSurfaceLinked(_EGLSurface *surf) -{ - return (EGLBoolean) (_eglGetSurfaceHandle(surf) != EGL_NO_SURFACE); -} - - /** * Cast an unsigned int to a pointer. */ diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 940a1b760c..5e9a3417a6 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -511,3 +511,73 @@ _eglCreatePbufferFromClientBuffer(_EGLDriver *drv, _EGLDisplay *dpy, } #endif /* EGL_VERSION_1_2 */ + + +/** + * Link a surface to a display and return the handle of the link. + * The handle can be passed to client directly. + */ +EGLSurface +_eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy) +{ + surf->Display = dpy; + surf->Next = dpy->SurfaceList; + dpy->SurfaceList = surf; + return (EGLSurface) surf; +} + + +/** + * Unlink a linked surface from its display. + * Accessing an unlinked surface should generate EGL_BAD_SURFACE error. + */ +void +_eglUnlinkSurface(_EGLSurface *surf) +{ + _EGLSurface *prev; + + prev = surf->Display->SurfaceList; + if (prev != surf) { + while (prev) { + if (prev->Next == surf) + break; + prev = prev->Next; + } + assert(prev); + prev->Next = surf->Next; + } + else { + prev = NULL; + surf->Display->SurfaceList = surf->Next; + } + + surf->Next = NULL; + surf->Display = NULL; +} + + +#ifndef _EGL_SKIP_HANDLE_CHECK + + +/** + * Return EGL_TRUE if the given handle is a valid handle to a surface. + */ +EGLBoolean +_eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy) +{ + _EGLSurface *cur = NULL; + + if (dpy) + cur = dpy->SurfaceList; + while (cur) { + if (cur == (_EGLSurface *) surf) { + assert(cur->Display == dpy); + break; + } + cur = cur->Next; + } + return (cur != NULL); +} + + +#endif /* !_EGL_SKIP_HANDLE_CHECK */ diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h index dacdf7e63c..b1163293fe 100644 --- a/src/egl/main/eglsurface.h +++ b/src/egl/main/eglsurface.h @@ -111,4 +111,67 @@ _eglIsSurfaceBound(_EGLSurface *surf) } +extern EGLSurface +_eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy); + + +extern void +_eglUnlinkSurface(_EGLSurface *surf); + + +#ifndef _EGL_SKIP_HANDLE_CHECK + + +extern EGLBoolean +_eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy); + + +#else /* !_EGL_SKIP_HANDLE_CHECK */ + + +static INLINE EGLBoolean +_eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy) +{ + _EGLSurface *s = (_EGLSurface *) surf; + return (dpy && s && s->Display == dpy); +} + + +#endif /* _EGL_SKIP_HANDLE_CHECK */ + + +/** + * Lookup a handle to find the linked surface. + * Return NULL if the handle has no corresponding linked surface. + */ +static INLINE _EGLSurface * +_eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy) +{ + _EGLSurface *surf = (_EGLSurface *) surface; + if (!_eglCheckSurfaceHandle(surf, dpy)) + surf = NULL; + return surf; +} + + +/** + * Return the handle of a linked surface, or EGL_NO_SURFACE. + */ +static INLINE EGLSurface +_eglGetSurfaceHandle(_EGLSurface *surf) +{ + return (EGLSurface) ((surf && surf->Display) ? surf : EGL_NO_SURFACE); +} + + +/** + * Return true if the surface is linked to a display. + */ +static INLINE EGLBoolean +_eglIsSurfaceLinked(_EGLSurface *surf) +{ + return (EGLBoolean) (_eglGetSurfaceHandle(surf) != EGL_NO_SURFACE); +} + + #endif /* EGLSURFACE_INCLUDED */ -- cgit v1.2.3 From 7abf42626fe8552cf898652134f3767e591614ab Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 24 Jan 2010 20:30:04 +0800 Subject: egl: Add _EGLResource and _EGLResourceType. Resources are objects managed by a display. They can be linked to or unlinked from a display. It is also possible to check if a resource is valid. --- src/egl/main/egldisplay.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++ src/egl/main/egldisplay.h | 49 +++++++++++++++++++++++++++++++++++++ src/egl/main/egltypedefs.h | 4 ++++ 3 files changed, 113 insertions(+) diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index 79efa8477e..ef144f7f07 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -205,4 +205,64 @@ _eglCheckDisplayHandle(EGLDisplay dpy) } +/** + * Return EGL_TRUE if the given resource is valid. That is, the display does + * own the resource. + */ +EGLBoolean +_eglCheckResource(_EGLResource *res, _EGLResourceType type, _EGLDisplay *dpy) +{ + _EGLResource *list = dpy->ResourceLists[type]; + + while (list) { + if (res == list) { + assert(list->Display == dpy); + break; + } + list = list->Next; + } + + return (list != NULL); +} + + #endif /* !_EGL_SKIP_HANDLE_CHECK */ + + +/** + * Link a resource to a display. + */ +void +_eglLinkResource(_EGLResource *res, _EGLResourceType type, _EGLDisplay *dpy) +{ + res->Display = dpy; + res->Next = dpy->ResourceLists[type]; + dpy->ResourceLists[type] = res; +} + + +/** + * Unlink a linked resource from its display. + */ +void +_eglUnlinkResource(_EGLResource *res, _EGLResourceType type) +{ + _EGLResource *prev; + + prev = res->Display->ResourceLists[type]; + if (prev != res) { + while (prev) { + if (prev->Next == res) + break; + prev = prev->Next; + } + assert(prev); + prev->Next = res->Next; + } + else { + res->Display->ResourceLists[type] = res->Next; + } + + res->Next = NULL; + res->Display = NULL; +} diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 77458cb38d..c1069d7c59 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -5,6 +5,24 @@ #include "egldefines.h" +enum _egl_resource_type { + _EGL_RESOURCE_CONTEXT, + _EGL_RESOURCE_SURFACE, + + _EGL_NUM_RESOURCES +}; + + +/** + * A resource of a display. + */ +struct _egl_resource +{ + _EGLDisplay *Display; + _EGLResource *Next; +}; + + /** * Optional EGL extensions info. */ @@ -48,6 +66,8 @@ struct _egl_display /* lists of linked contexts and surface */ _EGLContext *ContextList; _EGLSurface *SurfaceList; + + _EGLResource *ResourceLists[_EGL_NUM_RESOURCES]; }; @@ -86,6 +106,10 @@ extern EGLBoolean _eglCheckDisplayHandle(EGLDisplay dpy); +extern EGLBoolean +_eglCheckResource(_EGLResource *res, _EGLResourceType type, _EGLDisplay *dpy); + + #else /* !_EGL_SKIP_HANDLE_CHECK */ /* Only do a quick check. This is NOT standard compliant. */ @@ -97,6 +121,13 @@ _eglCheckDisplayHandle(EGLDisplay dpy) } +static INLINE EGLBoolean +_eglCheckResource(_EGLResource *res, _EGLResourceType type, _EGLDisplay *dpy) +{ + return (res->Display == dpy); +} + + #endif /* _EGL_SKIP_HANDLE_CHECK */ @@ -134,6 +165,24 @@ _eglIsDisplayLinked(_EGLDisplay *dpy) } +extern void +_eglLinkResource(_EGLResource *res, _EGLResourceType type, _EGLDisplay *dpy); + + +extern void +_eglUnlinkResource(_EGLResource *res, _EGLResourceType type); + + +/** + * Return true if the resource is linked. + */ +static INLINE EGLBoolean +_eglIsResourceLinked(_EGLResource *res) +{ + return (res->Display != NULL); +} + + /** * Cast an unsigned int to a pointer. */ diff --git a/src/egl/main/egltypedefs.h b/src/egl/main/egltypedefs.h index 4461440b9b..a49ffbb0cd 100644 --- a/src/egl/main/egltypedefs.h +++ b/src/egl/main/egltypedefs.h @@ -8,6 +8,8 @@ #include "eglcompiler.h" +typedef enum _egl_resource_type _EGLResourceType; + typedef struct _egl_api _EGLAPI; typedef struct _egl_config _EGLConfig; @@ -22,6 +24,8 @@ typedef struct _egl_extensions _EGLExtensions; typedef struct _egl_mode _EGLMode; +typedef struct _egl_resource _EGLResource; + typedef struct _egl_screen _EGLScreen; typedef struct _egl_surface _EGLSurface; -- cgit v1.2.3 From ecb3b3102a3022e31cf9d75ae099eddbe298517f Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 24 Jan 2010 20:32:34 +0800 Subject: egl: Make surfaces and contexts resources. Turn _EGLSurface and _EGLContext into _EGLResource so that they can be managed uniformly. --- src/egl/main/eglapi.c | 6 +-- src/egl/main/eglcontext.c | 69 ------------------------ src/egl/main/eglcontext.h | 56 ++++++++++---------- src/egl/main/eglcurrent.c | 2 +- src/egl/main/egldisplay.c | 34 ++++++------ src/egl/main/egldisplay.h | 5 +- src/egl/main/eglsurface.c | 70 ------------------------- src/egl/main/eglsurface.h | 56 ++++++++++---------- src/gallium/state_trackers/egl/common/egl_g3d.c | 2 +- 9 files changed, 79 insertions(+), 221 deletions(-) diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 6e8f444d7f..26ed45c6fe 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -526,7 +526,7 @@ eglSwapInterval(EGLDisplay dpy, EGLint interval) _EGLSurface *surf; _EGL_DECLARE_DD(dpy); - if (!ctx || !_eglIsContextLinked(ctx) || ctx->Display != disp) + if (!ctx || !_eglIsContextLinked(ctx) || ctx->Resource.Display != disp) return _eglError(EGL_BAD_CONTEXT, __FUNCTION__); surf = ctx->DrawSurface; @@ -573,7 +573,7 @@ eglWaitClient(void) return _eglError(EGL_BAD_CURRENT_SURFACE, __FUNCTION__); /* a valid current context implies an initialized current display */ - disp = ctx->Display; + disp = ctx->Resource.Display; drv = disp->Driver; assert(drv); @@ -617,7 +617,7 @@ eglWaitNative(EGLint engine) return _eglError(EGL_BAD_CURRENT_SURFACE, __FUNCTION__); /* a valid current context implies an initialized current display */ - disp = ctx->Display; + disp = ctx->Resource.Display; drv = disp->Driver; assert(drv); diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index 41960f5426..ee4b1b59f5 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -251,72 +251,3 @@ _eglCopyContextMESA(_EGLDriver *drv, EGLDisplay dpy, EGLContext source, */ return EGL_FALSE; } - - -/** - * Link a context to a display and return the handle of the link. - * The handle can be passed to client directly. - */ -EGLContext -_eglLinkContext(_EGLContext *ctx, _EGLDisplay *dpy) -{ - ctx->Display = dpy; - ctx->Next = dpy->ContextList; - dpy->ContextList = ctx; - return (EGLContext) ctx; -} - - -/** - * Unlink a linked context from its display. - * Accessing an unlinked context should generate EGL_BAD_CONTEXT error. - */ -void -_eglUnlinkContext(_EGLContext *ctx) -{ - _EGLContext *prev; - - prev = ctx->Display->ContextList; - if (prev != ctx) { - while (prev) { - if (prev->Next == ctx) - break; - prev = prev->Next; - } - assert(prev); - prev->Next = ctx->Next; - } - else { - ctx->Display->ContextList = ctx->Next; - } - - ctx->Next = NULL; - ctx->Display = NULL; -} - - -#ifndef _EGL_SKIP_HANDLE_CHECK - - -/** - * Return EGL_TRUE if the given handle is a valid handle to a context. - */ -EGLBoolean -_eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy) -{ - _EGLContext *cur = NULL; - - if (dpy) - cur = dpy->ContextList; - while (cur) { - if (cur == (_EGLContext *) ctx) { - assert(cur->Display == dpy); - break; - } - cur = cur->Next; - } - return (cur != NULL); -} - - -#endif /* !_EGL_SKIP_HANDLE_CHECK */ diff --git a/src/egl/main/eglcontext.h b/src/egl/main/eglcontext.h index 0dcec92488..b81dc1ed82 100644 --- a/src/egl/main/eglcontext.h +++ b/src/egl/main/eglcontext.h @@ -4,6 +4,7 @@ #include "egltypedefs.h" +#include "egldisplay.h" /** @@ -11,9 +12,8 @@ */ struct _egl_context { - /* Managed by EGLDisplay for linking */ - _EGLDisplay *Display; - _EGLContext *Next; + /* A context is a display resource */ + _EGLResource Resource; /* The bound status of the context */ _EGLThreadInfo *Binding; @@ -65,33 +65,27 @@ _eglIsContextBound(_EGLContext *ctx) } -extern EGLContext -_eglLinkContext(_EGLContext *ctx, _EGLDisplay *dpy); - - -extern void -_eglUnlinkContext(_EGLContext *ctx); - - -#ifndef _EGL_SKIP_HANDLE_CHECK - - -extern EGLBoolean -_eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy); - - -#else /* !_EGL_SKIP_HANDLE_CHECK */ - - -static INLINE EGLBoolean -_eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy) +/** + * Link a context to a display and return the handle of the link. + * The handle can be passed to client directly. + */ +static INLINE EGLContext +_eglLinkContext(_EGLContext *ctx, _EGLDisplay *dpy) { - _EGLContext *c = (_EGLContext *) ctx; - return (dpy && c && c->Display == dpy); + _eglLinkResource(&ctx->Resource, _EGL_RESOURCE_CONTEXT, dpy); + return (EGLContext) ctx; } -#endif /* _EGL_SKIP_HANDLE_CHECK */ +/** + * Unlink a linked context from its display. + * Accessing an unlinked context should generate EGL_BAD_CONTEXT error. + */ +static INLINE void +_eglUnlinkContext(_EGLContext *ctx) +{ + _eglUnlinkResource(&ctx->Resource, _EGL_RESOURCE_CONTEXT); +} /** @@ -101,8 +95,9 @@ _eglCheckContextHandle(EGLContext ctx, _EGLDisplay *dpy) static INLINE _EGLContext * _eglLookupContext(EGLContext context, _EGLDisplay *dpy) { + _EGLResource *res = (_EGLResource *) context; _EGLContext *ctx = (_EGLContext *) context; - if (!_eglCheckContextHandle(context, dpy)) + if (!res || !dpy || !_eglCheckResource(res, _EGL_RESOURCE_CONTEXT, dpy)) ctx = NULL; return ctx; } @@ -114,7 +109,9 @@ _eglLookupContext(EGLContext context, _EGLDisplay *dpy) static INLINE EGLContext _eglGetContextHandle(_EGLContext *ctx) { - return (EGLContext) ((ctx && ctx->Display) ? ctx : EGL_NO_CONTEXT); + _EGLResource *res = (_EGLResource *) ctx; + return (res && _eglIsResourceLinked(res)) ? + (EGLContext) ctx : EGL_NO_CONTEXT; } @@ -124,7 +121,8 @@ _eglGetContextHandle(_EGLContext *ctx) static INLINE EGLBoolean _eglIsContextLinked(_EGLContext *ctx) { - return (EGLBoolean) (_eglGetContextHandle(ctx) != EGL_NO_CONTEXT); + _EGLResource *res = (_EGLResource *) ctx; + return (res && _eglIsResourceLinked(res)); } diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c index df506151b5..f91631240f 100644 --- a/src/egl/main/eglcurrent.c +++ b/src/egl/main/eglcurrent.c @@ -246,7 +246,7 @@ _eglGetCurrentDisplay(void) _EGLThreadInfo *t = _eglGetCurrentThread(); _EGLContext *ctx = t->CurrentContexts[t->CurrentAPIIndex]; if (ctx) - return ctx->Display; + return ctx->Resource.Display; else return NULL; } diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index ef144f7f07..c978adb47f 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -26,12 +26,18 @@ _eglFiniDisplay(void) /* atexit function is called with global mutex locked */ dpyList = _eglGlobal.DisplayList; while (dpyList) { + EGLint i; + /* pop list head */ dpy = dpyList; dpyList = dpyList->Next; - if (dpy->ContextList || dpy->SurfaceList) - _eglLog(_EGL_DEBUG, "Display %p is destroyed with resources", dpy); + for (i = 0; i < _EGL_NUM_RESOURCES; i++) { + if (dpy->ResourceLists[i]) { + _eglLog(_EGL_DEBUG, "Display %p is destroyed with resources", dpy); + break; + } + } free(dpy); } @@ -135,29 +141,27 @@ _eglFindDisplay(NativeDisplayType nativeDisplay) void _eglReleaseDisplayResources(_EGLDriver *drv, _EGLDisplay *display) { - _EGLContext *contexts; - _EGLSurface *surfaces; - - contexts = display->ContextList; - surfaces = display->SurfaceList; + _EGLResource *list; - while (contexts) { - _EGLContext *ctx = contexts; - contexts = contexts->Next; + list = display->ResourceLists[_EGL_RESOURCE_CONTEXT]; + while (list) { + _EGLContext *ctx = (_EGLContext *) list; + list = list->Next; _eglUnlinkContext(ctx); drv->API.DestroyContext(drv, display, ctx); } - assert(!display->ContextList); + assert(!display->ResourceLists[_EGL_RESOURCE_CONTEXT]); - while (surfaces) { - _EGLSurface *surf = surfaces; - surfaces = surfaces->Next; + list = display->ResourceLists[_EGL_RESOURCE_SURFACE]; + while (list) { + _EGLSurface *surf = (_EGLSurface *) list; + list = list->Next; _eglUnlinkSurface(surf); drv->API.DestroySurface(drv, display, surf); } - assert(!display->SurfaceList); + assert(!display->ResourceLists[_EGL_RESOURCE_SURFACE]); } diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index c1069d7c59..60ed7bcc03 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -63,10 +63,7 @@ struct _egl_display EGLint NumConfigs; _EGLConfig **Configs; /* array [NumConfigs] of ptr to _EGLConfig */ - /* lists of linked contexts and surface */ - _EGLContext *ContextList; - _EGLSurface *SurfaceList; - + /* lists of resources */ _EGLResource *ResourceLists[_EGL_NUM_RESOURCES]; }; diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 5e9a3417a6..940a1b760c 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -511,73 +511,3 @@ _eglCreatePbufferFromClientBuffer(_EGLDriver *drv, _EGLDisplay *dpy, } #endif /* EGL_VERSION_1_2 */ - - -/** - * Link a surface to a display and return the handle of the link. - * The handle can be passed to client directly. - */ -EGLSurface -_eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy) -{ - surf->Display = dpy; - surf->Next = dpy->SurfaceList; - dpy->SurfaceList = surf; - return (EGLSurface) surf; -} - - -/** - * Unlink a linked surface from its display. - * Accessing an unlinked surface should generate EGL_BAD_SURFACE error. - */ -void -_eglUnlinkSurface(_EGLSurface *surf) -{ - _EGLSurface *prev; - - prev = surf->Display->SurfaceList; - if (prev != surf) { - while (prev) { - if (prev->Next == surf) - break; - prev = prev->Next; - } - assert(prev); - prev->Next = surf->Next; - } - else { - prev = NULL; - surf->Display->SurfaceList = surf->Next; - } - - surf->Next = NULL; - surf->Display = NULL; -} - - -#ifndef _EGL_SKIP_HANDLE_CHECK - - -/** - * Return EGL_TRUE if the given handle is a valid handle to a surface. - */ -EGLBoolean -_eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy) -{ - _EGLSurface *cur = NULL; - - if (dpy) - cur = dpy->SurfaceList; - while (cur) { - if (cur == (_EGLSurface *) surf) { - assert(cur->Display == dpy); - break; - } - cur = cur->Next; - } - return (cur != NULL); -} - - -#endif /* !_EGL_SKIP_HANDLE_CHECK */ diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h index b1163293fe..da07133c2c 100644 --- a/src/egl/main/eglsurface.h +++ b/src/egl/main/eglsurface.h @@ -3,6 +3,7 @@ #include "egltypedefs.h" +#include "egldisplay.h" /** @@ -10,9 +11,8 @@ */ struct _egl_surface { - /* Managed by EGLDisplay for linking */ - _EGLDisplay *Display; - _EGLSurface *Next; + /* A surface is a display resource */ + _EGLResource Resource; /* The bound status of the surface */ _EGLContext *Binding; @@ -111,33 +111,27 @@ _eglIsSurfaceBound(_EGLSurface *surf) } -extern EGLSurface -_eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy); - - -extern void -_eglUnlinkSurface(_EGLSurface *surf); - - -#ifndef _EGL_SKIP_HANDLE_CHECK - - -extern EGLBoolean -_eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy); - - -#else /* !_EGL_SKIP_HANDLE_CHECK */ - - -static INLINE EGLBoolean -_eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy) +/** + * Link a surface to a display and return the handle of the link. + * The handle can be passed to client directly. + */ +static INLINE EGLSurface +_eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy) { - _EGLSurface *s = (_EGLSurface *) surf; - return (dpy && s && s->Display == dpy); + _eglLinkResource(&surf->Resource, _EGL_RESOURCE_SURFACE, dpy); + return (EGLSurface) surf; } -#endif /* _EGL_SKIP_HANDLE_CHECK */ +/** + * Unlink a linked surface from its display. + * Accessing an unlinked surface should generate EGL_BAD_SURFACE error. + */ +static INLINE void +_eglUnlinkSurface(_EGLSurface *surf) +{ + _eglUnlinkResource(&surf->Resource, _EGL_RESOURCE_SURFACE); +} /** @@ -147,8 +141,9 @@ _eglCheckSurfaceHandle(EGLSurface surf, _EGLDisplay *dpy) static INLINE _EGLSurface * _eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy) { + _EGLResource *res = (_EGLResource *) surface; _EGLSurface *surf = (_EGLSurface *) surface; - if (!_eglCheckSurfaceHandle(surf, dpy)) + if (!res || !dpy || !_eglCheckResource(res, _EGL_RESOURCE_SURFACE, dpy)) surf = NULL; return surf; } @@ -160,7 +155,9 @@ _eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy) static INLINE EGLSurface _eglGetSurfaceHandle(_EGLSurface *surf) { - return (EGLSurface) ((surf && surf->Display) ? surf : EGL_NO_SURFACE); + _EGLResource *res = (_EGLResource *) surf; + return (res && _eglIsResourceLinked(res)) ? + (EGLSurface) surf : EGL_NO_SURFACE; } @@ -170,7 +167,8 @@ _eglGetSurfaceHandle(_EGLSurface *surf) static INLINE EGLBoolean _eglIsSurfaceLinked(_EGLSurface *surf) { - return (EGLBoolean) (_eglGetSurfaceHandle(surf) != EGL_NO_SURFACE); + _EGLResource *res = (_EGLResource *) surf; + return (res && _eglIsResourceLinked(res)); } diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index 2ac6215646..dc26f95cee 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -543,7 +543,7 @@ egl_g3d_update_buffer(struct pipe_screen *screen, void *context_private) * Set force_validate to skip an unnecessary check. */ gctx->force_validate = EGL_TRUE; - egl_g3d_validate_context(gctx->base.Display, &gctx->base); + egl_g3d_validate_context(gctx->base.Resource.Display, &gctx->base); } static EGLBoolean -- cgit v1.2.3 From 56b93a25ea5c573587ac699bf6806fe530f81b2f Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 24 Jan 2010 20:21:23 +0800 Subject: egl: Remove unused casting functions. _eglUIntToPointer and _eglPointerToUInt are no longer used. --- src/egl/main/egldisplay.h | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 60ed7bcc03..b13ce08261 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -180,25 +180,4 @@ _eglIsResourceLinked(_EGLResource *res) } -/** - * Cast an unsigned int to a pointer. - */ -static INLINE void * -_eglUIntToPointer(unsigned int v) -{ - return (void *) ((uintptr_t) v); -} - - -/** - * Cast a pointer to an unsigned int. The pointer must be one that is - * returned by _eglUIntToPointer. - */ -static INLINE unsigned int -_eglPointerToUInt(const void *p) -{ - return (unsigned int) ((uintptr_t) p); -} - - #endif /* EGLDISPLAY_INCLUDED */ -- cgit v1.2.3 From cf7c1ea4f1a805a3b6003808aa0b034603412870 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 24 Jan 2010 20:44:39 +0800 Subject: egl: Remove unused helper functions. _eglFillInConfigs and _eglFindAPIs have no user in Mesa and are unlikely to find one soon. It should be fine to remove them. --- src/egl/main/eglconfigutil.c | 207 ------------------------------------------- src/egl/main/eglconfigutil.h | 10 --- 2 files changed, 217 deletions(-) diff --git a/src/egl/main/eglconfigutil.c b/src/egl/main/eglconfigutil.c index 36e94f0d2d..9cf94b3c4a 100644 --- a/src/egl/main/eglconfigutil.c +++ b/src/egl/main/eglconfigutil.c @@ -128,210 +128,3 @@ _eglConfigFromContextModesRec(_EGLConfig *conf, const __GLcontextModes *m, return EGL_TRUE; } - - -/** - * Creates a set of \c _EGLConfigs that a driver will expose. - * - * A set of \c __GLcontextModes will be created based on the supplied - * parameters. The number of modes processed will be 2 * - * \c num_depth_stencil_bits * \c num_db_modes. - * - * For the most part, data is just copied from \c depth_bits, \c stencil_bits, - * \c db_modes, and \c visType into each \c __GLcontextModes element. - * However, the meanings of \c fb_format and \c fb_type require further - * explanation. The \c fb_format specifies which color components are in - * each pixel and what the default order is. For example, \c GL_RGB specifies - * that red, green, blue are available and red is in the "most significant" - * position and blue is in the "least significant". The \c fb_type specifies - * the bit sizes of each component and the actual ordering. For example, if - * \c GL_UNSIGNED_SHORT_5_6_5_REV is specified with \c GL_RGB, bits [15:11] - * are the blue value, bits [10:5] are the green value, and bits [4:0] are - * the red value. - * - * One sublte issue is the combination of \c GL_RGB or \c GL_BGR and either - * of the \c GL_UNSIGNED_INT_8_8_8_8 modes. The resulting mask values in the - * \c __GLcontextModes structure is \b identical to the \c GL_RGBA or - * \c GL_BGRA case, except the \c alphaMask is zero. This means that, as - * far as this routine is concerned, \c GL_RGB with \c GL_UNSIGNED_INT_8_8_8_8 - * still uses 32-bits. - * - * If in doubt, look at the tables used in the function. - * - * \param configs the array of configs generated - * \param fb_format Format of the framebuffer. Currently only \c GL_RGB, - * \c GL_RGBA, \c GL_BGR, and \c GL_BGRA are supported. - * \param fb_type Type of the pixels in the framebuffer. Currently only - * \c GL_UNSIGNED_SHORT_5_6_5, - * \c GL_UNSIGNED_SHORT_5_6_5_REV, - * \c GL_UNSIGNED_INT_8_8_8_8, and - * \c GL_UNSIGNED_INT_8_8_8_8_REV are supported. - * \param depth_bits Array of depth buffer sizes to be exposed. - * \param stencil_bits Array of stencil buffer sizes to be exposed. - * \param num_depth_stencil_bits Number of entries in both \c depth_bits and - * \c stencil_bits. - * \param db_modes Array of buffer swap modes. If an element has a - * value of \c GLX_NONE, then it represents a - * single-buffered mode. Other valid values are - * \c GLX_SWAP_EXCHANGE_OML, \c GLX_SWAP_COPY_OML, and - * \c GLX_SWAP_UNDEFINED_OML. See the - * GLX_OML_swap_method extension spec for more details. - * \param num_db_modes Number of entries in \c db_modes. - * \param visType GLX visual type. Usually either \c GLX_TRUE_COLOR or - * \c GLX_DIRECT_COLOR. - * - * \returns - * \c GL_TRUE on success or \c GL_FALSE on failure. Currently the only - * cause of failure is a bad parameter (i.e., unsupported \c fb_format or - * \c fb_type). - * - * \todo - * There is currently no way to support packed RGB modes (i.e., modes with - * exactly 3 bytes per pixel) or floating-point modes. This could probably - * be done by creating some new, private enums with clever names likes - * \c GL_UNSIGNED_3BYTE_8_8_8, \c GL_4FLOAT_32_32_32_32, - * \c GL_4HALF_16_16_16_16, etc. We can cross that bridge when we come to it. - */ -EGLBoolean -_eglFillInConfigs(_EGLConfig * configs, - GLenum fb_format, GLenum fb_type, - const uint8_t * depth_bits, const uint8_t * stencil_bits, - unsigned num_depth_stencil_bits, - const GLenum * db_modes, unsigned num_db_modes, - int visType) -{ - static const uint8_t bits_table[3][4] = { - /* R G B A */ - { 5, 6, 5, 0 }, /* Any GL_UNSIGNED_SHORT_5_6_5 */ - { 8, 8, 8, 0 }, /* Any RGB with any GL_UNSIGNED_INT_8_8_8_8 */ - { 8, 8, 8, 8 } /* Any RGBA with any GL_UNSIGNED_INT_8_8_8_8 */ - }; - - /* The following arrays are all indexed by the fb_type masked with 0x07. - * Given the four supported fb_type values, this results in valid array - * indices of 3, 4, 5, and 7. - */ - static const uint32_t masks_table_rgb[8][4] = { - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000F800, 0x000007E0, 0x0000001F, 0x00000000}, /* 5_6_5 */ - {0x0000001F, 0x000007E0, 0x0000F800, 0x00000000}, /* 5_6_5_REV */ - {0xFF000000, 0x00FF0000, 0x0000FF00, 0x00000000}, /* 8_8_8_8 */ - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000} /* 8_8_8_8_REV */ - }; - - static const uint32_t masks_table_rgba[8][4] = { - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000F800, 0x000007E0, 0x0000001F, 0x00000000}, /* 5_6_5 */ - {0x0000001F, 0x000007E0, 0x0000F800, 0x00000000}, /* 5_6_5_REV */ - {0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF}, /* 8_8_8_8 */ - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000}, /* 8_8_8_8_REV */ - }; - -#if 0 - static const uint32_t masks_table_bgr[8][4] = { - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000001F, 0x000007E0, 0x0000F800, 0x00000000}, /* 5_6_5 */ - {0x0000F800, 0x000007E0, 0x0000001F, 0x00000000}, /* 5_6_5_REV */ - {0x0000FF00, 0x00FF0000, 0xFF000000, 0x00000000}, /* 8_8_8_8 */ - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000}, /* 8_8_8_8_REV */ - }; - - static const uint32_t masks_table_bgra[8][4] = { - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x0000001F, 0x000007E0, 0x0000F800, 0x00000000}, /* 5_6_5 */ - {0x0000F800, 0x000007E0, 0x0000001F, 0x00000000}, /* 5_6_5_REV */ - {0x0000FF00, 0x00FF0000, 0xFF000000, 0x000000FF}, /* 8_8_8_8 */ - {0x00000000, 0x00000000, 0x00000000, 0x00000000}, - {0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000}, /* 8_8_8_8_REV */ - }; -#endif - - static const uint8_t bytes_per_pixel[8] = { - 0, 0, 0, 2, 2, 4, 0, 4 - }; - - const uint8_t * bits; - const uint32_t * masks; - const int index = fb_type & 0x07; - _EGLConfig *config; - unsigned i; - unsigned j; - unsigned k; - - if ( bytes_per_pixel[index] == 0 ) { - _eglLog(_EGL_INFO, - "[_eglFillInConfigs:%u] Framebuffer type 0x%04x has 0 bytes per pixel.", - __LINE__, fb_type); - return GL_FALSE; - } - - /* Valid types are GL_UNSIGNED_SHORT_5_6_5 and GL_UNSIGNED_INT_8_8_8_8 and - * the _REV versions. - * - * Valid formats are GL_RGBA, GL_RGB, and GL_BGRA. - */ - switch ( fb_format ) { - case GL_RGB: - bits = (bytes_per_pixel[index] == 2) ? bits_table[0] : bits_table[1]; - masks = masks_table_rgb[index]; - break; - - case GL_RGBA: - bits = (bytes_per_pixel[index] == 2) ? bits_table[0] : bits_table[2]; - masks = masks_table_rgba[index]; - break; - -#if 0 - case GL_BGR: - bits = (bytes_per_pixel[index] == 2) ? bits_table[0] : bits_table[1]; - masks = masks_table_bgr[index]; - break; - - case GL_BGRA: - bits = (bytes_per_pixel[index] == 2) ? bits_table[0] : bits_table[2]; - masks = masks_table_bgra[index]; - break; -#endif - - default: - _eglLog(_EGL_WARNING, - "[_eglFillInConfigs:%u] Framebuffer format 0x%04x is not GL_RGB, GL_RGBA, GL_BGR, or GL_BGRA.", - __LINE__, fb_format); - return GL_FALSE; - } - - config = configs; - for (k = 0; k < num_depth_stencil_bits; k++) { - for (i = 0; i < num_db_modes; i++) { - for (j = 0; j < 2; j++) { - _eglSetConfigAttrib(config, EGL_RED_SIZE, bits[0]); - _eglSetConfigAttrib(config, EGL_GREEN_SIZE, bits[1]); - _eglSetConfigAttrib(config, EGL_BLUE_SIZE, bits[2]); - _eglSetConfigAttrib(config, EGL_ALPHA_SIZE, bits[3]); - _eglSetConfigAttrib(config, EGL_BUFFER_SIZE, - bits[0] + bits[1] + bits[2] + bits[3]); - - _eglSetConfigAttrib(config, EGL_STENCIL_SIZE, stencil_bits[k]); - _eglSetConfigAttrib(config, EGL_DEPTH_SIZE, depth_bits[i]); - - _eglSetConfigAttrib(config, EGL_SURFACE_TYPE, EGL_SCREEN_BIT_MESA | - EGL_PBUFFER_BIT | EGL_PIXMAP_BIT | EGL_WINDOW_BIT); - - config++; - } - } - } - return GL_TRUE; -} - diff --git a/src/egl/main/eglconfigutil.h b/src/egl/main/eglconfigutil.h index 9f8906dedb..c6f4819960 100644 --- a/src/egl/main/eglconfigutil.h +++ b/src/egl/main/eglconfigutil.h @@ -16,14 +16,4 @@ _eglConfigFromContextModesRec(_EGLConfig *conf, const __GLcontextModes *m, EGLint conformant, EGLint renderable_type); -PUBLIC EGLBoolean -_eglFillInConfigs( _EGLConfig *configs, - EGLenum fb_format, EGLenum fb_type, - const uint8_t * depth_bits, const uint8_t * stencil_bits, - unsigned num_depth_stencil_bits, - const EGLenum * db_modes, unsigned num_db_modes, - int visType ); - - - #endif /* EGLCONFIGUTIL_INCLUDED */ -- cgit v1.2.3 From cecc33cd4f2b3ae1fa590a450eeaefc9b761fb30 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 24 Jan 2010 20:53:41 +0800 Subject: egl: Remove _eglFindAPIs. This function is not used and should have been removed by last commit. My mistake. --- src/egl/main/egldriver.c | 52 ------------------------------------------------ src/egl/main/egldriver.h | 4 ---- 2 files changed, 56 deletions(-) diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index f890df1bb1..97550ea27c 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -526,58 +526,6 @@ _eglInitDriverFallbacks(_EGLDriver *drv) } - -/** - * Try to determine which EGL APIs (OpenGL, OpenGL ES, OpenVG, etc) - * are supported on the system by looking for standard library names. - */ -EGLint -_eglFindAPIs(void) -{ - EGLint mask = 0x0; - lib_handle lib; -#if defined(_EGL_PLATFORM_WINDOWS) - /* XXX not sure about these names */ - const char *es1_libname = "libGLESv1_CM.dll"; - const char *es2_libname = "libGLESv2.dll"; - const char *gl_libname = "OpenGL32.dll"; - const char *vg_libname = "libOpenVG.dll"; -#elif defined(_EGL_PLATFORM_POSIX) - const char *es1_libname = "libGLESv1_CM.so"; - const char *es2_libname = "libGLESv2.so"; - const char *gl_libname = "libGL.so"; - const char *vg_libname = "libOpenVG.so"; -#else /* _EGL_PLATFORM_NO_OS */ - const char *es1_libname = NULL; - const char *es2_libname = NULL; - const char *gl_libname = NULL; - const char *vg_libname = NULL; -#endif - - if ((lib = open_library(es1_libname))) { - close_library(lib); - mask |= EGL_OPENGL_ES_BIT; - } - - if ((lib = open_library(es2_libname))) { - close_library(lib); - mask |= EGL_OPENGL_ES2_BIT; - } - - if ((lib = open_library(gl_libname))) { - close_library(lib); - mask |= EGL_OPENGL_BIT; - } - - if ((lib = open_library(vg_libname))) { - close_library(lib); - mask |= EGL_OPENVG_BIT; - } - - return mask; -} - - /** * Set the probe cache at the given key. * diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index d9d61297c1..4a1a7ece8c 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -62,10 +62,6 @@ PUBLIC void _eglInitDriverFallbacks(_EGLDriver *drv); -PUBLIC EGLint -_eglFindAPIs(void); - - PUBLIC void _eglSetProbeCache(EGLint key, const void *val); -- cgit v1.2.3 From 21b2c0a6e5ecb6d542bd7d3750c5a0b745104edd Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 24 Jan 2010 21:04:35 +0800 Subject: egl: Add and use make_library_path. Add a platform specific function to turn a library name to a library path. It is used to convert EGL_DRIVER or the default driver to a library path that can be loaded. --- src/egl/main/egldriver.c | 76 +++++++++++++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 27 deletions(-) diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 97550ea27c..d997326729 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -58,6 +58,20 @@ library_suffix(void) } +static EGLBoolean +make_library_path(char *buf, unsigned int size, const char *name) +{ + EGLBoolean need_suffix; + const char *suffix = ".dll"; + int ret; + + need_suffix = (strchr(name, '.') == NULL); + ret = snprintf(buf, size, "%s%s", name, (need_suffix) ? suffix : ""); + + return ((unsigned int) ret < size); +} + + #elif defined(_EGL_PLATFORM_POSIX) @@ -85,6 +99,24 @@ library_suffix(void) } +static EGLBoolean +make_library_path(char *buf, unsigned int size, const char *name) +{ + EGLBoolean need_dir, need_suffix; + const char *suffix = ".so"; + int ret; + + need_dir = (strchr(name, '/') == NULL); + need_suffix = (strchr(name, '.') == NULL); + + ret = snprintf(buf, size, "%s%s%s", + (need_dir) ? _EGL_DRIVER_SEARCH_DIR"/" : "", name, + (need_suffix) ? suffix : ""); + + return ((unsigned int) ret < size); +} + + #else /* _EGL_PLATFORM_NO_OS */ static const char DefaultDriverName[] = "builtin"; @@ -110,6 +142,14 @@ library_suffix(void) } +static EGLBoolean +make_library_path(char *buf, unsigned int size, const char *name) +{ + int ret = snprintf(buf, size, name); + return ((unsigned int) ret < size); +} + + #endif @@ -288,36 +328,21 @@ _eglPreloadUserDriver(void) { #if defined(_EGL_PLATFORM_POSIX) || defined(_EGL_PLATFORM_WINDOWS) _EGLDriver *drv; - char *env, *path; - const char *suffix, *p; + char path[1024]; + char *env; env = getenv("EGL_DRIVER"); if (!env) return EGL_FALSE; - path = env; - suffix = library_suffix(); - - /* append suffix if there isn't */ - p = strrchr(path, '.'); - if (!p && suffix) { - size_t len = strlen(path); - char *tmp = malloc(len + strlen(suffix) + 2); - if (tmp) { - memcpy(tmp, path, len); - tmp[len++] = '.'; - tmp[len] = '\0'; - strcat(tmp + len, suffix); - - path = tmp; - } - } + if (!make_library_path(path, sizeof(path), env)) + return EGL_FALSE; drv = _eglLoadDriver(path, NULL); - if (path != env) - free(path); - if (!drv) + if (!drv) { + _eglLog(_EGL_WARNING, "EGL_DRIVER is set to an invalid driver"); return EGL_FALSE; + } _eglGlobal.Drivers[_eglGlobal.NumDrivers++] = drv; @@ -399,12 +424,9 @@ _eglPreloadDefaultDriver(void) { _EGLDriver *drv; char path[1024]; - const char *suffix = library_suffix(); - if (suffix) - snprintf(path, sizeof(path), "%s.%s", DefaultDriverName, suffix); - else - snprintf(path, sizeof(path), DefaultDriverName); + if (!make_library_path(path, sizeof(path), DefaultDriverName)) + return EGL_FALSE; drv = _eglLoadDriver(path, NULL); if (!drv) -- cgit v1.2.3 From d6fd31a8d47b6cc70b5e64757e1272ccc6594350 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sun, 24 Jan 2010 15:13:17 +0100 Subject: nv50: implement render_condition Still not handling queries on multiple contexts though. --- src/gallium/drivers/nv50/nv50_query.c | 40 +++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_query.c b/src/gallium/drivers/nv50/nv50_query.c index 5a4ab3508b..9eba4c9611 100644 --- a/src/gallium/drivers/nv50/nv50_query.c +++ b/src/gallium/drivers/nv50/nv50_query.c @@ -48,7 +48,7 @@ nv50_query_create(struct pipe_context *pipe, unsigned type) assert (q->type == PIPE_QUERY_OCCLUSION_COUNTER); q->type = type; - ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM | NOUVEAU_BO_MAP, 256, + ret = nouveau_bo_new(dev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, 256, 16, &q->bo); if (ret) { FREE(q); @@ -95,11 +95,13 @@ nv50_query_end(struct pipe_context *pipe, struct pipe_query *pq) MARK_RING (chan, 5, 2); /* flush on lack of space or relocs */ BEGIN_RING(chan, tesla, NV50TCL_QUERY_ADDRESS_HIGH, 4); - OUT_RELOCh(chan, q->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); - OUT_RELOCl(chan, q->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR); + OUT_RELOCh(chan, q->bo, 0, NOUVEAU_BO_GART | NOUVEAU_BO_WR); + OUT_RELOCl(chan, q->bo, 0, NOUVEAU_BO_GART | NOUVEAU_BO_WR); OUT_RING (chan, 0x00000000); OUT_RING (chan, 0x0100f002); - FIRE_RING (chan); + + BEGIN_RING(chan, tesla, NV50TCL_SAMPLECNT_ENABLE, 1); + OUT_RING (chan, 0); } static boolean @@ -123,6 +125,35 @@ nv50_query_result(struct pipe_context *pipe, struct pipe_query *pq, return q->ready; } +static void +nv50_render_condition(struct pipe_context *pipe, + struct pipe_query *pq, uint mode) +{ + struct nv50_context *nv50 = nv50_context(pipe); + struct nouveau_channel *chan = nv50->screen->base.channel; + struct nouveau_grobj *tesla = nv50->screen->tesla; + struct nv50_query *q; + + if (!pq) { + BEGIN_RING(chan, tesla, NV50TCL_COND_MODE, 1); + OUT_RING (chan, NV50TCL_COND_MODE_ALWAYS); + return; + } + q = nv50_query(pq); + + if (mode == PIPE_RENDER_COND_WAIT || + mode == PIPE_RENDER_COND_BY_REGION_WAIT) { + /* XXX: big fence, FIFO semaphore might be better */ + BEGIN_RING(chan, tesla, 0x0110, 1); + OUT_RING (chan, 0); + } + + BEGIN_RING(chan, tesla, NV50TCL_COND_ADDRESS_HIGH, 3); + OUT_RELOCh(chan, q->bo, 0, NOUVEAU_BO_GART | NOUVEAU_BO_RD); + OUT_RELOCl(chan, q->bo, 0, NOUVEAU_BO_GART | NOUVEAU_BO_RD); + OUT_RING (chan, NV50TCL_COND_MODE_RES); +} + void nv50_init_query_functions(struct nv50_context *nv50) { @@ -131,4 +162,5 @@ nv50_init_query_functions(struct nv50_context *nv50) nv50->pipe.begin_query = nv50_query_begin; nv50->pipe.end_query = nv50_query_end; nv50->pipe.get_query_result = nv50_query_result; + nv50->pipe.render_condition = nv50_render_condition; } -- cgit v1.2.3 From 49dde55b96f717171a9dc6facd800e1c4be6eedf Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 23 Jan 2010 18:35:27 +0100 Subject: nv50: only flush texture caches on st request --- src/gallium/drivers/nv50/nv50_context.c | 5 +++++ src/gallium/drivers/nv50/nv50_tex.c | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_context.c b/src/gallium/drivers/nv50/nv50_context.c index 1e69746322..e2198b189d 100644 --- a/src/gallium/drivers/nv50/nv50_context.c +++ b/src/gallium/drivers/nv50/nv50_context.c @@ -34,6 +34,11 @@ nv50_flush(struct pipe_context *pipe, unsigned flags, struct nv50_context *nv50 = nv50_context(pipe); struct nouveau_channel *chan = nv50->screen->base.channel; + if (flags & PIPE_FLUSH_TEXTURE_CACHE) { + BEGIN_RING(chan, nv50->screen->tesla, 0x1338, 1); + OUT_RING (chan, 0x20); + } + if (flags & PIPE_FLUSH_FRAME) FIRE_RING(chan); } diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c index 871536dca9..9f1a171303 100644 --- a/src/gallium/drivers/nv50/nv50_tex.c +++ b/src/gallium/drivers/nv50/nv50_tex.c @@ -220,11 +220,8 @@ nv50_tex_validate(struct nv50_context *nv50) return; } - /* not sure if the following really do what I think: */ so_method(so, tesla, 0x1330, 1); /* flush TIC */ so_data (so, 0); - so_method(so, tesla, 0x1338, 1); /* flush texture caches */ - so_data (so, 0x20); so_ref(so, &nv50->state.tic_upload); so_ref(NULL, &so); -- cgit v1.2.3 From 833acea8f6bcbed8b477eb1a1d897127afb0e73e Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sun, 24 Jan 2010 14:22:41 +0100 Subject: nv50: fix handling of FragCoord input --- src/gallium/drivers/nv50/nv50_program.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 20db51070f..cd2fd0a076 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -3728,13 +3728,21 @@ nv50_program_tx_prep(struct nv50_pc *pc) copy_semantic_info(p); } else if (p->type == PIPE_SHADER_FRAGMENT) { - int rid, aid, base; + int rid, aid; unsigned n = 0, m = pc->attr_nr - flat_nr; pc->allow32 = TRUE; - base = (TGSI_SEMANTIC_POSITION == - p->info.input_semantic_name[0]) ? 0 : 1; + /* do we read FragCoord ? */ + if (pc->attr_nr && + p->info.input_semantic_name[0] == TGSI_SEMANTIC_POSITION) { + /* select FCRD components we want accessible */ + for (c = 0; c < 4; ++c) + if (pc->attr[c].acc) + p->cfg.regs[1] |= 1 << (24 + c); + aid = 0; + } else /* offset by 1 if FCRD.w is needed for pinterp */ + aid = popcnt4(p->cfg.regs[1] >> 24); /* non-flat interpolants have to be mapped to * the lower hardware IDs, so sort them: @@ -3750,12 +3758,6 @@ nv50_program_tx_prep(struct nv50_pc *pc) } copy_semantic_info(p); - if (!base) /* set w-coordinate mask from perspective interp */ - p->cfg.in[0].mask |= p->cfg.regs[1] >> 24; - - aid = popcnt4( /* if fcrd isn't contained in cfg.io */ - base ? (p->cfg.regs[1] >> 24) : p->cfg.in[0].mask); - for (n = 0; n < pc->attr_nr; ++n) { p->cfg.in[n].hw = rid = aid; i = p->cfg.in[n].id; @@ -3777,9 +3779,6 @@ nv50_program_tx_prep(struct nv50_pc *pc) aid += popcnt4(p->cfg.in[n].mask); } - if (!base) - p->cfg.regs[1] |= p->cfg.in[0].mask << 24; - m = popcnt4(p->cfg.regs[1] >> 24); /* set count of non-position inputs and of non-flat -- cgit v1.2.3 From 283b21d02bff3d4bd6127f6b642331e06db41ace Mon Sep 17 00:00:00 2001 From: Marcin Slusarz Date: Sun, 17 Jan 2010 23:50:50 +0100 Subject: nouveau: fix winsys object leak --- src/gallium/drivers/nouveau/nouveau_screen.c | 2 ++ src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c index 7ebc94ed6c..1ad539d285 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.c +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -260,6 +260,8 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) void nouveau_screen_fini(struct nouveau_screen *screen) { + struct pipe_winsys *ws = screen->base.winsys; nouveau_channel_free(&screen->channel); + ws->destroy(ws); } diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c index c9f39d815d..29afff6faf 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c @@ -54,6 +54,14 @@ static struct dri1_api nouveau_dri1_api = { nouveau_dri1_front_surface, }; +static void +nouveau_drm_destroy_winsys(struct pipe_winsys *s) +{ + struct nouveau_winsys *nv_winsys = nouveau_winsys(s); + FREE(nv_winsys->pctx); + FREE(nv_winsys); +} + static struct pipe_screen * nouveau_drm_create_screen(struct drm_api *api, int fd, struct drm_create_screen_arg *arg) @@ -105,6 +113,7 @@ nouveau_drm_create_screen(struct drm_api *api, int fd, return NULL; } ws = &nvws->base; + ws->destroy = nouveau_drm_destroy_winsys; nvws->pscreen = init(ws, dev); if (!nvws->pscreen) { -- cgit v1.2.3 From 74989972ba4fd629905799ed2181f8f6f4e53c2b Mon Sep 17 00:00:00 2001 From: Marcin Slusarz Date: Sun, 17 Jan 2010 23:51:22 +0100 Subject: nouveau/winsys: be nice and close the device on destroy --- src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c index 29afff6faf..75cd1e2902 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c @@ -58,6 +58,8 @@ static void nouveau_drm_destroy_winsys(struct pipe_winsys *s) { struct nouveau_winsys *nv_winsys = nouveau_winsys(s); + struct nouveau_screen *nv_screen= nouveau_screen(nv_winsys->pscreen); + nouveau_device_close(&nv_screen->device); FREE(nv_winsys->pctx); FREE(nv_winsys); } -- cgit v1.2.3 From 0ef781c1ae04451ac4f184187e900f872cad5f94 Mon Sep 17 00:00:00 2001 From: Marcin Slusarz Date: Wed, 20 Jan 2010 23:27:07 +0100 Subject: nv50: fix crash in nv50_pre_pipebuffer_map (nv50_screen->cur_ctx) nv50_pre_pipebuffer_map references screen->cur_ctx which points to freed memory after the context is destroyed. This crash is easily triggerable by progs/xdemos/glxcontexts. --- src/gallium/drivers/nv50/nv50_context.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gallium/drivers/nv50/nv50_context.c b/src/gallium/drivers/nv50/nv50_context.c index e2198b189d..5c705ccc8f 100644 --- a/src/gallium/drivers/nv50/nv50_context.c +++ b/src/gallium/drivers/nv50/nv50_context.c @@ -86,6 +86,10 @@ nv50_destroy(struct pipe_context *pipe) so_ref(NULL, &nv50->state.vtxattr); draw_destroy(nv50->draw); + + if (nv50->screen->cur_ctx == nv50) + nv50->screen->cur_ctx = NULL; + FREE(nv50); } -- cgit v1.2.3 From 9e1550dbafe1b28b81dc15822762e6cfe53e3a4b Mon Sep 17 00:00:00 2001 From: Marcin Slusarz Date: Sun, 24 Jan 2010 19:27:59 +0100 Subject: nv50: fix uninitialized variable in nv50_revdep_reorder "unsafe" is never initialized, but used (found by valgrind) --- src/gallium/drivers/nv50/nv50_program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index cd2fd0a076..e74a526c62 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -3283,7 +3283,7 @@ prep_inspect_insn(struct nv50_pc *pc, const struct tgsi_full_instruction *insn) static unsigned nv50_revdep_reorder(unsigned m[4], unsigned rdep[4]) { - unsigned i, c, x, unsafe; + unsigned i, c, x, unsafe = 0; for (c = 0; c < 4; c++) m[c] = c; -- cgit v1.2.3 From fdfa4c85297d5d25e7256bf73e35309b358af86c Mon Sep 17 00:00:00 2001 From: Xavier Chantry Date: Sat, 23 Jan 2010 17:27:21 +0100 Subject: st/mesa: fix unsigned/signed breakage in scissor commit 53174afeeb introduced a portability change that converted GLint x,y to GLuint. That breaks when x and y are negative, which seems to be allowed, and which at least one game uses : teeworlds. Rather than simply reverting the change, it seems possible to convert the 16bit unsigned to GLint so that comparisons are made between signed integers instead. This hopefully does not break anything while keeping MSVC happy. Signed-off-by: Xavier Chantry Signed-off-by: Brian Paul --- src/mesa/state_tracker/st_atom_scissor.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mesa/state_tracker/st_atom_scissor.c b/src/mesa/state_tracker/st_atom_scissor.c index 3fd59e1945..fb666b8546 100644 --- a/src/mesa/state_tracker/st_atom_scissor.c +++ b/src/mesa/state_tracker/st_atom_scissor.c @@ -52,14 +52,14 @@ update_scissor( struct st_context *st ) scissor.maxy = fb->Height; if (st->ctx->Scissor.Enabled) { - if ((GLuint)st->ctx->Scissor.X > scissor.minx) + if (st->ctx->Scissor.X > (GLint)scissor.minx) scissor.minx = st->ctx->Scissor.X; - if ((GLuint)st->ctx->Scissor.Y > scissor.miny) + if (st->ctx->Scissor.Y > (GLint)scissor.miny) scissor.miny = st->ctx->Scissor.Y; - if ((GLuint)st->ctx->Scissor.X + st->ctx->Scissor.Width < scissor.maxx) + if (st->ctx->Scissor.X + st->ctx->Scissor.Width < (GLint)scissor.maxx) scissor.maxx = st->ctx->Scissor.X + st->ctx->Scissor.Width; - if ((GLuint)st->ctx->Scissor.Y + st->ctx->Scissor.Height < scissor.maxy) + if (st->ctx->Scissor.Y + st->ctx->Scissor.Height < (GLint)scissor.maxy) scissor.maxy = st->ctx->Scissor.Y + st->ctx->Scissor.Height; /* check for null space */ -- cgit v1.2.3 From e88d6fe299cb43eedfae7f0fa3bb14c8086a8cd4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sun, 24 Jan 2010 17:54:44 -0700 Subject: mesa: move _mesa_debug() call earlier in _mesa_Scissor Part of a patch from Xavier Chantry --- src/mesa/main/scissor.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/scissor.c b/src/mesa/main/scissor.c index b5f4cde789..523f3c3ab8 100644 --- a/src/mesa/main/scissor.c +++ b/src/mesa/main/scissor.c @@ -37,14 +37,14 @@ _mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height ) GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(ctx, "glScissor %d %d %d %d\n", x, y, width, height); + if (width < 0 || height < 0) { _mesa_error( ctx, GL_INVALID_VALUE, "glScissor" ); return; } - if (MESA_VERBOSE & VERBOSE_API) - _mesa_debug(ctx, "glScissor %d %d %d %d\n", x, y, width, height); - _mesa_set_scissor(ctx, x, y, width, height); } -- cgit v1.2.3 From 47d30b0c2c36f952cc14deefb9f937f1b0a9b531 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sun, 24 Jan 2010 18:18:17 -0700 Subject: st/mesa: fix int->uint conversion for negative scissor bound values Based on a patch by Xavier Chantry : If x+width or y+height is negative, then maxx or maxy will get a bogus value when converting that to unsigned. Fix this by setting 0 as minimal value. This was also triggered by teeworlds, but only with some combination of resolution and map section. For example upper part of dm2 at 1280x1024. --- src/mesa/state_tracker/st_atom_scissor.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/mesa/state_tracker/st_atom_scissor.c b/src/mesa/state_tracker/st_atom_scissor.c index fb666b8546..5e0c51cff0 100644 --- a/src/mesa/state_tracker/st_atom_scissor.c +++ b/src/mesa/state_tracker/st_atom_scissor.c @@ -31,6 +31,7 @@ */ +#include "main/macros.h" #include "st_context.h" #include "pipe/p_context.h" #include "st_atom.h" @@ -52,15 +53,19 @@ update_scissor( struct st_context *st ) scissor.maxy = fb->Height; if (st->ctx->Scissor.Enabled) { + /* need to be careful here with xmax or ymax < 0 */ + GLint xmax = MAX2(0, st->ctx->Scissor.X + st->ctx->Scissor.Width); + GLint ymax = MAX2(0, st->ctx->Scissor.Y + st->ctx->Scissor.Height); + if (st->ctx->Scissor.X > (GLint)scissor.minx) scissor.minx = st->ctx->Scissor.X; if (st->ctx->Scissor.Y > (GLint)scissor.miny) scissor.miny = st->ctx->Scissor.Y; - if (st->ctx->Scissor.X + st->ctx->Scissor.Width < (GLint)scissor.maxx) - scissor.maxx = st->ctx->Scissor.X + st->ctx->Scissor.Width; - if (st->ctx->Scissor.Y + st->ctx->Scissor.Height < (GLint)scissor.maxy) - scissor.maxy = st->ctx->Scissor.Y + st->ctx->Scissor.Height; + if (xmax < (GLint) scissor.maxx) + scissor.maxx = xmax; + if (ymax < (GLint) scissor.maxy) + scissor.maxy = ymax; /* check for null space */ if (scissor.minx >= scissor.maxx || scissor.miny >= scissor.maxy) -- cgit v1.2.3 From daea9270f877e3f32ef93f71ffa2d27dac4162b4 Mon Sep 17 00:00:00 2001 From: Igor Oliveira Date: Sun, 24 Jan 2010 12:26:31 -0400 Subject: egl: check if driver_name is null --- src/gallium/state_trackers/egl/x11/native_x11.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/egl/x11/native_x11.c b/src/gallium/state_trackers/egl/x11/native_x11.c index 695ab88010..dd3c9f8b6a 100644 --- a/src/gallium/state_trackers/egl/x11/native_x11.c +++ b/src/gallium/state_trackers/egl/x11/native_x11.c @@ -70,7 +70,8 @@ native_create_probe(EGLNativeDisplayType dpy) if (xscr) { if (x11_screen_support(xscr, X11_SCREEN_EXTENSION_DRI2)) { driver_name = x11_screen_probe_dri2(xscr); - nprobe->data = strdup(driver_name); + if (driver_name) + nprobe->data = strdup(driver_name); } x11_screen_destroy(xscr); -- cgit v1.2.3 From 95f8f75ad8bdb1d8e1cc16ea91fed8c407c36abd Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 15 Aug 2009 22:57:47 +0800 Subject: egl: Update headers. Update to the current versions found at http://www.khronos.org/registry/egl/. There is one modification in khrplatform.h for GCC visibility. --- include/EGL/egl.h | 39 ++++++- include/EGL/eglext.h | 60 +++++++++- include/EGL/eglplatform.h | 138 ++++++++++++----------- include/KHR/khrplatform.h | 273 ++++++++++++++++++++++++++++++++++++++++++++++ src/egl/main/eglapi.c | 3 +- src/egl/main/eglconfig.c | 5 +- 6 files changed, 441 insertions(+), 77 deletions(-) create mode 100644 include/KHR/khrplatform.h diff --git a/include/EGL/egl.h b/include/EGL/egl.h index e33a315723..99ea342a47 100644 --- a/include/EGL/egl.h +++ b/include/EGL/egl.h @@ -1,9 +1,32 @@ /* -*- mode: c; tab-width: 8; -*- */ /* vi: set sw=4 ts=8: */ /* Reference version of egl.h for EGL 1.4. - * Last modified 2008/05/02 + * $Revision: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $ */ +/* +** Copyright (c) 2007-2009 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE 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 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + #ifndef __egl_h_ #define __egl_h_ @@ -17,7 +40,7 @@ extern "C" { #endif /* EGL Types */ -typedef int32_t EGLint; +/* EGLint is defined in eglplatform.h */ typedef unsigned int EGLBoolean; typedef unsigned int EGLenum; typedef void *EGLConfig; @@ -42,7 +65,7 @@ typedef void *EGLClientBuffer; #define EGL_TRUE 1 /* Out-of-band handle values */ -#define EGL_DEFAULT_DISPLAY ((void *)0) +#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0) #define EGL_NO_CONTEXT ((EGLContext)0) #define EGL_NO_DISPLAY ((EGLDisplay)0) #define EGL_NO_SURFACE ((EGLSurface)0) @@ -86,7 +109,6 @@ typedef void *EGLClientBuffer; #define EGL_NATIVE_RENDERABLE 0x302D #define EGL_NATIVE_VISUAL_ID 0x302E #define EGL_NATIVE_VISUAL_TYPE 0x302F -#define EGL_PRESERVED_RESOURCES 0x3030 #define EGL_SAMPLES 0x3031 #define EGL_SAMPLE_BUFFERS 0x3032 #define EGL_SURFACE_TYPE 0x3033 @@ -291,7 +313,14 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target); -EGLAPI void (* EGLAPIENTRY eglGetProcAddress(const char *procname))(void); +/* This is a generic function pointer type, whose name indicates it must + * be cast to the proper type *and calling convention* before use. + */ +typedef void (*__eglMustCastToProperFunctionPointerType)(void); + +/* Now, define eglGetProcAddress using the generic function ptr. type */ +EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY + eglGetProcAddress(const char *procname); #ifdef __cplusplus } diff --git a/include/EGL/eglext.h b/include/EGL/eglext.h index b65f7f2bcc..a9e598d6dd 100644 --- a/include/EGL/eglext.h +++ b/include/EGL/eglext.h @@ -6,7 +6,7 @@ extern "C" { #endif /* -** Copyright (c) 2007 The Khronos Group Inc. +** Copyright (c) 2007-2009 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -33,9 +33,9 @@ extern "C" { /*************************************************************/ /* Header file version number */ -/* eglext.h last updated 2007/11/20 */ /* Current version at http://www.khronos.org/registry/egl/ */ -#define EGL_EGLEXT_VERSION 1 +/* $Revision: 10185 $ on $Date: 2010-01-22 11:38:01 -0800 (Fri, 22 Jan 2010) $ */ +#define EGL_EGLEXT_VERSION 5 #ifndef EGL_KHR_config_attribs #define EGL_KHR_config_attribs 1 @@ -79,12 +79,12 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay display #define EGL_KHR_image 1 #define EGL_NATIVE_PIXMAP_KHR 0x30B0 /* eglCreateImageKHR target */ typedef void *EGLImageKHR; -extern const EGLImageKHR EGL_NO_IMAGE_KHR; +#define EGL_NO_IMAGE_KHR ((EGLImageKHR)0) #ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, EGLint *attr_list); +EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image); #endif /* EGL_EGLEXT_PROTOTYPES */ -typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, EGLint *attr_list); +typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image); #endif @@ -120,6 +120,35 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGL #define EGL_GL_RENDERBUFFER_KHR 0x30B9 /* eglCreateImageKHR target */ #endif +#ifndef EGL_KHR_reusable_sync +#define EGL_KHR_reusable_sync 1 + +typedef void* EGLSyncKHR; +typedef khronos_utime_nanoseconds_t EGLTimeKHR; + +#define EGL_SYNC_STATUS_KHR 0x30F1 +#define EGL_SIGNALED_KHR 0x30F2 +#define EGL_UNSIGNALED_KHR 0x30F3 +#define EGL_TIMEOUT_EXPIRED_KHR 0x30F5 +#define EGL_CONDITION_SATISFIED_KHR 0x30F6 +#define EGL_SYNC_TYPE_KHR 0x30F7 +#define EGL_SYNC_REUSABLE_KHR 0x30FA +#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 /* eglClientWaitSyncKHR bitfield */ +#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull +#define EGL_NO_SYNC_KHR ((EGLSyncKHR)0) +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync); +EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); +EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); +EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync); +typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); +#endif /* EGL_MESA_screen extension >>> PRELIMINARY <<< */ #ifndef EGL_MESA_screen_surface @@ -179,6 +208,25 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOPYCONTEXTMESA) (EGLDisplay dpy, EGLCont #endif /* EGL_MESA_copy_context */ +#ifndef EGL_KHR_image_base +#define EGL_KHR_image_base 1 +/* Most interfaces defined by EGL_KHR_image_pixmap above */ +#define EGL_IMAGE_PRESERVED_KHR 0x30D2 /* eglCreateImageKHR attribute */ +#endif + +#ifndef EGL_KHR_image_pixmap +#define EGL_KHR_image_pixmap 1 +/* Interfaces defined by EGL_KHR_image above */ +#endif + +#ifndef EGL_IMG_context_priority +#define EGL_IMG_context_priority 1 +#define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100 +#define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101 +#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102 +#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103 +#endif + #ifdef __cplusplus } #endif diff --git a/include/EGL/eglplatform.h b/include/EGL/eglplatform.h index 09abb5d844..22e855f56c 100644 --- a/include/EGL/eglplatform.h +++ b/include/EGL/eglplatform.h @@ -1,43 +1,59 @@ -/* -*- mode: c; tab-width: 8; -*- */ -/* vi: set sw=4 ts=8: */ -/* Platform-specific types and definitions for egl.h */ - #ifndef __eglplatform_h_ #define __eglplatform_h_ -/* Windows calling convention boilerplate */ -#if (defined(WIN32) || defined(_WIN32_WCE)) -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ -#endif -#include -#endif - -#if !defined(_WIN32_WCE) -#include -#include -#endif +/* +** Copyright (c) 2007-2009 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE 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 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Platform-specific types and definitions for egl.h + * $Revision: 9724 $ on $Date: 2009-12-02 02:05:33 -0800 (Wed, 02 Dec 2009) $ + * + * Adopters may modify khrplatform.h and this file to suit their platform. + * You are encouraged to submit all modifications to the Khronos group so that + * they can be included in future versions of this file. Please submit changes + * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) + * by filing a bug against product "EGL" component "Registry". + */ -#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 -# define EGLAPI __attribute__((visibility("default"))) -# define EGLAPIENTRY -#endif +#include /* Macros used in EGL function prototype declarations. + * + * EGL functions should be prototyped as: * * EGLAPI return-type EGLAPIENTRY eglFunction(arguments); * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments); * - * On Windows, EGLAPIENTRY can be defined like APIENTRY. - * On most other platforms, it should be empty. + * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h */ -#ifndef EGLAPIENTRY -#define EGLAPIENTRY +#ifndef EGLAPI +#define EGLAPI KHRONOS_APICALL #endif -#ifndef EGLAPIENTRYP -#define EGLAPIENTRYP EGLAPIENTRY * + +#ifndef EGLAPIENTRY +#define EGLAPIENTRY KHRONOS_APIENTRY #endif +#define EGLAPIENTRYP EGLAPIENTRY* /* The types NativeDisplayType, NativeWindowType, and NativePixmapType * are aliases of window-system-dependent types, such as X Display * or @@ -46,53 +62,49 @@ * types, renamed in EGL 1.3 so all types in the API start with "EGL". */ -/* Unix (tentative) - #include - typedef Display *NativeDisplayType; - - or maybe, if encoding "hostname:display.head" - typedef const char *NativeWindowType; - etc. - */ - - -#if (defined(WIN32) || defined(_WIN32_WCE)) - -/** BEGIN Added for Windows **/ -#ifndef EGLAPI -#define EGLAPI __declspec(dllexport) +#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */ +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 #endif +#include -typedef long int32_t; -typedef unsigned long uint32_t; -typedef unsigned char uint8_t; -#define snprintf _snprintf -#define strcasecmp _stricmp -#define vsnprintf _vsnprintf - -typedef HDC NativeDisplayType; -typedef HWND NativeWindowType; -typedef HBITMAP NativePixmapType; -/** END Added for Windows **/ +typedef HDC EGLNativeDisplayType; +typedef HBITMAP EGLNativePixmapType; +typedef HWND EGLNativeWindowType; -#elif defined(__gnu_linux__) || defined(__FreeBSD__) || defined(__sun) || defined(__APPLE__) +#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */ +typedef int EGLNativeDisplayType; +typedef void *EGLNativeWindowType; +typedef void *EGLNativePixmapType; -/** BEGIN Added for X (Mesa) **/ -#ifndef EGLAPI -#define EGLAPI extern -#endif +#elif defined(__unix__) +/* X11 (tentative) */ #include -typedef Display *NativeDisplayType; -typedef Window NativeWindowType; -typedef Pixmap NativePixmapType; -/** END Added for X (Mesa) **/ +#include + +typedef Display *EGLNativeDisplayType; +typedef Pixmap EGLNativePixmapType; +typedef Window EGLNativeWindowType; +#else +#error "Platform not recognized" #endif /* EGL 1.2 types, renamed for consistency in EGL 1.3 */ -typedef NativeDisplayType EGLNativeDisplayType; -typedef NativePixmapType EGLNativePixmapType; -typedef NativeWindowType EGLNativeWindowType; +typedef EGLNativeDisplayType NativeDisplayType; +typedef EGLNativePixmapType NativePixmapType; +typedef EGLNativeWindowType NativeWindowType; + + +/* Define EGLint. This must be a signed integral type large enough to contain + * all legal attribute names and values passed into and out of EGL, whether + * their type is boolean, bitmask, enumerant (symbolic constant), integer, + * handle, or other. While in general a 32-bit integer will suffice, if + * handles are 64 bit types, then EGLint should be defined as a signed 64-bit + * integer type. + */ +typedef khronos_int32_t EGLint; #endif /* __eglplatform_h */ diff --git a/include/KHR/khrplatform.h b/include/KHR/khrplatform.h new file mode 100644 index 0000000000..a4b88ebc3d --- /dev/null +++ b/include/KHR/khrplatform.h @@ -0,0 +1,273 @@ +#ifndef __khrplatform_h_ +#define __khrplatform_h_ + +/* +** Copyright (c) 2008-2009 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE 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 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Khronos platform-specific types and definitions. + * + * $Revision: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $ + * + * Adopters may modify this file to suit their platform. Adopters are + * encouraged to submit platform specific modifications to the Khronos + * group so that they can be included in future versions of this file. + * Please submit changes by sending them to the public Khronos Bugzilla + * (http://khronos.org/bugzilla) by filing a bug against product + * "Khronos (general)" component "Registry". + * + * A predefined template which fills in some of the bug fields can be + * reached using http://tinyurl.com/khrplatform-h-bugreport, but you + * must create a Bugzilla login first. + * + * + * See the Implementer's Guidelines for information about where this file + * should be located on your system and for more details of its use: + * http://www.khronos.org/registry/implementers_guide.pdf + * + * This file should be included as + * #include + * by Khronos client API header files that use its types and defines. + * + * The types in khrplatform.h should only be used to define API-specific types. + * + * Types defined in khrplatform.h: + * khronos_int8_t signed 8 bit + * khronos_uint8_t unsigned 8 bit + * khronos_int16_t signed 16 bit + * khronos_uint16_t unsigned 16 bit + * khronos_int32_t signed 32 bit + * khronos_uint32_t unsigned 32 bit + * khronos_int64_t signed 64 bit + * khronos_uint64_t unsigned 64 bit + * khronos_intptr_t signed same number of bits as a pointer + * khronos_uintptr_t unsigned same number of bits as a pointer + * khronos_ssize_t signed size + * khronos_usize_t unsigned size + * khronos_float_t signed 32 bit floating point + * khronos_time_ns_t unsigned 64 bit time in nanoseconds + * khronos_utime_nanoseconds_t unsigned time interval or absolute time in + * nanoseconds + * khronos_stime_nanoseconds_t signed time interval in nanoseconds + * khronos_boolean_enum_t enumerated boolean type. This should + * only be used as a base type when a client API's boolean type is + * an enum. Client APIs which use an integer or other type for + * booleans cannot use this as the base type for their boolean. + * + * Tokens defined in khrplatform.h: + * + * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. + * + * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. + * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. + * + * Calling convention macros defined in this file: + * KHRONOS_APICALL + * KHRONOS_APIENTRY + * KHRONOS_APIATTRIBUTES + * + * These may be used in function prototypes as: + * + * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( + * int arg1, + * int arg2) KHRONOS_APIATTRIBUTES; + */ + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APICALL + *------------------------------------------------------------------------- + * This precedes the return type of the function in the function prototype. + */ +#if defined(_WIN32) && !defined(__SCITECH_SNAP__) +# define KHRONOS_APICALL __declspec(dllimport) +#elif defined (__SYMBIAN32__) +# define KHRONOS_APICALL IMPORT_C +#elif (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303) \ + || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +/* KHRONOS_APIATTRIBUTES is not used by the client API headers yet */ +# define KHRONOS_APICALL __attribute__((visibility("default"))) +#else +# define KHRONOS_APICALL +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIENTRY + *------------------------------------------------------------------------- + * This follows the return type of the function and precedes the function + * name in the function prototype. + */ +#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) + /* Win32 but not WinCE */ +# define KHRONOS_APIENTRY __stdcall +#else +# define KHRONOS_APIENTRY +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIATTRIBUTES + *------------------------------------------------------------------------- + * This follows the closing parenthesis of the function prototype arguments. + */ +#if defined (__ARMCC_2__) +#define KHRONOS_APIATTRIBUTES __softfp +#else +#define KHRONOS_APIATTRIBUTES +#endif + +/*------------------------------------------------------------------------- + * basic type definitions + *-----------------------------------------------------------------------*/ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) + + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__VMS ) || defined(__sgi) + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) + +/* + * Win32 + */ +typedef __int32 khronos_int32_t; +typedef unsigned __int32 khronos_uint32_t; +typedef __int64 khronos_int64_t; +typedef unsigned __int64 khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__sun__) || defined(__digital__) + +/* + * Sun or Digital + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#if defined(__arch64__) || defined(_LP64) +typedef long int khronos_int64_t; +typedef unsigned long int khronos_uint64_t; +#else +typedef long long int khronos_int64_t; +typedef unsigned long long int khronos_uint64_t; +#endif /* __arch64__ */ +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif 0 + +/* + * Hypothetical platform with no float or int64 support + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#define KHRONOS_SUPPORT_INT64 0 +#define KHRONOS_SUPPORT_FLOAT 0 + +#else + +/* + * Generic fallback + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#endif + + +/* + * Types that are (so far) the same on all platforms + */ +typedef signed char khronos_int8_t; +typedef unsigned char khronos_uint8_t; +typedef signed short int khronos_int16_t; +typedef unsigned short int khronos_uint16_t; +typedef signed long int khronos_intptr_t; +typedef unsigned long int khronos_uintptr_t; +typedef signed long int khronos_ssize_t; +typedef unsigned long int khronos_usize_t; + +#if KHRONOS_SUPPORT_FLOAT +/* + * Float type + */ +typedef float khronos_float_t; +#endif + +#if KHRONOS_SUPPORT_INT64 +/* Time types + * + * These types can be used to represent a time interval in nanoseconds or + * an absolute Unadjusted System Time. Unadjusted System Time is the number + * of nanoseconds since some arbitrary system event (e.g. since the last + * time the system booted). The Unadjusted System Time is an unsigned + * 64 bit value that wraps back to 0 every 584 years. Time intervals + * may be either signed or unsigned. + */ +typedef khronos_uint64_t khronos_utime_nanoseconds_t; +typedef khronos_int64_t khronos_stime_nanoseconds_t; +#endif + +/* + * Dummy value used to pad enum types to 32 bits. + */ +#ifndef KHRONOS_MAX_ENUM +#define KHRONOS_MAX_ENUM 0x7FFFFFFF +#endif + +/* + * Enumerated boolean type + * + * Values other than zero should be considered to be true. Therefore + * comparisons should not be made against KHRONOS_TRUE. + */ +typedef enum { + KHRONOS_FALSE = 0, + KHRONOS_TRUE = 1, + KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM +} khronos_boolean_enum_t; + +#endif /* __khrplatform_h_ */ diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 26ed45c6fe..e57ce211b8 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -678,7 +678,8 @@ eglGetError(void) } -void (* EGLAPIENTRY eglGetProcAddress(const char *procname))() +__eglMustCastToProperFunctionPointerType EGLAPIENTRY +eglGetProcAddress(const char *procname) { static const struct { const char *name; diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index 4d149603ae..a57aa33352 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -224,7 +224,8 @@ static const struct { { EGL_MATCH_NATIVE_PIXMAP, ATTRIB_TYPE_PSEUDO, ATTRIB_CRITERION_SPECIAL, EGL_NONE }, - { EGL_PRESERVED_RESOURCES, ATTRIB_TYPE_PSEUDO, + /* there is a gap before EGL_SAMPLES */ + { 0x3030, ATTRIB_TYPE_PSEUDO, ATTRIB_CRITERION_IGNORE, 0 }, { EGL_NONE, ATTRIB_TYPE_PSEUDO, @@ -773,7 +774,7 @@ _eglIsConfigAttribValid(_EGLConfig *conf, EGLint attr) /* there are some holes in the range */ switch (attr) { - case EGL_PRESERVED_RESOURCES: + case 0x3030 /* a gap before EGL_SAMPLES */: case EGL_NONE: #ifdef EGL_VERSION_1_4 case EGL_MATCH_NATIVE_PIXMAP: -- cgit v1.2.3 From a1c4a8a3c855d52fbfef10023b9a8f116e163a97 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 15 Aug 2009 22:58:13 +0800 Subject: egl: Add support for EGL_KHR_image. Individual drivers still need to implement the API hooks. --- src/egl/main/Makefile | 2 + src/egl/main/eglapi.c | 54 ++++++++++++++++++++++++++ src/egl/main/eglapi.h | 13 ++++++- src/egl/main/egldisplay.h | 3 ++ src/egl/main/egldriver.c | 6 +++ src/egl/main/eglimage.c | 51 +++++++++++++++++++++++++ src/egl/main/eglimage.h | 95 ++++++++++++++++++++++++++++++++++++++++++++++ src/egl/main/eglmisc.c | 8 ++++ src/egl/main/egltypedefs.h | 2 + 9 files changed, 233 insertions(+), 1 deletion(-) create mode 100644 src/egl/main/eglimage.c create mode 100644 src/egl/main/eglimage.h diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index 20614d8753..5b83b43bc2 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -19,6 +19,7 @@ HEADERS = \ egldisplay.h \ egldriver.h \ eglglobals.h \ + eglimage.h \ egllog.h \ eglmisc.h \ eglmode.h \ @@ -36,6 +37,7 @@ SOURCES = \ egldisplay.c \ egldriver.c \ eglglobals.c \ + eglimage.c \ egllog.c \ eglmisc.c \ eglmode.c \ diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index e57ce211b8..218de3ab6b 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -65,6 +65,7 @@ #include "eglconfig.h" #include "eglscreen.h" #include "eglmode.h" +#include "eglimage.h" /** @@ -700,6 +701,10 @@ eglGetProcAddress(const char *procname) { "eglQueryScreenModeMESA", (_EGLProc) eglQueryScreenModeMESA }, { "eglQueryModeStringMESA", (_EGLProc) eglQueryModeStringMESA }, #endif /* EGL_MESA_screen_surface */ +#ifdef EGL_KHR_image_base + { "eglCreateImageKHR", (_EGLProc) eglCreateImageKHR }, + { "eglDestroyImageKHR", (_EGLProc) eglDestroyImageKHR }, +#endif /* EGL_KHR_image_base */ { NULL, NULL } }; EGLint i; @@ -995,3 +1000,52 @@ eglReleaseThread(void) #endif /* EGL_VERSION_1_2 */ + + +#ifdef EGL_KHR_image_base + + +EGLImageKHR +eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, + EGLClientBuffer buffer, const EGLint *attr_list) +{ + _EGLDisplay *disp = _eglLookupDisplay(dpy); + _EGLContext *context = _eglLookupContext(ctx, disp); + _EGLDriver *drv; + _EGLImage *img; + + drv = _eglCheckDisplay(disp, __FUNCTION__); + if (!drv) + return EGL_NO_IMAGE_KHR; + if (!context && ctx != EGL_NO_CONTEXT) { + _eglError(EGL_BAD_CONTEXT, __FUNCTION__); + return EGL_NO_IMAGE_KHR; + } + + img = drv->API.CreateImageKHR(drv, + disp, context, target, buffer, attr_list); + if (img) + return _eglLinkImage(img, disp); + else + return EGL_NO_IMAGE_KHR; +} + + +EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image) +{ + _EGLDisplay *disp = _eglLookupDisplay(dpy); + _EGLImage *img = _eglLookupImage(image, disp); + _EGLDriver *drv; + + drv = _eglCheckDisplay(disp, __FUNCTION__); + if (!drv) + return EGL_FALSE; + if (!img) + return _eglError(EGL_BAD_PARAMETER, __FUNCTION__); + + _eglUnlinkImage(img); + return drv->API.DestroyImageKHR(drv, disp, img); +} + + +#endif /* EGL_KHR_image_base */ diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h index 080f2155e3..bd3c3b4875 100644 --- a/src/egl/main/eglapi.h +++ b/src/egl/main/eglapi.h @@ -69,6 +69,11 @@ typedef _EGLSurface *(*CreatePbufferFromClientBuffer_t)(_EGLDriver *drv, _EGLDis #endif /* EGL_VERSION_1_2 */ +#ifdef EGL_KHR_image_base +typedef _EGLImage *(*CreateImageKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list); +typedef EGLBoolean (*DestroyImageKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image); +#endif /* EGL_KHR_image_base */ + /** * The API dispatcher jumps through these functions @@ -104,7 +109,7 @@ struct _egl_api WaitNative_t WaitNative; GetProcAddress_t GetProcAddress; - /* EGL_MESA_screen extension */ +#ifdef EGL_MESA_screen_surface ChooseModeMESA_t ChooseModeMESA; GetModesMESA_t GetModesMESA; GetModeAttribMESA_t GetModeAttribMESA; @@ -117,10 +122,16 @@ struct _egl_api QueryScreenSurfaceMESA_t QueryScreenSurfaceMESA; QueryScreenModeMESA_t QueryScreenModeMESA; QueryModeStringMESA_t QueryModeStringMESA; +#endif /* EGL_MESA_screen_surface */ #ifdef EGL_VERSION_1_2 CreatePbufferFromClientBuffer_t CreatePbufferFromClientBuffer; #endif + +#ifdef EGL_KHR_image_base + CreateImageKHR_t CreateImageKHR; + DestroyImageKHR_t DestroyImageKHR; +#endif /* EGL_KHR_image_base */ }; #endif /* EGLAPI_INCLUDED */ diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index b13ce08261..70fe29513c 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -8,6 +8,7 @@ enum _egl_resource_type { _EGL_RESOURCE_CONTEXT, _EGL_RESOURCE_SURFACE, + _EGL_RESOURCE_IMAGE, _EGL_NUM_RESOURCES }; @@ -30,6 +31,8 @@ struct _egl_extensions { EGLBoolean MESA_screen_surface; EGLBoolean MESA_copy_context; + EGLBoolean KHR_image_base; + EGLBoolean KHR_image_pixmap; char String[_EGL_MAX_EXTENSIONS_LEN]; }; diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index d997326729..b820b966f9 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -19,6 +19,7 @@ #include "eglscreen.h" #include "eglstring.h" #include "eglsurface.h" +#include "eglimage.h" #if defined(_EGL_PLATFORM_POSIX) #include @@ -545,6 +546,11 @@ _eglInitDriverFallbacks(_EGLDriver *drv) #ifdef EGL_VERSION_1_2 drv->API.CreatePbufferFromClientBuffer = _eglCreatePbufferFromClientBuffer; #endif /* EGL_VERSION_1_2 */ + +#ifdef EGL_KHR_image_base + drv->API.CreateImageKHR = _eglCreateImageKHR; + drv->API.DestroyImageKHR = _eglDestroyImageKHR; +#endif /* EGL_KHR_image_base */ } diff --git a/src/egl/main/eglimage.c b/src/egl/main/eglimage.c new file mode 100644 index 0000000000..5044112fa8 --- /dev/null +++ b/src/egl/main/eglimage.c @@ -0,0 +1,51 @@ +#include + +#include "eglimage.h" +#include "egldisplay.h" + + +#ifdef EGL_KHR_image_base + + +EGLBoolean +_eglInitImage(_EGLDriver *drv, _EGLImage *img, const EGLint *attrib_list) +{ + EGLint i; + + img->Preserved = EGL_FALSE; + + for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { + switch (attrib_list[i]) { + case EGL_IMAGE_PRESERVED_KHR: + i++; + img->Preserved = attrib_list[i]; + break; + default: + /* not an error */ + break; + } + } + + return EGL_TRUE; +} + + +_EGLImage * +_eglCreateImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, + EGLenum target, EGLClientBuffer buffer, + const EGLint *attr_list) +{ + /* driver should override this function */ + return NULL; +} + + +EGLBoolean +_eglDestroyImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image) +{ + /* driver should override this function */ + return EGL_FALSE; +} + + +#endif /* EGL_KHR_image_base */ diff --git a/src/egl/main/eglimage.h b/src/egl/main/eglimage.h new file mode 100644 index 0000000000..026b10307d --- /dev/null +++ b/src/egl/main/eglimage.h @@ -0,0 +1,95 @@ +#ifndef EGLIMAGE_INCLUDED +#define EGLIMAGE_INCLUDED + + +#include "egltypedefs.h" +#include "egldisplay.h" + + +/** + * "Base" class for device driver images. + */ +struct _egl_image +{ + /* An image is a display resource */ + _EGLResource Resource; + + EGLBoolean Preserved; +}; + + +PUBLIC EGLBoolean +_eglInitImage(_EGLDriver *drv, _EGLImage *img, const EGLint *attrib_list); + + +extern _EGLImage * +_eglCreateImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, + EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list); + + +extern EGLBoolean +_eglDestroyImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image); + + +/** + * Link an image to a display and return the handle of the link. + * The handle can be passed to client directly. + */ +static INLINE EGLImageKHR +_eglLinkImage(_EGLImage *img, _EGLDisplay *dpy) +{ + _eglLinkResource(&img->Resource, _EGL_RESOURCE_IMAGE, dpy); + return (EGLImageKHR) img; +} + + +/** + * Unlink a linked image from its display. + * Accessing an unlinked image should generate EGL_BAD_PARAMETER error. + */ +static INLINE void +_eglUnlinkImage(_EGLImage *img) +{ + _eglUnlinkResource(&img->Resource, _EGL_RESOURCE_IMAGE); +} + + +/** + * Lookup a handle to find the linked image. + * Return NULL if the handle has no corresponding linked image. + */ +static INLINE _EGLImage * +_eglLookupImage(EGLImageKHR image, _EGLDisplay *dpy) +{ + _EGLResource *res = (_EGLResource *) image; + _EGLImage *img = (_EGLImage *) image; + if (!res || !dpy || !_eglCheckResource(res, _EGL_RESOURCE_IMAGE, dpy)) + img = NULL; + return img; +} + + +/** + * Return the handle of a linked image, or EGL_NO_IMAGE_KHR. + */ +static INLINE EGLImageKHR +_eglGetImageHandle(_EGLImage *img) +{ + _EGLResource *res = (_EGLResource *) img; + return (res && _eglIsResourceLinked(res)) ? + (EGLImageKHR) img : EGL_NO_IMAGE_KHR; +} + + +/** + * Return true if the image is linked to a display. + */ +static INLINE EGLBoolean +_eglIsImageLinked(_EGLImage *img) +{ + _EGLResource *res = (_EGLResource *) img; + return (res && _eglIsResourceLinked(res)); +} + + +#endif /* EGLIMAGE_INCLUDED */ diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c index e66913320b..5726f5bca8 100644 --- a/src/egl/main/eglmisc.c +++ b/src/egl/main/eglmisc.c @@ -54,6 +54,14 @@ _eglUpdateExtensionsString(_EGLDisplay *dpy) strcat(exts, "EGL_MESA_screen_surface "); if (dpy->Extensions.MESA_copy_context) strcat(exts, "EGL_MESA_copy_context "); + + if (dpy->Extensions.KHR_image_base) + strcat(exts, "EGL_KHR_image_base "); + if (dpy->Extensions.KHR_image_pixmap) + strcat(exts, "EGL_KHR_image_pixmap "); + if (dpy->Extensions.KHR_image_base && dpy->Extensions.KHR_image_pixmap) + strcat(exts, "EGL_KHR_image "); + assert(strlen(exts) < _EGL_MAX_EXTENSIONS_LEN); } diff --git a/src/egl/main/egltypedefs.h b/src/egl/main/egltypedefs.h index a49ffbb0cd..e6b19b35d0 100644 --- a/src/egl/main/egltypedefs.h +++ b/src/egl/main/egltypedefs.h @@ -22,6 +22,8 @@ typedef struct _egl_driver _EGLDriver; typedef struct _egl_extensions _EGLExtensions; +typedef struct _egl_image _EGLImage; + typedef struct _egl_mode _EGLMode; typedef struct _egl_resource _EGLResource; -- cgit v1.2.3 From 3f932a444021958d632e3e6334d7b168304dfd74 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 25 Jan 2010 11:34:09 +0800 Subject: egl: Install EGL headers. Install EGL (and KHR) headers along with the library. --- src/egl/main/Makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index 5b83b43bc2..31f214cf6f 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -74,7 +74,15 @@ $(TOP)/$(LIB_DIR)/$(EGL_LIB_NAME): $(OBJECTS) -install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \ $(EGL_LIB_DEPS) $(OBJECTS) -install: default +install-headers: + $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/KHR + $(INSTALL) -m 644 $(TOP)/include/KHR/*.h \ + $(DESTDIR)$(INSTALL_INC_DIR)/KHR + $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/EGL + $(INSTALL) -m 644 $(TOP)/include/EGL/*.h \ + $(DESTDIR)$(INSTALL_INC_DIR)/EGL + +install: default install-headers $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) $(MINSTALL) $(TOP)/$(LIB_DIR)/$(EGL_LIB_GLOB) \ $(DESTDIR)$(INSTALL_LIB_DIR) -- cgit v1.2.3 From dbb866ab33862defc2749134805bafebf323fd11 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 25 Jan 2010 11:39:44 +0800 Subject: egl: Make resource void pointer in _eglCheckResource. This emphasizes the fact that the resource to be checked could really be invalid and have an unknown type. --- src/egl/main/eglcontext.h | 3 +-- src/egl/main/egldisplay.c | 7 +++++-- src/egl/main/egldisplay.h | 6 +++--- src/egl/main/eglimage.h | 3 +-- src/egl/main/eglsurface.h | 3 +-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/egl/main/eglcontext.h b/src/egl/main/eglcontext.h index b81dc1ed82..be00642d13 100644 --- a/src/egl/main/eglcontext.h +++ b/src/egl/main/eglcontext.h @@ -95,9 +95,8 @@ _eglUnlinkContext(_EGLContext *ctx) static INLINE _EGLContext * _eglLookupContext(EGLContext context, _EGLDisplay *dpy) { - _EGLResource *res = (_EGLResource *) context; _EGLContext *ctx = (_EGLContext *) context; - if (!res || !dpy || !_eglCheckResource(res, _EGL_RESOURCE_CONTEXT, dpy)) + if (!dpy || !_eglCheckResource((void *) ctx, _EGL_RESOURCE_CONTEXT, dpy)) ctx = NULL; return ctx; } diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index c978adb47f..74c655df41 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -214,12 +214,15 @@ _eglCheckDisplayHandle(EGLDisplay dpy) * own the resource. */ EGLBoolean -_eglCheckResource(_EGLResource *res, _EGLResourceType type, _EGLDisplay *dpy) +_eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *dpy) { _EGLResource *list = dpy->ResourceLists[type]; + if (!res) + return EGL_FALSE; + while (list) { - if (res == list) { + if (res == (void *) list) { assert(list->Display == dpy); break; } diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 70fe29513c..5d44eb1ea8 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -107,7 +107,7 @@ _eglCheckDisplayHandle(EGLDisplay dpy); extern EGLBoolean -_eglCheckResource(_EGLResource *res, _EGLResourceType type, _EGLDisplay *dpy); +_eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *dpy); #else /* !_EGL_SKIP_HANDLE_CHECK */ @@ -122,9 +122,9 @@ _eglCheckDisplayHandle(EGLDisplay dpy) static INLINE EGLBoolean -_eglCheckResource(_EGLResource *res, _EGLResourceType type, _EGLDisplay *dpy) +_eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *dpy); { - return (res->Display == dpy); + return (((_EGLResource *) res)->Display == dpy); } diff --git a/src/egl/main/eglimage.h b/src/egl/main/eglimage.h index 026b10307d..43107c23e9 100644 --- a/src/egl/main/eglimage.h +++ b/src/egl/main/eglimage.h @@ -61,9 +61,8 @@ _eglUnlinkImage(_EGLImage *img) static INLINE _EGLImage * _eglLookupImage(EGLImageKHR image, _EGLDisplay *dpy) { - _EGLResource *res = (_EGLResource *) image; _EGLImage *img = (_EGLImage *) image; - if (!res || !dpy || !_eglCheckResource(res, _EGL_RESOURCE_IMAGE, dpy)) + if (!dpy || !_eglCheckResource((void *) img, _EGL_RESOURCE_IMAGE, dpy)) img = NULL; return img; } diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h index da07133c2c..f1642356b0 100644 --- a/src/egl/main/eglsurface.h +++ b/src/egl/main/eglsurface.h @@ -141,9 +141,8 @@ _eglUnlinkSurface(_EGLSurface *surf) static INLINE _EGLSurface * _eglLookupSurface(EGLSurface surface, _EGLDisplay *dpy) { - _EGLResource *res = (_EGLResource *) surface; _EGLSurface *surf = (_EGLSurface *) surface; - if (!res || !dpy || !_eglCheckResource(res, _EGL_RESOURCE_SURFACE, dpy)) + if (!dpy || !_eglCheckResource((void *) surf, _EGL_RESOURCE_SURFACE, dpy)) surf = NULL; return surf; } -- cgit v1.2.3 From 4aed0944f4b8b8d14d210cf6bc87ccddfa9a77ec Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 25 Jan 2010 11:55:48 +0800 Subject: egl: Native types are renamed in EGL 1.3. Rename Native*Type to EGLNative*Type. --- src/egl/drivers/glx/egl_glx.c | 10 ++++++---- src/egl/drivers/xdri/egl_xdri.c | 3 ++- src/egl/main/eglapi.c | 8 ++++---- src/egl/main/eglapi.h | 6 +++--- src/egl/main/egldisplay.c | 4 ++-- src/egl/main/egldisplay.h | 4 ++-- src/egl/main/eglsurface.c | 6 +++--- src/egl/main/eglsurface.h | 6 +++--- src/gallium/state_trackers/egl/common/egl_g3d.c | 2 +- 9 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c index 6d2815888b..89a4353f8a 100644 --- a/src/egl/drivers/glx/egl_glx.c +++ b/src/egl/drivers/glx/egl_glx.c @@ -677,8 +677,9 @@ get_drawable_size(Display *dpy, Drawable d, uint *width, uint *height) * Called via eglCreateWindowSurface(), drv->API.CreateWindowSurface(). */ static _EGLSurface * -GLX_eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, - NativeWindowType window, const EGLint *attrib_list) +GLX_eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *disp, + _EGLConfig *conf, EGLNativeWindowType window, + const EGLint *attrib_list) { struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp); struct GLX_egl_surface *GLX_surf; @@ -719,8 +720,9 @@ GLX_eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, } static _EGLSurface * -GLX_eglCreatePixmapSurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, - NativePixmapType pixmap, const EGLint *attrib_list) +GLX_eglCreatePixmapSurface(_EGLDriver *drv, _EGLDisplay *disp, + _EGLConfig *conf, EGLNativePixmapType pixmap, + const EGLint *attrib_list) { struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp); struct GLX_egl_surface *GLX_surf; diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index b133939155..df251d908b 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -484,7 +484,8 @@ xdri_eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *d, */ static _EGLSurface * xdri_eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, - NativeWindowType window, const EGLint *attrib_list) + EGLNativeWindowType window, + const EGLint *attrib_list) { struct xdri_egl_display *xdri_dpy = lookup_display(dpy); struct xdri_egl_config *xdri_config = lookup_config(conf); diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 218de3ab6b..c197cfd38f 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -73,7 +73,7 @@ * We initialize our global vars and create a private _EGLDisplay object. */ EGLDisplay EGLAPIENTRY -eglGetDisplay(NativeDisplayType nativeDisplay) +eglGetDisplay(EGLNativeDisplayType nativeDisplay) { _EGLDisplay *dpy; dpy = _eglFindDisplay(nativeDisplay); @@ -418,7 +418,7 @@ eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, - NativeWindowType window, const EGLint *attrib_list) + EGLNativeWindowType window, const EGLint *attrib_list) { _EGLDisplay *disp = _eglLookupDisplay(dpy); _EGLConfig *conf = _eglLookupConfig(config, disp); @@ -439,7 +439,7 @@ eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, - NativePixmapType pixmap, const EGLint *attrib_list) + EGLNativePixmapType pixmap, const EGLint *attrib_list) { _EGLDisplay *disp = _eglLookupDisplay(dpy); _EGLConfig *conf = _eglLookupConfig(config, disp); @@ -553,7 +553,7 @@ eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) EGLBoolean EGLAPIENTRY -eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, NativePixmapType target) +eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) { _EGL_DECLARE_DD_AND_SURFACE(dpy, surface); return drv->API.CopyBuffers(drv, disp, surf, target); diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h index bd3c3b4875..db31c7cf93 100644 --- a/src/egl/main/eglapi.h +++ b/src/egl/main/eglapi.h @@ -27,8 +27,8 @@ typedef EGLBoolean (*MakeCurrent_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurfa typedef EGLBoolean (*QueryContext_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLint attribute, EGLint *value); /* surface funcs */ -typedef _EGLSurface *(*CreateWindowSurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, NativeWindowType window, const EGLint *attrib_list); -typedef _EGLSurface *(*CreatePixmapSurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, NativePixmapType pixmap, const EGLint *attrib_list); +typedef _EGLSurface *(*CreateWindowSurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, EGLNativeWindowType window, const EGLint *attrib_list); +typedef _EGLSurface *(*CreatePixmapSurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, EGLNativePixmapType pixmap, const EGLint *attrib_list); typedef _EGLSurface *(*CreatePbufferSurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, const EGLint *attrib_list); typedef EGLBoolean (*DestroySurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface); typedef EGLBoolean (*QuerySurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint attribute, EGLint *value); @@ -37,7 +37,7 @@ typedef EGLBoolean (*BindTexImage_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurf typedef EGLBoolean (*ReleaseTexImage_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint buffer); typedef EGLBoolean (*SwapInterval_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint interval); typedef EGLBoolean (*SwapBuffers_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw); -typedef EGLBoolean (*CopyBuffers_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, NativePixmapType target); +typedef EGLBoolean (*CopyBuffers_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLNativePixmapType target); /* misc funcs */ typedef const char *(*QueryString_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name); diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index 74c655df41..359900ca2f 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -52,7 +52,7 @@ _eglFiniDisplay(void) * Note that nativeDisplay may be an X Display ptr, or a string. */ _EGLDisplay * -_eglNewDisplay(NativeDisplayType nativeDisplay) +_eglNewDisplay(EGLNativeDisplayType nativeDisplay) { _EGLDisplay *dpy = (_EGLDisplay *) calloc(1, sizeof(_EGLDisplay)); if (dpy) { @@ -114,7 +114,7 @@ _eglUnlinkDisplay(_EGLDisplay *dpy) * linked displays. */ _EGLDisplay * -_eglFindDisplay(NativeDisplayType nativeDisplay) +_eglFindDisplay(EGLNativeDisplayType nativeDisplay) { _EGLDisplay *dpy; diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 5d44eb1ea8..d811f2ee8e 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -76,7 +76,7 @@ _eglFiniDisplay(void); extern _EGLDisplay * -_eglNewDisplay(NativeDisplayType displayName); +_eglNewDisplay(EGLNativeDisplayType displayName); extern EGLDisplay @@ -88,7 +88,7 @@ _eglUnlinkDisplay(_EGLDisplay *dpy); extern _EGLDisplay * -_eglFindDisplay(NativeDisplayType nativeDisplay); +_eglFindDisplay(EGLNativeDisplayType nativeDisplay); PUBLIC void diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 940a1b760c..89eb93d808 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -237,7 +237,7 @@ _eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) EGLBoolean _eglCopyBuffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, - NativePixmapType target) + EGLNativePixmapType target) { /* copy surface to native pixmap */ /* All implementation burdon for this is in the device driver */ @@ -319,7 +319,7 @@ _eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, */ _EGLSurface * _eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, - NativeWindowType window, const EGLint *attrib_list) + EGLNativeWindowType window, const EGLint *attrib_list) { #if 0 /* THIS IS JUST EXAMPLE CODE */ _EGLSurface *surf; @@ -344,7 +344,7 @@ _eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, */ _EGLSurface * _eglCreatePixmapSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, - NativePixmapType pixmap, const EGLint *attrib_list) + EGLNativePixmapType pixmap, const EGLint *attrib_list) { #if 0 /* THIS IS JUST EXAMPLE CODE */ _EGLSurface *surf; diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h index f1642356b0..4062b990fa 100644 --- a/src/egl/main/eglsurface.h +++ b/src/egl/main/eglsurface.h @@ -50,7 +50,7 @@ _eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf); extern EGLBoolean -_eglCopyBuffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, NativePixmapType target); +_eglCopyBuffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLNativePixmapType target); extern EGLBoolean @@ -58,11 +58,11 @@ _eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint at extern _EGLSurface * -_eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, NativeWindowType window, const EGLint *attrib_list); +_eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, EGLNativeWindowType window, const EGLint *attrib_list); extern _EGLSurface * -_eglCreatePixmapSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, NativePixmapType pixmap, const EGLint *attrib_list); +_eglCreatePixmapSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, EGLNativePixmapType pixmap, const EGLint *attrib_list); extern _EGLSurface * diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index dc26f95cee..d073f226f2 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -974,7 +974,7 @@ get_pipe_surface(struct native_display *ndpy, struct native_surface *nsurf, static EGLBoolean egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, - NativePixmapType target) + EGLNativePixmapType target) { struct egl_g3d_display *gdpy = egl_g3d_display(dpy); struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); -- cgit v1.2.3 From 85059964307c3f10e4a328d82af2bb791a5a4927 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sat, 23 Jan 2010 17:19:44 +0100 Subject: radeong: do not emit a zero-sized command stream Fixing a hardlock introduced in fcbd285e421903ee0a65f19f5d633b25b5923c24 and reproducible with piglit/bugs/fdo23489. --- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 0875ee41cb..0253bc2527 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -108,6 +108,11 @@ static void radeon_flush_cs(struct radeon_winsys* winsys) { int retval; + /* Don't flush a zero-sized CS. */ + if (!winsys->priv->cs->cdw) { + return; + } + /* Emit the CS. */ retval = radeon_cs_emit(winsys->priv->cs); if (retval) { -- cgit v1.2.3 From b7a002df1e06504ff1ed0dc005c9b10aa4be54f7 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 17 Jan 2010 00:57:04 +0100 Subject: r300g,radeong: set tiling flags in libdrm --- src/gallium/drivers/r300/r300_texture.c | 7 +++++++ src/gallium/winsys/drm/radeon/core/radeon_buffer.c | 22 ++++++++++++++++++++++ src/gallium/winsys/drm/radeon/core/radeon_winsys.h | 6 ++++++ 3 files changed, 35 insertions(+) diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 1f73f74c26..67bf8ce13f 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -30,6 +30,8 @@ #include "r300_texture.h" #include "r300_screen.h" +#include "radeon_winsys.h" + #define TILE_WIDTH 0 #define TILE_HEIGHT 1 @@ -209,6 +211,7 @@ static struct pipe_texture* { struct r300_texture* tex = CALLOC_STRUCT(r300_texture); struct r300_screen* rscreen = r300_screen(screen); + struct radeon_winsys* winsys = (struct radeon_winsys*)screen->winsys; if (!tex) { return NULL; @@ -225,6 +228,10 @@ static struct pipe_texture* tex->buffer = screen->buffer_create(screen, 2048, PIPE_BUFFER_USAGE_PIXEL, tex->size); + winsys->buffer_set_tiling(winsys, tex->buffer, + tex->pitch[0], + tex->microtile != R300_BUFFER_LINEAR, + tex->macrotile != R300_BUFFER_LINEAR); if (!tex->buffer) { FREE(tex); diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c index b020ff38fa..25e1cdcdb6 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c @@ -202,6 +202,26 @@ static void radeon_buffer_unmap(struct pipe_winsys *ws, } } +static void radeon_buffer_set_tiling(struct radeon_winsys *ws, + struct pipe_buffer *buffer, + uint32_t pitch, + boolean microtiled, + boolean macrotiled) +{ + struct radeon_pipe_buffer *radeon_buffer = + (struct radeon_pipe_buffer*)buffer; + uint32_t flags = 0; + + if (microtiled) { + flags |= RADEON_BO_FLAGS_MICRO_TILE; + } + if (macrotiled) { + flags |= RADEON_BO_FLAGS_MACRO_TILE; + } + + radeon_bo_set_tiling(radeon_buffer->bo, flags, pitch); +} + static void radeon_fence_reference(struct pipe_winsys *ws, struct pipe_fence_handle **ptr, struct pipe_fence_handle *pfence) @@ -304,5 +324,7 @@ struct radeon_winsys* radeon_pipe_winsys(int fd) radeon_ws->base.get_name = radeon_get_name; + radeon_ws->buffer_set_tiling = radeon_buffer_set_tiling; + return radeon_ws; } diff --git a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h index 9edc9e038c..864082b99b 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h @@ -100,6 +100,12 @@ struct radeon_winsys { void (*flush_cb)(void *), void *data); void (*reset_bos)(struct radeon_winsys *winsys); + + void (*buffer_set_tiling)(struct radeon_winsys* winsys, + struct pipe_buffer* buffer, + uint32_t pitch, + boolean microtiled, + boolean macrotiled); }; #endif -- cgit v1.2.3 From 9f8ec533123f07f29b084e8a46fc35c498b3a670 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 17 Jan 2010 23:13:51 +0100 Subject: r300g: fix zero-area scissor --- src/gallium/drivers/r300/r300_emit.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index e07185b778..36d2c64b58 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -686,6 +686,22 @@ void r300_emit_scissor_state(struct r300_context* r300, void* state) maxy = MIN2(maxy, scissor->maxy); } + /* Special case for zero-area scissor. + * + * We can't allow the variables maxx and maxy to be zero because they are + * subtracted from later in the code, which would cause emitting ~0 and + * making the kernel checker angry. + * + * Let's consider we change maxx and maxy to 1, which is effectively + * a one-pixel area. We must then change minx and miny to a number which is + * greater than 1 to get the zero area back. */ + if (!maxx || !maxy) { + minx = 2; + miny = 2; + maxx = 1; + maxy = 1; + } + if (r300screen->caps->is_r500) { top_left = (minx << R300_SCISSORS_X_SHIFT) | -- cgit v1.2.3 From 112239e9a66a155d36fe2ad0ab130e6f26eff298 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Mon, 18 Jan 2010 00:15:52 +0100 Subject: r300g,radeong: finish and enable the immediate mode Nearly 100% performance increase in glxgears. --- src/gallium/drivers/r300/r300_emit.c | 22 ---- src/gallium/drivers/r300/r300_render.c | 141 ++++++++++++++++----- src/gallium/drivers/r300/r300_state.c | 22 ++++ src/gallium/winsys/drm/radeon/core/radeon_buffer.c | 83 ++++++++++-- src/gallium/winsys/drm/radeon/core/radeon_buffer.h | 2 + src/gallium/winsys/drm/radeon/core/radeon_drm.h | 2 +- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 8 +- src/gallium/winsys/drm/radeon/core/radeon_winsys.h | 6 + 8 files changed, 219 insertions(+), 67 deletions(-) diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 36d2c64b58..badbf3715c 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -772,22 +772,6 @@ void r300_emit_texture(struct r300_context* r300, END_CS; } -static boolean r300_validate_aos(struct r300_context *r300) -{ - struct pipe_vertex_buffer *vbuf = r300->vertex_buffer; - struct pipe_vertex_element *velem = r300->vertex_element; - int i; - - /* Check if formats and strides are aligned to the size of DWORD. */ - for (i = 0; i < r300->vertex_element_count; i++) { - if (vbuf[velem[i].vertex_buffer_index].stride % 4 != 0 || - util_format_get_blocksize(velem[i].src_format) % 4 != 0) { - return FALSE; - } - } - return TRUE; -} - void r300_emit_aos(struct r300_context* r300, unsigned offset) { struct pipe_vertex_buffer *vb1, *vb2, *vbuf = r300->vertex_buffer; @@ -797,12 +781,6 @@ void r300_emit_aos(struct r300_context* r300, unsigned offset) unsigned packet_size = (aos_count * 3 + 1) / 2; CS_LOCALS(r300); - /* XXX Move this checking to a more approriate place. */ - if (!r300_validate_aos(r300)) { - /* XXX We should fallback using Draw. */ - assert(0); - } - BEGIN_CS(2 + packet_size + aos_count * 2); OUT_CS_PKT3(R300_PACKET3_3D_LOAD_VBPNTR, packet_size); OUT_CS(aos_count); diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 677031ef04..7f095bffe7 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -28,6 +28,7 @@ #include "pipe/p_inlines.h" +#include "util/u_format.h" #include "util/u_memory.h" #include "util/u_prim.h" @@ -114,20 +115,53 @@ static uint32_t r300_provoking_vertex_fixes(struct r300_context *r300, return color_control; } -static void r300_emit_draw_immediate(struct r300_context *r300, - unsigned mode, - unsigned start, - unsigned count) + +static void r300_emit_draw_arrays_immediate(struct r300_context *r300, + unsigned mode, + unsigned start, + unsigned count) { - struct pipe_buffer* vbo = r300->vertex_buffer[0].buffer; - unsigned vertex_size = r300->vertex_buffer[0].stride / sizeof(float); - unsigned i; - uint32_t* map; + struct pipe_vertex_element* velem; + struct pipe_vertex_buffer* vbuf; + unsigned vertex_element_count = r300->vertex_element_count; + unsigned i, v, vbi, dw, elem_offset; + + /* Size of the vertex, in dwords. */ + unsigned vertex_size = 0; + + /* Offsets of the attribute, in dwords, from the start of the vertex. */ + unsigned offset[PIPE_MAX_ATTRIBS]; + + /* Size of the vertex element, in dwords. */ + unsigned size[PIPE_MAX_ATTRIBS]; + + /* Stride to the same attrib in the next vertex in the vertex buffer, + * in dwords. */ + unsigned stride[PIPE_MAX_ATTRIBS]; + + /* Mapped vertex buffers. */ + uint32_t* map[PIPE_MAX_ATTRIBS] = {0}; + CS_LOCALS(r300); - map = (uint32_t*)pipe_buffer_map_range(r300->context.screen, vbo, - start * vertex_size, count * vertex_size, - PIPE_BUFFER_USAGE_CPU_READ); + /* Calculate the vertex size, offsets, strides etc. and map the buffers. */ + for (i = 0; i < vertex_element_count; i++) { + velem = &r300->vertex_element[i]; + offset[i] = velem->src_offset >> 2; + size[i] = util_format_get_blocksize(velem->src_format) >> 2; + vertex_size += size[i]; + vbi = velem->vertex_buffer_index; + + /* Map the buffer. */ + if (!map[vbi]) { + vbuf = &r300->vertex_buffer[vbi]; + map[vbi] = (uint32_t*)pipe_buffer_map(r300->context.screen, + vbuf->buffer, + PIPE_BUFFER_USAGE_CPU_READ); + map[vbi] += vbuf->buffer_offset >> 2; + stride[vbi] = vbuf->stride >> 2; + } + } BEGIN_CS(10 + count * vertex_size); OUT_CS_REG(R300_GA_COLOR_CONTROL, @@ -138,18 +172,31 @@ static void r300_emit_draw_immediate(struct r300_context *r300, OUT_CS_PKT3(R300_PACKET3_3D_DRAW_IMMD_2, count * vertex_size); OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_EMBEDDED | (count << 16) | r300_translate_primitive(mode)); - //debug_printf("r300: Immd %d verts, %d attrs\n", count, vertex_size); - for (i = 0; i < count * vertex_size; i++) { - if (i % vertex_size == 0) { - //debug_printf("r300: -- vert --\n"); + + /* Emit vertices. */ + for (v = 0; v < count; v++) { + for (i = 0; i < vertex_element_count; i++) { + velem = &r300->vertex_element[i]; + vbi = velem->vertex_buffer_index; + elem_offset = offset[i] + stride[vbi] * (v + start); + + for (dw = 0; dw < size[i]; dw++) { + OUT_CS(map[vbi][elem_offset + dw]); + } } - //debug_printf("r300: 0x%08x\n", *map); - OUT_CS(*map); - map++; } END_CS; - pipe_buffer_unmap(r300->context.screen, vbo); + /* Unmap buffers. */ + for (i = 0; i < vertex_element_count; i++) { + vbi = r300->vertex_element[i].vertex_buffer_index; + + if (map[vbi]) { + vbuf = &r300->vertex_buffer[vbi]; + pipe_buffer_unmap(r300->context.screen, vbuf->buffer); + map[vbi] = 0; + } + } } static void r300_emit_draw_arrays(struct r300_context *r300, @@ -222,16 +269,49 @@ static void r300_emit_draw_elements(struct r300_context *r300, } +static boolean r300_setup_local_vertex_buffers(struct r300_context *r300) +{ + struct pipe_vertex_buffer *vb; + boolean found_local_bo = FALSE, found_managed_bo = FALSE; + unsigned i; + + /* See what buffers we got. */ + for (i = 0; i < r300->vertex_element_count; i++) { + vb = &r300->vertex_buffer[r300->vertex_element[i].vertex_buffer_index]; + if (r300->winsys->buffer_is_local(r300->winsys, vb->buffer)) { + found_local_bo = TRUE; + } else { + found_managed_bo = TRUE; + } + } + + /* If we found both local and managed buffers, make local buffers managed + * because we shouldn't use the immediate mode in case a managed buffer is + * present, due to performance reasons. */ + if (found_local_bo && found_managed_bo) { + for (i = 0; i < r300->vertex_element_count; i++) { + vb = &r300->vertex_buffer[r300->vertex_element[i].vertex_buffer_index]; + if (r300->winsys->buffer_is_local(r300->winsys, vb->buffer)) { + r300->winsys->buffer_make_managed(r300->winsys, vb->buffer); + } + } + } + + return !found_managed_bo; +} + static boolean r300_setup_vertex_buffers(struct r300_context *r300) { struct pipe_vertex_buffer *vbuf = r300->vertex_buffer; struct pipe_vertex_element *velem = r300->vertex_element; + struct pipe_buffer *pbuf; validate: for (int i = 0; i < r300->vertex_element_count; i++) { - if (!r300->winsys->add_buffer(r300->winsys, - vbuf[velem[i].vertex_buffer_index].buffer, - RADEON_GEM_DOMAIN_GTT, 0)) { + pbuf = vbuf[velem[i].vertex_buffer_index].buffer; + + if (!r300->winsys->add_buffer(r300->winsys, pbuf, + RADEON_GEM_DOMAIN_GTT, 0)) { r300->context.flush(&r300->context, 0, NULL); goto validate; } @@ -245,6 +325,7 @@ validate: return TRUE; } + static void r300_shorten_ubyte_elts(struct r300_context* r300, struct pipe_buffer** elts, unsigned count) @@ -365,15 +446,15 @@ void r300_draw_arrays(struct pipe_context* pipe, unsigned mode, r300_emit_buffer_validate(r300); - if (!r300_setup_vertex_buffers(r300)) { - return; - } - - r300_emit_dirty_state(r300); - - if (FALSE && count <= 4 && r300->vertex_buffer_count == 1) { - r300_emit_draw_immediate(r300, mode, start, count); + if (r300_setup_local_vertex_buffers(r300)) { + r300_emit_dirty_state(r300); + r300_emit_draw_arrays_immediate(r300, mode, start, count); } else { + if (!r300_setup_vertex_buffers(r300)) { + return; + } + + r300_emit_dirty_state(r300); r300_emit_aos(r300, start); r300_emit_draw_arrays(r300, mode, count); } diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index e2ec0bc5bd..641e95e7fc 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -924,6 +924,22 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe, r300->dirty_state |= R300_NEW_VERTEX_FORMAT; } +static boolean r300_validate_aos(struct r300_context *r300) +{ + struct pipe_vertex_buffer *vbuf = r300->vertex_buffer; + struct pipe_vertex_element *velem = r300->vertex_element; + int i; + + /* Check if formats and strides are aligned to the size of DWORD. */ + for (i = 0; i < r300->vertex_element_count; i++) { + if (vbuf[velem[i].vertex_buffer_index].stride % 4 != 0 || + util_format_get_blocksize(velem[i].src_format) % 4 != 0) { + return FALSE; + } + } + return TRUE; +} + static void r300_set_vertex_elements(struct pipe_context* pipe, unsigned count, const struct pipe_vertex_element* elements) @@ -939,6 +955,12 @@ static void r300_set_vertex_elements(struct pipe_context* pipe, draw_flush(r300->draw); draw_set_vertex_elements(r300->draw, count, elements); } + + if (!r300_validate_aos(r300)) { + /* XXX We should fallback using draw. */ + assert(0); + abort(); + } } static void* r300_create_vs_state(struct pipe_context* pipe, diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c index 25e1cdcdb6..5214b6d8bc 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c @@ -51,6 +51,23 @@ static const char *radeon_get_name(struct pipe_winsys *ws) return "Radeon/GEM+KMS"; } +uint32_t radeon_domain_from_usage(unsigned usage) +{ + uint32_t domain = 0; + + if (usage & PIPE_BUFFER_USAGE_PIXEL) { + domain |= RADEON_GEM_DOMAIN_VRAM; + } + if (usage & PIPE_BUFFER_USAGE_VERTEX) { + domain |= RADEON_GEM_DOMAIN_GTT; + } + if (usage & PIPE_BUFFER_USAGE_INDEX) { + domain |= RADEON_GEM_DOMAIN_GTT; + } + + return domain; +} + static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws, unsigned alignment, unsigned usage, @@ -71,25 +88,17 @@ static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws, radeon_buffer->base.usage = usage; radeon_buffer->base.size = size; - if (usage == PIPE_BUFFER_USAGE_CONSTANT && is_r3xx(radeon_ws->pci_id)) { + if ((usage == PIPE_BUFFER_USAGE_CONSTANT && is_r3xx(radeon_ws->pci_id)) || + (usage == PIPE_BUFFER_USAGE_VERTEX && size < 512)) { /* Don't bother allocating a BO, as it'll never get to the card. */ + /* Also, create small vertex buffers in RAM. */ desc.alignment = alignment; desc.usage = usage; radeon_buffer->pb = pb_malloc_buffer_create(size, &desc); return &radeon_buffer->base; } - domain = 0; - - if (usage & PIPE_BUFFER_USAGE_PIXEL) { - domain |= RADEON_GEM_DOMAIN_VRAM; - } - if (usage & PIPE_BUFFER_USAGE_VERTEX) { - domain |= RADEON_GEM_DOMAIN_GTT; - } - if (usage & PIPE_BUFFER_USAGE_INDEX) { - domain |= RADEON_GEM_DOMAIN_GTT; - } + domain = radeon_domain_from_usage(usage); radeon_buffer->bo = radeon_bo_open(radeon_ws->priv->bom, 0, size, alignment, domain, 0); @@ -222,6 +231,54 @@ static void radeon_buffer_set_tiling(struct radeon_winsys *ws, radeon_bo_set_tiling(radeon_buffer->bo, flags, pitch); } +static boolean radeon_buffer_is_local(struct radeon_winsys *ws, + struct pipe_buffer *buffer) +{ + struct radeon_pipe_buffer *radeon_buffer = + (struct radeon_pipe_buffer*)buffer; + + return radeon_buffer->pb != NULL; +} + +static void radeon_buffer_make_managed(struct radeon_winsys *ws, + struct pipe_buffer *buffer) +{ + struct radeon_pipe_buffer* radeon_buffer = + (struct radeon_pipe_buffer*)buffer; + uint32_t domain; + void *map; + + if (radeon_buffer->pb) { + domain = radeon_domain_from_usage(buffer->usage); + + /* Create a managed buffer. */ + radeon_buffer->bo = radeon_bo_open(ws->priv->bom, 0, + buffer->size, buffer->alignment, + domain, 0); + if (radeon_buffer->bo == NULL) { + /* XXX What now? */ + fprintf(stderr, "radeon: cannot create a buffer in function %s\n", + __FUNCTION__); + assert(0); + abort(); + } + + /* Move data. */ + radeon_bo_map(radeon_buffer->bo, 1); + map = pb_map(radeon_buffer->pb, PIPE_BUFFER_USAGE_CPU_READ); + + memcpy(radeon_buffer->bo->ptr, map, buffer->size); + + pb_unmap(radeon_buffer->pb); + radeon_bo_unmap(radeon_buffer->bo); + + /* Release the locally-created buffer. */ + pipe_reference_init(&radeon_buffer->pb->base.reference, 0); + pb_destroy(radeon_buffer->pb); + radeon_buffer->pb = 0; + } +} + static void radeon_fence_reference(struct pipe_winsys *ws, struct pipe_fence_handle **ptr, struct pipe_fence_handle *pfence) @@ -325,6 +382,8 @@ struct radeon_winsys* radeon_pipe_winsys(int fd) radeon_ws->base.get_name = radeon_get_name; radeon_ws->buffer_set_tiling = radeon_buffer_set_tiling; + radeon_ws->buffer_is_local = radeon_buffer_is_local; + radeon_ws->buffer_make_managed = radeon_buffer_make_managed; return radeon_ws; } diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h index de71cb2f42..c46abff793 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h @@ -77,6 +77,8 @@ struct radeon_winsys_priv { void *flush_data; }; +uint32_t radeon_domain_from_usage(unsigned usage); + struct radeon_winsys* radeon_pipe_winsys(int fb); #if 0 struct pipe_surface *radeon_surface_from_handle(struct radeon_context *radeon_context, diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.h b/src/gallium/winsys/drm/radeon/core/radeon_drm.h index ddd7983824..077388ee02 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.h @@ -81,7 +81,7 @@ void radeon_destroy_drm_api(struct drm_api* api); /* Guess at whether this chipset should use r300g. * * I believe that this check is valid, but I haven't been exhaustive. */ -static boolean is_r3xx(int pciid) +static INLINE boolean is_r3xx(int pciid) { return (pciid > 0x3150) && (pciid < 0x796f); } diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 0253bc2527..d759beaba1 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -81,9 +81,13 @@ static void radeon_write_cs_reloc(struct radeon_winsys* winsys, uint32_t flags) { int retval = 0; + struct radeon_pipe_buffer* radeon_buffer = + (struct radeon_pipe_buffer*)pbuffer; - retval = radeon_cs_write_reloc(winsys->priv->cs, - ((struct radeon_pipe_buffer*)pbuffer)->bo, rd, wd, flags); + assert(!radeon_buffer->pb); + + retval = radeon_cs_write_reloc(winsys->priv->cs, radeon_buffer->bo, + rd, wd, flags); if (retval) { debug_printf("radeon: Relocation of %p (%d, %d, %d) failed!\n", diff --git a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h index 864082b99b..462fba844e 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h @@ -106,6 +106,12 @@ struct radeon_winsys { uint32_t pitch, boolean microtiled, boolean macrotiled); + + boolean (*buffer_is_local)(struct radeon_winsys* winsys, + struct pipe_buffer* buffer); + + void (*buffer_make_managed)(struct radeon_winsys* winsys, + struct pipe_buffer* buffer); }; #endif -- cgit v1.2.3 From 8cf1af45075a1bf8c302a513566b7ef2314264b7 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 25 Jan 2010 01:12:30 -0800 Subject: gallium-docs: Add note on scissor. --- src/gallium/docs/source/context.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst index b7b625d25e..78b01cc9cb 100644 --- a/src/gallium/docs/source/context.rst +++ b/src/gallium/docs/source/context.rst @@ -54,7 +54,10 @@ objects. They all follow simple, one-method binding calls, e.g. * ``set_blend_color`` * ``set_clip_state`` * ``set_polygon_stipple`` -* ``set_scissor_state`` +* ``set_scissor_state`` sets the bounds for the scissor test, which culls + pixels before blending to render targets. If the :ref:`Rasterizer` does + not have the scissor test enabled, then the scissor bounds never need to + be set since they will not be used. * ``set_viewport_state`` * ``set_vertex_elements`` -- cgit v1.2.3 From 16cf7e14a6dee85fadc0ab4e7c066288c3362352 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 21 Jan 2010 21:28:14 +0100 Subject: st/xorg: Fix warning --- src/gallium/state_trackers/xorg/xorg_dri2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c index 468563e34c..83dc92e7fa 100644 --- a/src/gallium/state_trackers/xorg/xorg_dri2.c +++ b/src/gallium/state_trackers/xorg/xorg_dri2.c @@ -375,6 +375,7 @@ xorg_dri2_init(ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; modesettingPtr ms = modesettingPTR(pScrn); DRI2InfoRec dri2info; +#if DRI2INFOREC_VERSION >= 2 int major, minor; if (xf86LoaderCheckSymbol("DRI2Version")) { @@ -384,6 +385,7 @@ xorg_dri2_init(ScreenPtr pScreen) major = 1; minor = 0; } +#endif dri2info.version = DRI2INFOREC_VERSION; dri2info.fd = ms->fd; -- cgit v1.2.3 From 36fd55f9f03b00263ee1ccf22bbb50e5ba048e80 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 21 Jan 2010 21:23:22 +0100 Subject: st/xorg: Export helper function for detecting modesetting --- src/gallium/state_trackers/xorg/xorg_driver.c | 22 ++++++++++++++++++++++ src/gallium/state_trackers/xorg/xorg_winsys.h | 1 + 2 files changed, 23 insertions(+) diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index 41bfcd0f5e..c180f0b156 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -110,6 +110,28 @@ xorg_tracker_set_functions(ScrnInfoPtr scrn) scrn->ValidMode = drv_valid_mode; } +Bool +xorg_tracker_have_modesetting(ScrnInfoPtr pScrn, struct pci_device *device) +{ + char *BusID = xalloc(64); + sprintf(BusID, "pci:%04x:%02x:%02x.%d", + device->domain, device->bus, + device->dev, device->func); + + if (drmCheckModesettingSupported(BusID)) { + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0, + "Drm modesetting not supported %s\n", BusID); + xfree(BusID); + return FALSE; + } + + xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0, + "Drm modesetting supported on %s\n", BusID); + + xfree(BusID); + return TRUE; +} + /* * Internal function definitions diff --git a/src/gallium/state_trackers/xorg/xorg_winsys.h b/src/gallium/state_trackers/xorg/xorg_winsys.h index 47ee4b9ffd..865733bca2 100644 --- a/src/gallium/state_trackers/xorg/xorg_winsys.h +++ b/src/gallium/state_trackers/xorg/xorg_winsys.h @@ -45,5 +45,6 @@ void xorg_tracker_set_functions(ScrnInfoPtr scrn); const OptionInfoRec * xorg_tracker_available_options(int chipid, int busid); +Bool xorg_tracker_have_modesetting(ScrnInfoPtr pScrn, struct pci_device *device); #endif -- cgit v1.2.3 From a3b783ea294f348bf3424eeb4170dd7f0741519a Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 21 Jan 2010 21:32:28 +0100 Subject: vmware/xorg: Export pci_probe function for ugly chain-loading --- src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c b/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c index 4b208719ca..cd273d091f 100644 --- a/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c +++ b/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c @@ -34,10 +34,10 @@ #include "vmw_hook.h" static void vmw_xorg_identify(int flags); -static Bool vmw_xorg_pci_probe(DriverPtr driver, - int entity_num, - struct pci_device *device, - intptr_t match_data); +_X_EXPORT Bool vmw_xorg_pci_probe(DriverPtr driver, + int entity_num, + struct pci_device *device, + intptr_t match_data); static const struct pci_id_match vmw_xorg_device_match[] = { {0x15ad, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0}, @@ -126,7 +126,7 @@ vmw_xorg_identify(int flags) vmw_xorg_chipsets); } -static Bool +_X_EXPORT Bool vmw_xorg_pci_probe(DriverPtr driver, int entity_num, struct pci_device *device, intptr_t match_data) { -- cgit v1.2.3 From 0b482c4fbe69a807bb69bf92f37e362f818c664d Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 22 Jan 2010 18:28:40 +0100 Subject: st/xorg: Improve options and print them to log Set 2D acceleration to off by default Get fallback debugging from the Xorg config Also print if 3D acceleration is enabled --- src/gallium/state_trackers/xorg/xorg_driver.c | 20 +++++++++++++++++--- src/gallium/state_trackers/xorg/xorg_tracker.h | 1 + 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index c180f0b156..0ff6c52915 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -78,11 +78,13 @@ typedef enum { OPTION_SW_CURSOR, OPTION_2D_ACCEL, + OPTION_DEBUG_FALLBACK, } drv_option_enums; static const OptionInfoRec drv_options[] = { {OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE}, {OPTION_2D_ACCEL, "2DAccel", OPTV_BOOLEAN, {0}, FALSE}, + {OPTION_DEBUG_FALLBACK, "DebugFallback", OPTV_BOOLEAN, {0}, FALSE}, {-1, NULL, OPTV_NONE, {0}, FALSE} }; @@ -670,10 +672,11 @@ drv_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) xf86SetBlackWhitePixels(pScreen); + ms->accelerate_2d = xf86ReturnOptValBool(ms->Options, OPTION_2D_ACCEL, FALSE); + ms->debug_fallback = xf86ReturnOptValBool(ms->Options, OPTION_DEBUG_FALLBACK, TRUE); + if (ms->screen) { - ms->exa = xorg_exa_init(pScrn, xf86ReturnOptValBool(ms->Options, - OPTION_2D_ACCEL, TRUE)); - ms->debug_fallback = debug_get_bool_option("XORG_DEBUG_FALLBACK", TRUE); + ms->exa = xorg_exa_init(pScrn, ms->accelerate_2d); xorg_xv_init(pScreen); #ifdef DRI2 @@ -681,6 +684,17 @@ drv_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) #endif } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "2D Acceleration is %s\n", + ms->screen && ms->accelerate_2d ? "enabled" : "disabled"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Fallback debugging is %s\n", + ms->debug_fallback ? "enabled" : "disabled"); +#ifdef DRI2 + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "3D Acceleration is %s\n", + ms->screen ? "enabled" : "disabled"); +#else + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "3D Acceleration is disabled\n"); +#endif + miInitializeBackingStore(pScreen); xf86SetBackingStore(pScreen); xf86SetSilkenMouse(pScreen); diff --git a/src/gallium/state_trackers/xorg/xorg_tracker.h b/src/gallium/state_trackers/xorg/xorg_tracker.h index c0cfbe6061..b5915d2a42 100644 --- a/src/gallium/state_trackers/xorg/xorg_tracker.h +++ b/src/gallium/state_trackers/xorg/xorg_tracker.h @@ -112,6 +112,7 @@ typedef struct _modesettingRec /* exa */ struct exa_context *exa; Bool noEvict; + Bool accelerate_2d; Bool debug_fallback; /* winsys hocks */ -- cgit v1.2.3 From 6877c5de3c3ff39da514a74928ea270138cddff9 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 25 Jan 2010 12:27:47 +0100 Subject: vmware/xorg: Do buffer round-robin logic differently --- src/gallium/winsys/drm/vmware/xorg/vmw_video.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_video.c b/src/gallium/winsys/drm/vmware/xorg/vmw_video.c index b065b96346..ff3b992d07 100644 --- a/src/gallium/winsys/drm/vmware/xorg/vmw_video.c +++ b/src/gallium/winsys/drm/vmware/xorg/vmw_video.c @@ -649,7 +649,8 @@ vmw_video_port_play(ScrnInfoPtr pScrn, struct vmw_video_port *port, return XvBadAlloc; } - port->currBuf = ++port->currBuf & (VMWARE_VID_NUM_BUFFERS - 1); + if (++(port->currBuf) >= VMWARE_VID_NUM_BUFFERS) + port->currBuf = 0; return Success; } -- cgit v1.2.3 From 4c082faa7e0887205fe9158320884c177f416b80 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 25 Jan 2010 11:54:54 +0000 Subject: llvmpipe: Remove lp_tex_sample_c.c again. Popped back to life in some merge. Not necessary even as a reference, since it is identical to softpipe's sp_tex_sample.c with renamed symbols. --- src/gallium/drivers/llvmpipe/lp_tex_sample_c.c | 1712 ------------------------ 1 file changed, 1712 deletions(-) delete mode 100644 src/gallium/drivers/llvmpipe/lp_tex_sample_c.c diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample_c.c b/src/gallium/drivers/llvmpipe/lp_tex_sample_c.c deleted file mode 100644 index d1f5d9505d..0000000000 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample_c.c +++ /dev/null @@ -1,1712 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * Copyright 2008 VMware, Inc. All rights reserved. - * - * 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, sub license, 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. - * - **************************************************************************/ - -/** - * Texture sampling - * - * Authors: - * Brian Paul - */ - -#include "lp_context.h" -#include "lp_quad.h" -#include "lp_texture.h" -#include "lp_tex_sample.h" -#include "lp_tex_cache.h" -#include "pipe/p_context.h" -#include "pipe/p_defines.h" -#include "pipe/p_shader_tokens.h" -#include "util/u_math.h" -#include "util/u_memory.h" - - - -/* - * Note, the FRAC macro has to work perfectly. Otherwise you'll sometimes - * see 1-pixel bands of improperly weighted linear-filtered textures. - * The tests/texwrap.c demo is a good test. - * Also note, FRAC(x) doesn't truly return the fractional part of x for x < 0. - * Instead, if x < 0 then FRAC(x) = 1 - true_frac(x). - */ -#define FRAC(f) ((f) - util_ifloor(f)) - - -/** - * Linear interpolation macro - */ -static INLINE float -lerp(float a, float v0, float v1) -{ - return v0 + a * (v1 - v0); -} - - -/** - * Do 2D/biliner interpolation of float values. - * v00, v10, v01 and v11 are typically four texture samples in a square/box. - * a and b are the horizontal and vertical interpolants. - * It's important that this function is inlined when compiled with - * optimization! If we find that's not true on some systems, convert - * to a macro. - */ -static INLINE float -lerp_2d(float a, float b, - float v00, float v10, float v01, float v11) -{ - const float temp0 = lerp(a, v00, v10); - const float temp1 = lerp(a, v01, v11); - return lerp(b, temp0, temp1); -} - - -/** - * As above, but 3D interpolation of 8 values. - */ -static INLINE float -lerp_3d(float a, float b, float c, - float v000, float v100, float v010, float v110, - float v001, float v101, float v011, float v111) -{ - const float temp0 = lerp_2d(a, b, v000, v100, v010, v110); - const float temp1 = lerp_2d(a, b, v001, v101, v011, v111); - return lerp(c, temp0, temp1); -} - - - -/** - * If A is a signed integer, A % B doesn't give the right value for A < 0 - * (in terms of texture repeat). Just casting to unsigned fixes that. - */ -#define REMAINDER(A, B) ((unsigned) (A) % (unsigned) (B)) - - -/** - * Apply texture coord wrapping mode and return integer texture indexes - * for a vector of four texcoords (S or T or P). - * \param wrapMode PIPE_TEX_WRAP_x - * \param s the incoming texcoords - * \param size the texture image size - * \param icoord returns the integer texcoords - * \return integer texture index - */ -static INLINE void -nearest_texcoord_4(unsigned wrapMode, const float s[4], unsigned size, - int icoord[4]) -{ - uint ch; - switch (wrapMode) { - case PIPE_TEX_WRAP_REPEAT: - /* s limited to [0,1) */ - /* i limited to [0,size-1] */ - for (ch = 0; ch < 4; ch++) { - int i = util_ifloor(s[ch] * size); - icoord[ch] = REMAINDER(i, size); - } - return; - case PIPE_TEX_WRAP_CLAMP: - /* s limited to [0,1] */ - /* i limited to [0,size-1] */ - for (ch = 0; ch < 4; ch++) { - if (s[ch] <= 0.0F) - icoord[ch] = 0; - else if (s[ch] >= 1.0F) - icoord[ch] = size - 1; - else - icoord[ch] = util_ifloor(s[ch] * size); - } - return; - case PIPE_TEX_WRAP_CLAMP_TO_EDGE: - { - /* s limited to [min,max] */ - /* i limited to [0, size-1] */ - const float min = 1.0F / (2.0F * size); - const float max = 1.0F - min; - for (ch = 0; ch < 4; ch++) { - if (s[ch] < min) - icoord[ch] = 0; - else if (s[ch] > max) - icoord[ch] = size - 1; - else - icoord[ch] = util_ifloor(s[ch] * size); - } - } - return; - case PIPE_TEX_WRAP_CLAMP_TO_BORDER: - { - /* s limited to [min,max] */ - /* i limited to [-1, size] */ - const float min = -1.0F / (2.0F * size); - const float max = 1.0F - min; - for (ch = 0; ch < 4; ch++) { - if (s[ch] <= min) - icoord[ch] = -1; - else if (s[ch] >= max) - icoord[ch] = size; - else - icoord[ch] = util_ifloor(s[ch] * size); - } - } - return; - case PIPE_TEX_WRAP_MIRROR_REPEAT: - { - const float min = 1.0F / (2.0F * size); - const float max = 1.0F - min; - for (ch = 0; ch < 4; ch++) { - const int flr = util_ifloor(s[ch]); - float u; - if (flr & 1) - u = 1.0F - (s[ch] - (float) flr); - else - u = s[ch] - (float) flr; - if (u < min) - icoord[ch] = 0; - else if (u > max) - icoord[ch] = size - 1; - else - icoord[ch] = util_ifloor(u * size); - } - } - return; - case PIPE_TEX_WRAP_MIRROR_CLAMP: - for (ch = 0; ch < 4; ch++) { - /* s limited to [0,1] */ - /* i limited to [0,size-1] */ - const float u = fabsf(s[ch]); - if (u <= 0.0F) - icoord[ch] = 0; - else if (u >= 1.0F) - icoord[ch] = size - 1; - else - icoord[ch] = util_ifloor(u * size); - } - return; - case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE: - { - /* s limited to [min,max] */ - /* i limited to [0, size-1] */ - const float min = 1.0F / (2.0F * size); - const float max = 1.0F - min; - for (ch = 0; ch < 4; ch++) { - const float u = fabsf(s[ch]); - if (u < min) - icoord[ch] = 0; - else if (u > max) - icoord[ch] = size - 1; - else - icoord[ch] = util_ifloor(u * size); - } - } - return; - case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER: - { - /* s limited to [min,max] */ - /* i limited to [0, size-1] */ - const float min = -1.0F / (2.0F * size); - const float max = 1.0F - min; - for (ch = 0; ch < 4; ch++) { - const float u = fabsf(s[ch]); - if (u < min) - icoord[ch] = -1; - else if (u > max) - icoord[ch] = size; - else - icoord[ch] = util_ifloor(u * size); - } - } - return; - default: - assert(0); - } -} - - -/** - * Used to compute texel locations for linear sampling for four texcoords. - * \param wrapMode PIPE_TEX_WRAP_x - * \param s the texcoords - * \param size the texture image size - * \param icoord0 returns first texture indexes - * \param icoord1 returns second texture indexes (usually icoord0 + 1) - * \param w returns blend factor/weight between texture indexes - * \param icoord returns the computed integer texture coords - */ -static INLINE void -linear_texcoord_4(unsigned wrapMode, const float s[4], unsigned size, - int icoord0[4], int icoord1[4], float w[4]) -{ - uint ch; - - switch (wrapMode) { - case PIPE_TEX_WRAP_REPEAT: - for (ch = 0; ch < 4; ch++) { - float u = s[ch] * size - 0.5F; - icoord0[ch] = REMAINDER(util_ifloor(u), size); - icoord1[ch] = REMAINDER(icoord0[ch] + 1, size); - w[ch] = FRAC(u); - } - break;; - case PIPE_TEX_WRAP_CLAMP: - for (ch = 0; ch < 4; ch++) { - float u = CLAMP(s[ch], 0.0F, 1.0F); - u = u * size - 0.5f; - icoord0[ch] = util_ifloor(u); - icoord1[ch] = icoord0[ch] + 1; - w[ch] = FRAC(u); - } - break;; - case PIPE_TEX_WRAP_CLAMP_TO_EDGE: - for (ch = 0; ch < 4; ch++) { - float u = CLAMP(s[ch], 0.0F, 1.0F); - u = u * size - 0.5f; - icoord0[ch] = util_ifloor(u); - icoord1[ch] = icoord0[ch] + 1; - if (icoord0[ch] < 0) - icoord0[ch] = 0; - if (icoord1[ch] >= (int) size) - icoord1[ch] = size - 1; - w[ch] = FRAC(u); - } - break;; - case PIPE_TEX_WRAP_CLAMP_TO_BORDER: - { - const float min = -1.0F / (2.0F * size); - const float max = 1.0F - min; - for (ch = 0; ch < 4; ch++) { - float u = CLAMP(s[ch], min, max); - u = u * size - 0.5f; - icoord0[ch] = util_ifloor(u); - icoord1[ch] = icoord0[ch] + 1; - w[ch] = FRAC(u); - } - } - break;; - case PIPE_TEX_WRAP_MIRROR_REPEAT: - for (ch = 0; ch < 4; ch++) { - const int flr = util_ifloor(s[ch]); - float u; - if (flr & 1) - u = 1.0F - (s[ch] - (float) flr); - else - u = s[ch] - (float) flr; - u = u * size - 0.5F; - icoord0[ch] = util_ifloor(u); - icoord1[ch] = icoord0[ch] + 1; - if (icoord0[ch] < 0) - icoord0[ch] = 0; - if (icoord1[ch] >= (int) size) - icoord1[ch] = size - 1; - w[ch] = FRAC(u); - } - break;; - case PIPE_TEX_WRAP_MIRROR_CLAMP: - for (ch = 0; ch < 4; ch++) { - float u = fabsf(s[ch]); - if (u >= 1.0F) - u = (float) size; - else - u *= size; - u -= 0.5F; - icoord0[ch] = util_ifloor(u); - icoord1[ch] = icoord0[ch] + 1; - w[ch] = FRAC(u); - } - break;; - case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE: - for (ch = 0; ch < 4; ch++) { - float u = fabsf(s[ch]); - if (u >= 1.0F) - u = (float) size; - else - u *= size; - u -= 0.5F; - icoord0[ch] = util_ifloor(u); - icoord1[ch] = icoord0[ch] + 1; - if (icoord0[ch] < 0) - icoord0[ch] = 0; - if (icoord1[ch] >= (int) size) - icoord1[ch] = size - 1; - w[ch] = FRAC(u); - } - break;; - case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER: - { - const float min = -1.0F / (2.0F * size); - const float max = 1.0F - min; - for (ch = 0; ch < 4; ch++) { - float u = fabsf(s[ch]); - if (u <= min) - u = min * size; - else if (u >= max) - u = max * size; - else - u *= size; - u -= 0.5F; - icoord0[ch] = util_ifloor(u); - icoord1[ch] = icoord0[ch] + 1; - w[ch] = FRAC(u); - } - } - break;; - default: - assert(0); - } -} - - -/** - * For RECT textures / unnormalized texcoords - * Only a subset of wrap modes supported. - */ -static INLINE void -nearest_texcoord_unnorm_4(unsigned wrapMode, const float s[4], unsigned size, - int icoord[4]) -{ - uint ch; - switch (wrapMode) { - case PIPE_TEX_WRAP_CLAMP: - for (ch = 0; ch < 4; ch++) { - int i = util_ifloor(s[ch]); - icoord[ch]= CLAMP(i, 0, (int) size-1); - } - return; - case PIPE_TEX_WRAP_CLAMP_TO_EDGE: - /* fall-through */ - case PIPE_TEX_WRAP_CLAMP_TO_BORDER: - for (ch = 0; ch < 4; ch++) { - icoord[ch]= util_ifloor( CLAMP(s[ch], 0.5F, (float) size - 0.5F) ); - } - return; - default: - assert(0); - } -} - - -/** - * For RECT textures / unnormalized texcoords. - * Only a subset of wrap modes supported. - */ -static INLINE void -linear_texcoord_unnorm_4(unsigned wrapMode, const float s[4], unsigned size, - int icoord0[4], int icoord1[4], float w[4]) -{ - uint ch; - switch (wrapMode) { - case PIPE_TEX_WRAP_CLAMP: - for (ch = 0; ch < 4; ch++) { - /* Not exactly what the spec says, but it matches NVIDIA output */ - float u = CLAMP(s[ch] - 0.5F, 0.0f, (float) size - 1.0f); - icoord0[ch] = util_ifloor(u); - icoord1[ch] = icoord0[ch] + 1; - w[ch] = FRAC(u); - } - return; - case PIPE_TEX_WRAP_CLAMP_TO_EDGE: - /* fall-through */ - case PIPE_TEX_WRAP_CLAMP_TO_BORDER: - for (ch = 0; ch < 4; ch++) { - float u = CLAMP(s[ch], 0.5F, (float) size - 0.5F); - u -= 0.5F; - icoord0[ch] = util_ifloor(u); - icoord1[ch] = icoord0[ch] + 1; - if (icoord1[ch] > (int) size - 1) - icoord1[ch] = size - 1; - w[ch] = FRAC(u); - } - break; - default: - assert(0); - } -} - - -static unsigned -choose_cube_face(float rx, float ry, float rz, float *newS, float *newT) -{ - /* - major axis - direction target sc tc ma - ---------- ------------------------------- --- --- --- - +rx TEXTURE_CUBE_MAP_POSITIVE_X_EXT -rz -ry rx - -rx TEXTURE_CUBE_MAP_NEGATIVE_X_EXT +rz -ry rx - +ry TEXTURE_CUBE_MAP_POSITIVE_Y_EXT +rx +rz ry - -ry TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT +rx -rz ry - +rz TEXTURE_CUBE_MAP_POSITIVE_Z_EXT +rx -ry rz - -rz TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT -rx -ry rz - */ - const float arx = fabsf(rx), ary = fabsf(ry), arz = fabsf(rz); - unsigned face; - float sc, tc, ma; - - if (arx > ary && arx > arz) { - if (rx >= 0.0F) { - face = PIPE_TEX_FACE_POS_X; - sc = -rz; - tc = -ry; - ma = arx; - } - else { - face = PIPE_TEX_FACE_NEG_X; - sc = rz; - tc = -ry; - ma = arx; - } - } - else if (ary > arx && ary > arz) { - if (ry >= 0.0F) { - face = PIPE_TEX_FACE_POS_Y; - sc = rx; - tc = rz; - ma = ary; - } - else { - face = PIPE_TEX_FACE_NEG_Y; - sc = rx; - tc = -rz; - ma = ary; - } - } - else { - if (rz > 0.0F) { - face = PIPE_TEX_FACE_POS_Z; - sc = rx; - tc = -ry; - ma = arz; - } - else { - face = PIPE_TEX_FACE_NEG_Z; - sc = -rx; - tc = -ry; - ma = arz; - } - } - - *newS = ( sc / ma + 1.0F ) * 0.5F; - *newT = ( tc / ma + 1.0F ) * 0.5F; - - return face; -} - - -/** - * Examine the quad's texture coordinates to compute the partial - * derivatives w.r.t X and Y, then compute lambda (level of detail). - * - * This is only done for fragment shaders, not vertex shaders. - */ -static float -compute_lambda(struct tgsi_sampler *tgsi_sampler, - const float s[QUAD_SIZE], - const float t[QUAD_SIZE], - const float p[QUAD_SIZE], - float lodbias) -{ - const struct lp_shader_sampler *samp = lp_shader_sampler(tgsi_sampler); - const struct pipe_texture *texture = samp->texture; - const struct pipe_sampler_state *sampler = samp->sampler; - float rho, lambda; - - if (samp->processor == TGSI_PROCESSOR_VERTEX) - return lodbias; - - assert(sampler->normalized_coords); - - assert(s); - { - float dsdx = s[QUAD_BOTTOM_RIGHT] - s[QUAD_BOTTOM_LEFT]; - float dsdy = s[QUAD_TOP_LEFT] - s[QUAD_BOTTOM_LEFT]; - dsdx = fabsf(dsdx); - dsdy = fabsf(dsdy); - rho = MAX2(dsdx, dsdy) * texture->width[0]; - } - if (t) { - float dtdx = t[QUAD_BOTTOM_RIGHT] - t[QUAD_BOTTOM_LEFT]; - float dtdy = t[QUAD_TOP_LEFT] - t[QUAD_BOTTOM_LEFT]; - float max; - dtdx = fabsf(dtdx); - dtdy = fabsf(dtdy); - max = MAX2(dtdx, dtdy) * texture->height[0]; - rho = MAX2(rho, max); - } - if (p) { - float dpdx = p[QUAD_BOTTOM_RIGHT] - p[QUAD_BOTTOM_LEFT]; - float dpdy = p[QUAD_TOP_LEFT] - p[QUAD_BOTTOM_LEFT]; - float max; - dpdx = fabsf(dpdx); - dpdy = fabsf(dpdy); - max = MAX2(dpdx, dpdy) * texture->depth[0]; - rho = MAX2(rho, max); - } - - lambda = util_fast_log2(rho); - lambda += lodbias + sampler->lod_bias; - lambda = CLAMP(lambda, sampler->min_lod, sampler->max_lod); - - return lambda; -} - - -/** - * Do several things here: - * 1. Compute lambda from the texcoords, if needed - * 2. Determine if we're minifying or magnifying - * 3. If minifying, choose mipmap levels - * 4. Return image filter to use within mipmap images - * \param level0 Returns first mipmap level to sample from - * \param level1 Returns second mipmap level to sample from - * \param levelBlend Returns blend factor between levels, in [0,1] - * \param imgFilter Returns either the min or mag filter, depending on lambda - */ -static void -choose_mipmap_levels(struct tgsi_sampler *tgsi_sampler, - const float s[QUAD_SIZE], - const float t[QUAD_SIZE], - const float p[QUAD_SIZE], - float lodbias, - unsigned *level0, unsigned *level1, float *levelBlend, - unsigned *imgFilter) -{ - const struct lp_shader_sampler *samp = lp_shader_sampler(tgsi_sampler); - const struct pipe_texture *texture = samp->texture; - const struct pipe_sampler_state *sampler = samp->sampler; - - if (sampler->min_mip_filter == PIPE_TEX_MIPFILTER_NONE) { - /* no mipmap selection needed */ - *level0 = *level1 = CLAMP((int) sampler->min_lod, - 0, (int) texture->last_level); - - if (sampler->min_img_filter != sampler->mag_img_filter) { - /* non-mipmapped texture, but still need to determine if doing - * minification or magnification. - */ - float lambda = compute_lambda(tgsi_sampler, s, t, p, lodbias); - if (lambda <= 0.0) { - *imgFilter = sampler->mag_img_filter; - } - else { - *imgFilter = sampler->min_img_filter; - } - } - else { - *imgFilter = sampler->mag_img_filter; - } - } - else { - float lambda = compute_lambda(tgsi_sampler, s, t, p, lodbias); - - if (lambda <= 0.0) { /* XXX threshold depends on the filter */ - /* magnifying */ - *imgFilter = sampler->mag_img_filter; - *level0 = *level1 = 0; - } - else { - /* minifying */ - *imgFilter = sampler->min_img_filter; - - /* choose mipmap level(s) and compute the blend factor between them */ - if (sampler->min_mip_filter == PIPE_TEX_MIPFILTER_NEAREST) { - /* Nearest mipmap level */ - const int lvl = (int) (lambda + 0.5); - *level0 = - *level1 = CLAMP(lvl, 0, (int) texture->last_level); - } - else { - /* Linear interpolation between mipmap levels */ - const int lvl = (int) lambda; - *level0 = CLAMP(lvl, 0, (int) texture->last_level); - *level1 = CLAMP(lvl + 1, 0, (int) texture->last_level); - *levelBlend = FRAC(lambda); /* blending weight between levels */ - } - } - } -} - - -/** - * Get a texel from a texture, using the texture tile cache. - * - * \param face the cube face in 0..5 - * \param level the mipmap level - * \param x the x coord of texel within 2D image - * \param y the y coord of texel within 2D image - * \param z which slice of a 3D texture - * \param rgba the quad to put the texel/color into - * \param j which element of the rgba quad to write to - * - * XXX maybe move this into lp_tile_cache.c and merge with the - * lp_get_cached_tile_tex() function. Also, get 4 texels instead of 1... - */ -static void -get_texel_quad_2d(const struct tgsi_sampler *tgsi_sampler, - unsigned face, unsigned level, int x, int y, - const uint8_t *out[4]) -{ - const struct lp_shader_sampler *samp = lp_shader_sampler(tgsi_sampler); - - const struct llvmpipe_cached_tex_tile *tile - = lp_get_cached_tex_tile(samp->cache, - tex_tile_address(x, y, 0, face, level)); - - y %= TEX_TILE_SIZE; - x %= TEX_TILE_SIZE; - - out[0] = &tile->color[y ][x ][0]; - out[1] = &tile->color[y ][x+1][0]; - out[2] = &tile->color[y+1][x ][0]; - out[3] = &tile->color[y+1][x+1][0]; -} - -static INLINE const uint8_t * -get_texel_2d_ptr(const struct tgsi_sampler *tgsi_sampler, - unsigned face, unsigned level, int x, int y) -{ - const struct lp_shader_sampler *samp = lp_shader_sampler(tgsi_sampler); - - const struct llvmpipe_cached_tex_tile *tile - = lp_get_cached_tex_tile(samp->cache, - tex_tile_address(x, y, 0, face, level)); - - y %= TEX_TILE_SIZE; - x %= TEX_TILE_SIZE; - - return &tile->color[y][x][0]; -} - - -static void -get_texel_quad_2d_mt(const struct tgsi_sampler *tgsi_sampler, - unsigned face, unsigned level, - int x0, int y0, - int x1, int y1, - const uint8_t *out[4]) -{ - unsigned i; - - for (i = 0; i < 4; i++) { - unsigned tx = (i & 1) ? x1 : x0; - unsigned ty = (i >> 1) ? y1 : y0; - - out[i] = get_texel_2d_ptr( tgsi_sampler, face, level, tx, ty ); - } -} - -static void -get_texel(const struct tgsi_sampler *tgsi_sampler, - unsigned face, unsigned level, int x, int y, int z, - float rgba[NUM_CHANNELS][QUAD_SIZE], unsigned j) -{ - const struct lp_shader_sampler *samp = lp_shader_sampler(tgsi_sampler); - const struct pipe_texture *texture = samp->texture; - const struct pipe_sampler_state *sampler = samp->sampler; - - if (x < 0 || x >= (int) texture->width[level] || - y < 0 || y >= (int) texture->height[level] || - z < 0 || z >= (int) texture->depth[level]) { - rgba[0][j] = sampler->border_color[0]; - rgba[1][j] = sampler->border_color[1]; - rgba[2][j] = sampler->border_color[2]; - rgba[3][j] = sampler->border_color[3]; - } - else { - const unsigned tx = x % TEX_TILE_SIZE; - const unsigned ty = y % TEX_TILE_SIZE; - const struct llvmpipe_cached_tex_tile *tile; - - tile = lp_get_cached_tex_tile(samp->cache, - tex_tile_address(x, y, z, face, level)); - - rgba[0][j] = ubyte_to_float(tile->color[ty][tx][0]); - rgba[1][j] = ubyte_to_float(tile->color[ty][tx][1]); - rgba[2][j] = ubyte_to_float(tile->color[ty][tx][2]); - rgba[3][j] = ubyte_to_float(tile->color[ty][tx][3]); - if (0) - { - debug_printf("Get texel %f %f %f %f from %s\n", - rgba[0][j], rgba[1][j], rgba[2][j], rgba[3][j], - pf_name(texture->format)); - } - } -} - - -/** - * Compare texcoord 'p' (aka R) against texture value 'rgba[0]' - * When we sampled the depth texture, the depth value was put into all - * RGBA channels. We look at the red channel here. - * \param rgba quad of (depth) texel values - * \param p texture 'P' components for four pixels in quad - * \param j which pixel in the quad to test [0..3] - */ -static INLINE void -shadow_compare(const struct pipe_sampler_state *sampler, - float rgba[NUM_CHANNELS][QUAD_SIZE], - const float p[QUAD_SIZE], - uint j) -{ - int k; - switch (sampler->compare_func) { - case PIPE_FUNC_LESS: - k = p[j] < rgba[0][j]; - break; - case PIPE_FUNC_LEQUAL: - k = p[j] <= rgba[0][j]; - break; - case PIPE_FUNC_GREATER: - k = p[j] > rgba[0][j]; - break; - case PIPE_FUNC_GEQUAL: - k = p[j] >= rgba[0][j]; - break; - case PIPE_FUNC_EQUAL: - k = p[j] == rgba[0][j]; - break; - case PIPE_FUNC_NOTEQUAL: - k = p[j] != rgba[0][j]; - break; - case PIPE_FUNC_ALWAYS: - k = 1; - break; - case PIPE_FUNC_NEVER: - k = 0; - break; - default: - k = 0; - assert(0); - break; - } - - /* XXX returning result for default GL_DEPTH_TEXTURE_MODE = GL_LUMINANCE */ - rgba[0][j] = rgba[1][j] = rgba[2][j] = (float) k; - rgba[3][j] = 1.0F; -} - - -/** - * As above, but do four z/texture comparisons. - */ -static INLINE void -shadow_compare4(const struct pipe_sampler_state *sampler, - float rgba[NUM_CHANNELS][QUAD_SIZE], - const float p[QUAD_SIZE]) -{ - int j, k0, k1, k2, k3; - float val; - - /* compare four texcoords vs. four texture samples */ - switch (sampler->compare_func) { - case PIPE_FUNC_LESS: - k0 = p[0] < rgba[0][0]; - k1 = p[1] < rgba[0][1]; - k2 = p[2] < rgba[0][2]; - k3 = p[3] < rgba[0][3]; - break; - case PIPE_FUNC_LEQUAL: - k0 = p[0] <= rgba[0][0]; - k1 = p[1] <= rgba[0][1]; - k2 = p[2] <= rgba[0][2]; - k3 = p[3] <= rgba[0][3]; - break; - case PIPE_FUNC_GREATER: - k0 = p[0] > rgba[0][0]; - k1 = p[1] > rgba[0][1]; - k2 = p[2] > rgba[0][2]; - k3 = p[3] > rgba[0][3]; - break; - case PIPE_FUNC_GEQUAL: - k0 = p[0] >= rgba[0][0]; - k1 = p[1] >= rgba[0][1]; - k2 = p[2] >= rgba[0][2]; - k3 = p[3] >= rgba[0][3]; - break; - case PIPE_FUNC_EQUAL: - k0 = p[0] == rgba[0][0]; - k1 = p[1] == rgba[0][1]; - k2 = p[2] == rgba[0][2]; - k3 = p[3] == rgba[0][3]; - break; - case PIPE_FUNC_NOTEQUAL: - k0 = p[0] != rgba[0][0]; - k1 = p[1] != rgba[0][1]; - k2 = p[2] != rgba[0][2]; - k3 = p[3] != rgba[0][3]; - break; - case PIPE_FUNC_ALWAYS: - k0 = k1 = k2 = k3 = 1; - break; - case PIPE_FUNC_NEVER: - k0 = k1 = k2 = k3 = 0; - break; - default: - k0 = k1 = k2 = k3 = 0; - assert(0); - break; - } - - /* convert four pass/fail values to an intensity in [0,1] */ - val = 0.25F * (k0 + k1 + k2 + k3); - - /* XXX returning result for default GL_DEPTH_TEXTURE_MODE = GL_LUMINANCE */ - for (j = 0; j < 4; j++) { - rgba[0][j] = rgba[1][j] = rgba[2][j] = val; - rgba[3][j] = 1.0F; - } -} - - - -static void -lp_get_samples_2d_linear_repeat_POT(struct tgsi_sampler *tgsi_sampler, - const float s[QUAD_SIZE], - const float t[QUAD_SIZE], - const float p[QUAD_SIZE], - float lodbias, - float rgba[NUM_CHANNELS][QUAD_SIZE]) -{ - const struct lp_shader_sampler *samp = lp_shader_sampler(tgsi_sampler); - unsigned j; - unsigned level = samp->level; - unsigned xpot = 1 << (samp->xpot - level); - unsigned ypot = 1 << (samp->ypot - level); - unsigned xmax = (xpot - 1) & (TEX_TILE_SIZE - 1); /* MIN2(TEX_TILE_SIZE, xpot) - 1; */ - unsigned ymax = (ypot - 1) & (TEX_TILE_SIZE - 1); /* MIN2(TEX_TILE_SIZE, ypot) - 1; */ - - for (j = 0; j < QUAD_SIZE; j++) { - int c; - - float u = s[j] * xpot - 0.5F; - float v = t[j] * ypot - 0.5F; - - int uflr = util_ifloor(u); - int vflr = util_ifloor(v); - - float xw = u - (float)uflr; - float yw = v - (float)vflr; - - int x0 = uflr & (xpot - 1); - int y0 = vflr & (ypot - 1); - - const uint8_t *tx[4]; - - - /* Can we fetch all four at once: - */ - if (x0 < xmax && y0 < ymax) - { - get_texel_quad_2d(tgsi_sampler, 0, level, x0, y0, tx); - } - else - { - unsigned x1 = (x0 + 1) & (xpot - 1); - unsigned y1 = (y0 + 1) & (ypot - 1); - get_texel_quad_2d_mt(tgsi_sampler, 0, level, - x0, y0, x1, y1, tx); - } - - - /* interpolate R, G, B, A */ - for (c = 0; c < 4; c++) { - rgba[c][j] = lerp_2d(xw, yw, - ubyte_to_float(tx[0][c]), ubyte_to_float(tx[1][c]), - ubyte_to_float(tx[2][c]), ubyte_to_float(tx[3][c])); - } - } -} - - -static void -lp_get_samples_2d_nearest_repeat_POT(struct tgsi_sampler *tgsi_sampler, - const float s[QUAD_SIZE], - const float t[QUAD_SIZE], - const float p[QUAD_SIZE], - float lodbias, - float rgba[NUM_CHANNELS][QUAD_SIZE]) -{ - const struct lp_shader_sampler *samp = lp_shader_sampler(tgsi_sampler); - unsigned j; - unsigned level = samp->level; - unsigned xpot = 1 << (samp->xpot - level); - unsigned ypot = 1 << (samp->ypot - level); - - for (j = 0; j < QUAD_SIZE; j++) { - int c; - - float u = s[j] * xpot; - float v = t[j] * ypot; - - int uflr = util_ifloor(u); - int vflr = util_ifloor(v); - - int x0 = uflr & (xpot - 1); - int y0 = vflr & (ypot - 1); - - const uint8_t *out = get_texel_2d_ptr(tgsi_sampler, 0, level, x0, y0); - - for (c = 0; c < 4; c++) { - rgba[c][j] = ubyte_to_float(out[c]); - } - } -} - - -static void -lp_get_samples_2d_nearest_clamp_POT(struct tgsi_sampler *tgsi_sampler, - const float s[QUAD_SIZE], - const float t[QUAD_SIZE], - const float p[QUAD_SIZE], - float lodbias, - float rgba[NUM_CHANNELS][QUAD_SIZE]) -{ - const struct lp_shader_sampler *samp = lp_shader_sampler(tgsi_sampler); - unsigned j; - unsigned level = samp->level; - unsigned xpot = 1 << (samp->xpot - level); - unsigned ypot = 1 << (samp->ypot - level); - - for (j = 0; j < QUAD_SIZE; j++) { - int c; - - float u = s[j] * xpot; - float v = t[j] * ypot; - - int x0, y0; - const uint8_t *out; - - x0 = util_ifloor(u); - if (x0 < 0) - x0 = 0; - else if (x0 > xpot - 1) - x0 = xpot - 1; - - y0 = util_ifloor(v); - if (y0 < 0) - y0 = 0; - else if (y0 > ypot - 1) - y0 = ypot - 1; - - out = get_texel_2d_ptr(tgsi_sampler, 0, level, x0, y0); - - for (c = 0; c < 4; c++) { - rgba[c][j] = ubyte_to_float(out[c]); - } - } -} - - -static void -lp_get_samples_2d_linear_mip_linear_repeat_POT(struct tgsi_sampler *tgsi_sampler, - const float s[QUAD_SIZE], - const float t[QUAD_SIZE], - const float p[QUAD_SIZE], - float lodbias, - float rgba[NUM_CHANNELS][QUAD_SIZE]) -{ - struct lp_shader_sampler *samp = lp_shader_sampler(tgsi_sampler); - const struct pipe_texture *texture = samp->texture; - int level0; - float lambda; - - lambda = compute_lambda(tgsi_sampler, s, t, p, lodbias); - level0 = (int)lambda; - - if (lambda < 0.0) { - samp->level = 0; - lp_get_samples_2d_linear_repeat_POT( tgsi_sampler, - s, t, p, 0, rgba ); - } - else if (level0 >= texture->last_level) { - samp->level = texture->last_level; - lp_get_samples_2d_linear_repeat_POT( tgsi_sampler, - s, t, p, 0, rgba ); - } - else { - float levelBlend = lambda - level0; - float rgba0[4][4]; - float rgba1[4][4]; - int c,j; - - samp->level = level0; - lp_get_samples_2d_linear_repeat_POT( tgsi_sampler, - s, t, p, 0, rgba0 ); - - samp->level = level0+1; - lp_get_samples_2d_linear_repeat_POT( tgsi_sampler, - s, t, p, 0, rgba1 ); - - for (j = 0; j < QUAD_SIZE; j++) { - for (c = 0; c < 4; c++) { - rgba[c][j] = lerp(levelBlend, rgba0[c][j], rgba1[c][j]); - } - } - } -} - -/** - * Common code for sampling 1D/2D/cube textures. - * Could probably extend for 3D... - */ -static void -lp_get_samples_2d_common(struct tgsi_sampler *tgsi_sampler, - const float s[QUAD_SIZE], - const float t[QUAD_SIZE], - const float p[QUAD_SIZE], - float lodbias, - float rgba[NUM_CHANNELS][QUAD_SIZE], - const unsigned faces[4]) -{ - const struct lp_shader_sampler *samp = lp_shader_sampler(tgsi_sampler); - const struct pipe_texture *texture = samp->texture; - const struct pipe_sampler_state *sampler = samp->sampler; - unsigned level0, level1, j, imgFilter; - int width, height; - float levelBlend = 0.0F; - - choose_mipmap_levels(tgsi_sampler, s, t, p, - lodbias, - &level0, &level1, &levelBlend, &imgFilter); - - assert(sampler->normalized_coords); - - width = texture->width[level0]; - height = texture->height[level0]; - - assert(width > 0); - - switch (imgFilter) { - case PIPE_TEX_FILTER_NEAREST: - { - int x[4], y[4]; - nearest_texcoord_4(sampler->wrap_s, s, width, x); - nearest_texcoord_4(sampler->wrap_t, t, height, y); - - for (j = 0; j < QUAD_SIZE; j++) { - get_texel(tgsi_sampler, faces[j], level0, x[j], y[j], 0, rgba, j); - if (sampler->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) { - shadow_compare(sampler, rgba, p, j); - } - - if (level0 != level1) { - /* get texels from second mipmap level and blend */ - float rgba2[4][4]; - unsigned c; - x[j] /= 2; - y[j] /= 2; - get_texel(tgsi_sampler, faces[j], level1, x[j], y[j], 0, - rgba2, j); - if (sampler->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE){ - shadow_compare(sampler, rgba2, p, j); - } - - for (c = 0; c < NUM_CHANNELS; c++) { - rgba[c][j] = lerp(levelBlend, rgba[c][j], rgba2[c][j]); - } - } - } - } - break; - case PIPE_TEX_FILTER_LINEAR: - case PIPE_TEX_FILTER_ANISO: - { - int x0[4], y0[4], x1[4], y1[4]; - float xw[4], yw[4]; /* weights */ - - linear_texcoord_4(sampler->wrap_s, s, width, x0, x1, xw); - linear_texcoord_4(sampler->wrap_t, t, height, y0, y1, yw); - - for (j = 0; j < QUAD_SIZE; j++) { - float tx[4][4]; /* texels */ - int c; - get_texel(tgsi_sampler, faces[j], level0, x0[j], y0[j], 0, tx, 0); - get_texel(tgsi_sampler, faces[j], level0, x1[j], y0[j], 0, tx, 1); - get_texel(tgsi_sampler, faces[j], level0, x0[j], y1[j], 0, tx, 2); - get_texel(tgsi_sampler, faces[j], level0, x1[j], y1[j], 0, tx, 3); - if (sampler->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) { - shadow_compare4(sampler, tx, p); - } - - /* interpolate R, G, B, A */ - for (c = 0; c < 4; c++) { - rgba[c][j] = lerp_2d(xw[j], yw[j], - tx[c][0], tx[c][1], - tx[c][2], tx[c][3]); - } - - if (level0 != level1) { - /* get texels from second mipmap level and blend */ - float rgba2[4][4]; - - /* XXX: This is incorrect -- will often end up with (x0 - * == x1 && y0 == y1), meaning that we fetch the same - * texel four times and linearly interpolate between - * identical values. The correct approach would be to - * call linear_texcoord again for the second level. - */ - x0[j] /= 2; - y0[j] /= 2; - x1[j] /= 2; - y1[j] /= 2; - get_texel(tgsi_sampler, faces[j], level1, x0[j], y0[j], 0, tx, 0); - get_texel(tgsi_sampler, faces[j], level1, x1[j], y0[j], 0, tx, 1); - get_texel(tgsi_sampler, faces[j], level1, x0[j], y1[j], 0, tx, 2); - get_texel(tgsi_sampler, faces[j], level1, x1[j], y1[j], 0, tx, 3); - if (sampler->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE){ - shadow_compare4(sampler, tx, p); - } - - /* interpolate R, G, B, A */ - for (c = 0; c < 4; c++) { - rgba2[c][j] = lerp_2d(xw[j], yw[j], - tx[c][0], tx[c][1], tx[c][2], tx[c][3]); - } - - for (c = 0; c < NUM_CHANNELS; c++) { - rgba[c][j] = lerp(levelBlend, rgba[c][j], rgba2[c][j]); - } - } - } - } - break; - default: - assert(0); - } -} - - -static INLINE void -lp_get_samples_1d(struct tgsi_sampler *sampler, - const float s[QUAD_SIZE], - const float t[QUAD_SIZE], - const float p[QUAD_SIZE], - float lodbias, - float rgba[NUM_CHANNELS][QUAD_SIZE]) -{ - static const unsigned faces[4] = {0, 0, 0, 0}; - static const float tzero[4] = {0, 0, 0, 0}; - lp_get_samples_2d_common(sampler, s, tzero, NULL, - lodbias, rgba, faces); -} - - -static INLINE void -lp_get_samples_2d(struct tgsi_sampler *sampler, - const float s[QUAD_SIZE], - const float t[QUAD_SIZE], - const float p[QUAD_SIZE], - float lodbias, - float rgba[NUM_CHANNELS][QUAD_SIZE]) -{ - static const unsigned faces[4] = {0, 0, 0, 0}; - lp_get_samples_2d_common(sampler, s, t, p, - lodbias, rgba, faces); -} - - -static INLINE void -lp_get_samples_3d(struct tgsi_sampler *tgsi_sampler, - const float s[QUAD_SIZE], - const float t[QUAD_SIZE], - const float p[QUAD_SIZE], - float lodbias, - float rgba[NUM_CHANNELS][QUAD_SIZE]) -{ - const struct lp_shader_sampler *samp = lp_shader_sampler(tgsi_sampler); - const struct pipe_texture *texture = samp->texture; - const struct pipe_sampler_state *sampler = samp->sampler; - /* get/map pipe_surfaces corresponding to 3D tex slices */ - unsigned level0, level1, j, imgFilter; - int width, height, depth; - float levelBlend; - const uint face = 0; - - choose_mipmap_levels(tgsi_sampler, s, t, p, - lodbias, - &level0, &level1, &levelBlend, &imgFilter); - - assert(sampler->normalized_coords); - - width = texture->width[level0]; - height = texture->height[level0]; - depth = texture->depth[level0]; - - assert(width > 0); - assert(height > 0); - assert(depth > 0); - - switch (imgFilter) { - case PIPE_TEX_FILTER_NEAREST: - { - int x[4], y[4], z[4]; - nearest_texcoord_4(sampler->wrap_s, s, width, x); - nearest_texcoord_4(sampler->wrap_t, t, height, y); - nearest_texcoord_4(sampler->wrap_r, p, depth, z); - for (j = 0; j < QUAD_SIZE; j++) { - get_texel(tgsi_sampler, face, level0, x[j], y[j], z[j], rgba, j); - if (level0 != level1) { - /* get texels from second mipmap level and blend */ - float rgba2[4][4]; - unsigned c; - x[j] /= 2; - y[j] /= 2; - z[j] /= 2; - get_texel(tgsi_sampler, face, level1, x[j], y[j], z[j], rgba2, j); - for (c = 0; c < NUM_CHANNELS; c++) { - rgba[c][j] = lerp(levelBlend, rgba2[c][j], rgba[c][j]); - } - } - } - } - break; - case PIPE_TEX_FILTER_LINEAR: - case PIPE_TEX_FILTER_ANISO: - { - int x0[4], x1[4], y0[4], y1[4], z0[4], z1[4]; - float xw[4], yw[4], zw[4]; /* interpolation weights */ - linear_texcoord_4(sampler->wrap_s, s, width, x0, x1, xw); - linear_texcoord_4(sampler->wrap_t, t, height, y0, y1, yw); - linear_texcoord_4(sampler->wrap_r, p, depth, z0, z1, zw); - - for (j = 0; j < QUAD_SIZE; j++) { - int c; - float tx0[4][4], tx1[4][4]; - get_texel(tgsi_sampler, face, level0, x0[j], y0[j], z0[j], tx0, 0); - get_texel(tgsi_sampler, face, level0, x1[j], y0[j], z0[j], tx0, 1); - get_texel(tgsi_sampler, face, level0, x0[j], y1[j], z0[j], tx0, 2); - get_texel(tgsi_sampler, face, level0, x1[j], y1[j], z0[j], tx0, 3); - get_texel(tgsi_sampler, face, level0, x0[j], y0[j], z1[j], tx1, 0); - get_texel(tgsi_sampler, face, level0, x1[j], y0[j], z1[j], tx1, 1); - get_texel(tgsi_sampler, face, level0, x0[j], y1[j], z1[j], tx1, 2); - get_texel(tgsi_sampler, face, level0, x1[j], y1[j], z1[j], tx1, 3); - - /* interpolate R, G, B, A */ - for (c = 0; c < 4; c++) { - rgba[c][j] = lerp_3d(xw[j], yw[j], zw[j], - tx0[c][0], tx0[c][1], - tx0[c][2], tx0[c][3], - tx1[c][0], tx1[c][1], - tx1[c][2], tx1[c][3]); - } - - if (level0 != level1) { - /* get texels from second mipmap level and blend */ - float rgba2[4][4]; - x0[j] /= 2; - y0[j] /= 2; - z0[j] /= 2; - x1[j] /= 2; - y1[j] /= 2; - z1[j] /= 2; - get_texel(tgsi_sampler, face, level1, x0[j], y0[j], z0[j], tx0, 0); - get_texel(tgsi_sampler, face, level1, x1[j], y0[j], z0[j], tx0, 1); - get_texel(tgsi_sampler, face, level1, x0[j], y1[j], z0[j], tx0, 2); - get_texel(tgsi_sampler, face, level1, x1[j], y1[j], z0[j], tx0, 3); - get_texel(tgsi_sampler, face, level1, x0[j], y0[j], z1[j], tx1, 0); - get_texel(tgsi_sampler, face, level1, x1[j], y0[j], z1[j], tx1, 1); - get_texel(tgsi_sampler, face, level1, x0[j], y1[j], z1[j], tx1, 2); - get_texel(tgsi_sampler, face, level1, x1[j], y1[j], z1[j], tx1, 3); - - /* interpolate R, G, B, A */ - for (c = 0; c < 4; c++) { - rgba2[c][j] = lerp_3d(xw[j], yw[j], zw[j], - tx0[c][0], tx0[c][1], - tx0[c][2], tx0[c][3], - tx1[c][0], tx1[c][1], - tx1[c][2], tx1[c][3]); - } - - /* blend mipmap levels */ - for (c = 0; c < NUM_CHANNELS; c++) { - rgba[c][j] = lerp(levelBlend, rgba[c][j], rgba2[c][j]); - } - } - } - } - break; - default: - assert(0); - } -} - - -static void -lp_get_samples_cube(struct tgsi_sampler *sampler, - const float s[QUAD_SIZE], - const float t[QUAD_SIZE], - const float p[QUAD_SIZE], - float lodbias, - float rgba[NUM_CHANNELS][QUAD_SIZE]) -{ - unsigned faces[QUAD_SIZE], j; - float ssss[4], tttt[4]; - for (j = 0; j < QUAD_SIZE; j++) { - faces[j] = choose_cube_face(s[j], t[j], p[j], ssss + j, tttt + j); - } - lp_get_samples_2d_common(sampler, ssss, tttt, NULL, - lodbias, rgba, faces); -} - - -static void -lp_get_samples_rect(struct tgsi_sampler *tgsi_sampler, - const float s[QUAD_SIZE], - const float t[QUAD_SIZE], - const float p[QUAD_SIZE], - float lodbias, - float rgba[NUM_CHANNELS][QUAD_SIZE]) -{ - const struct lp_shader_sampler *samp = lp_shader_sampler(tgsi_sampler); - const struct pipe_texture *texture = samp->texture; - const struct pipe_sampler_state *sampler = samp->sampler; - const uint face = 0; - unsigned level0, level1, j, imgFilter; - int width, height; - float levelBlend; - - choose_mipmap_levels(tgsi_sampler, s, t, p, - lodbias, - &level0, &level1, &levelBlend, &imgFilter); - - /* texture RECTS cannot be mipmapped */ - assert(level0 == level1); - - width = texture->width[level0]; - height = texture->height[level0]; - - assert(width > 0); - - switch (imgFilter) { - case PIPE_TEX_FILTER_NEAREST: - { - int x[4], y[4]; - nearest_texcoord_unnorm_4(sampler->wrap_s, s, width, x); - nearest_texcoord_unnorm_4(sampler->wrap_t, t, height, y); - for (j = 0; j < QUAD_SIZE; j++) { - get_texel(tgsi_sampler, face, level0, x[j], y[j], 0, rgba, j); - if (sampler->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) { - shadow_compare(sampler, rgba, p, j); - } - } - } - break; - case PIPE_TEX_FILTER_LINEAR: - case PIPE_TEX_FILTER_ANISO: - { - int x0[4], y0[4], x1[4], y1[4]; - float xw[4], yw[4]; /* weights */ - linear_texcoord_unnorm_4(sampler->wrap_s, s, width, x0, x1, xw); - linear_texcoord_unnorm_4(sampler->wrap_t, t, height, y0, y1, yw); - for (j = 0; j < QUAD_SIZE; j++) { - float tx[4][4]; /* texels */ - int c; - get_texel(tgsi_sampler, face, level0, x0[j], y0[j], 0, tx, 0); - get_texel(tgsi_sampler, face, level0, x1[j], y0[j], 0, tx, 1); - get_texel(tgsi_sampler, face, level0, x0[j], y1[j], 0, tx, 2); - get_texel(tgsi_sampler, face, level0, x1[j], y1[j], 0, tx, 3); - if (sampler->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) { - shadow_compare4(sampler, tx, p); - } - for (c = 0; c < 4; c++) { - rgba[c][j] = lerp_2d(xw[j], yw[j], - tx[c][0], tx[c][1], tx[c][2], tx[c][3]); - } - } - } - break; - default: - assert(0); - } -} - - -/** - * Error condition handler - */ -static INLINE void -lp_get_samples_null(struct tgsi_sampler *tgsi_sampler, - const float s[QUAD_SIZE], - const float t[QUAD_SIZE], - const float p[QUAD_SIZE], - float lodbias, - float rgba[NUM_CHANNELS][QUAD_SIZE]) -{ - int i,j; - - for (i = 0; i < 4; i++) - for (j = 0; j < 4; j++) - rgba[i][j] = 1.0; -} - -/** - * Called via tgsi_sampler::get_samples() when using a sampler for the - * first time. Determine the actual sampler function, link it in and - * call it. - */ -void -lp_get_samples(struct tgsi_sampler *tgsi_sampler, - const float s[QUAD_SIZE], - const float t[QUAD_SIZE], - const float p[QUAD_SIZE], - float lodbias, - float rgba[NUM_CHANNELS][QUAD_SIZE]) -{ - struct lp_shader_sampler *samp = lp_shader_sampler(tgsi_sampler); - const struct pipe_texture *texture = samp->texture; - const struct pipe_sampler_state *sampler = samp->sampler; - - /* Default to the 'undefined' case: - */ - tgsi_sampler->get_samples = lp_get_samples_null; - - if (!texture) { - assert(0); /* is this legal?? */ - goto out; - } - - if (!sampler->normalized_coords) { - assert (texture->target == PIPE_TEXTURE_2D); - tgsi_sampler->get_samples = lp_get_samples_rect; - goto out; - } - - switch (texture->target) { - case PIPE_TEXTURE_1D: - tgsi_sampler->get_samples = lp_get_samples_1d; - break; - case PIPE_TEXTURE_2D: - tgsi_sampler->get_samples = lp_get_samples_2d; - break; - case PIPE_TEXTURE_3D: - tgsi_sampler->get_samples = lp_get_samples_3d; - break; - case PIPE_TEXTURE_CUBE: - tgsi_sampler->get_samples = lp_get_samples_cube; - break; - default: - assert(0); - break; - } - - /* Do this elsewhere: - */ - samp->xpot = util_unsigned_logbase2( samp->texture->width[0] ); - samp->ypot = util_unsigned_logbase2( samp->texture->height[0] ); - - /* Try to hook in a faster sampler. Ultimately we'll have to - * code-generate these. Luckily most of this looks like it is - * orthogonal state within the sampler. - */ - if (texture->target == PIPE_TEXTURE_2D && - sampler->min_img_filter == sampler->mag_img_filter && - sampler->wrap_s == sampler->wrap_t && - sampler->compare_mode == FALSE && - sampler->normalized_coords) - { - if (sampler->min_mip_filter == PIPE_TEX_MIPFILTER_NONE) { - samp->level = CLAMP((int) sampler->min_lod, - 0, (int) texture->last_level); - - if (sampler->wrap_s == PIPE_TEX_WRAP_REPEAT) { - switch (sampler->min_img_filter) { - case PIPE_TEX_FILTER_NEAREST: - tgsi_sampler->get_samples = lp_get_samples_2d_nearest_repeat_POT; - break; - case PIPE_TEX_FILTER_LINEAR: - tgsi_sampler->get_samples = lp_get_samples_2d_linear_repeat_POT; - break; - default: - break; - } - } - else if (sampler->wrap_s == PIPE_TEX_WRAP_CLAMP) { - switch (sampler->min_img_filter) { - case PIPE_TEX_FILTER_NEAREST: - tgsi_sampler->get_samples = lp_get_samples_2d_nearest_clamp_POT; - break; - default: - break; - } - } - } - else if (sampler->min_mip_filter == PIPE_TEX_MIPFILTER_LINEAR) { - if (sampler->wrap_s == PIPE_TEX_WRAP_REPEAT) { - switch (sampler->min_img_filter) { - case PIPE_TEX_FILTER_LINEAR: - tgsi_sampler->get_samples = lp_get_samples_2d_linear_mip_linear_repeat_POT; - break; - default: - break; - } - } - } - } - else if (0) { - _debug_printf("target %d/%d min_mip %d/%d min_img %d/%d wrap %d/%d compare %d/%d norm %d/%d\n", - texture->target, PIPE_TEXTURE_2D, - sampler->min_mip_filter, PIPE_TEX_MIPFILTER_NONE, - sampler->min_img_filter, sampler->mag_img_filter, - sampler->wrap_s, sampler->wrap_t, - sampler->compare_mode, FALSE, - sampler->normalized_coords, TRUE); - } - -out: - tgsi_sampler->get_samples( tgsi_sampler, s, t, p, lodbias, rgba ); -} - - -void PIPE_CDECL -lp_fetch_texel_soa( struct tgsi_sampler **samplers, - uint32_t unit, - float *store ) -{ - struct tgsi_sampler *sampler = samplers[unit]; - -#if 0 - uint j; - - debug_printf("%s sampler: %p (%p) store: %p\n", - __FUNCTION__, - sampler, *sampler, - store ); - - debug_printf("lodbias %f\n", store[12]); - - for (j = 0; j < 4; j++) - debug_printf("sample %d texcoord %f %f\n", - j, - store[0+j], - store[4+j]); -#endif - - { - float rgba[NUM_CHANNELS][QUAD_SIZE]; - sampler->get_samples(sampler, - &store[0], - &store[4], - &store[8], - 0.0f, /*store[12], lodbias */ - rgba); - memcpy(store, rgba, sizeof rgba); - } - -#if 0 - for (j = 0; j < 4; j++) - debug_printf("sample %d result %f %f %f %f\n", - j, - store[0+j], - store[4+j], - store[8+j], - store[12+j]); -#endif -} - - -#include "lp_bld_type.h" -#include "lp_bld_intr.h" -#include "lp_bld_tgsi.h" - - -struct lp_c_sampler_soa -{ - struct lp_build_sampler_soa base; - - LLVMValueRef context_ptr; - - LLVMValueRef samplers_ptr; - - /** Coords/texels store */ - LLVMValueRef store_ptr; -}; - - -static void -lp_c_sampler_soa_destroy(struct lp_build_sampler_soa *sampler) -{ - FREE(sampler); -} - - -static void -lp_c_sampler_soa_emit_fetch_texel(struct lp_build_sampler_soa *_sampler, - LLVMBuilderRef builder, - struct lp_type type, - unsigned unit, - unsigned num_coords, - const LLVMValueRef *coords, - LLVMValueRef lodbias, - LLVMValueRef *texel) -{ - struct lp_c_sampler_soa *sampler = (struct lp_c_sampler_soa *)_sampler; - LLVMTypeRef vec_type = LLVMTypeOf(coords[0]); - LLVMValueRef args[3]; - unsigned i; - - if(!sampler->samplers_ptr) - sampler->samplers_ptr = lp_jit_context_samplers(builder, sampler->context_ptr); - - if(!sampler->store_ptr) - sampler->store_ptr = LLVMBuildArrayAlloca(builder, - vec_type, - LLVMConstInt(LLVMInt32Type(), 4, 0), - "texel_store"); - - for (i = 0; i < num_coords; i++) { - LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0); - LLVMValueRef coord_ptr = LLVMBuildGEP(builder, sampler->store_ptr, &index, 1, ""); - LLVMBuildStore(builder, coords[i], coord_ptr); - } - - args[0] = sampler->samplers_ptr; - args[1] = LLVMConstInt(LLVMInt32Type(), unit, 0); - args[2] = sampler->store_ptr; - - lp_build_intrinsic(builder, "fetch_texel", LLVMVoidType(), args, 3); - - for (i = 0; i < NUM_CHANNELS; ++i) { - LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0); - LLVMValueRef texel_ptr = LLVMBuildGEP(builder, sampler->store_ptr, &index, 1, ""); - texel[i] = LLVMBuildLoad(builder, texel_ptr, ""); - } -} - - -struct lp_build_sampler_soa * -lp_c_sampler_soa_create(LLVMValueRef context_ptr) -{ - struct lp_c_sampler_soa *sampler; - - sampler = CALLOC_STRUCT(lp_c_sampler_soa); - if(!sampler) - return NULL; - - sampler->base.destroy = lp_c_sampler_soa_destroy; - sampler->base.emit_fetch_texel = lp_c_sampler_soa_emit_fetch_texel; - sampler->context_ptr = context_ptr; - - return &sampler->base; -} - -- cgit v1.2.3 From cb64ca5066a3f4611680aa8c9a5d1caf68538cb5 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 25 Jan 2010 13:17:47 +0000 Subject: pipebuffer: Reapply the mesa_7_7_branch's changes. After the last mesa_7_7_branch merge the old master code remained, instead of the newer mesa_7_7_branch's code. This commit makes both branches match, modulo interface changes. Note: future mesa_7_7_branch -> master merges will most likely hit conflicts in these files. Unless otherwise stated, the mesa_7_7_branch is the reference. --- .../auxiliary/pipebuffer/pb_buffer_fenced.c | 1067 ++++++++++++++------ .../auxiliary/pipebuffer/pb_buffer_fenced.h | 37 - 2 files changed, 769 insertions(+), 335 deletions(-) diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c index a4b78f1494..ba087ac0f3 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c @@ -1,6 +1,6 @@ /************************************************************************** * - * Copyright 2007-2009 VMware, Inc. + * Copyright 2007-2010 VMware, Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -28,9 +28,9 @@ /** * \file * Implementation of fenced buffers. - * - * \author Jose Fonseca - * \author Thomas Hellström + * + * \author Jose Fonseca + * \author Thomas Hellström */ @@ -50,6 +50,7 @@ #include "pb_buffer.h" #include "pb_buffer_fenced.h" +#include "pb_bufmgr.h" @@ -59,32 +60,79 @@ #define SUPER(__derived) (&(__derived)->base) -struct fenced_buffer_list +struct fenced_manager { - pipe_mutex mutex; - + struct pb_manager base; + struct pb_manager *provider; struct pb_fence_ops *ops; - - pb_size numDelayed; - struct list_head delayed; - -#ifdef DEBUG - pb_size numUnfenced; + + /** + * Maximum buffer size that can be safely allocated. + */ + pb_size max_buffer_size; + + /** + * Maximum cpu memory we can allocate before we start waiting for the + * GPU to idle. + */ + pb_size max_cpu_total_size; + + /** + * Following members are mutable and protected by this mutex. + */ + pipe_mutex mutex; + + /** + * Fenced buffer list. + * + * All fenced buffers are placed in this listed, ordered from the oldest + * fence to the newest fence. + */ + struct list_head fenced; + pb_size num_fenced; + struct list_head unfenced; -#endif + pb_size num_unfenced; + + /** + * How much temporary CPU memory is being used to hold unvalidated buffers. + */ + pb_size cpu_total_size; }; /** + * Fenced buffer. + * * Wrapper around a pipe buffer which adds fencing and reference counting. */ struct fenced_buffer { + /* + * Immutable members. + */ + struct pb_buffer base; - + struct fenced_manager *mgr; + + /* + * Following members are mutable and protected by fenced_manager::mutex. + */ + + struct list_head head; + + /** + * Buffer with storage. + */ struct pb_buffer *buffer; + pb_size size; + struct pb_desc desc; - /* FIXME: protect access with mutex */ + /** + * Temporary CPU storage data. Used when there isn't enough GPU memory to + * store the buffer. + */ + void *data; /** * A bitmask of PIPE_BUFFER_USAGE_CPU/GPU_READ/WRITE describing the current @@ -93,15 +141,22 @@ struct fenced_buffer unsigned flags; unsigned mapcount; + struct pb_validate *vl; unsigned validation_flags; - struct pipe_fence_handle *fence; - struct list_head head; - struct fenced_buffer_list *list; + struct pipe_fence_handle *fence; }; +static INLINE struct fenced_manager * +fenced_manager(struct pb_manager *mgr) +{ + assert(mgr); + return (struct fenced_manager *)mgr; +} + + static INLINE struct fenced_buffer * fenced_buffer(struct pb_buffer *buf) { @@ -110,221 +165,568 @@ fenced_buffer(struct pb_buffer *buf) } -static INLINE void -_fenced_buffer_add(struct fenced_buffer *fenced_buf) -{ - struct fenced_buffer_list *fenced_list = fenced_buf->list; +static void +fenced_buffer_destroy_cpu_storage_locked(struct fenced_buffer *fenced_buf); - assert(pipe_is_referenced(&fenced_buf->base.base.reference)); - assert(fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE); - assert(fenced_buf->fence); +static enum pipe_error +fenced_buffer_create_cpu_storage_locked(struct fenced_manager *fenced_mgr, + struct fenced_buffer *fenced_buf); +static void +fenced_buffer_destroy_gpu_storage_locked(struct fenced_buffer *fenced_buf); + +static enum pipe_error +fenced_buffer_create_gpu_storage_locked(struct fenced_manager *fenced_mgr, + struct fenced_buffer *fenced_buf, + boolean wait); + +static enum pipe_error +fenced_buffer_copy_storage_to_gpu_locked(struct fenced_buffer *fenced_buf); + +static enum pipe_error +fenced_buffer_copy_storage_to_cpu_locked(struct fenced_buffer *fenced_buf); + + +/** + * Dump the fenced buffer list. + * + * Useful to understand failures to allocate buffers. + */ +static void +fenced_manager_dump_locked(struct fenced_manager *fenced_mgr) +{ #ifdef DEBUG - LIST_DEL(&fenced_buf->head); - assert(fenced_list->numUnfenced); - --fenced_list->numUnfenced; + struct pb_fence_ops *ops = fenced_mgr->ops; + struct list_head *curr, *next; + struct fenced_buffer *fenced_buf; + + debug_printf("%10s %7s %8s %7s %10s %s\n", + "buffer", "size", "refcount", "storage", "fence", "signalled"); + + curr = fenced_mgr->unfenced.next; + next = curr->next; + while(curr != &fenced_mgr->unfenced) { + fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); + assert(!fenced_buf->fence); + debug_printf("%10p %7u %8u %7s\n", + (void *) fenced_buf, + fenced_buf->base.base.size, + p_atomic_read(&fenced_buf->base.base.reference.count), + fenced_buf->buffer ? "gpu" : (fenced_buf->data ? "cpu" : "none")); + curr = next; + next = curr->next; + } + + curr = fenced_mgr->fenced.next; + next = curr->next; + while(curr != &fenced_mgr->fenced) { + int signaled; + fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); + assert(fenced_buf->buffer); + signaled = ops->fence_signalled(ops, fenced_buf->fence, 0); + debug_printf("%10p %7u %8u %7s %10p %s\n", + (void *) fenced_buf, + fenced_buf->base.base.size, + p_atomic_read(&fenced_buf->base.base.reference.count), + "gpu", + (void *) fenced_buf->fence, + signaled == 0 ? "y" : "n"); + curr = next; + next = curr->next; + } +#else + (void)fenced_mgr; #endif - LIST_ADDTAIL(&fenced_buf->head, &fenced_list->delayed); - ++fenced_list->numDelayed; } -/** - * Actually destroy the buffer. - */ static INLINE void -_fenced_buffer_destroy(struct fenced_buffer *fenced_buf) +fenced_buffer_destroy_locked(struct fenced_manager *fenced_mgr, + struct fenced_buffer *fenced_buf) { - struct fenced_buffer_list *fenced_list = fenced_buf->list; - assert(!pipe_is_referenced(&fenced_buf->base.base.reference)); + assert(!fenced_buf->fence); -#ifdef DEBUG assert(fenced_buf->head.prev); assert(fenced_buf->head.next); LIST_DEL(&fenced_buf->head); - assert(fenced_list->numUnfenced); - --fenced_list->numUnfenced; -#else - (void)fenced_list; -#endif - pb_reference(&fenced_buf->buffer, NULL); + assert(fenced_mgr->num_unfenced); + --fenced_mgr->num_unfenced; + + fenced_buffer_destroy_gpu_storage_locked(fenced_buf); + fenced_buffer_destroy_cpu_storage_locked(fenced_buf); + FREE(fenced_buf); } +/** + * Add the buffer to the fenced list. + * + * Reference count should be incremented before calling this function. + */ static INLINE void -_fenced_buffer_remove(struct fenced_buffer_list *fenced_list, - struct fenced_buffer *fenced_buf) +fenced_buffer_add_locked(struct fenced_manager *fenced_mgr, + struct fenced_buffer *fenced_buf) +{ + assert(pipe_is_referenced(&fenced_buf->base.base.reference)); + assert(fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE); + assert(fenced_buf->fence); + + p_atomic_inc(&fenced_buf->base.base.reference.count); + + LIST_DEL(&fenced_buf->head); + assert(fenced_mgr->num_unfenced); + --fenced_mgr->num_unfenced; + LIST_ADDTAIL(&fenced_buf->head, &fenced_mgr->fenced); + ++fenced_mgr->num_fenced; +} + + +/** + * Remove the buffer from the fenced list, and potentially destroy the buffer + * if the reference count reaches zero. + * + * Returns TRUE if the buffer was detroyed. + */ +static INLINE boolean +fenced_buffer_remove_locked(struct fenced_manager *fenced_mgr, + struct fenced_buffer *fenced_buf) { - struct pb_fence_ops *ops = fenced_list->ops; + struct pb_fence_ops *ops = fenced_mgr->ops; assert(fenced_buf->fence); - assert(fenced_buf->list == fenced_list); - + assert(fenced_buf->mgr == fenced_mgr); + ops->fence_reference(ops, &fenced_buf->fence, NULL); fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE; - + assert(fenced_buf->head.prev); assert(fenced_buf->head.next); - + LIST_DEL(&fenced_buf->head); - assert(fenced_list->numDelayed); - --fenced_list->numDelayed; - -#ifdef DEBUG - LIST_ADDTAIL(&fenced_buf->head, &fenced_list->unfenced); - ++fenced_list->numUnfenced; -#endif - - /** - * FIXME!!! - */ + assert(fenced_mgr->num_fenced); + --fenced_mgr->num_fenced; + + LIST_ADDTAIL(&fenced_buf->head, &fenced_mgr->unfenced); + ++fenced_mgr->num_unfenced; + + if (p_atomic_dec_zero(&fenced_buf->base.base.reference.count)) { + fenced_buffer_destroy_locked(fenced_mgr, fenced_buf); + return TRUE; + } - if(!pipe_is_referenced(&fenced_buf->base.base.reference)) - _fenced_buffer_destroy(fenced_buf); + return FALSE; } +/** + * Wait for the fence to expire, and remove it from the fenced list. + * + * This function will release and re-aquire the mutex, so any copy of mutable + * state must be discarded after calling it. + */ static INLINE enum pipe_error -_fenced_buffer_finish(struct fenced_buffer *fenced_buf) +fenced_buffer_finish_locked(struct fenced_manager *fenced_mgr, + struct fenced_buffer *fenced_buf) { - struct fenced_buffer_list *fenced_list = fenced_buf->list; - struct pb_fence_ops *ops = fenced_list->ops; + struct pb_fence_ops *ops = fenced_mgr->ops; + enum pipe_error ret = PIPE_ERROR; #if 0 debug_warning("waiting for GPU"); #endif + assert(pipe_is_referenced(&fenced_buf->base.base.reference)); assert(fenced_buf->fence); + if(fenced_buf->fence) { - if(ops->fence_finish(ops, fenced_buf->fence, 0) != 0) { - return PIPE_ERROR; + struct pipe_fence_handle *fence = NULL; + int finished; + boolean proceed; + + ops->fence_reference(ops, &fence, fenced_buf->fence); + + pipe_mutex_unlock(fenced_mgr->mutex); + + finished = ops->fence_finish(ops, fenced_buf->fence, 0); + + pipe_mutex_lock(fenced_mgr->mutex); + + assert(pipe_is_referenced(&fenced_buf->base.base.reference)); + + /* + * Only proceed if the fence object didn't change in the meanwhile. + * Otherwise assume the work has been already carried out by another + * thread that re-aquired the lock before us. + */ + proceed = fence == fenced_buf->fence ? TRUE : FALSE; + + ops->fence_reference(ops, &fence, NULL); + + if(proceed && finished == 0) { + /* + * Remove from the fenced list + */ + + boolean destroyed; + + destroyed = fenced_buffer_remove_locked(fenced_mgr, fenced_buf); + + /* TODO: remove consequents buffers with the same fence? */ + + assert(!destroyed); + + fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE; + + ret = PIPE_OK; } - /* Remove from the fenced list */ - /* TODO: remove consequents */ - _fenced_buffer_remove(fenced_list, fenced_buf); } - fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE; - return PIPE_OK; + return ret; } /** - * Free as many fenced buffers from the list head as possible. + * Remove as many fenced buffers from the fenced list as possible. + * + * Returns TRUE if at least one buffer was removed. */ -static void -_fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list, - int wait) +static boolean +fenced_manager_check_signalled_locked(struct fenced_manager *fenced_mgr, + boolean wait) { - struct pb_fence_ops *ops = fenced_list->ops; + struct pb_fence_ops *ops = fenced_mgr->ops; struct list_head *curr, *next; struct fenced_buffer *fenced_buf; - struct pb_buffer *pb_buf; struct pipe_fence_handle *prev_fence = NULL; + boolean ret = FALSE; - curr = fenced_list->delayed.next; + curr = fenced_mgr->fenced.next; next = curr->next; - while(curr != &fenced_list->delayed) { + while(curr != &fenced_mgr->fenced) { fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); if(fenced_buf->fence != prev_fence) { int signaled; - if (wait) + + if (wait) { signaled = ops->fence_finish(ops, fenced_buf->fence, 0); - else + + /* + * Don't return just now. Instead preemptively check if the + * following buffers' fences already expired, without further waits. + */ + wait = FALSE; + } + else { signaled = ops->fence_signalled(ops, fenced_buf->fence, 0); - if (signaled != 0) - break; + } + + if (signaled != 0) { + return ret; + } + prev_fence = fenced_buf->fence; } else { + /* This buffer's fence object is identical to the previous buffer's + * fence object, so no need to check the fence again. + */ assert(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0); } - _fenced_buffer_remove(fenced_list, fenced_buf); + fenced_buffer_remove_locked(fenced_mgr, fenced_buf); + + ret = TRUE; + + curr = next; + next = curr->next; + } + + return ret; +} + + +/** + * Try to free some GPU memory by backing it up into CPU memory. + * + * Returns TRUE if at least one buffer was freed. + */ +static boolean +fenced_manager_free_gpu_storage_locked(struct fenced_manager *fenced_mgr) +{ + struct list_head *curr, *next; + struct fenced_buffer *fenced_buf; - curr = next; + curr = fenced_mgr->unfenced.next; + next = curr->next; + while(curr != &fenced_mgr->unfenced) { + fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); + + /* + * We can only move storage if the buffer is not mapped and not + * validated. + */ + if(fenced_buf->buffer && + !fenced_buf->mapcount && + !fenced_buf->vl) { + enum pipe_error ret; + + ret = fenced_buffer_create_cpu_storage_locked(fenced_mgr, fenced_buf); + if(ret == PIPE_OK) { + ret = fenced_buffer_copy_storage_to_cpu_locked(fenced_buf); + if(ret == PIPE_OK) { + fenced_buffer_destroy_gpu_storage_locked(fenced_buf); + return TRUE; + } + fenced_buffer_destroy_cpu_storage_locked(fenced_buf); + } + } + + curr = next; next = curr->next; } + + return FALSE; } +/** + * Destroy CPU storage for this buffer. + */ static void -fenced_buffer_destroy(struct pb_buffer *buf) +fenced_buffer_destroy_cpu_storage_locked(struct fenced_buffer *fenced_buf) { - struct fenced_buffer *fenced_buf = fenced_buffer(buf); - struct fenced_buffer_list *fenced_list = fenced_buf->list; + if(fenced_buf->data) { + align_free(fenced_buf->data); + fenced_buf->data = NULL; + assert(fenced_buf->mgr->cpu_total_size >= fenced_buf->size); + fenced_buf->mgr->cpu_total_size -= fenced_buf->size; + } +} - pipe_mutex_lock(fenced_list->mutex); - assert(!pipe_is_referenced(&fenced_buf->base.base.reference)); - if (fenced_buf->fence) { - struct pb_fence_ops *ops = fenced_list->ops; - if(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) { - struct list_head *curr, *prev; - curr = &fenced_buf->head; - prev = curr->prev; - do { - fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); - assert(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0); - _fenced_buffer_remove(fenced_list, fenced_buf); - curr = prev; - prev = curr->prev; - } while (curr != &fenced_list->delayed); - } - else { - /* delay destruction */ + +/** + * Create CPU storage for this buffer. + */ +static enum pipe_error +fenced_buffer_create_cpu_storage_locked(struct fenced_manager *fenced_mgr, + struct fenced_buffer *fenced_buf) +{ + assert(!fenced_buf->data); + if(fenced_buf->data) + return PIPE_OK; + + if (fenced_mgr->cpu_total_size + fenced_buf->size > fenced_mgr->max_cpu_total_size) + return PIPE_ERROR_OUT_OF_MEMORY; + + fenced_buf->data = align_malloc(fenced_buf->size, fenced_buf->desc.alignment); + if(!fenced_buf->data) + return PIPE_ERROR_OUT_OF_MEMORY; + + fenced_mgr->cpu_total_size += fenced_buf->size; + + return PIPE_OK; +} + + +/** + * Destroy the GPU storage. + */ +static void +fenced_buffer_destroy_gpu_storage_locked(struct fenced_buffer *fenced_buf) +{ + if(fenced_buf->buffer) { + pb_reference(&fenced_buf->buffer, NULL); + } +} + + +/** + * Try to create GPU storage for this buffer. + * + * This function is a shorthand around pb_manager::create_buffer for + * fenced_buffer_create_gpu_storage_locked()'s benefit. + */ +static INLINE boolean +fenced_buffer_try_create_gpu_storage_locked(struct fenced_manager *fenced_mgr, + struct fenced_buffer *fenced_buf) +{ + struct pb_manager *provider = fenced_mgr->provider; + + assert(!fenced_buf->buffer); + + fenced_buf->buffer = provider->create_buffer(fenced_mgr->provider, + fenced_buf->size, + &fenced_buf->desc); + return fenced_buf->buffer ? TRUE : FALSE; +} + + +/** + * Create GPU storage for this buffer. + */ +static enum pipe_error +fenced_buffer_create_gpu_storage_locked(struct fenced_manager *fenced_mgr, + struct fenced_buffer *fenced_buf, + boolean wait) +{ + assert(!fenced_buf->buffer); + + /* + * Check for signaled buffers before trying to allocate. + */ + fenced_manager_check_signalled_locked(fenced_mgr, FALSE); + + fenced_buffer_try_create_gpu_storage_locked(fenced_mgr, fenced_buf); + + /* + * Keep trying while there is some sort of progress: + * - fences are expiring, + * - or buffers are being being swapped out from GPU memory into CPU memory. + */ + while(!fenced_buf->buffer && + (fenced_manager_check_signalled_locked(fenced_mgr, FALSE) || + fenced_manager_free_gpu_storage_locked(fenced_mgr))) { + fenced_buffer_try_create_gpu_storage_locked(fenced_mgr, fenced_buf); + } + + if(!fenced_buf->buffer && wait) { + /* + * Same as before, but this time around, wait to free buffers if + * necessary. + */ + while(!fenced_buf->buffer && + (fenced_manager_check_signalled_locked(fenced_mgr, TRUE) || + fenced_manager_free_gpu_storage_locked(fenced_mgr))) { + fenced_buffer_try_create_gpu_storage_locked(fenced_mgr, fenced_buf); } } - else { - _fenced_buffer_destroy(fenced_buf); + + if(!fenced_buf->buffer) { + if(0) + fenced_manager_dump_locked(fenced_mgr); + + /* give up */ + return PIPE_ERROR_OUT_OF_MEMORY; } - pipe_mutex_unlock(fenced_list->mutex); + + return PIPE_OK; +} + + +static enum pipe_error +fenced_buffer_copy_storage_to_gpu_locked(struct fenced_buffer *fenced_buf) +{ + uint8_t *map; + + assert(fenced_buf->data); + assert(fenced_buf->buffer); + + map = pb_map(fenced_buf->buffer, PIPE_BUFFER_USAGE_CPU_WRITE); + if(!map) + return PIPE_ERROR; + + memcpy(map, fenced_buf->data, fenced_buf->size); + + pb_unmap(fenced_buf->buffer); + + return PIPE_OK; +} + + +static enum pipe_error +fenced_buffer_copy_storage_to_cpu_locked(struct fenced_buffer *fenced_buf) +{ + const uint8_t *map; + + assert(fenced_buf->data); + assert(fenced_buf->buffer); + + map = pb_map(fenced_buf->buffer, PIPE_BUFFER_USAGE_CPU_READ); + if(!map) + return PIPE_ERROR; + + memcpy(fenced_buf->data, map, fenced_buf->size); + + pb_unmap(fenced_buf->buffer); + + return PIPE_OK; +} + + +static void +fenced_buffer_destroy(struct pb_buffer *buf) +{ + struct fenced_buffer *fenced_buf = fenced_buffer(buf); + struct fenced_manager *fenced_mgr = fenced_buf->mgr; + + assert(!pipe_is_referenced(&fenced_buf->base.base.reference)); + + pipe_mutex_lock(fenced_mgr->mutex); + + fenced_buffer_destroy_locked(fenced_mgr, fenced_buf); + + pipe_mutex_unlock(fenced_mgr->mutex); } static void * -fenced_buffer_map(struct pb_buffer *buf, +fenced_buffer_map(struct pb_buffer *buf, unsigned flags) { struct fenced_buffer *fenced_buf = fenced_buffer(buf); - struct fenced_buffer_list *fenced_list = fenced_buf->list; - struct pb_fence_ops *ops = fenced_list->ops; - void *map; + struct fenced_manager *fenced_mgr = fenced_buf->mgr; + struct pb_fence_ops *ops = fenced_mgr->ops; + void *map = NULL; + + pipe_mutex_lock(fenced_mgr->mutex); assert(!(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE)); - - /* Serialize writes */ - if((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_WRITE) || - ((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ) && (flags & PIPE_BUFFER_USAGE_CPU_WRITE))) { - if(flags & PIPE_BUFFER_USAGE_DONTBLOCK) { - /* Don't wait for the GPU to finish writing */ - if(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) - _fenced_buffer_remove(fenced_list, fenced_buf); - else - return NULL; + + /* + * Serialize writes. + */ + while((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_WRITE) || + ((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ) && + (flags & PIPE_BUFFER_USAGE_CPU_WRITE))) { + + /* + * Don't wait for the GPU to finish accessing it, if blocking is forbidden. + */ + if((flags & PIPE_BUFFER_USAGE_DONTBLOCK) && + ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) { + goto done; } - else { - /* Wait for the GPU to finish writing */ - _fenced_buffer_finish(fenced_buf); + + if (flags & PIPE_BUFFER_USAGE_UNSYNCHRONIZED) { + break; } + + /* + * Wait for the GPU to finish accessing. This will release and re-acquire + * the mutex, so all copies of mutable state must be discarded. + */ + fenced_buffer_finish_locked(fenced_mgr, fenced_buf); } -#if 0 - /* Check for CPU write access (read is OK) */ - if(fenced_buf->flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE) { - /* this is legal -- just for debugging */ - debug_warning("concurrent CPU writes"); + if(fenced_buf->buffer) { + map = pb_map(fenced_buf->buffer, flags); } -#endif - - map = pb_map(fenced_buf->buffer, flags); + else { + assert(fenced_buf->data); + map = fenced_buf->data; + } + if(map) { ++fenced_buf->mapcount; fenced_buf->flags |= flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE; } +done: + pipe_mutex_unlock(fenced_mgr->mutex); + return map; } @@ -333,13 +735,20 @@ static void fenced_buffer_unmap(struct pb_buffer *buf) { struct fenced_buffer *fenced_buf = fenced_buffer(buf); + struct fenced_manager *fenced_mgr = fenced_buf->mgr; + + pipe_mutex_lock(fenced_mgr->mutex); + assert(fenced_buf->mapcount); if(fenced_buf->mapcount) { - pb_unmap(fenced_buf->buffer); + if (fenced_buf->buffer) + pb_unmap(fenced_buf->buffer); --fenced_buf->mapcount; if(!fenced_buf->mapcount) fenced_buf->flags &= ~PIPE_BUFFER_USAGE_CPU_READ_WRITE; } + + pipe_mutex_unlock(fenced_mgr->mutex); } @@ -349,48 +758,72 @@ fenced_buffer_validate(struct pb_buffer *buf, unsigned flags) { struct fenced_buffer *fenced_buf = fenced_buffer(buf); + struct fenced_manager *fenced_mgr = fenced_buf->mgr; enum pipe_error ret; - + + pipe_mutex_lock(fenced_mgr->mutex); + if(!vl) { /* invalidate */ fenced_buf->vl = NULL; fenced_buf->validation_flags = 0; - return PIPE_OK; + ret = PIPE_OK; + goto done; } - + assert(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE); assert(!(flags & ~PIPE_BUFFER_USAGE_GPU_READ_WRITE)); flags &= PIPE_BUFFER_USAGE_GPU_READ_WRITE; - /* Buffer cannot be validated in two different lists */ - if(fenced_buf->vl && fenced_buf->vl != vl) - return PIPE_ERROR_RETRY; - -#if 0 - /* Do not validate if buffer is still mapped */ - if(fenced_buf->flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE) { - /* TODO: wait for the thread that mapped the buffer to unmap it */ - return PIPE_ERROR_RETRY; + /* Buffer cannot be validated in two different lists */ + if(fenced_buf->vl && fenced_buf->vl != vl) { + ret = PIPE_ERROR_RETRY; + goto done; } - /* Final sanity checking */ - assert(!(fenced_buf->flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE)); - assert(!fenced_buf->mapcount); -#endif if(fenced_buf->vl == vl && (fenced_buf->validation_flags & flags) == flags) { /* Nothing to do -- buffer already validated */ - return PIPE_OK; + ret = PIPE_OK; + goto done; + } + + /* + * Create and update GPU storage. + */ + if(!fenced_buf->buffer) { + assert(!fenced_buf->mapcount); + + ret = fenced_buffer_create_gpu_storage_locked(fenced_mgr, fenced_buf, TRUE); + if(ret != PIPE_OK) { + goto done; + } + + ret = fenced_buffer_copy_storage_to_gpu_locked(fenced_buf); + if(ret != PIPE_OK) { + fenced_buffer_destroy_gpu_storage_locked(fenced_buf); + goto done; + } + + if(fenced_buf->mapcount) { + debug_printf("warning: validating a buffer while it is still mapped\n"); + } + else { + fenced_buffer_destroy_cpu_storage_locked(fenced_buf); + } } - + ret = pb_validate(fenced_buf->buffer, vl, flags); if (ret != PIPE_OK) - return ret; - + goto done; + fenced_buf->vl = vl; fenced_buf->validation_flags |= flags; - - return PIPE_OK; + +done: + pipe_mutex_unlock(fenced_mgr->mutex); + + return ret; } @@ -398,36 +831,37 @@ static void fenced_buffer_fence(struct pb_buffer *buf, struct pipe_fence_handle *fence) { - struct fenced_buffer *fenced_buf; - struct fenced_buffer_list *fenced_list; - struct pb_fence_ops *ops; + struct fenced_buffer *fenced_buf = fenced_buffer(buf); + struct fenced_manager *fenced_mgr = fenced_buf->mgr; + struct pb_fence_ops *ops = fenced_mgr->ops; - fenced_buf = fenced_buffer(buf); - fenced_list = fenced_buf->list; - ops = fenced_list->ops; - - if(fence == fenced_buf->fence) { - /* Nothing to do */ - return; - } + pipe_mutex_lock(fenced_mgr->mutex); - assert(fenced_buf->vl); - assert(fenced_buf->validation_flags); - - pipe_mutex_lock(fenced_list->mutex); - if (fenced_buf->fence) - _fenced_buffer_remove(fenced_list, fenced_buf); - if (fence) { - ops->fence_reference(ops, &fenced_buf->fence, fence); - fenced_buf->flags |= fenced_buf->validation_flags; - _fenced_buffer_add(fenced_buf); + assert(pipe_is_referenced(&fenced_buf->base.base.reference)); + assert(fenced_buf->buffer); + + if(fence != fenced_buf->fence) { + assert(fenced_buf->vl); + assert(fenced_buf->validation_flags); + + if (fenced_buf->fence) { + boolean destroyed; + destroyed = fenced_buffer_remove_locked(fenced_mgr, fenced_buf); + assert(!destroyed); + } + if (fence) { + ops->fence_reference(ops, &fenced_buf->fence, fence); + fenced_buf->flags |= fenced_buf->validation_flags; + fenced_buffer_add_locked(fenced_mgr, fenced_buf); + } + + pb_fence(fenced_buf->buffer, fence); + + fenced_buf->vl = NULL; + fenced_buf->validation_flags = 0; } - pipe_mutex_unlock(fenced_list->mutex); - - pb_fence(fenced_buf->buffer, fence); - fenced_buf->vl = NULL; - fenced_buf->validation_flags = 0; + pipe_mutex_unlock(fenced_mgr->mutex); } @@ -437,11 +871,29 @@ fenced_buffer_get_base_buffer(struct pb_buffer *buf, pb_size *offset) { struct fenced_buffer *fenced_buf = fenced_buffer(buf); - pb_get_base_buffer(fenced_buf->buffer, base_buf, offset); + struct fenced_manager *fenced_mgr = fenced_buf->mgr; + + pipe_mutex_lock(fenced_mgr->mutex); + + /* + * This should only be called when the buffer is validated. Typically + * when processing relocations. + */ + assert(fenced_buf->vl); + assert(fenced_buf->buffer); + + if(fenced_buf->buffer) + pb_get_base_buffer(fenced_buf->buffer, base_buf, offset); + else { + *base_buf = buf; + *offset = 0; + } + + pipe_mutex_unlock(fenced_mgr->mutex); } -static const struct pb_vtbl +static const struct pb_vtbl fenced_buffer_vtbl = { fenced_buffer_destroy, fenced_buffer_map, @@ -452,147 +904,166 @@ fenced_buffer_vtbl = { }; -struct pb_buffer * -fenced_buffer_create(struct fenced_buffer_list *fenced_list, - struct pb_buffer *buffer) +/** + * Wrap a buffer in a fenced buffer. + */ +static struct pb_buffer * +fenced_bufmgr_create_buffer(struct pb_manager *mgr, + pb_size size, + const struct pb_desc *desc) { - struct fenced_buffer *buf; - - if(!buffer) - return NULL; - - buf = CALLOC_STRUCT(fenced_buffer); - if(!buf) { - pb_reference(&buffer, NULL); - return NULL; + struct fenced_manager *fenced_mgr = fenced_manager(mgr); + struct fenced_buffer *fenced_buf; + enum pipe_error ret; + + /* + * Don't stall the GPU, waste time evicting buffers, or waste memory + * trying to create a buffer that will most likely never fit into the + * graphics aperture. + */ + if(size > fenced_mgr->max_buffer_size) { + goto no_buffer; } - - pipe_reference_init(&buf->base.base.reference, 1); - buf->base.base.alignment = buffer->base.alignment; - buf->base.base.usage = buffer->base.usage; - buf->base.base.size = buffer->base.size; - - buf->base.vtbl = &fenced_buffer_vtbl; - buf->buffer = buffer; - buf->list = fenced_list; - -#ifdef DEBUG - pipe_mutex_lock(fenced_list->mutex); - LIST_ADDTAIL(&buf->head, &fenced_list->unfenced); - ++fenced_list->numUnfenced; - pipe_mutex_unlock(fenced_list->mutex); -#endif - return &buf->base; -} + fenced_buf = CALLOC_STRUCT(fenced_buffer); + if(!fenced_buf) + goto no_buffer; + pipe_reference_init(&fenced_buf->base.base.reference, 1); + fenced_buf->base.base.alignment = desc->alignment; + fenced_buf->base.base.usage = desc->usage; + fenced_buf->base.base.size = size; + fenced_buf->size = size; + fenced_buf->desc = *desc; -struct fenced_buffer_list * -fenced_buffer_list_create(struct pb_fence_ops *ops) -{ - struct fenced_buffer_list *fenced_list; + fenced_buf->base.vtbl = &fenced_buffer_vtbl; + fenced_buf->mgr = fenced_mgr; - fenced_list = CALLOC_STRUCT(fenced_buffer_list); - if (!fenced_list) - return NULL; + pipe_mutex_lock(fenced_mgr->mutex); + + /* + * Try to create GPU storage without stalling, + */ + ret = fenced_buffer_create_gpu_storage_locked(fenced_mgr, fenced_buf, FALSE); - fenced_list->ops = ops; + /* + * Attempt to use CPU memory to avoid stalling the GPU. + */ + if(ret != PIPE_OK) { + ret = fenced_buffer_create_cpu_storage_locked(fenced_mgr, fenced_buf); + } - LIST_INITHEAD(&fenced_list->delayed); - fenced_list->numDelayed = 0; - -#ifdef DEBUG - LIST_INITHEAD(&fenced_list->unfenced); - fenced_list->numUnfenced = 0; -#endif + /* + * Create GPU storage, waiting for some to be available. + */ + if(ret != PIPE_OK) { + ret = fenced_buffer_create_gpu_storage_locked(fenced_mgr, fenced_buf, TRUE); + } + + /* + * Give up. + */ + if(ret != PIPE_OK) { + goto no_storage; + } - pipe_mutex_init(fenced_list->mutex); + assert(fenced_buf->buffer || fenced_buf->data); - return fenced_list; -} + LIST_ADDTAIL(&fenced_buf->head, &fenced_mgr->unfenced); + ++fenced_mgr->num_unfenced; + pipe_mutex_unlock(fenced_mgr->mutex); + return &fenced_buf->base; -void -fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list, - int wait) -{ - pipe_mutex_lock(fenced_list->mutex); - _fenced_buffer_list_check_free(fenced_list, wait); - pipe_mutex_unlock(fenced_list->mutex); +no_storage: + pipe_mutex_unlock(fenced_mgr->mutex); + FREE(fenced_buf); +no_buffer: + return NULL; } -#ifdef DEBUG -void -fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list) +static void +fenced_bufmgr_flush(struct pb_manager *mgr) { - struct pb_fence_ops *ops = fenced_list->ops; - struct list_head *curr, *next; - struct fenced_buffer *fenced_buf; + struct fenced_manager *fenced_mgr = fenced_manager(mgr); - pipe_mutex_lock(fenced_list->mutex); + pipe_mutex_lock(fenced_mgr->mutex); + while(fenced_manager_check_signalled_locked(fenced_mgr, TRUE)) + ; + pipe_mutex_unlock(fenced_mgr->mutex); - debug_printf("%10s %7s %7s %10s %s\n", - "buffer", "size", "refcount", "fence", "signalled"); - - curr = fenced_list->unfenced.next; - next = curr->next; - while(curr != &fenced_list->unfenced) { - fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); - assert(!fenced_buf->fence); - debug_printf("%10p %7u %7u\n", - (void *) fenced_buf, - fenced_buf->base.base.size, - p_atomic_read(&fenced_buf->base.base.reference.count)); - curr = next; - next = curr->next; - } - - curr = fenced_list->delayed.next; - next = curr->next; - while(curr != &fenced_list->delayed) { - int signaled; - fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head); - signaled = ops->fence_signalled(ops, fenced_buf->fence, 0); - debug_printf("%10p %7u %7u %10p %s\n", - (void *) fenced_buf, - fenced_buf->base.base.size, - p_atomic_read(&fenced_buf->base.base.reference.count), - (void *) fenced_buf->fence, - signaled == 0 ? "y" : "n"); - curr = next; - next = curr->next; - } - - pipe_mutex_unlock(fenced_list->mutex); + assert(fenced_mgr->provider->flush); + if(fenced_mgr->provider->flush) + fenced_mgr->provider->flush(fenced_mgr->provider); } -#endif -void -fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list) +static void +fenced_bufmgr_destroy(struct pb_manager *mgr) { - pipe_mutex_lock(fenced_list->mutex); + struct fenced_manager *fenced_mgr = fenced_manager(mgr); + + pipe_mutex_lock(fenced_mgr->mutex); /* Wait on outstanding fences */ - while (fenced_list->numDelayed) { - pipe_mutex_unlock(fenced_list->mutex); + while (fenced_mgr->num_fenced) { + pipe_mutex_unlock(fenced_mgr->mutex); #if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) sched_yield(); #endif - _fenced_buffer_list_check_free(fenced_list, 1); - pipe_mutex_lock(fenced_list->mutex); + pipe_mutex_lock(fenced_mgr->mutex); + while(fenced_manager_check_signalled_locked(fenced_mgr, TRUE)) + ; } #ifdef DEBUG - /*assert(!fenced_list->numUnfenced);*/ + /*assert(!fenced_mgr->num_unfenced);*/ #endif - - pipe_mutex_unlock(fenced_list->mutex); - - fenced_list->ops->destroy(fenced_list->ops); - - FREE(fenced_list); + + pipe_mutex_unlock(fenced_mgr->mutex); + pipe_mutex_destroy(fenced_mgr->mutex); + + if(fenced_mgr->provider) + fenced_mgr->provider->destroy(fenced_mgr->provider); + + fenced_mgr->ops->destroy(fenced_mgr->ops); + + FREE(fenced_mgr); } +struct pb_manager * +fenced_bufmgr_create(struct pb_manager *provider, + struct pb_fence_ops *ops, + pb_size max_buffer_size, + pb_size max_cpu_total_size) +{ + struct fenced_manager *fenced_mgr; + + if(!provider) + return NULL; + + fenced_mgr = CALLOC_STRUCT(fenced_manager); + if (!fenced_mgr) + return NULL; + + fenced_mgr->base.destroy = fenced_bufmgr_destroy; + fenced_mgr->base.create_buffer = fenced_bufmgr_create_buffer; + fenced_mgr->base.flush = fenced_bufmgr_flush; + + fenced_mgr->provider = provider; + fenced_mgr->ops = ops; + fenced_mgr->max_buffer_size = max_buffer_size; + fenced_mgr->max_cpu_total_size = max_cpu_total_size; + + LIST_INITHEAD(&fenced_mgr->fenced); + fenced_mgr->num_fenced = 0; + + LIST_INITHEAD(&fenced_mgr->unfenced); + fenced_mgr->num_unfenced = 0; + + pipe_mutex_init(fenced_mgr->mutex); + + return &fenced_mgr->base; +} diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h index 034ca1e024..0372f81d0a 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h @@ -98,43 +98,6 @@ struct pb_fence_ops }; -/** - * Create a fenced buffer list. - * - * See also fenced_bufmgr_create for a more convenient way to use this. - */ -struct fenced_buffer_list * -fenced_buffer_list_create(struct pb_fence_ops *ops); - - -/** - * Walk the fenced buffer list to check and free signalled buffers. - */ -void -fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list, - int wait); - - -#ifdef DEBUG -void -fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list); -#endif - - -void -fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list); - - -/** - * Wrap a buffer in a fenced buffer. - * - * NOTE: this will not increase the buffer reference count. - */ -struct pb_buffer * -fenced_buffer_create(struct fenced_buffer_list *fenced, - struct pb_buffer *buffer); - - #ifdef __cplusplus } #endif -- cgit v1.2.3 From 2204447de320afe201a9369f57658cae0a11a440 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 25 Jan 2010 22:29:51 +0800 Subject: winsys/drm: Correctly install EGL drivers. Remove extraneous quotes that prevent some drivers to be installed when there are more than one display in EGL_DISPLAYS. --- src/gallium/winsys/drm/Makefile.egl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/winsys/drm/Makefile.egl b/src/gallium/winsys/drm/Makefile.egl index d79ceee5b7..b1f2038550 100644 --- a/src/gallium/winsys/drm/Makefile.egl +++ b/src/gallium/winsys/drm/Makefile.egl @@ -55,7 +55,7 @@ clean: install: $(EGL_DISPLAY_LIBS) $(INSTALL) -d $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR) - for lib in "$(EGL_DISPLAY_LIBS)"; do \ + for lib in $(EGL_DISPLAY_LIBS); do \ $(MINSTALL) -m 755 "$$lib" $(DESTDIR)$(EGL_DRIVER_INSTALL_DIR); \ done -- cgit v1.2.3 From 9328f3a670993167d7fb9a590f9e712467e77c7c Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Tue, 19 Jan 2010 17:39:27 -0800 Subject: Fix compressed texture loads for non-minimal pitches again My commit eea6a7639f767b1d30b6ef1f91a9c49e3f3b78f0 does a memcpy of height lines, but that's wrong because the texture has a block layout and we must thus use the number of vertical blocks instead of the height. Signed-off-by: Brian Paul --- src/mesa/state_tracker/st_cb_texture.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index b94bfc8538..cee2452eaf 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -686,9 +686,11 @@ st_TexImage(GLcontext * ctx, { char *dst = texImage->Data; const char *src = pixels; - int i; + GLuint i, bw, bh, lines; + _mesa_get_format_block_size(texImage->TexFormat, &bw, &bh); + lines = (height + bh - 1) / bh; - for(i = 0; i < height; ++i) + for(i = 0; i < lines; ++i) { memcpy(dst, src, srcImageStride); dst += dstRowStride; -- cgit v1.2.3 From cbb8d35a3ae999f0192dfdca35f7cbc1d494fabb Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 25 Jan 2010 16:31:21 +0100 Subject: gallium: fix cast for size calc of pipe_blend_state --- src/gallium/auxiliary/cso_cache/cso_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index c8fdfc8124..c479c36064 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -315,7 +315,7 @@ enum pipe_error cso_set_blend(struct cso_context *ctx, void *handle; key_size = templ->independent_blend_enable ? sizeof(struct pipe_blend_state) : - (void *)&(templ->rt[1]) - (void *)templ; + (char *)&(templ->rt[1]) - (char *)templ; hash_key = cso_construct_key((void*)templ, key_size); iter = cso_find_state_template(ctx->cache, hash_key, CSO_BLEND, (void*)templ); -- cgit v1.2.3 From 92676b9fe6356a8974830c47c0191d1ca57a0741 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 25 Jan 2010 16:32:18 +0100 Subject: xorg: adapt to blend changes --- src/gallium/state_trackers/xorg/xorg_composite.c | 12 ++++++------ src/gallium/state_trackers/xorg/xorg_renderer.c | 10 +++++----- src/gallium/state_trackers/xorg/xorg_xv.c | 12 ++++++------ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c index 1c248a629e..66f83f566c 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.c +++ b/src/gallium/state_trackers/xorg/xorg_composite.c @@ -220,13 +220,13 @@ bind_blend_state(struct exa_context *exa, int op, blend_for_op(&blend_opt, op, pSrcPicture, pMaskPicture, pDstPicture); memset(&blend, 0, sizeof(struct pipe_blend_state)); - blend.blend_enable = 1; - blend.colormask |= PIPE_MASK_RGBA; + blend.rt[0].blend_enable = 1; + blend.rt[0].colormask = PIPE_MASK_RGBA; - blend.rgb_src_factor = blend_opt.rgb_src; - blend.alpha_src_factor = blend_opt.rgb_src; - blend.rgb_dst_factor = blend_opt.rgb_dst; - blend.alpha_dst_factor = blend_opt.rgb_dst; + blend.rt[0].rgb_src_factor = blend_opt.rgb_src; + blend.rt[0].alpha_src_factor = blend_opt.rgb_src; + blend.rt[0].rgb_dst_factor = blend_opt.rgb_dst; + blend.rt[0].alpha_dst_factor = blend_opt.rgb_dst; cso_set_blend(exa->renderer->cso, &blend); } diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c index 8f729b565b..0b6600da6f 100644 --- a/src/gallium/state_trackers/xorg/xorg_renderer.c +++ b/src/gallium/state_trackers/xorg/xorg_renderer.c @@ -445,11 +445,11 @@ void renderer_copy_prepare(struct xorg_renderer *r, { struct pipe_blend_state blend; memset(&blend, 0, sizeof(blend)); - blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE; - blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend.colormask = PIPE_MASK_RGBA; + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].colormask = PIPE_MASK_RGBA; cso_set_blend(r->cso, &blend); } diff --git a/src/gallium/state_trackers/xorg/xorg_xv.c b/src/gallium/state_trackers/xorg/xorg_xv.c index 5bf0e94b62..c4580935c3 100644 --- a/src/gallium/state_trackers/xorg/xorg_xv.c +++ b/src/gallium/state_trackers/xorg/xorg_xv.c @@ -403,14 +403,14 @@ bind_blend_state(struct xorg_xv_port_priv *port) struct pipe_blend_state blend; memset(&blend, 0, sizeof(struct pipe_blend_state)); - blend.blend_enable = 1; - blend.colormask |= PIPE_MASK_RGBA; + blend.rt[0].blend_enable = 1; /* XXX why? */ + blend.rt[0].colormask = PIPE_MASK_RGBA; /* porter&duff src */ - blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE; - blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; cso_set_blend(port->r->cso, &blend); } -- cgit v1.2.3 From feefa7a510058f57a81e5e928cd2fcb63506624f Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 25 Jan 2010 16:33:09 +0100 Subject: vega: adapt to blend changes --- src/gallium/state_trackers/vega/api_filters.c | 18 +++---- src/gallium/state_trackers/vega/api_masks.c | 13 ++--- src/gallium/state_trackers/vega/mask.c | 15 +++--- src/gallium/state_trackers/vega/polygon.c | 10 ++-- src/gallium/state_trackers/vega/renderer.c | 20 ++++---- src/gallium/state_trackers/vega/vg_context.c | 70 +++++++++++++-------------- 6 files changed, 70 insertions(+), 76 deletions(-) diff --git a/src/gallium/state_trackers/vega/api_filters.c b/src/gallium/state_trackers/vega/api_filters.c index 8f69ee0109..555d3bd7f9 100644 --- a/src/gallium/state_trackers/vega/api_filters.c +++ b/src/gallium/state_trackers/vega/api_filters.c @@ -127,19 +127,19 @@ static void setup_blend() struct vg_context *ctx = vg_current_context(); struct pipe_blend_state blend; memset(&blend, 0, sizeof(blend)); - blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE; - blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; if (ctx->state.vg.filter_channel_mask & VG_RED) - blend.colormask |= PIPE_MASK_R; + blend.rt[0].colormask |= PIPE_MASK_R; if (ctx->state.vg.filter_channel_mask & VG_GREEN) - blend.colormask |= PIPE_MASK_G; + blend.rt[0].colormask |= PIPE_MASK_G; if (ctx->state.vg.filter_channel_mask & VG_BLUE) - blend.colormask |= PIPE_MASK_B; + blend.rt[0].colormask |= PIPE_MASK_B; if (ctx->state.vg.filter_channel_mask & VG_ALPHA) - blend.colormask |= PIPE_MASK_A; - blend.blend_enable = 1; + blend.rt[0].colormask |= PIPE_MASK_A; + blend.rt[0].blend_enable = 1; /* XXX why? */ cso_set_blend(ctx->cso_context, &blend); } diff --git a/src/gallium/state_trackers/vega/api_masks.c b/src/gallium/state_trackers/vega/api_masks.c index 97cbe69205..e6070c7353 100644 --- a/src/gallium/state_trackers/vega/api_masks.c +++ b/src/gallium/state_trackers/vega/api_masks.c @@ -128,14 +128,11 @@ clear_with_quad(struct vg_context *st, float x0, float y0, { struct pipe_blend_state blend; memset(&blend, 0, sizeof(blend)); - blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE; - blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend.colormask |= PIPE_MASK_R; - blend.colormask |= PIPE_MASK_G; - blend.colormask |= PIPE_MASK_B; - blend.colormask |= PIPE_MASK_A; + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].colormask = PIPE_MASK_RGBA; cso_set_blend(st->cso_context, &blend); } diff --git a/src/gallium/state_trackers/vega/mask.c b/src/gallium/state_trackers/vega/mask.c index 3e260e7073..d94fa47da6 100644 --- a/src/gallium/state_trackers/vega/mask.c +++ b/src/gallium/state_trackers/vega/mask.c @@ -354,15 +354,12 @@ static void setup_mask_blend() struct pipe_blend_state blend; memset(&blend, 0, sizeof(struct pipe_blend_state)); - blend.blend_enable = 1; - blend.colormask |= PIPE_MASK_R; - blend.colormask |= PIPE_MASK_G; - blend.colormask |= PIPE_MASK_B; - blend.colormask |= PIPE_MASK_A; - blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE; - blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].blend_enable = 1; /* XXX why? */ + blend.rt[0].colormask = PIPE_MASK_RGBA; + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; cso_set_blend(ctx->cso_context, &blend); } diff --git a/src/gallium/state_trackers/vega/polygon.c b/src/gallium/state_trackers/vega/polygon.c index d385ee567f..f5352ee84e 100644 --- a/src/gallium/state_trackers/vega/polygon.c +++ b/src/gallium/state_trackers/vega/polygon.c @@ -248,12 +248,12 @@ VGboolean polygon_is_closed(struct polygon *p) static void set_blend_for_fill(struct pipe_blend_state *blend) { memset(blend, 0, sizeof(struct pipe_blend_state)); - blend->colormask = 0; /*disable colorwrites*/ + blend->rt[0].colormask = 0; /*disable colorwrites*/ - blend->rgb_src_factor = PIPE_BLENDFACTOR_ONE; - blend->alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend->rgb_dst_factor = PIPE_BLENDFACTOR_INV_SRC_ALPHA; - blend->alpha_dst_factor = PIPE_BLENDFACTOR_INV_SRC_ALPHA; + blend->rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; + blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend->rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_INV_SRC_ALPHA; + blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_INV_SRC_ALPHA; } static void draw_polygon(struct vg_context *ctx, diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c index 64e3a7c545..47e18dc1e2 100644 --- a/src/gallium/state_trackers/vega/renderer.c +++ b/src/gallium/state_trackers/vega/renderer.c @@ -317,11 +317,11 @@ void renderer_copy_texture(struct renderer *ctx, { struct pipe_blend_state blend; memset(&blend, 0, sizeof(blend)); - blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE; - blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend.colormask = PIPE_MASK_RGBA; + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].colormask = PIPE_MASK_RGBA; cso_set_blend(ctx->cso, &blend); } @@ -486,11 +486,11 @@ void renderer_copy_surface(struct renderer *ctx, { struct pipe_blend_state blend; memset(&blend, 0, sizeof(blend)); - blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE; - blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend.colormask = PIPE_MASK_RGBA; + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].colormask = PIPE_MASK_RGBA; cso_set_blend(ctx->cso, &blend); } diff --git a/src/gallium/state_trackers/vega/vg_context.c b/src/gallium/state_trackers/vega/vg_context.c index c16ac036e3..f05a5e68c6 100644 --- a/src/gallium/state_trackers/vega/vg_context.c +++ b/src/gallium/state_trackers/vega/vg_context.c @@ -252,7 +252,7 @@ static void update_clip_state(struct vg_context *ctx) ctx->pipe->clear(ctx->pipe, PIPE_CLEAR_DEPTHSTENCIL, NULL, 1.0, 0); /* disable color writes */ - blend->colormask = 0; /*disable colorwrites*/ + blend->rt[0].colormask = 0; /*disable colorwrites*/ cso_set_blend(ctx->cso_context, blend); /* enable scissoring */ @@ -286,7 +286,8 @@ static void update_clip_state(struct vg_context *ctx) renderer_draw_quad(ctx->renderer, minx, miny, maxx, maxy, 0.0f); } - blend->colormask = 1; /*enable colorwrites*/ + blend->rt[0].colormask = PIPE_MASK_R; /*enable colorwrites*/ + /* XXX really only for red channel? */ cso_restore_blend(ctx->cso_context); cso_restore_fragment_shader(ctx->cso_context); @@ -301,57 +302,56 @@ void vg_validate_state(struct vg_context *ctx) if ((ctx->state.dirty & BLEND_DIRTY)) { struct pipe_blend_state *blend = &ctx->state.g3d.blend; memset(blend, 0, sizeof(struct pipe_blend_state)); - blend->blend_enable = 1; - blend->colormask |= PIPE_MASK_R; - blend->colormask |= PIPE_MASK_G; - blend->colormask |= PIPE_MASK_B; - blend->colormask |= PIPE_MASK_A; + blend->rt[0].blend_enable = 1; + blend->rt[0].colormask = PIPE_MASK_RGBA; switch (ctx->state.vg.blend_mode) { case VG_BLEND_SRC: - blend->rgb_src_factor = PIPE_BLENDFACTOR_ONE; - blend->alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend->rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend->alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend->rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; + blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend->rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; + /* could disable blending ? */ break; case VG_BLEND_SRC_OVER: - blend->rgb_src_factor = PIPE_BLENDFACTOR_SRC_ALPHA; - blend->alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend->rgb_dst_factor = PIPE_BLENDFACTOR_INV_SRC_ALPHA; - blend->alpha_dst_factor = PIPE_BLENDFACTOR_INV_SRC_ALPHA; + blend->rt[0].rgb_src_factor = PIPE_BLENDFACTOR_SRC_ALPHA; + blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend->rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_INV_SRC_ALPHA; + blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_INV_SRC_ALPHA; break; case VG_BLEND_DST_OVER: - blend->rgb_src_factor = PIPE_BLENDFACTOR_INV_DST_ALPHA; - blend->alpha_src_factor = PIPE_BLENDFACTOR_INV_DST_ALPHA; - blend->rgb_dst_factor = PIPE_BLENDFACTOR_DST_ALPHA; - blend->alpha_dst_factor = PIPE_BLENDFACTOR_DST_ALPHA; + blend->rt[0].rgb_src_factor = PIPE_BLENDFACTOR_INV_DST_ALPHA; + blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_INV_DST_ALPHA; + blend->rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_DST_ALPHA; + blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_DST_ALPHA; break; case VG_BLEND_SRC_IN: - blend->rgb_src_factor = PIPE_BLENDFACTOR_DST_ALPHA; - blend->alpha_src_factor = PIPE_BLENDFACTOR_DST_ALPHA; - blend->rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend->alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend->rt[0].rgb_src_factor = PIPE_BLENDFACTOR_DST_ALPHA; + blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_DST_ALPHA; + blend->rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; break; case VG_BLEND_DST_IN: - blend->rgb_src_factor = PIPE_BLENDFACTOR_ZERO; - blend->alpha_src_factor = PIPE_BLENDFACTOR_ZERO; - blend->rgb_dst_factor = PIPE_BLENDFACTOR_SRC_ALPHA; - blend->alpha_dst_factor = PIPE_BLENDFACTOR_SRC_ALPHA; + blend->rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ZERO; + blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ZERO; + blend->rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_SRC_ALPHA; + blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_SRC_ALPHA; break; case VG_BLEND_MULTIPLY: case VG_BLEND_SCREEN: case VG_BLEND_DARKEN: case VG_BLEND_LIGHTEN: - blend->rgb_src_factor = PIPE_BLENDFACTOR_ONE; - blend->alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend->rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend->alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend->rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; + blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend->rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; + /* could disable blending ? */ break; case VG_BLEND_ADDITIVE: - blend->rgb_src_factor = PIPE_BLENDFACTOR_ONE; - blend->alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend->rgb_dst_factor = PIPE_BLENDFACTOR_ONE; - blend->alpha_dst_factor = PIPE_BLENDFACTOR_ONE; + blend->rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; + blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend->rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ONE; + blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ONE; break; default: assert(!"not implemented blend mode"); -- cgit v1.2.3 From 3770769f21138ba722a38c1400b501fdcedea17d Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 25 Jan 2010 16:34:29 +0100 Subject: st/python: adapt to blend changes --- src/gallium/state_trackers/python/samples/gs.py | 10 +++++----- src/gallium/state_trackers/python/samples/tri.py | 10 +++++----- src/gallium/state_trackers/python/st_device.c | 10 +++++----- .../tests/regress/fragment-shader/fragment-shader.py | 10 +++++----- .../tests/regress/vertex-shader/vertex-shader.py | 10 +++++----- .../state_trackers/python/tests/texture_render.py | 10 +++++----- .../state_trackers/python/tests/texture_sample.py | 20 ++++++++++---------- 7 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/gallium/state_trackers/python/samples/gs.py b/src/gallium/state_trackers/python/samples/gs.py index a07cf557f2..cd68abac9a 100644 --- a/src/gallium/state_trackers/python/samples/gs.py +++ b/src/gallium/state_trackers/python/samples/gs.py @@ -72,11 +72,11 @@ def test(dev): # disabled blending/masking blend = Blend() - blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE - blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE - blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.colormask = PIPE_MASK_RGBA + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO + blend.rt[0].colormask = PIPE_MASK_RGBA ctx.set_blend(blend) # depth/stencil/alpha diff --git a/src/gallium/state_trackers/python/samples/tri.py b/src/gallium/state_trackers/python/samples/tri.py index e5e168bdc8..f0b5e3dc98 100644 --- a/src/gallium/state_trackers/python/samples/tri.py +++ b/src/gallium/state_trackers/python/samples/tri.py @@ -72,11 +72,11 @@ def test(dev): # disabled blending/masking blend = Blend() - blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE - blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE - blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.colormask = PIPE_MASK_RGBA + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO + blend.rt[0].colormask = PIPE_MASK_RGBA ctx.set_blend(blend) # depth/stencil/alpha diff --git a/src/gallium/state_trackers/python/st_device.c b/src/gallium/state_trackers/python/st_device.c index d144af2447..e41125f6f9 100644 --- a/src/gallium/state_trackers/python/st_device.c +++ b/src/gallium/state_trackers/python/st_device.c @@ -180,11 +180,11 @@ st_context_create(struct st_device *st_dev) { struct pipe_blend_state blend; memset(&blend, 0, sizeof(blend)); - blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE; - blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend.colormask = PIPE_MASK_RGBA; + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; + blend.rt[0].colormask = PIPE_MASK_RGBA; cso_set_blend(st_ctx->cso, &blend); } diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py b/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py index 8d3bf9d4d7..e9d844c718 100644 --- a/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py @@ -50,11 +50,11 @@ def test(dev, name): # disabled blending/masking blend = Blend() - blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE - blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE - blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.colormask = PIPE_MASK_RGBA + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO + blend.rt[0].colormask = PIPE_MASK_RGBA ctx.set_blend(blend) # depth/stencil/alpha diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py index 01bf5a3210..a185474fa3 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py @@ -50,11 +50,11 @@ def test(dev, name): # disabled blending/masking blend = Blend() - blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE - blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE - blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.colormask = PIPE_MASK_RGBA + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO + blend.rt[0].colormask = PIPE_MASK_RGBA ctx.set_blend(blend) # depth/stencil/alpha diff --git a/src/gallium/state_trackers/python/tests/texture_render.py b/src/gallium/state_trackers/python/tests/texture_render.py index 79287f2cac..0fac1ea5ef 100755 --- a/src/gallium/state_trackers/python/tests/texture_render.py +++ b/src/gallium/state_trackers/python/tests/texture_render.py @@ -115,11 +115,11 @@ class TextureTest(TestCase): # disabled blending/masking blend = Blend() - blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE - blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE - blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.colormask = PIPE_MASK_RGBA + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO + blend.rt[0].colormask = PIPE_MASK_RGBA ctx.set_blend(blend) # no-op depth/stencil/alpha diff --git a/src/gallium/state_trackers/python/tests/texture_sample.py b/src/gallium/state_trackers/python/tests/texture_sample.py index 520961c805..db32b537a1 100755 --- a/src/gallium/state_trackers/python/tests/texture_sample.py +++ b/src/gallium/state_trackers/python/tests/texture_sample.py @@ -140,11 +140,11 @@ class TextureColorSampleTest(TestCase): # disabled blending/masking blend = Blend() - blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE - blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE - blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.colormask = PIPE_MASK_RGBA + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO + blend.rt[0].colormask = PIPE_MASK_RGBA ctx.set_blend(blend) # no-op depth/stencil/alpha @@ -327,11 +327,11 @@ class TextureDepthSampleTest(TestCase): # disabled blending/masking blend = Blend() - blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE - blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE - blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO - blend.colormask = PIPE_MASK_RGBA + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO + blend.rt[0].colormask = PIPE_MASK_RGBA ctx.set_blend(blend) # depth/stencil/alpha -- cgit v1.2.3 From 99e28d4ee3ce995845d9290b735b1fbe1b96886d Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 25 Jan 2010 16:35:56 +0100 Subject: llvmpipe: adapt to blend changes --- src/gallium/drivers/llvmpipe/lp_test_blend.c | 72 ++++++++++++++-------------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_test_blend.c b/src/gallium/drivers/llvmpipe/lp_test_blend.c index 6c29e8d8ac..07f636f8e7 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_blend.c +++ b/src/gallium/drivers/llvmpipe/lp_test_blend.c @@ -104,18 +104,18 @@ write_tsv_row(FILE *fp, fprintf(fp, "%s\t%s\t%s\t", - blend->rgb_func != blend->alpha_func ? "true" : "false", - blend->rgb_src_factor != blend->alpha_src_factor ? "true" : "false", - blend->rgb_dst_factor != blend->alpha_dst_factor ? "true" : "false"); + blend->rt[0].rgb_func != blend->rt[0].alpha_func ? "true" : "false", + blend->rt[0].rgb_src_factor != blend->rt[0].alpha_src_factor ? "true" : "false", + blend->rt[0].rgb_dst_factor != blend->rt[0].alpha_dst_factor ? "true" : "false"); fprintf(fp, "%s\t%s\t%s\t%s\t%s\t%s\n", - debug_dump_blend_func(blend->rgb_func, TRUE), - debug_dump_blend_factor(blend->rgb_src_factor, TRUE), - debug_dump_blend_factor(blend->rgb_dst_factor, TRUE), - debug_dump_blend_func(blend->alpha_func, TRUE), - debug_dump_blend_factor(blend->alpha_src_factor, TRUE), - debug_dump_blend_factor(blend->alpha_dst_factor, TRUE)); + debug_dump_blend_func(blend->rt[0].rgb_func, TRUE), + debug_dump_blend_factor(blend->rt[0].rgb_src_factor, TRUE), + debug_dump_blend_factor(blend->rt[0].rgb_dst_factor, TRUE), + debug_dump_blend_func(blend->rt[0].alpha_func, TRUE), + debug_dump_blend_factor(blend->rt[0].alpha_src_factor, TRUE), + debug_dump_blend_factor(blend->rt[0].alpha_dst_factor, TRUE)); fflush(fp); } @@ -137,12 +137,12 @@ dump_blend_type(FILE *fp, fprintf(fp, " %s=%s %s=%s %s=%s %s=%s %s=%s %s=%s", - "rgb_func", debug_dump_blend_func(blend->rgb_func, TRUE), - "rgb_src_factor", debug_dump_blend_factor(blend->rgb_src_factor, TRUE), - "rgb_dst_factor", debug_dump_blend_factor(blend->rgb_dst_factor, TRUE), - "alpha_func", debug_dump_blend_func(blend->alpha_func, TRUE), - "alpha_src_factor", debug_dump_blend_factor(blend->alpha_src_factor, TRUE), - "alpha_dst_factor", debug_dump_blend_factor(blend->alpha_dst_factor, TRUE)); + "rgb_func", debug_dump_blend_func(blend->rt[0].rgb_func, TRUE), + "rgb_src_factor", debug_dump_blend_factor(blend->rt[0].rgb_src_factor, TRUE), + "rgb_dst_factor", debug_dump_blend_factor(blend->rt[0].rgb_dst_factor, TRUE), + "alpha_func", debug_dump_blend_func(blend->rt[0].alpha_func, TRUE), + "alpha_src_factor", debug_dump_blend_factor(blend->rt[0].alpha_src_factor, TRUE), + "alpha_dst_factor", debug_dump_blend_factor(blend->rt[0].alpha_dst_factor, TRUE)); fprintf(fp, " ...\n"); fflush(fp); @@ -401,13 +401,15 @@ compute_blend_ref(const struct pipe_blend_state *blend, double src_term[4]; double dst_term[4]; - compute_blend_ref_term(blend->rgb_src_factor, blend->alpha_src_factor, src, src, dst, con, src_term); - compute_blend_ref_term(blend->rgb_dst_factor, blend->alpha_dst_factor, dst, src, dst, con, dst_term); + compute_blend_ref_term(blend->rt[0].rgb_src_factor, blend->rt[0].alpha_src_factor, + src, src, dst, con, src_term); + compute_blend_ref_term(blend->rt[0].rgb_dst_factor, blend->rt[0].alpha_dst_factor, + dst, src, dst, con, dst_term); /* * Combine RGB terms */ - switch (blend->rgb_func) { + switch (blend->rt[0].rgb_func) { case PIPE_BLEND_ADD: ADD_SAT(res[0], src_term[0], dst_term[0]); /* R */ ADD_SAT(res[1], src_term[1], dst_term[1]); /* G */ @@ -440,7 +442,7 @@ compute_blend_ref(const struct pipe_blend_state *blend, /* * Combine A terms */ - switch (blend->alpha_func) { + switch (blend->rt[0].alpha_func) { case PIPE_BLEND_ADD: ADD_SAT(res[3], src_term[3], dst_term[3]); /* A */ break; @@ -806,14 +808,14 @@ test_all(unsigned verbose, FILE *fp) continue; memset(&blend, 0, sizeof blend); - blend.blend_enable = 1; - blend.rgb_func = *rgb_func; - blend.rgb_src_factor = *rgb_src_factor; - blend.rgb_dst_factor = *rgb_dst_factor; - blend.alpha_func = *alpha_func; - blend.alpha_src_factor = *alpha_src_factor; - blend.alpha_dst_factor = *alpha_dst_factor; - blend.colormask = PIPE_MASK_RGBA; + blend.rt[0].blend_enable = 1; + blend.rt[0].rgb_func = *rgb_func; + blend.rt[0].rgb_src_factor = *rgb_src_factor; + blend.rt[0].rgb_dst_factor = *rgb_dst_factor; + blend.rt[0].alpha_func = *alpha_func; + blend.rt[0].alpha_src_factor = *alpha_src_factor; + blend.rt[0].alpha_dst_factor = *alpha_dst_factor; + blend.rt[0].colormask = PIPE_MASK_RGBA; if(!test_one(verbose, fp, &blend, mode, *type)) success = FALSE; @@ -865,14 +867,14 @@ test_some(unsigned verbose, FILE *fp, unsigned long n) type = &blend_types[rand() % num_types]; memset(&blend, 0, sizeof blend); - blend.blend_enable = 1; - blend.rgb_func = *rgb_func; - blend.rgb_src_factor = *rgb_src_factor; - blend.rgb_dst_factor = *rgb_dst_factor; - blend.alpha_func = *alpha_func; - blend.alpha_src_factor = *alpha_src_factor; - blend.alpha_dst_factor = *alpha_dst_factor; - blend.colormask = PIPE_MASK_RGBA; + blend.rt[0].blend_enable = 1; + blend.rt[0].rgb_func = *rgb_func; + blend.rt[0].rgb_src_factor = *rgb_src_factor; + blend.rt[0].rgb_dst_factor = *rgb_dst_factor; + blend.rt[0].alpha_func = *alpha_func; + blend.rt[0].alpha_src_factor = *alpha_src_factor; + blend.rt[0].alpha_dst_factor = *alpha_dst_factor; + blend.rt[0].colormask = PIPE_MASK_RGBA; if(!test_one(verbose, fp, &blend, mode, *type)) success = FALSE; -- cgit v1.2.3 From 88388b99fbde4652d39f4876a2fc0235de415a3f Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 25 Jan 2010 16:36:37 +0100 Subject: cell: adapt to blend changes --- src/gallium/drivers/cell/ppu/cell_gen_fragment.c | 20 ++++----- .../drivers/cell/ppu/cell_state_per_fragment.c | 48 +++++++++++----------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/gallium/drivers/cell/ppu/cell_gen_fragment.c b/src/gallium/drivers/cell/ppu/cell_gen_fragment.c index 66d4b3b6a3..0dab34075d 100644 --- a/src/gallium/drivers/cell/ppu/cell_gen_fragment.c +++ b/src/gallium/drivers/cell/ppu/cell_gen_fragment.c @@ -408,7 +408,7 @@ gen_blend(const struct pipe_blend_state *blend, int one_reg = -1; int constR_reg = -1, constG_reg = -1, constB_reg = -1, constA_reg = -1; - ASSERT(blend->blend_enable); + ASSERT(blend->rt[0].blend_enable); /* packed RGBA -> float colors */ unpack_colors(f, color_format, fbRGBA_reg, @@ -420,7 +420,7 @@ gen_blend(const struct pipe_blend_state *blend, * because in some cases (like PIPE_BLENDFACTOR_ONE and * PIPE_BLENDFACTOR_ZERO) we can avoid doing unnecessary math. */ - switch (blend->rgb_src_factor) { + switch (blend->rt[0].rgb_src_factor) { case PIPE_BLENDFACTOR_ONE: /* factors = (1,1,1), so term = (R,G,B) */ spe_move(f, term1R_reg, fragR_reg); @@ -574,7 +574,7 @@ gen_blend(const struct pipe_blend_state *blend, * the full term A*factor, not just the factor itself, because * in many cases we can avoid doing unnecessary multiplies. */ - switch (blend->alpha_src_factor) { + switch (blend->rt[0].alpha_src_factor) { case PIPE_BLENDFACTOR_ZERO: /* factor = 0, so term = 0 */ spe_load_float(f, term1A_reg, 0.0f); @@ -648,7 +648,7 @@ gen_blend(const struct pipe_blend_state *blend, * the full term (Rfb,Gfb,Bfb)*(factor), not just the factor itself, because * in many cases we can avoid doing unnecessary multiplies. */ - switch (blend->rgb_dst_factor) { + switch (blend->rt[0].rgb_dst_factor) { case PIPE_BLENDFACTOR_ONE: /* factors = (1,1,1), so term = (Rfb,Gfb,Bfb) */ spe_move(f, term2R_reg, fbR_reg); @@ -786,7 +786,7 @@ gen_blend(const struct pipe_blend_state *blend, * the full term Afb*factor, not just the factor itself, because * in many cases we can avoid doing unnecessary multiplies. */ - switch (blend->alpha_dst_factor) { + switch (blend->rt[0].alpha_dst_factor) { case PIPE_BLENDFACTOR_ONE: /* factor = 1, so term = Afb */ spe_move(f, term2A_reg, fbA_reg); @@ -858,7 +858,7 @@ gen_blend(const struct pipe_blend_state *blend, /* * Combine Src/Dest RGB terms as per the blend equation. */ - switch (blend->rgb_func) { + switch (blend->rt[0].rgb_func) { case PIPE_BLEND_ADD: spe_fa(f, fragR_reg, term1R_reg, term2R_reg); spe_fa(f, fragG_reg, term1G_reg, term2G_reg); @@ -891,7 +891,7 @@ gen_blend(const struct pipe_blend_state *blend, /* * Combine Src/Dest A term */ - switch (blend->alpha_func) { + switch (blend->rt[0].alpha_func) { case PIPE_BLEND_ADD: spe_fa(f, fragA_reg, term1A_reg, term2A_reg); break; @@ -2118,7 +2118,7 @@ cell_gen_fragment_function(struct cell_context *cell, spe_comment(f, 0, "Fetch quad colors from tile"); spe_lqx(f, fbRGBA_reg, color_tile_reg, quad_offset_reg); - if (blend->blend_enable) { + if (blend->rt[0].blend_enable) { spe_comment(f, 0, "Perform blending"); gen_blend(blend, blend_color, f, color_format, fragR_reg, fragG_reg, fragB_reg, fragA_reg, fbRGBA_reg); @@ -2143,9 +2143,9 @@ cell_gen_fragment_function(struct cell_context *cell, gen_logicop(blend, f, rgba_reg, fbRGBA_reg); } - if (blend->colormask != PIPE_MASK_RGBA) { + if (blend->rt[0].colormask != PIPE_MASK_RGBA) { spe_comment(f, 0, "Compute color mask"); - gen_colormask(f, blend->colormask, color_format, rgba_reg, fbRGBA_reg); + gen_colormask(f, blend->rt[0].colormask, color_format, rgba_reg, fbRGBA_reg); } /* Mix fragment colors with framebuffer colors using the quad/pixel mask: diff --git a/src/gallium/drivers/cell/ppu/cell_state_per_fragment.c b/src/gallium/drivers/cell/ppu/cell_state_per_fragment.c index d97c22b2ef..21af7ed1c3 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_per_fragment.c +++ b/src/gallium/drivers/cell/ppu/cell_state_per_fragment.c @@ -999,23 +999,23 @@ cell_generate_alpha_blend(struct cell_blend_state *cb) /* Does the selected blend mode make use of the source / destination * color (RGB) blend factors? */ - boolean need_color_factor = b->blend_enable - && (b->rgb_func != PIPE_BLEND_MIN) - && (b->rgb_func != PIPE_BLEND_MAX); + boolean need_color_factor = b->rt[0].blend_enable + && (b->rt[0].rgb_func != PIPE_BLEND_MIN) + && (b->rt[0].rgb_func != PIPE_BLEND_MAX); /* Does the selected blend mode make use of the source / destination * alpha blend factors? */ - boolean need_alpha_factor = b->blend_enable - && (b->alpha_func != PIPE_BLEND_MIN) - && (b->alpha_func != PIPE_BLEND_MAX); + boolean need_alpha_factor = b->rt[0].blend_enable + && (b->rt[0].alpha_func != PIPE_BLEND_MIN) + && (b->rt[0].alpha_func != PIPE_BLEND_MAX); - if (b->blend_enable) { - sF[0] = b->rgb_src_factor; + if (b->rt[0].blend_enable) { + sF[0] = b->rt[0].rgb_src_factor; sF[1] = sF[0]; sF[2] = sF[0]; - switch (b->alpha_src_factor & 0x0f) { + switch (b->rt[0].alpha_src_factor & 0x0f) { case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE: sF[3] = PIPE_BLENDFACTOR_ONE; break; @@ -1023,30 +1023,30 @@ cell_generate_alpha_blend(struct cell_blend_state *cb) case PIPE_BLENDFACTOR_DST_COLOR: case PIPE_BLENDFACTOR_CONST_COLOR: case PIPE_BLENDFACTOR_SRC1_COLOR: - sF[3] = b->alpha_src_factor + 1; + sF[3] = b->rt[0].alpha_src_factor + 1; break; default: - sF[3] = b->alpha_src_factor; + sF[3] = b->rt[0].alpha_src_factor; } - dF[0] = b->rgb_dst_factor; + dF[0] = b->rt[0].rgb_dst_factor; dF[1] = dF[0]; dF[2] = dF[0]; - switch (b->alpha_dst_factor & 0x0f) { + switch (b->rt[0].alpha_dst_factor & 0x0f) { case PIPE_BLENDFACTOR_SRC_COLOR: case PIPE_BLENDFACTOR_DST_COLOR: case PIPE_BLENDFACTOR_CONST_COLOR: case PIPE_BLENDFACTOR_SRC1_COLOR: - dF[3] = b->alpha_dst_factor + 1; + dF[3] = b->rt[0].alpha_dst_factor + 1; break; default: - dF[3] = b->alpha_dst_factor; + dF[3] = b->rt[0].alpha_dst_factor; } - func[0] = b->rgb_func; + func[0] = b->rt[0].rgb_func; func[1] = func[0]; func[2] = func[0]; - func[3] = b->alpha_func; + func[3] = b->rt[0].alpha_func; } else { sF[0] = PIPE_BLENDFACTOR_ONE; sF[1] = PIPE_BLENDFACTOR_ONE; @@ -1067,7 +1067,7 @@ cell_generate_alpha_blend(struct cell_blend_state *cb) /* If alpha writing is enabled and the alpha blend mode requires use of * the alpha factor, calculate the alpha factor. */ - if (((b->colormask & 8) != 0) && need_alpha_factor) { + if (((b->rt[0].colormask & 8) != 0) && need_alpha_factor) { src_factor[3] = emit_alpha_factor_calculation(f, sF[3], const_color[3], frag[3], pixel[3]); @@ -1091,8 +1091,8 @@ cell_generate_alpha_blend(struct cell_blend_state *cb) src_factor[2] = dst_factor[3]; } else if (need_color_factor) { emit_color_factor_calculation(f, - b->rgb_src_factor, - b->colormask, + b->rt[0].rgb_src_factor, + b->rt[0].colormask, frag, pixel, const_color, src_factor); } @@ -1111,15 +1111,15 @@ cell_generate_alpha_blend(struct cell_blend_state *cb) dst_factor[2] = src_factor[2]; } else if (need_color_factor) { emit_color_factor_calculation(f, - b->rgb_dst_factor, - b->colormask, + b->rt[0].rgb_dst_factor, + b->rt[0].colormask, frag, pixel, const_color, dst_factor); } for (i = 0; i < 4; ++i) { - if ((b->colormask & (1U << i)) != 0) { + if ((b->rt[0].colormask & (1U << i)) != 0) { emit_blend_calculation(f, func[i], sF[i], dF[i], frag[i], src_factor[i], @@ -1216,7 +1216,7 @@ cell_generate_logic_op(struct spe_function *f, /* Short-circuit the noop and invert cases. */ - if ((logic_op == PIPE_LOGICOP_NOOP) || (blend->colormask == 0)) { + if ((logic_op == PIPE_LOGICOP_NOOP) || (blend->rt[0].colormask == 0)) { spe_bi(f, 0, 0, 0); return; } else if (logic_op == PIPE_LOGICOP_INVERT) { -- cgit v1.2.3 From bc160fc9b293f155d5ed48912dc09c111b97ec74 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 25 Jan 2010 16:37:09 +0100 Subject: i915g: adapt to blend changes --- src/gallium/drivers/i915/i915_state.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c index 0fab6e1bc3..db98256d2a 100644 --- a/src/gallium/drivers/i915/i915_state.c +++ b/src/gallium/drivers/i915/i915_state.c @@ -105,13 +105,13 @@ i915_create_blend_state(struct pipe_context *pipe, struct i915_blend_state *cso_data = CALLOC_STRUCT( i915_blend_state ); { - unsigned eqRGB = blend->rgb_func; - unsigned srcRGB = blend->rgb_src_factor; - unsigned dstRGB = blend->rgb_dst_factor; + unsigned eqRGB = blend->rt[0].rgb_func; + unsigned srcRGB = blend->rt[0].rgb_src_factor; + unsigned dstRGB = blend->rt[0].rgb_dst_factor; - unsigned eqA = blend->alpha_func; - unsigned srcA = blend->alpha_src_factor; - unsigned dstA = blend->alpha_dst_factor; + unsigned eqA = blend->rt[0].alpha_func; + unsigned srcA = blend->rt[0].alpha_src_factor; + unsigned dstA = blend->rt[0].alpha_dst_factor; /* Special handling for MIN/MAX filter modes handled at * state_tracker level. @@ -148,22 +148,22 @@ i915_create_blend_state(struct pipe_context *pipe, if (blend->dither) cso_data->LIS5 |= S5_COLOR_DITHER_ENABLE; - if ((blend->colormask & PIPE_MASK_R) == 0) + if ((blend->rt[0].colormask & PIPE_MASK_R) == 0) cso_data->LIS5 |= S5_WRITEDISABLE_RED; - if ((blend->colormask & PIPE_MASK_G) == 0) + if ((blend->rt[0].colormask & PIPE_MASK_G) == 0) cso_data->LIS5 |= S5_WRITEDISABLE_GREEN; - if ((blend->colormask & PIPE_MASK_B) == 0) + if ((blend->rt[0].colormask & PIPE_MASK_B) == 0) cso_data->LIS5 |= S5_WRITEDISABLE_BLUE; - if ((blend->colormask & PIPE_MASK_A) == 0) + if ((blend->rt[0].colormask & PIPE_MASK_A) == 0) cso_data->LIS5 |= S5_WRITEDISABLE_ALPHA; - if (blend->blend_enable) { - unsigned funcRGB = blend->rgb_func; - unsigned srcRGB = blend->rgb_src_factor; - unsigned dstRGB = blend->rgb_dst_factor; + if (blend->rt[0].blend_enable) { + unsigned funcRGB = blend->rt[0].rgb_func; + unsigned srcRGB = blend->rt[0].rgb_src_factor; + unsigned dstRGB = blend->rt[0].rgb_dst_factor; cso_data->LIS6 |= (S6_CBUF_BLEND_ENABLE | SRC_BLND_FACT(i915_translate_blend_factor(srcRGB)) | -- cgit v1.2.3 From 4e0c825a799b9982ad62125df1aa876b3b0c110d Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 25 Jan 2010 16:37:27 +0100 Subject: i965g: adapt to blend changes --- src/gallium/drivers/i965/brw_pipe_blend.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/gallium/drivers/i965/brw_pipe_blend.c b/src/gallium/drivers/i965/brw_pipe_blend.c index b759a910b6..21f786f871 100644 --- a/src/gallium/drivers/i965/brw_pipe_blend.c +++ b/src/gallium/drivers/i965/brw_pipe_blend.c @@ -118,14 +118,14 @@ static void *brw_create_blend_state( struct pipe_context *pipe, blend->cc2.logicop_enable = 1; blend->cc5.logicop_func = translate_logicop(templ->logicop_func); } - else if (templ->blend_enable) { - blend->cc6.dest_blend_factor = translate_blend_factor(templ->rgb_dst_factor); - blend->cc6.src_blend_factor = translate_blend_factor(templ->rgb_src_factor); - blend->cc6.blend_function = translate_blend_equation(templ->rgb_func); + else if (templ->rt[0].blend_enable) { + blend->cc6.dest_blend_factor = translate_blend_factor(templ->rt[0].rgb_dst_factor); + blend->cc6.src_blend_factor = translate_blend_factor(templ->rt[0].rgb_src_factor); + blend->cc6.blend_function = translate_blend_equation(templ->rt[0].rgb_func); - blend->cc5.ia_dest_blend_factor = translate_blend_factor(templ->alpha_dst_factor); - blend->cc5.ia_src_blend_factor = translate_blend_factor(templ->alpha_src_factor); - blend->cc5.ia_blend_function = translate_blend_equation(templ->alpha_func); + blend->cc5.ia_dest_blend_factor = translate_blend_factor(templ->rt[0].alpha_dst_factor); + blend->cc5.ia_src_blend_factor = translate_blend_factor(templ->rt[0].alpha_src_factor); + blend->cc5.ia_blend_function = translate_blend_equation(templ->rt[0].alpha_func); blend->cc3.blend_enable = 1; blend->cc3.ia_blend_enable = @@ -146,10 +146,10 @@ static void *brw_create_blend_state( struct pipe_context *pipe, /* Per-surface color mask -- just follow global state: */ - blend->ss0.writedisable_red = (templ->colormask & PIPE_MASK_R) ? 0 : 1; - blend->ss0.writedisable_green = (templ->colormask & PIPE_MASK_G) ? 0 : 1; - blend->ss0.writedisable_blue = (templ->colormask & PIPE_MASK_B) ? 0 : 1; - blend->ss0.writedisable_alpha = (templ->colormask & PIPE_MASK_A) ? 0 : 1; + blend->ss0.writedisable_red = (templ->rt[0].colormask & PIPE_MASK_R) ? 0 : 1; + blend->ss0.writedisable_green = (templ->rt[0].colormask & PIPE_MASK_G) ? 0 : 1; + blend->ss0.writedisable_blue = (templ->rt[0].colormask & PIPE_MASK_B) ? 0 : 1; + blend->ss0.writedisable_alpha = (templ->rt[0].colormask & PIPE_MASK_A) ? 0 : 1; return (void *)blend; } -- cgit v1.2.3 From d241964e47ac5576e754d6e6ae19fece8bf8752c Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 25 Jan 2010 16:37:51 +0100 Subject: r300g: adapt to blend changes --- src/gallium/drivers/r300/r300_state.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index e2ec0bc5bd..c5e313ce43 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -164,15 +164,15 @@ static void* r300_create_blend_state(struct pipe_context* pipe, { struct r300_blend_state* blend = CALLOC_STRUCT(r300_blend_state); - if (state->blend_enable) + if (state->rt[0].blend_enable) { - unsigned eqRGB = state->rgb_func; - unsigned srcRGB = state->rgb_src_factor; - unsigned dstRGB = state->rgb_dst_factor; + unsigned eqRGB = state->rt[0].rgb_func; + unsigned srcRGB = state->rt[0].rgb_src_factor; + unsigned dstRGB = state->rt[0].rgb_dst_factor; - unsigned eqA = state->alpha_func; - unsigned srcA = state->alpha_src_factor; - unsigned dstA = state->alpha_dst_factor; + unsigned eqA = state->rt[0].alpha_func; + unsigned srcA = state->rt[0].alpha_src_factor; + unsigned dstA = state->rt[0].alpha_dst_factor; /* despite the name, ALPHA_BLEND_ENABLE has nothing to do with alpha, * this is just the crappy D3D naming */ @@ -290,16 +290,16 @@ static void* r300_create_blend_state(struct pipe_context* pipe, } /* Color Channel Mask */ - if (state->colormask & PIPE_MASK_R) { + if (state->rt[0].colormask & PIPE_MASK_R) { blend->color_channel_mask |= RB3D_COLOR_CHANNEL_MASK_RED_MASK0; } - if (state->colormask & PIPE_MASK_G) { + if (state->rt[0].colormask & PIPE_MASK_G) { blend->color_channel_mask |= RB3D_COLOR_CHANNEL_MASK_GREEN_MASK0; } - if (state->colormask & PIPE_MASK_B) { + if (state->rt[0].colormask & PIPE_MASK_B) { blend->color_channel_mask |= RB3D_COLOR_CHANNEL_MASK_BLUE_MASK0; } - if (state->colormask & PIPE_MASK_A) { + if (state->rt[0].colormask & PIPE_MASK_A) { blend->color_channel_mask |= RB3D_COLOR_CHANNEL_MASK_ALPHA_MASK0; } -- cgit v1.2.3 From e908abf1740dce1a3b391ce5bcfda4f2a0b480de Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 25 Jan 2010 16:38:32 +0100 Subject: nouveau: adapt drviers to blend changes --- src/gallium/drivers/nv04/nv04_state.c | 10 +++++----- src/gallium/drivers/nv10/nv10_state.c | 20 ++++++++++---------- src/gallium/drivers/nv20/nv20_state.c | 20 ++++++++++---------- src/gallium/drivers/nv30/nv30_state.c | 20 ++++++++++---------- src/gallium/drivers/nv40/nv40_state.c | 22 +++++++++++----------- src/gallium/drivers/nv50/nv50_state.c | 22 +++++++++++----------- 6 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/gallium/drivers/nv04/nv04_state.c b/src/gallium/drivers/nv04/nv04_state.c index b67f1e16b1..1fdb764b53 100644 --- a/src/gallium/drivers/nv04/nv04_state.c +++ b/src/gallium/drivers/nv04/nv04_state.c @@ -17,11 +17,11 @@ nv04_blend_state_create(struct pipe_context *pipe, cb = MALLOC(sizeof(struct nv04_blend_state)); - cb->b_enable = cso->blend_enable ? 1 : 0; - cb->b_src = ((nvgl_blend_func(cso->alpha_src_factor)<<16) | - (nvgl_blend_func(cso->rgb_src_factor))); - cb->b_dst = ((nvgl_blend_func(cso->alpha_dst_factor)<<16) | - (nvgl_blend_func(cso->rgb_dst_factor))); + cb->b_enable = cso->rt[0].blend_enable ? 1 : 0; + cb->b_src = ((nvgl_blend_func(cso->rt[0].alpha_src_factor)<<16) | + (nvgl_blend_func(cso->rt[0].rgb_src_factor))); + cb->b_dst = ((nvgl_blend_func(cso->rt[0].alpha_dst_factor)<<16) | + (nvgl_blend_func(cso->rt[0].rgb_dst_factor))); return (void *)cb; diff --git a/src/gallium/drivers/nv10/nv10_state.c b/src/gallium/drivers/nv10/nv10_state.c index ad7def53b1..9aafc60411 100644 --- a/src/gallium/drivers/nv10/nv10_state.c +++ b/src/gallium/drivers/nv10/nv10_state.c @@ -17,16 +17,16 @@ nv10_blend_state_create(struct pipe_context *pipe, cb = MALLOC(sizeof(struct nv10_blend_state)); - cb->b_enable = cso->blend_enable ? 1 : 0; - cb->b_srcfunc = ((nvgl_blend_func(cso->alpha_src_factor)<<16) | - (nvgl_blend_func(cso->rgb_src_factor))); - cb->b_dstfunc = ((nvgl_blend_func(cso->alpha_dst_factor)<<16) | - (nvgl_blend_func(cso->rgb_dst_factor))); - - cb->c_mask = (((cso->colormask & PIPE_MASK_A) ? (0x01<<24) : 0) | - ((cso->colormask & PIPE_MASK_R) ? (0x01<<16) : 0) | - ((cso->colormask & PIPE_MASK_G) ? (0x01<< 8) : 0) | - ((cso->colormask & PIPE_MASK_B) ? (0x01<< 0) : 0)); + cb->b_enable = cso->rt[0].blend_enable ? 1 : 0; + cb->b_srcfunc = ((nvgl_blend_func(cso->rt[0].alpha_src_factor)<<16) | + (nvgl_blend_func(cso->rt[0].rgb_src_factor))); + cb->b_dstfunc = ((nvgl_blend_func(cso->rt[0].alpha_dst_factor)<<16) | + (nvgl_blend_func(cso->rt[0].rgb_dst_factor))); + + cb->c_mask = (((cso->rt[0].colormask & PIPE_MASK_A) ? (0x01<<24) : 0) | + ((cso->rt[0].colormask & PIPE_MASK_R) ? (0x01<<16) : 0) | + ((cso->rt[0].colormask & PIPE_MASK_G) ? (0x01<< 8) : 0) | + ((cso->rt[0].colormask & PIPE_MASK_B) ? (0x01<< 0) : 0)); cb->d_enable = cso->dither ? 1 : 0; diff --git a/src/gallium/drivers/nv20/nv20_state.c b/src/gallium/drivers/nv20/nv20_state.c index 45697a60ef..83335c790a 100644 --- a/src/gallium/drivers/nv20/nv20_state.c +++ b/src/gallium/drivers/nv20/nv20_state.c @@ -17,16 +17,16 @@ nv20_blend_state_create(struct pipe_context *pipe, cb = MALLOC(sizeof(struct nv20_blend_state)); - cb->b_enable = cso->blend_enable ? 1 : 0; - cb->b_srcfunc = ((nvgl_blend_func(cso->alpha_src_factor)<<16) | - (nvgl_blend_func(cso->rgb_src_factor))); - cb->b_dstfunc = ((nvgl_blend_func(cso->alpha_dst_factor)<<16) | - (nvgl_blend_func(cso->rgb_dst_factor))); - - cb->c_mask = (((cso->colormask & PIPE_MASK_A) ? (0x01<<24) : 0) | - ((cso->colormask & PIPE_MASK_R) ? (0x01<<16) : 0) | - ((cso->colormask & PIPE_MASK_G) ? (0x01<< 8) : 0) | - ((cso->colormask & PIPE_MASK_B) ? (0x01<< 0) : 0)); + cb->b_enable = cso->rt[0].blend_enable ? 1 : 0; + cb->b_srcfunc = ((nvgl_blend_func(cso->rt[0].alpha_src_factor)<<16) | + (nvgl_blend_func(cso->rt[0].rgb_src_factor))); + cb->b_dstfunc = ((nvgl_blend_func(cso->rt[0].alpha_dst_factor)<<16) | + (nvgl_blend_func(cso->rt[0].rgb_dst_factor))); + + cb->c_mask = (((cso->rt[0].colormask & PIPE_MASK_A) ? (0x01<<24) : 0) | + ((cso->rt[0].colormask & PIPE_MASK_R) ? (0x01<<16) : 0) | + ((cso->rt[0].colormask & PIPE_MASK_G) ? (0x01<< 8) : 0) | + ((cso->rt[0].colormask & PIPE_MASK_B) ? (0x01<< 0) : 0)); cb->d_enable = cso->dither ? 1 : 0; diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c index 065c927a10..1f4c964270 100644 --- a/src/gallium/drivers/nv30/nv30_state.c +++ b/src/gallium/drivers/nv30/nv30_state.c @@ -16,27 +16,27 @@ nv30_blend_state_create(struct pipe_context *pipe, struct nv30_blend_state *bso = CALLOC(1, sizeof(*bso)); struct nouveau_stateobj *so = so_new(5, 8, 0); - if (cso->blend_enable) { + if (cso->rt[0].blend_enable) { so_method(so, rankine, NV34TCL_BLEND_FUNC_ENABLE, 3); so_data (so, 1); - so_data (so, (nvgl_blend_func(cso->alpha_src_factor) << 16) | - nvgl_blend_func(cso->rgb_src_factor)); - so_data (so, nvgl_blend_func(cso->alpha_dst_factor) << 16 | - nvgl_blend_func(cso->rgb_dst_factor)); + so_data (so, (nvgl_blend_func(cso->rt[0].alpha_src_factor) << 16) | + nvgl_blend_func(cso->rt[0].rgb_src_factor)); + so_data (so, nvgl_blend_func(cso->rt[0].alpha_dst_factor) << 16 | + nvgl_blend_func(cso->rt[0].rgb_dst_factor)); /* FIXME: Gallium assumes GL_EXT_blend_func_separate. It is not the case for NV30 */ so_method(so, rankine, NV34TCL_BLEND_EQUATION, 1); - so_data (so, nvgl_blend_eqn(cso->rgb_func)); + so_data (so, nvgl_blend_eqn(cso->rt[0].rgb_func)); } else { so_method(so, rankine, NV34TCL_BLEND_FUNC_ENABLE, 1); so_data (so, 0); } so_method(so, rankine, NV34TCL_COLOR_MASK, 1); - so_data (so, (((cso->colormask & PIPE_MASK_A) ? (0x01 << 24) : 0) | - ((cso->colormask & PIPE_MASK_R) ? (0x01 << 16) : 0) | - ((cso->colormask & PIPE_MASK_G) ? (0x01 << 8) : 0) | - ((cso->colormask & PIPE_MASK_B) ? (0x01 << 0) : 0))); + so_data (so, (((cso->rt[0].colormask & PIPE_MASK_A) ? (0x01 << 24) : 0) | + ((cso->rt[0].colormask & PIPE_MASK_R) ? (0x01 << 16) : 0) | + ((cso->rt[0].colormask & PIPE_MASK_G) ? (0x01 << 8) : 0) | + ((cso->rt[0].colormask & PIPE_MASK_B) ? (0x01 << 0) : 0))); if (cso->logicop_enable) { so_method(so, rankine, NV34TCL_COLOR_LOGIC_OP_ENABLE, 2); diff --git a/src/gallium/drivers/nv40/nv40_state.c b/src/gallium/drivers/nv40/nv40_state.c index 7d990f7d56..7a63fba18c 100644 --- a/src/gallium/drivers/nv40/nv40_state.c +++ b/src/gallium/drivers/nv40/nv40_state.c @@ -18,26 +18,26 @@ nv40_blend_state_create(struct pipe_context *pipe, struct nv40_blend_state *bso = CALLOC(1, sizeof(*bso)); struct nouveau_stateobj *so = so_new(5, 8, 0); - if (cso->blend_enable) { + if (cso->rt[0].blend_enable) { so_method(so, curie, NV40TCL_BLEND_ENABLE, 3); so_data (so, 1); - so_data (so, (nvgl_blend_func(cso->alpha_src_factor) << 16) | - nvgl_blend_func(cso->rgb_src_factor)); - so_data (so, nvgl_blend_func(cso->alpha_dst_factor) << 16 | - nvgl_blend_func(cso->rgb_dst_factor)); + so_data (so, (nvgl_blend_func(cso->rt[0].alpha_src_factor) << 16) | + nvgl_blend_func(cso->rt[0].rgb_src_factor)); + so_data (so, nvgl_blend_func(cso->rt[0].alpha_dst_factor) << 16 | + nvgl_blend_func(cso->rt[0].rgb_dst_factor)); so_method(so, curie, NV40TCL_BLEND_EQUATION, 1); - so_data (so, nvgl_blend_eqn(cso->alpha_func) << 16 | - nvgl_blend_eqn(cso->rgb_func)); + so_data (so, nvgl_blend_eqn(cso->rt[0].alpha_func) << 16 | + nvgl_blend_eqn(cso->rt[0].rgb_func)); } else { so_method(so, curie, NV40TCL_BLEND_ENABLE, 1); so_data (so, 0); } so_method(so, curie, NV40TCL_COLOR_MASK, 1); - so_data (so, (((cso->colormask & PIPE_MASK_A) ? (0x01 << 24) : 0) | - ((cso->colormask & PIPE_MASK_R) ? (0x01 << 16) : 0) | - ((cso->colormask & PIPE_MASK_G) ? (0x01 << 8) : 0) | - ((cso->colormask & PIPE_MASK_B) ? (0x01 << 0) : 0))); + so_data (so, (((cso->rt[0].colormask & PIPE_MASK_A) ? (0x01 << 24) : 0) | + ((cso->rt[0].colormask & PIPE_MASK_R) ? (0x01 << 16) : 0) | + ((cso->rt[0].colormask & PIPE_MASK_G) ? (0x01 << 8) : 0) | + ((cso->rt[0].colormask & PIPE_MASK_B) ? (0x01 << 0) : 0))); if (cso->logicop_enable) { so_method(so, curie, NV40TCL_COLOR_LOGIC_OP_ENABLE, 2); diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c index 6ab33be663..815dfa4f6f 100644 --- a/src/gallium/drivers/nv50/nv50_state.c +++ b/src/gallium/drivers/nv50/nv50_state.c @@ -44,7 +44,7 @@ nv50_blend_state_create(struct pipe_context *pipe, * - dither */ - if (cso->blend_enable == 0) { + if (cso->rt[0].blend_enable == 0) { so_method(so, tesla, NV50TCL_BLEND_ENABLE(0), 8); for (i = 0; i < 8; i++) so_data(so, 0); @@ -53,13 +53,13 @@ nv50_blend_state_create(struct pipe_context *pipe, for (i = 0; i < 8; i++) so_data(so, 1); so_method(so, tesla, NV50TCL_BLEND_EQUATION_RGB, 5); - so_data (so, nvgl_blend_eqn(cso->rgb_func)); - so_data (so, 0x4000 | nvgl_blend_func(cso->rgb_src_factor)); - so_data (so, 0x4000 | nvgl_blend_func(cso->rgb_dst_factor)); - so_data (so, nvgl_blend_eqn(cso->alpha_func)); - so_data (so, 0x4000 | nvgl_blend_func(cso->alpha_src_factor)); + so_data (so, nvgl_blend_eqn(cso->rt[0].rgb_func)); + so_data (so, 0x4000 | nvgl_blend_func(cso->rt[0].rgb_src_factor)); + so_data (so, 0x4000 | nvgl_blend_func(cso->rt[0].rgb_dst_factor)); + so_data (so, nvgl_blend_eqn(cso->rt[0].alpha_func)); + so_data (so, 0x4000 | nvgl_blend_func(cso->rt[0].alpha_src_factor)); so_method(so, tesla, NV50TCL_BLEND_FUNC_DST_ALPHA, 1); - so_data (so, 0x4000 | nvgl_blend_func(cso->alpha_dst_factor)); + so_data (so, 0x4000 | nvgl_blend_func(cso->rt[0].alpha_dst_factor)); } if (cso->logicop_enable == 0 ) { @@ -71,13 +71,13 @@ nv50_blend_state_create(struct pipe_context *pipe, so_data (so, nvgl_logicop_func(cso->logicop_func)); } - if (cso->colormask & PIPE_MASK_R) + if (cso->rt[0].colormask & PIPE_MASK_R) cmask |= (1 << 0); - if (cso->colormask & PIPE_MASK_G) + if (cso->rt[0].colormask & PIPE_MASK_G) cmask |= (1 << 4); - if (cso->colormask & PIPE_MASK_B) + if (cso->rt[0].colormask & PIPE_MASK_B) cmask |= (1 << 8); - if (cso->colormask & PIPE_MASK_A) + if (cso->rt[0].colormask & PIPE_MASK_A) cmask |= (1 << 12); so_method(so, tesla, NV50TCL_COLOR_MASK(0), 8); for (i = 0; i < 8; i++) -- cgit v1.2.3 From 4e6bfa6de1940f1da018aace444ae7ca16792d28 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 25 Jan 2010 16:39:16 +0100 Subject: softpipe: adapt to blend changes --- src/gallium/drivers/softpipe/sp_quad_blend.c | 44 ++++++++++++------------- src/gallium/drivers/softpipe/sp_video_context.c | 17 +++++----- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/gallium/drivers/softpipe/sp_quad_blend.c b/src/gallium/drivers/softpipe/sp_quad_blend.c index d9babe81da..abca323314 100644 --- a/src/gallium/drivers/softpipe/sp_quad_blend.c +++ b/src/gallium/drivers/softpipe/sp_quad_blend.c @@ -234,7 +234,7 @@ blend_quad(struct quad_stage *qs, /* * Compute src/first term RGB */ - switch (softpipe->blend->rgb_src_factor) { + switch (softpipe->blend->rt[0].rgb_src_factor) { case PIPE_BLENDFACTOR_ONE: VEC4_COPY(source[0], quadColor[0]); /* R */ VEC4_COPY(source[1], quadColor[1]); /* G */ @@ -384,7 +384,7 @@ blend_quad(struct quad_stage *qs, /* * Compute src/first term A */ - switch (softpipe->blend->alpha_src_factor) { + switch (softpipe->blend->rt[0].alpha_src_factor) { case PIPE_BLENDFACTOR_ONE: VEC4_COPY(source[3], quadColor[3]); /* A */ break; @@ -453,7 +453,7 @@ blend_quad(struct quad_stage *qs, /* * Compute dest/second term RGB */ - switch (softpipe->blend->rgb_dst_factor) { + switch (softpipe->blend->rt[0].rgb_dst_factor) { case PIPE_BLENDFACTOR_ONE: /* dest = dest * 1 NO-OP, leave dest as-is */ break; @@ -593,7 +593,7 @@ blend_quad(struct quad_stage *qs, /* * Compute dest/second term A */ - switch (softpipe->blend->alpha_dst_factor) { + switch (softpipe->blend->rt[0].alpha_dst_factor) { case PIPE_BLENDFACTOR_ONE: /* dest = dest * 1 NO-OP, leave dest as-is */ break; @@ -656,7 +656,7 @@ blend_quad(struct quad_stage *qs, /* * Combine RGB terms */ - switch (softpipe->blend->rgb_func) { + switch (softpipe->blend->rt[0].rgb_func) { case PIPE_BLEND_ADD: VEC4_ADD_SAT(quadColor[0], source[0], dest[0]); /* R */ VEC4_ADD_SAT(quadColor[1], source[1], dest[1]); /* G */ @@ -689,7 +689,7 @@ blend_quad(struct quad_stage *qs, /* * Combine A terms */ - switch (softpipe->blend->alpha_func) { + switch (softpipe->blend->rt[0].alpha_func) { case PIPE_BLEND_ADD: VEC4_ADD_SAT(quadColor[3], source[3], dest[3]); /* A */ break; @@ -718,19 +718,19 @@ colormask_quad(struct quad_stage *qs, struct softpipe_context *softpipe = qs->softpipe; /* R */ - if (!(softpipe->blend->colormask & PIPE_MASK_R)) + if (!(softpipe->blend->rt[0].colormask & PIPE_MASK_R)) COPY_4V(quadColor[0], dest[0]); /* G */ - if (!(softpipe->blend->colormask & PIPE_MASK_G)) + if (!(softpipe->blend->rt[0].colormask & PIPE_MASK_G)) COPY_4V(quadColor[1], dest[1]); /* B */ - if (!(softpipe->blend->colormask & PIPE_MASK_B)) + if (!(softpipe->blend->rt[0].colormask & PIPE_MASK_B)) COPY_4V(quadColor[2], dest[2]); /* A */ - if (!(softpipe->blend->colormask & PIPE_MASK_A)) + if (!(softpipe->blend->rt[0].colormask & PIPE_MASK_A)) COPY_4V(quadColor[3], dest[3]); } @@ -773,11 +773,11 @@ blend_fallback(struct quad_stage *qs, if (blend->logicop_enable) { logicop_quad( qs, quadColor, dest ); } - else if (blend->blend_enable) { + else if (blend->rt[0].blend_enable) { blend_quad( qs, quadColor, dest ); } - if (blend->colormask != 0xf) + if (blend->rt[0].colormask != 0xf) colormask_quad( qs, quadColor, dest ); /* Output color values @@ -954,23 +954,23 @@ choose_blend_quad(struct quad_stage *qs, qs->run = blend_noop; } else if (!softpipe->blend->logicop_enable && - softpipe->blend->colormask == 0xf && + softpipe->blend->rt[0].colormask == 0xf && softpipe->framebuffer.nr_cbufs == 1) { - if (!blend->blend_enable) { + if (!blend->rt[0].blend_enable) { qs->run = single_output_color; } - else if (blend->rgb_src_factor == blend->alpha_src_factor && - blend->rgb_dst_factor == blend->alpha_dst_factor && - blend->rgb_func == blend->alpha_func) + else if (blend->rt[0].rgb_src_factor == blend->rt[0].alpha_src_factor && + blend->rt[0].rgb_dst_factor == blend->rt[0].alpha_dst_factor && + blend->rt[0].rgb_func == blend->rt[0].alpha_func) { - if (blend->alpha_func == PIPE_BLEND_ADD) { - if (blend->rgb_src_factor == PIPE_BLENDFACTOR_ONE && - blend->rgb_dst_factor == PIPE_BLENDFACTOR_ONE) { + if (blend->rt[0].alpha_func == PIPE_BLEND_ADD) { + if (blend->rt[0].rgb_src_factor == PIPE_BLENDFACTOR_ONE && + blend->rt[0].rgb_dst_factor == PIPE_BLENDFACTOR_ONE) { qs->run = blend_single_add_one_one; } - else if (blend->rgb_src_factor == PIPE_BLENDFACTOR_SRC_ALPHA && - blend->rgb_dst_factor == PIPE_BLENDFACTOR_INV_SRC_ALPHA) + else if (blend->rt[0].rgb_src_factor == PIPE_BLENDFACTOR_SRC_ALPHA && + blend->rt[0].rgb_dst_factor == PIPE_BLENDFACTOR_INV_SRC_ALPHA) qs->run = blend_single_add_src_alpha_inv_src_alpha; } diff --git a/src/gallium/drivers/softpipe/sp_video_context.c b/src/gallium/drivers/softpipe/sp_video_context.c index cae2d3efc5..d0723ebe9e 100644 --- a/src/gallium/drivers/softpipe/sp_video_context.c +++ b/src/gallium/drivers/softpipe/sp_video_context.c @@ -185,17 +185,18 @@ init_pipe_state(struct sp_mpeg12_context *ctx) ctx->rast = ctx->pipe->create_rasterizer_state(ctx->pipe, &rast); ctx->pipe->bind_rasterizer_state(ctx->pipe, ctx->rast); - blend.blend_enable = 0; - blend.rgb_func = PIPE_BLEND_ADD; - blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE; - blend.rgb_dst_factor = PIPE_BLENDFACTOR_ONE; - blend.alpha_func = PIPE_BLEND_ADD; - blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend.alpha_dst_factor = PIPE_BLENDFACTOR_ONE; + blend.independent_blend_enable = 0; + blend.rt[0].blend_enable = 0; + blend.rt[0].rgb_func = PIPE_BLEND_ADD; + blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].alpha_func = PIPE_BLEND_ADD; + blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ONE; blend.logicop_enable = 0; blend.logicop_func = PIPE_LOGICOP_CLEAR; /* Needed to allow color writes to FB, even if blending disabled */ - blend.colormask = PIPE_MASK_RGBA; + blend.rt[0].colormask = PIPE_MASK_RGBA; blend.dither = 0; ctx->blend = ctx->pipe->create_blend_state(ctx->pipe, &blend); ctx->pipe->bind_blend_state(ctx->pipe, ctx->blend); -- cgit v1.2.3 From 6893948d482ab69a41290d1b0172834197ee48f2 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 25 Jan 2010 16:39:39 +0100 Subject: svga: adapt to blend changes --- src/gallium/drivers/svga/svga_pipe_blend.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/svga/svga_pipe_blend.c b/src/gallium/drivers/svga/svga_pipe_blend.c index 855d228755..4029299311 100644 --- a/src/gallium/drivers/svga/svga_pipe_blend.c +++ b/src/gallium/drivers/svga/svga_pipe_blend.c @@ -182,15 +182,15 @@ svga_create_blend_state(struct pipe_context *pipe, } } else { - blend->rt[i].blend_enable = templ->blend_enable; + blend->rt[i].blend_enable = templ->rt[0].blend_enable; - if (templ->blend_enable) { - blend->rt[i].srcblend = svga_translate_blend_factor(templ->rgb_src_factor); - blend->rt[i].dstblend = svga_translate_blend_factor(templ->rgb_dst_factor); - blend->rt[i].blendeq = svga_translate_blend_func(templ->rgb_func); - blend->rt[i].srcblend_alpha = svga_translate_blend_factor(templ->alpha_src_factor); - blend->rt[i].dstblend_alpha = svga_translate_blend_factor(templ->alpha_dst_factor); - blend->rt[i].blendeq_alpha = svga_translate_blend_func(templ->alpha_func); + if (templ->rt[0].blend_enable) { + blend->rt[i].srcblend = svga_translate_blend_factor(templ->rt[0].rgb_src_factor); + blend->rt[i].dstblend = svga_translate_blend_factor(templ->rt[0].rgb_dst_factor); + blend->rt[i].blendeq = svga_translate_blend_func(templ->rt[0].rgb_func); + blend->rt[i].srcblend_alpha = svga_translate_blend_factor(templ->rt[0].alpha_src_factor); + blend->rt[i].dstblend_alpha = svga_translate_blend_factor(templ->rt[0].alpha_dst_factor); + blend->rt[i].blendeq_alpha = svga_translate_blend_func(templ->rt[0].alpha_func); if (blend->rt[i].srcblend_alpha != blend->rt[i].srcblend || blend->rt[i].dstblend_alpha != blend->rt[i].dstblend || @@ -201,7 +201,7 @@ svga_create_blend_state(struct pipe_context *pipe, } } - blend->rt[i].writemask = templ->colormask; + blend->rt[i].writemask = templ->rt[0].colormask; } return blend; -- cgit v1.2.3 From 13b74b585a013f0f089ea14c9512e3d709bdca67 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 25 Jan 2010 16:41:57 +0100 Subject: trace: adapt to blend changes --- src/gallium/drivers/trace/tr_dump_state.c | 32 ++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c index 32f61f8c94..dbca5de0a5 100644 --- a/src/gallium/drivers/trace/tr_dump_state.c +++ b/src/gallium/drivers/trace/tr_dump_state.c @@ -323,9 +323,23 @@ void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_ trace_dump_struct_end(); } +static void trace_dump_rt_blend_state(const struct pipe_rt_blend_state *state) +{ + trace_dump_member(uint, state, rgb_func); + trace_dump_member(uint, state, rgb_src_factor); + trace_dump_member(uint, state, rgb_dst_factor); + + trace_dump_member(uint, state, alpha_func); + trace_dump_member(uint, state, alpha_src_factor); + trace_dump_member(uint, state, alpha_dst_factor); + + trace_dump_member(uint, state, colormask); + +} void trace_dump_blend_state(const struct pipe_blend_state *state) { + unsigned valid_entries = 1; if (!trace_dumping_enabled_locked()) return; @@ -336,21 +350,17 @@ void trace_dump_blend_state(const struct pipe_blend_state *state) trace_dump_struct_begin("pipe_blend_state"); - trace_dump_member(bool, state, blend_enable); - - trace_dump_member(uint, state, rgb_func); - trace_dump_member(uint, state, rgb_src_factor); - trace_dump_member(uint, state, rgb_dst_factor); - - trace_dump_member(uint, state, alpha_func); - trace_dump_member(uint, state, alpha_src_factor); - trace_dump_member(uint, state, alpha_dst_factor); + trace_dump_member(bool, state, dither); trace_dump_member(bool, state, logicop_enable); trace_dump_member(uint, state, logicop_func); - trace_dump_member(uint, state, colormask); - trace_dump_member(bool, state, dither); + trace_dump_member(bool, state, independent_blend_enable); + + if (state->independent_blend_enable) + valid_entries = PIPE_MAX_COLOR_BUFS; + + trace_dump_struct_array(rt_blend_state, state->rt, valid_entries); trace_dump_struct_end(); } -- cgit v1.2.3 From dbc0e24ab866ce8bdd974b52e050dd022620b146 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 25 Jan 2010 16:43:33 +0100 Subject: xorg: do not enable unnecessary blending for xv --- src/gallium/state_trackers/xorg/xorg_xv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/xorg/xorg_xv.c b/src/gallium/state_trackers/xorg/xorg_xv.c index c4580935c3..73c076fac4 100644 --- a/src/gallium/state_trackers/xorg/xorg_xv.c +++ b/src/gallium/state_trackers/xorg/xorg_xv.c @@ -403,7 +403,7 @@ bind_blend_state(struct xorg_xv_port_priv *port) struct pipe_blend_state blend; memset(&blend, 0, sizeof(struct pipe_blend_state)); - blend.rt[0].blend_enable = 1; /* XXX why? */ + blend.rt[0].blend_enable = 0; blend.rt[0].colormask = PIPE_MASK_RGBA; /* porter&duff src */ -- cgit v1.2.3 From 0d3a6a505d537b879f31be0ed14fa8577717efaf Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 25 Jan 2010 16:52:14 +0100 Subject: vega: don't enable blending if not necessary In some places blending was enabled even though it wasn't necessary. Also remove a (bogus) reenabling of color writes, which wasn't really used. --- src/gallium/state_trackers/vega/api_filters.c | 2 +- src/gallium/state_trackers/vega/mask.c | 2 +- src/gallium/state_trackers/vega/vg_context.c | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/gallium/state_trackers/vega/api_filters.c b/src/gallium/state_trackers/vega/api_filters.c index 555d3bd7f9..cf4a11bb14 100644 --- a/src/gallium/state_trackers/vega/api_filters.c +++ b/src/gallium/state_trackers/vega/api_filters.c @@ -139,7 +139,7 @@ static void setup_blend() blend.rt[0].colormask |= PIPE_MASK_B; if (ctx->state.vg.filter_channel_mask & VG_ALPHA) blend.rt[0].colormask |= PIPE_MASK_A; - blend.rt[0].blend_enable = 1; /* XXX why? */ + blend.rt[0].blend_enable = 0; cso_set_blend(ctx->cso_context, &blend); } diff --git a/src/gallium/state_trackers/vega/mask.c b/src/gallium/state_trackers/vega/mask.c index d94fa47da6..ba8ecef1d2 100644 --- a/src/gallium/state_trackers/vega/mask.c +++ b/src/gallium/state_trackers/vega/mask.c @@ -354,7 +354,7 @@ static void setup_mask_blend() struct pipe_blend_state blend; memset(&blend, 0, sizeof(struct pipe_blend_state)); - blend.rt[0].blend_enable = 1; /* XXX why? */ + blend.rt[0].blend_enable = 0; blend.rt[0].colormask = PIPE_MASK_RGBA; blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; diff --git a/src/gallium/state_trackers/vega/vg_context.c b/src/gallium/state_trackers/vega/vg_context.c index f05a5e68c6..64207d97ba 100644 --- a/src/gallium/state_trackers/vega/vg_context.c +++ b/src/gallium/state_trackers/vega/vg_context.c @@ -286,8 +286,6 @@ static void update_clip_state(struct vg_context *ctx) renderer_draw_quad(ctx->renderer, minx, miny, maxx, maxy, 0.0f); } - blend->rt[0].colormask = PIPE_MASK_R; /*enable colorwrites*/ - /* XXX really only for red channel? */ cso_restore_blend(ctx->cso_context); cso_restore_fragment_shader(ctx->cso_context); @@ -311,7 +309,7 @@ void vg_validate_state(struct vg_context *ctx) blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; blend->rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; - /* could disable blending ? */ + blend->rt[0].blend_enable = 0; break; case VG_BLEND_SRC_OVER: blend->rt[0].rgb_src_factor = PIPE_BLENDFACTOR_SRC_ALPHA; @@ -345,7 +343,7 @@ void vg_validate_state(struct vg_context *ctx) blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; blend->rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; - /* could disable blending ? */ + blend->rt[0].blend_enable = 0; break; case VG_BLEND_ADDITIVE: blend->rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; -- cgit v1.2.3 From 0d051af6127d206d165a1034ca0795ce8fdcd389 Mon Sep 17 00:00:00 2001 From: Igor Oliveira Date: Mon, 25 Jan 2010 09:53:53 -0700 Subject: vega: fix incorrect samplers, textures indexes in blend_bind_samplers() Fixes fd.o bug 25863. Signed-off-by: Brian Paul --- src/gallium/state_trackers/vega/shader.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/vega/shader.c b/src/gallium/state_trackers/vega/shader.c index d9074a377b..91909da2c0 100644 --- a/src/gallium/state_trackers/vega/shader.c +++ b/src/gallium/state_trackers/vega/shader.c @@ -135,8 +135,8 @@ static VGint blend_bind_samplers(struct vg_context *ctx, textures[2] = stfb->blend_texture; if (!samplers[0] || !textures[0]) { - samplers[1] = samplers[2]; - textures[1] = textures[2]; + samplers[0] = samplers[2]; + textures[0] = textures[2]; } if (!samplers[1] || !textures[1]) { samplers[1] = samplers[0]; -- cgit v1.2.3 From 5fae36147e1067ac8b1eb5bcade2f9b1dbf29aa4 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 25 Jan 2010 19:27:05 +0100 Subject: st/mesa: handle EXT_draw_buffers2 per rendertarget blend enables / colormasks uses the new gallium per-rt blend functionality --- src/gallium/state_trackers/dri/dri_extensions.c | 5 ++ src/mesa/state_tracker/st_atom_blend.c | 93 ++++++++++++++++--------- src/mesa/state_tracker/st_extensions.c | 10 +++ 3 files changed, 77 insertions(+), 31 deletions(-) diff --git a/src/gallium/state_trackers/dri/dri_extensions.c b/src/gallium/state_trackers/dri/dri_extensions.c index 8b014a2a8b..1259813a41 100644 --- a/src/gallium/state_trackers/dri/dri_extensions.c +++ b/src/gallium/state_trackers/dri/dri_extensions.c @@ -50,6 +50,7 @@ #define need_GL_EXT_blend_func_separate #define need_GL_EXT_blend_minmax #define need_GL_EXT_cull_vertex +#define need_GL_EXT_draw_buffers2 #define need_GL_EXT_fog_coord #define need_GL_EXT_framebuffer_object #define need_GL_EXT_multi_draw_arrays @@ -98,6 +99,7 @@ static const struct dri_extension card_extensions[] = { {"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions}, {"GL_EXT_blend_subtract", NULL}, {"GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions}, + {"GL_EXT_draw_buffers2", GL_EXT_draw_buffers2_functions}, {"GL_EXT_fog_coord", GL_EXT_fog_coord_functions}, {"GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions}, {"GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions}, @@ -130,6 +132,9 @@ dri_init_extensions(struct dri_context *ctx) /* The card_extensions list should be pruned according to the * capabilities of the pipe_screen. This is actually something * that can/should be done inside st_create_context(). + * XXX Not pruning is very bogus. Always all these extensions above + * will be advertized, regardless what st_init_extensions + * (which depends on the pipe cap bits) does. */ driInitExtensions(ctx->st->ctx, card_extensions, GL_TRUE); } diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c index 75c1418335..809b10d479 100644 --- a/src/mesa/state_tracker/st_atom_blend.c +++ b/src/mesa/state_tracker/st_atom_blend.c @@ -152,14 +152,40 @@ translate_logicop(GLenum logicop) } } +static boolean +colormask_perrt(GLcontext *ctx) +{ + /* XXX this is ugly beyond belief */ + unsigned i; + for (i = 1; i < ctx->Const.MaxDrawBuffers; i++) { + if (!TEST_EQ_4V(ctx->Color.ColorMask[0], ctx->Color.ColorMask[i])) { + return true; + } + } + return false; +} static void update_blend( struct st_context *st ) { struct pipe_blend_state *blend = &st->state.blend; + unsigned num_state = 1; + unsigned i; memset(blend, 0, sizeof(*blend)); + if ((st->ctx->Color.BlendEnabled && + (st->ctx->Color.BlendEnabled != ((1 << st->ctx->Const.MaxDrawBuffers) - 1))) || + colormask_perrt(st->ctx)) { + num_state = st->ctx->Const.MaxDrawBuffers; + blend->independent_blend_enable = 1; + } + /* Note it is impossible to correctly deal with EXT_blend_logic_op and + EXT_draw_buffers2/EXT_blend_equation_separate at the same time. + These combinations would require support for per-rt logicop enables + and separate alpha/rgb logicop/blend support respectively. Neither + possible in gallium nor most hardware. Assume these combinations + don't happen. */ if (st->ctx->Color.ColorLogicOpEnabled || (st->ctx->Color.BlendEnabled && st->ctx->Color.BlendEquationRGB == GL_LOGIC_OP)) { @@ -169,30 +195,33 @@ update_blend( struct st_context *st ) } else if (st->ctx->Color.BlendEnabled) { /* blending enabled */ - blend->rt[0].blend_enable = 1; - - blend->rt[0].rgb_func = translate_blend(st->ctx->Color.BlendEquationRGB); - if (st->ctx->Color.BlendEquationRGB == GL_MIN || - st->ctx->Color.BlendEquationRGB == GL_MAX) { - /* Min/max are special */ - blend->rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; - blend->rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ONE; - } - else { - blend->rt[0].rgb_src_factor = translate_blend(st->ctx->Color.BlendSrcRGB); - blend->rt[0].rgb_dst_factor = translate_blend(st->ctx->Color.BlendDstRGB); - } + for (i = 0; i < num_state; i++) { - blend->rt[0].alpha_func = translate_blend(st->ctx->Color.BlendEquationA); - if (st->ctx->Color.BlendEquationA == GL_MIN || - st->ctx->Color.BlendEquationA == GL_MAX) { - /* Min/max are special */ - blend->rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend->rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ONE; - } - else { - blend->rt[0].alpha_src_factor = translate_blend(st->ctx->Color.BlendSrcA); - blend->rt[0].alpha_dst_factor = translate_blend(st->ctx->Color.BlendDstA); + blend->rt[i].blend_enable = (st->ctx->Color.BlendEnabled >> i) & 0x1; + + blend->rt[i].rgb_func = translate_blend(st->ctx->Color.BlendEquationRGB); + if (st->ctx->Color.BlendEquationRGB == GL_MIN || + st->ctx->Color.BlendEquationRGB == GL_MAX) { + /* Min/max are special */ + blend->rt[i].rgb_src_factor = PIPE_BLENDFACTOR_ONE; + blend->rt[i].rgb_dst_factor = PIPE_BLENDFACTOR_ONE; + } + else { + blend->rt[i].rgb_src_factor = translate_blend(st->ctx->Color.BlendSrcRGB); + blend->rt[i].rgb_dst_factor = translate_blend(st->ctx->Color.BlendDstRGB); + } + + blend->rt[i].alpha_func = translate_blend(st->ctx->Color.BlendEquationA); + if (st->ctx->Color.BlendEquationA == GL_MIN || + st->ctx->Color.BlendEquationA == GL_MAX) { + /* Min/max are special */ + blend->rt[i].alpha_src_factor = PIPE_BLENDFACTOR_ONE; + blend->rt[i].alpha_dst_factor = PIPE_BLENDFACTOR_ONE; + } + else { + blend->rt[i].alpha_src_factor = translate_blend(st->ctx->Color.BlendSrcA); + blend->rt[i].alpha_dst_factor = translate_blend(st->ctx->Color.BlendDstA); + } } } else { @@ -200,14 +229,16 @@ update_blend( struct st_context *st ) } /* Colormask - maybe reverse these bits? */ - if (st->ctx->Color.ColorMask[0][0]) - blend->rt[0].colormask |= PIPE_MASK_R; - if (st->ctx->Color.ColorMask[0][1]) - blend->rt[0].colormask |= PIPE_MASK_G; - if (st->ctx->Color.ColorMask[0][2]) - blend->rt[0].colormask |= PIPE_MASK_B; - if (st->ctx->Color.ColorMask[0][3]) - blend->rt[0].colormask |= PIPE_MASK_A; + for (i = 0; i < num_state; i++) { + if (st->ctx->Color.ColorMask[i][0]) + blend->rt[i].colormask |= PIPE_MASK_R; + if (st->ctx->Color.ColorMask[i][1]) + blend->rt[i].colormask |= PIPE_MASK_G; + if (st->ctx->Color.ColorMask[i][2]) + blend->rt[i].colormask |= PIPE_MASK_B; + if (st->ctx->Color.ColorMask[i][3]) + blend->rt[i].colormask |= PIPE_MASK_A; + } if (st->ctx->Color.DitherFlag) blend->dither = 1; diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 2a5fb27d8f..a7411c8643 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -315,4 +315,14 @@ void st_init_extensions(struct st_context *st) if (st->pipe->render_condition) { ctx->Extensions.NV_conditional_render = GL_TRUE; } + + if (screen->get_param(screen, PIPE_CAP_INDEP_BLEND_ENABLE)) { + ctx->Extensions.EXT_draw_buffers2 = GL_TRUE; + } + +#if 0 /* not yet */ + if (screen->get_param(screen, PIPE_CAP_INDEP_BLEND_FUNC)) { + ctx->Extensions.ARB_draw_buffers_blend = GL_TRUE; + } +#endif } -- cgit v1.2.3 From 6749310d3f60df70ad8f82db986871ab9496793b Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 25 Jan 2010 20:07:43 +0100 Subject: st/xorg: Fix crash on resize with libkms --- src/gallium/state_trackers/xorg/xorg_driver.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index 0ff6c52915..e4ad789e9b 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -1066,12 +1066,22 @@ drv_bind_front_buffer_kms(ScrnInfoPtr pScrn) goto err_destroy; pScreen->ModifyPixmapHeader(rootPixmap, - pScreen->width, - pScreen->height, + pScrn->virtualX, + pScrn->virtualY, pScreen->rootDepth, pScrn->bitsPerPixel, stride, ptr); + + /* This a hack to work around EnableDisableFBAccess setting the pointer + * the real fix would be to replace pScrn->EnableDisableFBAccess hook + * and set the rootPixmap->devPrivate.ptr to something valid before that. + * + * But in its infinit visdome something uses either this some times before + * that, so our hook doesn't get called before the crash happens. + */ + pScrn->pixmapPrivate.ptr = ptr; + return TRUE; err_destroy: -- cgit v1.2.3 From df4395198ce433251c8bd2d497543c7b389e5aca Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 25 Jan 2010 20:20:52 +0100 Subject: softpipe: enable new blend functionality works with tests/drawbuffers2 --- src/gallium/drivers/softpipe/sp_quad_blend.c | 35 ++++++++++++++-------------- src/gallium/drivers/softpipe/sp_screen.c | 4 ++++ 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/gallium/drivers/softpipe/sp_quad_blend.c b/src/gallium/drivers/softpipe/sp_quad_blend.c index abca323314..a1fe5192b0 100644 --- a/src/gallium/drivers/softpipe/sp_quad_blend.c +++ b/src/gallium/drivers/softpipe/sp_quad_blend.c @@ -224,7 +224,8 @@ logicop_quad(struct quad_stage *qs, static void blend_quad(struct quad_stage *qs, float (*quadColor)[4], - float (*dest)[4]) + float (*dest)[4], + unsigned cbuf) { static const float zero[4] = { 0, 0, 0, 0 }; static const float one[4] = { 1, 1, 1, 1 }; @@ -234,7 +235,7 @@ blend_quad(struct quad_stage *qs, /* * Compute src/first term RGB */ - switch (softpipe->blend->rt[0].rgb_src_factor) { + switch (softpipe->blend->rt[cbuf].rgb_src_factor) { case PIPE_BLENDFACTOR_ONE: VEC4_COPY(source[0], quadColor[0]); /* R */ VEC4_COPY(source[1], quadColor[1]); /* G */ @@ -384,7 +385,7 @@ blend_quad(struct quad_stage *qs, /* * Compute src/first term A */ - switch (softpipe->blend->rt[0].alpha_src_factor) { + switch (softpipe->blend->rt[cbuf].alpha_src_factor) { case PIPE_BLENDFACTOR_ONE: VEC4_COPY(source[3], quadColor[3]); /* A */ break; @@ -453,7 +454,7 @@ blend_quad(struct quad_stage *qs, /* * Compute dest/second term RGB */ - switch (softpipe->blend->rt[0].rgb_dst_factor) { + switch (softpipe->blend->rt[cbuf].rgb_dst_factor) { case PIPE_BLENDFACTOR_ONE: /* dest = dest * 1 NO-OP, leave dest as-is */ break; @@ -593,7 +594,7 @@ blend_quad(struct quad_stage *qs, /* * Compute dest/second term A */ - switch (softpipe->blend->rt[0].alpha_dst_factor) { + switch (softpipe->blend->rt[cbuf].alpha_dst_factor) { case PIPE_BLENDFACTOR_ONE: /* dest = dest * 1 NO-OP, leave dest as-is */ break; @@ -656,7 +657,7 @@ blend_quad(struct quad_stage *qs, /* * Combine RGB terms */ - switch (softpipe->blend->rt[0].rgb_func) { + switch (softpipe->blend->rt[cbuf].rgb_func) { case PIPE_BLEND_ADD: VEC4_ADD_SAT(quadColor[0], source[0], dest[0]); /* R */ VEC4_ADD_SAT(quadColor[1], source[1], dest[1]); /* G */ @@ -689,7 +690,7 @@ blend_quad(struct quad_stage *qs, /* * Combine A terms */ - switch (softpipe->blend->rt[0].alpha_func) { + switch (softpipe->blend->rt[cbuf].alpha_func) { case PIPE_BLEND_ADD: VEC4_ADD_SAT(quadColor[3], source[3], dest[3]); /* A */ break; @@ -711,26 +712,24 @@ blend_quad(struct quad_stage *qs, } static void -colormask_quad(struct quad_stage *qs, +colormask_quad(unsigned colormask, float (*quadColor)[4], float (*dest)[4]) { - struct softpipe_context *softpipe = qs->softpipe; - /* R */ - if (!(softpipe->blend->rt[0].colormask & PIPE_MASK_R)) + if (!(colormask & PIPE_MASK_R)) COPY_4V(quadColor[0], dest[0]); /* G */ - if (!(softpipe->blend->rt[0].colormask & PIPE_MASK_G)) + if (!(colormask & PIPE_MASK_G)) COPY_4V(quadColor[1], dest[1]); /* B */ - if (!(softpipe->blend->rt[0].colormask & PIPE_MASK_B)) + if (!(colormask & PIPE_MASK_B)) COPY_4V(quadColor[2], dest[2]); /* A */ - if (!(softpipe->blend->rt[0].colormask & PIPE_MASK_A)) + if (!(colormask & PIPE_MASK_A)) COPY_4V(quadColor[3], dest[3]); } @@ -773,12 +772,12 @@ blend_fallback(struct quad_stage *qs, if (blend->logicop_enable) { logicop_quad( qs, quadColor, dest ); } - else if (blend->rt[0].blend_enable) { - blend_quad( qs, quadColor, dest ); + else if (blend->rt[cbuf].blend_enable) { + blend_quad( qs, quadColor, dest, cbuf ); } - if (blend->rt[0].colormask != 0xf) - colormask_quad( qs, quadColor, dest ); + if (blend->rt[cbuf].colormask != 0xf) + colormask_quad( blend->rt[cbuf].colormask, quadColor, dest); /* Output color values */ diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index bd3532de4f..e36f9ec5da 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -91,6 +91,10 @@ softpipe_get_param(struct pipe_screen *screen, int param) return 1; case PIPE_CAP_BLEND_EQUATION_SEPARATE: return 1; + case PIPE_CAP_INDEP_BLEND_ENABLE: + return 1; + case PIPE_CAP_INDEP_BLEND_FUNC: + return 1; default: return 0; } -- cgit v1.2.3 From 72778a9d254f6c9c63d86413936ee7f3e5a6e56e Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 25 Jan 2010 10:52:19 -0800 Subject: Revert "r300g,radeong: finish and enable the immediate mode" This reverts commit 112239e9a66a155d36fe2ad0ab130e6f26eff298. --- src/gallium/drivers/r300/r300_emit.c | 22 ++++ src/gallium/drivers/r300/r300_render.c | 141 +++++---------------- src/gallium/drivers/r300/r300_state.c | 22 ---- src/gallium/winsys/drm/radeon/core/radeon_buffer.c | 83 ++---------- src/gallium/winsys/drm/radeon/core/radeon_buffer.h | 2 - src/gallium/winsys/drm/radeon/core/radeon_drm.h | 2 +- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 8 +- src/gallium/winsys/drm/radeon/core/radeon_winsys.h | 6 - 8 files changed, 67 insertions(+), 219 deletions(-) diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index badbf3715c..36d2c64b58 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -772,6 +772,22 @@ void r300_emit_texture(struct r300_context* r300, END_CS; } +static boolean r300_validate_aos(struct r300_context *r300) +{ + struct pipe_vertex_buffer *vbuf = r300->vertex_buffer; + struct pipe_vertex_element *velem = r300->vertex_element; + int i; + + /* Check if formats and strides are aligned to the size of DWORD. */ + for (i = 0; i < r300->vertex_element_count; i++) { + if (vbuf[velem[i].vertex_buffer_index].stride % 4 != 0 || + util_format_get_blocksize(velem[i].src_format) % 4 != 0) { + return FALSE; + } + } + return TRUE; +} + void r300_emit_aos(struct r300_context* r300, unsigned offset) { struct pipe_vertex_buffer *vb1, *vb2, *vbuf = r300->vertex_buffer; @@ -781,6 +797,12 @@ void r300_emit_aos(struct r300_context* r300, unsigned offset) unsigned packet_size = (aos_count * 3 + 1) / 2; CS_LOCALS(r300); + /* XXX Move this checking to a more approriate place. */ + if (!r300_validate_aos(r300)) { + /* XXX We should fallback using Draw. */ + assert(0); + } + BEGIN_CS(2 + packet_size + aos_count * 2); OUT_CS_PKT3(R300_PACKET3_3D_LOAD_VBPNTR, packet_size); OUT_CS(aos_count); diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 7f095bffe7..677031ef04 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -28,7 +28,6 @@ #include "pipe/p_inlines.h" -#include "util/u_format.h" #include "util/u_memory.h" #include "util/u_prim.h" @@ -115,53 +114,20 @@ static uint32_t r300_provoking_vertex_fixes(struct r300_context *r300, return color_control; } - -static void r300_emit_draw_arrays_immediate(struct r300_context *r300, - unsigned mode, - unsigned start, - unsigned count) +static void r300_emit_draw_immediate(struct r300_context *r300, + unsigned mode, + unsigned start, + unsigned count) { - struct pipe_vertex_element* velem; - struct pipe_vertex_buffer* vbuf; - unsigned vertex_element_count = r300->vertex_element_count; - unsigned i, v, vbi, dw, elem_offset; - - /* Size of the vertex, in dwords. */ - unsigned vertex_size = 0; - - /* Offsets of the attribute, in dwords, from the start of the vertex. */ - unsigned offset[PIPE_MAX_ATTRIBS]; - - /* Size of the vertex element, in dwords. */ - unsigned size[PIPE_MAX_ATTRIBS]; - - /* Stride to the same attrib in the next vertex in the vertex buffer, - * in dwords. */ - unsigned stride[PIPE_MAX_ATTRIBS]; - - /* Mapped vertex buffers. */ - uint32_t* map[PIPE_MAX_ATTRIBS] = {0}; - + struct pipe_buffer* vbo = r300->vertex_buffer[0].buffer; + unsigned vertex_size = r300->vertex_buffer[0].stride / sizeof(float); + unsigned i; + uint32_t* map; CS_LOCALS(r300); - /* Calculate the vertex size, offsets, strides etc. and map the buffers. */ - for (i = 0; i < vertex_element_count; i++) { - velem = &r300->vertex_element[i]; - offset[i] = velem->src_offset >> 2; - size[i] = util_format_get_blocksize(velem->src_format) >> 2; - vertex_size += size[i]; - vbi = velem->vertex_buffer_index; - - /* Map the buffer. */ - if (!map[vbi]) { - vbuf = &r300->vertex_buffer[vbi]; - map[vbi] = (uint32_t*)pipe_buffer_map(r300->context.screen, - vbuf->buffer, - PIPE_BUFFER_USAGE_CPU_READ); - map[vbi] += vbuf->buffer_offset >> 2; - stride[vbi] = vbuf->stride >> 2; - } - } + map = (uint32_t*)pipe_buffer_map_range(r300->context.screen, vbo, + start * vertex_size, count * vertex_size, + PIPE_BUFFER_USAGE_CPU_READ); BEGIN_CS(10 + count * vertex_size); OUT_CS_REG(R300_GA_COLOR_CONTROL, @@ -172,31 +138,18 @@ static void r300_emit_draw_arrays_immediate(struct r300_context *r300, OUT_CS_PKT3(R300_PACKET3_3D_DRAW_IMMD_2, count * vertex_size); OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_EMBEDDED | (count << 16) | r300_translate_primitive(mode)); - - /* Emit vertices. */ - for (v = 0; v < count; v++) { - for (i = 0; i < vertex_element_count; i++) { - velem = &r300->vertex_element[i]; - vbi = velem->vertex_buffer_index; - elem_offset = offset[i] + stride[vbi] * (v + start); - - for (dw = 0; dw < size[i]; dw++) { - OUT_CS(map[vbi][elem_offset + dw]); - } + //debug_printf("r300: Immd %d verts, %d attrs\n", count, vertex_size); + for (i = 0; i < count * vertex_size; i++) { + if (i % vertex_size == 0) { + //debug_printf("r300: -- vert --\n"); } + //debug_printf("r300: 0x%08x\n", *map); + OUT_CS(*map); + map++; } END_CS; - /* Unmap buffers. */ - for (i = 0; i < vertex_element_count; i++) { - vbi = r300->vertex_element[i].vertex_buffer_index; - - if (map[vbi]) { - vbuf = &r300->vertex_buffer[vbi]; - pipe_buffer_unmap(r300->context.screen, vbuf->buffer); - map[vbi] = 0; - } - } + pipe_buffer_unmap(r300->context.screen, vbo); } static void r300_emit_draw_arrays(struct r300_context *r300, @@ -269,49 +222,16 @@ static void r300_emit_draw_elements(struct r300_context *r300, } -static boolean r300_setup_local_vertex_buffers(struct r300_context *r300) -{ - struct pipe_vertex_buffer *vb; - boolean found_local_bo = FALSE, found_managed_bo = FALSE; - unsigned i; - - /* See what buffers we got. */ - for (i = 0; i < r300->vertex_element_count; i++) { - vb = &r300->vertex_buffer[r300->vertex_element[i].vertex_buffer_index]; - if (r300->winsys->buffer_is_local(r300->winsys, vb->buffer)) { - found_local_bo = TRUE; - } else { - found_managed_bo = TRUE; - } - } - - /* If we found both local and managed buffers, make local buffers managed - * because we shouldn't use the immediate mode in case a managed buffer is - * present, due to performance reasons. */ - if (found_local_bo && found_managed_bo) { - for (i = 0; i < r300->vertex_element_count; i++) { - vb = &r300->vertex_buffer[r300->vertex_element[i].vertex_buffer_index]; - if (r300->winsys->buffer_is_local(r300->winsys, vb->buffer)) { - r300->winsys->buffer_make_managed(r300->winsys, vb->buffer); - } - } - } - - return !found_managed_bo; -} - static boolean r300_setup_vertex_buffers(struct r300_context *r300) { struct pipe_vertex_buffer *vbuf = r300->vertex_buffer; struct pipe_vertex_element *velem = r300->vertex_element; - struct pipe_buffer *pbuf; validate: for (int i = 0; i < r300->vertex_element_count; i++) { - pbuf = vbuf[velem[i].vertex_buffer_index].buffer; - - if (!r300->winsys->add_buffer(r300->winsys, pbuf, - RADEON_GEM_DOMAIN_GTT, 0)) { + if (!r300->winsys->add_buffer(r300->winsys, + vbuf[velem[i].vertex_buffer_index].buffer, + RADEON_GEM_DOMAIN_GTT, 0)) { r300->context.flush(&r300->context, 0, NULL); goto validate; } @@ -325,7 +245,6 @@ validate: return TRUE; } - static void r300_shorten_ubyte_elts(struct r300_context* r300, struct pipe_buffer** elts, unsigned count) @@ -446,15 +365,15 @@ void r300_draw_arrays(struct pipe_context* pipe, unsigned mode, r300_emit_buffer_validate(r300); - if (r300_setup_local_vertex_buffers(r300)) { - r300_emit_dirty_state(r300); - r300_emit_draw_arrays_immediate(r300, mode, start, count); - } else { - if (!r300_setup_vertex_buffers(r300)) { - return; - } + if (!r300_setup_vertex_buffers(r300)) { + return; + } + + r300_emit_dirty_state(r300); - r300_emit_dirty_state(r300); + if (FALSE && count <= 4 && r300->vertex_buffer_count == 1) { + r300_emit_draw_immediate(r300, mode, start, count); + } else { r300_emit_aos(r300, start); r300_emit_draw_arrays(r300, mode, count); } diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 641e95e7fc..e2ec0bc5bd 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -924,22 +924,6 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe, r300->dirty_state |= R300_NEW_VERTEX_FORMAT; } -static boolean r300_validate_aos(struct r300_context *r300) -{ - struct pipe_vertex_buffer *vbuf = r300->vertex_buffer; - struct pipe_vertex_element *velem = r300->vertex_element; - int i; - - /* Check if formats and strides are aligned to the size of DWORD. */ - for (i = 0; i < r300->vertex_element_count; i++) { - if (vbuf[velem[i].vertex_buffer_index].stride % 4 != 0 || - util_format_get_blocksize(velem[i].src_format) % 4 != 0) { - return FALSE; - } - } - return TRUE; -} - static void r300_set_vertex_elements(struct pipe_context* pipe, unsigned count, const struct pipe_vertex_element* elements) @@ -955,12 +939,6 @@ static void r300_set_vertex_elements(struct pipe_context* pipe, draw_flush(r300->draw); draw_set_vertex_elements(r300->draw, count, elements); } - - if (!r300_validate_aos(r300)) { - /* XXX We should fallback using draw. */ - assert(0); - abort(); - } } static void* r300_create_vs_state(struct pipe_context* pipe, diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c index 5214b6d8bc..25e1cdcdb6 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c @@ -51,23 +51,6 @@ static const char *radeon_get_name(struct pipe_winsys *ws) return "Radeon/GEM+KMS"; } -uint32_t radeon_domain_from_usage(unsigned usage) -{ - uint32_t domain = 0; - - if (usage & PIPE_BUFFER_USAGE_PIXEL) { - domain |= RADEON_GEM_DOMAIN_VRAM; - } - if (usage & PIPE_BUFFER_USAGE_VERTEX) { - domain |= RADEON_GEM_DOMAIN_GTT; - } - if (usage & PIPE_BUFFER_USAGE_INDEX) { - domain |= RADEON_GEM_DOMAIN_GTT; - } - - return domain; -} - static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws, unsigned alignment, unsigned usage, @@ -88,17 +71,25 @@ static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws, radeon_buffer->base.usage = usage; radeon_buffer->base.size = size; - if ((usage == PIPE_BUFFER_USAGE_CONSTANT && is_r3xx(radeon_ws->pci_id)) || - (usage == PIPE_BUFFER_USAGE_VERTEX && size < 512)) { + if (usage == PIPE_BUFFER_USAGE_CONSTANT && is_r3xx(radeon_ws->pci_id)) { /* Don't bother allocating a BO, as it'll never get to the card. */ - /* Also, create small vertex buffers in RAM. */ desc.alignment = alignment; desc.usage = usage; radeon_buffer->pb = pb_malloc_buffer_create(size, &desc); return &radeon_buffer->base; } - domain = radeon_domain_from_usage(usage); + domain = 0; + + if (usage & PIPE_BUFFER_USAGE_PIXEL) { + domain |= RADEON_GEM_DOMAIN_VRAM; + } + if (usage & PIPE_BUFFER_USAGE_VERTEX) { + domain |= RADEON_GEM_DOMAIN_GTT; + } + if (usage & PIPE_BUFFER_USAGE_INDEX) { + domain |= RADEON_GEM_DOMAIN_GTT; + } radeon_buffer->bo = radeon_bo_open(radeon_ws->priv->bom, 0, size, alignment, domain, 0); @@ -231,54 +222,6 @@ static void radeon_buffer_set_tiling(struct radeon_winsys *ws, radeon_bo_set_tiling(radeon_buffer->bo, flags, pitch); } -static boolean radeon_buffer_is_local(struct radeon_winsys *ws, - struct pipe_buffer *buffer) -{ - struct radeon_pipe_buffer *radeon_buffer = - (struct radeon_pipe_buffer*)buffer; - - return radeon_buffer->pb != NULL; -} - -static void radeon_buffer_make_managed(struct radeon_winsys *ws, - struct pipe_buffer *buffer) -{ - struct radeon_pipe_buffer* radeon_buffer = - (struct radeon_pipe_buffer*)buffer; - uint32_t domain; - void *map; - - if (radeon_buffer->pb) { - domain = radeon_domain_from_usage(buffer->usage); - - /* Create a managed buffer. */ - radeon_buffer->bo = radeon_bo_open(ws->priv->bom, 0, - buffer->size, buffer->alignment, - domain, 0); - if (radeon_buffer->bo == NULL) { - /* XXX What now? */ - fprintf(stderr, "radeon: cannot create a buffer in function %s\n", - __FUNCTION__); - assert(0); - abort(); - } - - /* Move data. */ - radeon_bo_map(radeon_buffer->bo, 1); - map = pb_map(radeon_buffer->pb, PIPE_BUFFER_USAGE_CPU_READ); - - memcpy(radeon_buffer->bo->ptr, map, buffer->size); - - pb_unmap(radeon_buffer->pb); - radeon_bo_unmap(radeon_buffer->bo); - - /* Release the locally-created buffer. */ - pipe_reference_init(&radeon_buffer->pb->base.reference, 0); - pb_destroy(radeon_buffer->pb); - radeon_buffer->pb = 0; - } -} - static void radeon_fence_reference(struct pipe_winsys *ws, struct pipe_fence_handle **ptr, struct pipe_fence_handle *pfence) @@ -382,8 +325,6 @@ struct radeon_winsys* radeon_pipe_winsys(int fd) radeon_ws->base.get_name = radeon_get_name; radeon_ws->buffer_set_tiling = radeon_buffer_set_tiling; - radeon_ws->buffer_is_local = radeon_buffer_is_local; - radeon_ws->buffer_make_managed = radeon_buffer_make_managed; return radeon_ws; } diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h index c46abff793..de71cb2f42 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h @@ -77,8 +77,6 @@ struct radeon_winsys_priv { void *flush_data; }; -uint32_t radeon_domain_from_usage(unsigned usage); - struct radeon_winsys* radeon_pipe_winsys(int fb); #if 0 struct pipe_surface *radeon_surface_from_handle(struct radeon_context *radeon_context, diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.h b/src/gallium/winsys/drm/radeon/core/radeon_drm.h index 077388ee02..ddd7983824 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.h @@ -81,7 +81,7 @@ void radeon_destroy_drm_api(struct drm_api* api); /* Guess at whether this chipset should use r300g. * * I believe that this check is valid, but I haven't been exhaustive. */ -static INLINE boolean is_r3xx(int pciid) +static boolean is_r3xx(int pciid) { return (pciid > 0x3150) && (pciid < 0x796f); } diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index d759beaba1..0253bc2527 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -81,13 +81,9 @@ static void radeon_write_cs_reloc(struct radeon_winsys* winsys, uint32_t flags) { int retval = 0; - struct radeon_pipe_buffer* radeon_buffer = - (struct radeon_pipe_buffer*)pbuffer; - assert(!radeon_buffer->pb); - - retval = radeon_cs_write_reloc(winsys->priv->cs, radeon_buffer->bo, - rd, wd, flags); + retval = radeon_cs_write_reloc(winsys->priv->cs, + ((struct radeon_pipe_buffer*)pbuffer)->bo, rd, wd, flags); if (retval) { debug_printf("radeon: Relocation of %p (%d, %d, %d) failed!\n", diff --git a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h index 462fba844e..864082b99b 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h @@ -106,12 +106,6 @@ struct radeon_winsys { uint32_t pitch, boolean microtiled, boolean macrotiled); - - boolean (*buffer_is_local)(struct radeon_winsys* winsys, - struct pipe_buffer* buffer); - - void (*buffer_make_managed)(struct radeon_winsys* winsys, - struct pipe_buffer* buffer); }; #endif -- cgit v1.2.3 From 67149051be56825151659eb1672242b624555f7d Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 25 Jan 2010 11:01:16 -0800 Subject: radeong: Clean up domain usages. Split from Marek's immd-mode patch. --- src/gallium/winsys/drm/radeon/core/radeon_buffer.c | 29 ++++++++++++++-------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c index 25e1cdcdb6..421fda2b45 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c @@ -51,6 +51,23 @@ static const char *radeon_get_name(struct pipe_winsys *ws) return "Radeon/GEM+KMS"; } +static uint32_t radeon_domain_from_usage(unsigned usage) +{ + uint32_t domain = 0; + + if (usage & PIPE_BUFFER_USAGE_PIXEL) { + domain |= RADEON_GEM_DOMAIN_VRAM; + } + if (usage & PIPE_BUFFER_USAGE_VERTEX) { + domain |= RADEON_GEM_DOMAIN_GTT; + } + if (usage & PIPE_BUFFER_USAGE_INDEX) { + domain |= RADEON_GEM_DOMAIN_GTT; + } + + return domain; +} + static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws, unsigned alignment, unsigned usage, @@ -79,17 +96,7 @@ static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws, return &radeon_buffer->base; } - domain = 0; - - if (usage & PIPE_BUFFER_USAGE_PIXEL) { - domain |= RADEON_GEM_DOMAIN_VRAM; - } - if (usage & PIPE_BUFFER_USAGE_VERTEX) { - domain |= RADEON_GEM_DOMAIN_GTT; - } - if (usage & PIPE_BUFFER_USAGE_INDEX) { - domain |= RADEON_GEM_DOMAIN_GTT; - } + domain = radeon_domain_from_usage(usage); radeon_buffer->bo = radeon_bo_open(radeon_ws->priv->bom, 0, size, alignment, domain, 0); -- cgit v1.2.3 From c486bfb463f30bf894d2dae1326973aeb3de1159 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 25 Jan 2010 11:04:15 -0800 Subject: radeong: Make is_r3xx inline to avoid warnings. Split from Marek's immd-mode patch. --- src/gallium/winsys/drm/radeon/core/radeon_drm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.h b/src/gallium/winsys/drm/radeon/core/radeon_drm.h index ddd7983824..077388ee02 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.h @@ -81,7 +81,7 @@ void radeon_destroy_drm_api(struct drm_api* api); /* Guess at whether this chipset should use r300g. * * I believe that this check is valid, but I haven't been exhaustive. */ -static boolean is_r3xx(int pciid) +static INLINE boolean is_r3xx(int pciid) { return (pciid > 0x3150) && (pciid < 0x796f); } -- cgit v1.2.3 From 1571602153128971ae9ed549d633d67aac65da14 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 25 Jan 2010 11:04:55 -0800 Subject: radeong: Make sure that we're not emitting relocations for local buffers. Split from Marek's immd-mode patch. --- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 0253bc2527..d759beaba1 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -81,9 +81,13 @@ static void radeon_write_cs_reloc(struct radeon_winsys* winsys, uint32_t flags) { int retval = 0; + struct radeon_pipe_buffer* radeon_buffer = + (struct radeon_pipe_buffer*)pbuffer; - retval = radeon_cs_write_reloc(winsys->priv->cs, - ((struct radeon_pipe_buffer*)pbuffer)->bo, rd, wd, flags); + assert(!radeon_buffer->pb); + + retval = radeon_cs_write_reloc(winsys->priv->cs, radeon_buffer->bo, + rd, wd, flags); if (retval) { debug_printf("radeon: Relocation of %p (%d, %d, %d) failed!\n", -- cgit v1.2.3 From 5fe71949d9e3790ce38ab616aee29079c6b67721 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 25 Jan 2010 11:27:50 -0800 Subject: r300g: Finish and enable immediate mode. Based on Marek's immd-mode patch. --- src/gallium/drivers/r300/r300_emit.c | 22 ------- src/gallium/drivers/r300/r300_render.c | 115 ++++++++++++++++++++++++--------- src/gallium/drivers/r300/r300_state.c | 22 +++++++ 3 files changed, 106 insertions(+), 53 deletions(-) diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 36d2c64b58..badbf3715c 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -772,22 +772,6 @@ void r300_emit_texture(struct r300_context* r300, END_CS; } -static boolean r300_validate_aos(struct r300_context *r300) -{ - struct pipe_vertex_buffer *vbuf = r300->vertex_buffer; - struct pipe_vertex_element *velem = r300->vertex_element; - int i; - - /* Check if formats and strides are aligned to the size of DWORD. */ - for (i = 0; i < r300->vertex_element_count; i++) { - if (vbuf[velem[i].vertex_buffer_index].stride % 4 != 0 || - util_format_get_blocksize(velem[i].src_format) % 4 != 0) { - return FALSE; - } - } - return TRUE; -} - void r300_emit_aos(struct r300_context* r300, unsigned offset) { struct pipe_vertex_buffer *vb1, *vb2, *vbuf = r300->vertex_buffer; @@ -797,12 +781,6 @@ void r300_emit_aos(struct r300_context* r300, unsigned offset) unsigned packet_size = (aos_count * 3 + 1) / 2; CS_LOCALS(r300); - /* XXX Move this checking to a more approriate place. */ - if (!r300_validate_aos(r300)) { - /* XXX We should fallback using Draw. */ - assert(0); - } - BEGIN_CS(2 + packet_size + aos_count * 2); OUT_CS_PKT3(R300_PACKET3_3D_LOAD_VBPNTR, packet_size); OUT_CS(aos_count); diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 677031ef04..dcd0761944 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -28,6 +28,7 @@ #include "pipe/p_inlines.h" +#include "util/u_format.h" #include "util/u_memory.h" #include "util/u_prim.h" @@ -114,20 +115,58 @@ static uint32_t r300_provoking_vertex_fixes(struct r300_context *r300, return color_control; } -static void r300_emit_draw_immediate(struct r300_context *r300, - unsigned mode, - unsigned start, - unsigned count) +static boolean immd_is_good_idea(struct r300_context *r300, + unsigned count) { - struct pipe_buffer* vbo = r300->vertex_buffer[0].buffer; - unsigned vertex_size = r300->vertex_buffer[0].stride / sizeof(float); - unsigned i; - uint32_t* map; + return count <= 4; +} + +static void r300_emit_draw_arrays_immediate(struct r300_context *r300, + unsigned mode, + unsigned start, + unsigned count) +{ + struct pipe_vertex_element* velem; + struct pipe_vertex_buffer* vbuf; + unsigned vertex_element_count = r300->vertex_element_count; + unsigned i, v, vbi, dw, elem_offset; + + /* Size of the vertex, in dwords. */ + unsigned vertex_size = 0; + + /* Offsets of the attribute, in dwords, from the start of the vertex. */ + unsigned offset[PIPE_MAX_ATTRIBS]; + + /* Size of the vertex element, in dwords. */ + unsigned size[PIPE_MAX_ATTRIBS]; + + /* Stride to the same attrib in the next vertex in the vertex buffer, + * in dwords. */ + unsigned stride[PIPE_MAX_ATTRIBS]; + + /* Mapped vertex buffers. */ + uint32_t* map[PIPE_MAX_ATTRIBS] = {0}; + CS_LOCALS(r300); - map = (uint32_t*)pipe_buffer_map_range(r300->context.screen, vbo, - start * vertex_size, count * vertex_size, - PIPE_BUFFER_USAGE_CPU_READ); + /* Calculate the vertex size, offsets, strides etc. and map the buffers. */ + for (i = 0; i < vertex_element_count; i++) { + velem = &r300->vertex_element[i]; + offset[i] = velem->src_offset / 4; + size[i] = util_format_get_blocksize(velem->src_format) / 4; + vertex_size += size[i]; + vbi = velem->vertex_buffer_index; + + /* Map the buffer. */ + if (!map[vbi]) { + vbuf = &r300->vertex_buffer[vbi]; + map[vbi] = (uint32_t*)pipe_buffer_map(r300->context.screen, + vbuf->buffer, + PIPE_BUFFER_USAGE_CPU_READ); + map[vbi] += vbuf->buffer_offset / 4; + stride[vbi] = vbuf->stride / 4; + } + } BEGIN_CS(10 + count * vertex_size); OUT_CS_REG(R300_GA_COLOR_CONTROL, @@ -138,18 +177,31 @@ static void r300_emit_draw_immediate(struct r300_context *r300, OUT_CS_PKT3(R300_PACKET3_3D_DRAW_IMMD_2, count * vertex_size); OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_EMBEDDED | (count << 16) | r300_translate_primitive(mode)); - //debug_printf("r300: Immd %d verts, %d attrs\n", count, vertex_size); - for (i = 0; i < count * vertex_size; i++) { - if (i % vertex_size == 0) { - //debug_printf("r300: -- vert --\n"); + + /* Emit vertices. */ + for (v = 0; v < count; v++) { + for (i = 0; i < vertex_element_count; i++) { + velem = &r300->vertex_element[i]; + vbi = velem->vertex_buffer_index; + elem_offset = offset[i] + stride[vbi] * (v + start); + + for (dw = 0; dw < size[i]; dw++) { + OUT_CS(map[vbi][elem_offset + dw]); + } } - //debug_printf("r300: 0x%08x\n", *map); - OUT_CS(*map); - map++; } END_CS; - pipe_buffer_unmap(r300->context.screen, vbo); + /* Unmap buffers. */ + for (i = 0; i < vertex_element_count; i++) { + vbi = r300->vertex_element[i].vertex_buffer_index; + + if (map[vbi]) { + vbuf = &r300->vertex_buffer[vbi]; + pipe_buffer_unmap(r300->context.screen, vbuf->buffer); + map[vbi] = NULL; + } + } } static void r300_emit_draw_arrays(struct r300_context *r300, @@ -221,17 +273,18 @@ static void r300_emit_draw_elements(struct r300_context *r300, END_CS; } - static boolean r300_setup_vertex_buffers(struct r300_context *r300) { struct pipe_vertex_buffer *vbuf = r300->vertex_buffer; struct pipe_vertex_element *velem = r300->vertex_element; + struct pipe_buffer *pbuf; validate: for (int i = 0; i < r300->vertex_element_count; i++) { - if (!r300->winsys->add_buffer(r300->winsys, - vbuf[velem[i].vertex_buffer_index].buffer, - RADEON_GEM_DOMAIN_GTT, 0)) { + pbuf = vbuf[velem[i].vertex_buffer_index].buffer; + + if (!r300->winsys->add_buffer(r300->winsys, pbuf, + RADEON_GEM_DOMAIN_GTT, 0)) { r300->context.flush(&r300->context, 0, NULL); goto validate; } @@ -365,15 +418,15 @@ void r300_draw_arrays(struct pipe_context* pipe, unsigned mode, r300_emit_buffer_validate(r300); - if (!r300_setup_vertex_buffers(r300)) { - return; - } - - r300_emit_dirty_state(r300); - - if (FALSE && count <= 4 && r300->vertex_buffer_count == 1) { - r300_emit_draw_immediate(r300, mode, start, count); + if (immd_is_good_idea(r300, count)) { + r300_emit_dirty_state(r300); + r300_emit_draw_arrays_immediate(r300, mode, start, count); } else { + if (!r300_setup_vertex_buffers(r300)) { + return; + } + + r300_emit_dirty_state(r300); r300_emit_aos(r300, start); r300_emit_draw_arrays(r300, mode, count); } diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index e2ec0bc5bd..641e95e7fc 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -924,6 +924,22 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe, r300->dirty_state |= R300_NEW_VERTEX_FORMAT; } +static boolean r300_validate_aos(struct r300_context *r300) +{ + struct pipe_vertex_buffer *vbuf = r300->vertex_buffer; + struct pipe_vertex_element *velem = r300->vertex_element; + int i; + + /* Check if formats and strides are aligned to the size of DWORD. */ + for (i = 0; i < r300->vertex_element_count; i++) { + if (vbuf[velem[i].vertex_buffer_index].stride % 4 != 0 || + util_format_get_blocksize(velem[i].src_format) % 4 != 0) { + return FALSE; + } + } + return TRUE; +} + static void r300_set_vertex_elements(struct pipe_context* pipe, unsigned count, const struct pipe_vertex_element* elements) @@ -939,6 +955,12 @@ static void r300_set_vertex_elements(struct pipe_context* pipe, draw_flush(r300->draw); draw_set_vertex_elements(r300->draw, count, elements); } + + if (!r300_validate_aos(r300)) { + /* XXX We should fallback using draw. */ + assert(0); + abort(); + } } static void* r300_create_vs_state(struct pipe_context* pipe, -- cgit v1.2.3 From 7e7f8815fbfa21ab2397e673fa19c36603bc7a51 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Mon, 25 Jan 2010 16:19:19 -0500 Subject: r300: rv350+ support FLT16_2/4 vertex formats --- src/mesa/drivers/dri/r300/r300_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c index 74947a95d2..2efdae078e 100644 --- a/src/mesa/drivers/dri/r300/r300_context.c +++ b/src/mesa/drivers/dri/r300/r300_context.c @@ -451,7 +451,7 @@ static void r300InitGLExtensions(GLcontext *ctx) if (!r300->radeon.radeonScreen->drmSupportsOcclusionQueries) { _mesa_disable_extension(ctx, "GL_ARB_occlusion_query"); } - if (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) + if (r300->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV350) _mesa_enable_extension(ctx, "GL_ARB_half_float_vertex"); } -- cgit v1.2.3 From 7a9329ba99fe1242c07fbf4fd04e7a4dbeba2e72 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Wed, 20 Jan 2010 03:01:14 +0000 Subject: mesa: misc GLX_INTEL_swap_event fixes Fixup a few issues found through testing: - update GLX names to match glproto - register DRI2WireToEvent so it actually gets called Signed-off-by: Robert Bragg --- include/GL/glx.h | 6 +++++- include/GL/glxext.h | 8 ++++---- src/glx/x11/dri2.c | 20 ++++++++++++++------ src/glx/x11/glxclient.h | 5 +++++ src/glx/x11/glxext.c | 7 +++---- 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/include/GL/glx.h b/include/GL/glx.h index 82b0f22114..fd53964ea0 100644 --- a/include/GL/glx.h +++ b/include/GL/glx.h @@ -518,8 +518,12 @@ typedef struct { } GLXPbufferClobberEvent; typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + GLXDrawable drawable; /* drawable on which event was requested in event mask */ int event_type; - GLXDrawable drawable; int64_t ust; int64_t msc; int64_t sbc; diff --git a/include/GL/glxext.h b/include/GL/glxext.h index 36ee3665df..50740dd29d 100644 --- a/include/GL/glxext.h +++ b/include/GL/glxext.h @@ -698,10 +698,10 @@ typedef void ( * PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawabl #ifndef GLX_INTEL_swap_event #define GLX_INTEL_swap_event -#define GLX_BUFFER_SWAP_COMPLETE_MASK 0x10000000 -#define GLX_EXCHANGE_COMPLETE 0x8024 -#define GLX_BLIT_COMPLETE 0x8025 -#define GLX_FLIP_COMPLETE 0x8026 +#define GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK 0x10000000 +#define GLX_EXCHANGE_COMPLETE_INTEL 0x8024 +#define GLX_BLIT_COMPLETE_INTEL 0x8025 +#define GLX_FLIP_COMPLETE_INTEL 0x8026 #endif #ifndef GLX_SGIX_swap_barrier diff --git a/src/glx/x11/dri2.c b/src/glx/x11/dri2.c index 2cb5d3463a..832935a3ba 100644 --- a/src/glx/x11/dri2.c +++ b/src/glx/x11/dri2.c @@ -81,12 +81,15 @@ static XEXT_GENERATE_FIND_DISPLAY (DRI2FindDisplay, dri2Info, dri2ExtensionName, &dri2ExtensionHooks, - 0, NULL) + 1, NULL) static Bool DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire) { XExtDisplayInfo *info = DRI2FindDisplay(dpy); + XExtDisplayInfo *glx_info = __glXFindDisplay(dpy); + static int glx_event_base; + static Bool found_glx_info = False; XextCheckExtension(dpy, info, dri2ExtensionName, False); @@ -95,21 +98,26 @@ DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire) { GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event; xDRI2BufferSwapComplete *awire = (xDRI2BufferSwapComplete *)wire; - switch (awire->type) { + aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire); + aevent->type = + (glx_info->codes->first_event + GLX_BufferSwapComplete) & 0x75; + aevent->send_event = (awire->type & 0x80) != 0; + aevent->display = dpy; + aevent->drawable = awire->drawable; + switch (awire->event_type) { case DRI2_EXCHANGE_COMPLETE: - aevent->event_type = GLX_EXCHANGE_COMPLETE; + aevent->event_type = GLX_EXCHANGE_COMPLETE_INTEL; break; case DRI2_BLIT_COMPLETE: - aevent->event_type = GLX_BLIT_COMPLETE; + aevent->event_type = GLX_BLIT_COMPLETE_INTEL; break; case DRI2_FLIP_COMPLETE: - aevent->event_type = GLX_FLIP_COMPLETE; + aevent->event_type = GLX_FLIP_COMPLETE_INTEL; break; default: /* unknown swap completion type */ return False; } - aevent->drawable = awire->drawable; aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo; aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo; aevent->sbc = ((CARD64)awire->sbc_hi << 32) | awire->sbc_lo; diff --git a/src/glx/x11/glxclient.h b/src/glx/x11/glxclient.h index ded4f5a434..e0b286b688 100644 --- a/src/glx/x11/glxclient.h +++ b/src/glx/x11/glxclient.h @@ -41,6 +41,7 @@ #define NEED_EVENTS #include #include +#include #define GLX_GLXEXT_PROTOTYPES #include #include @@ -793,6 +794,10 @@ extern GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable, GLboolean __driGetMscRateOML(__DRIdrawable * draw, int32_t * numerator, int32_t * denominator, void *private); + +/* So that dri2.c:DRI2WireToEvent() can access + * glx_info->codes->first_event */ +XExtDisplayInfo *__glXFindDisplay (Display *dpy); #endif #endif /* !__GLX_client_h__ */ diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c index fe65216c41..09bb850319 100644 --- a/src/glx/x11/glxext.c +++ b/src/glx/x11/glxext.c @@ -120,7 +120,6 @@ static /* const */ XExtensionHooks __glXExtensionHooks = { __glXErrorString, /* error_string */ }; -static XEXT_GENERATE_FIND_DISPLAY(__glXFindDisplay, __glXExtensionInfo, __glXExtensionName, &__glXExtensionHooks, __GLX_NUMBER_EVENTS, NULL) @@ -194,11 +193,11 @@ __glXEventToWire(Display *dpy, XEvent *event, xEvent *wire) break; case GLX_SAVED: break; - case GLX_EXCHANGE_COMPLETE: + case GLX_EXCHANGE_COMPLETE_INTEL: break; - case GLX_BLIT_COMPLETE: + case GLX_BLIT_COMPLETE_INTEL: break; - case GLX_FLIP_COMPLETE: + case GLX_FLIP_COMPLETE_INTEL: break; default: /* client doesn't support server event */ -- cgit v1.2.3 From 0d2d40451d01a07db515452561c71eaacb789872 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 26 Jan 2010 10:46:32 +0800 Subject: egl/xdri: Update with glxclient.h change. __glXFindDisplay is no longer static since 7a9329ba99fe1242c07fbf4fd04e7a4dbeba2e72. --- src/egl/drivers/xdri/glxinit.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/egl/drivers/xdri/glxinit.c b/src/egl/drivers/xdri/glxinit.c index 5c0fbc6b3c..ba6132788a 100644 --- a/src/egl/drivers/xdri/glxinit.c +++ b/src/egl/drivers/xdri/glxinit.c @@ -53,7 +53,6 @@ static /* const */ XExtensionHooks __glXExtensionHooks = { NULL, /* error_string */ }; -static XEXT_GENERATE_FIND_DISPLAY(__glXFindDisplay, __glXExtensionInfo, __glXExtensionName, &__glXExtensionHooks, __GLX_NUMBER_EVENTS, NULL) -- cgit v1.2.3 From a6342afe502fe52190be4d97df58eb3406b70246 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 26 Jan 2010 10:54:45 +0800 Subject: docs: Update EGL documentation. Add --enable-gallium-swrast to the example. Document missing --with-egl-driver-dir and update TODOs. --- docs/egl.html | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/egl.html b/docs/egl.html index 0882598966..305e5f6eab 100644 --- a/docs/egl.html +++ b/docs/egl.html @@ -32,7 +32,7 @@ cards.

      the Gallium driver for your hardware. For example

      -  $ ./configure --with-state-trackers=egl,es,vega --enable-gallium-intel
      +  $ ./configure --with-state-trackers=egl,es,vega --enable-gallium-{swrast,intel}
       

      The main library will be enabled by default. The egl state @@ -62,6 +62,13 @@ will not be built.

      +
    • --with-egl-driver-dir + +

      The directory EGL drivers should be installed to. If not specified, EGL +drivers will be installed to ${libdir}/egl.

      + +
    • +
    • --with-egl-displays

      List the window system(s) to support. It is by default x11, @@ -227,6 +234,7 @@ be found at src/gallium/state_trackers/egl/.

    • Pass the conformance tests
    • Better automatic driver selection: EGL_DISPLAY loads all drivers and might eat too much memory.
    • +
    • Stop using glxinit.c and sources from src/glx/x11/
    -- cgit v1.2.3 From 146931769c75978c58ac0088e8ab630fc41074ec Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 21 Jan 2010 17:58:28 +0800 Subject: glx: Build GLX normally. GLX was built specially and before Mesa core because libglapi.a could not be built with IN_DRI_DRIVER defined. This is no longer the case since 6e99e6ddbf488f6955e34ef0bc438fdcb4d90f74. It works fine in my (limited) testing with both direct and indirect rendering. I also compare the outputs after preprocessing (gcc -E) with or without this commit, and they are identical. --- configure.ac | 2 +- src/glx/x11/Makefile | 21 +++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/configure.ac b/configure.ac index 6f8b76d7ca..10e0bd47ab 100644 --- a/configure.ac +++ b/configure.ac @@ -445,7 +445,7 @@ xlib) GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS xlib" ;; dri) - CORE_DIRS="glx/x11 $CORE_DIRS" + SRC_DIRS="$SRC_DIRS glx/x11" DRIVER_DIRS="dri" WINDOW_SYSTEM="dri" GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm" diff --git a/src/glx/x11/Makefile b/src/glx/x11/Makefile index 86d84d4b9f..e681be834f 100644 --- a/src/glx/x11/Makefile +++ b/src/glx/x11/Makefile @@ -1,7 +1,7 @@ TOP = ../../.. include $(TOP)/configs/current -EXTRA_DEFINES = -DXF86VIDMODE -D_REENTRANT -UIN_DRI_DRIVER \ +EXTRA_DEFINES = -DXF86VIDMODE -D_REENTRANT \ -DDEFAULT_DRIVER_DIR=\"$(DRI_DRIVER_SEARCH_DIR)\" SOURCES = \ @@ -39,13 +39,9 @@ SOURCES = \ dri2_glx.c \ dri2.c -include $(TOP)/src/mesa/sources.mak +GLAPI_LIB = $(TOP)/src/mesa/libglapi.a -MESA_GLAPI_ASM_SOURCES = $(addprefix $(TOP)/src/mesa/, $(GLAPI_ASM_SOURCES)) -MESA_GLAPI_SOURCES = $(addprefix $(TOP)/src/mesa/, $(GLAPI_SOURCES)) -MESA_GLAPI_OBJECTS = $(addprefix $(TOP)/src/mesa/, $(GLAPI_OBJECTS)) - -OBJECTS = $(SOURCES:.c=.o) $(MESA_GLAPI_OBJECTS) +OBJECTS = $(SOURCES:.c=.o) INCLUDES = -I. \ -I$(TOP)/include \ @@ -70,18 +66,19 @@ INCLUDES = -I. \ default: depend $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) # Make libGL -$(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) Makefile +$(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) $(GLAPI_LIB) Makefile $(MKLIB) -o $(GL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \ -major 1 -minor 2 $(MKLIB_OPTIONS) \ -install $(TOP)/$(LIB_DIR) -id $(INSTALL_LIB_DIR)/lib$(GL_LIB).1.dylib \ - $(GL_LIB_DEPS) $(OBJECTS) + $(GL_LIB_DEPS) $(OBJECTS) $(GLAPI_LIB) +$(GLAPI_LIB): + @$(MAKE) -C $(TOP)/src/mesa libglapi.a -depend: $(SOURCES) $(MESA_GLAPI_SOURCES) $(MESA_GLAPI_ASM_SOURCES) Makefile +depend: $(SOURCES) Makefile rm -f depend touch depend - $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(SOURCES) \ - $(MESA_GLAPI_SOURCES) $(MESA_GLAPI_ASM_SOURCES) + $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(SOURCES) # Emacs tags -- cgit v1.2.3 From 74aa773f7cbe456ca8f25c8a9a2c911795cc2a63 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 26 Jan 2010 11:35:30 +0800 Subject: docs: Mention EGL and OpenGL ES in 7.8 release notes. --- docs/relnotes-7.8.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/relnotes-7.8.html b/docs/relnotes-7.8.html index 717b96282c..4fcc491036 100644 --- a/docs/relnotes-7.8.html +++ b/docs/relnotes-7.8.html @@ -36,6 +36,8 @@ tbd
    • GL_NV_conditional_render extension (swrast driver only)
    • GL_EXT_draw_buffers2 extension (swrast driver only) +
    • Much improved support for EGL in Mesa +
    • New state trackers for OpenGL ES 1.1 and 2.0
    -- cgit v1.2.3 From a098fd71d7b7347bb8f1841bad0e7ce24e0e6de9 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 25 Jan 2010 22:27:46 -0800 Subject: i965: Fix build after merge of mesa stable branch. --- src/mesa/drivers/dri/i965/brw_context.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 568db97ec7..65f51be341 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -37,6 +37,7 @@ #include "shader/shader_api.h" #include "brw_context.h" +#include "brw_defines.h" #include "brw_draw.h" #include "brw_state.h" #include "intel_span.h" -- cgit v1.2.3 From 5e1851b144a97bd577409dd5c6f3f6f45b4ff56f Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 19 Jan 2010 15:26:56 -0800 Subject: i965: Remove unnecessary malloc/free in VS binding table setup. --- src/mesa/drivers/dri/i965/brw_vs_surface_state.c | 4 +--- src/mesa/drivers/dri/intel/intel_batchbuffer.c | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c index ca93ca7506..ead623fc0e 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c @@ -155,7 +155,7 @@ brw_vs_get_binding_table(struct brw_context *brw) if (bind_bo == NULL) { GLuint data_size = BRW_VS_MAX_SURF * sizeof(GLuint); - uint32_t *data = malloc(data_size); + uint32_t data[BRW_VS_MAX_SURF]; int i; for (i = 0; i < BRW_VS_MAX_SURF; i++) @@ -180,8 +180,6 @@ brw_vs_get_binding_table(struct brw_context *brw) I915_GEM_DOMAIN_INSTRUCTION, 0); } } - - free(data); } return bind_bo; diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c index 3a4b21a844..f18fb91a88 100644 --- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c @@ -167,7 +167,8 @@ _intel_batchbuffer_flush(struct intel_batchbuffer *batch, const char *file, struct intel_context *intel = batch->intel; GLuint used = batch->ptr - batch->map; - if (intel->first_post_swapbuffers_batch == NULL) { + if (!intel->using_dri2_swapbuffers && + intel->first_post_swapbuffers_batch == NULL) { intel->first_post_swapbuffers_batch = intel->batch->buf; drm_intel_bo_reference(intel->first_post_swapbuffers_batch); } -- cgit v1.2.3 From c7fc9bfb2207638a479ddaff3ad108ffd9cd294a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 25 Jan 2010 14:48:57 -0800 Subject: Revert "intel: Use the new DRI2 flush invalidate entrypoint to signal frame done." This reverts commit 7d4e674b212c9dc6408c13913a399bd4a2b9a1e3. It broke throttling in the non-new-DRI2 case. --- src/mesa/drivers/dri/intel/intel_context.c | 20 ++++++++++++++++++++ src/mesa/drivers/dri/intel/intel_screen.c | 21 --------------------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 5f2a473e22..cac9b7e565 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -505,7 +505,27 @@ intelFlush(GLcontext * ctx) static void intel_glFlush(GLcontext *ctx) { + struct intel_context *intel = intel_context(ctx); + intel_flush(ctx, GL_TRUE); + + /* We're using glFlush as an indicator that a frame is done, which is + * what DRI2 does before calling SwapBuffers (and means we should catch + * people doing front-buffer rendering, as well).. + * + * Wait for the swapbuffers before the one we just emitted, so we don't + * get too many swaps outstanding for apps that are GPU-heavy but not + * CPU-heavy. + * + * Unfortunately, we don't have a handle to the batch containing the swap, + * and getting our hands on that doesn't seem worth it, so we just us the + * first batch we emitted after the last swap. + */ + if (intel->first_post_swapbuffers_batch != NULL) { + drm_intel_bo_wait_rendering(intel->first_post_swapbuffers_batch); + drm_intel_bo_unreference(intel->first_post_swapbuffers_batch); + intel->first_post_swapbuffers_batch = NULL; + } } void diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index fe50416642..a98600b575 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -126,29 +126,8 @@ intelDRI2Flush(__DRIdrawable *drawable) static void intelDRI2FlushInvalidate(__DRIdrawable *drawable) { - struct intel_context *intel = drawable->driContextPriv->driverPrivate; - intelDRI2Flush(drawable); drawable->validBuffers = GL_FALSE; - - /* We're using FlushInvalidate as an indicator that a frame is - * done. It's only called immediately after SwapBuffers, so it - * won't affect front-buffer rendering or applications explicitly - * managing swap regions using MESA_copy_buffer. - * - * Wait for the swapbuffers before the one we just emitted, so we don't - * get too many swaps outstanding for apps that are GPU-heavy but not - * CPU-heavy. - * - * Unfortunately, we don't have a handle to the batch containing the swap, - * and getting our hands on that doesn't seem worth it, so we just use the - * first batch we emitted after the last swap. - */ - if (intel->first_post_swapbuffers_batch != NULL) { - drm_intel_bo_wait_rendering(intel->first_post_swapbuffers_batch); - drm_intel_bo_unreference(intel->first_post_swapbuffers_batch); - intel->first_post_swapbuffers_batch = NULL; - } } static const struct __DRI2flushExtensionRec intelFlushExtension = { -- cgit v1.2.3 From 7aed23c36288c2b343073d6d06ca0ea167805cd3 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 25 Jan 2010 14:53:50 -0800 Subject: intel: Don't do client-side frame throttling with DRI2 SwapBuffers. The server side does the throttling on our behalf now by putting the client to sleep, so we don't need our previous hacks for limiting the number of outstanding frames. Same effect as 7d4e674b212c9dc6408c13913a399bd4a2b9a1e3. --- src/mesa/drivers/dri/intel/intel_context.c | 3 ++- src/mesa/drivers/dri/intel/intel_context.h | 1 + src/mesa/drivers/dri/intel/intel_screen.c | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index cac9b7e565..3896bfa091 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -521,7 +521,8 @@ intel_glFlush(GLcontext *ctx) * and getting our hands on that doesn't seem worth it, so we just us the * first batch we emitted after the last swap. */ - if (intel->first_post_swapbuffers_batch != NULL) { + if (!intel->using_dri2_swapbuffers && + intel->first_post_swapbuffers_batch != NULL) { drm_intel_bo_wait_rendering(intel->first_post_swapbuffers_batch); drm_intel_bo_unreference(intel->first_post_swapbuffers_batch); intel->first_post_swapbuffers_batch = NULL; diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h index 6ba281cc14..57c3391130 100644 --- a/src/mesa/drivers/dri/intel/intel_context.h +++ b/src/mesa/drivers/dri/intel/intel_context.h @@ -186,6 +186,7 @@ struct intel_context struct intel_batchbuffer *batch; drm_intel_bo *first_post_swapbuffers_batch; GLboolean no_batch_wrap; + GLboolean using_dri2_swapbuffers; struct { diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index a98600b575..b170317699 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -126,6 +126,10 @@ intelDRI2Flush(__DRIdrawable *drawable) static void intelDRI2FlushInvalidate(__DRIdrawable *drawable) { + struct intel_context *intel = drawable->driContextPriv->driverPrivate; + + intel->using_dri2_swapbuffers = GL_TRUE; + intelDRI2Flush(drawable); drawable->validBuffers = GL_FALSE; } -- cgit v1.2.3 From c73dbce8916ecff36f09d957046c6218a8ac5861 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Tue, 26 Jan 2010 00:45:54 -0800 Subject: glsl/pp: Silence GCC "no previous prototype" warning. --- src/glsl/pp/sl_pp_purify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glsl/pp/sl_pp_purify.c b/src/glsl/pp/sl_pp_purify.c index b50f819251..acc000cf3d 100644 --- a/src/glsl/pp/sl_pp_purify.c +++ b/src/glsl/pp/sl_pp_purify.c @@ -140,7 +140,7 @@ sl_pp_purify_state_init(struct sl_pp_purify_state *state, } -unsigned int +static unsigned int _purify_comment(struct sl_pp_purify_state *state, char *output, unsigned int *current_line, -- cgit v1.2.3 From d21ee93fdb817a96b47b5dd4be925e23c19bb5a7 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 26 Jan 2010 15:10:18 +0800 Subject: egl: Mark _eglCheckResource as PUBLIC. To support extensions such as GL_OES_EGL_image, the drivers need a way to check if a given EGLImageKHR is valid. --- src/egl/main/egldisplay.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index d811f2ee8e..0f5d3a01bb 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -106,7 +106,7 @@ extern EGLBoolean _eglCheckDisplayHandle(EGLDisplay dpy); -extern EGLBoolean +PUBLIC EGLBoolean _eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *dpy); -- cgit v1.2.3 From f65ed0a3097d91289ced44d53786506333122b55 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 26 Jan 2010 15:16:49 +0800 Subject: egl: Use a boolean to indicate whether a resource is linked. An unlinked resource may still be a current resource such as current surfaces. There might still be a need to know which display the unlinked resource belongs to. --- src/egl/main/egldisplay.c | 6 +++++- src/egl/main/egldisplay.h | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index 359900ca2f..125909d2bc 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -242,7 +242,10 @@ _eglCheckResource(void *res, _EGLResourceType type, _EGLDisplay *dpy) void _eglLinkResource(_EGLResource *res, _EGLResourceType type, _EGLDisplay *dpy) { + assert(!res->Display || res->Display == dpy); + res->Display = dpy; + res->IsLinked = EGL_TRUE; res->Next = dpy->ResourceLists[type]; dpy->ResourceLists[type] = res; } @@ -271,5 +274,6 @@ _eglUnlinkResource(_EGLResource *res, _EGLResourceType type) } res->Next = NULL; - res->Display = NULL; + /* do not reset res->Display */ + res->IsLinked = EGL_FALSE; } diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 0f5d3a01bb..8f74ad23a8 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -19,7 +19,11 @@ enum _egl_resource_type { */ struct _egl_resource { + /* which display the resource belongs to */ _EGLDisplay *Display; + EGLBoolean IsLinked; + + /* used to link resources of the same type */ _EGLResource *Next; }; @@ -179,7 +183,7 @@ _eglUnlinkResource(_EGLResource *res, _EGLResourceType type); static INLINE EGLBoolean _eglIsResourceLinked(_EGLResource *res) { - return (res->Display != NULL); + return res->IsLinked; } -- cgit v1.2.3 From 6f6f3e4227855c87a78a717bce7374a7d64172ce Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 26 Jan 2010 16:52:14 +0800 Subject: egl: Add _eglGetAPIContext. It will return the currently bound context of the given API. --- src/egl/main/eglcurrent.c | 13 ++++++++++++- src/egl/main/eglcurrent.h | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c index f91631240f..b3be2305fd 100644 --- a/src/egl/main/eglcurrent.c +++ b/src/egl/main/eglcurrent.c @@ -227,7 +227,18 @@ _eglIsCurrentThreadDummy(void) /** - * Return the currently bound context, or NULL. + * Return the currently bound context of the given API, or NULL. + */ +PUBLIC _EGLContext * +_eglGetAPIContext(EGLenum api) +{ + _EGLThreadInfo *t = _eglGetCurrentThread(); + return t->CurrentContexts[_eglConvertApiToIndex(api)]; +} + + +/** + * Return the currently bound context of the current API, or NULL. */ _EGLContext * _eglGetCurrentContext(void) diff --git a/src/egl/main/eglcurrent.h b/src/egl/main/eglcurrent.h index c4478b3891..b8c2bda485 100644 --- a/src/egl/main/eglcurrent.h +++ b/src/egl/main/eglcurrent.h @@ -72,6 +72,10 @@ extern EGLBoolean _eglIsCurrentThreadDummy(void); +PUBLIC _EGLContext * +_eglGetAPIContext(EGLenum api); + + PUBLIC _EGLContext * _eglGetCurrentContext(void); -- cgit v1.2.3 From 7c09296d4ce977f711f36c3393fd1a2718a6a6ce Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 26 Jan 2010 16:53:40 +0800 Subject: egl: Refactor _eglMakeCurrent. Refactor _eglMakeCurrent into _eglCheckMakeCurrent, _eglBindContextToSurface, and _eglBindContextToThread. --- src/egl/main/eglcontext.c | 236 +++++++++++++++++++++++++++++++--------------- 1 file changed, 158 insertions(+), 78 deletions(-) diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index ee4b1b59f5..deaa8d3f41 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -140,101 +140,181 @@ _eglQueryContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *c, /** - * Drivers will typically call this to do the error checking and - * update the various flags. - * Then, the driver will do its device-dependent Make-Current stuff. + * Bind the context to the surface as the draw or read surface. Return the + * previous surface that the context is bound to. + * + * Note that the context may be NULL. */ -EGLBoolean -_eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, - _EGLSurface *read, _EGLContext *ctx) +static _EGLSurface * +_eglBindContextToSurface(_EGLContext *ctx, _EGLSurface *surf, EGLint readdraw) +{ + _EGLSurface **attachment, *oldSurf; + + if (!ctx) { + surf->Binding = NULL; + return NULL; + } + + attachment = (readdraw == EGL_DRAW) ? + &ctx->DrawSurface : &ctx->ReadSurface; + oldSurf = *attachment; + + if (oldSurf == surf) + return NULL; + + if (oldSurf) + oldSurf->Binding = NULL; + surf->Binding = ctx; + *attachment = surf; + + return oldSurf; +} + + +/** + * Bind the context to the thread and return the previous context. + * + * Note that the context may be NULL. + */ +static _EGLContext * +_eglBindContextToThread(_EGLContext *ctx, _EGLThreadInfo *t) { - _EGLThreadInfo *t = _eglGetCurrentThread(); - _EGLContext *oldContext = NULL; - _EGLSurface *oldDrawSurface = NULL; - _EGLSurface *oldReadSurface = NULL; EGLint apiIndex; + _EGLContext *oldCtx; + + apiIndex = (ctx) ? + _eglConvertApiToIndex(ctx->ClientAPI) : t->CurrentAPIIndex; + + oldCtx = t->CurrentContexts[apiIndex]; + if (ctx == oldCtx) + return NULL; + + if (oldCtx) + oldCtx->Binding = NULL; + if (ctx) + ctx->Binding = t; + + t->CurrentContexts[apiIndex] = ctx; + + return oldCtx; +} + + +/** + * Return true if the given context and surfaces can be made current. + */ +static EGLBoolean +_eglCheckMakeCurrent(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read) +{ + _EGLThreadInfo *t = _eglGetCurrentThread(); + EGLint conflict_api; if (_eglIsCurrentThreadDummy()) return _eglError(EGL_BAD_ALLOC, "eglMakeCurrent"); - if (ctx) { - /* error checking */ - if (ctx->Binding && ctx->Binding != t) - return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent"); - if (draw == NULL || read == NULL) - return _eglError(EGL_BAD_MATCH, "eglMakeCurrent"); - if (draw->Config != ctx->Config || read->Config != ctx->Config) + /* this is easy */ + if (!ctx) { + if (draw || read) return _eglError(EGL_BAD_MATCH, "eglMakeCurrent"); - if ((draw->Binding && draw->Binding->Binding != t) || - (read->Binding && read->Binding->Binding != t)) - return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent"); + return EGL_TRUE; + } + + /* ctx/draw/read must be all given */ + if (draw == NULL || read == NULL) + return _eglError(EGL_BAD_MATCH, "eglMakeCurrent"); + + /* context stealing from another thread is not allowed */ + if (ctx->Binding && ctx->Binding != t) + return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent"); + + /* + * The spec says + * + * "If ctx is current to some other thread, or if either draw or read are + * bound to contexts in another thread, an EGL_BAD_ACCESS error is + * generated." + * + * But it also says + * + * "at most one context may be bound to a particular surface at a given + * time" + * + * The latter is more restrictive so we can check only the latter case. + */ + if ((draw->Binding && draw->Binding != ctx) || + (read->Binding && read->Binding != ctx)) + return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent"); + + /* simply require the configs to be equal */ + if (draw->Config != ctx->Config || read->Config != ctx->Config) + return _eglError(EGL_BAD_MATCH, "eglMakeCurrent"); + switch (ctx->ClientAPI) { #ifdef EGL_VERSION_1_4 - /* OpenGL and OpenGL ES are conflicting */ - switch (ctx->ClientAPI) { - case EGL_OPENGL_ES_API: - if (t->CurrentContexts[_eglConvertApiToIndex(EGL_OPENGL_API)]) - return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent"); - break; - case EGL_OPENGL_API: - if (t->CurrentContexts[_eglConvertApiToIndex(EGL_OPENGL_ES_API)]) - return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent"); - break; - default: - break; - } + /* OpenGL and OpenGL ES are conflicting */ + case EGL_OPENGL_ES_API: + conflict_api = EGL_OPENGL_API; + break; + case EGL_OPENGL_API: + conflict_api = EGL_OPENGL_ES_API; + break; #endif - apiIndex = _eglConvertApiToIndex(ctx->ClientAPI); - } - else { - if (draw != NULL || read != NULL) - return _eglError(EGL_BAD_MATCH, "eglMakeCurrent"); - apiIndex = t->CurrentAPIIndex; + default: + conflict_api = -1; + break; } - oldContext = t->CurrentContexts[apiIndex]; - if (oldContext) { - oldDrawSurface = oldContext->DrawSurface; - oldReadSurface = oldContext->ReadSurface; - assert(oldDrawSurface); - assert(oldReadSurface); - - /* break old bindings */ - t->CurrentContexts[apiIndex] = NULL; - oldContext->Binding = NULL; - oldContext->DrawSurface = NULL; - oldContext->ReadSurface = NULL; - oldDrawSurface->Binding = NULL; - oldReadSurface->Binding = NULL; - - /* - * check if the old context or surfaces need to be deleted - */ - if (!_eglIsSurfaceLinked(oldDrawSurface)) { - assert(draw != oldDrawSurface && read != oldDrawSurface); - drv->API.DestroySurface(drv, dpy, oldDrawSurface); - } - if (oldReadSurface != oldDrawSurface && - !_eglIsSurfaceLinked(oldReadSurface)) { - assert(draw != oldReadSurface && read != oldReadSurface); - drv->API.DestroySurface(drv, dpy, oldReadSurface); - } - if (!_eglIsContextLinked(oldContext)) { - assert(ctx != oldContext); - drv->API.DestroyContext(drv, dpy, oldContext); - } - } + if (conflict_api >= 0 && _eglGetAPIContext(conflict_api)) + return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent"); + + return EGL_TRUE; +} + + +/** + * Drivers will typically call this to do the error checking and + * update the various flags. + * Then, the driver will do its device-dependent Make-Current stuff. + */ +EGLBoolean +_eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, + _EGLSurface *read, _EGLContext *ctx) +{ + _EGLThreadInfo *t = _eglGetCurrentThread(); + _EGLSurface *oldDraw = NULL, *oldRead = NULL; + _EGLContext *oldCtx; + + if (!_eglCheckMakeCurrent(ctx, draw, read)) + return EGL_FALSE; + + oldCtx = _eglBindContextToThread(ctx, t); - /* build new bindings */ if (ctx) { - t->CurrentContexts[apiIndex] = ctx; - ctx->Binding = t; - ctx->DrawSurface = draw; - ctx->ReadSurface = read; - draw->Binding = ctx; - read->Binding = ctx; + oldDraw = _eglBindContextToSurface(ctx, draw, EGL_DRAW); + oldRead = _eglBindContextToSurface(ctx, read, EGL_READ); + } + else if (oldCtx) { + /* unbind the old context from its binding surfaces */ + oldDraw = oldCtx->DrawSurface; + oldRead = oldCtx->ReadSurface; + + if (oldDraw) + _eglBindContextToSurface(NULL, oldDraw, EGL_DRAW); + if (oldRead && oldRead != oldDraw) + _eglBindContextToSurface(NULL, oldRead, EGL_READ); } + /* avoid double destroy */ + if (oldRead && oldRead == oldDraw) + oldRead = NULL; + + if (oldCtx && !_eglIsContextLinked(oldCtx)) + drv->API.DestroyContext(drv, dpy, oldCtx); + if (oldDraw && !_eglIsSurfaceLinked(oldDraw)) + drv->API.DestroySurface(drv, dpy, oldDraw); + if (oldRead && !_eglIsSurfaceLinked(oldRead)) + drv->API.DestroySurface(drv, dpy, oldRead); + return EGL_TRUE; } -- cgit v1.2.3 From 11cf3cb2c463cf8af8a7e63eb9521979bfd303f8 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 26 Jan 2010 17:22:21 +0800 Subject: egl: Fix leaks in eglReleaseThread. There may be multiple bound contexts that should be unbound. --- src/egl/main/eglapi.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index c197cfd38f..2e5027a32e 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -984,13 +984,20 @@ eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype, EGLBoolean eglReleaseThread(void) { - /* unbind current context */ + /* unbind current contexts */ if (!_eglIsCurrentThreadDummy()) { - _EGLDisplay *disp = _eglGetCurrentDisplay(); - _EGLDriver *drv; - if (disp) { - drv = disp->Driver; - (void) drv->API.MakeCurrent(drv, disp, NULL, NULL, NULL); + _EGLThreadInfo *t = _eglGetCurrentThread(); + EGLint i; + + for (i = 0; i < _EGL_API_NUM_APIS; i++) { + _EGLContext *ctx = t->CurrentContexts[i]; + if (ctx) { + _EGLDisplay *disp = ctx->Resource.Display; + _EGLDriver *drv = disp->Driver; + /* what if drv is not avaialbe? */ + if (drv) + (void) drv->API.MakeCurrent(drv, disp, NULL, NULL, NULL); + } } } -- cgit v1.2.3 From a1717970e78d897f527273278bf1346cc86a5741 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 26 Jan 2010 17:13:51 +0800 Subject: egl: Remove _eglGetCurrentSurface and _eglGetCurrentDisplay. They have little use in drivers since drivers need to work for multiple current contexts. --- src/egl/drivers/xdri/egl_xdri.c | 3 +- src/egl/main/eglapi.c | 4 +-- src/egl/main/eglcurrent.c | 37 ------------------------- src/egl/main/eglcurrent.h | 8 ------ src/gallium/state_trackers/egl/common/egl_g3d.c | 7 +++-- 5 files changed, 7 insertions(+), 52 deletions(-) diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index df251d908b..e13d884e71 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -574,8 +574,7 @@ xdri_eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw) struct xdri_egl_surface *xdri_surf = lookup_surface(draw); /* swapBuffers does not flush commands */ - if (draw == _eglGetCurrentSurface(EGL_DRAW) && - xdri_driver->FlushCurrentContext) + if (draw->Binding && xdri_driver->FlushCurrentContext) xdri_driver->FlushCurrentContext(); xdri_dpy->psc->driScreen->swapBuffers(xdri_surf->driDrawable, 0, 0, 0); diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 2e5027a32e..492a14180a 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -629,8 +629,8 @@ eglWaitNative(EGLint engine) EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void) { - _EGLDisplay *dpy = _eglGetCurrentDisplay(); - return _eglGetDisplayHandle(dpy); + _EGLContext *ctx = _eglGetCurrentContext(); + return (ctx) ? _eglGetDisplayHandle(ctx->Resource.Display) : EGL_NO_DISPLAY; } diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c index b3be2305fd..696d04e8ba 100644 --- a/src/egl/main/eglcurrent.c +++ b/src/egl/main/eglcurrent.c @@ -248,43 +248,6 @@ _eglGetCurrentContext(void) } -/** - * Return the display of the currently bound context, or NULL. - */ -_EGLDisplay * -_eglGetCurrentDisplay(void) -{ - _EGLThreadInfo *t = _eglGetCurrentThread(); - _EGLContext *ctx = t->CurrentContexts[t->CurrentAPIIndex]; - if (ctx) - return ctx->Resource.Display; - else - return NULL; -} - - -/** - * Return the read or write surface of the currently bound context, or NULL. - */ -_EGLSurface * -_eglGetCurrentSurface(EGLint readdraw) -{ - _EGLThreadInfo *t = _eglGetCurrentThread(); - _EGLContext *ctx = t->CurrentContexts[t->CurrentAPIIndex]; - if (ctx) { - switch (readdraw) { - case EGL_DRAW: - return ctx->DrawSurface; - case EGL_READ: - return ctx->ReadSurface; - default: - return NULL; - } - } - return NULL; -} - - /** * Record EGL error code. */ diff --git a/src/egl/main/eglcurrent.h b/src/egl/main/eglcurrent.h index b8c2bda485..c169c93e94 100644 --- a/src/egl/main/eglcurrent.h +++ b/src/egl/main/eglcurrent.h @@ -80,14 +80,6 @@ PUBLIC _EGLContext * _eglGetCurrentContext(void); -PUBLIC _EGLDisplay * -_eglGetCurrentDisplay(void); - - -PUBLIC _EGLSurface * -_eglGetCurrentSurface(EGLint readdraw); - - PUBLIC EGLBoolean _eglError(EGLint errCode, const char *msg); diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index d073f226f2..aa4f012216 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -1037,14 +1037,15 @@ egl_g3d_wait_client(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) static EGLBoolean egl_g3d_wait_native(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine) { - _EGLSurface *surf = _eglGetCurrentSurface(EGL_DRAW); - struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); + _EGLContext *ctx = _eglGetCurrentContext(); if (engine != EGL_CORE_NATIVE_ENGINE) return _eglError(EGL_BAD_PARAMETER, "eglWaitNative"); - if (gsurf) + if (ctx && ctx->DrawSurface) { + struct egl_g3d_surface *gsurf = egl_g3d_surface(ctx->DrawSurface); gsurf->native->wait(gsurf->native); + } return EGL_TRUE; } -- cgit v1.2.3 From 545eaf83b5f096e5b16b2056e13b76f58d9211c9 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 26 Jan 2010 18:34:29 +0800 Subject: egl: Fix a segfault when a display is initialized again. Reset dpy->MaxConfigs so that dpy->Configs is re-allocated. --- src/egl/main/egldisplay.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index 125909d2bc..b53cc59713 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -180,6 +180,7 @@ _eglCleanupDisplay(_EGLDisplay *disp) free(disp->Configs); disp->Configs = NULL; disp->NumConfigs = 0; + disp->MaxConfigs = 0; } /* XXX incomplete */ -- cgit v1.2.3 From 092b1ca989ba3bdc3f4d421b83b3943af260b7db Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 26 Jan 2010 18:41:15 +0800 Subject: egl: Remove _eglOpenDriver and _eglCloseDriver. _eglCloseDriver is no-op and _eglOpenDriver does nothing but call _eglMatchDriver. Export _eglMatchDriver directly. --- src/egl/main/eglapi.c | 7 ++----- src/egl/main/egldriver.c | 23 +---------------------- src/egl/main/egldriver.h | 6 +----- 3 files changed, 4 insertions(+), 32 deletions(-) diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 492a14180a..90828bd3e9 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -104,15 +104,13 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) if (!drv) { _eglPreloadDrivers(); - drv = _eglOpenDriver(disp); + drv = _eglMatchDriver(disp); if (!drv) return _eglError(EGL_NOT_INITIALIZED, __FUNCTION__); /* Initialize the particular display now */ - if (!drv->API.Initialize(drv, disp, &major_int, &minor_int)) { - _eglCloseDriver(drv, disp); + if (!drv->API.Initialize(drv, disp, &major_int, &minor_int)) return _eglError(EGL_NOT_INITIALIZED, __FUNCTION__); - } disp->APImajor = major_int; disp->APIminor = minor_int; @@ -150,7 +148,6 @@ eglTerminate(EGLDisplay dpy) drv = disp->Driver; if (drv) { drv->API.Terminate(drv, disp); - _eglCloseDriver(drv, disp); disp->Driver = NULL; } diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index b820b966f9..1dadbf783b 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -269,7 +269,7 @@ _eglLoadDriver(const char *path, const char *args) * * The matching is done by finding the driver with the highest score. */ -static _EGLDriver * +_EGLDriver * _eglMatchDriver(_EGLDisplay *dpy) { _EGLDriver *best_drv = NULL; @@ -298,27 +298,6 @@ _eglMatchDriver(_EGLDisplay *dpy) } -/** - * Open a preloaded driver. - */ -_EGLDriver * -_eglOpenDriver(_EGLDisplay *dpy) -{ - _EGLDriver *drv = _eglMatchDriver(dpy); - return drv; -} - - -/** - * Close a preloaded driver. - */ -EGLBoolean -_eglCloseDriver(_EGLDriver *drv, _EGLDisplay *dpy) -{ - return EGL_TRUE; -} - - /** * Preload a user driver. * diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index 4a1a7ece8c..6ebb60a8f1 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -43,11 +43,7 @@ _eglMain(const char *args); extern _EGLDriver * -_eglOpenDriver(_EGLDisplay *dpy); - - -extern EGLBoolean -_eglCloseDriver(_EGLDriver *drv, _EGLDisplay *dpy); +_eglMatchDriver(_EGLDisplay *dpy); extern EGLBoolean -- cgit v1.2.3 From 9bc80ff17496feda3b47cf40e577976237f87957 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 26 Jan 2010 15:35:31 +0100 Subject: mesa/st: code cleanups for new blend functionality minor code changes, style and comment fixes --- src/mesa/state_tracker/st_atom_blend.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c index 809b10d479..1511b88dd1 100644 --- a/src/mesa/state_tracker/st_atom_blend.c +++ b/src/mesa/state_tracker/st_atom_blend.c @@ -152,17 +152,33 @@ translate_logicop(GLenum logicop) } } -static boolean -colormask_perrt(GLcontext *ctx) +/** + * Figure out if colormasks are different per rt. + */ +static GLboolean +colormask_per_rt(GLcontext *ctx) { - /* XXX this is ugly beyond belief */ + /* a bit suboptimal have to compare lots of values */ unsigned i; for (i = 1; i < ctx->Const.MaxDrawBuffers; i++) { - if (!TEST_EQ_4V(ctx->Color.ColorMask[0], ctx->Color.ColorMask[i])) { - return true; + if (memcmp(ctx->Color.ColorMask[0], ctx->Color.ColorMask[i], 4)) { + return GL_TRUE; } } - return false; + return GL_FALSE; +} + +/** + * Figure out if blend enables are different per rt. + */ +static GLboolean +blend_per_rt(GLcontext *ctx) +{ + if (ctx->Color.BlendEnabled && + (ctx->Color.BlendEnabled != ((1 << ctx->Const.MaxDrawBuffers) - 1))) { + return GL_TRUE; + } + return GL_FALSE; } static void @@ -174,9 +190,7 @@ update_blend( struct st_context *st ) memset(blend, 0, sizeof(*blend)); - if ((st->ctx->Color.BlendEnabled && - (st->ctx->Color.BlendEnabled != ((1 << st->ctx->Const.MaxDrawBuffers) - 1))) || - colormask_perrt(st->ctx)) { + if (blend_per_rt(st->ctx) || colormask_per_rt(st->ctx)) { num_state = st->ctx->Const.MaxDrawBuffers; blend->independent_blend_enable = 1; } -- cgit v1.2.3 From 786bd78be4a412e58ded6eed1d6d3e4a61b1ba2b Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Tue, 26 Jan 2010 07:21:40 -0800 Subject: r300g: Per-MRT blending is not supported. --- src/gallium/drivers/r300/r300_screen.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index 67325c6b80..ebe8793486 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -149,6 +149,9 @@ static int r300_get_param(struct pipe_screen* pscreen, int param) } else { return 0; } + case PIPE_CAP_INDEP_BLEND_ENABLE: + case PIPE_CAP_INDEP_BLEND_FUNC: + return 0; default: debug_printf("r300: Implementation error: Bad param %d\n", param); -- cgit v1.2.3 From 1d8b308cbf6e17f2703807152deaa1ee075882e2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 26 Jan 2010 09:12:32 -0700 Subject: docs: document Intel, R300 env vars --- docs/envvars.html | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/envvars.html b/docs/envvars.html index b2c0e01ee3..bb1c914cc7 100644 --- a/docs/envvars.html +++ b/docs/envvars.html @@ -51,5 +51,24 @@ See the Xlib software driver page for details. +

    +These environment variables are for the Intel i945/i965 drivers: +

    +
      +
    • INTEL_STRICT_CONFORMANCE - if set to 1, enable sw fallbacks to improve + OpenGL conformance. If set to 2, always use software rendering. +
    • INTEL_NO_BLIT - if set, disable hardware-accelerated glBitmap, + glCopyPixels, glDrawPixels. +
    + + +

    +These environment variables are for the Radeon R300 driver: +

    +
      +
    • R300_NO_TCL - if set, disable hardware-accelerated Transform/Clip/Lighting. +
    + + -- cgit v1.2.3 From 1a9d01dcde26aee4db662deb7069fa14069062de Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 26 Jan 2010 17:32:57 +0100 Subject: gallium: add the new PIPE_CAP blend bits to more drivers some drivers will complain if they don't know the cap bit --- src/gallium/drivers/llvmpipe/lp_screen.c | 4 ++++ src/gallium/drivers/nv04/nv04_screen.c | 4 ++++ src/gallium/drivers/nv10/nv10_screen.c | 4 ++++ src/gallium/drivers/nv20/nv20_screen.c | 4 ++++ src/gallium/drivers/nv30/nv30_screen.c | 4 ++++ src/gallium/drivers/nv40/nv40_screen.c | 4 ++++ src/gallium/drivers/nv50/nv50_screen.c | 4 ++++ 7 files changed, 28 insertions(+) diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 9b47415f00..f04c0320ba 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -110,6 +110,10 @@ llvmpipe_get_param(struct pipe_screen *screen, int param) return 1; case PIPE_CAP_BLEND_EQUATION_SEPARATE: return 1; + case PIPE_CAP_INDEP_BLEND_ENABLE: + return 0; + case PIPE_CAP_INDEP_BLEND_FUNC: + return 0; default: return 0; } diff --git a/src/gallium/drivers/nv04/nv04_screen.c b/src/gallium/drivers/nv04/nv04_screen.c index 7c5b6e8229..4eba772575 100644 --- a/src/gallium/drivers/nv04/nv04_screen.c +++ b/src/gallium/drivers/nv04/nv04_screen.c @@ -45,6 +45,10 @@ nv04_screen_get_param(struct pipe_screen *screen, int param) case NOUVEAU_CAP_HW_VTXBUF: case NOUVEAU_CAP_HW_IDXBUF: return 0; + case PIPE_CAP_INDEP_BLEND_ENABLE: + return 0; + case PIPE_CAP_INDEP_BLEND_FUNC: + return 0; default: NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param); return 0; diff --git a/src/gallium/drivers/nv10/nv10_screen.c b/src/gallium/drivers/nv10/nv10_screen.c index 69a6dab866..2dabc4509f 100644 --- a/src/gallium/drivers/nv10/nv10_screen.c +++ b/src/gallium/drivers/nv10/nv10_screen.c @@ -40,6 +40,10 @@ nv10_screen_get_param(struct pipe_screen *screen, int param) case NOUVEAU_CAP_HW_VTXBUF: case NOUVEAU_CAP_HW_IDXBUF: return 0; + case PIPE_CAP_INDEP_BLEND_ENABLE: + return 0; + case PIPE_CAP_INDEP_BLEND_FUNC: + return 0; default: NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param); return 0; diff --git a/src/gallium/drivers/nv20/nv20_screen.c b/src/gallium/drivers/nv20/nv20_screen.c index d091335063..7782cbe3a8 100644 --- a/src/gallium/drivers/nv20/nv20_screen.c +++ b/src/gallium/drivers/nv20/nv20_screen.c @@ -40,6 +40,10 @@ nv20_screen_get_param(struct pipe_screen *screen, int param) case NOUVEAU_CAP_HW_VTXBUF: case NOUVEAU_CAP_HW_IDXBUF: return 0; + case PIPE_CAP_INDEP_BLEND_ENABLE: + return 0; + case PIPE_CAP_INDEP_BLEND_FUNC: + return 0; default: NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param); return 0; diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c index 9ed48178dc..8f8f3ea1a9 100644 --- a/src/gallium/drivers/nv30/nv30_screen.c +++ b/src/gallium/drivers/nv30/nv30_screen.c @@ -67,6 +67,10 @@ nv30_screen_get_param(struct pipe_screen *pscreen, int param) case NOUVEAU_CAP_HW_VTXBUF: case NOUVEAU_CAP_HW_IDXBUF: return 1; + case PIPE_CAP_INDEP_BLEND_ENABLE: + return 0; + case PIPE_CAP_INDEP_BLEND_FUNC: + return 0; default: NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param); return 0; diff --git a/src/gallium/drivers/nv40/nv40_screen.c b/src/gallium/drivers/nv40/nv40_screen.c index 9e55e5a089..4eab5daa80 100644 --- a/src/gallium/drivers/nv40/nv40_screen.c +++ b/src/gallium/drivers/nv40/nv40_screen.c @@ -52,6 +52,10 @@ nv40_screen_get_param(struct pipe_screen *pscreen, int param) if (screen->curie->grclass == NV40TCL) return 1; return 0; + case PIPE_CAP_INDEP_BLEND_ENABLE: + return 0; + case PIPE_CAP_INDEP_BLEND_FUNC: + return 0; default: NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param); return 0; diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 9d58f3c965..3992469383 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -135,6 +135,10 @@ nv50_screen_get_param(struct pipe_screen *pscreen, int param) return 1; case NOUVEAU_CAP_HW_IDXBUF: return 0; + case PIPE_CAP_INDEP_BLEND_ENABLE: + return 0; + case PIPE_CAP_INDEP_BLEND_FUNC: + return 0; default: NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param); return 0; -- cgit v1.2.3 From a5d67dc0119035c518d9778854948d13f0ce2d69 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Tue, 26 Jan 2010 17:58:50 +0100 Subject: nv50: supports independent blend enables --- src/gallium/drivers/nv50/nv50_screen.c | 2 +- src/gallium/drivers/nv50/nv50_state.c | 56 ++++++++++++++++++++++++---------- 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 3992469383..6af9700c1a 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -136,7 +136,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, int param) case NOUVEAU_CAP_HW_IDXBUF: return 0; case PIPE_CAP_INDEP_BLEND_ENABLE: - return 0; + return 1; case PIPE_CAP_INDEP_BLEND_FUNC: return 0; default: diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c index 815dfa4f6f..da8dc933b0 100644 --- a/src/gallium/drivers/nv50/nv50_state.c +++ b/src/gallium/drivers/nv50/nv50_state.c @@ -31,6 +31,23 @@ #include "nouveau/nouveau_stateobj.h" +static INLINE uint32_t +nv50_colormask(unsigned mask) +{ + uint32_t cmask = 0; + + if (mask & PIPE_MASK_R) + cmask |= 0x0001; + if (mask & PIPE_MASK_G) + cmask |= 0x0010; + if (mask & PIPE_MASK_B) + cmask |= 0x0100; + if (mask & PIPE_MASK_A) + cmask |= 0x1000; + + return cmask; +} + static void * nv50_blend_state_create(struct pipe_context *pipe, const struct pipe_blend_state *cso) @@ -38,20 +55,29 @@ nv50_blend_state_create(struct pipe_context *pipe, struct nouveau_stateobj *so = so_new(5, 24, 0); struct nouveau_grobj *tesla = nv50_context(pipe)->screen->tesla; struct nv50_blend_stateobj *bso = CALLOC_STRUCT(nv50_blend_stateobj); - unsigned cmask = 0, i; + unsigned i, blend_enabled = 0; /*XXX ignored: * - dither */ - if (cso->rt[0].blend_enable == 0) { - so_method(so, tesla, NV50TCL_BLEND_ENABLE(0), 8); + so_method(so, tesla, NV50TCL_BLEND_ENABLE(0), 8); + if (cso->independent_blend_enable) { + for (i = 0; i < 8; ++i) { + so_data(so, cso->rt[i].blend_enable); + if (cso->rt[i].blend_enable) + blend_enabled = 1; + } + } else + if (cso->rt[0].blend_enable) { + blend_enabled = 1; for (i = 0; i < 8; i++) - so_data(so, 0); + so_data(so, 1); } else { - so_method(so, tesla, NV50TCL_BLEND_ENABLE(0), 8); for (i = 0; i < 8; i++) - so_data(so, 1); + so_data(so, 0); + } + if (blend_enabled) { so_method(so, tesla, NV50TCL_BLEND_EQUATION_RGB, 5); so_data (so, nvgl_blend_eqn(cso->rt[0].rgb_func)); so_data (so, 0x4000 | nvgl_blend_func(cso->rt[0].rgb_src_factor)); @@ -71,17 +97,15 @@ nv50_blend_state_create(struct pipe_context *pipe, so_data (so, nvgl_logicop_func(cso->logicop_func)); } - if (cso->rt[0].colormask & PIPE_MASK_R) - cmask |= (1 << 0); - if (cso->rt[0].colormask & PIPE_MASK_G) - cmask |= (1 << 4); - if (cso->rt[0].colormask & PIPE_MASK_B) - cmask |= (1 << 8); - if (cso->rt[0].colormask & PIPE_MASK_A) - cmask |= (1 << 12); so_method(so, tesla, NV50TCL_COLOR_MASK(0), 8); - for (i = 0; i < 8; i++) - so_data(so, cmask); + if (cso->independent_blend_enable) + for (i = 0; i < 8; ++i) + so_data(so, nv50_colormask(cso->rt[i].colormask)); + else { + uint32_t cmask = nv50_colormask(cso->rt[0].colormask); + for (i = 0; i < 8; i++) + so_data(so, cmask); + } bso->pipe = *cso; so_ref(so, &bso->so); -- cgit v1.2.3 From 782f66c8a2424245ad23d17ba2e4bd9e7235c452 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 26 Jan 2010 10:48:00 -0700 Subject: progs/tests: use glDrawRangeElements() in bufferobj.c --- progs/tests/bufferobj.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/progs/tests/bufferobj.c b/progs/tests/bufferobj.c index d4ca270016..dc479af045 100644 --- a/progs/tests/bufferobj.c +++ b/progs/tests/bufferobj.c @@ -29,6 +29,7 @@ struct object GLuint VertexStride; GLuint ColorStride; GLuint NumElements; + GLuint MaxElement; }; static struct object Objects[NUM_OBJECTS]; @@ -58,7 +59,8 @@ static void DrawObject( const struct object *obj ) if (obj->NumElements > 0) { /* indexed arrays */ glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, obj->ElementsBufferID); - glDrawElements(GL_LINE_LOOP, obj->NumElements, GL_UNSIGNED_INT, NULL); + glDrawRangeElements(GL_LINE_LOOP, 0, obj->MaxElement, + obj->NumElements, GL_UNSIGNED_INT, NULL); } else { /* non-indexed arrays */ @@ -300,6 +302,7 @@ static void MakeObject1(struct object *obj) obj->VertexStride = 0; obj->ColorStride = 0; obj->NumElements = 0; + obj->MaxElement = 0; glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); @@ -345,6 +348,7 @@ static void MakeObject2(struct object *obj) obj->ColorStride = 6 * sizeof(GLfloat); obj->NumElements = 0; + obj->MaxElement = 0; glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); @@ -401,6 +405,7 @@ static void MakeObject3(struct object *obj) i[3] = 3; glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB); obj->NumElements = 4; + obj->MaxElement = 3; if (Have_ARB_vertex_array_object) { CreateVertexArrayObject(obj); @@ -445,6 +450,7 @@ static void MakeObject4(struct object *obj) /* Setup a buffer of indices to test the ELEMENTS path */ obj->ElementsBufferID = 0; obj->NumElements = 0; + obj->MaxElement = 0; if (Have_ARB_vertex_array_object) { CreateVertexArrayObject(obj); -- cgit v1.2.3 From af1e9403e732651fe2cedde230ac7010f2f1a649 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 26 Jan 2010 10:53:34 -0700 Subject: mesa: remove redundant _MaxElement computation Eric added some new code to check if offset < obj_size before computing _MaxElement but my original code was still present afterward and it clobbered the _MaxElement value. Not sure if this came from a bad merge or what. --- src/mesa/main/state.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 904ad01205..5e07d1d2f1 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -82,12 +82,6 @@ compute_max_element(struct gl_client_array *array) } else { array->_MaxElement = 0; } - /* Compute the max element we can access in the VBO without going - * out of bounds. - */ - array->_MaxElement = ((GLsizeiptrARB) array->BufferObj->Size - - (GLsizeiptrARB) array->Ptr + array->StrideB - - array->_ElementSize) / array->StrideB; } else { /* user-space array, no idea how big it is */ -- cgit v1.2.3 From cec0e7c086d04c73e5c0a516cb6e3df9bc250cb2 Mon Sep 17 00:00:00 2001 From: Aaron Plattner Date: Tue, 26 Jan 2010 10:14:11 -0800 Subject: glxgears: Support GLX_EXT_swap_control for querying the current swap interval. Signed-off-by: Aaron Plattner Signed-off-by: Brian Paul --- progs/xdemos/glxgears.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/progs/xdemos/glxgears.c b/progs/xdemos/glxgears.c index 2993c82416..92c75caa5e 100644 --- a/progs/xdemos/glxgears.c +++ b/progs/xdemos/glxgears.c @@ -35,6 +35,7 @@ #include #include #include +#include #ifndef GLX_MESA_swap_control #define GLX_MESA_swap_control 1 @@ -586,11 +587,17 @@ is_glx_extension_supported(Display *dpy, const char *query) * Attempt to determine whether or not the display is synched to vblank. */ static void -query_vsync(Display *dpy) +query_vsync(Display *dpy, GLXDrawable drawable) { int interval = 0; - +#if defined(GLX_EXT_swap_control) + if (is_glx_extension_supported(dpy, "GLX_EXT_swap_control")) { + unsigned int tmp = -1; + glXQueryDrawable(dpy, drawable, GLX_SWAP_INTERVAL_EXT, &tmp); + interval = tmp; + } else +#endif if (is_glx_extension_supported(dpy, "GLX_MESA_swap_control")) { PFNGLXGETSWAPINTERVALMESAPROC pglXGetSwapIntervalMESA = (PFNGLXGETSWAPINTERVALMESAPROC) @@ -749,7 +756,7 @@ main(int argc, char *argv[]) make_window(dpy, "glxgears", x, y, winWidth, winHeight, &win, &ctx); XMapWindow(dpy, win); glXMakeCurrent(dpy, win, ctx); - query_vsync(dpy); + query_vsync(dpy, win); if (printInfo) { printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); -- cgit v1.2.3 From 1019f0de1170f627e8e9ce7b449f7a76d89c6742 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Tue, 26 Jan 2010 19:13:27 +0000 Subject: only use -Werror flags with gcc 4.2.x and 4.3.x. could use a better test here though. --- scons/gallium.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scons/gallium.py b/scons/gallium.py index 24f88e104b..1a095d8993 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -268,16 +268,22 @@ def generate(env): ccflags += [ '-Wall', '-Wmissing-field-initializers', - '-Werror=pointer-arith', '-Wno-long-long', '-ffast-math', '-fmessage-length=0', # be nice to Eclipse ] cflags += [ - '-Werror=declaration-after-statement', '-Wmissing-prototypes', '-std=gnu99', ] + if env['CCVERSION'].startswith('4.2.') or + env['CCVERSION'].startswith('4.3.'): + ccflags += [ + '-Werror=pointer-arith', + ] + cflags += [ + '-Werror=declaration-after-statement', + ] if msvc: # See also: # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx -- cgit v1.2.3 From 6544be622363674430f70ca262629334d25b350a Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Tue, 26 Jan 2010 19:14:16 +0000 Subject: Allow the environment to override certain flags. --- SConstruct | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/SConstruct b/SConstruct index ff06b9b592..0770fe43e7 100644 --- a/SConstruct +++ b/SConstruct @@ -59,6 +59,17 @@ env = Environment( ENV = os.environ, ) +if os.environ.has_key('CC'): + env['CC'] = os.environ['CC'] +if os.environ.has_key('CFLAGS'): + env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS']) +if os.environ.has_key('CXX'): + env['CXX'] = os.environ['CXX'] +if os.environ.has_key('CXXFLAGS'): + env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS']) +if os.environ.has_key('LDFLAGS'): + env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS']) + Help(opts.GenerateHelpText(env)) # replicate options values in local variables -- cgit v1.2.3 From 18bb614acf3b9bbfd8c81253a6fd2fb24800dd70 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Tue, 26 Jan 2010 19:18:32 +0000 Subject: fix typo --- scons/gallium.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scons/gallium.py b/scons/gallium.py index 1a095d8993..5aa0b7bddd 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -276,8 +276,7 @@ def generate(env): '-Wmissing-prototypes', '-std=gnu99', ] - if env['CCVERSION'].startswith('4.2.') or - env['CCVERSION'].startswith('4.3.'): + if env['CCVERSION'].startswith('4.2.') or env['CCVERSION'].startswith('4.3.'): ccflags += [ '-Werror=pointer-arith', ] -- cgit v1.2.3 From 645e297a0019eb2f7513bd801ffdaac03187f29f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 26 Jan 2010 12:47:51 -0700 Subject: vbo: clamp DrawElements start/end to max possible values Some apps are sloppy with their start/end values. Clamp them to max possible values to prevent problems later. --- src/mesa/vbo/vbo_exec_array.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 2c82f7c9c5..f455382592 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -688,6 +688,16 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode, * or we can read/write out of memory in several different places! */ + /* Catch/fix some potential user errors */ + if (type == GL_UNSIGNED_BYTE) { + start = MIN2(start, 0xff); + end = MIN2(end, 0xff); + } + else if (type == GL_UNSIGNED_SHORT) { + start = MIN2(start, 0xffff); + end = MIN2(end, 0xffff); + } + if (end >= ctx->Array.ArrayObj->_MaxElement) { /* the max element is out of bounds of one or more enabled arrays */ warnCount++; -- cgit v1.2.3 From cbecb8fc8e85cfafed7fd8fd0e2dd1143efcf62b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 26 Jan 2010 12:49:44 -0700 Subject: vbo: if 'end' is out of bounds, clamp it If we determine that the 'end' parameter to glDrawElements() is out of bounds, clamp it to the max legal index value. --- src/mesa/vbo/vbo_exec_array.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index f455382592..bd2fccdba1 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -748,6 +748,10 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode, */ } #endif + + /* Set 'end' to the max possible legal value */ + assert(ctx->Array.ArrayObj->_MaxElement >= 1); + end = ctx->Array.ArrayObj->_MaxElement - 1; } else if (0) { _mesa_printf("glDraw[Range]Elements{,BaseVertex}" -- cgit v1.2.3 From 550fc19a5f927b0a95e6aae96c64d094cffe1c36 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Tue, 26 Jan 2010 19:57:34 +0000 Subject: add missing SCons.Util --- SConstruct | 1 + 1 file changed, 1 insertion(+) diff --git a/SConstruct b/SConstruct index 0770fe43e7..3a40244d88 100644 --- a/SConstruct +++ b/SConstruct @@ -23,6 +23,7 @@ import os import os.path import sys +import SCons.Util import common -- cgit v1.2.3 From 06d228d8b92b7f4031f0596d498c24c4ed952e68 Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Tue, 26 Jan 2010 22:16:53 +0200 Subject: intel: make sure we update the renderbuffers after a swap Now that LOCK_HARDWARE is gone, we don't have a convenient place to update the renderbuffers everywhere we need them. So grab new buffers when we invalidate the old ones until we optimize things further. --- src/mesa/drivers/dri/intel/intel_screen.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index b170317699..96e7f2885a 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -132,6 +132,8 @@ intelDRI2FlushInvalidate(__DRIdrawable *drawable) intelDRI2Flush(drawable); drawable->validBuffers = GL_FALSE; + + intel_update_renderbuffers(intel->driContext, drawable); } static const struct __DRI2flushExtensionRec intelFlushExtension = { -- cgit v1.2.3 From 68ca19afd7299fa9c686f95d53b7e14df37aba4c Mon Sep 17 00:00:00 2001 From: Erik Wien Date: Tue, 26 Jan 2010 13:19:30 -0700 Subject: mesa: Don't bind DRAW/READ_FRAMEBUFFER separately without FBO blit support If GL_EXT_framebuffer_blit was not supported _mesa_DeleteFramebuffersEXT would raise an error when deleting the currently bound framebuffer. This because it tried to bind the default DRAW- and READ_FRAMEBUFFER separately. This patch binds the default FRAMEBUFFER instead in that case. Encountered in the fbo/fbo-copyteximage piglit test on R600. Patch cleaned up a bit by Brian Paul. --- src/mesa/main/fbobject.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 56e806559f..0e83a4e87f 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -1350,15 +1350,26 @@ _mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers) ASSERT(fb == &DummyFramebuffer || fb->Name == framebuffers[i]); /* check if deleting currently bound framebuffer object */ - if (fb == ctx->DrawBuffer) { - /* bind default */ - ASSERT(fb->RefCount >= 2); - _mesa_BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0); + if (ctx->Extensions.EXT_framebuffer_blit) { + /* separate draw/read binding points */ + if (fb == ctx->DrawBuffer) { + /* bind default */ + ASSERT(fb->RefCount >= 2); + _mesa_BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0); + } + if (fb == ctx->ReadBuffer) { + /* bind default */ + ASSERT(fb->RefCount >= 2); + _mesa_BindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0); + } } - if (fb == ctx->ReadBuffer) { - /* bind default */ - ASSERT(fb->RefCount >= 2); - _mesa_BindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0); + else { + /* only one binding point for read/draw buffers */ + if (fb == ctx->DrawBuffer || fb == ctx->ReadBuffer) { + /* bind default */ + ASSERT(fb->RefCount >= 2); + _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + } } /* remove from hash table immediately, to free the ID */ -- cgit v1.2.3 From 46f453b29890afebb49daa04e0dbeadc45e662c2 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Tue, 26 Jan 2010 20:57:03 +0000 Subject: Check for __USE_MISC for defining uint & ushort --- src/gallium/include/pipe/p_compiler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/include/pipe/p_compiler.h b/src/gallium/include/pipe/p_compiler.h index 272d0308cc..6a9018aa3a 100644 --- a/src/gallium/include/pipe/p_compiler.h +++ b/src/gallium/include/pipe/p_compiler.h @@ -63,7 +63,7 @@ #include -#ifndef __HAIKU__ +#if !defined(__HAIKU__) && !defined(__USE_MISC) typedef unsigned int uint; typedef unsigned short ushort; #endif -- cgit v1.2.3 From dea98eb792b5a0637ff2067d9bfe2f666f01423e Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Tue, 26 Jan 2010 20:58:11 +0000 Subject: support an 'embedded' platform target which turns off most parts of the build. --- SConstruct | 13 ++++++--- common.py | 3 +-- progs/SConscript | 71 +++++++++++++++++++++++++------------------------- src/SConscript | 5 ++-- src/gallium/SConscript | 7 ++--- 5 files changed, 54 insertions(+), 45 deletions(-) diff --git a/SConstruct b/SConstruct index 3a40244d88..3b8a9e0341 100644 --- a/SConstruct +++ b/SConstruct @@ -38,6 +38,9 @@ if common.default_platform in ('linux', 'freebsd', 'darwin'): elif common.default_platform in ('winddk',): default_drivers = 'softpipe,svga,i915,i965,trace,identity' default_winsys = 'all' +elif common.default_platform in ('embedded',): + default_drivers = 'softpipe,llvmpipe' + default_winsys = 'xlib' else: default_drivers = 'all' default_winsys = 'all' @@ -83,7 +86,7 @@ platform = env['platform'] # derived options x86 = machine == 'x86' ppc = machine == 'ppc' -gcc = platform in ('linux', 'freebsd', 'darwin') +gcc = platform in ('linux', 'freebsd', 'darwin', 'embedded') msvc = platform in ('windows', 'winddk') Export([ @@ -114,7 +117,7 @@ if env['msvc']: # Posix -if platform in ('posix', 'linux', 'freebsd', 'darwin'): +if platform in ('posix', 'linux', 'freebsd', 'darwin', 'embedded'): env.Append(CPPDEFINES = [ '_POSIX_SOURCE', ('_POSIX_C_SOURCE', '199309L'), @@ -132,9 +135,13 @@ if platform in ('posix', 'linux', 'freebsd', 'darwin'): env.Append(LIBS = [ 'm', 'pthread', - 'expat', 'dl', ]) + if platform != 'embedded': + env.Append(LIBS = [ + 'expat', + ]) + # DRI diff --git a/common.py b/common.py index 101fc558f4..928a4496f7 100644 --- a/common.py +++ b/common.py @@ -59,9 +59,8 @@ def AddOptions(opts): opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine, allowed_values=('generic', 'ppc', 'x86', 'x86_64'))) opts.Add(EnumOption('platform', 'target platform', default_platform, - allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince', 'darwin'))) + allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince', 'darwin', 'embedded'))) opts.Add(EnumOption('toolchain', 'compiler toolchain', 'default', allowed_values=('default', 'crossmingw', 'winsdk', 'winddk'))) opts.Add(BoolOption('llvm', 'use LLVM', 'no')) opts.Add(BoolOption('dri', 'build DRI drivers', default_dri)) - diff --git a/progs/SConscript b/progs/SConscript index 3b180d00bc..66a1745271 100644 --- a/progs/SConscript +++ b/progs/SConscript @@ -15,38 +15,39 @@ if progs_env['platform'] == 'windows': 'gdi32', ]) -# OpenGL -if progs_env['platform'] == 'windows': - progs_env.Prepend(LIBS = ['glu32', 'opengl32']) -else: - progs_env.Prepend(LIBS = ['GLU', 'GL']) - -# Glut -progs_env.Prepend(LIBS = [glut]) - -# GLEW -progs_env.Prepend(LIBS = [glew]) - -progs_env.Prepend(CPPPATH = [ - '#progs/util', -]) - -progs_env.Prepend(LIBS = [ - util, -]) - -Export('progs_env') - -SConscript([ - 'demos/SConscript', - 'glsl/SConscript', - 'redbook/SConscript', - 'samples/SConscript', - 'tests/SConscript', - 'trivial/SConscript', - 'vp/SConscript', - 'vpglsl/SConscript', - 'fp/SConscript', - 'wgl/SConscript', - 'perf/SConscript', -]) +if platform != 'embedded': + # OpenGL + if progs_env['platform'] == 'windows': + progs_env.Prepend(LIBS = ['glu32', 'opengl32']) + else: + progs_env.Prepend(LIBS = ['GLU', 'GL']) + + # Glut + progs_env.Prepend(LIBS = [glut]) + + # GLEW + progs_env.Prepend(LIBS = [glew]) + + progs_env.Prepend(CPPPATH = [ + '#progs/util', + ]) + + progs_env.Prepend(LIBS = [ + util, + ]) + + Export('progs_env') + + SConscript([ + 'demos/SConscript', + 'glsl/SConscript', + 'redbook/SConscript', + 'samples/SConscript', + 'tests/SConscript', + 'trivial/SConscript', + 'vp/SConscript', + 'vpglsl/SConscript', + 'fp/SConscript', + 'wgl/SConscript', + 'perf/SConscript', + ]) diff --git a/src/SConscript b/src/SConscript index 6083fcbec9..cd4896ada4 100644 --- a/src/SConscript +++ b/src/SConscript @@ -8,5 +8,6 @@ if 'mesa' in env['statetrackers']: SConscript('gallium/winsys/SConscript') -SConscript('glut/glx/SConscript') -SConscript('glew/SConscript') +if platform != 'embedded': + SConscript('glut/glx/SConscript') + SConscript('glew/SConscript') diff --git a/src/gallium/SConscript b/src/gallium/SConscript index eea32b1314..d56c5c8461 100644 --- a/src/gallium/SConscript +++ b/src/gallium/SConscript @@ -8,9 +8,10 @@ for driver in env['drivers']: SConscript(os.path.join('drivers', driver, 'SConscript')) SConscript('state_trackers/python/SConscript') -SConscript('state_trackers/glx/xlib/SConscript') -SConscript('state_trackers/dri/SConscript') -SConscript('state_trackers/xorg/SConscript') +if platform != 'embedded': + SConscript('state_trackers/glx/xlib/SConscript') + SConscript('state_trackers/dri/SConscript') + SConscript('state_trackers/xorg/SConscript') if platform == 'windows': SConscript('state_trackers/wgl/SConscript') -- cgit v1.2.3 From 11c581c6ce0b09dc4203a7f93ebb8f76357f19be Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 26 Jan 2010 12:43:43 -0800 Subject: swrast: Implement ARB_fragment_coord_conventions but don't enable. This brings swrast's support up to the state of gallium, and fixes the default center behavior of fragment.position.xy in piglit fp-arb-fragment-coord-conventions-none. The extension is not enabled currently because the GLSL part of the extension isn't supported, so piglit glsl-arb-fragment-coord-conventions-define fails as would any serious test of the GLSL part. --- src/mesa/swrast/s_fragprog.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c index 9ac33a26a6..1c6492cc8f 100644 --- a/src/mesa/swrast/s_fragprog.c +++ b/src/mesa/swrast/s_fragprog.c @@ -144,12 +144,22 @@ init_machine(GLcontext *ctx, struct gl_program_machine *machine, const struct gl_fragment_program *program, const SWspan *span, GLuint col) { + GLfloat *wpos = span->array->attribs[FRAG_ATTRIB_WPOS][col]; + if (program->Base.Target == GL_FRAGMENT_PROGRAM_NV) { /* Clear temporary registers (undefined for ARB_f_p) */ _mesa_bzero(machine->Temporaries, MAX_PROGRAM_TEMPS * 4 * sizeof(GLfloat)); } + /* ARB_fragment_coord_conventions */ + if (program->OriginUpperLeft) + wpos[1] = ctx->DrawBuffer->Height - 1 - wpos[1]; + if (!program->PixelCenterInteger) { + wpos[0] += 0.5; + wpos[1] += 0.5; + } + /* Setup pointer to input attributes */ machine->Attribs = span->array->attribs; -- cgit v1.2.3 From f62c2a0bb89041567467a6c01cf1eb27cec01e9e Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 26 Jan 2010 13:08:42 -0800 Subject: i965: Fix fp fragment.position handling and enable HW part of ARB_fcc. As with swrast, this fixes the default pixel center behavior which was broken, and implements the previous behavior for integer. Fixes piglit fp-arb-fragment-coord-conventions-none. The extension won't be exposed until we get the GLSL part implemented. The DRI1 origin_x/y parts are dropped since they're no longer relevant. --- src/mesa/drivers/dri/i965/brw_wm.c | 6 +---- src/mesa/drivers/dri/i965/brw_wm.h | 1 - src/mesa/drivers/dri/i965/brw_wm_emit.c | 44 +++++++++++++++++++++++++-------- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c index 8afd1f4aef..9191c81755 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.c +++ b/src/mesa/drivers/dri/i965/brw_wm.c @@ -336,11 +336,7 @@ static void brw_wm_populate_key( struct brw_context *brw, * drawable height in order to invert the Y axis. */ if (fp->program.Base.InputsRead & FRAG_BIT_WPOS) { - if (brw->intel.driDrawable != NULL) { - key->origin_x = brw->intel.driDrawable->x; - key->origin_y = brw->intel.driDrawable->y; - key->drawable_height = brw->intel.driDrawable->h; - } + key->drawable_height = ctx->DrawBuffer->Height; } key->nr_color_regions = brw->state.nr_color_regions; diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h index b9b987ea70..88d84ee82f 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.h +++ b/src/mesa/drivers/dri/i965/brw_wm.h @@ -76,7 +76,6 @@ struct brw_wm_prog_key { GLushort tex_swizzles[BRW_MAX_TEX_UNIT]; - GLushort origin_x, origin_y; GLushort drawable_height; GLbitfield64 vp_outputs_written; GLuint program_string_id:32; diff --git a/src/mesa/drivers/dri/i965/brw_wm_emit.c b/src/mesa/drivers/dri/i965/brw_wm_emit.c index f316e0cda4..fa0898c586 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_emit.c +++ b/src/mesa/drivers/dri/i965/brw_wm_emit.c @@ -138,19 +138,43 @@ void emit_wpos_xy(struct brw_wm_compile *c, * X and Y channels. */ if (mask & WRITEMASK_X) { - /* X' = X - origin */ - brw_ADD(p, - dst[0], - retype(arg0[0], BRW_REGISTER_TYPE_W), - brw_imm_d(0 - c->key.origin_x)); + if (c->fp->program.PixelCenterInteger) { + /* X' = X */ + brw_MOV(p, + dst[0], + retype(arg0[0], BRW_REGISTER_TYPE_W)); + } else { + /* X' = X + 0.5 */ + brw_ADD(p, + dst[0], + retype(arg0[0], BRW_REGISTER_TYPE_W), + brw_imm_f(0.5)); + } } if (mask & WRITEMASK_Y) { - /* Y' = height - (Y - origin_y) = height + origin_y - Y */ - brw_ADD(p, - dst[1], - negate(retype(arg0[1], BRW_REGISTER_TYPE_W)), - brw_imm_d(c->key.origin_y + c->key.drawable_height - 1)); + if (c->fp->program.OriginUpperLeft) { + if (c->fp->program.PixelCenterInteger) { + /* Y' = Y */ + brw_MOV(p, + dst[1], + retype(arg0[1], BRW_REGISTER_TYPE_W)); + } else { + /* Y' = Y + 0.5 */ + brw_ADD(p, + dst[1], + retype(arg0[1], BRW_REGISTER_TYPE_W), + brw_imm_f(0.5)); + } + } else { + float center_offset = c->fp->program.PixelCenterInteger ? 0.0 : 0.5; + + /* Y' = (height - 1) - Y + center */ + brw_ADD(p, + dst[1], + negate(retype(arg0[1], BRW_REGISTER_TYPE_W)), + brw_imm_f(c->key.drawable_height - 1 + center_offset)); + } } } -- cgit v1.2.3 From ab53f710151d920286d0c92f93262fb468008051 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 26 Jan 2010 14:43:23 -0800 Subject: i965: Add support for EXT_draw_buffers2. --- docs/relnotes-7.8.html | 2 +- src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 4 ++-- src/mesa/drivers/dri/intel/intel_extensions.c | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/relnotes-7.8.html b/docs/relnotes-7.8.html index 4fcc491036..6511d613d6 100644 --- a/docs/relnotes-7.8.html +++ b/docs/relnotes-7.8.html @@ -35,7 +35,7 @@ tbd

    New features

    • GL_NV_conditional_render extension (swrast driver only) -
    • GL_EXT_draw_buffers2 extension (swrast driver only) +
    • GL_EXT_draw_buffers2 extension (swrast and i965 driver only)
    • Much improved support for EGL in Mesa
    • New state trackers for OpenGL ES 1.1 and 2.0
    diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index 357c8c90de..1db438ae7b 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -577,7 +577,7 @@ brw_update_renderbuffer_surface(struct brw_context *brw, key.draw_y = 0; } /* _NEW_COLOR */ - memcpy(key.color_mask, ctx->Color.ColorMask[0], + memcpy(key.color_mask, ctx->Color.ColorMask[unit], sizeof(key.color_mask)); /* As mentioned above, disable writes to the alpha component when the @@ -587,7 +587,7 @@ brw_update_renderbuffer_surface(struct brw_context *brw, key.color_mask[3] = GL_FALSE; key.color_blend = (!ctx->Color._LogicOpEnabled && - ctx->Color.BlendEnabled); + (ctx->Color.BlendEnabled & (1 << unit))); dri_bo_unreference(brw->wm.surf_bo[unit]); brw->wm.surf_bo[unit] = brw_search_cache(&brw->surface_cache, diff --git a/src/mesa/drivers/dri/intel/intel_extensions.c b/src/mesa/drivers/dri/intel/intel_extensions.c index 6fdd22b9e9..84c8d013e3 100644 --- a/src/mesa/drivers/dri/intel/intel_extensions.c +++ b/src/mesa/drivers/dri/intel/intel_extensions.c @@ -48,6 +48,7 @@ #define need_GL_EXT_blend_func_separate #define need_GL_EXT_blend_minmax #define need_GL_EXT_cull_vertex +#define need_GL_EXT_draw_buffers2 #define need_GL_EXT_fog_coord #define need_GL_EXT_framebuffer_object #define need_GL_EXT_framebuffer_blit @@ -161,6 +162,7 @@ static const struct dri_extension brw_extensions[] = { { "GL_ARB_shadow", NULL }, { "GL_MESA_texture_signed_rgba", NULL }, { "GL_ARB_texture_non_power_of_two", NULL }, + { "GL_EXT_draw_buffers2", GL_EXT_draw_buffers2_functions }, { "GL_EXT_shadow_funcs", NULL }, { "GL_EXT_stencil_two_side", GL_EXT_stencil_two_side_functions }, { "GL_EXT_texture_sRGB", NULL }, -- cgit v1.2.3 From db89bf40025805165bbc34ac7a6610f9468d8749 Mon Sep 17 00:00:00 2001 From: Igor Oliveira Date: Mon, 25 Jan 2010 19:23:04 -0400 Subject: docs: add documentation to double opcodes Signed-off-by: Brian Paul --- src/gallium/docs/source/tgsi.rst | 111 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/src/gallium/docs/source/tgsi.rst b/src/gallium/docs/source/tgsi.rst index 65a669d8cf..2c34a6bae5 100644 --- a/src/gallium/docs/source/tgsi.rst +++ b/src/gallium/docs/source/tgsi.rst @@ -1111,6 +1111,117 @@ BREAKC - Break Conditional TBD +Double Opcodes +^^^^^^^^^^^^^^^ + +DADD - Add Double + +.. math:: + + dst.xy = src0.xy + src1.xy + + dst.zw = src0.zw + src1.zw + + +DDIV - Divide Double + +.. math:: + + dst.xy = src0.xy / src1.xy + + dst.zw = src0.zw / src1.zw + +DSEQ - Set Double on Equal + +.. math:: + + dst.xy = src0.xy == src1.xy ? 1.0F : 0.0F + + dst.zw = src0.zw == src1.zw ? 1.0F : 0.0F + +DSLT - Set Double on Less than + +.. math:: + + dst.xy = src0.xy < src1.xy ? 1.0F : 0.0F + + dst.zw = src0.zw < src1.zw ? 1.0F : 0.0F + +DFRAC - Double Fraction + +.. math:: + + dst.xy = src.xy - \lfloor src.xy\rfloor + + dst.zw = src.zw - \lfloor src.zw\rfloor + + +DFRACEXP - Convert Double Number to Fractional and Integral Components + +.. math:: + + dst0.xy = frexp(src.xy, dst1.xy) + + dst0.zw = frexp(src.zw, dst1.zw) + +DLDEXP - Multiple Double Number by Integral Power of 2 + +.. math:: + + dst.xy = ldexp(src0.xy, src1.xy) + + dst.zw = ldexp(src0.zw, src1.zw) + +DMIN - Minimum Double + +.. math:: + + dst.xy = min(src0.xy, src1.xy) + + dst.zw = min(src0.zw, src1.zw) + +DMAX - Maximum Double + +.. math:: + + dst.xy = max(src0.xy, src1.xy) + + dst.zw = max(src0.zw, src1.zw) + +DMUL - Multiply Double + +.. math:: + + dst.xy = src0.xy \times src1.xy + + dst.zw = src0.zw \times src1.zw + + +DMAD - Multiply And Add Doubles + +.. math:: + + dst.xy = src0.xy \times src1.xy + src2.xy + + dst.zw = src0.zw \times src1.zw + src2.zw + + +DRCP - Reciprocal Double + +.. math:: + + dst.xy = \frac{1}{src.xy} + + dst.zw = \frac{1}{src.zw} + +DSQRT - Square root double + +.. math:: + + dst.xy = \sqrt{src.xy} + + dst.zw = \sqrt{src.zw} + Explanation of symbols used ------------------------------ -- cgit v1.2.3 From 63b10e8fe71c1de5b0ee9aac72fd7303551f59a0 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 26 Jan 2010 16:22:10 -0800 Subject: intel: Fix PBO blit ReadPixels from an FBO. Bug #25921 -- clutter PBO usage gave unreliable results. --- src/mesa/drivers/dri/intel/intel_pixel_read.c | 81 ++++++++++++--------------- 1 file changed, 37 insertions(+), 44 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_pixel_read.c b/src/mesa/drivers/dri/intel/intel_pixel_read.c index 7611ba8650..a60db52664 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_read.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_read.c @@ -168,6 +168,8 @@ do_blit_readpixels(GLcontext * ctx, struct intel_buffer_object *dst = intel_buffer_object(pack->BufferObj); GLuint dst_offset; GLuint rowLength; + drm_intel_bo *dst_buffer; + drm_clip_rect_t read_bounds, rect, src_rect; if (INTEL_DEBUG & DEBUG_PIXEL) _mesa_printf("%s\n", __FUNCTION__); @@ -208,56 +210,47 @@ do_blit_readpixels(GLcontext * ctx, return GL_FALSE; } else { - rowLength = -rowLength; + if (ctx->ReadBuffer->Name == 0) + rowLength = -rowLength; } dst_offset = (GLintptr) _mesa_image_address(2, pack, pixels, width, height, format, type, 0, 0, 0); + GLboolean all = (width * height * src->cpp == dst->Base.Size && + x == 0 && dst_offset == 0); - /* Although the blits go on the command buffer, need to do this and - * fire with lock held to guarentee cliprects are correct. - */ - intelFlush(&intel->ctx); - - if (intel->driReadDrawable->numClipRects) { - GLboolean all = (width * height * src->cpp == dst->Base.Size && - x == 0 && dst_offset == 0); - - dri_bo *dst_buffer = intel_bufferobj_buffer(intel, dst, - all ? INTEL_WRITE_FULL : - INTEL_WRITE_PART); - __DRIdrawable *dPriv = intel->driReadDrawable; - int nbox = dPriv->numClipRects; - drm_clip_rect_t *box = dPriv->pClipRects; - drm_clip_rect_t rect; - drm_clip_rect_t src_rect; - int i; - - src_rect.x1 = dPriv->x + x; - src_rect.y1 = dPriv->y + dPriv->h - (y + height); - src_rect.x2 = src_rect.x1 + width; - src_rect.y2 = src_rect.y1 + height; - - - - for (i = 0; i < nbox; i++) { - if (!intel_intersect_cliprects(&rect, &src_rect, &box[i])) - continue; - - if (!intelEmitCopyBlit(intel, - src->cpp, - src->pitch, src->buffer, 0, src->tiling, - rowLength, dst_buffer, dst_offset, GL_FALSE, - rect.x1, - rect.y1, - rect.x1 - src_rect.x1, - rect.y2 - src_rect.y2, - rect.x2 - rect.x1, rect.y2 - rect.y1, - GL_COPY)) { - return GL_FALSE; - } - } + dst_buffer = intel_bufferobj_buffer(intel, dst, + all ? INTEL_WRITE_FULL : + INTEL_WRITE_PART); + + src_rect.x1 = x; + if (ctx->ReadBuffer->Name == 0) + src_rect.y1 = ctx->ReadBuffer->Height - (y + height); + else + src_rect.y1 = y; + src_rect.x2 = src_rect.x1 + width; + src_rect.y2 = src_rect.y1 + height; + + read_bounds.x1 = 0; + read_bounds.y1 = 0; + read_bounds.x2 = ctx->ReadBuffer->Width; + read_bounds.y2 = ctx->ReadBuffer->Height; + + if (!intel_intersect_cliprects(&rect, &src_rect, &read_bounds)) + return GL_TRUE; + + if (!intelEmitCopyBlit(intel, + src->cpp, + src->pitch, src->buffer, 0, src->tiling, + rowLength, dst_buffer, dst_offset, GL_FALSE, + rect.x1, + rect.y1, + rect.x1 - src_rect.x1, + rect.y2 - src_rect.y2, + rect.x2 - rect.x1, rect.y2 - rect.y1, + GL_COPY)) { + return GL_FALSE; } if (INTEL_DEBUG & DEBUG_PIXEL) -- cgit v1.2.3 From 1187a3c957578355f0e4475d45a4eab4c13d4cd8 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Tue, 26 Jan 2010 16:37:10 -0800 Subject: st/mesa: Silence uninitialized variable warning. --- src/mesa/state_tracker/st_cb_condrender.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/state_tracker/st_cb_condrender.c b/src/mesa/state_tracker/st_cb_condrender.c index 780b40c206..8483b93bd8 100644 --- a/src/mesa/state_tracker/st_cb_condrender.c +++ b/src/mesa/state_tracker/st_cb_condrender.c @@ -69,6 +69,7 @@ st_BeginConditionalRender(GLcontext *ctx, struct gl_query_object *q, break; default: assert(0 && "bad mode in st_BeginConditionalRender"); + m = PIPE_RENDER_COND_WAIT; } pipe->render_condition(pipe, stq->pq, m); -- cgit v1.2.3 From 6ab9740b7a4f2be55533b5229519ae9563bd88ee Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Tue, 26 Jan 2010 16:45:32 -0800 Subject: softpipe: Remove unused variables. --- src/gallium/drivers/softpipe/sp_tex_sample.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c index 1ae8fecacf..473ec3e150 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.c +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c @@ -517,7 +517,6 @@ compute_lambda_1d(const struct sp_sampler_varient *samp, const float p[QUAD_SIZE]) { const struct pipe_texture *texture = samp->texture; - const struct pipe_sampler_state *sampler = samp->sampler; float dsdx = fabsf(s[QUAD_BOTTOM_RIGHT] - s[QUAD_BOTTOM_LEFT]); float dsdy = fabsf(s[QUAD_TOP_LEFT] - s[QUAD_BOTTOM_LEFT]); float rho = MAX2(dsdx, dsdy) * texture->width0; @@ -533,7 +532,6 @@ compute_lambda_2d(const struct sp_sampler_varient *samp, const float p[QUAD_SIZE]) { const struct pipe_texture *texture = samp->texture; - const struct pipe_sampler_state *sampler = samp->sampler; float dsdx = fabsf(s[QUAD_BOTTOM_RIGHT] - s[QUAD_BOTTOM_LEFT]); float dsdy = fabsf(s[QUAD_TOP_LEFT] - s[QUAD_BOTTOM_LEFT]); float dtdx = fabsf(t[QUAD_BOTTOM_RIGHT] - t[QUAD_BOTTOM_LEFT]); @@ -553,7 +551,6 @@ compute_lambda_3d(const struct sp_sampler_varient *samp, const float p[QUAD_SIZE]) { const struct pipe_texture *texture = samp->texture; - const struct pipe_sampler_state *sampler = samp->sampler; float dsdx = fabsf(s[QUAD_BOTTOM_RIGHT] - s[QUAD_BOTTOM_LEFT]); float dsdy = fabsf(s[QUAD_TOP_LEFT] - s[QUAD_BOTTOM_LEFT]); float dtdx = fabsf(t[QUAD_BOTTOM_RIGHT] - t[QUAD_BOTTOM_LEFT]); -- cgit v1.2.3 From 25b8ce3a6aa67db96550946aab94bd3416e5b10a Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Tue, 26 Jan 2010 17:00:15 -0800 Subject: i965g: Silence uninitialized variable warning. --- src/gallium/drivers/i965/brw_screen.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gallium/drivers/i965/brw_screen.c b/src/gallium/drivers/i965/brw_screen.c index 0ecacac9a3..a3728fb16e 100644 --- a/src/gallium/drivers/i965/brw_screen.c +++ b/src/gallium/drivers/i965/brw_screen.c @@ -138,6 +138,9 @@ brw_get_name(struct pipe_screen *screen) case PCI_CHIP_ILM_G: chipset = "ILM_G"; break; + default: + chipset = "unknown"; + break; } util_snprintf(buffer, sizeof(buffer), "i965 (chipset: %s)", chipset); -- cgit v1.2.3 From a3d8e7e48152d88217a409bf366e10497ee75763 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 26 Jan 2010 16:35:27 -0800 Subject: i965: Remove DRI1 leftovers from stipple offset handling. --- src/mesa/drivers/dri/i965/brw_misc_state.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c b/src/mesa/drivers/dri/i965/brw_misc_state.c index 7b70f787b7..f708ee0063 100644 --- a/src/mesa/drivers/dri/i965/brw_misc_state.c +++ b/src/mesa/drivers/dri/i965/brw_misc_state.c @@ -327,7 +327,7 @@ const struct brw_tracked_state brw_polygon_stipple = { static void upload_polygon_stipple_offset(struct brw_context *brw) { - __DRIdrawable *dPriv = brw->intel.driDrawable; + GLcontext *ctx = &brw->intel.ctx; struct brw_polygon_stipple_offset bpso; memset(&bpso, 0, sizeof(bpso)); @@ -343,8 +343,8 @@ static void upload_polygon_stipple_offset(struct brw_context *brw) * worry about. */ if (brw->intel.ctx.DrawBuffer->Name == 0) { - bpso.bits0.x_offset = (32 - (dPriv->x & 31)) & 31; - bpso.bits0.y_offset = (32 - ((dPriv->y + dPriv->h) & 31)) & 31; + bpso.bits0.x_offset = 0; + bpso.bits0.y_offset = (32 - (ctx->DrawBuffer->Height & 31)) & 31; } else { bpso.bits0.y_offset = 0; -- cgit v1.2.3 From 3efd88f183485fc8a4cde3ec306c6a9191477902 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 26 Jan 2010 16:40:05 -0800 Subject: intel: Remove DRI1 junk from glClear blit implementation. --- src/mesa/drivers/dri/intel/intel_blit.c | 297 +++++++++++++------------------- 1 file changed, 123 insertions(+), 174 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c index 72b6e1acb9..45464e45d2 100644 --- a/src/mesa/drivers/dri/intel/intel_blit.c +++ b/src/mesa/drivers/dri/intel/intel_blit.c @@ -212,10 +212,8 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask) struct intel_context *intel = intel_context(ctx); struct gl_framebuffer *fb = ctx->DrawBuffer; GLuint clear_depth; - GLbitfield skipBuffers = 0; - unsigned int num_cliprects; - struct drm_clip_rect *cliprects; - int x_off, y_off; + GLboolean all; + GLint cx, cy, cw, ch; BATCH_LOCALS; /* @@ -229,183 +227,134 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask) clear_depth |= (ctx->Stencil.Clear & 0xff) << 24; } - /* If clearing both depth and stencil, skip BUFFER_BIT_STENCIL in - * the loop below. - */ - if ((mask & BUFFER_BIT_DEPTH) && (mask & BUFFER_BIT_STENCIL)) { - skipBuffers = BUFFER_BIT_STENCIL; - } - - intel_get_cliprects(intel, &cliprects, &num_cliprects, &x_off, &y_off); - if (num_cliprects) { - GLint cx, cy, cw, ch; - drm_clip_rect_t clear; - int i; - - /* Get clear bounds after locking */ - cx = fb->_Xmin; + cx = fb->_Xmin; + if (fb->Name == 0) cy = fb->_Ymin; - cw = fb->_Xmax - cx; - ch = fb->_Ymax - cy; - - if (fb->Name == 0) { - /* clearing a window */ - - /* flip top to bottom */ - clear.x1 = cx + x_off; - clear.y1 = intel->driDrawable->y + intel->driDrawable->h - cy - ch; - clear.x2 = clear.x1 + cw; - clear.y2 = clear.y1 + ch; - } - else { - /* clearing FBO */ - assert(num_cliprects == 1); - assert(cliprects == &intel->fboRect); - clear.x1 = cx; - clear.y1 = cy; - clear.x2 = clear.x1 + cw; - clear.y2 = clear.y1 + ch; - /* no change to mask */ + else + cy = ctx->DrawBuffer->Height - fb->_Ymax; + cw = fb->_Xmax - fb->_Xmin; + ch = fb->_Ymax - fb->_Ymin; + + if (cw == 0 || ch == 0) + return; + + GLuint buf; + all = (cw == fb->Width && ch == fb->Height); + + /* Loop over all renderbuffers */ + for (buf = 0; buf < BUFFER_COUNT && mask; buf++) { + const GLbitfield bufBit = 1 << buf; + struct intel_renderbuffer *irb; + drm_intel_bo *write_buffer; + int x1, y1, x2, y2; + uint32_t clear_val; + uint32_t BR13, CMD; + int pitch, cpp; + + if (!(mask & bufBit)) + continue; + + /* OK, clear this renderbuffer */ + irb = intel_get_renderbuffer(fb, buf); + write_buffer = intel_region_buffer(intel, irb->region, + all ? INTEL_WRITE_FULL : + INTEL_WRITE_PART); + x1 = cx + irb->region->draw_x; + y1 = cy + irb->region->draw_y; + x2 = cx + cw + irb->region->draw_x; + y2 = cy + ch + irb->region->draw_y; + + pitch = irb->region->pitch; + cpp = irb->region->cpp; + + DBG("%s dst:buf(%p)/%d %d,%d sz:%dx%d\n", + __FUNCTION__, + irb->region->buffer, (pitch * cpp), + x1, y1, x2 - x1, y2 - y1); + + BR13 = 0xf0 << 16; + CMD = XY_COLOR_BLT_CMD; + + /* Setup the blit command */ + if (cpp == 4) { + BR13 |= BR13_8888; + if (buf == BUFFER_DEPTH || buf == BUFFER_STENCIL) { + if (mask & BUFFER_BIT_DEPTH) + CMD |= XY_BLT_WRITE_RGB; + if (mask & BUFFER_BIT_STENCIL) + CMD |= XY_BLT_WRITE_ALPHA; + } else { + /* clearing RGBA */ + CMD |= XY_BLT_WRITE_ALPHA | XY_BLT_WRITE_RGB; + } + } else { + ASSERT(cpp == 2); + BR13 |= BR13_565; } - for (i = 0; i < num_cliprects; i++) { - const drm_clip_rect_t *box = &cliprects[i]; - drm_clip_rect_t b; - GLuint buf; - GLuint clearMask = mask; /* use copy, since we modify it below */ - GLboolean all = (cw == fb->Width && ch == fb->Height); - - if (!all) { - intel_intersect_cliprects(&b, &clear, box); - } - else { - b = *box; - } - - if (b.x1 >= b.x2 || b.y1 >= b.y2) - continue; - - if (0) - _mesa_printf("clear %d,%d..%d,%d, mask %x\n", - b.x1, b.y1, b.x2, b.y2, mask); - - /* Loop over all renderbuffers */ - for (buf = 0; buf < BUFFER_COUNT && clearMask; buf++) { - const GLbitfield bufBit = 1 << buf; - if ((clearMask & bufBit) && !(bufBit & skipBuffers)) { - /* OK, clear this renderbuffer */ - struct intel_renderbuffer *irb = intel_get_renderbuffer(fb, buf); - dri_bo *write_buffer = - intel_region_buffer(intel, irb->region, - all ? INTEL_WRITE_FULL : - INTEL_WRITE_PART); - int x1 = b.x1 + irb->region->draw_x; - int y1 = b.y1 + irb->region->draw_y; - int x2 = b.x2 + irb->region->draw_x; - int y2 = b.y2 + irb->region->draw_y; - - GLuint clearVal; - GLint pitch, cpp; - GLuint BR13, CMD; - - pitch = irb->region->pitch; - cpp = irb->region->cpp; - - DBG("%s dst:buf(%p)/%d %d,%d sz:%dx%d\n", - __FUNCTION__, - irb->region->buffer, (pitch * cpp), - x1, y1, x2 - x1, y2 - y1); - - BR13 = 0xf0 << 16; - CMD = XY_COLOR_BLT_CMD; - - /* Setup the blit command */ - if (cpp == 4) { - BR13 |= BR13_8888; - if (buf == BUFFER_DEPTH || buf == BUFFER_STENCIL) { - if (clearMask & BUFFER_BIT_DEPTH) - CMD |= XY_BLT_WRITE_RGB; - if (clearMask & BUFFER_BIT_STENCIL) - CMD |= XY_BLT_WRITE_ALPHA; - } - else { - /* clearing RGBA */ - CMD |= XY_BLT_WRITE_ALPHA | XY_BLT_WRITE_RGB; - } - } - else { - ASSERT(cpp == 2); - BR13 |= BR13_565; - } - - assert(irb->region->tiling != I915_TILING_Y); + assert(irb->region->tiling != I915_TILING_Y); #ifndef I915 - if (irb->region->tiling != I915_TILING_NONE) { - CMD |= XY_DST_TILED; - pitch /= 4; - } + if (irb->region->tiling != I915_TILING_NONE) { + CMD |= XY_DST_TILED; + pitch /= 4; + } #endif - BR13 |= (pitch * cpp); - - if (buf == BUFFER_DEPTH || buf == BUFFER_STENCIL) { - clearVal = clear_depth; - } - else { - uint8_t clear[4]; - GLclampf *color = ctx->Color.ClearColor; - - CLAMPED_FLOAT_TO_UBYTE(clear[0], color[0]); - CLAMPED_FLOAT_TO_UBYTE(clear[1], color[1]); - CLAMPED_FLOAT_TO_UBYTE(clear[2], color[2]); - CLAMPED_FLOAT_TO_UBYTE(clear[3], color[3]); - - switch (irb->Base.Format) { - case MESA_FORMAT_ARGB8888: - case MESA_FORMAT_XRGB8888: - clearVal = PACK_COLOR_8888(clear[3], clear[0], - clear[1], clear[2]); - break; - case MESA_FORMAT_RGB565: - clearVal = PACK_COLOR_565(clear[0], clear[1], clear[2]); - break; - case MESA_FORMAT_ARGB4444: - clearVal = PACK_COLOR_4444(clear[3], clear[0], - clear[1], clear[2]); - break; - case MESA_FORMAT_ARGB1555: - clearVal = PACK_COLOR_1555(clear[3], clear[0], - clear[1], clear[2]); - break; - default: - _mesa_problem(ctx, "Unexpected renderbuffer format: %d\n", - irb->Base.Format); - clearVal = 0; - } - } - - /* - _mesa_debug(ctx, "hardware blit clear buf %d rb id %d\n", - buf, irb->Base.Name); - */ - - assert(x1 < x2); - assert(y1 < y2); - - BEGIN_BATCH(6); - OUT_BATCH(CMD); - OUT_BATCH(BR13); - OUT_BATCH((y1 << 16) | x1); - OUT_BATCH((y2 << 16) | x2); - OUT_RELOC(write_buffer, - I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, - 0); - OUT_BATCH(clearVal); - ADVANCE_BATCH(); - clearMask &= ~bufBit; /* turn off bit, for faster loop exit */ - } - } + BR13 |= (pitch * cpp); + + if (buf == BUFFER_DEPTH || buf == BUFFER_STENCIL) { + clear_val = clear_depth; + } else { + uint8_t clear[4]; + GLclampf *color = ctx->Color.ClearColor; + + CLAMPED_FLOAT_TO_UBYTE(clear[0], color[0]); + CLAMPED_FLOAT_TO_UBYTE(clear[1], color[1]); + CLAMPED_FLOAT_TO_UBYTE(clear[2], color[2]); + CLAMPED_FLOAT_TO_UBYTE(clear[3], color[3]); + + switch (irb->Base.Format) { + case MESA_FORMAT_ARGB8888: + case MESA_FORMAT_XRGB8888: + clear_val = PACK_COLOR_8888(clear[3], clear[0], + clear[1], clear[2]); + break; + case MESA_FORMAT_RGB565: + clear_val = PACK_COLOR_565(clear[0], clear[1], clear[2]); + break; + case MESA_FORMAT_ARGB4444: + clear_val = PACK_COLOR_4444(clear[3], clear[0], + clear[1], clear[2]); + break; + case MESA_FORMAT_ARGB1555: + clear_val = PACK_COLOR_1555(clear[3], clear[0], + clear[1], clear[2]); + break; + default: + _mesa_problem(ctx, "Unexpected renderbuffer format: %d\n", + irb->Base.Format); + clear_val = 0; + } } + + assert(x1 < x2); + assert(y1 < y2); + + BEGIN_BATCH(6); + OUT_BATCH(CMD); + OUT_BATCH(BR13); + OUT_BATCH((y1 << 16) | x1); + OUT_BATCH((y2 << 16) | x2); + OUT_RELOC(write_buffer, + I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, + 0); + OUT_BATCH(clear_val); + ADVANCE_BATCH(); + + if (buf == BUFFER_DEPTH || buf == BUFFER_STENCIL) + mask &= ~(BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL); + else + mask &= ~bufBit; /* turn off bit, for faster loop exit */ } } -- cgit v1.2.3 From 3f912e0b3a84ef3703b974a6c29dbe3ec8e817b2 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 26 Jan 2010 17:02:55 -0800 Subject: intel: Remove DRI1 junk from CopyPixels. --- src/mesa/drivers/dri/intel/intel_pixel_copy.c | 137 ++++++++++---------------- 1 file changed, 50 insertions(+), 87 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_pixel_copy.c b/src/mesa/drivers/dri/intel/intel_pixel_copy.c index e002516cdd..87c293d8b0 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_copy.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_copy.c @@ -112,9 +112,10 @@ do_blit_copypixels(GLcontext * ctx, struct intel_region *src = copypix_src_region(intel, type); struct gl_framebuffer *fb = ctx->DrawBuffer; struct gl_framebuffer *read_fb = ctx->ReadBuffer; - unsigned int num_cliprects; - drm_clip_rect_t *cliprects; - int x_off, y_off; + GLint orig_dstx; + GLint orig_dsty; + GLint orig_srcx; + GLint orig_srcy; if (type == GL_DEPTH || type == GL_STENCIL) { if (INTEL_DEBUG & DEBUG_FALLBACKS) @@ -135,94 +136,56 @@ do_blit_copypixels(GLcontext * ctx, if (!src || !dst) return GL_FALSE; - - intelFlush(&intel->ctx); - intel_get_cliprects(intel, &cliprects, &num_cliprects, &x_off, &y_off); - if (num_cliprects != 0) { - GLint delta_x; - GLint delta_y; - GLint orig_dstx; - GLint orig_dsty; - GLint orig_srcx; - GLint orig_srcy; - GLuint i; - - /* XXX: We fail to handle different inversion between read and draw framebuffer. */ - - /* Clip to destination buffer. */ - orig_dstx = dstx; - orig_dsty = dsty; - if (!_mesa_clip_to_region(fb->_Xmin, fb->_Ymin, - fb->_Xmax, fb->_Ymax, - &dstx, &dsty, &width, &height)) - goto out; - /* Adjust src coords for our post-clipped destination origin */ - srcx += dstx - orig_dstx; - srcy += dsty - orig_dsty; - - /* Clip to source buffer. */ - orig_srcx = srcx; - orig_srcy = srcy; - if (!_mesa_clip_to_region(0, 0, - read_fb->Width, read_fb->Height, - &srcx, &srcy, &width, &height)) - goto out; - /* Adjust dst coords for our post-clipped source origin */ - dstx += srcx - orig_srcx; - dsty += srcy - orig_srcy; - - /* Convert from GL to hardware coordinates: - */ - if (fb->Name == 0) { - /* copypixels to a system framebuffer */ - dstx = x_off + dstx; - dsty = y_off + (fb->Height - dsty - height); - } else { - /* copypixels to a user framebuffer object */ - dstx = x_off + dstx; - dsty = y_off + dsty; - } - - /* Flip source Y if it's a system framebuffer. */ - if (read_fb->Name == 0) { - srcx = intel->driReadDrawable->x + srcx; - srcy = intel->driReadDrawable->y + (fb->Height - srcy - height); - } - - delta_x = srcx - dstx; - delta_y = srcy - dsty; - /* Could do slightly more clipping: Eg, take the intersection of - * the destination cliprects and the read drawable cliprects - * - * This code will not overwrite other windows, but will - * introduce garbage when copying from obscured window regions. - */ - for (i = 0; i < num_cliprects; i++) { - GLint clip_x = dstx; - GLint clip_y = dsty; - GLint clip_w = width; - GLint clip_h = height; - - if (!_mesa_clip_to_region(cliprects[i].x1, cliprects[i].y1, - cliprects[i].x2, cliprects[i].y2, - &clip_x, &clip_y, &clip_w, &clip_h)) - continue; - - if (!intel_region_copy(intel, - dst, 0, clip_x, clip_y, - src, 0, clip_x + delta_x, clip_y + delta_y, - clip_w, clip_h, - ctx->Color.ColorLogicOpEnabled ? - ctx->Color.LogicOp : GL_COPY)) { - DBG("%s: blit failure\n", __FUNCTION__); - return GL_FALSE; - } - } + /* XXX: We fail to handle different inversion between read and draw framebuffer. */ + + /* Clip to destination buffer. */ + orig_dstx = dstx; + orig_dsty = dsty; + if (!_mesa_clip_to_region(fb->_Xmin, fb->_Ymin, + fb->_Xmax, fb->_Ymax, + &dstx, &dsty, &width, &height)) + goto out; + /* Adjust src coords for our post-clipped destination origin */ + srcx += dstx - orig_dstx; + srcy += dsty - orig_dsty; + + /* Clip to source buffer. */ + orig_srcx = srcx; + orig_srcy = srcy; + if (!_mesa_clip_to_region(0, 0, + read_fb->Width, read_fb->Height, + &srcx, &srcy, &width, &height)) + goto out; + /* Adjust dst coords for our post-clipped source origin */ + dstx += srcx - orig_srcx; + dsty += srcy - orig_srcy; + + /* Convert from GL to hardware coordinates: */ + if (fb->Name == 0) { + /* copypixels to a system framebuffer */ + dsty = fb->Height - dsty - height; + } else { + /* copypixels to a user framebuffer object */ + dsty = dsty; } -out: + /* Flip source Y if it's a system framebuffer. */ + if (read_fb->Name == 0) + srcy = fb->Height - srcy - height; + + if (!intel_region_copy(intel, + dst, 0, dstx, dsty, + src, 0, srcx, srcy, + width, height, + ctx->Color.ColorLogicOpEnabled ? + ctx->Color.LogicOp : GL_COPY)) { + DBG("%s: blit failure\n", __FUNCTION__); + return GL_FALSE; + } + +out: intel_check_front_buffer_rendering(intel); DBG("%s: success\n", __FUNCTION__); -- cgit v1.2.3 From 348fadc5df83c22b237c59f1aed26573ab9f7506 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 26 Jan 2010 17:11:11 -0800 Subject: intel: Remove DRI1 junk from blit glBitmap. --- src/mesa/drivers/dri/intel/intel_pixel_bitmap.c | 135 ++++++++++-------------- 1 file changed, 53 insertions(+), 82 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c index b27766ee6f..aaf3a8b889 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c @@ -188,11 +188,12 @@ do_blit_bitmap( GLcontext *ctx, GLfloat tmpColor[4]; GLubyte ubcolor[4]; GLuint color; - unsigned int num_cliprects; - drm_clip_rect_t *cliprects; - int x_off, y_off; GLsizei bitmap_width = width; GLsizei bitmap_height = height; + GLint px, py; + GLuint stipple[32]; + GLint orig_dstx = dstx; + GLint orig_dsty = dsty; /* Update draw buffer bounds */ _mesa_update_state(ctx); @@ -233,90 +234,60 @@ do_blit_bitmap( GLcontext *ctx, if (!intel_check_blit_fragment_ops(ctx, tmpColor[3] == 1.0F)) return GL_FALSE; - intel_get_cliprects(intel, &cliprects, &num_cliprects, &x_off, &y_off); - if (num_cliprects != 0) { - GLuint i; - GLint orig_dstx = dstx; - GLint orig_dsty = dsty; - - /* Clip to buffer bounds and scissor. */ - if (!_mesa_clip_to_region(fb->_Xmin, fb->_Ymin, - fb->_Xmax, fb->_Ymax, - &dstx, &dsty, &width, &height)) - goto out; - - dstx = x_off + dstx; - dsty = y_off + y_flip(fb, dsty, height); - - for (i = 0; i < num_cliprects; i++) { - int box_x, box_y, box_w, box_h; - GLint px, py; - GLuint stipple[32]; - - box_x = dstx; - box_y = dsty; - box_w = width; - box_h = height; - - /* Clip to drawable cliprect */ - if (!_mesa_clip_to_region(cliprects[i].x1, - cliprects[i].y1, - cliprects[i].x2, - cliprects[i].y2, - &box_x, &box_y, &box_w, &box_h)) - continue; + /* Clip to buffer bounds and scissor. */ + if (!_mesa_clip_to_region(fb->_Xmin, fb->_Ymin, + fb->_Xmax, fb->_Ymax, + &dstx, &dsty, &width, &height)) + goto out; + + dsty = y_flip(fb, dsty, height); #define DY 32 #define DX 32 - /* Then, finally, chop it all into chunks that can be - * digested by hardware: + /* Chop it all into chunks that can be digested by hardware: */ + for (py = 0; py < height; py += DY) { + for (px = 0; px < width; px += DX) { + int h = MIN2(DY, height - py); + int w = MIN2(DX, width - px); + GLuint sz = ALIGN(ALIGN(w,8) * h, 64)/8; + GLenum logic_op = ctx->Color.ColorLogicOpEnabled ? + ctx->Color.LogicOp : GL_COPY; + + assert(sz <= sizeof(stipple)); + memset(stipple, 0, sz); + + /* May need to adjust this when padding has been introduced in + * sz above: + * + * Have to translate destination coordinates back into source + * coordinates. */ - for (py = 0; py < box_h; py += DY) { - for (px = 0; px < box_w; px += DX) { - int h = MIN2(DY, box_h - py); - int w = MIN2(DX, box_w - px); - GLuint sz = ALIGN(ALIGN(w,8) * h, 64)/8; - GLenum logic_op = ctx->Color.ColorLogicOpEnabled ? - ctx->Color.LogicOp : GL_COPY; - - assert(sz <= sizeof(stipple)); - memset(stipple, 0, sz); - - /* May need to adjust this when padding has been introduced in - * sz above: - * - * Have to translate destination coordinates back into source - * coordinates. - */ - if (get_bitmap_rect(bitmap_width, bitmap_height, unpack, - bitmap, - -orig_dstx + (box_x + px - x_off), - -orig_dsty + y_flip(fb, - box_y + py - y_off, h), - w, h, - (GLubyte *)stipple, - 8, - fb->Name == 0 ? GL_TRUE : GL_FALSE) == 0) - continue; - - if (!intelEmitImmediateColorExpandBlit(intel, - dst->cpp, - (GLubyte *)stipple, - sz, - color, - dst->pitch, - dst->buffer, - 0, - dst->tiling, - box_x + px, - box_y + py, - w, h, - logic_op)) { - return GL_FALSE; - } - } - } + if (get_bitmap_rect(bitmap_width, bitmap_height, unpack, + bitmap, + -orig_dstx + (dstx + px), + -orig_dsty + y_flip(fb, dsty + py, h), + w, h, + (GLubyte *)stipple, + 8, + fb->Name == 0 ? GL_TRUE : GL_FALSE) == 0) + continue; + + if (!intelEmitImmediateColorExpandBlit(intel, + dst->cpp, + (GLubyte *)stipple, + sz, + color, + dst->pitch, + dst->buffer, + 0, + dst->tiling, + dstx + px, + dsty + py, + w, h, + logic_op)) { + return GL_FALSE; + } } } out: -- cgit v1.2.3 From ee454f0ba422e37157c7ac774884474bcc6c9d34 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 26 Jan 2010 17:36:35 -0800 Subject: intel: Remove DRI1 junk from spans code. This reduces the driver size by over 1%. --- src/mesa/drivers/dri/intel/intel_span.c | 41 +++++++++------------------------ 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_span.c b/src/mesa/drivers/dri/intel/intel_span.c index 605734d8e5..d925cb9997 100644 --- a/src/mesa/drivers/dri/intel/intel_span.c +++ b/src/mesa/drivers/dri/intel/intel_span.c @@ -259,36 +259,20 @@ static uint32_t y_tile_swizzle(struct intel_renderbuffer *irb, #define DBG 0 #define LOCAL_VARS \ - struct intel_context *intel = intel_context(ctx); \ struct intel_renderbuffer *irb = intel_renderbuffer(rb); \ const GLint yScale = ctx->DrawBuffer->Name ? 1 : -1; \ const GLint yBias = ctx->DrawBuffer->Name ? 0 : irb->Base.Height - 1;\ - unsigned int num_cliprects; \ - struct drm_clip_rect *cliprects; \ - int x_off, y_off; \ + int minx = 0, miny = 0; \ + int maxx = ctx->DrawBuffer->Width; \ + int maxy = ctx->DrawBuffer->Height; \ int pitch = irb->region->pitch * irb->region->cpp; \ void *buf = irb->region->buffer->virtual; \ GLuint p; \ (void) p; \ (void)buf; (void)pitch; /* unused for non-gttmap. */ \ - intel_get_cliprects(intel, &cliprects, &num_cliprects, &x_off, &y_off); -/* XXX FBO: this is identical to the macro in spantmp2.h except we get - * the cliprect info from the context, not the driDrawable. - * Move this into spantmp2.h someday. - */ -#define HW_CLIPLOOP() \ - do { \ - int _nc = num_cliprects; \ - while ( _nc-- ) { \ - int minx = cliprects[_nc].x1 - x_off; \ - int miny = cliprects[_nc].y1 - y_off; \ - int maxx = cliprects[_nc].x2 - x_off; \ - int maxy = cliprects[_nc].y2 - y_off; - -#if 0 - }} -#endif +#define HW_CLIPLOOP() +#define HW_ENDCLIPLOOP() #define Y_FLIP(_y) ((_y) * yScale + yBias) @@ -297,9 +281,9 @@ static uint32_t y_tile_swizzle(struct intel_renderbuffer *irb, #define HW_UNLOCK() /* Convenience macros to avoid typing the swizzle argument over and over */ -#define NO_TILE(_X, _Y) no_tile_swizzle(irb, (_X) + x_off, (_Y) + y_off) -#define X_TILE(_X, _Y) x_tile_swizzle(irb, (_X) + x_off, (_Y) + y_off) -#define Y_TILE(_X, _Y) y_tile_swizzle(irb, (_X) + x_off, (_Y) + y_off) +#define NO_TILE(_X, _Y) no_tile_swizzle(irb, (_X), (_Y)) +#define X_TILE(_X, _Y) x_tile_swizzle(irb, (_X), (_Y)) +#define Y_TILE(_X, _Y) y_tile_swizzle(irb, (_X), (_Y)) /* r5g6b5 color span and pixel functions */ #define INTEL_PIXEL_FMT GL_RGB @@ -342,18 +326,15 @@ static uint32_t y_tile_swizzle(struct intel_renderbuffer *irb, #include "intel_spantmp.h" #define LOCAL_DEPTH_VARS \ - struct intel_context *intel = intel_context(ctx); \ struct intel_renderbuffer *irb = intel_renderbuffer(rb); \ const GLint yScale = ctx->DrawBuffer->Name ? 1 : -1; \ const GLint yBias = ctx->DrawBuffer->Name ? 0 : irb->Base.Height - 1;\ - unsigned int num_cliprects; \ - struct drm_clip_rect *cliprects; \ - int x_off, y_off; \ + int minx = 0, miny = 0; \ + int maxx = ctx->DrawBuffer->Width; \ + int maxy = ctx->DrawBuffer->Height; \ int pitch = irb->region->pitch * irb->region->cpp; \ void *buf = irb->region->buffer->virtual; \ (void)buf; (void)pitch; /* unused for non-gttmap. */ \ - intel_get_cliprects(intel, &cliprects, &num_cliprects, &x_off, &y_off); - #define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS -- cgit v1.2.3 From a389d6bd566ba241a285c3a33039d5e964bc8f30 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 26 Jan 2010 17:40:44 -0800 Subject: intel: Remove the remaining cliprects code from DRI1. --- src/mesa/drivers/dri/intel/intel_buffers.c | 18 ------------------ src/mesa/drivers/dri/intel/intel_context.h | 4 ---- 2 files changed, 22 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_buffers.c b/src/mesa/drivers/dri/intel/intel_buffers.c index de75257349..9171bab63a 100644 --- a/src/mesa/drivers/dri/intel/intel_buffers.c +++ b/src/mesa/drivers/dri/intel/intel_buffers.c @@ -94,24 +94,6 @@ intel_readbuf_region(struct intel_context *intel) return NULL; } -void -intel_get_cliprects(struct intel_context *intel, - struct drm_clip_rect **cliprects, - unsigned int *num_cliprects, - int *x_off, int *y_off) -{ - intel->fboRect.x1 = 0; - intel->fboRect.y1 = 0; - intel->fboRect.x2 = intel->ctx.DrawBuffer->Width; - intel->fboRect.y2 = intel->ctx.DrawBuffer->Height; - - *cliprects = &intel->fboRect; - *num_cliprects = 1; - *x_off = 0; - *y_off = 0; -} - - /** * Check if we're about to draw into the front color buffer. * If so, set the intel->front_buffer_dirty field to true. diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h index 57c3391130..8d7c95976f 100644 --- a/src/mesa/drivers/dri/intel/intel_context.h +++ b/src/mesa/drivers/dri/intel/intel_context.h @@ -273,10 +273,6 @@ struct intel_context GLboolean use_texture_tiling; GLboolean use_early_z; - drm_clip_rect_t fboRect; /**< cliprect for FBO rendering */ - - drm_clip_rect_t draw_rect; - drm_clip_rect_t scissor_rect; int driFd; -- cgit v1.2.3 From 41f4d82ba8e2497d9fe27f55cb1b8707862fed46 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 26 Jan 2010 17:47:03 -0800 Subject: intel: Clean up stale comments about cliprects. --- src/mesa/drivers/dri/i965/brw_sf_state.c | 6 ++-- src/mesa/drivers/dri/intel/intel_batchbuffer.c | 38 ------------------------- src/mesa/drivers/dri/intel/intel_pixel_bitmap.c | 2 +- 3 files changed, 4 insertions(+), 42 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c b/src/mesa/drivers/dri/i965/brw_sf_state.c index 8ebbd09e43..847c886279 100644 --- a/src/mesa/drivers/dri/i965/brw_sf_state.c +++ b/src/mesa/drivers/dri/i965/brw_sf_state.c @@ -69,9 +69,9 @@ static void upload_sf_vp(struct brw_context *brw) * for DrawBuffer->_[XY]{min,max} */ - /* The scissor only needs to handle the intersection of drawable and - * scissor rect. Clipping to the boundaries of static shared buffers - * for front/back/depth is covered by looping over cliprects in brw_draw.c. + /* The scissor only needs to handle the intersection of drawable + * and scissor rect, since there are no longer cliprects for shared + * buffers with DRI2. * * Note that the hardware's coordinates are inclusive, while Mesa's min is * inclusive but max is exclusive. diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c index f18fb91a88..ae0f8a16f9 100644 --- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c @@ -32,44 +32,6 @@ #include "intel_bufmgr.h" #include "intel_buffers.h" -/* Relocations in kernel space: - * - pass dma buffer seperately - * - memory manager knows how to patch - * - pass list of dependent buffers - * - pass relocation list - * - * Either: - * - get back an offset for buffer to fire - * - memory manager knows how to fire buffer - * - * Really want the buffer to be AGP and pinned. - * - */ - -/* Cliprect fence: The highest fence protecting a dma buffer - * containing explicit cliprect information. Like the old drawable - * lock but irq-driven. X server must wait for this fence to expire - * before changing cliprects [and then doing sw rendering?]. For - * other dma buffers, the scheduler will grab current cliprect info - * and mix into buffer. X server must hold the lock while changing - * cliprects??? Make per-drawable. Need cliprects in shared memory - * -- beats storing them with every cmd buffer in the queue. - * - * ==> X server must wait for this fence to expire before touching the - * framebuffer with new cliprects. - * - * ==> Cliprect-dependent buffers associated with a - * cliprect-timestamp. All of the buffers associated with a timestamp - * must go to hardware before any buffer with a newer timestamp. - * - * ==> Dma should be queued per-drawable for correct X/GL - * synchronization. Or can fences be used for this? - * - * Applies to: Blit operations, metaops, X server operations -- X - * server automatically waits on its own dma to complete before - * modifying cliprects ??? - */ - void intel_batchbuffer_reset(struct intel_batchbuffer *batch) { diff --git a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c index aaf3a8b889..1e517650b7 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c @@ -103,7 +103,7 @@ static void set_bit( GLubyte *dest, GLuint bit ) } /* Extract a rectangle's worth of data from the bitmap. Called - * per-cliprect. + * per chunk of HW-sized bitmap. */ static GLuint get_bitmap_rect(GLsizei width, GLsizei height, const struct gl_pixelstore_attrib *unpack, -- cgit v1.2.3 From c8e6a0f2f8637d803006d207bb2fb8e4292bdb28 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 26 Jan 2010 18:01:37 -0800 Subject: intel: Use a handy helper in glReadPixels source clipping. --- src/mesa/drivers/dri/intel/intel_blit.c | 2 +- src/mesa/drivers/dri/intel/intel_buffers.c | 35 ----------------------- src/mesa/drivers/dri/intel/intel_buffers.h | 6 ---- src/mesa/drivers/dri/intel/intel_pixel_read.c | 40 ++++++++++++--------------- 4 files changed, 19 insertions(+), 64 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c index 45464e45d2..f12a1c6fd3 100644 --- a/src/mesa/drivers/dri/intel/intel_blit.c +++ b/src/mesa/drivers/dri/intel/intel_blit.c @@ -102,7 +102,7 @@ intelEmitCopyBlit(struct intel_context *intel, return GL_FALSE; } - /* do space/cliprects check before going any further */ + /* do space check before going any further */ do { aper_array[0] = intel->batch->buf; aper_array[1] = dst_buffer; diff --git a/src/mesa/drivers/dri/intel/intel_buffers.c b/src/mesa/drivers/dri/intel/intel_buffers.c index 9171bab63a..5bf0bdb963 100644 --- a/src/mesa/drivers/dri/intel/intel_buffers.c +++ b/src/mesa/drivers/dri/intel/intel_buffers.c @@ -31,41 +31,6 @@ #include "intel_batchbuffer.h" #include "main/framebuffer.h" - -/** - * XXX move this into a new dri/common/cliprects.c file. - */ -GLboolean -intel_intersect_cliprects(drm_clip_rect_t * dst, - const drm_clip_rect_t * a, - const drm_clip_rect_t * b) -{ - GLint bx = b->x1; - GLint by = b->y1; - GLint bw = b->x2 - bx; - GLint bh = b->y2 - by; - - if (bx < a->x1) - bw -= a->x1 - bx, bx = a->x1; - if (by < a->y1) - bh -= a->y1 - by, by = a->y1; - if (bx + bw > a->x2) - bw = a->x2 - bx; - if (by + bh > a->y2) - bh = a->y2 - by; - if (bw <= 0) - return GL_FALSE; - if (bh <= 0) - return GL_FALSE; - - dst->x1 = bx; - dst->y1 = by; - dst->x2 = bx + bw; - dst->y2 = by + bh; - - return GL_TRUE; -} - /** * Return pointer to current color drawing region, or NULL. */ diff --git a/src/mesa/drivers/dri/intel/intel_buffers.h b/src/mesa/drivers/dri/intel/intel_buffers.h index d7800f2ca2..abb86aade6 100644 --- a/src/mesa/drivers/dri/intel/intel_buffers.h +++ b/src/mesa/drivers/dri/intel/intel_buffers.h @@ -35,12 +35,6 @@ struct intel_context; struct intel_framebuffer; - -extern GLboolean -intel_intersect_cliprects(drm_clip_rect_t * dest, - const drm_clip_rect_t * a, - const drm_clip_rect_t * b); - extern struct intel_region *intel_readbuf_region(struct intel_context *intel); extern struct intel_region *intel_drawbuf_region(struct intel_context *intel); diff --git a/src/mesa/drivers/dri/intel/intel_pixel_read.c b/src/mesa/drivers/dri/intel/intel_pixel_read.c index a60db52664..80a2b9740f 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_read.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_read.c @@ -169,7 +169,8 @@ do_blit_readpixels(GLcontext * ctx, GLuint dst_offset; GLuint rowLength; drm_intel_bo *dst_buffer; - drm_clip_rect_t read_bounds, rect, src_rect; + GLboolean all; + GLint dst_x, dst_y; if (INTEL_DEBUG & DEBUG_PIXEL) _mesa_printf("%s\n", __FUNCTION__); @@ -217,38 +218,33 @@ do_blit_readpixels(GLcontext * ctx, dst_offset = (GLintptr) _mesa_image_address(2, pack, pixels, width, height, format, type, 0, 0, 0); - GLboolean all = (width * height * src->cpp == dst->Base.Size && - x == 0 && dst_offset == 0); + if (!_mesa_clip_copytexsubimage(ctx, + &dst_x, &dst_y, + &x, &y, + &width, &height)) { + return GL_TRUE; + } + + all = (width * height * src->cpp == dst->Base.Size && + x == 0 && dst_offset == 0); + + dst_x = 0; + dst_y = 0; dst_buffer = intel_bufferobj_buffer(intel, dst, all ? INTEL_WRITE_FULL : INTEL_WRITE_PART); - src_rect.x1 = x; if (ctx->ReadBuffer->Name == 0) - src_rect.y1 = ctx->ReadBuffer->Height - (y + height); - else - src_rect.y1 = y; - src_rect.x2 = src_rect.x1 + width; - src_rect.y2 = src_rect.y1 + height; - - read_bounds.x1 = 0; - read_bounds.y1 = 0; - read_bounds.x2 = ctx->ReadBuffer->Width; - read_bounds.y2 = ctx->ReadBuffer->Height; - - if (!intel_intersect_cliprects(&rect, &src_rect, &read_bounds)) - return GL_TRUE; + y = ctx->ReadBuffer->Height - (y + height); if (!intelEmitCopyBlit(intel, src->cpp, src->pitch, src->buffer, 0, src->tiling, rowLength, dst_buffer, dst_offset, GL_FALSE, - rect.x1, - rect.y1, - rect.x1 - src_rect.x1, - rect.y2 - src_rect.y2, - rect.x2 - rect.x1, rect.y2 - rect.y1, + x, y, + dst_x, dst_y, + width, height, GL_COPY)) { return GL_FALSE; } -- cgit v1.2.3 From 2792baec343e5773ff51e93c1b6df8b63d3af4af Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 26 Jan 2010 18:04:03 -0800 Subject: intel: Remove dead code from having to clip copyteximage source rect. mesa core does it now. If only it did so for other entrypoints. --- src/mesa/drivers/dri/intel/intel_tex_copy.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_tex_copy.c b/src/mesa/drivers/dri/intel/intel_tex_copy.c index 79994b4a6a..d67451cf8e 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_copy.c +++ b/src/mesa/drivers/dri/intel/intel_tex_copy.c @@ -113,8 +113,6 @@ do_copy_texsubimage(struct intel_context *intel, drm_intel_bo *dst_bo = intel_region_buffer(intel, intelImage->mt->region, INTEL_WRITE_PART); - const GLint orig_x = x; - const GLint orig_y = y; GLuint image_x, image_y; GLshort src_pitch; @@ -124,9 +122,6 @@ do_copy_texsubimage(struct intel_context *intel, intelImage->face, 0, &image_x, &image_y); - /* Update dst for clipped src. Need to also clip the source rect. */ - dstx += x - orig_x; - dsty += y - orig_y; /* Can't blit to tiled buffers with non-tile-aligned offset. */ if (intelImage->mt->region->tiling == I915_TILING_Y) { -- cgit v1.2.3 From e6df209490a265f35be255468d7b9123404ef14c Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 27 Jan 2010 11:02:32 +1000 Subject: radeon: remove unused file --- src/mesa/drivers/dri/radeon/radeon_lighting.c | 681 -------------------------- 1 file changed, 681 deletions(-) delete mode 100644 src/mesa/drivers/dri/radeon/radeon_lighting.c diff --git a/src/mesa/drivers/dri/radeon/radeon_lighting.c b/src/mesa/drivers/dri/radeon/radeon_lighting.c deleted file mode 100644 index ba444f2b10..0000000000 --- a/src/mesa/drivers/dri/radeon/radeon_lighting.c +++ /dev/null @@ -1,681 +0,0 @@ -/* - * Copyright 2000, 2001 VA Linux Systems Inc., Fremont, California. - * - * All Rights Reserved. - * - * 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 - * on the rights to use, copy, modify, merge, publish, distribute, sub - * license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL - * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS 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. - * - * Authors: - * Gareth Hughes - * Keith Whitwell - */ - -#include "main/glheader.h" -#include "main/imports.h" -#include "api_arrayelt.h" -/* #include "mmath.h" */ -#include "main/enums.h" -#include "colormac.h" - - -#include "radeon_context.h" -#include "radeon_ioctl.h" -#include "radeon_state.h" -#include "radeon_tcl.h" -#include "radeon_tex.h" -#include "radeon_vtxfmt.h" - - - -/* ============================================================= - * Materials - */ - - -/* Update on colormaterial, material emmissive/ambient, - * lightmodel.globalambient - */ -void update_global_ambient( GLcontext *ctx ) -{ - radeonContextPtr rmesa = RADEON_CONTEXT(ctx); - float *fcmd = (float *)RADEON_DB_STATE( glt ); - - /* Need to do more if both emmissive & ambient are PREMULT: - */ - if ((rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] & - ((3 << RADEON_EMISSIVE_SOURCE_SHIFT) | - (3 << RADEON_AMBIENT_SOURCE_SHIFT))) == 0) - { - COPY_3V( &fcmd[GLT_RED], - ctx->Light.Material[0].Emission); - ACC_SCALE_3V( &fcmd[GLT_RED], - ctx->Light.Model.Ambient, - ctx->Light.Material[0].Ambient); - } - else - { - COPY_3V( &fcmd[GLT_RED], ctx->Light.Model.Ambient ); - } - - RADEON_DB_STATECHANGE(rmesa, &rmesa->hw.glt); -} - -/* Update on change to - * - light[p].colors - * - light[p].enabled - * - material, - * - colormaterial enabled - * - colormaterial bitmask - */ -void update_light_colors( GLcontext *ctx, GLuint p ) -{ - struct gl_light *l = &ctx->Light.Light[p]; - -/* fprintf(stderr, "%s\n", __FUNCTION__); */ - - if (l->Enabled) { - radeonContextPtr rmesa = RADEON_CONTEXT(ctx); - float *fcmd = (float *)RADEON_DB_STATE( lit[p] ); - GLuint bitmask = ctx->Light.ColorMaterialBitmask; - struct gl_material *mat = &ctx->Light.Material[0]; - - COPY_4V( &fcmd[LIT_AMBIENT_RED], l->Ambient ); - COPY_4V( &fcmd[LIT_DIFFUSE_RED], l->Diffuse ); - COPY_4V( &fcmd[LIT_SPECULAR_RED], l->Specular ); - - if (!ctx->Light.ColorMaterialEnabled) - bitmask = 0; - - if ((bitmask & FRONT_AMBIENT_BIT) == 0) - SELF_SCALE_3V( &fcmd[LIT_AMBIENT_RED], mat->Ambient ); - - if ((bitmask & FRONT_DIFFUSE_BIT) == 0) - SELF_SCALE_3V( &fcmd[LIT_DIFFUSE_RED], mat->Diffuse ); - - if ((bitmask & FRONT_SPECULAR_BIT) == 0) - SELF_SCALE_3V( &fcmd[LIT_SPECULAR_RED], mat->Specular ); - - RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.lit[p] ); - } -} - -/* Also fallback for asym colormaterial mode in twoside lighting... - */ -void check_twoside_fallback( GLcontext *ctx ) -{ - GLboolean fallback = GL_FALSE; - - if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) { - if (memcmp( &ctx->Light.Material[0], - &ctx->Light.Material[1], - sizeof(struct gl_material)) != 0) - fallback = GL_TRUE; - else if (ctx->Light.ColorMaterialEnabled && - (ctx->Light.ColorMaterialBitmask & BACK_MATERIAL_BITS) != - ((ctx->Light.ColorMaterialBitmask & FRONT_MATERIAL_BITS)<<1)) - fallback = GL_TRUE; - } - - TCL_FALLBACK( ctx, RADEON_TCL_FALLBACK_LIGHT_TWOSIDE, fallback ); -} - -void radeonColorMaterial( GLcontext *ctx, GLenum face, GLenum mode ) -{ - if (ctx->Light.ColorMaterialEnabled) { - radeonContextPtr rmesa = RADEON_CONTEXT(ctx); - GLuint light_model_ctl = rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL]; - GLuint mask = ctx->Light.ColorMaterialBitmask; - - /* Default to PREMULT: - */ - light_model_ctl &= ~((3 << RADEON_EMISSIVE_SOURCE_SHIFT) | - (3 << RADEON_AMBIENT_SOURCE_SHIFT) | - (3 << RADEON_DIFFUSE_SOURCE_SHIFT) | - (3 << RADEON_SPECULAR_SOURCE_SHIFT)); - - if (mask & FRONT_EMISSION_BIT) { - light_model_ctl |= (RADEON_LM_SOURCE_VERTEX_DIFFUSE << - RADEON_EMISSIVE_SOURCE_SHIFT); - } - - if (mask & FRONT_AMBIENT_BIT) { - light_model_ctl |= (RADEON_LM_SOURCE_VERTEX_DIFFUSE << - RADEON_AMBIENT_SOURCE_SHIFT); - } - - if (mask & FRONT_DIFFUSE_BIT) { - light_model_ctl |= (RADEON_LM_SOURCE_VERTEX_DIFFUSE << - RADEON_DIFFUSE_SOURCE_SHIFT); - } - - if (mask & FRONT_SPECULAR_BIT) { - light_model_ctl |= (RADEON_LM_SOURCE_VERTEX_DIFFUSE << - RADEON_SPECULAR_SOURCE_SHIFT); - } - - if (light_model_ctl != rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL]) { - GLuint p; - - RADEON_STATECHANGE( rmesa, tcl ); - rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] = light_model_ctl; - - for (p = 0 ; p < MAX_LIGHTS; p++) - update_light_colors( ctx, p ); - update_global_ambient( ctx ); - } - } - - check_twoside_fallback( ctx ); -} - -void radeonUpdateMaterial( GLcontext *ctx ) -{ - radeonContextPtr rmesa = RADEON_CONTEXT(ctx); - GLfloat *fcmd = (GLfloat *)RADEON_DB_STATE( mtl ); - GLuint p; - GLuint mask = ~0; - - if (ctx->Light.ColorMaterialEnabled) - mask &= ~ctx->Light.ColorMaterialBitmask; - - if (RADEON_DEBUG & RADEON_STATE) - fprintf(stderr, "%s\n", __FUNCTION__); - - - if (mask & FRONT_EMISSION_BIT) { - fcmd[MTL_EMMISSIVE_RED] = ctx->Light.Material[0].Emission[0]; - fcmd[MTL_EMMISSIVE_GREEN] = ctx->Light.Material[0].Emission[1]; - fcmd[MTL_EMMISSIVE_BLUE] = ctx->Light.Material[0].Emission[2]; - fcmd[MTL_EMMISSIVE_ALPHA] = ctx->Light.Material[0].Emission[3]; - } - if (mask & FRONT_AMBIENT_BIT) { - fcmd[MTL_AMBIENT_RED] = ctx->Light.Material[0].Ambient[0]; - fcmd[MTL_AMBIENT_GREEN] = ctx->Light.Material[0].Ambient[1]; - fcmd[MTL_AMBIENT_BLUE] = ctx->Light.Material[0].Ambient[2]; - fcmd[MTL_AMBIENT_ALPHA] = ctx->Light.Material[0].Ambient[3]; - } - if (mask & FRONT_DIFFUSE_BIT) { - fcmd[MTL_DIFFUSE_RED] = ctx->Light.Material[0].Diffuse[0]; - fcmd[MTL_DIFFUSE_GREEN] = ctx->Light.Material[0].Diffuse[1]; - fcmd[MTL_DIFFUSE_BLUE] = ctx->Light.Material[0].Diffuse[2]; - fcmd[MTL_DIFFUSE_ALPHA] = ctx->Light.Material[0].Diffuse[3]; - } - if (mask & FRONT_SPECULAR_BIT) { - fcmd[MTL_SPECULAR_RED] = ctx->Light.Material[0].Specular[0]; - fcmd[MTL_SPECULAR_GREEN] = ctx->Light.Material[0].Specular[1]; - fcmd[MTL_SPECULAR_BLUE] = ctx->Light.Material[0].Specular[2]; - fcmd[MTL_SPECULAR_ALPHA] = ctx->Light.Material[0].Specular[3]; - } - if (mask & FRONT_SHININESS_BIT) { - fcmd[MTL_SHININESS] = ctx->Light.Material[0].Shininess; - } - - if (RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.mtl )) { - for (p = 0 ; p < MAX_LIGHTS; p++) - update_light_colors( ctx, p ); - - check_twoside_fallback( ctx ); - update_global_ambient( ctx ); - } - else if (RADEON_DEBUG & (RADEON_PRIMS|DEBUG_STATE)) - fprintf(stderr, "%s: Elided noop material call\n", __FUNCTION__); -} - -/* _NEW_LIGHT - * _NEW_MODELVIEW - * _MESA_NEW_NEED_EYE_COORDS - * - * Uses derived state from mesa: - * _VP_inf_norm - * _h_inf_norm - * _Position - * _NormSpotDirection - * _ModelViewInvScale - * _NeedEyeCoords - * _EyeZDir - * - * which are calculated in light.c and are correct for the current - * lighting space (model or eye), hence dependencies on _NEW_MODELVIEW - * and _MESA_NEW_NEED_EYE_COORDS. - */ -void radeonUpdateLighting( GLcontext *ctx ) -{ - radeonContextPtr rmesa = RADEON_CONTEXT(ctx); - - /* Have to check these, or have an automatic shortcircuit mechanism - * to remove noop statechanges. (Or just do a better job on the - * front end). - */ - { - GLuint tmp = rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL]; - - if (ctx->_NeedEyeCoords) - tmp &= ~RADEON_LIGHT_IN_MODELSPACE; - else - tmp |= RADEON_LIGHT_IN_MODELSPACE; - - - /* Leave this test disabled: (unexplained q3 lockup) (even with - new packets) - */ - if (tmp != rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL]) - { - RADEON_STATECHANGE( rmesa, tcl ); - rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] = tmp; - } - } - - { - GLfloat *fcmd = (GLfloat *)RADEON_DB_STATE( eye ); - fcmd[EYE_X] = ctx->_EyeZDir[0]; - fcmd[EYE_Y] = ctx->_EyeZDir[1]; - fcmd[EYE_Z] = - ctx->_EyeZDir[2]; - fcmd[EYE_RESCALE_FACTOR] = ctx->_ModelViewInvScale; - RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.eye ); - } - - -/* RADEON_STATECHANGE( rmesa, glt ); */ - - if (ctx->Light.Enabled) { - GLint p; - for (p = 0 ; p < MAX_LIGHTS; p++) { - if (ctx->Light.Light[p].Enabled) { - struct gl_light *l = &ctx->Light.Light[p]; - GLfloat *fcmd = (GLfloat *)RADEON_DB_STATE( lit[p] ); - - if (l->EyePosition[3] == 0.0) { - COPY_3FV( &fcmd[LIT_POSITION_X], l->_VP_inf_norm ); - COPY_3FV( &fcmd[LIT_DIRECTION_X], l->_h_inf_norm ); - fcmd[LIT_POSITION_W] = 0; - fcmd[LIT_DIRECTION_W] = 0; - } else { - COPY_4V( &fcmd[LIT_POSITION_X], l->_Position ); - fcmd[LIT_DIRECTION_X] = -l->_NormSpotDirection[0]; - fcmd[LIT_DIRECTION_Y] = -l->_NormSpotDirection[1]; - fcmd[LIT_DIRECTION_Z] = -l->_NormSpotDirection[2]; - fcmd[LIT_DIRECTION_W] = 0; - } - - RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.lit[p] ); - } - } - } -} - - -void radeonLightfv( GLcontext *ctx, GLenum light, - GLenum pname, const GLfloat *params ) -{ - radeonContextPtr rmesa = RADEON_CONTEXT(ctx); - GLint p = light - GL_LIGHT0; - struct gl_light *l = &ctx->Light.Light[p]; - GLfloat *fcmd = (GLfloat *)rmesa->hw.lit[p].cmd; - - - switch (pname) { - case GL_AMBIENT: - case GL_DIFFUSE: - case GL_SPECULAR: - update_light_colors( ctx, p ); - break; - - case GL_SPOT_DIRECTION: - /* picked up in update_light */ - break; - - case GL_POSITION: { - /* positions picked up in update_light, but can do flag here */ - GLuint flag = (p&1)? RADEON_LIGHT_1_IS_LOCAL : RADEON_LIGHT_0_IS_LOCAL; - GLuint idx = TCL_PER_LIGHT_CTL_0 + p/2; - - RADEON_STATECHANGE(rmesa, tcl); - if (l->EyePosition[3] != 0.0F) - rmesa->hw.tcl.cmd[idx] |= flag; - else - rmesa->hw.tcl.cmd[idx] &= ~flag; - break; - } - - case GL_SPOT_EXPONENT: - RADEON_STATECHANGE(rmesa, lit[p]); - fcmd[LIT_SPOT_EXPONENT] = params[0]; - break; - - case GL_SPOT_CUTOFF: { - GLuint flag = (p&1) ? RADEON_LIGHT_1_IS_SPOT : RADEON_LIGHT_0_IS_SPOT; - GLuint idx = TCL_PER_LIGHT_CTL_0 + p/2; - - RADEON_STATECHANGE(rmesa, lit[p]); - fcmd[LIT_SPOT_CUTOFF] = l->_CosCutoff; - - RADEON_STATECHANGE(rmesa, tcl); - if (l->SpotCutoff != 180.0F) - rmesa->hw.tcl.cmd[idx] |= flag; - else - rmesa->hw.tcl.cmd[idx] &= ~flag; - break; - } - - case GL_CONSTANT_ATTENUATION: - RADEON_STATECHANGE(rmesa, lit[p]); - fcmd[LIT_ATTEN_CONST] = params[0]; - break; - case GL_LINEAR_ATTENUATION: - RADEON_STATECHANGE(rmesa, lit[p]); - fcmd[LIT_ATTEN_LINEAR] = params[0]; - break; - case GL_QUADRATIC_ATTENUATION: - RADEON_STATECHANGE(rmesa, lit[p]); - fcmd[LIT_ATTEN_QUADRATIC] = params[0]; - break; - default: - return; - } - -} - - - - -void radeonLightModelfv( GLcontext *ctx, GLenum pname, - const GLfloat *param ) -{ - radeonContextPtr rmesa = RADEON_CONTEXT(ctx); - - switch (pname) { - case GL_LIGHT_MODEL_AMBIENT: - update_global_ambient( ctx ); - break; - - case GL_LIGHT_MODEL_LOCAL_VIEWER: - RADEON_STATECHANGE( rmesa, tcl ); - if (ctx->Light.Model.LocalViewer) - rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_LOCAL_VIEWER; - else - rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &= ~RADEON_LOCAL_VIEWER; - break; - - case GL_LIGHT_MODEL_TWO_SIDE: - RADEON_STATECHANGE( rmesa, tcl ); - if (ctx->Light.Model.TwoSide) - rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= RADEON_LIGHT_TWOSIDE; - else - rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] &= ~RADEON_LIGHT_TWOSIDE; - - check_twoside_fallback( ctx ); - -#if _HAVE_SWTNL - if (rmesa->TclFallback) { - radeonChooseRenderState( ctx ); - radeonChooseVertexState( ctx ); - } -#endif - break; - - case GL_LIGHT_MODEL_COLOR_CONTROL: - radeonUpdateSpecular(ctx); - - RADEON_STATECHANGE( rmesa, tcl ); - if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) - rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &= - ~RADEON_DIFFUSE_SPECULAR_COMBINE; - else - rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= - RADEON_DIFFUSE_SPECULAR_COMBINE; - break; - - default: - break; - } -} - - -/* ============================================================= - * Fog - */ - - -static void radeonFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param ) -{ - radeonContextPtr rmesa = RADEON_CONTEXT(ctx); - union { int i; float f; } c, d; - GLchan col[4]; - - c.i = rmesa->hw.fog.cmd[FOG_C]; - d.i = rmesa->hw.fog.cmd[FOG_D]; - - switch (pname) { - case GL_FOG_MODE: - if (!ctx->Fog.Enabled) - return; - RADEON_STATECHANGE(rmesa, tcl); - rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] &= ~RADEON_TCL_FOG_MASK; - switch (ctx->Fog.Mode) { - case GL_LINEAR: - rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= RADEON_TCL_FOG_LINEAR; - if (ctx->Fog.Start == ctx->Fog.End) { - c.f = 1.0F; - d.f = 1.0F; - } - else { - c.f = ctx->Fog.End/(ctx->Fog.End-ctx->Fog.Start); - d.f = 1.0/(ctx->Fog.End-ctx->Fog.Start); - } - break; - case GL_EXP: - rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= RADEON_TCL_FOG_EXP; - c.f = 0.0; - d.f = ctx->Fog.Density; - break; - case GL_EXP2: - rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= RADEON_TCL_FOG_EXP2; - c.f = 0.0; - d.f = -(ctx->Fog.Density * ctx->Fog.Density); - break; - default: - return; - } - break; - case GL_FOG_DENSITY: - switch (ctx->Fog.Mode) { - case GL_EXP: - c.f = 0.0; - d.f = ctx->Fog.Density; - break; - case GL_EXP2: - c.f = 0.0; - d.f = -(ctx->Fog.Density * ctx->Fog.Density); - break; - default: - break; - } - break; - case GL_FOG_START: - case GL_FOG_END: - if (ctx->Fog.Mode == GL_LINEAR) { - if (ctx->Fog.Start == ctx->Fog.End) { - c.f = 1.0F; - d.f = 1.0F; - } else { - c.f = ctx->Fog.End/(ctx->Fog.End-ctx->Fog.Start); - d.f = 1.0/(ctx->Fog.End-ctx->Fog.Start); - } - } - break; - case GL_FOG_COLOR: - RADEON_STATECHANGE( rmesa, ctx ); - UNCLAMPED_FLOAT_TO_RGB_CHAN( col, ctx->Fog.Color ); - rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] = - radeonPackColor( 4, col[0], col[1], col[2], 0 ); - break; - case GL_FOG_COORDINATE_SOURCE_EXT: - /* What to do? - */ - break; - default: - return; - } - - if (c.i != rmesa->hw.fog.cmd[FOG_C] || d.i != rmesa->hw.fog.cmd[FOG_D]) { - RADEON_STATECHANGE( rmesa, fog ); - rmesa->hw.fog.cmd[FOG_C] = c.i; - rmesa->hw.fog.cmd[FOG_D] = d.i; - } -} - -/* Examine lighting and texture state to determine if separate specular - * should be enabled. - */ -void radeonUpdateSpecular( GLcontext *ctx ) -{ - radeonContextPtr rmesa = RADEON_CONTEXT(ctx); - GLuint p = rmesa->hw.ctx.cmd[CTX_PP_CNTL]; - - if (NEED_SECONDARY_COLOR(ctx)) { - p |= RADEON_SPECULAR_ENABLE; - } else { - p &= ~RADEON_SPECULAR_ENABLE; - } - - if ( rmesa->hw.ctx.cmd[CTX_PP_CNTL] != p ) { - RADEON_STATECHANGE( rmesa, ctx ); - rmesa->hw.ctx.cmd[CTX_PP_CNTL] = p; - } - - /* Bizzare: have to leave lighting enabled to get fog. - */ - RADEON_STATECHANGE( rmesa, tcl ); - if ((ctx->Light.Enabled && - ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)) { - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] |= RADEON_TCL_COMPUTE_SPECULAR; - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] |= RADEON_TCL_COMPUTE_DIFFUSE; - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_SPEC; - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_DIFFUSE; - rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_LIGHTING_ENABLE; - } - else if (ctx->Fog.Enabled) { - if (ctx->Light.Enabled) { - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] |= RADEON_TCL_COMPUTE_SPECULAR; - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] |= RADEON_TCL_COMPUTE_DIFFUSE; - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_SPEC; - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_DIFFUSE; - rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_LIGHTING_ENABLE; - } else { - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] |= RADEON_TCL_COMPUTE_SPECULAR; - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] &= ~RADEON_TCL_COMPUTE_DIFFUSE; - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_SPEC; - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_DIFFUSE; - rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_LIGHTING_ENABLE; - } - } - else if (ctx->Light.Enabled) { - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] &= ~RADEON_TCL_COMPUTE_SPECULAR; - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] |= RADEON_TCL_COMPUTE_DIFFUSE; - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] &= ~RADEON_TCL_VTX_PK_SPEC; - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_DIFFUSE; - rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_LIGHTING_ENABLE; - } else if (ctx->Fog.ColorSumEnabled ) { - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] &= ~RADEON_TCL_COMPUTE_SPECULAR; - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] &= ~RADEON_TCL_COMPUTE_DIFFUSE; - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_SPEC; - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_DIFFUSE; - rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &= ~RADEON_LIGHTING_ENABLE; - } else { - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] &= ~RADEON_TCL_COMPUTE_SPECULAR; - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] &= ~RADEON_TCL_COMPUTE_DIFFUSE; - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] &= ~RADEON_TCL_VTX_PK_SPEC; - rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_DIFFUSE; - rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &= ~RADEON_LIGHTING_ENABLE; - } - -#if _HAVE_SWTNL - /* Update vertex/render formats - */ - if (rmesa->TclFallback) { - radeonChooseRenderState( ctx ); - radeonChooseVertexState( ctx ); - } -#endif -} - - - -static void radeonLightingSpaceChange( GLcontext *ctx ) -{ - radeonContextPtr rmesa = RADEON_CONTEXT(ctx); - GLboolean tmp; - RADEON_STATECHANGE( rmesa, tcl ); - - if (RADEON_DEBUG & RADEON_STATE) - fprintf(stderr, "%s %d\n", __FUNCTION__, ctx->_NeedEyeCoords); - - if (ctx->_NeedEyeCoords) - tmp = ctx->Transform.RescaleNormals; - else - tmp = !ctx->Transform.RescaleNormals; - - if ( tmp ) { - rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_RESCALE_NORMALS; - } else { - rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &= ~RADEON_RESCALE_NORMALS; - } -} - -void radeonInitLightStateFuncs( GLcontext *ctx ) -{ - radeonContextPtr rmesa = RADEON_CONTEXT(ctx); - int i; - - ctx->Driver.LightModelfv = radeonLightModelfv; - ctx->Driver.Lightfv = radeonLightfv; - ctx->Driver.Fogfv = radeonFogfv; - ctx->Driver.LightingSpaceChange = radeonLightingSpaceChange; - - for (i = 0 ; i < 8; i++) { - struct gl_light *l = &ctx->Light.Light[i]; - GLenum p = GL_LIGHT0 + i; - *(float *)&(rmesa->hw.lit[i].cmd[LIT_RANGE_CUTOFF]) = FLT_MAX; - - ctx->Driver.Lightfv( ctx, p, GL_AMBIENT, l->Ambient ); - ctx->Driver.Lightfv( ctx, p, GL_DIFFUSE, l->Diffuse ); - ctx->Driver.Lightfv( ctx, p, GL_SPECULAR, l->Specular ); - ctx->Driver.Lightfv( ctx, p, GL_POSITION, 0 ); - ctx->Driver.Lightfv( ctx, p, GL_SPOT_DIRECTION, 0 ); - ctx->Driver.Lightfv( ctx, p, GL_SPOT_EXPONENT, &l->SpotExponent ); - ctx->Driver.Lightfv( ctx, p, GL_SPOT_CUTOFF, &l->SpotCutoff ); - ctx->Driver.Lightfv( ctx, p, GL_CONSTANT_ATTENUATION, - &l->ConstantAttenuation ); - ctx->Driver.Lightfv( ctx, p, GL_LINEAR_ATTENUATION, - &l->LinearAttenuation ); - ctx->Driver.Lightfv( ctx, p, GL_QUADRATIC_ATTENUATION, - &l->QuadraticAttenuation ); - } - - ctx->Driver.LightModelfv( ctx, GL_LIGHT_MODEL_AMBIENT, - ctx->Light.Model.Ambient ); - - ctx->Driver.Fogfv( ctx, GL_FOG_MODE, 0 ); - ctx->Driver.Fogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density ); - ctx->Driver.Fogfv( ctx, GL_FOG_START, &ctx->Fog.Start ); - ctx->Driver.Fogfv( ctx, GL_FOG_END, &ctx->Fog.End ); - ctx->Driver.Fogfv( ctx, GL_FOG_COLOR, ctx->Fog.Color ); - ctx->Driver.Fogfv( ctx, GL_FOG_COORDINATE_SOURCE_EXT, 0 ); -} -- cgit v1.2.3 From 395e08a839bca94b8c0cd7fca4b48bb06bc02952 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 27 Jan 2010 11:46:26 +1000 Subject: radeon/r200/r300: don't clean non-emitted state. So if we don't actually emit an atom to the hw because we don't need it in the current state (e.g. lighting related atoms when lighting is off) then don't mark it as clean, because when lighting gets switched on we won't emit it at all. This fixes funky gears colors. Signed-off-by: Dave Airlie --- src/mesa/drivers/dri/radeon/radeon_common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/radeon/radeon_common.c b/src/mesa/drivers/dri/radeon/radeon_common.c index e0b853bc97..79f3ff7da6 100644 --- a/src/mesa/drivers/dri/radeon/radeon_common.c +++ b/src/mesa/drivers/dri/radeon/radeon_common.c @@ -1036,10 +1036,11 @@ static INLINE void radeon_emit_atom(radeonContextPtr radeon, struct radeon_state OUT_BATCH_TABLE(atom->cmd, dwords); END_BATCH(); } + atom->dirty = GL_FALSE; + } else { radeon_print(RADEON_STATE, RADEON_VERBOSE, " skip state %s\n", atom->name); } - atom->dirty = GL_FALSE; } -- cgit v1.2.3 From 15e283669aa8832347b4733f9556efdb5692640e Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Tue, 26 Jan 2010 20:11:39 -0800 Subject: r300g: Add A8_UNORM texture format. Keeps teeworld happy. --- src/gallium/drivers/r300/r300_screen.c | 1 + src/gallium/drivers/r300/r300_texture.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index 67325c6b80..a4a0e52815 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -219,6 +219,7 @@ static boolean r300_is_format_supported(struct pipe_screen* screen, case PIPE_FORMAT_DXT5_RGBA: case PIPE_FORMAT_YCBCR: case PIPE_FORMAT_L8_UNORM: + case PIPE_FORMAT_A8_UNORM: case PIPE_FORMAT_A8L8_UNORM: retval = usage & PIPE_TEXTURE_USAGE_SAMPLER; break; diff --git a/src/gallium/drivers/r300/r300_texture.h b/src/gallium/drivers/r300/r300_texture.h index 1be1e6843c..453fb1accc 100644 --- a/src/gallium/drivers/r300/r300_texture.h +++ b/src/gallium/drivers/r300/r300_texture.h @@ -42,6 +42,7 @@ static INLINE uint32_t r300_translate_texformat(enum pipe_format format) { switch (format) { /* X8 */ + case PIPE_FORMAT_A8_UNORM: case PIPE_FORMAT_I8_UNORM: return R300_EASY_TX_FORMAT(X, X, X, X, X8); case PIPE_FORMAT_L8_UNORM: -- cgit v1.2.3 From e62520de70731b39bb34411372eb3d30638cf5a6 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Tue, 26 Jan 2010 21:41:44 -0800 Subject: r300g: Kill dead code for hashing custom state. It just wasn't meant to be. --- src/gallium/drivers/r300/r300_context.c | 16 --------- src/gallium/drivers/r300/r300_context.h | 3 -- src/gallium/drivers/r300/r300_state_derived.c | 52 --------------------------- 3 files changed, 71 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 3bf9c8b18d..5a689e0bd7 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -40,25 +40,12 @@ #include "r300_texture.h" #include "r300_winsys.h" -static enum pipe_error r300_clear_hash_table(void* key, void* value, - void* data) -{ - FREE(key); - FREE(value); - return PIPE_OK; -} - static void r300_destroy_context(struct pipe_context* context) { struct r300_context* r300 = r300_context(context); struct r300_query* query, * temp; util_blitter_destroy(r300->blitter); - - util_hash_table_foreach(r300->shader_hash_table, r300_clear_hash_table, - NULL); - util_hash_table_destroy(r300->shader_hash_table); - draw_destroy(r300->draw); /* Free the OQ BO. */ @@ -183,9 +170,6 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, r300->context.is_texture_referenced = r300_is_texture_referenced; r300->context.is_buffer_referenced = r300_is_buffer_referenced; - r300->shader_hash_table = util_hash_table_create(r300_shader_key_hash, - r300_shader_key_compare); - r300_setup_atoms(r300); r300->blend_color_state.state = CALLOC_STRUCT(r300_blend_color_state); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 48c86fdad7..a25e46afaa 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -272,9 +272,6 @@ struct r300_context { struct r300_query *query_current; struct r300_query query_list; - /* Shader hash table. Used to store vertex formatting information, which - * depends on the combination of both currently loaded shaders. */ - struct util_hash_table* shader_hash_table; /* Vertex formatting information. */ struct r300_vertex_info* vertex_info; diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 99c2720897..45a3e93df1 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -37,32 +37,6 @@ /* r300_state_derived: Various bits of state which are dependent upon * currently bound CSO data. */ -struct r300_shader_key { - struct r300_vertex_shader* vs; - struct r300_fragment_shader* fs; -}; - -struct r300_shader_derived_value { - struct r300_vertex_format* vformat; - struct r300_rs_block* rs_block; -}; - -unsigned r300_shader_key_hash(void* key) { - struct r300_shader_key* shader_key = (struct r300_shader_key*)key; - unsigned vs = (intptr_t)shader_key->vs; - unsigned fs = (intptr_t)shader_key->fs; - - return (vs << 16) | (fs & 0xffff); -} - -int r300_shader_key_compare(void* key1, void* key2) { - struct r300_shader_key* shader_key1 = (struct r300_shader_key*)key1; - struct r300_shader_key* shader_key2 = (struct r300_shader_key*)key2; - - return (shader_key1->vs == shader_key2->vs) && - (shader_key1->fs == shader_key2->fs); -} - static void r300_draw_emit_attrib(struct r300_context* r300, enum attrib_emit emit, enum interp_mode interp, @@ -440,32 +414,6 @@ static void r300_update_derived_shader_state(struct r300_context* r300) { struct r300_screen* r300screen = r300_screen(r300->context.screen); - /* - struct r300_shader_key* key; - struct r300_shader_derived_value* value; - key = CALLOC_STRUCT(r300_shader_key); - key->vs = r300->vs; - key->fs = r300->fs; - - value = (struct r300_shader_derived_value*) - util_hash_table_get(r300->shader_hash_table, (void*)key); - if (value) { - //vformat = value->vformat; - rs_block = value->rs_block; - - FREE(key); - } else { - rs_block = CALLOC_STRUCT(r300_rs_block); - value = CALLOC_STRUCT(r300_shader_derived_value); - - r300_update_rs_block(r300, rs_block); - - //value->vformat = vformat; - value->rs_block = rs_block; - util_hash_table_set(r300->shader_hash_table, - (void*)key, (void*)value); - } */ - /* Reset structures */ memset(r300->rs_block, 0, sizeof(struct r300_rs_block)); memset(r300->vertex_info, 0, sizeof(struct r300_vertex_info)); -- cgit v1.2.3 From 60aa7f1f8042a9291339a3b337a2f1adacf12841 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Tue, 26 Jan 2010 21:49:02 -0800 Subject: r300g: Make vertex_format into an atom. Some delicious hax here. --- src/gallium/drivers/r300/r300_context.c | 5 +++-- src/gallium/drivers/r300/r300_context.h | 3 +-- src/gallium/drivers/r300/r300_emit.c | 30 ++++++++++++--------------- src/gallium/drivers/r300/r300_emit.h | 2 +- src/gallium/drivers/r300/r300_render.c | 2 +- src/gallium/drivers/r300/r300_state.c | 9 ++++---- src/gallium/drivers/r300/r300_state_derived.c | 25 +++++++++++++++------- 7 files changed, 41 insertions(+), 35 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 5a689e0bd7..1460778ece 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -61,7 +61,7 @@ static void r300_destroy_context(struct pipe_context* context) FREE(r300->clip_state.state); FREE(r300->rs_block); FREE(r300->scissor_state.state); - FREE(r300->vertex_info); + FREE(r300->vertex_format_state.state); FREE(r300->viewport_state.state); FREE(r300->ztop_state.state); FREE(r300); @@ -125,6 +125,7 @@ static void r300_setup_atoms(struct r300_context* r300) R300_INIT_ATOM(rs, 25); R300_INIT_ATOM(scissor, 3); R300_INIT_ATOM(viewport, 9); + R300_INIT_ATOM(vertex_format, 26); } struct pipe_context* r300_create_context(struct pipe_screen* screen, @@ -176,7 +177,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, r300->clip_state.state = CALLOC_STRUCT(pipe_clip_state); r300->rs_block = CALLOC_STRUCT(r300_rs_block); r300->scissor_state.state = CALLOC_STRUCT(pipe_scissor_state); - r300->vertex_info = CALLOC_STRUCT(r300_vertex_info); + r300->vertex_format_state.state = CALLOC_STRUCT(r300_vertex_info); r300->viewport_state.state = CALLOC_STRUCT(r300_viewport_state); r300->ztop_state.state = CALLOC_STRUCT(r300_ztop_state); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index a25e46afaa..407891e175 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -147,7 +147,6 @@ struct r300_ztop_state { #define R300_ANY_NEW_SAMPLERS 0x0001fe00 #define R300_NEW_TEXTURE 0x00040000 #define R300_ANY_NEW_TEXTURES 0x03fc0000 -#define R300_NEW_VERTEX_FORMAT 0x04000000 #define R300_NEW_VERTEX_SHADER 0x08000000 #define R300_NEW_VERTEX_SHADER_CONSTANTS 0x10000000 #define R300_NEW_QUERY 0x40000000 @@ -273,7 +272,7 @@ struct r300_context { struct r300_query query_list; /* Vertex formatting information. */ - struct r300_vertex_info* vertex_info; + struct r300_atom vertex_format_state; /* Various CSO state objects. */ /* Beginning of atom list. */ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index badbf3715c..8081f1d956 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -812,38 +812,39 @@ void r300_emit_aos(struct r300_context* r300, unsigned offset) END_CS; } -void r300_emit_vertex_format_state(struct r300_context* r300) +void r300_emit_vertex_format_state(struct r300_context* r300, void* state) { - int i; + struct r300_vertex_info* vertex_info = (struct r300_vertex_info*)state; + unsigned i; CS_LOCALS(r300); DBG(r300, DBG_DRAW, "r300: VAP/PSC emit:\n"); BEGIN_CS(26); - OUT_CS_REG(R300_VAP_VTX_SIZE, r300->vertex_info->vinfo.size); + OUT_CS_REG(R300_VAP_VTX_SIZE, vertex_info->vinfo.size); OUT_CS_REG_SEQ(R300_VAP_VTX_STATE_CNTL, 2); - OUT_CS(r300->vertex_info->vinfo.hwfmt[0]); - OUT_CS(r300->vertex_info->vinfo.hwfmt[1]); + OUT_CS(vertex_info->vinfo.hwfmt[0]); + OUT_CS(vertex_info->vinfo.hwfmt[1]); OUT_CS_REG_SEQ(R300_VAP_OUTPUT_VTX_FMT_0, 2); - OUT_CS(r300->vertex_info->vinfo.hwfmt[2]); - OUT_CS(r300->vertex_info->vinfo.hwfmt[3]); + OUT_CS(vertex_info->vinfo.hwfmt[2]); + OUT_CS(vertex_info->vinfo.hwfmt[3]); for (i = 0; i < 4; i++) { DBG(r300, DBG_DRAW, " : hwfmt%d: 0x%08x\n", i, - r300->vertex_info->vinfo.hwfmt[i]); + vertex_info->vinfo.hwfmt[i]); } OUT_CS_REG_SEQ(R300_VAP_PROG_STREAM_CNTL_0, 8); for (i = 0; i < 8; i++) { - OUT_CS(r300->vertex_info->vap_prog_stream_cntl[i]); + OUT_CS(vertex_info->vap_prog_stream_cntl[i]); DBG(r300, DBG_DRAW, " : prog_stream_cntl%d: 0x%08x\n", i, - r300->vertex_info->vap_prog_stream_cntl[i]); + vertex_info->vap_prog_stream_cntl[i]); } OUT_CS_REG_SEQ(R300_VAP_PROG_STREAM_CNTL_EXT_0, 8); for (i = 0; i < 8; i++) { - OUT_CS(r300->vertex_info->vap_prog_stream_cntl_ext[i]); + OUT_CS(vertex_info->vap_prog_stream_cntl_ext[i]); DBG(r300, DBG_DRAW, " : prog_stream_cntl_ext%d: 0x%08x\n", i, - r300->vertex_info->vap_prog_stream_cntl_ext[i]); + vertex_info->vap_prog_stream_cntl_ext[i]); } END_CS; } @@ -1171,11 +1172,6 @@ void r300_emit_dirty_state(struct r300_context* r300) r300_flush_textures(r300); } - if (r300->dirty_state & R300_NEW_VERTEX_FORMAT) { - r300_emit_vertex_format_state(r300); - r300->dirty_state &= ~R300_NEW_VERTEX_FORMAT; - } - if (r300->dirty_state & (R300_NEW_VERTEX_SHADER | R300_NEW_VERTEX_SHADER_CONSTANTS)) { r300_flush_pvs(r300); } diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index 2f3d013f5e..6788e3d655 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -73,7 +73,7 @@ void r300_emit_texture(struct r300_context* r300, void r300_emit_vertex_buffer(struct r300_context* r300); -void r300_emit_vertex_format_state(struct r300_context* r300); +void r300_emit_vertex_format_state(struct r300_context* r300, void* state); void r300_emit_vertex_program_code(struct r300_context* r300, struct r300_vertex_program_code* code); diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index dcd0761944..354f3bb921 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -556,7 +556,7 @@ r300_render_get_vertex_info(struct vbuf_render* render) r300_update_derived_state(r300); - return &r300->vertex_info->vinfo; + return (struct vertex_info*)r300->vertex_format_state.state; } static boolean r300_render_allocate_vertices(struct vbuf_render* render, diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 641e95e7fc..7068a5a4ec 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -552,7 +552,7 @@ static void r300_bind_fs_state(struct pipe_context* pipe, void* shader) r300_pick_fragment_shader(r300); if (r300->vs && r300_vertex_shader_setup_wpos(r300)) { - r300->dirty_state |= R300_NEW_VERTEX_FORMAT; + r300->vertex_format_state.dirty = TRUE; } r300->dirty_state |= R300_NEW_FRAGMENT_SHADER | R300_NEW_FRAGMENT_SHADER_CONSTANTS; @@ -921,7 +921,7 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe, draw_set_vertex_buffers(r300->draw, count, buffers); } - r300->dirty_state |= R300_NEW_VERTEX_FORMAT; + r300->vertex_format_state.dirty = TRUE; } static boolean r300_validate_aos(struct r300_context *r300) @@ -1001,9 +1001,10 @@ static void r300_bind_vs_state(struct pipe_context* pipe, void* shader) r300_vertex_shader_setup_wpos(r300); } + r300->vertex_format_state.dirty = TRUE; + r300->dirty_state |= - R300_NEW_VERTEX_SHADER | R300_NEW_VERTEX_SHADER_CONSTANTS | - R300_NEW_VERTEX_FORMAT; + R300_NEW_VERTEX_SHADER | R300_NEW_VERTEX_SHADER_CONSTANTS; } else { draw_flush(r300->draw); draw_bind_vertex_shader(r300->draw, diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 45a3e93df1..1a1eabe5fb 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -48,7 +48,9 @@ static void r300_draw_emit_attrib(struct r300_context* r300, output = draw_find_shader_output(r300->draw, info->output_semantic_name[index], info->output_semantic_index[index]); - draw_emit_vertex_attr(&r300->vertex_info->vinfo, emit, interp, output); + draw_emit_vertex_attr( + (struct vertex_info*)r300->vertex_format_state.state, + emit, interp, output); } static void r300_draw_emit_all_attribs(struct r300_context* r300) @@ -104,7 +106,8 @@ static void r300_draw_emit_all_attribs(struct r300_context* r300) /* Update the PSC tables. */ static void r300_vertex_psc(struct r300_context* r300) { - struct r300_vertex_info *vformat = r300->vertex_info; + struct r300_vertex_info *vformat = + (struct r300_vertex_info*)r300->vertex_format_state.state; uint16_t type, swizzle; enum pipe_format format; unsigned i; @@ -156,7 +159,8 @@ static void r300_vertex_psc(struct r300_context* r300) /* Update the PSC tables for SW TCL, using Draw. */ static void r300_swtcl_vertex_psc(struct r300_context* r300) { - struct r300_vertex_info *vformat = r300->vertex_info; + struct r300_vertex_info *vformat = + (struct r300_vertex_info*)r300->vertex_format_state.state; struct vertex_info* vinfo = &vformat->vinfo; uint16_t type, swizzle; enum pipe_format format; @@ -413,11 +417,15 @@ static void r300_update_rs_block(struct r300_context* r300, static void r300_update_derived_shader_state(struct r300_context* r300) { struct r300_screen* r300screen = r300_screen(r300->context.screen); + struct r300_vertex_info *vformat = + (struct r300_vertex_info*)r300->vertex_format_state.state; + struct vertex_info* vinfo = &vformat->vinfo; /* Reset structures */ memset(r300->rs_block, 0, sizeof(struct r300_rs_block)); - memset(r300->vertex_info, 0, sizeof(struct r300_vertex_info)); - memcpy(r300->vertex_info->vinfo.hwfmt, r300->vs->hwfmt, sizeof(uint)*4); + /* Mmm, delicious hax */ + memset(r300->vertex_format_state.state, 0, sizeof(struct r300_vertex_info)); + memcpy(vinfo->hwfmt, r300->vs->hwfmt, sizeof(uint)*4); r300_update_rs_block(r300, &r300->vs->outputs, &r300->fs->inputs); @@ -425,7 +433,8 @@ static void r300_update_derived_shader_state(struct r300_context* r300) r300_vertex_psc(r300); } else { r300_draw_emit_all_attribs(r300); - draw_compute_vertex_size(&r300->vertex_info->vinfo); + draw_compute_vertex_size( + (struct vertex_info*)r300->vertex_format_state.state); r300_swtcl_vertex_psc(r300); } @@ -507,8 +516,8 @@ void r300_update_derived_state(struct r300_context* r300) { /* XXX */ if (r300->dirty_state & - (R300_NEW_FRAGMENT_SHADER | R300_NEW_VERTEX_SHADER | - R300_NEW_VERTEX_FORMAT) || r300->rs_state.dirty) { + (R300_NEW_FRAGMENT_SHADER | R300_NEW_VERTEX_SHADER) || + r300->vertex_format_state.dirty || r300->rs_state.dirty) { r300_update_derived_shader_state(r300); } -- cgit v1.2.3 From fc20efe8e511bb9ec15c3d70e28b348ddaa4ad37 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Tue, 26 Jan 2010 22:08:11 -0800 Subject: r300g: Turn the RS block into an atom. At least one extraneous dirty was eliminated, as well as the chance for avoiding dirty on shader change. --- src/gallium/drivers/r300/r300_context.c | 5 ++-- src/gallium/drivers/r300/r300_context.h | 3 +-- src/gallium/drivers/r300/r300_emit.c | 11 +++----- src/gallium/drivers/r300/r300_emit.h | 3 +-- src/gallium/drivers/r300/r300_state.c | 1 - src/gallium/drivers/r300/r300_state_derived.c | 36 ++++++++++++++------------- 6 files changed, 27 insertions(+), 32 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 1460778ece..052cc23a77 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -59,7 +59,7 @@ static void r300_destroy_context(struct pipe_context* context) FREE(r300->blend_color_state.state); FREE(r300->clip_state.state); - FREE(r300->rs_block); + FREE(r300->rs_block_state.state); FREE(r300->scissor_state.state); FREE(r300->vertex_format_state.state); FREE(r300->viewport_state.state); @@ -125,6 +125,7 @@ static void r300_setup_atoms(struct r300_context* r300) R300_INIT_ATOM(rs, 25); R300_INIT_ATOM(scissor, 3); R300_INIT_ATOM(viewport, 9); + R300_INIT_ATOM(rs_block, 21); R300_INIT_ATOM(vertex_format, 26); } @@ -175,7 +176,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, r300->blend_color_state.state = CALLOC_STRUCT(r300_blend_color_state); r300->clip_state.state = CALLOC_STRUCT(pipe_clip_state); - r300->rs_block = CALLOC_STRUCT(r300_rs_block); + r300->rs_block_state.state = CALLOC_STRUCT(r300_rs_block); r300->scissor_state.state = CALLOC_STRUCT(pipe_scissor_state); r300->vertex_format_state.state = CALLOC_STRUCT(r300_vertex_info); r300->viewport_state.state = CALLOC_STRUCT(r300_viewport_state); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 407891e175..c4c137d6f8 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -142,7 +142,6 @@ struct r300_ztop_state { #define R300_NEW_FRAMEBUFFERS 0x00000010 #define R300_NEW_FRAGMENT_SHADER 0x00000020 #define R300_NEW_FRAGMENT_SHADER_CONSTANTS 0x00000040 -#define R300_NEW_RS_BLOCK 0x00000100 #define R300_NEW_SAMPLER 0x00000200 #define R300_ANY_NEW_SAMPLERS 0x0001fe00 #define R300_NEW_TEXTURE 0x00040000 @@ -294,7 +293,7 @@ struct r300_context { /* Rasterizer state. */ struct r300_atom rs_state; /* RS block state. */ - struct r300_rs_block* rs_block; + struct r300_atom rs_block_state; /* Sampler states. */ struct r300_sampler_state* sampler_states[8]; int sampler_count; diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 8081f1d956..8bc9da9361 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -627,10 +627,10 @@ void r300_emit_rs_state(struct r300_context* r300, void* state) END_CS; } -void r300_emit_rs_block_state(struct r300_context* r300, - struct r300_rs_block* rs) +void r300_emit_rs_block_state(struct r300_context* r300, void* state) { - int i; + struct r300_rs_block* rs = (struct r300_rs_block*)state; + unsigned i; struct r300_screen* r300screen = r300_screen(r300->context.screen); CS_LOCALS(r300); @@ -1142,11 +1142,6 @@ void r300_emit_dirty_state(struct r300_context* r300) r300->dirty_state &= ~R300_NEW_FRAMEBUFFERS; } - if (r300->dirty_state & R300_NEW_RS_BLOCK) { - r300_emit_rs_block_state(r300, r300->rs_block); - r300->dirty_state &= ~R300_NEW_RS_BLOCK; - } - /* Samplers and textures are tracked separately but emitted together. */ if (r300->dirty_state & (R300_ANY_NEW_SAMPLERS | R300_ANY_NEW_TEXTURES)) { diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index 6788e3d655..c6dbc5af1e 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -61,8 +61,7 @@ void r300_emit_query_end(struct r300_context* r300); void r300_emit_rs_state(struct r300_context* r300, void* state); -void r300_emit_rs_block_state(struct r300_context* r300, - struct r300_rs_block* rs); +void r300_emit_rs_block_state(struct r300_context* r300, void* state); void r300_emit_scissor_state(struct r300_context* r300, void* state); diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 7068a5a4ec..f3acd16579 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -720,7 +720,6 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state) r300->viewport_state.dirty = TRUE; /* XXX Clean these up when we move to atom emits */ - r300->dirty_state |= R300_NEW_RS_BLOCK; if (r300->fs && r300->fs->inputs.wpos != ATTR_UNUSED) { r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS; } diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 1a1eabe5fb..a351c9d01b 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -305,7 +305,7 @@ static void r300_update_rs_block(struct r300_context* r300, struct r300_shader_semantics* vs_outputs, struct r300_shader_semantics* fs_inputs) { - struct r300_rs_block* rs = r300->rs_block; + struct r300_rs_block rs = { 0 }; int i, col_count = 0, tex_count = 0, fp_offset = 0; void (*rX00_rs_col)(struct r300_rs_block*, int, int, boolean); void (*rX00_rs_col_write)(struct r300_rs_block*, int, int); @@ -332,11 +332,11 @@ static void r300_update_rs_block(struct r300_context* r300, vs_outputs->color[1] != ATTR_UNUSED) { /* Always rasterize if it's written by the VS, * otherwise it locks up. */ - rX00_rs_col(rs, col_count, i, FALSE); + rX00_rs_col(&rs, col_count, i, FALSE); /* Write it to the FS input register if it's used by the FS. */ if (fs_inputs->color[i] != ATTR_UNUSED) { - rX00_rs_col_write(rs, col_count, fp_offset); + rX00_rs_col_write(&rs, col_count, fp_offset); fp_offset++; } col_count++; @@ -354,11 +354,11 @@ static void r300_update_rs_block(struct r300_context* r300, if (vs_outputs->generic[i] != ATTR_UNUSED) { /* Always rasterize if it's written by the VS, * otherwise it locks up. */ - rX00_rs_tex(rs, tex_count, tex_count, FALSE); + rX00_rs_tex(&rs, tex_count, tex_count, FALSE); /* Write it to the FS input register if it's used by the FS. */ if (fs_inputs->generic[i] != ATTR_UNUSED) { - rX00_rs_tex_write(rs, tex_count, fp_offset); + rX00_rs_tex_write(&rs, tex_count, fp_offset); fp_offset++; } tex_count++; @@ -375,11 +375,11 @@ static void r300_update_rs_block(struct r300_context* r300, if (vs_outputs->fog != ATTR_UNUSED) { /* Always rasterize if it's written by the VS, * otherwise it locks up. */ - rX00_rs_tex(rs, tex_count, tex_count, TRUE); + rX00_rs_tex(&rs, tex_count, tex_count, TRUE); /* Write it to the FS input register if it's used by the FS. */ if (fs_inputs->fog != ATTR_UNUSED) { - rX00_rs_tex_write(rs, tex_count, fp_offset); + rX00_rs_tex_write(&rs, tex_count, fp_offset); fp_offset++; } tex_count++; @@ -394,8 +394,8 @@ static void r300_update_rs_block(struct r300_context* r300, /* Rasterize WPOS. */ /* If the FS doesn't need it, it's not written by the VS. */ if (fs_inputs->wpos != ATTR_UNUSED) { - rX00_rs_tex(rs, tex_count, tex_count, FALSE); - rX00_rs_tex_write(rs, tex_count, fp_offset); + rX00_rs_tex(&rs, tex_count, tex_count, FALSE); + rX00_rs_tex_write(&rs, tex_count, fp_offset); fp_offset++; tex_count++; @@ -403,17 +403,23 @@ static void r300_update_rs_block(struct r300_context* r300, /* Rasterize at least one color, or bad things happen. */ if (col_count == 0 && tex_count == 0) { - rX00_rs_col(rs, 0, 0, TRUE); + rX00_rs_col(&rs, 0, 0, TRUE); col_count++; } - rs->count = (tex_count*4) | (col_count << R300_IC_COUNT_SHIFT) | + rs.count = (tex_count*4) | (col_count << R300_IC_COUNT_SHIFT) | R300_HIRES_EN; - rs->inst_count = MAX3(col_count - 1, tex_count - 1, 0); + rs.inst_count = MAX3(col_count - 1, tex_count - 1, 0); + + /* Now, after all that, see if we actually need to update the state. */ + if (memcmp(r300->rs_block_state.state, &rs, sizeof(struct r300_rs_block))) { + memcpy(r300->rs_block_state.state, &rs, sizeof(struct r300_rs_block)); + r300->rs_block_state.dirty = TRUE; + } } -/* Update the vertex format. */ +/* Update the shader-dependant states. */ static void r300_update_derived_shader_state(struct r300_context* r300) { struct r300_screen* r300screen = r300_screen(r300->context.screen); @@ -421,8 +427,6 @@ static void r300_update_derived_shader_state(struct r300_context* r300) (struct r300_vertex_info*)r300->vertex_format_state.state; struct vertex_info* vinfo = &vformat->vinfo; - /* Reset structures */ - memset(r300->rs_block, 0, sizeof(struct r300_rs_block)); /* Mmm, delicious hax */ memset(r300->vertex_format_state.state, 0, sizeof(struct r300_vertex_info)); memcpy(vinfo->hwfmt, r300->vs->hwfmt, sizeof(uint)*4); @@ -437,8 +441,6 @@ static void r300_update_derived_shader_state(struct r300_context* r300) (struct vertex_info*)r300->vertex_format_state.state); r300_swtcl_vertex_psc(r300); } - - r300->dirty_state |= R300_NEW_RS_BLOCK; } static boolean r300_dsa_writes_depth_stencil(struct r300_dsa_state* dsa) -- cgit v1.2.3 From 7d29afb3a29642e6e13fb30948f7c87434057102 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Tue, 26 Jan 2010 22:56:58 -0800 Subject: scons: Use '-Werror=' option on GCC 4.2.x and greater. The existing code only checked for GCC 4.2.x and 4.3.x. --- scons/gallium.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scons/gallium.py b/scons/gallium.py index 5aa0b7bddd..c88af96898 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -30,6 +30,7 @@ Frontend-tool for Gallium3D architecture. # +import distutils.version import os import os.path import re @@ -276,7 +277,7 @@ def generate(env): '-Wmissing-prototypes', '-std=gnu99', ] - if env['CCVERSION'].startswith('4.2.') or env['CCVERSION'].startswith('4.3.'): + if distutils.version.LooseVersion(env['CCVERSION']) >= distutils.version.LooseVersion('4.2'): ccflags += [ '-Werror=pointer-arith', ] -- cgit v1.2.3 From aa2423b5b32735b5d71a71546b8b0300aab3c1b8 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Tue, 26 Jan 2010 23:26:41 -0800 Subject: i915g: Remove unnecessary headers. --- src/gallium/drivers/i915/i915_surface.c | 2 -- src/gallium/drivers/i915/i915_texture.c | 1 - 2 files changed, 3 deletions(-) diff --git a/src/gallium/drivers/i915/i915_surface.c b/src/gallium/drivers/i915/i915_surface.c index 13684aa59c..1ff6b9f4c6 100644 --- a/src/gallium/drivers/i915/i915_surface.c +++ b/src/gallium/drivers/i915/i915_surface.c @@ -28,8 +28,6 @@ #include "i915_context.h" #include "i915_blit.h" #include "pipe/p_defines.h" -#include "pipe/p_inlines.h" -#include "pipe/internal/p_winsys_screen.h" #include "util/u_format.h" diff --git a/src/gallium/drivers/i915/i915_texture.c b/src/gallium/drivers/i915/i915_texture.c index 441bc4f193..612e5c1cdd 100644 --- a/src/gallium/drivers/i915/i915_texture.c +++ b/src/gallium/drivers/i915/i915_texture.c @@ -34,7 +34,6 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_inlines.h" -#include "pipe/internal/p_winsys_screen.h" #include "util/u_format.h" #include "util/u_math.h" #include "util/u_memory.h" -- cgit v1.2.3 From 2a0622182281bfa8402d3c64345c698583c383d7 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Tue, 26 Jan 2010 23:28:23 -0800 Subject: softpipe: Remove unnecessary header. --- src/gallium/drivers/softpipe/sp_winsys.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gallium/drivers/softpipe/sp_winsys.c b/src/gallium/drivers/softpipe/sp_winsys.c index 8169071dc9..38bcd64c6a 100644 --- a/src/gallium/drivers/softpipe/sp_winsys.c +++ b/src/gallium/drivers/softpipe/sp_winsys.c @@ -39,7 +39,6 @@ #include "pipe/internal/p_winsys_screen.h"/* port to just p_screen */ #include "pipe/p_format.h" #include "pipe/p_context.h" -#include "pipe/p_inlines.h" #include "util/u_format.h" #include "util/u_math.h" #include "util/u_memory.h" -- cgit v1.2.3 From fb24c2678a3f5150a2316a08a37bacdb3b9d2687 Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Wed, 27 Jan 2010 10:20:15 +0200 Subject: r600: fix XPD with writemask same variable used for 2 different temp registers fixes e.g. glsl/bump --- src/mesa/drivers/dri/r600/r700_assembler.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r700_assembler.c b/src/mesa/drivers/dri/r600/r700_assembler.c index c01b2fbb14..89adb77bf5 100644 --- a/src/mesa/drivers/dri/r600/r700_assembler.c +++ b/src/mesa/drivers/dri/r600/r700_assembler.c @@ -4491,20 +4491,21 @@ GLboolean assemble_TEX(r700_AssemblerBase *pAsm) GLboolean assemble_XPD(r700_AssemblerBase *pAsm) { - BITS tmp; + BITS tmp1; + BITS tmp2 = 0; if( GL_FALSE == checkop2(pAsm) ) { return GL_FALSE; } - tmp = gethelpr(pAsm); + tmp1 = gethelpr(pAsm); pAsm->D.dst.opcode = SQ_OP2_INST_MUL; setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE); pAsm->D.dst.rtype = DST_REG_TEMPORARY; - pAsm->D.dst.reg = tmp; + pAsm->D.dst.reg = tmp1; nomask_PVSDST(&(pAsm->D.dst)); if( GL_FALSE == assemble_src(pAsm, 0, -1) ) @@ -4530,11 +4531,11 @@ GLboolean assemble_XPD(r700_AssemblerBase *pAsm) if(0xF != pAsm->pILInst[pAsm->uiCurInst].DstReg.WriteMask) { - tmp = gethelpr(pAsm); + tmp2 = gethelpr(pAsm); setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE); pAsm->D.dst.rtype = DST_REG_TEMPORARY; - pAsm->D.dst.reg = tmp; + pAsm->D.dst.reg = tmp2; nomask_PVSDST(&(pAsm->D.dst)); } @@ -4562,7 +4563,7 @@ GLboolean assemble_XPD(r700_AssemblerBase *pAsm) // result1 + (neg) result0 setaddrmode_PVSSRC(&(pAsm->S[2].src),ADDR_ABSOLUTE); pAsm->S[2].src.rtype = SRC_REG_TEMPORARY; - pAsm->S[2].src.reg = tmp; + pAsm->S[2].src.reg = tmp1; neg_PVSSRC(&(pAsm->S[2].src)); noswizzle_PVSSRC(&(pAsm->S[2].src)); @@ -4585,7 +4586,7 @@ GLboolean assemble_XPD(r700_AssemblerBase *pAsm) // Use tmp as source setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE); pAsm->S[0].src.rtype = SRC_REG_TEMPORARY; - pAsm->S[0].src.reg = tmp; + pAsm->S[0].src.reg = tmp2; noneg_PVSSRC(&(pAsm->S[0].src)); noswizzle_PVSSRC(&(pAsm->S[0].src)); -- cgit v1.2.3 From 07d47cb92d7401b7a5ed21a8f97949f4bd2f66bc Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Wed, 27 Jan 2010 11:22:56 +0200 Subject: r600: increase max texture units to 16 --- src/mesa/drivers/dri/r600/r600_context.c | 6 ++---- src/mesa/drivers/dri/r600/r600_tex.h | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r600_context.c b/src/mesa/drivers/dri/r600/r600_context.c index 68112c49dc..2ac0e7c11c 100644 --- a/src/mesa/drivers/dri/r600/r600_context.c +++ b/src/mesa/drivers/dri/r600/r600_context.c @@ -248,10 +248,8 @@ static void r600InitConstValues(GLcontext *ctx, radeonScreenPtr screen) { context_t *r600 = R700_CONTEXT(ctx); - ctx->Const.MaxTextureImageUnits = - driQueryOptioni(&r600->radeon.optionCache, "texture_image_units"); - ctx->Const.MaxTextureCoordUnits = - driQueryOptioni(&r600->radeon.optionCache, "texture_coord_units"); + ctx->Const.MaxTextureImageUnits = 16; + ctx->Const.MaxTextureCoordUnits = 8; ctx->Const.MaxTextureUnits = MIN2(ctx->Const.MaxTextureImageUnits, ctx->Const.MaxTextureCoordUnits); diff --git a/src/mesa/drivers/dri/r600/r600_tex.h b/src/mesa/drivers/dri/r600/r600_tex.h index c2141ef5e5..1d75a2ecd6 100644 --- a/src/mesa/drivers/dri/r600/r600_tex.h +++ b/src/mesa/drivers/dri/r600/r600_tex.h @@ -42,7 +42,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* Texel pitch is 8 alignment. */ #define R700_TEXEL_PITCH_ALIGNMENT_MASK 0x7 -#define R700_MAX_TEXTURE_UNITS 8 /* TODO : should be 16, lets make it work, review later */ +#define R700_MAX_TEXTURE_UNITS 16 extern void r600SetDepthTexMode(struct gl_texture_object *tObj); -- cgit v1.2.3 From 1ecf505087136c1120f440c265c57418b14d0442 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Wed, 27 Jan 2010 12:46:46 +0000 Subject: Duplicate CCVERSION check code to compensate for different env CC. --- scons/gallium.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/scons/gallium.py b/scons/gallium.py index c88af96898..91a2fbbca6 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -34,6 +34,7 @@ import distutils.version import os import os.path import re +import subprocess import SCons.Action import SCons.Builder @@ -109,6 +110,9 @@ def generate(env): env['toolchain'] = 'wcesdk' env.Tool(env['toolchain']) + if os.environ.has_key('CC'): + env['CC'] = os.environ['CC'] + env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-') env['msvc'] = env['CC'] == 'cl' @@ -232,9 +236,19 @@ def generate(env): cxxflags = [] # C++ ccflags = [] # C & C++ if gcc: + ccversion = '' + pipe = SCons.Action._subproc(env, [env['CC'], '--version'], + stdin = 'devnull', + stderr = 'devnull', + stdout = subprocess.PIPE) + if pipe.wait() == 0: + line = pipe.stdout.readline() + match = re.search(r'[0-9]+(\.[0-9]+)+', line) + if match: + ccversion = match.group(0) if debug: ccflags += ['-O0', '-g3'] - elif env['CCVERSION'].startswith('4.2.'): + elif ccversion.startswith('4.2.'): # gcc 4.2.x optimizer is broken print "warning: gcc 4.2.x optimizer is broken -- disabling optimizations" ccflags += ['-O0', '-g3'] @@ -277,7 +291,7 @@ def generate(env): '-Wmissing-prototypes', '-std=gnu99', ] - if distutils.version.LooseVersion(env['CCVERSION']) >= distutils.version.LooseVersion('4.2'): + if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2'): ccflags += [ '-Werror=pointer-arith', ] -- cgit v1.2.3 From b8656c4825b9e054f05258773ba012e41d4fcdee Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 27 Jan 2010 09:21:57 -0700 Subject: cell: remove commas from structs wrapped in PIPE_ALIGN_TYPE macro This avoids the need to make PIPE_ALIGN_TYPE a variadic macro. --- src/gallium/drivers/cell/spu/spu_main.h | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/cell/spu/spu_main.h b/src/gallium/drivers/cell/spu/spu_main.h index b18f4c22ef..a9d72f84d5 100644 --- a/src/gallium/drivers/cell/spu/spu_main.h +++ b/src/gallium/drivers/cell/spu/spu_main.h @@ -100,8 +100,10 @@ struct spu_framebuffer void *depth_start; /**< addr of depth surface in main memory */ enum pipe_format color_format; enum pipe_format depth_format; - uint width, height; /**< size in pixels */ - uint width_tiles, height_tiles; /**< width and height in tiles */ + uint width; /**< width in pixels */ + uint height; /**< height in pixels */ + uint width_tiles; /**< width in tiles */ + uint height_tiles; /**< width in tiles */ uint color_clear_value; uint depth_clear_value; @@ -116,15 +118,23 @@ PIPE_ALIGN_TYPE(16, struct spu_texture_level { void *start; - ushort width, height, depth; + ushort width; + ushort height; + ushort depth; ushort tiles_per_row; uint bytes_per_image; /** texcoord scale factors */ - vector float scale_s, scale_t, scale_r; + vector float scale_s; + vector float scale_t; + vector float scale_r; /** texcoord masks (if REPEAT then size-1, else ~0) */ - vector signed int mask_s, mask_t, mask_r; + vector signed int mask_s; + vector signed int mask_t; + vector signed int mask_r; /** texcoord clamp limits */ - vector signed int max_s, max_t, max_r; + vector signed int max_s; + vector signed int max_t; + vector signed int max_r; }); @@ -166,7 +176,8 @@ struct spu_global boolean read_depth_stencil; /** Current tiles' status */ - ubyte cur_ctile_status, cur_ztile_status; + ubyte cur_ctile_status; + ubyte cur_ztile_status; /** Status of all tiles in framebuffer */ PIPE_ALIGN_VAR(16) ubyte ctile_status[CELL_MAX_HEIGHT/TILE_SIZE][CELL_MAX_WIDTH/TILE_SIZE]; -- cgit v1.2.3 From 1fdf04ade3f99f943cb7c6e8784b6a9c9686d452 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Wed, 27 Jan 2010 12:16:50 -0500 Subject: r600: rv670 support 8 tex instructions just like other r6xx also clarify some other const values. --- src/mesa/drivers/dri/r600/r600_context.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r600_context.c b/src/mesa/drivers/dri/r600/r600_context.c index 2ac0e7c11c..922291ae69 100644 --- a/src/mesa/drivers/dri/r600/r600_context.c +++ b/src/mesa/drivers/dri/r600/r600_context.c @@ -249,6 +249,9 @@ static void r600InitConstValues(GLcontext *ctx, radeonScreenPtr screen) context_t *r600 = R700_CONTEXT(ctx); ctx->Const.MaxTextureImageUnits = 16; + /* 8 per clause on r6xx, 16 on r7xx + * but I think mesa only supports 8 at the moment + */ ctx->Const.MaxTextureCoordUnits = 8; ctx->Const.MaxTextureUnits = MIN2(ctx->Const.MaxTextureImageUnits, @@ -284,9 +287,8 @@ static void r600InitConstValues(GLcontext *ctx, radeonScreenPtr screen) ctx->Const.FragmentProgram.MaxNativeAttribs = 32; ctx->Const.FragmentProgram.MaxNativeParameters = 256; ctx->Const.FragmentProgram.MaxNativeAluInstructions = 8192; - /* 8 per clause on r6xx, 16 on rv670/r7xx */ - if ((screen->chip_family == CHIP_FAMILY_RV670) || - (screen->chip_family >= CHIP_FAMILY_RV770)) + /* 8 per clause on r6xx, 16 on r7xx */ + if (screen->chip_family >= CHIP_FAMILY_RV770) ctx->Const.FragmentProgram.MaxNativeTexInstructions = 16; else ctx->Const.FragmentProgram.MaxNativeTexInstructions = 8; -- cgit v1.2.3 From ccb4ba3e3b147426a0534763ffe20571336c3cf1 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Wed, 27 Jan 2010 12:18:02 -0500 Subject: r600: fix warning --- src/mesa/drivers/dri/r600/r600_context.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r600_context.c b/src/mesa/drivers/dri/r600/r600_context.c index 922291ae69..ab3c7723c9 100644 --- a/src/mesa/drivers/dri/r600/r600_context.c +++ b/src/mesa/drivers/dri/r600/r600_context.c @@ -246,8 +246,6 @@ static void r600_init_vtbl(radeonContextPtr radeon) static void r600InitConstValues(GLcontext *ctx, radeonScreenPtr screen) { - context_t *r600 = R700_CONTEXT(ctx); - ctx->Const.MaxTextureImageUnits = 16; /* 8 per clause on r6xx, 16 on r7xx * but I think mesa only supports 8 at the moment -- cgit v1.2.3 From 01ed5c6ef5395038add9eae2735fa32e40d39895 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Wed, 27 Jan 2010 14:04:53 -0800 Subject: r300g: Silence GCC "missing braces around initializer" warning. --- src/gallium/drivers/r300/r300_state_derived.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index a351c9d01b..bad9e76067 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -305,7 +305,7 @@ static void r300_update_rs_block(struct r300_context* r300, struct r300_shader_semantics* vs_outputs, struct r300_shader_semantics* fs_inputs) { - struct r300_rs_block rs = { 0 }; + struct r300_rs_block rs = { { 0 } }; int i, col_count = 0, tex_count = 0, fp_offset = 0; void (*rX00_rs_col)(struct r300_rs_block*, int, int, boolean); void (*rX00_rs_col_write)(struct r300_rs_block*, int, int); -- cgit v1.2.3 From 83d2b4d4a65958172cf3e30b314d4bffdebefd0b Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Wed, 27 Jan 2010 15:06:13 -0800 Subject: gallium/draw: Remove unnecessary headers. --- src/gallium/auxiliary/draw/draw_context.c | 2 -- src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c | 1 - 2 files changed, 3 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index fb1bc05af4..1639043832 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -36,8 +36,6 @@ #include "draw_context.h" #include "draw_vs.h" #include "draw_gs.h" -#include "draw_pt.h" -#include "draw_pipe.h" struct draw_context *draw_create( void ) diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c index 23da556f79..2c996e7308 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c @@ -33,7 +33,6 @@ #include "draw/draw_pt.h" #include "draw/draw_vs.h" #include "draw/draw_gs.h" -#include "translate/translate.h" struct fetch_pipeline_middle_end { -- cgit v1.2.3 From 00c36079175a9582f54ca48fc4608faaba1ca4a6 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Wed, 27 Jan 2010 15:32:48 -0800 Subject: tgsi: Remove unnecessary header. --- src/gallium/auxiliary/tgsi/tgsi_util.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_util.c b/src/gallium/auxiliary/tgsi/tgsi_util.c index f4ca9e21ed..0a7e4105a8 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_util.c +++ b/src/gallium/auxiliary/tgsi/tgsi_util.c @@ -28,7 +28,6 @@ #include "util/u_debug.h" #include "pipe/p_shader_tokens.h" #include "tgsi_parse.h" -#include "tgsi_build.h" #include "tgsi_util.h" union pointer_hack -- cgit v1.2.3 From f7f59b50ce7a15518c76fc87f1653b1079d27d8c Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Wed, 27 Jan 2010 15:35:58 -0800 Subject: util: Remove unnecessary header. --- src/gallium/auxiliary/util/u_surface.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c index 35c4978204..f828908f0b 100644 --- a/src/gallium/auxiliary/util/u_surface.c +++ b/src/gallium/auxiliary/util/u_surface.c @@ -36,7 +36,6 @@ #include "pipe/p_state.h" #include "pipe/p_defines.h" -#include "util/u_format.h" #include "util/u_surface.h" -- cgit v1.2.3 From 83e6ba564c82ddf6403223588e8155f8fcb570e6 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Wed, 27 Jan 2010 15:54:21 -0800 Subject: i965g: Remove unnecessary headers. --- src/gallium/drivers/i965/brw_cc.c | 1 - src/gallium/drivers/i965/brw_clip.c | 1 - src/gallium/drivers/i965/brw_clip_line.c | 1 - src/gallium/drivers/i965/brw_clip_point.c | 1 - src/gallium/drivers/i965/brw_clip_tri.c | 1 - src/gallium/drivers/i965/brw_clip_util.c | 1 - src/gallium/drivers/i965/brw_context.c | 1 - src/gallium/drivers/i965/brw_curbe.c | 2 -- src/gallium/drivers/i965/brw_draw.c | 1 - src/gallium/drivers/i965/brw_gs.c | 1 - src/gallium/drivers/i965/brw_gs_emit.c | 1 - src/gallium/drivers/i965/brw_pipe_fb.c | 1 - src/gallium/drivers/i965/brw_pipe_sampler.c | 1 - src/gallium/drivers/i965/brw_sf.c | 1 - src/gallium/drivers/i965/brw_sf_emit.c | 1 - src/gallium/drivers/i965/brw_state_cache.c | 1 - src/gallium/drivers/i965/brw_util.c | 2 -- src/gallium/drivers/i965/brw_vs.c | 2 -- src/gallium/drivers/i965/brw_vs_surface_state.c | 1 - src/gallium/drivers/i965/brw_wm_fp.c | 1 - src/gallium/drivers/i965/brw_wm_surface_state.c | 1 - 21 files changed, 24 deletions(-) diff --git a/src/gallium/drivers/i965/brw_cc.c b/src/gallium/drivers/i965/brw_cc.c index 3e070f5591..4a543276f5 100644 --- a/src/gallium/drivers/i965/brw_cc.c +++ b/src/gallium/drivers/i965/brw_cc.c @@ -32,7 +32,6 @@ #include "brw_context.h" #include "brw_state.h" -#include "brw_defines.h" static enum pipe_error prepare_cc_vp( struct brw_context *brw ) diff --git a/src/gallium/drivers/i965/brw_clip.c b/src/gallium/drivers/i965/brw_clip.c index d67a1a6263..ccba205e8c 100644 --- a/src/gallium/drivers/i965/brw_clip.c +++ b/src/gallium/drivers/i965/brw_clip.c @@ -38,7 +38,6 @@ #include "brw_defines.h" #include "brw_context.h" #include "brw_eu.h" -#include "brw_util.h" #include "brw_state.h" #include "brw_pipe_rast.h" #include "brw_clip.h" diff --git a/src/gallium/drivers/i965/brw_clip_line.c b/src/gallium/drivers/i965/brw_clip_line.c index 54282d975e..66caadc4d5 100644 --- a/src/gallium/drivers/i965/brw_clip_line.c +++ b/src/gallium/drivers/i965/brw_clip_line.c @@ -33,7 +33,6 @@ #include "brw_defines.h" #include "brw_eu.h" -#include "brw_util.h" #include "brw_clip.h" diff --git a/src/gallium/drivers/i965/brw_clip_point.c b/src/gallium/drivers/i965/brw_clip_point.c index e0a5330556..124156c1b5 100644 --- a/src/gallium/drivers/i965/brw_clip_point.c +++ b/src/gallium/drivers/i965/brw_clip_point.c @@ -31,7 +31,6 @@ #include "brw_defines.h" #include "brw_eu.h" -#include "brw_util.h" #include "brw_clip.h" diff --git a/src/gallium/drivers/i965/brw_clip_tri.c b/src/gallium/drivers/i965/brw_clip_tri.c index 4cde7294ea..069524bc14 100644 --- a/src/gallium/drivers/i965/brw_clip_tri.c +++ b/src/gallium/drivers/i965/brw_clip_tri.c @@ -31,7 +31,6 @@ #include "brw_defines.h" #include "brw_eu.h" -#include "brw_util.h" #include "brw_clip.h" static void release_tmps( struct brw_clip_compile *c ) diff --git a/src/gallium/drivers/i965/brw_clip_util.c b/src/gallium/drivers/i965/brw_clip_util.c index 97a5710310..23e51ee9bc 100644 --- a/src/gallium/drivers/i965/brw_clip_util.c +++ b/src/gallium/drivers/i965/brw_clip_util.c @@ -32,7 +32,6 @@ #include "brw_defines.h" #include "brw_eu.h" -#include "brw_util.h" #include "brw_clip.h" diff --git a/src/gallium/drivers/i965/brw_context.c b/src/gallium/drivers/i965/brw_context.c index e67551882d..d60b7b99b6 100644 --- a/src/gallium/drivers/i965/brw_context.c +++ b/src/gallium/drivers/i965/brw_context.c @@ -34,7 +34,6 @@ #include "util/u_simple_list.h" #include "brw_context.h" -#include "brw_defines.h" #include "brw_draw.h" #include "brw_state.h" #include "brw_batchbuffer.h" diff --git a/src/gallium/drivers/i965/brw_curbe.c b/src/gallium/drivers/i965/brw_curbe.c index 3f031577d5..4b215a001c 100644 --- a/src/gallium/drivers/i965/brw_curbe.c +++ b/src/gallium/drivers/i965/brw_curbe.c @@ -36,9 +36,7 @@ #include "brw_context.h" #include "brw_defines.h" #include "brw_state.h" -#include "brw_util.h" #include "brw_debug.h" -#include "brw_screen.h" /** diff --git a/src/gallium/drivers/i965/brw_draw.c b/src/gallium/drivers/i965/brw_draw.c index ea8d39adaf..1b5cd23995 100644 --- a/src/gallium/drivers/i965/brw_draw.c +++ b/src/gallium/drivers/i965/brw_draw.c @@ -34,7 +34,6 @@ #include "brw_context.h" #include "brw_state.h" #include "brw_debug.h" -#include "brw_screen.h" #include "brw_batchbuffer.h" diff --git a/src/gallium/drivers/i965/brw_gs.c b/src/gallium/drivers/i965/brw_gs.c index 921b201bae..06826635a8 100644 --- a/src/gallium/drivers/i965/brw_gs.c +++ b/src/gallium/drivers/i965/brw_gs.c @@ -34,7 +34,6 @@ #include "brw_defines.h" #include "brw_context.h" #include "brw_eu.h" -#include "brw_util.h" #include "brw_state.h" #include "brw_gs.h" diff --git a/src/gallium/drivers/i965/brw_gs_emit.c b/src/gallium/drivers/i965/brw_gs_emit.c index fd8e2acced..9b58773b3b 100644 --- a/src/gallium/drivers/i965/brw_gs_emit.c +++ b/src/gallium/drivers/i965/brw_gs_emit.c @@ -35,7 +35,6 @@ #include "brw_defines.h" #include "brw_context.h" #include "brw_eu.h" -#include "brw_util.h" #include "brw_gs.h" static void brw_gs_alloc_regs( struct brw_gs_compile *c, diff --git a/src/gallium/drivers/i965/brw_pipe_fb.c b/src/gallium/drivers/i965/brw_pipe_fb.c index 5d4e5025f9..c1f049272a 100644 --- a/src/gallium/drivers/i965/brw_pipe_fb.c +++ b/src/gallium/drivers/i965/brw_pipe_fb.c @@ -3,7 +3,6 @@ #include "pipe/p_state.h" #include "brw_context.h" -#include "brw_debug.h" /** * called from intelDrawBuffer() diff --git a/src/gallium/drivers/i965/brw_pipe_sampler.c b/src/gallium/drivers/i965/brw_pipe_sampler.c index 81712798a5..ef6c1bb315 100644 --- a/src/gallium/drivers/i965/brw_pipe_sampler.c +++ b/src/gallium/drivers/i965/brw_pipe_sampler.c @@ -7,7 +7,6 @@ #include "brw_context.h" #include "brw_defines.h" -#include "brw_debug.h" diff --git a/src/gallium/drivers/i965/brw_sf.c b/src/gallium/drivers/i965/brw_sf.c index e1986a9dbb..6e99eaa09d 100644 --- a/src/gallium/drivers/i965/brw_sf.c +++ b/src/gallium/drivers/i965/brw_sf.c @@ -36,7 +36,6 @@ #include "brw_context.h" #include "brw_pipe_rast.h" #include "brw_eu.h" -#include "brw_util.h" #include "brw_sf.h" #include "brw_state.h" diff --git a/src/gallium/drivers/i965/brw_sf_emit.c b/src/gallium/drivers/i965/brw_sf_emit.c index 3b85725e36..497634ec9e 100644 --- a/src/gallium/drivers/i965/brw_sf_emit.c +++ b/src/gallium/drivers/i965/brw_sf_emit.c @@ -35,7 +35,6 @@ #include "brw_defines.h" #include "brw_context.h" #include "brw_eu.h" -#include "brw_util.h" #include "brw_sf.h" diff --git a/src/gallium/drivers/i965/brw_state_cache.c b/src/gallium/drivers/i965/brw_state_cache.c index 16b643ceb2..85c20076fb 100644 --- a/src/gallium/drivers/i965/brw_state_cache.c +++ b/src/gallium/drivers/i965/brw_state_cache.c @@ -59,7 +59,6 @@ #include "brw_debug.h" #include "brw_state.h" -#include "brw_batchbuffer.h" /* XXX: Fixme - have to include these to get the sizes of the prog_key * structs: diff --git a/src/gallium/drivers/i965/brw_util.c b/src/gallium/drivers/i965/brw_util.c index 458058d668..1fd2e29713 100644 --- a/src/gallium/drivers/i965/brw_util.c +++ b/src/gallium/drivers/i965/brw_util.c @@ -30,8 +30,6 @@ */ -#include "brw_util.h" -#include "brw_defines.h" diff --git a/src/gallium/drivers/i965/brw_vs.c b/src/gallium/drivers/i965/brw_vs.c index e3ea5a3a13..ca8ee79550 100644 --- a/src/gallium/drivers/i965/brw_vs.c +++ b/src/gallium/drivers/i965/brw_vs.c @@ -33,9 +33,7 @@ #include "brw_context.h" #include "brw_vs.h" -#include "brw_util.h" #include "brw_state.h" -#include "brw_pipe_rast.h" diff --git a/src/gallium/drivers/i965/brw_vs_surface_state.c b/src/gallium/drivers/i965/brw_vs_surface_state.c index 177a5170d2..004e3cb4e6 100644 --- a/src/gallium/drivers/i965/brw_vs_surface_state.c +++ b/src/gallium/drivers/i965/brw_vs_surface_state.c @@ -31,7 +31,6 @@ #include "brw_context.h" #include "brw_state.h" -#include "brw_defines.h" #include "brw_winsys.h" /* XXX: disabled true constant buffer functionality diff --git a/src/gallium/drivers/i965/brw_wm_fp.c b/src/gallium/drivers/i965/brw_wm_fp.c index 9c5b527f89..9c67759ad0 100644 --- a/src/gallium/drivers/i965/brw_wm_fp.c +++ b/src/gallium/drivers/i965/brw_wm_fp.c @@ -41,7 +41,6 @@ #include "tgsi/tgsi_util.h" #include "brw_wm.h" -#include "brw_util.h" #include "brw_debug.h" diff --git a/src/gallium/drivers/i965/brw_wm_surface_state.c b/src/gallium/drivers/i965/brw_wm_surface_state.c index f92b8198ed..b01a7f194b 100644 --- a/src/gallium/drivers/i965/brw_wm_surface_state.c +++ b/src/gallium/drivers/i965/brw_wm_surface_state.c @@ -34,7 +34,6 @@ #include "brw_batchbuffer.h" #include "brw_context.h" #include "brw_state.h" -#include "brw_defines.h" #include "brw_screen.h" -- cgit v1.2.3 From f103f7e460131f582c0ea8129640ad19178a1ff9 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 26 Jan 2010 17:31:06 -0700 Subject: configs: added vega to default GALLIUM_STATE_TRACKERS_DIRS --- configs/default | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/default b/configs/default index d79039561e..ad6d93c92f 100644 --- a/configs/default +++ b/configs/default @@ -102,7 +102,7 @@ GALLIUM_DRIVERS_DIRS = softpipe failover svga i915 i965 r300 trace identity GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a) GALLIUM_WINSYS_DIRS = drm xlib GALLIUM_WINSYS_DRM_DIRS = swrast -GALLIUM_STATE_TRACKERS_DIRS = glx +GALLIUM_STATE_TRACKERS_DIRS = glx vega # native displays EGL should support EGL_DISPLAYS = x11 -- cgit v1.2.3 From 4e5364d6fcd63b6f927ac4fb76effec0007d6797 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 27 Jan 2010 17:00:15 -0700 Subject: mesa: more info in glActiveTexture error msg --- src/mesa/main/texstate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 25333d8994..2b26f651a5 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -291,7 +291,8 @@ _mesa_ActiveTextureARB(GLenum texture) _mesa_lookup_enum_by_nr(texture)); if (texUnit >= ctx->Const.MaxTextureImageUnits) { - _mesa_error(ctx, GL_INVALID_ENUM, "glActiveTexture(texture)"); + _mesa_error(ctx, GL_INVALID_ENUM, "glActiveTexture(texture=%s)", + _mesa_lookup_enum_by_nr(texture)); return; } -- cgit v1.2.3 From 880411c72aee7c0ec81366bdf6ab8cf25bebb9d5 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 27 Jan 2010 17:00:32 -0700 Subject: swrast: silence double->float assignment warnings Reported by Karl Schultz. --- src/mesa/swrast/s_aatritemp.h | 8 ++++---- src/mesa/swrast/s_accum.c | 2 +- src/mesa/swrast/s_alpha.c | 4 ++-- src/mesa/swrast/s_atifragshader.c | 27 ++++++++++++++------------- src/mesa/swrast/s_context.c | 10 +++++----- src/mesa/swrast/s_fog.c | 12 ++++++------ src/mesa/swrast/s_fragprog.c | 6 +++--- src/mesa/swrast/s_points.c | 12 ++++++------ src/mesa/swrast/s_span.c | 2 +- src/mesa/swrast/s_texcombine.c | 20 ++++++++++---------- src/mesa/swrast/s_texfilter.c | 2 +- 11 files changed, 53 insertions(+), 52 deletions(-) diff --git a/src/mesa/swrast/s_aatritemp.h b/src/mesa/swrast/s_aatritemp.h index 0827b3db9e..a8b22c548f 100644 --- a/src/mesa/swrast/s_aatritemp.h +++ b/src/mesa/swrast/s_aatritemp.h @@ -220,11 +220,11 @@ #if defined(DO_ATTRIBS) /* compute attributes at left-most fragment */ - span.attrStart[FRAG_ATTRIB_WPOS][3] = solve_plane(ix + 0.5, iy + 0.5, wPlane); + span.attrStart[FRAG_ATTRIB_WPOS][3] = solve_plane(ix + 0.5F, iy + 0.5F, wPlane); ATTRIB_LOOP_BEGIN GLuint c; for (c = 0; c < 4; c++) { - span.attrStart[attr][c] = solve_plane(ix + 0.5, iy + 0.5, attrPlane[attr][c]); + span.attrStart[attr][c] = solve_plane(ix + 0.5F, iy + 0.5F, attrPlane[attr][c]); } ATTRIB_LOOP_END #endif @@ -328,11 +328,11 @@ #if defined(DO_ATTRIBS) /* compute attributes at left-most fragment */ - span.attrStart[FRAG_ATTRIB_WPOS][3] = solve_plane(ix + 1.5, iy + 0.5, wPlane); + span.attrStart[FRAG_ATTRIB_WPOS][3] = solve_plane(ix + 1.5, iy + 0.5F, wPlane); ATTRIB_LOOP_BEGIN GLuint c; for (c = 0; c < 4; c++) { - span.attrStart[attr][c] = solve_plane(ix + 1.5, iy + 0.5, attrPlane[attr][c]); + span.attrStart[attr][c] = solve_plane(ix + 1.5, iy + 0.5F, attrPlane[attr][c]); } ATTRIB_LOOP_END #endif diff --git a/src/mesa/swrast/s_accum.c b/src/mesa/swrast/s_accum.c index cf53f01b7c..2dd9ca6348 100644 --- a/src/mesa/swrast/s_accum.c +++ b/src/mesa/swrast/s_accum.c @@ -37,7 +37,7 @@ /* XXX this would have to change for accum buffers with more or less * than 16 bits per color channel. */ -#define ACCUM_SCALE16 32767.0 +#define ACCUM_SCALE16 32767.0F /* diff --git a/src/mesa/swrast/s_alpha.c b/src/mesa/swrast/s_alpha.c index 5761bb00b4..ebac562272 100644 --- a/src/mesa/swrast/s_alpha.c +++ b/src/mesa/swrast/s_alpha.c @@ -146,8 +146,8 @@ _swrast_alpha_test(const GLcontext *ctx, SWspan *span) ALPHA_TEST(FixedToInt(alpha), alpha += alphaStep); } else { - const GLfloat alphaStep = span->alphaStep; - GLfloat alpha = span->alpha; + const GLfloat alphaStep = FIXED_TO_FLOAT(span->alphaStep); + GLfloat alpha = FIXED_TO_FLOAT(span->alpha); const GLfloat ref = ctx->Color.AlphaRef; ALPHA_TEST(alpha, alpha += alphaStep); } diff --git a/src/mesa/swrast/s_atifragshader.c b/src/mesa/swrast/s_atifragshader.c index 353e9999d6..05da64de3a 100644 --- a/src/mesa/swrast/s_atifragshader.c +++ b/src/mesa/swrast/s_atifragshader.c @@ -82,10 +82,11 @@ apply_swizzle(GLfloat values[4], GLuint swizzle) break; case GL_SWIZZLE_STQ_DQ_ATI: /* make sure q is not 0 to avoid problems later with infinite values (texture lookup)? */ - if (q == 0.0F) q = 0.000000001; + if (q == 0.0F) + q = 0.000000001F; values[0] = s / q; values[1] = t / q; - values[2] = 1 / q; + values[2] = 1.0 / q; break; } values[3] = 0.0; @@ -171,27 +172,27 @@ apply_dst_mod(GLuint optype, GLuint mod, GLfloat * val) val[i] = 8 * val[i]; break; case GL_HALF_BIT_ATI: - val[i] = val[i] * 0.5; + val[i] = val[i] * 0.5F; break; case GL_QUARTER_BIT_ATI: - val[i] = val[i] * 0.25; + val[i] = val[i] * 0.25F; break; case GL_EIGHTH_BIT_ATI: - val[i] = val[i] * 0.125; + val[i] = val[i] * 0.125F; break; } if (has_sat) { - if (val[i] < 0.0) - val[i] = 0; - else if (val[i] > 1.0) - val[i] = 1.0; + if (val[i] < 0.0F) + val[i] = 0.0F; + else if (val[i] > 1.0F) + val[i] = 1.0F; } else { - if (val[i] < -8.0) - val[i] = -8.0; - else if (val[i] > 8.0) - val[i] = 8.0; + if (val[i] < -8.0F) + val[i] = -8.0F; + else if (val[i] > 8.0F) + val[i] = 8.0F; } } } diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index f9092c215a..0d4680db9f 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -149,26 +149,26 @@ _swrast_update_polygon( GLcontext *ctx ) if (ctx->Polygon.CullFlag) { switch (ctx->Polygon.CullFaceMode) { case GL_BACK: - backface_sign = -1.0; + backface_sign = -1.0F; break; case GL_FRONT: - backface_sign = 1.0; + backface_sign = 1.0F; break; case GL_FRONT_AND_BACK: /* fallthrough */ default: - backface_sign = 0.0; + backface_sign = 0.0F; } } else { - backface_sign = 0.0; + backface_sign = 0.0F; } SWRAST_CONTEXT(ctx)->_BackfaceCullSign = backface_sign; /* This is for front/back-face determination, but not for culling */ SWRAST_CONTEXT(ctx)->_BackfaceSign - = (ctx->Polygon.FrontFace == GL_CW) ? -1.0 : 1.0; + = (ctx->Polygon.FrontFace == GL_CW) ? -1.0F : 1.0F; } diff --git a/src/mesa/swrast/s_fog.c b/src/mesa/swrast/s_fog.c index 77ed0cfef9..0472bbf553 100644 --- a/src/mesa/swrast/s_fog.c +++ b/src/mesa/swrast/s_fog.c @@ -172,14 +172,14 @@ _swrast_fog_rgba_span( const GLcontext *ctx, SWspan *span ) /* compute (scaled) fog color */ if (span->array->ChanType == GL_UNSIGNED_BYTE) { - rFog = ctx->Fog.Color[RCOMP] * 255.0; - gFog = ctx->Fog.Color[GCOMP] * 255.0; - bFog = ctx->Fog.Color[BCOMP] * 255.0; + rFog = ctx->Fog.Color[RCOMP] * 255.0F; + gFog = ctx->Fog.Color[GCOMP] * 255.0F; + bFog = ctx->Fog.Color[BCOMP] * 255.0F; } else if (span->array->ChanType == GL_UNSIGNED_SHORT) { - rFog = ctx->Fog.Color[RCOMP] * 65535.0; - gFog = ctx->Fog.Color[GCOMP] * 65535.0; - bFog = ctx->Fog.Color[BCOMP] * 65535.0; + rFog = ctx->Fog.Color[RCOMP] * 65535.0F; + gFog = ctx->Fog.Color[GCOMP] * 65535.0F; + bFog = ctx->Fog.Color[BCOMP] * 65535.0F; } else { rFog = ctx->Fog.Color[RCOMP]; diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c index 1c6492cc8f..d31da4c402 100644 --- a/src/mesa/swrast/s_fragprog.c +++ b/src/mesa/swrast/s_fragprog.c @@ -156,8 +156,8 @@ init_machine(GLcontext *ctx, struct gl_program_machine *machine, if (program->OriginUpperLeft) wpos[1] = ctx->DrawBuffer->Height - 1 - wpos[1]; if (!program->PixelCenterInteger) { - wpos[0] += 0.5; - wpos[1] += 0.5; + wpos[0] += 0.5F; + wpos[1] += 0.5F; } /* Setup pointer to input attributes */ @@ -172,7 +172,7 @@ init_machine(GLcontext *ctx, struct gl_program_machine *machine, /* if running a GLSL program (not ARB_fragment_program) */ if (ctx->Shader.CurrentProgram) { /* Store front/back facing value */ - machine->Attribs[FRAG_ATTRIB_FACE][col][0] = 1.0 - span->facing; + machine->Attribs[FRAG_ATTRIB_FACE][col][0] = 1.0F - span->facing; } machine->CurElement = col; diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c index 6b955429e9..a9a704a16e 100644 --- a/src/mesa/swrast/s_points.c +++ b/src/mesa/swrast/s_points.c @@ -125,16 +125,16 @@ sprite_point(GLcontext *ctx, const SWvertex *vert) GLfloat s, r, dsdx; /* texcoord / pointcoord interpolants */ - s = 0.0; - dsdx = 1.0 / size; + s = 0.0F; + dsdx = 1.0F / size; if (ctx->Point.SpriteOrigin == GL_LOWER_LEFT) { - dtdy = 1.0 / size; - t0 = 0.5 * dtdy; + dtdy = 1.0F / size; + t0 = 0.5F * dtdy; } else { /* GL_UPPER_LEFT */ - dtdy = -1.0 / size; - t0 = 1.0 + 0.5 * dtdy; + dtdy = -1.0F / size; + t0 = 1.0F + 0.5F * dtdy; } ATTRIB_LOOP_BEGIN diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index 874a37b224..905cf3d550 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -645,7 +645,7 @@ interpolate_wpos(GLcontext *ctx, SWspan *span) { GLfloat (*wpos)[4] = span->array->attribs[FRAG_ATTRIB_WPOS]; GLuint i; - const GLfloat zScale = 1.0 / ctx->DrawBuffer->_DepthMaxF; + const GLfloat zScale = 1.0F / ctx->DrawBuffer->_DepthMaxF; GLfloat w, dw; if (span->arrayMask & SPAN_XY) { diff --git a/src/mesa/swrast/s_texcombine.c b/src/mesa/swrast/s_texcombine.c index 594b71a03c..95e2c082ba 100644 --- a/src/mesa/swrast/s_texcombine.c +++ b/src/mesa/swrast/s_texcombine.c @@ -316,18 +316,18 @@ texture_combine( GLcontext *ctx, GLuint unit, GLuint n, /* (a * b) + (c * d) - 0.5 */ for (i = 0; i < n; i++) { rgba[i][RCOMP] = (arg0[i][RCOMP] * arg1[i][RCOMP] + - arg2[i][RCOMP] * arg3[i][RCOMP] - 0.5) * scaleRGB; + arg2[i][RCOMP] * arg3[i][RCOMP] - 0.5F) * scaleRGB; rgba[i][GCOMP] = (arg0[i][GCOMP] * arg1[i][GCOMP] + - arg2[i][GCOMP] * arg3[i][GCOMP] - 0.5) * scaleRGB; + arg2[i][GCOMP] * arg3[i][GCOMP] - 0.5F) * scaleRGB; rgba[i][BCOMP] = (arg0[i][BCOMP] * arg1[i][BCOMP] + - arg2[i][BCOMP] * arg3[i][BCOMP] - 0.5) * scaleRGB; + arg2[i][BCOMP] * arg3[i][BCOMP] - 0.5F) * scaleRGB; } } else { for (i = 0; i < n; i++) { - rgba[i][RCOMP] = (arg0[i][RCOMP] + arg1[i][RCOMP] - 0.5) * scaleRGB; - rgba[i][GCOMP] = (arg0[i][GCOMP] + arg1[i][GCOMP] - 0.5) * scaleRGB; - rgba[i][BCOMP] = (arg0[i][BCOMP] + arg1[i][BCOMP] - 0.5) * scaleRGB; + rgba[i][RCOMP] = (arg0[i][RCOMP] + arg1[i][RCOMP] - 0.5F) * scaleRGB; + rgba[i][GCOMP] = (arg0[i][GCOMP] + arg1[i][GCOMP] - 0.5F) * scaleRGB; + rgba[i][BCOMP] = (arg0[i][BCOMP] + arg1[i][BCOMP] - 0.5F) * scaleRGB; } } break; @@ -385,11 +385,11 @@ texture_combine( GLcontext *ctx, GLuint unit, GLuint n, case GL_MODULATE_SIGNED_ADD_ATI: for (i = 0; i < n; i++) { rgba[i][RCOMP] = ((arg0[i][RCOMP] * arg2[i][RCOMP]) + - arg1[i][RCOMP] - 0.5) * scaleRGB; + arg1[i][RCOMP] - 0.5F) * scaleRGB; rgba[i][GCOMP] = ((arg0[i][GCOMP] * arg2[i][GCOMP]) + - arg1[i][GCOMP] - 0.5) * scaleRGB; + arg1[i][GCOMP] - 0.5F) * scaleRGB; rgba[i][BCOMP] = ((arg0[i][BCOMP] * arg2[i][BCOMP]) + - arg1[i][BCOMP] - 0.5) * scaleRGB; + arg1[i][BCOMP] - 0.5F) * scaleRGB; } break; case GL_MODULATE_SUBTRACT_ATI: @@ -456,7 +456,7 @@ texture_combine( GLcontext *ctx, GLuint unit, GLuint n, for (i = 0; i < n; i++) { rgba[i][ACOMP] = (arg0[i][ACOMP] * arg1[i][ACOMP] + arg2[i][ACOMP] * arg3[i][ACOMP] - - 0.5) * scaleA; + 0.5F) * scaleA; } } else { diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c index 76b65cc755..ff7deecc39 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -445,7 +445,7 @@ clamp_rect_coord_linear(GLenum wrapMode, GLfloat coord, GLint max, switch (wrapMode) { case GL_CLAMP: /* Not exactly what the spec says, but it matches NVIDIA output */ - fcol = CLAMP(coord - 0.5F, 0.0, max-1); + fcol = CLAMP(coord - 0.5F, 0.0F, max - 1); i0 = IFLOOR(fcol); i1 = i0 + 1; break; -- cgit v1.2.3 From 28bd4a1d81c200d7eff4545de946dd943d853b08 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 27 Jan 2010 17:01:10 -0700 Subject: tnl: fix double->float and int/uint conversion warnings Reported by Karl Schultz. --- src/mesa/tnl/t_draw.c | 2 +- src/mesa/tnl/t_vb_points.c | 2 +- src/mesa/tnl/t_vertex.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c index d8c611031d..adc50485c1 100644 --- a/src/mesa/tnl/t_draw.c +++ b/src/mesa/tnl/t_draw.c @@ -399,7 +399,7 @@ void _tnl_draw_prims( GLcontext *ctx, TNLcontext *tnl = TNL_CONTEXT(ctx); const GLuint TEST_SPLIT = 0; const GLint max = TEST_SPLIT ? 8 : tnl->vb.Size - MAX_CLIPPED_VERTICES; - GLuint max_basevertex = prim->basevertex; + GLint max_basevertex = prim->basevertex; GLuint i; if (!_mesa_check_conditional_render(ctx)) diff --git a/src/mesa/tnl/t_vb_points.c b/src/mesa/tnl/t_vb_points.c index a52505b4b8..ab8ea60cf2 100644 --- a/src/mesa/tnl/t_vb_points.c +++ b/src/mesa/tnl/t_vb_points.c @@ -64,7 +64,7 @@ run_point_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage) for (i = 0; i < VB->Count; i++) { const GLfloat dist = FABSF(*eyeCoord); const GLfloat q = p0 + dist * (p1 + dist * p2); - const GLfloat atten = (q != 0.0) ? SQRTF(1.0 / q) : 1.0; + const GLfloat atten = (q != 0.0F) ? SQRTF(1.0F / q) : 1.0F; size[i][0] = pointSize * atten; /* clamping done in rasterization */ eyeCoord += eyeCoordStride; } diff --git a/src/mesa/tnl/t_vertex.c b/src/mesa/tnl/t_vertex.c index fe4209ae57..d3955873dc 100644 --- a/src/mesa/tnl/t_vertex.c +++ b/src/mesa/tnl/t_vertex.c @@ -383,7 +383,7 @@ static void adjust_input_ptrs( GLcontext *ctx, GLint diff) struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); struct tnl_clipspace_attr *a = vtx->attr; const GLuint count = vtx->attr_count; - int j; + GLuint j; diff -= 1; for (j=0; j Date: Wed, 27 Jan 2010 17:01:54 -0700 Subject: mesa: fix int/uint comparison warnings Reported by Karl Schultz. --- src/mesa/main/fbobject.c | 2 +- src/mesa/main/teximage.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index de1b524c0b..0e6f69f573 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -954,7 +954,7 @@ renderbuffer_storage(GLenum target, GLenum internalFormat, /* NumSamples == 0 indicates non-multisampling */ samples = 0; } - else if (samples > ctx->Const.MaxSamples) { + else if (samples > (GLsizei) ctx->Const.MaxSamples) { /* note: driver may choose to use more samples than what's requested */ _mesa_error(ctx, GL_INVALID_VALUE, "%s(samples)", func); return; diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 76273b0267..da3c6f9841 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -3224,8 +3224,8 @@ compressed_subtexture_error_check2(GLcontext *ctx, GLuint dims, } if (((width == 1 || width == 2) && - (GLuint) width != texImage->Width) || - (width > texImage->Width)) { + width != (GLsizei) texImage->Width) || + (width > (GLsizei) texImage->Width)) { _mesa_error(ctx, GL_INVALID_VALUE, "glCompressedTexSubImage%uD(width=%d)", dims, width); return GL_TRUE; @@ -3233,8 +3233,8 @@ compressed_subtexture_error_check2(GLcontext *ctx, GLuint dims, if (dims >= 2) { if (((height == 1 || height == 2) && - (GLuint) height != texImage->Height) || - (height > texImage->Height)) { + height != (GLsizei) texImage->Height) || + (height > (GLsizei) texImage->Height)) { _mesa_error(ctx, GL_INVALID_VALUE, "glCompressedTexSubImage%uD(height=%d)", dims, height); return GL_TRUE; @@ -3243,8 +3243,8 @@ compressed_subtexture_error_check2(GLcontext *ctx, GLuint dims, if (dims >= 3) { if (((depth == 1 || depth == 2) && - (GLuint) depth != texImage->Depth) || - (depth > texImage->Depth)) { + depth != (GLsizei) texImage->Depth) || + (depth > (GLsizei) texImage->Depth)) { _mesa_error(ctx, GL_INVALID_VALUE, "glCompressedTexSubImage%uD(depth=%d)", dims, depth); return GL_TRUE; -- cgit v1.2.3 From 6703fb1917a79889df31777682283556c31e30bd Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 27 Jan 2010 17:02:29 -0700 Subject: mesa: fix double->float assignment warnings Reported by Karl Schultz. --- src/mesa/main/dlist.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 7db686c0ae..b182bbe0d0 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -3729,7 +3729,7 @@ save_TexEnvi(GLenum target, GLenum pname, GLint param) { GLfloat p[4]; p[0] = (GLfloat) param; - p[1] = p[2] = p[3] = 0.0; + p[1] = p[2] = p[3] = 0.0F; save_TexEnvfv(target, pname, p); } @@ -3863,7 +3863,7 @@ save_TexParameteri(GLenum target, GLenum pname, GLint param) { GLfloat fparam[4]; fparam[0] = (GLfloat) param; - fparam[1] = fparam[2] = fparam[3] = 0.0; + fparam[1] = fparam[2] = fparam[3] = 0.0F; save_TexParameterfv(target, pname, fparam); } @@ -3873,7 +3873,7 @@ save_TexParameteriv(GLenum target, GLenum pname, const GLint *params) { GLfloat fparam[4]; fparam[0] = (GLfloat) params[0]; - fparam[1] = fparam[2] = fparam[3] = 0.0; + fparam[1] = fparam[2] = fparam[3] = 0.0F; save_TexParameterfv(target, pname, fparam); } -- cgit v1.2.3 From 20fbb24b67dda0679774756e4b6d98c2c66c2c42 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 27 Jan 2010 17:03:04 -0700 Subject: mesa: fix double->float assignment warnings, int/uint comparison warnings Reported by Karl Schultz. --- src/mesa/shader/nvprogram.c | 4 ++-- src/mesa/shader/prog_execute.c | 4 ++-- src/mesa/shader/prog_optimize.c | 8 ++++---- src/mesa/shader/program.c | 2 +- src/mesa/shader/shader_api.c | 8 ++++---- src/mesa/shader/slang/slang_codegen.c | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/mesa/shader/nvprogram.c b/src/mesa/shader/nvprogram.c index fd6cbb0f40..87f295e39a 100644 --- a/src/mesa/shader/nvprogram.c +++ b/src/mesa/shader/nvprogram.c @@ -515,7 +515,7 @@ _mesa_emit_nv_temp_initialization(GLcontext *ctx, struct gl_program *program) { struct prog_instruction *inst; - int i; + GLuint i; if (!ctx->Shader.EmitNVTempInitialization) return; @@ -559,7 +559,7 @@ _mesa_emit_nv_temp_initialization(GLcontext *ctx, void _mesa_setup_nv_temporary_count(GLcontext *ctx, struct gl_program *program) { - int i; + GLuint i; program->NumTemporaries = 0; for (i = 0; i < program->NumInstructions; i++) { diff --git a/src/mesa/shader/prog_execute.c b/src/mesa/shader/prog_execute.c index c212790dcd..5641014d2c 100644 --- a/src/mesa/shader/prog_execute.c +++ b/src/mesa/shader/prog_execute.c @@ -1017,12 +1017,12 @@ _mesa_execute_program(GLcontext * ctx, /* XXX we could probably just use pow() here */ if (a[0] > 0.0F) { if (a[1] == 0.0 && a[3] == 0.0) - result[2] = 1.0; + result[2] = 1.0F; else result[2] = (GLfloat) _mesa_pow(a[1], a[3]); } else { - result[2] = 0.0; + result[2] = 0.0F; } result[3] = 1.0F; store_vector4(inst, machine, result); diff --git a/src/mesa/shader/prog_optimize.c b/src/mesa/shader/prog_optimize.c index ce411731b2..e1ec52254c 100644 --- a/src/mesa/shader/prog_optimize.c +++ b/src/mesa/shader/prog_optimize.c @@ -459,7 +459,7 @@ _mesa_remove_extra_move_use(struct gl_program *prog) */ for (j = i + 1; j < prog->NumInstructions; j++) { struct prog_instruction *inst2 = prog->Instructions + j; - int arg; + GLuint arg; if (_mesa_is_flow_control_opcode(inst2->Opcode)) break; @@ -867,7 +867,7 @@ find_live_intervals(struct gl_program *prog, _mesa_printf("Reg[%d] live [%d, %d]:", inv->Reg, inv->Start, inv->End); if (1) { - int j; + GLuint j; for (j = 0; j < inv->Start; j++) _mesa_printf(" "); for (j = inv->Start; j <= inv->End; j++) @@ -945,7 +945,7 @@ _mesa_reallocate_registers(struct gl_program *prog) */ { GLint j; - for (j = 0; j < activeIntervals.Num; j++) { + for (j = 0; j < (GLint) activeIntervals.Num; j++) { const struct interval *inv = activeIntervals.Intervals + j; if (inv->End >= live->Start) { /* Stop now. Since the activeInterval list is sorted @@ -994,7 +994,7 @@ _mesa_reallocate_registers(struct gl_program *prog) } } - if (maxTemp + 1 < liveIntervals.Num) { + if (maxTemp + 1 < (GLint) liveIntervals.Num) { /* OK, we've reduced the number of registers needed. * Scan the program and replace all the old temporary register * indexes with the new indexes. diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 6b8d94e661..3e86d0adad 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -580,7 +580,7 @@ _mesa_delete_instructions(struct gl_program *prog, GLuint start, GLuint count) for (i = 0; i < prog->NumInstructions; i++) { struct prog_instruction *inst = prog->Instructions + i; if (inst->BranchTarget > 0) { - if (inst->BranchTarget > start) { + if (inst->BranchTarget > (GLint) start) { inst->BranchTarget -= count; } } diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index e522d7017a..d53580f5f6 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -955,7 +955,7 @@ _mesa_get_active_uniform(GLcontext *ctx, GLuint program, GLuint index, if (size) { GLint typeSize = sizeof_glsl_type(param->DataType); - if (param->Size > typeSize) { + if ((GLint) param->Size > typeSize) { /* This is an array. * Array elements are placed on vector[4] boundaries so they're * a multiple of four floats. We round typeSize up to next multiple @@ -1726,7 +1726,7 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program, const GLint typeSize = sizeof_glsl_type(param->DataType); GLsizei k, i; - if (param->Size > typeSize) { + if ((GLint) param->Size > typeSize) { /* an array */ /* we'll ignore extra data below */ } @@ -1911,7 +1911,7 @@ set_program_uniform_matrix(GLcontext *ctx, struct gl_program *program, GLuint mat, row, col; GLuint src = 0; const struct gl_program_parameter * param = &program->Parameters->Parameters[index]; - const GLint slots = (param->Size + 3) / 4; + const GLuint slots = (param->Size + 3) / 4; const GLint typeSize = sizeof_glsl_type(param->DataType); GLint nr, nc; @@ -1923,7 +1923,7 @@ set_program_uniform_matrix(GLcontext *ctx, struct gl_program *program, return; } - if (param->Size <= typeSize) { + if ((GLint) param->Size <= typeSize) { /* non-array: count must be at most one; count == 0 is handled by the loop below */ if (count > 1) { _mesa_error(ctx, GL_INVALID_OPERATION, diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 372a9acdd0..83098b7350 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -3196,7 +3196,7 @@ _slang_unroll_for_loop(slang_assemble_ctx * A, const slang_operation *oper) newOper = slang_operation_new(1); newOper->type = SLANG_OPER_LITERAL_INT; newOper->literal_size = 1; - newOper->literal[0] = iter; + newOper->literal[0] = (GLfloat) iter; /* replace instances of the loop variable with newOper */ slang_substitute(A, body, 1, &oldVar, &newOper, GL_FALSE); -- cgit v1.2.3 From dd89ac249c56d04bbc23ecd9877426af9f09269c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 27 Jan 2010 17:03:48 -0700 Subject: mesa: fix int/uint comparison warnings Reported by Karl Schultz. --- src/mesa/vbo/vbo_exec_array.c | 10 +++++----- src/mesa/vbo/vbo_split.c | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index bd2fccdba1..d6452cb664 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -49,7 +49,7 @@ vbo_get_minmax_index(GLcontext *ctx, GLuint *min_index, GLuint *max_index) { GLuint i; - GLsizei count = prim->count; + GLuint count = prim->count; const void *indices; if (_mesa_is_bufferobj(ib->obj)) { @@ -132,7 +132,7 @@ check_array_data(GLcontext *ctx, struct gl_client_array *array, case GL_FLOAT: { GLfloat *f = (GLfloat *) ((GLubyte *) data + array->StrideB * j); - GLuint k; + GLint k; for (k = 0; k < array->Size; k++) { if (IS_INF_OR_NAN(f[k]) || f[k] >= 1.0e20 || f[k] <= -1.0e10) { @@ -542,7 +542,7 @@ dump_element_buffer(GLcontext *ctx, GLenum type) case GL_UNSIGNED_BYTE: { const GLubyte *us = (const GLubyte *) map; - GLuint i; + GLint i; for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size; i++) { _mesa_printf("%02x ", us[i]); if (i % 32 == 31) @@ -554,7 +554,7 @@ dump_element_buffer(GLcontext *ctx, GLenum type) case GL_UNSIGNED_SHORT: { const GLushort *us = (const GLushort *) map; - GLuint i; + GLint i; for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size / 2; i++) { _mesa_printf("%04x ", us[i]); if (i % 16 == 15) @@ -566,7 +566,7 @@ dump_element_buffer(GLcontext *ctx, GLenum type) case GL_UNSIGNED_INT: { const GLuint *us = (const GLuint *) map; - GLuint i; + GLint i; for (i = 0; i < ctx->Array.ElementArrayBufferObj->Size / 4; i++) { _mesa_printf("%08x ", us[i]); if (i % 8 == 7) diff --git a/src/mesa/vbo/vbo_split.c b/src/mesa/vbo/vbo_split.c index c445acca7d..ce40cbbcc3 100644 --- a/src/mesa/vbo/vbo_split.c +++ b/src/mesa/vbo/vbo_split.c @@ -108,12 +108,14 @@ void vbo_split_prims( GLcontext *ctx, vbo_draw_func draw, const struct split_limits *limits ) { - GLuint max_basevertex = prim->basevertex; + GLint max_basevertex = prim->basevertex; GLuint i; for (i = 1; i < nr_prims; i++) max_basevertex = MAX2(max_basevertex, prim[i].basevertex); + /* XXX max_basevertex is computed but not used, why? */ + if (ib) { if (limits->max_indices == 0) { /* Could traverse the indices, re-emitting vertices in turn. -- cgit v1.2.3 From 978568c647844693f602364bd9e1041d1cecea4f Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Wed, 27 Jan 2010 16:11:23 -0800 Subject: r300g: Remove unnecessary headers. --- src/gallium/drivers/r300/r300_blit.c | 2 -- src/gallium/drivers/r300/r300_context.c | 4 ---- src/gallium/drivers/r300/r300_debug.c | 2 -- src/gallium/drivers/r300/r300_emit.c | 2 -- src/gallium/drivers/r300/r300_flush.c | 1 - src/gallium/drivers/r300/r300_state.c | 1 - 6 files changed, 12 deletions(-) diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index c14414fff6..11c21e071b 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -23,8 +23,6 @@ #include "r300_blit.h" #include "r300_context.h" -#include "util/u_rect.h" - static void r300_blitter_save_states(struct r300_context* r300) { util_blitter_save_blend(r300->blitter, r300->blend_state.state); diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 052cc23a77..694452a389 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -22,9 +22,6 @@ #include "draw/draw_context.h" -#include "tgsi/tgsi_scan.h" - -#include "util/u_hash_table.h" #include "util/u_memory.h" #include "util/u_simple_list.h" @@ -35,7 +32,6 @@ #include "r300_query.h" #include "r300_render.h" #include "r300_screen.h" -#include "r300_state_derived.h" #include "r300_state_invariant.h" #include "r300_texture.h" #include "r300_winsys.h" diff --git a/src/gallium/drivers/r300/r300_debug.c b/src/gallium/drivers/r300/r300_debug.c index 00d4f31c2b..b881730848 100644 --- a/src/gallium/drivers/r300/r300_debug.c +++ b/src/gallium/drivers/r300/r300_debug.c @@ -22,8 +22,6 @@ #include "r300_context.h" -#include - struct debug_option { const char * name; diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 8bc9da9361..8c5b1607d0 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -32,9 +32,7 @@ #include "r300_emit.h" #include "r300_fs.h" #include "r300_screen.h" -#include "r300_state_derived.h" #include "r300_state_inlines.h" -#include "r300_texture.h" #include "r300_vs.h" void r300_emit_blend_state(struct r300_context* r300, void* state) diff --git a/src/gallium/drivers/r300/r300_flush.c b/src/gallium/drivers/r300/r300_flush.c index 15e612d8a6..e37d309270 100644 --- a/src/gallium/drivers/r300/r300_flush.c +++ b/src/gallium/drivers/r300/r300_flush.c @@ -29,7 +29,6 @@ #include "r300_cs.h" #include "r300_emit.h" #include "r300_flush.h" -#include "r300_state_invariant.h" static void r300_flush(struct pipe_context* pipe, unsigned flags, diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index f3acd16579..b1c9aebd28 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -30,7 +30,6 @@ #include "tgsi/tgsi_parse.h" #include "pipe/p_config.h" -#include "pipe/internal/p_winsys_screen.h" #include "r300_context.h" #include "r300_reg.h" -- cgit v1.2.3 From 714d3ec9bc3e9085fe7caf522dc001198aaf685c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 27 Jan 2010 17:48:15 -0700 Subject: swrast: s/FIXED_TO_FLOAT/FixedToFloat/ --- src/mesa/swrast/s_alpha.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/swrast/s_alpha.c b/src/mesa/swrast/s_alpha.c index ebac562272..509477433a 100644 --- a/src/mesa/swrast/s_alpha.c +++ b/src/mesa/swrast/s_alpha.c @@ -146,8 +146,8 @@ _swrast_alpha_test(const GLcontext *ctx, SWspan *span) ALPHA_TEST(FixedToInt(alpha), alpha += alphaStep); } else { - const GLfloat alphaStep = FIXED_TO_FLOAT(span->alphaStep); - GLfloat alpha = FIXED_TO_FLOAT(span->alpha); + const GLfloat alphaStep = FixedToFloat(span->alphaStep); + GLfloat alpha = FixedToFloat(span->alpha); const GLfloat ref = ctx->Color.AlphaRef; ALPHA_TEST(alpha, alpha += alphaStep); } -- cgit v1.2.3 From c2bd1657a80cec2099e648ec62424d0d06cd6b9b Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Wed, 27 Jan 2010 18:08:37 -0800 Subject: llvmpipe: Remove unnecessary headers. --- src/gallium/drivers/llvmpipe/lp_setup.c | 1 - src/gallium/drivers/llvmpipe/lp_state_derived.c | 1 - src/gallium/drivers/llvmpipe/lp_texture.c | 1 - 3 files changed, 3 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 0b2d3a2801..50b07308c7 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -40,7 +40,6 @@ #include "draw/draw_private.h" #include "draw/draw_vertex.h" #include "pipe/p_shader_tokens.h" -#include "pipe/p_thread.h" #include "util/u_format.h" #include "util/u_math.h" #include "util/u_memory.h" diff --git a/src/gallium/drivers/llvmpipe/lp_state_derived.c b/src/gallium/drivers/llvmpipe/lp_state_derived.c index 6c1ef6bc42..0155b9be50 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_derived.c +++ b/src/gallium/drivers/llvmpipe/lp_state_derived.c @@ -33,7 +33,6 @@ #include "draw/draw_private.h" #include "lp_context.h" #include "lp_screen.h" -#include "lp_tex_cache.h" #include "lp_state.h" diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 039539d682..3701219dcf 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -33,7 +33,6 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "pipe/p_inlines.h" -#include "pipe/internal/p_winsys_screen.h" #include "util/u_format.h" #include "util/u_math.h" -- cgit v1.2.3 From 4030cd5a2d2cea6e0eab602ce6fdd9a558db6275 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 28 Jan 2010 00:20:22 -0800 Subject: st/dri: Remove unnecessary headers. --- src/gallium/state_trackers/dri/dri_drawable.c | 1 - src/gallium/state_trackers/dri/dri_screen.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 28fd8decf1..1f456cb829 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -35,7 +35,6 @@ #include "pipe/p_context.h" #include "pipe/p_screen.h" -#include "pipe/p_inlines.h" #include "main/mtypes.h" #include "main/renderbuffer.h" #include "state_tracker/drm_api.h" diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index cdc8eb1b12..a412b81256 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -37,14 +37,10 @@ #include "dri_context.h" #include "dri_drawable.h" -#include "pipe/p_context.h" #include "pipe/p_screen.h" -#include "pipe/p_inlines.h" #include "pipe/p_format.h" #include "state_tracker/drm_api.h" #include "state_tracker/dri1_api.h" -#include "state_tracker/st_public.h" -#include "state_tracker/st_cb_fbo.h" PUBLIC const char __driConfigOptions[] = DRI_CONF_BEGIN DRI_CONF_SECTION_PERFORMANCE -- cgit v1.2.3 From 347cd2b0d507dad538859ad2d75a005821bc2461 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 28 Jan 2010 00:25:20 -0800 Subject: st/xorg: Remove unnecessary headers. --- src/gallium/state_trackers/xorg/xorg_crtc.c | 1 - src/gallium/state_trackers/xorg/xorg_dri2.c | 1 - src/gallium/state_trackers/xorg/xorg_exa.c | 1 - src/gallium/state_trackers/xorg/xorg_renderer.c | 1 - src/gallium/state_trackers/xorg/xorg_xv.c | 2 -- 5 files changed, 6 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c index 650d2c0d1d..2786558b76 100644 --- a/src/gallium/state_trackers/xorg/xorg_crtc.c +++ b/src/gallium/state_trackers/xorg/xorg_crtc.c @@ -50,7 +50,6 @@ #endif #include "pipe/p_inlines.h" -#include "util/u_format.h" #include "util/u_rect.h" #ifdef HAVE_LIBKMS diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c index 11b81c9ce2..59588f0ff7 100644 --- a/src/gallium/state_trackers/xorg/xorg_dri2.c +++ b/src/gallium/state_trackers/xorg/xorg_dri2.c @@ -41,7 +41,6 @@ #include "pipe/p_inlines.h" #include "util/u_format.h" -#include "util/u_rect.h" /* Make all the #if cases in the code esier to read */ #ifndef DRI2INFOREC_VERSION diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index c91dee7346..70af0c5fed 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -42,7 +42,6 @@ #include "pipe/p_context.h" #include "pipe/p_state.h" -#include "util/u_format.h" #include "util/u_rect.h" #include "util/u_math.h" #include "util/u_debug.h" diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c index 8f729b565b..db3330bc40 100644 --- a/src/gallium/state_trackers/xorg/xorg_renderer.c +++ b/src/gallium/state_trackers/xorg/xorg_renderer.c @@ -5,7 +5,6 @@ #include "cso_cache/cso_context.h" #include "util/u_draw_quad.h" -#include "util/u_format.h" #include "util/u_math.h" #include "util/u_memory.h" #include "util/u_rect.h" diff --git a/src/gallium/state_trackers/xorg/xorg_xv.c b/src/gallium/state_trackers/xorg/xorg_xv.c index 7bcf77e1d3..a3bcd7cb4c 100644 --- a/src/gallium/state_trackers/xorg/xorg_xv.c +++ b/src/gallium/state_trackers/xorg/xorg_xv.c @@ -12,8 +12,6 @@ #include "pipe/p_screen.h" -#include "util/u_format.h" - /*XXX get these from pipe's texture limits */ #define IMAGE_MAX_WIDTH 2048 #define IMAGE_MAX_HEIGHT 2048 -- cgit v1.2.3 From 1eb1d4e23885b4921cff27473aadb93b942865b1 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 28 Jan 2010 00:33:30 -0800 Subject: radeon: Silence "format" compiler warnings. --- src/mesa/drivers/dri/radeon/radeon_queryobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/radeon/radeon_queryobj.c b/src/mesa/drivers/dri/radeon/radeon_queryobj.c index 98117cdfc1..d0dcf0e431 100644 --- a/src/mesa/drivers/dri/radeon/radeon_queryobj.c +++ b/src/mesa/drivers/dri/radeon/radeon_queryobj.c @@ -65,7 +65,7 @@ static void radeonQueryGetResult(GLcontext *ctx, struct gl_query_object *q) } radeon_print(RADEON_STATE, RADEON_TRACE, - "%d start: %lx, end: %lx %ld\n", i, start, end, end - start); + "%d start: %llx, end: %llx %lld\n", i, start, end, end - start); } } else { for (i = 0; i < query->curr_offset/sizeof(uint32_t); ++i) { -- cgit v1.2.3 From 5dcc088bf16c8c4659e5e7c272ab226f0ed95d75 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 28 Jan 2010 00:40:43 -0800 Subject: tgsi: Silence uninitialized variable warning. --- src/gallium/auxiliary/tgsi/tgsi_ureg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index ab557a23f9..b3be3fc412 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -579,7 +579,7 @@ decl_immediate( struct ureg_program *ureg, unsigned type ) { unsigned i, j; - unsigned swizzle; + unsigned swizzle = 0; /* Could do a first pass where we examine all existing immediates * without expanding. -- cgit v1.2.3 From 8f81769148eab0042ffb7192a702350275648715 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 28 Jan 2010 01:19:53 -0800 Subject: scons: Fix GLEW build on Mac OS X. --- src/glew/SConscript | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/glew/SConscript b/src/glew/SConscript index ce6e71e157..45375e083a 100644 --- a/src/glew/SConscript +++ b/src/glew/SConscript @@ -52,6 +52,9 @@ prog_env = env.Clone() prog_env.Prepend(LIBS = [glew]) +if prog_env['platform'] == 'darwin': + prog_env.Append(FRAMEWORKS = ['AGL']) + prog_env.Program( target = 'glewinfo', source = ['glewinfo.c'], -- cgit v1.2.3 From a933259daa98615ad7473c53623a96f612e9a311 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 27 Jan 2010 23:55:58 +0800 Subject: egl: Use a boolean to indicate whether a display is initialized. The driver pointer of the display was used to decide whether a display is initialized. Use a boolean for that purpose allows accessing the driver of an uninitialized display. --- src/egl/main/eglapi.c | 35 +++++++++++++++++++---------------- src/egl/main/egldisplay.h | 1 + 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 90828bd3e9..2c26dfada8 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -94,19 +94,20 @@ EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) { _EGLDisplay *disp = _eglLookupDisplay(dpy); - _EGLDriver *drv; EGLint major_int, minor_int; if (!disp) return _eglError(EGL_BAD_DISPLAY, __FUNCTION__); - drv = disp->Driver; - if (!drv) { - _eglPreloadDrivers(); + if (!disp->Initialized) { + _EGLDriver *drv = disp->Driver; - drv = _eglMatchDriver(disp); - if (!drv) - return _eglError(EGL_NOT_INITIALIZED, __FUNCTION__); + if (!drv) { + _eglPreloadDrivers(); + drv = _eglMatchDriver(disp); + if (!drv) + return _eglError(EGL_NOT_INITIALIZED, __FUNCTION__); + } /* Initialize the particular display now */ if (!drv->API.Initialize(drv, disp, &major_int, &minor_int)) @@ -121,6 +122,7 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) disp->ClientAPIsMask &= _EGL_API_ALL_BITS; disp->Driver = drv; + disp->Initialized = EGL_TRUE; } else { major_int = disp->APImajor; minor_int = disp->APIminor; @@ -140,15 +142,16 @@ EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy) { _EGLDisplay *disp = _eglLookupDisplay(dpy); - _EGLDriver *drv; if (!disp) return _eglError(EGL_BAD_DISPLAY, __FUNCTION__); - drv = disp->Driver; - if (drv) { + if (disp->Initialized) { + _EGLDriver *drv = disp->Driver; + drv->API.Terminate(drv, disp); - disp->Driver = NULL; + /* do not reset disp->Driver */ + disp->Initialized = EGL_FALSE; } return EGL_TRUE; @@ -165,7 +168,7 @@ _eglCheckDisplay(_EGLDisplay *disp, const char *msg) _eglError(EGL_BAD_DISPLAY, msg); return NULL; } - if (!disp->Driver) { + if (!disp->Initialized) { _eglError(EGL_NOT_INITIALIZED, msg); return NULL; } @@ -572,8 +575,8 @@ eglWaitClient(void) /* a valid current context implies an initialized current display */ disp = ctx->Resource.Display; + assert(disp->Initialized); drv = disp->Driver; - assert(drv); return drv->API.WaitClient(drv, disp, ctx); } @@ -616,8 +619,8 @@ eglWaitNative(EGLint engine) /* a valid current context implies an initialized current display */ disp = ctx->Resource.Display; + assert(disp->Initialized); drv = disp->Driver; - assert(drv); return drv->API.WaitNative(drv, disp, engine); } @@ -991,8 +994,8 @@ eglReleaseThread(void) if (ctx) { _EGLDisplay *disp = ctx->Resource.Display; _EGLDriver *drv = disp->Driver; - /* what if drv is not avaialbe? */ - if (drv) + /* what if display is not initialized? */ + if (disp->Initialized) (void) drv->API.MakeCurrent(drv, disp, NULL, NULL, NULL); } } diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 8f74ad23a8..4aea10c3eb 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -49,6 +49,7 @@ struct _egl_display EGLNativeDisplayType NativeDisplay; + EGLBoolean Initialized; /**< True if the display is initialized */ _EGLDriver *Driver; void *DriverData; /* private to driver */ -- cgit v1.2.3 From 959481ad70b033a254f4d7d0a94dfdfab6b94c15 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 27 Jan 2010 23:31:20 +0800 Subject: egl: Add _eglBindContext. It works similar to _eglMakeCurrent, except that the old context and surfaces are returned instead of destroyed. _eglMakeCurrent is now calling the new _eglBindContext. --- src/egl/main/eglcontext.c | 123 ++++++++++++++++++++++++++-------------------- src/egl/main/eglcontext.h | 4 ++ 2 files changed, 74 insertions(+), 53 deletions(-) diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index deaa8d3f41..4a9a47204c 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -140,34 +140,31 @@ _eglQueryContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *c, /** - * Bind the context to the surface as the draw or read surface. Return the - * previous surface that the context is bound to. - * - * Note that the context may be NULL. + * Bind the context to the surfaces. Return the surfaces that are "orphaned". + * That is, when the context is not NULL, return the surfaces it previously + * bound to; when the context is NULL, the same surfaces are returned. */ -static _EGLSurface * -_eglBindContextToSurface(_EGLContext *ctx, _EGLSurface *surf, EGLint readdraw) +static void +_eglBindContextToSurfaces(_EGLContext *ctx, + _EGLSurface **draw, _EGLSurface **read) { - _EGLSurface **attachment, *oldSurf; - - if (!ctx) { - surf->Binding = NULL; - return NULL; - } + _EGLSurface *newDraw = *draw, *newRead = *read; - attachment = (readdraw == EGL_DRAW) ? - &ctx->DrawSurface : &ctx->ReadSurface; - oldSurf = *attachment; + if (newDraw->Binding) + newDraw->Binding->DrawSurface = NULL; + newDraw->Binding = ctx; - if (oldSurf == surf) - return NULL; + if (newRead->Binding) + newRead->Binding->ReadSurface = NULL; + newRead->Binding = ctx; - if (oldSurf) - oldSurf->Binding = NULL; - surf->Binding = ctx; - *attachment = surf; + if (ctx) { + *draw = ctx->DrawSurface; + ctx->DrawSurface = newDraw; - return oldSurf; + *read = ctx->ReadSurface; + ctx->ReadSurface = newRead; + } } @@ -271,6 +268,47 @@ _eglCheckMakeCurrent(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read) } +/** + * Bind the context to the current thread and given surfaces. Return the + * previously bound context and the surfaces it bound to. Each argument is + * both input and output. + */ +EGLBoolean +_eglBindContext(_EGLContext **ctx, _EGLSurface **draw, _EGLSurface **read) +{ + _EGLThreadInfo *t = _eglGetCurrentThread(); + _EGLContext *newCtx = *ctx, *oldCtx; + + if (!_eglCheckMakeCurrent(newCtx, *draw, *read)) + return EGL_FALSE; + + /* bind the new context */ + oldCtx = _eglBindContextToThread(newCtx, t); + *ctx = oldCtx; + if (newCtx) + _eglBindContextToSurfaces(newCtx, draw, read); + + /* unbind the old context from its binding surfaces */ + if (oldCtx) { + /* + * If the new context replaces some old context, the new one should not + * be current before the replacement and it should not be bound to any + * surface. + */ + if (newCtx) + assert(!*draw && !*read); + + *draw = oldCtx->DrawSurface; + *read = oldCtx->ReadSurface; + assert(*draw && *read); + + _eglBindContextToSurfaces(NULL, draw, read); + } + + return EGL_TRUE; +} + + /** * Drivers will typically call this to do the error checking and * update the various flags. @@ -280,40 +318,19 @@ EGLBoolean _eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, _EGLSurface *read, _EGLContext *ctx) { - _EGLThreadInfo *t = _eglGetCurrentThread(); - _EGLSurface *oldDraw = NULL, *oldRead = NULL; - _EGLContext *oldCtx; - - if (!_eglCheckMakeCurrent(ctx, draw, read)) + if (!_eglBindContext(&ctx, &draw, &read)) return EGL_FALSE; - oldCtx = _eglBindContextToThread(ctx, t); - - if (ctx) { - oldDraw = _eglBindContextToSurface(ctx, draw, EGL_DRAW); - oldRead = _eglBindContextToSurface(ctx, read, EGL_READ); - } - else if (oldCtx) { - /* unbind the old context from its binding surfaces */ - oldDraw = oldCtx->DrawSurface; - oldRead = oldCtx->ReadSurface; - - if (oldDraw) - _eglBindContextToSurface(NULL, oldDraw, EGL_DRAW); - if (oldRead && oldRead != oldDraw) - _eglBindContextToSurface(NULL, oldRead, EGL_READ); - } - /* avoid double destroy */ - if (oldRead && oldRead == oldDraw) - oldRead = NULL; - - if (oldCtx && !_eglIsContextLinked(oldCtx)) - drv->API.DestroyContext(drv, dpy, oldCtx); - if (oldDraw && !_eglIsSurfaceLinked(oldDraw)) - drv->API.DestroySurface(drv, dpy, oldDraw); - if (oldRead && !_eglIsSurfaceLinked(oldRead)) - drv->API.DestroySurface(drv, dpy, oldRead); + if (read && read == draw) + read = NULL; + + if (ctx && !_eglIsContextLinked(ctx)) + drv->API.DestroyContext(drv, dpy, ctx); + if (draw && !_eglIsSurfaceLinked(draw)) + drv->API.DestroySurface(drv, dpy, draw); + if (read && !_eglIsSurfaceLinked(read)) + drv->API.DestroySurface(drv, dpy, read); return EGL_TRUE; } diff --git a/src/egl/main/eglcontext.h b/src/egl/main/eglcontext.h index be00642d13..84d8deed51 100644 --- a/src/egl/main/eglcontext.h +++ b/src/egl/main/eglcontext.h @@ -47,6 +47,10 @@ extern EGLBoolean _eglQueryContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLint attribute, EGLint *value); +PUBLIC EGLBoolean +_eglBindContext(_EGLContext **ctx, _EGLSurface **draw, _EGLSurface **read); + + PUBLIC EGLBoolean _eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, _EGLSurface *read, _EGLContext *ctx); -- cgit v1.2.3 From 17330479b39409a63a06ec9e6b0f8e28b585db12 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 27 Jan 2010 23:51:54 +0800 Subject: egl: eglMakeCurrent should accept an uninitialized display. When no context or surface are given, the display is allowed to be uninitialized. Most drivers cannot handle an uninitialized display. But they are updated to at least throw a fatal message. --- src/egl/drivers/glx/egl_glx.c | 64 +++++++++++-------------- src/egl/drivers/xdri/egl_xdri.c | 53 ++++++++++++++------ src/egl/main/eglapi.c | 18 +++++-- src/egl/main/eglapi.h | 1 + src/egl/main/eglcontext.c | 23 +++++---- src/gallium/state_trackers/egl/common/egl_g3d.c | 40 ++++++++++++---- 6 files changed, 124 insertions(+), 75 deletions(-) diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c index 89a4353f8a..5efb72e875 100644 --- a/src/egl/drivers/glx/egl_glx.c +++ b/src/egl/drivers/glx/egl_glx.c @@ -103,6 +103,8 @@ struct GLX_egl_surface Drawable drawable; GLXDrawable glx_drawable; + + void (*destroy)(Display *, GLXDrawable); }; @@ -630,6 +632,21 @@ GLX_eglCreateContext(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, } +/** + * Destroy a surface. The display is allowed to be uninitialized. + */ +static void +destroy_surface(_EGLDisplay *disp, _EGLSurface *surf) +{ + struct GLX_egl_surface *GLX_surf = GLX_egl_surface(surf); + + if (GLX_surf->destroy) + GLX_surf->destroy(disp->NativeDisplay, GLX_surf->glx_drawable); + + free(GLX_surf); +} + + /** * Called via eglMakeCurrent(), drv->API.MakeCurrent(). */ @@ -712,6 +729,9 @@ GLX_eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *disp, return NULL; } + if (GLX_dpy->have_1_3 && !GLX_dpy->glx_window_quirk) + GLX_surf->destroy = glXDestroyWindow; + get_drawable_size(GLX_dpy->dpy, window, &width, &height); GLX_surf->Base.Width = width; GLX_surf->Base.Height = height; @@ -769,6 +789,9 @@ GLX_eglCreatePixmapSurface(_EGLDriver *drv, _EGLDisplay *disp, return NULL; } + GLX_surf->destroy = (GLX_dpy->have_1_3) ? + glXDestroyPixmap : glXDestroyGLXPixmap; + get_drawable_size(GLX_dpy->dpy, pixmap, &width, &height); GLX_surf->Base.Width = width; GLX_surf->Base.Height = height; @@ -833,47 +856,18 @@ GLX_eglCreatePbufferSurface(_EGLDriver *drv, _EGLDisplay *disp, return NULL; } + GLX_surf->destroy = (GLX_dpy->have_1_3) ? + glXDestroyPbuffer : GLX_dpy->glXDestroyGLXPbufferSGIX; + return &GLX_surf->Base; } + static EGLBoolean GLX_eglDestroySurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) { - struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp); - if (!_eglIsSurfaceBound(surf)) { - struct GLX_egl_surface *GLX_surf = GLX_egl_surface(surf); - - if (GLX_dpy->have_1_3) { - switch (surf->Type) { - case EGL_WINDOW_BIT: - if (!GLX_dpy->glx_window_quirk) - glXDestroyWindow(GLX_dpy->dpy, GLX_surf->glx_drawable); - break; - case EGL_PBUFFER_BIT: - glXDestroyPbuffer(GLX_dpy->dpy, GLX_surf->glx_drawable); - break; - case EGL_PIXMAP_BIT: - glXDestroyPixmap(GLX_dpy->dpy, GLX_surf->glx_drawable); - break; - default: - break; - } - } - else { - switch (surf->Type) { - case EGL_PBUFFER_BIT: - GLX_dpy->glXDestroyGLXPbufferSGIX(GLX_dpy->dpy, - GLX_surf->glx_drawable); - break; - case EGL_PIXMAP_BIT: - glXDestroyGLXPixmap(GLX_dpy->dpy, GLX_surf->glx_drawable); - break; - default: - break; - } - } - free(surf); - } + if (!_eglIsSurfaceBound(surf)) + destroy_surface(disp, surf); return EGL_TRUE; } diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index e13d884e71..26fe95b043 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -419,19 +419,47 @@ xdri_eglCreateContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, } -static EGLBoolean -xdri_eglDestroyContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) +/** + * Destroy a context. + */ +static void +destroy_context(_EGLDisplay *dpy, _EGLContext *ctx) { struct xdri_egl_display *xdri_dpy = lookup_display(dpy); struct xdri_egl_context *xdri_ctx = lookup_context(ctx); - if (!_eglIsContextBound(ctx)) { - xdri_ctx->driContext->destroyContext(xdri_ctx->driContext, - xdri_dpy->psc, xdri_dpy->dpy); - free(xdri_ctx->dummy_gc); - free(xdri_ctx); - } + /* FIXME a context might live longer than its display */ + if (!dpy->Initialized) + _eglLog(_EGL_FATAL, "destroy a context with an unitialized display"); + + xdri_ctx->driContext->destroyContext(xdri_ctx->driContext, + xdri_dpy->psc, xdri_dpy->dpy); + free(xdri_ctx->dummy_gc); + free(xdri_ctx); +} + +/** + * Destroy a surface. + */ +static void +destroy_surface(_EGLDisplay *dpy, _EGLSurface *surf) +{ + struct xdri_egl_surface *xdri_surf = lookup_surface(surf); + + if (!dpy->Initialized) + _eglLog(_EGL_FATAL, "destroy a surface with an unitialized display"); + + xdri_surf->driDrawable->destroyDrawable(xdri_surf->driDrawable); + free(xdri_surf); +} + + +static EGLBoolean +xdri_eglDestroyContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) +{ + if (!_eglIsContextBound(ctx)) + destroy_context(dpy, ctx); return EGL_TRUE; } @@ -539,13 +567,8 @@ xdri_eglCreatePbufferSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf static EGLBoolean xdri_eglDestroySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface) { - struct xdri_egl_surface *xdri_surf = lookup_surface(surface); - - if (!_eglIsSurfaceBound(&xdri_surf->Base)) { - xdri_surf->driDrawable->destroyDrawable(xdri_surf->driDrawable); - free(xdri_surf); - } - + if (!_eglIsSurfaceBound(surface)) + destroy_surface(dpy, surface); return EGL_TRUE; } diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 2c26dfada8..d0f9749f84 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -394,9 +394,19 @@ eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, _EGLSurface *read_surf = _eglLookupSurface(read, disp); _EGLDriver *drv; - drv = _eglCheckDisplay(disp, __FUNCTION__); + if (!disp) + return _eglError(EGL_BAD_DISPLAY, __FUNCTION__); + drv = disp->Driver; + + /* display is allowed to be uninitialized under certain condition */ + if (!disp->Initialized) { + if (draw != EGL_NO_SURFACE || read != EGL_NO_SURFACE || + ctx != EGL_NO_CONTEXT) + return _eglError(EGL_BAD_DISPLAY, __FUNCTION__); + } if (!drv) - return EGL_FALSE; + return EGL_TRUE; + if (!context && ctx != EGL_NO_CONTEXT) return _eglError(EGL_BAD_CONTEXT, __FUNCTION__); if ((!draw_surf && draw != EGL_NO_SURFACE) || @@ -994,9 +1004,7 @@ eglReleaseThread(void) if (ctx) { _EGLDisplay *disp = ctx->Resource.Display; _EGLDriver *drv = disp->Driver; - /* what if display is not initialized? */ - if (disp->Initialized) - (void) drv->API.MakeCurrent(drv, disp, NULL, NULL, NULL); + (void) drv->API.MakeCurrent(drv, disp, NULL, NULL, NULL); } } } diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h index db31c7cf93..a7600820f3 100644 --- a/src/egl/main/eglapi.h +++ b/src/egl/main/eglapi.h @@ -23,6 +23,7 @@ typedef EGLBoolean (*GetConfigAttrib_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLC /* context funcs */ typedef _EGLContext *(*CreateContext_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *config, _EGLContext *share_list, const EGLint *attrib_list); typedef EGLBoolean (*DestroyContext_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx); +/* this is the only function (other than Initialize) that may be called with an uninitialized display */ typedef EGLBoolean (*MakeCurrent_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, _EGLSurface *read, _EGLContext *ctx); typedef EGLBoolean (*QueryContext_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLint attribute, EGLint *value); diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index 4a9a47204c..60d2efd44b 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -321,16 +321,19 @@ _eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, if (!_eglBindContext(&ctx, &draw, &read)) return EGL_FALSE; - /* avoid double destroy */ - if (read && read == draw) - read = NULL; - - if (ctx && !_eglIsContextLinked(ctx)) - drv->API.DestroyContext(drv, dpy, ctx); - if (draw && !_eglIsSurfaceLinked(draw)) - drv->API.DestroySurface(drv, dpy, draw); - if (read && !_eglIsSurfaceLinked(read)) - drv->API.DestroySurface(drv, dpy, read); + /* nothing we can do if the display is uninitialized */ + if (dpy->Initialized) { + /* avoid double destroy */ + if (read && read == draw) + read = NULL; + + if (ctx && !_eglIsContextLinked(ctx)) + drv->API.DestroyContext(drv, dpy, ctx); + if (draw && !_eglIsSurfaceLinked(draw)) + drv->API.DestroySurface(drv, dpy, draw); + if (read && !_eglIsSurfaceLinked(read)) + drv->API.DestroySurface(drv, dpy, read); + } return EGL_TRUE; } diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index aa4f012216..657c771a6b 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -672,21 +672,30 @@ egl_g3d_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, return &gctx->base; } -static EGLBoolean -egl_g3d_destroy_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) +/** + * Destroy a context. + */ +static void +destroy_context(_EGLDisplay *dpy, _EGLContext *ctx) { struct egl_g3d_context *gctx = egl_g3d_context(ctx); - if (_eglIsContextBound(&gctx->base)) - return EGL_TRUE; + /* FIXME a context might live longer than its display */ + if (!dpy->Initialized) + _eglLog(_EGL_FATAL, "destroy a context with an unitialized display"); egl_g3d_realloc_context(dpy, &gctx->base); - - /* it will destroy pipe context */ + /* it will destroy the associated pipe context */ gctx->stapi->st_destroy_context(gctx->st_ctx); free(gctx); +} +static EGLBoolean +egl_g3d_destroy_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) +{ + if (!_eglIsContextBound(ctx)) + destroy_context(dpy, ctx); return EGL_TRUE; } @@ -817,17 +826,28 @@ egl_g3d_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy, return &gsurf->base; } -static EGLBoolean -egl_g3d_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) +/** + * Destroy a surface. + */ +static void +destroy_surface(_EGLDisplay *dpy, _EGLSurface *surf) { struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - if (_eglIsSurfaceBound(&gsurf->base)) - return EGL_TRUE; + /* FIXME a surface might live longer than its display */ + if (!dpy->Initialized) + _eglLog(_EGL_FATAL, "destroy a surface with an unitialized display"); pipe_surface_reference(&gsurf->render_surface, NULL); gsurf->native->destroy(gsurf->native); free(gsurf); +} + +static EGLBoolean +egl_g3d_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) +{ + if (!_eglIsSurfaceBound(surf)) + destroy_surface(dpy, surf); return EGL_TRUE; } -- cgit v1.2.3 From 45ba53324341234144ca02122bf2c0b5ef58c361 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 28 Jan 2010 16:49:40 +0800 Subject: egl: Correctly unbind contexts in eglReleaseThread. MakeCurrent unbinds the current context of the current API. Modify the current API to make sure all contexts are correctly unbound. --- src/egl/main/eglapi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index d0f9749f84..7e77ef1f03 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -997,6 +997,7 @@ eglReleaseThread(void) /* unbind current contexts */ if (!_eglIsCurrentThreadDummy()) { _EGLThreadInfo *t = _eglGetCurrentThread(); + EGLint api_index = t->CurrentAPIIndex; EGLint i; for (i = 0; i < _EGL_API_NUM_APIS; i++) { @@ -1004,9 +1005,12 @@ eglReleaseThread(void) if (ctx) { _EGLDisplay *disp = ctx->Resource.Display; _EGLDriver *drv = disp->Driver; + t->CurrentAPIIndex = i; (void) drv->API.MakeCurrent(drv, disp, NULL, NULL, NULL); } } + + t->CurrentAPIIndex = api_index; } _eglDestroyCurrentThread(); -- cgit v1.2.3 From 6baa2c8d022e5dd1e305e7da2925c1e6f9370f35 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 28 Jan 2010 16:57:49 +0800 Subject: egl: Migrate drivers to use _eglBindContext. _eglMakeCurrent is a big hammer that is not easy to use. Migrate drivers to use _eglBindContext and un-export _eglMakeCurrent. --- src/egl/drivers/glx/egl_glx.c | 20 ++++++++++++++++---- src/egl/drivers/xdri/egl_xdri.c | 21 ++++++++++++--------- src/egl/main/eglcontext.c | 23 ++--------------------- src/egl/main/eglcontext.h | 2 +- src/gallium/state_trackers/egl/common/egl_g3d.c | 21 +++++++++++---------- 5 files changed, 42 insertions(+), 45 deletions(-) diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c index 5efb72e875..1c38db6491 100644 --- a/src/egl/drivers/glx/egl_glx.c +++ b/src/egl/drivers/glx/egl_glx.c @@ -660,8 +660,10 @@ GLX_eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf, struct GLX_egl_context *GLX_ctx = GLX_egl_context(ctx); GLXDrawable ddraw, rdraw; GLXContext cctx; + EGLBoolean ret = EGL_FALSE; - if (!_eglMakeCurrent(drv, disp, dsurf, rsurf, ctx)) + /* bind the new context and return the "orphaned" one */ + if (!_eglBindContext(&ctx, &dsurf, &rsurf)) return EGL_FALSE; ddraw = (GLX_dsurf) ? GLX_dsurf->glx_drawable : None; @@ -669,11 +671,21 @@ GLX_eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf, cctx = (GLX_ctx) ? GLX_ctx->context : NULL; if (GLX_dpy->have_make_current_read) - return glXMakeContextCurrent(GLX_dpy->dpy, ddraw, rdraw, cctx); + ret = glXMakeContextCurrent(GLX_dpy->dpy, ddraw, rdraw, cctx); else if (ddraw == rdraw) - return glXMakeCurrent(GLX_dpy->dpy, ddraw, cctx); + ret = glXMakeCurrent(GLX_dpy->dpy, ddraw, cctx); - return EGL_FALSE; + if (ret) { + if (dsurf && !_eglIsSurfaceLinked(dsurf)) + destroy_surface(disp, dsurf); + if (rsurf && rsurf != dsurf && !_eglIsSurfaceLinked(rsurf)) + destroy_surface(disp, rsurf); + } + else { + _eglBindContext(&ctx, &dsurf, &rsurf); + } + + return ret; } /** Get size of given window */ diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index 26fe95b043..2ca9ea8a5b 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -475,17 +475,13 @@ xdri_eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *d, struct xdri_egl_context *xdri_ctx = lookup_context(context); struct xdri_egl_surface *draw = lookup_surface(d); struct xdri_egl_surface *read = lookup_surface(r); - _EGLContext *old = _eglGetCurrentContext(); - /* an unlinked context will be invalid after context switch */ - if (!_eglIsContextLinked(old)) - old = NULL; - - if (!_eglMakeCurrent(drv, dpy, d, r, context)) + /* bind the new context and return the "orphaned" one */ + if (!_eglBindContext(&context, &d, &r)) return EGL_FALSE; /* flush before context switch */ - if (old && old != context && xdri_driver->FlushCurrentContext) + if (context && xdri_driver->FlushCurrentContext) xdri_driver->FlushCurrentContext(); /* the symbol is defined in libGL.so */ @@ -498,11 +494,18 @@ xdri_eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *d, return EGL_FALSE; } } - else if (old) { - xdri_ctx = lookup_context(old); + else if (context) { + xdri_ctx = lookup_context(context); xdri_ctx->driContext->unbindContext(xdri_ctx->driContext); } + if (context && !_eglIsContextLinked(context)) + destroy_context(dpy, context); + if (d && !_eglIsSurfaceLinked(d)) + destroy_surface(dpy, d); + if (r && r != d && !_eglIsSurfaceLinked(r)) + destroy_surface(dpy, r); + return EGL_TRUE; } diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index 60d2efd44b..4496f76ece 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -310,32 +310,13 @@ _eglBindContext(_EGLContext **ctx, _EGLSurface **draw, _EGLSurface **read) /** - * Drivers will typically call this to do the error checking and - * update the various flags. - * Then, the driver will do its device-dependent Make-Current stuff. + * Just a placeholder/demo function. Drivers should override this. */ EGLBoolean _eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, _EGLSurface *read, _EGLContext *ctx) { - if (!_eglBindContext(&ctx, &draw, &read)) - return EGL_FALSE; - - /* nothing we can do if the display is uninitialized */ - if (dpy->Initialized) { - /* avoid double destroy */ - if (read && read == draw) - read = NULL; - - if (ctx && !_eglIsContextLinked(ctx)) - drv->API.DestroyContext(drv, dpy, ctx); - if (draw && !_eglIsSurfaceLinked(draw)) - drv->API.DestroySurface(drv, dpy, draw); - if (read && !_eglIsSurfaceLinked(read)) - drv->API.DestroySurface(drv, dpy, read); - } - - return EGL_TRUE; + return EGL_FALSE; } diff --git a/src/egl/main/eglcontext.h b/src/egl/main/eglcontext.h index 84d8deed51..4811e3bb7a 100644 --- a/src/egl/main/eglcontext.h +++ b/src/egl/main/eglcontext.h @@ -51,7 +51,7 @@ PUBLIC EGLBoolean _eglBindContext(_EGLContext **ctx, _EGLSurface **draw, _EGLSurface **read); -PUBLIC EGLBoolean +extern EGLBoolean _eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, _EGLSurface *read, _EGLContext *ctx); diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index 657c771a6b..f8334217c4 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -856,18 +856,14 @@ egl_g3d_make_current(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, _EGLSurface *read, _EGLContext *ctx) { struct egl_g3d_context *gctx = egl_g3d_context(ctx); + struct egl_g3d_surface *gdraw = egl_g3d_surface(draw); struct egl_g3d_context *old_gctx; - EGLint api; EGLBoolean ok = EGL_TRUE; - /* find the old context */ - api = (gctx) ? gctx->base.ClientAPI : eglQueryAPI(); - old_gctx = egl_g3d_get_current_context(api); - if (old_gctx && !_eglIsContextLinked(&old_gctx->base)) - old_gctx = NULL; - - if (!_eglMakeCurrent(drv, dpy, draw, read, ctx)) + /* bind the new context and return the "orphaned" one */ + if (!_eglBindContext(&ctx, &draw, &read)) return EGL_FALSE; + old_gctx = egl_g3d_context(ctx); if (old_gctx) { /* flush old context */ @@ -883,8 +879,6 @@ egl_g3d_make_current(_EGLDriver *drv, _EGLDisplay *dpy, } if (gctx) { - struct egl_g3d_surface *gdraw = egl_g3d_surface(draw); - ok = egl_g3d_realloc_context(dpy, &gctx->base); if (ok) { ok = gctx->stapi->st_make_current(gctx->st_ctx, @@ -904,6 +898,13 @@ egl_g3d_make_current(_EGLDriver *drv, _EGLDisplay *dpy, old_gctx->base.WindowRenderBuffer = EGL_NONE; } + if (ctx && !_eglIsContextLinked(ctx)) + destroy_context(dpy, ctx); + if (draw && !_eglIsSurfaceLinked(draw)) + destroy_surface(dpy, draw); + if (read && read != draw && !_eglIsSurfaceLinked(read)) + destroy_surface(dpy, read); + return ok; } -- cgit v1.2.3 From 51ab599ddb213d6b846f333bbf03d5f6dde4831f Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 28 Jan 2010 01:32:15 -0800 Subject: scons: Do not use linker option '-Bsymbolic' on Mac OS X. ld on Mac OS X does not recognize the option '-Bsymbolic'. --- scons/gallium.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scons/gallium.py b/scons/gallium.py index 91a2fbbca6..467b67fad7 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -393,9 +393,10 @@ def generate(env): linkflags += ['-m32'] if env['machine'] == 'x86_64': linkflags += ['-m64'] - shlinkflags += [ - '-Wl,-Bsymbolic', - ] + if env['platform'] not in ('darwin'): + shlinkflags += [ + '-Wl,-Bsymbolic', + ] # Handle circular dependencies in the libraries if env['platform'] in ('darwin'): pass -- cgit v1.2.3 From 14cbf324dc57f8caa4a61dff5146b43cfc42c834 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 27 Jan 2010 23:18:22 +0800 Subject: docs: Update the developer section of egl.html. Mainly to add a subsection on the lifetime of display resources. --- docs/egl.html | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/docs/egl.html b/docs/egl.html index 305e5f6eab..57b1d1488a 100644 --- a/docs/egl.html +++ b/docs/egl.html @@ -223,9 +223,43 @@ runtime.

    Developers

    -The sources of the main library and the classic drivers can be found at +

    The sources of the main library and the classic drivers can be found at src/egl/. The sources of the egl state tracker can -be found at src/gallium/state_trackers/egl/. +be found at src/gallium/state_trackers/egl/.

    + +

    The suggested way to learn to write a EGL driver is to see how other drivers +are written. egl_glx should be a good reference. It works in any +environment that has GLX support, and it is simpler than most drivers.

    + +

    Lifetime of Display Resources

    + +

    Contexts and surfaces are examples of display resources. They might live +longer than the display that creates them.

    + +

    In EGL, when a display is terminated through eglTerminate, all +display resources should be destroyed. Similarly, when a thread is released +throught eglReleaseThread, all current display resources should be +released. Another way to destory or release resources is through functions +such as eglDestroySurface or eglMakeCurrent.

    + +

    When a resource that is current to some thread is destroyed, the resource +should not be destroyed immediately. EGL requires the resource to live until +it is no longer current. A driver usually calls +eglIs<Resource>Bound to check if a resource is bound +(current) to any thread in the destroy callbacks. If it is still bound, the +resource is not destroyed.

    + +

    The main library will mark destroyed current resources as unlinked. In a +driver's MakeCurrent callback, +eglIs<Resource>Linked can then be called to check if a newly +released resource is linked to a display. If it is not, the last reference to +the resource is removed and the driver should destroy the resource. But it +should be careful here because MakeCurrent might be called with an +uninitialized display.

    + +

    This is the only mechanism provided by the main library to help manage the +resources. The drivers are responsible to the correct behavior as defined by +EGL.

    TODOs

    -- cgit v1.2.3 From b9ae570bab5d0fefef93a9f6808603971304a74d Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 27 Jan 2010 21:31:36 -0800 Subject: r300g: Atomize framebuffers. There might be some optimizations possible here... --- src/gallium/drivers/r300/r300_blit.c | 12 ++++++----- src/gallium/drivers/r300/r300_context.c | 1 + src/gallium/drivers/r300/r300_context.h | 5 ++--- src/gallium/drivers/r300/r300_emit.c | 36 ++++++++++++++++----------------- src/gallium/drivers/r300/r300_emit.h | 3 +-- src/gallium/drivers/r300/r300_state.c | 18 +++++++++++++---- 6 files changed, 43 insertions(+), 32 deletions(-) diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index 11c21e071b..cdedb30220 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -73,13 +73,15 @@ void r300_clear(struct pipe_context* pipe, */ struct r300_context* r300 = r300_context(pipe); + struct pipe_framebuffer_state* fb = + (struct pipe_framebuffer_state*)r300->fb_state.state; r300_blitter_save_states(r300); util_blitter_clear(r300->blitter, - r300->framebuffer_state.width, - r300->framebuffer_state.height, - r300->framebuffer_state.nr_cbufs, + fb->width, + fb->height, + fb->nr_cbufs, buffers, rgba, depth, stencil); } @@ -97,7 +99,7 @@ void r300_surface_copy(struct pipe_context* pipe, * is really transparent. The states will be restored by the blitter once * copying is done. */ r300_blitter_save_states(r300); - util_blitter_save_framebuffer(r300->blitter, &r300->framebuffer_state); + util_blitter_save_framebuffer(r300->blitter, r300->fb_state.state); util_blitter_save_fragment_sampler_states( r300->blitter, r300->sampler_count, (void**)r300->sampler_states); @@ -121,7 +123,7 @@ void r300_surface_fill(struct pipe_context* pipe, struct r300_context* r300 = r300_context(pipe); r300_blitter_save_states(r300); - util_blitter_save_framebuffer(r300->blitter, &r300->framebuffer_state); + util_blitter_save_framebuffer(r300->blitter, r300->fb_state.state); util_blitter_fill(r300->blitter, dst, dstx, dsty, width, height, value); diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 694452a389..9837530a7a 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -118,6 +118,7 @@ static void r300_setup_atoms(struct r300_context* r300) R300_INIT_ATOM(blend_color, 3); R300_INIT_ATOM(clip, 29); R300_INIT_ATOM(dsa, 8); + R300_INIT_ATOM(fb, 56); R300_INIT_ATOM(rs, 25); R300_INIT_ATOM(scissor, 3); R300_INIT_ATOM(viewport, 9); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index c4c137d6f8..3f461640a0 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -139,7 +139,6 @@ struct r300_ztop_state { uint32_t z_buffer_top; /* R300_ZB_ZTOP: 0x4f14 */ }; -#define R300_NEW_FRAMEBUFFERS 0x00000010 #define R300_NEW_FRAGMENT_SHADER 0x00000020 #define R300_NEW_FRAGMENT_SHADER_CONSTANTS 0x00000040 #define R300_NEW_SAMPLER 0x00000200 @@ -288,8 +287,8 @@ struct r300_context { struct r300_atom dsa_state; /* Fragment shader. */ struct r300_fragment_shader* fs; - /* Framebuffer state. We currently don't need our own version of this. */ - struct pipe_framebuffer_state framebuffer_state; + /* Framebuffer state. */ + struct r300_atom fb_state; /* Rasterizer state. */ struct r300_atom rs_state; /* RS block state. */ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 8c5b1607d0..f1d32764fd 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -38,12 +38,14 @@ void r300_emit_blend_state(struct r300_context* r300, void* state) { struct r300_blend_state* blend = (struct r300_blend_state*)state; + struct pipe_framebuffer_state* fb = + (struct pipe_framebuffer_state*)r300->fb_state.state; CS_LOCALS(r300); BEGIN_CS(8); OUT_CS_REG(R300_RB3D_ROPCNTL, blend->rop); OUT_CS_REG_SEQ(R300_RB3D_CBLEND, 3); - if (r300->framebuffer_state.nr_cbufs) { + if (fb->nr_cbufs) { OUT_CS(blend->blend_control); OUT_CS(blend->alpha_blend_control); OUT_CS(blend->color_channel_mask); @@ -110,6 +112,8 @@ void r300_emit_dsa_state(struct r300_context* r300, void* state) { struct r300_dsa_state* dsa = (struct r300_dsa_state*)state; struct r300_screen* r300screen = r300_screen(r300->context.screen); + struct pipe_framebuffer_state* fb = + (struct pipe_framebuffer_state*)r300->fb_state.state; CS_LOCALS(r300); BEGIN_CS(r300screen->caps->is_r500 ? 8 : 6); @@ -122,7 +126,7 @@ void r300_emit_dsa_state(struct r300_context* r300, void* state) OUT_CS_REG_SEQ(R300_ZB_CNTL, 3); - if (r300->framebuffer_state.zsbuf) { + if (fb->zsbuf) { OUT_CS(dsa->z_buffer_control); OUT_CS(dsa->z_stencil_control); } else { @@ -382,17 +386,14 @@ void r500_emit_fs_constant_buffer(struct r300_context* r300, END_CS; } -void r300_emit_fb_state(struct r300_context* r300, - struct pipe_framebuffer_state* fb) +void r300_emit_fb_state(struct r300_context* r300, void* state) { + struct pipe_framebuffer_state* fb = (struct pipe_framebuffer_state*)state; struct r300_texture* tex; struct pipe_surface* surf; int i; CS_LOCALS(r300); - /* Shouldn't fail unless there is a bug in the state tracker. */ - assert(fb->nr_cbufs <= 4); - BEGIN_CS((10 * fb->nr_cbufs) + (2 * (4 - fb->nr_cbufs)) + (fb->zsbuf ? 10 : 0) + 6); @@ -671,11 +672,13 @@ void r300_emit_scissor_state(struct r300_context* r300, void* state) uint32_t top_left, bottom_right; struct r300_screen* r300screen = r300_screen(r300->context.screen); struct pipe_scissor_state* scissor = (struct pipe_scissor_state*)state; + struct pipe_framebuffer_state* fb = + (struct pipe_framebuffer_state*)r300->fb_state.state; CS_LOCALS(r300); minx = miny = 0; - maxx = r300->framebuffer_state.width; - maxy = r300->framebuffer_state.height; + maxx = fb->width; + maxy = fb->height; if (((struct r300_rs_state*)r300->rs_state.state)->rs.scissor) { minx = MAX2(minx, scissor->minx); @@ -1009,6 +1012,8 @@ static void r300_flush_pvs(struct r300_context* r300) void r300_emit_buffer_validate(struct r300_context *r300) { + struct pipe_framebuffer_state* fb = + (struct pipe_framebuffer_state*)r300->fb_state.state; struct r300_texture* tex; unsigned i; boolean invalid = FALSE; @@ -1018,8 +1023,8 @@ void r300_emit_buffer_validate(struct r300_context *r300) validate: /* Color buffers... */ - for (i = 0; i < r300->framebuffer_state.nr_cbufs; i++) { - tex = (struct r300_texture*)r300->framebuffer_state.cbufs[i]->texture; + for (i = 0; i < fb->nr_cbufs; i++) { + tex = (struct r300_texture*)fb->cbufs[i]->texture; assert(tex && tex->buffer && "cbuf is marked, but NULL!"); if (!r300->winsys->add_buffer(r300->winsys, tex->buffer, 0, RADEON_GEM_DOMAIN_VRAM)) { @@ -1028,8 +1033,8 @@ validate: } } /* ...depth buffer... */ - if (r300->framebuffer_state.zsbuf) { - tex = (struct r300_texture*)r300->framebuffer_state.zsbuf->texture; + if (fb->zsbuf) { + tex = (struct r300_texture*)fb->zsbuf->texture; assert(tex && tex->buffer && "zsbuf is marked, but NULL!"); if (!r300->winsys->add_buffer(r300->winsys, tex->buffer, 0, RADEON_GEM_DOMAIN_VRAM)) { @@ -1135,11 +1140,6 @@ void r300_emit_dirty_state(struct r300_context* r300) r300->dirty_state &= ~R300_NEW_FRAGMENT_SHADER_CONSTANTS; } - if (r300->dirty_state & R300_NEW_FRAMEBUFFERS) { - r300_emit_fb_state(r300, &r300->framebuffer_state); - r300->dirty_state &= ~R300_NEW_FRAMEBUFFERS; - } - /* Samplers and textures are tracked separately but emitted together. */ if (r300->dirty_state & (R300_ANY_NEW_SAMPLERS | R300_ANY_NEW_TEXTURES)) { diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index c6dbc5af1e..6b96d9b57c 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -51,8 +51,7 @@ void r500_emit_fragment_program_code(struct r300_context* r300, void r500_emit_fs_constant_buffer(struct r300_context* r300, struct rc_constant_list* constants); -void r300_emit_fb_state(struct r300_context* r300, - struct pipe_framebuffer_state* fb); +void r300_emit_fb_state(struct r300_context* r300, void* state); void r300_emit_query_begin(struct r300_context* r300, struct r300_query* query); diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index b1c9aebd28..1b920563a5 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -487,20 +487,30 @@ static void struct r300_context* r300 = r300_context(pipe); uint32_t zbuffer_bpp = 0; + r300->fb_state.size = (10 * state->nr_cbufs) + + (2 * (4 - state->nr_cbufs)) + + (state->zsbuf ? 10 : 0) + 6; + + if (state->nr_cbufs > 4) { + debug_printf("r300: Implementation error: Too many MRTs in %s, " + "refusing to bind framebuffer state!\n", __FUNCTION__); + return; + } + if (r300->draw) { draw_flush(r300->draw); } - r300->framebuffer_state = *state; + r300->fb_state.state = state; /* Don't rely on the order of states being set for the first time. */ - r300->dirty_state |= R300_NEW_FRAMEBUFFERS; - + /* XXX wait what */ r300->blend_state.dirty = TRUE; r300->dsa_state.dirty = TRUE; + r300->fb_state.dirty = TRUE; r300->scissor_state.dirty = TRUE; - /* Polyfon offset depends on the zbuffer bit depth. */ + /* Polygon offset depends on the zbuffer bit depth. */ if (state->zsbuf && r300->polygon_offset_enabled) { switch (util_format_get_blocksize(state->zsbuf->texture->format)) { case 2: -- cgit v1.2.3 From 12f97d9c09dee7fffe073c943fd8428db4362e0c Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 28 Jan 2010 01:28:59 -0800 Subject: r300g: Fix bizarre half-flushes with immd mode. --- src/gallium/drivers/r300/r300_render.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 354f3bb921..bcb3707149 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -168,6 +168,8 @@ static void r300_emit_draw_arrays_immediate(struct r300_context *r300, } } + r300_emit_dirty_state(r300); + BEGIN_CS(10 + count * vertex_size); OUT_CS_REG(R300_GA_COLOR_CONTROL, r300_provoking_vertex_fixes(r300, mode)); @@ -419,7 +421,6 @@ void r300_draw_arrays(struct pipe_context* pipe, unsigned mode, r300_emit_buffer_validate(r300); if (immd_is_good_idea(r300, count)) { - r300_emit_dirty_state(r300); r300_emit_draw_arrays_immediate(r300, mode, start, count); } else { if (!r300_setup_vertex_buffers(r300)) { -- cgit v1.2.3 From 2102ee204c4dc39f11f07c4c32080c8d69c0e7e7 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 28 Jan 2010 02:43:45 -0800 Subject: gallium-docs: Start doc'ing screen buffers. --- src/gallium/docs/source/screen.rst | 51 +++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index 72bb75a55d..7830a9ee07 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -6,6 +6,41 @@ A screen is an object representing the context-independent part of a device. Useful Flags ------------ +.. _pipe_buffer_usage: + +PIPE_BUFFER_USAGE +^^^^^^^^^^^^^^^^^ + +These flags control buffer creation. Buffers may only have one role, so +care should be taken to not allocate a buffer with the wrong usage. + +* ``PIXEL``: This is the flag to use for all textures. +* ``VERTEX``: A vertex buffer. +* ``INDEX``: An element buffer. +* ``CONSTANT``: A buffer of shader constants. + +Buffers are inevitably abstracting the pipe's underlying memory management, +so many of their usage flags can be used to direct the way the buffer is +handled. + +* ``CPU_READ``, ``CPU_WRITE``: Whether the user will map and, in the case of + the latter, write to, the buffer. The convenience flag ``CPU_READ_WRITE`` is + available to signify a read/write buffer. +* ``GPU_READ``, ``GPU_WRITE``: Whether the driver will internally need to + read from or write to the buffer. The latter will only happen if the buffer + is made into a render target. +* ``DISCARD``: When set on a map, the contents of the map will be discarded + beforehand. Cannot be used with ``CPU_READ``. +* ``DONTBLOCK``: When set on a map, the map will fail if the buffer cannot be + mapped immediately. +* ``UNSYNCHRONIZED``: When set on a map, any outstanding operations on the + buffer will be ignored. The interaction of any writes to the map and any + operations pending with the buffer are undefined. Cannot be used with + ``CPU_READ``. +* ``FLUSH_EXPLICIT``: When set on a map, written ranges of the map require + explicit flushes using :ref:`buffer_flush_mapped_range`. Requires + ``CPU_WRITE``. + .. _pipe_texture_usage: PIPE_TEXTURE_USAGE @@ -63,7 +98,21 @@ Returns TRUE if all usages can be satisfied. ``PIPE_TEXTURE_USAGE_DYNAMIC`` is not a valid usage. +.. _texture_create: + texture_create ^^^^^^^^^^^^^^ -Given a template of texture setup, create a BO-backed texture. +Given a template of texture setup, create a buffer and texture. + +texture_blanket +^^^^^^^^^^^^^^^ + +Like :ref:`texture_create`, but use a supplied buffer instead of creating a +new one. + +texture_destroy +^^^^^^^^^^^^^^^ + +Destroy a texture. The buffer backing the texture is destroyed if it has no +more references. -- cgit v1.2.3 From f0a3f824acdce98b5ca1543ecb3d7a316cfdd108 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 28 Jan 2010 02:58:28 -0800 Subject: gallium-docs: Moar buffer info. Oh look, that one question about map_buffer_range is answered. --- src/gallium/docs/source/screen.rst | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index 7830a9ee07..1fff20f539 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -116,3 +116,38 @@ texture_destroy Destroy a texture. The buffer backing the texture is destroyed if it has no more references. + +buffer_map +^^^^^^^^^^ + +Map a buffer into memory. + +**usage** is a bitmask of :ref:`PIPE_TEXTURE_USAGE` flags. + +Returns a pointer to the map, or NULL if the mapping failed. + +buffer_map_range +^^^^^^^^^^^^^^^^ + +Map a range of a buffer into memory. + +The returned map is always relative to the beginning of the buffer, not the +beginning of the mapped range. + +.. _buffer_flush_mapped_range: + +buffer_flush_mapped_range +^^^^^^^^^^^^^^^^^^^^^^^^^ + +Flush a range of mapped memory into a buffer. + +The buffer must have been mapped with ``PIPE_BUFFER_USAGE_FLUSH_EXPLICIT``. + +**usage** is a bitmask of :ref:`PIPE_TEXTURE_USAGE` flags. + +buffer_unmap +^^^^^^^^^^^^ + +Unmap a buffer from memory. + +Any pointers into the map should be considered invalid and discarded. -- cgit v1.2.3 From 241a0b8cf34a2c688f59f33758446d95d29e8447 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 28 Jan 2010 03:03:07 -0800 Subject: radeong: Slight improvement to buffer creation. --- src/gallium/winsys/drm/radeon/core/radeon_buffer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c index 421fda2b45..f484503e0e 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c @@ -55,6 +55,9 @@ static uint32_t radeon_domain_from_usage(unsigned usage) { uint32_t domain = 0; + if (usage & PIPE_BUFFER_USAGE_GPU_WRITE) { + domain |= RADEON_GEM_DOMAIN_VRAM; + } if (usage & PIPE_BUFFER_USAGE_PIXEL) { domain |= RADEON_GEM_DOMAIN_VRAM; } @@ -88,7 +91,7 @@ static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws, radeon_buffer->base.usage = usage; radeon_buffer->base.size = size; - if (usage == PIPE_BUFFER_USAGE_CONSTANT && is_r3xx(radeon_ws->pci_id)) { + if (usage & PIPE_BUFFER_USAGE_CONSTANT && is_r3xx(radeon_ws->pci_id)) { /* Don't bother allocating a BO, as it'll never get to the card. */ desc.alignment = alignment; desc.usage = usage; -- cgit v1.2.3 From 0adfdaeaa1e20c81a9f37455fe78d15c6406e3d3 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 19 Jan 2010 13:03:01 +0100 Subject: gallium: Add tgsi_declaration_dimension token. This will allow us to declare two-dimensional constant buffers. --- src/gallium/include/pipe/p_shader_tokens.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h index b489b04466..b47f4971f1 100644 --- a/src/gallium/include/pipe/p_shader_tokens.h +++ b/src/gallium/include/pipe/p_shader_tokens.h @@ -109,10 +109,11 @@ struct tgsi_declaration unsigned File : 4; /**< one of TGSI_FILE_x */ unsigned UsageMask : 4; /**< bitmask of TGSI_WRITEMASK_x flags */ unsigned Interpolate : 4; /**< one of TGSI_INTERPOLATE_x */ + unsigned Dimension : 1; /**< any extra dimension info? */ unsigned Semantic : 1; /**< BOOL, any semantic info? */ unsigned Centroid : 1; /**< centroid sampling? */ unsigned Invariant : 1; /**< invariant optimization? */ - unsigned Padding : 5; + unsigned Padding : 4; }; struct tgsi_declaration_range @@ -121,6 +122,12 @@ struct tgsi_declaration_range unsigned Last : 16; /**< UINT */ }; +struct tgsi_declaration_dimension +{ + unsigned Index2D:16; /**< UINT */ + unsigned Padding:16; +}; + #define TGSI_SEMANTIC_POSITION 0 #define TGSI_SEMANTIC_COLOR 1 #define TGSI_SEMANTIC_BCOLOR 2 /**< back-face color */ -- cgit v1.2.3 From 4367de152cc5bd7240d75a33e75c1b1671b5cc16 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 19 Jan 2010 13:16:20 +0100 Subject: tgsi: Handle 2-D declarations. --- src/gallium/auxiliary/tgsi/tgsi_dump.c | 50 +++++----- src/gallium/auxiliary/tgsi/tgsi_parse.c | 4 + src/gallium/auxiliary/tgsi/tgsi_parse.h | 1 + src/gallium/auxiliary/tgsi/tgsi_sanity.c | 6 +- src/gallium/auxiliary/tgsi/tgsi_ureg.c | 154 +++++++++++++++++++------------ src/gallium/auxiliary/tgsi/tgsi_ureg.h | 30 ++++++ 6 files changed, 156 insertions(+), 89 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c index c254a7274f..5472466eb6 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_dump.c +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c @@ -177,29 +177,6 @@ static const char *primitive_names[] = }; -static void -_dump_register_decl( - struct dump_ctx *ctx, - uint file, - int first, - int last ) -{ - ENM( file, file_names ); - - /* all geometry shader inputs are two dimensional */ - if (file == TGSI_FILE_INPUT && - ctx->iter.processor.Processor == TGSI_PROCESSOR_GEOMETRY) - TXT("[]"); - - CHR( '[' ); - SID( first ); - if (first != last) { - TXT( ".." ); - SID( last ); - } - CHR( ']' ); -} - static void _dump_register_dst( struct dump_ctx *ctx, @@ -299,11 +276,28 @@ iter_declaration( TXT( "DCL " ); - _dump_register_decl( - ctx, - decl->Declaration.File, - decl->Range.First, - decl->Range.Last ); + ENM(decl->Declaration.File, file_names); + + /* all geometry shader inputs are two dimensional */ + if (decl->Declaration.File == TGSI_FILE_INPUT && + iter->processor.Processor == TGSI_PROCESSOR_GEOMETRY) { + TXT("[]"); + } + + if (decl->Declaration.Dimension) { + CHR('['); + SID(decl->Dim.Index2D); + CHR(']'); + } + + CHR('['); + SID(decl->Range.First); + if (decl->Range.First != decl->Range.Last) { + TXT(".."); + SID(decl->Range.Last); + } + CHR(']'); + _dump_writemask( ctx, decl->Declaration.UsageMask ); diff --git a/src/gallium/auxiliary/tgsi/tgsi_parse.c b/src/gallium/auxiliary/tgsi/tgsi_parse.c index 8c7062d850..fd37fc3079 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_parse.c +++ b/src/gallium/auxiliary/tgsi/tgsi_parse.c @@ -109,6 +109,10 @@ tgsi_parse_token( next_token( ctx, &decl->Range ); + if (decl->Declaration.Dimension) { + next_token(ctx, &decl->Dim); + } + if( decl->Declaration.Semantic ) { next_token( ctx, &decl->Semantic ); } diff --git a/src/gallium/auxiliary/tgsi/tgsi_parse.h b/src/gallium/auxiliary/tgsi/tgsi_parse.h index 439a57269b..8150e3cd29 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_parse.h +++ b/src/gallium/auxiliary/tgsi/tgsi_parse.h @@ -58,6 +58,7 @@ struct tgsi_full_declaration { struct tgsi_declaration Declaration; struct tgsi_declaration_range Range; + struct tgsi_declaration_dimension Dim; struct tgsi_declaration_semantic Semantic; }; diff --git a/src/gallium/auxiliary/tgsi/tgsi_sanity.c b/src/gallium/auxiliary/tgsi/tgsi_sanity.c index 431c3ffb14..91e1b27da1 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sanity.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sanity.c @@ -413,7 +413,11 @@ iter_declaration( } } else { scan_register *reg = MALLOC(sizeof(scan_register)); - fill_scan_register1d(reg, file, i); + if (decl->Declaration.Dimension) { + fill_scan_register2d(reg, file, i, decl->Dim.Index2D); + } else { + fill_scan_register1d(reg, file, i); + } check_and_declare(ctx, reg); } } diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index b3be3fc412..c18db2e5b7 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -44,6 +44,7 @@ union tgsi_any_token { struct tgsi_property_data prop_data; struct tgsi_declaration decl; struct tgsi_declaration_range decl_range; + struct tgsi_declaration_dimension decl_dim; struct tgsi_declaration_semantic decl_semantic; struct tgsi_immediate imm; union tgsi_immediate_data imm_data; @@ -75,6 +76,14 @@ struct ureg_tokens { #define UREG_MAX_LOOP 1 #define UREG_MAX_PRED 1 +struct const_decl { + struct { + unsigned first; + unsigned last; + } constant_range[UREG_MAX_CONSTANT_RANGE]; + unsigned nr_constant_ranges; +}; + #define DOMAIN_DECL 0 #define DOMAIN_INSN 1 @@ -127,11 +136,7 @@ struct ureg_program unsigned temps_active[UREG_MAX_TEMP / 32]; unsigned nr_temps; - struct { - unsigned first; - unsigned last; - } constant_range[UREG_MAX_CONSTANT_RANGE]; - unsigned nr_constant_ranges; + struct const_decl const_decls[PIPE_MAX_CONSTANT]; unsigned property_gs_input_prim; @@ -235,31 +240,6 @@ ureg_dst_register( unsigned file, return dst; } -static INLINE struct ureg_src -ureg_src_register( unsigned file, - unsigned index ) -{ - struct ureg_src src; - - src.File = file; - src.SwizzleX = TGSI_SWIZZLE_X; - src.SwizzleY = TGSI_SWIZZLE_Y; - src.SwizzleZ = TGSI_SWIZZLE_Z; - src.SwizzleW = TGSI_SWIZZLE_W; - src.Indirect = 0; - src.IndirectFile = TGSI_FILE_NULL; - src.IndirectIndex = 0; - src.IndirectSwizzle = 0; - src.Absolute = 0; - src.Index = index; - src.Negate = 0; - src.Dimension = 0; - src.DimensionIndex = 0; - - return src; -} - - void ureg_property_gs_input_prim(struct ureg_program *ureg, @@ -379,58 +359,80 @@ out: * value or manage any constant_buffer contents -- that's the * resposibility of the calling code. */ -struct ureg_src ureg_DECL_constant(struct ureg_program *ureg, - unsigned index ) +void +ureg_DECL_constant2D(struct ureg_program *ureg, + unsigned first, + unsigned last, + unsigned index2D) { + struct const_decl *decl = &ureg->const_decls[index2D]; + + assert(index2D < PIPE_MAX_CONSTANT); + + if (decl->nr_constant_ranges < UREG_MAX_CONSTANT_RANGE) { + uint i = decl->nr_constant_ranges++; + + decl->constant_range[i].first = first; + decl->constant_range[i].last = last; + } +} + + +struct ureg_src +ureg_DECL_constant(struct ureg_program *ureg, + unsigned index) +{ + struct const_decl *decl = &ureg->const_decls[0]; unsigned minconst = index, maxconst = index; unsigned i; /* Inside existing range? */ - for (i = 0; i < ureg->nr_constant_ranges; i++) { - if (ureg->constant_range[i].first <= index && - ureg->constant_range[i].last >= index) + for (i = 0; i < decl->nr_constant_ranges; i++) { + if (decl->constant_range[i].first <= index && + decl->constant_range[i].last >= index) { goto out; + } } /* Extend existing range? */ - for (i = 0; i < ureg->nr_constant_ranges; i++) { - if (ureg->constant_range[i].last == index - 1) { - ureg->constant_range[i].last = index; + for (i = 0; i < decl->nr_constant_ranges; i++) { + if (decl->constant_range[i].last == index - 1) { + decl->constant_range[i].last = index; goto out; } - if (ureg->constant_range[i].first == index + 1) { - ureg->constant_range[i].first = index; + if (decl->constant_range[i].first == index + 1) { + decl->constant_range[i].first = index; goto out; } - minconst = MIN2(minconst, ureg->constant_range[i].first); - maxconst = MAX2(maxconst, ureg->constant_range[i].last); + minconst = MIN2(minconst, decl->constant_range[i].first); + maxconst = MAX2(maxconst, decl->constant_range[i].last); } /* Create new range? */ - if (ureg->nr_constant_ranges < UREG_MAX_CONSTANT_RANGE) { - i = ureg->nr_constant_ranges++; - ureg->constant_range[i].first = index; - ureg->constant_range[i].last = index; + if (decl->nr_constant_ranges < UREG_MAX_CONSTANT_RANGE) { + i = decl->nr_constant_ranges++; + decl->constant_range[i].first = index; + decl->constant_range[i].last = index; goto out; } /* Collapse all ranges down to one: */ i = 0; - ureg->constant_range[0].first = minconst; - ureg->constant_range[0].last = maxconst; - ureg->nr_constant_ranges = 1; + decl->constant_range[0].first = minconst; + decl->constant_range[0].last = maxconst; + decl->nr_constant_ranges = 1; out: - assert(i < ureg->nr_constant_ranges); - assert(ureg->constant_range[i].first <= index); - assert(ureg->constant_range[i].last >= index); - return ureg_src_register( TGSI_FILE_CONSTANT, index ); + assert(i < decl->nr_constant_ranges); + assert(decl->constant_range[i].first <= index); + assert(decl->constant_range[i].last >= index); + return ureg_src_register(TGSI_FILE_CONSTANT, index); } @@ -1087,6 +1089,31 @@ static void emit_decl_range( struct ureg_program *ureg, out[1].decl_range.Last = first + count - 1; } +static void +emit_decl_range2D(struct ureg_program *ureg, + unsigned file, + unsigned first, + unsigned last, + unsigned index2D) +{ + union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, 3); + + out[0].value = 0; + out[0].decl.Type = TGSI_TOKEN_TYPE_DECLARATION; + out[0].decl.NrTokens = 3; + out[0].decl.File = file; + out[0].decl.UsageMask = 0xf; + out[0].decl.Interpolate = TGSI_INTERPOLATE_CONSTANT; + out[0].decl.Dimension = 1; + + out[1].value = 0; + out[1].decl_range.First = first; + out[1].decl_range.Last = last; + + out[2].value = 0; + out[2].decl_dim.Index2D = index2D; +} + static void emit_immediate( struct ureg_program *ureg, const unsigned *v, @@ -1182,13 +1209,20 @@ static void emit_decls( struct ureg_program *ureg ) ureg->sampler[i].Index, 1 ); } - if (ureg->nr_constant_ranges) { - for (i = 0; i < ureg->nr_constant_ranges; i++) - emit_decl_range( ureg, - TGSI_FILE_CONSTANT, - ureg->constant_range[i].first, - (ureg->constant_range[i].last + 1 - - ureg->constant_range[i].first) ); + for (i = 0; i < PIPE_MAX_CONSTANT; i++) { + struct const_decl *decl = &ureg->const_decls[i]; + + if (decl->nr_constant_ranges) { + uint j; + + for (j = 0; j < decl->nr_constant_ranges; j++) { + emit_decl_range2D(ureg, + TGSI_FILE_CONSTANT, + decl->constant_range[j].first, + decl->constant_range[j].last, + i); + } + } } if (ureg->nr_temps) { diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h index 8c8a6bbce6..c0dc722673 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h @@ -178,6 +178,12 @@ ureg_DECL_immediate_int( struct ureg_program *, const int *v, unsigned nr ); +void +ureg_DECL_constant2D(struct ureg_program *ureg, + unsigned first, + unsigned last, + unsigned index2D); + struct ureg_src ureg_DECL_constant( struct ureg_program *, unsigned index ); @@ -815,6 +821,30 @@ ureg_dst( struct ureg_src src ) return dst; } +static INLINE struct ureg_src +ureg_src_register(unsigned file, + unsigned index) +{ + struct ureg_src src; + + src.File = file; + src.SwizzleX = TGSI_SWIZZLE_X; + src.SwizzleY = TGSI_SWIZZLE_Y; + src.SwizzleZ = TGSI_SWIZZLE_Z; + src.SwizzleW = TGSI_SWIZZLE_W; + src.Indirect = 0; + src.IndirectFile = TGSI_FILE_NULL; + src.IndirectIndex = 0; + src.IndirectSwizzle = 0; + src.Absolute = 0; + src.Index = index; + src.Negate = 0; + src.Dimension = 0; + src.DimensionIndex = 0; + + return src; +} + static INLINE struct ureg_src ureg_src( struct ureg_dst dst ) { -- cgit v1.2.3 From 835bab0143e11ab98551a061043f944fd6eab456 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Tue, 19 Jan 2010 13:20:15 +0100 Subject: gallium: Implement 2D constant buffers for fragment shader in softpipe. --- src/gallium/auxiliary/draw/draw_gs.c | 2 +- src/gallium/auxiliary/draw/draw_vs_exec.c | 2 +- src/gallium/auxiliary/tgsi/tgsi_exec.c | 267 +++++++++++--------------- src/gallium/auxiliary/tgsi/tgsi_exec.h | 2 +- src/gallium/drivers/softpipe/sp_context.c | 10 +- src/gallium/drivers/softpipe/sp_context.h | 4 +- src/gallium/drivers/softpipe/sp_draw_arrays.c | 35 ++-- src/gallium/drivers/softpipe/sp_fs_sse.c | 2 +- src/gallium/drivers/softpipe/sp_quad_fs.c | 7 +- src/gallium/drivers/softpipe/sp_state_fs.c | 4 +- 10 files changed, 158 insertions(+), 177 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c index daf8d071f1..c3cc365a8d 100644 --- a/src/gallium/auxiliary/draw/draw_gs.c +++ b/src/gallium/auxiliary/draw/draw_gs.c @@ -302,7 +302,7 @@ void draw_geometry_shader_run(struct draw_geometry_shader *shader, unsigned num_primitives = count/num_vertices; unsigned inputs_from_vs = 0; - machine->Consts = constants; + machine->Consts[0] = constants; for (i = 0; i < shader->info.num_inputs; ++i) { if (shader->info.input_semantic_name[i] != TGSI_SEMANTIC_PRIMID) diff --git a/src/gallium/auxiliary/draw/draw_vs_exec.c b/src/gallium/auxiliary/draw/draw_vs_exec.c index 41cc802613..3f7a5ca14b 100644 --- a/src/gallium/auxiliary/draw/draw_vs_exec.c +++ b/src/gallium/auxiliary/draw/draw_vs_exec.c @@ -95,7 +95,7 @@ vs_exec_run_linear( struct draw_vertex_shader *shader, unsigned int i, j; unsigned slot; - machine->Consts = constants; + machine->Consts[0] = constants; for (i = 0; i < count; i += MAX_TGSI_VERTICES) { unsigned int max_vertices = MIN2(MAX_TGSI_VERTICES, count - i); diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 83646b73c1..74e7e637cc 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -953,107 +953,90 @@ micro_sub( } static void -fetch_src_file_channel( - const struct tgsi_exec_machine *mach, - const uint file, - const uint swizzle, - const union tgsi_exec_channel *index, - union tgsi_exec_channel *chan ) -{ - switch( swizzle ) { - case TGSI_SWIZZLE_X: - case TGSI_SWIZZLE_Y: - case TGSI_SWIZZLE_Z: - case TGSI_SWIZZLE_W: - switch( file ) { - case TGSI_FILE_CONSTANT: - assert(mach->Consts); - if (index->i[0] < 0) - chan->f[0] = 0.0f; - else - chan->f[0] = mach->Consts[index->i[0]][swizzle]; - if (index->i[1] < 0) - chan->f[1] = 0.0f; - else - chan->f[1] = mach->Consts[index->i[1]][swizzle]; - if (index->i[2] < 0) - chan->f[2] = 0.0f; - else - chan->f[2] = mach->Consts[index->i[2]][swizzle]; - if (index->i[3] < 0) - chan->f[3] = 0.0f; - else - chan->f[3] = mach->Consts[index->i[3]][swizzle]; - break; +fetch_src_file_channel(const struct tgsi_exec_machine *mach, + const uint file, + const uint swizzle, + const union tgsi_exec_channel *index, + const union tgsi_exec_channel *index2D, + union tgsi_exec_channel *chan) +{ + uint i; - case TGSI_FILE_INPUT: - case TGSI_FILE_SYSTEM_VALUE: - chan->u[0] = mach->Inputs[index->i[0]].xyzw[swizzle].u[0]; - chan->u[1] = mach->Inputs[index->i[1]].xyzw[swizzle].u[1]; - chan->u[2] = mach->Inputs[index->i[2]].xyzw[swizzle].u[2]; - chan->u[3] = mach->Inputs[index->i[3]].xyzw[swizzle].u[3]; - break; + switch (file) { + case TGSI_FILE_CONSTANT: + for (i = 0; i < QUAD_SIZE; i++) { + assert(index2D->i[i] >= 0 && index2D->i[i] < PIPE_MAX_CONSTANT); + assert(mach->Consts[index2D->i[i]]); - case TGSI_FILE_TEMPORARY: - assert(index->i[0] < TGSI_EXEC_NUM_TEMPS); - chan->u[0] = mach->Temps[index->i[0]].xyzw[swizzle].u[0]; - chan->u[1] = mach->Temps[index->i[1]].xyzw[swizzle].u[1]; - chan->u[2] = mach->Temps[index->i[2]].xyzw[swizzle].u[2]; - chan->u[3] = mach->Temps[index->i[3]].xyzw[swizzle].u[3]; - break; + if (index->i[i] < 0) { + chan->u[i] = 0; + } else { + const uint *p = (const uint *)mach->Consts[index2D->i[i]]; - case TGSI_FILE_IMMEDIATE: - assert( index->i[0] < (int) mach->ImmLimit ); - chan->f[0] = mach->Imms[index->i[0]][swizzle]; - assert( index->i[1] < (int) mach->ImmLimit ); - chan->f[1] = mach->Imms[index->i[1]][swizzle]; - assert( index->i[2] < (int) mach->ImmLimit ); - chan->f[2] = mach->Imms[index->i[2]][swizzle]; - assert( index->i[3] < (int) mach->ImmLimit ); - chan->f[3] = mach->Imms[index->i[3]][swizzle]; - break; + chan->u[i] = p[index->i[i] * 4 + swizzle]; + } + } + break; - case TGSI_FILE_ADDRESS: - chan->u[0] = mach->Addrs[index->i[0]].xyzw[swizzle].u[0]; - chan->u[1] = mach->Addrs[index->i[1]].xyzw[swizzle].u[1]; - chan->u[2] = mach->Addrs[index->i[2]].xyzw[swizzle].u[2]; - chan->u[3] = mach->Addrs[index->i[3]].xyzw[swizzle].u[3]; - break; + case TGSI_FILE_INPUT: + case TGSI_FILE_SYSTEM_VALUE: + for (i = 0; i < QUAD_SIZE; i++) { + /* XXX: 2D indexing */ + chan->u[i] = mach->Inputs[index2D->i[i] * TGSI_EXEC_MAX_INPUT_ATTRIBS + index->i[i]].xyzw[swizzle].u[i]; + } + break; - case TGSI_FILE_PREDICATE: - assert(index->i[0] < TGSI_EXEC_NUM_PREDS); - assert(index->i[1] < TGSI_EXEC_NUM_PREDS); - assert(index->i[2] < TGSI_EXEC_NUM_PREDS); - assert(index->i[3] < TGSI_EXEC_NUM_PREDS); - chan->u[0] = mach->Predicates[0].xyzw[swizzle].u[0]; - chan->u[1] = mach->Predicates[0].xyzw[swizzle].u[1]; - chan->u[2] = mach->Predicates[0].xyzw[swizzle].u[2]; - chan->u[3] = mach->Predicates[0].xyzw[swizzle].u[3]; - break; + case TGSI_FILE_TEMPORARY: + for (i = 0; i < QUAD_SIZE; i++) { + assert(index->i[i] < TGSI_EXEC_NUM_TEMPS); + assert(index2D->i[i] == 0); - case TGSI_FILE_OUTPUT: - /* vertex/fragment output vars can be read too */ - chan->u[0] = mach->Outputs[index->i[0]].xyzw[swizzle].u[0]; - chan->u[1] = mach->Outputs[index->i[1]].xyzw[swizzle].u[1]; - chan->u[2] = mach->Outputs[index->i[2]].xyzw[swizzle].u[2]; - chan->u[3] = mach->Outputs[index->i[3]].xyzw[swizzle].u[3]; - break; + chan->u[i] = mach->Temps[index->i[i]].xyzw[swizzle].u[i]; + } + break; - default: - assert( 0 ); - chan->u[0] = 0; - chan->u[1] = 0; - chan->u[2] = 0; - chan->u[3] = 0; + case TGSI_FILE_IMMEDIATE: + for (i = 0; i < QUAD_SIZE; i++) { + assert(index->i[i] >= 0 && index->i[i] < (int)mach->ImmLimit); + assert(index2D->i[i] == 0); + + chan->f[i] = mach->Imms[index->i[i]][swizzle]; + } + break; + + case TGSI_FILE_ADDRESS: + for (i = 0; i < QUAD_SIZE; i++) { + assert(index->i[i] >= 0); + assert(index2D->i[i] == 0); + + chan->u[i] = mach->Addrs[index->i[i]].xyzw[swizzle].u[i]; + } + break; + + case TGSI_FILE_PREDICATE: + for (i = 0; i < QUAD_SIZE; i++) { + assert(index->i[i] >= 0 && index->i[i] < TGSI_EXEC_NUM_PREDS); + assert(index2D->i[i] == 0); + + chan->u[i] = mach->Predicates[0].xyzw[swizzle].u[i]; + } + break; + + case TGSI_FILE_OUTPUT: + /* vertex/fragment output vars can be read too */ + for (i = 0; i < QUAD_SIZE; i++) { + assert(index->i[i] >= 0); + assert(index2D->i[i] == 0); + + chan->u[i] = mach->Outputs[index->i[i]].xyzw[swizzle].u[i]; } break; default: - assert( 0 ); - chan->u[0] = 0; - chan->u[1] = 0; - chan->u[2] = 0; - chan->u[3] = 0; + assert(0); + for (i = 0; i < QUAD_SIZE; i++) { + chan->u[i] = 0; + } } } @@ -1065,6 +1048,7 @@ fetch_source(const struct tgsi_exec_machine *mach, enum tgsi_exec_datatype src_datatype) { union tgsi_exec_channel index; + union tgsi_exec_channel index2D; uint swizzle; /* We start with a direct index into a register file. @@ -1103,12 +1087,12 @@ fetch_source(const struct tgsi_exec_machine *mach, /* get current value of address register[swizzle] */ swizzle = tgsi_util_get_src_register_swizzle( ®->Indirect, CHAN_X ); - fetch_src_file_channel( - mach, - reg->Indirect.File, - swizzle, - &index2, - &indir_index ); + fetch_src_file_channel(mach, + reg->Indirect.File, + swizzle, + &index2, + &ZeroVec, + &indir_index); /* add value of address register to the offset */ index.i[0] += indir_index.i[0]; @@ -1129,35 +1113,15 @@ fetch_source(const struct tgsi_exec_machine *mach, * subscript to a register file. Effectively it means that * the register file is actually a 2D array of registers. * - * file[3][1] == file[3*sizeof(file[1])+1], + * file[3][1], * where: * [3] = Dimension.Index */ if (reg->Register.Dimension) { - int array_size; - union tgsi_exec_channel dim_index; - - /* The size of the first-order array depends on the register file type. - * We need to multiply the index to the first array to get an effective, - * "flat" index that points to the beginning of the second-order array. - */ - switch (reg->Register.File) { - case TGSI_FILE_INPUT: - case TGSI_FILE_SYSTEM_VALUE: - array_size = TGSI_EXEC_MAX_INPUT_ATTRIBS; - break; - case TGSI_FILE_CONSTANT: - array_size = TGSI_EXEC_MAX_CONST_BUFFER; - break; - default: - assert( 0 ); - array_size = 0; - } - - dim_index.i[0] = - dim_index.i[1] = - dim_index.i[2] = - dim_index.i[3] = reg->Dimension.Index; + index2D.i[0] = + index2D.i[1] = + index2D.i[2] = + index2D.i[3] = reg->Dimension.Index; /* Again, the second subscript index can be addressed indirectly * identically to the first one. @@ -1182,45 +1146,46 @@ fetch_source(const struct tgsi_exec_machine *mach, index2.i[3] = reg->DimIndirect.Index; swizzle = tgsi_util_get_src_register_swizzle( ®->DimIndirect, CHAN_X ); - fetch_src_file_channel( - mach, - reg->DimIndirect.File, - swizzle, - &index2, - &indir_index ); - - dim_index.i[0] += indir_index.i[0]; - dim_index.i[1] += indir_index.i[1]; - dim_index.i[2] += indir_index.i[2]; - dim_index.i[3] += indir_index.i[3]; + fetch_src_file_channel(mach, + reg->DimIndirect.File, + swizzle, + &index2, + &ZeroVec, + &indir_index); + + index2D.i[0] += indir_index.i[0]; + index2D.i[1] += indir_index.i[1]; + index2D.i[2] += indir_index.i[2]; + index2D.i[3] += indir_index.i[3]; /* for disabled execution channels, zero-out the index to * avoid using a potential garbage value. */ for (i = 0; i < QUAD_SIZE; i++) { - if ((execmask & (1 << i)) == 0) - dim_index.i[i] = 0; + if ((execmask & (1 << i)) == 0) { + index2D.i[i] = 0; + } } } - index.i[0] += dim_index.i[0] * array_size; - index.i[1] += dim_index.i[1] * array_size; - index.i[2] += dim_index.i[2] * array_size; - index.i[3] += dim_index.i[3] * array_size; - /* If by any chance there was a need for a 3D array of register * files, we would have to check whether Dimension is followed * by a dimension register and continue the saga. */ + } else { + index2D.i[0] = + index2D.i[1] = + index2D.i[2] = + index2D.i[3] = 0; } swizzle = tgsi_util_get_full_src_register_swizzle( reg, chan_index ); - fetch_src_file_channel( - mach, - reg->Register.File, - swizzle, - &index, - chan ); + fetch_src_file_channel(mach, + reg->Register.File, + swizzle, + &index, + &index2D, + chan); if (reg->Register.Absolute) { if (src_datatype == TGSI_EXEC_DATA_FLOAT) { @@ -1283,12 +1248,12 @@ store_dest(struct tgsi_exec_machine *mach, swizzle = tgsi_util_get_src_register_swizzle( ®->Indirect, CHAN_X ); /* fetch values from the address/indirection register */ - fetch_src_file_channel( - mach, - reg->Indirect.File, - swizzle, - &index, - &indir_index ); + fetch_src_file_channel(mach, + reg->Indirect.File, + swizzle, + &index, + &ZeroVec, + &indir_index); /* save indirection offset */ offset = indir_index.i[0]; diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h index 59e3b445cc..1f3e85fb62 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.h +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h @@ -260,7 +260,7 @@ struct tgsi_exec_machine struct tgsi_sampler **Samplers; unsigned ImmLimit; - const float (*Consts)[4]; + const void *Consts[PIPE_MAX_CONSTANT]; const struct tgsi_token *Tokens; /**< Declarations, instructions */ unsigned Processor; /**< TGSI_PROCESSOR_x */ diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index 73e075f0d8..a3a7825aa1 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -111,9 +111,13 @@ softpipe_destroy( struct pipe_context *pipe ) pipe_texture_reference(&softpipe->vertex_textures[i], NULL); } - for (i = 0; i < Elements(softpipe->constants); i++) { - if (softpipe->constants[i]) { - pipe_buffer_reference(&softpipe->constants[i], NULL); + for (i = 0; i < PIPE_SHADER_TYPES; i++) { + uint j; + + for (j = 0; j < PIPE_MAX_CONSTANT; j++) { + if (softpipe->constants[i][j]) { + pipe_buffer_reference(&softpipe->constants[i][j], NULL); + } } } diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h index da673c57ad..f19b3cd5be 100644 --- a/src/gallium/drivers/softpipe/sp_context.h +++ b/src/gallium/drivers/softpipe/sp_context.h @@ -63,7 +63,7 @@ struct softpipe_context { /** Other rendering state */ struct pipe_blend_color blend_color; struct pipe_clip_state clip; - struct pipe_buffer *constants[PIPE_SHADER_TYPES]; + struct pipe_buffer *constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT]; struct pipe_framebuffer_state framebuffer; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; @@ -92,7 +92,7 @@ struct softpipe_context { ubyte *mapped_vbuffer[PIPE_MAX_ATTRIBS]; /** Mapped constant buffers */ - void *mapped_constants[PIPE_SHADER_TYPES]; + void *mapped_constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT]; /** Vertex format */ struct vertex_info vertex_info; diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c index 03b58d2fb7..cbb9631fa5 100644 --- a/src/gallium/drivers/softpipe/sp_draw_arrays.c +++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c @@ -52,26 +52,32 @@ softpipe_map_constant_buffers(struct softpipe_context *sp) uint i, vssize, gssize; for (i = 0; i < PIPE_SHADER_TYPES; i++) { - if (sp->constants[i] && sp->constants[i]->size) - sp->mapped_constants[i] = ws->buffer_map(ws, sp->constants[i], - PIPE_BUFFER_USAGE_CPU_READ); + uint j; + + for (j = 0; j < PIPE_MAX_CONSTANT; j++) { + if (sp->constants[i][j] && sp->constants[i][j]->size) { + sp->mapped_constants[i][j] = ws->buffer_map(ws, + sp->constants[i][j], + PIPE_BUFFER_USAGE_CPU_READ); + } + } } - if (sp->constants[PIPE_SHADER_VERTEX]) - vssize = sp->constants[PIPE_SHADER_VERTEX]->size; + if (sp->constants[PIPE_SHADER_VERTEX][0]) + vssize = sp->constants[PIPE_SHADER_VERTEX][0]->size; else vssize = 0; - if (sp->constants[PIPE_SHADER_GEOMETRY]) - gssize = sp->constants[PIPE_SHADER_GEOMETRY]->size; + if (sp->constants[PIPE_SHADER_GEOMETRY][0]) + gssize = sp->constants[PIPE_SHADER_GEOMETRY][0]->size; else gssize = 0; draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_VERTEX, - sp->mapped_constants[PIPE_SHADER_VERTEX], + sp->mapped_constants[PIPE_SHADER_VERTEX][0], vssize); draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_GEOMETRY, - sp->mapped_constants[PIPE_SHADER_GEOMETRY], + sp->mapped_constants[PIPE_SHADER_GEOMETRY][0], gssize); } @@ -91,9 +97,14 @@ softpipe_unmap_constant_buffers(struct softpipe_context *sp) draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_GEOMETRY, NULL, 0); for (i = 0; i < PIPE_SHADER_TYPES; i++) { - if (sp->constants[i] && sp->constants[i]->size) - ws->buffer_unmap(ws, sp->constants[i]); - sp->mapped_constants[i] = NULL; + uint j; + + for (j = 0; j < PIPE_MAX_CONSTANT; j++) { + if (sp->constants[i][j] && sp->constants[i][j]->size) { + ws->buffer_unmap(ws, sp->constants[i][j]); + } + sp->mapped_constants[i][j] = NULL; + } } } diff --git a/src/gallium/drivers/softpipe/sp_fs_sse.c b/src/gallium/drivers/softpipe/sp_fs_sse.c index f912950658..acee213670 100644 --- a/src/gallium/drivers/softpipe/sp_fs_sse.c +++ b/src/gallium/drivers/softpipe/sp_fs_sse.c @@ -135,7 +135,7 @@ fs_sse_run( const struct sp_fragment_shader *base, tgsi_set_exec_mask(machine, 1, 1, 1, 1); shader->func( machine, - machine->Consts, + (const float (*)[4])machine->Consts[0], (const float (*)[4])shader->immediates, machine->InterpCoefs /*, &machine->QuadPos*/ diff --git a/src/gallium/drivers/softpipe/sp_quad_fs.c b/src/gallium/drivers/softpipe/sp_quad_fs.c index e799df136e..9c497073c2 100644 --- a/src/gallium/drivers/softpipe/sp_quad_fs.c +++ b/src/gallium/drivers/softpipe/sp_quad_fs.c @@ -107,10 +107,11 @@ shade_quads(struct quad_stage *qs, struct quad_shade_stage *qss = quad_shade_stage( qs ); struct softpipe_context *softpipe = qs->softpipe; struct tgsi_exec_machine *machine = qss->machine; - unsigned i, pass = 0; - - machine->Consts = softpipe->mapped_constants[PIPE_SHADER_FRAGMENT]; + + for (i = 0; i < PIPE_MAX_CONSTANT; i++) { + machine->Consts[i] = softpipe->mapped_constants[PIPE_SHADER_FRAGMENT][i]; + } machine->InterpCoefs = quads[0]->coef; for (i = 0; i < nr; i++) { diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c index b7ed4441b4..50ed51661a 100644 --- a/src/gallium/drivers/softpipe/sp_state_fs.c +++ b/src/gallium/drivers/softpipe/sp_state_fs.c @@ -164,12 +164,12 @@ softpipe_set_constant_buffer(struct pipe_context *pipe, struct softpipe_context *softpipe = softpipe_context(pipe); assert(shader < PIPE_SHADER_TYPES); - assert(index == 0); + assert(index < PIPE_MAX_CONSTANT); draw_flush(softpipe->draw); /* note: reference counting */ - pipe_buffer_reference(&softpipe->constants[shader], buf); + pipe_buffer_reference(&softpipe->constants[shader][index], buf); softpipe->dirty |= SP_NEW_CONSTANTS; } -- cgit v1.2.3 From d96bb01d2db4d07ab7e4b6a50da2f96787180a4d Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 11 Jan 2010 20:50:57 +0100 Subject: regress: Fix shader header. --- .../state_trackers/python/tests/regress/fragment-shader/frag-slt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-slt.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-slt.sh index f2a1521cbf..d58b7886a1 100644 --- a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-slt.sh +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-slt.sh @@ -1,4 +1,4 @@ -FRAG1.1 +FRAG DCL IN[0], COLOR, LINEAR DCL OUT[0], COLOR -- cgit v1.2.3 From dcf8543ab375dd9c128d1ca772b1e587cebbdc7c Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 21 Jan 2010 20:02:17 +0100 Subject: tgsi: Handle two-dimensional constants in text parser. --- src/gallium/auxiliary/tgsi/tgsi_build.c | 46 +++++++++++++++++++++++++++++++++ src/gallium/auxiliary/tgsi/tgsi_build.h | 9 +++++++ src/gallium/auxiliary/tgsi/tgsi_text.c | 34 ++++++++++++++++-------- 3 files changed, 78 insertions(+), 11 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c b/src/gallium/auxiliary/tgsi/tgsi_build.c index de9cbc8630..e38b0be7ab 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_build.c +++ b/src/gallium/auxiliary/tgsi/tgsi_build.c @@ -103,6 +103,7 @@ tgsi_default_declaration( void ) declaration.File = TGSI_FILE_NULL; declaration.UsageMask = TGSI_WRITEMASK_XYZW; declaration.Interpolate = TGSI_INTERPOLATE_CONSTANT; + declaration.Dimension = 0; declaration.Semantic = 0; declaration.Centroid = 0; declaration.Invariant = 0; @@ -116,6 +117,7 @@ tgsi_build_declaration( unsigned file, unsigned usage_mask, unsigned interpolate, + unsigned dimension, unsigned semantic, unsigned centroid, unsigned invariant, @@ -130,6 +132,7 @@ tgsi_build_declaration( declaration.File = file; declaration.UsageMask = usage_mask; declaration.Interpolate = interpolate; + declaration.Dimension = dimension; declaration.Semantic = semantic; declaration.Centroid = centroid; declaration.Invariant = invariant; @@ -183,6 +186,7 @@ tgsi_build_full_declaration( full_decl->Declaration.File, full_decl->Declaration.UsageMask, full_decl->Declaration.Interpolate, + full_decl->Declaration.Dimension, full_decl->Declaration.Semantic, full_decl->Declaration.Centroid, full_decl->Declaration.Invariant, @@ -199,6 +203,20 @@ tgsi_build_full_declaration( declaration, header ); + if (full_decl->Declaration.Dimension) { + struct tgsi_declaration_dimension *dd; + + if (maxsize <= size) { + return 0; + } + dd = (struct tgsi_declaration_dimension *)&tokens[size]; + size++; + + *dd = tgsi_build_declaration_dimension(full_decl->Dim.Index2D, + declaration, + header); + } + if( full_decl->Declaration.Semantic ) { struct tgsi_declaration_semantic *ds; @@ -249,6 +267,34 @@ tgsi_build_declaration_range( return declaration_range; } +struct tgsi_declaration_dimension +tgsi_default_declaration_dimension(void) +{ + struct tgsi_declaration_dimension dd; + + dd.Index2D = 0; + dd.Padding = 0; + + return dd; +} + +struct tgsi_declaration_dimension +tgsi_build_declaration_dimension(unsigned index_2d, + struct tgsi_declaration *declaration, + struct tgsi_header *header) +{ + struct tgsi_declaration_dimension dd; + + assert(index_2d <= 0xFFFF); + + dd = tgsi_default_declaration_dimension(); + dd.Index2D = index_2d; + + declaration_grow(declaration, header); + + return dd; +} + struct tgsi_declaration_semantic tgsi_default_declaration_semantic( void ) { diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.h b/src/gallium/auxiliary/tgsi/tgsi_build.h index 9de2757fe4..ebee4ce5f6 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_build.h +++ b/src/gallium/auxiliary/tgsi/tgsi_build.h @@ -64,6 +64,7 @@ tgsi_build_declaration( unsigned file, unsigned usage_mask, unsigned interpolate, + unsigned dimension, unsigned semantic, unsigned centroid, unsigned invariant, @@ -89,6 +90,14 @@ tgsi_build_declaration_range( struct tgsi_declaration *declaration, struct tgsi_header *header ); +struct tgsi_declaration_dimension +tgsi_default_declaration_dimension(void); + +struct tgsi_declaration_dimension +tgsi_build_declaration_dimension(unsigned index_2d, + struct tgsi_declaration *declaration, + struct tgsi_header *header); + struct tgsi_declaration_semantic tgsi_default_declaration_semantic( void ); diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c index 7fe5dad5ff..f74b56bfb5 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_text.c +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c @@ -553,7 +553,7 @@ parse_register_dcl_bracket( report_error( ctx, "Expected literal unsigned integer" ); return FALSE; } - bracket->first = (int) uindex; + bracket->first = uindex; eat_opt_white( &ctx->cur ); @@ -617,10 +617,12 @@ parse_register_dcl( * input primitive. so we want to declare just * the index relevant to the semantics which is in * the second bracket */ - if (ctx->processor == TGSI_PROCESSOR_GEOMETRY) { + if (ctx->processor == TGSI_PROCESSOR_GEOMETRY && *file == TGSI_FILE_INPUT) { brackets[0] = brackets[1]; + *num_brackets = 1; + } else { + *num_brackets = 2; } - *num_brackets = 2; } return TRUE; @@ -738,6 +740,13 @@ parse_src_operand( return FALSE; src->Register.File = file; + if (parsed_opt_brackets) { + src->Register.Dimension = 1; + src->Dimension.Indirect = 0; + src->Dimension.Dimension = 0; + src->Dimension.Index = bracket[0].index; + bracket[0] = bracket[1]; + } src->Register.Index = bracket[0].index; if (bracket[0].ind_file != TGSI_FILE_NULL) { src->Register.Indirect = 1; @@ -748,12 +757,6 @@ parse_src_operand( src->Indirect.SwizzleZ = bracket[0].ind_comp; src->Indirect.SwizzleW = bracket[0].ind_comp; } - if (parsed_opt_brackets) { - src->Register.Dimension = 1; - src->Dimension.Indirect = 0; - src->Dimension.Dimension = 0; - src->Dimension.Index = bracket[1].index; - } /* Parse optional swizzle. */ @@ -969,8 +972,17 @@ static boolean parse_declaration( struct translate_ctx *ctx ) decl = tgsi_default_full_declaration(); decl.Declaration.File = file; decl.Declaration.UsageMask = writemask; - decl.Range.First = brackets[0].first; - decl.Range.Last = brackets[0].last; + + if (num_brackets == 1) { + decl.Range.First = brackets[0].first; + decl.Range.Last = brackets[0].last; + } else { + decl.Range.First = brackets[1].first; + decl.Range.Last = brackets[1].last; + + decl.Declaration.Dimension = 1; + decl.Dim.Index2D = brackets[0].first; + } cur = ctx->cur; eat_opt_white( &cur ); -- cgit v1.2.3 From 91d58c3520452798bd1542f86936e0f408182fbf Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 21 Jan 2010 20:02:44 +0100 Subject: python: Link to ws2_32 on windows. --- src/gallium/state_trackers/python/SConscript | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/state_trackers/python/SConscript b/src/gallium/state_trackers/python/SConscript index 8498a90812..527e065cd9 100644 --- a/src/gallium/state_trackers/python/SConscript +++ b/src/gallium/state_trackers/python/SConscript @@ -21,6 +21,7 @@ if 'python' in env['statetrackers']: 'gdi32', 'user32', 'kernel32', + 'ws2_32', ]) else: env.Append(LIBS = [ -- cgit v1.2.3 From 4771e536e16699a0488b68e153de3478dfbc55d0 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 21 Jan 2010 20:03:13 +0100 Subject: regress: Add two-dimension constant buffer test. --- .../tests/regress/fragment-shader/frag-cb-2d.sh | 9 +++++ .../regress/fragment-shader/fragment-shader.py | 38 ++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-cb-2d.sh diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-cb-2d.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-cb-2d.sh new file mode 100644 index 0000000000..f70a5146f4 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-cb-2d.sh @@ -0,0 +1,9 @@ +FRAG + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR +DCL CONST[1][1..2] + +MAD OUT[0], IN[0], CONST[1][2], CONST[1][1] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py b/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py index 8d3bf9d4d7..6a0c1f824b 100644 --- a/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py @@ -26,6 +26,7 @@ # ########################################################################## +import struct from gallium import * @@ -146,6 +147,42 @@ def test(dev, name): fs = Shader(file('frag-' + name + '.sh', 'rt').read()) ctx.set_fragment_shader(fs) + constbuf0 = dev.buffer_create(16, + (PIPE_BUFFER_USAGE_CONSTANT | + PIPE_BUFFER_USAGE_GPU_READ | + PIPE_BUFFER_USAGE_CPU_WRITE), + 4 * 4 * 4) + + cbdata = '' + cbdata += struct.pack('4f', 0.5, 0.5, 0.5, 0.5) + cbdata += struct.pack('4f', 0.5, 0.5, 0.5, 0.5) + cbdata += struct.pack('4f', 0.5, 0.5, 0.5, 0.5) + cbdata += struct.pack('4f', 0.5, 0.5, 0.5, 0.5) + + constbuf0.write(cbdata, 0) + + ctx.set_constant_buffer(PIPE_SHADER_FRAGMENT, + 0, + constbuf0) + + constbuf1 = dev.buffer_create(64, + (PIPE_BUFFER_USAGE_CONSTANT | + PIPE_BUFFER_USAGE_GPU_READ | + PIPE_BUFFER_USAGE_CPU_WRITE), + 4 * 4 * 4) + + cbdata = '' + cbdata += struct.pack('4f', 0.1, 0.1, 0.1, 0.1) + cbdata += struct.pack('4f', 0.25, 0.25, 0.25, 0.25) + cbdata += struct.pack('4f', 0.5, 0.5, 0.5, 0.5) + cbdata += struct.pack('4f', 0.75, 0.75, 0.75, 0.75) + + constbuf1.write(cbdata, 0) + + ctx.set_constant_buffer(PIPE_SHADER_FRAGMENT, + 1, + constbuf1) + xy = [ -0.8, -0.8, 0.8, -0.8, @@ -184,6 +221,7 @@ def main(): tests = [ 'abs', 'add', + 'cb-2d', 'dp3', 'dp4', 'dst', -- cgit v1.2.3 From 44ac4c4e2c7890236ee7e9cd0cf82b58710d57ef Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Fri, 22 Jan 2010 09:40:33 +0100 Subject: regress: Add fragment shader test for one-dimensional constant buffers. --- .../python/tests/regress/fragment-shader/frag-cb-1d.sh | 13 +++++++++++++ .../python/tests/regress/fragment-shader/fragment-shader.py | 11 ++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-cb-1d.sh diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-cb-1d.sh b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-cb-1d.sh new file mode 100644 index 0000000000..85fb9ea4e7 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-cb-1d.sh @@ -0,0 +1,13 @@ +FRAG + +DCL IN[0], COLOR, LINEAR +DCL OUT[0], COLOR +DCL CONST[1] +DCL CONST[3] +DCL TEMP[0..1] + +ADD TEMP[0], IN[0], CONST[1] +RCP TEMP[1], CONST[3].xxxx +MUL OUT[0], TEMP[0], TEMP[1] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py b/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py index 6a0c1f824b..9e668d2ac6 100644 --- a/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py +++ b/src/gallium/state_trackers/python/tests/regress/fragment-shader/fragment-shader.py @@ -147,17 +147,17 @@ def test(dev, name): fs = Shader(file('frag-' + name + '.sh', 'rt').read()) ctx.set_fragment_shader(fs) - constbuf0 = dev.buffer_create(16, + constbuf0 = dev.buffer_create(64, (PIPE_BUFFER_USAGE_CONSTANT | PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_CPU_WRITE), 4 * 4 * 4) cbdata = '' - cbdata += struct.pack('4f', 0.5, 0.5, 0.5, 0.5) - cbdata += struct.pack('4f', 0.5, 0.5, 0.5, 0.5) - cbdata += struct.pack('4f', 0.5, 0.5, 0.5, 0.5) - cbdata += struct.pack('4f', 0.5, 0.5, 0.5, 0.5) + cbdata += struct.pack('4f', 0.4, 0.0, 0.0, 1.0) + cbdata += struct.pack('4f', 1.0, 1.0, 1.0, 1.0) + cbdata += struct.pack('4f', 2.0, 2.0, 2.0, 2.0) + cbdata += struct.pack('4f', 4.0, 8.0, 16.0, 32.0) constbuf0.write(cbdata, 0) @@ -221,6 +221,7 @@ def main(): tests = [ 'abs', 'add', + 'cb-1d', 'cb-2d', 'dp3', 'dp4', -- cgit v1.2.3 From 9851644435f991a1a1bbb145333a97601627b37d Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 25 Jan 2010 12:36:50 +0100 Subject: gallium: Enable multiple constant buffers for vertex and geometry shaders. --- src/gallium/auxiliary/draw/draw_context.c | 11 +++-- src/gallium/auxiliary/draw/draw_context.h | 10 +++-- src/gallium/auxiliary/draw/draw_gs.c | 14 ++++--- src/gallium/auxiliary/draw/draw_gs.h | 2 +- src/gallium/auxiliary/draw/draw_private.h | 28 ++++++++----- .../auxiliary/draw/draw_pt_fetch_shade_pipeline.c | 12 +++--- src/gallium/auxiliary/draw/draw_vs.c | 40 ++++++++++-------- src/gallium/auxiliary/draw/draw_vs.h | 8 ++-- src/gallium/auxiliary/draw/draw_vs_aos.c | 10 ++++- src/gallium/auxiliary/draw/draw_vs_aos.h | 2 +- src/gallium/auxiliary/draw/draw_vs_aos_machine.c | 14 ++++--- src/gallium/auxiliary/draw/draw_vs_exec.c | 6 ++- src/gallium/auxiliary/draw/draw_vs_llvm.c | 5 ++- src/gallium/auxiliary/draw/draw_vs_ppc.c | 4 +- src/gallium/auxiliary/draw/draw_vs_sse.c | 4 +- src/gallium/auxiliary/draw/draw_vs_varient.c | 4 +- src/gallium/drivers/cell/ppu/cell_draw_arrays.c | 2 +- src/gallium/drivers/i915/i915_context.c | 2 +- src/gallium/drivers/llvmpipe/lp_state_fs.c | 2 +- src/gallium/drivers/nv04/nv04_vbo.c | 2 +- src/gallium/drivers/nv10/nv10_vbo.c | 1 + src/gallium/drivers/nv20/nv20_vbo.c | 2 +- src/gallium/drivers/nv40/nv40_draw.c | 2 +- src/gallium/drivers/r300/r300_render.c | 2 + src/gallium/drivers/softpipe/sp_draw_arrays.c | 48 +++++++++++++--------- src/gallium/drivers/svga/svga_swtnl_draw.c | 2 +- src/mesa/state_tracker/st_draw_feedback.c | 2 +- 27 files changed, 146 insertions(+), 95 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 1639043832..a52b93e122 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -234,17 +234,20 @@ draw_set_mapped_vertex_buffer(struct draw_context *draw, void draw_set_mapped_constant_buffer(struct draw_context *draw, unsigned shader_type, + unsigned slot, const void *buffer, unsigned size ) { debug_assert(shader_type == PIPE_SHADER_VERTEX || shader_type == PIPE_SHADER_GEOMETRY); + debug_assert(slot < PIPE_MAX_CONSTANT); + if (shader_type == PIPE_SHADER_VERTEX) { - draw->pt.user.vs_constants = buffer; - draw_vs_set_constants( draw, (const float (*)[4])buffer, size ); + draw->pt.user.vs_constants[slot] = buffer; + draw_vs_set_constants(draw, slot, buffer, size); } else if (shader_type == PIPE_SHADER_GEOMETRY) { - draw->pt.user.gs_constants = buffer; - draw_gs_set_constants( draw, (const float (*)[4])buffer, size ); + draw->pt.user.gs_constants[slot] = buffer; + draw_gs_set_constants(draw, slot, buffer, size); } } diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h index 8a64c06efc..acd81b9712 100644 --- a/src/gallium/auxiliary/draw/draw_context.h +++ b/src/gallium/auxiliary/draw/draw_context.h @@ -151,10 +151,12 @@ void draw_set_mapped_element_buffer( struct draw_context *draw, void draw_set_mapped_vertex_buffer(struct draw_context *draw, unsigned attr, const void *buffer); -void draw_set_mapped_constant_buffer(struct draw_context *draw, - unsigned shader_type, - const void *buffer, - unsigned size ); +void +draw_set_mapped_constant_buffer(struct draw_context *draw, + unsigned shader_type, + unsigned slot, + const void *buffer, + unsigned size); /*********************************************************************** diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c index c3cc365a8d..96be5dba0b 100644 --- a/src/gallium/auxiliary/draw/draw_gs.c +++ b/src/gallium/auxiliary/draw/draw_gs.c @@ -69,9 +69,11 @@ void draw_gs_destroy( struct draw_context *draw ) tgsi_exec_machine_destroy(draw->gs.machine); } -void draw_gs_set_constants( struct draw_context *draw, - const float (*constants)[4], - unsigned size ) +void +draw_gs_set_constants(struct draw_context *draw, + unsigned slot, + const void *constants, + unsigned size) { } @@ -291,7 +293,7 @@ draw_geometry_fetch_outputs(struct draw_geometry_shader *shader, void draw_geometry_shader_run(struct draw_geometry_shader *shader, const float (*input)[4], float (*output)[4], - const float (*constants)[4], + const void *constants[PIPE_MAX_CONSTANT], unsigned count, unsigned input_stride, unsigned vertex_size) @@ -302,7 +304,9 @@ void draw_geometry_shader_run(struct draw_geometry_shader *shader, unsigned num_primitives = count/num_vertices; unsigned inputs_from_vs = 0; - machine->Consts[0] = constants; + for (i = 0; i < PIPE_MAX_CONSTANT; i++) { + machine->Consts[i] = constants[i]; + } for (i = 0; i < shader->info.num_inputs; ++i) { if (shader->info.input_semantic_name[i] != TGSI_SEMANTIC_PRIMID) diff --git a/src/gallium/auxiliary/draw/draw_gs.h b/src/gallium/auxiliary/draw/draw_gs.h index d6a97d9c4e..e055c8a05c 100644 --- a/src/gallium/auxiliary/draw/draw_gs.h +++ b/src/gallium/auxiliary/draw/draw_gs.h @@ -62,7 +62,7 @@ struct draw_geometry_shader { void draw_geometry_shader_run(struct draw_geometry_shader *shader, const float (*input)[4], float (*output)[4], - const float (*constants)[4], + const void *constants[PIPE_MAX_CONSTANT], unsigned count, unsigned input_stride, unsigned output_stride); diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index ef49e57536..ecb17cbbe2 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -153,8 +153,8 @@ struct draw_context const void *vbuffer[PIPE_MAX_ATTRIBS]; /** constant buffer (for vertex/geometry shader) */ - const void *vs_constants; - const void *gs_constants; + const void *vs_constants[PIPE_MAX_CONSTANT]; + const void *gs_constants[PIPE_MAX_CONSTANT]; } user; boolean test_fse; /* enable FSE even though its not correct (eg for softpipe) */ @@ -202,10 +202,10 @@ struct draw_context struct aos_machine *aos_machine; - const float (*aligned_constants)[4]; + const void *aligned_constants[PIPE_MAX_CONSTANT]; - const float (*aligned_constant_storage)[4]; - unsigned const_storage_size; + const void *aligned_constant_storage[PIPE_MAX_CONSTANT]; + unsigned const_storage_size[PIPE_MAX_CONSTANT]; struct translate *fetch; @@ -256,9 +256,11 @@ void draw_vs_destroy( struct draw_context *draw ); void draw_vs_set_viewport( struct draw_context *, const struct pipe_viewport_state * ); -void draw_vs_set_constants( struct draw_context *, - const float (*constants)[4], - unsigned size ); +void +draw_vs_set_constants(struct draw_context *, + unsigned slot, + const void *constants, + unsigned size); @@ -266,9 +268,13 @@ void draw_vs_set_constants( struct draw_context *, * Geometry shading code: */ boolean draw_gs_init( struct draw_context *draw ); -void draw_gs_set_constants( struct draw_context *, - const float (*constants)[4], - unsigned size ); + +void +draw_gs_set_constants(struct draw_context *, + unsigned slot, + const void *constants, + unsigned size); + void draw_gs_destroy( struct draw_context *draw ); /******************************************************************************* diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c index 2c996e7308..56b69354b2 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c @@ -163,7 +163,7 @@ static void fetch_pipeline_run( struct draw_pt_middle_end *middle, vshader->run_linear(vshader, (const float (*)[4])pipeline_verts->data, ( float (*)[4])pipeline_verts->data, - (const float (*)[4])draw->pt.user.vs_constants, + draw->pt.user.vs_constants, fetch_count, fpme->vertex_size, fpme->vertex_size); @@ -171,7 +171,7 @@ static void fetch_pipeline_run( struct draw_pt_middle_end *middle, draw_geometry_shader_run(gshader, (const float (*)[4])pipeline_verts->data, ( float (*)[4])pipeline_verts->data, - (const float (*)[4])draw->pt.user.gs_constants, + draw->pt.user.gs_constants, fetch_count, fpme->vertex_size, fpme->vertex_size); @@ -248,7 +248,7 @@ static void fetch_pipeline_linear_run( struct draw_pt_middle_end *middle, shader->run_linear(shader, (const float (*)[4])pipeline_verts->data, ( float (*)[4])pipeline_verts->data, - (const float (*)[4])draw->pt.user.vs_constants, + draw->pt.user.vs_constants, count, fpme->vertex_size, fpme->vertex_size); @@ -257,7 +257,7 @@ static void fetch_pipeline_linear_run( struct draw_pt_middle_end *middle, draw_geometry_shader_run(geometry_shader, (const float (*)[4])pipeline_verts->data, ( float (*)[4])pipeline_verts->data, - (const float (*)[4])draw->pt.user.gs_constants, + draw->pt.user.gs_constants, count, fpme->vertex_size, fpme->vertex_size); @@ -328,7 +328,7 @@ static boolean fetch_pipeline_linear_run_elts( struct draw_pt_middle_end *middle shader->run_linear(shader, (const float (*)[4])pipeline_verts->data, ( float (*)[4])pipeline_verts->data, - (const float (*)[4])draw->pt.user.vs_constants, + draw->pt.user.vs_constants, count, fpme->vertex_size, fpme->vertex_size); @@ -337,7 +337,7 @@ static boolean fetch_pipeline_linear_run_elts( struct draw_pt_middle_end *middle draw_geometry_shader_run(geometry_shader, (const float (*)[4])pipeline_verts->data, ( float (*)[4])pipeline_verts->data, - (const float (*)[4])draw->pt.user.gs_constants, + draw->pt.user.gs_constants, count, fpme->vertex_size, fpme->vertex_size); diff --git a/src/gallium/auxiliary/draw/draw_vs.c b/src/gallium/auxiliary/draw/draw_vs.c index e03ac8c229..120b976d9f 100644 --- a/src/gallium/auxiliary/draw/draw_vs.c +++ b/src/gallium/auxiliary/draw/draw_vs.c @@ -48,24 +48,27 @@ -void draw_vs_set_constants( struct draw_context *draw, - const float (*constants)[4], - unsigned size ) +void +draw_vs_set_constants(struct draw_context *draw, + unsigned slot, + const void *constants, + unsigned size) { if (((uintptr_t)constants) & 0xf) { - if (size > draw->vs.const_storage_size) { - if (draw->vs.aligned_constant_storage) - align_free((void *)draw->vs.aligned_constant_storage); - draw->vs.aligned_constant_storage = align_malloc( size, 16 ); + if (size > draw->vs.const_storage_size[slot]) { + if (draw->vs.aligned_constant_storage[slot]) { + align_free((void *)draw->vs.aligned_constant_storage[slot]); + } + draw->vs.aligned_constant_storage[slot] = align_malloc(size, 16); } - memcpy( (void*)draw->vs.aligned_constant_storage, - constants, - size ); - constants = draw->vs.aligned_constant_storage; + memcpy((void *)draw->vs.aligned_constant_storage[slot], + constants, + size); + constants = draw->vs.aligned_constant_storage[slot]; } - - draw->vs.aligned_constants = constants; - draw_vs_aos_machine_constants( draw->vs.aos_machine, constants ); + + draw->vs.aligned_constants[slot] = constants; + draw_vs_aos_machine_constants(draw->vs.aos_machine, slot, constants); } @@ -182,6 +185,8 @@ draw_vs_init( struct draw_context *draw ) void draw_vs_destroy( struct draw_context *draw ) { + uint i; + if (draw->vs.fetch_cache) translate_cache_destroy(draw->vs.fetch_cache); @@ -191,8 +196,11 @@ draw_vs_destroy( struct draw_context *draw ) if (draw->vs.aos_machine) draw_vs_aos_machine_destroy(draw->vs.aos_machine); - if (draw->vs.aligned_constant_storage) - align_free((void*)draw->vs.aligned_constant_storage); + for (i = 0; i < PIPE_MAX_CONSTANT; i++) { + if (draw->vs.aligned_constant_storage[i]) { + align_free((void *)draw->vs.aligned_constant_storage[i]); + } + } tgsi_exec_machine_destroy(draw->vs.machine); } diff --git a/src/gallium/auxiliary/draw/draw_vs.h b/src/gallium/auxiliary/draw/draw_vs.h index 00036cfe68..6bd3683d39 100644 --- a/src/gallium/auxiliary/draw/draw_vs.h +++ b/src/gallium/auxiliary/draw/draw_vs.h @@ -132,7 +132,7 @@ struct draw_vertex_shader { void (*run_linear)( struct draw_vertex_shader *shader, const float (*input)[4], float (*output)[4], - const float (*constants)[4], + const void *constants[PIPE_MAX_CONSTANT], unsigned count, unsigned input_stride, unsigned output_stride ); @@ -212,8 +212,10 @@ static INLINE int draw_vs_varient_key_compare( const struct draw_vs_varient_key struct aos_machine *draw_vs_aos_machine( void ); void draw_vs_aos_machine_destroy( struct aos_machine *machine ); -void draw_vs_aos_machine_constants( struct aos_machine *machine, - const float (*constants)[4] ); +void +draw_vs_aos_machine_constants(struct aos_machine *machine, + unsigned slot, + const void *constants); void draw_vs_aos_machine_viewport( struct aos_machine *machine, const struct pipe_viewport_state *viewport ); diff --git a/src/gallium/auxiliary/draw/draw_vs_aos.c b/src/gallium/auxiliary/draw/draw_vs_aos.c index 1aaae4ab7a..4d73de413d 100644 --- a/src/gallium/auxiliary/draw/draw_vs_aos.c +++ b/src/gallium/auxiliary/draw/draw_vs_aos.c @@ -2114,11 +2114,14 @@ static void PIPE_CDECL vaos_run_elts( struct draw_vs_varient *varient, { struct draw_vs_varient_aos_sse *vaos = (struct draw_vs_varient_aos_sse *)varient; struct aos_machine *machine = vaos->draw->vs.aos_machine; + unsigned i; if (0) debug_printf("%s %d\n", __FUNCTION__, count); machine->internal[IMM_PSIZE][0] = vaos->draw->rasterizer->point_size; - machine->constants = vaos->draw->vs.aligned_constants; + for (i = 0; i < PIPE_MAX_CONSTANT; i++) { + machine->constants[i] = vaos->draw->vs.aligned_constants[i]; + } machine->immediates = vaos->base.vs->immediates; machine->buffer = vaos->buffer; @@ -2135,12 +2138,15 @@ static void PIPE_CDECL vaos_run_linear( struct draw_vs_varient *varient, { struct draw_vs_varient_aos_sse *vaos = (struct draw_vs_varient_aos_sse *)varient; struct aos_machine *machine = vaos->draw->vs.aos_machine; + unsigned i; if (0) debug_printf("%s %d %d const: %x\n", __FUNCTION__, start, count, vaos->base.key.const_vbuffers); machine->internal[IMM_PSIZE][0] = vaos->draw->rasterizer->point_size; - machine->constants = vaos->draw->vs.aligned_constants; + for (i = 0; i < PIPE_MAX_CONSTANT; i++) { + machine->constants[i] = vaos->draw->vs.aligned_constants[i]; + } machine->immediates = vaos->base.vs->immediates; machine->buffer = vaos->buffer; diff --git a/src/gallium/auxiliary/draw/draw_vs_aos.h b/src/gallium/auxiliary/draw/draw_vs_aos.h index 2cf72ddf7b..eefc097464 100644 --- a/src/gallium/auxiliary/draw/draw_vs_aos.h +++ b/src/gallium/auxiliary/draw/draw_vs_aos.h @@ -122,7 +122,7 @@ struct aos_machine { ushort fpucntl; /* one of FPU_* above */ const float (*immediates)[4]; /* points to shader data */ - const float (*constants)[4]; /* points to draw data */ + const void *constants[PIPE_MAX_CONSTANT]; /* points to draw data */ const struct aos_buffer *buffer; /* points to ? */ }; diff --git a/src/gallium/auxiliary/draw/draw_vs_aos_machine.c b/src/gallium/auxiliary/draw/draw_vs_aos_machine.c index 3240e3745d..0eda414ee6 100644 --- a/src/gallium/auxiliary/draw/draw_vs_aos_machine.c +++ b/src/gallium/auxiliary/draw/draw_vs_aos_machine.c @@ -219,10 +219,12 @@ static void PIPE_CDECL populate_lut( struct aos_machine *machine, } -void draw_vs_aos_machine_constants( struct aos_machine *machine, - const float (*constants)[4] ) +void +draw_vs_aos_machine_constants(struct aos_machine *machine, + unsigned slot, + const void *constants) { - machine->constants = constants; + machine->constants[slot] = constants; { unsigned i; @@ -307,8 +309,10 @@ void draw_vs_aos_machine_viewport( struct aos_machine *machine, { } -void draw_vs_aos_machine_constants( struct aos_machine *machine, - const float (*constants)[4] ) +void +draw_vs_aos_machine_constants(struct aos_machine *machine, + unsigned slot, + const void *constants) { } diff --git a/src/gallium/auxiliary/draw/draw_vs_exec.c b/src/gallium/auxiliary/draw/draw_vs_exec.c index 3f7a5ca14b..652c844654 100644 --- a/src/gallium/auxiliary/draw/draw_vs_exec.c +++ b/src/gallium/auxiliary/draw/draw_vs_exec.c @@ -85,7 +85,7 @@ static void vs_exec_run_linear( struct draw_vertex_shader *shader, const float (*input)[4], float (*output)[4], - const float (*constants)[4], + const void *constants[PIPE_MAX_CONSTANT], unsigned count, unsigned input_stride, unsigned output_stride ) @@ -95,7 +95,9 @@ vs_exec_run_linear( struct draw_vertex_shader *shader, unsigned int i, j; unsigned slot; - machine->Consts[0] = constants; + for (i = 0; i < PIPE_MAX_CONSTANT; i++) { + machine->Consts[i] = constants[i]; + } for (i = 0; i < count; i += MAX_TGSI_VERTICES) { unsigned int max_vertices = MIN2(MAX_TGSI_VERTICES, count - i); diff --git a/src/gallium/auxiliary/draw/draw_vs_llvm.c b/src/gallium/auxiliary/draw/draw_vs_llvm.c index b3535c0e48..e8e72f06ec 100644 --- a/src/gallium/auxiliary/draw/draw_vs_llvm.c +++ b/src/gallium/auxiliary/draw/draw_vs_llvm.c @@ -64,7 +64,7 @@ static void vs_llvm_run_linear( struct draw_vertex_shader *base, const float (*input)[4], float (*output)[4], - const float (*constants)[4], + const void *constants[PIPE_MAX_CONSTANT], unsigned count, unsigned input_stride, unsigned output_stride ) @@ -74,7 +74,8 @@ vs_llvm_run_linear( struct draw_vertex_shader *base, gallivm_cpu_vs_exec(shader->llvm_prog, shader->machine, input, base->info.num_inputs, output, base->info.num_outputs, - constants, count, input_stride, output_stride); + (const float (*)[4])constants[0], + count, input_stride, output_stride); } diff --git a/src/gallium/auxiliary/draw/draw_vs_ppc.c b/src/gallium/auxiliary/draw/draw_vs_ppc.c index da9f3e3d35..9952b40fcc 100644 --- a/src/gallium/auxiliary/draw/draw_vs_ppc.c +++ b/src/gallium/auxiliary/draw/draw_vs_ppc.c @@ -85,7 +85,7 @@ static void vs_ppc_run_linear( struct draw_vertex_shader *base, const float (*input)[4], float (*output)[4], - const float (*constants)[4], + const void *constants[PIPE_MAX_CONSTANT], unsigned count, unsigned input_stride, unsigned output_stride ) @@ -125,7 +125,7 @@ vs_ppc_run_linear( struct draw_vertex_shader *base, */ shader->func(inputs_soa, outputs_soa, temps_soa, (float (*)[4]) shader->base.immediates, - (float (*)[4]) constants, + (const float (*)[4])constants[0], ppc_builtin_constants); /* convert (up to) four output verts from SoA back to AoS format */ diff --git a/src/gallium/auxiliary/draw/draw_vs_sse.c b/src/gallium/auxiliary/draw/draw_vs_sse.c index 702051387a..297013dc74 100644 --- a/src/gallium/auxiliary/draw/draw_vs_sse.c +++ b/src/gallium/auxiliary/draw/draw_vs_sse.c @@ -83,7 +83,7 @@ static void vs_sse_run_linear( struct draw_vertex_shader *base, const float (*input)[4], float (*output)[4], - const float (*constants)[4], + const void *constants[PIPE_MAX_CONSTANT], unsigned count, unsigned input_stride, unsigned output_stride ) @@ -112,7 +112,7 @@ vs_sse_run_linear( struct draw_vertex_shader *base, /* run compiled shader */ shader->func(machine, - constants, + (const float (*)[4])constants[0], shader->base.immediates, input, base->info.num_inputs, diff --git a/src/gallium/auxiliary/draw/draw_vs_varient.c b/src/gallium/auxiliary/draw/draw_vs_varient.c index b87a465f6b..5ed706cb4f 100644 --- a/src/gallium/auxiliary/draw/draw_vs_varient.c +++ b/src/gallium/auxiliary/draw/draw_vs_varient.c @@ -147,7 +147,7 @@ static void PIPE_CDECL vsvg_run_elts( struct draw_vs_varient *varient, vsvg->base.vs->run_linear( vsvg->base.vs, temp_buffer, temp_buffer, - (const float (*)[4])vsvg->base.vs->draw->pt.user.vs_constants, + vsvg->base.vs->draw->pt.user.vs_constants, count, temp_vertex_stride, temp_vertex_stride); @@ -210,7 +210,7 @@ static void PIPE_CDECL vsvg_run_linear( struct draw_vs_varient *varient, vsvg->base.vs->run_linear( vsvg->base.vs, temp_buffer, temp_buffer, - (const float (*)[4])vsvg->base.vs->draw->pt.user.vs_constants, + vsvg->base.vs->draw->pt.user.vs_constants, count, temp_vertex_stride, temp_vertex_stride); diff --git a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c index 0a4da8ecc8..c674d0be63 100644 --- a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c +++ b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c @@ -59,7 +59,7 @@ cell_map_constant_buffers(struct cell_context *sp) } } - draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_VERTEX, + draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_VERTEX, 0, sp->mapped_constants[PIPE_SHADER_VERTEX], sp->constants[PIPE_SHADER_VERTEX]->size); } diff --git a/src/gallium/drivers/i915/i915_context.c b/src/gallium/drivers/i915/i915_context.c index 4c5ff37ca8..a0c80d0228 100644 --- a/src/gallium/drivers/i915/i915_context.c +++ b/src/gallium/drivers/i915/i915_context.c @@ -81,7 +81,7 @@ i915_draw_range_elements(struct pipe_context *pipe, } - draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, + draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0, i915->current.constants[PIPE_SHADER_VERTEX], (i915->current.num_user_constants[PIPE_SHADER_VERTEX] * 4 * sizeof(float))); diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 70e2a082cc..0cb335fe27 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -731,7 +731,7 @@ llvmpipe_set_constant_buffer(struct pipe_context *pipe, } if(shader == PIPE_SHADER_VERTEX) { - draw_set_mapped_constant_buffer(llvmpipe->draw, PIPE_SHADER_VERTEX, + draw_set_mapped_constant_buffer(llvmpipe->draw, PIPE_SHADER_VERTEX, 0, data, size); } diff --git a/src/gallium/drivers/nv04/nv04_vbo.c b/src/gallium/drivers/nv04/nv04_vbo.c index 3484771814..2db61d8941 100644 --- a/src/gallium/drivers/nv04/nv04_vbo.c +++ b/src/gallium/drivers/nv04/nv04_vbo.c @@ -45,7 +45,7 @@ void nv04_draw_elements( struct pipe_context *pipe, draw_set_mapped_element_buffer(draw, 0, NULL); } - draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, + draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0, nv04->constbuf[PIPE_SHADER_VERTEX], nv04->constbuf_nr[PIPE_SHADER_VERTEX]); diff --git a/src/gallium/drivers/nv10/nv10_vbo.c b/src/gallium/drivers/nv10/nv10_vbo.c index 9180c72c9b..da5c93f081 100644 --- a/src/gallium/drivers/nv10/nv10_vbo.c +++ b/src/gallium/drivers/nv10/nv10_vbo.c @@ -46,6 +46,7 @@ void nv10_draw_elements( struct pipe_context *pipe, draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, + 0, nv10->constbuf[PIPE_SHADER_VERTEX], nv10->constbuf_nr[PIPE_SHADER_VERTEX]); diff --git a/src/gallium/drivers/nv20/nv20_vbo.c b/src/gallium/drivers/nv20/nv20_vbo.c index 52991a0d85..6dc9538901 100644 --- a/src/gallium/drivers/nv20/nv20_vbo.c +++ b/src/gallium/drivers/nv20/nv20_vbo.c @@ -45,7 +45,7 @@ void nv20_draw_elements( struct pipe_context *pipe, draw_set_mapped_element_buffer(draw, 0, NULL); } - draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, + draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0, nv20->constbuf[PIPE_SHADER_VERTEX], nv20->constbuf_nr[PIPE_SHADER_VERTEX]); diff --git a/src/gallium/drivers/nv40/nv40_draw.c b/src/gallium/drivers/nv40/nv40_draw.c index d826f8c2f5..a2fd5f6c02 100644 --- a/src/gallium/drivers/nv40/nv40_draw.c +++ b/src/gallium/drivers/nv40/nv40_draw.c @@ -271,7 +271,7 @@ nv40_draw_elements_swtnl(struct pipe_context *pipe, map = pipe_buffer_map(pscreen, nv40->constbuf[PIPE_SHADER_VERTEX], PIPE_BUFFER_USAGE_CPU_READ); - draw_set_mapped_constant_buffer(nv40->draw, PIPE_SHADER_VERTEX, + draw_set_mapped_constant_buffer(nv40->draw, PIPE_SHADER_VERTEX, 0, map, nr); } diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index bcb3707149..95b7cb5fa4 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -462,6 +462,7 @@ void r300_swtcl_draw_arrays(struct pipe_context* pipe, draw_set_mapped_constant_buffer(r300->draw, PIPE_SHADER_VERTEX, + 0, r300->shader_constants[PIPE_SHADER_VERTEX].constants, r300->shader_constants[PIPE_SHADER_VERTEX].count * (sizeof(float) * 4)); @@ -506,6 +507,7 @@ void r300_swtcl_draw_range_elements(struct pipe_context* pipe, draw_set_mapped_constant_buffer(r300->draw, PIPE_SHADER_VERTEX, + 0, r300->shader_constants[PIPE_SHADER_VERTEX].constants, r300->shader_constants[PIPE_SHADER_VERTEX].count * (sizeof(float) * 4)); diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c index cbb9631fa5..06b97ab7c9 100644 --- a/src/gallium/drivers/softpipe/sp_draw_arrays.c +++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c @@ -49,7 +49,7 @@ static void softpipe_map_constant_buffers(struct softpipe_context *sp) { struct pipe_winsys *ws = sp->pipe.winsys; - uint i, vssize, gssize; + uint i; for (i = 0; i < PIPE_SHADER_TYPES; i++) { uint j; @@ -63,22 +63,22 @@ softpipe_map_constant_buffers(struct softpipe_context *sp) } } - if (sp->constants[PIPE_SHADER_VERTEX][0]) - vssize = sp->constants[PIPE_SHADER_VERTEX][0]->size; - else - vssize = 0; - - if (sp->constants[PIPE_SHADER_GEOMETRY][0]) - gssize = sp->constants[PIPE_SHADER_GEOMETRY][0]->size; - else - gssize = 0; - - draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_VERTEX, - sp->mapped_constants[PIPE_SHADER_VERTEX][0], - vssize); - draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_GEOMETRY, - sp->mapped_constants[PIPE_SHADER_GEOMETRY][0], - gssize); + for (i = 0; i < PIPE_MAX_CONSTANT; i++) { + if (sp->constants[PIPE_SHADER_VERTEX][i]) { + draw_set_mapped_constant_buffer(sp->draw, + PIPE_SHADER_VERTEX, + i, + sp->mapped_constants[PIPE_SHADER_VERTEX][i], + sp->constants[PIPE_SHADER_VERTEX][i]->size); + } + if (sp->constants[PIPE_SHADER_GEOMETRY][i]) { + draw_set_mapped_constant_buffer(sp->draw, + PIPE_SHADER_GEOMETRY, + i, + sp->mapped_constants[PIPE_SHADER_GEOMETRY][i], + sp->constants[PIPE_SHADER_GEOMETRY][i]->size); + } + } } @@ -93,8 +93,18 @@ softpipe_unmap_constant_buffers(struct softpipe_context *sp) */ draw_flush(sp->draw); - draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_VERTEX, NULL, 0); - draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_GEOMETRY, NULL, 0); + for (i = 0; i < PIPE_MAX_CONSTANT; i++) { + draw_set_mapped_constant_buffer(sp->draw, + PIPE_SHADER_VERTEX, + i, + NULL, + 0); + draw_set_mapped_constant_buffer(sp->draw, + PIPE_SHADER_GEOMETRY, + i, + NULL, + 0); + } for (i = 0; i < PIPE_SHADER_TYPES; i++) { uint j; diff --git a/src/gallium/drivers/svga/svga_swtnl_draw.c b/src/gallium/drivers/svga/svga_swtnl_draw.c index 0ae58c7d9d..5e6e30c7df 100644 --- a/src/gallium/drivers/svga/svga_swtnl_draw.c +++ b/src/gallium/drivers/svga/svga_swtnl_draw.c @@ -89,7 +89,7 @@ svga_swtnl_draw_range_elements(struct svga_context *svga, PIPE_BUFFER_USAGE_CPU_READ); assert(map); draw_set_mapped_constant_buffer( - draw, PIPE_SHADER_VERTEX, + draw, PIPE_SHADER_VERTEX, 0, map, svga->curr.cb[PIPE_SHADER_VERTEX]->size); } diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c index dd27a1e3a8..cdaee2a353 100644 --- a/src/mesa/state_tracker/st_draw_feedback.c +++ b/src/mesa/state_tracker/st_draw_feedback.c @@ -241,7 +241,7 @@ st_feedback_draw_vbo(GLcontext *ctx, mapped_constants = pipe_buffer_map(pipe->screen, st->state.constants[PIPE_SHADER_VERTEX], PIPE_BUFFER_USAGE_CPU_READ); - draw_set_mapped_constant_buffer(st->draw, PIPE_SHADER_VERTEX, + draw_set_mapped_constant_buffer(st->draw, PIPE_SHADER_VERTEX, 0, mapped_constants, st->state.constants[PIPE_SHADER_VERTEX]->size); -- cgit v1.2.3 From 333c035a519a36efd19d2ab227924feb8b0f4c25 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 25 Jan 2010 12:42:17 +0100 Subject: regress: Add vertex shaders tests for constant buffers. --- .../tests/regress/vertex-shader/vert-cb-1d.sh | 16 +++++++++ .../tests/regress/vertex-shader/vert-cb-2d.sh | 12 +++++++ .../tests/regress/vertex-shader/vertex-shader.py | 40 ++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-cb-1d.sh create mode 100644 src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-cb-2d.sh diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-cb-1d.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-cb-1d.sh new file mode 100644 index 0000000000..b41fe5dd38 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-cb-1d.sh @@ -0,0 +1,16 @@ +VERT + +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR +DCL CONST[1] +DCL CONST[3] +DCL TEMP[0..1] + +MOV OUT[0], IN[0] +ADD TEMP[0], IN[1], CONST[1] +RCP TEMP[1], CONST[3].xxxx +MUL OUT[1], TEMP[0], TEMP[1] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-cb-2d.sh b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-cb-2d.sh new file mode 100644 index 0000000000..45f5e6b729 --- /dev/null +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vert-cb-2d.sh @@ -0,0 +1,12 @@ +VERT + +DCL IN[0], POSITION +DCL IN[1], COLOR +DCL OUT[0], POSITION +DCL OUT[1], COLOR +DCL CONST[1][1..2] + +MOV OUT[0], IN[0] +MAD OUT[1], IN[1], CONST[1][2], CONST[1][1] + +END diff --git a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py index 01bf5a3210..96503778ae 100644 --- a/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py +++ b/src/gallium/state_trackers/python/tests/regress/vertex-shader/vertex-shader.py @@ -27,6 +27,8 @@ ########################################################################## +import struct + from gallium import * def make_image(surface): @@ -143,6 +145,42 @@ def test(dev, name): ''') ctx.set_fragment_shader(fs) + constbuf0 = dev.buffer_create(64, + (PIPE_BUFFER_USAGE_CONSTANT | + PIPE_BUFFER_USAGE_GPU_READ | + PIPE_BUFFER_USAGE_CPU_WRITE), + 4 * 4 * 4) + + cbdata = '' + cbdata += struct.pack('4f', 0.4, 0.0, 0.0, 1.0) + cbdata += struct.pack('4f', 1.0, 1.0, 1.0, 1.0) + cbdata += struct.pack('4f', 2.0, 2.0, 2.0, 2.0) + cbdata += struct.pack('4f', 4.0, 8.0, 16.0, 32.0) + + constbuf0.write(cbdata, 0) + + ctx.set_constant_buffer(PIPE_SHADER_VERTEX, + 0, + constbuf0) + + constbuf1 = dev.buffer_create(64, + (PIPE_BUFFER_USAGE_CONSTANT | + PIPE_BUFFER_USAGE_GPU_READ | + PIPE_BUFFER_USAGE_CPU_WRITE), + 4 * 4 * 4) + + cbdata = '' + cbdata += struct.pack('4f', 0.1, 0.1, 0.1, 0.1) + cbdata += struct.pack('4f', 0.25, 0.25, 0.25, 0.25) + cbdata += struct.pack('4f', 0.5, 0.5, 0.5, 0.5) + cbdata += struct.pack('4f', 0.75, 0.75, 0.75, 0.75) + + constbuf1.write(cbdata, 0) + + ctx.set_constant_buffer(PIPE_SHADER_VERTEX, + 1, + constbuf1) + xy = [ 0.0, 0.8, -0.2, 0.4, @@ -213,6 +251,8 @@ def main(): 'add', 'arl', 'arr', + 'cb-1d', + 'cb-2d', 'dp3', 'dp4', 'dst', -- cgit v1.2.3 From 7c5f255201f42303188137f56ea8acc030444f0e Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 25 Jan 2010 13:29:33 +0100 Subject: gallium: Rename PIPE_MAX_CONSTANT to PIPE_MAX_CONSTANT_BUFFERS. --- src/gallium/auxiliary/draw/draw_context.c | 2 +- src/gallium/auxiliary/draw/draw_gs.c | 4 ++-- src/gallium/auxiliary/draw/draw_gs.h | 2 +- src/gallium/auxiliary/draw/draw_private.h | 10 +++++----- src/gallium/auxiliary/draw/draw_vs.c | 2 +- src/gallium/auxiliary/draw/draw_vs.h | 2 +- src/gallium/auxiliary/draw/draw_vs_aos.c | 4 ++-- src/gallium/auxiliary/draw/draw_vs_aos.h | 2 +- src/gallium/auxiliary/draw/draw_vs_exec.c | 4 ++-- src/gallium/auxiliary/draw/draw_vs_llvm.c | 2 +- src/gallium/auxiliary/draw/draw_vs_ppc.c | 2 +- src/gallium/auxiliary/draw/draw_vs_sse.c | 2 +- src/gallium/auxiliary/tgsi/tgsi_exec.c | 2 +- src/gallium/auxiliary/tgsi/tgsi_exec.h | 2 +- src/gallium/auxiliary/tgsi/tgsi_ureg.c | 6 +++--- src/gallium/drivers/softpipe/sp_context.c | 2 +- src/gallium/drivers/softpipe/sp_context.h | 4 ++-- src/gallium/drivers/softpipe/sp_draw_arrays.c | 8 ++++---- src/gallium/drivers/softpipe/sp_quad_fs.c | 2 +- src/gallium/drivers/softpipe/sp_state_fs.c | 2 +- src/gallium/include/pipe/p_state.h | 2 +- 21 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index a52b93e122..d3084fd428 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -240,7 +240,7 @@ draw_set_mapped_constant_buffer(struct draw_context *draw, { debug_assert(shader_type == PIPE_SHADER_VERTEX || shader_type == PIPE_SHADER_GEOMETRY); - debug_assert(slot < PIPE_MAX_CONSTANT); + debug_assert(slot < PIPE_MAX_CONSTANT_BUFFERS); if (shader_type == PIPE_SHADER_VERTEX) { draw->pt.user.vs_constants[slot] = buffer; diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c index 96be5dba0b..7069aa6b18 100644 --- a/src/gallium/auxiliary/draw/draw_gs.c +++ b/src/gallium/auxiliary/draw/draw_gs.c @@ -293,7 +293,7 @@ draw_geometry_fetch_outputs(struct draw_geometry_shader *shader, void draw_geometry_shader_run(struct draw_geometry_shader *shader, const float (*input)[4], float (*output)[4], - const void *constants[PIPE_MAX_CONSTANT], + const void *constants[PIPE_MAX_CONSTANT_BUFFERS], unsigned count, unsigned input_stride, unsigned vertex_size) @@ -304,7 +304,7 @@ void draw_geometry_shader_run(struct draw_geometry_shader *shader, unsigned num_primitives = count/num_vertices; unsigned inputs_from_vs = 0; - for (i = 0; i < PIPE_MAX_CONSTANT; i++) { + for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++) { machine->Consts[i] = constants[i]; } diff --git a/src/gallium/auxiliary/draw/draw_gs.h b/src/gallium/auxiliary/draw/draw_gs.h index e055c8a05c..d8eb210343 100644 --- a/src/gallium/auxiliary/draw/draw_gs.h +++ b/src/gallium/auxiliary/draw/draw_gs.h @@ -62,7 +62,7 @@ struct draw_geometry_shader { void draw_geometry_shader_run(struct draw_geometry_shader *shader, const float (*input)[4], float (*output)[4], - const void *constants[PIPE_MAX_CONSTANT], + const void *constants[PIPE_MAX_CONSTANT_BUFFERS], unsigned count, unsigned input_stride, unsigned output_stride); diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index ecb17cbbe2..6a7190e975 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -153,8 +153,8 @@ struct draw_context const void *vbuffer[PIPE_MAX_ATTRIBS]; /** constant buffer (for vertex/geometry shader) */ - const void *vs_constants[PIPE_MAX_CONSTANT]; - const void *gs_constants[PIPE_MAX_CONSTANT]; + const void *vs_constants[PIPE_MAX_CONSTANT_BUFFERS]; + const void *gs_constants[PIPE_MAX_CONSTANT_BUFFERS]; } user; boolean test_fse; /* enable FSE even though its not correct (eg for softpipe) */ @@ -202,10 +202,10 @@ struct draw_context struct aos_machine *aos_machine; - const void *aligned_constants[PIPE_MAX_CONSTANT]; + const void *aligned_constants[PIPE_MAX_CONSTANT_BUFFERS]; - const void *aligned_constant_storage[PIPE_MAX_CONSTANT]; - unsigned const_storage_size[PIPE_MAX_CONSTANT]; + const void *aligned_constant_storage[PIPE_MAX_CONSTANT_BUFFERS]; + unsigned const_storage_size[PIPE_MAX_CONSTANT_BUFFERS]; struct translate *fetch; diff --git a/src/gallium/auxiliary/draw/draw_vs.c b/src/gallium/auxiliary/draw/draw_vs.c index 120b976d9f..6bdd612e6f 100644 --- a/src/gallium/auxiliary/draw/draw_vs.c +++ b/src/gallium/auxiliary/draw/draw_vs.c @@ -196,7 +196,7 @@ draw_vs_destroy( struct draw_context *draw ) if (draw->vs.aos_machine) draw_vs_aos_machine_destroy(draw->vs.aos_machine); - for (i = 0; i < PIPE_MAX_CONSTANT; i++) { + for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++) { if (draw->vs.aligned_constant_storage[i]) { align_free((void *)draw->vs.aligned_constant_storage[i]); } diff --git a/src/gallium/auxiliary/draw/draw_vs.h b/src/gallium/auxiliary/draw/draw_vs.h index 6bd3683d39..d095c9bad1 100644 --- a/src/gallium/auxiliary/draw/draw_vs.h +++ b/src/gallium/auxiliary/draw/draw_vs.h @@ -132,7 +132,7 @@ struct draw_vertex_shader { void (*run_linear)( struct draw_vertex_shader *shader, const float (*input)[4], float (*output)[4], - const void *constants[PIPE_MAX_CONSTANT], + const void *constants[PIPE_MAX_CONSTANT_BUFFERS], unsigned count, unsigned input_stride, unsigned output_stride ); diff --git a/src/gallium/auxiliary/draw/draw_vs_aos.c b/src/gallium/auxiliary/draw/draw_vs_aos.c index 4d73de413d..e7121f3654 100644 --- a/src/gallium/auxiliary/draw/draw_vs_aos.c +++ b/src/gallium/auxiliary/draw/draw_vs_aos.c @@ -2119,7 +2119,7 @@ static void PIPE_CDECL vaos_run_elts( struct draw_vs_varient *varient, if (0) debug_printf("%s %d\n", __FUNCTION__, count); machine->internal[IMM_PSIZE][0] = vaos->draw->rasterizer->point_size; - for (i = 0; i < PIPE_MAX_CONSTANT; i++) { + for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++) { machine->constants[i] = vaos->draw->vs.aligned_constants[i]; } machine->immediates = vaos->base.vs->immediates; @@ -2144,7 +2144,7 @@ static void PIPE_CDECL vaos_run_linear( struct draw_vs_varient *varient, vaos->base.key.const_vbuffers); machine->internal[IMM_PSIZE][0] = vaos->draw->rasterizer->point_size; - for (i = 0; i < PIPE_MAX_CONSTANT; i++) { + for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++) { machine->constants[i] = vaos->draw->vs.aligned_constants[i]; } machine->immediates = vaos->base.vs->immediates; diff --git a/src/gallium/auxiliary/draw/draw_vs_aos.h b/src/gallium/auxiliary/draw/draw_vs_aos.h index eefc097464..1911242f82 100644 --- a/src/gallium/auxiliary/draw/draw_vs_aos.h +++ b/src/gallium/auxiliary/draw/draw_vs_aos.h @@ -122,7 +122,7 @@ struct aos_machine { ushort fpucntl; /* one of FPU_* above */ const float (*immediates)[4]; /* points to shader data */ - const void *constants[PIPE_MAX_CONSTANT]; /* points to draw data */ + const void *constants[PIPE_MAX_CONSTANT_BUFFERS]; /* points to draw data */ const struct aos_buffer *buffer; /* points to ? */ }; diff --git a/src/gallium/auxiliary/draw/draw_vs_exec.c b/src/gallium/auxiliary/draw/draw_vs_exec.c index 652c844654..7deca2b69d 100644 --- a/src/gallium/auxiliary/draw/draw_vs_exec.c +++ b/src/gallium/auxiliary/draw/draw_vs_exec.c @@ -85,7 +85,7 @@ static void vs_exec_run_linear( struct draw_vertex_shader *shader, const float (*input)[4], float (*output)[4], - const void *constants[PIPE_MAX_CONSTANT], + const void *constants[PIPE_MAX_CONSTANT_BUFFERS], unsigned count, unsigned input_stride, unsigned output_stride ) @@ -95,7 +95,7 @@ vs_exec_run_linear( struct draw_vertex_shader *shader, unsigned int i, j; unsigned slot; - for (i = 0; i < PIPE_MAX_CONSTANT; i++) { + for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++) { machine->Consts[i] = constants[i]; } diff --git a/src/gallium/auxiliary/draw/draw_vs_llvm.c b/src/gallium/auxiliary/draw/draw_vs_llvm.c index e8e72f06ec..fd9166fda5 100644 --- a/src/gallium/auxiliary/draw/draw_vs_llvm.c +++ b/src/gallium/auxiliary/draw/draw_vs_llvm.c @@ -64,7 +64,7 @@ static void vs_llvm_run_linear( struct draw_vertex_shader *base, const float (*input)[4], float (*output)[4], - const void *constants[PIPE_MAX_CONSTANT], + const void *constants[PIPE_MAX_CONSTANT_BUFFERS], unsigned count, unsigned input_stride, unsigned output_stride ) diff --git a/src/gallium/auxiliary/draw/draw_vs_ppc.c b/src/gallium/auxiliary/draw/draw_vs_ppc.c index 9952b40fcc..d869eecec5 100644 --- a/src/gallium/auxiliary/draw/draw_vs_ppc.c +++ b/src/gallium/auxiliary/draw/draw_vs_ppc.c @@ -85,7 +85,7 @@ static void vs_ppc_run_linear( struct draw_vertex_shader *base, const float (*input)[4], float (*output)[4], - const void *constants[PIPE_MAX_CONSTANT], + const void *constants[PIPE_MAX_CONSTANT_BUFFERS], unsigned count, unsigned input_stride, unsigned output_stride ) diff --git a/src/gallium/auxiliary/draw/draw_vs_sse.c b/src/gallium/auxiliary/draw/draw_vs_sse.c index 297013dc74..54e6423388 100644 --- a/src/gallium/auxiliary/draw/draw_vs_sse.c +++ b/src/gallium/auxiliary/draw/draw_vs_sse.c @@ -83,7 +83,7 @@ static void vs_sse_run_linear( struct draw_vertex_shader *base, const float (*input)[4], float (*output)[4], - const void *constants[PIPE_MAX_CONSTANT], + const void *constants[PIPE_MAX_CONSTANT_BUFFERS], unsigned count, unsigned input_stride, unsigned output_stride ) diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 74e7e637cc..fbb9aa0e63 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -965,7 +965,7 @@ fetch_src_file_channel(const struct tgsi_exec_machine *mach, switch (file) { case TGSI_FILE_CONSTANT: for (i = 0; i < QUAD_SIZE; i++) { - assert(index2D->i[i] >= 0 && index2D->i[i] < PIPE_MAX_CONSTANT); + assert(index2D->i[i] >= 0 && index2D->i[i] < PIPE_MAX_CONSTANT_BUFFERS); assert(mach->Consts[index2D->i[i]]); if (index->i[i] < 0) { diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h index 1f3e85fb62..a22873e4c2 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.h +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h @@ -260,7 +260,7 @@ struct tgsi_exec_machine struct tgsi_sampler **Samplers; unsigned ImmLimit; - const void *Consts[PIPE_MAX_CONSTANT]; + const void *Consts[PIPE_MAX_CONSTANT_BUFFERS]; const struct tgsi_token *Tokens; /**< Declarations, instructions */ unsigned Processor; /**< TGSI_PROCESSOR_x */ diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index c18db2e5b7..df0173928c 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -136,7 +136,7 @@ struct ureg_program unsigned temps_active[UREG_MAX_TEMP / 32]; unsigned nr_temps; - struct const_decl const_decls[PIPE_MAX_CONSTANT]; + struct const_decl const_decls[PIPE_MAX_CONSTANT_BUFFERS]; unsigned property_gs_input_prim; @@ -367,7 +367,7 @@ ureg_DECL_constant2D(struct ureg_program *ureg, { struct const_decl *decl = &ureg->const_decls[index2D]; - assert(index2D < PIPE_MAX_CONSTANT); + assert(index2D < PIPE_MAX_CONSTANT_BUFFERS); if (decl->nr_constant_ranges < UREG_MAX_CONSTANT_RANGE) { uint i = decl->nr_constant_ranges++; @@ -1209,7 +1209,7 @@ static void emit_decls( struct ureg_program *ureg ) ureg->sampler[i].Index, 1 ); } - for (i = 0; i < PIPE_MAX_CONSTANT; i++) { + for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++) { struct const_decl *decl = &ureg->const_decls[i]; if (decl->nr_constant_ranges) { diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index a3a7825aa1..53133d2888 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -114,7 +114,7 @@ softpipe_destroy( struct pipe_context *pipe ) for (i = 0; i < PIPE_SHADER_TYPES; i++) { uint j; - for (j = 0; j < PIPE_MAX_CONSTANT; j++) { + for (j = 0; j < PIPE_MAX_CONSTANT_BUFFERS; j++) { if (softpipe->constants[i][j]) { pipe_buffer_reference(&softpipe->constants[i][j], NULL); } diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h index f19b3cd5be..be4613b622 100644 --- a/src/gallium/drivers/softpipe/sp_context.h +++ b/src/gallium/drivers/softpipe/sp_context.h @@ -63,7 +63,7 @@ struct softpipe_context { /** Other rendering state */ struct pipe_blend_color blend_color; struct pipe_clip_state clip; - struct pipe_buffer *constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT]; + struct pipe_buffer *constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS]; struct pipe_framebuffer_state framebuffer; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; @@ -92,7 +92,7 @@ struct softpipe_context { ubyte *mapped_vbuffer[PIPE_MAX_ATTRIBS]; /** Mapped constant buffers */ - void *mapped_constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT]; + void *mapped_constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS]; /** Vertex format */ struct vertex_info vertex_info; diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c index 06b97ab7c9..2b82427d54 100644 --- a/src/gallium/drivers/softpipe/sp_draw_arrays.c +++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c @@ -54,7 +54,7 @@ softpipe_map_constant_buffers(struct softpipe_context *sp) for (i = 0; i < PIPE_SHADER_TYPES; i++) { uint j; - for (j = 0; j < PIPE_MAX_CONSTANT; j++) { + for (j = 0; j < PIPE_MAX_CONSTANT_BUFFERS; j++) { if (sp->constants[i][j] && sp->constants[i][j]->size) { sp->mapped_constants[i][j] = ws->buffer_map(ws, sp->constants[i][j], @@ -63,7 +63,7 @@ softpipe_map_constant_buffers(struct softpipe_context *sp) } } - for (i = 0; i < PIPE_MAX_CONSTANT; i++) { + for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++) { if (sp->constants[PIPE_SHADER_VERTEX][i]) { draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_VERTEX, @@ -93,7 +93,7 @@ softpipe_unmap_constant_buffers(struct softpipe_context *sp) */ draw_flush(sp->draw); - for (i = 0; i < PIPE_MAX_CONSTANT; i++) { + for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++) { draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_VERTEX, i, @@ -109,7 +109,7 @@ softpipe_unmap_constant_buffers(struct softpipe_context *sp) for (i = 0; i < PIPE_SHADER_TYPES; i++) { uint j; - for (j = 0; j < PIPE_MAX_CONSTANT; j++) { + for (j = 0; j < PIPE_MAX_CONSTANT_BUFFERS; j++) { if (sp->constants[i][j] && sp->constants[i][j]->size) { ws->buffer_unmap(ws, sp->constants[i][j]); } diff --git a/src/gallium/drivers/softpipe/sp_quad_fs.c b/src/gallium/drivers/softpipe/sp_quad_fs.c index 9c497073c2..ad04dc2afc 100644 --- a/src/gallium/drivers/softpipe/sp_quad_fs.c +++ b/src/gallium/drivers/softpipe/sp_quad_fs.c @@ -109,7 +109,7 @@ shade_quads(struct quad_stage *qs, struct tgsi_exec_machine *machine = qss->machine; unsigned i, pass = 0; - for (i = 0; i < PIPE_MAX_CONSTANT; i++) { + for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++) { machine->Consts[i] = softpipe->mapped_constants[PIPE_SHADER_FRAGMENT][i]; } machine->InterpCoefs = quads[0]->coef; diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c index 50ed51661a..04bdcaacc2 100644 --- a/src/gallium/drivers/softpipe/sp_state_fs.c +++ b/src/gallium/drivers/softpipe/sp_state_fs.c @@ -164,7 +164,7 @@ softpipe_set_constant_buffer(struct pipe_context *pipe, struct softpipe_context *softpipe = softpipe_context(pipe); assert(shader < PIPE_SHADER_TYPES); - assert(index < PIPE_MAX_CONSTANT); + assert(index < PIPE_MAX_CONSTANT_BUFFERS); draw_flush(softpipe->draw); diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index fdd29ed449..b250ed9440 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -58,7 +58,7 @@ extern "C" { #define PIPE_MAX_ATTRIBS 32 #define PIPE_MAX_CLIP_PLANES 6 #define PIPE_MAX_COLOR_BUFS 8 -#define PIPE_MAX_CONSTANT 32 +#define PIPE_MAX_CONSTANT_BUFFERS 32 #define PIPE_MAX_SAMPLERS 16 #define PIPE_MAX_VERTEX_SAMPLERS 16 #define PIPE_MAX_SHADER_INPUTS 16 -- cgit v1.2.3 From 25123e0c8820d641a36e0717bddc934718bc05ee Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 25 Jan 2010 13:35:35 +0100 Subject: gallium: Add CAPs for constant buffers. --- src/gallium/include/pipe/p_defines.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 35f3830ebc..353d79a6a7 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -405,6 +405,8 @@ enum pipe_transfer_usage { #define PIPE_CAP_MAX_PREDICATE_REGISTERS 30 #define PIPE_CAP_MAX_COMBINED_SAMPLERS 31 /*< Maximum texture image units accessible from vertex and fragment shaders combined */ +#define PIPE_CAP_MAX_CONST_BUFFERS 32 +#define PIPE_CAP_MAX_CONST_BUFFER_SIZE 33 /*< In bytes */ /** -- cgit v1.2.3 From 3320acb67dfa9330a80ab38e0c164f5d9c0a074a Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 25 Jan 2010 14:31:32 +0100 Subject: softpipe: Report some sane values for constant buffer CAP queries. --- src/gallium/drivers/softpipe/sp_screen.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index bd3532de4f..69f40dc7b6 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -91,6 +91,10 @@ softpipe_get_param(struct pipe_screen *screen, int param) return 1; case PIPE_CAP_BLEND_EQUATION_SEPARATE: return 1; + case PIPE_CAP_MAX_CONST_BUFFERS: + return PIPE_MAX_CONSTANT_BUFFERS; + case PIPE_CAP_MAX_CONST_BUFFER_SIZE: + return 4096 * 4 * sizeof(float); default: return 0; } -- cgit v1.2.3 From 6522804cb3f38bd844a249030c9ee014b329124f Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 25 Jan 2010 14:55:24 +0100 Subject: docs: Implement constant buffer CAPs. --- src/gallium/docs/source/screen.rst | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index 1fff20f539..905ff24db9 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -78,7 +78,29 @@ Returns the screen vendor. get_param ^^^^^^^^^ -Get an integer/boolean screen parameter. +Get an integer/boolean screen parameter. Valid parameter names include. + +* ``PIPE_CAP_MAX_CONST_BUFFERS``: Maximum number of constant buffers that + can be bound to any shader stage using ``set_constant_buffer``. + + If 0 is returned, the driver is not aware of multiple constant buffers, + supports binding of only one constant buffer, and does not support + two-dimensional CONST register file access in TGSI shaders. + + If a value greater than 0 is returned, the driver can have multiple + constant buffers bound to shader stages. The CONST register file can + be accessed with two-dimensional indices, like in the example below. + + DCL CONST[0][0..7] # declare first 8 vectors of constbuf 0 + DCL CONST[3][0] # declare first vector of constbuf 3 + MOV OUT[0], CONST[0][3] # copy vector 3 of constbuf 0 + + For backwards compatibility, one-dimensional access to CONST register + file is still supported. In that case, the constbuf index is assumed + to be 0. + +* ``PIPE_CAP_MAX_CONST_BUFFER_SIZE``: Maximum byte size of a single constant + buffer. get_paramf ^^^^^^^^^^ -- cgit v1.2.3 From 3ba2ab3a23099f00366bdbec09f18612bfa71225 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 27 Jan 2010 15:24:50 +0100 Subject: tgsi: Add ureg_property_gs_output_prim/max_vertices(). --- src/gallium/auxiliary/tgsi/tgsi_ureg.c | 38 ++++++++++++++++++++++++++++++++-- src/gallium/auxiliary/tgsi/tgsi_ureg.h | 10 ++++++++- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index df0173928c..d207097984 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -139,6 +139,8 @@ struct ureg_program struct const_decl const_decls[PIPE_MAX_CONSTANT_BUFFERS]; unsigned property_gs_input_prim; + unsigned property_gs_output_prim; + unsigned property_gs_max_vertices; unsigned nr_addrs; unsigned nr_preds; @@ -243,9 +245,23 @@ ureg_dst_register( unsigned file, void ureg_property_gs_input_prim(struct ureg_program *ureg, - unsigned gs_input_prim) + unsigned input_prim) { - ureg->property_gs_input_prim = gs_input_prim; + ureg->property_gs_input_prim = input_prim; +} + +void +ureg_property_gs_output_prim(struct ureg_program *ureg, + unsigned output_prim) +{ + ureg->property_gs_output_prim = output_prim; +} + +void +ureg_property_gs_max_vertices(struct ureg_program *ureg, + unsigned max_vertices) +{ + ureg->property_gs_max_vertices = max_vertices; } @@ -1161,6 +1177,22 @@ static void emit_decls( struct ureg_program *ureg ) ureg->property_gs_input_prim); } + if (ureg->property_gs_output_prim != ~0) { + assert(ureg->processor == TGSI_PROCESSOR_GEOMETRY); + + emit_property(ureg, + TGSI_PROPERTY_GS_OUTPUT_PRIM, + ureg->property_gs_output_prim); + } + + if (ureg->property_gs_max_vertices != ~0) { + assert(ureg->processor == TGSI_PROCESSOR_GEOMETRY); + + emit_property(ureg, + TGSI_PROPERTY_GS_MAX_VERTICES, + ureg->property_gs_max_vertices); + } + if (ureg->processor == TGSI_PROCESSOR_VERTEX) { for (i = 0; i < UREG_MAX_INPUT; i++) { if (ureg->vs_inputs[i/32] & (1 << (i%32))) { @@ -1378,6 +1410,8 @@ struct ureg_program *ureg_create( unsigned processor ) ureg->processor = processor; ureg->property_gs_input_prim = ~0; + ureg->property_gs_output_prim = ~0; + ureg->property_gs_max_vertices = ~0; return ureg; } diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h index c0dc722673..2ac00deca1 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h @@ -126,7 +126,15 @@ ureg_create_shader_and_destroy( struct ureg_program *p, void ureg_property_gs_input_prim(struct ureg_program *ureg, - unsigned gs_input_prim); + unsigned input_prim); + +void +ureg_property_gs_output_prim(struct ureg_program *ureg, + unsigned output_prim); + +void +ureg_property_gs_max_vertices(struct ureg_program *ureg, + unsigned max_vertices); /*********************************************************************** -- cgit v1.2.3 From 9e895831bcb35b0a14f68538376b15ae4e94ae0d Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 27 Jan 2010 20:43:42 +0100 Subject: tgsi: Constants declared with ureg_DECL_constant() are one-dimensional. This is to maintain backward compatibility with drivers that don't support arrays of constant buffers. --- src/gallium/auxiliary/tgsi/tgsi_ureg.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index d207097984..f2610d0764 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -136,7 +136,8 @@ struct ureg_program unsigned temps_active[UREG_MAX_TEMP / 32]; unsigned nr_temps; - struct const_decl const_decls[PIPE_MAX_CONSTANT_BUFFERS]; + struct const_decl const_decls; + struct const_decl const_decls2D[PIPE_MAX_CONSTANT_BUFFERS]; unsigned property_gs_input_prim; unsigned property_gs_output_prim; @@ -371,6 +372,9 @@ out: /* Returns a new constant register. Keep track of which have been * referred to so that we can emit decls later. * + * Constant operands declared with this function must be addressed + * with a two-dimensional index. + * * There is nothing in this code to bind this constant to any tracked * value or manage any constant_buffer contents -- that's the * resposibility of the calling code. @@ -381,7 +385,7 @@ ureg_DECL_constant2D(struct ureg_program *ureg, unsigned last, unsigned index2D) { - struct const_decl *decl = &ureg->const_decls[index2D]; + struct const_decl *decl = &ureg->const_decls2D[index2D]; assert(index2D < PIPE_MAX_CONSTANT_BUFFERS); @@ -394,11 +398,16 @@ ureg_DECL_constant2D(struct ureg_program *ureg, } +/* A one-dimensional, depricated version of ureg_DECL_constant2D(). + * + * Constant operands declared with this function must be addressed + * with a one-dimensional index. + */ struct ureg_src ureg_DECL_constant(struct ureg_program *ureg, unsigned index) { - struct const_decl *decl = &ureg->const_decls[0]; + struct const_decl *decl = &ureg->const_decls; unsigned minconst = index, maxconst = index; unsigned i; @@ -1241,8 +1250,17 @@ static void emit_decls( struct ureg_program *ureg ) ureg->sampler[i].Index, 1 ); } + if (ureg->const_decls.nr_constant_ranges) { + for (i = 0; i < ureg->const_decls.nr_constant_ranges; i++) { + emit_decl_range(ureg, + TGSI_FILE_CONSTANT, + ureg->const_decls.constant_range[i].first, + ureg->const_decls.constant_range[i].last - ureg->const_decls.constant_range[i].first + 1); + } + } + for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++) { - struct const_decl *decl = &ureg->const_decls[i]; + struct const_decl *decl = &ureg->const_decls2D[i]; if (decl->nr_constant_ranges) { uint j; -- cgit v1.2.3 From bd60e6cd5ce7c19e52338f12f73dfa1b622391d5 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Thu, 28 Jan 2010 15:34:10 +0000 Subject: add PIPE_SUBSYSTEM_EMBEDDED when embedded platform used --- scons/gallium.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scons/gallium.py b/scons/gallium.py index 467b67fad7..03856207ed 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -229,6 +229,8 @@ def generate(env): if platform == 'wince': cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE'] cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE_OGL'] + if platform == 'embedded': + cppdefines += ['PIPE_SUBSYSTEM_EMBEDDED'] env.Append(CPPDEFINES = cppdefines) # C compiler options -- cgit v1.2.3 From 2fa34bf44c7cd7ba03ce8a7e82fe56898a57e9b4 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 28 Jan 2010 17:11:49 +0100 Subject: gallium: remove PIPE_CAP_S3TC, and add PIPE_CAP_DUAL_SOURCE_BLEND there's no point in keeping deprecated PIPE_CAPS around since there's no stable interface (yet). Reuse the enum for PIPE_CAP_DUAL_SOURCE_BLEND. Drivers advertizing this will accept the pipe blendfactors with SRC1 in them and be able to do dual source blending (src color from pixel shader output 0, and blendfactor with SRC1 will come from output 1, only one render target may be bound when using any of these blend factors). --- src/gallium/include/pipe/p_defines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 185ab6a711..41a4f20901 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -377,7 +377,7 @@ enum pipe_transfer_usage { #define PIPE_CAP_NPOT_TEXTURES 2 #define PIPE_CAP_TWO_SIDED_STENCIL 3 #define PIPE_CAP_GLSL 4 /* XXX need something better */ -#define PIPE_CAP_S3TC 5 /* XXX: deprecated; cap determined via supported sampler formats */ +#define PIPE_CAP_DUAL_SOURCE_BLEND 5 #define PIPE_CAP_ANISOTROPIC_FILTER 6 #define PIPE_CAP_POINT_SPRITE 7 #define PIPE_CAP_MAX_RENDER_TARGETS 8 -- cgit v1.2.3 From 75cd6f3ece181b231dcf287bcb928f24f0d10962 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Thu, 28 Jan 2010 17:22:35 +0000 Subject: Don't define HAVE_POSIX_MEMALIGN for embedded target. --- SConstruct | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index 3b8a9e0341..9f1e8a72ae 100644 --- a/SConstruct +++ b/SConstruct @@ -126,8 +126,9 @@ if platform in ('posix', 'linux', 'freebsd', 'darwin', 'embedded'): '_GNU_SOURCE', 'PTHREADS', - 'HAVE_POSIX_MEMALIGN', ]) + if platform != 'embedded': + env.Append(CPPDEFINES = ['HAVE_POSIX_MEMALIGN']) if platform == 'darwin': env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE']) env.Append(CPPPATH = ['/usr/X11R6/include']) -- cgit v1.2.3 From 32e6043150077662323c66ff05334c8d8952fc04 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Thu, 28 Jan 2010 17:26:05 +0000 Subject: define own embedded target and cleanup previous commit. --- SConstruct | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/SConstruct b/SConstruct index 9f1e8a72ae..1c7550d783 100644 --- a/SConstruct +++ b/SConstruct @@ -115,9 +115,25 @@ env.Append(CPPPATH = [ if env['msvc']: env.Append(CPPPATH = ['#include/c99']) +# Embedded +if platform == 'embedded': + env.Append(CPPDEFINES = [ + '_POSIX_SOURCE', + ('_POSIX_C_SOURCE', '199309L'), + '_SVID_SOURCE', + '_BSD_SOURCE', + '_GNU_SOURCE', + + 'PTHREADS', + ]) + env.Append(LIBS = [ + 'm', + 'pthread', + 'dl', + ]) # Posix -if platform in ('posix', 'linux', 'freebsd', 'darwin', 'embedded'): +if platform in ('posix', 'linux', 'freebsd', 'darwin'): env.Append(CPPDEFINES = [ '_POSIX_SOURCE', ('_POSIX_C_SOURCE', '199309L'), @@ -126,9 +142,8 @@ if platform in ('posix', 'linux', 'freebsd', 'darwin', 'embedded'): '_GNU_SOURCE', 'PTHREADS', + 'HAVE_POSIX_MEMALIGN', ]) - if platform != 'embedded': - env.Append(CPPDEFINES = ['HAVE_POSIX_MEMALIGN']) if platform == 'darwin': env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE']) env.Append(CPPPATH = ['/usr/X11R6/include']) @@ -136,14 +151,9 @@ if platform in ('posix', 'linux', 'freebsd', 'darwin', 'embedded'): env.Append(LIBS = [ 'm', 'pthread', + 'expat', 'dl', ]) - if platform != 'embedded': - env.Append(LIBS = [ - 'expat', - ]) - - # DRI if dri: -- cgit v1.2.3 From c75e238434f64657e96f09e0215f02cefa6ad6d6 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 28 Jan 2010 17:59:26 +0100 Subject: st/xorg: Update to new libkms interface but be backwards compatible --- src/gallium/state_trackers/xorg/xorg_crtc.c | 4 ++++ src/gallium/state_trackers/xorg/xorg_driver.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c index 2786558b76..2395d54975 100644 --- a/src/gallium/state_trackers/xorg/xorg_crtc.c +++ b/src/gallium/state_trackers/xorg/xorg_crtc.c @@ -242,7 +242,11 @@ crtc_load_cursor_argb_kms(xf86CrtcPtr crtc, CARD32 * image) unsigned attr[8]; attr[0] = KMS_BO_TYPE; +#ifdef KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8 + attr[1] = KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8; +#else attr[1] = KMS_BO_TYPE_CURSOR; +#endif attr[2] = KMS_WIDTH; attr[3] = 64; attr[4] = KMS_HEIGHT; diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index e4ad789e9b..f53a879a14 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -1008,7 +1008,11 @@ drv_create_front_buffer_kms(ScrnInfoPtr pScrn) int ret; attr[0] = KMS_BO_TYPE; +#ifdef KMS_BO_TYPE_SCANOUT_X8R8G8B8 + attr[1] = KMS_BO_TYPE_SCANOUT_X8R8G8B8; +#else attr[1] = KMS_BO_TYPE_SCANOUT; +#endif attr[2] = KMS_WIDTH; attr[3] = pScrn->virtualX; attr[4] = KMS_HEIGHT; -- cgit v1.2.3 From f9439e4a4696b8bc5fcdf3ac664f5e8d446f6621 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 27 Jan 2010 21:22:00 -0800 Subject: intel: Remove long-disabled meta readpixels, and associated meta support. --- src/mesa/drivers/dri/i915/Makefile | 2 - src/mesa/drivers/dri/i915/i830_context.c | 1 - src/mesa/drivers/dri/i915/i830_context.h | 6 +- src/mesa/drivers/dri/i915/i830_metaops.c | 456 ----------------------- src/mesa/drivers/dri/i915/i830_vtbl.c | 39 +- src/mesa/drivers/dri/i915/i915_context.c | 1 - src/mesa/drivers/dri/i915/i915_context.h | 8 +- src/mesa/drivers/dri/i915/i915_metaops.c | 507 -------------------------- src/mesa/drivers/dri/i915/i915_vtbl.c | 42 +-- src/mesa/drivers/dri/intel/intel_context.h | 34 -- src/mesa/drivers/dri/intel/intel_pixel_read.c | 102 ------ 11 files changed, 20 insertions(+), 1178 deletions(-) delete mode 100644 src/mesa/drivers/dri/i915/i830_metaops.c delete mode 100644 src/mesa/drivers/dri/i915/i915_metaops.c diff --git a/src/mesa/drivers/dri/i915/Makefile b/src/mesa/drivers/dri/i915/Makefile index cf32476f40..dc15ae425c 100644 --- a/src/mesa/drivers/dri/i915/Makefile +++ b/src/mesa/drivers/dri/i915/Makefile @@ -8,7 +8,6 @@ MINIGLX_SOURCES = server/intel_dri.c DRIVER_SOURCES = \ i830_context.c \ - i830_metaops.c \ i830_state.c \ i830_texblend.c \ i830_texstate.c \ @@ -40,7 +39,6 @@ DRIVER_SOURCES = \ i915_debug.c \ i915_debug_fp.c \ i915_fragprog.c \ - i915_metaops.c \ i915_program.c \ i915_state.c \ i915_vtbl.c \ diff --git a/src/mesa/drivers/dri/i915/i830_context.c b/src/mesa/drivers/dri/i915/i830_context.c index 947330b2f1..ebe8b15ca7 100644 --- a/src/mesa/drivers/dri/i915/i830_context.c +++ b/src/mesa/drivers/dri/i915/i830_context.c @@ -105,7 +105,6 @@ i830CreateContext(const __GLcontextModes * mesaVis, intel->verts = TNL_CONTEXT(ctx)->clipspace.vertex_buf; i830InitState(i830); - i830InitMetaFuncs(i830); _tnl_allow_vertex_fog(ctx, 1); _tnl_allow_pixel_fog(ctx, 0); diff --git a/src/mesa/drivers/dri/i915/i830_context.h b/src/mesa/drivers/dri/i915/i830_context.h index 592ae53976..b1e3ec4500 100644 --- a/src/mesa/drivers/dri/i915/i830_context.h +++ b/src/mesa/drivers/dri/i915/i830_context.h @@ -144,7 +144,7 @@ struct i830_context GLuint lodbias_tm0s3[MAX_TEXTURE_UNITS]; DECLARE_RENDERINPUTS(last_index_bitset); - struct i830_hw_state meta, initial, state, *current; + struct i830_hw_state initial, state, *current; }; @@ -206,10 +206,6 @@ extern void i830EmitState(struct i830_context *i830); extern void i830InitState(struct i830_context *i830); extern void i830_update_provoking_vertex(GLcontext *ctx); -/* i830_metaops.c - */ -extern void i830InitMetaFuncs(struct i830_context *i830); - /*====================================================================== * Inline conversion functions. These are better-typed than the * macros used previously: diff --git a/src/mesa/drivers/dri/i915/i830_metaops.c b/src/mesa/drivers/dri/i915/i830_metaops.c deleted file mode 100644 index 2cce661c86..0000000000 --- a/src/mesa/drivers/dri/i915/i830_metaops.c +++ /dev/null @@ -1,456 +0,0 @@ -/************************************************************************** - * - * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * 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, sub license, 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. - * - **************************************************************************/ - -#include "main/glheader.h" -#include "main/enums.h" -#include "main/mtypes.h" -#include "main/macros.h" -#include "utils.h" - -#include "intel_screen.h" -#include "intel_batchbuffer.h" -#include "intel_regions.h" - -#include "i830_context.h" -#include "i830_reg.h" - -/* A large amount of state doesn't need to be uploaded. - */ -#define ACTIVE (I830_UPLOAD_INVARIENT | \ - I830_UPLOAD_CTX | \ - I830_UPLOAD_BUFFERS | \ - I830_UPLOAD_STIPPLE | \ - I830_UPLOAD_TEXBLEND(0) | \ - I830_UPLOAD_TEX(0)) - - -#define SET_STATE( i830, STATE ) \ -do { \ - i830->current->emitted &= ~ACTIVE; \ - i830->current = &i830->STATE; \ - i830->current->emitted &= ~ACTIVE; \ -} while (0) - - -static void -set_no_stencil_write(struct intel_context *intel) -{ - struct i830_context *i830 = i830_context(&intel->ctx); - - /* ctx->Driver.Enable( ctx, GL_STENCIL_TEST, GL_FALSE ) - */ - i830->meta.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_STENCIL_TEST; - i830->meta.Ctx[I830_CTXREG_ENABLES_2] &= ~ENABLE_STENCIL_WRITE; - i830->meta.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_STENCIL_TEST; - i830->meta.Ctx[I830_CTXREG_ENABLES_2] |= DISABLE_STENCIL_WRITE; - - i830->meta.emitted &= ~I830_UPLOAD_CTX; -} - -static void -set_no_depth_write(struct intel_context *intel) -{ - struct i830_context *i830 = i830_context(&intel->ctx); - - /* ctx->Driver.Enable( ctx, GL_DEPTH_TEST, GL_FALSE ) - */ - i830->meta.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_DIS_DEPTH_TEST_MASK; - i830->meta.Ctx[I830_CTXREG_ENABLES_2] &= ~ENABLE_DIS_DEPTH_WRITE_MASK; - i830->meta.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_DEPTH_TEST; - i830->meta.Ctx[I830_CTXREG_ENABLES_2] |= DISABLE_DEPTH_WRITE; - - i830->meta.emitted &= ~I830_UPLOAD_CTX; -} - -/* Set depth unit to replace. - */ -static void -set_depth_replace(struct intel_context *intel) -{ - struct i830_context *i830 = i830_context(&intel->ctx); - - /* ctx->Driver.Enable( ctx, GL_DEPTH_TEST, GL_FALSE ) - * ctx->Driver.DepthMask( ctx, GL_TRUE ) - */ - i830->meta.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_DIS_DEPTH_TEST_MASK; - i830->meta.Ctx[I830_CTXREG_ENABLES_2] &= ~ENABLE_DIS_DEPTH_WRITE_MASK; - i830->meta.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_DEPTH_TEST; - i830->meta.Ctx[I830_CTXREG_ENABLES_2] |= ENABLE_DEPTH_WRITE; - - /* ctx->Driver.DepthFunc( ctx, GL_ALWAYS ) - */ - i830->meta.Ctx[I830_CTXREG_STATE3] &= ~DEPTH_TEST_FUNC_MASK; - i830->meta.Ctx[I830_CTXREG_STATE3] |= (ENABLE_DEPTH_TEST_FUNC | - DEPTH_TEST_FUNC - (COMPAREFUNC_ALWAYS)); - - i830->meta.emitted &= ~I830_UPLOAD_CTX; -} - - -/* Set stencil unit to replace always with the reference value. - */ -static void -set_stencil_replace(struct intel_context *intel, - GLuint s_mask, GLuint s_clear) -{ - struct i830_context *i830 = i830_context(&intel->ctx); - - /* ctx->Driver.Enable( ctx, GL_STENCIL_TEST, GL_TRUE ) - */ - i830->meta.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_STENCIL_TEST; - i830->meta.Ctx[I830_CTXREG_ENABLES_2] |= ENABLE_STENCIL_WRITE; - - /* ctx->Driver.StencilMask( ctx, s_mask ) - */ - i830->meta.Ctx[I830_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_WRITE_MASK; - i830->meta.Ctx[I830_CTXREG_STATE4] |= (ENABLE_STENCIL_WRITE_MASK | - STENCIL_WRITE_MASK((s_mask & - 0xff))); - - /* ctx->Driver.StencilOp( ctx, GL_REPLACE, GL_REPLACE, GL_REPLACE ) - */ - i830->meta.Ctx[I830_CTXREG_STENCILTST] &= ~(STENCIL_OPS_MASK); - i830->meta.Ctx[I830_CTXREG_STENCILTST] |= - (ENABLE_STENCIL_PARMS | - STENCIL_FAIL_OP(STENCILOP_REPLACE) | - STENCIL_PASS_DEPTH_FAIL_OP(STENCILOP_REPLACE) | - STENCIL_PASS_DEPTH_PASS_OP(STENCILOP_REPLACE)); - - /* ctx->Driver.StencilFunc( ctx, GL_ALWAYS, s_clear, ~0 ) - */ - i830->meta.Ctx[I830_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_TEST_MASK; - i830->meta.Ctx[I830_CTXREG_STATE4] |= (ENABLE_STENCIL_TEST_MASK | - STENCIL_TEST_MASK(0xff)); - - i830->meta.Ctx[I830_CTXREG_STENCILTST] &= ~(STENCIL_REF_VALUE_MASK | - ENABLE_STENCIL_TEST_FUNC_MASK); - i830->meta.Ctx[I830_CTXREG_STENCILTST] |= - (ENABLE_STENCIL_REF_VALUE | - ENABLE_STENCIL_TEST_FUNC | - STENCIL_REF_VALUE((s_clear & 0xff)) | - STENCIL_TEST_FUNC(COMPAREFUNC_ALWAYS)); - - - - i830->meta.emitted &= ~I830_UPLOAD_CTX; -} - - -static void -set_color_mask(struct intel_context *intel, GLboolean state) -{ - struct i830_context *i830 = i830_context(&intel->ctx); - - const GLuint mask = ((1 << WRITEMASK_RED_SHIFT) | - (1 << WRITEMASK_GREEN_SHIFT) | - (1 << WRITEMASK_BLUE_SHIFT) | - (1 << WRITEMASK_ALPHA_SHIFT)); - - i830->meta.Ctx[I830_CTXREG_ENABLES_2] &= ~mask; - - if (state) { - i830->meta.Ctx[I830_CTXREG_ENABLES_2] |= - (i830->state.Ctx[I830_CTXREG_ENABLES_2] & mask); - } - - i830->meta.emitted &= ~I830_UPLOAD_CTX; -} - -/* Installs a one-stage passthrough texture blend pipeline. Is there - * more that can be done to turn off texturing? - */ -static void -set_no_texture(struct intel_context *intel) -{ - struct i830_context *i830 = i830_context(&intel->ctx); - static const struct gl_tex_env_combine_state comb = { - GL_NONE, GL_NONE, - {GL_TEXTURE, 0, 0,}, {GL_TEXTURE, 0, 0,}, - {GL_SRC_COLOR, 0, 0}, {GL_SRC_ALPHA, 0, 0}, - 0, 0, 0, 0 - }; - - i830->meta.TexBlendWordsUsed[0] = - i830SetTexEnvCombine(i830, &comb, 0, TEXBLENDARG_TEXEL0, - i830->meta.TexBlend[0], NULL); - - i830->meta.TexBlend[0][0] |= TEXOP_LAST_STAGE; - i830->meta.emitted &= ~I830_UPLOAD_TEXBLEND(0); -} - -/* Set up a single element blend stage for 'replace' texturing with no - * funny ops. - */ -static void -set_texture_blend_replace(struct intel_context *intel) -{ - struct i830_context *i830 = i830_context(&intel->ctx); - static const struct gl_tex_env_combine_state comb = { - GL_REPLACE, GL_REPLACE, - {GL_TEXTURE, GL_TEXTURE, GL_TEXTURE,}, {GL_TEXTURE, GL_TEXTURE, - GL_TEXTURE,}, - {GL_SRC_COLOR, GL_SRC_COLOR, GL_SRC_COLOR}, {GL_SRC_ALPHA, GL_SRC_ALPHA, - GL_SRC_ALPHA}, - 0, 0, 1, 1 - }; - - i830->meta.TexBlendWordsUsed[0] = - i830SetTexEnvCombine(i830, &comb, 0, TEXBLENDARG_TEXEL0, - i830->meta.TexBlend[0], NULL); - - i830->meta.TexBlend[0][0] |= TEXOP_LAST_STAGE; - i830->meta.emitted &= ~I830_UPLOAD_TEXBLEND(0); - -/* fprintf(stderr, "%s: TexBlendWordsUsed[0]: %d\n", */ -/* __FUNCTION__, i830->meta.TexBlendWordsUsed[0]); */ -} - - - -/* Set up an arbitary piece of memory as a rectangular texture - * (including the front or back buffer). - */ -static GLboolean -set_tex_rect_source(struct intel_context *intel, - dri_bo *buffer, - GLuint offset, - GLuint pitch, GLuint height, GLenum format, GLenum type) -{ - struct i830_context *i830 = i830_context(&intel->ctx); - GLuint *setup = i830->meta.Tex[0]; - GLint numLevels = 1; - GLuint textureFormat; - GLuint cpp; - - /* A full implementation of this would do the upload through - * glTexImage2d, and get all the conversion operations at that - * point. We are restricted, but still at least have access to the - * fragment program swizzle. - */ - switch (format) { - case GL_BGRA: - switch (type) { - case GL_UNSIGNED_INT_8_8_8_8_REV: - case GL_UNSIGNED_BYTE: - textureFormat = (MAPSURF_32BIT | MT_32BIT_ARGB8888); - cpp = 4; - break; - default: - return GL_FALSE; - } - break; - case GL_RGBA: - switch (type) { - case GL_UNSIGNED_INT_8_8_8_8_REV: - case GL_UNSIGNED_BYTE: - textureFormat = (MAPSURF_32BIT | MT_32BIT_ABGR8888); - cpp = 4; - break; - default: - return GL_FALSE; - } - break; - case GL_BGR: - switch (type) { - case GL_UNSIGNED_SHORT_5_6_5_REV: - textureFormat = (MAPSURF_16BIT | MT_16BIT_RGB565); - cpp = 2; - break; - default: - return GL_FALSE; - } - break; - case GL_RGB: - switch (type) { - case GL_UNSIGNED_SHORT_5_6_5: - textureFormat = (MAPSURF_16BIT | MT_16BIT_RGB565); - cpp = 2; - break; - default: - return GL_FALSE; - } - break; - - default: - return GL_FALSE; - } - - i830->meta.tex_buffer[0] = buffer; - i830->meta.tex_offset[0] = offset; - - setup[I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 | - (LOAD_TEXTURE_MAP0 << 0) | 4); - setup[I830_TEXREG_TM0S1] = (((height - 1) << TM0S1_HEIGHT_SHIFT) | - ((pitch - 1) << TM0S1_WIDTH_SHIFT) | - textureFormat); - setup[I830_TEXREG_TM0S2] = - (((((pitch * cpp) / 4) - - 1) << TM0S2_PITCH_SHIFT) | TM0S2_CUBE_FACE_ENA_MASK); - - setup[I830_TEXREG_TM0S3] = - ((((numLevels - - 1) * - 4) << TM0S3_MIN_MIP_SHIFT) | (FILTER_NEAREST << - TM0S3_MIN_FILTER_SHIFT) | - (MIPFILTER_NONE << TM0S3_MIP_FILTER_SHIFT) | (FILTER_NEAREST << - TM0S3_MAG_FILTER_SHIFT)); - - setup[I830_TEXREG_CUBE] = (_3DSTATE_MAP_CUBE | MAP_UNIT(0)); - - setup[I830_TEXREG_MCS] = (_3DSTATE_MAP_COORD_SET_CMD | - MAP_UNIT(0) | - ENABLE_TEXCOORD_PARAMS | - TEXCOORDS_ARE_IN_TEXELUNITS | - TEXCOORDTYPE_CARTESIAN | - ENABLE_ADDR_V_CNTL | - TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_WRAP) | - ENABLE_ADDR_U_CNTL | - TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_WRAP)); - - i830->meta.emitted &= ~I830_UPLOAD_TEX(0); - return GL_TRUE; -} - - -static void -set_vertex_format(struct intel_context *intel) -{ - struct i830_context *i830 = i830_context(&intel->ctx); - i830->meta.Ctx[I830_CTXREG_VF] = (_3DSTATE_VFT0_CMD | - VFT0_TEX_COUNT(1) | - VFT0_DIFFUSE | VFT0_XYZ); - i830->meta.Ctx[I830_CTXREG_VF2] = (_3DSTATE_VFT1_CMD | - VFT1_TEX0_FMT(TEXCOORDFMT_2D) | - VFT1_TEX1_FMT(TEXCOORDFMT_2D) | - VFT1_TEX2_FMT(TEXCOORDFMT_2D) | - VFT1_TEX3_FMT(TEXCOORDFMT_2D)); - i830->meta.emitted &= ~I830_UPLOAD_CTX; -} - - -static void -meta_import_pixel_state(struct intel_context *intel) -{ - struct i830_context *i830 = i830_context(&intel->ctx); - - i830->meta.Ctx[I830_CTXREG_STATE1] = i830->state.Ctx[I830_CTXREG_STATE1]; - i830->meta.Ctx[I830_CTXREG_STATE2] = i830->state.Ctx[I830_CTXREG_STATE2]; - i830->meta.Ctx[I830_CTXREG_STATE3] = i830->state.Ctx[I830_CTXREG_STATE3]; - i830->meta.Ctx[I830_CTXREG_STATE4] = i830->state.Ctx[I830_CTXREG_STATE4]; - i830->meta.Ctx[I830_CTXREG_STATE5] = i830->state.Ctx[I830_CTXREG_STATE5]; - i830->meta.Ctx[I830_CTXREG_IALPHAB] = i830->state.Ctx[I830_CTXREG_IALPHAB]; - i830->meta.Ctx[I830_CTXREG_STENCILTST] = - i830->state.Ctx[I830_CTXREG_STENCILTST]; - i830->meta.Ctx[I830_CTXREG_ENABLES_1] = - i830->state.Ctx[I830_CTXREG_ENABLES_1]; - i830->meta.Ctx[I830_CTXREG_ENABLES_2] = - i830->state.Ctx[I830_CTXREG_ENABLES_2]; - i830->meta.Ctx[I830_CTXREG_AA] = i830->state.Ctx[I830_CTXREG_AA]; - i830->meta.Ctx[I830_CTXREG_FOGCOLOR] = - i830->state.Ctx[I830_CTXREG_FOGCOLOR]; - i830->meta.Ctx[I830_CTXREG_BLENDCOLOR0] = - i830->state.Ctx[I830_CTXREG_BLENDCOLOR0]; - i830->meta.Ctx[I830_CTXREG_BLENDCOLOR1] = - i830->state.Ctx[I830_CTXREG_BLENDCOLOR1]; - i830->meta.Ctx[I830_CTXREG_MCSB0] = i830->state.Ctx[I830_CTXREG_MCSB0]; - i830->meta.Ctx[I830_CTXREG_MCSB1] = i830->state.Ctx[I830_CTXREG_MCSB1]; - - - i830->meta.Ctx[I830_CTXREG_STATE3] &= ~CULLMODE_MASK; - i830->meta.Stipple[I830_STPREG_ST1] &= ~ST1_ENABLE; - i830->meta.emitted &= ~I830_UPLOAD_CTX; - - - i830->meta.Buffer[I830_DESTREG_SENABLE] = - i830->state.Buffer[I830_DESTREG_SENABLE]; - i830->meta.Buffer[I830_DESTREG_SR1] = i830->state.Buffer[I830_DESTREG_SR1]; - i830->meta.Buffer[I830_DESTREG_SR2] = i830->state.Buffer[I830_DESTREG_SR2]; - i830->meta.emitted &= ~I830_UPLOAD_BUFFERS; -} - - - -/* Select between front and back draw buffers. - */ -static void -meta_draw_region(struct intel_context *intel, - struct intel_region *color_region, - struct intel_region *depth_region) -{ - struct i830_context *i830 = i830_context(&intel->ctx); - - i830_state_draw_region(intel, &i830->meta, color_region, depth_region); -} - - -/* Operations where the 3D engine is decoupled temporarily from the - * current GL state and used for other purposes than simply rendering - * incoming triangles. - */ -static void -install_meta_state(struct intel_context *intel) -{ - struct i830_context *i830 = i830_context(&intel->ctx); - memcpy(&i830->meta, &i830->initial, sizeof(i830->meta)); - - i830->meta.active = ACTIVE; - i830->meta.emitted = 0; - - SET_STATE(i830, meta); - set_vertex_format(intel); - set_no_texture(intel); -} - -static void -leave_meta_state(struct intel_context *intel) -{ - struct i830_context *i830 = i830_context(&intel->ctx); - intel_region_release(&i830->meta.draw_region); - intel_region_release(&i830->meta.depth_region); -/* intel_region_release(intel, &i830->meta.tex_region[0]); */ - SET_STATE(i830, state); -} - - - -void -i830InitMetaFuncs(struct i830_context *i830) -{ - i830->intel.vtbl.install_meta_state = install_meta_state; - i830->intel.vtbl.leave_meta_state = leave_meta_state; - i830->intel.vtbl.meta_no_depth_write = set_no_depth_write; - i830->intel.vtbl.meta_no_stencil_write = set_no_stencil_write; - i830->intel.vtbl.meta_stencil_replace = set_stencil_replace; - i830->intel.vtbl.meta_depth_replace = set_depth_replace; - i830->intel.vtbl.meta_color_mask = set_color_mask; - i830->intel.vtbl.meta_no_texture = set_no_texture; - i830->intel.vtbl.meta_texture_blend_replace = set_texture_blend_replace; - i830->intel.vtbl.meta_tex_rect_source = set_tex_rect_source; - i830->intel.vtbl.meta_draw_region = meta_draw_region; - i830->intel.vtbl.meta_import_pixel_state = meta_import_pixel_state; -} diff --git a/src/mesa/drivers/dri/i915/i830_vtbl.c b/src/mesa/drivers/dri/i915/i830_vtbl.c index 3767712d19..6dd64ef45e 100644 --- a/src/mesa/drivers/dri/i915/i830_vtbl.c +++ b/src/mesa/drivers/dri/i915/i830_vtbl.c @@ -541,10 +541,6 @@ i830_emit_state(struct intel_context *intel) I915_GEM_DOMAIN_SAMPLER, 0, state->tex_offset[i]); } - else if (state == &i830->meta) { - assert(i == 0); - OUT_BATCH(0); - } else { OUT_BATCH(state->tex_offset[i]); } @@ -579,8 +575,6 @@ i830_destroy_context(struct intel_context *intel) intel_region_release(&i830->state.draw_region); intel_region_release(&i830->state.depth_region); - intel_region_release(&i830->meta.draw_region); - intel_region_release(&i830->meta.depth_region); intel_region_release(&i830->initial.draw_region); intel_region_release(&i830->initial.depth_region); @@ -594,24 +588,22 @@ i830_destroy_context(struct intel_context *intel) _tnl_free_vertices(&intel->ctx); } - -void -i830_state_draw_region(struct intel_context *intel, - struct i830_hw_state *state, - struct intel_region *color_region, - struct intel_region *depth_region) +static void +i830_set_draw_region(struct intel_context *intel, + struct intel_region *color_regions[], + struct intel_region *depth_region, + GLuint num_regions) { struct i830_context *i830 = i830_context(&intel->ctx); GLcontext *ctx = &intel->ctx; struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; struct intel_renderbuffer *irb = intel_renderbuffer(rb); GLuint value; + struct i830_hw_state *state = &i830->state; - ASSERT(state == &i830->state || state == &i830->meta); - - if (state->draw_region != color_region) { + if (state->draw_region != color_regions[0]) { intel_region_release(&state->draw_region); - intel_region_reference(&state->draw_region, color_region); + intel_region_reference(&state->draw_region, color_regions[0]); } if (state->depth_region != depth_region) { intel_region_release(&state->depth_region); @@ -622,7 +614,7 @@ i830_state_draw_region(struct intel_context *intel, * Set stride/cpp values */ i915_set_buf_info_for_region(&state->Buffer[I830_DESTREG_CBUFADDR0], - color_region, BUF_3D_ID_COLOR_BACK); + color_regions[0], BUF_3D_ID_COLOR_BACK); i915_set_buf_info_for_region(&state->Buffer[I830_DESTREG_DBUFADDR0], depth_region, BUF_3D_ID_DEPTH); @@ -672,19 +664,6 @@ i830_state_draw_region(struct intel_context *intel, state->Buffer[I830_DESTREG_DRAWRECT5] = 0; I830_STATECHANGE(i830, I830_UPLOAD_BUFFERS); - - -} - - -static void -i830_set_draw_region(struct intel_context *intel, - struct intel_region *color_regions[], - struct intel_region *depth_region, - GLuint num_regions) -{ - struct i830_context *i830 = i830_context(&intel->ctx); - i830_state_draw_region(intel, &i830->state, color_regions[0], depth_region); } /* This isn't really handled at the moment. diff --git a/src/mesa/drivers/dri/i915/i915_context.c b/src/mesa/drivers/dri/i915/i915_context.c index 8477e2f9a4..ed9a44ff24 100644 --- a/src/mesa/drivers/dri/i915/i915_context.c +++ b/src/mesa/drivers/dri/i915/i915_context.c @@ -111,7 +111,6 @@ i915CreateContext(const __GLcontextModes * mesaVis, _mesa_printf("\ntexmem-0-3 branch\n\n"); i915InitVtbl(i915); - i915InitMetaFuncs(i915); i915InitDriverFunctions(&functions); diff --git a/src/mesa/drivers/dri/i915/i915_context.h b/src/mesa/drivers/dri/i915/i915_context.h index f55b551139..7c091f3f92 100644 --- a/src/mesa/drivers/dri/i915/i915_context.h +++ b/src/mesa/drivers/dri/i915/i915_context.h @@ -259,7 +259,7 @@ struct i915_context struct i915_fragment_program *current_program; - struct i915_hw_state meta, initial, state, *current; + struct i915_hw_state initial, state, *current; }; @@ -345,12 +345,6 @@ extern void i915_update_provoking_vertex(GLcontext *ctx); extern void i915UpdateTextureState(struct intel_context *intel); extern void i915InitTextureFuncs(struct dd_function_table *functions); -/*====================================================================== - * i915_metaops.c - */ -void i915InitMetaFuncs(struct i915_context *i915); - - /*====================================================================== * i915_fragprog.c */ diff --git a/src/mesa/drivers/dri/i915/i915_metaops.c b/src/mesa/drivers/dri/i915/i915_metaops.c deleted file mode 100644 index 90a78c6082..0000000000 --- a/src/mesa/drivers/dri/i915/i915_metaops.c +++ /dev/null @@ -1,507 +0,0 @@ -/************************************************************************** - * - * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * 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, sub license, 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 NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. - * - **************************************************************************/ - -#include "main/glheader.h" -#include "main/enums.h" -#include "main/mtypes.h" -#include "main/macros.h" -#include "utils.h" - -#include "intel_screen.h" -#include "intel_batchbuffer.h" -#include "intel_regions.h" - -#include "i915_context.h" -#include "i915_reg.h" - -/* We touch almost everything: - */ -#define ACTIVE (I915_UPLOAD_INVARIENT | \ - I915_UPLOAD_CTX | \ - I915_UPLOAD_BUFFERS | \ - I915_UPLOAD_STIPPLE | \ - I915_UPLOAD_PROGRAM | \ - I915_UPLOAD_FOG | \ - I915_UPLOAD_TEX(0)) - -#define SET_STATE( i915, STATE ) \ -do { \ - i915->current->emitted &= ~ACTIVE; \ - i915->current = &i915->STATE; \ - i915->current->emitted &= ~ACTIVE; \ -} while (0) - - -static void -meta_no_stencil_write(struct intel_context *intel) -{ - struct i915_context *i915 = i915_context(&intel->ctx); - - /* ctx->Driver.Enable( ctx, GL_STENCIL_TEST, GL_FALSE ) - */ - i915->meta.Ctx[I915_CTXREG_LIS5] &= ~(S5_STENCIL_TEST_ENABLE | - S5_STENCIL_WRITE_ENABLE); - - i915->meta.emitted &= ~I915_UPLOAD_CTX; -} - -static void -meta_no_depth_write(struct intel_context *intel) -{ - struct i915_context *i915 = i915_context(&intel->ctx); - - /* ctx->Driver.Enable( ctx, GL_DEPTH_TEST, GL_FALSE ) - */ - i915->meta.Ctx[I915_CTXREG_LIS6] &= ~(S6_DEPTH_TEST_ENABLE | - S6_DEPTH_WRITE_ENABLE); - - i915->meta.emitted &= ~I915_UPLOAD_CTX; -} - -static void -meta_depth_replace(struct intel_context *intel) -{ - struct i915_context *i915 = i915_context(&intel->ctx); - - /* ctx->Driver.Enable( ctx, GL_DEPTH_TEST, GL_TRUE ) - * ctx->Driver.DepthMask( ctx, GL_TRUE ) - */ - i915->meta.Ctx[I915_CTXREG_LIS6] |= (S6_DEPTH_TEST_ENABLE | - S6_DEPTH_WRITE_ENABLE); - - /* ctx->Driver.DepthFunc( ctx, GL_ALWAYS ) - */ - i915->meta.Ctx[I915_CTXREG_LIS6] &= ~S6_DEPTH_TEST_FUNC_MASK; - i915->meta.Ctx[I915_CTXREG_LIS6] |= - COMPAREFUNC_ALWAYS << S6_DEPTH_TEST_FUNC_SHIFT; - - i915->meta.emitted &= ~I915_UPLOAD_CTX; -} - - -/* Set stencil unit to replace always with the reference value. - */ -static void -meta_stencil_replace(struct intel_context *intel, - GLuint s_mask, GLuint s_clear) -{ - struct i915_context *i915 = i915_context(&intel->ctx); - GLuint op = STENCILOP_REPLACE; - GLuint func = COMPAREFUNC_ALWAYS; - - /* ctx->Driver.Enable( ctx, GL_STENCIL_TEST, GL_TRUE ) - */ - i915->meta.Ctx[I915_CTXREG_LIS5] |= (S5_STENCIL_TEST_ENABLE | - S5_STENCIL_WRITE_ENABLE); - - /* ctx->Driver.StencilMask( ctx, s_mask ) - */ - i915->meta.Ctx[I915_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_WRITE_MASK; - - i915->meta.Ctx[I915_CTXREG_STATE4] |= (ENABLE_STENCIL_WRITE_MASK | - STENCIL_WRITE_MASK(s_mask)); - - /* ctx->Driver.StencilOp( ctx, GL_REPLACE, GL_REPLACE, GL_REPLACE ) - */ - i915->meta.Ctx[I915_CTXREG_LIS5] &= ~(S5_STENCIL_FAIL_MASK | - S5_STENCIL_PASS_Z_FAIL_MASK | - S5_STENCIL_PASS_Z_PASS_MASK); - - i915->meta.Ctx[I915_CTXREG_LIS5] |= ((op << S5_STENCIL_FAIL_SHIFT) | - (op << S5_STENCIL_PASS_Z_FAIL_SHIFT) | - (op << S5_STENCIL_PASS_Z_PASS_SHIFT)); - - - /* ctx->Driver.StencilFunc( ctx, GL_ALWAYS, s_ref, ~0 ) - */ - i915->meta.Ctx[I915_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_TEST_MASK; - i915->meta.Ctx[I915_CTXREG_STATE4] |= (ENABLE_STENCIL_TEST_MASK | - STENCIL_TEST_MASK(0xff)); - - i915->meta.Ctx[I915_CTXREG_LIS5] &= ~(S5_STENCIL_REF_MASK | - S5_STENCIL_TEST_FUNC_MASK); - - i915->meta.Ctx[I915_CTXREG_LIS5] |= ((s_clear << S5_STENCIL_REF_SHIFT) | - (func << S5_STENCIL_TEST_FUNC_SHIFT)); - - - i915->meta.emitted &= ~I915_UPLOAD_CTX; -} - - -static void -meta_color_mask(struct intel_context *intel, GLboolean state) -{ - struct i915_context *i915 = i915_context(&intel->ctx); - const GLuint mask = (S5_WRITEDISABLE_RED | - S5_WRITEDISABLE_GREEN | - S5_WRITEDISABLE_BLUE | S5_WRITEDISABLE_ALPHA); - - /* Copy colormask state from "regular" hw context. - */ - if (state) { - i915->meta.Ctx[I915_CTXREG_LIS5] &= ~mask; - i915->meta.Ctx[I915_CTXREG_LIS5] |= - (i915->state.Ctx[I915_CTXREG_LIS5] & mask); - } - else - i915->meta.Ctx[I915_CTXREG_LIS5] |= mask; - - i915->meta.emitted &= ~I915_UPLOAD_CTX; -} - - - -static void -meta_import_pixel_state(struct intel_context *intel) -{ - struct i915_context *i915 = i915_context(&intel->ctx); - memcpy(i915->meta.Fog, i915->state.Fog, I915_FOG_SETUP_SIZE * 4); - - i915->meta.Ctx[I915_CTXREG_LIS5] = i915->state.Ctx[I915_CTXREG_LIS5]; - i915->meta.Ctx[I915_CTXREG_LIS6] = i915->state.Ctx[I915_CTXREG_LIS6]; - i915->meta.Ctx[I915_CTXREG_STATE4] = i915->state.Ctx[I915_CTXREG_STATE4]; - i915->meta.Ctx[I915_CTXREG_BLENDCOLOR1] = - i915->state.Ctx[I915_CTXREG_BLENDCOLOR1]; - i915->meta.Ctx[I915_CTXREG_IAB] = i915->state.Ctx[I915_CTXREG_IAB]; - - i915->meta.Buffer[I915_DESTREG_SENABLE] = - i915->state.Buffer[I915_DESTREG_SENABLE]; - i915->meta.Buffer[I915_DESTREG_SR1] = i915->state.Buffer[I915_DESTREG_SR1]; - i915->meta.Buffer[I915_DESTREG_SR2] = i915->state.Buffer[I915_DESTREG_SR2]; - - i915->meta.emitted &= ~I915_UPLOAD_FOG; - i915->meta.emitted &= ~I915_UPLOAD_BUFFERS; - i915->meta.emitted &= ~I915_UPLOAD_CTX; -} - - - - -#define REG( type, nr ) (((type)<<5)|(nr)) - -#define REG_R(x) REG(REG_TYPE_R, x) -#define REG_T(x) REG(REG_TYPE_T, x) -#define REG_CONST(x) REG(REG_TYPE_CONST, x) -#define REG_S(x) REG(REG_TYPE_S, x) -#define REG_OC REG(REG_TYPE_OC, 0) -#define REG_OD REG(REG_TYPE_OD, 0) -#define REG_U(x) REG(REG_TYPE_U, x) - -#define REG_T_DIFFUSE REG(REG_TYPE_T, T_DIFFUSE) -#define REG_T_SPECULAR REG(REG_TYPE_T, T_SPECULAR) -#define REG_T_FOG_W REG(REG_TYPE_T, T_FOG_W) -#define REG_T_TEX(x) REG(REG_TYPE_T, x) - - -#define A0_DEST_REG( reg ) ( (reg) << A0_DEST_NR_SHIFT ) -#define A0_SRC0_REG( reg ) ( (reg) << A0_SRC0_NR_SHIFT ) -#define A1_SRC1_REG( reg ) ( (reg) << A1_SRC1_NR_SHIFT ) -#define A1_SRC2_REG( reg ) ( (reg) << A1_SRC2_NR_SHIFT ) -#define A2_SRC2_REG( reg ) ( (reg) << A2_SRC2_NR_SHIFT ) -#define D0_DECL_REG( reg ) ( (reg) << D0_NR_SHIFT ) -#define T0_DEST_REG( reg ) ( (reg) << T0_DEST_NR_SHIFT ) - -#define T0_SAMPLER( unit ) ((unit)<ctx); - - static const GLuint prog[] = { - _3DSTATE_PIXEL_SHADER_PROGRAM, - - /* Declare incoming diffuse color: - */ - (D0_DCL | D0_DECL_REG(REG_T_DIFFUSE) | D0_CHANNEL_ALL), - D1_MBZ, - D2_MBZ, - - /* output-color = mov(t_diffuse) - */ - (A0_MOV | - A0_DEST_REG(REG_OC) | - A0_DEST_CHANNEL_ALL | A0_SRC0_REG(REG_T_DIFFUSE)), - (A1_SRC0_XYZW), - 0, - }; - - - memcpy(i915->meta.Program, prog, sizeof(prog)); - i915->meta.ProgramSize = sizeof(prog) / sizeof(*prog); - i915->meta.Program[0] |= i915->meta.ProgramSize - 2; - i915->meta.emitted &= ~I915_UPLOAD_PROGRAM; -} - -static void -meta_texture_blend_replace(struct intel_context *intel) -{ - struct i915_context *i915 = i915_context(&intel->ctx); - - static const GLuint prog[] = { - _3DSTATE_PIXEL_SHADER_PROGRAM, - - /* Declare the sampler: - */ - (D0_DCL | D0_DECL_REG(REG_S(0)) | D0_SAMPLE_TYPE_2D | D0_CHANNEL_NONE), - D1_MBZ, - D2_MBZ, - - /* Declare the interpolated texture coordinate: - */ - (D0_DCL | D0_DECL_REG(REG_T_TEX(0)) | D0_CHANNEL_ALL), - D1_MBZ, - D2_MBZ, - - /* output-color = texld(sample0, texcoord0) - */ - (T0_TEXLD | T0_DEST_REG(REG_OC) | T0_SAMPLER(0)), - T1_ADDRESS_REG(REG_TYPE_T, 0), - T2_MBZ - }; - - memcpy(i915->meta.Program, prog, sizeof(prog)); - i915->meta.ProgramSize = sizeof(prog) / sizeof(*prog); - i915->meta.Program[0] |= i915->meta.ProgramSize - 2; - i915->meta.emitted &= ~I915_UPLOAD_PROGRAM; -} - - - - - -/* Set up an arbitary piece of memory as a rectangular texture - * (including the front or back buffer). - */ -static GLboolean -meta_tex_rect_source(struct intel_context *intel, - dri_bo *buffer, - GLuint offset, - GLuint pitch, GLuint height, GLenum format, GLenum type) -{ - struct i915_context *i915 = i915_context(&intel->ctx); - GLuint unit = 0; - GLint numLevels = 1; - GLuint *state = i915->meta.Tex[0]; - GLuint textureFormat; - GLuint cpp; - - /* A full implementation of this would do the upload through - * glTexImage2d, and get all the conversion operations at that - * point. We are restricted, but still at least have access to the - * fragment program swizzle. - */ - switch (format) { - case GL_BGRA: - switch (type) { - case GL_UNSIGNED_INT_8_8_8_8_REV: - case GL_UNSIGNED_BYTE: - textureFormat = (MAPSURF_32BIT | MT_32BIT_ARGB8888); - cpp = 4; - break; - default: - return GL_FALSE; - } - break; - case GL_RGBA: - switch (type) { - case GL_UNSIGNED_INT_8_8_8_8_REV: - case GL_UNSIGNED_BYTE: - textureFormat = (MAPSURF_32BIT | MT_32BIT_ABGR8888); - cpp = 4; - break; - default: - return GL_FALSE; - } - break; - case GL_BGR: - switch (type) { - case GL_UNSIGNED_SHORT_5_6_5_REV: - textureFormat = (MAPSURF_16BIT | MT_16BIT_RGB565); - cpp = 2; - break; - default: - return GL_FALSE; - } - break; - case GL_RGB: - switch (type) { - case GL_UNSIGNED_SHORT_5_6_5: - textureFormat = (MAPSURF_16BIT | MT_16BIT_RGB565); - cpp = 2; - break; - default: - return GL_FALSE; - } - break; - - default: - return GL_FALSE; - } - - - if ((pitch * cpp) & 3) { - _mesa_printf("%s: texture is not dword pitch\n", __FUNCTION__); - return GL_FALSE; - } - -/* intel_region_release(&i915->meta.tex_region[0]); */ -/* intel_region_reference(&i915->meta.tex_region[0], region); */ - i915->meta.tex_buffer[0] = buffer; - i915->meta.tex_offset[0] = offset; - - state[I915_TEXREG_MS3] = (((height - 1) << MS3_HEIGHT_SHIFT) | - ((pitch - 1) << MS3_WIDTH_SHIFT) | - textureFormat | MS3_USE_FENCE_REGS); - - state[I915_TEXREG_MS4] = (((((pitch * cpp) / 4) - 1) << MS4_PITCH_SHIFT) | - MS4_CUBE_FACE_ENA_MASK | - ((((numLevels - 1) * 4)) << MS4_MAX_LOD_SHIFT)); - - state[I915_TEXREG_SS2] = ((FILTER_NEAREST << SS2_MIN_FILTER_SHIFT) | - (MIPFILTER_NONE << SS2_MIP_FILTER_SHIFT) | - (FILTER_NEAREST << SS2_MAG_FILTER_SHIFT)); - - state[I915_TEXREG_SS3] = ((TEXCOORDMODE_WRAP << SS3_TCX_ADDR_MODE_SHIFT) | - (TEXCOORDMODE_WRAP << SS3_TCY_ADDR_MODE_SHIFT) | - (TEXCOORDMODE_WRAP << SS3_TCZ_ADDR_MODE_SHIFT) | - (unit << SS3_TEXTUREMAP_INDEX_SHIFT)); - - state[I915_TEXREG_SS4] = 0; - - i915->meta.emitted &= ~I915_UPLOAD_TEX(0); - return GL_TRUE; -} - - -/** - * Set the color and depth drawing region for meta ops. - */ -static void -meta_draw_region(struct intel_context *intel, - struct intel_region *color_region, - struct intel_region *depth_region) -{ - struct i915_context *i915 = i915_context(&intel->ctx); - i915_state_draw_region(intel, &i915->meta, color_region, depth_region); -} - - -static void -set_vertex_format(struct intel_context *intel) -{ - struct i915_context *i915 = i915_context(&intel->ctx); - - i915->meta.Ctx[I915_CTXREG_LIS2] = - (S2_TEXCOORD_FMT(0, TEXCOORDFMT_2D) | - S2_TEXCOORD_FMT(1, TEXCOORDFMT_NOT_PRESENT) | - S2_TEXCOORD_FMT(2, TEXCOORDFMT_NOT_PRESENT) | - S2_TEXCOORD_FMT(3, TEXCOORDFMT_NOT_PRESENT) | - S2_TEXCOORD_FMT(4, TEXCOORDFMT_NOT_PRESENT) | - S2_TEXCOORD_FMT(5, TEXCOORDFMT_NOT_PRESENT) | - S2_TEXCOORD_FMT(6, TEXCOORDFMT_NOT_PRESENT) | - S2_TEXCOORD_FMT(7, TEXCOORDFMT_NOT_PRESENT)); - - i915->meta.Ctx[I915_CTXREG_LIS4] &= ~S4_VFMT_MASK; - - i915->meta.Ctx[I915_CTXREG_LIS4] |= (S4_VFMT_COLOR | S4_VFMT_XYZ); - - i915->meta.emitted &= ~I915_UPLOAD_CTX; -} - - - -/* Operations where the 3D engine is decoupled temporarily from the - * current GL state and used for other purposes than simply rendering - * incoming triangles. - */ -static void -install_meta_state(struct intel_context *intel) -{ - struct i915_context *i915 = i915_context(&intel->ctx); - memcpy(&i915->meta, &i915->initial, sizeof(i915->meta)); - i915->meta.active = ACTIVE; - i915->meta.emitted = 0; - - SET_STATE(i915, meta); - set_vertex_format(intel); - meta_no_texture(intel); -} - -static void -leave_meta_state(struct intel_context *intel) -{ - struct i915_context *i915 = i915_context(&intel->ctx); - intel_region_release(&i915->meta.draw_region); - intel_region_release(&i915->meta.depth_region); -/* intel_region_release(&i915->meta.tex_region[0]); */ - SET_STATE(i915, state); -} - - - -void -i915InitMetaFuncs(struct i915_context *i915) -{ - i915->intel.vtbl.install_meta_state = install_meta_state; - i915->intel.vtbl.leave_meta_state = leave_meta_state; - i915->intel.vtbl.meta_no_depth_write = meta_no_depth_write; - i915->intel.vtbl.meta_no_stencil_write = meta_no_stencil_write; - i915->intel.vtbl.meta_stencil_replace = meta_stencil_replace; - i915->intel.vtbl.meta_depth_replace = meta_depth_replace; - i915->intel.vtbl.meta_color_mask = meta_color_mask; - i915->intel.vtbl.meta_no_texture = meta_no_texture; - i915->intel.vtbl.meta_texture_blend_replace = meta_texture_blend_replace; - i915->intel.vtbl.meta_tex_rect_source = meta_tex_rect_source; - i915->intel.vtbl.meta_draw_region = meta_draw_region; - i915->intel.vtbl.meta_import_pixel_state = meta_import_pixel_state; -} diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c b/src/mesa/drivers/dri/i915/i915_vtbl.c index 933a565f02..e5dbdcf78d 100644 --- a/src/mesa/drivers/dri/i915/i915_vtbl.c +++ b/src/mesa/drivers/dri/i915/i915_vtbl.c @@ -440,10 +440,6 @@ i915_emit_state(struct intel_context *intel) I915_GEM_DOMAIN_SAMPLER, 0, state->tex_offset[i]); } - else if (state == &i915->meta) { - assert(i == 0); - OUT_BATCH(0); - } else { OUT_BATCH(state->tex_offset[i]); } @@ -497,8 +493,6 @@ i915_destroy_context(struct intel_context *intel) intel_region_release(&i915->state.draw_region); intel_region_release(&i915->state.depth_region); - intel_region_release(&i915->meta.draw_region); - intel_region_release(&i915->meta.depth_region); intel_region_release(&i915->initial.draw_region); intel_region_release(&i915->initial.depth_region); @@ -530,29 +524,22 @@ i915_set_buf_info_for_region(uint32_t *state, struct intel_region *region, } } -/** - * Set the drawing regions for the color and depth/stencil buffers. - * This involves setting the pitch, cpp and buffer ID/location. - * Also set pixel format for color and Z rendering - * Used for setting both regular and meta state. - */ -void -i915_state_draw_region(struct intel_context *intel, - struct i915_hw_state *state, - struct intel_region *color_region, - struct intel_region *depth_region) +static void +i915_set_draw_region(struct intel_context *intel, + struct intel_region *color_regions[], + struct intel_region *depth_region, + GLuint num_regions) { struct i915_context *i915 = i915_context(&intel->ctx); GLcontext *ctx = &intel->ctx; struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; struct intel_renderbuffer *irb = intel_renderbuffer(rb); GLuint value; + struct i915_hw_state *state = &i915->state; - ASSERT(state == &i915->state || state == &i915->meta); - - if (state->draw_region != color_region) { + if (state->draw_region != color_regions[0]) { intel_region_release(&state->draw_region); - intel_region_reference(&state->draw_region, color_region); + intel_region_reference(&state->draw_region, color_regions[0]); } if (state->depth_region != depth_region) { intel_region_release(&state->depth_region); @@ -563,7 +550,7 @@ i915_state_draw_region(struct intel_context *intel, * Set stride/cpp values */ i915_set_buf_info_for_region(&state->Buffer[I915_DESTREG_CBUFADDR0], - color_region, BUF_3D_ID_COLOR_BACK); + color_regions[0], BUF_3D_ID_COLOR_BACK); i915_set_buf_info_for_region(&state->Buffer[I915_DESTREG_DBUFADDR0], depth_region, BUF_3D_ID_DEPTH); @@ -624,17 +611,6 @@ i915_state_draw_region(struct intel_context *intel, } -static void -i915_set_draw_region(struct intel_context *intel, - struct intel_region *color_regions[], - struct intel_region *depth_region, - GLuint num_regions) -{ - struct i915_context *i915 = i915_context(&intel->ctx); - i915_state_draw_region(intel, &i915->state, color_regions[0], depth_region); -} - - static void i915_new_batch(struct intel_context *intel) diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h index 8d7c95976f..36abef470a 100644 --- a/src/mesa/drivers/dri/intel/intel_context.h +++ b/src/mesa/drivers/dri/intel/intel_context.h @@ -124,40 +124,6 @@ struct intel_context void (*invalidate_state) (struct intel_context *intel, GLuint new_state); - - /* Metaops: - */ - void (*install_meta_state) (struct intel_context * intel); - void (*leave_meta_state) (struct intel_context * intel); - - void (*meta_draw_region) (struct intel_context * intel, - struct intel_region * draw_region, - struct intel_region * depth_region); - - void (*meta_color_mask) (struct intel_context * intel, GLboolean); - - void (*meta_stencil_replace) (struct intel_context * intel, - GLuint mask, GLuint clear); - - void (*meta_depth_replace) (struct intel_context * intel); - - void (*meta_texture_blend_replace) (struct intel_context * intel); - - void (*meta_no_stencil_write) (struct intel_context * intel); - void (*meta_no_depth_write) (struct intel_context * intel); - void (*meta_no_texture) (struct intel_context * intel); - - void (*meta_import_pixel_state) (struct intel_context * intel); - void (*meta_frame_buffer_texture) (struct intel_context *intel, - GLint xoff, GLint yoff); - - GLboolean(*meta_tex_rect_source) (struct intel_context * intel, - dri_bo * buffer, - GLuint offset, - GLuint pitch, - GLuint height, - GLenum format, GLenum type); - void (*assert_not_dirty) (struct intel_context *intel); void (*debug_batch)(struct intel_context *intel); diff --git a/src/mesa/drivers/dri/intel/intel_pixel_read.c b/src/mesa/drivers/dri/intel/intel_pixel_read.c index 80a2b9740f..a98e8e16c2 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_read.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_read.c @@ -64,99 +64,6 @@ * any case. */ - -static GLboolean -do_texture_readpixels(GLcontext * ctx, - GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, - const struct gl_pixelstore_attrib *pack, - struct intel_region *dest_region) -{ -#if 0 - struct intel_context *intel = intel_context(ctx); - intelScreenPrivate *screen = intel->intelScreen; - GLint pitch = pack->RowLength ? pack->RowLength : width; - __DRIdrawable *dPriv = intel->driDrawable; - int textureFormat; - GLenum glTextureFormat; - int destFormat, depthFormat, destPitch; - drm_clip_rect_t tmp; - - if (INTEL_DEBUG & DEBUG_PIXEL) - fprintf(stderr, "%s\n", __FUNCTION__); - - - if (ctx->_ImageTransferState || - pack->SwapBytes || pack->LsbFirst || !pack->Invert) { - if (INTEL_DEBUG & DEBUG_PIXEL) - fprintf(stderr, "%s: check_color failed\n", __FUNCTION__); - return GL_FALSE; - } - - intel->vtbl.meta_texrect_source(intel, intel_readbuf_region(intel)); - - if (!intel->vtbl.meta_render_dest(intel, dest_region, type, format)) { - if (INTEL_DEBUG & DEBUG_PIXEL) - fprintf(stderr, "%s: couldn't set dest %s/%s\n", - __FUNCTION__, - _mesa_lookup_enum_by_nr(type), - _mesa_lookup_enum_by_nr(format)); - return GL_FALSE; - } - - if (intel->driDrawable->numClipRects) { - intel->vtbl.install_meta_state(intel); - intel->vtbl.meta_no_depth_write(intel); - intel->vtbl.meta_no_stencil_write(intel); - - if (!driClipRectToFramebuffer(ctx->ReadBuffer, &x, &y, &width, &height)) { - SET_STATE(i830, state); - if (INTEL_DEBUG & DEBUG_PIXEL) - fprintf(stderr, "%s: cliprect failed\n", __FUNCTION__); - return GL_TRUE; - } - - y = dPriv->h - y - height; - x += dPriv->x; - y += dPriv->y; - - - /* Set the frontbuffer up as a large rectangular texture. - */ - intel->vtbl.meta_tex_rect_source(intel, src_region, textureFormat); - - - intel->vtbl.meta_texture_blend_replace(i830, glTextureFormat); - - - /* Set the 3d engine to draw into the destination region: - */ - - intel->vtbl.meta_draw_region(intel, dest_region); - intel->vtbl.meta_draw_format(intel, destFormat, depthFormat); /* ?? */ - - - /* Draw a single quad, no cliprects: - */ - intel->vtbl.meta_disable_cliprects(intel); - - intel->vtbl.draw_quad(intel, - 0, width, 0, height, - 0x00ff00ff, x, x + width, y, y + height); - - intel->vtbl.leave_meta_state(intel); - } - - intel_region_wait_fence(ctx, dest_region); /* required by GL */ - return GL_TRUE; -#endif - - return GL_FALSE; -} - - - - static GLboolean do_blit_readpixels(GLcontext * ctx, GLint x, GLint y, GLsizei width, GLsizei height, @@ -270,15 +177,6 @@ intelReadPixels(GLcontext * ctx, (ctx, x, y, width, height, format, type, pack, pixels)) return; -#ifdef I915 - if (do_texture_readpixels - (ctx, x, y, width, height, format, type, pack, pixels)) - return; -#else - (void)do_blit_readpixels; - (void)do_texture_readpixels; -#endif - if (INTEL_DEBUG & DEBUG_PIXEL) _mesa_printf("%s: fallback to swrast\n", __FUNCTION__); -- cgit v1.2.3 From c9886d535e4ac5ae108b1015a9682f4ddd297536 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 27 Jan 2010 22:22:49 -0800 Subject: i915: Remove unused initial and current state, now that there's nothing else. --- src/mesa/drivers/dri/i915/i830_context.h | 2 +- src/mesa/drivers/dri/i915/i830_state.c | 3 --- src/mesa/drivers/dri/i915/i830_vtbl.c | 11 ++++------- src/mesa/drivers/dri/i915/i915_context.h | 2 +- src/mesa/drivers/dri/i915/i915_state.c | 3 --- src/mesa/drivers/dri/i915/i915_vtbl.c | 11 ++++------- 6 files changed, 10 insertions(+), 22 deletions(-) diff --git a/src/mesa/drivers/dri/i915/i830_context.h b/src/mesa/drivers/dri/i915/i830_context.h index b1e3ec4500..b755d48678 100644 --- a/src/mesa/drivers/dri/i915/i830_context.h +++ b/src/mesa/drivers/dri/i915/i830_context.h @@ -144,7 +144,7 @@ struct i830_context GLuint lodbias_tm0s3[MAX_TEXTURE_UNITS]; DECLARE_RENDERINPUTS(last_index_bitset); - struct i830_hw_state initial, state, *current; + struct i830_hw_state state; }; diff --git a/src/mesa/drivers/dri/i915/i830_state.c b/src/mesa/drivers/dri/i915/i830_state.c index acda7e70de..3b9b3ae329 100644 --- a/src/mesa/drivers/dri/i915/i830_state.c +++ b/src/mesa/drivers/dri/i915/i830_state.c @@ -1127,9 +1127,6 @@ i830InitState(struct i830_context *i830) _mesa_init_driver_state(ctx); - memcpy(&i830->initial, &i830->state, sizeof(i830->state)); - - i830->current = &i830->state; i830->state.emitted = 0; i830->state.active = (I830_UPLOAD_INVARIENT | I830_UPLOAD_RASTER_RULES | diff --git a/src/mesa/drivers/dri/i915/i830_vtbl.c b/src/mesa/drivers/dri/i915/i830_vtbl.c index 6dd64ef45e..a8df77c600 100644 --- a/src/mesa/drivers/dri/i915/i830_vtbl.c +++ b/src/mesa/drivers/dri/i915/i830_vtbl.c @@ -235,8 +235,8 @@ static GLboolean i830_check_vertex_size(struct intel_context *intel, GLuint expected) { struct i830_context *i830 = i830_context(&intel->ctx); - int vft0 = i830->current->Ctx[I830_CTXREG_VF]; - int vft1 = i830->current->Ctx[I830_CTXREG_VF2]; + int vft0 = i830->state.Ctx[I830_CTXREG_VF]; + int vft1 = i830->state.Ctx[I830_CTXREG_VF2]; int nrtex = (vft0 & VFT0_TEX_COUNT_MASK) >> VFT0_TEX_COUNT_SHIFT; int i, sz = 0; @@ -412,7 +412,7 @@ static void i830_emit_state(struct intel_context *intel) { struct i830_context *i830 = i830_context(&intel->ctx); - struct i830_hw_state *state = i830->current; + struct i830_hw_state *state = &i830->state; int i, count; GLuint dirty; dri_bo *aper_array[3 + I830_TEX_UNITS]; @@ -575,8 +575,6 @@ i830_destroy_context(struct intel_context *intel) intel_region_release(&i830->state.draw_region); intel_region_release(&i830->state.depth_region); - intel_region_release(&i830->initial.draw_region); - intel_region_release(&i830->initial.depth_region); for (i = 0; i < I830_TEX_UNITS; i++) { if (i830->state.tex_buffer[i] != NULL) { @@ -679,8 +677,7 @@ static void i830_assert_not_dirty( struct intel_context *intel ) { struct i830_context *i830 = i830_context(&intel->ctx); - struct i830_hw_state *state = i830->current; - assert(!get_dirty(state)); + assert(!get_dirty(&i830->state)); } static void diff --git a/src/mesa/drivers/dri/i915/i915_context.h b/src/mesa/drivers/dri/i915/i915_context.h index 7c091f3f92..60b357ec28 100644 --- a/src/mesa/drivers/dri/i915/i915_context.h +++ b/src/mesa/drivers/dri/i915/i915_context.h @@ -259,7 +259,7 @@ struct i915_context struct i915_fragment_program *current_program; - struct i915_hw_state initial, state, *current; + struct i915_hw_state state; }; diff --git a/src/mesa/drivers/dri/i915/i915_state.c b/src/mesa/drivers/dri/i915/i915_state.c index 9d7a9e1dfe..7275617a6f 100644 --- a/src/mesa/drivers/dri/i915/i915_state.c +++ b/src/mesa/drivers/dri/i915/i915_state.c @@ -1157,7 +1157,4 @@ i915InitState(struct i915_context *i915) i915_init_packets(i915); _mesa_init_driver_state(ctx); - - memcpy(&i915->initial, &i915->state, sizeof(i915->state)); - i915->current = &i915->state; } diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c b/src/mesa/drivers/dri/i915/i915_vtbl.c index e5dbdcf78d..3dda5339c3 100644 --- a/src/mesa/drivers/dri/i915/i915_vtbl.c +++ b/src/mesa/drivers/dri/i915/i915_vtbl.c @@ -97,8 +97,8 @@ static GLboolean i915_check_vertex_size(struct intel_context *intel, GLuint expected) { struct i915_context *i915 = i915_context(&intel->ctx); - int lis2 = i915->current->Ctx[I915_CTXREG_LIS2]; - int lis4 = i915->current->Ctx[I915_CTXREG_LIS4]; + int lis2 = i915->state.Ctx[I915_CTXREG_LIS2]; + int lis4 = i915->state.Ctx[I915_CTXREG_LIS4]; int i, sz = 0; switch (lis4 & S4_VFMT_XYZW_MASK) { @@ -284,7 +284,7 @@ static void i915_emit_state(struct intel_context *intel) { struct i915_context *i915 = i915_context(&intel->ctx); - struct i915_hw_state *state = i915->current; + struct i915_hw_state *state = &i915->state; int i, count, aper_count; GLuint dirty; dri_bo *aper_array[3 + I915_TEX_UNITS]; @@ -493,8 +493,6 @@ i915_destroy_context(struct intel_context *intel) intel_region_release(&i915->state.draw_region); intel_region_release(&i915->state.depth_region); - intel_region_release(&i915->initial.draw_region); - intel_region_release(&i915->initial.depth_region); for (i = 0; i < I915_TEX_UNITS; i++) { if (i915->state.tex_buffer[i] != NULL) { @@ -628,8 +626,7 @@ static void i915_assert_not_dirty( struct intel_context *intel ) { struct i915_context *i915 = i915_context(&intel->ctx); - struct i915_hw_state *state = i915->current; - GLuint dirty = get_dirty(state); + GLuint dirty = get_dirty(&i915->state); assert(!dirty); } -- cgit v1.2.3 From f20e83210e81a33712f52eaa8d944d116b56b46c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 28 Jan 2010 10:53:04 -0800 Subject: intel: Set the region's tiling to none when attaching a PBO to a region. Note that when detaching the PBO from the region and making a new BO for the region, we don't make it tiled even if the region originally was. Fixes piglit pbo-teximage-tiling. --- src/mesa/drivers/dri/intel/intel_regions.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c index f415589c5d..301c3df17c 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.c +++ b/src/mesa/drivers/dri/intel/intel_regions.c @@ -442,6 +442,7 @@ intel_region_attach_pbo(struct intel_context *intel, region->pbo->region = region; dri_bo_reference(buffer); region->buffer = buffer; + region->tiling = I915_TILING_NONE; } -- cgit v1.2.3 From a5f7c63fc09d9924f3579bcef178e75fec6bfac3 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 28 Jan 2010 12:22:08 -0800 Subject: gallium-docs: Add PIPE_CAP info. --- src/gallium/docs/source/glossary.rst | 4 +++ src/gallium/docs/source/screen.rst | 63 ++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/src/gallium/docs/source/glossary.rst b/src/gallium/docs/source/glossary.rst index aec89f8b5c..e49141b5e2 100644 --- a/src/gallium/docs/source/glossary.rst +++ b/src/gallium/docs/source/glossary.rst @@ -13,3 +13,7 @@ Glossary Transform, Clipping, & Lighting. The three stages of preparation in a rasterizing pipeline prior to the actual rasterization of vertices into fragments. + + NPOT + Non-power-of-two. Usually applied to textures which have at least one + dimension which is not a power of two. diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index 905ff24db9..f0833bfe54 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -6,6 +6,61 @@ A screen is an object representing the context-independent part of a device. Useful Flags ------------ +.. _pipe_cap: + +PIPE_CAP +^^^^^^^^ + +Pipe capabilities help expose hardware functionality not explicitly required +by Gallium. For floating-point values, use :ref:`get_paramf`, and for boolean +or integer values, use :ref:`get_param`. + +The integer capabilities: + +* ``MAX_TEXTURE_IMAGE_UNITS``: The maximum number of samplers available. +* ``NPOT_TEXTURES``: Whether :term:`NPOT` textures may have repeat modes, + normalized coordinates, and mipmaps. +* ``TWO_SIDED_STENCIL``: Whether the stencil test can also affect back-facing + polygons. +* ``GLSL``: Deprecated. +* ``S3TC``: Deprecated. +* ``ANISOTROPIC_FILTER``: Whether textures can be filtered anisotropically. +* ``POINT_SPRITE``: Whether point sprites are available. +* ``MAX_RENDER_TARGETS``: The maximum number of render targets that may be + bound. +* ``OCCLUSION_QUERY``: Whether occlusion queries are available. +* ``TEXTURE_SHADOW_MAP``: XXX +* ``MAX_TEXTURE_2D_LEVELS``: The maximum number of mipmap levels available + for a 2D texture. +* ``MAX_TEXTURE_3D_LEVELS``: The maximum number of mipmap levels available + for a 3D texture. +* ``MAX_TEXTURE_CUBE_LEVELS``: The maximum number of mipmap levels available + for a cubemap. +* ``TEXTURE_MIRROR_CLAMP``: Whether mirrored texture coordinates with clamp + are supported. +* ``TEXTURE_MIRROR_REPEAT``: Whether mirrored repeating texture coordinates + are supported. +* ``MAX_VERTEX_TEXTURE_UNITS``: The maximum number of samplers addressable + inside the vertex shader. If this is 0, then the vertex shader cannot + sample textures. +* ``TGSI_CONT_SUPPORTED``: Whether the TGSI CONT opcode is supported. +* ``BLEND_EQUATION_SEPARATE``: Whether alpha blend equations may be different + from color blend equations, in :ref:`Blend` state. +* ``SM3``: Whether the vertex shader and fragment shader support equivalent + opcodes to the Shader Model 3 specification. XXX oh god this is horrible +* ``MAX_PREDICATE_REGISTERS``: XXX +* ``MAX_COMBINED_SAMPLERS``: The total number of samplers accessible from + the vertex and fragment shader, inclusive. + +The floating-point capabilities: + +* ``MAX_LINE_WIDTH``: The maximum width of a regular line. +* ``MAX_LINE_WIDTH_AA``: The maximum width of a smoothed line. +* ``MAX_POINT_WIDTH``: The maximum width and height of a point. +* ``MAX_POINT_WIDTH_AA``: The maximum width and height of a smoothed point. +* ``GUARD_BAND_LEFT``, ``GUARD_BAND_TOP``, ``GUARD_BAND_RIGHT``, + ``GUARD_BAND_BOTTOM``: XXX + .. _pipe_buffer_usage: PIPE_BUFFER_USAGE @@ -75,6 +130,8 @@ get_vendor Returns the screen vendor. +.. _get_param: + get_param ^^^^^^^^^ @@ -102,11 +159,17 @@ Get an integer/boolean screen parameter. Valid parameter names include. * ``PIPE_CAP_MAX_CONST_BUFFER_SIZE``: Maximum byte size of a single constant buffer. +**param** is one of the :ref:`PIPE_CAP` names. + +.. _get_paramf: + get_paramf ^^^^^^^^^^ Get a floating-point screen parameter. +**param** is one of the :ref:`PIPE_CAP` names. + is_format_supported ^^^^^^^^^^^^^^^^^^^ -- cgit v1.2.3 From 505a43aff23d0a6b71f89c25fc67f097cfa8c080 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 28 Jan 2010 12:29:53 -0800 Subject: gallium-docs: Clean up constantbuf info a bit. Hmm, does this belong in context, next to set_constant_buffer? Maybe a paragraph in shaders might be useful. --- src/gallium/docs/source/screen.rst | 47 +++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index f0833bfe54..39938f7bb7 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -51,6 +51,11 @@ The integer capabilities: * ``MAX_PREDICATE_REGISTERS``: XXX * ``MAX_COMBINED_SAMPLERS``: The total number of samplers accessible from the vertex and fragment shader, inclusive. +* ``MAX_CONST_BUFFERS``: Maximum number of constant buffers that can be bound + to any shader stage using ``set_constant_buffer``. If 0 or 1, the pipe will + only permit binding one constant buffer per shader, and the shaders will + not permit two-dimensional access to constants. +* ``MAX_CONST_BUFFER_SIZE``: Maximum byte size of a single constant buffer. The floating-point capabilities: @@ -61,6 +66,24 @@ The floating-point capabilities: * ``GUARD_BAND_LEFT``, ``GUARD_BAND_TOP``, ``GUARD_BAND_RIGHT``, ``GUARD_BAND_BOTTOM``: XXX +XXX Is there a better home for this? vvv + +If 0 is returned, the driver is not aware of multiple constant buffers, +supports binding of only one constant buffer, and does not support +two-dimensional CONST register file access in TGSI shaders. + +If a value greater than 0 is returned, the driver can have multiple +constant buffers bound to shader stages. The CONST register file can +be accessed with two-dimensional indices, like in the example below. + +DCL CONST[0][0..7] # declare first 8 vectors of constbuf 0 +DCL CONST[3][0] # declare first vector of constbuf 3 +MOV OUT[0], CONST[0][3] # copy vector 3 of constbuf 0 + +For backwards compatibility, one-dimensional access to CONST register +file is still supported. In that case, the constbuf index is assumed +to be 0. + .. _pipe_buffer_usage: PIPE_BUFFER_USAGE @@ -135,29 +158,7 @@ Returns the screen vendor. get_param ^^^^^^^^^ -Get an integer/boolean screen parameter. Valid parameter names include. - -* ``PIPE_CAP_MAX_CONST_BUFFERS``: Maximum number of constant buffers that - can be bound to any shader stage using ``set_constant_buffer``. - - If 0 is returned, the driver is not aware of multiple constant buffers, - supports binding of only one constant buffer, and does not support - two-dimensional CONST register file access in TGSI shaders. - - If a value greater than 0 is returned, the driver can have multiple - constant buffers bound to shader stages. The CONST register file can - be accessed with two-dimensional indices, like in the example below. - - DCL CONST[0][0..7] # declare first 8 vectors of constbuf 0 - DCL CONST[3][0] # declare first vector of constbuf 3 - MOV OUT[0], CONST[0][3] # copy vector 3 of constbuf 0 - - For backwards compatibility, one-dimensional access to CONST register - file is still supported. In that case, the constbuf index is assumed - to be 0. - -* ``PIPE_CAP_MAX_CONST_BUFFER_SIZE``: Maximum byte size of a single constant - buffer. +Get an integer/boolean screen parameter. **param** is one of the :ref:`PIPE_CAP` names. -- cgit v1.2.3 From 2e481e9fad946ffb0e3121a2e9d3531e131da0ec Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 28 Jan 2010 13:37:09 -0800 Subject: gallium-docs: Minor grammar, need to talk about dual-source blends. --- src/gallium/docs/source/cso/blend.rst | 12 ++++++++++-- src/gallium/docs/source/screen.rst | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/gallium/docs/source/cso/blend.rst b/src/gallium/docs/source/cso/blend.rst index 3fc573054e..55c0f32885 100644 --- a/src/gallium/docs/source/cso/blend.rst +++ b/src/gallium/docs/source/cso/blend.rst @@ -6,6 +6,14 @@ Blend This state controls blending of the final fragments into the target rendering buffers. +Blend Factors +------------- + +The blend factors largely follow the same pattern as their counterparts +in other modern and legacy drawing APIs. + +XXX blurb about dual-source blends + Members ------- @@ -22,9 +30,9 @@ logicop_func dither Whether dithering is enabled. rt - Contains the per rendertarget blend state. + Contains the per-rendertarget blend state. -per rendertarget members +Per-rendertarget Members ------------------------ blend_enable diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index 39938f7bb7..f2421c74ae 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -23,7 +23,8 @@ The integer capabilities: * ``TWO_SIDED_STENCIL``: Whether the stencil test can also affect back-facing polygons. * ``GLSL``: Deprecated. -* ``S3TC``: Deprecated. +* ``DUAL_SOURCE_BLEND``: Whether dual-source blend factors are supported. See + :ref:`Blend` for more information. * ``ANISOTROPIC_FILTER``: Whether textures can be filtered anisotropically. * ``POINT_SPRITE``: Whether point sprites are available. * ``MAX_RENDER_TARGETS``: The maximum number of render targets that may be -- cgit v1.2.3 From 00873227292df458b28249d7c3736d633e619dab Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 28 Jan 2010 13:39:13 -0800 Subject: r300g: Clean up blend masks, change caps. progs/tests/drawbuffers should work, except I can't test it. GG new shader parser. GG. --- src/gallium/drivers/r300/r300_emit.c | 9 ++++++++- src/gallium/drivers/r300/r300_screen.c | 4 ++++ src/gallium/drivers/r300/r300_state.c | 18 ++++++------------ 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index f1d32764fd..9e813569e3 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -406,7 +406,14 @@ void r300_emit_fb_state(struct r300_context* r300, void* state) R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE); /* Set the number of colorbuffers. */ - OUT_CS_REG(R300_RB3D_CCTL, R300_RB3D_CCTL_NUM_MULTIWRITES(fb->nr_cbufs)); + if (fb->nr_cbufs > 1) { + OUT_CS_REG(R300_RB3D_CCTL, + R300_RB3D_CCTL_NUM_MULTIWRITES(fb->nr_cbufs) | + R300_RB3D_CCTL_INDEPENDENT_COLOR_CHANNEL_MASK_ENABLE | + R300_RB3D_CCTL_INDEPENDENT_COLORFORMAT_ENABLE_ENABLE); + } else { + OUT_CS_REG(R300_RB3D_CCTL, 0x0); + } /* Set up colorbuffers. */ for (i = 0; i < fb->nr_cbufs; i++) { diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index b8fbf03d3a..679a5644af 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -113,6 +113,9 @@ static int r300_get_param(struct pipe_screen* pscreen, int param) * ~ C. */ return 1; + case PIPE_CAP_DUAL_SOURCE_BLEND: + /* XXX need to figure out how to do it */ + return 0; case PIPE_CAP_ANISOTROPIC_FILTER: return 1; case PIPE_CAP_POINT_SPRITE: @@ -150,6 +153,7 @@ static int r300_get_param(struct pipe_screen* pscreen, int param) return 0; } case PIPE_CAP_INDEP_BLEND_ENABLE: + return 1; case PIPE_CAP_INDEP_BLEND_FUNC: return 0; default: diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 3cdcf94274..8295799553 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -288,18 +288,12 @@ static void* r300_create_blend_state(struct pipe_context* pipe, (state->logicop_func) << R300_RB3D_ROPCNTL_ROP_SHIFT; } - /* Color Channel Mask */ - if (state->rt[0].colormask & PIPE_MASK_R) { - blend->color_channel_mask |= RB3D_COLOR_CHANNEL_MASK_RED_MASK0; - } - if (state->rt[0].colormask & PIPE_MASK_G) { - blend->color_channel_mask |= RB3D_COLOR_CHANNEL_MASK_GREEN_MASK0; - } - if (state->rt[0].colormask & PIPE_MASK_B) { - blend->color_channel_mask |= RB3D_COLOR_CHANNEL_MASK_BLUE_MASK0; - } - if (state->rt[0].colormask & PIPE_MASK_A) { - blend->color_channel_mask |= RB3D_COLOR_CHANNEL_MASK_ALPHA_MASK0; + /* Color channel masks for all MRTs. */ + blend->color_channel_mask = state->rt[0].colormask; + if (state->independent_blend_enable) { + blend->color_channel_mask |= (state->rt[1].colormask << 4); + blend->color_channel_mask |= (state->rt[2].colormask << 8); + blend->color_channel_mask |= (state->rt[3].colormask << 12); } if (state->dither) { -- cgit v1.2.3 From 07fb52bcf6d8a1ff03c6d7b8c4bcae2fae57de05 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 28 Jan 2010 14:20:33 -0800 Subject: progs/glsl: Remove unnecessary header from samplers.c. --- progs/glsl/samplers.c | 1 - 1 file changed, 1 deletion(-) diff --git a/progs/glsl/samplers.c b/progs/glsl/samplers.c index 87dad5d857..8f26a5e329 100644 --- a/progs/glsl/samplers.c +++ b/progs/glsl/samplers.c @@ -41,7 +41,6 @@ #include #include #include "GL/glut.h" -#include "readtex.h" #include "shaderutil.h" -- cgit v1.2.3 From 77b1f2fbcfbb74c3df23c2bb6f8d6b27f0ddc6ed Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 28 Jan 2010 14:54:10 -0800 Subject: progs/glsl: Remove unused variable in bump.c. --- progs/glsl/bump.c | 1 - 1 file changed, 1 deletion(-) diff --git a/progs/glsl/bump.c b/progs/glsl/bump.c index e31afab939..784596448c 100644 --- a/progs/glsl/bump.c +++ b/progs/glsl/bump.c @@ -51,7 +51,6 @@ static GLint win = 0; static GLfloat xRot = 20.0f, yRot = 0.0f, zRot = 0.0f; static GLint tangentAttrib; -static GLint tangentAttribTex; static GLuint Texture; -- cgit v1.2.3 From bbb41153c23600f8ec25405add2341f770346911 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 28 Jan 2010 14:58:24 -0800 Subject: progs/glsl: Fix bump GLSL compilation error on Mac OS. --- progs/glsl/CH11-bumpmaptex.frag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/progs/glsl/CH11-bumpmaptex.frag b/progs/glsl/CH11-bumpmaptex.frag index b1f93b784d..b5dabb4c8a 100644 --- a/progs/glsl/CH11-bumpmaptex.frag +++ b/progs/glsl/CH11-bumpmaptex.frag @@ -17,7 +17,7 @@ uniform float BumpDensity; // = 16.0 uniform float BumpSize; // = 0.15 uniform float SpecularFactor; // = 0.5 -sampler2D Tex; +uniform sampler2D Tex; void main() { -- cgit v1.2.3 From d40070029f8f57b55c87e9310ab948342313a046 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 28 Jan 2010 15:11:39 -0800 Subject: progs/tests: Remove unnecessary headers. --- progs/tests/arraytexture.c | 1 - progs/tests/bug_3195.c | 1 - progs/tests/cva.c | 1 - progs/tests/mipgen.c | 2 -- progs/tests/mipmap_comp.c | 2 -- progs/tests/mipmap_comp_tests.c | 2 -- progs/tests/mipmap_view.c | 1 - progs/tests/no_s3tc.c | 1 - progs/tests/streaming_rect.c | 2 -- progs/tests/zcomp.c | 1 - 10 files changed, 14 deletions(-) diff --git a/progs/tests/arraytexture.c b/progs/tests/arraytexture.c index 28252a354b..e4e86b9b4c 100644 --- a/progs/tests/arraytexture.c +++ b/progs/tests/arraytexture.c @@ -36,7 +36,6 @@ #include #include #include -#include #if !defined(GL_EXT_texture_array) && !defined(GL_MESA_texture_array) # error "This demo requires enums for either GL_EXT_texture_array or GL_MESA_texture_array to build." diff --git a/progs/tests/bug_3195.c b/progs/tests/bug_3195.c index a075b94e37..3574c1f717 100644 --- a/progs/tests/bug_3195.c +++ b/progs/tests/bug_3195.c @@ -38,7 +38,6 @@ #include #include #include -#include #include "readtex.h" diff --git a/progs/tests/cva.c b/progs/tests/cva.c index 02d1dcba2e..b3e041c21e 100644 --- a/progs/tests/cva.c +++ b/progs/tests/cva.c @@ -17,7 +17,6 @@ #define GL_GLEXT_LEGACY #include #include -#include GLfloat verts[][4] = { { -0.5, -0.5, -2.0, 0.0 }, diff --git a/progs/tests/mipgen.c b/progs/tests/mipgen.c index 088f643215..48e52c9c31 100644 --- a/progs/tests/mipgen.c +++ b/progs/tests/mipgen.c @@ -48,8 +48,6 @@ #include #include -#include "readtex.h" - static GLfloat LodBias = 6.0; /* make smallest miplevel visible */ static GLuint texImage; diff --git a/progs/tests/mipmap_comp.c b/progs/tests/mipmap_comp.c index dd2232113b..122d157949 100644 --- a/progs/tests/mipmap_comp.c +++ b/progs/tests/mipmap_comp.c @@ -48,8 +48,6 @@ #include #include -#include "readtex.h" - #define SIZE 16 /* not larger then 16 */ static GLint BaseLevel = 0, MaxLevel = 9; diff --git a/progs/tests/mipmap_comp_tests.c b/progs/tests/mipmap_comp_tests.c index e865b30ad0..b93a5c6139 100644 --- a/progs/tests/mipmap_comp_tests.c +++ b/progs/tests/mipmap_comp_tests.c @@ -48,8 +48,6 @@ #include #include -#include "readtex.h" - #define SIZE 16 /* not larger then 16 */ static GLint BaseLevel = 0, MaxLevel ; diff --git a/progs/tests/mipmap_view.c b/progs/tests/mipmap_view.c index 808d348699..eb52197052 100644 --- a/progs/tests/mipmap_view.c +++ b/progs/tests/mipmap_view.c @@ -12,7 +12,6 @@ #include #include #include -#include #include "readtex.h" diff --git a/progs/tests/no_s3tc.c b/progs/tests/no_s3tc.c index 31cfb40b9d..c4132cd956 100644 --- a/progs/tests/no_s3tc.c +++ b/progs/tests/no_s3tc.c @@ -40,7 +40,6 @@ #include #include #include -#include static unsigned data[16]; diff --git a/progs/tests/streaming_rect.c b/progs/tests/streaming_rect.c index f65ac4ce36..3b016e55af 100644 --- a/progs/tests/streaming_rect.c +++ b/progs/tests/streaming_rect.c @@ -13,8 +13,6 @@ #include #include -#include "readtex.h" - #define ANIMATE 10 #define PBO 11 diff --git a/progs/tests/zcomp.c b/progs/tests/zcomp.c index 15e35f17b0..d6b9c07022 100644 --- a/progs/tests/zcomp.c +++ b/progs/tests/zcomp.c @@ -7,7 +7,6 @@ #include #include #include -#include "../util/showbuffer.c" static int Win; -- cgit v1.2.3 From fc4939bff917b520f0d428ce00219593df8b6d96 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 28 Jan 2010 15:39:11 -0800 Subject: egl: Remove unnecessary headers. --- src/egl/main/eglconfig.c | 1 - src/egl/main/eglconfigutil.c | 1 - src/egl/main/egldisplay.c | 1 - src/egl/main/eglglobals.c | 1 - src/egl/main/eglsurface.c | 1 - 5 files changed, 5 deletions(-) diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index a57aa33352..2db9b9401a 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -9,7 +9,6 @@ #include #include "eglconfig.h" #include "egldisplay.h" -#include "egldriver.h" #include "eglglobals.h" #include "egllog.h" diff --git a/src/egl/main/eglconfigutil.c b/src/egl/main/eglconfigutil.c index 9cf94b3c4a..ddb886c54d 100644 --- a/src/egl/main/eglconfigutil.c +++ b/src/egl/main/eglconfigutil.c @@ -7,7 +7,6 @@ #include #include #include "eglconfigutil.h" -#include "egllog.h" /** diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index b53cc59713..d7a8d14292 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -10,7 +10,6 @@ #include "egldisplay.h" #include "egldriver.h" #include "eglglobals.h" -#include "eglstring.h" #include "eglmutex.h" #include "egllog.h" diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c index 443d0f072c..9c4902621f 100644 --- a/src/egl/main/eglglobals.c +++ b/src/egl/main/eglglobals.c @@ -2,7 +2,6 @@ #include #include "eglglobals.h" #include "egldriver.h" -#include "egllog.h" #include "eglmutex.h" diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 89eb93d808..3219231ed2 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -9,7 +9,6 @@ #include "egldisplay.h" #include "eglcontext.h" #include "eglconfig.h" -#include "egldriver.h" #include "eglglobals.h" #include "egllog.h" #include "eglsurface.h" -- cgit v1.2.3 From 1a2f9d722e9492bad1f3d8c7fa99ff19af829b56 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 28 Jan 2010 15:54:57 -0800 Subject: llvmpipe: Remove unnecessary header. --- src/gallium/drivers/llvmpipe/lp_setup.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 50b07308c7..92baa980bc 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -37,7 +37,6 @@ #include "lp_setup.h" #include "lp_state.h" #include "draw/draw_context.h" -#include "draw/draw_private.h" #include "draw/draw_vertex.h" #include "pipe/p_shader_tokens.h" #include "util/u_format.h" -- cgit v1.2.3 From 7280c4c9fead8fac6bfc2fe765b8f434fd2a0ed0 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 28 Jan 2010 15:56:50 -0800 Subject: softpipe: Remove unnecessary header. --- src/gallium/drivers/softpipe/sp_setup.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c index f6c3a2b38b..ba1f0f0b2e 100644 --- a/src/gallium/drivers/softpipe/sp_setup.c +++ b/src/gallium/drivers/softpipe/sp_setup.c @@ -38,7 +38,6 @@ #include "sp_setup.h" #include "sp_state.h" #include "draw/draw_context.h" -#include "draw/draw_private.h" #include "draw/draw_vertex.h" #include "pipe/p_shader_tokens.h" #include "util/u_math.h" -- cgit v1.2.3 From 548b9c4ece5acd747b42241dce9db51d9c84dc11 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 28 Jan 2010 17:32:33 -0800 Subject: svga: Remove unnecessary headers. --- src/gallium/drivers/svga/svga_pipe_constants.c | 1 - src/gallium/drivers/svga/svga_pipe_vertex.c | 1 - 2 files changed, 2 deletions(-) diff --git a/src/gallium/drivers/svga/svga_pipe_constants.c b/src/gallium/drivers/svga/svga_pipe_constants.c index 93022f3cc5..9022f7c439 100644 --- a/src/gallium/drivers/svga/svga_pipe_constants.c +++ b/src/gallium/drivers/svga/svga_pipe_constants.c @@ -26,7 +26,6 @@ #include "pipe/p_inlines.h" #include "pipe/p_defines.h" #include "util/u_math.h" -#include "util/u_memory.h" #include "tgsi/tgsi_parse.h" #include "svga_context.h" diff --git a/src/gallium/drivers/svga/svga_pipe_vertex.c b/src/gallium/drivers/svga/svga_pipe_vertex.c index 0bf43fa900..724166a335 100644 --- a/src/gallium/drivers/svga/svga_pipe_vertex.c +++ b/src/gallium/drivers/svga/svga_pipe_vertex.c @@ -26,7 +26,6 @@ #include "pipe/p_inlines.h" #include "pipe/p_defines.h" #include "util/u_math.h" -#include "util/u_memory.h" #include "tgsi/tgsi_parse.h" #include "svga_screen.h" -- cgit v1.2.3 From df8273494ed9a92932a19fa3d19f5160dfe30881 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 28 Jan 2010 18:07:04 -0800 Subject: glu/sgi: Remove unnecessary headers. --- src/glu/sgi/libnurbs/internals/arc.cc | 1 - src/glu/sgi/libnurbs/internals/backend.cc | 1 - src/glu/sgi/libnurbs/internals/curvelist.cc | 1 - src/glu/sgi/libnurbs/internals/curvesub.cc | 1 - src/glu/sgi/libnurbs/internals/maplist.cc | 1 - src/glu/sgi/libnurbs/internals/patchlist.cc | 1 - src/glu/sgi/libnurbs/internals/quilt.cc | 2 -- src/glu/sgi/libnurbs/internals/renderhints.cc | 1 - src/glu/sgi/libnurbs/internals/trimregion.cc | 1 - src/glu/sgi/libutil/error.c | 2 -- src/glu/sgi/libutil/mipmap.c | 1 - 11 files changed, 13 deletions(-) diff --git a/src/glu/sgi/libnurbs/internals/arc.cc b/src/glu/sgi/libnurbs/internals/arc.cc index b85139de93..cd4c4048a0 100644 --- a/src/glu/sgi/libnurbs/internals/arc.cc +++ b/src/glu/sgi/libnurbs/internals/arc.cc @@ -43,7 +43,6 @@ #include "myassert.h" #include "arc.h" #include "bin.h" -#include "bezierarc.h" #include "pwlarc.h" #include "simplemath.h" diff --git a/src/glu/sgi/libnurbs/internals/backend.cc b/src/glu/sgi/libnurbs/internals/backend.cc index 88dc3f5168..27b41ebb29 100644 --- a/src/glu/sgi/libnurbs/internals/backend.cc +++ b/src/glu/sgi/libnurbs/internals/backend.cc @@ -46,7 +46,6 @@ #include "backend.h" #include "basiccrveval.h" #include "basicsurfeval.h" -#include "nurbsconsts.h" #define NOWIREFRAME diff --git a/src/glu/sgi/libnurbs/internals/curvelist.cc b/src/glu/sgi/libnurbs/internals/curvelist.cc index 872eb5816d..abfebb767f 100644 --- a/src/glu/sgi/libnurbs/internals/curvelist.cc +++ b/src/glu/sgi/libnurbs/internals/curvelist.cc @@ -43,7 +43,6 @@ #include "quilt.h" #include "curvelist.h" #include "curve.h" -#include "nurbsconsts.h" #include "types.h" Curvelist::Curvelist( Quilt *quilts, REAL pta, REAL ptb ) diff --git a/src/glu/sgi/libnurbs/internals/curvesub.cc b/src/glu/sgi/libnurbs/internals/curvesub.cc index f85acc269a..91f2ca8ce8 100644 --- a/src/glu/sgi/libnurbs/internals/curvesub.cc +++ b/src/glu/sgi/libnurbs/internals/curvesub.cc @@ -45,7 +45,6 @@ #include "backend.h" #include "quilt.h" #include "curvelist.h" -#include "curve.h" #include "nurbsconsts.h" /*-------------------------------------------------------------------------- diff --git a/src/glu/sgi/libnurbs/internals/maplist.cc b/src/glu/sgi/libnurbs/internals/maplist.cc index f944d1529e..e51a3e85d0 100644 --- a/src/glu/sgi/libnurbs/internals/maplist.cc +++ b/src/glu/sgi/libnurbs/internals/maplist.cc @@ -44,7 +44,6 @@ #include "nurbsconsts.h" #include "maplist.h" #include "mapdesc.h" -#include "backend.h" Maplist::Maplist( Backend& b ) : mapdescPool( sizeof( Mapdesc ), 10, "mapdesc pool" ), diff --git a/src/glu/sgi/libnurbs/internals/patchlist.cc b/src/glu/sgi/libnurbs/internals/patchlist.cc index 989d2dd00a..6a400ab6f7 100644 --- a/src/glu/sgi/libnurbs/internals/patchlist.cc +++ b/src/glu/sgi/libnurbs/internals/patchlist.cc @@ -44,7 +44,6 @@ #include "quilt.h" #include "patchlist.h" #include "patch.h" -#include "nurbsconsts.h" Patchlist::Patchlist( Quilt *quilts, REAL *pta, REAL *ptb ) { diff --git a/src/glu/sgi/libnurbs/internals/quilt.cc b/src/glu/sgi/libnurbs/internals/quilt.cc index 4fc58b7473..d16f4bfec0 100644 --- a/src/glu/sgi/libnurbs/internals/quilt.cc +++ b/src/glu/sgi/libnurbs/internals/quilt.cc @@ -44,9 +44,7 @@ #include "backend.h" #include "mapdesc.h" #include "flist.h" -#include "knotvector.h" #include "patchlist.h" -#include "math.h" //fglu_abs() #include "simplemath.h" //min() /* local preprocessor definitions */ diff --git a/src/glu/sgi/libnurbs/internals/renderhints.cc b/src/glu/sgi/libnurbs/internals/renderhints.cc index 7025f74f5b..4b347ebc7f 100644 --- a/src/glu/sgi/libnurbs/internals/renderhints.cc +++ b/src/glu/sgi/libnurbs/internals/renderhints.cc @@ -40,7 +40,6 @@ #include "glimports.h" #include "mystdio.h" #include "renderhints.h" -#include "defines.h" #include "nurbsconsts.h" diff --git a/src/glu/sgi/libnurbs/internals/trimregion.cc b/src/glu/sgi/libnurbs/internals/trimregion.cc index efe7893569..4aeb5eeac1 100644 --- a/src/glu/sgi/libnurbs/internals/trimregion.cc +++ b/src/glu/sgi/libnurbs/internals/trimregion.cc @@ -41,7 +41,6 @@ #include "myassert.h" #include "mystdio.h" #include "trimregion.h" -#include "backend.h" TrimRegion::TrimRegion( void ) { diff --git a/src/glu/sgi/libutil/error.c b/src/glu/sgi/libutil/error.c index e734818ed6..7212748450 100644 --- a/src/glu/sgi/libutil/error.c +++ b/src/glu/sgi/libutil/error.c @@ -31,8 +31,6 @@ #include "gluos.h" #include "gluint.h" #include -#include -#include struct token_string diff --git a/src/glu/sgi/libutil/mipmap.c b/src/glu/sgi/libutil/mipmap.c index d1fd5a7d72..8e63eaaad7 100644 --- a/src/glu/sgi/libutil/mipmap.c +++ b/src/glu/sgi/libutil/mipmap.c @@ -36,7 +36,6 @@ #include #include /* UINT_MAX */ #include -#include "gluint.h" typedef union { unsigned char ub[4]; -- cgit v1.2.3 From 7683271e63e4527fc72f309472181c743922e7e9 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Fri, 29 Jan 2010 10:22:22 +0000 Subject: another gcc 4.2.x check for mstackrealign --- scons/gallium.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scons/gallium.py b/scons/gallium.py index 03856207ed..ac68bd604c 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -276,8 +276,11 @@ def generate(env): # instead. ccflags += [ '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics - '-mstackrealign', # ensure stack is aligned ] + if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2'): + ccflags += [ + '-mstackrealign', # ensure stack is aligned + ] if env['machine'] == 'x86_64': ccflags += ['-m64'] # See also: -- cgit v1.2.3 From 3cea5525d0b59c7dadb4be634cc244948cd634e6 Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Thu, 28 Jan 2010 23:17:27 +0100 Subject: mesa: don't expose GL_ARB_fragment_coord_conventions until the GLSL part is done Exposing it was incorrect, as the GLSL part of the extension is missing. We still keep the ARB_fragment_coord_conventions field, so that the ARBfp parser can know whether to accept or reject the keywords. --- src/mesa/main/extensions.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 73be24d80c..e1320224a8 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -50,7 +50,8 @@ static const struct { { OFF, "GL_ARB_depth_clamp", F(ARB_depth_clamp) }, { ON, "GL_ARB_draw_buffers", F(ARB_draw_buffers) }, { OFF, "GL_ARB_draw_elements_base_vertex", F(ARB_draw_elements_base_vertex) }, - { OFF, "GL_ARB_fragment_coord_conventions", F(ARB_fragment_coord_conventions) }, + /* TODO: uncomment the following line once GLSL layout(...) support is implemented */ + /* { OFF, "GL_ARB_fragment_coord_conventions", F(ARB_fragment_coord_conventions) }, */ { OFF, "GL_ARB_fragment_program", F(ARB_fragment_program) }, { OFF, "GL_ARB_fragment_program_shadow", F(ARB_fragment_program_shadow) }, { OFF, "GL_ARB_fragment_shader", F(ARB_fragment_shader) }, -- cgit v1.2.3 From 73317139a4f78126af0dc4ddaef8206352740727 Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Thu, 21 Jan 2010 05:36:14 +0100 Subject: tgsi: add properties for fragment coord conventions (v3) Changes in v3: - Documented the new properties - Added comments for property values - Rebased to current master Changes in v2: - Caps are added in a separate, subsequent patch This adds two TGSI fragment program properties that indicate the fragment coord conventions. The properties behave as described in the extension spec for GL_ARB_fragment_coord_conventions, but the default origin in upper left instead of lower left as in OpenGL. The syntax is: PROPERTY FS_COORD_ORIGIN [UPPER_LEFT|LOWER_LEFT] PROPERTY FS_COORD_PIXEL_CENTER [HALF_INTEGER|INTEGER] The names have been chosen for consistency with the GS properties and the OpenGL extension spec. The defaults are of course the previously assumed conventions: UPPER_LEFT and HALF_INTEGER. --- src/gallium/auxiliary/tgsi/tgsi_dump.c | 22 ++++++++++- src/gallium/auxiliary/tgsi/tgsi_text.c | 63 +++++++++++++++++++++++++++++- src/gallium/auxiliary/tgsi/tgsi_ureg.c | 32 +++++++++++++++ src/gallium/auxiliary/tgsi/tgsi_ureg.h | 7 ++++ src/gallium/docs/source/tgsi.rst | 47 ++++++++++++++++++++-- src/gallium/include/pipe/p_shader_tokens.h | 10 ++++- 6 files changed, 175 insertions(+), 6 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c index 5472466eb6..dd36555875 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_dump.c +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c @@ -159,7 +159,9 @@ static const char *property_names[] = { "GS_INPUT_PRIMITIVE", "GS_OUTPUT_PRIMITIVE", - "GS_MAX_OUTPUT_VERTICES" + "GS_MAX_OUTPUT_VERTICES", + "FS_COORD_ORIGIN", + "FS_COORD_PIXEL_CENTER" }; static const char *primitive_names[] = @@ -176,6 +178,18 @@ static const char *primitive_names[] = "POLYGON" }; +static const char *fs_coord_origin_names[] = +{ + "UPPER_LEFT", + "LOWER_LEFT" +}; + +static const char *fs_coord_pixel_center_names[] = +{ + "HALF_INTEGER", + "INTEGER" +}; + static void _dump_register_dst( @@ -366,6 +380,12 @@ iter_property( case TGSI_PROPERTY_GS_OUTPUT_PRIM: ENM(prop->u[i].Data, primitive_names); break; + case TGSI_PROPERTY_FS_COORD_ORIGIN: + ENM(prop->u[i].Data, fs_coord_origin_names); + break; + case TGSI_PROPERTY_FS_COORD_PIXEL_CENTER: + ENM(prop->u[i].Data, fs_coord_pixel_center_names); + break; default: SID( prop->u[i].Data ); break; diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c index f74b56bfb5..96be353e26 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_text.c +++ b/src/gallium/auxiliary/tgsi/tgsi_text.c @@ -1129,7 +1129,9 @@ static const char *property_names[] = { "GS_INPUT_PRIMITIVE", "GS_OUTPUT_PRIMITIVE", - "GS_MAX_OUTPUT_VERTICES" + "GS_MAX_OUTPUT_VERTICES", + "FS_COORD_ORIGIN", + "FS_COORD_PIXEL_CENTER" }; static const char *primitive_names[] = @@ -1146,6 +1148,19 @@ static const char *primitive_names[] = "POLYGON" }; +static const char *fs_coord_origin_names[] = +{ + "UPPER_LEFT", + "LOWER_LEFT" +}; + +static const char *fs_coord_pixel_center_names[] = +{ + "HALF_INTEGER", + "INTEGER" +}; + + static boolean parse_primitive( const char **pcur, uint *primitive ) { @@ -1163,6 +1178,40 @@ parse_primitive( const char **pcur, uint *primitive ) return FALSE; } +static boolean +parse_fs_coord_origin( const char **pcur, uint *fs_coord_origin ) +{ + uint i; + + for (i = 0; i < sizeof(fs_coord_origin_names) / sizeof(fs_coord_origin_names[0]); i++) { + const char *cur = *pcur; + + if (str_match_no_case( &cur, fs_coord_origin_names[i])) { + *fs_coord_origin = i; + *pcur = cur; + return TRUE; + } + } + return FALSE; +} + +static boolean +parse_fs_coord_pixel_center( const char **pcur, uint *fs_coord_pixel_center ) +{ + uint i; + + for (i = 0; i < sizeof(fs_coord_pixel_center_names) / sizeof(fs_coord_pixel_center_names[0]); i++) { + const char *cur = *pcur; + + if (str_match_no_case( &cur, fs_coord_pixel_center_names[i])) { + *fs_coord_pixel_center = i; + *pcur = cur; + return TRUE; + } + } + return FALSE; +} + static boolean parse_property( struct translate_ctx *ctx ) { @@ -1204,6 +1253,18 @@ static boolean parse_property( struct translate_ctx *ctx ) ctx->implied_array_size = u_vertices_per_prim(values[0]); } break; + case TGSI_PROPERTY_FS_COORD_ORIGIN: + if (!parse_fs_coord_origin(&ctx->cur, &values[0] )) { + report_error( ctx, "Unknown coord origin as property: must be UPPER_LEFT or LOWER_LEFT!" ); + return FALSE; + } + break; + case TGSI_PROPERTY_FS_COORD_PIXEL_CENTER: + if (!parse_fs_coord_pixel_center(&ctx->cur, &values[0] )) { + report_error( ctx, "Unknown coord pixel center as property: must be HALF_INTEGER or INTEGER!" ); + return FALSE; + } + break; default: if (!parse_uint(&ctx->cur, &values[0] )) { report_error( ctx, "Expected unsigned integer as property!" ); diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index f2610d0764..0ae46785bb 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -142,6 +142,8 @@ struct ureg_program unsigned property_gs_input_prim; unsigned property_gs_output_prim; unsigned property_gs_max_vertices; + unsigned char property_fs_coord_origin; /* = TGSI_FS_COORD_ORIGIN_* */ + unsigned char property_fs_coord_pixel_center; /* = TGSI_FS_COORD_PIXEL_CENTER_* */ unsigned nr_addrs; unsigned nr_preds; @@ -265,6 +267,20 @@ ureg_property_gs_max_vertices(struct ureg_program *ureg, ureg->property_gs_max_vertices = max_vertices; } +void +ureg_property_fs_coord_origin(struct ureg_program *ureg, + unsigned fs_coord_origin) +{ + ureg->property_fs_coord_origin = fs_coord_origin; +} + +void +ureg_property_fs_coord_pixel_center(struct ureg_program *ureg, + unsigned fs_coord_pixel_center) +{ + ureg->property_fs_coord_pixel_center = fs_coord_pixel_center; +} + struct ureg_src @@ -1202,6 +1218,22 @@ static void emit_decls( struct ureg_program *ureg ) ureg->property_gs_max_vertices); } + if (ureg->property_fs_coord_origin) { + assert(ureg->processor == TGSI_PROCESSOR_FRAGMENT); + + emit_property(ureg, + TGSI_PROPERTY_FS_COORD_ORIGIN, + ureg->property_fs_coord_origin); + } + + if (ureg->property_fs_coord_pixel_center) { + assert(ureg->processor == TGSI_PROCESSOR_FRAGMENT); + + emit_property(ureg, + TGSI_PROPERTY_FS_COORD_PIXEL_CENTER, + ureg->property_fs_coord_pixel_center); + } + if (ureg->processor == TGSI_PROCESSOR_VERTEX) { for (i = 0; i < UREG_MAX_INPUT; i++) { if (ureg->vs_inputs[i/32] & (1 << (i%32))) { diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h index 2ac00deca1..e25f35c6dc 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h @@ -136,6 +136,13 @@ void ureg_property_gs_max_vertices(struct ureg_program *ureg, unsigned max_vertices); +void +ureg_property_fs_coord_origin(struct ureg_program *ureg, + unsigned fs_coord_origin); + +void +ureg_property_fs_coord_pixel_center(struct ureg_program *ureg, + unsigned fs_coord_pixel_center); /*********************************************************************** * Build shader declarations: diff --git a/src/gallium/docs/source/tgsi.rst b/src/gallium/docs/source/tgsi.rst index 2c34a6bae5..3e702ceeda 100644 --- a/src/gallium/docs/source/tgsi.rst +++ b/src/gallium/docs/source/tgsi.rst @@ -1319,9 +1319,8 @@ are the Cartesian coordinates, and ``w`` is the homogenous coordinate and used for the perspective divide, if enabled. As a vertex shader output, position should be scaled to the viewport. When -used in fragment shaders, position will --- - -XXX --- wait a minute. Should position be in [0,1] for x and y? +used in fragment shaders, position will be in window coordinates. The convention +used depends on the FS_COORD_ORIGIN and FS_COORD_PIXEL_CENTER properties. XXX additionally, is there a way to configure the perspective divide? it's accelerated on most chipsets AFAIK... @@ -1400,3 +1399,45 @@ TGSI_SEMANTIC_EDGEFLAG """""""""""""""""""""" XXX no clue + + +Properties +^^^^^^^^^^^^^^^^^^^^^^^^ + + + Properties are general directives that apply to the whole TGSI program. + +FS_COORD_ORIGIN +""""""""""""""" + +Specifies the fragment shader TGSI_SEMANTIC_POSITION coordinate origin. +The default value is UPPER_LEFT. + +If UPPER_LEFT, the position will be (0,0) at the upper left corner and +increase downward and rightward. +If LOWER_LEFT, the position will be (0,0) at the lower left corner and +increase upward and rightward. + +OpenGL defaults to LOWER_LEFT, and is configurable with the +GL_ARB_fragment_coord_conventions extension. + +DirectX 9/10 use UPPER_LEFT. + +FS_COORD_PIXEL_CENTER +""""""""""""""""""""" + +Specifies the fragment shader TGSI_SEMANTIC_POSITION pixel center convention. +The default value is HALF_INTEGER. + +If HALF_INTEGER, the fractionary part of the position will be 0.5 +If INTEGER, the fractionary part of the position will be 0.0 + +Note that this does not affect the set of fragments generated by +rasterization, which is instead controlled by gl_rasterization_rules in the +rasterizer. + +OpenGL defaults to HALF_INTEGER, and is configurable with the +GL_ARB_fragment_coord_conventions extension. + +DirectX 9 uses INTEGER. +DirectX 10 uses HALF_INTEGER. diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h index b47f4971f1..21581a4674 100644 --- a/src/gallium/include/pipe/p_shader_tokens.h +++ b/src/gallium/include/pipe/p_shader_tokens.h @@ -170,7 +170,9 @@ union tgsi_immediate_data #define TGSI_PROPERTY_GS_INPUT_PRIM 0 #define TGSI_PROPERTY_GS_OUTPUT_PRIM 1 #define TGSI_PROPERTY_GS_MAX_VERTICES 2 -#define TGSI_PROPERTY_COUNT 3 +#define TGSI_PROPERTY_FS_COORD_ORIGIN 3 +#define TGSI_PROPERTY_FS_COORD_PIXEL_CENTER 4 +#define TGSI_PROPERTY_COUNT 5 struct tgsi_property { unsigned Type : 4; /**< TGSI_TOKEN_TYPE_PROPERTY */ @@ -179,6 +181,12 @@ struct tgsi_property { unsigned Padding : 12; }; +#define TGSI_FS_COORD_ORIGIN_UPPER_LEFT 0 +#define TGSI_FS_COORD_ORIGIN_LOWER_LEFT 1 + +#define TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER 0 +#define TGSI_FS_COORD_PIXEL_CENTER_INTEGER 1 + struct tgsi_property_data { unsigned Data; }; -- cgit v1.2.3 From 6c403750d6515f8b2f333d995c87676016e1883d Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Thu, 21 Jan 2010 05:36:14 +0100 Subject: tgsi: add caps for fragment coord conventions (v3) Changes in v3: - Renumber caps to accomodate caps to add to master in the meantime - Document caps - Add unsupported caps to *_screen.c too Changes in v2: - Split for properties patch - Use positive caps instead of negative caps This adds 4 caps to indicate support of each of the fragment coord conventions. All drivers are also modifed to add the appropriate caps. Some drivers were incorrectly using non-Gallium-default conventions, and caps for them have them set so that they will behave correctly after the later state tracker patches. This drivers are softpipe/llvmpipe (uses integer rather than half integer) and pre-nv50 Nouveau (uses lower left rather than upper left). Other drivers might be broken. With this patchset, fixing them is only a matter of exposing the appropriate caps that match the behavior of the existing code. Drivers are encouraged to support all conventions themselves for better performance, and this feature is added to softpipe in a later patch. --- src/gallium/docs/source/screen.rst | 8 ++++++++ src/gallium/drivers/cell/ppu/cell_screen.c | 6 ++++++ src/gallium/drivers/i915/i915_screen.c | 6 ++++++ src/gallium/drivers/i965/brw_screen.c | 6 ++++++ src/gallium/drivers/llvmpipe/lp_screen.c | 6 ++++++ src/gallium/drivers/nv04/nv04_screen.c | 6 ++++++ src/gallium/drivers/nv10/nv10_screen.c | 6 ++++++ src/gallium/drivers/nv20/nv20_screen.c | 6 ++++++ src/gallium/drivers/nv30/nv30_screen.c | 6 ++++++ src/gallium/drivers/nv40/nv40_screen.c | 6 ++++++ src/gallium/drivers/nv50/nv50_screen.c | 6 ++++++ src/gallium/drivers/r300/r300_screen.c | 6 ++++++ src/gallium/drivers/softpipe/sp_screen.c | 6 ++++++ src/gallium/drivers/svga/svga_screen.c | 7 +++++++ src/gallium/include/pipe/p_defines.h | 4 ++++ 15 files changed, 91 insertions(+) diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index f2421c74ae..0507b81627 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -57,6 +57,14 @@ The integer capabilities: only permit binding one constant buffer per shader, and the shaders will not permit two-dimensional access to constants. * ``MAX_CONST_BUFFER_SIZE``: Maximum byte size of a single constant buffer. +* ``PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT``: Whether the TGSI property + FS_COORD_ORIGIN with value UPPER_LEFT is supported +* ``PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT``: Whether the TGSI property + FS_COORD_ORIGIN with value LOWER_LEFT is supported +* ``PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER``: Whether the TGSI + property FS_COORD_PIXEL_CENTER with value HALF_INTEGER is supported +* ``PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER``: Whether the TGSI + property FS_COORD_PIXEL_CENTER with value INTEGER is supported The floating-point capabilities: diff --git a/src/gallium/drivers/cell/ppu/cell_screen.c b/src/gallium/drivers/cell/ppu/cell_screen.c index d185c6b849..37b04396b3 100644 --- a/src/gallium/drivers/cell/ppu/cell_screen.c +++ b/src/gallium/drivers/cell/ppu/cell_screen.c @@ -86,6 +86,12 @@ cell_get_param(struct pipe_screen *screen, int param) return 0; /* XXX to do */ case PIPE_CAP_TGSI_CONT_SUPPORTED: return 1; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: + return 1; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: + return 0; default: return 0; } diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c index d4ee8f5339..7b8d66b8aa 100644 --- a/src/gallium/drivers/i915/i915_screen.c +++ b/src/gallium/drivers/i915/i915_screen.c @@ -117,6 +117,12 @@ i915_get_param(struct pipe_screen *screen, int param) return 8; /* max 128x128x128 */ case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: return 11; /* max 1024x1024 */ + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: + return 1; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: + return 0; default: return 0; } diff --git a/src/gallium/drivers/i965/brw_screen.c b/src/gallium/drivers/i965/brw_screen.c index a3728fb16e..a8f9892d71 100644 --- a/src/gallium/drivers/i965/brw_screen.c +++ b/src/gallium/drivers/i965/brw_screen.c @@ -175,6 +175,12 @@ brw_get_param(struct pipe_screen *screen, int param) return 8; /* max 128x128x128 */ case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: return 11; /* max 1024x1024 */ + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: + return 1; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: + return 0; default: return 0; } diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index f04c0320ba..902009d90b 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -114,6 +114,12 @@ llvmpipe_get_param(struct pipe_screen *screen, int param) return 0; case PIPE_CAP_INDEP_BLEND_FUNC: return 0; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: + return 1; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: + return 0; default: return 0; } diff --git a/src/gallium/drivers/nv04/nv04_screen.c b/src/gallium/drivers/nv04/nv04_screen.c index 4eba772575..97538964af 100644 --- a/src/gallium/drivers/nv04/nv04_screen.c +++ b/src/gallium/drivers/nv04/nv04_screen.c @@ -49,6 +49,12 @@ nv04_screen_get_param(struct pipe_screen *screen, int param) return 0; case PIPE_CAP_INDEP_BLEND_FUNC: return 0; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: + return 1; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: + return 0; default: NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param); return 0; diff --git a/src/gallium/drivers/nv10/nv10_screen.c b/src/gallium/drivers/nv10/nv10_screen.c index 2dabc4509f..4e6bc12994 100644 --- a/src/gallium/drivers/nv10/nv10_screen.c +++ b/src/gallium/drivers/nv10/nv10_screen.c @@ -44,6 +44,12 @@ nv10_screen_get_param(struct pipe_screen *screen, int param) return 0; case PIPE_CAP_INDEP_BLEND_FUNC: return 0; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: + return 1; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: + return 0; default: NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param); return 0; diff --git a/src/gallium/drivers/nv20/nv20_screen.c b/src/gallium/drivers/nv20/nv20_screen.c index 7782cbe3a8..df9401bcce 100644 --- a/src/gallium/drivers/nv20/nv20_screen.c +++ b/src/gallium/drivers/nv20/nv20_screen.c @@ -44,6 +44,12 @@ nv20_screen_get_param(struct pipe_screen *screen, int param) return 0; case PIPE_CAP_INDEP_BLEND_FUNC: return 0; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: + return 1; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: + return 0; default: NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param); return 0; diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c index 8f8f3ea1a9..ee83ec5676 100644 --- a/src/gallium/drivers/nv30/nv30_screen.c +++ b/src/gallium/drivers/nv30/nv30_screen.c @@ -71,6 +71,12 @@ nv30_screen_get_param(struct pipe_screen *pscreen, int param) return 0; case PIPE_CAP_INDEP_BLEND_FUNC: return 0; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: + return 1; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: + return 0; default: NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param); return 0; diff --git a/src/gallium/drivers/nv40/nv40_screen.c b/src/gallium/drivers/nv40/nv40_screen.c index 4eab5daa80..b1a7343b40 100644 --- a/src/gallium/drivers/nv40/nv40_screen.c +++ b/src/gallium/drivers/nv40/nv40_screen.c @@ -56,6 +56,12 @@ nv40_screen_get_param(struct pipe_screen *pscreen, int param) return 0; case PIPE_CAP_INDEP_BLEND_FUNC: return 0; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: + return 1; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: + return 0; default: NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param); return 0; diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 6af9700c1a..c4465a228c 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -139,6 +139,12 @@ nv50_screen_get_param(struct pipe_screen *pscreen, int param) return 1; case PIPE_CAP_INDEP_BLEND_FUNC: return 0; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: + return 1; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: + return 0; default: NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param); return 0; diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index 679a5644af..f311284d15 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -156,6 +156,12 @@ static int r300_get_param(struct pipe_screen* pscreen, int param) return 1; case PIPE_CAP_INDEP_BLEND_FUNC: return 0; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: + return 1; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: + return 0; default: debug_printf("r300: Implementation error: Bad param %d\n", param); diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index b2841f4103..410fabf490 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -99,6 +99,12 @@ softpipe_get_param(struct pipe_screen *screen, int param) return 1; case PIPE_CAP_INDEP_BLEND_FUNC: return 1; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: + return 1; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: + return 0; default: return 0; } diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index cd1ed7bac8..c9db9ac874 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -144,6 +144,13 @@ svga_get_paramf(struct pipe_screen *screen, int param) case PIPE_CAP_BLEND_EQUATION_SEPARATE: /* req. for GL 1.5 */ return 1; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: + return 1; + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: + return 0; + default: return 0; } diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index b28441dca9..63ba3119b8 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -409,6 +409,10 @@ enum pipe_transfer_usage { #define PIPE_CAP_MAX_CONST_BUFFER_SIZE 33 /*< In bytes */ #define PIPE_CAP_INDEP_BLEND_ENABLE 34 /*< blend enables and write masks per rendertarget */ #define PIPE_CAP_INDEP_BLEND_FUNC 35 /*< different blend funcs per rendertarget */ +#define PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT 36 +#define PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT 37 +#define PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER 38 +#define PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER 39 /** -- cgit v1.2.3 From 62c673b6ac65d27ed83acc92434874b45f75db5c Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Thu, 21 Jan 2010 06:37:48 +0100 Subject: st/mesa: Gallium support for ARB_fragment_coord_conventions (v4) Changes in v4; - Implemented Brian Paul's style suggestions Changes in v3: - Use positive caps instead of negative ones Changes in v2: - Updated formatting The state tracker will use the TGSI convention properties if the hardware exposes the appropriate capability, and otherwise adjust WPOS itself. This will also fix some drivers that were previously broken due to their incorrect, inadvertent, use of conventions other than upper_left+half_integer. --- src/mesa/state_tracker/st_extensions.c | 1 + src/mesa/state_tracker/st_mesa_to_tgsi.c | 74 ++++++++++++++++++++++++++++++-- 2 files changed, 72 insertions(+), 3 deletions(-) diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 31c03c0783..f2a62f9b69 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -147,6 +147,7 @@ void st_init_extensions(struct st_context *st) * Extensions that are supported by all Gallium drivers: */ ctx->Extensions.ARB_copy_buffer = GL_TRUE; + ctx->Extensions.ARB_fragment_coord_conventions = GL_TRUE; ctx->Extensions.ARB_fragment_program = GL_TRUE; ctx->Extensions.ARB_map_buffer_range = GL_TRUE; ctx->Extensions.ARB_multisample = GL_TRUE; diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 05b56c9b58..4aed2df8c3 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -34,8 +34,10 @@ #include "pipe/p_compiler.h" #include "pipe/p_shader_tokens.h" #include "pipe/p_state.h" +#include "pipe/p_context.h" #include "tgsi/tgsi_ureg.h" #include "st_mesa_to_tgsi.h" +#include "st_context.h" #include "shader/prog_instruction.h" #include "shader/prog_parameter.h" #include "shader/prog_print.h" @@ -665,6 +667,22 @@ compile_instruction( } } +/** + * Emit the TGSI instructions to adjust the WPOS pixel center convention + */ +static void +emit_adjusted_wpos( struct st_translate *t, + const struct gl_program *program, GLfloat value) +{ + struct ureg_program *ureg = t->ureg; + struct ureg_dst wpos_temp = ureg_DECL_temporary(ureg); + struct ureg_src wpos_input = t->inputs[t->inputMapping[FRAG_ATTRIB_WPOS]]; + + ureg_ADD(ureg, ureg_writemask(wpos_temp, TGSI_WRITEMASK_X | TGSI_WRITEMASK_Y), + wpos_input, ureg_imm1f(ureg, value)); + + t->inputs[t->inputMapping[FRAG_ATTRIB_WPOS]] = ureg_src(wpos_temp); +} /** * Emit the TGSI instructions for inverting the WPOS y coordinate. @@ -690,12 +708,17 @@ emit_inverted_wpos( struct st_translate *t, winSizeState); struct ureg_src winsize = ureg_DECL_constant( ureg, winHeightConst ); - struct ureg_dst wpos_temp = ureg_DECL_temporary( ureg ); + struct ureg_dst wpos_temp; struct ureg_src wpos_input = t->inputs[t->inputMapping[FRAG_ATTRIB_WPOS]]; /* MOV wpos_temp, input[wpos] */ - ureg_MOV( ureg, wpos_temp, wpos_input ); + if (wpos_input.File == TGSI_FILE_TEMPORARY) + wpos_temp = ureg_dst(wpos_input); + else { + wpos_temp = ureg_DECL_temporary( ureg ); + ureg_MOV( ureg, wpos_temp, wpos_input ); + } /* SUB wpos_temp.y, winsize_const, wpos_input */ @@ -801,6 +824,7 @@ st_translate_mesa_program( * Declare input attributes. */ if (procType == TGSI_PROCESSOR_FRAGMENT) { + struct gl_fragment_program* fp = (struct gl_fragment_program*)program; for (i = 0; i < numInputs; i++) { t->inputs[i] = ureg_DECL_fs_input(ureg, inputSemanticName[i], @@ -812,7 +836,51 @@ st_translate_mesa_program( /* Must do this after setting up t->inputs, and before * emitting constant references, below: */ - emit_inverted_wpos( t, program ); + struct pipe_screen* pscreen = st_context(ctx)->pipe->screen; + boolean invert = FALSE; + + if (fp->OriginUpperLeft) { + if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT)) { + } + else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT)) { + ureg_property_fs_coord_origin(ureg, TGSI_FS_COORD_ORIGIN_LOWER_LEFT); + invert = TRUE; + } + else + assert(0); + } + else { + if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT)) + ureg_property_fs_coord_origin(ureg, TGSI_FS_COORD_ORIGIN_LOWER_LEFT); + else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT)) + invert = TRUE; + else + assert(0); + } + + if (fp->PixelCenterInteger) { + if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER)) + ureg_property_fs_coord_pixel_center(ureg, TGSI_FS_COORD_PIXEL_CENTER_INTEGER); + else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER)) + emit_adjusted_wpos(t, program, invert ? 0.5f : -0.5f); + else + assert(0); + } + else { + if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER)) { + } + else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER)) { + ureg_property_fs_coord_pixel_center(ureg, TGSI_FS_COORD_PIXEL_CENTER_INTEGER); + emit_adjusted_wpos(t, program, invert ? -0.5f : 0.5f); + } + else + assert(0); + } + + /* we invert after adjustment so that we avoid the MOV to temporary, + * and reuse the adjustment ADD instead */ + if (invert) + emit_inverted_wpos(t, program); } if (program->InputsRead & FRAG_BIT_FACE) { -- cgit v1.2.3 From b2299d80b4278b8b6553d4e4da4d40d37881d76e Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Thu, 21 Jan 2010 05:38:45 +0100 Subject: softpipe: support all TGSI fragment coord conventions (v4) Changes in v4: - Rebase and modify for changes in previous patches Changes in v3: - Use positive caps instead of negative caps Changes in v2: - Now takes the fragment convention directly from the fragment shader Adds internal support for all fragment coord conventions to softpipe. This patch is not required for use with the current state trackers, but it allows softpipe to run any TGSI program and enhances performance. --- src/gallium/drivers/softpipe/sp_screen.c | 5 ++--- src/gallium/drivers/softpipe/sp_setup.c | 11 +++++++---- src/gallium/drivers/softpipe/sp_state.h | 3 +++ src/gallium/drivers/softpipe/sp_state_fs.c | 8 ++++++++ 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index 410fabf490..714a1cf534 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -100,11 +100,10 @@ softpipe_get_param(struct pipe_screen *screen, int param) case PIPE_CAP_INDEP_BLEND_FUNC: return 1; case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: - case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: - return 1; case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: - return 0; + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: + return 1; default: return 0; } diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c index ba1f0f0b2e..bb1bff581c 100644 --- a/src/gallium/drivers/softpipe/sp_setup.c +++ b/src/gallium/drivers/softpipe/sp_setup.c @@ -504,21 +504,24 @@ static void tri_persp_coeff( struct setup_context *setup, /** * Special coefficient setup for gl_FragCoord. - * X and Y are trivial, though Y has to be inverted for OpenGL. + * X and Y are trivial, though Y may have to be inverted for OpenGL. * Z and W are copied from posCoef which should have already been computed. * We could do a bit less work if we'd examine gl_FragCoord's swizzle mask. */ static void setup_fragcoord_coeff(struct setup_context *setup, uint slot) { + struct sp_fragment_shader* spfs = setup->softpipe->fs; /*X*/ - setup->coef[slot].a0[0] = 0; + setup->coef[slot].a0[0] = spfs->pixel_center_integer ? 0.0 : 0.5; setup->coef[slot].dadx[0] = 1.0; setup->coef[slot].dady[0] = 0.0; /*Y*/ - setup->coef[slot].a0[1] = 0.0; + setup->coef[slot].a0[1] = + (spfs->origin_lower_left ? setup->softpipe->framebuffer.height : 0) + + (spfs->pixel_center_integer ? 0.0 : 0.5); setup->coef[slot].dadx[1] = 0.0; - setup->coef[slot].dady[1] = 1.0; + setup->coef[slot].dady[1] = spfs->origin_lower_left ? -1.0 : 1.0; /*Z*/ setup->coef[slot].a0[2] = setup->posCoef.a0[2]; setup->coef[slot].dadx[2] = setup->posCoef.dadx[2]; diff --git a/src/gallium/drivers/softpipe/sp_state.h b/src/gallium/drivers/softpipe/sp_state.h index 7f244c4fd4..a83cae7361 100644 --- a/src/gallium/drivers/softpipe/sp_state.h +++ b/src/gallium/drivers/softpipe/sp_state.h @@ -68,6 +68,9 @@ struct sp_fragment_shader { struct tgsi_shader_info info; + boolean origin_lower_left; /**< fragment shader uses lower left position origin? */ + boolean pixel_center_integer; /**< fragment shader uses integer pixel center? */ + void (*prepare)( const struct sp_fragment_shader *shader, struct tgsi_exec_machine *machine, struct tgsi_sampler **samplers); diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c index 04bdcaacc2..de3edde976 100644 --- a/src/gallium/drivers/softpipe/sp_state_fs.c +++ b/src/gallium/drivers/softpipe/sp_state_fs.c @@ -44,6 +44,7 @@ softpipe_create_fs_state(struct pipe_context *pipe, { struct softpipe_context *softpipe = softpipe_context(pipe); struct sp_fragment_shader *state; + unsigned i; /* debug */ if (softpipe->dump_fs) @@ -60,6 +61,13 @@ softpipe_create_fs_state(struct pipe_context *pipe, /* get/save the summary info for this shader */ tgsi_scan_shader(templ->tokens, &state->info); + for (i = 0; i < state->info.num_properties; ++i) { + if (state->info.properties[i].name == TGSI_PROPERTY_FS_COORD_ORIGIN) + state->origin_lower_left = state->info.properties[i].data[0]; + else if (state->info.properties[i].name == TGSI_PROPERTY_FS_COORD_PIXEL_CENTER) + state->pixel_center_integer = state->info.properties[i].data[0]; + } + return state; } -- cgit v1.2.3 From 4886f677ecf121c863f8f65a846284ab9d26cbea Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 29 Jan 2010 08:31:48 -0700 Subject: mesa: Warn when indices are out of bounds, but do not skip the draw in debug builds. The driver (or preferably the hardware) should handle out of bounds indices. If there are problems then it's better to detect those in the debug builds. (cherry picked from commit e3257912e006120f6ab611e77005eed1a464030a) --- src/mesa/vbo/vbo_exec_array.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index d6452cb664..392da43c5e 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -722,8 +722,7 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode, #ifdef DEBUG /* 'end' was out of bounds, but now let's check the actual array - * indexes to see if any of them are out of bounds. If so, warn - * and skip the draw to avoid potential segfault, etc. + * indexes to see if any of them are out of bounds. */ { GLuint max = _mesa_max_buffer_index(ctx, count, type, indices, @@ -740,7 +739,6 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode, ctx->Array.ElementArrayBufferObj->Name, ctx->Array.ElementArrayBufferObj->Size); } - return; } /* XXX we could also find the min index and compare to 'start' * to see if start is correct. But it's more likely to get the -- cgit v1.2.3 From 81cca6d4538bdde1661ce868af2a5de47cd251ab Mon Sep 17 00:00:00 2001 From: Rodolfo Ribeiro Gomes Date: Fri, 29 Jan 2010 08:36:47 -0700 Subject: glx: fix possible memory leaks in dri2CreateScreen() Original patch fixed up by Brian Paul. --- src/glx/x11/dri2_glx.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/glx/x11/dri2_glx.c b/src/glx/x11/dri2_glx.c index 7b0c52b50d..2228958144 100644 --- a/src/glx/x11/dri2_glx.c +++ b/src/glx/x11/dri2_glx.c @@ -504,8 +504,10 @@ dri2CreateScreen(__GLXscreenConfigs * psc, int screen, psc->ext_list_first_time = GL_TRUE; if (!DRI2Connect(psc->dpy, RootWindow(psc->dpy, screen), - &driverName, &deviceName)) + &driverName, &deviceName)) { + XFree(psp); return NULL; + } psc->driver = driOpenDriver(driverName); if (psc->driver == NULL) { @@ -534,17 +536,17 @@ dri2CreateScreen(__GLXscreenConfigs * psc, int screen, psc->fd = open(deviceName, O_RDWR); if (psc->fd < 0) { ErrorMessageF("failed to open drm device: %s\n", strerror(errno)); - return NULL; + goto handle_error; } if (drmGetMagic(psc->fd, &magic)) { ErrorMessageF("failed to get magic\n"); - return NULL; + goto handle_error; } if (!DRI2Authenticate(psc->dpy, RootWindow(psc->dpy, screen), magic)) { ErrorMessageF("failed to authenticate magic %d\n", magic); - return NULL; + goto handle_error; } /* If the server does not support the protocol for @@ -558,7 +560,7 @@ dri2CreateScreen(__GLXscreenConfigs * psc, int screen, if (psc->__driScreen == NULL) { ErrorMessageF("failed to create dri screen\n"); - return NULL; + goto handle_error; } driBindCommonExtensions(psc); @@ -602,6 +604,7 @@ dri2CreateScreen(__GLXscreenConfigs * psc, int screen, handle_error: Xfree(driverName); Xfree(deviceName); + XFree(psp); /* FIXME: clean up here */ -- cgit v1.2.3 From ee5e84eba6e94ddd504cb9e0aaaae7363160e74b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 29 Jan 2010 08:37:15 -0700 Subject: windows: assorted build fixes These changes were originally submitted by Karl Schultz for Mesa 7.7-rc2 but weren't applied. (cherry picked from commit 82c76cd16f35f4d903f49761af7eb28a755ad299) --- src/mesa/drivers/windows/gdi/mesa.def | 4 ++-- src/mesa/drivers/windows/gdi/wmesa.c | 12 ------------ windows/VC8/mesa/gdi/gdi.vcproj | 8 ++++++++ windows/VC8/mesa/mesa/mesa.vcproj | 12 ++++++++++-- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/mesa/drivers/windows/gdi/mesa.def b/src/mesa/drivers/windows/gdi/mesa.def index 62f75d9541..700e333429 100644 --- a/src/mesa/drivers/windows/gdi/mesa.def +++ b/src/mesa/drivers/windows/gdi/mesa.def @@ -870,7 +870,6 @@ EXPORTS _mesa_bzero _mesa_calloc _mesa_choose_tex_format - _mesa_compressed_texture_size _mesa_create_framebuffer _mesa_create_visual _mesa_delete_array_object @@ -932,6 +931,8 @@ EXPORTS _mesa_update_framebuffer_visual _mesa_use_program _mesa_Viewport + _mesa_meta_init + _mesa_meta_free _mesa_meta_CopyColorSubTable _mesa_meta_CopyColorTable _mesa_meta_CopyConvolutionFilter1D @@ -941,7 +942,6 @@ EXPORTS _mesa_meta_CopyTexSubImage1D _mesa_meta_CopyTexSubImage2D _mesa_meta_CopyTexSubImage3D - _mesa_wait_query _swrast_Accum _swrast_Bitmap _swrast_BlitFramebuffer diff --git a/src/mesa/drivers/windows/gdi/wmesa.c b/src/mesa/drivers/windows/gdi/wmesa.c index 76c825a090..ceeafd5f90 100644 --- a/src/mesa/drivers/windows/gdi/wmesa.c +++ b/src/mesa/drivers/windows/gdi/wmesa.c @@ -1286,9 +1286,6 @@ void wmesa_set_renderbuffer_funcs(struct gl_renderbuffer *rb, int pixelformat, rb->PutMonoValues = write_mono_rgba_pixels_16; rb->GetRow = read_rgba_span_16; rb->GetValues = read_rgba_pixels_16; - rb->RedBits = 5; - rb->GreenBits = 6; - rb->BlueBits = 5; break; case PF_8R8G8B: if (cColorBits == 24) @@ -1300,9 +1297,6 @@ void wmesa_set_renderbuffer_funcs(struct gl_renderbuffer *rb, int pixelformat, rb->PutMonoValues = write_mono_rgba_pixels_24; rb->GetRow = read_rgba_span_24; rb->GetValues = read_rgba_pixels_24; - rb->RedBits = 8; - rb->GreenBits = 8; - rb->BlueBits = 8; } else { @@ -1313,9 +1307,6 @@ void wmesa_set_renderbuffer_funcs(struct gl_renderbuffer *rb, int pixelformat, rb->PutMonoValues = write_mono_rgba_pixels_32; rb->GetRow = read_rgba_span_32; rb->GetValues = read_rgba_pixels_32; - rb->RedBits = 8; - rb->GreenBits = 8; - rb->BlueBits = 8; } break; default: @@ -1331,9 +1322,6 @@ void wmesa_set_renderbuffer_funcs(struct gl_renderbuffer *rb, int pixelformat, rb->PutMonoValues = write_mono_rgba_pixels_front; rb->GetRow = read_rgba_span_front; rb->GetValues = read_rgba_pixels_front; - rb->RedBits = 8; /* XXX fix these (565?) */ - rb->GreenBits = 8; - rb->BlueBits = 8; } } diff --git a/windows/VC8/mesa/gdi/gdi.vcproj b/windows/VC8/mesa/gdi/gdi.vcproj index a3dd5ef5b6..220923f905 100644 --- a/windows/VC8/mesa/gdi/gdi.vcproj +++ b/windows/VC8/mesa/gdi/gdi.vcproj @@ -396,6 +396,10 @@ RelativePath="..\..\..\..\src\mesa\drivers\windows\gdi\mesa.def" > + + @@ -417,6 +421,10 @@ RelativePath="..\..\..\..\src\mesa\drivers\common\driverfuncs.h" > + + diff --git a/windows/VC8/mesa/mesa/mesa.vcproj b/windows/VC8/mesa/mesa/mesa.vcproj index 05bf7d2ea0..4719e342cf 100644 --- a/windows/VC8/mesa/mesa/mesa.vcproj +++ b/windows/VC8/mesa/mesa/mesa.vcproj @@ -450,6 +450,10 @@ RelativePath="..\..\..\..\src\mesa\main\fog.c" > + + @@ -1319,6 +1323,10 @@ RelativePath="..\..\..\..\src\mesa\main\fog.h" > + + @@ -1876,11 +1884,11 @@ > Date: Fri, 29 Jan 2010 08:37:31 -0700 Subject: docs: Fixed Windows build for 7.7.1 (cherry picked from commit a0518e66b2960d3bab386985e24ccbc9c51abf97) --- docs/relnotes-7.7.1.html | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/relnotes-7.7.1.html b/docs/relnotes-7.7.1.html index b20c8a7724..959efd9e57 100644 --- a/docs/relnotes-7.7.1.html +++ b/docs/relnotes-7.7.1.html @@ -43,6 +43,7 @@ tbd
  • Allocate constants more tightly in GL_ARB_vertex/fragment parser.
  • Fixed mipmap generation bug caused by invalid viewport state.
  • Gallium SSE codegen for XPD didn't always work. +
  • Fixed Windows build. -- cgit v1.2.3 From a38859569dca1d8b139c4c451499bf6e328379e9 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 29 Jan 2010 08:38:11 -0700 Subject: mesa: do state validation in _mesa_valid_to_render() ...rather than checking/validating before all the calls to _mesa_valid_to_render() and valid_to_render(). The next patch will actually fix some bugs... (cherry picked from commit 23eda89ec89e2bd5bc26077bd56e8d6b5d4040d4) --- src/mesa/main/api_validate.c | 9 --------- src/mesa/main/context.c | 4 ++++ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c index e71e5a6ce8..013048bbc1 100644 --- a/src/mesa/main/api_validate.c +++ b/src/mesa/main/api_validate.c @@ -190,9 +190,6 @@ _mesa_validate_DrawElements(GLcontext *ctx, return GL_FALSE; } - if (ctx->NewState) - _mesa_update_state(ctx); - if (!check_valid_to_render(ctx, "glDrawElements")) return GL_FALSE; @@ -254,9 +251,6 @@ _mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode, return GL_FALSE; } - if (ctx->NewState) - _mesa_update_state(ctx); - if (!check_valid_to_render(ctx, "glDrawRangeElements")) return GL_FALSE; @@ -304,9 +298,6 @@ _mesa_validate_DrawArrays(GLcontext *ctx, return GL_FALSE; } - if (ctx->NewState) - _mesa_update_state(ctx); - if (!check_valid_to_render(ctx, "glDrawArrays")) return GL_FALSE; diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index a570506d57..eb6bc8e436 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1578,6 +1578,10 @@ _mesa_set_mvp_with_dp4( GLcontext *ctx, GLboolean _mesa_valid_to_render(GLcontext *ctx, const char *where) { + /* This depends on having up to date derived state (shaders) */ + if (ctx->NewState) + _mesa_update_state(ctx); + if (ctx->Shader.CurrentProgram) { /* using shaders */ if (!ctx->Shader.CurrentProgram->LinkStatus) { -- cgit v1.2.3 From 5ce9183c1c535d924a79c2b6b280c6a2648cec19 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 29 Jan 2010 08:38:21 -0700 Subject: vbo: fix missing state validation bugs Commit 2708ddfb06a36d8568e2aa130bf1f7d551fcd309 caused a few regressions. We need to check/validate state after calling bind_arrays() because it might set the _NEW_ARRAYS flag if the varying VP inputs change. The symptom of this problem was some attribute arrays being ignored (or interpreted as constant-valued) in glDrawRangeElements or glMultiDrawElements. A follow-on patch will add some additional asserts to try to catch this kind of thing in the future. (cherry picked from commit 3cba779e16935f7c3a0bfd8af48bd5e015068e96) --- src/mesa/vbo/vbo_exec_array.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 392da43c5e..88502f3d35 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -443,6 +443,13 @@ recalculate_input_bindings(GLcontext *ctx) } +/** + * Examine the enabled vertex arrays to set the exec->array.inputs[] values. + * These will point to the arrays to actually use for drawing. Some will + * be user-provided arrays, other will be zero-stride const-valued arrays. + * Note that this might set the _NEW_ARRAY dirty flag so state validation + * must be done after this call. + */ static void bind_arrays(GLcontext *ctx) { @@ -484,9 +491,6 @@ vbo_exec_DrawArrays(GLenum mode, GLint start, GLsizei count) FLUSH_CURRENT( ctx, 0 ); - if (ctx->NewState) - _mesa_update_state( ctx ); - if (!_mesa_valid_to_render(ctx, "glDrawArrays")) { return; } @@ -600,18 +604,16 @@ vbo_validated_drawrangeelements(GLcontext *ctx, GLenum mode, FLUSH_CURRENT( ctx, 0 ); - if (ctx->NewState) - _mesa_update_state( ctx ); - if (!_mesa_valid_to_render(ctx, "glDraw[Range]Elements")) { return; } + bind_arrays( ctx ); + + /* check for dirty state again */ if (ctx->NewState) _mesa_update_state( ctx ); - bind_arrays( ctx ); - ib.count = count; ib.type = type; ib.obj = ctx->Array.ElementArrayBufferObj; @@ -848,16 +850,10 @@ vbo_validated_multidrawelements(GLcontext *ctx, GLenum mode, FLUSH_CURRENT( ctx, 0 ); - if (ctx->NewState) - _mesa_update_state( ctx ); - if (!_mesa_valid_to_render(ctx, "glMultiDrawElements")) { return; } - if (ctx->NewState) - _mesa_update_state( ctx ); - prim = _mesa_calloc(primcount * sizeof(*prim)); if (prim == NULL) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMultiDrawElements"); @@ -869,6 +865,10 @@ vbo_validated_multidrawelements(GLcontext *ctx, GLenum mode, */ bind_arrays( ctx ); + /* check for dirty state again */ + if (ctx->NewState) + _mesa_update_state( ctx ); + switch (type) { case GL_UNSIGNED_INT: index_type_size = 4; -- cgit v1.2.3 From 987dd63b90adc77b2ae580579a9baed4a3d56382 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 29 Jan 2010 08:39:47 -0700 Subject: st/mesa: check that state is validated before drawing (cherry picked from commit 4d1234e22242529c8d85f5ef0cf826af41a91570) Conflicts: src/mesa/state_tracker/st_draw.c --- src/mesa/state_tracker/st_draw.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index b0d5b993a7..381c68474d 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -531,6 +531,9 @@ st_draw_vbo(GLcontext *ctx, GLboolean userSpace = GL_FALSE; GLboolean vertDataEdgeFlags; + /* Mesa core state should have been validated already */ + assert(ctx->NewState == 0x0); + /* Gallium probably doesn't want this in some cases. */ if (!index_bounds_valid) if (!vbo_all_varyings_in_vbos(arrays)) -- cgit v1.2.3 From 6fea2be7959620fe0a1b28c275a7d960005c8b09 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 29 Jan 2010 08:40:46 -0700 Subject: tnl: check that state is validated before drawing (cherry picked from commit 9fd3c74724e557bc6ecc851d8552615ab3becfe2) Conflicts: src/mesa/tnl/t_draw.c --- src/mesa/tnl/t_draw.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c index adc50485c1..812d712b07 100644 --- a/src/mesa/tnl/t_draw.c +++ b/src/mesa/tnl/t_draw.c @@ -402,6 +402,9 @@ void _tnl_draw_prims( GLcontext *ctx, GLint max_basevertex = prim->basevertex; GLuint i; + /* Mesa core state should have been validated already */ + assert(ctx->NewState == 0x0); + if (!_mesa_check_conditional_render(ctx)) return; /* don't draw */ -- cgit v1.2.3 From e94021660b731f66e0557fd5a8939e65236a0762 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 29 Jan 2010 08:43:28 -0700 Subject: progs/tests: added a few more files to .gitignore --- progs/tests/.gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/progs/tests/.gitignore b/progs/tests/.gitignore index 3479ff8b33..8b3e9f3558 100644 --- a/progs/tests/.gitignore +++ b/progs/tests/.gitignore @@ -13,6 +13,7 @@ arbvptest3 arbvptorus arbvpwarpmesh arraytexture +auxbuffer blendminmax blendsquare blendxor @@ -23,10 +24,12 @@ bug_3195 bug_texstore_i8 bumpmap calibrate_rast +condrender copypixrate crossbar cva drawbuffers +drawbuffers2 extfuncs.h exactrast fbotest1 -- cgit v1.2.3 From 882279d31a15181316b8bf0f18d558deb13d99a4 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 29 Jan 2010 09:53:55 -0800 Subject: docs: Mark what I've been up to. Brian, feel free to split/revert if you disagree. --- docs/relnotes-7.8.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/relnotes-7.8.html b/docs/relnotes-7.8.html index 6511d613d6..7510139ccd 100644 --- a/docs/relnotes-7.8.html +++ b/docs/relnotes-7.8.html @@ -38,12 +38,14 @@ tbd
  • GL_EXT_draw_buffers2 extension (swrast and i965 driver only)
  • Much improved support for EGL in Mesa
  • New state trackers for OpenGL ES 1.1 and 2.0 +
  • Dedicated documentation for Gallium

    Bug fixes

      -
    • TBD +
    • Massive improvements to the Gallium driver for R300-R500 Radeons; this + driver is now moderately stable but not terribly performant.
    -- cgit v1.2.3 From 98f3f1c695f232120541670a8b5a355003ce3cc8 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 29 Jan 2010 12:36:26 -0700 Subject: gallium: document pipe_context::get_query_result() --- src/gallium/docs/source/context.rst | 12 +++++++++--- src/gallium/include/pipe/p_context.h | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst index 78b01cc9cb..a7669575b9 100644 --- a/src/gallium/docs/source/context.rst +++ b/src/gallium/docs/source/context.rst @@ -148,9 +148,15 @@ draws. Queries may be nested, though no state tracker currently exercises this. Queries can be created with ``create_query`` and deleted with -``destroy_query``. To enable a query, use ``begin_query``, and when finished, -use ``end_query`` to stop the query. Finally, ``get_query_result`` is used -to retrieve the results. +``destroy_query``. To start a query, use ``begin_query``, and when finished, +use ``end_query`` to end the query. + +``get_query_result`` is used to retrieve the results of a query. If +the ``wait`` parameter is TRUE, then the ``get_query_result`` call +will block until the results of the query are ready (and TRUE will be +returned). Otherwise, if the ``wait`` parameter is FALSE, the call +will not block and the return value will be TRUE if the query has +completed or FALSE otherwise. A common type of query is the occlusion query which counts the number of fragments/pixels which are written to the framebuffer (and not culled by diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index f3ee095448..f1e6a60e04 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -122,6 +122,11 @@ struct pipe_context { void (*begin_query)(struct pipe_context *pipe, struct pipe_query *q); void (*end_query)(struct pipe_context *pipe, struct pipe_query *q); + /** + * Get results of a query. + * \param wait if true, this query will block until the result is ready + * \return TRUE if results are ready, FALSE otherwise + */ boolean (*get_query_result)(struct pipe_context *pipe, struct pipe_query *q, boolean wait, -- cgit v1.2.3 From b8d4cbd7e2f76e647d8ac8c4dc4881d71c984b68 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 29 Jan 2010 14:01:12 -0700 Subject: progs/demos: new image dissolve demo Dissolve between two images using a random pattern in the stencil buffer and a varying stencil ref value. --- progs/demos/Makefile | 1 + progs/demos/SConscript | 1 + progs/demos/dissolve.c | 158 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 160 insertions(+) create mode 100644 progs/demos/dissolve.c diff --git a/progs/demos/Makefile b/progs/demos/Makefile index f21d916330..5b1d2a0b65 100644 --- a/progs/demos/Makefile +++ b/progs/demos/Makefile @@ -20,6 +20,7 @@ PROGS = \ copypix \ cubemap \ dinoshade \ + dissolve \ drawpix \ engine \ fbo_firecube \ diff --git a/progs/demos/SConscript b/progs/demos/SConscript index 742dd66f36..10d53b50bf 100644 --- a/progs/demos/SConscript +++ b/progs/demos/SConscript @@ -8,6 +8,7 @@ progs = [ 'clearspd', 'copypix', 'cubemap', + 'dissolve', 'drawpix', 'engine', 'fbo_firecube', diff --git a/progs/demos/dissolve.c b/progs/demos/dissolve.c new file mode 100644 index 0000000000..f1589a4e41 --- /dev/null +++ b/progs/demos/dissolve.c @@ -0,0 +1,158 @@ +/** + * Dissolve between two images using randomized stencil buffer + * and varying stencil ref. + * + * Brian Paul + * 29 Jan 2010 + */ + + +#include +#include +#include +#include +#include "readtex.h" + +#define FILE1 "../images/bw.rgb" +#define FILE2 "../images/arch.rgb" + + +static int Win; +static int WinWidth = 400, WinHeight = 400; +static GLboolean Anim = GL_TRUE; + +static int ImgWidth[2], ImgHeight[2]; +static GLenum ImgFormat[2]; +static GLubyte *Image[2]; +static GLfloat ScaleX[2], ScaleY[2]; + +static GLubyte StencilRef = 0; + + +static void +Idle(void) +{ + StencilRef = (GLint) (glutGet(GLUT_ELAPSED_TIME) / 10); + glutPostRedisplay(); +} + + +static void +RandomizeStencilBuffer(void) +{ + GLubyte *b = malloc(WinWidth * WinHeight); + int i; + for (i = 0; i < WinWidth * WinHeight; i++) { + b[i] = rand() & 0xff; + } + + glStencilFunc(GL_ALWAYS, 0, ~0); + glPixelZoom(1.0, 1.0); + glDrawPixels(WinWidth, WinHeight, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, b); + + free(b); +} + + + +static void +Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glPixelZoom(ScaleX[0], ScaleY[0]); + glStencilFunc(GL_LESS, StencilRef, ~0); + glDrawPixels(ImgWidth[0], ImgHeight[0], ImgFormat[0], GL_UNSIGNED_BYTE, Image[0]); + + glPixelZoom(ScaleX[1], ScaleY[1]); + glStencilFunc(GL_GEQUAL, StencilRef, ~0); + glDrawPixels(ImgWidth[1], ImgHeight[1], ImgFormat[1], GL_UNSIGNED_BYTE, Image[1]); + + glutSwapBuffers(); +} + + +static void +Reshape(int width, int height) +{ + WinWidth = width; + WinHeight = height; + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -15.0); + + RandomizeStencilBuffer(); + + ScaleX[0] = (float) width / ImgWidth[0]; + ScaleY[0] = (float) height / ImgHeight[0]; + + ScaleX[1] = (float) width / ImgWidth[1]; + ScaleY[1] = (float) height / ImgHeight[1]; +} + + +static void +Key(unsigned char key, int x, int y) +{ + (void) x; + (void) y; + switch (key) { + case 'a': + Anim = !Anim; + if (Anim) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; + case 27: + glutDestroyWindow(Win); + exit(0); + break; + } + glutPostRedisplay(); +} + + + +static void +Init(void) +{ + Image[0] = LoadRGBImage(FILE1, &ImgWidth[0], &ImgHeight[0], &ImgFormat[0]); + if (!Image[0]) { + printf("Couldn't read %s\n", FILE1); + exit(0); + } + + Image[1] = LoadRGBImage(FILE2, &ImgWidth[1], &ImgHeight[1], &ImgFormat[1]); + if (!Image[1]) { + printf("Couldn't read %s\n", FILE1); + exit(0); + } + + glEnable(GL_STENCIL_TEST); + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); +} + + +int +main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitWindowSize(WinWidth, WinHeight); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL); + Win = glutCreateWindow(argv[0]); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + if (Anim) + glutIdleFunc(Idle); + Init(); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From 847ac8ec5ff683076dff17d8e0426a64b4ad65e7 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Sat, 30 Jan 2010 01:56:42 +0100 Subject: gallium: fix blend state cso if independent blend state was disabled, only the data from first rt was stored, however the comparison used the full state, hence there never was a match and always a new object was created. Fixes a huge performance drop with llvmpipe due to recompilation. --- src/gallium/auxiliary/cso_cache/cso_cache.c | 23 +------------------ src/gallium/auxiliary/cso_cache/cso_cache.h | 2 +- src/gallium/auxiliary/cso_cache/cso_context.c | 32 +++++++++++++++------------ 3 files changed, 20 insertions(+), 37 deletions(-) diff --git a/src/gallium/auxiliary/cso_cache/cso_cache.c b/src/gallium/auxiliary/cso_cache/cso_cache.c index e6dce3f0e5..a6a07e72c2 100644 --- a/src/gallium/auxiliary/cso_cache/cso_cache.c +++ b/src/gallium/auxiliary/cso_cache/cso_cache.c @@ -113,26 +113,6 @@ static struct cso_hash *_cso_hash_for_type(struct cso_cache *sc, enum cso_cache_ return hash; } -static int _cso_size_for_type(enum cso_cache_type type) -{ - switch(type) { - case CSO_BLEND: - return sizeof(struct pipe_blend_state); - case CSO_SAMPLER: - return sizeof(struct pipe_sampler_state); - case CSO_DEPTH_STENCIL_ALPHA: - return sizeof(struct pipe_depth_stencil_alpha_state); - case CSO_RASTERIZER: - return sizeof(struct pipe_rasterizer_state); - case CSO_FRAGMENT_SHADER: - return sizeof(struct pipe_shader_state); - case CSO_VERTEX_SHADER: - return sizeof(struct pipe_shader_state); - } - return 0; -} - - static void delete_blend_state(void *state, void *data) { struct cso_blend *cso = (struct cso_blend *)state; @@ -282,10 +262,9 @@ void *cso_hash_find_data_from_template( struct cso_hash *hash, struct cso_hash_iter cso_find_state_template(struct cso_cache *sc, unsigned hash_key, enum cso_cache_type type, - void *templ) + void *templ, unsigned size) { struct cso_hash_iter iter = cso_find_state(sc, hash_key, type); - int size = _cso_size_for_type(type); while (!cso_hash_iter_is_null(iter)) { void *iter_data = cso_hash_iter_data(iter); if (!memcmp(iter_data, templ, size)) diff --git a/src/gallium/auxiliary/cso_cache/cso_cache.h b/src/gallium/auxiliary/cso_cache/cso_cache.h index 6b5c230e8f..eea60b940b 100644 --- a/src/gallium/auxiliary/cso_cache/cso_cache.h +++ b/src/gallium/auxiliary/cso_cache/cso_cache.h @@ -160,7 +160,7 @@ struct cso_hash_iter cso_find_state(struct cso_cache *sc, unsigned hash_key, enum cso_cache_type type); struct cso_hash_iter cso_find_state_template(struct cso_cache *sc, unsigned hash_key, enum cso_cache_type type, - void *templ); + void *templ, unsigned size); void cso_for_each_state(struct cso_cache *sc, enum cso_cache_type type, cso_state_callback func, void *user_data); void * cso_take_state(struct cso_cache *sc, unsigned hash_key, diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index c479c36064..dec830ba93 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -317,7 +317,7 @@ enum pipe_error cso_set_blend(struct cso_context *ctx, key_size = templ->independent_blend_enable ? sizeof(struct pipe_blend_state) : (char *)&(templ->rt[1]) - (char *)templ; hash_key = cso_construct_key((void*)templ, key_size); - iter = cso_find_state_template(ctx->cache, hash_key, CSO_BLEND, (void*)templ); + iter = cso_find_state_template(ctx->cache, hash_key, CSO_BLEND, (void*)templ, key_size); if (cso_hash_iter_is_null(iter)) { struct cso_blend *cso = MALLOC(sizeof(struct cso_blend)); @@ -372,10 +372,11 @@ enum pipe_error cso_single_sampler(struct cso_context *ctx, void *handle = NULL; if (templ != NULL) { - unsigned hash_key = cso_construct_key((void*)templ, sizeof(struct pipe_sampler_state)); + unsigned key_size = sizeof(struct pipe_sampler_state); + unsigned hash_key = cso_construct_key((void*)templ, key_size); struct cso_hash_iter iter = cso_find_state_template(ctx->cache, hash_key, CSO_SAMPLER, - (void*)templ); + (void*)templ, key_size); if (cso_hash_iter_is_null(iter)) { struct cso_sampler *cso = MALLOC(sizeof(struct cso_sampler)); @@ -412,10 +413,11 @@ cso_single_vertex_sampler(struct cso_context *ctx, void *handle = NULL; if (templ != NULL) { - unsigned hash_key = cso_construct_key((void*)templ, sizeof(struct pipe_sampler_state)); + unsigned key_size = sizeof(struct pipe_sampler_state); + unsigned hash_key = cso_construct_key((void*)templ, key_size); struct cso_hash_iter iter = cso_find_state_template(ctx->cache, hash_key, CSO_SAMPLER, - (void*)templ); + (void*)templ, key_size); if (cso_hash_iter_is_null(iter)) { struct cso_sampler *cso = MALLOC(sizeof(struct cso_sampler)); @@ -701,12 +703,12 @@ cso_restore_vertex_sampler_textures(struct cso_context *ctx) enum pipe_error cso_set_depth_stencil_alpha(struct cso_context *ctx, const struct pipe_depth_stencil_alpha_state *templ) { - unsigned hash_key = cso_construct_key((void*)templ, - sizeof(struct pipe_depth_stencil_alpha_state)); + unsigned key_size = sizeof(struct pipe_depth_stencil_alpha_state); + unsigned hash_key = cso_construct_key((void*)templ, key_size); struct cso_hash_iter iter = cso_find_state_template(ctx->cache, hash_key, - CSO_DEPTH_STENCIL_ALPHA, - (void*)templ); + CSO_DEPTH_STENCIL_ALPHA, + (void*)templ, key_size); void *handle; if (cso_hash_iter_is_null(iter)) { @@ -758,11 +760,11 @@ void cso_restore_depth_stencil_alpha(struct cso_context *ctx) enum pipe_error cso_set_rasterizer(struct cso_context *ctx, const struct pipe_rasterizer_state *templ) { - unsigned hash_key = cso_construct_key((void*)templ, - sizeof(struct pipe_rasterizer_state)); + unsigned key_size = sizeof(struct pipe_rasterizer_state); + unsigned hash_key = cso_construct_key((void*)templ, key_size); struct cso_hash_iter iter = cso_find_state_template(ctx->cache, hash_key, CSO_RASTERIZER, - (void*)templ); + (void*)templ, key_size); void *handle = NULL; if (cso_hash_iter_is_null(iter)) { @@ -844,7 +846,8 @@ enum pipe_error cso_set_fragment_shader(struct cso_context *ctx, struct cso_hash_iter iter = cso_find_state_template(ctx->cache, hash_key, CSO_FRAGMENT_SHADER, - (void*)tokens); + (void*)tokens, + sizeof(*templ)); /* XXX correct? tokens_size? */ void *handle = NULL; if (cso_hash_iter_is_null(iter)) { @@ -923,7 +926,8 @@ enum pipe_error cso_set_vertex_shader(struct cso_context *ctx, sizeof(struct pipe_shader_state)); struct cso_hash_iter iter = cso_find_state_template(ctx->cache, hash_key, CSO_VERTEX_SHADER, - (void*)templ); + (void*)templ, + sizeof(*templ)); void *handle = NULL; if (cso_hash_iter_is_null(iter)) { -- cgit v1.2.3 From 94cb321b5d246185abf71d89968d472a626f1a23 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 29 Jan 2010 09:00:30 +0800 Subject: egl: Clean up header inclusions. Mainly to remove eglcurrent.h and egldisplay.h from eglglobals.h. --- src/egl/drivers/glx/egl_glx.c | 2 +- src/egl/drivers/xdri/egl_xdri.c | 2 +- src/egl/main/eglapi.c | 1 + src/egl/main/eglapi.h | 2 +- src/egl/main/eglconfig.c | 3 +-- src/egl/main/eglconfigutil.c | 1 - src/egl/main/eglcontext.c | 2 +- src/egl/main/eglcontext.h | 1 - src/egl/main/eglcurrent.c | 4 ++-- src/egl/main/eglcurrent.h | 1 + src/egl/main/egldisplay.c | 1 + src/egl/main/egldisplay.h | 1 + src/egl/main/egldriver.c | 1 + src/egl/main/egldriver.h | 3 +++ src/egl/main/eglglobals.c | 1 + src/egl/main/eglglobals.h | 3 +-- src/egl/main/egllog.h | 2 ++ src/egl/main/eglmisc.c | 2 +- src/egl/main/eglmisc.h | 3 ++- src/egl/main/eglmode.c | 3 +-- src/egl/main/eglscreen.c | 1 + src/egl/main/eglscreen.h | 3 +++ src/egl/main/eglsurface.c | 2 +- src/egl/main/egltypedefs.h | 4 ---- 24 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c index 1c38db6491..af653b86ee 100644 --- a/src/egl/drivers/glx/egl_glx.c +++ b/src/egl/drivers/glx/egl_glx.c @@ -43,7 +43,7 @@ #include "eglcontext.h" #include "egldisplay.h" #include "egldriver.h" -#include "eglglobals.h" +#include "eglcurrent.h" #include "egllog.h" #include "eglsurface.h" diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index 2ca9ea8a5b..10f7a31f5b 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -52,7 +52,7 @@ #include "eglcontext.h" #include "egldisplay.h" #include "egldriver.h" -#include "eglglobals.h" +#include "eglcurrent.h" #include "egllog.h" #include "eglsurface.h" diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 7e77ef1f03..364ad9c458 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -60,6 +60,7 @@ #include "egldisplay.h" #include "egltypedefs.h" #include "eglglobals.h" +#include "eglcurrent.h" #include "egldriver.h" #include "eglsurface.h" #include "eglconfig.h" diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h index a7600820f3..c3676ec56a 100644 --- a/src/egl/main/eglapi.h +++ b/src/egl/main/eglapi.h @@ -4,7 +4,7 @@ /** * A generic function ptr type */ -typedef void (*_EGLProc)(); +typedef void (*_EGLProc)(void); /** diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index 2db9b9401a..b974e40cce 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -4,12 +4,11 @@ #include -#include #include #include #include "eglconfig.h" #include "egldisplay.h" -#include "eglglobals.h" +#include "eglcurrent.h" #include "egllog.h" diff --git a/src/egl/main/eglconfigutil.c b/src/egl/main/eglconfigutil.c index ddb886c54d..e416b190f0 100644 --- a/src/egl/main/eglconfigutil.c +++ b/src/egl/main/eglconfigutil.c @@ -4,7 +4,6 @@ #include -#include #include #include "eglconfigutil.h" diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index 4496f76ece..ee9d60e17a 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -5,7 +5,7 @@ #include "eglcontext.h" #include "egldisplay.h" #include "egldriver.h" -#include "eglglobals.h" +#include "eglcurrent.h" #include "eglsurface.h" diff --git a/src/egl/main/eglcontext.h b/src/egl/main/eglcontext.h index 4811e3bb7a..ebb50aa60e 100644 --- a/src/egl/main/eglcontext.h +++ b/src/egl/main/eglcontext.h @@ -1,4 +1,3 @@ - #ifndef EGLCONTEXT_INCLUDED #define EGLCONTEXT_INCLUDED diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c index 696d04e8ba..a19dcf4096 100644 --- a/src/egl/main/eglcurrent.c +++ b/src/egl/main/eglcurrent.c @@ -1,10 +1,10 @@ #include #include -#include "eglcurrent.h" +#include "eglglobals.h" #include "eglcontext.h" #include "egllog.h" #include "eglmutex.h" -#include "eglglobals.h" +#include "eglcurrent.h" /* This should be kept in sync with _eglInitThreadInfo() */ diff --git a/src/egl/main/eglcurrent.h b/src/egl/main/eglcurrent.h index c169c93e94..e5c94ce60a 100644 --- a/src/egl/main/eglcurrent.h +++ b/src/egl/main/eglcurrent.h @@ -1,6 +1,7 @@ #ifndef EGLCURRENT_INCLUDED #define EGLCURRENT_INCLUDED + #include "egltypedefs.h" diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c index d7a8d14292..5897372fc5 100644 --- a/src/egl/main/egldisplay.c +++ b/src/egl/main/egldisplay.c @@ -10,6 +10,7 @@ #include "egldisplay.h" #include "egldriver.h" #include "eglglobals.h" +#include "eglcurrent.h" #include "eglmutex.h" #include "egllog.h" diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 4aea10c3eb..b04b094d84 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -1,6 +1,7 @@ #ifndef EGLDISPLAY_INCLUDED #define EGLDISPLAY_INCLUDED + #include "egltypedefs.h" #include "egldefines.h" diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 1dadbf783b..df36369ac2 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -13,6 +13,7 @@ #include "egldisplay.h" #include "egldriver.h" #include "eglglobals.h" +#include "eglcurrent.h" #include "egllog.h" #include "eglmisc.h" #include "eglmode.h" diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h index 6ebb60a8f1..5149acd964 100644 --- a/src/egl/main/egldriver.h +++ b/src/egl/main/egldriver.h @@ -6,6 +6,9 @@ #include "eglapi.h" +typedef _EGLDriver *(*_EGLMain_t)(const char *args); + + /** * Base class for device drivers. */ diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c index 9c4902621f..5182b18e22 100644 --- a/src/egl/main/eglglobals.c +++ b/src/egl/main/eglglobals.c @@ -1,6 +1,7 @@ #include #include #include "eglglobals.h" +#include "egldisplay.h" #include "egldriver.h" #include "eglmutex.h" diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h index 5ebb914ca7..cd1dd5851b 100644 --- a/src/egl/main/eglglobals.h +++ b/src/egl/main/eglglobals.h @@ -1,9 +1,8 @@ #ifndef EGLGLOBALS_INCLUDED #define EGLGLOBALS_INCLUDED + #include "egltypedefs.h" -#include "egldisplay.h" -#include "eglcurrent.h" #include "eglmutex.h" diff --git a/src/egl/main/egllog.h b/src/egl/main/egllog.h index 3a99bfea4b..03bef2670f 100644 --- a/src/egl/main/egllog.h +++ b/src/egl/main/egllog.h @@ -1,8 +1,10 @@ #ifndef EGLLOG_INCLUDED #define EGLLOG_INCLUDED + #include "egltypedefs.h" + #define _EGL_FATAL 0 /* unrecoverable error */ #define _EGL_WARNING 1 /* recoverable error/problem */ #define _EGL_INFO 2 /* just useful info */ diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c index 5726f5bca8..907a057b44 100644 --- a/src/egl/main/eglmisc.c +++ b/src/egl/main/eglmisc.c @@ -33,7 +33,7 @@ #include #include -#include "eglglobals.h" +#include "eglcurrent.h" #include "eglmisc.h" #include "egldisplay.h" diff --git a/src/egl/main/eglmisc.h b/src/egl/main/eglmisc.h index 829d4cde79..5e6a2d41df 100644 --- a/src/egl/main/eglmisc.h +++ b/src/egl/main/eglmisc.h @@ -29,7 +29,8 @@ #ifndef EGLMISC_INCLUDED #define EGLMISC_INCLUDED -#include "egldriver.h" + +#include "egltypedefs.h" extern const char * diff --git a/src/egl/main/eglmode.c b/src/egl/main/eglmode.c index 0f3ba6e5c0..503b9e595e 100644 --- a/src/egl/main/eglmode.c +++ b/src/egl/main/eglmode.c @@ -1,4 +1,3 @@ -#include #include #include #include @@ -6,7 +5,7 @@ #include "egldisplay.h" #include "egldriver.h" #include "eglmode.h" -#include "eglglobals.h" +#include "eglcurrent.h" #include "eglscreen.h" diff --git a/src/egl/main/eglscreen.c b/src/egl/main/eglscreen.c index 14a1e9f8fe..1079a1cbe6 100644 --- a/src/egl/main/eglscreen.c +++ b/src/egl/main/eglscreen.c @@ -17,6 +17,7 @@ #include "egldisplay.h" #include "eglglobals.h" +#include "eglcurrent.h" #include "eglmode.h" #include "eglconfig.h" #include "eglsurface.h" diff --git a/src/egl/main/eglscreen.h b/src/egl/main/eglscreen.h index d52e5388c3..c400ac3d15 100644 --- a/src/egl/main/eglscreen.h +++ b/src/egl/main/eglscreen.h @@ -2,6 +2,9 @@ #define EGLSCREEN_INCLUDED +#include "egltypedefs.h" + + /** * Per-screen information. * Note that an EGL screen doesn't have a size. A screen may be set to diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 3219231ed2..8f87239fe2 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -9,7 +9,7 @@ #include "egldisplay.h" #include "eglcontext.h" #include "eglconfig.h" -#include "eglglobals.h" +#include "eglcurrent.h" #include "egllog.h" #include "eglsurface.h" diff --git a/src/egl/main/egltypedefs.h b/src/egl/main/egltypedefs.h index e6b19b35d0..e0c95762c6 100644 --- a/src/egl/main/egltypedefs.h +++ b/src/egl/main/egltypedefs.h @@ -34,8 +34,4 @@ typedef struct _egl_surface _EGLSurface; typedef struct _egl_thread_info _EGLThreadInfo; - -typedef _EGLDriver *(*_EGLMain_t)(const char *args); - - #endif /* EGLTYPEDEFS_INCLUDED */ -- cgit v1.2.3 From 00e1790f3230de550121591d611b47da299ae15c Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 30 Jan 2010 22:45:54 +0800 Subject: egl: Rename Binding to CurrentContext in _EGLSurface. A context can be bound to a surface just like it can be bound to a thread. CurrentContext is a more consistent name. --- src/egl/drivers/xdri/egl_xdri.c | 2 +- src/egl/main/eglcontext.c | 16 ++++++++-------- src/egl/main/eglsurface.h | 14 +++++++------- src/gallium/state_trackers/egl/common/egl_g3d.c | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/egl/drivers/xdri/egl_xdri.c b/src/egl/drivers/xdri/egl_xdri.c index 10f7a31f5b..9c21576539 100644 --- a/src/egl/drivers/xdri/egl_xdri.c +++ b/src/egl/drivers/xdri/egl_xdri.c @@ -600,7 +600,7 @@ xdri_eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw) struct xdri_egl_surface *xdri_surf = lookup_surface(draw); /* swapBuffers does not flush commands */ - if (draw->Binding && xdri_driver->FlushCurrentContext) + if (draw->CurrentContext && xdri_driver->FlushCurrentContext) xdri_driver->FlushCurrentContext(); xdri_dpy->psc->driScreen->swapBuffers(xdri_surf->driDrawable, 0, 0, 0); diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index ee9d60e17a..37c4b25b68 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -150,13 +150,13 @@ _eglBindContextToSurfaces(_EGLContext *ctx, { _EGLSurface *newDraw = *draw, *newRead = *read; - if (newDraw->Binding) - newDraw->Binding->DrawSurface = NULL; - newDraw->Binding = ctx; + if (newDraw->CurrentContext) + newDraw->CurrentContext->DrawSurface = NULL; + newDraw->CurrentContext = ctx; - if (newRead->Binding) - newRead->Binding->ReadSurface = NULL; - newRead->Binding = ctx; + if (newRead->CurrentContext) + newRead->CurrentContext->ReadSurface = NULL; + newRead->CurrentContext = ctx; if (ctx) { *draw = ctx->DrawSurface; @@ -238,8 +238,8 @@ _eglCheckMakeCurrent(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read) * * The latter is more restrictive so we can check only the latter case. */ - if ((draw->Binding && draw->Binding != ctx) || - (read->Binding && read->Binding != ctx)) + if ((draw->CurrentContext && draw->CurrentContext != ctx) || + (read->CurrentContext && read->CurrentContext != ctx)) return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent"); /* simply require the configs to be equal */ diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h index 4062b990fa..eee66f6d86 100644 --- a/src/egl/main/eglsurface.h +++ b/src/egl/main/eglsurface.h @@ -14,9 +14,8 @@ struct _egl_surface /* A surface is a display resource */ _EGLResource Resource; - /* The bound status of the surface */ - _EGLContext *Binding; - EGLBoolean BoundToTexture; + /* The context that is currently bound to the surface */ + _EGLContext *CurrentContext; _EGLConfig *Config; @@ -26,6 +25,9 @@ struct _egl_surface EGLint MipmapTexture, MipmapLevel; EGLint SwapInterval; + /* True if the surface is bound to an OpenGL ES texture */ + EGLBoolean BoundToTexture; + /* If type == EGL_SCREEN_BIT: */ EGLint VisibleRefCount; /* number of screens I'm displayed on */ @@ -100,14 +102,12 @@ _eglCreatePbufferFromClientBuffer(_EGLDriver *drv, _EGLDisplay *dpy, /** - * Return true if the surface is bound to a thread. - * A surface bound to a texutre is not considered bound by - * this function. + * Return true if there is a context bound to the surface. */ static INLINE EGLBoolean _eglIsSurfaceBound(_EGLSurface *surf) { - return (surf->Binding != NULL); + return (surf->CurrentContext != NULL); } diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index f8334217c4..3f520851c4 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -1129,8 +1129,8 @@ egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, } /* flush properly if the surface is bound */ - if (gsurf->base.Binding) { - gctx = egl_g3d_context(gsurf->base.Binding); + if (gsurf->base.CurrentContext) { + gctx = egl_g3d_context(gsurf->base.CurrentContext); gctx->stapi->st_flush(gctx->st_ctx, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); } -- cgit v1.2.3 From 6fc304456e4b5c166efdaac512b2fb285b9f5d7f Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 30 Jan 2010 22:55:00 +0800 Subject: egl: Remove unused VisibleRefCount. --- src/egl/main/eglsurface.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h index eee66f6d86..0d64d20dd4 100644 --- a/src/egl/main/eglsurface.h +++ b/src/egl/main/eglsurface.h @@ -28,9 +28,6 @@ struct _egl_surface /* True if the surface is bound to an OpenGL ES texture */ EGLBoolean BoundToTexture; - /* If type == EGL_SCREEN_BIT: */ - EGLint VisibleRefCount; /* number of screens I'm displayed on */ - #ifdef EGL_VERSION_1_2 EGLint SwapBehavior; /* one of EGL_BUFFER_PRESERVED/DESTROYED */ EGLint HorizontalResolution, VerticalResolution; -- cgit v1.2.3 From 2c3a23a96f510ee56103b6f6e9308eedd6cd4c4c Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 30 Jan 2010 23:02:12 +0800 Subject: egl: Remove my_strdup. There is already _eglstrdup for the main library's use. --- src/egl/main/eglmode.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/egl/main/eglmode.c b/src/egl/main/eglmode.c index 503b9e595e..1e26ea83f5 100644 --- a/src/egl/main/eglmode.c +++ b/src/egl/main/eglmode.c @@ -7,27 +7,12 @@ #include "eglmode.h" #include "eglcurrent.h" #include "eglscreen.h" +#include "eglstring.h" #define MIN2(A, B) (((A) < (B)) ? (A) : (B)) -static char * -my_strdup(const char *s) -{ - if (s) { - int l = strlen(s); - char *s2 = malloc(l + 1); - if (s2) - strcpy(s2, s); - return s2; - } - else { - return NULL; - } -} - - /** * Given an EGLModeMESA handle, return the corresponding _EGLMode object * or null if non-existant. @@ -81,7 +66,7 @@ _eglAddNewMode(_EGLScreen *screen, EGLint width, EGLint height, screen->Modes[n].RefreshRate = refreshRate; screen->Modes[n].Optimal = EGL_FALSE; screen->Modes[n].Interlaced = EGL_FALSE; - screen->Modes[n].Name = my_strdup(name); + screen->Modes[n].Name = _eglstrdup(name); screen->NumModes++; return screen->Modes + n; } -- cgit v1.2.3 From 5714e674c75652c195482a8e607a2d624a5e524e Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 30 Jan 2010 23:13:18 +0800 Subject: st/egl: eglBindTexImage should bind to an OpenGL ES texture. The spec says that it only works with OpenGL ES. --- src/gallium/state_trackers/egl/common/egl_g3d.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index 3f520851c4..f4c4032086 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -1135,8 +1135,7 @@ egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); } - /* XXX change to EGL_OPENGL_ES_API once OpenGL ES is merged */ - gctx = egl_g3d_get_current_context(EGL_OPENGL_API); + gctx = egl_g3d_get_current_context(EGL_OPENGL_ES_API); if (gctx) { if (!gsurf->render_surface) return EGL_FALSE; @@ -1163,9 +1162,8 @@ egl_g3d_release_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, if (gsurf->render_surface) { _EGLThreadInfo *t = _eglGetCurrentThread(); - /* XXX change to EGL_OPENGL_ES_API once OpenGL ES is merged */ struct egl_g3d_context *gctx = egl_g3d_context( - t->CurrentContexts[_eglConvertApiToIndex(EGL_OPENGL_API)]); + t->CurrentContexts[_eglConvertApiToIndex(EGL_OPENGL_ES_API)]); /* what if the context the surface binds to is no longer current? */ if (gctx) -- cgit v1.2.3 From 7056a74734d078c501d8318d47a364832aa8aeb6 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 30 Jan 2010 23:07:31 +0800 Subject: progs/es1: Add bindtex. It is ported from progs/egl/xeglbindtex.c. With the OpenGL ES port, the OpenGL version is removed. --- progs/egl/Makefile | 4 - progs/egl/xeglbindtex.c | 478 ----------------------------------------------- progs/es1/xegl/Makefile | 5 + progs/es1/xegl/bindtex.c | 474 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 479 insertions(+), 482 deletions(-) delete mode 100644 progs/egl/xeglbindtex.c create mode 100644 progs/es1/xegl/bindtex.c diff --git a/progs/egl/Makefile b/progs/egl/Makefile index ff9a858c56..68bb5679f8 100644 --- a/progs/egl/Makefile +++ b/progs/egl/Makefile @@ -20,7 +20,6 @@ PROGRAMS = \ eglgears \ eglscreen \ peglgears \ - xeglbindtex \ xeglgears \ xeglthreads \ xegl_tri @@ -57,9 +56,6 @@ eglscreen: eglscreen.o $(HEADERS) $(LIB_DEP) peglgears: peglgears.o $(HEADERS) $(LIB_DEP) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(LIBDRM_LIB) -xeglbindtex: xeglbindtex.o $(HEADERS) $(LIB_DEP) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lX11 - xeglgears: xeglgears.o $(HEADERS) $(LIB_DEP) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lX11 diff --git a/progs/egl/xeglbindtex.c b/progs/egl/xeglbindtex.c deleted file mode 100644 index de0ede92ca..0000000000 --- a/progs/egl/xeglbindtex.c +++ /dev/null @@ -1,478 +0,0 @@ -/* - * Simple demo for eglBindTexImage. Based on xegl_tri.c by - * - * Copyright (C) 2008 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL 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. - */ - -/* - * The spec says that eglBindTexImage supports only OpenGL ES context, but this - * demo uses OpenGL context. Keep in mind that this is non-standard. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static EGLDisplay dpy; -static EGLContext ctx_win, ctx_pbuf; -static EGLSurface surf_win, surf_pbuf; -static GLuint tex_pbuf; - -static GLfloat view_rotx = 0.0, view_roty = 0.0, view_rotz = 0.0; -static GLboolean blend = GL_TRUE; -static GLuint color_flow; - -static void -make_pbuffer(int width, int height) -{ - static const EGLint config_attribs[] = { - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_BIND_TO_TEXTURE_RGB, EGL_TRUE, - EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, - EGL_NONE - }; - EGLint pbuf_attribs[] = { - EGL_WIDTH, width, - EGL_HEIGHT, height, - EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB, - EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, - EGL_NONE - }; - EGLConfig config; - EGLint num_configs; - - if (!eglChooseConfig(dpy, config_attribs, &config, 1, &num_configs) || - !num_configs) { - printf("Error: couldn't get an EGL visual config for pbuffer\n"); - exit(1); - } - - eglBindAPI(EGL_OPENGL_API); - ctx_pbuf = eglCreateContext(dpy, config, EGL_NO_CONTEXT, NULL ); - surf_pbuf = eglCreatePbufferSurface(dpy, config, pbuf_attribs); - if (surf_pbuf == EGL_NO_SURFACE) { - printf("failed to allocate pbuffer\n"); - exit(1); - } -} - -static void -use_pbuffer(void) -{ - static int initialized; - - eglMakeCurrent(dpy, surf_pbuf, surf_pbuf, ctx_pbuf); - if (!initialized) { - EGLint width, height; - GLfloat ar; - - initialized = 1; - - eglQuerySurface(dpy, surf_pbuf, EGL_WIDTH, &width); - eglQuerySurface(dpy, surf_pbuf, EGL_WIDTH, &height); - ar = (GLfloat) width / (GLfloat) height; - - glViewport(0, 0, (GLint) width, (GLint) height); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum(-ar, ar, -1, 1, 1.0, 10.0); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - /* y-inverted */ - glScalef(1.0, -1.0, 1.0); - - glTranslatef(0.0, 0.0, -5.0); - - glClearColor(0.2, 0.2, 0.2, 0.0); - - glGenTextures(1, &tex_pbuf); - } -} - -static void -make_window(Display *x_dpy, const char *name, - int x, int y, int width, int height, - Window *winRet) -{ - static const EGLint attribs[] = { - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_ALPHA_SIZE, 8, - EGL_DEPTH_SIZE, 8, - EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, - EGL_NONE - }; - - int scrnum; - XSetWindowAttributes attr; - unsigned long mask; - Window root; - Window win; - XVisualInfo *visInfo, visTemplate; - int num_visuals; - EGLConfig config; - EGLint num_configs, vid; - - scrnum = DefaultScreen( x_dpy ); - root = RootWindow( x_dpy, scrnum ); - - if (!eglChooseConfig(dpy, attribs, &config, 1, &num_configs) || - !num_configs) { - printf("Error: couldn't get an EGL visual config\n"); - exit(1); - } - - if (!eglGetConfigAttrib(dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) { - printf("Error: eglGetConfigAttrib() failed\n"); - exit(1); - } - - /* The X window visual must match the EGL config */ - visTemplate.visualid = vid; - visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals); - if (!visInfo) { - printf("Error: couldn't get X visual\n"); - exit(1); - } - - /* window attributes */ - attr.background_pixel = 0; - attr.border_pixel = 0; - attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone); - attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; - attr.override_redirect = 0; - mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect; - - win = XCreateWindow( x_dpy, root, 0, 0, width, height, - 0, visInfo->depth, InputOutput, - visInfo->visual, mask, &attr ); - - /* set hints and properties */ - { - XSizeHints sizehints; - sizehints.x = x; - sizehints.y = y; - sizehints.width = width; - sizehints.height = height; - sizehints.flags = USSize | USPosition; - XSetNormalHints(x_dpy, win, &sizehints); - XSetStandardProperties(x_dpy, win, name, name, - None, (char **)NULL, 0, &sizehints); - } - - eglBindAPI(EGL_OPENGL_API); - ctx_win = eglCreateContext(dpy, config, EGL_NO_CONTEXT, NULL ); - if (!ctx_win) { - printf("Error: glXCreateContext failed\n"); - exit(1); - } - - surf_win = eglCreateWindowSurface(dpy, config, win, NULL); - - XFree(visInfo); - - *winRet = win; -} - -static void -use_window(void) -{ - static int initialized; - - eglMakeCurrent(dpy, surf_win, surf_win, ctx_win); - if (!initialized) { - initialized = 1; - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, tex_pbuf); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } -} - -static void -draw_triangle(void) -{ - static const GLfloat verts[3][2] = { - { -3, -3 }, - { 3, -3 }, - { 0, 3 } - }; - GLfloat colors[3][3] = { - { 1, 0, 0 }, - { 0, 1, 0 }, - { 0, 0, 1 } - }; - GLint i; - - /* flow the color */ - for (i = 0; i < 3; i++) { - GLint first = (i + color_flow / 256) % 3; - GLint second = (first + 1) % 3; - GLint third = (second + 1) % 3; - GLfloat c = (color_flow % 256) / 256.0f; - - c = c * c * c; - colors[i][first] = 1.0f - c; - colors[i][second] = c; - colors[i][third] = 0.0f; - } - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glVertexPointer(2, GL_FLOAT, 0, verts); - glColorPointer(3, GL_FLOAT, 0, colors); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); - - glDrawArrays(GL_TRIANGLES, 0, 3); - - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); -} - -static void -draw_textured_cube(void) -{ - static const GLfloat verts[][2] = { - { -4, -4 }, - { 4, -4 }, - { 4, 4 }, - { -4, 4 } - }; - static const GLfloat colors[][4] = { - { 1, 1, 1, 0.5 }, - { 1, 1, 1, 0.5 }, - { 1, 1, 1, 0.5 }, - { 1, 1, 1, 0.5 } - }; - static const GLfloat texs[][2] = { - { 0, 0 }, - { 1, 0 }, - { 1, 1 }, - { 0, 1 } - }; - static const GLfloat xforms[6][4] = { - { 0, 0, 1, 0 }, - { 90, 0, 1, 0 }, - { 180, 0, 1, 0 }, - { 270, 0, 1, 0 }, - { 90, 1, 0, 0 }, - { -90, 1, 0, 0 } - }; - GLint i; - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - if (blend) { - glDisable(GL_DEPTH_TEST); - glEnable(GL_BLEND); - } else { - glEnable(GL_DEPTH_TEST); - glDisable(GL_BLEND); - } - - glVertexPointer(2, GL_FLOAT, 0, verts); - glColorPointer(4, GL_FLOAT, 0, colors); - glTexCoordPointer(2, GL_FLOAT, 0, texs); - - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - - for (i = 0; i < 6; i++) { - glPushMatrix(); - glRotatef(xforms[i][0], xforms[i][1], xforms[i][2], xforms[i][3]); - glTranslatef(0, 0, 4.1); - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - glPopMatrix(); - } - - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); -} - -static void -draw(void) -{ - use_pbuffer(); - draw_triangle(); - - use_window(); - - eglBindTexImage(dpy, surf_pbuf, EGL_BACK_BUFFER); - - glPushMatrix(); - glRotatef(view_rotx, 1, 0, 0); - glRotatef(view_roty, 0, 1, 0); - glRotatef(view_rotz, 0, 0, 1); - - draw_textured_cube(); - - glPopMatrix(); - - eglReleaseTexImage(dpy, surf_pbuf, EGL_BACK_BUFFER); -} - -/* new window size or exposure */ -static void -reshape(int width, int height) -{ - GLfloat ar = (GLfloat) width / (GLfloat) height; - - use_window(); - - glViewport(0, 0, (GLint) width, (GLint) height); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum(-ar, ar, -1, 1, 5.0, 60.0); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.0, 0.0, -40.0); -} - -static void -event_loop(Display *x_dpy, Window win) -{ - while (1) { - int redraw = 1; - - if (XPending(x_dpy) > 0) { - XEvent event; - XNextEvent(x_dpy, &event); - - switch (event.type) { - case Expose: - redraw = 1; - break; - case ConfigureNotify: - reshape(event.xconfigure.width, event.xconfigure.height); - break; - case KeyPress: - { - char buffer[10]; - int r, code; - code = XLookupKeysym(&event.xkey, 0); - if (code == XK_Left) { - view_roty += 5.0; - } - else if (code == XK_Right) { - view_roty -= 5.0; - } - else if (code == XK_Up) { - view_rotx += 5.0; - } - else if (code == XK_Down) { - view_rotx -= 5.0; - } - else if (code == XK_b) { - blend = !blend; - } - else { - r = XLookupString(&event.xkey, buffer, sizeof(buffer), - NULL, NULL); - if (buffer[0] == 27) { - /* escape */ - return; - } - } - } - redraw = 1; - break; - default: - ; /*no-op*/ - } - } - - if (redraw) { - view_rotx += 1.0; - view_roty += 2.0; - view_rotz += 1.5; - color_flow += 20; - draw(); - eglSwapBuffers(dpy, surf_win); - } - } -} - -int -main(int argc, char *argv[]) -{ - const int winWidth = 300, winHeight = 300; - Display *x_dpy; - Window win; - char *dpyName = NULL; - EGLint egl_major, egl_minor; - const char *s; - - x_dpy = XOpenDisplay(dpyName); - if (!x_dpy) { - printf("Error: couldn't open display %s\n", - dpyName ? dpyName : getenv("DISPLAY")); - return -1; - } - - dpy = eglGetDisplay(x_dpy); - if (!dpy) { - printf("Error: eglGetDisplay() failed\n"); - return -1; - } - - if (!eglInitialize(dpy, &egl_major, &egl_minor)) { - printf("Error: eglInitialize() failed\n"); - return -1; - } - - s = eglQueryString(dpy, EGL_VERSION); - printf("EGL_VERSION = %s\n", s); - - make_window(x_dpy, "color flow", 0, 0, winWidth, winHeight, &win); - make_pbuffer(winWidth, winHeight); - - XMapWindow(x_dpy, win); - - reshape(winWidth, winHeight); - event_loop(x_dpy, win); - - glDeleteTextures(1, &tex_pbuf); - - eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - eglTerminate(dpy); - - XDestroyWindow(x_dpy, win); - XCloseDisplay(x_dpy); - - return 0; -} diff --git a/progs/es1/xegl/Makefile b/progs/es1/xegl/Makefile index 7f684d68e3..6869c44306 100644 --- a/progs/es1/xegl/Makefile +++ b/progs/es1/xegl/Makefile @@ -20,6 +20,7 @@ ES1_LIBS = \ -L$(TOP)/$(LIB_DIR) -lGLESv1_CM $(LIBDRM_LIB) -lX11 PROGRAMS = \ + bindtex \ drawtex \ es1_info \ msaa \ @@ -39,6 +40,10 @@ default: $(PROGRAMS) +bindtex: bindtex.o $(ES1_LIB_DEPS) + $(CC) $(CFLAGS) bindtex.o $(ES1_LIBS) -o $@ + + drawtex: drawtex.o $(ES1_LIB_DEPS) $(CC) $(CFLAGS) drawtex.o $(ES1_LIBS) -o $@ diff --git a/progs/es1/xegl/bindtex.c b/progs/es1/xegl/bindtex.c new file mode 100644 index 0000000000..c243b5941b --- /dev/null +++ b/progs/es1/xegl/bindtex.c @@ -0,0 +1,474 @@ +/* + * Simple demo for eglBindTexImage. Based on xegl_tri.c by + * + * Copyright (C) 2008 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL 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. + */ + +/* + * The spec says that eglBindTexImage supports only OpenGL ES context, but this + * demo uses OpenGL context. Keep in mind that this is non-standard. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static EGLDisplay dpy; +static EGLContext ctx_win, ctx_pbuf; +static EGLSurface surf_win, surf_pbuf; +static GLuint tex_pbuf; + +static GLfloat view_rotx = 0.0, view_roty = 0.0, view_rotz = 0.0; +static GLboolean blend = GL_TRUE; +static GLuint color_flow; + +static void +make_pbuffer(int width, int height) +{ + static const EGLint config_attribs[] = { + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_BIND_TO_TEXTURE_RGB, EGL_TRUE, + EGL_NONE + }; + EGLint pbuf_attribs[] = { + EGL_WIDTH, width, + EGL_HEIGHT, height, + EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB, + EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, + EGL_NONE + }; + EGLConfig config; + EGLint num_configs; + + if (!eglChooseConfig(dpy, config_attribs, &config, 1, &num_configs) || + !num_configs) { + printf("Error: couldn't get an EGL visual config for pbuffer\n"); + exit(1); + } + + ctx_pbuf = eglCreateContext(dpy, config, EGL_NO_CONTEXT, NULL ); + surf_pbuf = eglCreatePbufferSurface(dpy, config, pbuf_attribs); + if (surf_pbuf == EGL_NO_SURFACE) { + printf("failed to allocate pbuffer\n"); + exit(1); + } +} + +static void +use_pbuffer(void) +{ + static int initialized; + + eglMakeCurrent(dpy, surf_pbuf, surf_pbuf, ctx_pbuf); + if (!initialized) { + EGLint width, height; + GLfloat ar; + + initialized = 1; + + eglQuerySurface(dpy, surf_pbuf, EGL_WIDTH, &width); + eglQuerySurface(dpy, surf_pbuf, EGL_WIDTH, &height); + ar = (GLfloat) width / (GLfloat) height; + + glViewport(0, 0, (GLint) width, (GLint) height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustumf(-ar, ar, -1, 1, 1.0, 10.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + /* y-inverted */ + glScalef(1.0, -1.0, 1.0); + + glTranslatef(0.0, 0.0, -5.0); + + glClearColor(0.2, 0.2, 0.2, 0.0); + + glGenTextures(1, &tex_pbuf); + } +} + +static void +make_window(Display *x_dpy, const char *name, + int x, int y, int width, int height, + Window *winRet) +{ + static const EGLint attribs[] = { + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, 8, + EGL_DEPTH_SIZE, 8, + EGL_NONE + }; + + int scrnum; + XSetWindowAttributes attr; + unsigned long mask; + Window root; + Window win; + XVisualInfo *visInfo, visTemplate; + int num_visuals; + EGLConfig config; + EGLint num_configs, vid; + + scrnum = DefaultScreen( x_dpy ); + root = RootWindow( x_dpy, scrnum ); + + if (!eglChooseConfig(dpy, attribs, &config, 1, &num_configs) || + !num_configs) { + printf("Error: couldn't get an EGL visual config\n"); + exit(1); + } + + if (!eglGetConfigAttrib(dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) { + printf("Error: eglGetConfigAttrib() failed\n"); + exit(1); + } + + /* The X window visual must match the EGL config */ + visTemplate.visualid = vid; + visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals); + if (!visInfo) { + printf("Error: couldn't get X visual\n"); + exit(1); + } + + /* window attributes */ + attr.background_pixel = 0; + attr.border_pixel = 0; + attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone); + attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; + attr.override_redirect = 0; + mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect; + + win = XCreateWindow( x_dpy, root, 0, 0, width, height, + 0, visInfo->depth, InputOutput, + visInfo->visual, mask, &attr ); + + /* set hints and properties */ + { + XSizeHints sizehints; + sizehints.x = x; + sizehints.y = y; + sizehints.width = width; + sizehints.height = height; + sizehints.flags = USSize | USPosition; + XSetNormalHints(x_dpy, win, &sizehints); + XSetStandardProperties(x_dpy, win, name, name, + None, (char **)NULL, 0, &sizehints); + } + + ctx_win = eglCreateContext(dpy, config, EGL_NO_CONTEXT, NULL ); + if (!ctx_win) { + printf("Error: eglCreateContext failed\n"); + exit(1); + } + + surf_win = eglCreateWindowSurface(dpy, config, win, NULL); + + XFree(visInfo); + + *winRet = win; +} + +static void +use_window(void) +{ + static int initialized; + + eglMakeCurrent(dpy, surf_win, surf_win, ctx_win); + if (!initialized) { + initialized = 1; + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, tex_pbuf); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } +} + +static void +draw_triangle(void) +{ + static const GLfloat verts[3][2] = { + { -3, -3 }, + { 3, -3 }, + { 0, 3 } + }; + GLfloat colors[3][4] = { + { 1, 0, 0, 1 }, + { 0, 1, 0, 1 }, + { 0, 0, 1, 1 } + }; + GLint i; + + /* flow the color */ + for (i = 0; i < 3; i++) { + GLint first = (i + color_flow / 256) % 3; + GLint second = (first + 1) % 3; + GLint third = (second + 1) % 3; + GLfloat c = (color_flow % 256) / 256.0f; + + c = c * c * c; + colors[i][first] = 1.0f - c; + colors[i][second] = c; + colors[i][third] = 0.0f; + } + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + glVertexPointer(2, GL_FLOAT, 0, verts); + glColorPointer(4, GL_FLOAT, 0, colors); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + + glDrawArrays(GL_TRIANGLES, 0, 3); + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); +} + +static void +draw_textured_cube(void) +{ + static const GLfloat verts[][2] = { + { -4, -4 }, + { 4, -4 }, + { 4, 4 }, + { -4, 4 } + }; + static const GLfloat colors[][4] = { + { 1, 1, 1, 0.5 }, + { 1, 1, 1, 0.5 }, + { 1, 1, 1, 0.5 }, + { 1, 1, 1, 0.5 } + }; + static const GLfloat texs[][2] = { + { 0, 0 }, + { 1, 0 }, + { 1, 1 }, + { 0, 1 } + }; + static const GLfloat xforms[6][4] = { + { 0, 0, 1, 0 }, + { 90, 0, 1, 0 }, + { 180, 0, 1, 0 }, + { 270, 0, 1, 0 }, + { 90, 1, 0, 0 }, + { -90, 1, 0, 0 } + }; + GLint i; + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + if (blend) { + glDisable(GL_DEPTH_TEST); + glEnable(GL_BLEND); + } else { + glEnable(GL_DEPTH_TEST); + glDisable(GL_BLEND); + } + + glVertexPointer(2, GL_FLOAT, 0, verts); + glColorPointer(4, GL_FLOAT, 0, colors); + glTexCoordPointer(2, GL_FLOAT, 0, texs); + + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + for (i = 0; i < 6; i++) { + glPushMatrix(); + glRotatef(xforms[i][0], xforms[i][1], xforms[i][2], xforms[i][3]); + glTranslatef(0, 0, 4.1); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + glPopMatrix(); + } + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); +} + +static void +draw(void) +{ + use_pbuffer(); + draw_triangle(); + + use_window(); + + eglBindTexImage(dpy, surf_pbuf, EGL_BACK_BUFFER); + + glPushMatrix(); + glRotatef(view_rotx, 1, 0, 0); + glRotatef(view_roty, 0, 1, 0); + glRotatef(view_rotz, 0, 0, 1); + + draw_textured_cube(); + + glPopMatrix(); + + eglReleaseTexImage(dpy, surf_pbuf, EGL_BACK_BUFFER); +} + +/* new window size or exposure */ +static void +reshape(int width, int height) +{ + GLfloat ar = (GLfloat) width / (GLfloat) height; + + use_window(); + + glViewport(0, 0, (GLint) width, (GLint) height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustumf(-ar, ar, -1, 1, 5.0, 60.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -40.0); +} + +static void +event_loop(Display *x_dpy, Window win) +{ + while (1) { + int redraw = 1; + + if (XPending(x_dpy) > 0) { + XEvent event; + XNextEvent(x_dpy, &event); + + switch (event.type) { + case Expose: + redraw = 1; + break; + case ConfigureNotify: + reshape(event.xconfigure.width, event.xconfigure.height); + break; + case KeyPress: + { + char buffer[10]; + int r, code; + code = XLookupKeysym(&event.xkey, 0); + if (code == XK_Left) { + view_roty += 5.0; + } + else if (code == XK_Right) { + view_roty -= 5.0; + } + else if (code == XK_Up) { + view_rotx += 5.0; + } + else if (code == XK_Down) { + view_rotx -= 5.0; + } + else if (code == XK_b) { + blend = !blend; + } + else { + r = XLookupString(&event.xkey, buffer, sizeof(buffer), + NULL, NULL); + if (buffer[0] == 27) { + /* escape */ + return; + } + } + } + redraw = 1; + break; + default: + ; /*no-op*/ + } + } + + if (redraw) { + view_rotx += 1.0; + view_roty += 2.0; + view_rotz += 1.5; + color_flow += 20; + draw(); + eglSwapBuffers(dpy, surf_win); + } + } +} + +int +main(int argc, char *argv[]) +{ + const int winWidth = 300, winHeight = 300; + Display *x_dpy; + Window win; + char *dpyName = NULL; + EGLint egl_major, egl_minor; + const char *s; + + x_dpy = XOpenDisplay(dpyName); + if (!x_dpy) { + printf("Error: couldn't open display %s\n", + dpyName ? dpyName : getenv("DISPLAY")); + return -1; + } + + dpy = eglGetDisplay(x_dpy); + if (!dpy) { + printf("Error: eglGetDisplay() failed\n"); + return -1; + } + + if (!eglInitialize(dpy, &egl_major, &egl_minor)) { + printf("Error: eglInitialize() failed\n"); + return -1; + } + + s = eglQueryString(dpy, EGL_VERSION); + printf("EGL_VERSION = %s\n", s); + + make_window(x_dpy, "color flow", 0, 0, winWidth, winHeight, &win); + make_pbuffer(winWidth, winHeight); + + XMapWindow(x_dpy, win); + + reshape(winWidth, winHeight); + event_loop(x_dpy, win); + + glDeleteTextures(1, &tex_pbuf); + + eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglTerminate(dpy); + + XDestroyWindow(x_dpy, win); + XCloseDisplay(x_dpy); + + return 0; +} -- cgit v1.2.3 From 5a64bdaa0150c0d3883953237b7b8a910c98e5b3 Mon Sep 17 00:00:00 2001 From: Mathias Fröhlich Date: Sat, 30 Jan 2010 11:38:21 -0800 Subject: r300g: Add alpha render targets. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Corbin Simpson Tested-by: Mathias Fröhlich --- src/gallium/drivers/r300/r300_screen.c | 4 ++-- src/gallium/drivers/r300/r300_state_inlines.h | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index f311284d15..7df3ad02c8 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -217,6 +217,8 @@ static boolean r300_is_format_supported(struct pipe_screen* screen, case PIPE_FORMAT_A4R4G4B4_UNORM: case PIPE_FORMAT_R5G6B5_UNORM: case PIPE_FORMAT_A1R5G5B5_UNORM: + case PIPE_FORMAT_A8_UNORM: + case PIPE_FORMAT_L8_UNORM: retval = usage & (PIPE_TEXTURE_USAGE_RENDER_TARGET | PIPE_TEXTURE_USAGE_DISPLAY_TARGET | @@ -231,8 +233,6 @@ static boolean r300_is_format_supported(struct pipe_screen* screen, case PIPE_FORMAT_DXT3_RGBA: case PIPE_FORMAT_DXT5_RGBA: case PIPE_FORMAT_YCBCR: - case PIPE_FORMAT_L8_UNORM: - case PIPE_FORMAT_A8_UNORM: case PIPE_FORMAT_A8L8_UNORM: retval = usage & PIPE_TEXTURE_USAGE_SAMPLER; break; diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index e2180b33b7..faa049492f 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -331,7 +331,10 @@ static INLINE uint32_t r300_translate_colorformat(enum pipe_format format) { switch (format) { /* 8-bit buffers */ + case PIPE_FORMAT_A8_UNORM: case PIPE_FORMAT_I8_UNORM: + case PIPE_FORMAT_L8_UNORM: + /* case PIPE_FORMAT_S8_UNORM: ??? */ return R300_COLOR_FORMAT_I8; /* 16-bit buffers */ case PIPE_FORMAT_R5G6B5_UNORM: @@ -408,6 +411,16 @@ static INLINE uint32_t r300_translate_out_fmt(enum pipe_format format) return R300_US_OUT_FMT_C4_8 | R300_C0_SEL_A | R300_C1_SEL_B | R300_C2_SEL_G | R300_C3_SEL_R; + + /* 8-bit outputs */ + case PIPE_FORMAT_A8_UNORM: + return R300_US_OUT_FMT_C4_8 | + R300_C0_SEL_A; + case PIPE_FORMAT_I8_UNORM: + case PIPE_FORMAT_L8_UNORM: + return R300_US_OUT_FMT_C4_8 | + R300_C0_SEL_R; + /* R300_OUT_SIGN(x) */ default: debug_printf("r300: Implementation error: " "Got unsupported output format %s in %s\n", -- cgit v1.2.3 From bfbec0818f0e7ab9358809a1af732a1366245507 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 30 Jan 2010 12:03:20 -0800 Subject: r300g: Dual-source blending isn't possible, period. --- src/gallium/drivers/r300/r300_screen.c | 1 - src/gallium/drivers/r300/r300_state_inlines.h | 14 +++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index 7df3ad02c8..ae3155c0ed 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -114,7 +114,6 @@ static int r300_get_param(struct pipe_screen* pscreen, int param) */ return 1; case PIPE_CAP_DUAL_SOURCE_BLEND: - /* XXX need to figure out how to do it */ return 0; case PIPE_CAP_ANISOTROPIC_FILTER: return 1; diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index faa049492f..5df6815221 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -81,9 +81,6 @@ static INLINE uint32_t r300_translate_blend_factor(int blend_fact) return R300_BLEND_GL_CONST_COLOR; case PIPE_BLENDFACTOR_CONST_ALPHA: return R300_BLEND_GL_CONST_ALPHA; - /* XXX WTF are these? - case PIPE_BLENDFACTOR_SRC1_COLOR: - case PIPE_BLENDFACTOR_SRC1_ALPHA: */ case PIPE_BLENDFACTOR_ZERO: return R300_BLEND_GL_ZERO; case PIPE_BLENDFACTOR_INV_SRC_COLOR: @@ -98,9 +95,16 @@ static INLINE uint32_t r300_translate_blend_factor(int blend_fact) return R300_BLEND_GL_ONE_MINUS_CONST_COLOR; case PIPE_BLENDFACTOR_INV_CONST_ALPHA: return R300_BLEND_GL_ONE_MINUS_CONST_ALPHA; - /* XXX see above + + case PIPE_BLENDFACTOR_SRC1_COLOR: + case PIPE_BLENDFACTOR_SRC1_ALPHA: case PIPE_BLENDFACTOR_INV_SRC1_COLOR: - case PIPE_BLENDFACTOR_INV_SRC1_ALPHA: */ + case PIPE_BLENDFACTOR_INV_SRC1_ALPHA: + debug_printf("r300: Implementation error: " + "Bad blend factor %d not supported!\n", blend_fact); + assert(0); + break; + default: debug_printf("r300: Unknown blend factor %d\n", blend_fact); assert(0); -- cgit v1.2.3 From 268cc5ff38d3df96781b53bbbdfc3fd7cfe09fc2 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 30 Jan 2010 12:11:28 -0800 Subject: gallium-docs: Fix missing PIPE_CAPs. Hmm, need to cross-ref those TGSI things. My work is never done... :3 --- src/gallium/docs/source/glossary.rst | 4 ++++ src/gallium/docs/source/screen.rst | 18 ++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/gallium/docs/source/glossary.rst b/src/gallium/docs/source/glossary.rst index e49141b5e2..0696cb5d27 100644 --- a/src/gallium/docs/source/glossary.rst +++ b/src/gallium/docs/source/glossary.rst @@ -17,3 +17,7 @@ Glossary NPOT Non-power-of-two. Usually applied to textures which have at least one dimension which is not a power of two. + + LOD + Level of Detail. Also spelled "LoD." The value that determines when the + switches between mipmaps occur during texture sampling. diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index 0507b81627..3e57a282fd 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -57,14 +57,20 @@ The integer capabilities: only permit binding one constant buffer per shader, and the shaders will not permit two-dimensional access to constants. * ``MAX_CONST_BUFFER_SIZE``: Maximum byte size of a single constant buffer. +* ``INDEP_BLEND_ENABLE``: Whether per-rendertarget blend enabling and channel + masks are supported. If 0, then the first rendertarget's blend mask is + replicated across all MRTs. +* ``INDEP_BLEND_FUNC``: Whether per-rendertarget blend functions are + available. If 0, then the first rendertarget's blend functions affect all + MRTs. * ``PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT``: Whether the TGSI property - FS_COORD_ORIGIN with value UPPER_LEFT is supported + FS_COORD_ORIGIN with value UPPER_LEFT is supported. * ``PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT``: Whether the TGSI property - FS_COORD_ORIGIN with value LOWER_LEFT is supported + FS_COORD_ORIGIN with value LOWER_LEFT is supported. * ``PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER``: Whether the TGSI - property FS_COORD_PIXEL_CENTER with value HALF_INTEGER is supported + property FS_COORD_PIXEL_CENTER with value HALF_INTEGER is supported. * ``PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER``: Whether the TGSI - property FS_COORD_PIXEL_CENTER with value INTEGER is supported + property FS_COORD_PIXEL_CENTER with value INTEGER is supported. The floating-point capabilities: @@ -72,6 +78,10 @@ The floating-point capabilities: * ``MAX_LINE_WIDTH_AA``: The maximum width of a smoothed line. * ``MAX_POINT_WIDTH``: The maximum width and height of a point. * ``MAX_POINT_WIDTH_AA``: The maximum width and height of a smoothed point. +* ``MAX_TEXTURE_ANISOTROPY``: The maximum level of anisotropy that can be + applied to anisotropically filtered textures. +* ``MAX_TEXTURE_LOD_BIAS``: The maximum :term:`LOD` bias that may be applied + to filtered textures. * ``GUARD_BAND_LEFT``, ``GUARD_BAND_TOP``, ``GUARD_BAND_RIGHT``, ``GUARD_BAND_BOTTOM``: XXX -- cgit v1.2.3 From f7467f7437af57c1b1c9686c05ea5f1be25176f1 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 30 Jan 2010 12:23:24 -0800 Subject: r300g: Fix comment on SHADOW_AMBIENT. --- src/gallium/drivers/r300/r300_emit.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 9e813569e3..a429457625 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -170,9 +170,8 @@ static const float * get_shader_constant( vec[1] = 1.0 / tex->height0; break; - /* Texture compare-fail value. */ - /* XXX Since Gallium doesn't support GL_ARB_shadow_ambient, - * this is always (0,0,0,0), right? */ + /* Texture compare-fail value. Shouldn't ever show up, but if + * it does, we'll be ready. */ case RC_STATE_SHADOW_AMBIENT: vec[3] = 0; break; -- cgit v1.2.3 From 627a45848faf9e6d19d386b9eb30d36bf18d0998 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 30 Jan 2010 12:23:43 -0800 Subject: r300g: Don't handle SHADOW_AMBIENT. Bisected so that only this commit has to be reverted if I'm wrong. ...Pfft, like I'm ever wrong. :3 --- src/gallium/drivers/r300/r300_emit.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index a429457625..04001ee129 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -170,12 +170,6 @@ static const float * get_shader_constant( vec[1] = 1.0 / tex->height0; break; - /* Texture compare-fail value. Shouldn't ever show up, but if - * it does, we'll be ready. */ - case RC_STATE_SHADOW_AMBIENT: - vec[3] = 0; - break; - case RC_STATE_R300_VIEWPORT_SCALE: if (r300->tcl_bypass) { vec[0] = 1; -- cgit v1.2.3 From b6ac2403aca240c72c8622ddbc3a4e123d5aa37f Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 30 Jan 2010 12:33:44 -0800 Subject: r300g: Independent blend enables only work on r500. --- src/gallium/drivers/r300/r300_screen.c | 6 +++++- src/gallium/drivers/r300/r300_state.c | 15 +++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index ae3155c0ed..fa8ed581da 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -152,7 +152,11 @@ static int r300_get_param(struct pipe_screen* pscreen, int param) return 0; } case PIPE_CAP_INDEP_BLEND_ENABLE: - return 1; + if (r300screen->caps->is_r500) { + return 1; + } else { + return 0; + } case PIPE_CAP_INDEP_BLEND_FUNC: return 0; case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 8295799553..a5c0869066 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -161,6 +161,7 @@ static boolean blend_discard_if_src_alpha_color_1(unsigned srcRGB, unsigned srcA static void* r300_create_blend_state(struct pipe_context* pipe, const struct pipe_blend_state* state) { + struct r300_screen* r300screen = r300_screen(pipe->screen); struct r300_blend_state* blend = CALLOC_STRUCT(r300_blend_state); if (state->rt[0].blend_enable) @@ -290,10 +291,16 @@ static void* r300_create_blend_state(struct pipe_context* pipe, /* Color channel masks for all MRTs. */ blend->color_channel_mask = state->rt[0].colormask; - if (state->independent_blend_enable) { - blend->color_channel_mask |= (state->rt[1].colormask << 4); - blend->color_channel_mask |= (state->rt[2].colormask << 8); - blend->color_channel_mask |= (state->rt[3].colormask << 12); + if (r300screen->caps->is_r500 && state->independent_blend_enable) { + if (state->rt[1].blend_enable) { + blend->color_channel_mask |= (state->rt[1].colormask << 4); + } + if (state->rt[2].blend_enable) { + blend->color_channel_mask |= (state->rt[2].colormask << 8); + } + if (state->rt[3].blend_enable) { + blend->color_channel_mask |= (state->rt[3].colormask << 12); + } } if (state->dither) { -- cgit v1.2.3 From a44219c5543ade267f668312e1faf773c41eedb8 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 30 Jan 2010 12:37:54 -0800 Subject: intel: Fix inverting of inversion test for windows in glClear cleanup. Bug #26290. --- src/mesa/drivers/dri/intel/intel_blit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c index f12a1c6fd3..31d4f3d421 100644 --- a/src/mesa/drivers/dri/intel/intel_blit.c +++ b/src/mesa/drivers/dri/intel/intel_blit.c @@ -229,9 +229,9 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask) cx = fb->_Xmin; if (fb->Name == 0) - cy = fb->_Ymin; - else cy = ctx->DrawBuffer->Height - fb->_Ymax; + else + cy = fb->_Ymin; cw = fb->_Xmax - fb->_Xmin; ch = fb->_Ymax - fb->_Ymin; -- cgit v1.2.3 From a794c660d30b04ed50482cf2f26e0a7f9687319e Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 30 Jan 2010 14:09:04 -0800 Subject: Revert "r300g: Don't handle SHADOW_AMBIENT." This reverts commit 627a45848faf9e6d19d386b9eb30d36bf18d0998. I was wrong. Who could have known? :3 --- src/gallium/drivers/r300/r300_emit.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 04001ee129..a429457625 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -170,6 +170,12 @@ static const float * get_shader_constant( vec[1] = 1.0 / tex->height0; break; + /* Texture compare-fail value. Shouldn't ever show up, but if + * it does, we'll be ready. */ + case RC_STATE_SHADOW_AMBIENT: + vec[3] = 0; + break; + case RC_STATE_R300_VIEWPORT_SCALE: if (r300->tcl_bypass) { vec[0] = 1; -- cgit v1.2.3 From 22bbc979944084ddffbb2c42a8178e172beaece0 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 30 Jan 2010 15:11:09 -0800 Subject: intel: Respect texture tiling when doing a PBO blit teximage upload. Bug #26008. Fixes piglit pbo-teximage-tiling-2. --- src/mesa/drivers/dri/intel/intel_tex_image.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c index f5d0dabebb..a56e085b90 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_image.c +++ b/src/mesa/drivers/dri/intel/intel_tex_image.c @@ -240,7 +240,8 @@ try_pbo_upload(struct intel_context *intel, if (!intelEmitCopyBlit(intel, intelImage->mt->cpp, src_stride, src_buffer, src_offset, GL_FALSE, - dst_stride, dst_buffer, 0, GL_FALSE, + dst_stride, dst_buffer, 0, + intelImage->mt->region->tiling, 0, 0, dst_x, dst_y, width, height, GL_COPY)) { return GL_FALSE; -- cgit v1.2.3 From c641703f21c858464ca34a1f99c79ccfd9a85d70 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 30 Jan 2010 18:54:56 -0800 Subject: i915: Remove unnecessary headers. --- src/mesa/drivers/dri/i915/i915_vtbl.c | 1 - src/mesa/drivers/dri/i915/intel_tris.c | 1 - 2 files changed, 2 deletions(-) diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c b/src/mesa/drivers/dri/i915/i915_vtbl.c index 3dda5339c3..392126b7dc 100644 --- a/src/mesa/drivers/dri/i915/i915_vtbl.c +++ b/src/mesa/drivers/dri/i915/i915_vtbl.c @@ -40,7 +40,6 @@ #include "intel_regions.h" #include "intel_tris.h" #include "intel_fbo.h" -#include "intel_chipset.h" #include "i915_reg.h" #include "i915_context.h" diff --git a/src/mesa/drivers/dri/i915/intel_tris.c b/src/mesa/drivers/dri/i915/intel_tris.c index 763c1a0ae7..6d498c5654 100644 --- a/src/mesa/drivers/dri/i915/intel_tris.c +++ b/src/mesa/drivers/dri/i915/intel_tris.c @@ -52,7 +52,6 @@ #include "intel_buffers.h" #include "intel_reg.h" #include "intel_span.h" -#include "intel_chipset.h" #include "i830_context.h" #include "i830_reg.h" -- cgit v1.2.3 From 6e0f702b23ebdc9fbf6b20697624bc77be08383e Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 30 Jan 2010 19:01:19 -0800 Subject: i965: Remove unnecessary headers. --- src/mesa/drivers/dri/i965/brw_fallback.c | 1 - src/mesa/drivers/dri/i965/brw_state_dump.c | 1 - src/mesa/drivers/dri/i965/brw_tex_layout.c | 1 - 3 files changed, 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fallback.c b/src/mesa/drivers/dri/i965/brw_fallback.c index 79691c3a0f..ba401c215c 100644 --- a/src/mesa/drivers/dri/i965/brw_fallback.c +++ b/src/mesa/drivers/dri/i965/brw_fallback.c @@ -36,7 +36,6 @@ #include "swrast/swrast.h" #include "tnl/tnl.h" #include "brw_context.h" -#include "intel_chipset.h" #include "intel_fbo.h" #include "intel_regions.h" diff --git a/src/mesa/drivers/dri/i965/brw_state_dump.c b/src/mesa/drivers/dri/i965/brw_state_dump.c index e94fa7d2b4..020ac523b6 100644 --- a/src/mesa/drivers/dri/i965/brw_state_dump.c +++ b/src/mesa/drivers/dri/i965/brw_state_dump.c @@ -28,7 +28,6 @@ #include "main/mtypes.h" #include "brw_context.h" -#include "brw_state.h" #include "brw_defines.h" /** diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c b/src/mesa/drivers/dri/i965/brw_tex_layout.c index 64a9535282..09edfd81fd 100644 --- a/src/mesa/drivers/dri/i965/brw_tex_layout.c +++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c @@ -36,7 +36,6 @@ #include "intel_tex_layout.h" #include "intel_context.h" #include "main/macros.h" -#include "intel_chipset.h" #define FILE_DEBUG_FLAG DEBUG_MIPTREE -- cgit v1.2.3 From c6e26d76c7f59b51be00c960112c85ad4b3d2334 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 30 Jan 2010 19:11:31 -0800 Subject: intel: Remove unnecessary headers. --- src/mesa/drivers/dri/intel/intel_buffers.c | 1 - src/mesa/drivers/dri/intel/intel_context.c | 2 -- src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 1 - src/mesa/drivers/dri/intel/intel_pixel_draw.c | 1 - src/mesa/drivers/dri/intel/intel_screen.c | 2 -- src/mesa/drivers/dri/intel/intel_tex_format.c | 1 - 6 files changed, 8 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_buffers.c b/src/mesa/drivers/dri/intel/intel_buffers.c index 5bf0bdb963..2f03e45005 100644 --- a/src/mesa/drivers/dri/intel/intel_buffers.c +++ b/src/mesa/drivers/dri/intel/intel_buffers.c @@ -28,7 +28,6 @@ #include "intel_context.h" #include "intel_buffers.h" #include "intel_fbo.h" -#include "intel_batchbuffer.h" #include "main/framebuffer.h" /** diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 3896bfa091..0adee6131e 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -51,13 +51,11 @@ #include "intel_regions.h" #include "intel_buffer_objects.h" #include "intel_fbo.h" -#include "intel_decode.h" #include "intel_bufmgr.h" #include "intel_screen.h" #include "drirenderbuffer.h" #include "utils.h" -#include "xmlpool.h" /* for symbolic values of enum-type options */ #ifndef INTEL_DEBUG diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c index 82e4150c6a..cb5a341050 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c @@ -29,7 +29,6 @@ #include "intel_mipmap_tree.h" #include "intel_regions.h" #include "intel_tex_layout.h" -#include "intel_chipset.h" #ifndef I915 #include "brw_state.h" #endif diff --git a/src/mesa/drivers/dri/intel/intel_pixel_draw.c b/src/mesa/drivers/dri/intel/intel_pixel_draw.c index 7e82c5b8aa..10177228bd 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_draw.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_draw.c @@ -46,7 +46,6 @@ #include "drivers/common/meta.h" #include "intel_context.h" -#include "intel_buffers.h" #include "intel_pixel.h" #include "intel_fbo.h" diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index 96e7f2885a..e8cc202f88 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -38,12 +38,10 @@ #include "intel_bufmgr.h" #include "intel_chipset.h" #include "intel_fbo.h" -#include "intel_regions.h" #include "intel_screen.h" #include "intel_tex.h" #include "i915_drm.h" -#include "i830_dri.h" #define DRI_CONF_TEXTURE_TILING(def) \ DRI_CONF_OPT_BEGIN(texture_tiling, bool, def) \ diff --git a/src/mesa/drivers/dri/intel/intel_tex_format.c b/src/mesa/drivers/dri/intel/intel_tex_format.c index a7c6c45ffe..7be5231eae 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_format.c +++ b/src/mesa/drivers/dri/intel/intel_tex_format.c @@ -1,6 +1,5 @@ #include "intel_context.h" #include "intel_tex.h" -#include "intel_chipset.h" #include "main/enums.h" -- cgit v1.2.3 From 6d12c7083e81625e1468351ef5e24e9168f0d549 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 31 Jan 2010 01:18:18 +0800 Subject: st/egl: Remove egl_g3d_get_current_context. There is now _eglGetAPIContext that can return the current context of the given API. --- src/gallium/state_trackers/egl/common/egl_g3d.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index f4c4032086..e8f46e56bc 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -243,17 +243,6 @@ egl_g3d_realloc_context(_EGLDisplay *dpy, _EGLContext *ctx) return EGL_TRUE; } -/** - * Return the current context of the given API. - */ -static struct egl_g3d_context * -egl_g3d_get_current_context(EGLint api) -{ - _EGLThreadInfo *t = _eglGetCurrentThread(); - EGLint api_index = _eglConvertApiToIndex(api); - return egl_g3d_context(t->CurrentContexts[api_index]); -} - /** * Return the state tracker for the given context. */ @@ -1098,7 +1087,8 @@ egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint buffer) { struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - struct egl_g3d_context *gctx; + _EGLContext *ctx = _eglGetAPIContext(EGL_OPENGL_ES_API); + struct egl_g3d_context *gctx = egl_g3d_context(ctx); enum pipe_format target_format; int target; @@ -1135,7 +1125,6 @@ egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); } - gctx = egl_g3d_get_current_context(EGL_OPENGL_ES_API); if (gctx) { if (!gsurf->render_surface) return EGL_FALSE; @@ -1161,9 +1150,8 @@ egl_g3d_release_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, return _eglError(EGL_BAD_PARAMETER, "eglReleaseTexImage"); if (gsurf->render_surface) { - _EGLThreadInfo *t = _eglGetCurrentThread(); - struct egl_g3d_context *gctx = egl_g3d_context( - t->CurrentContexts[_eglConvertApiToIndex(EGL_OPENGL_ES_API)]); + _EGLContext *ctx = _eglGetAPIContext(EGL_OPENGL_ES_API); + struct egl_g3d_context *gctx = egl_g3d_context(ctx); /* what if the context the surface binds to is no longer current? */ if (gctx) -- cgit v1.2.3 From 66f0517695668ba9a30618015a94bfea4ba08a9b Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 31 Jan 2010 01:25:59 +0800 Subject: st/egl: Do not ignore configs without a renderable type. Configs without a renderable type are still informative for programs such as eglinfo. --- src/gallium/state_trackers/egl/common/egl_g3d.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index e8f46e56bc..6c8f3b9f79 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -464,18 +464,18 @@ egl_g3d_add_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint id) struct egl_g3d_config *gconf; EGLBoolean valid; + gconf = CALLOC_STRUCT(egl_g3d_config); + if (!gconf) + continue; + + _eglInitConfig(&gconf->base, id); + api_mask = get_mode_api_mask(&native_configs[i]->mode, gdrv->api_mask); if (!api_mask) { _eglLog(_EGL_DEBUG, "no state tracker supports config 0x%x", native_configs[i]->mode.visualID); - continue; } - gconf = CALLOC_STRUCT(egl_g3d_config); - if (!gconf) - continue; - - _eglInitConfig(&gconf->base, id); valid = _eglConfigFromContextModesRec(&gconf->base, &native_configs[i]->mode, api_mask, api_mask); if (valid) { -- cgit v1.2.3 From 89e6eb5fbe7fb036f5d1a5fef040cc9635a10672 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 31 Jan 2010 01:57:37 +0800 Subject: progs/egl: Update eglinfo to display more attributes. Add config caveat, bind-to-texture, and renderable type. Remove double buffer and stereo attributes. --- progs/egl/Makefile | 2 +- progs/egl/eglinfo.c | 30 ++++++++++++++++++++---------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/progs/egl/Makefile b/progs/egl/Makefile index 68bb5679f8..0ddb2cabb4 100644 --- a/progs/egl/Makefile +++ b/progs/egl/Makefile @@ -45,7 +45,7 @@ egltri: egltri.o $(HEADERS) $(LIB_DEP) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(LIBDRM_LIB) eglinfo: eglinfo.o $(HEADERS) $(LIB_DEP) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(LIBDRM_LIB) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) eglgears: eglgears.o $(HEADERS) $(LIB_DEP) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(LIBDRM_LIB) diff --git a/progs/egl/eglinfo.c b/progs/egl/eglinfo.c index 4486916e95..9664667a68 100644 --- a/progs/egl/eglinfo.c +++ b/progs/egl/eglinfo.c @@ -49,16 +49,15 @@ PrintConfigs(EGLDisplay d) eglGetConfigs(d, configs, MAX_CONFIGS, &numConfigs); printf("Configurations:\n"); - printf(" bf lv d st colorbuffer dp st ms vis supported\n"); - printf(" id sz l b ro r g b a th cl ns b id surfaces \n"); - printf("--------------------------------------------------------\n"); + printf(" bf lv colorbuffer dp st ms vis cav bi renderable supported\n"); + printf(" id sz l r g b a th cl ns b id eat nd gl es es2 vg surfaces \n"); + printf("---------------------------------------------------------------------\n"); for (i = 0; i < numConfigs; i++) { EGLint id, size, level; EGLint red, green, blue, alpha; EGLint depth, stencil; - EGLint surfaces; - EGLint doubleBuf = 1, stereo = 0; - EGLint vid; + EGLint renderable, surfaces; + EGLint vid, caveat, bindRgb, bindRgba; EGLint samples, sampleBuffers; char surfString[100] = ""; @@ -73,6 +72,11 @@ PrintConfigs(EGLDisplay d) eglGetConfigAttrib(d, configs[i], EGL_DEPTH_SIZE, &depth); eglGetConfigAttrib(d, configs[i], EGL_STENCIL_SIZE, &stencil); eglGetConfigAttrib(d, configs[i], EGL_NATIVE_VISUAL_ID, &vid); + + eglGetConfigAttrib(d, configs[i], EGL_CONFIG_CAVEAT, &caveat); + eglGetConfigAttrib(d, configs[i], EGL_BIND_TO_TEXTURE_RGB, &bindRgb); + eglGetConfigAttrib(d, configs[i], EGL_BIND_TO_TEXTURE_RGBA, &bindRgba); + eglGetConfigAttrib(d, configs[i], EGL_RENDERABLE_TYPE, &renderable); eglGetConfigAttrib(d, configs[i], EGL_SURFACE_TYPE, &surfaces); eglGetConfigAttrib(d, configs[i], EGL_SAMPLES, &samples); @@ -91,13 +95,19 @@ PrintConfigs(EGLDisplay d) if (strlen(surfString) > 0) surfString[strlen(surfString) - 1] = 0; - printf("0x%02x %2d %2d %c %c %2d %2d %2d %2d %2d %2d %2d%2d 0x%02x %-12s\n", + printf("0x%02x %2d %2d %2d %2d %2d %2d %2d %2d %2d%2d 0x%03x ", id, size, level, - doubleBuf ? 'y' : '.', - stereo ? 'y' : '.', red, green, blue, alpha, depth, stencil, - samples, sampleBuffers, vid, surfString); + samples, sampleBuffers, vid); + printf(" %c %c %c %c %c %c %s\n", + (caveat != EGL_NONE) ? 'y' : ' ', + (bindRgba) ? 'a' : (bindRgb) ? 'y' : ' ', + (renderable & EGL_OPENGL_BIT) ? 'y' : ' ', + (renderable & EGL_OPENGL_ES_BIT) ? 'y' : ' ', + (renderable & EGL_OPENGL_ES2_BIT) ? 'y' : ' ', + (renderable & EGL_OPENVG_BIT) ? 'y' : ' ', + surfString); } } -- cgit v1.2.3 From 996fd61442e4186e23418cc8a3b0cd593398be26 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 31 Jan 2010 11:26:56 +0800 Subject: egl: Remove code blocks that are commented out. They are either unit tests or to demonstrate how functions are supposed to be used. The unit test is outdated and it should be better to take a look at any of the working drivers to see how a function is used. --- src/egl/main/eglcontext.c | 14 -------------- src/egl/main/eglmode.c | 38 ------------------------------------- src/egl/main/eglscreen.c | 17 +---------------- src/egl/main/eglsurface.c | 48 +++-------------------------------------------- 4 files changed, 4 insertions(+), 113 deletions(-) diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index 37c4b25b68..d0c6b1b64c 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -58,20 +58,6 @@ _EGLContext * _eglCreateContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, _EGLContext *share_list, const EGLint *attrib_list) { -#if 0 /* example code */ - _EGLContext *context; - - context = (_EGLContext *) calloc(1, sizeof(_EGLContext)); - if (!context) - return NULL; - - if (!_eglInitContext(drv, context, conf, attrib_list)) { - free(context); - return NULL; - } - - return context; -#endif return NULL; } diff --git a/src/egl/main/eglmode.c b/src/egl/main/eglmode.c index 1e26ea83f5..66446c0495 100644 --- a/src/egl/main/eglmode.c +++ b/src/egl/main/eglmode.c @@ -350,41 +350,3 @@ _eglQueryModeStringMESA(_EGLDriver *drv, _EGLDisplay *dpy, _EGLMode *m) { return m->Name; } - - -#if 0 -static int -_eglRand(int max) -{ - return rand() % max; -} - -void -_eglTestModeModule(void) -{ - EGLint count = 30; - _EGLMode *modes = (_EGLMode *) malloc(count * sizeof(_EGLMode)); - _EGLMode **modeList = (_EGLMode **) malloc(count * sizeof(_EGLMode*)); - EGLint i; - - for (i = 0; i < count; i++) { - modes[i].Handle = _eglRand(20); - modes[i].Width = 512 + 256 * _eglRand(2); - modes[i].Height = 512 + 256 * _eglRand(2); - modes[i].RefreshRate = 50 + 5 * _eglRand(3); - modes[i].Interlaced = _eglRand(2); - modes[i].Optimal = _eglRand(4) == 0; - modeList[i] = modes + i; - } - - /* sort array of pointers */ - qsort(modeList, count, sizeof(_EGLMode *), compareModes); - - for (i = 0; i < count; i++) { - _EGLMode *m = modeList[i]; - printf("%2d: %3d %4d x %4d @ %3d opt %d int %d\n", i, - m->Handle, m->Width, m->Height, m->RefreshRate, - m->Optimal, m->Interlaced); - } -} -#endif diff --git a/src/egl/main/eglscreen.c b/src/egl/main/eglscreen.c index 1079a1cbe6..97a405a4b4 100644 --- a/src/egl/main/eglscreen.c +++ b/src/egl/main/eglscreen.c @@ -111,27 +111,12 @@ _eglGetScreensMESA(_EGLDriver *drv, _EGLDisplay *display, EGLScreenMESA *screens /** - * Example function - drivers should do a proper implementation. + * Drivers should do a proper implementation. */ _EGLSurface * _eglCreateScreenSurfaceMESA(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, const EGLint *attrib_list) { -#if 0 /* THIS IS JUST EXAMPLE CODE */ - _EGLSurface *surf; - - surf = (_EGLSurface *) calloc(1, sizeof(_EGLSurface)); - if (!surf) - return NULL; - - if (!_eglInitSurface(drv, surf, EGL_SCREEN_BIT_MESA, - conf, attrib_list)) { - free(surf); - return NULL; - } - - return surf; -#endif return NULL; } diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index 8f87239fe2..aa2da9dd09 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -314,76 +314,34 @@ _eglQuerySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, /** - * Example function - drivers should do a proper implementation. + * Drivers should do a proper implementation. */ _EGLSurface * _eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, EGLNativeWindowType window, const EGLint *attrib_list) { -#if 0 /* THIS IS JUST EXAMPLE CODE */ - _EGLSurface *surf; - - surf = (_EGLSurface *) calloc(1, sizeof(_EGLSurface)); - if (!surf) - return NULL; - - if (!_eglInitSurface(drv, surf, EGL_WINDOW_BIT, conf, attrib_list)) { - free(surf); - return NULL; - } - - return surf; -#endif return NULL; } /** - * Example function - drivers should do a proper implementation. + * Drivers should do a proper implementation. */ _EGLSurface * _eglCreatePixmapSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, EGLNativePixmapType pixmap, const EGLint *attrib_list) { -#if 0 /* THIS IS JUST EXAMPLE CODE */ - _EGLSurface *surf; - - surf = (_EGLSurface *) calloc(1, sizeof(_EGLSurface)); - if (!surf) - return NULL; - - if (!_eglInitSurface(drv, surf, EGL_PIXMAP_BIT, conf, attrib_list)) { - free(surf); - return NULL; - } - - return surf; -#endif return NULL; } /** - * Example function - drivers should do a proper implementation. + * Drivers should do a proper implementation. */ _EGLSurface * _eglCreatePbufferSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, const EGLint *attrib_list) { -#if 0 /* THIS IS JUST EXAMPLE CODE */ - _EGLSurface *surf; - - surf = (_EGLSurface *) calloc(1, sizeof(_EGLSurface)); - if (!surf) - return NULL; - - if (!_eglInitSurface(drv, surf, EGL_PBUFFER_BIT, conf, attrib_list)) { - free(surf); - return NULL; - } - - return NULL; -#endif return NULL; } -- cgit v1.2.3 From 12eb32e34244db9923cacaaed9ba951b7ac274a4 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 30 Jan 2010 20:24:13 -0800 Subject: r128: Remove unnecessary headers. --- src/mesa/drivers/dri/r128/r128_context.c | 1 - src/mesa/drivers/dri/r128/r128_dd.c | 3 --- src/mesa/drivers/dri/r128/r128_lock.c | 2 -- src/mesa/drivers/dri/r128/r128_screen.c | 1 - src/mesa/drivers/dri/r128/r128_span.c | 2 -- src/mesa/drivers/dri/r128/r128_state.c | 2 -- src/mesa/drivers/dri/r128/r128_tex.c | 5 ----- src/mesa/drivers/dri/r128/r128_texmem.c | 3 --- src/mesa/drivers/dri/r128/r128_texstate.c | 1 - 9 files changed, 20 deletions(-) diff --git a/src/mesa/drivers/dri/r128/r128_context.c b/src/mesa/drivers/dri/r128/r128_context.c index e389e1c87b..67e9240505 100644 --- a/src/mesa/drivers/dri/r128/r128_context.c +++ b/src/mesa/drivers/dri/r128/r128_context.c @@ -36,7 +36,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/context.h" #include "main/simple_list.h" #include "main/imports.h" -#include "main/matrix.h" #include "main/extensions.h" #include "swrast/swrast.h" diff --git a/src/mesa/drivers/dri/r128/r128_dd.c b/src/mesa/drivers/dri/r128/r128_dd.c index dfe47f2dd6..64dec70cdd 100644 --- a/src/mesa/drivers/dri/r128/r128_dd.c +++ b/src/mesa/drivers/dri/r128/r128_dd.c @@ -34,12 +34,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_context.h" #include "r128_ioctl.h" -#include "r128_state.h" #include "r128_dd.h" -#include "swrast/swrast.h" #include "main/context.h" -#include "main/framebuffer.h" #include "utils.h" diff --git a/src/mesa/drivers/dri/r128/r128_lock.c b/src/mesa/drivers/dri/r128/r128_lock.c index 9bc3515b5a..c1fa068d1f 100644 --- a/src/mesa/drivers/dri/r128/r128_lock.c +++ b/src/mesa/drivers/dri/r128/r128_lock.c @@ -33,8 +33,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_context.h" #include "r128_lock.h" -#include "r128_tex.h" -#include "r128_state.h" #include "drirenderbuffer.h" diff --git a/src/mesa/drivers/dri/r128/r128_screen.c b/src/mesa/drivers/dri/r128/r128_screen.c index 80b265811e..ef6b5a35c4 100644 --- a/src/mesa/drivers/dri/r128/r128_screen.c +++ b/src/mesa/drivers/dri/r128/r128_screen.c @@ -37,7 +37,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_context.h" #include "r128_ioctl.h" #include "r128_span.h" -#include "r128_tris.h" #include "main/context.h" #include "main/imports.h" diff --git a/src/mesa/drivers/dri/r128/r128_span.c b/src/mesa/drivers/dri/r128/r128_span.c index 0413e5b4f1..2fbe93c590 100644 --- a/src/mesa/drivers/dri/r128/r128_span.c +++ b/src/mesa/drivers/dri/r128/r128_span.c @@ -35,9 +35,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_context.h" #include "r128_ioctl.h" -#include "r128_state.h" #include "r128_span.h" -#include "r128_tex.h" #include "swrast/swrast.h" diff --git a/src/mesa/drivers/dri/r128/r128_state.c b/src/mesa/drivers/dri/r128/r128_state.c index 2254a7a4ff..42f6dd7388 100644 --- a/src/mesa/drivers/dri/r128/r128_state.c +++ b/src/mesa/drivers/dri/r128/r128_state.c @@ -47,8 +47,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "tnl/tnl.h" #include "swrast_setup/swrast_setup.h" -#include "tnl/t_pipeline.h" - #include "drirenderbuffer.h" diff --git a/src/mesa/drivers/dri/r128/r128_tex.c b/src/mesa/drivers/dri/r128/r128_tex.c index f1be7cc1c4..24fbf8f519 100644 --- a/src/mesa/drivers/dri/r128/r128_tex.c +++ b/src/mesa/drivers/dri/r128/r128_tex.c @@ -33,21 +33,16 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "r128_context.h" -#include "r128_state.h" #include "r128_ioctl.h" -#include "r128_tris.h" #include "r128_tex.h" #include "r128_texobj.h" -#include "main/context.h" -#include "main/macros.h" #include "main/simple_list.h" #include "main/enums.h" #include "main/texstore.h" #include "main/teximage.h" #include "main/texobj.h" #include "main/imports.h" -#include "main/colormac.h" #include "main/texobj.h" #include "xmlpool.h" diff --git a/src/mesa/drivers/dri/r128/r128_texmem.c b/src/mesa/drivers/dri/r128/r128_texmem.c index 4ddcb86bcd..5eec8c08cd 100644 --- a/src/mesa/drivers/dri/r128/r128_texmem.c +++ b/src/mesa/drivers/dri/r128/r128_texmem.c @@ -33,12 +33,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "r128_context.h" -#include "r128_state.h" #include "r128_ioctl.h" -#include "r128_tris.h" #include "r128_tex.h" -#include "main/context.h" #include "main/macros.h" #include "main/simple_list.h" #include "main/imports.h" diff --git a/src/mesa/drivers/dri/r128/r128_texstate.c b/src/mesa/drivers/dri/r128/r128_texstate.c index cb2b5f9536..2505b5cd65 100644 --- a/src/mesa/drivers/dri/r128/r128_texstate.c +++ b/src/mesa/drivers/dri/r128/r128_texstate.c @@ -38,7 +38,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/macros.h" #include "r128_context.h" -#include "r128_state.h" #include "r128_ioctl.h" #include "r128_tris.h" #include "r128_tex.h" -- cgit v1.2.3