[Mesa-dev] [PATCH 1/2] mesa: set CORE profile by default
a) Per the OpenGL 3.2 spec, this is the default value unless the user overrides it at context creation; b) The client can't query this state until Mesa exposes OpenGL 3.2 anyway, so it doesn't really matter yet. --- src/mesa/main/context.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 243053e..18a9ac8 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -661,8 +661,8 @@ _mesa_init_constants(struct gl_context *ctx) ctx-Const.MaxUniformBlockSize = 16384; ctx-Const.UniformBufferOffsetAlignment = 1; - /* GL 3.2: hard-coded for now: */ - ctx-Const.ProfileMask = GL_CONTEXT_COMPATIBILITY_PROFILE_BIT; + /* GL 3.2: per GLX_ARB_create_context_profile, the default is 'core'. */ + ctx-Const.ProfileMask = GL_CONTEXT_CORE_PROFILE_BIT; /** GL_EXT_gpu_shader4 */ ctx-Const.MinProgramTexelOffset = -8; -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] mesa: add _mesa_feature_removed() helper
And a more trivial _mesa_feature_deprecated(). --- src/mesa/main/context.c | 29 + src/mesa/main/context.h | 14 ++ 2 files changed, 43 insertions(+) diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 18a9ac8..1a025e8 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1897,5 +1897,34 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where) return GL_TRUE; } +GLboolean +_mesa_feature_removed(struct gl_context *ctx, int deprecated, int removed) +{ + int version = ctx-VersionMajor * 10 + ctx-VersionMinor; + + /* Has not been deprecated or removed in this version. */ + if (version deprecated) + return GL_FALSE; + /* Has been deprecated, and removed since this is a forward-compatible + context. */ + if (ctx-Const.ContextFlags GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT) + return GL_TRUE; + /* Has not been removed from any core GL version yet. */ + if (removed == 0) + return GL_FALSE; + /* Has been deprecated, but not removed in this version, and this is + not a forward-compatible context, so it's still present. */ + if (version removed) + return GL_FALSE; + /* Has been removed in this version, but this is a compatibility + context, which restores removed features. */ + if (ctx-Const.ProfileMask GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) + return GL_FALSE; + + /* Has been removed in this version, and this is a core context. */ + assert(ctx-Const.ProfileMask GL_CONTEXT_CORE_PROFILE_BIT); + return GL_TRUE; +} + /*@}*/ diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index a66dd50..169dde0 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -165,6 +165,20 @@ extern GLboolean _mesa_valid_to_render(struct gl_context *ctx, const char *where); +static inline GLboolean +_mesa_feature_deprecated(struct gl_context *ctx, int deprecated) +{ + int version = ctx-VersionMajor * 10 + ctx-VersionMinor; + + /* Has been deprecated or removed in this version. */ + if (version = deprecated) + return GL_TRUE; + return GL_FALSE; +} + +extern GLboolean +_mesa_feature_removed(struct gl_context *ctx, int deprecated, int removed); + /** \name Miscellaneous */ /*@{*/ -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2 7/7] mesa: don't enable legacy GL functions when using API_OPENGL_CORE
On Fri, Jul 27, 2012 at 6:43 AM, Jordan Justen jordan.l.jus...@intel.com wrote: Signed-off-by: Jordan Justen jordan.l.jus...@intel.com --- src/mesa/main/api_exec.c | 227 -- src/mesa/main/api_exec.h |3 +- src/mesa/main/context.c |2 +- src/mesa/main/vtxfmt.c | 167 ++ 4 files changed, 232 insertions(+), 167 deletions(-) Adding this whole new enum seems like a lot of unnecessary code everywhere in the previous 6 patches -- I just sent out a patch with a function that checks the same thing (I wrote it a while ago trying to work on some of this but didn't get around to testing it), and you can just replace all if (ctx-API != API_OPENGL_CORE) with if (!_mesa_feature_removed(ctx, 30, 31)) For all these instances of stuff that was deprecated in 3.0 and removed in 3.1. (Some other small features were only deprecated in later versions.) ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] mapi: share sources.mak with Android again
This (sort of) reverts commit 5154b45217695e5daf24110bcff043fa1959d0a5 mapi: Fix Android build --- src/mapi/Android.mk | 12 +--- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/mapi/Android.mk b/src/mapi/Android.mk index d1749a2..9d54210 100644 --- a/src/mapi/Android.mk +++ b/src/mapi/Android.mk @@ -25,6 +25,10 @@ LOCAL_PATH := $(call my-dir) +# LOCAL_SRC_FILES must only contain relative paths. +MAPI := ./mapi +include $(LOCAL_PATH)/mapi/sources.mak + mapi_abi_headers := # --- @@ -35,13 +39,7 @@ include $(CLEAR_VARS) abi_header := shared-glapi/glapi_mapi_tmp.h -LOCAL_SRC_FILES := \ - mapi/entry.c \ - mapi/mapi_glapi.c \ - mapi/stub.c \ - mapi/table.c \ - mapi/u_current.c \ - mapi/u_execmem.c +LOCAL_SRC_FILES := $(MAPI_GLAPI_FILES) LOCAL_CFLAGS := \ -DMAPI_MODE_GLAPI \ -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/4] mapi: use a path prefix for sources variable
This makes it possible to share sources.mak with the Android build again. v2: Keep $(TOP) variable that is actually used by an included Makefile. --- src/mapi/glapi/Makefile.am|5 +++-- src/mapi/mapi/sources.mak | 25 ++--- src/mapi/shared-glapi/Makefile.am |7 +-- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/mapi/glapi/Makefile.am b/src/mapi/glapi/Makefile.am index 668d7fa..b6c4345 100644 --- a/src/mapi/glapi/Makefile.am +++ b/src/mapi/glapi/Makefile.am @@ -19,9 +19,10 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. -TOP = $(top_srcdir) include sources.mak -include ../mapi/sources.mak + +MAPI = $(srcdir)/../mapi +include $(MAPI)/sources.mak AM_CPPFLAGS = \ $(DEFINES) \ diff --git a/src/mapi/mapi/sources.mak b/src/mapi/mapi/sources.mak index 56f4afd..6c15170 100644 --- a/src/mapi/mapi/sources.mak +++ b/src/mapi/mapi/sources.mak @@ -13,24 +13,27 @@ # # - In bridge mode, mapi provides entry points calling into glapi. To use #this mode, compile MAPI_BRIDGE_FILES with MAPI_MODE_BRIDGE defined. +# +# The variable $(MAPI) must be defined to point to this source directory +# before the following variables can be used. MAPI_UTIL_FILES = \ - $(TOP)/src/mapi/mapi/u_current.c \ - $(TOP)/src/mapi/mapi/u_execmem.c + $(MAPI)/u_current.c \ + $(MAPI)/u_execmem.c MAPI_FILES = \ - $(TOP)/src/mapi/mapi/entry.c \ - $(TOP)/src/mapi/mapi/mapi.c \ - $(TOP)/src/mapi/mapi/stub.c \ - $(TOP)/src/mapi/mapi/table.c \ + $(MAPI)/entry.c \ + $(MAPI)/mapi.c \ + $(MAPI)/stub.c \ + $(MAPI)/table.c \ $(MAPI_UTIL_FILES) MAPI_GLAPI_FILES = \ - $(TOP)/src/mapi/mapi/entry.c \ - $(TOP)/src/mapi/mapi/mapi_glapi.c \ - $(TOP)/src/mapi/mapi/stub.c \ - $(TOP)/src/mapi/mapi/table.c \ + $(MAPI)/entry.c \ + $(MAPI)/mapi_glapi.c \ + $(MAPI)/stub.c \ + $(MAPI)/table.c \ $(MAPI_UTIL_FILES) MAPI_BRIDGE_FILES = \ - $(TOP)/src/mapi/mapi/entry.c + $(MAPI)/entry.c diff --git a/src/mapi/shared-glapi/Makefile.am b/src/mapi/shared-glapi/Makefile.am index 9485683..de958f6 100644 --- a/src/mapi/shared-glapi/Makefile.am +++ b/src/mapi/shared-glapi/Makefile.am @@ -1,13 +1,16 @@ # Used by OpenGL ES or when --enable-shared-glapi is specified -TOP = $(top_srcdir) GLAPI = $(top_srcdir)/src/mapi/glapi -include $(top_srcdir)/src/mapi/mapi/sources.mak +MAPI = $(top_srcdir)/src/mapi/mapi + +include $(MAPI)/sources.mak lib_LTLIBRARIES = libglapi.la libglapi_la_SOURCES = $(MAPI_GLAPI_FILES) libglapi_la_LDFLAGS = -no-undefined +# FIXME: eliminate the use of $(TOP) +TOP = $(top_srcdir) include $(GLAPI)/gen/glapi_gen.mk glapi_mapi_tmp.h : $(GLAPI)/gen/gl_and_es_API.xml $(glapi_gen_mapi_deps) $(call glapi_gen_mapi,$,shared-glapi) -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/4] autoconf: add $(TOP_SRCDIR) substitution
Useful while the static Makefiles are still alive. --- configs/current.in |4 +++- configure.ac | 15 ++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/configs/current.in b/configs/current.in index dc0dea8..ea926d5 100644 --- a/configs/current.in +++ b/configs/current.in @@ -1,7 +1,9 @@ # Autoconf configuration +TOP_SRCDIR = @TOP_SRCDIR@ + # Pull in the defaults -include $(TOP)/configs/default +include $(TOP_SRCDIR)/configs/default # This is generated by configure CONFIG_NAME = autoconf diff --git a/configure.ac b/configure.ac index 1d60957..344d054 100644 --- a/configure.ac +++ b/configure.ac @@ -13,9 +13,22 @@ AC_CANONICAL_HOST AM_INIT_AUTOMAKE([foreign]) dnl http://people.gnome.org/~walters/docs/build-api.txt -dnl We don't support srcdir != builddir. +dnl We don't support srcdir != builddir yet. echo \#buildapi-variable-no-builddir /dev/null +dnl This is for the sake of the static Makefiles until they're +dnl finally gone for good. +TOP_SRCDIR=$srcdir +case $TOP_SRCDIR in +[\\/]*) +dnl Path is already absolute. +;; +*) +TOP_SRCDIR=$ac_pwd/$TOP_SRCDIR +;; +esac +AC_SUBST(TOP_SRCDIR) + # Support silent build rules, requires at least automake-1.11. Disable # by either passing --disable-silent-rules to configure or passing V=1 # to make -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/4] mapi: drop use of $(TOP)
Use $(TOP_SRCDIR) in the static Makefile, but use a more specific variable for glapi_gen.mk now. --- src/mapi/es1api/Makefile |4 ++-- src/mapi/glapi/gen/glapi_gen.mk | 14 +++--- src/mapi/shared-glapi/Makefile.am |2 -- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/mapi/es1api/Makefile b/src/mapi/es1api/Makefile index a9c9123..91ae815 100644 --- a/src/mapi/es1api/Makefile +++ b/src/mapi/es1api/Makefile @@ -32,8 +32,8 @@ endif ESAPI = $(ES)api -GLAPI := $(TOP)/src/mapi/glapi -MAPI := $(TOP)/src/mapi/mapi +GLAPI := $(TOP_SRCDIR)/src/mapi/glapi +MAPI := $(TOP_SRCDIR)/src/mapi/mapi esapi_CPPFLAGS := \ -I$(TOP)/include \ diff --git a/src/mapi/glapi/gen/glapi_gen.mk b/src/mapi/glapi/gen/glapi_gen.mk index 1b05a40..fdc7e19 100644 --- a/src/mapi/glapi/gen/glapi_gen.mk +++ b/src/mapi/glapi/gen/glapi_gen.mk @@ -1,14 +1,14 @@ # Helpers for glapi header generation -ifndef TOP -$(error TOP must be defined.) +ifndef GLAPI +$(error GLAPI must be defined to point to src/mapi/glapi) endif glapi_gen_common_deps := \ - $(wildcard $(TOP)/src/mapi/glapi/gen/*.xml) \ - $(wildcard $(TOP)/src/mapi/glapi/gen/*.py) + $(wildcard $(GLAPI)/gen/*.xml) \ + $(wildcard $(GLAPI)/gen/*.py) -glapi_gen_mapi_script := $(TOP)/src/mapi/mapi/mapi_abi.py +glapi_gen_mapi_script := $(GLAPI)/../mapi/mapi_abi.py glapi_gen_mapi_deps := \ $(glapi_gen_mapi_script) \ $(glapi_gen_common_deps) @@ -21,7 +21,7 @@ $(AM_V_GEN)$(PYTHON2) $(PYTHON_FLAGS) $(glapi_gen_mapi_script) \ --mode lib --printer $(2) $(1) $@ endef -glapi_gen_dispatch_script := $(TOP)/src/mapi/glapi/gen/gl_table.py +glapi_gen_dispatch_script := $(GLAPI)/gen/gl_table.py glapi_gen_dispatch_deps := $(glapi_gen_common_deps) # $(1): path to an XML file @@ -32,7 +32,7 @@ $(AM_V_GEN)$(PYTHON2) $(PYTHON_FLAGS) $(glapi_gen_dispatch_script) \ -f $(1) -m remap_table $(if $(2),-c $(2),) $@ endef -glapi_gen_remap_script := $(TOP)/src/mapi/glapi/gen/remap_helper.py +glapi_gen_remap_script := $(GLAPI)/gen/remap_helper.py glapi_gen_remap_deps := $(glapi_gen_common_deps) # $(1): path to an XML file diff --git a/src/mapi/shared-glapi/Makefile.am b/src/mapi/shared-glapi/Makefile.am index de958f6..db68683 100644 --- a/src/mapi/shared-glapi/Makefile.am +++ b/src/mapi/shared-glapi/Makefile.am @@ -9,8 +9,6 @@ lib_LTLIBRARIES = libglapi.la libglapi_la_SOURCES = $(MAPI_GLAPI_FILES) libglapi_la_LDFLAGS = -no-undefined -# FIXME: eliminate the use of $(TOP) -TOP = $(top_srcdir) include $(GLAPI)/gen/glapi_gen.mk glapi_mapi_tmp.h : $(GLAPI)/gen/gl_and_es_API.xml $(glapi_gen_mapi_deps) $(call glapi_gen_mapi,$,shared-glapi) -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/9] automake: convert libOSmesa building
On Mon, Jul 9, 2012 at 11:41 AM, Jon TURNEY jon.tur...@dronecode.org.uk wrote: From: Laurent Carlier lordhea...@gmail.com This also currently fix the installation of libOSmesa. v2: Remove old Makefile, libOSmesa is now versioned, fix typos v3: Keep config substitution alphabetized v4: Update .gitignore Reviewed-by: Jon TURNEY jon.tur...@dronecode.org.uk --- configure.ac|5 +++ src/mesa/drivers/osmesa/.gitignore |1 + src/mesa/drivers/osmesa/Makefile| 51 --- src/mesa/drivers/osmesa/Makefile.am | 50 ++ 4 files changed, 56 insertions(+), 51 deletions(-) create mode 100644 src/mesa/drivers/osmesa/.gitignore delete mode 100644 src/mesa/drivers/osmesa/Makefile create mode 100644 src/mesa/drivers/osmesa/Makefile.am diff --git a/configure.ac b/configure.ac index 46265a2..e5ac791 100644 --- a/configure.ac +++ b/configure.ac @@ -1370,10 +1370,14 @@ if test x$enable_osmesa = xyes; then OSMESA_MESA_DEPS= OSMESA_PC_LIB_PRIV=-lm -lpthread $SELINUX_LIBS $DLOPEN_LIBS fi + +OSMESA_VERSION=`echo $VERSION | $SED 's/\./:/g'` + AC_SUBST([OSMESA_LIB_DEPS]) AC_SUBST([OSMESA_MESA_DEPS]) AC_SUBST([OSMESA_PC_REQ]) AC_SUBST([OSMESA_PC_LIB_PRIV]) +AC_SUBST([OSMESA_VERSION]) dnl dnl gbm configuration @@ -2188,6 +2192,7 @@ AC_CONFIG_FILES([configs/current src/mesa/drivers/dri/r200/Makefile src/mesa/drivers/dri/radeon/Makefile src/mesa/drivers/dri/swrast/Makefile + src/mesa/drivers/osmesa/Makefile src/mesa/drivers/x11/Makefile src/mesa/gl.pc src/mesa/osmesa.pc]) diff --git a/src/mesa/drivers/osmesa/.gitignore b/src/mesa/drivers/osmesa/.gitignore new file mode 100644 index 000..5fc607b --- /dev/null +++ b/src/mesa/drivers/osmesa/.gitignore @@ -0,0 +1 @@ +/Makefile diff --git a/src/mesa/drivers/osmesa/Makefile b/src/mesa/drivers/osmesa/Makefile deleted file mode 100644 index 39ab09a..000 --- a/src/mesa/drivers/osmesa/Makefile +++ /dev/null @@ -1,51 +0,0 @@ -# src/mesa/drivers/osmesa/Makefile for libOSMesa.so - -# Note that we may generate libOSMesa.so or libOSMesa16.so or libOSMesa32.so -# with this Makefile - - -TOP = ../../../.. - -include $(TOP)/configs/current - - - -SOURCES = osmesa.c - -OBJECTS = $(SOURCES:.c=.o) - -INCLUDE_DIRS = \ - -I$(TOP)/include \ - -I$(TOP)/src/mapi \ - -I$(TOP)/src/mesa \ - -I$(TOP)/src/mesa/main - -CORE_MESA = \ - $(TOP)/src/mesa/libmesa.a \ - $(TOP)/src/mapi/glapi/libglapi.a \ - $(TOP)/src/glsl/libglsl.a - -.c.o: - $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $ -o $@ - - -default: $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME) - - -# libOSMesa can be used in conjuction with libGL or with all other Mesa -# sources. We can also build libOSMesa16/libOSMesa32 by setting -# -DCHAN_BITS=16/32. -$(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME): $(OBJECTS) $(CORE_MESA) - $(MKLIB) -o $(OSMESA_LIB) -linker '$(CXX)' -ldflags '$(LDFLAGS)' \ - -major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \ - -install $(TOP)/$(LIB_DIR) -cplusplus $(MKLIB_OPTIONS) \ - -id $(INSTALL_LIB_DIR)/lib$(OSMESA_LIB).$(MESA_MAJOR).dylib \ - $(OSMESA_LIB_DEPS) $(OBJECTS) $(CORE_MESA) - - - -clean: - -rm -f *.o *~ - - -# XXX todo install rule? diff --git a/src/mesa/drivers/osmesa/Makefile.am b/src/mesa/drivers/osmesa/Makefile.am new file mode 100644 index 000..863c8f7 --- /dev/null +++ b/src/mesa/drivers/osmesa/Makefile.am @@ -0,0 +1,50 @@ + + +# Copyright © 2012 Laurent Carlier lordhea...@gmail.com +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the Software), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +# Hack to make some of the non-automake variables work.
Re: [Mesa-dev] [PATCH 1/8] __DRIimage: version 5, add new formats and createSubImage
On Sat, Jul 7, 2012 at 1:40 AM, Kristian Høgsberg hoegsb...@gmail.com wrote: On Fri, Jul 06, 2012 at 02:10:57PM -0700, Eric Anholt wrote: Kristian Høgsberg k...@bitplanet.net writes: The additions in version 5 enables creating EGLImages for different planes of a YUV buffer. createImageFromName is still used to create the containing __DRIimage, and createSubImage can then be used no that __DRIimage to create __DRIimages that correspond to the y, u, and v planes (__DRI_IMAGE_FORMAT_R8) or the uv planes (__DRI_IMAGE_FORMAT_RG88) for formats such as NV12 where the u and v components are interleaved. Packed formats such as YUYV etc doesn't require any special treatment, we just sample those as a regular ARGB texture. This patch series is making more sense to me than the last few yuv patchsets I've seen. Thanks for the feedback. I wanted to mention that while it would be a lot easier to use different bo's for the different planes, we can't do that. The decoder takes a base address for the destination buffer and then offsets relative to that to identify the various planes. So it has to be all within the same bo and the patch series has to touch the miptree setup. Also, after I sent out the series I started working on YUYV support (which is what the SNB+ sprites take), and the sub-image feature turns out to be useful there as well. We can create an RG88 texture for sampling the Y-component and then an RGBA texture for sampling the U and V channels, which means that we can texture from a YUYV buffer with bilinear filtering. Signed-off-by: Kristian Høgsberg k...@bitplanet.net --- include/GL/internal/dri_interface.h | 16 1 file changed, 16 insertions(+) diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index e37917e..5dfe15b 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -907,6 +907,10 @@ struct __DRIdri2ExtensionRec { #define __DRI_IMAGE_FORMAT_ARGB 0x1003 #define __DRI_IMAGE_FORMAT_ABGR 0x1004 #define __DRI_IMAGE_FORMAT_XBGR 0x1005 +#define __DRI_IMAGE_FORMAT_R8 0x1006 /* Since version 5 */ +#define __DRI_IMAGE_FORMAT_RG88 0x1007 +#define __DRI_IMAGE_FORMAT_YUV420 0x1008 +#define __DRI_IMAGE_FORMAT_NV12 0x1009 Could we get just a couple notes on the yuv420/nv12 formats here? Also, can one of these end up as an OES_EGL_image that someone might try to bind as a texture? What should happen, if so? (If it's possible, the MESA_FORMAT_NONE in the next patch would result in a bunch of _mesa_problem()s and failure) The __DRIimage we create with either of the YUV formats is never exposed as an EGLImage. We hold on to it in the wl_buffer object and use it to create subimages of one of the types that we can actually texture from and those get exposed as EGLImages. I had __DRI_IMAGE_FORMAT_NONE instead of the YUV formats, I think that may be clearer. #define __DRI_IMAGE_USE_SHARE 0x0001 #define __DRI_IMAGE_USE_SCANOUT0x0002 @@ -963,6 +967,18 @@ struct __DRIimageExtensionRec { * \since 4 */ int (*write)(__DRIimage *image, const void *buf, size_t count); + + /** +* Create an image out of a sub-region of a parent image. This +* entry point lets us create individual __DRIimages for different +* planes in a planar buffer (typically yuv), for example. +* +* \since 5 +*/ +__DRIimage *(*createSubImage)(__DRIimage *image, + int width, int height, int format, + int offset, int pitch, + void *loaderPrivate); }; Some notes about lifetime would be good here. In the implementation you have, the subimage gets separated from the parent, so changing the storage of the parent (if that's a thing that's possible -- I don't understand egl image lifetimes) wouldn't be tracked in the child. You could free the parent safely, as well. The lifetime rules are pretty simple; each subimage is an independent __DRIimage and its lifetime is not tied to the that of the parent. I'll put that in the docs. If the subimage can get bound as a render target, it won't be reliably synchronized with texturing from another subimage that overlaps it, and that seems like something to be noted. I didn't intend for the subimages to end up as render targets, but there's nothing in the API that prevents that. I guess the semantics I have in mind are much like the image_external restrictions, where you can't write to the EGLImage in any way (no glTexImage2D or glTexSubImage2D, no binding as rendertarget, no rendering to the image in OpenVG etc). I can add language to the wayland GLES2 extension that exposes the subimages to say that any such usage will result in undefined
Re: [Mesa-dev] Mesa (master): mesa: #define fprintf to be __mingw_fprintf() on Mingw32
On Fri, Jun 22, 2012 at 11:26 PM, Brian Paul bri...@kemper.freedesktop.org wrote: Module: Mesa Branch: master Commit: cbffaf20e9e6154310ba68bb2b44adc37ba83bcd URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cbffaf20e9e6154310ba68bb2b44adc37ba83bcd Author: Brian Paul bri...@vmware.com Date: Fri Jun 22 10:16:25 2012 -0600 mesa: #define fprintf to be __mingw_fprintf() on Mingw32 So that formats such as %llx are understood. Can't you just use the PRIx64 portability macro (and the others) instead? Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/main/imports.h | 10 ++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index c0b6cec..9fb6ae8 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -646,6 +646,16 @@ _mesa_vsnprintf(char *str, size_t size, const char *fmt, va_list arg); #endif +/** + * On Mingw32 we need to use __mingw_fprintf() to parse formats such + * as 0x%llx, and possibly others + */ +#ifdef __MINGW32__ +#define fprintf __mingw_fprintf +#endif + + + #ifdef __cplusplus } #endif ___ mesa-commit mailing list mesa-com...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/2] gles2: Add GL_NV_read_buffer extension
On Fri, Jun 15, 2012 at 7:44 PM, Kristian Høgsberg k...@bitplanet.net wrote: This lets us select the front buffer for reading under GLES2. --- src/mapi/glapi/gen/es_EXT.xml |7 +++ src/mapi/glapi/gen/gles_api.py |2 ++ src/mesa/main/APIspec.xml | 13 + src/mesa/main/extensions.c |1 + src/mesa/main/get.c| 20 +++- src/mesa/main/mtypes.h |1 + 6 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/mapi/glapi/gen/es_EXT.xml b/src/mapi/glapi/gen/es_EXT.xml index c7e7d07..b26cac5 100644 --- a/src/mapi/glapi/gen/es_EXT.xml +++ b/src/mapi/glapi/gen/es_EXT.xml @@ -627,4 +627,11 @@ enum name=REQUIRED_TEXTURE_IMAGE_UNITS_OES value=0x8D68/ /category +!-- 93. GL_NV_read_buffer -- +category name=NV_read_buffer +function name=ReadBufferNV offset=assign +param name=mode type=GLenum/ +/function +/category + /OpenGLAPI diff --git a/src/mapi/glapi/gen/gles_api.py b/src/mapi/glapi/gen/gles_api.py index 0116ba4..70ae2e3 100644 --- a/src/mapi/glapi/gen/gles_api.py +++ b/src/mapi/glapi/gen/gles_api.py @@ -451,4 +451,6 @@ es2_api = es2_core + ( 'ProgramBinaryOES', # GL_NV_draw_buffers 'DrawBuffersNV', +# GL_NV_read_buffer +'ReadBufferNV', ) diff --git a/src/mesa/main/APIspec.xml b/src/mesa/main/APIspec.xml index f23857a..64e666e 100644 --- a/src/mesa/main/APIspec.xml +++ b/src/mesa/main/APIspec.xml @@ -3534,6 +3534,13 @@ /proto /template +template name=ReadBuffer + proto + return type=void/ + param name=mode type=GLenum/ + /proto +/template + api name=mesa implementation=true category name=MESA/ @@ -3810,6 +3817,9 @@ function name=EGLImageTargetRenderbufferStorageOES template=EGLImageTargetRenderbufferStorage/ function name=DrawBuffersARB template=DrawBuffers/ + + function name=ReadBuffer template=ReadBuffer/ + /api api name=GLES1.1 @@ -4150,7 +4160,10 @@ category name=EXT_unpack_subimage/ category name=NV_draw_buffers/ + category name=NV_read_buffer/ + function name=DrawBuffersNV template=DrawBuffers/ + function name=ReadBufferNV template=ReadBuffer/ function name=CullFace template=CullFace/ diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 2688f7a..0e81783 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -300,6 +300,7 @@ static const struct extension extension_table[] = { { GL_NV_packed_depth_stencil, o(EXT_packed_depth_stencil),GL, 2000 }, { GL_NV_point_sprite, o(NV_point_sprite), GL, 2001 }, { GL_NV_primitive_restart,o(NV_primitive_restart), GL, 2002 }, + { GL_NV_read_buffer, o(dummy_true), ES2,2011 }, This is always advertised, but... { GL_NV_texgen_reflection,o(NV_texgen_reflection), GL, 1999 }, { GL_NV_texture_barrier, o(NV_texture_barrier), GL, 2009 }, { GL_NV_texture_env_combine4, o(NV_texture_env_combine4), GL, 1999 }, diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index a8e1d86..969b55b 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -131,6 +131,7 @@ enum value_extra { EXTRA_VERSION_30, EXTRA_VERSION_31, EXTRA_VERSION_32, + EXTRA_API_GL, EXTRA_API_ES2, EXTRA_NEW_BUFFERS, EXTRA_NEW_FRAG_CLAMP, @@ -369,6 +370,13 @@ extra_ARB_vertex_program_api_es2[] = { EXTRA_END }; +static const int +extra_NV_read_buffer_api_gl[] = { + EXT(NV_read_buffer), + EXTRA_API_GL, + EXTRA_END +}; + #define API_OPENGL_BIT (1 API_OPENGL) #define API_OPENGLES_BIT (1 API_OPENGLES) #define API_OPENGLES2_BIT (1 API_OPENGLES2) @@ -750,6 +758,11 @@ static const struct value_desc values[] = { /* GL_ARB_fragment_program/OES_standard_derivatives */ { GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB, CONTEXT_ENUM(Hint.FragmentShaderDerivative), extra_ARB_fragment_shader }, + + /* GL_NV_read_buffer */ + { GL_READ_BUFFER, + LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, extra_NV_read_buffer_api_gl }, + The query only actually works when this newly-added extension field is set to true... which is never, right? #endif /* FEATURE_GL || FEATURE_ES2 */ #if FEATURE_ES2 @@ -884,7 +897,6 @@ static const struct value_desc values[] = { { GL_POLYGON_SMOOTH, CONTEXT_BOOL(Polygon.SmoothFlag), NO_EXTRA }, { GL_POLYGON_SMOOTH_HINT, CONTEXT_ENUM(Hint.PolygonSmooth), NO_EXTRA }, { GL_POLYGON_STIPPLE,
[Mesa-dev] [PATCH 1/4] glapi/gen: fix out of tree build
Add -f $(srcdir)/gl_API.xml to the arguments of all the scripts that by default look for gl_API.xml in the working directory when run with no arguments, and prepend $(srcdir) to those scripts that are already using an explicit -f argument. --- src/mapi/glapi/gen/Makefile.am | 52 ++-- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am index d0d0a7b..d3a82e4 100644 --- a/src/mapi/glapi/gen/Makefile.am +++ b/src/mapi/glapi/gen/Makefile.am @@ -159,82 +159,88 @@ $(MESA_GLAPI_DIR)/glapi_mapi_tmp.h: $(MESA_MAPI_DIR)/mapi_abi.py $(COMMON_ES) --printer glapi --mode lib gl_and_es_API.xml $@ $(MESA_GLAPI_DIR)/glprocs.h: gl_procs.py $(COMMON) - $(PYTHON_GEN) $ $@ + $(PYTHON_GEN) $ -f $(srcdir)/gl_API.xml $@ $(MESA_GLAPI_DIR)/glapitemp.h: gl_apitemp.py $(COMMON) - $(PYTHON_GEN) $ $@ + $(PYTHON_GEN) $ -f $(srcdir)/gl_API.xml $@ $(MESA_GLAPI_DIR)/glapitable.h: gl_table.py $(COMMON) - $(PYTHON_GEN) $ $@ + $(PYTHON_GEN) $ -f $(srcdir)/gl_API.xml $@ $(MESA_GLAPI_DIR)/glapi_gentable.c: gl_gentable.py $(COMMON) - $(PYTHON_GEN) $ $@ + $(PYTHON_GEN) $ -f $(srcdir)/gl_API.xml $@ ## $(MESA_GLAPI_DIR)/glapi_x86.S: gl_x86_asm.py $(COMMON) - $(PYTHON_GEN) $ $@ + $(PYTHON_GEN) $ -f $(srcdir)/gl_API.xml $@ $(MESA_GLAPI_DIR)/glapi_x86-64.S: gl_x86-64_asm.py $(COMMON) - $(PYTHON_GEN) $ $@ + $(PYTHON_GEN) $ -f $(srcdir)/gl_API.xml $@ $(MESA_GLAPI_DIR)/glapi_sparc.S: gl_SPARC_asm.py $(COMMON) - $(PYTHON_GEN) $ $@ + $(PYTHON_GEN) $ -f $(srcdir)/gl_API.xml $@ ## $(MESA_DIR)/main/enums.c: gl_enums.py $(COMMON_ES) - $(PYTHON_GEN) $ -f gl_and_es_API.xml $@ + $(PYTHON_GEN) $ -f $(srcdir)/gl_and_es_API.xml $@ $(MESA_DIR)/main/dispatch.h: gl_table.py $(COMMON) - $(PYTHON_GEN) $ -m remap_table $@ + $(PYTHON_GEN) $ -f $(srcdir)/gl_API.xml -m remap_table $@ $(MESA_DIR)/main/remap_helper.h: remap_helper.py $(COMMON) - $(PYTHON_GEN) $ $@ + $(PYTHON_GEN) $ -f $(srcdir)/gl_API.xml $@ ## $(MESA_GLX_DIR)/indirect.c: glX_proto_send.py $(COMMON_GLX) - $(PYTHON_GEN) $ -m proto | $(INDENT) $(INDENT_FLAGS) $@ + $(PYTHON_GEN) $ -f $(srcdir)/gl_API.xml -m proto \ + | $(INDENT) $(INDENT_FLAGS) $@ $(MESA_GLX_DIR)/indirect.h: glX_proto_send.py $(COMMON_GLX) - $(PYTHON_GEN) $ -m init_h $@ + $(PYTHON_GEN) $ -f $(srcdir)/gl_API.xml -m init_h $@ $(MESA_GLX_DIR)/indirect_init.c: glX_proto_send.py $(COMMON_GLX) - $(PYTHON_GEN) $ -m init_c $@ + $(PYTHON_GEN) $ -f $(srcdir)/gl_API.xml -m init_c $@ $(MESA_GLX_DIR)/indirect_size.h $(XORG_GLX_DIR)/indirect_size.h: glX_proto_size.py $(COMMON_GLX) - $(PYTHON_GEN) $ -m size_h --only-set -h _INDIRECT_SIZE_H_ \ + $(PYTHON_GEN) $ -f $(srcdir)/gl_API.xml -m size_h --only-set \ + -h _INDIRECT_SIZE_H_ \ | $(INDENT) $(INDENT_FLAGS) $@ $(MESA_GLX_DIR)/indirect_size.c: glX_proto_size.py $(COMMON_GLX) - $(PYTHON_GEN) $ -m size_c --only-set \ + $(PYTHON_GEN) $ -f $(srcdir)/gl_API.xml -m size_c --only-set \ | $(INDENT) $(INDENT_FLAGS) $@ ## $(XORG_GLX_DIR)/indirect_dispatch.c: glX_proto_recv.py $(COMMON_GLX) - $(PYTHON_GEN) $ -m dispatch_c $@ + $(PYTHON_GEN) $ -f $(srcdir)/gl_API.xml -m dispatch_c $@ $(XORG_GLX_DIR)/indirect_dispatch_swap.c: glX_proto_recv.py $(COMMON_GLX) - $(PYTHON_GEN) $ -m dispatch_c -s $@ + $(PYTHON_GEN) $ -f $(srcdir)/gl_API.xml -m dispatch_c -s $@ $(XORG_GLX_DIR)/indirect_dispatch.h: glX_proto_recv.py gl_and_glX_API.xml $(COMMON_GLX) - $(PYTHON_GEN) $ -m dispatch_h -f gl_and_glX_API.xml -s $@ + $(PYTHON_GEN) $ -m dispatch_h -f $(srcdir)/gl_and_glX_API.xml -s $@ $(XORG_GLX_DIR)/indirect_size_get.h: glX_proto_size.py $(COMMON_GLX) - $(PYTHON_GEN) $ -m size_h --only-get -h '_INDIRECT_SIZE_GET_H_' \ + $(PYTHON_GEN) $ -f $(srcdir)/gl_API.xml -m size_h \ + --only-get -h '_INDIRECT_SIZE_GET_H_' \ | $(INDENT) $(INDENT_FLAGS) $@ $(XORG_GLX_DIR)/indirect_size_get.c: glX_proto_size.py $(COMMON_GLX) - $(PYTHON_GEN) $ -m size_c | $(INDENT) $(INDENT_FLAGS) $@ + $(PYTHON_GEN) $ -f $(srcdir)/gl_API.xml -m size_c \ + | $(INDENT) $(INDENT_FLAGS) $@ $(XORG_GLX_DIR)/indirect_reqsize.h: glX_proto_size.py $(COMMON_GLX) - $(PYTHON_GEN) $ -m reqsize_h --only-get -h '_INDIRECT_SIZE_GET_H_' \ + $(PYTHON_GEN) $ -f $(srcdir)/gl_API.xml -m reqsize_h \ + --only-get -h '_INDIRECT_SIZE_GET_H_' \ | $(INDENT) $(INDENT_FLAGS) -l200 $@
[Mesa-dev] [PATCH 2/4] mesa: fix api source gen for out-of-tree builds
Add $(srcdir) where needed. --- src/mesa/Makefile.am |6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mesa/Makefile.am b/src/mesa/Makefile.am index e52678d..44ec619 100644 --- a/src/mesa/Makefile.am +++ b/src/mesa/Makefile.am @@ -78,10 +78,12 @@ main/api_exec_es2_remap_helper.h: $(GLAPI)/gl_and_es_API.xml $(glapi_gen_remap_d main/api_exec_es2.o: main/api_exec_es2_dispatch.h main/api_exec_es2_remap_helper.h main/api_exec_es1.c: main/APIspec.xml main/es_generator.py main/APIspecutil.py main/APIspec.py - $(PYTHON2) $(PYTHON_FLAGS) main/es_generator.py -S main/APIspec.xml -V GLES1.1 $@ + $(PYTHON2) $(PYTHON_FLAGS) main/es_generator.py \ + -S $(srcdir)/main/APIspec.xml -V GLES1.1 $@ main/api_exec_es2.c: main/APIspec.xml main/es_generator.py main/APIspecutil.py main/APIspec.py - $(PYTHON2) $(PYTHON_FLAGS) main/es_generator.py -S main/APIspec.xml -V GLES2.0 $@ + $(PYTHON2) $(PYTHON_FLAGS) main/es_generator.py \ + -S $(srcdir)/main/APIspec.xml -V GLES2.0 $@ program/program_parse.tab.c program/program_parse.tab.h: program/program_parse.y $(YACC) -v -d --output=program/program_parse.tab.c $ -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/4] mesa: point to Makefile.old in the srcdir
Gets out-of-tree builds slightly closer to working. --- src/mesa/Makefile.am |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/Makefile.am b/src/mesa/Makefile.am index 5736c5d..bada760 100644 --- a/src/mesa/Makefile.am +++ b/src/mesa/Makefile.am @@ -94,13 +94,13 @@ program/lex.yy.c: program/program_lexer.l $(LEX) --never-interactive --outfile=$@ $ all-local: - $(MAKE) -f Makefile.old + $(MAKE) -f $(srcdir)/Makefile.old install-exec-local: - $(MAKE) -f Makefile.old install + $(MAKE) -f $(srcdir)/Makefile.old install clean-local: - $(MAKE) -f Makefile.old clean + $(MAKE) -f $(srcdir)/Makefile.old clean pkgconfigdir = $(libdir)/pkgconfig -- 1.7.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] egl: fix copy/pasted misnomer
This is a long-standing typo that propagated from the wayland code, confusing drm_magic_t and wayland object IDs. --- src/egl/drivers/dri2/egl_dri2.h|2 +- src/egl/drivers/dri2/platform_drm.c|4 ++-- src/egl/drivers/dri2/platform_wayland.c|4 ++-- src/egl/drivers/dri2/platform_x11.c|4 ++-- .../wayland/wayland-drm/protocol/wayland-drm.xml |2 +- src/egl/wayland/wayland-drm/wayland-drm.c |4 ++-- src/egl/wayland/wayland-drm/wayland-drm.h |2 +- src/gallium/state_trackers/egl/x11/x11_screen.c|4 ++-- src/gallium/state_trackers/egl/x11/x11_screen.h|2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h index c30e230..97b88a5 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -127,7 +127,7 @@ struct dri2_egl_display int formats; #endif - int (*authenticate) (_EGLDisplay *disp, uint32_t id); + int (*authenticate) (_EGLDisplay *disp, uint32_t magic); }; struct dri2_egl_context diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c index 54067ff..8a6d385 100644 --- a/src/egl/drivers/dri2/platform_drm.c +++ b/src/egl/drivers/dri2/platform_drm.c @@ -382,11 +382,11 @@ dri2_drm_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp, } static int -dri2_drm_authenticate(_EGLDisplay *disp, uint32_t id) +dri2_drm_authenticate(_EGLDisplay *disp, uint32_t magic) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); - return drmAuthMagic(dri2_dpy-fd, id); + return drmAuthMagic(dri2_dpy-fd, magic); } EGLBoolean diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index d291f0f..3423236 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -692,14 +692,14 @@ dri2_wayland_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp, } static int -dri2_wayland_authenticate(_EGLDisplay *disp, uint32_t id) +dri2_wayland_authenticate(_EGLDisplay *disp, uint32_t magic) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); int ret = 0; dri2_dpy-authenticated = 0; - wl_drm_authenticate(dri2_dpy-wl_drm, id); + wl_drm_authenticate(dri2_dpy-wl_drm, magic); wl_display_roundtrip(dri2_dpy-wl_dpy); if (!dri2_dpy-authenticated) diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index 7486a91..f4629bf 100644 --- a/src/egl/drivers/dri2/platform_x11.c +++ b/src/egl/drivers/dri2/platform_x11.c @@ -564,7 +564,7 @@ dri2_connect(struct dri2_egl_display *dri2_dpy) } static int -dri2_x11_authenticate(_EGLDisplay *disp, uint32_t id) +dri2_x11_authenticate(_EGLDisplay *disp, uint32_t magic) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); xcb_dri2_authenticate_reply_t *authenticate; @@ -574,7 +574,7 @@ dri2_x11_authenticate(_EGLDisplay *disp, uint32_t id) s = xcb_setup_roots_iterator(xcb_get_setup(dri2_dpy-conn)); authenticate_cookie = - xcb_dri2_authenticate_unchecked(dri2_dpy-conn, s.data-root, id); + xcb_dri2_authenticate_unchecked(dri2_dpy-conn, s.data-root, magic); authenticate = xcb_dri2_authenticate_reply(dri2_dpy-conn, authenticate_cookie, NULL); diff --git a/src/egl/wayland/wayland-drm/protocol/wayland-drm.xml b/src/egl/wayland/wayland-drm/protocol/wayland-drm.xml index 89fd8f0..5ed307e 100644 --- a/src/egl/wayland/wayland-drm/protocol/wayland-drm.xml +++ b/src/egl/wayland/wayland-drm/protocol/wayland-drm.xml @@ -105,7 +105,7 @@ DRIAuthConnection() call. This authentication must be completed before create_buffer could be used. -- request name=authenticate - arg name=id type=uint/ + arg name=magic type=uint/ /request !-- Create a wayland buffer for the named DRM buffer. The DRM diff --git a/src/egl/wayland/wayland-drm/wayland-drm.c b/src/egl/wayland/wayland-drm/wayland-drm.c index 5f831b3..313eec5 100644 --- a/src/egl/wayland/wayland-drm/wayland-drm.c +++ b/src/egl/wayland/wayland-drm/wayland-drm.c @@ -156,11 +156,11 @@ drm_create_buffer(struct wl_client *client, struct wl_resource *resource, static void drm_authenticate(struct wl_client *client, -struct wl_resource *resource, uint32_t id) +struct wl_resource *resource, uint32_t magic) { struct wl_drm *drm = resource-data; - if (drm-callbacks-authenticate(drm-user_data, id) 0) + if (drm-callbacks-authenticate(drm-user_data, magic) 0) wl_resource_post_error(resource, WL_DRM_ERROR_AUTHENTICATE_FAIL, authenicate failed); diff --git a/src/egl/wayland/wayland-drm/wayland-drm.h b/src/egl/wayland/wayland-drm/wayland-drm.h index bec50a5..ab6a67e 100644 ---
[Mesa-dev] [PATCH 1/6] dri: add driWarnImmutableTexture()
This warns about trying to respecify a texture marked immutable by GL_ARB_texture_storage. --- src/mesa/drivers/dri/common/dri_util.c | 14 ++ src/mesa/drivers/dri/common/dri_util.h |3 +++ 2 files changed, 17 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 53707a8..4b11ea5 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -596,3 +596,17 @@ driUpdateFramebufferSize(struct gl_context *ctx, const __DRIdrawable *dPriv) assert(fb-Height == dPriv-h); } } + +/** + * Every DRI driver needs to give this warning in its setTexBuffer2() + * implementation, so this is kept in common code. + */ +void +driWarnImmutableTexture(struct gl_context *ctx, GLuint texture) +{ + _mesa_problem(ctx, Texture %u is immutable and can't be modified with + glXBindTexImageEXT() or eglBindTexImage(). There should be + a BadMatch or EGL_BAD_MATCH error here, but a version + of the DRI interface that can't report errors was used., + texture); +} diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index 900f048..3740f06 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -266,4 +266,7 @@ dri2InvalidateDrawable(__DRIdrawable *drawable); extern void driUpdateFramebufferSize(struct gl_context *ctx, const __DRIdrawable *dPriv); +extern void +driWarnImmutableTexture(struct gl_context *ctx, GLuint texture); + #endif /* _DRI_UTIL_H_ */ -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/6] swrast: don't modify immutable textures
--- src/mesa/drivers/dri/swrast/swrast.c |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index 22d71bf..70bbcb8 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -84,6 +84,12 @@ static void swrastSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, _mesa_lock_texture(dri_ctx-Base, texObj); +if (texObj-Immutable) { +driWarnImmutableTexture(dri_ctx-Base, texObj-Name); +_mesa_unlock_texture(dri_ctx-Base, texObj); +return; +} + sPriv-swrast_loader-getDrawableInfo(dPriv, x, y, w, h, dPriv-loaderPrivate); if (texture_format == __DRI_TEXTURE_FORMAT_RGB) -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/6] intel: don't modify immutable textures
--- src/mesa/drivers/dri/intel/intel_tex_image.c |7 +++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c index 094d3cd..264cfc1 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_image.c +++ b/src/mesa/drivers/dri/intel/intel_tex_image.c @@ -356,6 +356,13 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, } _mesa_lock_texture(intel-ctx, texObj); + +if (texObj-Immutable) { +driWarnImmutableTexture(ctx, texObj-Name); +_mesa_unlock_texture(ctx, texObj); +return; +} + texImage = _mesa_get_tex_image(ctx, texObj, target, level); intel_set_texture_image_region(ctx, texImage, rb-mt-region, target, internalFormat, texFormat); -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/6] nouveau_vieux: don't modify immutable textures
--- src/mesa/drivers/dri/nouveau/nouveau_texture.c |7 +++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_texture.c b/src/mesa/drivers/dri/nouveau/nouveau_texture.c index a2e96aa..8954666 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_texture.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_texture.c @@ -723,6 +723,13 @@ nouveau_set_texbuffer(__DRIcontext *dri_ctx, struct nouveau_surface *s; _mesa_lock_texture(ctx, t); + + if (t-Immutable) { + driWarnImmutableTexture(ctx, t-Name); + _mesa_unlock_texture(ctx, t); + return; + } + ti = _mesa_get_tex_image(ctx, t, target, 0); nti = to_nouveau_teximage(ti); s = to_nouveau_teximage(ti)-surface; -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 5/6] radeon: don't modify immutable textures
--- src/mesa/drivers/dri/radeon/radeon_texstate.c |7 +++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/dri/radeon/radeon_texstate.c b/src/mesa/drivers/dri/radeon/radeon_texstate.c index 87f12d5..932b706 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texstate.c +++ b/src/mesa/drivers/dri/radeon/radeon_texstate.c @@ -636,6 +636,13 @@ void radeonSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint texture_form } _mesa_lock_texture(radeon-glCtx, texObj); + + if (texObj-Immutable) { + driWarnImmutableTexture(radeon-glCtx, texObj-Name); + _mesa_unlock_texture(radeon-glCtx, texObj); + return; + } + if (t-bo) { radeon_bo_unref(t-bo); t-bo = NULL; -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 6/6] st/mesa: don't modify immutable textures
--- src/mesa/state_tracker/st_manager.c |8 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index d54b7ed..5a1fb73 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -501,6 +501,14 @@ st_context_teximage(struct st_context_iface *stctxi, texObj = _mesa_select_tex_object(ctx, texUnit, target); _mesa_lock_texture(ctx, texObj); + if (texObj-Immutable) { + /* Ideally, we should not be able to get here. */ + _mesa_problem(ctx, Texture %u is immutable: its format and dimensions + can't be modified., texObj-Name); + _mesa_unlock_texture(ctx, texObj); + return FALSE; + } + stObj = st_texture_object(texObj); /* switch to surface based */ if (!stObj-surface_based) { -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/4 v2] glsl: consolidate code
And lay the groundwork for GL_ARB_debug_output. --- src/glsl/glsl_parser_extras.cpp | 33 +++-- 1 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index ae7a365..6a4ab4a 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -134,24 +134,34 @@ _mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target) return unknown; } +static void +_mesa_glsl_msg(const YYLTYPE *locp, _mesa_glsl_parse_state *state, + GLenum type, GLuint id, const char *fmt, va_list ap) +{ + bool error = (type == GL_DEBUG_TYPE_ERROR_ARB); + + assert(state-info_log != NULL); + ralloc_asprintf_append(state-info_log, %u:%u(%u): %s: , + locp-source, + locp-first_line, + locp-first_column, + error ? error : warning); + ralloc_vasprintf_append(state-info_log, fmt, ap); + ralloc_strcat(state-info_log, \n); +} void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, const char *fmt, ...) { va_list ap; + GLenum type = GL_DEBUG_TYPE_ERROR_ARB; state-error = true; - assert(state-info_log != NULL); - ralloc_asprintf_append(state-info_log, %u:%u(%u): error: , - locp-source, - locp-first_line, - locp-first_column); va_start(ap, fmt); - ralloc_vasprintf_append(state-info_log, fmt, ap); + _mesa_glsl_msg(locp, state, type, SHADER_ERROR_UNKNOWN, fmt, ap); va_end(ap); - ralloc_strcat(state-info_log, \n); } @@ -160,16 +170,11 @@ _mesa_glsl_warning(const YYLTYPE *locp, _mesa_glsl_parse_state *state, const char *fmt, ...) { va_list ap; + GLenum type = GL_DEBUG_TYPE_OTHER_ARB; - assert(state-info_log != NULL); - ralloc_asprintf_append(state-info_log, %u:%u(%u): warning: , - locp-source, - locp-first_line, - locp-first_column); va_start(ap, fmt); - ralloc_vasprintf_append(state-info_log, fmt, ap); + _mesa_glsl_msg(locp, state, type, 0, fmt, ap); va_end(ap); - ralloc_strcat(state-info_log, \n); } -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/4 v2] mesa: add _mesa_shader_debug()
This should be the one entrypoint libglsl needs for GL_ARB_debug_output. --- src/mesa/main/errors.c | 34 ++ src/mesa/main/errors.h |4 2 files changed, 38 insertions(+), 0 deletions(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index fcf873f..be271eb 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -1062,4 +1062,38 @@ _mesa_debug( const struct gl_context *ctx, const char *fmtString, ... ) (void) fmtString; } + +void +_mesa_shader_debug( struct gl_context *ctx, GLenum type, GLuint err, +const char *msg, int len ) +{ + GLenum source = GL_DEBUG_SOURCE_SHADER_COMPILER_ARB, + severity; + + switch (type) { + case GL_DEBUG_TYPE_ERROR_ARB: + assert(err SHADER_ERROR_COUNT); + severity = GL_DEBUG_SEVERITY_HIGH_ARB; + break; + case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB: + case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB: + case GL_DEBUG_TYPE_PORTABILITY_ARB: + case GL_DEBUG_TYPE_PERFORMANCE_ARB: + case GL_DEBUG_TYPE_OTHER_ARB: + assert(0 other categories not implemented yet); + default: + _mesa_problem(ctx, bad enum in _mesa_shader_debug()); + return; + } + + if (len 0) + len = strlen(msg); + + /* Truncate the message if necessary. */ + if (len = MAX_DEBUG_MESSAGE_LENGTH) + len = MAX_DEBUG_MESSAGE_LENGTH - 1; + + _mesa_log_msg(ctx, source, type, err, severity, len, msg); +} + /*@}*/ diff --git a/src/mesa/main/errors.h b/src/mesa/main/errors.h index ed1c6fc..2b4f5ff 100644 --- a/src/mesa/main/errors.h +++ b/src/mesa/main/errors.h @@ -38,6 +38,7 @@ #include compiler.h #include glheader.h +#include mtypes.h #ifdef __cplusplus @@ -68,6 +69,9 @@ _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... ) extern void _mesa_debug( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3); +extern void +_mesa_shader_debug( struct gl_context *ctx, GLenum type, GLuint err, const char *msg, int len ); + #ifdef __cplusplus } #endif -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/4 resend] glsl: add gl_context member
--- src/glsl/glsl_parser_extras.cpp |3 ++- src/glsl/glsl_parser_extras.h |3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 6a4ab4a..3d99cc5 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -36,8 +36,9 @@ extern C { #include ir_optimization.h #include loop_analysis.h -_mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *ctx, +_mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx, GLenum target, void *mem_ctx) + : ctx(_ctx) { switch (target) { case GL_VERTEX_SHADER: this-target = vertex_shader; break; diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index 55676f5..1a909c6 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -57,7 +57,7 @@ struct glsl_switch_state { }; struct _mesa_glsl_parse_state { - _mesa_glsl_parse_state(struct gl_context *ctx, GLenum target, + _mesa_glsl_parse_state(struct gl_context *_ctx, GLenum target, void *mem_ctx); /* Callers of this ralloc-based new need not call delete. It's @@ -77,6 +77,7 @@ struct _mesa_glsl_parse_state { ralloc_free(mem); } + struct gl_context *const ctx; void *scanner; exec_list translation_unit; glsl_symbol_table *symbols; -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/4 v2] glsl: report errors via GL_ARB_debug_output
--- src/glsl/glsl_parser_extras.cpp | 11 +++ src/glsl/standalone_scaffolding.cpp |6 ++ src/glsl/standalone_scaffolding.h |4 3 files changed, 21 insertions(+), 0 deletions(-) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 3d99cc5..d2469f5 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -142,12 +142,23 @@ _mesa_glsl_msg(const YYLTYPE *locp, _mesa_glsl_parse_state *state, bool error = (type == GL_DEBUG_TYPE_ERROR_ARB); assert(state-info_log != NULL); + + /* Get the offset that the new message will be written to. */ + int msg_offset = strlen(state-info_log); + ralloc_asprintf_append(state-info_log, %u:%u(%u): %s: , locp-source, locp-first_line, locp-first_column, error ? error : warning); ralloc_vasprintf_append(state-info_log, fmt, ap); + + const char *const msg = state-info_log[msg_offset]; + struct gl_context *ctx = state-ctx; + /* Report the error via GL_ARB_debug_output. */ + if (error) + _mesa_shader_debug(ctx, type, id, msg, strlen(msg)); + ralloc_strcat(state-info_log, \n); } diff --git a/src/glsl/standalone_scaffolding.cpp b/src/glsl/standalone_scaffolding.cpp index 24cc64a..f15f2d8 100644 --- a/src/glsl/standalone_scaffolding.cpp +++ b/src/glsl/standalone_scaffolding.cpp @@ -41,6 +41,12 @@ _mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr, *ptr = sh; } +void +_mesa_shader_debug(struct gl_context *, GLenum, GLuint, + const char *, int) +{ +} + struct gl_shader * _mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type) { diff --git a/src/glsl/standalone_scaffolding.h b/src/glsl/standalone_scaffolding.h index 8773320..41ce35b 100644 --- a/src/glsl/standalone_scaffolding.h +++ b/src/glsl/standalone_scaffolding.h @@ -40,6 +40,10 @@ _mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr, extern C struct gl_shader * _mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type); +extern C void +_mesa_shader_debug(struct gl_context *ctx, GLenum type, GLuint id, + const char *msg, int len); + /** * Initialize the given gl_context structure to a reasonable set of * defaults representing the minimum capabilities required by the -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/3] mesa: generate GL_INVALID_VALUE when bufSize 0
On Tue, Apr 24, 2012 at 9:29 AM, Ian Romanick i...@freedesktop.org wrote: On 04/22/2012 09:44 AM, nobled wrote: Though not explicit in the GL_ARB_robustness extension, the GL standard says: If a negative number is provided where an argument of type sizei or sizeiptr is specified, the error INVALID_VALUE is generated. While the extension says that GL_INVALID_OPERATION is given when the required space is greater thanbufSize, and this Which error do other implementations generate? If there's a clear trend, we should follow that. If there's not a clear trend, I can file a bug against the spec for being ambiguous. I'm still waiting for someone who can use the proprietary drivers to test the piglit patch I sent out a week ago. Till then, how about I just commit a minimal fix for the accidentally no error bug: [PATCH] mesa: fix potential buffer overflow This fixes a bug in _mesa_validate_pbo_access() where the signed value clientMemSize was blindly cast to an unsigned value. When bufSize/clientMemSize were negative, it would be cast to a value greater than INT_MAX and no error would have been given. There's some ambiguity with the GL_ARB_robustness spec whether the error should be GL_INVALID_VALUE or GL_INVALID_OPERATION. While waiting for someone to run the piglit test on the proprietary drivers, just give GL_INVALID_OPERATION for now. --- src/mesa/main/pbo.c |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/src/mesa/main/pbo.c b/src/mesa/main/pbo.c index d8fa919..c6b7ede 100644 --- a/src/mesa/main/pbo.c +++ b/src/mesa/main/pbo.c @@ -77,6 +77,8 @@ _mesa_validate_pbo_access(GLuint dimensions, In that case 'clientMemSize' is ignored: we just use the PBO's size. */ if (!_mesa_is_bufferobj(pack-BufferObj)) { + if (clientMemSize 0) + return GL_FALSE; offset = 0; size = clientMemSize; } else { -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] mesa: reject immutable textures in glEGLImageTargetTexture2DOES()
GL_ARB_texture_storage says: The commands eglBindTexImage, wglBindTexImageARB, glXBindTexImageEXT or EGLImageTargetTexture2DOES are not permitted on an immutable-format texture. They will generate the following errors: - EGLImageTargetTexture2DOES: INVALID_OPERATION - eglBindTexImage: EGL_BAD_MATCH - wglBindTexImage: ERROR_INVALID_OPERATION - glXBindTexImageEXT: BadMatch Fixing the EGL and GLX cases requires extending the DRI interface, since setTexBuffer2 doesn't return any error information. --- src/mesa/main/teximage.c |7 +++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 2348646..50095d2 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -2692,6 +2692,13 @@ _mesa_EGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image) texObj = _mesa_get_current_tex_object(ctx, target); _mesa_lock_texture(ctx, texObj); + if (texObj-Immutable) { + _mesa_error(ctx, GL_INVALID_OPERATION, + glEGLImageTargetTexture2D(texture is immutable)); + _mesa_unlock_texture(ctx, texObj); + return; + } + texImage = _mesa_get_tex_image(ctx, texObj, target, 0); if (!texImage) { _mesa_error(ctx, GL_OUT_OF_MEMORY, glEGLImageTargetTexture2D); -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 7/9] glcpp: pass gl_context to preprocess()
On Sun, Apr 15, 2012 at 6:08 AM, nobled nob...@dreamwidth.org wrote: On Fri, Apr 13, 2012 at 2:04 PM, Ian Romanick i...@freedesktop.org wrote: On 04/13/2012 08:52 AM, nobled wrote: --- src/glsl/glcpp/glcpp.c | 2 +- src/glsl/glcpp/glcpp.h | 4 +++- src/glsl/glcpp/pp.c | 3 ++- src/glsl/glsl_parser_extras.h | 2 +- src/glsl/linker.cpp | 2 -- src/glsl/main.cpp | 2 +- src/glsl/test_optpass.cpp | 2 +- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/glsl/glcpp/glcpp.c b/src/glsl/glcpp/glcpp.c index e461a65..bd6344b 100644 --- a/src/glsl/glcpp/glcpp.c +++ b/src/glsl/glcpp/glcpp.c @@ -111,7 +111,7 @@ main (int argc, char *argv[]) if (shader == NULL) return 1; - ret = preprocess(ctx,shader,info_log, NULL, API_OPENGL); + ret = preprocess(ctx,shader,info_log, API_OPENGL, NULL); printf(%s, shader); fprintf(stderr, %s, info_log); diff --git a/src/glsl/glcpp/glcpp.h b/src/glsl/glcpp/glcpp.h index 2d7cad2..0c52077 100644 --- a/src/glsl/glcpp/glcpp.h +++ b/src/glsl/glcpp/glcpp.h @@ -160,6 +160,8 @@ typedef struct active_list { struct active_list *next; } active_list_t; +struct gl_context; + struct glcpp_parser { yyscan_t scanner; struct hash_table *defines; @@ -192,7 +194,7 @@ glcpp_parser_destroy (glcpp_parser_t *parser); int preprocess(void *ralloc_ctx, const char **shader, char **info_log, - const struct gl_extensions *extensions, int api); + int api, struct gl_context *glctx); /* Functions for writing to the info log */ diff --git a/src/glsl/glcpp/pp.c b/src/glsl/glcpp/pp.c index b0afed4..7218eeb 100644 --- a/src/glsl/glcpp/pp.c +++ b/src/glsl/glcpp/pp.c @@ -146,9 +146,10 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader) int preprocess(void *ralloc_ctx, const char **shader, char **info_log, - const struct gl_extensions *extensions, int api) + int api, struct gl_context *glctx) { int errors; + struct gl_extensions *extensions = glctx ?glctx-Extensions : NULL; It looks like the only place that can call preprocess with a NULL extension pointer is the standalone preprocessor. I think it would be better to modify that code to pass an empty gl_context with the gl_extensions field cleared to zeros. I think that would simplify this code a bit, and it would eliminate the need to have a separate api parameter (preprocess could just look at the gl_context). Yeah, I wanted to do that at first, but... Some helpers like in standalone_scaffolding.cpp might be in order. This would match the way the standalone GLSL compiler works. Yeah, it looked like it required duplicating initialize_context_to_defaults() and initialize_context() from main.cpp and standalone_scaffolding.cpp. Can we just move these down a layer into a new file, glcpp_standalone.cpp? The standalone preprocessor is already duplicating the _mesa_reference_shader(), and now the _mesa_shader_error(), standalone functions. ping. Good idea or bad idea? As a side comment, we should probably get the glcpp unit tests wired into 'make check'. glcpp_parser_t *parser = glcpp_parser_create (extensions, api); *shader = remove_line_continuations(parser, *shader); diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index 1a909c6..10402c9 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -297,7 +297,7 @@ extern C { #endif extern int preprocess(void *ctx, const char **shader, char **info_log, - const struct gl_extensions *extensions, int api); + int api, struct gl_context *glctx); extern void _mesa_destroy_shader_compiler(void); extern void _mesa_destroy_shader_compiler_caches(void); diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index e2a5ef9..e43ec3a 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -175,10 +175,8 @@ private: static void linker_msg(gl_shader_program *prog, bool error, const char *fmt, va_list ap) { - ralloc_strcat(prog-InfoLog, error ? error: : warning: ); ralloc_vasprintf_append(prog-InfoLog, fmt, ap); - Eh... maybe just don't introduce these whitespace errors in the earlier patch (6/9)? :) Whoops, heh. Should not use `git add -u`. } diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index d43bf1a..1d509eb 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -136,7 +136,7 @@ compile_shader(struct gl_context *ctx, struct gl_shader *shader) const char *source = shader-Source; state-error = preprocess(state,source,state-info_log, - state-extensions, ctx-API) != 0; + ctx-API, ctx) != 0; if (!state-error) { _mesa_glsl_lexer_ctor(state, source); diff --git a/src/glsl
[Mesa-dev] [PATCH 1/3] autoconf: pass -Wall to automake
And fix these warning that appear at autoreconf time: `:='-style assignments are not portable --- configure.ac |2 +- src/gallium/drivers/r300/Makefile.sources |2 +- src/mesa/drivers/dri/i915/Makefile.sources |4 ++-- src/mesa/drivers/dri/i965/Makefile.sources |8 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 694505d..ea9f331 100644 --- a/configure.ac +++ b/configure.ac @@ -16,7 +16,7 @@ AC_INIT([Mesa],[mesa_version], [https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa]) AC_CONFIG_AUX_DIR([bin]) AC_CANONICAL_HOST -AM_INIT_AUTOMAKE([foreign]) +AM_INIT_AUTOMAKE([foreign -Wall]) dnl http://people.gnome.org/~walters/docs/build-api.txt dnl We don't support srcdir != builddir. diff --git a/src/gallium/drivers/r300/Makefile.sources b/src/gallium/drivers/r300/Makefile.sources index e27b14e..436fe7e 100644 --- a/src/gallium/drivers/r300/Makefile.sources +++ b/src/gallium/drivers/r300/Makefile.sources @@ -1,4 +1,4 @@ -C_SOURCES := \ +C_SOURCES = \ r300_blit.c \ r300_chipset.c \ r300_context.c \ diff --git a/src/mesa/drivers/dri/i915/Makefile.sources b/src/mesa/drivers/dri/i915/Makefile.sources index 7d26640..7dcf63d 100644 --- a/src/mesa/drivers/dri/i915/Makefile.sources +++ b/src/mesa/drivers/dri/i915/Makefile.sources @@ -1,8 +1,8 @@ # Paths are relative to TOP. -i915_INCLUDES := \ +i915_INCLUDES = \ src/mesa/drivers/dri/intel -i915_C_FILES := \ +i915_C_FILES = \ i830_context.c \ i830_state.c \ i830_texblend.c \ diff --git a/src/mesa/drivers/dri/i965/Makefile.sources b/src/mesa/drivers/dri/i965/Makefile.sources index 750be51..084b874 100644 --- a/src/mesa/drivers/dri/i965/Makefile.sources +++ b/src/mesa/drivers/dri/i965/Makefile.sources @@ -1,8 +1,8 @@ -i965_INCLUDES := \ +i965_INCLUDES = \ $(MESA_TOP)/src \ $(MESA_TOP)/src/mesa/drivers/dri/intel -i965_C_FILES := \ +i965_C_FILES = \ intel_batchbuffer.c \ intel_blit.c \ intel_buffer_objects.c \ @@ -111,7 +111,7 @@ i965_C_FILES := \ gen7_wm_state.c \ gen7_wm_surface_state.c -i965_CXX_FILES := \ +i965_CXX_FILES = \ brw_cubemap_normalize.cpp \ brw_fs.cpp \ brw_fs_emit.cpp \ @@ -127,4 +127,4 @@ i965_CXX_FILES := \ brw_vec4_reg_allocate.cpp \ brw_vec4_visitor.cpp -i965_ASM_FILES := +i965_ASM_FILES = -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/3] mesa: require GL_MAX_SAMPLES = 4 for GL 3.0
As noted in commit be4e46b21a60cfdc826bf89d1078df54966115b1, this was missing before. NOTE: This is a candidate for the 8.0 branch. --- src/mesa/main/version.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c index 82cc54b..607230b 100644 --- a/src/mesa/main/version.c +++ b/src/mesa/main/version.c @@ -124,6 +124,7 @@ compute_version(struct gl_context *ctx) ctx-Extensions.EXT_texture_sRGB); const GLboolean ver_3_0 = (ver_2_1 ctx-Const.GLSLVersion = 130 + ctx-Const.MaxSamples = 4 ctx-Extensions.ARB_color_buffer_float ctx-Extensions.ARB_depth_buffer_float ctx-Extensions.ARB_half_float_pixel -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/3] mesa: generate GL_INVALID_VALUE when bufSize 0
Though not explicit in the GL_ARB_robustness extension, the GL standard says: If a negative number is provided where an argument of type sizei or sizeiptr is specified, the error INVALID_VALUE is generated. While the extension says that GL_INVALID_OPERATION is given when the required space is greater than bufSize, and this would be technically true for all negative values, defer to the above language. This error check seems to apply even when a PBO is bound, while insufficient but non-negative values of bufSize are ignored. This also fixes a bug in _mesa_validate_pbo_access() where the signed value clientMemSize was blindly cast to an unsigned value. When bufSize/clientMemSize were negative, it would be cast to a value greater than INT_MAX and no error would have been given, not even the incorrect GL_INVALID_OPERATION. Oops. NOTE: This is a candidate for the 8.0 branch. --- src/mesa/main/eval.c| 18 ++ src/mesa/main/pbo.c | 15 +++ src/mesa/main/pixel.c |6 ++ src/mesa/main/readpix.c |6 ++ src/mesa/main/texgetimage.c | 16 +++- src/mesa/main/uniform_query.cpp |9 - 6 files changed, 68 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/eval.c b/src/mesa/main/eval.c index e651715..8c25295 100644 --- a/src/mesa/main/eval.c +++ b/src/mesa/main/eval.c @@ -563,6 +563,12 @@ _mesa_GetnMapdvARB( GLenum target, GLenum query, GLsizei bufSize, GLdouble *v ) return; } + if (bufSize 0) { + _mesa_error( ctx, GL_INVALID_VALUE, + glGetnMapdvARB(bufSize = %d), bufSize ); + return; + } + map1d = get_1d_map(ctx, target); map2d = get_2d_map(ctx, target); ASSERT(map1d || map2d); @@ -655,6 +661,12 @@ _mesa_GetnMapfvARB( GLenum target, GLenum query, GLsizei bufSize, GLfloat *v ) return; } + if (bufSize 0) { + _mesa_error( ctx, GL_INVALID_VALUE, + glGetnMapfvARB(bufSize = %d), bufSize ); + return; + } + map1d = get_1d_map(ctx, target); map2d = get_2d_map(ctx, target); ASSERT(map1d || map2d); @@ -749,6 +761,12 @@ _mesa_GetnMapivARB( GLenum target, GLenum query, GLsizei bufSize, GLint *v ) return; } + if (bufSize 0) { + _mesa_error( ctx, GL_INVALID_VALUE, + glGetnMapivARB(bufSize = %d), bufSize ); + return; + } + map1d = get_1d_map(ctx, target); map2d = get_2d_map(ctx, target); ASSERT(map1d || map2d); diff --git a/src/mesa/main/pbo.c b/src/mesa/main/pbo.c index d8fa919..0fe5394 100644 --- a/src/mesa/main/pbo.c +++ b/src/mesa/main/pbo.c @@ -71,6 +71,9 @@ _mesa_validate_pbo_access(GLuint dimensions, /* unsigned, to detect overflow/wrap-around */ uintptr_t start, end, offset, size; + /* This should be error-checked by all callers beforehand. */ + assert(clientMemSize = 0); + /* If no PBO is bound, 'ptr' is a pointer to client memory containing 'clientMemSize' bytes. If a PBO is bound, 'ptr' is an offset into the bound PBO. @@ -180,6 +183,12 @@ _mesa_map_validate_pbo_source(struct gl_context *ctx, { ASSERT(dimensions == 1 || dimensions == 2 || dimensions == 3); + if (clientMemSize 0) { + _mesa_error( ctx, GL_INVALID_VALUE, + %s(bufSize = %d), where, clientMemSize ); + return NULL; + } + if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth, format, type, clientMemSize, ptr)) { if (_mesa_is_bufferobj(unpack-BufferObj)) { @@ -276,6 +285,12 @@ _mesa_map_validate_pbo_dest(struct gl_context *ctx, { ASSERT(dimensions == 1 || dimensions == 2 || dimensions == 3); + if (clientMemSize 0) { + _mesa_error( ctx, GL_INVALID_VALUE, + %s(bufSize = %d), where, clientMemSize ); + return NULL; + } + if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth, format, type, clientMemSize, ptr)) { if (_mesa_is_bufferobj(unpack-BufferObj)) { diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c index 450c936..be6a19d 100644 --- a/src/mesa/main/pixel.c +++ b/src/mesa/main/pixel.c @@ -153,6 +153,12 @@ validate_pbo_access(struct gl_context *ctx, { GLboolean ok; + if (clientMemSize 0) { + _mesa_error(ctx, GL_INVALID_VALUE, + glGetnPixelMap*vARB(bufSize = %d), clientMemSize); + return GL_FALSE; + } + /* Note, need to use DefaultPacking and Unpack's buffer object */ _mesa_reference_buffer_object(ctx, ctx-DefaultPacking.BufferObj, diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c index 31acfcb..d4fcc56 100644 --- a/src/mesa/main/readpix.c +++ b/src/mesa/main/readpix.c @@ -690,6 +690,12 @@ _mesa_ReadnPixelsARB( GLint x, GLint y, GLsizei width, GLsizei height, return; } + if (bufSize 0) { + _mesa_error( ctx, GL_INVALID_VALUE,
Re: [Mesa-dev] GLSL 1.40 and fixed function
On Mon, Apr 16, 2012 at 1:01 PM, Paul Berry stereotype...@gmail.com wrote: On 16 April 2012 09:44, Ian Romanick i...@freedesktop.org wrote: On 04/15/2012 03:25 AM, nobled wrote: I'm not sure if I'm missing something, but the non-compatibility OpenGL 3.1 Specification seems pretty straightforward about this: page 42/55 section 2.11 Vertex Shaders: If the program object has no vertex shader, or no program object is currently in use, the results of vertex shader execution are undefined. page 160/173 section 3.9 Fragment Shaders: If the program object has no fragment shader, or no program object is currently in use, the results of fragment shader execution are undefined. page 45/58 section 2.11.2 Program Objects: If UseProgram is called with program set to 0, then the current rendering state refers to an invalid program object, and the results of vertex and fragment shader execution are undefined. However, this is not an error. Right. It looks like this language persists all the way through OpenGL 4.2. I did a bit more spec spelunking, and it seems the only link error required by desktop OpenGL is for geometry shaders and tessellation shaders. Linking will also fail if the program object contains objects to form a geometry shader (see section 2.12), and * the program contains no objects to form a vertex shader; ... Linking can fail for a variety of reasons as specified in the OpenGL Shading Language Specification, as well as any of the following reasons: * ... * The program object contains objects to form a tessellation control shader (see section 2.12.1), and - the program is not separable and contains no objects to form a vertex shader; ... I'm not sure if undefined is used in the undefined rendering results sense or the summoning nasal demons sense, though. That's not defined. :p Sorry, I couldn't resist. Here's my new proposal: * Don't generate a linker error or warning for incomplete programs. * For draw calls that use incomplete programs, drop the rendering on the floor and emit a message to the debug log. That makes sense as a conservative approach. If it's truly undefined behaviour, then emitting INVALID_OPERATION would also be legal. I'm surprised that isn't required, since there's already something *almost* like that anyway in the standard for *other* conditions that make a program non useable-- validation is done when the first rendering command is issued, to determine if the currently active program object can be executed. If it cannot be executed then no fragments will be rendered, and the error INVALID_OPERATION will be generated. A point of clarification: if the program is incomplete because it lacks a fragment shader, is transform feedback expected to work? My read of the spec is that the phrase the results of fragment shader execution are undefined means that transform feedback is still expected to work in this situation. So we need to make sure that we only drop fragments on the floor, not vertices. Yep-- page 71/84 section 2.11.7 Shader Execution: Undefined behavior results if the program object in use has no fragment shader unless transform feedback is enabled, in which case only a vertex shader is re- quired. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 4/9] glsl: report errors via GL_ARB_debug_output
On Fri, Apr 13, 2012 at 2:04 PM, Ian Romanick i...@freedesktop.org wrote: On 04/13/2012 08:51 AM, nobled wrote: --- src/glsl/glsl_parser_extras.cpp | 14 ++ src/glsl/standalone_scaffolding.cpp | 6 ++ src/glsl/standalone_scaffolding.h | 4 3 files changed, 24 insertions(+), 0 deletions(-) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index aade2e1..d6a156d 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -139,13 +139,27 @@ static void _mesa_glsl_msg(const YYLTYPE *locp, _mesa_glsl_parse_state *state, bool error, const char *fmt, va_list ap) { + struct gl_context *ctx = state-ctx; Since this is C++ code, I'd suggest moving the declarations down to the assignments. Sure. + int msg_offset; + const char *msg; + assert(state-info_log != NULL); + + /* Get the offset that the new message will be written to. */ + msg_offset = strlen(state-info_log); + ralloc_asprintf_append(state-info_log, %u:%u(%u): %s: , locp-source, locp-first_line, locp-first_column, error ? error : warning); ralloc_vasprintf_append(state-info_log, fmt, ap); + + msg =state-info_log[msg_offset]; So this would become const char *const msg = state-info_log[msg_offset]; + /* Report the error via GL_ARB_debug_output. */ + if (error) + _mesa_shader_error(ctx, SHADER_ERROR_UNKNOWN, msg, strlen(msg)); Should warnings also be reported? Maybe use GL_DEBUG_TYPE_OTHER_ARB? We don't report that many warnings, so it may not matter that much. Same comment in patch 9/9 for the preprocessor warnings. I only wanted to do the minimum necessary to emit errors for now, because 'are you sure you meant to write this?' sanity-check warnings would go in OTHER, but some warnings should go in a more specific category, which'd require a new (possibly overloaded) _mesa_glsl_warning*() function to indicate which. Use of an extension that was set to 'warn' is definitely GL_DEBUG_TYPE_PORTABILITY_ARB, for example. + ralloc_strcat(state-info_log, \n); } diff --git a/src/glsl/standalone_scaffolding.cpp b/src/glsl/standalone_scaffolding.cpp index 24cc64a..99079b1 100644 --- a/src/glsl/standalone_scaffolding.cpp +++ b/src/glsl/standalone_scaffolding.cpp @@ -41,6 +41,12 @@ _mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr, *ptr = sh; } +void +_mesa_shader_error(struct gl_context *, gl_shader_error, + const char *, int) Is that valid C++? I thought you could only leave the names out in the prototype. This makes it a bit odd that the names in included in the prototype (in standalone_scaffolding.h, below). Yeah, this compiles fine. I just left them out to avoid 'unused' warnings instead of casting with (void). +{ +} + struct gl_shader * _mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type) { diff --git a/src/glsl/standalone_scaffolding.h b/src/glsl/standalone_scaffolding.h index 8773320..8dedbaa 100644 --- a/src/glsl/standalone_scaffolding.h +++ b/src/glsl/standalone_scaffolding.h @@ -40,6 +40,10 @@ _mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr, extern C struct gl_shader * _mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type); +extern C void +_mesa_shader_error(struct gl_context *ctx, gl_shader_error err, + const char *msg, int len); + /** * Initialize the given gl_context structure to a reasonable set of * defaults representing the minimum capabilities required by the ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 7/9] glcpp: pass gl_context to preprocess()
On Fri, Apr 13, 2012 at 2:04 PM, Ian Romanick i...@freedesktop.org wrote: On 04/13/2012 08:52 AM, nobled wrote: --- src/glsl/glcpp/glcpp.c | 2 +- src/glsl/glcpp/glcpp.h | 4 +++- src/glsl/glcpp/pp.c | 3 ++- src/glsl/glsl_parser_extras.h | 2 +- src/glsl/linker.cpp | 2 -- src/glsl/main.cpp | 2 +- src/glsl/test_optpass.cpp | 2 +- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/glsl/glcpp/glcpp.c b/src/glsl/glcpp/glcpp.c index e461a65..bd6344b 100644 --- a/src/glsl/glcpp/glcpp.c +++ b/src/glsl/glcpp/glcpp.c @@ -111,7 +111,7 @@ main (int argc, char *argv[]) if (shader == NULL) return 1; - ret = preprocess(ctx,shader,info_log, NULL, API_OPENGL); + ret = preprocess(ctx,shader,info_log, API_OPENGL, NULL); printf(%s, shader); fprintf(stderr, %s, info_log); diff --git a/src/glsl/glcpp/glcpp.h b/src/glsl/glcpp/glcpp.h index 2d7cad2..0c52077 100644 --- a/src/glsl/glcpp/glcpp.h +++ b/src/glsl/glcpp/glcpp.h @@ -160,6 +160,8 @@ typedef struct active_list { struct active_list *next; } active_list_t; +struct gl_context; + struct glcpp_parser { yyscan_t scanner; struct hash_table *defines; @@ -192,7 +194,7 @@ glcpp_parser_destroy (glcpp_parser_t *parser); int preprocess(void *ralloc_ctx, const char **shader, char **info_log, - const struct gl_extensions *extensions, int api); + int api, struct gl_context *glctx); /* Functions for writing to the info log */ diff --git a/src/glsl/glcpp/pp.c b/src/glsl/glcpp/pp.c index b0afed4..7218eeb 100644 --- a/src/glsl/glcpp/pp.c +++ b/src/glsl/glcpp/pp.c @@ -146,9 +146,10 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader) int preprocess(void *ralloc_ctx, const char **shader, char **info_log, - const struct gl_extensions *extensions, int api) + int api, struct gl_context *glctx) { int errors; + struct gl_extensions *extensions = glctx ?glctx-Extensions : NULL; It looks like the only place that can call preprocess with a NULL extension pointer is the standalone preprocessor. I think it would be better to modify that code to pass an empty gl_context with the gl_extensions field cleared to zeros. I think that would simplify this code a bit, and it would eliminate the need to have a separate api parameter (preprocess could just look at the gl_context). Yeah, I wanted to do that at first, but... Some helpers like in standalone_scaffolding.cpp might be in order. This would match the way the standalone GLSL compiler works. Yeah, it looked like it required duplicating initialize_context_to_defaults() and initialize_context() from main.cpp and standalone_scaffolding.cpp. Can we just move these down a layer into a new file, glcpp_standalone.cpp? The standalone preprocessor is already duplicating the _mesa_reference_shader(), and now the _mesa_shader_error(), standalone functions. As a side comment, we should probably get the glcpp unit tests wired into 'make check'. glcpp_parser_t *parser = glcpp_parser_create (extensions, api); *shader = remove_line_continuations(parser, *shader); diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index 1a909c6..10402c9 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -297,7 +297,7 @@ extern C { #endif extern int preprocess(void *ctx, const char **shader, char **info_log, - const struct gl_extensions *extensions, int api); + int api, struct gl_context *glctx); extern void _mesa_destroy_shader_compiler(void); extern void _mesa_destroy_shader_compiler_caches(void); diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index e2a5ef9..e43ec3a 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -175,10 +175,8 @@ private: static void linker_msg(gl_shader_program *prog, bool error, const char *fmt, va_list ap) { - ralloc_strcat(prog-InfoLog, error ? error: : warning: ); ralloc_vasprintf_append(prog-InfoLog, fmt, ap); - Eh... maybe just don't introduce these whitespace errors in the earlier patch (6/9)? :) Whoops, heh. Should not use `git add -u`. } diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index d43bf1a..1d509eb 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -136,7 +136,7 @@ compile_shader(struct gl_context *ctx, struct gl_shader *shader) const char *source = shader-Source; state-error = preprocess(state,source,state-info_log, - state-extensions, ctx-API) != 0; + ctx-API, ctx) != 0; if (!state-error) { _mesa_glsl_lexer_ctor(state, source); diff --git a/src/glsl/test_optpass.cpp b/src/glsl/test_optpass.cpp index 6abafb5..0844706 100644 --- a/src/glsl/test_optpass.cpp +++ b
Re: [Mesa-dev] [PATCH 1/9] glsl: consolidate code
On Fri, Apr 13, 2012 at 3:15 PM, Ian Romanick i...@freedesktop.org wrote: On 04/13/2012 08:51 AM, nobled wrote: This just occurred to me... Wouldn't it be easier to push all the compiler / linker error messages into the debug log in one shot *after* compilation (or linking) is done? Since the messages all start with either warning: or error: and end with a \n, they would be trivial to parse. That would make it impossible to add something I was planning after this got in; sorting warnings into the specific categories of GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB, GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB, GL_DEBUG_TYPE_PORTABILITY_ARB, and GL_DEBUG_TYPE_PERFORMANCE_ARB. That would have a couple advantages: 1. Less churn in the patch series. 2. Less headaches trying to push gl_context deeper into the compiler. We intentionally tried to keep gl_context out of the compiler as much as possible. It's already using the ctx-Extensions struct in the exact same places. It's definitely not any worse than the status quo, it's just a pointer to a mesa struct of a different type. By the way, is the long term plan to break the circular dependency between libglsl and libmesa? mesa creates _mesa_glsl_parse_state objects, and glsl needs structures defined in mesa headers and the functions defined standalone_scaffolding.cpp. Just a thought... This function is about to get longer. --- src/glsl/glsl_parser_extras.cpp | 29 +++-- 1 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index ae7a365..d14124f 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -134,6 +134,19 @@ _mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target) return unknown; } +static void +_mesa_glsl_msg(const YYLTYPE *locp, _mesa_glsl_parse_state *state, + bool error, const char *fmt, va_list ap) +{ + assert(state-info_log != NULL); + ralloc_asprintf_append(state-info_log, %u:%u(%u): %s: , + locp-source, + locp-first_line, + locp-first_column, + error ? error : warning); + ralloc_vasprintf_append(state-info_log, fmt, ap); + ralloc_strcat(state-info_log, \n); +} void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, @@ -143,15 +156,9 @@ _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, state-error = true; - assert(state-info_log != NULL); - ralloc_asprintf_append(state-info_log, %u:%u(%u): error: , - locp-source, - locp-first_line, - locp-first_column); va_start(ap, fmt); - ralloc_vasprintf_append(state-info_log, fmt, ap); + _mesa_glsl_msg(locp, state, true, fmt, ap); va_end(ap); - ralloc_strcat(state-info_log, \n); } @@ -161,15 +168,9 @@ _mesa_glsl_warning(const YYLTYPE *locp, _mesa_glsl_parse_state *state, { va_list ap; - assert(state-info_log != NULL); - ralloc_asprintf_append(state-info_log, %u:%u(%u): warning: , - locp-source, - locp-first_line, - locp-first_column); va_start(ap, fmt); - ralloc_vasprintf_append(state-info_log, fmt, ap); + _mesa_glsl_msg(locp, state, false, fmt, ap); va_end(ap); - ralloc_strcat(state-info_log, \n); } ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] GLSL 1.40 and fixed function
On Fri, Apr 13, 2012 at 5:52 PM, Ian Romanick i...@freedesktop.org wrote: On 04/13/2012 02:35 PM, Eric Anholt wrote: On Tue, 27 Mar 2012 10:41:09 -0700, Kenneth Graunkekenn...@whitecape.org wrote: On 03/27/2012 10:31 AM, Ian Romanick wrote: On 03/26/2012 01:35 PM, Eric Anholt wrote: I've got a question for GLSL 1.40 that could use some interpretation: Section 1.2.5 in the spec says: The following features, previously deprecated, are removed: ... Fixed functionality for a programmable stage. Supply shaders for all stages currently being used. What exactly does this mean? Undefined results? Link error? Draw time error? I couldn't find anything explicit in the 3.1 core spec (since it doesn't have fixed function, so it doesn't really explain interaction with it) or the compat spec (since it has ARB_compatibility, so that deprecated functionality is re-allowed). At the bottom of that list is also the line: Removed features were recast under the ARB_compatibility extension, within this specification. I believe this implies the same link error as in ES 2.0. The wording is weird. I thought we ended up saying something more clear than this, but it was a long time ago. I think my resolution would be: Don't expose GLSL 1.40 outside of a GL 3.1+ core context, thus dodging the question of how to interact between the FF and GLSL 1.40 without GL_ARB_compatibility exposed. I think that's reasonable. Though, this may lead to people wanting EXT_gpu_shader4 to get UBOs in some apps. I guess we can cross that bridge when we come to it. There is also a requirement that shaders from different stage must have the same version. We could just enable the same all-stages linker check if any stage is 1.40 that we already have for ES shaders. It's not a huge deal to me either way. Yeah, I think the linker needs to mandate all stages be present, like ES. That said, I'm still unclear what happens if you do a draw call without a UseProgram. Undefined results? GL error? Yeah, I haven't found any mandate there. I would think a GL_INVALID_OPERATION? I believe that ES says GL_INVALID_OPERATION. I think OpenGL 3.1 is ambiguous, but I have a vague recollection that it was cleaned up in some later spec. There's some complexity in later 3.x versions because: 1. You can have a VS+FS without a GS. 2. You can have a VS or VS+GS with transform feedback and rasterizer discard. Of course, it gets even more complicated with the tessellation stages. The link error makes sense, at least until GL_ARB_separate_shader_objects. And we just won't expose GL_EXT_sso on a 3.1 core context. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev I'm not sure if I'm missing something, but the non-compatibility OpenGL 3.1 Specification seems pretty straightforward about this: page 42/55 section 2.11 Vertex Shaders: If the program object has no vertex shader, or no program object is currently in use, the results of vertex shader execution are undefined. page 160/173 section 3.9 Fragment Shaders: If the program object has no fragment shader, or no program object is currently in use, the results of fragment shader execution are undefined. page 45/58 section 2.11.2 Program Objects: If UseProgram is called with program set to 0, then the current rendering state refers to an invalid program object, and the results of vertex and fragment shader execution are undefined. However, this is not an error. I'm not sure if undefined is used in the undefined rendering results sense or the summoning nasal demons sense, though. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/9] glsl: consolidate code
This function is about to get longer. --- src/glsl/glsl_parser_extras.cpp | 29 +++-- 1 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index ae7a365..d14124f 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -134,6 +134,19 @@ _mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target) return unknown; } +static void +_mesa_glsl_msg(const YYLTYPE *locp, _mesa_glsl_parse_state *state, + bool error, const char *fmt, va_list ap) +{ + assert(state-info_log != NULL); + ralloc_asprintf_append(state-info_log, %u:%u(%u): %s: , + locp-source, + locp-first_line, + locp-first_column, + error ? error : warning); + ralloc_vasprintf_append(state-info_log, fmt, ap); + ralloc_strcat(state-info_log, \n); +} void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, @@ -143,15 +156,9 @@ _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state, state-error = true; - assert(state-info_log != NULL); - ralloc_asprintf_append(state-info_log, %u:%u(%u): error: , - locp-source, - locp-first_line, - locp-first_column); va_start(ap, fmt); - ralloc_vasprintf_append(state-info_log, fmt, ap); + _mesa_glsl_msg(locp, state, true, fmt, ap); va_end(ap); - ralloc_strcat(state-info_log, \n); } @@ -161,15 +168,9 @@ _mesa_glsl_warning(const YYLTYPE *locp, _mesa_glsl_parse_state *state, { va_list ap; - assert(state-info_log != NULL); - ralloc_asprintf_append(state-info_log, %u:%u(%u): warning: , - locp-source, - locp-first_line, - locp-first_column); va_start(ap, fmt); - ralloc_vasprintf_append(state-info_log, fmt, ap); + _mesa_glsl_msg(locp, state, false, fmt, ap); va_end(ap); - ralloc_strcat(state-info_log, \n); } -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/9] mesa: add _mesa_shader_error()
--- src/mesa/main/errors.c | 19 +++ src/mesa/main/errors.h |4 2 files changed, 23 insertions(+), 0 deletions(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index fcf873f..f03ebd3 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -1062,4 +1062,23 @@ _mesa_debug( const struct gl_context *ctx, const char *fmtString, ... ) (void) fmtString; } + +void +_mesa_shader_error( struct gl_context *ctx, gl_shader_error err, +const char *msg, int len) +{ + const GLenum source = GL_DEBUG_SOURCE_SHADER_COMPILER_ARB, + type = GL_DEBUG_TYPE_ERROR_ARB, + severity = GL_DEBUG_SEVERITY_HIGH_ARB; + + if (len 0) + len = strlen(msg); + + /* Truncate the message if necessary. */ + if (len = MAX_DEBUG_MESSAGE_LENGTH) + len = MAX_DEBUG_MESSAGE_LENGTH - 1; + + _mesa_log_msg(ctx, source, type, err, severity, len, msg); +} + /*@}*/ diff --git a/src/mesa/main/errors.h b/src/mesa/main/errors.h index ed1c6fc..93cccaa 100644 --- a/src/mesa/main/errors.h +++ b/src/mesa/main/errors.h @@ -38,6 +38,7 @@ #include compiler.h #include glheader.h +#include mtypes.h #ifdef __cplusplus @@ -68,6 +69,9 @@ _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... ) extern void _mesa_debug( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3); +extern void +_mesa_shader_error( struct gl_context *ctx, gl_shader_error err, const char *msg, int len); + #ifdef __cplusplus } #endif -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/9] glsl: add gl_context member
--- src/glsl/glsl_parser_extras.cpp |3 ++- src/glsl/glsl_parser_extras.h |3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index d14124f..aade2e1 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -36,8 +36,9 @@ extern C { #include ir_optimization.h #include loop_analysis.h -_mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *ctx, +_mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx, GLenum target, void *mem_ctx) + : ctx(_ctx) { switch (target) { case GL_VERTEX_SHADER: this-target = vertex_shader; break; diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index 55676f5..1a909c6 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -57,7 +57,7 @@ struct glsl_switch_state { }; struct _mesa_glsl_parse_state { - _mesa_glsl_parse_state(struct gl_context *ctx, GLenum target, + _mesa_glsl_parse_state(struct gl_context *_ctx, GLenum target, void *mem_ctx); /* Callers of this ralloc-based new need not call delete. It's @@ -77,6 +77,7 @@ struct _mesa_glsl_parse_state { ralloc_free(mem); } + struct gl_context *const ctx; void *scanner; exec_list translation_unit; glsl_symbol_table *symbols; -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/9] glsl: report errors via GL_ARB_debug_output
--- src/glsl/glsl_parser_extras.cpp | 14 ++ src/glsl/standalone_scaffolding.cpp |6 ++ src/glsl/standalone_scaffolding.h |4 3 files changed, 24 insertions(+), 0 deletions(-) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index aade2e1..d6a156d 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -139,13 +139,27 @@ static void _mesa_glsl_msg(const YYLTYPE *locp, _mesa_glsl_parse_state *state, bool error, const char *fmt, va_list ap) { + struct gl_context *ctx = state-ctx; + int msg_offset; + const char *msg; + assert(state-info_log != NULL); + + /* Get the offset that the new message will be written to. */ + msg_offset = strlen(state-info_log); + ralloc_asprintf_append(state-info_log, %u:%u(%u): %s: , locp-source, locp-first_line, locp-first_column, error ? error : warning); ralloc_vasprintf_append(state-info_log, fmt, ap); + + msg = state-info_log[msg_offset]; + /* Report the error via GL_ARB_debug_output. */ + if (error) + _mesa_shader_error(ctx, SHADER_ERROR_UNKNOWN, msg, strlen(msg)); + ralloc_strcat(state-info_log, \n); } diff --git a/src/glsl/standalone_scaffolding.cpp b/src/glsl/standalone_scaffolding.cpp index 24cc64a..99079b1 100644 --- a/src/glsl/standalone_scaffolding.cpp +++ b/src/glsl/standalone_scaffolding.cpp @@ -41,6 +41,12 @@ _mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr, *ptr = sh; } +void +_mesa_shader_error(struct gl_context *, gl_shader_error, + const char *, int) +{ +} + struct gl_shader * _mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type) { diff --git a/src/glsl/standalone_scaffolding.h b/src/glsl/standalone_scaffolding.h index 8773320..8dedbaa 100644 --- a/src/glsl/standalone_scaffolding.h +++ b/src/glsl/standalone_scaffolding.h @@ -40,6 +40,10 @@ _mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr, extern C struct gl_shader * _mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type); +extern C void +_mesa_shader_error(struct gl_context *ctx, gl_shader_error err, + const char *msg, int len); + /** * Initialize the given gl_context structure to a reasonable set of * defaults representing the minimum capabilities required by the -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 5/9] glcpp: consolidate error/warning code
--- src/glsl/glcpp/pp.c | 33 +++-- 1 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/glsl/glcpp/pp.c b/src/glsl/glcpp/pp.c index 3640896..b0afed4 100644 --- a/src/glsl/glcpp/pp.c +++ b/src/glsl/glcpp/pp.c @@ -27,21 +27,32 @@ #include glcpp.h #include main/core.h /* for isblank() on MSVC */ +static void +glcpp_msg (YYLTYPE *locp, glcpp_parser_t *parser, bool error, + const char *fmt, va_list ap) +{ + ralloc_asprintf_append(parser-info_log, %u:%u(%u): + preprocessor %s: , + locp-source, + locp-first_line, + locp-first_column, + error ? error : warning); + + ralloc_vasprintf_append(parser-info_log, fmt, ap); + + ralloc_strcat(parser-info_log, \n); +} + void glcpp_error (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) { va_list ap; parser-error = 1; - ralloc_asprintf_append(parser-info_log, %u:%u(%u): - preprocessor error: , - locp-source, - locp-first_line, - locp-first_column); + va_start(ap, fmt); - ralloc_vasprintf_append(parser-info_log, fmt, ap); + glcpp_msg(locp, parser, true, fmt, ap); va_end(ap); - ralloc_strcat(parser-info_log, \n); } void @@ -49,15 +60,9 @@ glcpp_warning (YYLTYPE *locp, glcpp_parser_t *parser, const char *fmt, ...) { va_list ap; - ralloc_asprintf_append(parser-info_log, %u:%u(%u): - preprocessor warning: , - locp-source, - locp-first_line, - locp-first_column); va_start(ap, fmt); - ralloc_vasprintf_append(parser-info_log, fmt, ap); + glcpp_msg(locp, parser, false, fmt, ap); va_end(ap); - ralloc_strcat(parser-info_log, \n); } /* Searches backwards for '^ *#' from a given starting point. */ -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 6/9] glsl: consolidate error/warning code
--- src/glsl/linker.cpp | 17 - 1 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 49b6b8f..e2a5ef9 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -172,14 +172,23 @@ private: }; +static void +linker_msg(gl_shader_program *prog, bool error, const char *fmt, va_list ap) +{ + + ralloc_strcat(prog-InfoLog, error ? error: : warning: ); + ralloc_vasprintf_append(prog-InfoLog, fmt, ap); + +} + + void linker_error(gl_shader_program *prog, const char *fmt, ...) { va_list ap; - ralloc_strcat(prog-InfoLog, error: ); va_start(ap, fmt); - ralloc_vasprintf_append(prog-InfoLog, fmt, ap); + linker_msg(prog, true, fmt, ap); va_end(ap); prog-LinkStatus = false; @@ -191,11 +200,9 @@ linker_warning(gl_shader_program *prog, const char *fmt, ...) { va_list ap; - ralloc_strcat(prog-InfoLog, error: ); va_start(ap, fmt); - ralloc_vasprintf_append(prog-InfoLog, fmt, ap); + linker_msg(prog, false, fmt, ap); va_end(ap); - } -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 7/9] glcpp: pass gl_context to preprocess()
--- src/glsl/glcpp/glcpp.c|2 +- src/glsl/glcpp/glcpp.h|4 +++- src/glsl/glcpp/pp.c |3 ++- src/glsl/glsl_parser_extras.h |2 +- src/glsl/linker.cpp |2 -- src/glsl/main.cpp |2 +- src/glsl/test_optpass.cpp |2 +- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/glsl/glcpp/glcpp.c b/src/glsl/glcpp/glcpp.c index e461a65..bd6344b 100644 --- a/src/glsl/glcpp/glcpp.c +++ b/src/glsl/glcpp/glcpp.c @@ -111,7 +111,7 @@ main (int argc, char *argv[]) if (shader == NULL) return 1; - ret = preprocess(ctx, shader, info_log, NULL, API_OPENGL); + ret = preprocess(ctx, shader, info_log, API_OPENGL, NULL); printf(%s, shader); fprintf(stderr, %s, info_log); diff --git a/src/glsl/glcpp/glcpp.h b/src/glsl/glcpp/glcpp.h index 2d7cad2..0c52077 100644 --- a/src/glsl/glcpp/glcpp.h +++ b/src/glsl/glcpp/glcpp.h @@ -160,6 +160,8 @@ typedef struct active_list { struct active_list *next; } active_list_t; +struct gl_context; + struct glcpp_parser { yyscan_t scanner; struct hash_table *defines; @@ -192,7 +194,7 @@ glcpp_parser_destroy (glcpp_parser_t *parser); int preprocess(void *ralloc_ctx, const char **shader, char **info_log, - const struct gl_extensions *extensions, int api); + int api, struct gl_context *glctx); /* Functions for writing to the info log */ diff --git a/src/glsl/glcpp/pp.c b/src/glsl/glcpp/pp.c index b0afed4..7218eeb 100644 --- a/src/glsl/glcpp/pp.c +++ b/src/glsl/glcpp/pp.c @@ -146,9 +146,10 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader) int preprocess(void *ralloc_ctx, const char **shader, char **info_log, - const struct gl_extensions *extensions, int api) + int api, struct gl_context *glctx) { int errors; + struct gl_extensions *extensions = glctx ? glctx-Extensions : NULL; glcpp_parser_t *parser = glcpp_parser_create (extensions, api); *shader = remove_line_continuations(parser, *shader); diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index 1a909c6..10402c9 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -297,7 +297,7 @@ extern C { #endif extern int preprocess(void *ctx, const char **shader, char **info_log, - const struct gl_extensions *extensions, int api); + int api, struct gl_context *glctx); extern void _mesa_destroy_shader_compiler(void); extern void _mesa_destroy_shader_compiler_caches(void); diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index e2a5ef9..e43ec3a 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -175,10 +175,8 @@ private: static void linker_msg(gl_shader_program *prog, bool error, const char *fmt, va_list ap) { - ralloc_strcat(prog-InfoLog, error ? error: : warning: ); ralloc_vasprintf_append(prog-InfoLog, fmt, ap); - } diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp index d43bf1a..1d509eb 100644 --- a/src/glsl/main.cpp +++ b/src/glsl/main.cpp @@ -136,7 +136,7 @@ compile_shader(struct gl_context *ctx, struct gl_shader *shader) const char *source = shader-Source; state-error = preprocess(state, source, state-info_log, -state-extensions, ctx-API) != 0; +ctx-API, ctx) != 0; if (!state-error) { _mesa_glsl_lexer_ctor(state, source); diff --git a/src/glsl/test_optpass.cpp b/src/glsl/test_optpass.cpp index 6abafb5..0844706 100644 --- a/src/glsl/test_optpass.cpp +++ b/src/glsl/test_optpass.cpp @@ -219,7 +219,7 @@ int test_optpass(int argc, char **argv) shader-Source = input.c_str(); const char *source = shader-Source; state-error = preprocess(state, source, state-info_log, -state-extensions, ctx-API) != 0; +ctx-API, ctx) != 0; if (!state-error) { _mesa_glsl_lexer_ctor(state, source); -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 8/9] glcpp: add gl_context to glcpp_parser_t
--- src/glsl/glcpp/glcpp-parse.y |5 - src/glsl/glcpp/glcpp.h |5 ++--- src/glsl/glcpp/pp.c |3 +-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 47ba54d..dd90a34 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -1081,16 +1081,19 @@ static void add_builtin_define(glcpp_parser_t *parser, } glcpp_parser_t * -glcpp_parser_create (const struct gl_extensions *extensions, int api) +glcpp_parser_create (int api, struct gl_context *ctx) { glcpp_parser_t *parser; int language_version; + const struct gl_extensions *extensions; parser = ralloc (NULL, glcpp_parser_t); + extensions = ctx ? ctx-Extensions : NULL; glcpp_lex_init_extra (parser, parser-scanner); parser-defines = hash_table_ctor (32, hash_table_string_hash, hash_table_string_compare); + parser-ctx = ctx; parser-active = NULL; parser-lexing_if = 0; parser-space_tokens = 1; diff --git a/src/glsl/glcpp/glcpp.h b/src/glsl/glcpp/glcpp.h index 0c52077..699b21b 100644 --- a/src/glsl/glcpp/glcpp.h +++ b/src/glsl/glcpp/glcpp.h @@ -164,6 +164,7 @@ struct gl_context; struct glcpp_parser { yyscan_t scanner; + struct gl_context *ctx; struct hash_table *defines; active_list_t *active; int lexing_if; @@ -181,10 +182,8 @@ struct glcpp_parser { int error; }; -struct gl_extensions; - glcpp_parser_t * -glcpp_parser_create (const struct gl_extensions *extensions, int api); +glcpp_parser_create (int api, struct gl_context *glctx); int glcpp_parser_parse (glcpp_parser_t *parser); diff --git a/src/glsl/glcpp/pp.c b/src/glsl/glcpp/pp.c index 7218eeb..32054bb 100644 --- a/src/glsl/glcpp/pp.c +++ b/src/glsl/glcpp/pp.c @@ -149,8 +149,7 @@ preprocess(void *ralloc_ctx, const char **shader, char **info_log, int api, struct gl_context *glctx) { int errors; - struct gl_extensions *extensions = glctx ? glctx-Extensions : NULL; - glcpp_parser_t *parser = glcpp_parser_create (extensions, api); + glcpp_parser_t *parser = glcpp_parser_create (api, glctx); *shader = remove_line_continuations(parser, *shader); glcpp_lex_set_source_string (parser, *shader); -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 9/9] glcpp: report errors via GL_ARB_debug_output
--- src/glsl/glcpp/glcpp.c |7 +++ src/glsl/glcpp/pp.c| 14 ++ 2 files changed, 21 insertions(+), 0 deletions(-) diff --git a/src/glsl/glcpp/glcpp.c b/src/glsl/glcpp/glcpp.c index bd6344b..3f20b2b 100644 --- a/src/glsl/glcpp/glcpp.c +++ b/src/glsl/glcpp/glcpp.c @@ -25,6 +25,7 @@ #include string.h #include errno.h #include glcpp.h +#include main/errors.h #include main/mtypes.h #include main/shaderobj.h @@ -38,6 +39,12 @@ _mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr, *ptr = sh; } +void +_mesa_shader_error(struct gl_context *ctx, gl_shader_error err, + const char *msg, int len) +{ +} + /* Read from fp until EOF and return a string of everything read. */ static char * diff --git a/src/glsl/glcpp/pp.c b/src/glsl/glcpp/pp.c index 32054bb..c19b638 100644 --- a/src/glsl/glcpp/pp.c +++ b/src/glsl/glcpp/pp.c @@ -31,6 +31,15 @@ static void glcpp_msg (YYLTYPE *locp, glcpp_parser_t *parser, bool error, const char *fmt, va_list ap) { + struct gl_context *ctx = parser-ctx; + int msg_offset; + const char *msg; + + assert(parser-info_log); + + /* Get the offset that the new message will be written to. */ + msg_offset = strlen(parser-info_log); + ralloc_asprintf_append(parser-info_log, %u:%u(%u): preprocessor %s: , locp-source, @@ -40,6 +49,11 @@ glcpp_msg (YYLTYPE *locp, glcpp_parser_t *parser, bool error, ralloc_vasprintf_append(parser-info_log, fmt, ap); + msg = parser-info_log[msg_offset]; + /* Report the error via GL_ARB_debug_output. */ + if (error) + _mesa_shader_error(ctx, SHADER_ERROR_UNKNOWN, msg, strlen(msg)); + ralloc_strcat(parser-info_log, \n); } -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/9] util: fix undefined behavior
On Sun, Apr 8, 2012 at 4:28 AM, Tolga Dalman tolga.dal...@googlemail.com wrote: On 06.04.2012 17:38, nobled wrote: On Mon, Apr 2, 2012 at 7:40 AM, Tolga Dalman tolga.dal...@googlemail.com wrote: Hi, On 02.04.2012 00:24, nobled wrote: #define LIST_FOR_EACH_ENTRY(pos, head, member) \ - for (pos = container_of((head)-next, pos, member); \ + for (pos = NULL, pos = container_of((head)-next, pos, member); \ pos-member != (head); \ pos = container_of(pos-member.next, pos, member)) The container_of macro is obviously error-prone and leads to future problems. Your patch works around that buggy API instead of really fixing it. container_of could be defined using the offsetof macro, i.e., #define container_of(ptr, type, member) \ (void *)((char *)(ptr) - offsetof(type, member)) As far as I can see, container_of is only used sparsely in mesa, so applying my proposal should be possible quite easily. Not really. container_of() is only used *directly* in this one header; but changing it to require a type parameter requires also changing all the macros that use it in turn, which actually are used widely in mesa. Widely is a bit exaggerated. Basically, it is only used in the LIST_FOR_EACH macros. A quick grep results: grep [[:space:]]LIST_FOR_EACH * -R|grep -v u_double_list.h|wc -l 35 I also noticed, that LIST_FOR_EACH_ENTRY_FROM and LIST_FOR_EACH_ENTRY_FROM_REV are not used anywhere in the mesa source. Adding the type name to every use of the LIST_FOR_EACH_* macros also introduces redundancy and the possibility of error, e.g. if the containing ever changes but not every use of the macro is updated, there's no compile error but it'll go wrong at runtime. That can't happen with the current version of it. Easy: use typeof(), i.e., the LIST_FOR_EACH_* macros are updated as follows: Love to, but typeof() is a GNU extension: http://gcc.gnu.org/onlinedocs/gcc/Typeof.html Unless MSVC suddenly started supporting it, it's a no-go in gallium code (which is supposed to be portable so it has to stick to C89). #define LIST_FOR_EACH_ENTRY(pos, head, member) \ for (pos = container_of((head)-next, typeof(pos), member); \ pos-member != (head); \ pos = container_of(pos-member.next, typeof(pos), member)) In the long term, the container_of/LIST_FOR_EACH mess should go away. Instead, just implement the clean linux kernel list_for_each implementation (whence, I presume, the Mesa list is borrowed from). container_of() just has one basic caveat that we can easily satisfy, since like you said, it isn't directly used in many places, and I don't think future problems are actually likely--any misuse will trigger uninitialized warnings like the above so they're easily caught, unlike possible typename mistakes. Agreed. Thanks and best regards Tolga Dalman ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/9] util: fix undefined behavior
On Mon, Apr 2, 2012 at 7:40 AM, Tolga Dalman tolga.dal...@googlemail.com wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, On 02.04.2012 00:24, nobled wrote: #define LIST_FOR_EACH_ENTRY(pos, head, member) \ - for (pos = container_of((head)-next, pos, member); \ + for (pos = NULL, pos = container_of((head)-next, pos, member); \ pos-member != (head); \ pos = container_of(pos-member.next, pos, member)) The container_of macro is obviously error-prone and leads to future problems. Your patch works around that buggy API instead of really fixing it. container_of could be defined using the offsetof macro, i.e., #define container_of(ptr, type, member) \ (void *)((char *)(ptr) - offsetof(type, member)) As far as I can see, container_of is only used sparsely in mesa, so applying my proposal should be possible quite easily. Not really. container_of() is only used *directly* in this one header; but changing it to require a type parameter requires also changing all the macros that use it in turn, which actually are used widely in mesa. Adding the type name to every use of the LIST_FOR_EACH_* macros also introduces redundancy and the possibility of error, e.g. if the containing ever changes but not every use of the macro is updated, there's no compile error but it'll go wrong at runtime. That can't happen with the current version of it. container_of() just has one basic caveat that we can easily satisfy, since like you said, it isn't directly used in many places, and I don't think future problems are actually likely--any misuse will trigger uninitialized warnings like the above so they're easily caught, unlike possible typename mistakes. Best regards Tolga Dalman -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.19 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJPeZAkAAoJEI0vwg8AaIlUzlQH/3dCLXcdoFvE9M7KtC/BEmhT Qw+sYrG77VvQaMhB5uM6DpNkEZUkXiZVqObarISwQvup0Wwarvr9QLQu5b2LYzRI NqHPEth16ndUnYDAuMeK0x7hc2/Vu7B6D48Q8n9EOs8gezQN3HG9fbswV+u40sl4 qj3HV7bP9IsYWe+fQOzx5k3NzaJQUjqPX5abfvjav4awV3SwHqm+EEaCEOQp6DYx p0snUq9JnVY3HzA+6bu7aOT6p4J8RvchscPCb/6YjxNa35YhtpeYn5Lgg6AnXYQu suIil4b8+/eDh9rHOB7DuFHRGoRVUP2NhVko0DbT7yLbKbJRpX9CVtKVbhc7qZo= =60Yn -END PGP SIGNATURE- ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/9] util: fix undefined behavior
container_of() can legally return anything, even invalid addresses that cause segfaults, when 'sample' is an uninitialized pointer. Bug exposed by clang. NOTE: This is a candidate for the 8.0 branch. --- src/gallium/auxiliary/util/u_double_list.h | 15 ++- 1 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/gallium/auxiliary/util/u_double_list.h b/src/gallium/auxiliary/util/u_double_list.h index 2384c36..9d1129b 100644 --- a/src/gallium/auxiliary/util/u_double_list.h +++ b/src/gallium/auxiliary/util/u_double_list.h @@ -105,6 +105,11 @@ static INLINE void list_delinit(struct list_head *item) #define LIST_IS_EMPTY(__list) \ ((__list)-next == (__list)) +/** + * Cast from a pointer to a member of a struct back to the containing struct. + * + * 'sample' MUST be initialized, or else the result is undefined! + */ #ifndef container_of #define container_of(ptr, sample, member) \ (void *)((char *)(ptr) \ @@ -112,29 +117,29 @@ static INLINE void list_delinit(struct list_head *item) #endif #define LIST_FOR_EACH_ENTRY(pos, head, member) \ - for (pos = container_of((head)-next, pos, member); \ + for (pos = NULL, pos = container_of((head)-next, pos, member); \ pos-member != (head); \ pos = container_of(pos-member.next, pos, member)) #define LIST_FOR_EACH_ENTRY_SAFE(pos, storage, head, member) \ - for (pos = container_of((head)-next, pos, member), \ + for (pos = NULL, pos = container_of((head)-next, pos, member), \ storage = container_of(pos-member.next, pos, member); \ pos-member != (head); \ pos = storage, storage = container_of(storage-member.next, storage, member)) #define LIST_FOR_EACH_ENTRY_SAFE_REV(pos, storage, head, member) \ - for (pos = container_of((head)-prev, pos, member), \ + for (pos = NULL, pos = container_of((head)-prev, pos, member), \ storage = container_of(pos-member.prev, pos, member); \ pos-member != (head); \ pos = storage, storage = container_of(storage-member.prev, storage, member)) #define LIST_FOR_EACH_ENTRY_FROM(pos, start, head, member) \ - for (pos = container_of((start), pos, member); \ + for (pos = NULL, pos = container_of((start), pos, member); \ pos-member != (head); \ pos = container_of(pos-member.next, pos, member)) #define LIST_FOR_EACH_ENTRY_FROM_REV(pos, start, head, member) \ - for (pos = container_of((start), pos, member); \ + for (pos = NULL, pos = container_of((start), pos, member); \ pos-member != (head); \ pos = container_of(pos-member.prev, pos, member)) -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/9] util: fix uninitialized table
Most of the 256 values in the 'generic_to_slot' table were supposed to be initialized with the default value 0xff, but were left at zero (from CALLOC_STRUCT()) instead. Noticed by clang: u_linkage.h:60:31: warning: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to provide an explicit length? [-Wsizeof-pointer-memaccess] memset(table, 0xff, sizeof(table)); ~ ^ Also fix a signed/unsigned comparison and a comment typo here. NOTE: This is a candidate for the 8.0 branch. --- src/gallium/auxiliary/util/u_linkage.h |9 + src/gallium/drivers/nvfx/nvfx_fragprog.c |3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gallium/auxiliary/util/u_linkage.h b/src/gallium/auxiliary/util/u_linkage.h index 43ec917..7b23123 100644 --- a/src/gallium/auxiliary/util/u_linkage.h +++ b/src/gallium/auxiliary/util/u_linkage.h @@ -49,15 +49,16 @@ unsigned util_semantic_set_from_program_file(struct util_semantic_set *set, cons * * num_slots is the size of the layout array and hardware limit instead. * - * efficient_slots == 0 or efficient_solts == num_slots are typical settings. + * efficient_slots == 0 or efficient_slots == num_slots are typical settings. */ void util_semantic_layout_from_set(unsigned char *layout, const struct util_semantic_set *set, unsigned efficient_slots, unsigned num_slots); static INLINE void -util_semantic_table_from_layout(unsigned char *table, unsigned char *layout, unsigned char first_slot_value, unsigned char num_slots) +util_semantic_table_from_layout(unsigned char *table, size_t table_size, unsigned char *layout, +unsigned char first_slot_value, unsigned char num_slots) { - int i; - memset(table, 0xff, sizeof(table)); + unsigned char i; + memset(table, 0xff, table_size); for(i = 0; i num_slots; ++i) table[layout[i]] = first_slot_value + i; diff --git a/src/gallium/drivers/nvfx/nvfx_fragprog.c b/src/gallium/drivers/nvfx/nvfx_fragprog.c index dbd7c77..0babcbb 100644 --- a/src/gallium/drivers/nvfx/nvfx_fragprog.c +++ b/src/gallium/drivers/nvfx/nvfx_fragprog.c @@ -977,7 +977,8 @@ nvfx_fragprog_prepare(struct nvfx_context* nvfx, struct nvfx_fpc *fpc) if(fpc-fp-num_slots num_texcoords) return FALSE; util_semantic_layout_from_set(fpc-fp-slot_to_generic, set, 0, num_texcoords); - util_semantic_table_from_layout(fpc-generic_to_slot, fpc-fp-slot_to_generic, 0, num_texcoords); + util_semantic_table_from_layout(fpc-generic_to_slot, sizeof fpc-generic_to_slot, +fpc-fp-slot_to_generic, 0, num_texcoords); memset(fpc-fp-slot_to_fp_input, 0xff, sizeof(fpc-fp-slot_to_fp_input)); -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/9] egl: fix uninitialized values
Noticed by clang: eglimage.c:48:28: warning: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to dereference it? [-Wsizeof-pointer-memaccess] memset(attrs, 0, sizeof(attrs)); ~^ NOTE: This is a candidate for the 8.0 branch. --- src/egl/main/eglimage.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/egl/main/eglimage.c b/src/egl/main/eglimage.c index d5deae7..1174d0a 100644 --- a/src/egl/main/eglimage.c +++ b/src/egl/main/eglimage.c @@ -45,7 +45,7 @@ _eglParseImageAttribList(_EGLImageAttribs *attrs, _EGLDisplay *dpy, (void) dpy; - memset(attrs, 0, sizeof(attrs)); + memset(attrs, 0, sizeof(*attrs)); attrs-ImagePreserved = EGL_FALSE; attrs-GLTextureLevel = 0; attrs-GLTextureZOffset = 0; -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/9] mesa: delete tautological compare
Noticed by clang: main/extensions.c:934:14: warning: comparison of unsigned expression 0 is always false [-Wtautological-compare] if (index 0) ~ ^ ~ Also don't cast away const needlessly in this function. --- src/mesa/main/extensions.c |5 + 1 files changed, 1 insertions(+), 4 deletions(-) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index b02a49d..6354ad3 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -931,14 +931,11 @@ _mesa_get_enabled_extension(struct gl_context *ctx, GLuint index) size_t n; const struct extension *i; - if (index 0) - return NULL; - base = (GLboolean*) ctx-Extensions; n = 0; for (i = extension_table; i-name != 0; ++i) { if (n == index base[i-offset]) { -return (GLubyte*) i-name; +return (const GLubyte*) i-name; } else if (base[i-offset]) { ++n; } -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 5/9] mesa: fix truncated value warning
Silences a clang warning: format_pack.c:2546:30: warning: implicit conversion from 'int' to 'GLubyte' (aka 'unsigned char') changes value from 65535 to 255 [-Wconstant-conversion] d[i] = d[i] ? 0x : 0x0; ~ ^~ --- src/mesa/main/format_pack.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/mesa/main/format_pack.c b/src/mesa/main/format_pack.c index 85b2c69..9df9b14 100644 --- a/src/mesa/main/format_pack.c +++ b/src/mesa/main/format_pack.c @@ -2543,7 +2543,7 @@ _mesa_pack_colormask(gl_format format, const GLubyte colorMask[4], void *dst) if (bits == 8) { GLubyte *d = (GLubyte *) dst; for (i = 0; i bytes; i++) { - d[i] = d[i] ? 0x : 0x0; + d[i] = d[i] ? 0xff : 0x0; } } else if (bits == 16) { -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 6/9] i965: fix typo
Noticed by clang: brw_wm_surface_state.c:330:30: warning: initializer overrides prior initialization of this subobject [-Winitializer-overrides] [MESA_FORMAT_Z24_S8] = 0, ^ brw_wm_surface_state.c:326:30: note: previous initialization is here [MESA_FORMAT_Z24_S8] = 0, ^ --- src/mesa/drivers/dri/i965/brw_wm_surface_state.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index 51d3a46..314e2e6 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -327,7 +327,7 @@ brw_format_for_mesa_format(gl_format mesa_format) [MESA_FORMAT_S8_Z24] = 0, [MESA_FORMAT_Z16] = 0, [MESA_FORMAT_X8_Z24] = 0, - [MESA_FORMAT_Z24_S8] = 0, + [MESA_FORMAT_Z24_X8] = 0, [MESA_FORMAT_Z32] = 0, [MESA_FORMAT_S8] = 0, -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 7/9] st/vega: silence enum cast warnings
clang warns on these: stroker.c:626:19: warning: implicit conversion from enumeration type 'VGPathCommand' to different enumeration type 'VGPathSegment' [-Wconversion] No change in the underlying value. --- src/gallium/state_trackers/vega/stroker.c |9 + 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gallium/state_trackers/vega/stroker.c b/src/gallium/state_trackers/vega/stroker.c index d89b6cf..b9f0f2c 100644 --- a/src/gallium/state_trackers/vega/stroker.c +++ b/src/gallium/state_trackers/vega/stroker.c @@ -623,7 +623,7 @@ static INLINE void create_round_join(struct stroker *stroker, /*stroker_emit_line_to(stroker, nx, ny);*/ - arc_init(arc, VG_SCCWARC_TO_ABS, + arc_init(arc, VG_SCCWARC_TO, x1, y1, x2, y2, width/2, height/2, 0); arc_stroker_emit(arc, stroker, matrix); } @@ -1097,12 +1097,12 @@ static void stroker_process_subpath(struct stroker *stroker) matrix_load_identity(matrix); stroker_emit_move_to(stroker, cx + offset, cy); - arc_init(arc, VG_SCCWARC_TO_ABS, + arc_init(arc, VG_SCCWARC_TO, cx + offset, cy, cx - offset, cy, offset, offset, 0); arc_stroker_emit(arc, stroker, matrix); - arc_init(arc, VG_SCCWARC_TO_ABS, + arc_init(arc, VG_SCCWARC_TO, cx - offset, cy, cx + offset, cy, offset, offset, 0); @@ -1291,7 +1291,8 @@ void stroker_init(struct stroker *stroker, stroker-path = path_create(VG_PATH_DATATYPE_F, 1.0f, 0.0f, 0, 0, VG_PATH_CAPABILITY_ALL); - stroker-last_cmd = VG_CLOSE_PATH; + /* Initialize with an invalid value */ + stroker-last_cmd = (VGPathCommand)0; } void dash_stroker_init(struct stroker *str, -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 8/9] st/vega: fix uninitialized values
C still treats array arguments exactly like pointer arguments. By sheer coincidence, this still worked fine on 64-bit machines where 2 * sizeof(float) == sizeof(void*), but not on 32-bit. Noticed by clang: text.c:76:51: warning: sizeof on array function parameter will return size of 'const VGfloat *' (aka 'const float *') instead of 'const VGfloat [2]' [-Wsizeof-array-argument] memcpy(glyph-glyph_origin, glyphOrigin, sizeof(glyphOrigin)); NOTE: This is a candidate for the 8.0 branch. --- src/gallium/state_trackers/vega/text.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/state_trackers/vega/text.c b/src/gallium/state_trackers/vega/text.c index a183933..4ed5062 100644 --- a/src/gallium/state_trackers/vega/text.c +++ b/src/gallium/state_trackers/vega/text.c @@ -73,8 +73,8 @@ static void add_glyph(struct vg_font *font, glyph = CALLOC_STRUCT(vg_glyph); glyph-object = obj; glyph-is_hinted = isHinted; - memcpy(glyph-glyph_origin, glyphOrigin, sizeof(glyphOrigin)); - memcpy(glyph-escapement, escapement, sizeof(escapement)); + memcpy(glyph-glyph_origin, glyphOrigin, sizeof(glyph-glyph_origin)); + memcpy(glyph-escapement, escapement, sizeof(glyph-escapement)); cso_hash_insert(font-glyphs, (unsigned) glyphIndex, glyph); } -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 9/9] egl-static: fix printf warning
Noticed by clang: egl_st.c:57:50: warning: field precision should have type 'int', but argument has type 'size_t' (aka 'unsigned long') [-Wformat] ret = util_snprintf(path, sizeof(path), %.*s/%s UTIL_DL_EXT, ~~^~ NOTE: This is a candidate for the 8.0 branch. --- src/gallium/targets/egl-static/egl_st.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/src/gallium/targets/egl-static/egl_st.c b/src/gallium/targets/egl-static/egl_st.c index 81d7bb4..fddb809 100644 --- a/src/gallium/targets/egl-static/egl_st.c +++ b/src/gallium/targets/egl-static/egl_st.c @@ -54,8 +54,9 @@ dlopen_gl_lib_cb(const char *dir, size_t len, void *callback_data) int ret; if (len) { + assert(len = INT_MAX path is insanely long!); ret = util_snprintf(path, sizeof(path), %.*s/%s UTIL_DL_EXT, -len, dir, name); +(int)len, dir, name); } else { ret = util_snprintf(path, sizeof(path), %s UTIL_DL_EXT, name); -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/2] glapi: add GL_ARB_depth_buffer_float
--- These are based on the sorting-the-xml patches I forgot to push a while back: http://lists.freedesktop.org/archives/mesa-dev/2012-January/017610.html Which I'll push along with these if they're okay to commit. src/mapi/glapi/gen/ARB_depth_buffer_float.xml | 15 +++ src/mapi/glapi/gen/Makefile |1 + src/mapi/glapi/gen/gl_API.xml |3 ++- 3 files changed, 18 insertions(+), 1 deletions(-) create mode 100644 src/mapi/glapi/gen/ARB_depth_buffer_float.xml diff --git a/src/mapi/glapi/gen/ARB_depth_buffer_float.xml b/src/mapi/glapi/gen/ARB_depth_buffer_float.xml new file mode 100644 index 000..7d25f6b --- /dev/null +++ b/src/mapi/glapi/gen/ARB_depth_buffer_float.xml @@ -0,0 +1,15 @@ +?xml version=1.0? +!DOCTYPE OpenGLAPI SYSTEM gl_API.dtd + +OpenGLAPI + +category name=GL_ARB_depth_buffer_float number=43 + +enum name=DEPTH_COMPONENT32Fvalue = 0x8CAC/ +enum name=DEPTH32F_STENCIL8 value = 0x8CAD/ + +enum name=FLOAT_32_UNSIGNED_INT_24_8_REV value = 0x8DAD/ + +/category + +/OpenGLAPI diff --git a/src/mapi/glapi/gen/Makefile b/src/mapi/glapi/gen/Makefile index fb9dab9..244c67e 100644 --- a/src/mapi/glapi/gen/Makefile +++ b/src/mapi/glapi/gen/Makefile @@ -66,6 +66,7 @@ API_XML = \ ARB_color_buffer_float.xml \ ARB_copy_buffer.xml \ ARB_debug_output.xml \ + ARB_depth_buffer_float.xml \ ARB_depth_clamp.xml \ ARB_draw_buffers_blend.xml \ ARB_draw_elements_base_vertex.xml \ diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml index e151347..e220e44 100644 --- a/src/mapi/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml @@ -7898,7 +7898,8 @@ !-- 40. GL_ARB_half_float_pixel -- !-- 41. GL_ARB_texture_float -- !-- 42. GL_ARB_pixel_buffer_object -- -!-- 43. GL_ARB_depth_buffer_float -- + +xi:include href=ARB_depth_buffer_float.xml xmlns:xi=http://www.w3.org/2001/XInclude/ xi:include href=ARB_draw_instanced.xml xmlns:xi=http://www.w3.org/2001/XInclude/ -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] glapi: add GL_ARB_texture_float
And add some missing core GL 3.0 enums that came from this extension, too. --- src/mapi/glapi/gen/ARB_texture_float.xml | 36 ++ src/mapi/glapi/gen/GL3x.xml |7 + src/mapi/glapi/gen/Makefile |1 + src/mapi/glapi/gen/gl_API.xml|4 ++- 4 files changed, 47 insertions(+), 1 deletions(-) create mode 100644 src/mapi/glapi/gen/ARB_texture_float.xml diff --git a/src/mapi/glapi/gen/ARB_texture_float.xml b/src/mapi/glapi/gen/ARB_texture_float.xml new file mode 100644 index 000..5db7691 --- /dev/null +++ b/src/mapi/glapi/gen/ARB_texture_float.xml @@ -0,0 +1,36 @@ +?xml version=1.0? +!DOCTYPE OpenGLAPI SYSTEM gl_API.dtd + +OpenGLAPI + +category name=GL_ARB_texture_float number=41 + +enum name=TEXTURE_RED_TYPE_ARB value=0x8C10/ +enum name=TEXTURE_GREEN_TYPE_ARBvalue=0x8C11/ +enum name=TEXTURE_BLUE_TYPE_ARB value=0x8C12/ +enum name=TEXTURE_ALPHA_TYPE_ARBvalue=0x8C13/ +enum name=TEXTURE_LUMINANCE_TYPE_ARB value=0x8C14/ +enum name=TEXTURE_INTENSITY_TYPE_ARB value=0x8C15/ +enum name=TEXTURE_DEPTH_TYPE_ARBvalue=0x8C16/ + +!-- The unsuffixed version of this is in ARB_framebuffer_object.xml -- +enum name=UNSIGNED_NORMALIZED_ARB value=0x8C17/ + +!-- Note only the RGBA/RGB formats have unsuffixed core GL equivalents, + since LUMINANCE/INTENSITY/ALPHA formats were deprecated. -- +enum name=RGBA32F_ARB value=0x8814/ +enum name=RGB32F_ARBvalue=0x8815/ +enum name=ALPHA32F_ARB value=0x8816/ +enum name=INTENSITY32F_ARB value=0x8817/ +enum name=LUMINANCE32F_ARB value=0x8818/ +enum name=LUMINANCE_ALPHA32F_ARBvalue=0x8819/ +enum name=RGBA16F_ARB value=0x881A/ +enum name=RGB16F_ARBvalue=0x881B/ +enum name=ALPHA16F_ARB value=0x881C/ +enum name=INTENSITY16F_ARB value=0x881D/ +enum name=LUMINANCE16F_ARB value=0x881E/ +enum name=LUMINANCE_ALPHA16F_ARBvalue=0x881F/ + +/category + +/OpenGLAPI diff --git a/src/mapi/glapi/gen/GL3x.xml b/src/mapi/glapi/gen/GL3x.xml index f74e360..86a9a2c 100644 --- a/src/mapi/glapi/gen/GL3x.xml +++ b/src/mapi/glapi/gen/GL3x.xml @@ -35,6 +35,13 @@ enum name=CLAMP_READ_COLOR value=0x891C/ enum name=FIXED_ONLY value=0x891D/ enum name=MAX_VARYING_COMPONENTS value=0x8B4B/ + enum name=TEXTURE_RED_TYPE value=0x8C10/ + enum name=TEXTURE_GREEN_TYPE value=0x8C11/ + enum name=TEXTURE_BLUE_TYPEvalue=0x8C12/ + enum name=TEXTURE_ALPHA_TYPE value=0x8C13/ + enum name=TEXTURE_LUMINANCE_TYPE value=0x8C14/ + enum name=TEXTURE_INTENSITY_TYPE value=0x8C15/ + enum name=TEXTURE_DEPTH_TYPE value=0x8C16/ enum name=TEXTURE_1D_ARRAY value=0x8C18/ enum name=PROXY_TEXTURE_1D_ARRAY value=0x8C19/ enum name=TEXTURE_2D_ARRAY value=0x8C1A/ diff --git a/src/mapi/glapi/gen/Makefile b/src/mapi/glapi/gen/Makefile index 244c67e..49dfd75 100644 --- a/src/mapi/glapi/gen/Makefile +++ b/src/mapi/glapi/gen/Makefile @@ -82,6 +82,7 @@ API_XML = \ ARB_sync.xml \ ARB_texture_buffer_object.xml \ ARB_texture_compression_rgtc.xml \ + ARB_texture_float.xml \ ARB_texture_rg.xml \ ARB_texture_storage.xml \ ARB_vertex_array_object.xml \ diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml index e220e44..2cfe40a 100644 --- a/src/mapi/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml @@ -7896,7 +7896,9 @@ xi:include href=ARB_color_buffer_float.xml xmlns:xi=http://www.w3.org/2001/XInclude/ !-- 40. GL_ARB_half_float_pixel -- -!-- 41. GL_ARB_texture_float -- + +xi:include href=ARB_texture_float.xml xmlns:xi=http://www.w3.org/2001/XInclude/ + !-- 42. GL_ARB_pixel_buffer_object -- xi:include href=ARB_depth_buffer_float.xml xmlns:xi=http://www.w3.org/2001/XInclude/ -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] intel: Fix a case when mapping large texture fails
On Thu, Mar 15, 2012 at 2:26 PM, Anuj Phogat anuj.pho...@gmail.com wrote: On Wed, Mar 7, 2012 at 4:28 PM, Anuj Phogat anuj.pho...@gmail.com wrote: On Mon 27 Feb 2012 11:45:46 AM PST, Anuj Phogat wrote: This patch handles a case when mapping a large texture fails in drm_intel_gem_bo_map_gtt(). These changes avoid assertion failure later in the driver as reported in following bugs: https://bugs.freedesktop.org/show_bug.cgi?id=44970 https://bugs.freedesktop.org/show_bug.cgi?id=46303 Signed-off-by: Anuj Phogat anuj.pho...@gmail.com I've been testing this since yesterday applied on top of the 8.0 branch, and compiz is still crashing for me (bug 46303). --- src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 26 --- src/mesa/drivers/dri/intel/intel_regions.c | 7 - 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c index 5290da4..507702a 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c @@ -702,15 +702,20 @@ intel_miptree_map_gtt(struct intel_context *intel, y /= bh; base = intel_region_map(intel, mt-region, map-mode); - /* Note that in the case of cube maps, the caller must have passed the slice - * number referencing the face. - */ - intel_miptree_get_image_offset(mt, level, 0, slice, image_x, image_y); - x += image_x; - y += image_y; - map-stride = mt-region-pitch * mt-cpp; - map-ptr = base + y * map-stride + x * mt-cpp; + if (base == NULL) + map-ptr = NULL; + else { + /* Note that in the case of cube maps, the caller must have passed the + * slice number referencing the face. + */ + intel_miptree_get_image_offset(mt, level, 0, slice, image_x, image_y); + x += image_x; + y += image_y; + + map-stride = mt-region-pitch * mt-cpp; + map-ptr = base + y * map-stride + x * mt-cpp; + } DBG(%s: %d,%d %dx%d from mt %p (%s) %d,%d = %p/%d\n, __FUNCTION__, map-x, map-y, map-w, map-h, @@ -1063,6 +1068,11 @@ intel_miptree_map(struct intel_context *intel, *out_ptr = map-ptr; *out_stride = map-stride; + + if (map-ptr == NULL) { + mt-level[level].slice[slice].map = NULL; + free(map); + } } void diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c index bc83649..982d6cb 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.c +++ b/src/mesa/drivers/dri/intel/intel_regions.c @@ -124,7 +124,7 @@ intel_region_map(struct intel_context *intel, struct intel_region *region, */ _DBG(%s %p\n, __FUNCTION__, region); - if (!region-map_refcount++) { + if (!region-map_refcount) { intel_flush(intel-ctx); if (region-tiling != I915_TILING_NONE) @@ -133,7 +133,10 @@ intel_region_map(struct intel_context *intel, struct intel_region *region, drm_intel_bo_map(region-bo, true); region-map = region-bo-virtual; - ++intel-num_mapped_regions; + if (region-map) { + ++intel-num_mapped_regions; + region-map_refcount++; + } } return region-map; Any comments on this patch? I am planning to push this today. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] Mesa (master): mesa: add back glGetnUniform*v() overflow error reporting
On Thu, Mar 15, 2012 at 5:27 PM, Ian Romanick i...@freedesktop.org wrote: On 03/15/2012 01:18 PM, Kenneth Graunke wrote: On 03/15/2012 11:26 AM, Ian Romanick wrote: On 03/13/2012 11:35 AM, Dylan Noblesmith wrote: Module: Mesa Branch: master Commit: b536ac6b2bc54ad9bb6e58fbd307055e419a288f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b536ac6b2bc54ad9bb6e58fbd307055e419a288f Author: Dylan Noblesmithnob...@dreamwidth.org Date: Thu Dec 22 21:05:38 2011 + mesa: add back glGetnUniform*v() overflow error reporting The error was removed in: commit 719909698c67c287a393d2380278e7b7495ae018 Author: Ian Romanickian.d.roman...@intel.com Date: Tue Oct 18 16:01:49 2011 -0700 mesa: Rewrite the way uniforms are tracked and handled The GL_ARB_robustness spec doesn't say the implementation should truncate the output, so just return after setting the required error like it did before the above commit. This patch is wrong. Please revert. The ARB_robustness spec specifically says: The commands void GetUniformfv(uint program, int location, float *params); void GetnUniformfvARB(uint program, int location, sizei bufSize, float *params); void GetUniformiv(uint program, int location, int *params); void GetnUniformivARB(uint program, int location, sizei bufSize, int *params); void GetUniformuiv(uint program, int location, uint *params); void GetnUniformuivARB(uint program, int location, sizei bufSize, uint *params); void GetUniformdv(uint program, int location, uint *params); void GetnUniformdvARB(uint program, int location, sizei bufSize, uint *params); return the value or values of the uniform at location location of the default uniform block for program object program in the array params. GetnUniformfvARB, GetnUniformivARB, GetnUniformuivARB and GetnUniformdvARB do not write more than bufSize bytes into params. The do not write more than bufSize bytes is the important bit. And zero is not more than bufSize, and we're writing zero bytes here, so I should have quoted more extensively though, you're right. Specifically: Errors [...] GetnUniformfvARB, GetnUniformivARB, GetnUniformuivARB and GetnUniformdvARB share all the errors of their unsized buffer query counterparts with the addition that INVALID_OPERATION is generated if the buffer size required to fill all the requested data is less than bufSize. and Issues [...] 5. If a new query with an explicit buffer size is called and the buffer size is not sufficient to return the data, what happens? RESOLVED: Return an INVALID_OPERATION error and ignore the query. Sorry for being too vague in the commit log; I should've said the spec *explicitly forbids* the implementation from doing anything at all when bufSize is not sufficient. In the future, please wait for at least one Reviewed-by when changing API behavior, and quote spec language in the code to justify such changes. In fairness, those patches had sat on the list for a long time, which seems to invoke the silence is consent rule. We should have reviewed it earlier. Yeah... I'm not sure how I missed these. I also noticed that there was review on the list from Brian, but that didn't end up as a Reviewed-by in the commit message. So, I'll take the last part back. :) ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] mesa: add back glGetnUniformfv() overflow error reporting
ping x2 Also an 8.0 candidate, now that 8.0 exists. On Mon, Jan 16, 2012 at 6:52 PM, nobled nob...@dreamwidth.org wrote: ping? On Thu, Dec 22, 2011 at 4:34 PM, nob...@dreamwidth.org wrote: The error was erroneously removed in this commit: 719909698c67c287a393d2380278e7b7495ae018 mesa: Rewrite the way uniforms are tracked and handled You also aren't even supposed to truncate the output to 'bufSize', so just return like before. Also fixup an old comment and add an assert. --- (This function has a random mixture of tabs+spaces and pure spaces for indentation, so I had no idea which style to use...) src/mesa/main/uniform_query.cpp | 16 src/mesa/main/uniforms.c | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp index 33ba53c..8e58fc0 100644 --- a/src/mesa/main/uniform_query.cpp +++ b/src/mesa/main/uniform_query.cpp @@ -203,10 +203,18 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location, const union gl_constant_value *const src = uni-storage[offset * elements]; - unsigned bytes = sizeof(uni-storage[0]) * elements; - if (bytes (unsigned) bufSize) { - elements = bufSize / sizeof(uni-storage[0]); - bytes = bufSize; + assert(returnType == GLSL_TYPE_FLOAT || returnType == GLSL_TYPE_INT || + returnType == GLSL_TYPE_UINT); + /* The three (currently) supported types all have the same size, + * which is of course the same as their union. That'll change + * with glGetUniformdv()... + */ + unsigned bytes = sizeof(src[0]) * elements; + if (bufSize 0 || bytes (unsigned) bufSize) { + _mesa_error( ctx, GL_INVALID_OPERATION, + glGetnUniformfvARB(out of bounds: bufSize is %d, + but %u bytes are required), bufSize, bytes ); + return; } /* If the return type and the uniform's native type are compatible, diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c index 685c0f1..981874e 100644 --- a/src/mesa/main/uniforms.c +++ b/src/mesa/main/uniforms.c @@ -478,7 +478,7 @@ _mesa_GetnUniformdvARB(GLhandleARB program, GLint location, (void) params; /* - _mesa_get_uniform(ctx, program, location, bufSize, GL_DOUBLE, params); + _mesa_get_uniform(ctx, program, location, bufSize, GLSL_TYPE_DOUBLE, params); */ _mesa_error(ctx, GL_INVALID_OPERATION, glGetUniformdvARB (GL_ARB_gpu_shader_fp64 not implemented)); -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] Doing 8.0.1 release?
On Mon, Mar 12, 2012 at 8:05 PM, Jakob Bornecrantz ja...@vmware.com wrote: Hi all We well over due for a 8.0.1 release, so I thought we do it aggressively this week. A quick rc tomorrow and a release on Thursday or Friday? Is that okay with people, comments please? This should be cherry-picked, right? commit b60120608f6ddf4098bc324363197c979ee04cb7 Author: David Fries da...@fries.net Set close on exec flag FD_CLOEXEC I think most of the marked candidates since the branch that show up in `git log origin/8.0..origin/master --grep=NOTE` are still only in master... And this in particular is reportedly vital[1] for llvmpipe FBO rendering: commit 5a70e12fc0897a3178c73b20d99fc0f11b180374 Author: Brian Paul bri...@vmware.com st/mesa: don't set PIPE_BIND_DISPLAY_TARGET for user-created renderbuffers [1] http://lists.freedesktop.org/archives/mesa-dev/2012-March/019690.html Cheers, Jakob. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] nouveau_vieux: don't use nested functions
It's a GNU extension that isn't supported by clang right now: http://gcc.gnu.org/onlinedocs/gcc-4.6.3/gcc/Nested-Functions.html http://clang.llvm.org/docs/UsersManual.html#c_unimpl_gcc With this, clang now compiles the nouveau classic driver. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=44061 (Types changed from e.g. 'unsigned char' to 'GLubyte' so that the types can be concatenated to form a unique function name without any whitespace interfering.) --- src/mesa/drivers/dri/nouveau/nouveau_array.c| 67 ++- src/mesa/drivers/dri/nouveau/nouveau_render_t.c | 67 +++ 2 files changed, 73 insertions(+), 61 deletions(-) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_array.c b/src/mesa/drivers/dri/nouveau/nouveau_array.c index 17e6d16..d9253b0 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_array.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_array.c @@ -29,54 +29,71 @@ #include nouveau_array.h #include nouveau_bufferobj.h +#define EXTRACT(in_t, out_t) extract_func_##in_t##_to_##out_t + +#define EXTRACT_FUNC(in_t, out_t, k) \ +static out_t EXTRACT(in_t, out_t) \ +(struct nouveau_array *a, int i, int j) { \ + in_t x = ((in_t *)(a-buf + i * a-stride))[j]; \ + \ + return (out_t)x / (k); \ +} + +EXTRACT_FUNC(GLchar, unsigned, 1); +EXTRACT_FUNC(GLchar, float, SCHAR_MAX); +EXTRACT_FUNC(GLubyte, unsigned, 1); +EXTRACT_FUNC(GLubyte, float, UCHAR_MAX); +EXTRACT_FUNC(GLshort, unsigned, 1); +EXTRACT_FUNC(GLshort, float, SHRT_MAX); +EXTRACT_FUNC(GLushort, unsigned, 1); +EXTRACT_FUNC(GLushort, float, USHRT_MAX); +EXTRACT_FUNC(GLint, unsigned, 1); +EXTRACT_FUNC(GLint, float, INT_MAX); +EXTRACT_FUNC(GLuint, unsigned, 1); +EXTRACT_FUNC(GLuint, float, UINT_MAX); +EXTRACT_FUNC(GLfloat, unsigned, 1.0 / UINT_MAX); +EXTRACT_FUNC(GLfloat, float, 1); + +#undef EXTRACT_FUNC + static void get_array_extract(struct nouveau_array *a, extract_u_t *extract_u, extract_f_t *extract_f) { -#define EXTRACT(in_t, out_t, k) \ - ({ \ - auto out_t f(struct nouveau_array *, int, int); \ - out_t f(struct nouveau_array *a, int i, int j) {\ - in_t x = ((in_t *)(a-buf + i * a-stride))[j]; \ - \ - return (out_t)x / (k); \ - }; \ - f; \ - }); - switch (a-type) { case GL_BYTE: - *extract_u = EXTRACT(char, unsigned, 1); - *extract_f = EXTRACT(char, float, SCHAR_MAX); + *extract_u = EXTRACT(GLchar, unsigned); + *extract_f = EXTRACT(GLchar, float); break; case GL_UNSIGNED_BYTE: - *extract_u = EXTRACT(unsigned char, unsigned, 1); - *extract_f = EXTRACT(unsigned char, float, UCHAR_MAX); + *extract_u = EXTRACT(GLubyte, unsigned); + *extract_f = EXTRACT(GLubyte, float); break; case GL_SHORT: - *extract_u = EXTRACT(short, unsigned, 1); - *extract_f = EXTRACT(short, float, SHRT_MAX); + *extract_u = EXTRACT(GLshort, unsigned); + *extract_f = EXTRACT(GLshort, float); break; case GL_UNSIGNED_SHORT: - *extract_u = EXTRACT(unsigned short, unsigned, 1); - *extract_f = EXTRACT(unsigned short, float, USHRT_MAX); + *extract_u = EXTRACT(GLushort, unsigned); + *extract_f = EXTRACT(GLushort, float); break; case GL_INT: - *extract_u = EXTRACT(int, unsigned, 1); - *extract_f = EXTRACT(int, float, INT_MAX); + *extract_u = EXTRACT(GLint, unsigned); + *extract_f = EXTRACT(GLint, float); break; case GL_UNSIGNED_INT: - *extract_u = EXTRACT(unsigned int, unsigned, 1); - *extract_f = EXTRACT(unsigned int, float, UINT_MAX); + *extract_u = EXTRACT(GLuint, unsigned); + *extract_f = EXTRACT(GLuint, float); break; case GL_FLOAT: - *extract_u = EXTRACT(float, unsigned, 1.0 / UINT_MAX); - *extract_f = EXTRACT(float, float, 1); + *extract_u = EXTRACT(GLfloat, unsigned); + *extract_f = EXTRACT(GLfloat, float); break; default: assert(0); } } +#undef EXTRACT void nouveau_init_array(struct nouveau_array *a, int attr, int stride, diff --git
Re: [Mesa-dev] [PATCH v2 1/2] configure.ac: Enable GLX_USE_TLS if possible.
On Mon, Feb 13, 2012 at 5:10 AM, Zhigang Gong zhigang.g...@linux.intel.com wrote: On Sun, Feb 12, 2012 at 09:02:44AM -0500, nobled wrote: Judging by the patch that tried to change the tls_model: https://bugs.freedesktop.org/show_bug.cgi?id=35268 It looks like we'd need to disable enable_asm if the tls_model attribute isn't supported, since it would probably end up defaulting to general-dynamic for PIC code IIRC, and the assembly depends on it being initial-exec. Clang still doesn't support the tls_model attribute, and it doesn't fail compilation: it just gives a -Wattributes warning, so we might need to add '-Werror -Wattributes' (to catch the versions before -Wattributes was added, which give an 'unknown warning option' warning) to the test-compilation CFLAGS... Plus, the test would have to be moved to before enable_asm is decided and adds the -DUSE_X86_ASM, etc defines. Thanks for the comments, I refined the patch according to you and Dan's suggestion. Here is the new version. As to the version check of CLANG, I haven't handled it as I don't have the environment at hand. Could you help to add it? From 75de119cf92cb43cecd4813267ed0c76979ddef4 Mon Sep 17 00:00:00 2001 From: Zhigang Gong zhigang.g...@linux.intel.com Date: Mon, 13 Feb 2012 17:26:21 +0800 Subject: [PATCH 1/2 v2] configure.ac: Enable GLX_USE_TLS if possible. If the system support tls, we prefer to enable it by default just as xserver does. Actually, the checking code is copied from xserver/configure.ac. According to nobled's suggestion, move the checking before enable_asm. As if tls_model is not supported, then asm may can't work correctly. Then we check the tls model first, and if doesn't support it, we need to disable the asm code. Signed-off-by: Zhigang Gong zhigang.g...@linux.intel.com Reviewed-by: Dan Nicholson dbn.li...@gmail.com --- acinclude.m4 | 36 configure.ac | 25 ++--- 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index a5b389d..509de5b 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -117,3 +117,39 @@ if test $enable_pic != no; then fi AC_SUBST([PIC_FLAGS]) ])# MESA_PIC_FLAGS + +dnl TLS detection +AC_DEFUN([MESA_TLS], +[AC_MSG_CHECKING(for thread local storage (TLS) support) +AC_CACHE_VAL(ac_cv_tls, [ + ac_cv_tls=none + keywords=__thread __declspec(thread) + for kw in $keywords ; do + AC_TRY_COMPILE([int $kw test;], [], ac_cv_tls=$kw) + done +]) +AC_MSG_RESULT($ac_cv_tls) + +if test $ac_cv_tls != none; then + AC_MSG_CHECKING(for tls_model attribute support) + saved_CFLAGS=$CFLAGS + if test x$acv_mesa_CLANG = xyes; then Oh, I didn't mean you had to check *specifically* for clang; I just meant that adding those two flags would make sure that the test would fail correctly (until they support the attribute). you only need to check for GCC compatibility when adding -W flags, like the rest of the script does: `if test x$GCC = xyes; then`. + CFLAGS=$CFLAGS -Wattribute -Werror + fi + AC_CACHE_VAL(ac_cv_tls_model, [ + AC_TRY_COMPILE([int $ac_cv_tls __attribute__((tls_model(initial-exec))) test;], [], + ac_cv_tls_model=yes, ac_cv_tls_model=no) + ]) + CFLAGS=$saved_CFLAGS + AC_MSG_RESULT($ac_cv_tls_model) + + AC_MSG_CHECKING([for $CC option to define TLS variable]) + if test x$ac_cv_tls_model = xyes ; then + TLS=$ac_cv_tls' __attribute__((tls_model(\initial-exec\)))' + else + TLS=$ac_cv_tls + fi + DEFINES=$DEFINES -DTLS=\$TLS\ + AC_MSG_RESULT([$TLS]) +fi +]) diff --git a/configure.ac b/configure.ac index b2b1ab8..3423cb2 100644 --- a/configure.ac +++ b/configure.ac @@ -433,6 +433,11 @@ AC_SUBST([VG_LIB_GLOB]) AC_SUBST([GLAPI_LIB_GLOB]) dnl +dnl Check tls model support +dnl +MESA_TLS + +dnl dnl Arch/platform-specific settings dnl AC_ARG_ENABLE([asm], @@ -446,6 +451,14 @@ ASM_FLAGS= MESA_ASM_SOURCES= GLAPI_ASM_SOURCES= AC_MSG_CHECKING([whether to enable assembly]) + +if test x$ac_cv_tls_model = xno ; then +dnl +dnl If tls model is not supported, disable asm. +dnl + enable_asm=no +fi + test x$enable_asm = xno AC_MSG_RESULT([no]) # disable if cross compiling on x86/x86_64 since we must run gen_matypes if test x$enable_asm = xyes test x$cross_compiling = xyes; then @@ -1102,9 +1115,15 @@ dnl AC_ARG_ENABLE([glx-tls], [AS_HELP_STRING([--enable-glx-tls], - [enable TLS support in GLX @:@default=disabled@:@])], - [GLX_USE_TLS=$enableval], - [GLX_USE_TLS=no]) + [enable TLS support in GLX @:@default=auto@:@])], + [GLX_USE_TLS=$enableval + if test x$GLX_USE_TLS = xyes test ${ac_cv_tls} = none ; then + AC_MSG_ERROR([GLX with TLS support requested, but the compiler does not support it.]) + fi], + [GLX_USE_TLS=no + if test ${ac_cv_tls
Re: [Mesa-dev] [PATCH 1/2] i965: Report the failure message when failing to compile the fragment shader.
On Fri, Feb 10, 2012 at 12:42 AM, Eric Anholt e...@anholt.net wrote: We just abort later, but at least this should result in more informative bug reports. --- src/mesa/drivers/dri/i965/brw_fs.cpp | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 6ecaa6c..bf59da3 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -1844,6 +1844,9 @@ brw_wm_fs_emit(struct brw_context *brw, struct brw_wm_compile *c, prog-LinkStatus = false; ralloc_strcat(prog-InfoLog, v.fail_msg); + _mesa_problem(NULL, Failed to compile fragment shader: %s\n, We should pass brw-intel.ctx here instead of null, right? + v.fail_msg); + return false; } -- 1.7.9 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] configure.ac: Enable GLX_USE_TLS if possible.
On Wed, Feb 8, 2012 at 8:11 PM, Zhigang Gong zhigang.g...@linux.intel.com wrote: On Wed, Feb 08, 2012 at 02:46:42PM -0800, Eric Anholt wrote: On Wed, 8 Feb 2012 16:19:38 +0800, zhigang.g...@linux.intel.com wrote: From: Zhigang Gong zhigang.g...@linux.intel.com If the system support tls, we prefer to enable it by default just as xserver does. Actually, the checking code is copied from xserver/configure.ac. Signed-off-by: Zhigang Gong zhigang.g...@linux.intel.com --- configure.ac | 10 -- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index b2b1ab8..7c2756b 100644 --- a/configure.ac +++ b/configure.ac @@ -1103,8 +1103,14 @@ dnl AC_ARG_ENABLE([glx-tls], [AS_HELP_STRING([--enable-glx-tls], [enable TLS support in GLX @:@default=disabled@:@])], - [GLX_USE_TLS=$enableval], - [GLX_USE_TLS=no]) + [GLX_USE_TLS=$enableval + if test x$GLX_USE_TLS = xyes test ${ac_cv_tls} = none ; then + AC_MSG_ERROR([GLX with TLS support requested, but the compiler does not support it.]) + fi], + [GLX_USE_TLS=no + if test ${ac_cv_tls} != none ; then + GLX_USE_TLS=yes + fi]) AC_SUBST(GLX_TLS, ${GLX_USE_TLS}) I don't think you have anything setting ac_cv_tls. You are right, I forgot to add the checking code which is also from xserver. Sorry for that, here is the v2 patch: From: Zhigang Gong zhigang.g...@linux.intel.com Date: Wed, 8 Feb 2012 16:12:42 +0800 Subject: [PATCH v2] configure.ac: Enable GLX_USE_TLS if possible. If the system support tls, we prefer to enable it by default just as xserver does. Actually, the checking code is copied from xserver/configure.ac. Signed-off-by: Zhigang Gong zhigang.g...@linux.intel.com --- configure.ac | 39 +-- 1 files changed, 37 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index b2b1ab8..3dfafba 100644 --- a/configure.ac +++ b/configure.ac @@ -1099,12 +1099,47 @@ esac dnl dnl TLS detection dnl +AC_MSG_CHECKING(for thread local storage (TLS) support) +AC_CACHE_VAL(ac_cv_tls, [ + ac_cv_tls=none + keywords=__thread __declspec(thread) + for kw in $keywords ; do + AC_TRY_COMPILE([int $kw test;], [], ac_cv_tls=$kw) + done +]) +AC_MSG_RESULT($ac_cv_tls) + +if test $ac_cv_tls != none; then + AC_MSG_CHECKING(for tls_model attribute support) + AC_CACHE_VAL(ac_cv_tls_model, [ + save_CFLAGS=$CFLAGS + CFLAGS=$CFLAGS $STRICT_CFLAGS + AC_TRY_COMPILE([int $ac_cv_tls __attribute__((tls_model(initial-exec))) test;], [], + ac_cv_tls_model=yes, ac_cv_tls_model=no) + CFLAGS=$save_CFLAGS + ]) + AC_MSG_RESULT($ac_cv_tls_model) + + if test x$ac_cv_tls_model = xyes ; then + mesa_tls=$ac_cv_tls' __attribute__((tls_model(initial-exec)))' + else + mesa_tls=$ac_cv_tls + fi Judging by the patch that tried to change the tls_model: https://bugs.freedesktop.org/show_bug.cgi?id=35268 It looks like we'd need to disable enable_asm if the tls_model attribute isn't supported, since it would probably end up defaulting to general-dynamic for PIC code IIRC, and the assembly depends on it being initial-exec. Clang still doesn't support the tls_model attribute, and it doesn't fail compilation: it just gives a -Wattributes warning, so we might need to add '-Werror -Wattributes' (to catch the versions before -Wattributes was added, which give an 'unknown warning option' warning) to the test-compilation CFLAGS... Plus, the test would have to be moved to before enable_asm is decided and adds the -DUSE_X86_ASM, etc defines. + + AC_DEFINE_UNQUOTED([TLS], $mesa_tls, [The compiler supported TLS storage class, prefering initial-exec if tls_model is supported]) +fi AC_ARG_ENABLE([glx-tls], [AS_HELP_STRING([--enable-glx-tls], [enable TLS support in GLX @:@default=disabled@:@])], - [GLX_USE_TLS=$enableval], - [GLX_USE_TLS=no]) + [GLX_USE_TLS=$enableval + if test x$GLX_USE_TLS = xyes test ${ac_cv_tls} = none ; then + AC_MSG_ERROR([GLX with TLS support requested, but the compiler does not support it.]) + fi], + [GLX_USE_TLS=no + if test ${ac_cv_tls} != none ; then + GLX_USE_TLS=yes + fi]) AC_SUBST(GLX_TLS, ${GLX_USE_TLS}) AS_IF([test x$GLX_USE_TLS = xyes], -- 1.7.4.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/4] glapi: remove non-existent parameter references
On Tue, Jan 17, 2012 at 6:10 PM, Brian Paul bri...@vmware.com wrote: On 01/16/2012 04:45 PM, nobled wrote: glGetTexImage, for example, has no width/height/depth parameters. Also, copy some missing parameter info from the original versions of certain functions over to their ARB_robustness counterparts. These look OK to me. There's no real change in the generated .[ch] files, right? Hmm. Okay, weirdly, it actually does seem to have an effect. It changes __glXReadPixelReply to __glXReadReply, mostly. And I'm not sure if the new code is equivalent because I'm not even sure how this works right now. (For example, it doesn't seem to call xcb_glx_get_histogram() with enough parameters[it's missing the last one, 'reset'], and with this change it calls it with even one fewer -- no more 'state-storePack.swapEndian'.) Difference attached. (I could just run `make mesa`, it turns out.) -Brian From 3e23a97f768905637900783b55b7a7b36861120d Mon Sep 17 00:00:00 2001 From: Dylan Noblesmith nob...@dreamwidth.org Date: Thu, 19 Jan 2012 19:55:50 + Subject: [PATCH] regen code for glapi: remove non-existent parameter references Investigate if this change makes sense... And also why the xcb_glx_get_histogram() function does not seem to be getting enough parameters before, or after, this patch... but even fewer after. --- src/glx/indirect.c | 114 +++ 1 files changed, 43 insertions(+), 71 deletions(-) diff --git a/src/glx/indirect.c b/src/glx/indirect.c index a6b0c0d..a5ed0bc 100644 --- a/src/glx/indirect.c +++ b/src/glx/indirect.c @@ -4495,10 +4495,9 @@ __indirect_glGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid * pixels) { struct glx_context *const gc = __glXGetCurrentContext(); -const __GLXattribute *const state = gc-client_state_private; Display *const dpy = gc-currentDpy; #ifndef USE_XCB -const GLuint cmdlen = 20; +const GLuint cmdlen = 16; #endif if (__builtin_expect(dpy != NULL, 1)) { #ifdef USE_XCB @@ -4510,14 +4509,14 @@ __indirect_glGetTexImage(GLenum target, GLint level, GLenum format, gc- currentContextTag, target, level, - format, type, - state- - storePack. - swapEndian), + format, type), NULL); -(void) memcpy(pixels, xcb_glx_get_tex_image_data(reply), - xcb_glx_get_tex_image_data_length(reply) * - sizeof(GLvoid)); +if (xcb_glx_get_tex_image_data_length(reply) == 0) +(void) memcpy(pixels, reply-datum, sizeof(reply-datum)); +else +(void) memcpy(pixels, xcb_glx_get_tex_image_data(reply), + xcb_glx_get_tex_image_data_length(reply) * + sizeof(GLvoid)); free(reply); #else GLubyte const *pc = @@ -4526,10 +4525,7 @@ __indirect_glGetTexImage(GLenum target, GLint level, GLenum format, (void) memcpy((void *) (pc + 4), (void *) (level), 4); (void) memcpy((void *) (pc + 8), (void *) (format), 4); (void) memcpy((void *) (pc + 12), (void *) (type), 4); -*(int32_t *) (pc + 16) = 0; -*(int8_t *) (pc + 16) = state-storePack.swapEndian; -__glXReadPixelReply(dpy, gc, 3, 0, 0, 0, format, type, pixels, -GL_TRUE); +(void) __glXReadReply(dpy, 1, pixels, GL_FALSE); UnlockDisplay(dpy); SyncHandle(); #endif /* USE_XCB */ @@ -5601,10 +5597,9 @@ __indirect_glGetColorTable(GLenum target, GLenum format, GLenum type, GLvoid * table) { struct glx_context *const gc = __glXGetCurrentContext(); -const __GLXattribute *const state = gc-client_state_private; Display *const dpy = gc-currentDpy; #ifndef USE_XCB -const GLuint cmdlen = 16; +const GLuint cmdlen = 12; #endif if (__builtin_expect(dpy != NULL, 1)) { #ifdef USE_XCB @@ -5617,14 +5612,14 @@ __indirect_glGetColorTable(GLenum target, GLenum format, GLenum type, currentContextTag, target, format, - type, - state
Re: [Mesa-dev] [PATCH 4/4] glapi: add GL_ARB_texture_compression_rgtc
On Thu, Jan 19, 2012 at 1:46 PM, Eric Anholt e...@anholt.net wrote: On Mon, 16 Jan 2012 18:50:44 -0500, nobled nob...@dreamwidth.org wrote: Noticed this was missing when writing the glapi: sort ARB extensions by number commit, which at least shows it was effective. --- .../glapi/gen/ARB_texture_compression_rgtc.xml | 15 +++ src/mapi/glapi/gen/Makefile | 1 + src/mapi/glapi/gen/gl_API.xml | 2 +- 3 files changed, 17 insertions(+), 1 deletions(-) create mode 100644 src/mapi/glapi/gen/ARB_texture_compression_rgtc.xml diff --git a/src/mapi/glapi/gen/ARB_texture_compression_rgtc.xml b/src/mapi/glapi/gen/ARB_texture_compression_rgtc.xml new file mode 100644 index 000..f0ecabd --- /dev/null +++ b/src/mapi/glapi/gen/ARB_texture_compression_rgtc.xml @@ -0,0 +1,15 @@ +?xml version=1.0? +!DOCTYPE OpenGLAPI SYSTEM gl_API.dtd + +OpenGLAPI + +category name=GL_ARB_texture_rgtc number=52 missing compression? + + enum name=COMPRESSED_RED_RGTC1 value = 0x8DBB/ + enum name=COMPRESSED_SIGNED_RED_RGTC1 value = 0x8DBC/ + enum name=COMPRESSED_RG_RGTC2 value = 0x8DBD/ + enum name=COMPRESSED_SIGNED_RG_RGTC2 value = 0x8DBE/ + +/category + +/OpenGLAPI I don't understand how the XML is used well enough to review this series, really. It just adds new table entries in the regenerated src/mesa/main/enums.c file, it doesn't touch anything else. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] intel: Fix accum buffer mapping since the swrast rework.
On Tue, Jan 24, 2012 at 6:59 PM, Eric Anholt e...@anholt.net wrote: A pure swrast-allocated buffer gets an irb of NULL, so we segfaulted in the clear-accum test. Just look at the swrast renderbuffer pointer for handling swrast rbs. --- src/mesa/drivers/dri/intel/intel_fbo.c | 12 +++- 1 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c index 3a35a01..27b0bfc 100644 --- a/src/mesa/drivers/dri/intel/intel_fbo.c +++ b/src/mesa/drivers/dri/intel/intel_fbo.c @@ -128,15 +128,16 @@ intel_map_renderbuffer(struct gl_context *ctx, GLint *out_stride) { struct intel_context *intel = intel_context(ctx); + struct swrast_renderbuffer *srb = (struct swrast_renderbuffer *)rb; struct intel_renderbuffer *irb = intel_renderbuffer(rb); void *map; int stride; - if (!irb irb-Base.Buffer) { Isn't the problem just that this (and the other condition) is instead of ||? - /* this is a malloc'd renderbuffer (accum buffer) */ + if (srb-Buffer) { + /* this is a malloc'd renderbuffer (accum buffer), not an irb */ GLint bpp = _mesa_get_format_bytes(rb-Format); - GLint rowStride = irb-Base.RowStride; - *out_map = (GLubyte *) irb-Base.Buffer + y * rowStride + x * bpp; + GLint rowStride = srb-RowStride; + *out_map = (GLubyte *) srb-Buffer + y * rowStride + x * bpp; *out_stride = rowStride; return; } @@ -180,12 +181,13 @@ intel_unmap_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb) { struct intel_context *intel = intel_context(ctx); + struct swrast_renderbuffer *srb = (struct swrast_renderbuffer *)rb; struct intel_renderbuffer *irb = intel_renderbuffer(rb); DBG(%s: rb %d (%s)\n, __FUNCTION__, rb-Name, _mesa_get_format_name(rb-Format)); - if (!irb irb-Base.Buffer) { + if (srb-Buffer) { /* this is a malloc'd renderbuffer (accum buffer) */ /* nothing to do */ return; -- 1.7.7.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] autoconf: Make the build fail on missing prototypes when possible.
On Tue, Jan 24, 2012 at 1:09 PM, Eric Anholt e...@anholt.net wrote: You don't want to continue on when you've used something that is probably a typo of a real symbol, or maybe just using the wrong signature. --- -Werror=implicit would help cover this from the caller side of things, too. configure.ac | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/configure.ac b/configure.ac index 18a40fc..74e5fe4 100644 --- a/configure.ac +++ b/configure.ac @@ -176,7 +176,7 @@ esac dnl Add flags for gcc and g++ if test x$GCC = xyes; then - CFLAGS=$CFLAGS -Wall -Wmissing-prototypes -std=c99 + CFLAGS=$CFLAGS -Wall -Wmissing-prototypes -Werror=missing-prototypes -std=c99 # Enable -fvisibility=hidden if using a gcc that supports it save_CFLAGS=$CFLAGS -- 1.7.7.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/4] glapi: remove non-existent parameter references
On Tue, Jan 17, 2012 at 6:10 PM, Brian Paul bri...@vmware.com wrote: On 01/16/2012 04:45 PM, nobled wrote: glGetTexImage, for example, has no width/height/depth parameters. Also, copy some missing parameter info from the original versions of certain functions over to their ARB_robustness counterparts. These look OK to me. There's no real change in the generated .[ch] files, right? I can't actually tell; whenever I try to run `make` in src/mapi/glapi/gen/, it errors out with Set XORG_BASE env var instead. -Brian ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/4] glapi: remove non-existent parameter references
glGetTexImage, for example, has no width/height/depth parameters. Also, copy some missing parameter info from the original versions of certain functions over to their ARB_robustness counterparts. --- src/mapi/glapi/gen/ARB_robustness.xml | 26 +- src/mapi/glapi/gen/gl_API.xml | 16 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_robustness.xml b/src/mapi/glapi/gen/ARB_robustness.xml index b347ef3..49444c5 100644 --- a/src/mapi/glapi/gen/ARB_robustness.xml +++ b/src/mapi/glapi/gen/ARB_robustness.xml @@ -29,21 +29,21 @@ param name=target type=GLenum/ param name=query type=GLenum/ param name=bufSize type=GLsizei/ -param name=v type=GLdouble * output=true/ +param name=v type=GLdouble * output=true variable_param=target query/ /function function name=GetnMapfvARB offset=assign param name=target type=GLenum/ param name=query type=GLenum/ param name=bufSize type=GLsizei/ -param name=v type=GLfloat * output=true/ +param name=v type=GLfloat * output=true variable_param=target query/ /function function name=GetnMapivARB offset=assign param name=target type=GLenum/ param name=query type=GLenum/ param name=bufSize type=GLsizei/ -param name=v type=GLint * output=true/ +param name=v type=GLint * output=true variable_param=target query/ /function @@ -51,26 +51,26 @@ function name=GetnPixelMapfvARB offset=assign param name=map type=GLenum/ param name=bufSize type=GLsizei/ -param name=values type=GLfloat * output=true/ +param name=values type=GLfloat * output=true variable_param=map/ /function function name=GetnPixelMapuivARB offset=assign param name=map type=GLenum/ param name=bufSize type=GLsizei/ -param name=values type=GLuint * output=true/ +param name=values type=GLuint * output=true variable_param=map/ /function function name=GetnPixelMapusvARB offset=assign param name=map type=GLenum/ param name=bufSize type=GLsizei/ -param name=values type=GLushort * output=true/ +param name=values type=GLushort * output=true variable_param=map/ /function function name=GetnPolygonStippleARB offset=assign param name=bufSize type=GLsizei/ -param name=pattern type=GLubyte * output=true/ +param name=pattern type=GLubyte * output=true img_width=32 img_height=32 img_format=GL_COLOR_INDEX img_type=GL_BITMAP/ /function function name=GetnTexImageARB offset=assign @@ -79,7 +79,7 @@ param name=format type=GLenum/ param name=type type=GLenum/ param name=bufSize type=GLsizei/ -param name=img type=GLvoid * output=true/ +param name=img type=GLvoid * output=true img_format=format img_type=type/ /function function name=ReadnPixelsARB offset=assign @@ -90,7 +90,7 @@ param name=format type=GLenum/ param name=type type=GLenum/ param name=bufSize type=GLsizei/ -param name=data type=GLvoid * output=true/ +param name=data type=GLvoid * output=true img_width=width img_height=height img_format=format img_type=type img_target=0/ /function @@ -100,7 +100,7 @@ param name=format type=GLenum/ param name=type type=GLenum/ param name=bufSize type=GLsizei/ -param name=table type=GLvoid * output=true/ +param name=table type=GLvoid * output=true img_format=format img_type=type/ /function function name=GetnConvolutionFilterARB offset=assign @@ -108,7 +108,7 @@ param name=format type=GLenum/ param name=type type=GLenum/ param name=bufSize type=GLsizei/ -param name=image type=GLvoid * output=true/ +param name=image type=GLvoid * output=true img_format=format img_type=type/ /function function name=GetnSeparableFilterARB offset=assign @@ -128,7 +128,7 @@ param name=format type=GLenum/ param name=type type=GLenum/ param name=bufSize type=GLsizei/ -param name=values type=GLvoid * output=true/ +param name=values type=GLvoid * output=true img_format=format img_type=type/ /function function name=GetnMinmaxARB offset=assign @@ -137,7 +137,7 @@ param name=format type=GLenum/ param name=type type=GLenum/ param name=bufSize type=GLsizei/ -param name=values type=GLvoid * output=true/ +param name=values type=GLvoid * output=true img_width=2 img_format=format img_type=type/ /function diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml index 24539c0..2242e9b 100644 --- a/src/mapi/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml @@ -2788,7 +2788,7 @@ param name=level type=GLint/ param name=format
[Mesa-dev] [PATCH 2/4] glapi: sort ARB extensions by number
And add comments to fill in for extensions that aren't there. Noticed the comment about ARB extensions sorted by extension number didn't extend to the xi:include directives when it became clear GL_ARB_texture_rg was missing, going by the error message seen here: https://bugs.freedesktop.org/show_bug.cgi?id=44039 This makes it easier to notice in the future if an extension is missing when it shouldn't be. --- src/mapi/glapi/gen/gl_API.xml | 86 +++-- 1 files changed, 65 insertions(+), 21 deletions(-) diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml index 2242e9b..fe93fa9 100644 --- a/src/mapi/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml @@ -7891,41 +7891,84 @@ /enum /category -xi:include href=ARB_ES2_compatibility.xml xmlns:xi=http://www.w3.org/2001/XInclude/ +xi:include href=ARB_color_buffer_float.xml xmlns:xi=http://www.w3.org/2001/XInclude/ + +!-- 40. GL_ARB_half_float_pixel -- +!-- 41. GL_ARB_texture_float -- +!-- 42. GL_ARB_pixel_buffer_object -- +!-- 43. GL_ARB_depth_buffer_float -- + +xi:include href=ARB_draw_instanced.xml xmlns:xi=http://www.w3.org/2001/XInclude/ xi:include href=ARB_framebuffer_object.xml xmlns:xi=http://www.w3.org/2001/XInclude/ -xi:include href=ARB_copy_buffer.xml xmlns:xi=http://www.w3.org/2001/XInclude/ +!-- 46. GL_ARB_framebuffer_sRGB -- -xi:include href=ARB_depth_clamp.xml xmlns:xi=http://www.w3.org/2001/XInclude/ +xi:include href=ARB_geometry_shader4.xml xmlns:xi=http://www.w3.org/2001/XInclude/ + +!-- 48. GL_ARB_half_float_vertex -- + +xi:include href=ARB_instanced_arrays.xml xmlns:xi=http://www.w3.org/2001/XInclude/ xi:include href=ARB_map_buffer_range.xml xmlns:xi=http://www.w3.org/2001/XInclude/ +xi:include href=ARB_texture_buffer_object.xml xmlns:xi=http://www.w3.org/2001/XInclude/ + +!-- 52. GL_ARB_texture_compression_rgtc -- +!-- 53. GL_ARB_texture_rg -- + xi:include href=ARB_vertex_array_object.xml xmlns:xi=http://www.w3.org/2001/XInclude/ -xi:include href=ARB_sync.xml xmlns:xi=http://www.w3.org/2001/XInclude/ +!-- ARB extension number 55 is a GLX extension. -- +!-- ARB extension number 56 is a WGL extension. -- +!-- 57. GL_ARB_uniform_buffer_object -- +!-- 58. GL_ARB_compatibility -- -xi:include href=ARB_seamless_cube_map.xml xmlns:xi=http://www.w3.org/2001/XInclude/ +xi:include href=ARB_copy_buffer.xml xmlns:xi=http://www.w3.org/2001/XInclude/ + +!-- 60. GL_ARB_shader_texture_lod -- + +xi:include href=ARB_depth_clamp.xml xmlns:xi=http://www.w3.org/2001/XInclude/ xi:include href=ARB_draw_elements_base_vertex.xml xmlns:xi=http://www.w3.org/2001/XInclude/ -xi:include href=NV_conditional_render.xml xmlns:xi=http://www.w3.org/2001/XInclude/ +!-- 63. GL_ARB_fragment_coord_conventions -- +!-- 64. GL_ARB_provoking_vertex -- -xi:include href=NV_primitive_restart.xml xmlns:xi=http://www.w3.org/2001/XInclude/ +xi:include href=ARB_seamless_cube_map.xml xmlns:xi=http://www.w3.org/2001/XInclude/ -xi:include href=NV_texture_barrier.xml xmlns:xi=http://www.w3.org/2001/XInclude/ +xi:include href=ARB_sync.xml xmlns:xi=http://www.w3.org/2001/XInclude/ -xi:include href=ARB_sampler_objects.xml xmlns:xi=http://www.w3.org/2001/XInclude/ +!-- 67. GL_ARB_texture_multisample -- +!-- 68. GL_ARB_vertex_array_bgra -- -xi:include href=EXT_transform_feedback.xml xmlns:xi=http://www.w3.org/2001/XInclude/ +xi:include href=ARB_draw_buffers_blend.xml xmlns:xi=http://www.w3.org/2001/XInclude/ +xi:include href=AMD_draw_buffers_blend.xml xmlns:xi=http://www.w3.org/2001/XInclude/ -xi:include href=ARB_draw_instanced.xml xmlns:xi=http://www.w3.org/2001/XInclude/ +!-- 70. GL_ARB_sample_shading -- +!-- 71. GL_ARB_texture_cube_map_array -- +!-- 72. GL_ARB_texture_gather -- +!-- 73. GL_ARB_texture_query_lod -- -xi:include href=ARB_geometry_shader4.xml xmlns:xi=http://www.w3.org/2001/XInclude/ +!-- ARB extension number 74 is a WGL extension. -- +!-- ARB extension number 75 is a GLX extension. -- -xi:include href=ARB_color_buffer_float.xml xmlns:xi=http://www.w3.org/2001/XInclude/ +!-- 76. GL_ARB_shading_language_include -- +!-- 77. GL_ARB_texture_compression_bptc -- +!-- 78. GL_ARB_blend_func_extended -- +!-- 79. GL_ARB_explicit_attrib_location -- +!-- 80. GL_ARB_occlusion_query2 -- -xi:include href=ARB_robustness.xml xmlns:xi=http://www.w3.org/2001/XInclude/ +xi:include href=ARB_sampler_objects.xml xmlns:xi=http://www.w3.org/2001/XInclude/ + +!-- 82. GL_ARB_shader_bit_encoding -- + +xi:include href=ARB_texture_rgb10_a2ui.xml xmlns:xi=http://www.w3.org/2001/XInclude/ + +!-- 84. GL_ARB_texture_swizzle -- +!-- 85. GL_ARB_timer_query -- + +xi:include href=ARB_vertex_type_2_10_10_10_rev.xml xmlns:xi=http://www.w3.org/2001/XInclude/ !-- Non-ARB extensions sorted by extension number. -- @@ -12413,17 +12456,18 @@ xi:include href=EXT_gpu_shader4.xml xmlns:xi=http://www.w3.org/2001/XInclude/ xi:include href=GL3x.xml xmlns:xi=http://www.w3.org/2001/XInclude/ -xi:include href=ARB_instanced_arrays.xml
[Mesa-dev] [PATCH 3/4] glapi: add ARB_texture_rg
Noticed it was missing based on the lack of a descriptive enum name from this bug's error message: https://bugs.freedesktop.org/show_bug.cgi?id=44039 This moves two enums out of GL3x.xml. Though since this and GL_ARB_texture_compression_rgtc are both strict subsets of GL3, both extensions could have had all their enums in that file to begin with, not just two of them. --- src/mapi/glapi/gen/ARB_texture_rg.xml | 42 + src/mapi/glapi/gen/GL3x.xml |2 - src/mapi/glapi/gen/Makefile |1 + src/mapi/glapi/gen/gl_API.xml |3 +- 4 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 src/mapi/glapi/gen/ARB_texture_rg.xml diff --git a/src/mapi/glapi/gen/ARB_texture_rg.xml b/src/mapi/glapi/gen/ARB_texture_rg.xml new file mode 100644 index 000..40c0ebf --- /dev/null +++ b/src/mapi/glapi/gen/ARB_texture_rg.xml @@ -0,0 +1,42 @@ +?xml version=1.0? +!DOCTYPE OpenGLAPI SYSTEM gl_API.dtd + +OpenGLAPI + +category name=GL_ARB_texture_rg number=53 + +enum name=COMPRESSED_REDvalue = 0x8225/ +enum name=COMPRESSED_RG value = 0x8226/ + +enum name=RGvalue = 0x8227/ +enum name=RG_INTEGERvalue = 0x8228/ + +enum name=R8value = 0x8229/ +enum name=R16 value = 0x822A/ + +enum name=RG8 value = 0x822B/ +enum name=RG16 value = 0x822C/ + +enum name=R16F value = 0x822D/ +enum name=R32F value = 0x822E/ + +enum name=RG16F value = 0x822F/ +enum name=RG32F value = 0x8230/ + +enum name=R8I value = 0x8231/ +enum name=R8UI value = 0x8232/ +enum name=R16I value = 0x8233/ +enum name=R16UI value = 0x8234/ +enum name=R32I value = 0x8235/ +enum name=R32UI value = 0x8236/ + +enum name=RG8I value = 0x8237/ +enum name=RG8UI value = 0x8238/ +enum name=RG16I value = 0x8239/ +enum name=RG16UIvalue = 0x823A/ +enum name=RG32I value = 0x823B/ +enum name=RG32UIvalue = 0x823C/ + +/category + +/OpenGLAPI diff --git a/src/mapi/glapi/gen/GL3x.xml b/src/mapi/glapi/gen/GL3x.xml index cec9c91..f74e360 100644 --- a/src/mapi/glapi/gen/GL3x.xml +++ b/src/mapi/glapi/gen/GL3x.xml @@ -23,8 +23,6 @@ enum name=CONTEXT_FLAGSvalue=0x821E/ enum name=DEPTH_BUFFER value=0x8223/ enum name=STENCIL_BUFFER value=0x8224/ - enum name=COMPRESSED_RED value=0x8225/ - enum name=COMPRESSED_RGvalue=0x8226/ enum name=CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT value=0x0001/ enum name=RGBA32F value=0x8814/ enum name=RGB32F value=0x8815/ diff --git a/src/mapi/glapi/gen/Makefile b/src/mapi/glapi/gen/Makefile index c409285..6bf6f86 100644 --- a/src/mapi/glapi/gen/Makefile +++ b/src/mapi/glapi/gen/Makefile @@ -79,6 +79,7 @@ API_XML = \ ARB_seamless_cube_map.xml \ ARB_sync.xml \ ARB_texture_buffer_object.xml \ + ARB_texture_rg.xml \ ARB_texture_storage.xml \ ARB_vertex_array_object.xml \ AMD_draw_buffers_blend.xml \ diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml index fe93fa9..0ac3624 100644 --- a/src/mapi/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml @@ -7915,7 +7915,8 @@ xi:include href=ARB_texture_buffer_object.xml xmlns:xi=http://www.w3.org/2001/XInclude/ !-- 52. GL_ARB_texture_compression_rgtc -- -!-- 53. GL_ARB_texture_rg -- + +xi:include href=ARB_texture_rg.xml xmlns:xi=http://www.w3.org/2001/XInclude/ xi:include href=ARB_vertex_array_object.xml xmlns:xi=http://www.w3.org/2001/XInclude/ -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/4] glapi: add GL_ARB_texture_compression_rgtc
Noticed this was missing when writing the glapi: sort ARB extensions by number commit, which at least shows it was effective. --- .../glapi/gen/ARB_texture_compression_rgtc.xml | 15 +++ src/mapi/glapi/gen/Makefile|1 + src/mapi/glapi/gen/gl_API.xml |2 +- 3 files changed, 17 insertions(+), 1 deletions(-) create mode 100644 src/mapi/glapi/gen/ARB_texture_compression_rgtc.xml diff --git a/src/mapi/glapi/gen/ARB_texture_compression_rgtc.xml b/src/mapi/glapi/gen/ARB_texture_compression_rgtc.xml new file mode 100644 index 000..f0ecabd --- /dev/null +++ b/src/mapi/glapi/gen/ARB_texture_compression_rgtc.xml @@ -0,0 +1,15 @@ +?xml version=1.0? +!DOCTYPE OpenGLAPI SYSTEM gl_API.dtd + +OpenGLAPI + +category name=GL_ARB_texture_rgtc number=52 + +enum name=COMPRESSED_RED_RGTC1value = 0x8DBB/ +enum name=COMPRESSED_SIGNED_RED_RGTC1 value = 0x8DBC/ +enum name=COMPRESSED_RG_RGTC2 value = 0x8DBD/ +enum name=COMPRESSED_SIGNED_RG_RGTC2 value = 0x8DBE/ + +/category + +/OpenGLAPI diff --git a/src/mapi/glapi/gen/Makefile b/src/mapi/glapi/gen/Makefile index 6bf6f86..6d159f9 100644 --- a/src/mapi/glapi/gen/Makefile +++ b/src/mapi/glapi/gen/Makefile @@ -79,6 +79,7 @@ API_XML = \ ARB_seamless_cube_map.xml \ ARB_sync.xml \ ARB_texture_buffer_object.xml \ + ARB_texture_compression_rgtc.xml \ ARB_texture_rg.xml \ ARB_texture_storage.xml \ ARB_vertex_array_object.xml \ diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml index 0ac3624..3c0c6de 100644 --- a/src/mapi/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml @@ -7914,7 +7914,7 @@ xi:include href=ARB_texture_buffer_object.xml xmlns:xi=http://www.w3.org/2001/XInclude/ -!-- 52. GL_ARB_texture_compression_rgtc -- +xi:include href=ARB_texture_compression_rgtc.xml xmlns:xi=http://www.w3.org/2001/XInclude/ xi:include href=ARB_texture_rg.xml xmlns:xi=http://www.w3.org/2001/XInclude/ -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] mesa: add back glGetnUniformfv() overflow error reporting
ping? On Thu, Dec 22, 2011 at 4:34 PM, nob...@dreamwidth.org wrote: The error was erroneously removed in this commit: 719909698c67c287a393d2380278e7b7495ae018 mesa: Rewrite the way uniforms are tracked and handled You also aren't even supposed to truncate the output to 'bufSize', so just return like before. Also fixup an old comment and add an assert. --- (This function has a random mixture of tabs+spaces and pure spaces for indentation, so I had no idea which style to use...) src/mesa/main/uniform_query.cpp | 16 src/mesa/main/uniforms.c | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp index 33ba53c..8e58fc0 100644 --- a/src/mesa/main/uniform_query.cpp +++ b/src/mesa/main/uniform_query.cpp @@ -203,10 +203,18 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location, const union gl_constant_value *const src = uni-storage[offset * elements]; - unsigned bytes = sizeof(uni-storage[0]) * elements; - if (bytes (unsigned) bufSize) { - elements = bufSize / sizeof(uni-storage[0]); - bytes = bufSize; + assert(returnType == GLSL_TYPE_FLOAT || returnType == GLSL_TYPE_INT || + returnType == GLSL_TYPE_UINT); + /* The three (currently) supported types all have the same size, + * which is of course the same as their union. That'll change + * with glGetUniformdv()... + */ + unsigned bytes = sizeof(src[0]) * elements; + if (bufSize 0 || bytes (unsigned) bufSize) { + _mesa_error( ctx, GL_INVALID_OPERATION, + glGetnUniformfvARB(out of bounds: bufSize is %d, + but %u bytes are required), bufSize, bytes ); + return; } /* If the return type and the uniform's native type are compatible, diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c index 685c0f1..981874e 100644 --- a/src/mesa/main/uniforms.c +++ b/src/mesa/main/uniforms.c @@ -478,7 +478,7 @@ _mesa_GetnUniformdvARB(GLhandleARB program, GLint location, (void) params; /* - _mesa_get_uniform(ctx, program, location, bufSize, GL_DOUBLE, params); + _mesa_get_uniform(ctx, program, location, bufSize, GLSL_TYPE_DOUBLE, params); */ _mesa_error(ctx, GL_INVALID_OPERATION, glGetUniformdvARB (GL_ARB_gpu_shader_fp64 not implemented)); -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] gallivm: add IABS opcode support
--- src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c |1 + src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c |1 + 2 files changed, 2 insertions(+), 0 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c index a021efd..88702bc 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c @@ -697,6 +697,7 @@ emit_instruction( return FALSE; case TGSI_OPCODE_ABS: + case TGSI_OPCODE_IABS: src0 = emit_fetch(bld, inst, 0); dst0 = lp_build_abs(bld-base, src0); break; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 40744e3..f9dc5b4 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -1812,6 +1812,7 @@ emit_instruction( break; case TGSI_OPCODE_ABS: + case TGSI_OPCODE_IABS: FOR_EACH_DST0_ENABLED_CHANNEL( inst, chan_index ) { tmp0 = emit_fetch( bld, inst, 0, chan_index ); dst0[chan_index] = lp_build_abs( bld-base, tmp0 ); -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] mesa: add back glGetnUniformfv() overflow error reporting
The error was erroneously removed in this commit: 719909698c67c287a393d2380278e7b7495ae018 mesa: Rewrite the way uniforms are tracked and handled You also aren't even supposed to truncate the output to 'bufSize', so just return like before. Also fixup an old comment and add an assert. --- (This function has a random mixture of tabs+spaces and pure spaces for indentation, so I had no idea which style to use...) src/mesa/main/uniform_query.cpp | 16 src/mesa/main/uniforms.c|2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp index 33ba53c..8e58fc0 100644 --- a/src/mesa/main/uniform_query.cpp +++ b/src/mesa/main/uniform_query.cpp @@ -203,10 +203,18 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location, const union gl_constant_value *const src = uni-storage[offset * elements]; - unsigned bytes = sizeof(uni-storage[0]) * elements; - if (bytes (unsigned) bufSize) { -elements = bufSize / sizeof(uni-storage[0]); -bytes = bufSize; + assert(returnType == GLSL_TYPE_FLOAT || returnType == GLSL_TYPE_INT || + returnType == GLSL_TYPE_UINT); + /* The three (currently) supported types all have the same size, + * which is of course the same as their union. That'll change + * with glGetUniformdv()... + */ + unsigned bytes = sizeof(src[0]) * elements; + if (bufSize 0 || bytes (unsigned) bufSize) { +_mesa_error( ctx, GL_INVALID_OPERATION, +glGetnUniformfvARB(out of bounds: bufSize is %d, + but %u bytes are required), bufSize, bytes ); +return; } /* If the return type and the uniform's native type are compatible, diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c index 685c0f1..981874e 100644 --- a/src/mesa/main/uniforms.c +++ b/src/mesa/main/uniforms.c @@ -478,7 +478,7 @@ _mesa_GetnUniformdvARB(GLhandleARB program, GLint location, (void) params; /* - _mesa_get_uniform(ctx, program, location, bufSize, GL_DOUBLE, params); + _mesa_get_uniform(ctx, program, location, bufSize, GLSL_TYPE_DOUBLE, params); */ _mesa_error(ctx, GL_INVALID_OPERATION, glGetUniformdvARB (GL_ARB_gpu_shader_fp64 not implemented)); -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] [RFC] program: fix out of bounds array accesses and other bad things
index, GLenum progType) result.varying[4], result.varying[5], result.varying[6], - result.varying[7] + result.varying[7], + result.varying[8], + result.varying[9], + result.varying[10], + result.varying[11], + result.varying[12], + result.varying[13], + result.varying[14], + result.varying[15] /* MAX_VARYING = 16 */ }; - const char *fragResults[] = { - result.color, - result.color(half), - result.depth, - result.color[0], + static const char *const fragResults[] = { + result.depth, /* FRAG_RESULT_DEPTH */ + result.(two), /* FRAG_RESULT_STENCIL */ + result.color, /* FRAG_RESULT_COLOR */ + result.color[0], /* FRAG_RESULT_DATA0 (named for GLSL's gl_FragData) */ result.color[1], result.color[2], - result.color[3] + result.color[3], + result.color[4], + result.color[5], + result.color[6], + result.color[7] /* MAX_DRAW_BUFFERS = 8 */ }; + /* sanity checks */ + STATIC_ASSERT(Elements(vertResults) == VERT_RESULT_MAX); + STATIC_ASSERT(Elements(fragResults) == FRAG_RESULT_MAX); + assert(strcmp(vertResults[VERT_RESULT_HPOS], result.position) == 0); + assert(strcmp(vertResults[VERT_RESULT_VAR0], result.varying[0]) == 0); + assert(strcmp(fragResults[FRAG_RESULT_DATA0], result.color[0]) == 0); + if (progType == GL_VERTEX_PROGRAM_ARB) { assert(index Elements(vertResults)); return vertResults[index]; } else { + assert(progType == GL_FRAGMENT_PROGRAM_ARB); assert(index Elements(fragResults)); return fragResults[index]; } -- 1.7.4.1 From 3e7927701928ba5ffd6ef84c5357f6a18625dab1 Mon Sep 17 00:00:00 2001 From: nobled nob...@dreamwidth.org Date: Thu, 8 Dec 2011 21:07:18 + Subject: [PATCH 4/4] program: fix out of bounds array accesses and other bad things Noticed a warning: array subscript is above array bounds given at one of the existing sanity-check asserts. Turns out all the arrays of strings haven't matched the corresponding enum values in a while, if ever. I didn't know the proper names for any of these and couldn't find them in the base specs aside from result.pointsize in ARB_vertex_program, so I just filled in the enum's value as was done with other slots. Also add four STATIC_ASSERT()s to be sure and catch future additions or bumps to MAX_VARYING/etc again, and some more non-static asserts where there weren't any before. (Note, the fragment enum that corresponded to result.color(half) was removed in 8d475822e6e19fa79719c856a2db5b6a205db1b9.) --- src/mesa/program/prog_print.c | 73 + 1 files changed, 59 insertions(+), 14 deletions(-) diff --git a/src/mesa/program/prog_print.c b/src/mesa/program/prog_print.c index e9bf3aa..dfb5793 100644 --- a/src/mesa/program/prog_print.c +++ b/src/mesa/program/prog_print.c @@ -95,15 +95,15 @@ arb_input_attrib_string(GLint index, GLenum progType) /* * These strings should match the VERT_ATTRIB_x and FRAG_ATTRIB_x tokens. */ - const char *vertAttribs[] = { + static const char *const vertAttribs[] = { vertex.position, vertex.weight, vertex.normal, vertex.color.primary, vertex.color.secondary, vertex.fogcoord, - vertex.(six), - vertex.(seven), + vertex.(six), /* VERT_ATTRIB_COLOR_INDEX */ + vertex.(seven), /* VERT_ATTRIB_EDGEFLAG */ vertex.texcoord[0], vertex.texcoord[1], vertex.texcoord[2], @@ -112,6 +112,7 @@ arb_input_attrib_string(GLint index, GLenum progType) vertex.texcoord[5], vertex.texcoord[6], vertex.texcoord[7], + vertex.(sixteen), /* VERT_ATTRIB_POINT_SIZE */ vertex.attrib[0], vertex.attrib[1], vertex.attrib[2], @@ -127,9 +128,9 @@ arb_input_attrib_string(GLint index, GLenum progType) vertex.attrib[12], vertex.attrib[13], vertex.attrib[14], - vertex.attrib[15] + vertex.attrib[15] /* MAX_VARYING = 16 */ }; - const char *fragAttribs[] = { + static const char *const fragAttribs[] = { fragment.position, fragment.color.primary, fragment.color.secondary, @@ -142,6 +143,10 @@ arb_input_attrib_string(GLint index, GLenum progType) fragment.texcoord[5], fragment.texcoord[6], fragment.texcoord[7], + fragment.(twelve), /* FRAG_ATTRIB_FACE */ + fragment.(thirteen), /* FRAG_ATTRIB_PNTC */ + fragment.(fourteen), /* FRAG_ATTRIB_CLIP_DIST0 */ + fragment.(fifteen), /* FRAG_ATTRIB_CLIP_DIST1 */ fragment.varying[0], fragment.varying[1], fragment.varying[2], @@ -149,18 +154,31 @@ arb_input_attrib_string(GLint index, GLenum progType) fragment.varying[4], fragment.varying[5], fragment.varying[6], - fragment.varying[7] + fragment.varying[7], + fragment.varying[8], + fragment.varying[9], + fragment.varying[10
[Mesa-dev] [PATCH] gen_matypes: eliminate printf warnings
The VERT_BIT_* defines are 64-bit values since commit f364ac1da10ff67eba5196c1074aff579864f741, but the printf was still expecting a simple int. This worked on little-endian hosts because the values were still less than INT_MAX, but probably would've gone bad and printed zero on big-endian ones. --- src/mesa/x86/gen_matypes.c |7 ++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/src/mesa/x86/gen_matypes.c b/src/mesa/x86/gen_matypes.c index 648bf87..18baa29 100644 --- a/src/mesa/x86/gen_matypes.c +++ b/src/mesa/x86/gen_matypes.c @@ -32,6 +32,11 @@ * Mesa, including lighting, clipping, texture image conversion etc. */ +#ifndef __STDC_FORMAT_MACROS +#define __STDC_FORMAT_MACROS +#endif +#include inttypes.h + #include main/glheader.h #include main/mtypes.h #include tnl/t_context.h @@ -68,7 +73,7 @@ do { \ printf( #define %s\t%lu\n, s, (unsigned long) sizeof(t) ); #define DEFINE( s, d ) \ - printf( #define %s\t0x%x\n, s, d ); + printf( #define %s\t0x%PRIx64\n, s, (uint64_t) d ); -- 1.7.4.1 From f88d54fde18f4109b5af5d90e513ef761e4021bd Mon Sep 17 00:00:00 2001 From: nobled nob...@dreamwidth.org Date: Thu, 8 Dec 2011 20:53:25 + Subject: [PATCH 2/4] gen_matypes: eliminate printf warnings The VERT_BIT_* defines are 64-bit values since commit f364ac1da10ff67eba5196c1074aff579864f741, but the printf was still expecting a simple int. This worked on little-endian hosts because the values were still less than INT_MAX, but probably would've gone bad and printed zero on big-endian ones. --- src/mesa/x86/gen_matypes.c |7 ++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/src/mesa/x86/gen_matypes.c b/src/mesa/x86/gen_matypes.c index 648bf87..18baa29 100644 --- a/src/mesa/x86/gen_matypes.c +++ b/src/mesa/x86/gen_matypes.c @@ -32,6 +32,11 @@ * Mesa, including lighting, clipping, texture image conversion etc. */ +#ifndef __STDC_FORMAT_MACROS +#define __STDC_FORMAT_MACROS +#endif +#include inttypes.h + #include main/glheader.h #include main/mtypes.h #include tnl/t_context.h @@ -68,7 +73,7 @@ do { \ printf( #define %s\t%lu\n, s, (unsigned long) sizeof(t) ); #define DEFINE( s, d ) \ - printf( #define %s\t0x%x\n, s, d ); + printf( #define %s\t0x%PRIx64\n, s, (uint64_t) d ); -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] configure: Don't use $CLANG since it will collide with the static analyzer.
From: Jeremy Huddleston jerem...@apple.com Date: Thu, 5 May 2011 14:08:57 -0700 We just prefix the $CLANG environment variable in configure.ac with acv_mesa_ Found by: tinderbox Signed-off-by: Jeremy Huddleston jerem...@apple.com --- Originally posted here: http://lists.freedesktop.org/archives/mesa-dev/2011-May/007411.html configure.ac |8 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index a4943e1..162945b 100644 --- a/configure.ac +++ b/configure.ac @@ -75,13 +75,13 @@ AC_COMPILE_IFELSE( not clang #endif ]])], -[CLANG=yes], [CLANG=no]) +[acv_mesa_CLANG=yes], [acv_mesa_CLANG=no]) -AC_MSG_RESULT([$CLANG]) +AC_MSG_RESULT([$acv_mesa_CLANG]) dnl If we're using GCC, make sure that it is at least version 3.3.0. Older dnl versions are explictly not supported. -if test x$GCC = xyes -a x$CLANG = xno; then +if test x$GCC = xyes -a x$acv_mesa_CLANG = xno; then AC_MSG_CHECKING([whether gcc version is sufficient]) major=0 minor=0 @@ -155,7 +155,7 @@ esac dnl Add flags for gcc and g++ if test x$GCC = xyes; then CFLAGS=$CFLAGS -Wall -Wmissing-prototypes -std=c99 -if test x$CLANG = xno; then +if test x$acv_mesa_CLANG = xno; then CFLAGS=$CFLAGS -ffast-math fi -- 1.7.4.1 From 60549bd4cee04817d097871e61f8c2a6d47a8b5d Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston jerem...@apple.com Date: Thu, 5 May 2011 14:08:57 -0700 Subject: [PATCH 3/4] configure: Don't use $CLANG since it will collide with the static analyzer. We just prefix the $CLANG environment variable in configure.ac with acv_mesa_ Found by: tinderbox Signed-off-by: Jeremy Huddleston jerem...@apple.com --- Originally posted here: http://lists.freedesktop.org/archives/mesa-dev/2011-May/007411.html configure.ac |8 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index a4943e1..162945b 100644 --- a/configure.ac +++ b/configure.ac @@ -75,13 +75,13 @@ AC_COMPILE_IFELSE( not clang #endif ]])], -[CLANG=yes], [CLANG=no]) +[acv_mesa_CLANG=yes], [acv_mesa_CLANG=no]) -AC_MSG_RESULT([$CLANG]) +AC_MSG_RESULT([$acv_mesa_CLANG]) dnl If we're using GCC, make sure that it is at least version 3.3.0. Older dnl versions are explictly not supported. -if test x$GCC = xyes -a x$CLANG = xno; then +if test x$GCC = xyes -a x$acv_mesa_CLANG = xno; then AC_MSG_CHECKING([whether gcc version is sufficient]) major=0 minor=0 @@ -155,7 +155,7 @@ esac dnl Add flags for gcc and g++ if test x$GCC = xyes; then CFLAGS=$CFLAGS -Wall -Wmissing-prototypes -std=c99 -if test x$CLANG = xno; then +if test x$acv_mesa_CLANG = xno; then CFLAGS=$CFLAGS -ffast-math fi -- 1.7.4.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] texgetimage: add missing return on error
Missed this back in the arb_robustness branch 6b329b9274b18c50f4177eef7ee087d50ebc1525. --- src/mesa/main/texgetimage.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index f911886..e6edb45 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -849,6 +849,7 @@ getcompressedteximage_error_check(struct gl_context *ctx, GLenum target, _mesa_error(ctx, GL_INVALID_OPERATION, glGetnCompressedTexImageARB(out of bounds access: bufSize (%d) is too small), clientMemSize); + return GL_TRUE; } } else { /* do bounds checking on PBO write */ -- 1.7.6.msysgit.0 0001-texgetimage-add-missing-return-on-error.patch Description: Binary data ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/4] mesa/image: delete dead store
The return value here is a) always zero, b) never used. --- src/mesa/main/image.c |7 --- 1 files changed, 0 insertions(+), 7 deletions(-) diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 7d95dd6..ca5771c 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1148,16 +1148,9 @@ _mesa_image_address( GLuint dimensions, if (type == GL_BITMAP) { /* BITMAP data */ GLint comp_per_pixel; /* components per pixel */ - GLint bytes_per_comp; /* bytes per component */ GLint bytes_per_row; GLint bytes_per_image; - /* Compute bytes per component */ - bytes_per_comp = _mesa_sizeof_packed_type( type ); - if (bytes_per_comp 0) { - return NULL; - } - /* Compute number of components per pixel */ comp_per_pixel = _mesa_components_in_format( format ); if (comp_per_pixel 0) { -- 1.7.6.msysgit.0 0006-mesa-image-delete-dead-store.patch Description: Binary data ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/4] mesa/image: assert on bad format
NULL as an error indicator is meaningless, since it will return NULL on success anyway if the caller passes in zero as the image's address and asks to calculate the offset of the first pixel. For example, _mesa_validate_pbo_access() does this. This also matches the code in the non-GL_BITMAP codepath, which already has an assert like this. --- src/mesa/main/image.c | 16 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index ca5771c..3e0ca05 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1093,17 +1093,17 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format) * Pixel unpacking/packing parameters are observed according to \p packing. * * \param dimensions either 1, 2 or 3 to indicate dimensionality of image + * \param packing the pixelstore attributes * \param image starting address of image data * \param width the image width - * \param height theimage height - * \param format the pixel format - * \param type the pixel data type - * \param packing the pixelstore attributes + * \param height the image height + * \param format the pixel format (must be validated beforehand) + * \param type the pixel data type (must be validated beforehand) * \param img which image in the volume (0 for 1D or 2D images) * \param row row of pixel in the image (0 for 1D images) * \param column column of pixel in the image * - * \return address of pixel on success, or NULL on error. + * \return address of pixel. * * \sa gl_pixelstore_attrib. */ @@ -1153,9 +1153,9 @@ _mesa_image_address( GLuint dimensions, /* Compute number of components per pixel */ comp_per_pixel = _mesa_components_in_format( format ); - if (comp_per_pixel 0) { - return NULL; - } + + /* The pixel type and format should have been error checked earlier */ + assert(comp_per_pixel 0); bytes_per_row = alignment * CEILING( comp_per_pixel*pixels_per_row, 8*alignment ); -- 1.7.6.msysgit.0 From adb592410ca506107b5294222eadd84c35584ed5 Mon Sep 17 00:00:00 2001 From: nobled nob...@dreamwidth.org Date: Mon, 17 Oct 2011 21:34:44 + Subject: [PATCH 2/4] mesa/image: assert on bad format NULL as an error indicator is meaningless, since it will return NULL on success anyway if the caller passes in zero as the image's address and asks to calculate the offset of the first pixel. For example, _mesa_validate_pbo_access() does this. This also matches the code in the non-GL_BITMAP codepath, which already has an assert like this. --- src/mesa/main/image.c | 16 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index ca5771c..3e0ca05 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1093,17 +1093,17 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format) * Pixel unpacking/packing parameters are observed according to \p packing. * * \param dimensions either 1, 2 or 3 to indicate dimensionality of image + * \param packing the pixelstore attributes * \param image starting address of image data * \param width the image width - * \param height theimage height - * \param format the pixel format - * \param type the pixel data type - * \param packing the pixelstore attributes + * \param height the image height + * \param format the pixel format (must be validated beforehand) + * \param type the pixel data type (must be validated beforehand) * \param img which image in the volume (0 for 1D or 2D images) * \param row row of pixel in the image (0 for 1D images) * \param column column of pixel in the image * - * \return address of pixel on success, or NULL on error. + * \return address of pixel. * * \sa gl_pixelstore_attrib. */ @@ -1153,9 +1153,9 @@ _mesa_image_address( GLuint dimensions, /* Compute number of components per pixel */ comp_per_pixel = _mesa_components_in_format( format ); - if (comp_per_pixel 0) { - return NULL; - } + + /* The pixel type and format should have been error checked earlier */ + assert(comp_per_pixel 0); bytes_per_row = alignment * CEILING( comp_per_pixel*pixels_per_row, 8*alignment ); -- 1.7.6.msysgit.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/4] mesa: add _mesa_image_offset()
); + extern GLvoid * _mesa_image_address( GLuint dimensions, const struct gl_pixelstore_attrib *packing, -- 1.7.6.msysgit.0 From bc1cc2c4c0e03f764d2812ebd5b0c7c3e00bb3cc Mon Sep 17 00:00:00 2001 From: nobled nob...@dreamwidth.org Date: Tue, 18 Oct 2011 20:50:16 + Subject: [PATCH 8/9] mesa: add _mesa_image_offset() --- src/mesa/main/image.c | 67 src/mesa/main/image.h |7 + 2 files changed, 57 insertions(+), 17 deletions(-) diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 3e0ca05..ba66c8a 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1088,13 +1088,12 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format) /** - * Return the address of a specific pixel in an image (1D, 2D or 3D). + * Return the byte offset of a specific pixel in an image (1D, 2D or 3D). * * Pixel unpacking/packing parameters are observed according to \p packing. * * \param dimensions either 1, 2 or 3 to indicate dimensionality of image * \param packing the pixelstore attributes - * \param image starting address of image data * \param width the image width * \param height the image height * \param format the pixel format (must be validated beforehand) @@ -1102,18 +1101,17 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format) * \param img which image in the volume (0 for 1D or 2D images) * \param row row of pixel in the image (0 for 1D images) * \param column column of pixel in the image - * - * \return address of pixel. + * + * \return offset of pixel. * * \sa gl_pixelstore_attrib. */ -GLvoid * -_mesa_image_address( GLuint dimensions, - const struct gl_pixelstore_attrib *packing, - const GLvoid *image, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - GLint img, GLint row, GLint column ) +GLintptr +_mesa_image_offset( GLuint dimensions, +const struct gl_pixelstore_attrib *packing, +GLsizei width, GLsizei height, +GLenum format, GLenum type, +GLint img, GLint row, GLint column ) { GLint alignment;/* 1, 2 or 4 */ GLint pixels_per_row; @@ -1121,7 +1119,7 @@ _mesa_image_address( GLuint dimensions, GLint skiprows; GLint skippixels; GLint skipimages; /* for 3-D volume images */ - GLubyte *pixel_addr; + GLintptr offset; ASSERT(dimensions = 1 dimensions = 3); @@ -1162,8 +1160,7 @@ _mesa_image_address( GLuint dimensions, bytes_per_image = bytes_per_row * rows_per_image; - pixel_addr = (GLubyte *) image - + (skipimages + img) * bytes_per_image + offset = (skipimages + img) * bytes_per_image + (skiprows + row) * bytes_per_row + (skippixels + column) / 8; } @@ -1196,14 +1193,50 @@ _mesa_image_address( GLuint dimensions, } /* compute final pixel address */ - pixel_addr = (GLubyte *) image - + (skipimages + img) * bytes_per_image + offset = (skipimages + img) * bytes_per_image + topOfImage + (skiprows + row) * bytes_per_row + (skippixels + column) * bytes_per_pixel; } - return (GLvoid *) pixel_addr; + return offset; +} + + +/** + * Return the address of a specific pixel in an image (1D, 2D or 3D). + * + * Pixel unpacking/packing parameters are observed according to \p packing. + * + * \param dimensions either 1, 2 or 3 to indicate dimensionality of image + * \param packing the pixelstore attributes + * \param image starting address of image data + * \param width the image width + * \param height the image height + * \param format the pixel format (must be validated beforehand) + * \param type the pixel data type (must be validated beforehand) + * \param img which image in the volume (0 for 1D or 2D images) + * \param row row of pixel in the image (0 for 1D images) + * \param column column of pixel in the image + * + * \return address of pixel. + * + * \sa gl_pixelstore_attrib. + */ +GLvoid * +_mesa_image_address( GLuint dimensions, + const struct gl_pixelstore_attrib *packing, + const GLvoid *image, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLint img, GLint row, GLint column ) +{ + const GLubyte *addr = (const GLubyte *) image; + + addr += _mesa_image_offset(dimensions, packing, width, height, + format, type, img, row, column); + + return (GLvoid *) addr; } diff --git a/src/mesa/main/image.h b/src/mesa/main/image.h index 46adaec..f0ce029 100644 --- a/src/mesa/main/image.h +++ b/src/mesa/main/image.h @@ -84,6 +84,13 @@ _mesa_is_integer_format(GLenum format); extern GLboolean
[Mesa-dev] [PATCH 4/4] mesa, intel: use _mesa_image_offset() for PBOs
This avoids forming invalid pointers needlessly, which even if never dereferenced is undefined behavior. It also makes _mesa_validate_pbo_access() more comprehensible. --- src/mesa/drivers/dri/intel/intel_pixel_read.c |5 +++-- src/mesa/main/pbo.c | 25 ++--- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_pixel_read.c b/src/mesa/drivers/dri/intel/intel_pixel_read.c index c8e415d..d45a442 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_read.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_read.c @@ -120,8 +120,9 @@ do_blit_readpixels(struct gl_context * ctx, rowLength = -rowLength; } - dst_offset = (GLintptr) _mesa_image_address(2, pack, pixels, width, height, - format, type, 0, 0, 0); + dst_offset = (GLintptr)pixels; + dst_offset += _mesa_image_offset(2, pack, width, height, + format, type, 0, 0, 0); if (!_mesa_clip_copytexsubimage(ctx, dst_x, dst_y, diff --git a/src/mesa/main/pbo.c b/src/mesa/main/pbo.c index 4e7e6f9..023662d 100644 --- a/src/mesa/main/pbo.c +++ b/src/mesa/main/pbo.c @@ -68,8 +68,8 @@ _mesa_validate_pbo_access(GLuint dimensions, GLenum format, GLenum type, GLsizei clientMemSize, const GLvoid *ptr) { - const GLvoid *start, *end, *offset; - const GLubyte *sizeAddr; /* buffer size, cast to a pointer */ + /* unsigned, to detect overflow/wrap-around */ + uintptr_t start, end, offset, size; /* If no PBO is bound, 'ptr' is a pointer to client memory containing 'clientMemSize' bytes. @@ -78,29 +78,32 @@ _mesa_validate_pbo_access(GLuint dimensions, */ if (!_mesa_is_bufferobj(pack-BufferObj)) { offset = 0; - sizeAddr = ((const GLubyte *) 0) + clientMemSize; + size = clientMemSize; } else { offset = ptr; - sizeAddr = ((const GLubyte *) 0) + pack-BufferObj-Size; + size = pack-BufferObj-Size; } - if (sizeAddr == 0) + if (size == 0) /* no buffer! */ return GL_FALSE; /* get the offset to the first pixel we'll read/write */ - start = _mesa_image_address(dimensions, pack, offset, width, height, - format, type, 0, 0, 0); + start = _mesa_image_offset(dimensions, pack, width, height, + format, type, 0, 0, 0); /* get the offset to just past the last pixel we'll read/write */ - end = _mesa_image_address(dimensions, pack, offset, width, height, - format, type, depth-1, height-1, width); + end = _mesa_image_offset(dimensions, pack, width, height, + format, type, depth-1, height-1, width); - if ((const GLubyte *) start sizeAddr) { + start += offset; + end += offset; + + if (start size) { /* This will catch negative values / wrap-around */ return GL_FALSE; } - if ((const GLubyte *) end sizeAddr) { + if (end size) { /* Image read/write goes beyond end of buffer */ return GL_FALSE; } -- 1.7.6.msysgit.0 From 0fec8cecad17894d77d6cd677bd7b2ec7773 Mon Sep 17 00:00:00 2001 From: nobled nob...@dreamwidth.org Date: Wed, 19 Oct 2011 06:35:53 + Subject: [PATCH 9/9] mesa,intel: use _mesa_image_offset() for PBOs This avoids forming invalid pointers needlessly, which even if never dereferenced is undefined behavior. It also makes _mesa_validate_pbo_access() more comprehensible. --- src/mesa/drivers/dri/intel/intel_pixel_read.c |5 +++-- src/mesa/main/pbo.c | 25 ++--- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_pixel_read.c b/src/mesa/drivers/dri/intel/intel_pixel_read.c index c8e415d..d45a442 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_read.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_read.c @@ -120,8 +120,9 @@ do_blit_readpixels(struct gl_context * ctx, rowLength = -rowLength; } - dst_offset = (GLintptr) _mesa_image_address(2, pack, pixels, width, height, - format, type, 0, 0, 0); + dst_offset = (GLintptr)pixels; + dst_offset += _mesa_image_offset(2, pack, width, height, + format, type, 0, 0, 0); if (!_mesa_clip_copytexsubimage(ctx, dst_x, dst_y, diff --git a/src/mesa/main/pbo.c b/src/mesa/main/pbo.c index 4e7e6f9..023662d 100644 --- a/src/mesa/main/pbo.c +++ b/src/mesa/main/pbo.c @@ -68,8 +68,8 @@ _mesa_validate_pbo_access(GLuint dimensions, GLenum format, GLenum type, GLsizei clientMemSize, const GLvoid *ptr) { - const GLvoid *start, *end, *offset; - const GLubyte *sizeAddr; /* buffer size, cast to a pointer */ + /* unsigned
[Mesa-dev] [PATCH 2/4 v2] mesa/image: assert on bad format
NULL as an error indicator is meaningless, since it will return NULL on success anyway if the caller passes in zero as the image's address and asks to calculate the offset of the first pixel. For example, _mesa_validate_pbo_access() does this. This also matches the code in the non-GL_BITMAP codepath, which already has an assert like this. v2: Per Brian Paul's review, remove the function call entirely and tighten the assert to only accept the two formats compatible with GL_BITMAP. They always have one component per pixel. --- src/mesa/main/image.c | 20 +--- 1 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index ca5771c..af96107 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1093,17 +1093,17 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format) * Pixel unpacking/packing parameters are observed according to \p packing. * * \param dimensions either 1, 2 or 3 to indicate dimensionality of image + * \param packing the pixelstore attributes * \param image starting address of image data * \param width the image width - * \param height theimage height - * \param format the pixel format - * \param type the pixel data type - * \param packing the pixelstore attributes + * \param height the image height + * \param format the pixel format (must be validated beforehand) + * \param type the pixel data type (must be validated beforehand) * \param img which image in the volume (0 for 1D or 2D images) * \param row row of pixel in the image (0 for 1D images) * \param column column of pixel in the image * - * \return address of pixel on success, or NULL on error. + * \return address of pixel. * * \sa gl_pixelstore_attrib. */ @@ -1147,15 +1147,13 @@ _mesa_image_address( GLuint dimensions, if (type == GL_BITMAP) { /* BITMAP data */ - GLint comp_per_pixel; /* components per pixel */ GLint bytes_per_row; GLint bytes_per_image; + /* components per pixel for color or stencil index: */ + const GLint comp_per_pixel = 1; - /* Compute number of components per pixel */ - comp_per_pixel = _mesa_components_in_format( format ); - if (comp_per_pixel 0) { - return NULL; - } + /* The pixel type and format should have been error checked earlier */ + assert(format == GL_COLOR_INDEX || format == GL_STENCIL_INDEX); bytes_per_row = alignment * CEILING( comp_per_pixel*pixels_per_row, 8*alignment ); -- 1.7.6.msysgit.0 0007-mesa-image-assert-on-bad-format.patch Description: Binary data ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/4 v2] mesa, intel: use _mesa_image_offset() for PBOs
This avoids forming invalid pointers needlessly, which even if never dereferenced is undefined behavior. It also makes _mesa_validate_pbo_access() more comprehensible. --- v2: Now rebased on top of the recent commit 9024d8af0ae. src/mesa/drivers/dri/intel/intel_pixel_read.c |5 ++- src/mesa/main/pbo.c | 27 +--- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_pixel_read.c b/src/mesa/drivers/dri/intel/intel_pixel_read.c index 803d714..1107017 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_read.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_read.c @@ -120,8 +120,9 @@ do_blit_readpixels(struct gl_context * ctx, rowLength = -rowLength; } - dst_offset = (GLintptr) _mesa_image_address(2, pack, pixels, width, height, - format, type, 0, 0, 0); + dst_offset = (GLintptr)pixels; + dst_offset += _mesa_image_offset(2, pack, width, height, + format, type, 0, 0, 0); if (!_mesa_clip_copytexsubimage(ctx, dst_x, dst_y, diff --git a/src/mesa/main/pbo.c b/src/mesa/main/pbo.c index 41ff2ff..28e1a2c 100644 --- a/src/mesa/main/pbo.c +++ b/src/mesa/main/pbo.c @@ -68,8 +68,8 @@ _mesa_validate_pbo_access(GLuint dimensions, GLenum format, GLenum type, GLsizei clientMemSize, const GLvoid *ptr) { - const GLvoid *start, *end, *offset; - const GLubyte *sizeAddr; /* buffer size, cast to a pointer */ + /* unsigned, to detect overflow/wrap-around */ + uintptr_t start, end, offset, size; /* If no PBO is bound, 'ptr' is a pointer to client memory containing 'clientMemSize' bytes. @@ -78,10 +78,10 @@ _mesa_validate_pbo_access(GLuint dimensions, */ if (!_mesa_is_bufferobj(pack-BufferObj)) { offset = 0; - sizeAddr = ((const GLubyte *) 0) + clientMemSize; + size = clientMemSize; } else { offset = ptr; - sizeAddr = ((const GLubyte *) 0) + pack-BufferObj-Size; + size = pack-BufferObj-Size; /* The ARB_pixel_buffer_object spec says: *INVALID_OPERATION is generated by ColorTable, ColorSubTable, *ConvolutionFilter2D, ConvolutionFilter1D, SeparableFilter2D, @@ -93,27 +93,30 @@ _mesa_validate_pbo_access(GLuint dimensions, *parameter. */ if (type != GL_BITMAP - ((GLintptr)offset % _mesa_sizeof_packed_type(type))) + (offset % _mesa_sizeof_packed_type(type))) return GL_FALSE; } - if (sizeAddr == 0) + if (size == 0) /* no buffer! */ return GL_FALSE; /* get the offset to the first pixel we'll read/write */ - start = _mesa_image_address(dimensions, pack, offset, width, height, - format, type, 0, 0, 0); + start = _mesa_image_offset(dimensions, pack, width, height, + format, type, 0, 0, 0); /* get the offset to just past the last pixel we'll read/write */ - end = _mesa_image_address(dimensions, pack, offset, width, height, - format, type, depth-1, height-1, width); + end = _mesa_image_offset(dimensions, pack, width, height, + format, type, depth-1, height-1, width); - if ((const GLubyte *) start sizeAddr) { + start += offset; + end += offset; + + if (start size) { /* This will catch negative values / wrap-around */ return GL_FALSE; } - if ((const GLubyte *) end sizeAddr) { + if (end size) { /* Image read/write goes beyond end of buffer */ return GL_FALSE; } -- 1.7.6.msysgit.0 0010-mesa-intel-use-_mesa_image_offset-for-PBOs.patch Description: Binary data ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/4 dri] st/dri: factor out software texbuffer code
--- src/gallium/state_trackers/dri/sw/dri_drawable.c | 72 -- 1 files changed, 40 insertions(+), 32 deletions(-) diff --git a/src/gallium/state_trackers/dri/sw/dri_drawable.c b/src/gallium/state_trackers/dri/sw/dri_drawable.c index 05c64b6..66997fb 100644 --- a/src/gallium/state_trackers/dri/sw/dri_drawable.c +++ b/src/gallium/state_trackers/dri/sw/dri_drawable.c @@ -187,6 +187,44 @@ dri_drawable_validate_att(struct dri_drawable *drawable, drawable-base.validate(drawable-base, statts, count, NULL); } +static void +drisw_copy_drawable(struct dri_context *ctx, __DRIdrawable *dPriv, +struct pipe_resource *res) +{ + struct st_context *stctx = (struct st_context *)ctx-st; + struct pipe_context *pipe = stctx-pipe; + struct pipe_transfer *tex_xfer; + char *map; + __DRIscreen *sPriv = dPriv-driScreenPriv; + int x, y, w, h, line, ximage_stride; + + sPriv-swrast_loader-getDrawableInfo(dPriv, x, y, w, h, + dPriv-loaderPrivate); + + tex_xfer = pipe_get_transfer(pipe, res, +0, 0,/* level, layer */ +PIPE_TRANSFER_WRITE, +x, y, +w, h); + + map = pipe_transfer_map(pipe, tex_xfer); + + /* Copy the Drawable content to the mapped texture buffer */ + sPriv-swrast_loader-getImage(dPriv, x, y, w, h, map, + dPriv-loaderPrivate); + + /* The pipe transfer has a pitch rounded up to the nearest 64 pixels. + We assume 32 bit pixels. */ + ximage_stride = w * 4; + for (line = h-1; line; --line) { + memmove(map[line * tex_xfer-stride], + map[line * ximage_stride], ximage_stride); + } + + pipe_transfer_unmap(pipe, tex_xfer); + pipe_transfer_destroy(pipe, tex_xfer); +} + /** * These are used for GLX_EXT_texture_from_pixmap */ @@ -197,15 +235,7 @@ dri_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target, struct dri_context *ctx = dri_context(pDRICtx); struct dri_drawable *drawable = dri_drawable(dPriv); struct pipe_resource *res; - struct st_context *stctx = (struct st_context *)ctx-st; - struct pipe_context *pipe = stctx-pipe; - struct pipe_transfer *tex_xfer; - char *map; - __DRIscreen *sPriv = dPriv-driScreenPriv; - int x, y, w, h, line, ximage_stride; - sPriv-swrast_loader-getDrawableInfo(dPriv, x, y, w, h, dPriv-loaderPrivate); - dri_drawable_validate_att(drawable, ST_ATTACHMENT_FRONT_LEFT); /* Use the pipe resource associated with the X drawable */ @@ -228,30 +258,8 @@ dri_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target, } } - - tex_xfer = pipe_get_transfer(pipe, res, -0, 0,// level, layer -PIPE_TRANSFER_WRITE, -x, y, -w, h); - - - map = pipe_transfer_map(pipe, tex_xfer); - - /* Copy the Drawable content to the mapped texture buffer */ - sPriv-swrast_loader-getImage(dPriv, x, y, w, h, map, - dPriv-loaderPrivate); - - /* The pipe transfer has a pitch rounded up to the nearest 64 pixels. - We assume 32 bit pixels. */ - ximage_stride = w * 4; - for (line = h-1; line; --line) { - memmove(map[line * tex_xfer-stride], map[line * ximage_stride], ximage_stride); - } - - pipe_transfer_unmap(pipe, tex_xfer); - - pipe_transfer_destroy(pipe, tex_xfer); + /* needed only for drisw: */ + drisw_copy_drawable(ctx, dPriv, res); ctx-st-teximage(ctx-st, (target == GL_TEXTURE_2D) ? ST_TEXTURE_2D : ST_TEXTURE_RECT, -- 1.7.6.msysgit.0 0002-st-dri-factor-out-software-texbuffer-code.patch Description: Binary data ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/4 dri] st/dri: add copy_drawable() callback
pipe/p_context.h #include state_tracker/drisw_api.h +#include state_tracker/st_context.h #include dri_screen.h #include dri_context.h @@ -293,6 +294,58 @@ drisw_create_buffer(__DRIscreen * sPriv, return TRUE; } +static void +drisw_copy_drawable(struct dri_context *ctx, __DRIdrawable *dPriv, +struct pipe_resource *res) +{ + struct st_context *stctx = (struct st_context *)ctx-st; + struct pipe_context *pipe = stctx-pipe; + struct pipe_transfer *tex_xfer; + char *map; + __DRIscreen *sPriv = dPriv-driScreenPriv; + int x, y, w, h, line, ximage_stride; + + sPriv-swrast_loader-getDrawableInfo(dPriv, x, y, w, h, + dPriv-loaderPrivate); + + tex_xfer = pipe_get_transfer(pipe, res, +0, 0,/* level, layer */ +PIPE_TRANSFER_WRITE, +x, y, +w, h); + + map = pipe_transfer_map(pipe, tex_xfer); + + /* Copy the Drawable content to the mapped texture buffer */ + sPriv-swrast_loader-getImage(dPriv, x, y, w, h, map, + dPriv-loaderPrivate); + + /* The pipe transfer has a pitch rounded up to the nearest 64 pixels. + We assume 32 bit pixels. */ + ximage_stride = w * 4; + for (line = h-1; line; --line) { + memmove(map[line * tex_xfer-stride], + map[line * ximage_stride], ximage_stride); + } + + pipe_transfer_unmap(pipe, tex_xfer); + pipe_transfer_destroy(pipe, tex_xfer); +} + +static GLboolean +drisw_create_context(gl_api api, const struct gl_config * visual, + __DRIcontext * cPriv, void *sharedContextPrivate) +{ + struct dri_context *ctx; + + if (!dri_create_context(api, visual, cPriv, sharedContextPrivate)) + return FALSE; + + ctx = dri_context(cPriv); + ctx-copy_drawable = drisw_copy_drawable; + return TRUE; +} + /** * DRI driver virtual function table. * @@ -301,7 +354,7 @@ drisw_create_buffer(__DRIscreen * sPriv, const struct __DriverAPIRec driDriverAPI = { .InitScreen = drisw_init_screen, .DestroyScreen = dri_destroy_screen, - .CreateContext = dri_create_context, + .CreateContext = drisw_create_context, .DestroyContext = dri_destroy_context, .CreateBuffer = drisw_create_buffer, .DestroyBuffer = dri_destroy_buffer, -- 1.7.6.msysgit.0 From f0ba9fe7da311a0764a807e030f189388331bd2a Mon Sep 17 00:00:00 2001 From: nobled nob...@dreamwidth.org Date: Wed, 12 Oct 2011 13:17:37 + Subject: [PATCH 2/4 dri] st/dri: add copy_drawable() callback This moves drisw-specific code into drisw.c, making it possible to eliminate the extra copy of dri_drawable.c. --- .../state_trackers/dri/common/dri_context.h|4 ++ src/gallium/state_trackers/dri/drm/dri2.c | 26 +- src/gallium/state_trackers/dri/sw/dri_drawable.c | 42 +--- src/gallium/state_trackers/dri/sw/drisw.c | 55 +++- 4 files changed, 84 insertions(+), 43 deletions(-) diff --git a/src/gallium/state_trackers/dri/common/dri_context.h b/src/gallium/state_trackers/dri/common/dri_context.h index cfc8e33..e2738d2 100644 --- a/src/gallium/state_trackers/dri/common/dri_context.h +++ b/src/gallium/state_trackers/dri/common/dri_context.h @@ -64,6 +64,10 @@ struct dri_context struct st_context_iface *st; struct pp_queue_t *pp; unsigned int pp_enabled[PP_FILTERS]; + + /* copy the contents of the __DRIdrawable to the pipe_resource: */ + void (*copy_drawable)(struct dri_context *, __DRIdrawable *, + struct pipe_resource *); }; static INLINE struct dri_context * diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c index f3c9e10..20a230c 100644 --- a/src/gallium/state_trackers/dri/drm/dri2.c +++ b/src/gallium/state_trackers/dri/drm/dri2.c @@ -711,6 +711,30 @@ dri2_create_buffer(__DRIscreen * sPriv, return TRUE; } +static void +dri2_copy_drawable(struct dri_context *ctx, __DRIdrawable *dPriv, + struct pipe_resource *res) +{ + /* no-op */ + (void)ctx; + (void)dPriv; + (void)res; +} + +static GLboolean +dri2_create_context(gl_api api, const struct gl_config * visual, +__DRIcontext * cPriv, void *sharedContextPrivate) +{ + struct dri_context *ctx; + + if (!dri_create_context(api, visual, cPriv, sharedContextPrivate)) + return FALSE; + + ctx = dri_context(cPriv); + ctx-copy_drawable = dri2_copy_drawable; + return TRUE; +} + /** * DRI driver virtual function table. * @@ -720,7 +744,7 @@ const struct __DriverAPIRec driDriverAPI = { .InitScreen = NULL, .InitScreen2 = dri2_init_screen, .DestroyScreen = dri_destroy_screen, - .CreateContext = dri_create_context, + .CreateContext = dri2_create_context, .DestroyContext = dri_destroy_context, .CreateBuffer = dri2_create_buffer, .DestroyBuffer
[Mesa-dev] [PATCH 3/4 dri] st/dri: sync the sw/ changes to dri_drawable.c
The sw copy needs to go away. It's already missing several new patches to the original. --- .../state_trackers/dri/common/dri_drawable.c | 13 - 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.c b/src/gallium/state_trackers/dri/common/dri_drawable.c index 340404e..7cf7219 100644 --- a/src/gallium/state_trackers/dri/common/dri_drawable.c +++ b/src/gallium/state_trackers/dri/common/dri_drawable.c @@ -203,14 +203,15 @@ dri_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target, { struct dri_context *ctx = dri_context(pDRICtx); struct dri_drawable *drawable = dri_drawable(dPriv); - struct pipe_resource *pt; + struct pipe_resource *res; dri_drawable_validate_att(drawable, ST_ATTACHMENT_FRONT_LEFT); - pt = drawable-textures[ST_ATTACHMENT_FRONT_LEFT]; + /* Use the pipe resource associated with the X drawable */ + res = drawable-textures[ST_ATTACHMENT_FRONT_LEFT]; - if (pt) { - enum pipe_format internal_format = pt-format; + if (res) { + enum pipe_format internal_format = res-format; if (format == __DRI_TEXTURE_FORMAT_RGB) { /* only need to cover the formats recognized by dri_fill_st_visual */ @@ -226,9 +227,11 @@ dri_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target, } } + ctx-copy_drawable(ctx, dPriv, res); + ctx-st-teximage(ctx-st, (target == GL_TEXTURE_2D) ? ST_TEXTURE_2D : ST_TEXTURE_RECT, -0, internal_format, pt, FALSE); +0, internal_format, res, FALSE); } } -- 1.7.6.msysgit.0 0004-st-dri-sync-the-sw-changes-to-dri_drawable.c.patch Description: Binary data ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/4 dri] Revert Duplicate state_tracker/dri/sw/dri_drawable.c
This reverts commit 569bde1fa7d03fb7688d0d391b32e61e857ad44e. --- src/gallium/state_trackers/dri/sw/dri_drawable.c | 274 +- 1 files changed, 1 insertions(+), 273 deletions(-) mode change 100644 = 12 src/gallium/state_trackers/dri/sw/dri_drawable.c diff --git a/src/gallium/state_trackers/dri/sw/dri_drawable.c b/src/gallium/state_trackers/dri/sw/dri_drawable.c deleted file mode 100644 index 41e2a8d..000 --- a/src/gallium/state_trackers/dri/sw/dri_drawable.c +++ /dev/null @@ -1,273 +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. - * - **/ -/* - * Author: Keith Whitwell kei...@vmware.com - * Author: Jakob Bornecrantz wallbra...@gmail.com - */ - -#include dri_screen.h -#include dri_context.h -#include dri_drawable.h - -#include pipe/p_screen.h -#include util/u_format.h -#include util/u_memory.h -#include util/u_inlines.h - - -static boolean -dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi, -const enum st_attachment_type *statts, -unsigned count, -struct pipe_resource **out) -{ - struct dri_drawable *drawable = - (struct dri_drawable *) stfbi-st_manager_private; - struct dri_screen *screen = dri_screen(drawable-sPriv); - unsigned statt_mask, new_mask; - boolean new_stamp; - int i; - - statt_mask = 0x0; - for (i = 0; i count; i++) - statt_mask |= (1 statts[i]); - - /* record newly allocated textures */ - new_mask = (statt_mask ~drawable-texture_mask); - - /* -* dPriv-pStamp is the server stamp. It should be accessed with a lock, at -* least for DRI1. dPriv-lastStamp is the client stamp. It has the value -* of the server stamp when last checked. -*/ - new_stamp = (drawable-texture_stamp != drawable-dPriv-lastStamp); - - if (new_stamp || new_mask || screen-broken_invalidate) { - if (new_stamp drawable-update_drawable_info) - drawable-update_drawable_info(drawable); - - drawable-allocate_textures(drawable, statts, count); - - /* add existing textures */ - for (i = 0; i ST_ATTACHMENT_COUNT; i++) { - if (drawable-textures[i]) -statt_mask |= (1 i); - } - - drawable-texture_stamp = drawable-dPriv-lastStamp; - drawable-texture_mask = statt_mask; - } - - if (!out) - return TRUE; - - for (i = 0; i count; i++) { - out[i] = NULL; - pipe_resource_reference(out[i], drawable-textures[statts[i]]); - } - - return TRUE; -} - -static boolean -dri_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi, - enum st_attachment_type statt) -{ - struct dri_drawable *drawable = - (struct dri_drawable *) stfbi-st_manager_private; - - /* XXX remove this and just set the correct one on the framebuffer */ - drawable-flush_frontbuffer(drawable, statt); - - return TRUE; -} - -/** - * This is called when we need to set up GL rendering to a new X window. - */ -boolean -dri_create_buffer(__DRIscreen * sPriv, - __DRIdrawable * dPriv, - const struct gl_config * visual, boolean isPixmap) -{ - struct dri_screen *screen = sPriv-private; - struct dri_drawable *drawable = NULL; - - if (isPixmap) - goto fail; /* not implemented */ - - drawable = CALLOC_STRUCT(dri_drawable); - if (drawable == NULL) - goto fail; - - dri_fill_st_visual(drawable-stvis, screen, visual); - - /* setup the st_framebuffer_iface */ - drawable-base.visual = drawable-stvis; - drawable-base.flush_front = dri_st_framebuffer_flush_front; - drawable-base.validate = dri_st_framebuffer_validate; -
[Mesa-dev] [PATCH 1/3] glx: Check flush DRI extension version at runtime
The DRI driver itself might not have version 3 of the DRI2 flush extension, in which case this would've pointed to out of bounds memory... --- src/glx/dri2_glx.c |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index ff48c79..179b7d7 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -640,7 +640,7 @@ dri2InvalidateBuffers(Display *dpy, XID drawable) struct dri2_drawable *pdp = (struct dri2_drawable *) pdraw; Date: Sun, 5 Sep 2010 19:10:58 + #if __DRI2_FLUSH_VERSION = 3 - if (pdraw psc-f) + if (pdraw psc-f psc-f-base.version = 3 psc-f-invalidate) psc-f-invalidate(pdp-driDrawable); #endif } @@ -663,7 +663,8 @@ dri2_bind_tex_image(Display * dpy, psc = (struct dri2_screen *) base-psc; #if __DRI2_FLUSH_VERSION = 3 - if (!pdp-invalidateAvailable psc-f) + if (!pdp-invalidateAvailable psc-f + psc-f-base.version = 3 psc-f-invalidate) psc-f-invalidate(pdraw-driDrawable); #endif -- 1.7.0.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/3] glx: Add teximage vfuncs to drisw
Copied the implementation from dri2_glx.c. --- src/glx/drisw_glx.c | 51 --- 1 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index c5b1791..81fd188 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -46,8 +46,10 @@ struct drisw_screen __DRIscreen *driScreen; __GLXDRIscreen vtable; - const __DRIcoreExtension *core; const __DRIswrastExtension *swrast; + const __DRIcoreExtension *core; + + const __DRItexBufferExtension *texBuffer; const __DRIconfig **driver_configs; void *driver; @@ -287,6 +289,49 @@ drisw_unbind_context(struct glx_context *context, struct glx_context *new) (*psc-core-unbindContext) (pcp-driContext); } +static void +drisw_bind_tex_image(Display * dpy, + GLXDrawable drawable, + int buffer, const int *attrib_list) +{ + struct glx_context *gc = __glXGetCurrentContext(); + struct drisw_context *pcp = (struct drisw_context *) gc; + __GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable); + struct drisw_drawable *pdraw = (struct drisw_drawable *) base; + struct glx_display *dpyPriv = __glXInitialize(dpy); + struct drisw_display *pdp = + (struct drisw_display *) dpyPriv-dri2Display; + struct drisw_screen *psc; + + if (pdraw != NULL) { + psc = (struct drisw_screen *) base-psc; + +/* FIXME: copied from dri2_glx.c. Can, should drisw do something like this? */ +#if 0 __DRI2_FLUSH_VERSION = 3 + if (!pdp-invalidateAvailable psc-f) +psc-f-invalidate(pdraw-driDrawable); +#endif + + if (psc-texBuffer-base.version = 2 + psc-texBuffer-setTexBuffer2 != NULL) { +(*psc-texBuffer-setTexBuffer2) (pcp-driContext, + pdraw-base.textureTarget, + pdraw-base.textureFormat, + pdraw-driDrawable); + } + else { +(*psc-texBuffer-setTexBuffer) (pcp-driContext, + pdraw-base.textureTarget, + pdraw-driDrawable); + } + } +} + +static void +drisw_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer) +{ +} + static const struct glx_context_vtable drisw_context_vtable = { drisw_destroy_context, drisw_bind_context, @@ -294,8 +339,8 @@ static const struct glx_context_vtable drisw_context_vtable = { NULL, NULL, DRI_glXUseXFont, - NULL, - NULL, + drisw_bind_tex_image, + drisw_release_tex_image, }; static struct glx_context * -- 1.7.0.4 From 2242a735c1e78f740a054e9b7a40c356b9505377 Mon Sep 17 00:00:00 2001 From: nobled nob...@dreamwidth.org Date: Sun, 5 Sep 2010 16:14:01 + Subject: [PATCH 2/4] glx: Add teximage vfuncs to drisw Copied the implementation from dri2_glx.c. --- src/glx/drisw_glx.c | 51 --- 1 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index c5b1791..81fd188 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -46,8 +46,10 @@ struct drisw_screen __DRIscreen *driScreen; __GLXDRIscreen vtable; - const __DRIcoreExtension *core; const __DRIswrastExtension *swrast; + const __DRIcoreExtension *core; + + const __DRItexBufferExtension *texBuffer; const __DRIconfig **driver_configs; void *driver; @@ -287,6 +289,49 @@ drisw_unbind_context(struct glx_context *context, struct glx_context *new) (*psc-core-unbindContext) (pcp-driContext); } +static void +drisw_bind_tex_image(Display * dpy, + GLXDrawable drawable, + int buffer, const int *attrib_list) +{ + struct glx_context *gc = __glXGetCurrentContext(); + struct drisw_context *pcp = (struct drisw_context *) gc; + __GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable); + struct drisw_drawable *pdraw = (struct drisw_drawable *) base; + struct glx_display *dpyPriv = __glXInitialize(dpy); + struct drisw_display *pdp = + (struct drisw_display *) dpyPriv-dri2Display; + struct drisw_screen *psc; + + if (pdraw != NULL) { + psc = (struct drisw_screen *) base-psc; + +/* FIXME: copied from dri2_glx.c. Can, should drisw do something like this? */ +#if 0 __DRI2_FLUSH_VERSION = 3 + if (!pdp-invalidateAvailable psc-f) + psc-f-invalidate(pdraw-driDrawable); +#endif + + if (psc-texBuffer-base.version = 2 + psc-texBuffer-setTexBuffer2 != NULL) { + (*psc-texBuffer-setTexBuffer2) (pcp-driContext, + pdraw-base.textureTarget, + pdraw-base.textureFormat, + pdraw-driDrawable); + } + else { + (*psc-texBuffer-setTexBuffer) (pcp-driContext, + pdraw-base.textureTarget, + pdraw-driDrawable); + } + } +} + +static void +drisw_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer) +{ +} + static const struct
[Mesa-dev] [PATCH 2/3 v2] glx: Add teximage vfuncs to drisw
Copied the implementation from dri2_glx.c. --- Sorry, accidentally sent an old version that didn't apply and was missing the release() code that got added between then and now. This one should work. src/glx/drisw_glx.c | 77 +-- 1 files changed, 74 insertions(+), 3 deletions(-) diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index 5c7f40c..04c68e2 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -46,8 +46,10 @@ struct drisw_screen __DRIscreen *driScreen; __GLXDRIscreen vtable; - const __DRIcoreExtension *core; const __DRIswrastExtension *swrast; + const __DRIcoreExtension *core; + + const __DRItexBufferExtension *texBuffer; const __DRIconfig **driver_configs; void *driver; @@ -287,6 +289,75 @@ drisw_unbind_context(struct glx_context *context, struct glx_context *new) driReleaseDrawables(pcp-base); } +static void +drisw_bind_tex_image(Display * dpy, + GLXDrawable drawable, + int buffer, const int *attrib_list) +{ + struct glx_context *gc = __glXGetCurrentContext(); + struct drisw_context *pcp = (struct drisw_context *) gc; + __GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable); + struct glx_display *dpyPriv = __glXInitialize(dpy); + struct drisw_drawable *pdraw = (struct drisw_drawable *) base; + struct drisw_display *pdp = + (struct drisw_display *) dpyPriv-dri2Display; + struct drisw_screen *psc; + + if (pdraw != NULL) { + psc = (struct drisw_screen *) base-psc; + + if (!psc-texBuffer) + return; + +/* FIXME: copied from dri2_glx.c. Can, should drisw do something like this? */ +#if 0 __DRI2_FLUSH_VERSION = 3 + if (!pdp-invalidateAvailable psc-f +psc-f-base.version = 3 psc-f-invalidate) +psc-f-invalidate(pdraw-driDrawable); +#endif + + if (psc-texBuffer-base.version = 2 + psc-texBuffer-setTexBuffer2 != NULL) { +(*psc-texBuffer-setTexBuffer2) (pcp-driContext, + pdraw-base.textureTarget, + pdraw-base.textureFormat, + pdraw-driDrawable); + } + else { +(*psc-texBuffer-setTexBuffer) (pcp-driContext, + pdraw-base.textureTarget, + pdraw-driDrawable); + } + } +} + +static void +drisw_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer) +{ +#if __DRI_TEX_BUFFER_VERSION = 3 + struct glx_context *gc = __glXGetCurrentContext(); + struct dri2_context *pcp = (struct dri2_context *) gc; + __GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable); + struct glx_display *dpyPriv = __glXInitialize(dpy); + struct dri2_drawable *pdraw = (struct dri2_drawable *) base; + struct dri2_screen *psc; + + if (pdraw != NULL) { + psc = (struct dri2_screen *) base-psc; + + if (!psc-texBuffer) + return; + + if (psc-texBuffer-base.version = 3 + psc-texBuffer-releaseTexBuffer != NULL) { + (*psc-texBuffer-releaseTexBuffer) (pcp-driContext, + pdraw-base.textureTarget, + pdraw-driDrawable); + } + } +#endif +} + static const struct glx_context_vtable drisw_context_vtable = { drisw_destroy_context, drisw_bind_context, @@ -294,8 +365,8 @@ static const struct glx_context_vtable drisw_context_vtable = { NULL, NULL, DRI_glXUseXFont, - NULL, - NULL, + drisw_bind_tex_image, + drisw_release_tex_image, }; static struct glx_context * -- 1.7.0.4 From b4ebb03ac6d9d50d9184609a72f16f7343f9ff6b Mon Sep 17 00:00:00 2001 From: nobled nob...@dreamwidth.org Date: Sun, 5 Sep 2010 16:14:01 + Subject: [PATCH 2/3] glx: Add teximage vfuncs to drisw Copied the implementation from dri2_glx.c. --- src/glx/drisw_glx.c | 77 +-- 1 files changed, 74 insertions(+), 3 deletions(-) diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index 5c7f40c..04c68e2 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -46,8 +46,10 @@ struct drisw_screen __DRIscreen *driScreen; __GLXDRIscreen vtable; - const __DRIcoreExtension *core; const __DRIswrastExtension *swrast; + const __DRIcoreExtension *core; + + const __DRItexBufferExtension *texBuffer; const __DRIconfig **driver_configs; void *driver; @@ -287,6 +289,75 @@ drisw_unbind_context(struct glx_context *context, struct glx_context *new) driReleaseDrawables(pcp-base); } +static void +drisw_bind_tex_image(Display * dpy, + GLXDrawable drawable, + int buffer, const int *attrib_list) +{ + struct glx_context *gc = __glXGetCurrentContext(); + struct drisw_context *pcp = (struct drisw_context *) gc; + __GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable); + struct
[Mesa-dev] [PATCH 3/3] glx: Enable GLX_EXT_texture_from_pixmap in software
Now if a software DRI driver advertises it, we can use it in direct-rendering contexts--without this, only the server took advantage of it for indirect contexts. This follows up on these commits: 8d789be03430b80e0ba2fef19d56dd0b8e699ea2 c14b4371ed58859d264b7b2581cfedc9cfd8401f 2b64886c817ffa2d86abb9b4a5d79d1e2451 --- Like I commented below, are there any other extensions that it makes sense to port to software drivers? Would invalidate be generally useful there? src/glx/drisw_glx.c | 17 + 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index d9f47db..aea853d 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -487,6 +487,20 @@ static const struct glx_screen_vtable drisw_screen_vtable = { drisw_create_context }; +static void +driswBindExtensions(struct drisw_screen *psc, const __DRIextension **extensions) +{ + int i; + + /* FIXME: Figure out what other extensions can be ported here from dri2. */ + for (i = 0; extensions[i]; i++) { + if ((strcmp(extensions[i]-name, __DRI_TEX_BUFFER) == 0)) { +psc-texBuffer = (__DRItexBufferExtension *) extensions[i]; +__glXEnableDirectExtension(psc-base, GLX_EXT_texture_from_pixmap); + } + } +} + static struct glx_screen * driCreateScreen(int screen, struct glx_display *priv) { @@ -536,6 +550,9 @@ driCreateScreen(int screen, struct glx_display *priv) goto handle_error; } + extensions = psc-core-getExtensions(psc-driScreen); + driswBindExtensions(psc, extensions); + psc-base.configs = driConvertConfigs(psc-core, psc-base.configs, driver_configs); psc-base.visuals = -- 1.7.0.4 From f8827527efcd0c6cef8f42ac9ebb74a48f092006 Mon Sep 17 00:00:00 2001 From: nobled nob...@dreamwidth.org Date: Sun, 5 Sep 2010 16:21:03 + Subject: [PATCH 3/3] glx: Enable GLX_EXT_texture_from_pixmap in software Now if a software DRI driver advertises it, we can use it in direct-rendering contexts--without this, only the server took advantage of it for indirect contexts. This follows up on these commits: 8d789be03430b80e0ba2fef19d56dd0b8e699ea2 c14b4371ed58859d264b7b2581cfedc9cfd8401f 2b64886c817ffa2d86abb9b4a5d79d1e2451 --- src/glx/drisw_glx.c | 17 + 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index d9f47db..aea853d 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -487,6 +487,20 @@ static const struct glx_screen_vtable drisw_screen_vtable = { drisw_create_context }; +static void +driswBindExtensions(struct drisw_screen *psc, const __DRIextension **extensions) +{ + int i; + + /* FIXME: Figure out what other extensions can be ported here from dri2. */ + for (i = 0; extensions[i]; i++) { + if ((strcmp(extensions[i]-name, __DRI_TEX_BUFFER) == 0)) { + psc-texBuffer = (__DRItexBufferExtension *) extensions[i]; + __glXEnableDirectExtension(psc-base, GLX_EXT_texture_from_pixmap); + } + } +} + static struct glx_screen * driCreateScreen(int screen, struct glx_display *priv) { @@ -536,6 +550,9 @@ driCreateScreen(int screen, struct glx_display *priv) goto handle_error; } + extensions = psc-core-getExtensions(psc-driScreen); + driswBindExtensions(psc, extensions); + psc-base.configs = driConvertConfigs(psc-core, psc-base.configs, driver_configs); psc-base.visuals = -- 1.7.0.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 0/11] implement GL_ARB_debug_output
On Tue, May 3, 2011 at 7:33 PM, Brian Paul bri...@vmware.com wrote: On 05/02/2011 04:59 PM, nobled wrote: git repo: https://github.com/nobled/mesa.git (branch: arb_debug_output, rebased on bd661a933b18fccd7102d05932774ee61a90ec9e) web interface: https://github.com/nobled/mesa/commits/arb_debug_output spec: http://www.opengl.org/registry/specs/ARB/debug_output.txt This series adds almost everything needed to advertise the extension GL_ARB_debug_output. The only thing missing is the ability to pass an array of IDs to glDebugMessageControlARB with the parameter 'source' having the value GL_DEBUG_SOURCE_APPLICATION_ARB or GL_DEBUG_SOURCE_THIRD_PARTY_ARB. Since the *ControlARB stuff was the part I was least certain about, I also broke it up into even smaller patches. What I think is needed to fill in the missing functionality is a structure that works like C++'s std::map, with a GLuint/GLboolean key/value pair. There would also need to be, for each map, three std::set-like structures that record the HIGH, MEDIUM, and LOW-severity message IDs. Otherwise it wouldn't be possible for clients to make calls like this that impact all messages of a certain severity level: glDebugMessageControlARB(GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DONT_CARE, GL_DEBUG_SEVERITY_LOW_ARB, 0, NULL, GL_TRUE); Does mesa have structures like those in the auxiliary code somewhere? Or is there a way to wrap the C++ STL in C code? To map GLuint to 'something' we typically use the hash table in hash.c Otherwise, you could make something based on simple_list.h. I believe we're talking about a pretty small set of GLuints, right? So linear search wouldn't be a big deal? Open question: The app might pass 'implementation-dependent' message IDs to glDebugMessageControlARB that don't actually exist in mesa. The spec doesn't say whether we should give an error or silently ignore IDs like that. Also an open question: what to do when apps misbehave and send the same source/type/message ID tuple to glDebugMessageInsertARB twice or more, but with different severity levels each time, and then they call glDebugMessageControlARB on all messages with a certain severity. Should mesa use the latest-specified severity as the canonical one, or the first? I haven't even read the spec for this extension yet so I don't have any answers for you. I did a quick review of your patches and they mostly look OK. I'll post specific comments in a bit. It looks like almost all the changes are confined to errors.c and mtypes.h so I'm not too worried about regressions or a big impact on the rest of the code. I'm OK with you committing what you have and following up with changes if/when the above questions get answered. -Brian Okay, I revised and rebased the branch on github based on your comments. Now there are several new patches implementing the final pieces and enabling the extension by default when the environment variable MESA_DEBUG is set (the same way it enables the current stderr debug messages). ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 12/15] mesa: implement the last of GL_ARB_debug_output
-Debug.SyncOutput = GL_FALSE; ctx-Debug.Log[0].length = 0; @@ -568,12 +747,44 @@ _mesa_init_errors(struct gl_context *ctx) memset(ctx-Debug.WinsysErrors, GL_TRUE, sizeof ctx-Debug.WinsysErrors); memset(ctx-Debug.ShaderErrors, GL_TRUE, sizeof ctx-Debug.ShaderErrors); memset(ctx-Debug.OtherErrors, GL_TRUE, sizeof ctx-Debug.OtherErrors); - memset(ctx-Debug.ClientIDs.Defaults[SEVERITY_HIGH], GL_TRUE, - sizeof ctx-Debug.ClientIDs.Defaults[SEVERITY_HIGH]); - memset(ctx-Debug.ClientIDs.Defaults[SEVERITY_MEDIUM], GL_TRUE, - sizeof ctx-Debug.ClientIDs.Defaults[SEVERITY_MEDIUM]); - memset(ctx-Debug.ClientIDs.Defaults[SEVERITY_LOW], GL_FALSE, - sizeof ctx-Debug.ClientIDs.Defaults[SEVERITY_LOW]); + memset(ClientIDs-Defaults[SEVERITY_HIGH], GL_TRUE, + sizeof ClientIDs-Defaults[SEVERITY_HIGH]); + memset(ClientIDs-Defaults[SEVERITY_MEDIUM], GL_TRUE, + sizeof ClientIDs-Defaults[SEVERITY_MEDIUM]); + memset(ClientIDs-Defaults[SEVERITY_LOW], GL_FALSE, + sizeof ClientIDs-Defaults[SEVERITY_LOW]); + + /* Initialize state for filtering client-provided debug messages. */ + for (s = 0; s SOURCE_COUNT; s++) + for (t = 0; t TYPE_COUNT; t++) { + ClientIDs-Namespaces[s][t].IDs = _mesa_NewHashTable(); + assert(ClientIDs-Namespaces[s][t].IDs); + + for (sev = 0; sev SEVERITY_COUNT; sev++) +make_empty_list(ClientIDs-Namespaces[s][t].Severity[sev]); + } +} + +void +_mesa_free_errors_data(struct gl_context *ctx) +{ + int s, t, sev; + struct gl_client_debug *ClientIDs = ctx-Debug.ClientIDs; + + /* Tear down state for filtering client-provided debug messages. */ + for (s = 0; s SOURCE_COUNT; s++) + for (t = 0; t TYPE_COUNT; t++) { + _mesa_DeleteHashTable(ClientIDs-Namespaces[s][t].IDs); + for (sev = 0; sev SEVERITY_COUNT; sev++) { +struct simple_node *node, *tmp; +struct gl_client_severity *entry; + +foreach_s(node, tmp, ClientIDs-Namespaces[s][t].Severity[sev]) { + entry = (struct gl_client_severity *)node; + FREE(entry); +} + } + } } /**/ diff --git a/src/mesa/main/errors.h b/src/mesa/main/errors.h index 6ab9b5e..ed1c6fc 100644 --- a/src/mesa/main/errors.h +++ b/src/mesa/main/errors.h @@ -54,6 +54,9 @@ extern void _mesa_init_errors( struct gl_context *ctx ); extern void +_mesa_free_errors_data( struct gl_context *ctx ); + +extern void _mesa_warning( struct gl_context *gc, const char *fmtString, ... ) PRINTFLIKE(2, 3); extern void -- 1.7.0.4 From 1812012f0be165580416dcc9a0a8ad09d20966b8 Mon Sep 17 00:00:00 2001 From: nobled nob...@dreamwidth.org Date: Wed, 4 May 2011 19:42:55 + Subject: [PATCH 12/15] mesa: implement the last of GL_ARB_debug_output Store client-defined message IDs in a hash table, and sort them by severity into three linked lists so they can be selected by severity level later. --- src/mesa/main/context.c |2 + src/mesa/main/errors.c | 267 ++- src/mesa/main/errors.h |3 + 3 files changed, 244 insertions(+), 28 deletions(-) diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 0173535..6b82817 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1148,6 +1148,8 @@ _mesa_free_context_data( struct gl_context *ctx ) /* needs to be after freeing shared state */ _mesa_free_display_list_data(ctx); + _mesa_free_errors_data(ctx); + if (ctx-Extensions.String) free((void *) ctx-Extensions.String); diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index a93137c..3a1d5a8 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -32,6 +32,7 @@ #include imports.h #include context.h +#include hash.h #include mtypes.h #include version.h @@ -39,6 +40,12 @@ #define MAXSTRING MAX_DEBUG_MESSAGE_LENGTH +struct gl_client_severity +{ + struct simple_node link; + GLuint ID; +}; + static char out_of_memory[] = Debugging error: out of memory; #define enum_is(e, kind1, kind2) \ @@ -114,6 +121,134 @@ enum_to_index(GLenum e) }; } + +/* + * We store a bitfield in the hash table, with five possible values total. + * + * The ENABLED_BIT's purpose is self-explanatory. + * + * The FOUND_BIT is needed to differentiate the value of DISABLED from + * the value returned by HashTableLookup() when it can't find the given key. + * + * The KNOWN_SEVERITY bit is a bit complicated: + * + * A client may call Control() with an array of IDs, then call Control() + * on all message IDs of a certain severity, then Insert() one of the + * previously specified IDs, giving us a known severity level, then call + * Control() on all message IDs of a certain severity level again. + * + * After the first call, those IDs will have a FOUND_BIT, but will not + * exist in any severity-specific list, so
[Mesa-dev] [PATCH 15/15] mesa: make debugging state per-context
Reduce duplication of code and make the MESA_DEBUG environment variable turn on GL_ARB_debug_output by default, and use the same logic to determine whether to print debugging output to the command-line. --- src/mesa/main/errors.c | 71 ++- 1 files changed, 27 insertions(+), 44 deletions(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index 44ecf5d..e1d4ef1 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -735,6 +735,25 @@ _mesa_init_errors(struct gl_context *ctx) { int s, t, sev; struct gl_client_debug *ClientIDs = ctx-Debug.ClientIDs; + GLboolean debug; + + /* Check the MESA_DEBUG environment variable. +*/ + { + char *env = _mesa_getenv(MESA_DEBUG); + + /* In a debug build, we print warning messages *unless* + * MESA_DEBUG is 0. In a non-debug build, we don't + * print warning messages *unless* MESA_DEBUG is + * set *to any value*. + */ +#ifdef DEBUG + debug = (env != NULL atoi(env) == 0) ? 0 : 1; +#else + debug = (env != NULL) ? 1 : 0; +#endif + } + ctx-Extensions.ARB_debug_output = debug; ctx-Debug.Callback = NULL; ctx-Debug.SyncOutput = GL_FALSE; @@ -804,28 +823,10 @@ _mesa_log_api_error(struct gl_context *ctx, gl_api_error id, } static void -output_if_debug(const char *prefixString, const char *outputString, -GLboolean newline) +output_if_debug(struct gl_context *ctx, const char *prefixString, +const char *outputString, GLboolean newline) { - static int debug = -1; - - /* Check the MESA_DEBUG environment variable if it hasn't -* been checked yet. We only have to check it once... -*/ - if (debug == -1) { - char *env = _mesa_getenv(MESA_DEBUG); - - /* In a debug build, we print warning messages *unless* - * MESA_DEBUG is 0. In a non-debug build, we don't - * print warning messages *unless* MESA_DEBUG is - * set *to any value*. - */ -#ifdef DEBUG - debug = (env != NULL atoi(env) == 0) ? 0 : 1; -#else - debug = (env != NULL) ? 1 : 0; -#endif - } + GLboolean debug = ctx-Extensions.ARB_debug_output; /* Now only print the string if we're required to do so. */ if (debug) { @@ -891,7 +892,7 @@ flush_delayed_errors( struct gl_context *ctx ) ctx-ErrorDebugCount, error_string(ctx-ErrorValue)); - output_if_debug(Mesa, s, GL_TRUE); + output_if_debug(ctx, Mesa, s, GL_TRUE); ctx-ErrorDebugCount = 0; } @@ -917,7 +918,7 @@ _mesa_warning( struct gl_context *ctx, const char *fmtString, ... ) if (ctx) flush_delayed_errors( ctx ); - output_if_debug(Mesa warning, str, GL_TRUE); + output_if_debug(ctx, Mesa warning, str, GL_TRUE); } @@ -965,25 +966,7 @@ _mesa_problem( const struct gl_context *ctx, const char *fmtString, ... ) void _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... ) { - static GLint debug = -1; - - /* Check debug environment variable only once: -*/ - if (debug == -1) { - const char *debugEnv = _mesa_getenv(MESA_DEBUG); - -#ifdef DEBUG - if (debugEnv strstr(debugEnv, silent)) - debug = GL_FALSE; - else - debug = GL_TRUE; -#else - if (debugEnv) - debug = GL_TRUE; - else - debug = GL_FALSE; -#endif - } + GLboolean debug = ctx-Extensions.ARB_debug_output; if (debug) { if (ctx-ErrorValue == error @@ -1007,7 +990,7 @@ _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... ) if (len MAXSTRING) { _mesa_log_api_error(ctx, API_ERROR_UNKNOWN, len, s2); -output_if_debug(Mesa: User error, s2, GL_TRUE); +output_if_debug(ctx, Mesa: User error, s2, GL_TRUE); } ctx-ErrorDebugFmtString = fmtString; @@ -1035,7 +1018,7 @@ _mesa_debug( const struct gl_context *ctx, const char *fmtString, ... ) va_start(args, fmtString); _mesa_vsnprintf(s, MAXSTRING, fmtString, args); va_end(args); - output_if_debug(Mesa, s, GL_FALSE); + output_if_debug(ctx, Mesa, s, GL_FALSE); #endif /* DEBUG */ (void) ctx; (void) fmtString; -- 1.7.0.4 From e7c380003806ff13e18297829e2f290ac6d46b4c Mon Sep 17 00:00:00 2001 From: nobled nob...@dreamwidth.org Date: Wed, 4 May 2011 20:00:34 + Subject: [PATCH 15/15] mesa: make debugging state per-context Reduce duplication of code and make the MESA_DEBUG environment variable turn on GL_ARB_debug_output by default, and use the same logic to determine whether to print debugging output to the command-line. --- src/mesa/main/errors.c | 71 ++- 1 files changed, 27 insertions(+), 44 deletions(-) diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c index 44ecf5d..e1d4ef1 100644 --- a/src/mesa/main/errors.c +++ b/src/mesa/main/errors.c @@ -735,6 +735,25 @@ _mesa_init_errors(struct
[Mesa-dev] [PATCH 0/11] implement GL_ARB_debug_output
git repo: https://github.com/nobled/mesa.git (branch: arb_debug_output, rebased on bd661a933b18fccd7102d05932774ee61a90ec9e) web interface: https://github.com/nobled/mesa/commits/arb_debug_output spec: http://www.opengl.org/registry/specs/ARB/debug_output.txt This series adds almost everything needed to advertise the extension GL_ARB_debug_output. The only thing missing is the ability to pass an array of IDs to glDebugMessageControlARB with the parameter 'source' having the value GL_DEBUG_SOURCE_APPLICATION_ARB or GL_DEBUG_SOURCE_THIRD_PARTY_ARB. Since the *ControlARB stuff was the part I was least certain about, I also broke it up into even smaller patches. What I think is needed to fill in the missing functionality is a structure that works like C++'s std::map, with a GLuint/GLboolean key/value pair. There would also need to be, for each map, three std::set-like structures that record the HIGH, MEDIUM, and LOW-severity message IDs. Otherwise it wouldn't be possible for clients to make calls like this that impact all messages of a certain severity level: glDebugMessageControlARB(GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DONT_CARE, GL_DEBUG_SEVERITY_LOW_ARB, 0, NULL, GL_TRUE); Does mesa have structures like those in the auxiliary code somewhere? Or is there a way to wrap the C++ STL in C code? Open question: The app might pass 'implementation-dependent' message IDs to glDebugMessageControlARB that don't actually exist in mesa. The spec doesn't say whether we should give an error or silently ignore IDs like that. Also an open question: what to do when apps misbehave and send the same source/type/message ID tuple to glDebugMessageInsertARB twice or more, but with different severity levels each time, and then they call glDebugMessageControlARB on all messages with a certain severity. Should mesa use the latest-specified severity as the canonical one, or the first? ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev