[Mesa-dev] [PATCH 1/9] scons: Remove dead code/comments.
From: José Fonseca jfons...@vmware.com - Remove no-op if-clause. - -mstackrealign has been enabled again on MinGW for quite some time and appears to work alright nowadays. - Drop -mmmx option as it is implied my -msse, and we don't use MMX intrinsics anyway. --- scons/gallium.py | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scons/gallium.py b/scons/gallium.py index 4df6e1a..fe800fa 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -378,21 +378,18 @@ def generate(env): #'-march=pentium4', ] if distutils.version.LooseVersion(ccversion) = distutils.version.LooseVersion('4.2') \ - and (platform != 'windows' or env['build'] == 'debug' or True) \ and platform != 'haiku': # NOTE: We need to ensure stack is realigned given that we # produce shared objects, and have no control over the stack # alignment policy of the application. Therefore we need # -mstackrealign ore -mincoming-stack-boundary=2. # -# XXX: -O and -mstackrealign causes stack corruption on MinGW -# # XXX: We could have SSE without -mstackrealign if we always used # __attribute__((force_align_arg_pointer)), but that's not # always the case. ccflags += [ '-mstackrealign', # ensure stack is aligned -'-mmmx', '-msse', '-msse2', # enable SIMD intrinsics +'-msse', '-msse2', # enable SIMD intrinsics #'-mfpmath=sse', ] if platform in ['windows', 'darwin']: -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/9] draw, gallivm, llvmpipe: Avoid implicit casts of 32-bit shifts to 64-bits.
From: José Fonseca jfons...@vmware.com Addresses MSVC warnings result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?), which can often be symptom of bugs, but in these cases were all benign. --- src/gallium/auxiliary/draw/draw_llvm.c| 4 ++-- src/gallium/auxiliary/gallivm/lp_bld_arit.c | 2 +- src/gallium/auxiliary/gallivm/lp_bld_sample.c | 2 +- src/gallium/drivers/llvmpipe/lp_setup_tri.c | 4 ++-- src/gallium/drivers/llvmpipe/lp_state_fs.c| 8 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index a2e6112..dbaece3 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -1269,7 +1269,7 @@ generate_clipmask(struct draw_llvm *llvm, test = lp_build_compare(gallivm, f32_type, PIPE_FUNC_GREATER, zero, clipdist); is_nan_or_inf = lp_build_is_inf_or_nan(gallivm, vs_type, clipdist); test = LLVMBuildOr(builder, test, is_nan_or_inf, ); -temp = lp_build_const_int_vec(gallivm, i32_type, 1 plane_idx); +temp = lp_build_const_int_vec(gallivm, i32_type, 1LL plane_idx); test = LLVMBuildAnd(builder, test, temp, ); mask = LLVMBuildOr(builder, mask, test, ); } else { @@ -1305,7 +1305,7 @@ generate_clipmask(struct draw_llvm *llvm, sum = LLVMBuildFAdd(builder, sum, test, ); test = lp_build_compare(gallivm, f32_type, PIPE_FUNC_GREATER, zero, sum); -temp = lp_build_const_int_vec(gallivm, i32_type, 1 plane_idx); +temp = lp_build_const_int_vec(gallivm, i32_type, 1LL plane_idx); test = LLVMBuildAnd(builder, test, temp, ); mask = LLVMBuildOr(builder, mask, test, ); } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index 87da355..cd05f11 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -932,7 +932,7 @@ lp_build_mul_norm(struct gallivm_state *gallivm, * half = sgn(ab) * 0.5 * (2 ** n) = sgn(ab) * (1 (n - 1)) */ - half = lp_build_const_int_vec(gallivm, wide_type, 1 (n - 1)); + half = lp_build_const_int_vec(gallivm, wide_type, 1LL (n - 1)); if (wide_type.sign) { LLVMValueRef minus_half = LLVMBuildNeg(builder, half, ); LLVMValueRef sign = lp_build_shr_imm(bld, ab, wide_type.width - 1); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c index 85c0d4e..8cee994 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c @@ -1641,7 +1641,7 @@ lp_build_cube_lookup(struct lp_build_sample_context *bld, LLVMValueRef ma, mai, signma, signmabit, imahalfpos; LLVMValueRef posHalf = lp_build_const_vec(gallivm, coord_bld-type, 0.5); LLVMValueRef signmask = lp_build_const_int_vec(gallivm, intctype, - 1 (intctype.width - 1)); + 1LL (intctype.width - 1)); LLVMValueRef signshift = lp_build_const_int_vec(gallivm, intctype, intctype.width -1); LLVMValueRef facex = lp_build_const_int_vec(gallivm, intctype, PIPE_TEX_FACE_POS_X); diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c b/src/gallium/drivers/llvmpipe/lp_setup_tri.c index 900df71..a2f55ed 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c +++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c @@ -760,8 +760,8 @@ lp_setup_bin_triangle( struct lp_setup_context *setup, for (i = 0; i nr_planes; i++) { int64_t planeout = cx[i] + eo[i]; int64_t planepartial = cx[i] + ei[i] - 1; - out |= (planeout 63); - partial |= (planepartial 63) (1i); + out |= (int) (planeout 63); + partial |= ((int) (planepartial 63)) (1i); } if (out) { diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 0fc3686..a68b274 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -174,10 +174,10 @@ generate_quad_mask(struct gallivm_state *gallivm, for (i = 0; i fs_type.length / 4; i++) { unsigned j = 2 * (i % 2) + (i / 2) * 8; - bits[4*i + 0] = LLVMConstInt(i32t, 1 (j + 0), 0); - bits[4*i + 1] = LLVMConstInt(i32t, 1 (j + 1), 0); - bits[4*i + 2] = LLVMConstInt(i32t, 1 (j + 4), 0); - bits[4*i + 3] = LLVMConstInt(i32t, 1 (j + 5), 0); + bits[4*i + 0] = LLVMConstInt(i32t, 1ULL (j + 0), 0); + bits[4*i + 1] = LLVMConstInt(i32t, 1ULL (j + 1), 0); + bits[4*i + 2] = LLVMConstInt(i32t, 1ULL (j + 4), 0); + bits[4*i + 3] =
[Mesa-dev] [PATCH 7/9] mapi/glapi: Fix dll linkage of GLES1 symbols.
From: José Fonseca jfons...@vmware.com This fixes several MSVC warnings like: warning C4273: 'glClearColorx' : inconsistent dll linkage In fact, we should avoid using `declspec(dllexport)` altogether, and use exclusively the .DEF instead, which gives more precise control of which symbols must be exported, but all the public GL/GLES headers practically force us to pick between `declspec(dllexport)` or `ideclspec(dllimport)`. --- src/mapi/glapi/SConscript | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mapi/glapi/SConscript b/src/mapi/glapi/SConscript index bc1c43a..97ebfe6 100644 --- a/src/mapi/glapi/SConscript +++ b/src/mapi/glapi/SConscript @@ -16,6 +16,7 @@ if env['platform'] == 'windows': env.Append(CPPDEFINES = [ '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers +'KHRONOS_DLL_EXPORTS', # declare gl* as __declspec(dllexport) in Khronos headers ]) if env['gles']: env.Append(CPPDEFINES = ['_GLAPI_DLL_EXPORTS']) -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/9] scons: Disable MSVC signed/unsigned mismatch warnings.
From: José Fonseca jfons...@vmware.com Unfortunately gcc completely ignores the issue, and as result code that mixes signed/unsigned is so widespread through the code base end up being little more than noise, potentially obscuring more pertinent warnings. This change disables them. --- scons/gallium.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scons/gallium.py b/scons/gallium.py index 8e2090b..d9bf760 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -462,6 +462,7 @@ def generate(env): ] ccflags += [ '/W3', # warning level +'/wd4018', # signed/unsigned mismatch '/wd4244', # conversion from 'type1' to 'type2', possible loss of data '/wd4305', # truncation from 'type1' to 'type2' '/wd4800', # forcing value to bool 'true' or 'false' (performance warning) -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/9] scons: Generate SSE2 floating-point arithmetic.
From: José Fonseca jfons...@vmware.com - SSE2 is available on all x86 processors we care about. - It's recommended by Intel: https://software.intel.com/en-us/blogs/2012/09/26/gcc-x86-performance-hints - And has been the default since MSVC 2012: http://msdn.microsoft.com/en-us/library/7t5yh4fd(v=vs.110).aspx --- scons/gallium.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scons/gallium.py b/scons/gallium.py index fe800fa..8e2090b 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -390,7 +390,7 @@ def generate(env): ccflags += [ '-mstackrealign', # ensure stack is aligned '-msse', '-msse2', # enable SIMD intrinsics -#'-mfpmath=sse', +'-mfpmath=sse', # generate SSE floating-point arithmetic ] if platform in ['windows', 'darwin']: # Workaround http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37216 @@ -469,7 +469,7 @@ def generate(env): ] if env['machine'] == 'x86': ccflags += [ -#'/arch:SSE2', # use the SSE2 instructions +'/arch:SSE2', # use the SSE2 instructions (default since MSVC 2012) ] if platform == 'windows': ccflags += [ -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 8/9] st/wgl: Don't export wglGetExtensionsStringARB.
From: José Fonseca jfons...@vmware.com It's not exported by the official opengl32.dll neither. Applications are supposed to get it via wglGetProcAddress(), not GetProcAddress(). --- src/gallium/state_trackers/wgl/opengl32.def | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gallium/state_trackers/wgl/opengl32.def b/src/gallium/state_trackers/wgl/opengl32.def index 01a29d0..c35c23b 100644 --- a/src/gallium/state_trackers/wgl/opengl32.def +++ b/src/gallium/state_trackers/wgl/opengl32.def @@ -367,7 +367,6 @@ EXPORTS wglUseFontBitmapsW wglUseFontOutlinesA wglUseFontOutlinesW - wglGetExtensionsStringARB DrvCopyContext DrvCreateContext DrvCreateLayerContext -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 6/9] util/u_snprintf: Don't redefine HAVE_STDINT_H as 0.
From: José Fonseca jfons...@vmware.com We now always guarantee availability of stdint.h on MSVC -- if MSVC doesn't supply one we use our own. --- src/gallium/auxiliary/util/u_snprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/util/u_snprintf.c b/src/gallium/auxiliary/util/u_snprintf.c index 7a2bf2a..39e9b70 100644 --- a/src/gallium/auxiliary/util/u_snprintf.c +++ b/src/gallium/auxiliary/util/u_snprintf.c @@ -176,7 +176,7 @@ #define HAVE_ASPRINTF 1 /* not needed */ #define HAVE_STDARG_H 1 #define HAVE_STDDEF_H 1 -#define HAVE_STDINT_H 0 +#define HAVE_STDINT_H 1 #define HAVE_STDLIB_H 1 #define HAVE_INTTYPES_H 0 #define HAVE_LOCALE_H 0 -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 5/9] gallivm: Removed unused variable.
From: José Fonseca jfons...@vmware.com --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c index 2ef5db1..738d5e9 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c @@ -492,7 +492,7 @@ lp_emit_instruction_aos( int *pc) { LLVMValueRef src0, src1, src2; - LLVMValueRef tmp0, tmp1; + LLVMValueRef tmp0; LLVMValueRef dst0 = NULL; /* -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 9/9] mesa/gdi: Don't pretend mesadef.py is auto generated.
From: José Fonseca jfons...@vmware.com Just use the same entrypoints we use for st/wgl's opengl32.dll. --- src/mesa/drivers/windows/gdi/mesa.def | 839 -- 1 file changed, 192 insertions(+), 647 deletions(-) diff --git a/src/mesa/drivers/windows/gdi/mesa.def b/src/mesa/drivers/windows/gdi/mesa.def index 92736b3..a52207b 100644 --- a/src/mesa/drivers/windows/gdi/mesa.def +++ b/src/mesa/drivers/windows/gdi/mesa.def @@ -1,6 +1,3 @@ -; DO NOT EDIT - This file generated automatically by mesadef.py script -;DESCRIPTION 'Mesa (OpenGL work-alike) for Win32' -VERSION 6.5 ; ; Module definition file for Mesa (OPENGL32.DLL) ; @@ -27,15 +24,23 @@ VERSION 6.5 ; points are compiled with dllexport declspec. ; EXPORTS - glNewList - glEndList - glCallList - glCallLists - glDeleteLists - glGenLists - glListBase + glAccum + glAlphaFunc + glAreTexturesResident + glArrayElement glBegin + glBindTexture glBitmap + glBlendFunc + glCallList + glCallLists + glClear + glClearAccum + glClearColor + glClearDepth + glClearIndex + glClearStencil + glClipPlane glColor3b glColor3bv glColor3d @@ -68,9 +73,88 @@ EXPORTS glColor4uiv glColor4us glColor4usv + glColorMask + glColorMaterial + glColorPointer + glCopyPixels + glCopyTexImage1D + glCopyTexImage2D + glCopyTexSubImage1D + glCopyTexSubImage2D + glCullFace + glDeleteLists + glDeleteTextures + glDepthFunc + glDepthMask + glDepthRange + glDisable + glDisableClientState + glDrawArrays + glDrawBuffer + glDrawElements + glDrawPixels glEdgeFlag + glEdgeFlagPointer glEdgeFlagv + glEnable + glEnableClientState glEnd + glEndList + glEvalCoord1d + glEvalCoord1dv + glEvalCoord1f + glEvalCoord1fv + glEvalCoord2d + glEvalCoord2dv + glEvalCoord2f + glEvalCoord2fv + glEvalMesh1 + glEvalMesh2 + glEvalPoint1 + glEvalPoint2 + glFeedbackBuffer + glFinish + glFlush + glFogf + glFogfv + glFogi + glFogiv + glFrontFace + glFrustum + glGenLists + glGenTextures + glGetBooleanv + glGetClipPlane + glGetDoublev + glGetError + glGetFloatv + glGetIntegerv + glGetLightfv + glGetLightiv + glGetMapdv + glGetMapfv + glGetMapiv + glGetMaterialfv + glGetMaterialiv + glGetPixelMapfv + glGetPixelMapuiv + glGetPixelMapusv + glGetPointerv + glGetPolygonStipple + glGetString + glGetTexEnvfv + glGetTexEnviv + glGetTexGendv + glGetTexGenfv + glGetTexGeniv + glGetTexImage + glGetTexLevelParameterfv + glGetTexLevelParameteriv + glGetTexParameterfv + glGetTexParameteriv + glHint + glIndexMask + glIndexPointer glIndexd glIndexdv glIndexf @@ -79,6 +163,45 @@ EXPORTS glIndexiv glIndexs glIndexsv + glIndexub + glIndexubv + glInitNames + glInterleavedArrays + glIsEnabled + glIsList + glIsTexture + glLightModelf + glLightModelfv + glLightModeli + glLightModeliv + glLightf + glLightfv + glLighti + glLightiv + glLineStipple + glLineWidth + glListBase + glLoadIdentity + glLoadMatrixd + glLoadMatrixf + glLoadName + glLogicOp + glMap1d + glMap1f + glMap2d + glMap2f + glMapGrid1d + glMapGrid1f + glMapGrid2d + glMapGrid2f + glMaterialf + glMaterialfv + glMateriali + glMaterialiv + glMatrixMode + glMultMatrixd + glMultMatrixf + glNewList glNormal3b glNormal3bv glNormal3d @@ -89,6 +212,30 @@ EXPORTS glNormal3iv glNormal3s glNormal3sv + glNormalPointer + glOrtho + glPassThrough + glPixelMapfv + glPixelMapuiv + glPixelMapusv + glPixelStoref + glPixelStorei + glPixelTransferf + glPixelTransferi + glPixelZoom + glPointSize + glPolygonMode + glPolygonOffset + glPolygonStipple + glPopAttrib + glPopClientAttrib + glPopMatrix + glPopName + glPrioritizeTextures + glPushAttrib + glPushClientAttrib + glPushMatrix + glPushName glRasterPos2d glRasterPos2dv glRasterPos2f @@ -113,6 +260,8 @@ EXPORTS glRasterPos4iv glRasterPos4s glRasterPos4sv + glReadBuffer + glReadPixels glRectd glRectdv
[Mesa-dev] [PATCH] rtasm,translate: Re-enable SSE on Mingw64.
From: José Fonseca jfons...@vmware.com This reverts f4dd0991719ef3e2606920c5100b372181c60899. The src/gallium/tests/unit/translate_test.c gives the same results on MinGW 64-bits as on Linux 64-bits. And since MinGW is often used for development/testing due to its convenience, it's better not to have this sort of differences relative to MSVC. --- src/gallium/auxiliary/rtasm/rtasm_x86sse.c | 2 +- src/gallium/auxiliary/translate/translate_sse.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/rtasm/rtasm_x86sse.c b/src/gallium/auxiliary/rtasm/rtasm_x86sse.c index 24ff820..f963788 100644 --- a/src/gallium/auxiliary/rtasm/rtasm_x86sse.c +++ b/src/gallium/auxiliary/rtasm/rtasm_x86sse.c @@ -25,7 +25,7 @@ #include pipe/p_config.h #include util/u_cpu_detect.h -#if defined(PIPE_ARCH_X86) || (defined(PIPE_ARCH_X86_64) !defined(__MINGW32__)) +#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) #include pipe/p_compiler.h #include util/u_debug.h diff --git a/src/gallium/auxiliary/translate/translate_sse.c b/src/gallium/auxiliary/translate/translate_sse.c index c7c53b3..c7b6c36 100644 --- a/src/gallium/auxiliary/translate/translate_sse.c +++ b/src/gallium/auxiliary/translate/translate_sse.c @@ -35,7 +35,7 @@ #include translate.h -#if (defined(PIPE_ARCH_X86) || (defined(PIPE_ARCH_X86_64) !defined(__MINGW32__))) !defined(PIPE_SUBSYSTEM_EMBEDDED) +#if (defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)) !defined(PIPE_SUBSYSTEM_EMBEDDED) #include rtasm/rtasm_cpu.h #include rtasm/rtasm_x86sse.h -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/3] wgl: Ensure PIXELFORMATDESCRIPTOR members are zeroed.
From: José Fonseca jfons...@vmware.com I suddenly started seeing many simple GL apps, including wglinfo, choosing Microsoft GDI OpenGL implementation, even though hardware accelerated pixel formats were available. It turned out that: - the screen was in 16bpp mode (some WHCK tests have the nasty habit of doing that) - NVIDIA opengl driver only reports R5G6B5 pixel formats (ie no alpha bits) in this case - non-zero cAlphaBits was being passed to ChoosePixelformat (or in the wglinfo case, garbage, as the structure wasn't being properly zeroed) - ChoosePixelFormat will choose a SW pixel format, just to honour the At least on the wglinfo and friends case the alpha bits are not needed, so this change will make sure that HW accelerated formats will be chosen before SW ones. --- src/wgl/sharedtex_mt.c | 6 -- src/wgl/wglinfo.c | 1 + src/wgl/wglthreads.c | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/wgl/sharedtex_mt.c b/src/wgl/sharedtex_mt.c index 161b2bb..073b100 100644 --- a/src/wgl/sharedtex_mt.c +++ b/src/wgl/sharedtex_mt.c @@ -118,7 +118,7 @@ initMainthread(void) { WNDCLASS wc = {0}; HWND win; - PIXELFORMATDESCRIPTOR pfd = {0}; + PIXELFORMATDESCRIPTOR pfd; int visinfo; wc.lpfnWndProc = WndProc; @@ -147,6 +147,7 @@ initMainthread(void) Error(Couldn't obtain HDC); } + memset(pfd, 0, sizeof(pfd)); pfd.cColorBits = 24; pfd.cDepthBits = 24; pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; @@ -405,7 +406,7 @@ threadRunner (void *arg) { struct thread_init_arg *tia = (struct thread_init_arg *) arg; struct window *win; - PIXELFORMATDESCRIPTOR pfd = {0}; + PIXELFORMATDESCRIPTOR pfd; int visinfo; win = Windows[tia-id]; @@ -419,6 +420,7 @@ threadRunner (void *arg) if(tia-id 0) WaitForSingleObject(Windows[tia-id - 1].hEventInitialised, INFINITE); + memset(pfd, 0, sizeof(pfd)); pfd.cColorBits = 24; pfd.cDepthBits = 24; pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; diff --git a/src/wgl/wglinfo.c b/src/wgl/wglinfo.c index 30b1307..b6285ec 100644 --- a/src/wgl/wglinfo.c +++ b/src/wgl/wglinfo.c @@ -123,6 +123,7 @@ print_screen_info(HDC _hdc, GLboolean limits, GLboolean singleLine, return; } + memset(pfd, 0, sizeof(pfd)); pfd.cColorBits = 3; pfd.cRedBits = 1; pfd.cGreenBits = 1; diff --git a/src/wgl/wglthreads.c b/src/wgl/wglthreads.c index 27dca10..2ee42e2 100644 --- a/src/wgl/wglthreads.c +++ b/src/wgl/wglthreads.c @@ -430,7 +430,7 @@ create_window(struct winthread *wt, HGLRC shareCtx) int ypos = (wt-Index / 8) * (width + 20); HWND win; HDC hdc; - PIXELFORMATDESCRIPTOR pfd = {0}; + PIXELFORMATDESCRIPTOR pfd; int visinfo; HGLRC ctx; @@ -463,6 +463,7 @@ create_window(struct winthread *wt, HGLRC shareCtx) Error(Couldn't obtain HDC); } + memset(pfd, 0, sizeof(pfd)); pfd.cColorBits = 24; pfd.cDepthBits = 24; pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/3] tests, trival, fp, vp: Rename errno with errnum.
From: José Fonseca jfons...@vmware.com Prevents warnings on MinGW due to conflicting linkage types for errno. --- src/fp/fp-tri.c | 8 src/tests/arbfpspec.c| 14 +++--- src/tests/arbfptest1.c | 8 src/tests/arbvptest1.c | 8 src/tests/arbvptest3.c | 8 src/tests/arbvptorus.c | 8 src/tests/arbvpwarpmesh.c| 8 src/trivial/draw2arrays.c| 8 src/trivial/drawarrays.c | 8 src/trivial/drawelements-large.c | 8 src/trivial/drawelements.c | 8 src/trivial/drawrange.c | 8 src/trivial/lineloop-elts.c | 8 src/trivial/tri-array-interleaved.c | 8 src/trivial/tri-fp-const-imm.c | 8 src/trivial/tri-fp.c | 8 src/trivial/vbo-drawarrays-2101010.c | 6 +++--- src/trivial/vbo-drawarrays.c | 8 src/trivial/vbo-drawelements.c | 8 src/trivial/vbo-drawrange.c | 8 src/trivial/vbo-noninterleaved.c | 8 src/trivial/vbo-tri.c| 8 src/trivial/vp-array-hf.c| 8 src/trivial/vp-array-int.c | 8 src/trivial/vp-array.c | 8 src/trivial/vp-clip.c| 8 src/trivial/vp-line-clip.c | 8 src/trivial/vp-tri-cb-pos.c | 8 src/trivial/vp-tri-cb-tex.c | 8 src/trivial/vp-tri-cb.c | 8 src/trivial/vp-tri-imm.c | 8 src/trivial/vp-tri-invariant.c | 8 src/trivial/vp-tri-swap.c| 8 src/trivial/vp-tri-tex.c | 8 src/trivial/vp-tri.c | 8 src/trivial/vp-unfilled.c| 8 src/vp/vp-tris.c | 8 37 files changed, 150 insertions(+), 150 deletions(-) diff --git a/src/fp/fp-tri.c b/src/fp/fp-tri.c index d063b85..4994d5d 100644 --- a/src/fp/fp-tri.c +++ b/src/fp/fp-tri.c @@ -71,7 +71,7 @@ static void args(int argc, char *argv[]) static void Init( void ) { GLuint Texture; - GLint errno; + GLint errnum; GLuint prognum; char buf[5]; GLuint sz; @@ -101,9 +101,9 @@ static void Init( void ) glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, sz, (const GLubyte *)buf); - errno = glGetError(); - printf(glGetError = 0x%x\n, errno); - if (errno != GL_NO_ERROR) { + errnum = glGetError(); + printf(glGetError = 0x%x\n, errnum); + if (errnum != GL_NO_ERROR) { GLint errorpos; glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, errorpos); diff --git a/src/tests/arbfpspec.c b/src/tests/arbfpspec.c index cfa6f3e..fcc5052 100644 --- a/src/tests/arbfpspec.c +++ b/src/tests/arbfpspec.c @@ -105,7 +105,7 @@ static void SpecialKey( int key, int x, int y ) static void Init( void ) { - GLint errno; + GLint errnum; GLuint prognum, fprognum; static const char prog[] = @@ -141,9 +141,9 @@ static void Init( void ) strlen(prog), (const GLubyte *) prog); assert(glIsProgramARB(prognum)); - errno = glGetError(); - printf(glGetError = %d\n, errno); - if (errno != GL_NO_ERROR) + errnum = glGetError(); + printf(glGetError = %d\n, errnum); + if (errnum != GL_NO_ERROR) { GLint errorpos; @@ -155,9 +155,9 @@ static void Init( void ) glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, fprognum); glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(fprog), (const GLubyte *) fprog); - errno = glGetError(); - printf(glGetError = %d\n, errno); - if (errno != GL_NO_ERROR) + errnum = glGetError(); + printf(glGetError = %d\n, errnum); + if (errnum != GL_NO_ERROR) { GLint errorpos; diff --git a/src/tests/arbfptest1.c b/src/tests/arbfptest1.c index d63e459..40b8aab 100644 --- a/src/tests/arbfptest1.c +++ b/src/tests/arbfptest1.c @@ -57,16 +57,16 @@ static void Key( unsigned char key, int x, int y ) static void load_program(const char *prog, GLuint prognum) { int a; - GLint errorpos, errno; + GLint errorpos, errnum; glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prognum); glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(prog), (const GLubyte *) prog); assert(glIsProgramARB(prognum)); - errno = glGetError(); - printf(glGetError = %d\n, errno); - if (errno != GL_NO_ERROR) + errnum = glGetError(); + printf(glGetError = %d\n, errnum); + if (errnum != GL_NO_ERROR) { glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, errorpos); printf(errorpos: %d\n, errorpos); diff --git
[Mesa-dev] [PATCH 1/3] cmake: Don't use gcc specific warnings with g++.
From: José Fonseca jfons...@vmware.com Avoids warning: command line option ‘-W...’ is valid for Ada/C/ObjC but not for C++. --- CMakeLists.txt | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c3e217f..57a46f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,16 +72,13 @@ if (CMAKE_COMPILER_IS_GNUCC) add_definitions( -Wall -Wpointer-arith - -Wstrict-prototypes - -Wmissing-prototypes -Wmissing-declarations - -Wnested-externs -fno-strict-aliasing - -Wbad-function-cast #-Wold-style-definition #-Wdeclaration-after-statement ) -endif (CMAKE_COMPILER_IS_GNUCC) + set (CMAKE_C_FLAGS -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wbad-function-cast ${CMAKE_CXX_FLAGS}) +endif () if (WIN32) # Nobody likes to include windows.h: -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] st/xlib: Generate errors as specified.
From: José Fonseca jfons...@vmware.com Tested with piglit glx tests. --- src/gallium/state_trackers/glx/xlib/glx_api.c | 125 ++ 1 file changed, 109 insertions(+), 16 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c index 810910e..1807edb 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_api.c +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c @@ -33,6 +33,9 @@ #define GLX_GLXEXT_PROTOTYPES #include GL/glx.h +#include X11/Xmd.h +#include GL/glxproto.h + #include xm_api.h @@ -647,6 +650,52 @@ register_with_display(Display *dpy) } +/** + * Fake an error. + */ +static int +generate_error(Display *dpy, + unsigned char error_code, + XID resourceid, + unsigned char minor_code, + Bool core) +{ + XErrorHandler handler; + int major_opcode; + int first_event; + int first_error; + XEvent event; + + handler = XSetErrorHandler(NULL); + XSetErrorHandler(handler); + if (!handler) { + return 0; + } + + if (!XQueryExtension(dpy, GLX_EXTENSION_NAME, major_opcode, first_event, first_error)) { + major_opcode = 0; + first_event = 0; + first_error = 0; + } + + if (!core) { + error_code += first_error; + } + + memset(event, 0, sizeof event); + + event.xerror.type = X_Error; + event.xerror.display = dpy; + event.xerror.resourceid = resourceid; + event.xerror.serial = NextRequest(dpy) - 1; + event.xerror.error_code = error_code; + event.xerror.request_code = major_opcode; + event.xerror.minor_code = minor_code; + + return handler(dpy, event.xerror); +} + + /**/ /*** Begin Fake GLX API Functions ***/ /**/ @@ -2082,8 +2131,10 @@ glXQueryDrawable(Display *dpy, GLXDrawable draw, int attribute, { GLuint width, height; XMesaBuffer xmbuf = XMesaFindBuffer(dpy, draw); - if (!xmbuf) + if (!xmbuf) { + generate_error(dpy, GLXBadDrawable, draw, X_GLXGetDrawableAttributes, False); return; + } /* make sure buffer's dimensions are up to date */ xmesa_get_window_size(dpy, xmbuf, width, height); @@ -2117,7 +2168,8 @@ glXQueryDrawable(Display *dpy, GLXDrawable draw, int attribute, #endif default: - return; /* raise BadValue error */ + generate_error(dpy, BadValue, 0, X_GLXCreateContextAtrribsARB, true); + return; } } @@ -2669,6 +2721,7 @@ glXReleaseTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer) /*** GLX_ARB_create_context ***/ + GLXContext glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, GLXContext shareCtx, Bool direct, @@ -2683,6 +2736,7 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, Bool done = False; const int contextFlagsAll = (GLX_CONTEXT_DEBUG_BIT_ARB | GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB); + GLXContext ctx; /* parse attrib_list */ for (i = 0; !done attrib_list attrib_list[i]; i++) { @@ -2708,37 +2762,76 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, break; default: /* bad attribute */ - /* XXX generate BadValue X Error */ + generate_error(dpy, BadValue, 0, X_GLXCreateContextAtrribsARB, True); return NULL; } } /* check contextFlags */ if (contextFlags ~contextFlagsAll) { - return NULL; /* generate BadValue X Error */ + generate_error(dpy, BadValue, 0, X_GLXCreateContextAtrribsARB, True); + return NULL; } /* check profileMask */ if (profileMask != GLX_CONTEXT_CORE_PROFILE_BIT_ARB profileMask != GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB profileMask != GLX_CONTEXT_ES_PROFILE_BIT_EXT) { - return NULL; /* generate BadValue X Error */ + generate_error(dpy, GLXBadProfileARB, 0, X_GLXCreateContextAtrribsARB, False); + return NULL; + } + + /* check renderType */ + if (renderType != GLX_RGBA_TYPE + renderType != GLX_COLOR_INDEX_TYPE) { + generate_error(dpy, BadValue, 0, X_GLXCreateContextAtrribsARB, True); + return NULL; } - /* check version (generate BadMatch if bad) */ - if (majorVersion 0 || minorVersion 0) + /* check version */ + if (majorVersion = 0 || + minorVersion 0 || + (profileMask != GLX_CONTEXT_ES_PROFILE_BIT_EXT +((majorVersion == 1 minorVersion 5) || + (majorVersion == 2 minorVersion 1) || + (majorVersion == 3 minorVersion 3) || + (majorVersion == 4 minorVersion 5) || + majorVersion 4))) { + generate_error(dpy, BadMatch, 0, X_GLXCreateContextAtrribsARB, True); return NULL; + } + if (profileMask == GLX_CONTEXT_ES_PROFILE_BIT_EXT +
[Mesa-dev] [PATCH 2/2] st/wgl: Implement WGL_EXT_create_context_es/es2_profile.
From: José Fonseca jfons...@vmware.com Derived from st/glx's GLX_EXT_create_context_es/es2_profile implementation. Tested with an OpenGL ES 2.0 ApiTrace. --- src/gallium/state_trackers/wgl/stw_context.c | 74 +- src/gallium/state_trackers/wgl/stw_ext_context.c | 65 +-- .../state_trackers/wgl/stw_ext_extensionsstring.c | 2 + 3 files changed, 78 insertions(+), 63 deletions(-) diff --git a/src/gallium/state_trackers/wgl/stw_context.c b/src/gallium/state_trackers/wgl/stw_context.c index 99debfd..2ed6c2bf 100644 --- a/src/gallium/state_trackers/wgl/stw_context.c +++ b/src/gallium/state_trackers/wgl/stw_context.c @@ -201,35 +201,51 @@ stw_create_context_attribs(HDC hdc, INT iLayerPlane, DHGLRC hShareContext, if (contextFlags WGL_CONTEXT_DEBUG_BIT_ARB) attribs.flags |= ST_CONTEXT_FLAG_DEBUG; - /* There are no profiles before OpenGL 3.2. The -* WGL_ARB_create_context_profile spec says: -* -* If the requested OpenGL version is less than 3.2, -* WGL_CONTEXT_PROFILE_MASK_ARB is ignored and the functionality of the -* context is determined solely by the requested version. -* -* The spec also says: -* -* The default value for WGL_CONTEXT_PROFILE_MASK_ARB is -* WGL_CONTEXT_CORE_PROFILE_BIT_ARB. -* -* The spec also says: -* -* If version 3.1 is requested, the context returned may implement -* any of the following versions: -* -* * Version 3.1. The GL_ARB_compatibility extension may or may not -* be implemented, as determined by the implementation. -* * The core profile of version 3.2 or greater. -* -* and because Mesa doesn't support GL_ARB_compatibility, the only chance to -* honour a 3.1 context is through core profile. -*/ - attribs.profile = ST_PROFILE_DEFAULT; - if (((majorVersion 3 || (majorVersion == 3 minorVersion = 2)) - ((profileMask WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) == 0)) || - (majorVersion == 3 minorVersion == 1)) - attribs.profile = ST_PROFILE_OPENGL_CORE; + switch (profileMask) { + case WGL_CONTEXT_CORE_PROFILE_BIT_ARB: + /* There are no profiles before OpenGL 3.2. The + * WGL_ARB_create_context_profile spec says: + * + * If the requested OpenGL version is less than 3.2, + * WGL_CONTEXT_PROFILE_MASK_ARB is ignored and the functionality + * of the context is determined solely by the requested version. + */ + if (majorVersion 3 || (majorVersion == 3 minorVersion = 2)) { + attribs.profile = ST_PROFILE_OPENGL_CORE; + break; + } + /* fall-through */ + case WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB: + /* + * The spec also says: + * + * If version 3.1 is requested, the context returned may implement + * any of the following versions: + * + * * Version 3.1. The GL_ARB_compatibility extension may or may not + * be implemented, as determined by the implementation. + * * The core profile of version 3.2 or greater. + * + * and because Mesa doesn't support GL_ARB_compatibility, the only chance to + * honour a 3.1 context is through core profile. + */ + if (majorVersion == 3 minorVersion == 1) { + attribs.profile = ST_PROFILE_OPENGL_CORE; + } else { + attribs.profile = ST_PROFILE_DEFAULT; + } + break; + case WGL_CONTEXT_ES_PROFILE_BIT_EXT: + if (majorVersion = 2) { + attribs.profile = ST_PROFILE_OPENGL_ES2; + } else { + attribs.profile = ST_PROFILE_OPENGL_ES1; + } + break; + default: + assert(0); + goto no_st_ctx; + } ctx-st = stw_dev-stapi-create_context(stw_dev-stapi, stw_dev-smapi, attribs, ctx_err, shareCtx ? shareCtx-st : NULL); diff --git a/src/gallium/state_trackers/wgl/stw_ext_context.c b/src/gallium/state_trackers/wgl/stw_ext_context.c index 451f330..8a96cac 100644 --- a/src/gallium/state_trackers/wgl/stw_ext_context.c +++ b/src/gallium/state_trackers/wgl/stw_ext_context.c @@ -62,6 +62,8 @@ wglCreateContextAttribsARB(HDC hDC, HGLRC hShareContext, const int *attribList) int profileMask = WGL_CONTEXT_CORE_PROFILE_BIT_ARB; int i; BOOL done = FALSE; + const int contextFlagsAll = (WGL_CONTEXT_DEBUG_BIT_ARB | +WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB); /* parse attrib_list */ if (attribList) { @@ -94,34 +96,36 @@ wglCreateContextAttribsARB(HDC hDC, HGLRC hShareContext, const int *attribList) } } + /* check contextFlags */ + if (contextFlags ~contextFlagsAll) { + SetLastError(ERROR_INVALID_PARAMETER); + return NULL; + } + + /* check profileMask */ + if (profileMask != WGL_CONTEXT_CORE_PROFILE_BIT_ARB + profileMask != WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB + profileMask
[Mesa-dev] [PATCH] mesa, st/glx, st/wgl: Move GL version validation into an helper.
From: José Fonseca jfons...@vmware.com As suggested by Brian Paul. Tested with piglit glx-create-context-invalid-{gl,es}-version. --- src/gallium/state_trackers/glx/xlib/glx_api.c| 13 +++--- src/gallium/state_trackers/wgl/stw_ext_context.c | 13 +++--- src/mesa/main/version.c | 33 src/mesa/main/version.h | 6 + 4 files changed, 47 insertions(+), 18 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c index 1807edb..d4e028c 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_api.c +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c @@ -36,6 +36,8 @@ #include X11/Xmd.h #include GL/glxproto.h +#include main/version.h + #include xm_api.h @@ -2792,19 +2794,12 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, if (majorVersion = 0 || minorVersion 0 || (profileMask != GLX_CONTEXT_ES_PROFILE_BIT_EXT -((majorVersion == 1 minorVersion 5) || - (majorVersion == 2 minorVersion 1) || - (majorVersion == 3 minorVersion 3) || - (majorVersion == 4 minorVersion 5) || - majorVersion 4))) { +!_mesa_is_valid_version(majorVersion, minorVersion))) { generate_error(dpy, BadMatch, 0, X_GLXCreateContextAtrribsARB, True); return NULL; } if (profileMask == GLX_CONTEXT_ES_PROFILE_BIT_EXT - ((majorVersion == 1 minorVersion 1) || -(majorVersion == 2 minorVersion 0) || -(majorVersion == 3 minorVersion 1) || -majorVersion 3)) { + !_mesa_is_valid_es_version(majorVersion, minorVersion)) { /* GLX_EXT_create_context_es2_profile says nothing to justifying a * different error code for invalid ES versions, but this is what NVIDIA * does and piglit expects. diff --git a/src/gallium/state_trackers/wgl/stw_ext_context.c b/src/gallium/state_trackers/wgl/stw_ext_context.c index 8a96cac..ee46334 100644 --- a/src/gallium/state_trackers/wgl/stw_ext_context.c +++ b/src/gallium/state_trackers/wgl/stw_ext_context.c @@ -30,6 +30,8 @@ #include GL/gl.h #include GL/wglext.h +#include main/version.h + #include stw_icd.h #include stw_context.h #include stw_device.h @@ -114,16 +116,9 @@ wglCreateContextAttribsARB(HDC hDC, HGLRC hShareContext, const int *attribList) if (majorVersion = 0 || minorVersion 0 || (profileMask != WGL_CONTEXT_ES_PROFILE_BIT_EXT -((majorVersion == 1 minorVersion 5) || - (majorVersion == 2 minorVersion 1) || - (majorVersion == 3 minorVersion 3) || - (majorVersion == 4 minorVersion 5) || - majorVersion 4)) || +!_mesa_is_valid_version(majorVersion, minorVersion)) || (profileMask == WGL_CONTEXT_ES_PROFILE_BIT_EXT -((majorVersion == 1 minorVersion 1) || - (majorVersion == 2 minorVersion 0) || - (majorVersion == 3 minorVersion 1) || - majorVersion 3))) { +!_mesa_is_valid_es_version(majorVersion, minorVersion))) { SetLastError(ERROR_INVALID_VERSION_ARB); return NULL; } diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c index 4951891..5bdef16 100644 --- a/src/mesa/main/version.c +++ b/src/mesa/main/version.c @@ -460,3 +460,36 @@ _mesa_compute_version(struct gl_context *ctx) break; } } + + +GLboolean +_mesa_is_valid_version(int major, int minor) +{ + static const char max_minor_version[] = { + /* 1 . */ 5, + /* 2 . */ 1, + /* 3 . */ 3, + /* 4 . */ 5, + }; + + return (major = 0 + major sizeof max_minor_version + minor = 0 + minor = max_minor_version[major - 1]); +} + + +GLboolean +_mesa_is_valid_es_version(int major, int minor) +{ + static const char max_minor_version[] = { + /* 1 . */ 1, + /* 2 . */ 0, + /* 3 . */ 1, + }; + + return (major = 0 + major sizeof max_minor_version + minor = 0 + minor = max_minor_version[major - 1]); +} diff --git a/src/mesa/main/version.h b/src/mesa/main/version.h index 450a0e3..e2e1fc2 100644 --- a/src/mesa/main/version.h +++ b/src/mesa/main/version.h @@ -50,4 +50,10 @@ _mesa_override_glsl_version(struct gl_constants *consts); extern int _mesa_get_gl_version_override(void); +extern GLboolean +_mesa_is_valid_version(int major, int minor); + +extern GLboolean +_mesa_is_valid_es_version(int major, int minor); + #endif /* VERSION_H */ -- 2.1.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/3] st/dri: Support EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR/GLX_CONTEXT_DEBUG_BIT_ARB on ES contexts.
From: José Fonseca jfons...@vmware.com The latest version of the specs explicitly allow it, and given that Mesa universally supports KHR_debug we should definitely support it. Totally untested. (Just happened to noticed this while implementing GLX_EXT_create_context_es2_profile for st/xlib.) --- src/gallium/state_trackers/dri/dri_context.c | 6 +++--- src/mesa/drivers/dri/common/dri_util.c | 14 ++ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c index fe3240a..84b8807 100644 --- a/src/gallium/state_trackers/dri/dri_context.c +++ b/src/gallium/state_trackers/dri/dri_context.c @@ -72,9 +72,6 @@ dri_create_context(gl_api api, const struct gl_config * visual, attribs.major = major_version; attribs.minor = minor_version; - if ((flags __DRI_CTX_FLAG_DEBUG) != 0) -attribs.flags |= ST_CONTEXT_FLAG_DEBUG; - if ((flags __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0) attribs.flags |= ST_CONTEXT_FLAG_FORWARD_COMPATIBLE; break; @@ -83,6 +80,9 @@ dri_create_context(gl_api api, const struct gl_config * visual, goto fail; } + if ((flags __DRI_CTX_FLAG_DEBUG) != 0) + attribs.flags |= ST_CONTEXT_FLAG_DEBUG; + if (flags ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_FORWARD_COMPATIBLE)) { *error = __DRI_CTX_ERROR_UNKNOWN_FLAG; goto fail; diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 02499f2..d6e875f 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -376,19 +376,17 @@ driCreateContextAttribs(__DRIscreen *screen, int api, return NULL; } -/* The EGL_KHR_create_context spec says: +/* The latest version of EGL_KHR_create_context spec says: * - * Flags are only defined for OpenGL context creation, and specifying - * a flags value other than zero for other types of contexts, - * including OpenGL ES contexts, will generate an error. + * If the EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR flag bit is set in + * EGL_CONTEXT_FLAGS_KHR, then a debug context will be created. + * [...] This bit is supported for OpenGL and OpenGL ES contexts. * - * The GLX_EXT_create_context_es2_profile specification doesn't say - * anything specific about this case. However, none of the known flags - * have any meaning in an ES context, so this seems safe. + * None of the other flags have any meaning in an ES context, so this seems safe. */ if (mesa_api != API_OPENGL_COMPAT mesa_api != API_OPENGL_CORE - flags != 0) { + (flags ~__DRI_CTX_FLAG_DEBUG)) { *error = __DRI_CTX_ERROR_BAD_FLAG; return NULL; } -- 2.1.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/3] st/glx: Implement GLX_EXT_create_context_es2_profile.
From: José Fonseca jfons...@vmware.com apitrace now supports it, and it makes it much easier to test tracing/replaying on OpenGL ES contexts since GLX_EXT_create_context_{es2,es}_profile are widely available. --- src/gallium/state_trackers/glx/xlib/glx_api.c | 5 +- src/gallium/state_trackers/glx/xlib/xm_api.c | 86 --- 2 files changed, 54 insertions(+), 37 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c index 976791b..810910e 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_api.c +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c @@ -56,6 +56,8 @@ GLX_ARB_create_context \ GLX_ARB_create_context_profile \ GLX_ARB_get_proc_address \ + GLX_EXT_create_context_es_profile \ + GLX_EXT_create_context_es2_profile \ GLX_EXT_texture_from_pixmap \ GLX_EXT_visual_info \ GLX_EXT_visual_rating \ @@ -2718,7 +2720,8 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, /* check profileMask */ if (profileMask != GLX_CONTEXT_CORE_PROFILE_BIT_ARB - profileMask != GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) { + profileMask != GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB + profileMask != GLX_CONTEXT_ES_PROFILE_BIT_EXT) { return NULL; /* generate BadValue X Error */ } diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 1b77729..2aa5ac4 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -866,12 +866,12 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list, XMesaContext c; if (!xmdpy) - return NULL; + goto no_xmesa_context; /* Note: the XMesaContext contains a Mesa struct gl_context struct (inheritance) */ c = (XMesaContext) CALLOC_STRUCT(xmesa_context); if (!c) - return NULL; + goto no_xmesa_context; c-xm_visual = v; c-xm_buffer = NULL; /* set later by XMesaMakeCurrent */ @@ -888,40 +888,56 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list, if (contextFlags GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB) attribs.flags |= ST_CONTEXT_FLAG_ROBUST_ACCESS; - /* There are no profiles before OpenGL 3.2. The -* GLX_ARB_create_context_profile spec says: -* -* If the requested OpenGL version is less than 3.2, -* GLX_CONTEXT_PROFILE_MASK_ARB is ignored and the functionality of the -* context is determined solely by the requested version. -* -* The spec also says: -* -* The default value for GLX_CONTEXT_PROFILE_MASK_ARB is -* GLX_CONTEXT_CORE_PROFILE_BIT_ARB. -* -* The spec also says: -* -* If version 3.1 is requested, the context returned may implement -* any of the following versions: -* -* * Version 3.1. The GL_ARB_compatibility extension may or may not -* be implemented, as determined by the implementation. -* * The core profile of version 3.2 or greater. -* -* and because Mesa doesn't support GL_ARB_compatibility, the only chance to -* honour a 3.1 context is through core profile. -*/ - attribs.profile = ST_PROFILE_DEFAULT; - if (((major 3 || (major == 3 minor = 2)) - ((profileMask GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) == 0)) || - (major == 3 minor == 1)) - attribs.profile = ST_PROFILE_OPENGL_CORE; + switch (profileMask) { + case GLX_CONTEXT_CORE_PROFILE_BIT_ARB: + /* There are no profiles before OpenGL 3.2. The + * GLX_ARB_create_context_profile spec says: + * + * If the requested OpenGL version is less than 3.2, + * GLX_CONTEXT_PROFILE_MASK_ARB is ignored and the functionality + * of the context is determined solely by the requested version. + */ + if (major 3 || (major == 3 minor = 2)) { + attribs.profile = ST_PROFILE_OPENGL_CORE; + break; + } + /* fall-through */ + case GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB: + /* + * The spec also says: + * + * If version 3.1 is requested, the context returned may implement + * any of the following versions: + * + * * Version 3.1. The GL_ARB_compatibility extension may or may not + * be implemented, as determined by the implementation. + * * The core profile of version 3.2 or greater. + * + * and because Mesa doesn't support GL_ARB_compatibility, the only chance to + * honour a 3.1 context is through core profile. + */ + if (major == 3 minor == 1) { + attribs.profile = ST_PROFILE_OPENGL_CORE; + } else { + attribs.profile = ST_PROFILE_DEFAULT; + } + break; + case GLX_CONTEXT_ES_PROFILE_BIT_EXT: + if (major = 2) { + attribs.profile = ST_PROFILE_OPENGL_ES2; + }
[Mesa-dev] [PATCH 3/3] glx: Allow to create any OpenGL ES version.
From: José Fonseca jfons...@vmware.com The latest version of GLX_EXT_create_context_es2_profile states: If the version requested is a valid and supported OpenGL-ES version, and the GLX_CONTEXT_ES_PROFILE_BIT_EXT bit is set in the GLX_CONTEXT_PROFILE_MASK_ARB attribute (see below), then the context returned will implement the OpenGL ES version requested. We must also export EXT_create_context_es_profile too, as EXT_create_context_es2_profile specification is crystal clear: NOTE: implementations of this extension must export BOTH extension strings, for backwards compatibility with applications written against version 1 of this extension. Totally untested. (Just happened to noticed this while implementing GLX_EXT_create_context_es2_profile for st/xlib.) --- src/glx/dri_common.c | 32 src/glx/drisw_glx.c | 2 ++ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c index 63c8de3..541abbb 100644 --- a/src/glx/dri_common.c +++ b/src/glx/dri_common.c @@ -544,9 +544,22 @@ dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs, case GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB: *api = __DRI_API_OPENGL; break; - case GLX_CONTEXT_ES2_PROFILE_BIT_EXT: -*api = __DRI_API_GLES2; -break; + case GLX_CONTEXT_ES_PROFILE_BIT_EXT: + switch (*major_ver) { + case 3: +*api = __DRI_API_GLES3; +break; + case 2: +*api = __DRI_API_GLES2; +break; + case 1: +*api = __DRI_API_GLES; +break; + default: +*error = __DRI_CTX_ERROR_BAD_API; +return false; + } + break; default: *error = __DRI_CTX_ERROR_BAD_API; return false; @@ -577,19 +590,6 @@ dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs, return false; } - /* The GLX_EXT_create_context_es2_profile spec says: -* -* ... If the version requested is 2.0, and the -* GLX_CONTEXT_ES2_PROFILE_BIT_EXT bit is set in the -* GLX_CONTEXT_PROFILE_MASK_ARB attribute (see below), then the context -* returned will implement OpenGL ES 2.0. This is the only way in which -* an implementation may request an OpenGL ES 2.0 context. -*/ - if (*api == __DRI_API_GLES2 (*major_ver != 2 || *minor_ver != 0)) { - *error = __DRI_CTX_ERROR_BAD_API; - return false; - } - *error = __DRI_CTX_ERROR_SUCCESS; return true; } diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index 749ceb0..b0be5d0 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -617,6 +617,8 @@ driswBindExtensions(struct drisw_screen *psc, const __DRIextension **extensions) /* DRISW version = 2 implies support for OpenGL ES 2.0. */ __glXEnableDirectExtension(psc-base, +GLX_EXT_create_context_es_profile); + __glXEnableDirectExtension(psc-base, GLX_EXT_create_context_es2_profile); } -- 2.1.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] util/format: Generate floating point constants for clamping.
From: José Fonseca jfons...@vmware.com This commit causes the generated C code to change as union util_format_r32g32b32a32_sscaled pixel; - pixel.chan.r = (int32_t)CLAMP(src[0], -2147483648, 2147483647); - pixel.chan.g = (int32_t)CLAMP(src[1], -2147483648, 2147483647); - pixel.chan.b = (int32_t)CLAMP(src[2], -2147483648, 2147483647); - pixel.chan.a = (int32_t)CLAMP(src[3], -2147483648, 2147483647); + pixel.chan.r = (int32_t)CLAMP(src[0], -2147483648.0f, 2147483647.0f); + pixel.chan.g = (int32_t)CLAMP(src[1], -2147483648.0f, 2147483647.0f); + pixel.chan.b = (int32_t)CLAMP(src[2], -2147483648.0f, 2147483647.0f); + pixel.chan.a = (int32_t)CLAMP(src[3], -2147483648.0f, 2147483647.0f); memcpy(dst, pixel, sizeof pixel); which surprisingly makes a difference for MSVC. Thanks to Juraj Svec for diagnosing this and drafting a fix. Fixes https://bugs.freedesktop.org/show_bug.cgi?id=29661 Cc: 10.2 10.3 mesa-sta...@lists.freedesktop.org --- src/gallium/auxiliary/util/u_format_pack.py | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py index 6ccf04c..90f348e 100644 --- a/src/gallium/auxiliary/util/u_format_pack.py +++ b/src/gallium/auxiliary/util/u_format_pack.py @@ -226,9 +226,9 @@ def native_to_constant(type, value): '''Get the value of unity for this type.''' if type.type == FLOAT: if type.size = 32: -return %ff % value +return %.1ff % float(value) else: -return %ff % value +return %.1f % float(value) else: return str(int(value)) @@ -251,8 +251,8 @@ def clamp_expr(src_channel, dst_channel, dst_native_type, value): dst_max = dst_channel.max() # Translate the destination range to the src native value -dst_min_native = value_to_native(src_channel, dst_min) -dst_max_native = value_to_native(src_channel, dst_max) +dst_min_native = native_to_constant(src_channel, value_to_native(src_channel, dst_min)) +dst_max_native = native_to_constant(src_channel, value_to_native(src_channel, dst_max)) if src_min dst_min and src_max dst_max: return 'CLAMP(%s, %s, %s)' % (value, dst_min_native, dst_max_native) -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] llvmpipe: Avoid deadlock when unloading opengl32.dll
From: José Fonseca jfons...@vmware.com On Windows, DllMain calls and thread creation/destruction are serialized, so when llvmpipe is destroyed from DllMain waiting for the rasterizer threads to finish will deadlock. So, instead of waiting for rasterizer threads to have finished, simply wait for the rasterizer threads to notify they are just about to finish. Verified with this very simple program: #include windows.h int main() { HMODULE hModule = LoadLibraryA(opengl32.dll); FreeLibrary(hModule); } Fixes https://bugs.freedesktop.org/show_bug.cgi?id=76252 Cc: 10.2 10.3 mesa-sta...@lists.freedesktop.org --- src/gallium/drivers/llvmpipe/lp_rast.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index a3420a2..6b54d43 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -800,6 +800,8 @@ static PIPE_THREAD_ROUTINE( thread_function, init_data ) pipe_semaphore_signal(task-work_done); } + pipe_semaphore_signal(task-work_done); + return 0; } @@ -885,9 +887,11 @@ void lp_rast_destroy( struct lp_rasterizer *rast ) pipe_semaphore_signal(rast-tasks[i].work_ready); } - /* Wait for threads to terminate before cleaning up per-thread data */ + /* Wait for threads to terminate before cleaning up per-thread data. +* We don't actually call pipe_thread_wait to avoid dead lock on Windows +* per https://bugs.freedesktop.org/show_bug.cgi?id=76252 */ for (i = 0; i rast-num_threads; i++) { - pipe_thread_wait(rast-threads[i]); + pipe_semaphore_wait(rast-tasks[i].work_done); } /* Clean up per-thread data */ -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] util/format: Fix clamping to 32bit integers.
From: José Fonseca jfons...@vmware.com Use clamping constants that guarantee no integer overflows. As spotted by Chris Forbes. This causes the code to change as: - value |= (uint32_t)CLAMP(src[0], 0.0f, 4294967295.0f); + value |= (uint32_t)CLAMP(src[0], 0.0f, 4294967040.0f); - value |= (uint32_t)((int32_t)CLAMP(src[0], -2147483648.0f, 2147483647.0f)); + value |= (uint32_t)((int32_t)CLAMP(src[0], -2147483648.0f, 2147483520.0f)); --- src/gallium/auxiliary/util/u_format_pack.py | 27 +++ 1 file changed, 27 insertions(+) diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py index 90f348e..d5138cc 100644 --- a/src/gallium/auxiliary/util/u_format_pack.py +++ b/src/gallium/auxiliary/util/u_format_pack.py @@ -207,9 +207,36 @@ def get_one_shift(type): assert False +def truncate_mantissa(x, bits): +'''Truncate an integer so it can be represented exactly with a floating +point mantissa''' + +assert isinstance(x, (int, long)) + +s = 1 +if x 0: +s = -1 +x = -x + +# We can represent integers up to mantissa + 1 bits exactly +mask = (1 (bits + 1)) - 1 + +# Slide the mask until the MSB matches +shift = 0 +while (x shift) ~mask: +shift += 1 + +x = mask shift +x *= s +return x + + def value_to_native(type, value): '''Get the value of unity for this type.''' if type.type == FLOAT: +if type.size = 32 \ +and isinstance(value, (int, long)): +return truncate_mantissa(value, 23) return value if type.type == FIXED: return int(value * (1 (type.size/2))) -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] llvmpipe: Flush stdout on lp_test_* unit tests.
From: José Fonseca jfons...@vmware.com So that the order of test messages and gallivm/llvmpipe debug output is preserved. Trivial. --- src/gallium/drivers/llvmpipe/lp_test_arit.c | 1 + src/gallium/drivers/llvmpipe/lp_test_format.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/gallium/drivers/llvmpipe/lp_test_arit.c b/src/gallium/drivers/llvmpipe/lp_test_arit.c index 660ad4d..3fc64ce 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_arit.c +++ b/src/gallium/drivers/llvmpipe/lp_test_arit.c @@ -395,6 +395,7 @@ test_unary(unsigned verbose, FILE *fp, const struct unary_test_t *test) printf(%s(%.9g): ref = %.9g, out = %.9g, precision = %f bits, %s\n, test-name, in[i], ref, out[i], precision, pass ? PASS : FAIL); +fflush(stdout); } if (!pass) { diff --git a/src/gallium/drivers/llvmpipe/lp_test_format.c b/src/gallium/drivers/llvmpipe/lp_test_format.c index cdacb1b..a4b3b56 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_format.c +++ b/src/gallium/drivers/llvmpipe/lp_test_format.c @@ -156,6 +156,7 @@ test_format_float(unsigned verbose, FILE *fp, if (first) { printf(Testing %s (float) ...\n, desc-name); +fflush(stdout); first = FALSE; } @@ -194,6 +195,7 @@ test_format_float(unsigned verbose, FILE *fp, test-unpacked[i][j][1], test-unpacked[i][j][2], test-unpacked[i][j][3]); + fflush(stdout); success = FALSE; } } -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] llvmpipe: Ensure the packed input of the lp_test_format is aligned.
From: José Fonseca jfons...@vmware.com https://bugs.freedesktop.org/show_bug.cgi?id=85377 http://llvm.org/bugs/show_bug.cgi?id=21365 --- src/gallium/drivers/llvmpipe/lp_test_format.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_test_format.c b/src/gallium/drivers/llvmpipe/lp_test_format.c index a4b3b56..48bf06e 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_format.c +++ b/src/gallium/drivers/llvmpipe/lp_test_format.c @@ -133,6 +133,7 @@ test_format_float(unsigned verbose, FILE *fp, struct gallivm_state *gallivm; LLVMValueRef fetch = NULL; fetch_ptr_t fetch_ptr; + PIPE_ALIGN_VAR(16) uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES]; PIPE_ALIGN_VAR(16) float unpacked[4]; boolean first = TRUE; boolean success = TRUE; @@ -160,13 +161,16 @@ test_format_float(unsigned verbose, FILE *fp, first = FALSE; } + /* To ensure it's 16-byte aligned */ + memcpy(packed, test-packed, sizeof packed); + for (i = 0; i desc-block.height; ++i) { for (j = 0; j desc-block.width; ++j) { boolean match = TRUE; memset(unpacked, 0, sizeof unpacked); - fetch_ptr(unpacked, test-packed, j, i); + fetch_ptr(unpacked, packed, j, i); for(k = 0; k 4; ++k) { if (util_double_inf_sign(test-unpacked[i][j][k]) != util_inf_sign(unpacked[k])) { @@ -220,6 +224,7 @@ test_format_unorm8(unsigned verbose, FILE *fp, struct gallivm_state *gallivm; LLVMValueRef fetch = NULL; fetch_ptr_t fetch_ptr; + PIPE_ALIGN_VAR(16) uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES]; uint8_t unpacked[4]; boolean first = TRUE; boolean success = TRUE; @@ -246,13 +251,16 @@ test_format_unorm8(unsigned verbose, FILE *fp, first = FALSE; } + /* To ensure it's 16-byte aligned */ + memcpy(packed, test-packed, sizeof packed); + for (i = 0; i desc-block.height; ++i) { for (j = 0; j desc-block.width; ++j) { boolean match; memset(unpacked, 0, sizeof unpacked); - fetch_ptr(unpacked, test-packed, j, i); + fetch_ptr(unpacked, packed, j, i); match = TRUE; for(k = 0; k 4; ++k) { -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/3] gallivm, llvmpipe, clover: Bump required LLVM version to 3.3.
From: José Fonseca jfons...@vmware.com We'll need to update gallivm for the interface changes in LLVM 3.6, and the fewer the number of older LLVM versions we support the less hairy that will be. As consequence HAVE_AVX define can disappear. (Note HAVE_AVX means whether LLVM version is supported or not. Runtime support for AVX is always checked and enforced independently.) Verified llvmpipe builds and runs with with LLVM 3.3, 3.4, and 3.5. --- configure.ac | 2 +- scons/llvm.py | 16 ++ src/gallium/auxiliary/gallivm/lp_bld.h | 4 +-- src/gallium/auxiliary/gallivm/lp_bld_debug.cpp | 6 +--- src/gallium/auxiliary/gallivm/lp_bld_init.c| 37 ++ src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 30 ++ src/gallium/drivers/llvmpipe/lp_screen.c | 6 src/gallium/drivers/llvmpipe/lp_state_fs.c | 8 - .../state_trackers/clover/llvm/invocation.cpp | 36 + 9 files changed, 11 insertions(+), 134 deletions(-) diff --git a/configure.ac b/configure.ac index 0ed9325..09a71b7 100644 --- a/configure.ac +++ b/configure.ac @@ -1714,7 +1714,7 @@ if test x$enable_gallium_llvm = xyes; then fi LLVM_REQUIRED_VERSION_MAJOR=3 -LLVM_REQUIRED_VERSION_MINOR=1 +LLVM_REQUIRED_VERSION_MINOR=3 if test $LLVM_VERSION_INT -lt ${LLVM_REQUIRED_VERSION_MAJOR}0${LLVM_REQUIRED_VERSION_MINOR}; then AC_MSG_ERROR([LLVM $LLVM_REQUIRED_VERSION_MAJOR.$LLVM_REQUIRED_VERSION_MINOR or newer is required]) fi diff --git a/scons/llvm.py b/scons/llvm.py index 288a080..1e312f9 100644 --- a/scons/llvm.py +++ b/scons/llvm.py @@ -37,7 +37,7 @@ import SCons.Errors import SCons.Util -required_llvm_version = '3.1' +required_llvm_version = '3.3' def generate(env): @@ -98,7 +98,7 @@ def generate(env): 'HAVE_STDINT_H', ]) env.Prepend(LIBPATH = [os.path.join(llvm_dir, 'lib')]) -if llvm_version = distutils.version.LooseVersion('3.2'): +if True: # 3.2 env.Prepend(LIBS = [ 'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser', @@ -110,18 +110,6 @@ def generate(env): 'LLVMAnalysis', 'LLVMTarget', 'LLVMMC', 'LLVMCore', 'LLVMSupport', 'LLVMRuntimeDyld', 'LLVMObject' ]) -else: -# 3.1 -env.Prepend(LIBS = [ -'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser', -'LLVMX86CodeGen', 'LLVMX86Desc', 'LLVMSelectionDAG', -'LLVMAsmPrinter', 'LLVMMCParser', 'LLVMX86AsmPrinter', -'LLVMX86Utils', 'LLVMX86Info', 'LLVMMCJIT', 'LLVMJIT', -'LLVMExecutionEngine', 'LLVMCodeGen', 'LLVMScalarOpts', -'LLVMInstCombine', 'LLVMTransformUtils', 'LLVMipa', -'LLVMAnalysis', 'LLVMTarget', 'LLVMMC', 'LLVMCore', -'LLVMSupport' -]) env.Append(LIBS = [ 'imagehlp', 'psapi', diff --git a/src/gallium/auxiliary/gallivm/lp_bld.h b/src/gallium/auxiliary/gallivm/lp_bld.h index a01c216..7ba925c 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld.h +++ b/src/gallium/auxiliary/gallivm/lp_bld.h @@ -53,8 +53,8 @@ #ifndef HAVE_LLVM #error HAVE_LLVM should be set with LLVM's version number, e.g. (0x0207 for 2.7) #endif -#if HAVE_LLVM 0x301 -#error LLVM 3.1 or newer required +#if HAVE_LLVM 0x303 +#error LLVM 3.3 or newer required #endif diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp index b6b52c8..bad65c2 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp @@ -43,11 +43,7 @@ #include llvm/Support/Host.h -#if HAVE_LLVM = 0x0303 #include llvm/IR/Module.h -#else -#include llvm/Module.h -#endif #include llvm/MC/MCDisassembler.h #include llvm/MC/MCAsmInfo.h @@ -57,7 +53,7 @@ #if HAVE_LLVM = 0x0305 #define OwningPtr std::unique_ptr -#elif HAVE_LLVM = 0x0303 +#else #include llvm/ADT/OwningPtr.h #endif diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c index 8d7a0b6..b82cb77 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c @@ -45,35 +45,13 @@ /* Only MCJIT is available as of LLVM SVN r216982 */ #if HAVE_LLVM = 0x0306 - -#define USE_MCJIT 1 -#define HAVE_AVX 1 - -#else - -/** - * AVX is supported in: - * - standard JIT from LLVM 3.2 onwards - * - MC-JIT from LLVM 3.1 - * - MC-JIT supports limited OSes (MacOSX and Linux) - * - standard JIT in LLVM 3.1, with backports - */ -#if defined(PIPE_ARCH_PPC_64) || defined(PIPE_ARCH_S390) || defined(PIPE_ARCH_ARM) || defined(PIPE_ARCH_AARCH64) # define USE_MCJIT 1 -# define HAVE_AVX 0 -#elif
[Mesa-dev] [PATCH 2/3] gallivm: Fix white-space.
From: José Fonseca jfons...@vmware.com Replace tabs with spaces. --- src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp index ab3b3c9..a1d2940 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp @@ -132,7 +132,7 @@ lp_set_load_alignment(LLVMValueRef Inst, extern C void lp_set_store_alignment(LLVMValueRef Inst, - unsigned Align) + unsigned Align) { llvm::unwrapllvm::StoreInst(Inst)-setAlignment(Align); } @@ -322,14 +322,14 @@ class ShaderMemoryManager : public DelegatingJITMemoryManager { * Deallocate things as previously requested and * free shared manager when no longer used. */ -Vec::iterator i; + Vec::iterator i; -assert(TheMM); -for ( i = FunctionBody.begin(); i != FunctionBody.end(); ++i ) - TheMM-deallocateFunctionBody(*i); + assert(TheMM); + for ( i = FunctionBody.begin(); i != FunctionBody.end(); ++i ) +TheMM-deallocateFunctionBody(*i); #if HAVE_LLVM 0x0304 -for ( i = ExceptionTable.begin(); i != ExceptionTable.end(); ++i ) - TheMM-deallocateExceptionTable(*i); + for ( i = ExceptionTable.begin(); i != ExceptionTable.end(); ++i ) +TheMM-deallocateExceptionTable(*i); #endif } }; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/3] gallivm: Properly update for removal of JITMemoryManager in LLVM 3.6.
From: José Fonseca jfons...@vmware.com JITMemoryManager was removed in LLVM 3.6, and replaced by its base class RTDyldMemoryManager. This change fixes our JIT memory managers specializations to derive from RTDyldMemoryManager in LLVM 3.6 instead of JITMemoryManager. This enables llvmpipe to run with LLVM 3.6. However, lp_free_generated_code is basically a no-op because there are not enough hook points in RTDyldMemoryManager to track and free the code of a module. In other words, with MCJIT, code once created, stays forever allocated until process destruction. This is not speicfic to LLVM 3.6 -- it will happen whenever MCJIT is used regardless of version. --- src/gallium/auxiliary/gallivm/lp_bld_init.c | 11 - src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 68 --- 2 files changed, 41 insertions(+), 38 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c index b82cb77..23a7c45 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c @@ -293,13 +293,9 @@ init_gallivm_state(struct gallivm_state *gallivm, const char *name, if (!gallivm-builder) goto fail; -#if HAVE_LLVM 0x0306 gallivm-memorymgr = lp_get_default_memory_manager(); if (!gallivm-memorymgr) goto fail; -#else - gallivm-memorymgr = 0; -#endif /* FIXME: MC-JIT only allows compiling one module at a time, and it must be * complete when MC-JIT is created. So defer the MC-JIT engine creation for @@ -364,13 +360,6 @@ lp_build_init(void) if (gallivm_initialized) return TRUE; - /* XXX: Remove this once lp_bld_misc.cpp has been adapted to the removal -* of JITMemoryManager -*/ -#if HAVE_LLVM = 0x0306 - return FALSE; -#endif - #ifdef DEBUG gallivm_debug = debug_get_option_gallivm_debug(); #endif diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp index a1d2940..776af47 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp @@ -57,6 +57,8 @@ #include llvm/ADT/Triple.h #if HAVE_LLVM 0x0306 #include llvm/ExecutionEngine/JITMemoryManager.h +#else +#include llvm/ExecutionEngine/SectionMemoryManager.h #endif #include llvm/Support/CommandLine.h #include llvm/Support/Host.h @@ -137,19 +139,26 @@ lp_set_store_alignment(LLVMValueRef Inst, llvm::unwrapllvm::StoreInst(Inst)-setAlignment(Align); } + #if HAVE_LLVM 0x0306 +typedef llvm::JITMemoryManager BaseMemoryManager; +#else +typedef llvm::RTDyldMemoryManager BaseMemoryManager; +#endif + /* * Delegating is tedious but the default manager class is hidden in an * anonymous namespace in LLVM, so we cannot just derive from it to change * its behavior. */ -class DelegatingJITMemoryManager : public llvm::JITMemoryManager { +class DelegatingJITMemoryManager : public BaseMemoryManager { protected: - virtual llvm::JITMemoryManager *mgr() const = 0; + virtual BaseMemoryManager *mgr() const = 0; public: +#if HAVE_LLVM 0x0306 /* * From JITMemoryManager */ @@ -233,6 +242,7 @@ class DelegatingJITMemoryManager : public llvm::JITMemoryManager { virtual unsigned GetNumStubSlabs() { return mgr()-GetNumStubSlabs(); } +#endif /* * From RTDyldMemoryManager @@ -306,14 +316,14 @@ class DelegatingJITMemoryManager : public llvm::JITMemoryManager { */ class ShaderMemoryManager : public DelegatingJITMemoryManager { - llvm::JITMemoryManager *TheMM; + BaseMemoryManager *TheMM; struct GeneratedCode { typedef std::vectorvoid * Vec; Vec FunctionBody, ExceptionTable; - llvm::JITMemoryManager *TheMM; + BaseMemoryManager *TheMM; - GeneratedCode(llvm::JITMemoryManager *MM) { + GeneratedCode(BaseMemoryManager *MM) { TheMM = MM; } @@ -322,6 +332,7 @@ class ShaderMemoryManager : public DelegatingJITMemoryManager { * Deallocate things as previously requested and * free shared manager when no longer used. */ +#if HAVE_LLVM 0x0306 Vec::iterator i; assert(TheMM); @@ -330,19 +341,20 @@ class ShaderMemoryManager : public DelegatingJITMemoryManager { #if HAVE_LLVM 0x0304 for ( i = ExceptionTable.begin(); i != ExceptionTable.end(); ++i ) TheMM-deallocateExceptionTable(*i); -#endif +#endif /* HAVE_LLVM 0x0304 */ +#endif /* HAVE_LLVM 0x0306 */ } }; GeneratedCode *code; - llvm::JITMemoryManager *mgr() const { + BaseMemoryManager *mgr() const { return TheMM; } public: - ShaderMemoryManager(llvm::JITMemoryManager* MM) { + ShaderMemoryManager(BaseMemoryManager* MM) { TheMM = MM; code = new GeneratedCode(MM); } @@ -375,7 +387,6 @@ class ShaderMemoryManager : public DelegatingJITMemoryManager {
[Mesa-dev] [PATCH] glsl/glcpp: Rename ERROR to ERROR_TOKEN.
From: José Fonseca jfons...@vmware.com To prevent collision with wingdi.h's ERROR define, using the same _TOKEN suffix already forsome other tokens due to similar reasons. PS: Name collisions will be rife with single capitalized words. And using _TOKEN suffix for only some of the tokens is not particularly consistent nor pretty. So it might be worth using an unique prefix/suffix for all tokens (even if something short like *_TKN or TKN_*), to avoid this sort of issue while having consistency. --- src/glsl/glcpp/glcpp-lex.l | 2 +- src/glsl/glcpp/glcpp-parse.y | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l index 4b9ab23..c126850 100644 --- a/src/glsl/glcpp/glcpp-lex.l +++ b/src/glsl/glcpp/glcpp-lex.l @@ -350,7 +350,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]? HASHerror.* { BEGIN INITIAL; - RETURN_STRING_TOKEN (ERROR); + RETURN_STRING_TOKEN (ERROR_TOKEN); } /* After we see a #define we enter the DEFINE start state diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index bc873cd..4ee4110 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -171,11 +171,11 @@ add_builtin_define(glcpp_parser_t *parser, const char *name, int value); /* We use HASH_TOKEN, DEFINE_TOKEN and VERSION_TOKEN (as opposed to * HASH, DEFINE, and VERSION) to avoid conflicts with other symbols, * (such as the HASH and DEFINE start conditions in the lexer). */ -%token COMMA_FINAL DEFINED ELIF_EXPANDED HASH_TOKEN DEFINE_TOKEN FUNC_IDENTIFIER OBJ_IDENTIFIER ELIF ELSE ENDIF ERROR IF IFDEF IFNDEF LINE PRAGMA UNDEF VERSION_TOKEN GARBAGE IDENTIFIER IF_EXPANDED INTEGER INTEGER_STRING LINE_EXPANDED NEWLINE OTHER PLACEHOLDER SPACE PLUS_PLUS MINUS_MINUS +%token COMMA_FINAL DEFINED ELIF_EXPANDED HASH_TOKEN DEFINE_TOKEN FUNC_IDENTIFIER OBJ_IDENTIFIER ELIF ELSE ENDIF ERROR_TOKEN IF IFDEF IFNDEF LINE PRAGMA UNDEF VERSION_TOKEN GARBAGE IDENTIFIER IF_EXPANDED INTEGER INTEGER_STRING LINE_EXPANDED NEWLINE OTHER PLACEHOLDER SPACE PLUS_PLUS MINUS_MINUS %token PASTE %type ival INTEGER operator SPACE integer_constant %type expression_value expression -%type str IDENTIFIER FUNC_IDENTIFIER OBJ_IDENTIFIER INTEGER_STRING OTHER ERROR PRAGMA +%type str IDENTIFIER FUNC_IDENTIFIER OBJ_IDENTIFIER INTEGER_STRING OTHER ERROR_TOKEN PRAGMA %type string_list identifier_list %type token preprocessing_token conditional_token %type token_list pp_tokens replacement_list text_line conditional_tokens @@ -421,7 +421,7 @@ control_line_success: ; control_line_error: - HASH_TOKEN ERROR NEWLINE { + HASH_TOKEN ERROR_TOKEN NEWLINE { glcpp_error( @1, parser, #%s, $2); } | HASH_TOKEN GARBAGE pp_tokens NEWLINE { -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] st/wgl: Clamp wglChoosePixelFormatARB's output nNumFormats to nMaxFormats.
From: José Fonseca jfons...@vmware.com While running https://github.com/nvMcJohn/apitest with apitrace I noticed that Mesa was producing bogus results: wglChoosePixelFormatARB(hdc, piAttribIList = {...}, pfAttribFList = 0, nMaxFormats = 1, piFormats = {19, 65576, 37, 198656, 131075, 0, 402653184, 0, 0, 0, 0, -573575710}, nNumFormats = 12) = TRUE However https://www.opengl.org/registry/specs/ARB/wgl_pixel_format.txt states nNumFormats returns the number of matching formats. The returned value is guaranteed to be no larger than nMaxFormats. Cc: 10.2 mesa-sta...@lists.freedesktop.org --- src/gallium/state_trackers/wgl/stw_ext_pixelformat.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/wgl/stw_ext_pixelformat.c b/src/gallium/state_trackers/wgl/stw_ext_pixelformat.c index d303b01..91682d1 100644 --- a/src/gallium/state_trackers/wgl/stw_ext_pixelformat.c +++ b/src/gallium/state_trackers/wgl/stw_ext_pixelformat.c @@ -448,9 +448,11 @@ wglChoosePixelFormatARB( */ for (i = 0; i count; i++) { if (scores[i].points 0) { - if (*nNumFormats nMaxFormats) -piFormats[*nNumFormats] = scores[i].index + 1; +piFormats[*nNumFormats] = scores[i].index + 1; (*nNumFormats)++; +if (*nNumFormats = nMaxFormats) { + break; +} } } -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] mesa/main: Prevent sefgault on glGetIntegerv(GL_ATOMIC_COUNTER_BUFFER_BINDING).
From: José Fonseca jfons...@vmware.com A recent ApiTrace change, that tries to dump more buffer state causes Mesa from my distro (10.1.4) to segfaults here. I haven't actually confirm this fixes it (I can't repro on master), but it seems a good idea to be defensive here anyway. Cc: 10.1 10.2 mesa-sta...@lists.freedesktop.org --- src/mesa/main/get.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 267b5f2..9b56edb 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1005,7 +1005,11 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu break; /* GL_ARB_shader_atomic_counters */ case GL_ATOMIC_COUNTER_BUFFER_BINDING: - v-value_int = ctx-AtomicBuffer-Name; + if (ctx-AtomicBuffer) { + v-value_int = ctx-AtomicBuffer-Name; + } else { + v-value_int = 0; + } break; /* GL_ARB_draw_indirect */ case GL_DRAW_INDIRECT_BUFFER_BINDING: -- 2.0.0.rc2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] wgl: Disable CRT message boxes when Windows system error messages boxes are disabled.
From: José Fonseca jfons...@vmware.com At least on MSVC we statically link against the CRT, so we must disable the CRT message boxes if we want to attended testing. The messages are convenient when running manually, so let them be if the system error message boxes are not disabled. --- src/gallium/auxiliary/util/u_debug.c| 32 + src/gallium/auxiliary/util/u_debug.h| 9 src/gallium/state_trackers/wgl/stw_device.c | 2 ++ 3 files changed, 43 insertions(+) diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c index dc840e8..d79f31e 100644 --- a/src/gallium/auxiliary/util/u_debug.c +++ b/src/gallium/auxiliary/util/u_debug.c @@ -46,6 +46,12 @@ #include limits.h /* CHAR_BIT */ #include ctype.h /* isalnum */ +#ifdef _WIN32 +#include windows.h +#include stdlib.h +#endif + + void _debug_vprintf(const char *format, va_list ap) { static char buf[4096] = {'\0'}; @@ -64,6 +70,32 @@ void _debug_vprintf(const char *format, va_list ap) } +void +debug_disable_error_message_boxes(void) +{ +#ifdef _WIN32 + /* When Windows' error message boxes are disabled for this process (as is +* typically the case when running tests in an automated fashion) we disable +* CRT message boxes too. +*/ + UINT uMode = SetErrorMode(0); + SetErrorMode(uMode); + if (uMode SEM_FAILCRITICALERRORS) { + /* Disable assertion failure message box. + * http://msdn.microsoft.com/en-us/library/sas1dkb2.aspx + */ + _set_error_mode(_OUT_TO_STDERR); +#ifdef _MSC_VER + /* Disable abort message box. + * http://msdn.microsoft.com/en-us/library/e631wekh.aspx + */ + _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); +#endif + } +#endif /* _WIN32 */ +} + + #ifdef DEBUG void debug_print_blob( const char *name, const void *blob, diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h index 9c41421..badd5e2 100644 --- a/src/gallium/auxiliary/util/u_debug.h +++ b/src/gallium/auxiliary/util/u_debug.h @@ -139,6 +139,15 @@ void debug_print_format(const char *msg, unsigned fmt ); /** + * Disable interactive error message boxes. + * + * Should be called as soon as possible for effectiveness. + */ +void +debug_disable_error_message_boxes(void); + + +/** * Hard-coded breakpoint. */ #ifdef DEBUG diff --git a/src/gallium/state_trackers/wgl/stw_device.c b/src/gallium/state_trackers/wgl/stw_device.c index 8f2cf9c..025dbdc 100644 --- a/src/gallium/state_trackers/wgl/stw_device.c +++ b/src/gallium/state_trackers/wgl/stw_device.c @@ -69,6 +69,8 @@ stw_init(const struct stw_winsys *stw_winsys) static struct stw_device stw_dev_storage; struct pipe_screen *screen; + debug_disable_error_message_boxes(); + debug_printf(%s\n, __FUNCTION__); assert(!stw_dev); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] mesa: Make glGetIntegerv(GL_*_ARRAY_SIZE) return GL_BGRA.
From: José Fonseca jfons...@vmware.com Same as b026b6bbfe3f15c8a7296ac107dc3d31f74e401e, but COLOR_ARRAY_SIZE/SECONDARY_COLOR_ARRAY_SIZE. Ideally we wouldn't munge the incoming state, so that we wouldn't need to unmunge it back on glGet*. But the array size state is copied and referred in many places, many of which . So just hack around on glGet* time, to ensure there is no risk of introducing regressions elsewhere. This bug causes problems to Apitrace, resulting in wrong traces. See https://github.com/apitrace/apitrace/issues/261 for details. Tested with piglit arb_vertex_array_bgra-get, which was created for this purpose. --- src/mesa/main/get.c | 10 ++ src/mesa/main/get_hash_params.py | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 80a5839..267b5f2 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -847,6 +847,16 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu v-value_int = ctx-Array.VAO-IndexBufferObj-Name; break; + /* ARB_vertex_array_bgra */ + case GL_COLOR_ARRAY_SIZE: + array = ctx-Array.VAO-VertexAttrib[VERT_ATTRIB_COLOR0]; + v-value_int = array-Format == GL_BGRA ? GL_BGRA : array-Size; + break; + case GL_SECONDARY_COLOR_ARRAY_SIZE: + array = ctx-Array.VAO-VertexAttrib[VERT_ATTRIB_COLOR1]; + v-value_int = array-Format == GL_BGRA ? GL_BGRA : array-Size; + break; + /* ARB_copy_buffer */ case GL_COPY_READ_BUFFER: v-value_int = ctx-CopyReadBuffer-Name; diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py index d40fa07..c7a6e02 100644 --- a/src/mesa/main/get_hash_params.py +++ b/src/mesa/main/get_hash_params.py @@ -199,7 +199,7 @@ descriptor=[ [ NORMAL_ARRAY_TYPE, ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_NORMAL].Type), NO_EXTRA ], [ NORMAL_ARRAY_STRIDE, ARRAY_INT(VertexAttrib[VERT_ATTRIB_NORMAL].Stride), NO_EXTRA ], [ COLOR_ARRAY, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_COLOR0].Enabled), NO_EXTRA ], - [ COLOR_ARRAY_SIZE, ARRAY_INT(VertexAttrib[VERT_ATTRIB_COLOR0].Size), NO_EXTRA ], + [ COLOR_ARRAY_SIZE, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA ], [ COLOR_ARRAY_TYPE, ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_COLOR0].Type), NO_EXTRA ], [ COLOR_ARRAY_STRIDE, ARRAY_INT(VertexAttrib[VERT_ATTRIB_COLOR0].Stride), NO_EXTRA ], [ TEXTURE_COORD_ARRAY, LOC_CUSTOM, TYPE_BOOLEAN, offsetof(struct gl_client_array, Enabled), NO_EXTRA ], @@ -552,7 +552,7 @@ descriptor=[ [ SECONDARY_COLOR_ARRAY, ARRAY_BOOL(VertexAttrib[VERT_ATTRIB_COLOR1].Enabled), NO_EXTRA ], [ SECONDARY_COLOR_ARRAY_TYPE, ARRAY_ENUM(VertexAttrib[VERT_ATTRIB_COLOR1].Type), NO_EXTRA ], [ SECONDARY_COLOR_ARRAY_STRIDE, ARRAY_INT(VertexAttrib[VERT_ATTRIB_COLOR1].Stride), NO_EXTRA ], - [ SECONDARY_COLOR_ARRAY_SIZE, ARRAY_INT(VertexAttrib[VERT_ATTRIB_COLOR1].Size), NO_EXTRA ], + [ SECONDARY_COLOR_ARRAY_SIZE, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA ], # GL_EXT_fog_coord [ CURRENT_FOG_COORDINATE, CONTEXT_FLOAT(Current.Attrib[VERT_ATTRIB_FOG][0]), extra_flush_current ], -- 2.0.0.rc2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] mesa/main: Make get_hash.c values constant.
From: José Fonseca jfons...@vmware.com --- src/mesa/main/get_hash_generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/get_hash_generator.py b/src/mesa/main/get_hash_generator.py index 96bc495..b200d19 100644 --- a/src/mesa/main/get_hash_generator.py +++ b/src/mesa/main/get_hash_generator.py @@ -52,7 +52,7 @@ def print_header(): (prime_factor, prime_step) def print_params(params): - print static struct value_desc values[] = { + print static const struct value_desc values[] = { for p in params: print { %s, %s }, % (p[0], p[1]) -- 2.0.0.rc2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] docs: Document how to replace Windows built-in OpenGL software rasterizer with llvmpipe.
From: José Fonseca jfons...@vmware.com Just happened to stumble across this registry key while debugging something else. This technique is much neater than trying to override opengl32.dll. Also a few minors cleanups. --- docs/llvmpipe.html | 52 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/docs/llvmpipe.html b/docs/llvmpipe.html index 74f0c67..291527b 100644 --- a/docs/llvmpipe.html +++ b/docs/llvmpipe.html @@ -43,11 +43,7 @@ It's the fastest software rasterizer for Mesa. /p /li li - pLLVM: version 2.9 recommended; 2.6 or later required./p - pbNOTE/b: LLVM 2.8 and earlier will not work on systems that support the - Intel AVX extensions (e.g. Sandybridge). LLVM's code generator will - fail when trying to emit AVX instructions. This was fixed in LLVM 2.9. - /p + pLLVM: version 3.4 recommended; 3.1 or later required./p p For Linux, on a recent Debian based distribution do: /p @@ -101,13 +97,15 @@ but the rest of these instructions assume that scons is used. For Windows the procedure is similar except the target: pre - scons build=debug libgl-gdi + scons platform=windows build=debug libgl-gdi /pre h1Using/h1 -On Linux, building will create a drop-in alternative for libGL.so into +h2Linux/h2 + +pOn Linux, building will create a drop-in alternative for libGL.so into/p pre build/foo/gallium/targets/libgl-xlib/libGL.so @@ -117,15 +115,45 @@ or lib/gallium/libGL.so /pre -To use it set the LD_LIBRARY_PATH environment variable accordingly. +pTo use it set the LD_LIBRARY_PATH environment variable accordingly./p + +pFor performance evaluation pass build=release to scons, and use the corresponding +lib directory without the -debug suffix./p + -For performance evaluation pass debug=no to scons, and use the corresponding -lib directory without the -debug suffix. +h2Windows/h2 -On Windows, building will create a drop-in alternative for opengl32.dll. To use -it put it in the same directory as the application. It can also be used by +p +On Windows, building will create +codebuild/windows-x86-debug/gallium/targets/libgl-gdi/opengl32.dll/code +which is a drop-in alternative for system's codeopengl32.dll/code. To use +it put it in the same directory as your application. It can also be used by replacing the native ICD driver, but it's quite an advanced usage, so if you need to ask, don't even try it. +/p + +p +There is however an easy way to replace the OpenGL software renderer that comes +with Microsoft Windows 7 (or later) with llvmpipe (that is, on systems without +any OpenGL drivers): +/p + +ul + lipcopy build/windows-x86-debug/gallium/targets/libgl-gdi/opengl32.dll to C:\Windows\SysWOW64\mesadrv.dll/p/li + lipload this registry settings:/p + preREGEDIT4 + +; http://technet.microsoft.com/en-us/library/cc749368.aspx +; http://www.msfn.org/board/topic/143241-portable-windows-7-build-from-winpe-30/page-5#entry942596 +[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\OpenGLDrivers\MSOGL] +DLL=mesadrv.dll +DriverVersion=dword:0001 +Flags=dword:0001 +Version=dword:0002 +/pre + /li + liDitto for 64 bits drivers if you need them./li +/ul h1Profiling/h1 -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] scons: Fix x86_64 build.
From: José Fonseca jfons...@vmware.com x86/common_x86.c is required also for x86_64 builds. --- src/mesa/SConscript | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/SConscript b/src/mesa/SConscript index cd959be..f565786 100644 --- a/src/mesa/SConscript +++ b/src/mesa/SConscript @@ -392,6 +392,7 @@ if (env['gcc'] or env['clang']) and \ 'USE_X86_64_ASM', ]) mesa_sources += [ +'x86/common_x86.c', 'x86-64/x86-64.c', 'x86-64/xform4.S', ] -- 2.0.0.rc2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] mesa: Rely on USE_X86_64_ASM.
From: José Fonseca jfons...@vmware.com This fixes MinGW x64 builds. We don't use assembly on any of the Windows builds, to avoid divergence between MSVC and MinGW when testing. --- src/mesa/main/cpuinfo.c | 2 +- src/mesa/main/cpuinfo.h | 2 +- src/mesa/x86/common_x86.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mesa/main/cpuinfo.c b/src/mesa/main/cpuinfo.c index 73e295c..0755d6b 100644 --- a/src/mesa/main/cpuinfo.c +++ b/src/mesa/main/cpuinfo.c @@ -34,7 +34,7 @@ void _mesa_get_cpu_features(void) { -#if defined USE_X86_ASM || (defined __x86_64__ !defined _MSC_VER) +#if defined USE_X86_ASM || defined USE_X86_64_ASM _mesa_get_x86_features(); #endif } diff --git a/src/mesa/main/cpuinfo.h b/src/mesa/main/cpuinfo.h index fcd611e..57925e8 100644 --- a/src/mesa/main/cpuinfo.h +++ b/src/mesa/main/cpuinfo.h @@ -27,7 +27,7 @@ #define CPUINFO_H -#if defined USE_X86_ASM || (defined __x86_64__ !defined _MSC_VER) +#if defined USE_X86_ASM || defined USE_X86_64_ASM #include x86/common_x86_asm.h #endif diff --git a/src/mesa/x86/common_x86.c b/src/mesa/x86/common_x86.c index a55c48e..9c12339 100644 --- a/src/mesa/x86/common_x86.c +++ b/src/mesa/x86/common_x86.c @@ -47,7 +47,7 @@ #include sys/sysctl.h #include machine/cpu.h #endif -#if defined(__x86_64__) !defined(_MSC_VER) +#if defined(USE_X86_64_ASM) #include cpuid.h #endif @@ -336,7 +336,7 @@ _mesa_get_x86_features(void) } #endif -#elif defined(__x86_64__) !defined(_MSC_VER) +#elif defined(USE_X86_64_ASM) unsigned int uninitialized_var(eax), uninitialized_var(ebx), uninitialized_var(ecx), uninitialized_var(edx); @@ -347,7 +347,7 @@ _mesa_get_x86_features(void) if (ecx bit_SSE4_1) _mesa_x86_cpu_features |= X86_FEATURE_SSE4_1; -#endif /* USE_X86_ASM */ +#endif /* USE_X86_64_ASM */ (void) detection_debug; } -- 2.0.0.rc2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] gallivm: Support MCJIT on Windows.
From: José Fonseca jfons...@vmware.com It works fine, though it requires using ELF objects. With this change there is nothing preventing us to switch exclusively to MCJIT, everywhere. It's still off though. --- scons/llvm.py | 8 +++- src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 9 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/scons/llvm.py b/scons/llvm.py index cdfbe43..288a080 100644 --- a/scons/llvm.py +++ b/scons/llvm.py @@ -104,7 +104,7 @@ def generate(env): 'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser', 'LLVMX86CodeGen', 'LLVMX86Desc', 'LLVMSelectionDAG', 'LLVMAsmPrinter', 'LLVMMCParser', 'LLVMX86AsmPrinter', -'LLVMX86Utils', 'LLVMX86Info', 'LLVMJIT', +'LLVMX86Utils', 'LLVMX86Info', 'LLVMMCJIT', 'LLVMJIT', 'LLVMExecutionEngine', 'LLVMCodeGen', 'LLVMScalarOpts', 'LLVMInstCombine', 'LLVMTransformUtils', 'LLVMipa', 'LLVMAnalysis', 'LLVMTarget', 'LLVMMC', 'LLVMCore', @@ -116,7 +116,7 @@ def generate(env): 'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser', 'LLVMX86CodeGen', 'LLVMX86Desc', 'LLVMSelectionDAG', 'LLVMAsmPrinter', 'LLVMMCParser', 'LLVMX86AsmPrinter', -'LLVMX86Utils', 'LLVMX86Info', 'LLVMJIT', +'LLVMX86Utils', 'LLVMX86Info', 'LLVMMCJIT', 'LLVMJIT', 'LLVMExecutionEngine', 'LLVMCodeGen', 'LLVMScalarOpts', 'LLVMInstCombine', 'LLVMTransformUtils', 'LLVMipa', 'LLVMAnalysis', 'LLVMTarget', 'LLVMMC', 'LLVMCore', @@ -165,9 +165,7 @@ def generate(env): if '-fno-rtti' in cxxflags: env.Append(CXXFLAGS = ['-fno-rtti']) -components = ['engine', 'bitwriter', 'x86asmprinter'] - -components.append('mcjit') +components = ['engine', 'mcjit', 'bitwriter', 'x86asmprinter'] env.ParseConfig('llvm-config --libs ' + ' '.join(components)) env.ParseConfig('llvm-config --ldflags') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp index d03680f..4d63f9a 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp @@ -57,6 +57,7 @@ #include llvm/ADT/Triple.h #include llvm/ExecutionEngine/JITMemoryManager.h #include llvm/Support/CommandLine.h +#include llvm/Support/Host.h #include llvm/Support/PrettyStackTrace.h #include llvm/Support/TargetSelect.h @@ -452,6 +453,14 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, if (useMCJIT) { builder.setUseMCJIT(true); +#ifdef _WIN32 + /* + * MCJIT works on Windows, but currently only through ELF object format. + */ + std::string targetTriple = llvm::sys::getProcessTriple(); + targetTriple.append(-elf); + unwrap(M)-setTargetTriple(targetTriple); +#endif } llvm::SmallVectorstd::string, 1 MAttrs; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] gallivm: Disable workaround for PR12833 on LLVM 3.2+.
From: José Fonseca jfons...@vmware.com Fixed upstream. --- src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp index 4d63f9a..ec54776 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp @@ -484,11 +484,11 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, builder.setJITMemoryManager(MM); ExecutionEngine *JIT; -#if 0 +#if HAVE_LLVM = 0x0302 JIT = builder.create(); #else /* -* Workaround http://llvm.org/bugs/show_bug.cgi?id=12833 +* Workaround http://llvm.org/PR12833 */ StringRef MArch = ; StringRef MCPU = ; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 04/12] gallivm: Stop using module providers.
From: José Fonseca jfons...@vmware.com Nowadays LLVMModuleProviderRef is just an alias for LLVMModuleRef, so its use just causes unnecessary confusion. --- src/gallium/auxiliary/gallivm/lp_bld_init.c | 33 ++--- src/gallium/auxiliary/gallivm/lp_bld_init.h | 1 - 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c index 85faef5..6934a28 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c @@ -122,7 +122,7 @@ create_pass_manager(struct gallivm_state *gallivm) assert(!gallivm-passmgr); assert(gallivm-target); - gallivm-passmgr = LLVMCreateFunctionPassManager(gallivm-provider); + gallivm-passmgr = LLVMCreateFunctionPassManagerForModule(gallivm-module); if (!gallivm-passmgr) return FALSE; @@ -177,26 +177,16 @@ create_pass_manager(struct gallivm_state *gallivm) static void free_gallivm_state(struct gallivm_state *gallivm) { - /* This leads to crashes w/ some versions of LLVM */ - LLVMModuleRef mod; - char *error; - - if (gallivm-engine gallivm-provider) - LLVMRemoveModuleProvider(gallivm-engine, gallivm-provider, - mod, error); - if (gallivm-passmgr) { LLVMDisposePassManager(gallivm-passmgr); } -#if 0 - /* XXX this seems to crash with all versions of LLVM */ - if (gallivm-provider) - LLVMDisposeModuleProvider(gallivm-provider); -#endif - - /* This will already destroy any associated module */ - LLVMDisposeExecutionEngine(gallivm-engine); + if (gallivm-engine) { + /* This will already destroy any associated module */ + LLVMDisposeExecutionEngine(gallivm-engine); + } else if (gallivm-module) { + LLVMDisposeModule(gallivm-module); + } #if !USE_MCJIT /* Don't free the TargetData, it's owned by the exec engine */ @@ -219,7 +209,6 @@ free_gallivm_state(struct gallivm_state *gallivm) gallivm-engine = NULL; gallivm-target = NULL; gallivm-module = NULL; - gallivm-provider = NULL; gallivm-passmgr = NULL; gallivm-context = NULL; gallivm-builder = NULL; @@ -253,8 +242,6 @@ init_gallivm_engine(struct gallivm_state *gallivm) } } - LLVMAddModuleProvider(gallivm-engine, gallivm-provider);//new - #if !USE_MCJIT gallivm-target = LLVMGetExecutionEngineTargetData(gallivm-engine); if (!gallivm-target) @@ -311,7 +298,6 @@ init_gallivm_state(struct gallivm_state *gallivm) { assert(!gallivm-context); assert(!gallivm-module); - assert(!gallivm-provider); lp_build_init(); @@ -327,11 +313,6 @@ init_gallivm_state(struct gallivm_state *gallivm) if (!gallivm-module) goto fail; - gallivm-provider = - LLVMCreateModuleProviderForExistingModule(gallivm-module); - if (!gallivm-provider) - goto fail; - gallivm-builder = LLVMCreateBuilderInContext(gallivm-context); if (!gallivm-builder) goto fail; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.h b/src/gallium/auxiliary/gallivm/lp_bld_init.h index 7edea61..68f4006 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.h @@ -40,7 +40,6 @@ struct gallivm_state { LLVMModuleRef module; LLVMExecutionEngineRef engine; - LLVMModuleProviderRef provider; LLVMTargetDataRef target; LLVMPassManagerRef passmgr; LLVMContextRef context; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 10/12] llvmpipe: Delete unneeded LLVM stuff earlier.
From: José Fonseca jfons...@vmware.com Same as Frank's change to draw module but for llvmpipe module. --- src/gallium/drivers/llvmpipe/lp_state_fs.c| 13 ++--- src/gallium/drivers/llvmpipe/lp_state_setup.c | 13 ++--- src/gallium/drivers/llvmpipe/lp_test_arit.c | 4 ++-- src/gallium/drivers/llvmpipe/lp_test_blend.c | 4 ++-- src/gallium/drivers/llvmpipe/lp_test_conv.c | 4 ++-- src/gallium/drivers/llvmpipe/lp_test_format.c | 8 src/gallium/drivers/llvmpipe/lp_test_printf.c | 4 ++-- 7 files changed, 16 insertions(+), 34 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 5e28f0e..a26b981 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -2639,6 +2639,8 @@ generate_variant(struct llvmpipe_context *lp, variant-jit_function[RAST_WHOLE] = variant-jit_function[RAST_EDGE_TEST]; } + gallivm_free_ir(variant-gallivm); + return variant; } @@ -2763,8 +2765,6 @@ void llvmpipe_remove_shader_variant(struct llvmpipe_context *lp, struct lp_fragment_shader_variant *variant) { - unsigned i; - if (gallivm_debug GALLIVM_DEBUG_IR) { debug_printf(llvmpipe: del fs #%u var #%u v created #%u v cached #%u v total cached #%u\n, @@ -2775,15 +2775,6 @@ llvmpipe_remove_shader_variant(struct llvmpipe_context *lp, lp-nr_fs_variants); } - /* free all the variant's JIT'd functions */ - for (i = 0; i Elements(variant-function); i++) { - if (variant-function[i]) { - gallivm_free_function(variant-gallivm, - variant-function[i], - variant-jit_function[i]); - } - } - gallivm_destroy(variant-gallivm); /* remove from shader's list */ diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c b/src/gallium/drivers/llvmpipe/lp_state_setup.c index 1d79a4a..10ede56 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c @@ -800,6 +800,8 @@ generate_setup_variant(struct lp_setup_variant_key *key, if (!variant-jit_function) goto fail; + gallivm_free_ir(variant-gallivm); + /* * Update timing information: */ @@ -813,11 +815,6 @@ generate_setup_variant(struct lp_setup_variant_key *key, fail: if (variant) { - if (variant-function) { - gallivm_free_function(gallivm, - variant-function, - variant-jit_function); - } if (variant-gallivm) { gallivm_destroy(variant-gallivm); } @@ -893,12 +890,6 @@ remove_setup_variant(struct llvmpipe_context *lp, variant-no, lp-nr_setup_variants); } - if (variant-function) { - gallivm_free_function(variant-gallivm, -variant-function, -variant-jit_function); - } - if (variant-gallivm) { gallivm_destroy(variant-gallivm); } diff --git a/src/gallium/drivers/llvmpipe/lp_test_arit.c b/src/gallium/drivers/llvmpipe/lp_test_arit.c index 8996411..f8998c1 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_arit.c +++ b/src/gallium/drivers/llvmpipe/lp_test_arit.c @@ -362,6 +362,8 @@ test_unary(unsigned verbose, FILE *fp, const struct unary_test_t *test) test_func_jit = (unary_func_t) gallivm_jit_function(gallivm, test_func); + gallivm_free_ir(gallivm); + for (j = 0; j (test-num_values + length - 1) / length; j++) { int num_vals = ((j + 1) * length = test-num_values) ? length : test-num_values % length; @@ -401,8 +403,6 @@ test_unary(unsigned verbose, FILE *fp, const struct unary_test_t *test) } } - gallivm_free_function(gallivm, test_func, test_func_jit); - gallivm_destroy(gallivm); align_free(in); diff --git a/src/gallium/drivers/llvmpipe/lp_test_blend.c b/src/gallium/drivers/llvmpipe/lp_test_blend.c index 70f71fa..ec80593 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_blend.c +++ b/src/gallium/drivers/llvmpipe/lp_test_blend.c @@ -458,6 +458,8 @@ test_one(unsigned verbose, blend_test_ptr = (blend_test_ptr_t)gallivm_jit_function(gallivm, func); + gallivm_free_ir(gallivm); + success = TRUE; { @@ -576,8 +578,6 @@ test_one(unsigned verbose, if(fp) write_tsv_row(fp, blend, type, cycles_avg, success); - gallivm_free_function(gallivm, func, blend_test_ptr); - gallivm_destroy(gallivm); return success; diff --git a/src/gallium/drivers/llvmpipe/lp_test_conv.c b/src/gallium/drivers/llvmpipe/lp_test_conv.c index e2ec6e2..b7d0bfd 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_conv.c +++ b/src/gallium/drivers/llvmpipe/lp_test_conv.c @@ -219,6 +219,8 @@ test_one(unsigned verbose, conv_test_ptr =
[Mesa-dev] [PATCH 11/12] gallivm: Remove gallivm_free_function.
From: José Fonseca jfons...@vmware.com Unused. Deprecated by gallivm_free_ir(). --- src/gallium/auxiliary/gallivm/lp_bld_init.c | 18 -- src/gallium/auxiliary/gallivm/lp_bld_init.h | 5 - 2 files changed, 23 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c index 6feec70..36d1bc5 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c @@ -610,21 +610,3 @@ gallivm_jit_function(struct gallivm_state *gallivm, return jit_func; } - - -/** - * Free the function (and its machine code). - */ -void -gallivm_free_function(struct gallivm_state *gallivm, - LLVMValueRef func, - const void *code) -{ -#if !USE_MCJIT - if (code) { - LLVMFreeMachineCodeForFunction(gallivm-engine, func); - } - - LLVMDeleteFunction(func); -#endif -} diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.h b/src/gallium/auxiliary/gallivm/lp_bld_init.h index b11e986..464bb83 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.h @@ -74,11 +74,6 @@ gallivm_jit_function(struct gallivm_state *gallivm, LLVMValueRef func); void -gallivm_free_function(struct gallivm_state *gallivm, - LLVMValueRef func, - const void * code); - -void lp_set_load_alignment(LLVMValueRef Inst, unsigned Align); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 08/12] gallivm: Separate freeing LLVM intermediate data from freeing final code.
From: Frank Henigman fjhenig...@google.com Split free_gallivm_state() into two steps. First step is gallivm_free_ir() which cleans up the LLVM scaffolding used to generate code while preserving the code itself. Second step is gallivm_free_code() to free the memory occupied by the code. v2: s/gallivm_teardown/gallivm_free_ir/ (Jose) Signed-off-by: José Fonseca jfons...@vmware.com --- src/gallium/auxiliary/gallivm/lp_bld_init.c | 27 --- src/gallium/auxiliary/gallivm/lp_bld_init.h | 2 ++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c index 982d1db..6feec70 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c @@ -182,10 +182,11 @@ create_pass_manager(struct gallivm_state *gallivm) /** - * Free gallivm object's LLVM allocations, but not the gallivm object itself. + * Free gallivm object's LLVM allocations, but not any generated code + * nor the gallivm object itself. */ -static void -free_gallivm_state(struct gallivm_state *gallivm) +void +gallivm_free_ir(struct gallivm_state *gallivm) { if (gallivm-passmgr) { LLVMDisposePassManager(gallivm-passmgr); @@ -212,14 +213,24 @@ free_gallivm_state(struct gallivm_state *gallivm) if (!USE_GLOBAL_CONTEXT gallivm-context) LLVMContextDispose(gallivm-context); - lp_free_generated_code(gallivm-code); - gallivm-engine = NULL; gallivm-target = NULL; gallivm-module = NULL; gallivm-passmgr = NULL; gallivm-context = NULL; gallivm-builder = NULL; +} + + +/** + * Free LLVM-generated code. Should be done AFTER gallivm_free_ir(). + */ +static void +gallivm_free_code(struct gallivm_state *gallivm) +{ + assert(!gallivm-module); + assert(!gallivm-engine); + lp_free_generated_code(gallivm-code); gallivm-code = NULL; } @@ -366,7 +377,8 @@ init_gallivm_state(struct gallivm_state *gallivm) return TRUE; fail: - free_gallivm_state(gallivm); + gallivm_free_ir(gallivm); + gallivm_free_code(gallivm); return FALSE; } @@ -497,7 +509,8 @@ gallivm_create(void) void gallivm_destroy(struct gallivm_state *gallivm) { - free_gallivm_state(gallivm); + gallivm_free_ir(gallivm); + gallivm_free_code(gallivm); FREE(gallivm); } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.h b/src/gallium/auxiliary/gallivm/lp_bld_init.h index e405b8a..b11e986 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.h @@ -59,6 +59,8 @@ gallivm_create(void); void gallivm_destroy(struct gallivm_state *gallivm); +void +gallivm_free_ir(struct gallivm_state *gallivm); void gallivm_verify_function(struct gallivm_state *gallivm, -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 06/12] gallivm: Run passes per module, not per function.
From: José Fonseca jfons...@vmware.com This is how it is meant to be done nowadays. --- src/gallium/auxiliary/gallivm/lp_bld_init.c | 47 - 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c index 2d854e9..a3549c1 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c @@ -499,32 +499,6 @@ gallivm_destroy(struct gallivm_state *gallivm) /** - * Validate and optimze a function. - */ -static void -gallivm_optimize_function(struct gallivm_state *gallivm, - LLVMValueRef func) -{ - if (0) { - debug_printf(optimizing %s...\n, LLVMGetValueName(func)); - } - - assert(gallivm-passmgr); - - /* Apply optimizations to LLVM IR */ - LLVMRunFunctionPassManager(gallivm-passmgr, func); - - if (0) { - if (gallivm_debug GALLIVM_DEBUG_IR) { - /* Print the LLVM IR to stderr */ - lp_debug_dump_value(func); - debug_printf(\n); - } - } -} - - -/** * Validate a function. */ void @@ -540,8 +514,6 @@ gallivm_verify_function(struct gallivm_state *gallivm, } #endif - gallivm_optimize_function(gallivm, func); - if (gallivm_debug GALLIVM_DEBUG_IR) { /* Print the LLVM IR to stderr */ lp_debug_dump_value(func); @@ -553,8 +525,27 @@ gallivm_verify_function(struct gallivm_state *gallivm, void gallivm_compile_module(struct gallivm_state *gallivm) { + LLVMValueRef func; + assert(!gallivm-compiled); + if (gallivm-builder) { + LLVMDisposeBuilder(gallivm-builder); + gallivm-builder = NULL; + } + + /* Run optimization passes */ + LLVMInitializeFunctionPassManager(gallivm-passmgr); + func = LLVMGetFirstFunction(gallivm-module); + while (func) { + if (0) { +debug_printf(optimizing %s...\n, LLVMGetValueName(func)); + } + LLVMRunFunctionPassManager(gallivm-passmgr, func); + func = LLVMGetNextFunction(func); + } + LLVMFinalizeFunctionPassManager(gallivm-passmgr); + /* Dump byte code to a file */ if (0) { LLVMWriteBitcodeToFile(gallivm-module, llvmpipe.bc); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 12/12] gallivm: Remove lp_func_delete_body.
From: José Fonseca jfons...@vmware.com Not necessary, now that we will free the whole module (hence all function bodies) immediately after compiling. --- src/gallium/auxiliary/gallivm/lp_bld_init.c | 3 --- src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 8 src/gallium/auxiliary/gallivm/lp_bld_misc.h | 4 3 files changed, 15 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c index 36d1bc5..a39c1a3 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c @@ -605,8 +605,5 @@ gallivm_jit_function(struct gallivm_state *gallivm, lp_profile(func, code); #endif - /* Free the function body to save memory */ - lp_func_delete_body(func); - return jit_func; } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp index 8825e54..d03680f 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp @@ -117,14 +117,6 @@ lp_set_target_options(void) } -extern C void -lp_func_delete_body(LLVMValueRef FF) -{ - llvm::Function *func = llvm::unwrapllvm::Function(FF); - func-deleteBody(); -} - - extern C LLVMValueRef lp_build_load_volatile(LLVMBuilderRef B, LLVMValueRef PointerVal, diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.h b/src/gallium/auxiliary/gallivm/lp_bld_misc.h index 847894b..64d2a04 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.h @@ -46,10 +46,6 @@ extern void lp_set_target_options(void); -extern void -lp_func_delete_body(LLVMValueRef func); - - extern LLVMValueRef lp_build_load_volatile(LLVMBuilderRef B, LLVMValueRef PointerVal, const char *Name); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 07/12] gallivm: One code memory pool with deferred free.
From: Frank Henigman fjhenig...@google.com Provide a JITMemoryManager derivative which puts all generated code into one memory pool instead of creating a new one each time code is generated. This saves significant memory per shader as the pool size is 512K and a small shader occupies just several K. This memory manager also defers freeing generated code until you tell it to do so, making it possible to destroy the LLVM engine while keeping the code, thus enabling future memory savings. v2: Fix compilation errors with LLVM 3.4 (Jose) Signed-off-by: José Fonseca jfons...@vmware.com --- src/gallium/auxiliary/gallivm/lp_bld_init.c | 4 + src/gallium/auxiliary/gallivm/lp_bld_init.h | 1 + src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 273 +- src/gallium/auxiliary/gallivm/lp_bld_misc.h | 6 + 4 files changed, 283 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c index a3549c1..982d1db 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c @@ -212,12 +212,15 @@ free_gallivm_state(struct gallivm_state *gallivm) if (!USE_GLOBAL_CONTEXT gallivm-context) LLVMContextDispose(gallivm-context); + lp_free_generated_code(gallivm-code); + gallivm-engine = NULL; gallivm-target = NULL; gallivm-module = NULL; gallivm-passmgr = NULL; gallivm-context = NULL; gallivm-builder = NULL; + gallivm-code = NULL; } @@ -237,6 +240,7 @@ init_gallivm_engine(struct gallivm_state *gallivm) } ret = lp_build_create_jit_compiler_for_module(gallivm-engine, +gallivm-code, gallivm-module, (unsigned) optlevel, USE_MCJIT, diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.h b/src/gallium/auxiliary/gallivm/lp_bld_init.h index 68f4006..e405b8a 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.h @@ -44,6 +44,7 @@ struct gallivm_state LLVMPassManagerRef passmgr; LLVMContextRef context; LLVMBuilderRef builder; + struct lp_generated_code *code; unsigned compiled; }; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp index fe45940..8825e54 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp @@ -151,6 +151,261 @@ lp_set_store_alignment(LLVMValueRef Inst, } +/* + * Delegating is tedious but the default manager class is hidden in an + * anonymous namespace in LLVM, so we cannot just derive from it to change + * its behavior. + */ +class DelegatingJITMemoryManager : public llvm::JITMemoryManager { + + protected: + virtual llvm::JITMemoryManager *mgr() const = 0; + + public: + /* + * From JITMemoryManager + */ + virtual void setMemoryWritable() { + mgr()-setMemoryWritable(); + } + virtual void setMemoryExecutable() { + mgr()-setMemoryExecutable(); + } + virtual void setPoisonMemory(bool poison) { + mgr()-setPoisonMemory(poison); + } + virtual void AllocateGOT() { + mgr()-AllocateGOT(); + /* + * isManagingGOT() is not virtual in base class so we can't delegate. + * Instead we mirror the value of HasGOT in our instance. + */ + HasGOT = mgr()-isManagingGOT(); + } + virtual uint8_t *getGOTBase() const { + return mgr()-getGOTBase(); + } + virtual uint8_t *startFunctionBody(const llvm::Function *F, + uintptr_t ActualSize) { + return mgr()-startFunctionBody(F, ActualSize); + } + virtual uint8_t *allocateStub(const llvm::GlobalValue *F, +unsigned StubSize, +unsigned Alignment) { + return mgr()-allocateStub(F, StubSize, Alignment); + } + virtual void endFunctionBody(const llvm::Function *F, + uint8_t *FunctionStart, + uint8_t *FunctionEnd) { + mgr()-endFunctionBody(F, FunctionStart, FunctionEnd); + } + virtual uint8_t *allocateSpace(intptr_t Size, unsigned Alignment) { + return mgr()-allocateSpace(Size, Alignment); + } + virtual uint8_t *allocateGlobal(uintptr_t Size, unsigned Alignment) { + return mgr()-allocateGlobal(Size, Alignment); + } + virtual void deallocateFunctionBody(void *Body) { + mgr()-deallocateFunctionBody(Body); + } +#if HAVE_LLVM 0x0304 + virtual uint8_t *startExceptionTable(const llvm::Function *F, + uintptr_t ActualSize) {
[Mesa-dev] [PATCH 02/12] configure: Require LLVM 3.1.
From: José Fonseca jfons...@vmware.com --- configure.ac | 6 ++ 1 file changed, 6 insertions(+) diff --git a/configure.ac b/configure.ac index 99a761a..b4a1606 100644 --- a/configure.ac +++ b/configure.ac @@ -1624,6 +1624,12 @@ if test x$enable_gallium_llvm = xyes; then LLVM_VERSION_INT=`echo $LLVM_VERSION | sed -e 's/\([[0-9]]\)\.\([[0-9]]\)/\10\2/g'` fi +LLVM_REQUIRED_VERSION_MAJOR=3 +LLVM_REQUIRED_VERSION_MINOR=1 +if test $LLVM_VERSION_INT -lt ${LLVM_REQUIRED_VERSION_MAJOR}0${LLVM_REQUIRED_VERSION_MINOR}; then +AC_MSG_ERROR([LLVM $LLVM_REQUIRED_VERSION_MAJOR.$LLVM_REQUIRED_VERSION_MINOR or newer is required]) +fi + LLVM_COMPONENTS=engine bitwriter if $LLVM_CONFIG --components | grep -qw 'mcjit'; then LLVM_COMPONENTS=${LLVM_COMPONENTS} mcjit -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 03/12] gallivm, draw, llvmpipe: Remove support for versions of LLVM prior to 3.1.
From: José Fonseca jfons...@vmware.com Older versions haven't been tested probably don't work anyway. But more importantly, code supporting it is hindering further work. --- src/gallium/auxiliary/draw/draw_llvm.c| 48 -- src/gallium/auxiliary/gallivm/lp_bld.h| 3 + src/gallium/auxiliary/gallivm/lp_bld_arit.c | 2 - src/gallium/auxiliary/gallivm/lp_bld_conv.c | 4 +- src/gallium/auxiliary/gallivm/lp_bld_debug.cpp| 75 + src/gallium/auxiliary/gallivm/lp_bld_init.c | 52 +- src/gallium/auxiliary/gallivm/lp_bld_logic.c | 189 -- src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 96 --- src/gallium/auxiliary/gallivm/lp_bld_pack.c | 8 - src/gallium/auxiliary/gallivm/lp_bld_sample.c | 9 -- src/gallium/auxiliary/gallivm/lp_bld_sample_aos.c | 10 -- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 18 +-- src/gallium/auxiliary/gallivm/lp_bld_swizzle.c| 18 +-- src/gallium/auxiliary/gallivm/lp_bld_type.c | 8 - src/gallium/drivers/llvmpipe/lp_jit.c | 28 15 files changed, 20 insertions(+), 548 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index b9f8bb9..6a3e5b2 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -97,15 +97,6 @@ create_jit_dvbuffer_type(struct gallivm_state *gallivm, dvbuffer_type = LLVMStructTypeInContext(gallivm-context, elem_types, Elements(elem_types), 0); -#if HAVE_LLVM 0x0300 - LLVMAddTypeName(gallivm-module, struct_name, dvbuffer_type); - - /* Make sure the target's struct layout cache doesn't return -* stale/invalid data. -*/ - LLVMInvalidateStructLayout(gallivm-target, dvbuffer_type); -#endif - LP_CHECK_MEMBER_OFFSET(struct draw_vertex_buffer, map, target, dvbuffer_type, DRAW_JIT_DVBUFFER_MAP); @@ -142,15 +133,6 @@ create_jit_texture_type(struct gallivm_state *gallivm, const char *struct_name) texture_type = LLVMStructTypeInContext(gallivm-context, elem_types, Elements(elem_types), 0); -#if HAVE_LLVM 0x0300 - LLVMAddTypeName(gallivm-module, struct_name, texture_type); - - /* Make sure the target's struct layout cache doesn't return -* stale/invalid data. -*/ - LLVMInvalidateStructLayout(gallivm-target, texture_type); -#endif - LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, width, target, texture_type, DRAW_JIT_TEXTURE_WIDTH); @@ -204,15 +186,6 @@ create_jit_sampler_type(struct gallivm_state *gallivm, const char *struct_name) sampler_type = LLVMStructTypeInContext(gallivm-context, elem_types, Elements(elem_types), 0); -#if HAVE_LLVM 0x0300 - LLVMAddTypeName(gallivm-module, struct_name, sampler_type); - - /* Make sure the target's struct layout cache doesn't return -* stale/invalid data. -*/ - LLVMInvalidateStructLayout(gallivm-target, sampler_type); -#endif - LP_CHECK_MEMBER_OFFSET(struct draw_jit_sampler, min_lod, target, sampler_type, DRAW_JIT_SAMPLER_MIN_LOD); @@ -259,12 +232,6 @@ create_jit_context_type(struct gallivm_state *gallivm, PIPE_MAX_SAMPLERS); /* samplers */ context_type = LLVMStructTypeInContext(gallivm-context, elem_types, Elements(elem_types), 0); -#if HAVE_LLVM 0x0300 - LLVMAddTypeName(gallivm-module, struct_name, context_type); - - LLVMInvalidateStructLayout(gallivm-target, context_type); -#endif - LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, vs_constants, target, context_type, DRAW_JIT_CTX_CONSTANTS); LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, num_vs_constants, @@ -322,11 +289,6 @@ create_gs_jit_context_type(struct gallivm_state *gallivm, context_type = LLVMStructTypeInContext(gallivm-context, elem_types, Elements(elem_types), 0); -#if HAVE_LLVM 0x0300 - LLVMAddTypeName(gallivm-module, struct_name, context_type); - - LLVMInvalidateStructLayout(gallivm-target, context_type); -#endif LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, constants, target, context_type, DRAW_GS_JIT_CTX_CONSTANTS); @@ -390,11 +352,6 @@ create_jit_vertex_buffer_type(struct gallivm_state *gallivm, vb_type = LLVMStructTypeInContext(gallivm-context, elem_types, Elements(elem_types), 0); -#if HAVE_LLVM 0x0300 - LLVMAddTypeName(gallivm-module, struct_name, vb_type); - - LLVMInvalidateStructLayout(gallivm-target, vb_type); -#endif LP_CHECK_MEMBER_OFFSET(struct pipe_vertex_buffer, stride,
[Mesa-dev] [PATCH 01/12] scons: Require LLVM 3.1
From: José Fonseca jfons...@vmware.com Support for prior versions will be removed in the following change. --- scons/llvm.py | 57 + 1 file changed, 13 insertions(+), 44 deletions(-) diff --git a/scons/llvm.py b/scons/llvm.py index 134a072..cdfbe43 100644 --- a/scons/llvm.py +++ b/scons/llvm.py @@ -37,6 +37,9 @@ import SCons.Errors import SCons.Util +required_llvm_version = '3.1' + + def generate(env): env['llvm'] = False @@ -84,6 +87,9 @@ def generate(env): if llvm_version is None: print 'scons: could not determine the LLVM version from %s' % llvm_config return +if llvm_version distutils.version.LooseVersion(required_llvm_version): +print 'scons: LLVM version %s found, but %s is required' % (llvm_version, required_llvm_version) +return env.Prepend(CPPPATH = [os.path.join(llvm_dir, 'include')]) env.AppendUnique(CPPDEFINES = [ @@ -104,8 +110,8 @@ def generate(env): 'LLVMAnalysis', 'LLVMTarget', 'LLVMMC', 'LLVMCore', 'LLVMSupport', 'LLVMRuntimeDyld', 'LLVMObject' ]) -elif llvm_version = distutils.version.LooseVersion('3.0'): -# 3.0 +else: +# 3.1 env.Prepend(LIBS = [ 'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser', 'LLVMX86CodeGen', 'LLVMX86Desc', 'LLVMSelectionDAG', @@ -116,46 +122,6 @@ def generate(env): 'LLVMAnalysis', 'LLVMTarget', 'LLVMMC', 'LLVMCore', 'LLVMSupport' ]) -elif llvm_version = distutils.version.LooseVersion('2.9'): -# 2.9 -env.Prepend(LIBS = [ -'LLVMObject', 'LLVMMCJIT', 'LLVMMCDisassembler', -'LLVMLinker', 'LLVMipo', 'LLVMInterpreter', -'LLVMInstrumentation', 'LLVMJIT', 'LLVMExecutionEngine', -'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser', -'LLVMMCParser', 'LLVMX86AsmPrinter', 'LLVMX86CodeGen', -'LLVMSelectionDAG', 'LLVMX86Utils', 'LLVMX86Info', 'LLVMAsmPrinter', -'LLVMCodeGen', 'LLVMScalarOpts', 'LLVMInstCombine', -'LLVMTransformUtils', 'LLVMipa', 'LLVMAsmParser', -'LLVMArchive', 'LLVMBitReader', 'LLVMAnalysis', 'LLVMTarget', -'LLVMCore', 'LLVMMC', 'LLVMSupport', -]) -elif llvm_version = distutils.version.LooseVersion('2.7'): -# 2.7 -env.Prepend(LIBS = [ -'LLVMLinker', 'LLVMipo', 'LLVMInterpreter', -'LLVMInstrumentation', 'LLVMJIT', 'LLVMExecutionEngine', -'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser', -'LLVMMCParser', 'LLVMX86AsmPrinter', 'LLVMX86CodeGen', -'LLVMSelectionDAG', 'LLVMX86Info', 'LLVMAsmPrinter', -'LLVMCodeGen', 'LLVMScalarOpts', 'LLVMInstCombine', -'LLVMTransformUtils', 'LLVMipa', 'LLVMAsmParser', -'LLVMArchive', 'LLVMBitReader', 'LLVMAnalysis', 'LLVMTarget', -'LLVMMC', 'LLVMCore', 'LLVMSupport', 'LLVMSystem', -]) -else: -# 2.6 -env.Prepend(LIBS = [ -'LLVMX86AsmParser', 'LLVMX86AsmPrinter', 'LLVMX86CodeGen', -'LLVMX86Info', 'LLVMLinker', 'LLVMipo', 'LLVMInterpreter', -'LLVMInstrumentation', 'LLVMJIT', 'LLVMExecutionEngine', -'LLVMDebugger', 'LLVMBitWriter', 'LLVMAsmParser', -'LLVMArchive', 'LLVMBitReader', 'LLVMSelectionDAG', -'LLVMAsmPrinter', 'LLVMCodeGen', 'LLVMScalarOpts', -'LLVMTransformUtils', 'LLVMipa', 'LLVMAnalysis', -'LLVMTarget', 'LLVMMC', 'LLVMCore', 'LLVMSupport', -'LLVMSystem', -]) env.Append(LIBS = [ 'imagehlp', 'psapi', @@ -180,6 +146,10 @@ def generate(env): llvm_version = env.backtick('llvm-config --version').rstrip() llvm_version = distutils.version.LooseVersion(llvm_version) +if llvm_version distutils.version.LooseVersion(required_llvm_version): +print 'scons: LLVM version %s found, but %s is required' % (llvm_version, required_llvm_version) +return + try: # Treat --cppflags specially to prevent NDEBUG from disabling # assertion failures in debug builds. @@ -197,8 +167,7 @@ def generate(env): components = ['engine', 'bitwriter', 'x86asmprinter'] -if llvm_version = distutils.version.LooseVersion('3.1'): -components.append('mcjit') +components.append('mcjit') env.ParseConfig('llvm-config --libs ' + ' '.join(components)) env.ParseConfig('llvm-config --ldflags') -- 1.9.1
[Mesa-dev] [PATCH 09/12] draw: Delete unneeded LLVM stuff earlier.
From: Frank Henigman fjhenig...@google.com Free up unneeded LLVM stuff immediately after generating vertex shader code. Saves about 500K per shader. v2: Don't bother calling gallivm_free_function (Jose) Signed-off-by: José Fonseca jfons...@vmware.com --- src/gallium/auxiliary/draw/draw_llvm.c | 19 --- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 6a3e5b2..7ecc340 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -555,6 +555,8 @@ draw_llvm_create_variant(struct draw_llvm *llvm, variant-jit_func_elts = (draw_jit_vert_func_elts) gallivm_jit_function(variant-gallivm, variant-function_elts); + gallivm_free_ir(variant-gallivm); + variant-shader = shader; variant-list_item_global.base = variant; variant-list_item_local.base = variant; @@ -1960,16 +1962,6 @@ draw_llvm_destroy_variant(struct draw_llvm_variant *variant) { struct draw_llvm *llvm = variant-llvm; - if (variant-function_elts) { - gallivm_free_function(variant-gallivm, -variant-function_elts, variant-jit_func_elts); - } - - if (variant-function) { - gallivm_free_function(variant-gallivm, -variant-function, variant-jit_func); - } - gallivm_destroy(variant-gallivm); remove_from_list(variant-list_item_local); @@ -2206,6 +2198,8 @@ draw_gs_llvm_create_variant(struct draw_llvm *llvm, variant-jit_func = (draw_gs_jit_func) gallivm_jit_function(variant-gallivm, variant-function); + gallivm_free_ir(variant-gallivm); + variant-list_item_global.base = variant; variant-list_item_local.base = variant; /*variant-no = */shader-variants_created++; @@ -2219,11 +2213,6 @@ draw_gs_llvm_destroy_variant(struct draw_gs_llvm_variant *variant) { struct draw_llvm *llvm = variant-llvm; - if (variant-function) { - gallivm_free_function(variant-gallivm, -variant-function, variant-jit_func); - } - gallivm_destroy(variant-gallivm); remove_from_list(variant-list_item_local); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 05/12] gallivm: Use LLVM global context.
From: José Fonseca jfons...@vmware.com I saw that LLVM internally uses its global context for some things, even when we use our own. Given ours is also global, might as well use LLVM's. However, sepearate contexts can still be enabled with a simple source code modification, for when the need/benefit arises. --- src/gallium/auxiliary/gallivm/lp_bld_init.c | 40 - 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c index 6934a28..2d854e9 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c @@ -68,6 +68,16 @@ void LLVMLinkInMCJIT(); #endif +/* + * LLVM has several global caches which pointing/derived from objects + * owned by the context, so if we freeing contexts causes + * memory leaks and false cache hits when these objects are destroyed. + * + * TODO: For thread safety on multi-threaded OpenGL we should use one LLVM + * context per thread, and put them in a pool when threads are destroyed. + */ +#define USE_GLOBAL_CONTEXT 1 + #ifdef DEBUG unsigned gallivm_debug = 0; @@ -196,16 +206,12 @@ free_gallivm_state(struct gallivm_state *gallivm) } #endif - /* Never free the LLVM context. -*/ -#if 0 - if (gallivm-context) - LLVMContextDispose(gallivm-context); -#endif - if (gallivm-builder) LLVMDisposeBuilder(gallivm-builder); + if (!USE_GLOBAL_CONTEXT gallivm-context) + LLVMContextDispose(gallivm-context); + gallivm-engine = NULL; gallivm-target = NULL; gallivm-module = NULL; @@ -277,19 +283,6 @@ fail: /** - * Singleton - * - * We must never free LLVM contexts, because LLVM has several global caches - * which pointing/derived from objects owned by the context, causing false - * memory leaks and false cache hits when these objects are destroyed. - * - * TODO: For thread safety on multi-threaded OpenGL we should use one LLVM - * context per thread, and put them in a pool when threads are destroyed. - */ -static LLVMContextRef gallivm_context = NULL; - - -/** * Allocate gallivm LLVM objects. * \return TRUE for success, FALSE for failure */ @@ -301,10 +294,11 @@ init_gallivm_state(struct gallivm_state *gallivm) lp_build_init(); - if (!gallivm_context) { - gallivm_context = LLVMContextCreate(); + if (USE_GLOBAL_CONTEXT) { + gallivm-context = LLVMGetGlobalContext(); + } else { + gallivm-context = LLVMContextCreate(); } - gallivm-context = gallivm_context; if (!gallivm-context) goto fail; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] ralloc: Omit detailed license information about talloc.
From: José Fonseca jfons...@vmware.com That information misleads source code auditing tools to think that ralloc itself is released under LGPL v3. Instead, simply state talloc is not licensed under a permissive license. --- src/glsl/ralloc.h | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/glsl/ralloc.h b/src/glsl/ralloc.h index 4581a7a..70f7d9c 100644 --- a/src/glsl/ralloc.h +++ b/src/glsl/ralloc.h @@ -38,10 +38,9 @@ * Tridgell's talloc, but ralloc is an independent implementation * released under the MIT license and tuned for Mesa. * - * The talloc implementation is available under the GNU Lesser - * General Public License (GNU LGPL), version 3 or later. It is - * more sophisticated than ralloc in that it includes reference - * counting and debugging features. See: http://talloc.samba.org/ + * The talloc implementation is not available under a permissive + * license. It is more sophisticated than ralloc in that it includes + * reference counting and debugging features. See: http://talloc.samba.org/ */ #ifndef RALLOC_H -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] st/wgl: Honour request of 3.1 contexts through core profile where available.
From: José Fonseca jfons...@vmware.com Port 5f493eed69f6fb11239c04119d602f1c23a68cbd from GLX. --- src/gallium/state_trackers/wgl/stw_context.c | 17 +++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/wgl/stw_context.c b/src/gallium/state_trackers/wgl/stw_context.c index 3a93091..43186fa 100644 --- a/src/gallium/state_trackers/wgl/stw_context.c +++ b/src/gallium/state_trackers/wgl/stw_context.c @@ -205,10 +205,23 @@ stw_create_context_attribs( * * The default value for WGL_CONTEXT_PROFILE_MASK_ARB is * WGL_CONTEXT_CORE_PROFILE_BIT_ARB. +* +* The spec also says: +* +* If version 3.1 is requested, the context returned may implement +* any of the following versions: +* +* * Version 3.1. The GL_ARB_compatibility extension may or may not +* be implemented, as determined by the implementation. +* * The core profile of version 3.2 or greater. +* +* and because Mesa doesn't support GL_ARB_compatibility, the only chance to +* honour a 3.1 context is through core profile. */ attribs.profile = ST_PROFILE_DEFAULT; - if ((majorVersion 3 || (majorVersion == 3 minorVersion = 2)) -((profileMask WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) == 0)) + if (((majorVersion 3 || (majorVersion == 3 minorVersion = 2)) + ((profileMask WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) == 0)) || + (majorVersion == 3 minorVersion == 1)) attribs.profile = ST_PROFILE_OPENGL_CORE; ctx-st = stw_dev-stapi-create_context(stw_dev-stapi, -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] st/wgl: Advertise WGL_ARB_create_context(_profile).
From: José Fonseca jfons...@vmware.com We added wglCreateContextAttribsARB but not the extension strings. This allows creation of GL 3.x contents. --- src/gallium/state_trackers/wgl/stw_ext_extensionsstring.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/state_trackers/wgl/stw_ext_extensionsstring.c b/src/gallium/state_trackers/wgl/stw_ext_extensionsstring.c index 566f78c..06a152b 100644 --- a/src/gallium/state_trackers/wgl/stw_ext_extensionsstring.c +++ b/src/gallium/state_trackers/wgl/stw_ext_extensionsstring.c @@ -35,6 +35,8 @@ static const char *stw_extension_string = + WGL_ARB_create_context + WGL_ARB_create_context_profile WGL_ARB_extensions_string WGL_ARB_multisample WGL_ARB_pbuffer -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/9] st/vega: Prevent signed/unsigned comparisons.
From: José Fonseca jfons...@vmware.com --- src/gallium/state_trackers/vega/vg_translate.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gallium/state_trackers/vega/vg_translate.c b/src/gallium/state_trackers/vega/vg_translate.c index 7b3df27..4aad899 100644 --- a/src/gallium/state_trackers/vega/vg_translate.c +++ b/src/gallium/state_trackers/vega/vg_translate.c @@ -34,7 +34,7 @@ void _vega_pack_rgba_span_float(struct vg_context *ctx, VGImageFormat dstFormat, void *dstAddr) { - VGint i; + VGuint i; switch (dstFormat) { case VG_sRGBX_: { @@ -458,7 +458,7 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx, VGImageFormat dataFormat, VGfloat rgba[][4]) { - VGint i; + VGuint i; union util_color uc; switch (dataFormat) { @@ -681,7 +681,7 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx, src += offset; for (i = 0; i n; i += 8) { VGfloat clr[4]; - VGint j; + VGuint j; for (j = 0; j 8 j n ; ++j) { VGint shift = j; clr[0] = (((*src) (1shift)) shift); @@ -705,7 +705,7 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx, src += offset; for (i = 0; i n; i += 8) { VGfloat clr[4]; - VGint j; + VGuint j; for (j = 0; j 8 j n ; ++j) { VGint shift = j; clr[0] = 0.f; @@ -728,7 +728,7 @@ void _vega_unpack_float_span_rgba(struct vg_context *ctx, src += offset/2; for (i = 0; i n; i += 2) { VGfloat clr[4]; - VGint j; + VGuint j; for (j = 0; j n j 2; ++j) { VGint bitter, shift; if (j == 0) { -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/9] scons: Adjust the warnings for VS.
From: José Fonseca jfons...@vmware.com Silence insignificant warnings so significant warnings have a chance to stand out. The only abundant warning that's not silenced here is C4018: signed/unsigned mismatch, as it could hide security issues, so it's better to actually fix the code. --- scons/gallium.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scons/gallium.py b/scons/gallium.py index d13d0e6..ca317b0 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -455,7 +455,9 @@ def generate(env): ] ccflags += [ '/W3', # warning level -#'/Wp64', # enable 64 bit porting warnings +'/wd4244', # conversion from 'type1' to 'type2', possible loss of data +'/wd4305', # truncation from 'type1' to 'type2' +'/wd4800', # forcing value to bool 'true' or 'false' (performance warning) '/wd4996', # disable deprecated POSIX name warnings ] if env['machine'] == 'x86': -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/9] util/u_debug_flush: Use util_snprintf.
From: José Fonseca jfons...@vmware.com --- src/gallium/auxiliary/util/u_debug_flush.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/util/u_debug_flush.c b/src/gallium/auxiliary/util/u_debug_flush.c index 9cf70db..fdb248c 100644 --- a/src/gallium/auxiliary/util/u_debug_flush.c +++ b/src/gallium/auxiliary/util/u_debug_flush.c @@ -46,6 +46,7 @@ #include util/u_hash_table.h #include util/u_double_list.h #include util/u_inlines.h +#include util/u_string.h #include os/os_thread.h #include stdio.h @@ -320,8 +321,8 @@ debug_flush_might_flush_cb(void *key, void *value, void *data) const char *reason = (const char *) data; char message[80]; - snprintf(message, sizeof(message), -%s referenced mapped buffer detected., reason); + util_snprintf(message, sizeof(message), + %s referenced mapped buffer detected., reason); pipe_mutex_lock(fbuf-mutex); if (fbuf-mapped_sync) { -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 5/9] scons: Don't restrict MSVC_VERSION values.
From: José Fonseca jfons...@vmware.com Saves the trouble of continuously needing to update. --- common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.py b/common.py index d6e6215..1d2d586 100644 --- a/common.py +++ b/common.py @@ -101,4 +101,4 @@ def AddOptions(opts): opts.Add(BoolOption('quiet', 'DEPRECATED: profile build', 'yes')) opts.Add(BoolOption('texture_float', 'enable floating-point textures and renderbuffers', 'no')) if host_platform == 'windows': - opts.Add(EnumOption('MSVC_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0', '10.0', '11.0', '12.0'))) + opts.Add('MSVC_VERSION', 'Microsoft Visual C/C++ version') -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 7/9] egl: Don't attempt to redefine stdint.h types with VS 2013.
From: José Fonseca jfons...@vmware.com Just include stdint.h. --- src/egl/main/eglcompiler.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/egl/main/eglcompiler.h b/src/egl/main/eglcompiler.h index 53dab54..5ea83d6 100644 --- a/src/egl/main/eglcompiler.h +++ b/src/egl/main/eglcompiler.h @@ -37,7 +37,8 @@ /** * Get standard integer types */ -#if (defined(__STDC_VERSION__) __STDC_VERSION__ = 199901L) +#if (defined(__STDC_VERSION__) __STDC_VERSION__ = 199901L) || \ +(defined(_MSC_VER) _MSC_VER = 1600) # include stdint.h #elif defined(_MSC_VER) typedef __int8 int8_t; -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 6/9] scons: Don't use bundled C99 headers for VS 2013.
From: José Fonseca jfons...@vmware.com Use the ones provided by the compiler instead. NOTE: External trees should be updated to not include '#include/c99' directory directly, but rather rely on scons/gallium.py to do the right thing. --- SConstruct | 6 -- scons/gallium.py | 6 ++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/SConstruct b/SConstruct index 0e10818..ef71ab6 100644 --- a/SConstruct +++ b/SConstruct @@ -80,9 +80,6 @@ env.Append(CPPPATH = [ '#/src/gallium/winsys', ]) -if env['msvc']: -env.Append(CPPPATH = ['#include/c99']) - # for debugging #print env.Dump() @@ -115,9 +112,6 @@ if env['crosscompile'] and not env['embedded']: host_env['hostonly'] = True assert host_env['crosscompile'] == False -if host_env['msvc']: -host_env.Append(CPPPATH = ['#include/c99']) - target_env = env env = host_env Export('env') diff --git a/scons/gallium.py b/scons/gallium.py index ca317b0..5109ebf 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -433,6 +433,12 @@ def generate(env): # See also: # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx # - cl /? +if 'MSVC_VERSION' not in env or distutils.version.LooseVersion(env['MSVC_VERSION']) distutils.version.LooseVersion('12.0'): +# Use bundled stdbool.h and stdint.h headers for older MSVC +# versions. stdint.h was introduced in MSVC 2010, but stdbool.h +# was only introduced in MSVC 2013. +top_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) +env.Append(CPPPATH = [os.path.join(top_dir, 'include/c99')]) if env['build'] == 'debug': ccflags += [ '/Od', # disable optimizations -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 9/9] util: Don't attempt to redefine INFINITY/NAN on VS 2013.
From: José Fonseca jfons...@vmware.com There are now provided by VS. --- src/gallium/auxiliary/util/u_math.h | 5 + 1 file changed, 5 insertions(+) diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index a60e183..2ade64a 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -138,8 +138,13 @@ roundf(float x) } #endif +#ifndef INFINITY #define INFINITY (DBL_MAX + DBL_MAX) +#endif + +#ifndef NAN #define NAN (INFINITY - INFINITY) +#endif #endif /* _MSC_VER */ -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/9] draw: Prevent signed/unsigned comparisons.
From: José Fonseca jfons...@vmware.com --- src/gallium/auxiliary/draw/draw_pt_so_emit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/draw/draw_pt_so_emit.c b/src/gallium/auxiliary/draw/draw_pt_so_emit.c index bd49d0a..91e67c0 100644 --- a/src/gallium/auxiliary/draw/draw_pt_so_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_so_emit.c @@ -162,7 +162,7 @@ static void so_emit_prim(struct pt_so_emit *so, for (i = 0; i num_vertices; ++i) { const float (*input)[4]; const float *pre_clip_pos = NULL; - int ob; + unsigned ob; input = (const float (*)[4])( (const char *)input_ptr + (indices[i] * input_vertex_stride)); -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 8/9] mesa: VS 2013 does not provide strcasecmp.
From: José Fonseca jfons...@vmware.com A define is necessary, like for earlier VS versions. --- src/mesa/main/imports.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index 17a9bd0..af780b2 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -126,7 +126,8 @@ typedef union { GLfloat f; GLint i; GLuint u; } fi_type; #define atanhf(f) ((float) atanh(f)) #endif -#if defined(_MSC_VER) (_MSC_VER 1800) /* Not req'd on VS2013 and above */ +#if defined(_MSC_VER) +#if _MSC_VER 1800 /* Not req'd on VS2013 and above */ static inline float truncf(float x) { return x 0.0f ? ceilf(x) : floorf(x); } static inline float exp2f(float x) { return powf(2.0f, x); } static inline float log2f(float x) { return logf(x) * 1.442695041f; } @@ -135,6 +136,7 @@ static inline float acoshf(float x) { return logf(x + sqrtf(x * x - 1.0f)); } static inline float atanhf(float x) { return (logf(1.0f + x) - logf(1.0f - x)) / 2.0f; } static inline int isblank(int ch) { return ch == ' ' || ch == '\t'; } #define strtoll(p, e, b) _strtoi64(p, e, b) +#endif /* _MSC_VER 1800 */ #define strcasecmp(s1, s2) _stricmp(s1, s2) #endif /*@}*/ -- 1.9.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] st/xlib: Honour request of 3.1 contexts through core profile where available.
From: José Fonseca jfons...@vmware.com The GLX_ARB_create_context_profile spec says: If version 3.1 is requested, the context returned may implement any of the following versions: * Version 3.1. The GL_ARB_compatibility extension may or may not be implemented, as determined by the implementation. * The core profile of version 3.2 or greater. Mesa does not support GL_ARB_compatibility, and there are no plans to ever support it, therefore the only chance to honour a 3.1 context is through core profile, i.e, the 2nd alternative from the spec. This change does that. And with it piglit tests that require 3.1 contexts no longer skip. Assuming there is no objection with this change, src/glx/dri_common.c and src/gallium/state_trackers/wgl/stw_context.c should also be updated accordingly, given they have the same logic. --- src/gallium/state_trackers/glx/xlib/xm_api.c | 17 +++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index bb2dd8e..7836c61 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -899,10 +899,23 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list, * * The default value for GLX_CONTEXT_PROFILE_MASK_ARB is * GLX_CONTEXT_CORE_PROFILE_BIT_ARB. +* +* The spec also says: +* +* If version 3.1 is requested, the context returned may implement +* any of the following versions: +* +* * Version 3.1. The GL_ARB_compatibility extension may or may not +* be implemented, as determined by the implementation. +* * The core profile of version 3.2 or greater. +* +* and because Mesa doesn't support GL_ARB_compatibility, the only chance to +* honour a 3.1 context is through core profile. */ attribs.profile = ST_PROFILE_DEFAULT; - if ((major 3 || (major == 3 minor = 2)) -((profileMask GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) == 0)) + if (((major 3 || (major == 3 minor = 2)) + ((profileMask GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) == 0)) || + (major == 3 minor == 1)) attribs.profile = ST_PROFILE_OPENGL_CORE; c-st = stapi-create_context(stapi, xmdpy-smapi, attribs, -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] llvmpipe: Advertise GLSL 3.30.
From: José Fonseca jfons...@vmware.com According to Roland all TGSI support is there in theory. In practice there are a few piglit failures and crashes, as this hadn't been tested before. --- src/gallium/drivers/llvmpipe/lp_screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 8fbc58f..27073a4 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -200,7 +200,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param) case PIPE_CAP_VERTEX_COLOR_CLAMPED: return 1; case PIPE_CAP_GLSL_FEATURE_LEVEL: - return 140; + return 330; case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION: return 0; case PIPE_CAP_COMPUTE: -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] st/xlib: Do minimal version checking in glXCreateContextAttribsARB.
From: José Fonseca jfons...@vmware.com The current version checking is wrongly refusing to create 3.3 contexts; unsupported version are checked elsewhere; and the DRI path doesn't do this sort of checking neither. This enables piglit glsl 3.30 tests to run without skipping. --- src/gallium/state_trackers/glx/xlib/glx_api.c | 20 +--- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c index 05880dd..d97cbd7 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_api.c +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c @@ -2724,26 +2724,8 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, } /* check version (generate BadMatch if bad) */ - switch (majorVersion) { - case 1: - if (minorVersion 0 || minorVersion 5) - return NULL; - break; - case 2: - if (minorVersion 0 || minorVersion 1) - return NULL; - break; - case 3: - if (minorVersion 0 || minorVersion 2) - return NULL; - break; - case 4: - if (minorVersion 0 || minorVersion 0) - return NULL; - break; - default: + if (majorVersion 0 || minorVersion 0) return NULL; - } if ((contextFlags GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB) majorVersion 3) -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] util/u_debug: Pass correct size to strncat.
From: José Fonseca jfons...@vmware.com Courtesy of Clang static analyzer. --- src/gallium/auxiliary/util/u_debug.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c index fe51717..dc840e8 100644 --- a/src/gallium/auxiliary/util/u_debug.c +++ b/src/gallium/auxiliary/util/u_debug.c @@ -334,10 +334,10 @@ debug_dump_flags(const struct debug_named_value *names, while(names-name) { if((names-value value) == names-value) { if (!first) - util_strncat(output, |, sizeof(output)); + util_strncat(output, |, sizeof(output) - strlen(output) - 1); else first = 0; -util_strncat(output, names-name, sizeof(output) - 1); +util_strncat(output, names-name, sizeof(output) - strlen(output) - 1); output[sizeof(output) - 1] = '\0'; value = ~names-value; } @@ -346,12 +346,12 @@ debug_dump_flags(const struct debug_named_value *names, if (value) { if (!first) -util_strncat(output, |, sizeof(output)); +util_strncat(output, |, sizeof(output) - strlen(output) - 1); else first = 0; util_snprintf(rest, sizeof(rest), 0x%08lx, value); - util_strncat(output, rest, sizeof(output) - 1); + util_strncat(output, rest, sizeof(output) - strlen(output) - 1); output[sizeof(output) - 1] = '\0'; } -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] mesa/st: Fix pipe_framebuffer_state::height for PIPE_TEXTURE_1D_ARRAY.
From: José Fonseca jfons...@vmware.com This prevents buffer overflow w/ llvmpipe when running piglit bin/gl-3.2-layered-rendering-clear-color-all-types 1d_array single_level -fbo -auto v2: Compute the framebuffer size as the minimum size, as pointed out by Brian; compacted code; ran piglit quick test list (with no regressions.) --- src/mesa/state_tracker/st_atom_framebuffer.c | 33 ++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index 4c4f839..f395ec7 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -31,6 +31,8 @@ * Brian Paul */ +#include limits.h + #include st_context.h #include st_atom.h #include st_cb_bitmap.h @@ -44,6 +46,24 @@ /** + * Update framebuffer size. + * + * framebuffer-width should match fb-Weight, but for PIPE_TEXTURE_1D_ARRAY + * textures fb-Height has the number of layers, and not the surface height. + */ +static void +update_framebuffer_size(struct pipe_framebuffer_state *framebuffer, +struct pipe_surface *surface) +{ + assert(surface); + assert(surface-width UINT_MAX); + assert(surface-height UINT_MAX); + framebuffer-width = MIN2(framebuffer-width, surface-width); + framebuffer-height = MIN2(framebuffer-height, surface-height); +} + + +/** * Update framebuffer state (color, depth, stencil, etc. buffers) */ static void @@ -57,11 +77,12 @@ update_framebuffer_state( struct st_context *st ) st_flush_bitmap_cache(st); st-state.fb_orientation = st_fb_orientation(fb); - framebuffer-width = fb-Width; - framebuffer-height = fb-Height; /*printf(-- fb size %d x %d\n, fb-Width, fb-Height);*/ + framebuffer-width = UINT_MAX; + framebuffer-height = UINT_MAX; + /* Examine Mesa's ctx-DrawBuffer-_ColorDrawBuffers state * to determine which surfaces to draw to */ @@ -81,6 +102,7 @@ update_framebuffer_state( struct st_context *st ) if (strb-surface) { pipe_surface_reference(framebuffer-cbufs[i], strb-surface); +update_framebuffer_size(framebuffer, strb-surface); } strb-defined = GL_TRUE; /* we'll be drawing something */ } @@ -100,12 +122,14 @@ update_framebuffer_state( struct st_context *st ) st_update_renderbuffer_surface(st, strb); } pipe_surface_reference(framebuffer-zsbuf, strb-surface); + update_framebuffer_size(framebuffer, strb-surface); } else { strb = st_renderbuffer(fb-Attachment[BUFFER_STENCIL].Renderbuffer); if (strb) { assert(strb-surface); pipe_surface_reference(framebuffer-zsbuf, strb-surface); + update_framebuffer_size(framebuffer, strb-surface); } else pipe_surface_reference(framebuffer-zsbuf, NULL); @@ -122,6 +146,11 @@ update_framebuffer_state( struct st_context *st ) } #endif + /* _mesa_test_framebuffer_completeness refuses framebuffers with no +* attachments, so this should never happen. */ + assert(framebuffer-width != UINT_MAX); + assert(framebuffer-height != UINT_MAX); + cso_set_framebuffer(st-cso_context, framebuffer); } -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/3] util: Add __declspec(noreturn) to _debug_assert_fail().
From: José Fonseca jfons...@vmware.com Mostly for consistency; as MSVC's static source code analysis doesn't seem to rely on assertions, but instead on different kind of source annotations( http://msdn.microsoft.com/en-us/library/hh916383.aspx ). --- src/gallium/auxiliary/util/u_debug.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h index 8570597..9c41421 100644 --- a/src/gallium/auxiliary/util/u_debug.h +++ b/src/gallium/auxiliary/util/u_debug.h @@ -151,6 +151,9 @@ void debug_print_format(const char *msg, unsigned fmt ); long debug_get_num_option(const char *name, long dfault); +#ifdef _MSC_VER +__declspec(noreturn) +#endif void _debug_assert_fail(const char *expr, const char *file, unsigned line, -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/3] auxiliary/os,auxiliary/util: Fix the `‘noreturn’ function does return` warning.
From: José Fonseca jfons...@vmware.com Now that _debug_assert_fail() has the noreturn attribute, it is better that execution truly never returns. Not just for sake of silencing the warning, but because the code at the return IP address may be invalid or lead to inconsistent results. This removes support for the GALLIUM_ABORT_ON_ASSERT debugging environment variable, but between the usefulness of GALLIUM_ABORT_ON_ASSERT and better static code analysis I think better static code analysis wins. --- src/gallium/auxiliary/os/os_misc.h | 2 +- src/gallium/auxiliary/util/u_debug.c | 5 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/gallium/auxiliary/os/os_misc.h b/src/gallium/auxiliary/os/os_misc.h index 5029ab9..582931f 100644 --- a/src/gallium/auxiliary/os/os_misc.h +++ b/src/gallium/auxiliary/os/os_misc.h @@ -67,7 +67,7 @@ extern C { * Abort the program. */ #if defined(DEBUG) -# define os_abort() os_break() +# define os_abort() do { os_break(); abort(); } while(0) #else # define os_abort() abort() #endif diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c index ae248e0..fe51717 100644 --- a/src/gallium/auxiliary/util/u_debug.c +++ b/src/gallium/auxiliary/util/u_debug.c @@ -274,10 +274,7 @@ void _debug_assert_fail(const char *expr, const char *function) { _debug_printf(%s:%u:%s: Assertion `%s' failed.\n, file, line, function, expr); - if (debug_get_bool_option(GALLIUM_ABORT_ON_ASSERT, TRUE)) - os_abort(); - else - _debug_printf(continuing...\n); + os_abort(); } -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/3] scons: Enable building through Clang Static Analyzer.
From: José Fonseca jfons...@vmware.com Same intent as commit a45a50a4828e1357e9555474bc127c5585b3a420, but this the C compiler is detected via C-preprocessor macros, similar to how autotools do it, as that seems to be the most reliable method. --- scons/gallium.py | 38 +++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/scons/gallium.py b/scons/gallium.py index bd71e51..d13d0e6 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -36,6 +36,8 @@ import os.path import re import subprocess import platform as _platform +import sys +import tempfile import SCons.Action import SCons.Builder @@ -104,6 +106,28 @@ def num_jobs(): return 1 +def check_cc(env, cc, expr, cpp_opt = '-E'): +# Invoke C-preprocessor to determine whether the specified expression is +# true or not. + +sys.stdout.write('Checking for %s ... ' % cc) + +source = tempfile.NamedTemporaryFile(suffix='.c', delete=False) +source.write('#if !(%s)\n#error\n#endif\n' % expr) +source.close() + +pipe = SCons.Action._subproc(env, [env['CC'], cpp_opt, source.name], + stdin = 'devnull', + stderr = 'devnull', + stdout = 'devnull') +result = pipe.wait() == 0 + +os.unlink(source.name) + +sys.stdout.write(' %s\n' % ['no', 'yes'][int(bool(result))]) +return result + + def generate(env): Common environment generation code @@ -137,10 +161,18 @@ def generate(env): if os.environ.has_key('LDFLAGS'): env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS']) -env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-') -env['msvc'] = env['CC'] == 'cl' +# Detect gcc/clang not by executable name, but through pre-defined macros +# as autoconf does, to avoid drawing wrong conclusions when using tools +# that overrice CC/CXX like scan-build. +env['gcc'] = 0 +env['clang'] = 0 +env['msvc'] = 0 +if _platform.system() == 'Windows': +env['msvc'] = check_cc(env, 'MSVC', 'defined(_MSC_VER)', '/E') +if not env['msvc']: +env['gcc'] = check_cc(env, 'GCC', 'defined(__GNUC__) !defined(__clang__)') +env['clang'] = check_cc(env, 'Clang', '__clang__') env['suncc'] = env['platform'] == 'sunos' and os.path.basename(env['CC']) == 'cc' -env['clang'] = env['CC'] == 'clang' env['icc'] = 'icc' == os.path.basename(env['CC']) if env['msvc'] and env['toolchain'] == 'default' and env['machine'] == 'x86_64': -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/3] scons: Add an analyze option.
From: José Fonseca jfons...@vmware.com For Clang static code analyzer, the scan-build script will produce more comprehensive output. Nevertheless you can invoke it as CC=clang CXX=clang++ scons analyze=1 For MSVC this is the best way to use its static code analysis. Simply invoke as scons analyze=1 --- common.py| 1 + scons/gallium.py | 12 2 files changed, 13 insertions(+) diff --git a/common.py b/common.py index 22c1725..d6e6215 100644 --- a/common.py +++ b/common.py @@ -91,6 +91,7 @@ def AddOptions(opts): opts.Add(EnumOption('platform', 'target platform', host_platform, allowed_values=('cygwin', 'darwin', 'freebsd', 'haiku', 'linux', 'sunos', 'windows'))) opts.Add(BoolOption('embedded', 'embedded build', 'no')) + opts.Add(BoolOption('analyze', 'enable static code analysis where available', 'no')) opts.Add('toolchain', 'compiler toolchain', default_toolchain) opts.Add(BoolOption('gles', 'EXPERIMENTAL: enable OpenGL ES support', 'no')) opts.Add(BoolOption('llvm', 'use LLVM', default_llvm)) diff --git a/scons/gallium.py b/scons/gallium.py index 42e8f7c..e873c65 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -467,6 +467,18 @@ def generate(env): env.Append(CCFLAGS = ['/MT']) env.Append(SHCCFLAGS = ['/LD']) +# Static code analysis +if env['analyze']: +if env['msvc']: +# http://msdn.microsoft.com/en-us/library/ms173498.aspx +env.Append(CCFLAGS = [ +'/analyze', +#'/analyze:log', '${TARGET.base}.xml', +]) +if env['clang']: +# scan-build will produce more comprehensive output +env.Append(CCFLAGS = ['--analyze']) + # Assembler options if gcc_compat: if env['machine'] == 'x86': -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/3] scons: Enable building through Clang Static Analyzer.
From: José Fonseca jfons...@vmware.com By accurately detecting gcc/clang through --version option instead of executable name. Clang Static Analyzer reports many issues, most false positives, but it found at least one real and subtle use-after-free issue in st_texture_get_sampler_view(): http://people.freedesktop.org/~jrfonseca/scan-build-2014-04-14-1/report-869047.html#EndPath --- scons/gallium.py | 31 +++ 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/scons/gallium.py b/scons/gallium.py index e11d4db..42e8f7c 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -104,6 +104,19 @@ def num_jobs(): return 1 +def get_cc_version(env): +# Get the first line of `$CC --version` +pipe = SCons.Action._subproc(env, [env['CC'], '--version'], + stdin = 'devnull', + stderr = 'devnull', + stdout = subprocess.PIPE) +if pipe.wait() != 0: +return '' + +line = pipe.stdout.readline() +return line + + def generate(env): Common environment generation code @@ -119,12 +132,8 @@ def generate(env): if os.environ.has_key('CC'): env['CC'] = os.environ['CC'] # Update CCVERSION to match -pipe = SCons.Action._subproc(env, [env['CC'], '--version'], - stdin = 'devnull', - stderr = 'devnull', - stdout = subprocess.PIPE) -if pipe.wait() == 0: -line = pipe.stdout.readline() +line = get_cc_version(env) +if line: match = re.search(r'[0-9]+(\.[0-9]+)+', line) if match: env['CCVERSION'] = match.group(0) @@ -137,10 +146,16 @@ def generate(env): if os.environ.has_key('LDFLAGS'): env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS']) -env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-') +# Detect gcc/clang not by executable name, but through `--version` option, +# to avoid drawing wrong conclusions when using tools that overrice CC/CXX +# like scan-build. +cc_version = get_cc_version(env) +cc_version_words = cc_version.split() + +env['gcc'] = 'gcc' in cc_version_words env['msvc'] = env['CC'] == 'cl' env['suncc'] = env['platform'] == 'sunos' and os.path.basename(env['CC']) == 'cc' -env['clang'] = env['CC'] == 'clang' +env['clang'] = 'clang' in cc_version_words env['icc'] = 'icc' == os.path.basename(env['CC']) if env['msvc'] and env['toolchain'] == 'default' and env['machine'] == 'x86_64': -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/3] util/u_debug: Add noreturn attribute to _debug_assert_fail().
From: José Fonseca jfons...@vmware.com As recommended by http://clang-analyzer.llvm.org/annotations.html#attr_noreturn --- src/gallium/auxiliary/util/u_debug.h | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h index 9e4eb41..8570597 100644 --- a/src/gallium/auxiliary/util/u_debug.h +++ b/src/gallium/auxiliary/util/u_debug.h @@ -154,7 +154,11 @@ debug_get_num_option(const char *name, long dfault); void _debug_assert_fail(const char *expr, const char *file, unsigned line, -const char *function); +const char *function) +#ifdef __GNUC__ + __attribute__((__noreturn__)) +#endif +; /** -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] mesa/st: Fix pipe_framebuffer_state::height for PIPE_TEXTURE_1D_ARRAY.
From: José Fonseca jfons...@vmware.com This prevents buffer overflow w/ llvmpipe when running piglit bin/gl-3.2-layered-rendering-clear-color-all-types 1d_array single_level -fbo -auto --- src/mesa/state_tracker/st_atom_framebuffer.c | 19 +-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index 4c4f839..f8eb1f0 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -52,13 +52,13 @@ update_framebuffer_state( struct st_context *st ) struct pipe_framebuffer_state *framebuffer = st-state.framebuffer; struct gl_framebuffer *fb = st-ctx-DrawBuffer; struct st_renderbuffer *strb; + unsigned width = 0; + unsigned height = 0; GLuint i; st_flush_bitmap_cache(st); st-state.fb_orientation = st_fb_orientation(fb); - framebuffer-width = fb-Width; - framebuffer-height = fb-Height; /*printf(-- fb size %d x %d\n, fb-Width, fb-Height);*/ @@ -81,6 +81,8 @@ update_framebuffer_state( struct st_context *st ) if (strb-surface) { pipe_surface_reference(framebuffer-cbufs[i], strb-surface); +width = MAX2(width, strb-surface-width); +height = MAX2(height, strb-surface-height); } strb-defined = GL_TRUE; /* we'll be drawing something */ } @@ -100,12 +102,18 @@ update_framebuffer_state( struct st_context *st ) st_update_renderbuffer_surface(st, strb); } pipe_surface_reference(framebuffer-zsbuf, strb-surface); + if (strb-surface) { + width = MAX2(width, strb-surface-width); + height = MAX2(height, strb-surface-height); + } } else { strb = st_renderbuffer(fb-Attachment[BUFFER_STENCIL].Renderbuffer); if (strb) { assert(strb-surface); pipe_surface_reference(framebuffer-zsbuf, strb-surface); + width = MAX2(width, strb-surface-width); + height = MAX2(height, strb-surface-height); } else pipe_surface_reference(framebuffer-zsbuf, NULL); @@ -122,6 +130,13 @@ update_framebuffer_state( struct st_context *st ) } #endif + /* +* framebuffer-width should match fb-Weight, but for PIPE_TEXTURE_1D_ARRAY +* fb-Height has the number of layers as opposed to height. +*/ + framebuffer-width = width; + framebuffer-height = height; + cso_set_framebuffer(st-cso_context, framebuffer); } -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] st/wgl: Remove wgl*Gallium*MESA().
From: José Fonseca jfons...@vmware.com These were only used by the Python state tracker, which was removed, hence they have no practical use. --- src/gallium/state_trackers/wgl/Makefile.sources| 1 - src/gallium/state_trackers/wgl/stw_ext_gallium.c | 50 -- src/gallium/state_trackers/wgl/stw_ext_gallium.h | 47 .../state_trackers/wgl/stw_getprocaddress.c| 5 --- 4 files changed, 103 deletions(-) delete mode 100644 src/gallium/state_trackers/wgl/stw_ext_gallium.c delete mode 100644 src/gallium/state_trackers/wgl/stw_ext_gallium.h diff --git a/src/gallium/state_trackers/wgl/Makefile.sources b/src/gallium/state_trackers/wgl/Makefile.sources index e93342a..d204efd 100644 --- a/src/gallium/state_trackers/wgl/Makefile.sources +++ b/src/gallium/state_trackers/wgl/Makefile.sources @@ -3,7 +3,6 @@ C_SOURCES := \ stw_device.c \ stw_ext_context.c \ stw_ext_extensionsstring.c \ - stw_ext_gallium.c \ stw_ext_pbuffer.c \ stw_ext_pixelformat.c \ stw_ext_swapinterval.c \ diff --git a/src/gallium/state_trackers/wgl/stw_ext_gallium.c b/src/gallium/state_trackers/wgl/stw_ext_gallium.c deleted file mode 100644 index 13aa960..000 --- a/src/gallium/state_trackers/wgl/stw_ext_gallium.c +++ /dev/null @@ -1,50 +0,0 @@ -/** - * - * 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 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. - * - **/ - - -#include pipe/p_screen.h -#include stw_device.h -#include stw_winsys.h -#include stw_ext_gallium.h - - -struct pipe_screen * APIENTRY -wglGetGalliumScreenMESA(void) -{ - return stw_dev ? stw_dev-screen : NULL; -} - - -/* XXX: Unify with stw_create_layer_context */ -struct pipe_context * APIENTRY -wglCreateGalliumContextMESA(void) -{ - if(!stw_dev) - return NULL; - - return stw_dev-screen-context_create( stw_dev-screen, NULL ); -} diff --git a/src/gallium/state_trackers/wgl/stw_ext_gallium.h b/src/gallium/state_trackers/wgl/stw_ext_gallium.h deleted file mode 100644 index cc35f2b..000 --- a/src/gallium/state_trackers/wgl/stw_ext_gallium.h +++ /dev/null @@ -1,47 +0,0 @@ -/** - * - * Copyright 2009 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 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. - * - **/ - -#ifndef STW_EXTGALLIUM_H_ -#define STW_EXTGALLIUM_H_ - - -#include windows.h - - -struct pipe_screen; -struct pipe_context; - - -struct pipe_screen * APIENTRY -wglGetGalliumScreenMESA(void); - - -struct pipe_context * APIENTRY -wglCreateGalliumContextMESA(void); - -
[Mesa-dev] [PATCH] mapi/glapi: Use ElementTree instead of libxml2.
From: José Fonseca jfons...@vmware.com It is quite hard to meet the dependency of the libxml2 python bindings out side Linux, and in particularly on MacOSX; whereas ElementTree is part of Python's standard library. ElementTree is more limited than libxml2: no DTD verification, defaults from DTD, or XInclude support, but none of this limitations is serious enough to justify libxml2. In fact, it was easier to refactor the code to use ElementTree than to try to get libxml2 python bindings... In the process, gl_item_factory class was refactored so that there is one method for each kind of object to be created, as it simplified things substantially. I confirmed that precisely the same output is generated for GL/GLX/GLES. --- SConstruct | 7 -- configure.ac | 1 - docs/README.WIN32 | 16 ++- docs/install.html | 4 - src/mapi/glapi/gen/glX_XML.py | 55 - src/mapi/glapi/gen/glX_proto_common.py | 13 +- src/mapi/glapi/gen/gl_XML.py | 217 - 7 files changed, 141 insertions(+), 172 deletions(-) diff --git a/SConstruct b/SConstruct index de735e9..0e10818 100644 --- a/SConstruct +++ b/SConstruct @@ -59,13 +59,6 @@ else: Help(opts.GenerateHelpText(env)) -# fail early for a common error on windows -if env['gles']: -try: -import libxml2 -except ImportError: -raise SCons.Errors.UserError, GLES requires libxml2-python to build - ### # Environment setup diff --git a/configure.ac b/configure.ac index c5042f9..04bf711 100644 --- a/configure.ac +++ b/configure.ac @@ -54,7 +54,6 @@ AM_PROG_CC_C_O AM_PROG_AS AC_CHECK_PROGS([MAKE], [gmake make]) AC_CHECK_PROGS([PYTHON2], [python2 python]) -AX_PYTHON_MODULE([libxml2], [needed]) AC_PROG_SED AC_PROG_MKDIR_P diff --git a/docs/README.WIN32 b/docs/README.WIN32 index 0cd007c..c8759f6 100644 --- a/docs/README.WIN32 +++ b/docs/README.WIN32 @@ -36,17 +36,15 @@ Recipe Building on windows requires several open-source packages. These are steps that work as of this writing. -1) install python 2.7 -2) install scons (latest) -3) install mingw, flex, and bison -4) install libxml2 from here: http://www.lfd.uci.edu/~gohlke/pythonlibs - get libxml2-python-2.9.1.win-amd64-py2.7.exe -5) install pywin32 from here: http://www.lfd.uci.edu/~gohlke/pythonlibs +- install python 2.7 +- install scons (latest) +- install mingw, flex, and bison +- install pywin32 from here: http://www.lfd.uci.edu/~gohlke/pythonlibs get pywin32-218.4.win-amd64-py2.7.exe -6) install git -7) download mesa from git +- install git +- download mesa from git see http://www.mesa3d.org/repository.html -8) run scons +- run scons General --- diff --git a/docs/install.html b/docs/install.html index 24492a7..5061ede 100644 --- a/docs/install.html +++ b/docs/install.html @@ -44,10 +44,6 @@ On Windows with MinGW, install flex and bison with: /li lipython - Python is needed for building the Gallium components. Version 2.6.4 or later should work. -br -br -To build OpenGL ES 1.1 and 2.0 you'll also need -a href=http://xmlsoft.org/sources/win32/python/libxml2-python-2.7.7.win32-py2.7.exe;libxml2-python/a. /li /ul diff --git a/src/mapi/glapi/gen/glX_XML.py b/src/mapi/glapi/gen/glX_XML.py index 03a35b7..12ff291 100644 --- a/src/mapi/glapi/gen/glX_XML.py +++ b/src/mapi/glapi/gen/glX_XML.py @@ -33,29 +33,27 @@ import sys, getopt, string class glx_item_factory(gl_XML.gl_item_factory): Factory to create GLX protocol oriented objects derived from gl_item. -def create_item(self, name, element, context): -if name == function: -return glx_function(element, context) -elif name == enum: -return glx_enum(element, context) -elif name == api: -return glx_api(self) -else: -return gl_XML.gl_item_factory.create_item(self, name, element, context) +def create_function(self, element, context): +return glx_function(element, context) + +def create_enum(self, element, context, category): +return glx_enum(element, context, category) + +def create_api(self): +return glx_api(self) class glx_enum(gl_XML.gl_enum): -def __init__(self, element, context): -gl_XML.gl_enum.__init__(self, element, context) +def __init__(self, element, context, category): +gl_XML.gl_enum.__init__(self, element, context, category) self.functions = {} -child = element.children -while child: -if child.type == element and child.name == size: -n = child.nsProp( name, None ) -c = child.nsProp( count, None ) -m = child.nsProp( mode, None ) +for child in element.getchildren(): +if child.tag == size: +n = child.get( name ) +
[Mesa-dev] [PATCH 2/2] llvmpipe: Simplify vertex and geometry shaders.
From: José Fonseca jfons...@vmware.com Eliminate lp_vertex_shader, as it added nothing over draw_vertex_shader. Simplify lp_geometry_shader, as most of the incoming state is unneeded. (We could also just use draw_geometry_shader if we were willing to peek inside the structure.) --- src/gallium/drivers/llvmpipe/lp_context.h | 4 +-- src/gallium/drivers/llvmpipe/lp_draw_arrays.c | 8 ++--- src/gallium/drivers/llvmpipe/lp_state.h | 13 ++-- src/gallium/drivers/llvmpipe/lp_state_gs.c| 32 +++ src/gallium/drivers/llvmpipe/lp_state_vs.c| 46 +++ 5 files changed, 33 insertions(+), 70 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_context.h b/src/gallium/drivers/llvmpipe/lp_context.h index 05cdfe5..ee8033c 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.h +++ b/src/gallium/drivers/llvmpipe/lp_context.h @@ -46,8 +46,8 @@ struct llvmpipe_vbuf_render; struct draw_context; struct draw_stage; +struct draw_vertex_shader; struct lp_fragment_shader; -struct lp_vertex_shader; struct lp_blend_state; struct lp_setup_context; struct lp_setup_variant; @@ -63,7 +63,7 @@ struct llvmpipe_context { const struct pipe_depth_stencil_alpha_state *depth_stencil; const struct pipe_rasterizer_state *rasterizer; struct lp_fragment_shader *fs; - const struct lp_vertex_shader *vs; + struct draw_vertex_shader *vs; const struct lp_geometry_shader *gs; const struct lp_velems_state *velems; const struct lp_so_state *so; diff --git a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c index 3df0a5c..99e6d19 100644 --- a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c +++ b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c @@ -112,11 +112,11 @@ llvmpipe_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) llvmpipe_prepare_geometry_sampling(lp, lp-num_sampler_views[PIPE_SHADER_GEOMETRY], lp-sampler_views[PIPE_SHADER_GEOMETRY]); - if (lp-gs !lp-gs-shader.tokens) { + if (lp-gs lp-gs-no_tokens) { /* we have an empty geometry shader with stream output, so attach the stream output info to the current vertex shader */ if (lp-vs) { - draw_vs_attach_so(lp-vs-draw_data, lp-gs-shader.stream_output); + draw_vs_attach_so(lp-vs, lp-gs-stream_output); } } draw_collect_pipeline_statistics(draw, @@ -136,11 +136,11 @@ llvmpipe_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) } draw_set_mapped_so_targets(draw, 0, NULL); - if (lp-gs !lp-gs-shader.tokens) { + if (lp-gs lp-gs-no_tokens) { /* we have attached stream output to the vs for rendering, now lets reset it */ if (lp-vs) { - draw_vs_reset_so(lp-vs-draw_data); + draw_vs_reset_so(lp-vs); } } diff --git a/src/gallium/drivers/llvmpipe/lp_state.h b/src/gallium/drivers/llvmpipe/lp_state.h index 8635cf1..2da6caa 100644 --- a/src/gallium/drivers/llvmpipe/lp_state.h +++ b/src/gallium/drivers/llvmpipe/lp_state.h @@ -65,17 +65,10 @@ struct llvmpipe_context; -/** Subclass of pipe_shader_state */ -struct lp_vertex_shader -{ - struct pipe_shader_state shader; - struct draw_vertex_shader *draw_data; -}; - -/** Subclass of pipe_shader_state */ struct lp_geometry_shader { - struct pipe_shader_state shader; - struct draw_geometry_shader *draw_data; + boolean no_tokens; + struct pipe_stream_output_info stream_output; + struct draw_geometry_shader *dgs; }; /** Vertex element state */ diff --git a/src/gallium/drivers/llvmpipe/lp_state_gs.c b/src/gallium/drivers/llvmpipe/lp_state_gs.c index 74cf992..c94afed 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_gs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_gs.c @@ -48,7 +48,7 @@ llvmpipe_create_gs_state(struct pipe_context *pipe, state = CALLOC_STRUCT(lp_geometry_shader); if (state == NULL ) - goto fail; + goto no_state; /* debug */ if (LP_DEBUG DEBUG_TGSI) { @@ -57,26 +57,19 @@ llvmpipe_create_gs_state(struct pipe_context *pipe, } /* copy stream output info */ - state-shader = *templ; - if (templ-tokens) { - /* copy shader tokens, the ones passed in will go away. */ - state-shader.tokens = tgsi_dup_tokens(templ-tokens); - if (state-shader.tokens == NULL) - goto fail; - - state-draw_data = draw_create_geometry_shader(llvmpipe-draw, templ); - if (state-draw_data == NULL) - goto fail; + state-no_tokens = !templ-tokens; + memcpy(state-stream_output, templ-stream_output, sizeof state-stream_output); + + state-dgs = draw_create_geometry_shader(llvmpipe-draw, templ); + if (state-dgs == NULL) { + goto no_dgs; } return state; -fail: - if (state) { - FREE( (void *)state-shader.tokens ); - FREE( state-draw_data ); - FREE( state ); -
[Mesa-dev] [PATCH 1/2] draw: Duplicate TGSI tokens in draw_pipe_pstipple module.
From: José Fonseca jfons...@vmware.com As done in draw_pipe_aaline and draw_pipe_aapoint modules. --- src/gallium/auxiliary/draw/draw_pipe_pstipple.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c index d7dcfdb..d216787 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c +++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c @@ -673,7 +673,7 @@ pstip_create_fs_state(struct pipe_context *pipe, struct pstip_fragment_shader *pstipfs = CALLOC_STRUCT(pstip_fragment_shader); if (pstipfs) { - pstipfs-state = *fs; + pstipfs-state.tokens = tgsi_dup_tokens(fs-tokens); /* pass-through */ pstipfs-driver_fs = pstip-driver_create_fs_state(pstip-pipe, fs); @@ -707,6 +707,7 @@ pstip_delete_fs_state(struct pipe_context *pipe, void *fs) if (pstipfs-pstip_fs) pstip-driver_delete_fs_state(pstip-pipe, pstipfs-pstip_fs); + FREE((void*)pstipfs-state.tokens); FREE(pstipfs); } -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] st/mesa: Add R8G8B8A8_SRGB case to st_pipe_format_to_mesa_format.
From: José Fonseca jfons...@vmware.com With the recent SRGB changes all my automated OpenGL llvmpipe tests (piglit, conform, glretrace) start asserting with the backtrace below. I'm hoping this change will fix it. I'm not entirely sure, as this doesn't happen in my development machine (the bug probably depends on the exact X visual). Anyway, it seems the sensible thing to do here. Program terminated with signal 5, Trace/breakpoint trap. #0 _debug_assert_fail (expr=expr@entry=0x7fa324df2ed7 0, file=file@entry=0x7fa324e3fc30 src/mesa/state_tracker/st_format.c, line=line@entry=758, function=function@entry=0x7fa324e40160 __func__.34798 st_pipe_format_to_mesa_format) at src/gallium/auxiliary/util/u_debug.c:281 #0 _debug_assert_fail (expr=expr@entry=0x7fa324df2ed7 0, file=file@entry=0x7fa324e3fc30 src/mesa/state_tracker/st_format.c, line=line@entry=758, function=function@entry=0x7fa324e40160 __func__.34798 st_pipe_format_to_mesa_format) at src/gallium/auxiliary/util/u_debug.c:281 No locals. #1 0x7fa3241d22b3 in st_pipe_format_to_mesa_format (format=format@entry=PIPE_FORMAT_R8G8B8A8_SRGB) at src/mesa/state_tracker/st_format.c:758 __func__ = st_pipe_format_to_mesa_format #2 0x7fa3241c8ec5 in st_new_renderbuffer_fb (format=format@entry=PIPE_FORMAT_R8G8B8A8_SRGB, samples=0, sw=optimised out) at src/mesa/state_tracker/st_cb_fbo.c:295 strb = 0x19e8420 #3 0x7fa32409d355 in st_framebuffer_add_renderbuffer (stfb=stfb@entry=0x19e7fa0, idx=optimised out) at src/mesa/state_tracker/st_manager.c:314 rb = optimised out format = PIPE_FORMAT_R8G8B8A8_SRGB sw = optimised out #4 0x7fa32409e635 in st_framebuffer_create (st=0x19e7fa0, st=0x19e7fa0, stfbi=0x19e7a30) at src/mesa/state_tracker/st_manager.c:458 stfb = 0x19e7fa0 mode = {rgbMode = 1 '\001', floatMode = 0 '\000', colorIndexMode = 0 '\000', doubleBufferMode = 0, stereoMode = 0, haveAccumBuffer = 0 '\000', haveDepthBuffer = 1 '\001', haveStencilBuffer = 1 '\001', redBits = 8, greenBits = 8, blueBits = 8, alphaBits = 8, redMask = 0, greenMask = 0, blueMask = 0, alphaMask = 0, rgbBits = 32, indexBits = 0, accumRedBits = 0, accumGreenBits = 0, accumBlueBits = 0, accumAlphaBits = 0, depthBits = 24, stencilBits = 8, numAuxBuffers = 0, level = 0, visualRating = 0, transparentPixel = 0, transparentRed = 0, transparentGreen = 0, transparentBlue = 0, transparentAlpha = 0, transparentIndex = 0, sampleBuffers = 0, samples = 0, maxPbufferWidth = 0, maxPbufferHeight = 0, maxPbufferPixels = 0, optimalPbufferWidth = 0, optimalPbufferHeight = 0, swapMethod = 0, bindToTextureRgb = 0, bindToTextureRgba = 0, bindToMipmapTexture = 0, bindToTextureTargets = 0, yInverted = 0, sRGBCapable = 1} idx = optimised out #5 st_framebuffer_reuse_or_create (st=st@entry=0x19dfce0, fb=optimised out, stfbi=stfbi@entry=0x19e7a30) at src/mesa/state_tracker/st_manager.c:728 No locals. #6 0x7fa32409e8cc in st_api_make_current (stapi=optimised out, stctxi=0x19dfce0, stdrawi=0x19e7a30, streadi=0x19e7a30) at src/mesa/state_tracker/st_manager.c:747 st = 0x19dfce0 stdraw = 0x640064 stread = 0x130006 ret = optimised out #7 0x7fa324074a20 in XMesaMakeCurrent2 (c=c@entry=0x195bb00, drawBuffer=0x19e7e90, readBuffer=0x19e7e90) at src/gallium/state_trackers/glx/xlib/xm_api.c:1194 No locals. #8 0x7fa3240783c8 in glXMakeContextCurrent (dpy=0x194e900, draw=8388610, read=8388610, ctx=0x195bac0) at src/gallium/state_trackers/glx/xlib/glx_api.c:1177 drawBuffer = optimised out readBuffer = optimised out xmctx = 0x195bb00 glxCtx = 0x195bac0 firsttime = 0 '\000' no_rast = 0 '\000' #9 0x7fa32407852f in glXMakeCurrent (dpy=optimised out, drawable=optimised out, ctx=optimised out) at src/gallium/state_trackers/glx/xlib/glx_api.c:1211 No locals. --- 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 25577ac..0311a2b 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -753,6 +753,8 @@ st_pipe_format_to_mesa_format(enum pipe_format format) case PIPE_FORMAT_B8G8R8X8_SRGB: return MESA_FORMAT_B8G8R8X8_SRGB; + case PIPE_FORMAT_R8G8B8A8_SRGB: + return MESA_FORMAT_B8G8R8A8_SRGB; default: assert(0); -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/3] c11: Fix nano to second conversion.
From: José Fonseca jfons...@vmware.com Per https://gist.github.com/yohhoy/2223710/#comment-710118 --- include/c11/threads_win32.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/c11/threads_win32.h b/include/c11/threads_win32.h index be1a389..771db94 100644 --- a/include/c11/threads_win32.h +++ b/include/c11/threads_win32.h @@ -146,7 +146,7 @@ static unsigned __stdcall impl_thrd_routine(void *p) static DWORD impl_xtime2msec(const xtime *xt) { -return (DWORD)((xt-sec * 1000u) + (xt-nsec / 1000)); +return (DWORD)((xt-sec * 1000U) + (xt-nsec / 100L)); } #ifdef EMULATED_THREADS_USE_NATIVE_CALL_ONCE -- 1.8.5.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/3] mapi/u_thread: Use GetCurrentThreadId
From: José Fonseca jfons...@vmware.com u_thread_self() expects thrd_current() to return a unique numeric ID for the current thread, but this is not feasible on Windows. --- src/mapi/u_thread.h | 18 ++ 1 file changed, 18 insertions(+) diff --git a/src/mapi/u_thread.h b/src/mapi/u_thread.h index ba5d98e..3e18358 100644 --- a/src/mapi/u_thread.h +++ b/src/mapi/u_thread.h @@ -89,10 +89,28 @@ typedef mtx_t u_mutex; #define u_mutex_lock(name)(void) mtx_lock((name)) #define u_mutex_unlock(name) (void) mtx_unlock((name)) + static INLINE unsigned long u_thread_self(void) { + /* +* XXX: Callers of u_thread_self assume it is a lightweight function, +* returning a numeric value. But unfortunately C11's thrd_current() gives +* no such guarantees. In fact, it's pretty hard to have a compliant +* implementation of thrd_current() on Windows with such characteristics. +* So for now, we side-step this mess and use Windows thread primitives +* directly here. +* +* FIXME: On the other hand, u_thread_self() and _glthread_GetID() are bad +* abstractions. Even with pthreads, there is no guarantee that +* pthread_self() will return numeric IDs -- we should be using +* pthread_equal() instead of assuming we can compare thread ids... +*/ +#ifdef _WIN32 + return GetCurrentThreadId(); +#else return (unsigned long) (uintptr_t) thrd_current(); +#endif } -- 1.8.5.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/3] c11/threads: Don't implement thrd_current on Windows.
From: José Fonseca jfons...@vmware.com GetCurrentThread() returns a pseudo-handle (a constant which can only be used within the calling thread) and not a real handle. DuplicateHandle will return a real handle, but it will create a new handle every time we call. Calling DuplicateHandle here means we will leak handles, which is also very bad. In short, the Windows implementation of thrd_t needs a thorough make over. And it won't be pretty. It looks like C11 committee over-simplified things: it would be much better to have seperate objects for threads and thread IDs like C++11. For now, just comment out the thrd_current() implementation, so we get build errors if anybody tries to use them. Thanks to Brian Paul for spotting and diagnosing this problem. --- include/c11/threads_win32.h | 34 -- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/include/c11/threads_win32.h b/include/c11/threads_win32.h index 771db94..d4c2a72 100644 --- a/include/c11/threads_win32.h +++ b/include/c11/threads_win32.h @@ -492,12 +492,42 @@ thrd_create(thrd_t *thr, thrd_start_t func, void *arg) return thrd_success; } +#if 0 // 7.25.5.2 static inline thrd_t thrd_current(void) { -return GetCurrentThread(); +HANDLE hCurrentThread; +BOOL bRet; + +/* GetCurrentThread() returns a pseudo-handle, which is useless. We need + * to call DuplicateHandle to get a real handle. However the handle value + * will not match the one returned by thread_create. + * + * Other potential solutions would be: + * - define thrd_t as a thread Ids, but this would mean we'd need to OpenThread for many operations + * - use malloc'ed memory for thrd_t. This would imply using TLS for current thread. + * + * Neither is particularly nice. + * + * Life would be much easier if C11 threads had different abstractions for + * threads and thread IDs, just like C++11 threads does... + */ + +bRet = DuplicateHandle(GetCurrentProcess(), // source process (pseudo) handle + GetCurrentThread(), // source (pseudo) handle + GetCurrentProcess(), // target process + hCurrentThread, // target handle + 0, + FALSE, + DUPLICATE_SAME_ACCESS); +assert(bRet); +if (!bRet) { + hCurrentThread = GetCurrentThread(); +} +return hCurrentThread; } +#endif // 7.25.5.3 static inline int @@ -511,7 +541,7 @@ thrd_detach(thrd_t thr) static inline int thrd_equal(thrd_t thr0, thrd_t thr1) { -return (thr0 == thr1); +return GetThreadId(thr0) == GetThreadId(thr1); } // 7.25.5.5 -- 1.8.5.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] trace: Re-license trace.xsl under MIT license.
From: José Fonseca jfons...@vmware.com I was the sole author, as Tungsten Graphics employee, which was since then acquired by VMware Inc. --- src/gallium/drivers/trace/trace.xsl | 36 ++-- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/gallium/drivers/trace/trace.xsl b/src/gallium/drivers/trace/trace.xsl index 7be95e0..12458ae 100644 --- a/src/gallium/drivers/trace/trace.xsl +++ b/src/gallium/drivers/trace/trace.xsl @@ -2,20 +2,28 @@ !-- -Copyright 2008 Tungsten Graphics, Inc. - -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU Lesser General Public License as published -by the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this program. If not, see http://www.gnu.org/licenses/. +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 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. !-- -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 7/7] c11: Make TIME_UTC a conditional macro.
From: José Fonseca jfons...@vmware.com Some system headers already define it, so this prevents conflict. --- include/c11/threads.h | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/c11/threads.h b/include/c11/threads.h index 678774c..4a4079d 100644 --- a/include/c11/threads.h +++ b/include/c11/threads.h @@ -10,6 +10,10 @@ #include time.h +#ifndef TIME_UTC +#define TIME_UTC 1 +#endif + #include c99_compat.h /* for `inline` */ /* types */ @@ -39,8 +43,6 @@ enum { thrd_nomem// out of memory }; -enum { TIME_UTC = 1 }; - /*-- functions --*/ #if defined(_WIN32) !defined(__CYGWIN__) -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/7] c11: Import threads.h emulation library.
From: José Fonseca jfons...@vmware.com Implementation is based of https://gist.github.com/2223710 with the following modifications: - inline implementatation - retain XP compatability - add temporary hack for static mutex initializers (as they are not part of the stack but still widely used internally). --- include/c11/threads.h | 56 + include/c11/threads_posix.h | 346 ++ include/c11/threads_win32.h | 588 3 files changed, 990 insertions(+) create mode 100644 include/c11/threads.h create mode 100644 include/c11/threads_posix.h create mode 100644 include/c11/threads_win32.h diff --git a/include/c11/threads.h b/include/c11/threads.h new file mode 100644 index 000..678774c --- /dev/null +++ b/include/c11/threads.h @@ -0,0 +1,56 @@ +/* + * C11 threads.h emulation library + * + * (C) Copyright yohhoy 2012. + * Distributed under the Boost Software License, Version 1.0. + * (See copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#ifndef EMULATED_THREADS_H_INCLUDED_ +#define EMULATED_THREADS_H_INCLUDED_ + +#include time.h + +#include c99_compat.h /* for `inline` */ + +/* types */ +typedef void (*tss_dtor_t)(void*); +typedef int (*thrd_start_t)(void*); + +struct xtime { +time_t sec; +long nsec; +}; +typedef struct xtime xtime; + + +/* enumeration constants */ +enum { +mtx_plain = 0, +mtx_try = 1, +mtx_timed = 2, +mtx_recursive = 4 +}; + +enum { +thrd_success = 0, // succeeded +thrd_timeout, // timeout +thrd_error, // failed +thrd_busy,// resource busy +thrd_nomem// out of memory +}; + +enum { TIME_UTC = 1 }; + +/*-- functions --*/ + +#if defined(_WIN32) !defined(__CYGWIN__) +#include threads_win32.h +#elif defined(__unix__) || defined(__unix) +#include threads_posix.h +#else +#error Not supported on this platform. +#endif + + + +#endif /* EMULATED_THREADS_H_INCLUDED_ */ diff --git a/include/c11/threads_posix.h b/include/c11/threads_posix.h new file mode 100644 index 000..463c93f --- /dev/null +++ b/include/c11/threads_posix.h @@ -0,0 +1,346 @@ +/* + * C11 threads.h emulation library + * + * (C) Copyright yohhoy 2012. + * Distributed under the Boost Software License, Version 1.0. + * (See copy at http://www.boost.org/LICENSE_1_0.txt) + */ +#include stdlib.h +#include assert.h +#include limits.h +#include errno.h +#include unistd.h +#include sched.h +#include stdint.h /* for intptr_t */ + +/* +Configuration macro: + + EMULATED_THREADS_USE_NATIVE_TIMEDLOCK +Use pthread_mutex_timedlock() for `mtx_timedlock()' +Otherwise use mtx_trylock() + *busy loop* emulation. +*/ +#if !defined(__CYGWIN__) +#define EMULATED_THREADS_USE_NATIVE_TIMEDLOCK +#endif + + +#include pthread.h + +/* macros */ +#define ONCE_FLAG_INIT PTHREAD_ONCE_INIT +#ifdef INIT_ONCE_STATIC_INIT +#define TSS_DTOR_ITERATIONS PTHREAD_DESTRUCTOR_ITERATIONS +#else +#define TSS_DTOR_ITERATIONS 1 // assume TSS dtor MAY be called at least once. +#endif + +// FIXME: temporary non-standard hack to ease transition +#define _MTX_INITIALIZER_NP PTHREAD_MUTEX_INITIALIZER + +/* types */ +typedef pthread_cond_t cnd_t; +typedef pthread_t thrd_t; +typedef pthread_key_t tss_t; +typedef pthread_mutex_t mtx_t; +typedef pthread_once_t once_flag; + + +/* +Implementation limits: + - Conditionally emulation for mutex with timeout +(see EMULATED_THREADS_USE_NATIVE_TIMEDLOCK macro) +*/ +struct impl_thrd_param { +thrd_start_t func; +void *arg; +}; + +static inline void * +impl_thrd_routine(void *p) +{ +struct impl_thrd_param pack = *((struct impl_thrd_param *)p); +free(p); +return (void*)(intptr_t)pack.func(pack.arg); +} + + +/*--- 7.25.2 Initialization functions ---*/ +// 7.25.2.1 +static inline void +call_once(once_flag *flag, void (*func)(void)) +{ +pthread_once(flag, func); +} + + +/*- 7.25.3 Condition variable functions -*/ +// 7.25.3.1 +static inline int +cnd_broadcast(cnd_t *cond) +{ +if (!cond) return thrd_error; +pthread_cond_broadcast(cond); +return thrd_success; +} + +// 7.25.3.2 +static inline void +cnd_destroy(cnd_t *cond) +{ +assert(cond); +pthread_cond_destroy(cond); +} + +// 7.25.3.3 +static inline int +cnd_init(cnd_t *cond) +{ +if (!cond) return thrd_error; +pthread_cond_init(cond, NULL); +return thrd_success; +} + +// 7.25.3.4 +static inline int +cnd_signal(cnd_t *cond) +{ +if (!cond) return thrd_error; +pthread_cond_signal(cond); +return thrd_success; +} + +// 7.25.3.5 +static inline int +cnd_timedwait(cnd_t *cond, mtx_t *mtx, const xtime *xt) +{ +struct timespec abs_time; +int rt; +
[Mesa-dev] [PATCH 5/7] egl: Use C11 thread abstractions.
From: José Fonseca jfons...@vmware.com --- src/egl/main/eglmutex.h | 26 +++--- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/src/egl/main/eglmutex.h b/src/egl/main/eglmutex.h index 1349e9e..2ec965c 100644 --- a/src/egl/main/eglmutex.h +++ b/src/egl/main/eglmutex.h @@ -31,46 +31,34 @@ #include eglcompiler.h -#ifdef HAVE_PTHREAD -#include pthread.h +#include c11/threads.h -typedef pthread_mutex_t _EGLMutex; +typedef mtx_t _EGLMutex; static INLINE void _eglInitMutex(_EGLMutex *m) { - pthread_mutex_init(m, NULL); + mtx_init(m, mtx_plain); } static INLINE void _eglDestroyMutex(_EGLMutex *m) { - pthread_mutex_destroy(m); + mtx_destroy(m); } static INLINE void _eglLockMutex(_EGLMutex *m) { - pthread_mutex_lock(m); + mtx_lock(m); } static INLINE void _eglUnlockMutex(_EGLMutex *m) { - pthread_mutex_unlock(m); + mtx_unlock(m); } -#define _EGL_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER +#define _EGL_MUTEX_INITIALIZER _MTX_INITIALIZER_NP -#else - -typedef int _EGLMutex; -static INLINE void _eglInitMutex(_EGLMutex *m) { (void) m; } -static INLINE void _eglDestroyMutex(_EGLMutex *m) { (void) m; } -static INLINE void _eglLockMutex(_EGLMutex *m) { (void) m; } -static INLINE void _eglUnlockMutex(_EGLMutex *m) { (void) m; } - -#define _EGL_MUTEX_INITIALIZER 0 - -#endif #endif /* EGLMUTEX_INCLUDED */ -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/7] mapi: Use C11 thread abstractions.
From: José Fonseca jfons...@vmware.com --- src/mapi/u_thread.h | 165 +--- 1 file changed, 13 insertions(+), 152 deletions(-) diff --git a/src/mapi/u_thread.h b/src/mapi/u_thread.h index 31999c4..75fbec6 100644 --- a/src/mapi/u_thread.h +++ b/src/mapi/u_thread.h @@ -46,12 +46,7 @@ #include stdlib.h #include u_compiler.h -#if defined(HAVE_PTHREAD) -#include pthread.h /* POSIX threads headers */ -#endif -#ifdef _WIN32 -#include windows.h -#endif +#include c11/threads.h #if defined(HAVE_PTHREAD) || defined(_WIN32) #ifndef THREADS @@ -79,43 +74,32 @@ extern C { #endif -/* - * POSIX threads. This should be your choice in the Unix world - * whenever possible. When building with POSIX threads, be sure - * to enable any compiler flags which will cause the MT-safe - * libc (if one exists) to be used when linking, as well as any - * header macros for MT-safe errno, etc. For Solaris, this is the -mt - * compiler flag. On Solaris with gcc, use -D_REENTRANT to enable - * proper compiling for MT-safe libc etc. - */ -#if defined(HAVE_PTHREAD) - struct u_tsd { - pthread_key_t key; + tss_t key; unsigned initMagic; }; -typedef pthread_mutex_t u_mutex; +typedef mtx_t u_mutex; #define u_mutex_declare_static(name) \ - static u_mutex name = PTHREAD_MUTEX_INITIALIZER + static u_mutex name = _MTX_INITIALIZER_NP -#define u_mutex_init(name)pthread_mutex_init((name), NULL) -#define u_mutex_destroy(name) pthread_mutex_destroy((name)) -#define u_mutex_lock(name)(void) pthread_mutex_lock((name)) -#define u_mutex_unlock(name) (void) pthread_mutex_unlock((name)) +#define u_mutex_init(name)mtx_init((name), mtx_plain) +#define u_mutex_destroy(name) mtx_destroy((name)) +#define u_mutex_lock(name)(void) mtx_lock((name)) +#define u_mutex_unlock(name) (void) mtx_unlock((name)) static INLINE unsigned long u_thread_self(void) { - return (unsigned long) pthread_self(); + return (unsigned long) thrd_current(); } static INLINE void u_tsd_init(struct u_tsd *tsd) { - if (pthread_key_create(tsd-key, NULL/*free*/) != 0) { + if (tss_create(tsd-key, NULL/*free*/) != 0) { perror(INIT_TSD_ERROR); exit(-1); } @@ -129,7 +113,7 @@ u_tsd_get(struct u_tsd *tsd) if (tsd-initMagic != INIT_MAGIC) { u_tsd_init(tsd); } - return pthread_getspecific(tsd-key); + return tss_get(tsd-key); } @@ -139,56 +123,12 @@ u_tsd_set(struct u_tsd *tsd, void *ptr) if (tsd-initMagic != INIT_MAGIC) { u_tsd_init(tsd); } - if (pthread_setspecific(tsd-key, ptr) != 0) { + if (tss_set(tsd-key, ptr) != 0) { perror(SET_TSD_ERROR); exit(-1); } } -#endif /* HAVE_PTHREAD */ - - -/* - * Windows threads. Should work with Windows NT and 95. - * IMPORTANT: Link with multithreaded runtime library when THREADS are - * used! - */ -#ifdef _WIN32 - -struct u_tsd { - DWORD key; - unsigned initMagic; -}; - -typedef CRITICAL_SECTION u_mutex; - -/* http://locklessinc.com/articles/pthreads_on_windows/ */ -#define u_mutex_declare_static(name) \ - static u_mutex name = {(PCRITICAL_SECTION_DEBUG)-1, -1, 0, 0, 0, 0} - -#define u_mutex_init(name)InitializeCriticalSection(name) -#define u_mutex_destroy(name) DeleteCriticalSection(name) -#define u_mutex_lock(name)EnterCriticalSection(name) -#define u_mutex_unlock(name) LeaveCriticalSection(name) - -static INLINE unsigned long -u_thread_self(void) -{ - return GetCurrentThreadId(); -} - - -static INLINE void -u_tsd_init(struct u_tsd *tsd) -{ - tsd-key = TlsAlloc(); - if (tsd-key == TLS_OUT_OF_INDEXES) { - perror(INIT_TSD_ERROR); - exit(-1); - } - tsd-initMagic = INIT_MAGIC; -} - static INLINE void u_tsd_destroy(struct u_tsd *tsd) @@ -196,90 +136,11 @@ u_tsd_destroy(struct u_tsd *tsd) if (tsd-initMagic != INIT_MAGIC) { return; } - TlsFree(tsd-key); + tss_delete(tsd-key); tsd-initMagic = 0x0; } -static INLINE void * -u_tsd_get(struct u_tsd *tsd) -{ - if (tsd-initMagic != INIT_MAGIC) { - u_tsd_init(tsd); - } - return TlsGetValue(tsd-key); -} - - -static INLINE void -u_tsd_set(struct u_tsd *tsd, void *ptr) -{ - /* the following code assumes that the struct u_tsd has been initialized - to zero at creation */ - if (tsd-initMagic != INIT_MAGIC) { - u_tsd_init(tsd); - } - if (TlsSetValue(tsd-key, ptr) == 0) { - perror(SET_TSD_ERROR); - exit(-1); - } -} - -#endif /* _WIN32 */ - - -/* - * THREADS not defined - */ -#ifndef THREADS - -struct u_tsd { - unsigned initMagic; -}; - -typedef unsigned u_mutex; - -#define u_mutex_declare_static(name) static u_mutex name = 0 -#define u_mutex_init(name) (void) name -#define u_mutex_destroy(name) (void) name -#define u_mutex_lock(name) (void) name -#define u_mutex_unlock(name) (void) name - -/* - * no-op functions - */ - -static INLINE unsigned long -u_thread_self(void) -{ -
[Mesa-dev] [PATCH 1/7] os: Remove pipe_static_condvar.
From: José Fonseca jfons...@vmware.com Never used. --- src/gallium/auxiliary/os/os_thread.h | 12 1 file changed, 12 deletions(-) diff --git a/src/gallium/auxiliary/os/os_thread.h b/src/gallium/auxiliary/os/os_thread.h index 4528abb..d16f36d 100644 --- a/src/gallium/auxiliary/os/os_thread.h +++ b/src/gallium/auxiliary/os/os_thread.h @@ -105,9 +105,6 @@ typedef pthread_mutex_t pipe_mutex; */ typedef pthread_cond_t pipe_condvar; -#define pipe_static_condvar(mutex) \ - static pipe_condvar mutex = PTHREAD_COND_INITIALIZER - #define pipe_condvar_init(cond)\ pthread_cond_init((cond), NULL) @@ -187,9 +184,6 @@ typedef CRITICAL_SECTION pipe_mutex; */ typedef CONDITION_VARIABLE pipe_condvar; -#define pipe_static_condvar(cond) \ - /*static*/ pipe_condvar cond = CONDITION_VARIABLE_INIT - #define pipe_condvar_init(cond) \ InitializeConditionVariable((cond)) @@ -213,9 +207,6 @@ typedef CONDITION_VARIABLE pipe_condvar; */ typedef DWORD pipe_condvar; -#define pipe_static_condvar(cond) \ - /*static*/ pipe_condvar cond = 1 - #define pipe_condvar_init(cond) \ (void) (cond = 1) @@ -284,9 +275,6 @@ typedef unsigned pipe_mutex; typedef int64_t pipe_condvar; -#define pipe_static_condvar(condvar) \ - static pipe_condvar condvar = 1000 - #define pipe_condvar_init(condvar) \ (void) (condvar = 1000) -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 6/7] rbug: Update for PIPE_THREAD_ROUTINE returning 0.
From: José Fonseca jfons...@vmware.com --- src/gallium/drivers/rbug/rbug_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/rbug/rbug_core.c b/src/gallium/drivers/rbug/rbug_core.c index 7cc9f79..c5b26b8 100644 --- a/src/gallium/drivers/rbug/rbug_core.c +++ b/src/gallium/drivers/rbug/rbug_core.c @@ -810,7 +810,7 @@ PIPE_THREAD_ROUTINE(rbug_thread, void_tr_rbug) if (s 0) { debug_printf(rbug_rbug - failed to listen\n); - return NULL; + return 0; } u_socket_block(s, false); -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/7] gallium: Use C11 threads.h.
From: José Fonseca jfons...@vmware.com Note that PIPE_ROUTINE now returns an int. --- src/gallium/auxiliary/os/os_thread.h | 262 +++--- src/gallium/drivers/llvmpipe/lp_rast.c| 2 +- src/gallium/drivers/rbug/rbug_core.c | 2 +- src/gallium/tests/unit/pipe_barrier_test.c| 2 +- src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 2 +- 5 files changed, 36 insertions(+), 234 deletions(-) diff --git a/src/gallium/auxiliary/os/os_thread.h b/src/gallium/auxiliary/os/os_thread.h index d16f36d..aae40c2 100644 --- a/src/gallium/auxiliary/os/os_thread.h +++ b/src/gallium/auxiliary/os/os_thread.h @@ -40,271 +40,97 @@ #include pipe/p_compiler.h #include util/u_debug.h /* for assert */ +#include c11/threads.h -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_CYGWIN) || defined(PIPE_OS_HURD) - -#include pthread.h /* POSIX threads headers */ -#include stdio.h /* for perror() */ +#ifdef HAVE_PTHREAD #include signal.h +#endif /* pipe_thread */ -typedef pthread_t pipe_thread; +typedef thrd_t pipe_thread; #define PIPE_THREAD_ROUTINE( name, param ) \ - void *name( void *param ) + int name( void *param ) -static INLINE pipe_thread pipe_thread_create( void *(* routine)( void *), void *param ) +static INLINE pipe_thread pipe_thread_create( PIPE_THREAD_ROUTINE((*routine), ), void *param ) { pipe_thread thread; +#ifdef HAVE_PTHREAD sigset_t saved_set, new_set; int ret; sigfillset(new_set); pthread_sigmask(SIG_SETMASK, new_set, saved_set); - ret = pthread_create( thread, NULL, routine, param ); + ret = thrd_create( thread, routine, param ); pthread_sigmask(SIG_SETMASK, saved_set, NULL); +#else + int ret; + ret = thrd_create( thread, routine, param ); +#endif if (ret) return 0; + return thread; } static INLINE int pipe_thread_wait( pipe_thread thread ) { - return pthread_join( thread, NULL ); + return thrd_join( thread, NULL ); } static INLINE int pipe_thread_destroy( pipe_thread thread ) { - return pthread_detach( thread ); + return thrd_detach( thread ); } /* pipe_mutex */ -typedef pthread_mutex_t pipe_mutex; +typedef mtx_t pipe_mutex; #define pipe_static_mutex(mutex) \ - static pipe_mutex mutex = PTHREAD_MUTEX_INITIALIZER + static pipe_mutex mutex = _MTX_INITIALIZER_NP #define pipe_mutex_init(mutex) \ - (void) pthread_mutex_init((mutex), NULL) + (void) mtx_init((mutex), mtx_plain) #define pipe_mutex_destroy(mutex) \ - pthread_mutex_destroy((mutex)) + mtx_destroy((mutex)) #define pipe_mutex_lock(mutex) \ - (void) pthread_mutex_lock((mutex)) + (void) mtx_lock((mutex)) #define pipe_mutex_unlock(mutex) \ - (void) pthread_mutex_unlock((mutex)) + (void) mtx_unlock((mutex)) /* pipe_condvar */ -typedef pthread_cond_t pipe_condvar; +typedef cnd_t pipe_condvar; #define pipe_condvar_init(cond)\ - pthread_cond_init((cond), NULL) - -#define pipe_condvar_destroy(cond) \ - pthread_cond_destroy((cond)) - -#define pipe_condvar_wait(cond, mutex) \ - pthread_cond_wait((cond), (mutex)) - -#define pipe_condvar_signal(cond) \ - pthread_cond_signal((cond)) - -#define pipe_condvar_broadcast(cond) \ - pthread_cond_broadcast((cond)) - - - -#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) - -#include windows.h - -/* pipe_thread - */ -typedef HANDLE pipe_thread; - -#define PIPE_THREAD_ROUTINE( name, param ) \ - void * WINAPI name( void *param ) - -static INLINE pipe_thread pipe_thread_create( void *(WINAPI * routine)( void *), void *param ) -{ - DWORD id; - return CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE) routine, param, 0, id ); -} - -static INLINE int pipe_thread_wait( pipe_thread thread ) -{ - if (WaitForSingleObject( thread, INFINITE ) == WAIT_OBJECT_0) - return 0; - return -1; -} - -static INLINE int pipe_thread_destroy( pipe_thread thread ) -{ - if (CloseHandle( thread )) - return 0; - return -1; -} - - -/* pipe_mutex - */ -typedef CRITICAL_SECTION pipe_mutex; - -/* http://locklessinc.com/articles/pthreads_on_windows/ */ -#define pipe_static_mutex(mutex) \ - static pipe_mutex mutex = {(PCRITICAL_SECTION_DEBUG)-1, -1, 0, 0, 0, 0} - -#define pipe_mutex_init(mutex) \ - InitializeCriticalSection(mutex) - -#define pipe_mutex_destroy(mutex) \ - DeleteCriticalSection(mutex) - -#define pipe_mutex_lock(mutex) \ - EnterCriticalSection(mutex) - -#define pipe_mutex_unlock(mutex) \ - LeaveCriticalSection(mutex) - -/* TODO: Need a macro to declare I don't care about WinXP compatibilty */ -#if 0 defined (_WIN32_WINNT) (_WIN32_WINNT = 0x0600) -/* CONDITION_VARIABLE is only available on newer versions of Windows - * (Server 2008/Vista or later). - * http://msdn.microsoft.com/en-us/library/ms682052(VS.85).aspx - * - * pipe_condvar - */ -typedef CONDITION_VARIABLE pipe_condvar; - -#define
[Mesa-dev] [PATCH 1/2] demos/pixeltest: Remove Line struct.
From: José Fonseca jfons...@vmware.com Not really used/necessary. --- src/demos/pixeltest.c | 113 +++--- 1 file changed, 52 insertions(+), 61 deletions(-) diff --git a/src/demos/pixeltest.c b/src/demos/pixeltest.c index e9b95b8..0898290 100644 --- a/src/demos/pixeltest.c +++ b/src/demos/pixeltest.c @@ -21,24 +21,16 @@ static int WinWidth, WinHeight; static int APosX, APosY; /* simple drawpixels */ static int BPosX, BPosY; /* read/draw pixels */ int MouseButton, MouseY, MouseX; /* mouse control */ -float x0offset = 0.0f; /* for line translation */ -float y0offset = 0.0f; -float x1offset = 0.0f; -float y1offset = 0.0f; +float X0 = 0.0f; /* for line translation */ +float Y0 = 0.0f; +float X1 = 0.0f; +float Y1 = 0.0f; float width = 1.0f; -struct Line{ - float x0; - float y0; - float x1; - float y1; -}; - #define STEP 16 /* subpixel resolution 1/STEP */ #define SIZE 128/* of non-zoomed drawing region */ #define ZOOM 32 /* scale factor for zooming */ -struct Line line; static GLboolean DrawFront = GL_FALSE; GLushort TempImage[SIZE][SIZE]; /* original 128 by 128 pixel image */ GLushort myImage[SIZE*ZOOM][SIZE*ZOOM]; /* zoom by a factor of 32 */ @@ -177,32 +169,32 @@ drawMagnifiedView(void) } /* Draws the actual line on zoomed version */ - drawline(line.x0+x0offset+APosX-MouseX, line.y0+y0offset+APosY-MouseY, -line.x1+x1offset+APosX-MouseX, line.y1+y1offset+APosY-MouseY, 0); + drawline(X0+APosX-MouseX, Y0+APosY-MouseY, +X1+APosX-MouseX, Y1+APosY-MouseY, 0); /* Draws bounding line area */ - if (fabsf(line.x0 + x0offset - line.x1 - x1offset) = - fabsf(line.y0 + y0offset - line.y1 - y1offset)) { + if (fabsf(X0 - X1) = + fabsf(Y0 - Y1)) { /* X-MAJOR line */ - drawline(line.x0+x0offset+APosX-MouseX, line.y0+y0offset+APosY-MouseY+halfwidth, - line.x1+x1offset+APosX-MouseX, line.y1+y1offset+APosY-MouseY+halfwidth, 0x); - drawline(line.x0+x0offset+APosX-MouseX, line.y0+y0offset+APosY-MouseY-halfwidth, - line.x1+x1offset+APosX-MouseX, line.y1+y1offset+APosY-MouseY-halfwidth, 0x); - drawline(line.x0+x0offset+APosX-MouseX, line.y0+y0offset+APosY-MouseY+halfwidth, - line.x0+x0offset+APosX-MouseX, line.y0+y0offset+APosY-MouseY-halfwidth, 0x); - drawline(line.x1+x1offset+APosX-MouseX, line.y1+y1offset+APosY-MouseY+halfwidth, - line.x1+x1offset+APosX-MouseX, line.y1+y1offset+APosY-MouseY-halfwidth, 0x); + drawline(X0+APosX-MouseX, Y0+APosY-MouseY+halfwidth, + X1+APosX-MouseX, Y1+APosY-MouseY+halfwidth, 0x); + drawline(X0+APosX-MouseX, Y0+APosY-MouseY-halfwidth, + X1+APosX-MouseX, Y1+APosY-MouseY-halfwidth, 0x); + drawline(X0+APosX-MouseX, Y0+APosY-MouseY+halfwidth, + X0+APosX-MouseX, Y0+APosY-MouseY-halfwidth, 0x); + drawline(X1+APosX-MouseX, Y1+APosY-MouseY+halfwidth, + X1+APosX-MouseX, Y1+APosY-MouseY-halfwidth, 0x); } else { /* Y-MAJOR line */ - drawline(line.x0+x0offset+APosX-MouseX+halfwidth, line.y0+y0offset+APosY-MouseY, - line.x1+x1offset+APosX-MouseX+halfwidth, line.y1+y1offset+APosY-MouseY, 0x); - drawline(line.x0+x0offset+APosX-MouseX-halfwidth, line.y0+y0offset+APosY-MouseY, - line.x1+x1offset+APosX-MouseX-halfwidth, line.y1+y1offset+APosY-MouseY, 0x); - drawline(line.x0+x0offset+APosX-MouseX+halfwidth, line.y0+y0offset+APosY-MouseY, - line.x0+x0offset+APosX-MouseX-halfwidth, line.y0+y0offset+APosY-MouseY, 0x); - drawline(line.x1+x1offset+APosX-MouseX+halfwidth, line.y1+y1offset+APosY-MouseY, - line.x1+x1offset+APosX-MouseX-halfwidth, line.y1+y1offset+APosY-MouseY, 0x); + drawline(X0+APosX-MouseX+halfwidth, Y0+APosY-MouseY, + X1+APosX-MouseX+halfwidth, Y1+APosY-MouseY, 0x); + drawline(X0+APosX-MouseX-halfwidth, Y0+APosY-MouseY, + X1+APosX-MouseX-halfwidth, Y1+APosY-MouseY, 0x); + drawline(X0+APosX-MouseX+halfwidth, Y0+APosY-MouseY, + X0+APosX-MouseX-halfwidth, Y0+APosY-MouseY, 0x); + drawline(X1+APosX-MouseX+halfwidth, Y1+APosY-MouseY, + X1+APosX-MouseX-halfwidth, Y1+APosY-MouseY, 0x); } } @@ -211,6 +203,11 @@ Display( void ) { float z = 0; + printf((%f, %f) - (%f, %f), width = %f\n, +X0, Y0, +X1, Y1, +width); + glClearColor(.3, .3, .3, 1); glClear( GL_COLOR_BUFFER_BIT ); @@ -238,9 +235,9 @@ Display( void ) glLineWidth(width); glBegin(GL_LINES); glColor3f(.8,0,0); - glVertex3f(line.x0+x0offset, line.y0+y0offset, z); + glVertex3f(X0, Y0, z); glColor3f(0,.9,0); - glVertex3f(line.x1+x1offset,
[Mesa-dev] [PATCH 2/2] demos/pixeltest: Adapt the example for points too.
From: José Fonseca jfons...@vmware.com This example is very useful to understand the rasterization of lines. And with this change, points too. Adding a key / command-line option to switch modes is left for a future opportunity though. --- src/demos/pixeltest.c | 109 -- 1 file changed, 69 insertions(+), 40 deletions(-) diff --git a/src/demos/pixeltest.c b/src/demos/pixeltest.c index 0898290..0b6a580 100644 --- a/src/demos/pixeltest.c +++ b/src/demos/pixeltest.c @@ -31,6 +31,10 @@ float width = 1.0f; #define SIZE 128/* of non-zoomed drawing region */ #define ZOOM 32 /* scale factor for zooming */ +// TODO: Allow to switch mode via key and/or command-line option. +//GLenum mode = GL_POINT; +GLenum mode = GL_LINE; + static GLboolean DrawFront = GL_FALSE; GLushort TempImage[SIZE][SIZE]; /* original 128 by 128 pixel image */ GLushort myImage[SIZE*ZOOM][SIZE*ZOOM]; /* zoom by a factor of 32 */ @@ -168,33 +172,48 @@ drawMagnifiedView(void) } } - /* Draws the actual line on zoomed version */ - drawline(X0+APosX-MouseX, Y0+APosY-MouseY, -X1+APosX-MouseX, Y1+APosY-MouseY, 0); - - /* Draws bounding line area */ - if (fabsf(X0 - X1) = - fabsf(Y0 - Y1)) { - /* X-MAJOR line */ - drawline(X0+APosX-MouseX, Y0+APosY-MouseY+halfwidth, - X1+APosX-MouseX, Y1+APosY-MouseY+halfwidth, 0x); - drawline(X0+APosX-MouseX, Y0+APosY-MouseY-halfwidth, - X1+APosX-MouseX, Y1+APosY-MouseY-halfwidth, 0x); - drawline(X0+APosX-MouseX, Y0+APosY-MouseY+halfwidth, - X0+APosX-MouseX, Y0+APosY-MouseY-halfwidth, 0x); - drawline(X1+APosX-MouseX, Y1+APosY-MouseY+halfwidth, - X1+APosX-MouseX, Y1+APosY-MouseY-halfwidth, 0x); - } - else { - /* Y-MAJOR line */ - drawline(X0+APosX-MouseX+halfwidth, Y0+APosY-MouseY, - X1+APosX-MouseX+halfwidth, Y1+APosY-MouseY, 0x); - drawline(X0+APosX-MouseX-halfwidth, Y0+APosY-MouseY, - X1+APosX-MouseX-halfwidth, Y1+APosY-MouseY, 0x); - drawline(X0+APosX-MouseX+halfwidth, Y0+APosY-MouseY, - X0+APosX-MouseX-halfwidth, Y0+APosY-MouseY, 0x); - drawline(X1+APosX-MouseX+halfwidth, Y1+APosY-MouseY, - X1+APosX-MouseX-halfwidth, Y1+APosY-MouseY, 0x); + switch (mode) { + case GL_POINT: + /* Draws bounding point area */ + drawline(X0+APosX-MouseX-halfwidth, Y0+APosY-MouseY-halfwidth, + X0+APosX-MouseX+halfwidth, Y0+APosY-MouseY-halfwidth, 0x); + drawline(X0+APosX-MouseX+halfwidth, Y0+APosY-MouseY-halfwidth, + X0+APosX-MouseX+halfwidth, Y0+APosY-MouseY+halfwidth, 0x); + drawline(X0+APosX-MouseX+halfwidth, Y0+APosY-MouseY+halfwidth, + X0+APosX-MouseX-halfwidth, Y0+APosY-MouseY+halfwidth, 0x); + drawline(X0+APosX-MouseX-halfwidth, Y0+APosY-MouseY+halfwidth, + X0+APosX-MouseX-halfwidth, Y0+APosY-MouseY-halfwidth, 0x); + break; + case GL_LINE: + /* Draws the actual line on zoomed version */ + drawline(X0+APosX-MouseX, Y0+APosY-MouseY, + X1+APosX-MouseX, Y1+APosY-MouseY, 0); + + /* Draws bounding line area */ + if (fabsf(X0 - X1) = + fabsf(Y0 - Y1)) { +/* X-MAJOR line */ +drawline(X0+APosX-MouseX, Y0+APosY-MouseY+halfwidth, + X1+APosX-MouseX, Y1+APosY-MouseY+halfwidth, 0x); +drawline(X0+APosX-MouseX, Y0+APosY-MouseY-halfwidth, + X1+APosX-MouseX, Y1+APosY-MouseY-halfwidth, 0x); +drawline(X0+APosX-MouseX, Y0+APosY-MouseY+halfwidth, + X0+APosX-MouseX, Y0+APosY-MouseY-halfwidth, 0x); +drawline(X1+APosX-MouseX, Y1+APosY-MouseY+halfwidth, + X1+APosX-MouseX, Y1+APosY-MouseY-halfwidth, 0x); + } + else { +/* Y-MAJOR line */ +drawline(X0+APosX-MouseX+halfwidth, Y0+APosY-MouseY, + X1+APosX-MouseX+halfwidth, Y1+APosY-MouseY, 0x); +drawline(X0+APosX-MouseX-halfwidth, Y0+APosY-MouseY, + X1+APosX-MouseX-halfwidth, Y1+APosY-MouseY, 0x); +drawline(X0+APosX-MouseX+halfwidth, Y0+APosY-MouseY, + X0+APosX-MouseX-halfwidth, Y0+APosY-MouseY, 0x); +drawline(X1+APosX-MouseX+halfwidth, Y1+APosY-MouseY, + X1+APosX-MouseX-halfwidth, Y1+APosY-MouseY, 0x); + } + break; } } @@ -203,11 +222,6 @@ Display( void ) { float z = 0; - printf((%f, %f) - (%f, %f), width = %f\n, -X0, Y0, -X1, Y1, -width); - glClearColor(.3, .3, .3, 1); glClear( GL_COLOR_BUFFER_BIT ); @@ -230,16 +244,31 @@ Display( void ) glVertex3f(150, 0, z); glEnd(); - /* Original line + /* Original geometry */ - glLineWidth(width); - glBegin(GL_LINES); -
[Mesa-dev] [PATCH] llvmpipe: Honour pipe_rasterizer::point_quad_rasterization.
From: José Fonseca jfons...@vmware.com Commit eda21d2a3010d9fc5a68b55a843c5e44b2abf8dd fixed the rasterization of points for Direct3D but ended up breaking the rasterization of OpenGL non-sprite points, in particular conform's pntrast.c test. The only way to get both working is to properly honour pipe_rasterizer::point_quad_rasterization, and follow the weird OpenGL rule when it is false. --- src/gallium/drivers/llvmpipe/lp_setup_point.c | 64 ++- 1 file changed, 54 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_setup_point.c b/src/gallium/drivers/llvmpipe/lp_setup_point.c index 988e0c5..e5ce4ee 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup_point.c +++ b/src/gallium/drivers/llvmpipe/lp_setup_point.c @@ -338,9 +338,13 @@ try_setup_point( struct lp_setup_context *setup, int fixed_width = MAX2(FIXED_ONE, (subpixel_snap(size) + FIXED_ONE/2 - 1) ~(FIXED_ONE-1)); - const int x0 = subpixel_snap(v0[0][0] - setup-pixel_offset) - fixed_width/2; - const int y0 = subpixel_snap(v0[0][1] - setup-pixel_offset) - fixed_width/2; - + /* Yes this is necessary to accurately calculate bounding boxes +* with the two fill-conventions we support. GL (normally) ends +* up needing a bottom-left fill convention, which requires +* slightly different rounding. +*/ + int adj = (setup-bottom_edge_rule != 0) ? 1 : 0; + struct lp_scene *scene = setup-scene; struct lp_rast_triangle *point; unsigned bytes; @@ -363,13 +367,14 @@ try_setup_point( struct lp_setup_context *setup, print_point(setup, v0); /* Bounding rectangle (in pixels) */ - { - /* Yes this is necessary to accurately calculate bounding boxes - * with the two fill-conventions we support. GL (normally) ends - * up needing a bottom-left fill convention, which requires - * slightly different rounding. + if (!lp_context-rasterizer || + lp_context-rasterizer-point_quad_rasterization) { + /* + * Rasterize points as quads. */ - int adj = (setup-bottom_edge_rule != 0) ? 1 : 0; + + const int x0 = subpixel_snap(v0[0][0] - setup-pixel_offset) - fixed_width/2; + const int y0 = subpixel_snap(v0[0][1] - setup-pixel_offset) - fixed_width/2; bbox.x0 = (x0 + (FIXED_ONE-1)) FIXED_ORDER; bbox.x1 = (x0 + fixed_width + (FIXED_ONE-1)) FIXED_ORDER; @@ -380,8 +385,47 @@ try_setup_point( struct lp_setup_context *setup, */ bbox.x1--; bbox.y1--; + } else { + /* + * OpenGL rasterization rules for non-sprite points. + * + * Per OpenGL 2.1 spec, section 3.3.1, Basic Point Rasterization. + */ + + const int x0 = subpixel_snap(v0[0][0]); + const int y0 = subpixel_snap(v0[0][1]) - adj; + + int int_width = fixed_width FIXED_ORDER; + + assert(setup-pixel_offset != 0); + + if (int_width == 1) { + bbox.x0 = x0 FIXED_ORDER; + bbox.y0 = y0 FIXED_ORDER; + bbox.x1 = bbox.x0; + bbox.y1 = bbox.y0; + } else { + if (int_width 1) { +/* Odd width */ +bbox.x0 = (x0 FIXED_ORDER) - (int_width - 1)/2; +bbox.y0 = (y0 FIXED_ORDER) - (int_width - 1)/2; + } else { +/* Even width */ +bbox.x0 = ((x0 + FIXED_ONE/2) FIXED_ORDER) - int_width/2; +bbox.y0 = ((y0 + FIXED_ONE/2) FIXED_ORDER) - int_width/2; + } + + bbox.x1 = bbox.x0 + int_width - 1; + bbox.y1 = bbox.y0 + int_width - 1; + } } - + + if (0) { + debug_printf( bbox: (%i, %i) - (%i, %i)\n, + bbox.x0, bbox.y0, + bbox.x1, bbox.y1); + } + if (!u_rect_test_intersection(setup-draw_regions[viewport_index], bbox)) { if (0) debug_printf(offscreen\n); LP_COUNT(nr_culled_tris); -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] trace: Dump PIPE_QUERY_* enums.
From: José Fonseca jfons...@vmware.com --- src/gallium/auxiliary/util/u_dump.h | 3 ++ src/gallium/auxiliary/util/u_dump_defines.c | 33 src/gallium/drivers/trace/tr_context.c | 3 +- src/gallium/drivers/trace/tr_dump_defines.h | 58 + src/gallium/drivers/trace/tr_dump_state.c | 10 + src/gallium/drivers/trace/tr_dump_state.h | 3 -- src/gallium/drivers/trace/tr_screen.c | 3 +- 7 files changed, 98 insertions(+), 15 deletions(-) create mode 100644 src/gallium/drivers/trace/tr_dump_defines.h diff --git a/src/gallium/auxiliary/util/u_dump.h b/src/gallium/auxiliary/util/u_dump.h index 71750a6..58e7dfd 100644 --- a/src/gallium/auxiliary/util/u_dump.h +++ b/src/gallium/auxiliary/util/u_dump.h @@ -85,6 +85,9 @@ util_dump_tex_mipfilter(unsigned value, boolean shortened); const char * util_dump_tex_filter(unsigned value, boolean shortened); +const char * +util_dump_query_type(unsigned value, boolean shortened); + /* * p_state.h, through a FILE diff --git a/src/gallium/auxiliary/util/u_dump_defines.c b/src/gallium/auxiliary/util/u_dump_defines.c index cc62687..03fd15d 100644 --- a/src/gallium/auxiliary/util/u_dump_defines.c +++ b/src/gallium/auxiliary/util/u_dump_defines.c @@ -359,3 +359,36 @@ util_dump_tex_filter_short_names[] = { }; DEFINE_UTIL_DUMP_CONTINUOUS(tex_filter) + + +static const char * +util_dump_query_type_names[] = { + PIPE_QUERY_OCCLUSION_COUNTER, + PIPE_QUERY_OCCLUSION_PREDICATE, + PIPE_QUERY_TIMESTAMP, + PIPE_QUERY_TIMESTAMP_DISJOINT, + PIPE_QUERY_TIME_ELAPSED, + PIPE_QUERY_PRIMITIVES_GENERATED, + PIPE_QUERY_PRIMITIVES_EMITTED, + PIPE_QUERY_SO_STATISTICS, + PIPE_QUERY_SO_OVERFLOW_PREDICATE, + PIPE_QUERY_GPU_FINISHED, + PIPE_QUERY_PIPELINE_STATISTICS, +}; + +static const char * +util_dump_query_type_short_names[] = { + occlusion_counter, + occlusion_predicate, + timestamp, + timestamp_disjoint, + time_elapsed, + primitives_generated, + primitives_emitted, + so_statistics, + so_overflow_predicate, + gpu_finished, + pipeline_statistics, +}; + +DEFINE_UTIL_DUMP_CONTINUOUS(query_type) diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index d9afb0a..4ac7d9b 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -33,6 +33,7 @@ #include pipe/p_screen.h #include tr_dump.h +#include tr_dump_defines.h #include tr_dump_state.h #include tr_public.h #include tr_screen.h @@ -135,7 +136,7 @@ trace_context_create_query(struct pipe_context *_pipe, trace_dump_call_begin(pipe_context, create_query); trace_dump_arg(ptr, pipe); - trace_dump_arg(uint, query_type); + trace_dump_arg(query_type, query_type); query = pipe-create_query(pipe, query_type); diff --git a/src/gallium/drivers/trace/tr_dump_defines.h b/src/gallium/drivers/trace/tr_dump_defines.h new file mode 100644 index 000..0c83c2b --- /dev/null +++ b/src/gallium/drivers/trace/tr_dump_defines.h @@ -0,0 +1,58 @@ +/** + * + * Copyright 2013 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 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. + * + **/ + +#ifndef TR_DUMP_DEFINES_H_ +#define TR_DUMP_DEFINES_H_ + +#include pipe/p_compiler.h +#include util/u_format.h +#include util/u_dump.h +#include tr_dump.h + + +static INLINE void +trace_dump_format(enum pipe_format format) +{ + if (!trace_dumping_enabled_locked()) + return; + + trace_dump_enum(util_format_name(format)); +} + + +static INLINE void +trace_dump_query_type(unsigned value) +{ + if (!trace_dumping_enabled_locked()) + return; + + trace_dump_enum(util_dump_query_type(value, FALSE)); +} + + + +#endif /* TR_DUMP_DEFINES_H_ */ diff --git
[Mesa-dev] [PATCH] docs: Add a section with recommended reading for llvmpipe development.
From: José Fonseca jfons...@vmware.com Several links contributed by Keith Whitwell and Roland Scheidegger. --- docs/llvmpipe.html | 58 -- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/docs/llvmpipe.html b/docs/llvmpipe.html index 80f8a01..d695907 100644 --- a/docs/llvmpipe.html +++ b/docs/llvmpipe.html @@ -203,11 +203,65 @@ for posterior analysis, e.g.: We use LLVM-C bindings for now. They are not documented, but follow the C++ interfaces very closely, and appear to be complete enough for code generation. See - http://npcontemplation.blogspot.com/2008/06/secret-of-llvm-c-bindings.html - for a stand-alone example. See the llvm-c/Core.h file for reference. + a href=http://npcontemplation.blogspot.com/2008/06/secret-of-llvm-c-bindings.html; + this stand-alone example/a. See the llvm-c/Core.h file for reference. /li /ul +h1 id=recommended_readingRecommended Reading/h1 + +ul + li +pRasterization/p +ul + lia href=http://www.cs.unc.edu/~olano/papers/2dh-tri/;Triangle Scan Conversion using 2D Homogeneous Coordinates/a/li + lia href=http://www.drdobbs.com/parallel/rasterization-on-larrabee/217200602;Rasterization on Larrabee/a (a href=http://devmaster.net/posts/2887/rasterization-on-larrabee;DevMaster copy/a)/li + lia href=http://devmaster.net/posts/6133/rasterization-using-half-space-functions;Rasterization using half-space functions/a/li + lia href=http://devmaster.net/posts/6145/advanced-rasterization;Advanced Rasterization/a/li + lia href=http://fgiesen.wordpress.com/2013/02/17/optimizing-sw-occlusion-culling-index/;Optimizing Software Occlusion Culling/a/li +/ul + /li + li +pTexture sampling/p +ul + lia href=http://chrishecker.com/Miscellaneous_Technical_Articles#Perspective_Texture_Mapping;Perspective Texture Mapping/a/li + lia href=http://www.flipcode.com/archives/Texturing_As_In_Unreal.shtml;Texturing As In Unreal/a/li + lia href=http://www.gamasutra.com/view/feature/3301/runtime_mipmap_filtering.php;Run-Time MIP-Map Filtering/a/li + lia href=http://alt.3dcenter.org/artikel/2003/10-26_a_english.php;Will brilinear filtering persist?/a/li + lia href=http://ixbtlabs.com/articles2/gffx/nv40-rx800-3.html;Trilinear filtering/a/li + lia href=http://devmaster.net/posts/12785/texture-swizzling;Texture Swizzling/a/li +/ul + /li + li +pSIMD/p +ul + lia href=http://www.cdl.uni-saarland.de/projects/wfv/#header4;Whole-Function Vectorization/a/li +/ul + /li + li +pOptimization/p +ul + lia href=http://www.drdobbs.com/optimizing-pixomatic-for-modern-x86-proc/184405807;Optimizing Pixomatic For Modern x86 Processors/a/li + lia href=http://www.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-optimization-manual.html;Intel 64 and IA-32 Architectures Optimization Reference Manual/a/li + lia href=http://www.agner.org/optimize/;Software optimization resources/a/li + lia href=http://software.intel.com/en-us/articles/intel-intrinsics-guide;Intel Intrinsics Guide/ali +/ul + /li + li +pLLVM/p +ul + lia href=http://llvm.org/docs/LangRef.html;LLVM Language Reference Manual/a/li + lia href=http://npcontemplation.blogspot.co.uk/2008/06/secret-of-llvm-c-bindings.html;The secret of LLVM C bindings/a/li +/ul + /li + li +pMisc/p +ul + lia href=http://msdn.microsoft.com/en-us/library/gg615082.aspx#architecture;WARP Architecture and Performance/a/li +/ul + /li +/ul + /div /body /html -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] tgsi_ureg: Refactor the ureg_* inline so that all variables are pre-declared.
From: José Fonseca jfons...@vmware.com Mere syntactical change. --- src/gallium/auxiliary/tgsi/tgsi_ureg.h | 200 + 1 file changed, 104 insertions(+), 96 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h index e104cd9..cf0c75e 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h @@ -564,18 +564,19 @@ ureg_fixup_insn_size(struct ureg_program *ureg, static INLINE void ureg_##op( struct ureg_program *ureg ) \ { \ unsigned opcode = TGSI_OPCODE_##op; \ - unsigned insn = ureg_emit_insn(ureg, \ - opcode, \ - FALSE,\ - FALSE,\ - FALSE,\ - TGSI_SWIZZLE_X, \ - TGSI_SWIZZLE_Y, \ - TGSI_SWIZZLE_Z, \ - TGSI_SWIZZLE_W, \ - 0,\ - 0).insn_token;\ - ureg_fixup_insn_size( ureg, insn ); \ + struct ureg_emit_insn_result insn; \ + insn = ureg_emit_insn(ureg, \ + opcode,\ + FALSE, \ + FALSE, \ + FALSE, \ + TGSI_SWIZZLE_X,\ + TGSI_SWIZZLE_Y,\ + TGSI_SWIZZLE_Z,\ + TGSI_SWIZZLE_W,\ + 0, \ + 0);\ + ureg_fixup_insn_size( ureg, insn.insn_token ); \ } #define OP01( op ) \ @@ -583,19 +584,20 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \ struct ureg_src src ) \ { \ unsigned opcode = TGSI_OPCODE_##op; \ - unsigned insn = ureg_emit_insn(ureg, \ - opcode, \ - FALSE,\ - FALSE,\ - FALSE,\ - TGSI_SWIZZLE_X, \ - TGSI_SWIZZLE_Y, \ - TGSI_SWIZZLE_Z, \ - TGSI_SWIZZLE_W, \ - 0,\ - 1).insn_token;\ + struct ureg_emit_insn_result insn; \ + insn = ureg_emit_insn(ureg, \ + opcode,\ + FALSE, \ + FALSE, \ + FALSE, \ + TGSI_SWIZZLE_X,\ + TGSI_SWIZZLE_Y,\ + TGSI_SWIZZLE_Z,\ + TGSI_SWIZZLE_W,\ + 0, \ + 1);\ ureg_emit_src( ureg, src ); \ - ureg_fixup_insn_size( ureg, insn ); \ + ureg_fixup_insn_size( ureg, insn.insn_token ); \ } #define OP00_LBL( op ) \ @@ -647,19 +649,20 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \ struct ureg_dst dst ) \ { \ unsigned opcode = TGSI_OPCODE_##op; \ - unsigned insn = ureg_emit_insn(ureg, \ - opcode,
[Mesa-dev] [PATCH 2/2] tgsi: Prevent emission of instructions with empty writemask.
From: José Fonseca jfons...@vmware.com These degenerate instructions can often be emitted by state trackers when the semantics of instructions don't match precisely. --- src/gallium/auxiliary/tgsi/tgsi_ureg.c | 8 src/gallium/auxiliary/tgsi/tgsi_ureg.h | 22 ++ 2 files changed, 30 insertions(+) diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index 432ed00..f06858e 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -1113,6 +1113,10 @@ ureg_insn(struct ureg_program *ureg, boolean negate = FALSE; unsigned swizzle[4] = { 0 }; + if (nr_dst ureg_dst_is_empty(dst[0])) { + return; + } + saturate = nr_dst ? dst[0].Saturate : FALSE; predicate = nr_dst ? dst[0].Predicate : FALSE; if (predicate) { @@ -1162,6 +1166,10 @@ ureg_tex_insn(struct ureg_program *ureg, boolean negate = FALSE; unsigned swizzle[4] = { 0 }; + if (nr_dst ureg_dst_is_empty(dst[0])) { + return; + } + saturate = nr_dst ? dst[0].Saturate : FALSE; predicate = nr_dst ? dst[0].Predicate : FALSE; if (predicate) { diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h index cf0c75e..d973edb 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h @@ -454,6 +454,16 @@ ureg_imm1i( struct ureg_program *ureg, return ureg_DECL_immediate_int( ureg, a, 1 ); } +/* Where the destination register has a valid file, but an empty + * writemask. + */ +static INLINE boolean +ureg_dst_is_empty( struct ureg_dst dst ) +{ + return dst.File != TGSI_FILE_NULL + dst.WriteMask == 0; +} + /*** * Functions for patching up labels */ @@ -650,6 +660,7 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \ { \ unsigned opcode = TGSI_OPCODE_##op; \ struct ureg_emit_insn_result insn; \ + if (ureg_dst_is_empty(dst)) return; \ insn = ureg_emit_insn(ureg, \ opcode,\ dst.Saturate, \ @@ -673,6 +684,7 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \ { \ unsigned opcode = TGSI_OPCODE_##op; \ struct ureg_emit_insn_result insn; \ + if (ureg_dst_is_empty(dst)) return; \ insn = ureg_emit_insn(ureg, \ opcode,\ dst.Saturate, \ @@ -697,6 +709,7 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \ { \ unsigned opcode = TGSI_OPCODE_##op; \ struct ureg_emit_insn_result insn; \ + if (ureg_dst_is_empty(dst)) return; \ insn = ureg_emit_insn(ureg, \ opcode,\ dst.Saturate, \ @@ -723,6 +736,7 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \ { \ unsigned opcode = TGSI_OPCODE_##op; \ struct ureg_emit_insn_result insn; \ + if (ureg_dst_is_empty(dst)) return; \ insn = ureg_emit_insn(ureg, \ opcode,\ dst.Saturate, \ @@ -750,6 +764,7 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \ unsigned opcode = TGSI_OPCODE_##op; \ unsigned target = TGSI_TEXTURE_UNKNOWN; \ struct ureg_emit_insn_result insn; \ + if (ureg_dst_is_empty(dst)) return; \ insn = ureg_emit_insn(ureg, \ opcode,\ dst.Saturate, \ @@ -777,6 +792,7 @@ static INLINE void ureg_##op(
[Mesa-dev] [PATCH] gallium: Make TGSI_SEMANTIC_FOG register four-component wide.
From: José Fonseca jfons...@vmware.com D3D9 Shader Model 2 restricted the fog register to one component, http://msdn.microsoft.com/en-us/library/windows/desktop/bb172945.aspx , but that restriction no longer exists in Shader Model 3, and several WHCK tests enforce that. So this change: - lifts the single-component restriction TGSI_SEMANTIC_FOG from Gallium interface - updates the Mesa state tracker to enforce output fog has (f, 0, 0, 1) - draw module was updated to leave TGSI_SEMANTIC_FOG output registers alone Several gallium drivers that are going out of their way to clear TGSI_SEMANTIC_FOG components could be simplified in the future. Thanks to Si Chen and Michal Krol for identifying the problem. Testing done: piglit fogcoord-*.vpfp tests --- src/gallium/auxiliary/draw/draw_llvm.c | 6 -- src/gallium/auxiliary/draw/draw_vs_exec.c | 7 +-- src/gallium/docs/source/tgsi.rst | 10 +++--- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 7 +++ src/mesa/state_tracker/st_mesa_to_tgsi.c | 7 +++ 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index fe49b86..71cc45f 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -659,12 +659,6 @@ generate_vs(struct draw_llvm_variant *variant, LLVMBuildStore(builder, out, outputs[attrib][chan]); } break; - case TGSI_SEMANTIC_FOG: - if (chan == 1 || chan == 2) - LLVMBuildStore(builder, bld.zero, outputs[attrib][chan]); - else if (chan == 3) - LLVMBuildStore(builder, bld.one, outputs[attrib][chan]); - break; } } } diff --git a/src/gallium/auxiliary/draw/draw_vs_exec.c b/src/gallium/auxiliary/draw/draw_vs_exec.c index 6100394..83cc5fd 100644 --- a/src/gallium/auxiliary/draw/draw_vs_exec.c +++ b/src/gallium/auxiliary/draw/draw_vs_exec.c @@ -167,12 +167,7 @@ vs_exec_run_linear( struct draw_vertex_shader *shader, output[slot][2] = CLAMP(machine-Outputs[slot].xyzw[2].f[j], 0.0f, 1.0f); output[slot][3] = CLAMP(machine-Outputs[slot].xyzw[3].f[j], 0.0f, 1.0f); } -else if (name == TGSI_SEMANTIC_FOG) { - output[slot][0] = machine-Outputs[slot].xyzw[0].f[j]; - output[slot][1] = 0; - output[slot][2] = 0; - output[slot][3] = 1; - } else +else { output[slot][0] = machine-Outputs[slot].xyzw[0].f[j]; output[slot][1] = machine-Outputs[slot].xyzw[1].f[j]; diff --git a/src/gallium/docs/source/tgsi.rst b/src/gallium/docs/source/tgsi.rst index f80c08d..1070619 100644 --- a/src/gallium/docs/source/tgsi.rst +++ b/src/gallium/docs/source/tgsi.rst @@ -2420,13 +2420,9 @@ TGSI_SEMANTIC_FOG Vertex shader inputs and outputs and fragment shader inputs may be labeled with TGSI_SEMANTIC_FOG to indicate that the register contains -a fog coordinate in the form (F, 0, 0, 1). Typically, the fragment -shader will use the fog coordinate to compute a fog blend factor which -is used to blend the normal fragment color with a constant fog color. - -Only the first component matters when writing from the vertex shader; -the driver will ensure that the coordinate is in this format when used -as a fragment shader input. +a fog coordinate. Typically, the fragment shader will use the fog coordinate +to compute a fog blend factor which is used to blend the normal fragment color +with a constant fog color. TGSI_SEMANTIC_PSIZE diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 6319079..74b3e5b 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -4889,6 +4889,13 @@ st_translate_program( t-outputs[i] = ureg_DECL_output(ureg, outputSemanticName[i], outputSemanticIndex[i]); + if (outputSemanticName[i] == TGSI_SEMANTIC_FOG) { +/* force register to contain a fog coordinate in the form (F, 0, 0, 1). */ +ureg_MOV(ureg, + ureg_writemask(t-outputs[i], TGSI_WRITEMASK_XYZW ~TGSI_WRITEMASK_X), + ureg_imm4f(ureg, 0.0f, 0.0f, 0.0f, 1.0f)); +t-outputs[i] = ureg_writemask(t-outputs[i], TGSI_WRITEMASK_X); +} } if (passthrough_edgeflags) emit_edgeflags(t); diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 921b0f9..7d79c62 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -1121,6 +1121,13 @@ st_translate_mesa_program(
[Mesa-dev] [PATCH] tgsi_exec: Fix mask calculation for emit_kill_if.
From: José Fonseca jfons...@vmware.com Same as Si Chen's commit e7a5905d8a3960b0981750f8131e3af9acbfcdb8 for tgsi_exec module. Not actually tested, because softpipe is failing the test that caught this bug due to unrelated issues. --- src/gallium/auxiliary/tgsi/tgsi_exec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 6db1238..b614907 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -1610,6 +1610,9 @@ exec_kill_if(struct tgsi_exec_machine *mach, kilmask |= 1 i; } + /* restrict to fragments currently executing */ + kilmask = mach-ExecMask; + mach-Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] |= kilmask; } -- 1.8.3.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] u_gen_mipmap: Use untampered cubemap texture coords when generating mipmaps.
From: José Fonseca jfons...@vmware.com It's not necessary to scale down cubemap texture coords when generating mipmaps: we are doing a 2x minification therefore it's guaranteed that the texture coords will always be at least 1 texel away of the edges. Scaling down can actually be harmful, as it may cause artefacts when generating mipmaps with nearest filtering. Sample points will lie exactly in the middle each 2x2 texels, so the scaling factor was causing different texels to be take on each quadrant of the cube face. This is apparent with a 1x1 checkerboard pattern in the base mipmap level: instead of next mipmap level receiving a constant color throughout the face, it will have different colors for each quadrant of the face. The behaviour for blits is left untouched for now, but the cubemap texture coord scaling hack should be reconsidered eventually. --- src/gallium/auxiliary/util/u_blit.c | 3 ++- src/gallium/auxiliary/util/u_blitter.c| 3 ++- src/gallium/auxiliary/util/u_gen_mipmap.c | 3 ++- src/gallium/auxiliary/util/u_texture.c| 11 +-- src/gallium/auxiliary/util/u_texture.h| 5 - 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index 4ba71b9..595287d 100644 --- a/src/gallium/auxiliary/util/u_blit.c +++ b/src/gallium/auxiliary/util/u_blit.c @@ -272,7 +272,8 @@ setup_vertex_data_tex(struct blit_state *ctx, const unsigned stride = sizeof ctx-vertices[0] / sizeof ctx-vertices[0][0][0]; util_map_texcoords2d_onto_cubemap(src_face, ctx-vertices[0][1][0], stride, -ctx-vertices[0][1][0], stride); +ctx-vertices[0][1][0], stride, +TRUE); } offset = get_next_slot( ctx ); diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 096d3bc..b95cbab 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -659,7 +659,8 @@ static void blitter_set_texcoords(struct blitter_context_priv *ctx, util_map_texcoords2d_onto_cubemap(layer % 6, /* pointer, stride in floats */ face_coord[0][0], 2, -ctx-vertices[0][1][0], 8); +ctx-vertices[0][1][0], 8, +TRUE); } else { set_texcoords_in_vertices(coord, ctx-vertices[0][1][0], 8); } diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index a885f2b..84bf30f 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -1409,7 +1409,8 @@ set_vertex_data(struct gen_mipmap_state *ctx, }; util_map_texcoords2d_onto_cubemap(layer, st[0][0], 2, -ctx-vertices[0][1][0], 8); +ctx-vertices[0][1][0], 8, +FALSE); } else if (tex_target == PIPE_TEXTURE_1D_ARRAY) { /* 1D texture array */ diff --git a/src/gallium/auxiliary/util/u_texture.c b/src/gallium/auxiliary/util/u_texture.c index d97e57a..e865f8e 100644 --- a/src/gallium/auxiliary/util/u_texture.c +++ b/src/gallium/auxiliary/util/u_texture.c @@ -42,7 +42,8 @@ void util_map_texcoords2d_onto_cubemap(unsigned face, const float *in_st, unsigned in_stride, - float *out_str, unsigned out_stride) + float *out_str, unsigned out_stride, + boolean allow_scale) { int i; float rx, ry, rz; @@ -52,8 +53,14 @@ void util_map_texcoords2d_onto_cubemap(unsigned face, /* Compute sc = +/-scale and tc = +/-scale. * Not +/-1 to avoid cube face selection ambiguity near the edges, * though that can still sometimes happen with this scale factor... + * + * XXX: Yep, there is no safe scale factor that will prevent sampling + * the neighbouring face when stretching out. A more reliable solution + * would be to clamp (sc, tc) against +/- 1.0-1.0/mipsize, in the shader. + * + * Also, this is not necessary when minifying, or 1:1 blits. */ - const float scale = 0.f; + const float scale = allow_scale ? 0.f : 1.0f; const float sc = (2 * in_st[0] - 1) * scale; const float tc = (2 * in_st[1] - 1) * scale; diff --git a/src/gallium/auxiliary/util/u_texture.h b/src/gallium/auxiliary/util/u_texture.h index 93b2f1e..b1c8c70 100644 --- a/src/gallium/auxiliary/util/u_texture.h +++ b/src/gallium/auxiliary/util/u_texture.h @@ -27,6 +27,8 @@ #ifndef U_TEXTURE_H #define