Re: [Mesa-dev] [PATCH 12/15] st/mesa: implement GL_ARB_texture_storage
This looks good, and so does the rest of the series AFAICS. Jose - Original Message - From: Brian Paul bri...@vmware.com --- src/mesa/state_tracker/st_cb_texture.c | 62 src/mesa/state_tracker/st_extensions.c |1 + 2 files changed, 63 insertions(+), 0 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 169e235..1735b8e 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1894,6 +1894,66 @@ st_get_default_texture(struct st_context *st) } +/** + * Called via ctx-Driver.AllocTextureStorage() to allocate texture memory + * for a whole mipmap stack. + */ +static GLboolean +st_AllocTextureStorage(struct gl_context *ctx, + struct gl_texture_object *texObj, + GLsizei levels, GLsizei width, + GLsizei height, GLsizei depth) +{ + const GLuint numFaces = (texObj-Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1; + struct st_context *st = st_context(ctx); + struct st_texture_object *stObj = st_texture_object(texObj); + GLuint ptWidth, ptHeight, ptDepth, ptLayers, bindings; + enum pipe_format fmt; + GLint level; + + assert(levels 0); + + /* Save the level=0 dimensions */ + stObj-width0 = width; + stObj-height0 = height; + stObj-depth0 = depth; + stObj-lastLevel = levels - 1; + + fmt = st_mesa_format_to_pipe_format(texObj-Image[0][0]-TexFormat); + + bindings = default_bindings(st, fmt); + + st_gl_texture_dims_to_pipe_dims(texObj-Target, + width, height, depth, + ptWidth, ptHeight, ptDepth, ptLayers); + + stObj-pt = st_texture_create(st, + gl_target_to_pipe(texObj-Target), + fmt, + levels, + ptWidth, + ptHeight, + ptDepth, + ptLayers, + bindings); + if (!stObj-pt) + return GL_FALSE; + + /* Set image resource pointers */ + for (level = 0; level levels; level++) { + GLuint face; + for (face = 0; face numFaces; face++) { + struct st_texture_image *stImage = +st_texture_image(texObj-Image[face][level]); + pipe_resource_reference(stImage-pt, stObj-pt); + } + } + + return GL_TRUE; +} + + + void st_init_texture_functions(struct dd_function_table *functions) { @@ -1931,4 +1991,6 @@ st_init_texture_functions(struct dd_function_table *functions) /* XXX Temporary until we can query pipe's texture sizes */ functions-TestProxyTexImage = _mesa_test_proxy_teximage; + + functions-AllocTextureStorage = st_AllocTextureStorage; } diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 37f36de..6d9ddf5 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -262,6 +262,7 @@ void st_init_extensions(struct st_context *st) ctx-Extensions.ARB_texture_env_combine = GL_TRUE; ctx-Extensions.ARB_texture_env_crossbar = GL_TRUE; ctx-Extensions.ARB_texture_env_dot3 = GL_TRUE; + ctx-Extensions.ARB_texture_storage = GL_TRUE; ctx-Extensions.ARB_vertex_array_object = GL_TRUE; ctx-Extensions.ARB_vertex_program = GL_TRUE; ctx-Extensions.ARB_window_pos = GL_TRUE; -- 1.7.3.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
[Mesa-dev] [Bug 42128] Crash when visiting a site with Firefox
https://bugs.freedesktop.org/show_bug.cgi?id=42128 --- Comment #5 from Thor t01...@yahoo.com 2011-10-27 02:53:52 UTC --- Created attachment 52818 -- https://bugs.freedesktop.org/attachment.cgi?id=52818 The output of glxinfo -- Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] Implement NV_fog_distance for Gallium hardware
If there are no other concerns, I'll push this on Saturday, including the nv20 fix from Francisco Jerez. http://cgit.freedesktop.org/~mareko/mesa/log/?h=nv-fog-distance Marek On Tue, Sep 20, 2011 at 7:50 AM, Nicholas Miell nmi...@gmail.com wrote: On 09/19/2011 10:23 AM, Ian Romanick wrote: I guess the big question is... why? With vertex shaders, this functionality is not terribly useful. Over the past few weeks we've been *removing* code like this, so it seems kind of odd to add some of it. If I'm not mistaken, the only hardware in Mesa that can do this but not vertex shaders is NV10. Is it really that helpful? I'm not necessarily opposed to adding this, I just want to be sure we're giving it full thought... that's all. Good question. In the general case, I'd agree with you that implementing ancient extensions is a waste of effort, but this one is (AFAICT) an extremely low impact change that benefits a number of existing projects. It even has new code being written to target it, oddly enough (which is what prompted my interest in the first place). My first pass at this actually skipped the extension entirely and just changed the generated vertex program to always use the eye radial distance, but I figured that a full implementation of the extension would be the correct thing to do, especially when there may be some program out in the wild that breaks if the fog distance isn't abs(Ze). ___ 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] Implement NV_fog_distance for Gallium hardware
I only see implementation for ffvertex_prog.c Wasn't (or will soon be) the FF-Mesa IR replaced with FF-GLSL IR? If so, can you truly enable unconditionally on gallium/st? Jose - Original Message - If there are no other concerns, I'll push this on Saturday, including the nv20 fix from Francisco Jerez. http://cgit.freedesktop.org/~mareko/mesa/log/?h=nv-fog-distance Marek On Tue, Sep 20, 2011 at 7:50 AM, Nicholas Miell nmi...@gmail.com wrote: On 09/19/2011 10:23 AM, Ian Romanick wrote: I guess the big question is... why? With vertex shaders, this functionality is not terribly useful. Over the past few weeks we've been *removing* code like this, so it seems kind of odd to add some of it. If I'm not mistaken, the only hardware in Mesa that can do this but not vertex shaders is NV10. Is it really that helpful? I'm not necessarily opposed to adding this, I just want to be sure we're giving it full thought... that's all. Good question. In the general case, I'd agree with you that implementing ancient extensions is a waste of effort, but this one is (AFAICT) an extremely low impact change that benefits a number of existing projects. It even has new code being written to target it, oddly enough (which is what prompted my interest in the first place). My first pass at this actually skipped the extension entirely and just changed the generated vertex program to always use the eye radial distance, but I figured that a full implementation of the extension would be the correct thing to do, especially when there may be some program out in the wild that breaks if the fog distance isn't abs(Ze). ___ 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 mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] Implement NV_fog_distance for Gallium hardware
From what I can see, the fog distance is computed per-vertex and stored in the FogCoord vertex shader output. There is no fragment shader change required. The fixed-function vertex program hasn't been converted to the GLSL IR yet, only the fragment program, which is irrelevant here. Gallium only uses shaders, which means it always uses the generated fixed-function programs (regardless of the IR being used), so NV_fog_distance can always be enabled. Marek On Thu, Oct 27, 2011 at 3:18 PM, Jose Fonseca jfons...@vmware.com wrote: I only see implementation for ffvertex_prog.c Wasn't (or will soon be) the FF-Mesa IR replaced with FF-GLSL IR? If so, can you truly enable unconditionally on gallium/st? Jose - Original Message - If there are no other concerns, I'll push this on Saturday, including the nv20 fix from Francisco Jerez. http://cgit.freedesktop.org/~mareko/mesa/log/?h=nv-fog-distance Marek On Tue, Sep 20, 2011 at 7:50 AM, Nicholas Miell nmi...@gmail.com wrote: On 09/19/2011 10:23 AM, Ian Romanick wrote: I guess the big question is... why? With vertex shaders, this functionality is not terribly useful. Over the past few weeks we've been *removing* code like this, so it seems kind of odd to add some of it. If I'm not mistaken, the only hardware in Mesa that can do this but not vertex shaders is NV10. Is it really that helpful? I'm not necessarily opposed to adding this, I just want to be sure we're giving it full thought... that's all. Good question. In the general case, I'd agree with you that implementing ancient extensions is a waste of effort, but this one is (AFAICT) an extremely low impact change that benefits a number of existing projects. It even has new code being written to target it, oddly enough (which is what prompted my interest in the first place). My first pass at this actually skipped the extension entirely and just changed the generated vertex program to always use the eye radial distance, but I figured that a full implementation of the extension would be the correct thing to do, especially when there may be some program out in the wild that breaks if the fog distance isn't abs(Ze). ___ 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 mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] Implement NV_fog_distance for Gallium hardware
- Original Message - From what I can see, the fog distance is computed per-vertex and stored in the FogCoord vertex shader output. There is no fragment shader change required. The fixed-function vertex program hasn't been converted to the GLSL IR yet, only the fragment program, which is irrelevant here. OK. I missed that tidbit. Jose ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/5] glsl: Fix copy-paste error in constant_expression_value(ir_binop_nequal)
On Wed, 26 Oct 2011 18:42:52 -0700, Paul Berry stereotype...@gmail.com wrote: The implementation of ir_binop_nequal in constant_expression_value() appears to have been copy-and-pasted from the implementation of ir_binop_equal, but with all instances of '==' changed to '!='. This is correct except for one minor flaw: one of those '==' operators was in an assertion checking that the types of the two arguments were equal. That one needs to stay an '=='. This series is Reviewed-by: Eric Anholt e...@anholt.net pgpUf0igB3Llz.pgp Description: PGP signature ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [Bug 42313] New: software rasterizer: ignore glTexCoordPointer if GL_TEXTURE_2D is disabled
https://bugs.freedesktop.org/show_bug.cgi?id=42313 Bug #: 42313 Summary: software rasterizer: ignore glTexCoordPointer if GL_TEXTURE_2D is disabled Classification: Unclassified Product: Mesa Version: 7.11 Platform: x86-64 (AMD64) OS/Version: Linux (All) Status: NEW Severity: trivial Priority: medium Component: Other AssignedTo: mesa-dev@lists.freedesktop.org ReportedBy: roman.va...@gmail.com Hello, fellows. I've noticed behavior of software rasterizer is slightly differs form most of hardware rendered implementations. At the moment I've tried it on several platforms (mesa/i945GM, fglrx and win32/nvidia) and software rasterizer of mesa. I'm focused to reduce excess OpenGL calls in my program due to eliminating unnecessary state changes. This also critical due to usage of python language. As a result I've found that I can use glDrawArrays to draw non-textured primitives even if glTexCoordPointer is binded to buffer (but glDisable(GL_TEXTURE_2D) and glBindTexture(GL_TEXTURE_2D, 0) was called before). It works fine on listed hardware platforms. But draws nothing with mesa software rasterizer. Is it possible to adjust behavior of mesa software rasterizer to closely match hardware renderers in this aspect? Thank you in advance, Roman. -- Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email --- You are receiving this mail because: --- You are the assignee for the bug. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] r600g: Replace needless flush in texture upload.
Looks good to me. Ideally even texture_barrier should not be needed. set_framebuffer_state() and flush() should flush caches automatically. If they don't, there is a bug. Marek 2011/10/27 Mathias Fröhlich mathias.froehl...@gmx.net: Hi, On Saturday, October 22, 2011 13:36:37 Mathias Fröhlich wrote: The attached patch reduces the amount of pipe flushes for r600g. I am not exactly sure if we could skip this flush entirely because of the internal r600g winsys flush logic. But what we can do is the attached patch: Replace pipe-flush() with pipe-texture_barrier() in the texture upload path for the staging texture. This should be enough to get data out of the gpu caches ready to be read for texture fetch. Please review. Any comment on that? May be I need to mention that it passed r600g piglit tests on an rv770 and rv635. Additionally I am running that on my installed systems since july. Thanks Mathias ___ 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] r600g: Replace needless flush in texture upload.
On Thursday 27 October 2011, Mathias Fröhlich wrote: Hi, On Saturday, October 22, 2011 13:36:37 Mathias Fröhlich wrote: The attached patch reduces the amount of pipe flushes for r600g. I am not exactly sure if we could skip this flush entirely because of the internal r600g winsys flush logic. But what we can do is the attached patch: Replace pipe-flush() with pipe-texture_barrier() in the texture upload path for the staging texture. This should be enough to get data out of the gpu caches ready to be read for texture fetch. Please review. Any comment on that? May be I need to mention that it passed r600g piglit tests on an rv770 and rv635. Additionally I am running that on my installed systems since july. A problem with texture_barrier() is that it flushes and invalidates all the texture and cb caches. It may be an improvement over pipe-flush(), but if we know which texture(s) are involved, I think we should be able to do better. Other than that I don't see a problem with it, assuming that flushing the caches is the only reason for calling pipe-flush() here. Regards, Fredrik ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] glsl: translate transform feedback varyings into low-level representation
On 10/26/2011 03:28 PM, Marek Olšák wrote: This adds a function that takes an array of varyings from glTranformFeedbackVaryingsEXT and generates gl_transform_feedback_info, which is supposed to be consumed by drivers. Useful for ir_to_mesa and glsl_to_tgsi. With Dan McCabe's patch, I think this is all that's needed for transform feedback GLSL support. This work should probably be better integrated with Dan's code though (maybe some stuff that's done here should be done in the linker instead). What's missing is reporting linker errors (AFAIK). This patch just covers the post-link part. The piglit tests ext_transform_feedback-position,separate,interleaved pass with this. --- src/glsl/Makefile |1 + src/glsl/ir.h | 15 ++ src/glsl/ir_set_transform_feedback_outs.cpp | 299 +++ src/mesa/main/mtypes.h | 12 + 4 files changed, 327 insertions(+), 0 deletions(-) create mode 100644 src/glsl/ir_set_transform_feedback_outs.cpp diff --git a/src/glsl/Makefile b/src/glsl/Makefile index 504f1fb..f3b8e2e 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -48,6 +48,7 @@ CXX_SOURCES = \ ir_reader.cpp \ ir_rvalue_visitor.cpp \ ir_set_program_inouts.cpp \ + ir_set_transform_feedback_outs.cpp \ ir_validate.cpp \ ir_variable.cpp \ ir_variable_refcount.cpp \ diff --git a/src/glsl/ir.h b/src/glsl/ir.h index b707634..c17473c 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -1685,4 +1685,19 @@ extern char * prototype_string(const glsl_type *return_type, const char *name, exec_list *parameters); +/** + * Set transform feedback output locations and other related info + * in gl_program. + * + * \param shaderprog The inputs are the parameters + *from glTransformFeedbackVaryings expected + *to be in gl_shader_program::TransformFeedback. + * + * \param infoWhere the resulting info is stored. + */ +extern void +do_set_transform_feedback_outs(exec_list *instructions, + struct gl_shader_program *shaderprog, + struct gl_transform_feedback_info *info); + #endif /* IR_H */ diff --git a/src/glsl/ir_set_transform_feedback_outs.cpp b/src/glsl/ir_set_transform_feedback_outs.cpp new file mode 100644 index 000..0138024 --- /dev/null +++ b/src/glsl/ir_set_transform_feedback_outs.cpp @@ -0,0 +1,299 @@ +/* + * Copyright © 2010 Intel Corporation + * Copyright © 2011 Marek Olšák mar...@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. + */ + +/** + * \file ir_set_transform_feedback_outs.cpp + * + * Used to obtain info about shader outputs from the GLSL IR + * for transform feedback. + * The driver codegen backend needs to know locations of the outputs + * which are to be stored in transform feedback buffers and the number + * of components each such output has. + * + * This is similar to ir_set_program_inouts. + */ + +extern C { +#include program/hash_table.h +} +#include main/core.h +#include ir.h +#include ir_visitor.h +#include glsl_types.h +#include cmath + + +struct tfeedback_decl { + char name[1024]; Not so excited about the arbitrarily sized string... + bool is_array; + unsigned array_index; +}; + + +/* This expects expressions of the form var and var[i], + * where i is a literal. + * + * We don't have to be pedantic about what is a valid GLSL variable name, + * because any variable with an invalid name can't exist in the IR anyway. */ +static bool parse_tfeedback_decl(const char *input, + struct tfeedback_decl *decl) +{ + unsigned name_index = 0; + + memset(decl, 0, sizeof(*decl)); + + /* Parse the variable name.
Re: [Mesa-dev] mis-counting varying vars in the linker
On 10/26/2011 11:11 AM, Brian Paul wrote: I think the linker is mis-counting gl_TexCoord[] varying vars when linking. For example, if we have this vertex/fragment shader combination: // vs void main() { gl_Position = ftransform(); gl_TexCoord[6] = gl_MultiTexCoord[0]; } // fs void main() { gl_Color = gl_TexCoord[6]; } the varying_vectors counter in assign_varying_locations() will be 7, not 1. It seems the gl_TexCoord var is being seen as an array of 7 elements and we're counting the whole array rather than the individual elements used. This is correct behavior. Page 54 (page 60 of the PDF) of the GLSL 1.20 spec says: As with all arrays, indices used to subscript gl_TexCoord must either be an integral constant expressions, or this array must be re-declared by the shader with a size. The size can be at most gl_MaxTextureCoords. Using indexes close to 0 may aid the implementation in preserving varying resources. The last sentence is the most important bit. This is causing a link failure in an app here because the vs/fs shader pair uses several user-defined varying vars plus gl_TexCoord[4]. The varying count exceeds GL_MAX_VARYING_FLOATS even though we're really not using that many varying slots. We do have other problems with varyings that may be the actual cause of the failure. We don't currently pack multiple variables into a vec4, so even using 17 float varyings will fail today. This is the topic of bug #34201. I believe that Paul is going to work on this as part of his work to implement the new 1.30 interpolation qualifiers. There were also some patches by Vincent Lejeune posted to the mesa-dev list a couple months ago. These patches had some significant issues, and Vincent never responded to the review comments. I think this will need to be implemented in at least two parts. Something like Vincent's code should be used in the linker to pack varyings with identical interpolation modes. This should cover 90% of cases. Each driver will need some device-specific code to handle packing varyings with differing interpolation modes. I don't know about other hardware, but it looks like i965-like GPUs will have some issues with mixing flat with either smooth or noperspective. Mixing smooth and noperspective shouldn't be a problem, but the driver still needs to know that they've been mixed. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 17/33] i965: Fold prepare() and emit() of VS surface state setup together.
On 24 October 2011 14:17, Eric Anholt e...@anholt.net wrote: This rearranges the code a bit, and makes the upload of the binding table take only as many surfaces as there are in use. --- src/mesa/drivers/dri/i965/brw_vs_surface_state.c | 62 +- 1 files changed, 25 insertions(+), 37 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c index bfc4f5d..0237b58 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c @@ -138,22 +138,6 @@ brw_update_vs_constant_surface( struct gl_context *ctx, } } - -static void -prepare_vs_surfaces(struct brw_context *brw) -{ - int nr_surfaces = 0; - - if (brw-vs.const_bo) { - nr_surfaces = 1; - } - - if (brw-vs.nr_surfaces != nr_surfaces) { - brw-state.dirty.brw |= BRW_NEW_NR_VS_SURFACES; - brw-vs.nr_surfaces = nr_surfaces; - } -} - /** * Vertex shader surfaces (constant buffer). * @@ -161,36 +145,41 @@ prepare_vs_surfaces(struct brw_context *brw) * to be updated, and produces BRW_NEW_NR_VS_SURFACES for the VS unit and * CACHE_NEW_SURF_BIND for the binding table upload. */ -static void upload_vs_surfaces(struct brw_context *brw) +static void +brw_upload_vs_surfaces(struct brw_context *brw) { struct gl_context *ctx = brw-intel.ctx; uint32_t *bind; int i; + int nr_surfaces = 0; + + /* BRW_NEW_VS_CONSTBUF */ + if (brw-vs.const_bo) { + nr_surfaces = 1; + brw_update_vs_constant_surface(ctx, SURF_INDEX_VERT_CONST_BUFFER); + } + + if (nr_surfaces != 0) { This reads a little strange to me. The only way nr_surfaces can be nonzero is if the previous if test succeeded, so why not just merge the two if statements? + bind = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE, +sizeof(uint32_t) * nr_surfaces, +32, brw-vs.bind_bo_offset); - /* BRW_NEW_NR_VS_SURFACES */ - if (brw-vs.nr_surfaces == 0) { + for (i = 0; i nr_surfaces; i++) { +/* BRW_NEW_VS_CONSTBUF */ +bind[i] = brw-vs.surf_offset[i]; + } This for loop also seems weird, since at this point in the code nr_surfaces is known to be equal to 1. Why not just do bind[0] = brw-vs.surf_offset[0];? + brw-state.dirty.brw |= BRW_NEW_VS_BINDING_TABLE; + } else { if (brw-vs.bind_bo_offset) { brw-state.dirty.brw |= BRW_NEW_VS_BINDING_TABLE; +brw-vs.bind_bo_offset = 0; } - brw-vs.bind_bo_offset = 0; - return; } - brw_update_vs_constant_surface(ctx, SURF_INDEX_VERT_CONST_BUFFER); - - /* Might want to calculate nr_surfaces first, to avoid taking up so much -* space for the binding table. (once we have vs samplers) -*/ - bind = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE, - sizeof(uint32_t) * BRW_VS_MAX_SURF, - 32, brw-vs.bind_bo_offset); - - for (i = 0; i BRW_VS_MAX_SURF; i++) { - /* BRW_NEW_VS_CONSTBUF */ - bind[i] = brw-vs.surf_offset[i]; + if (brw-vs.nr_surfaces != nr_surfaces) { + brw-state.dirty.brw |= BRW_NEW_NR_VS_SURFACES; + brw-vs.nr_surfaces = nr_surfaces; } - - brw-state.dirty.brw |= BRW_NEW_VS_BINDING_TABLE; } const struct brw_tracked_state brw_vs_surfaces = { @@ -201,6 +190,5 @@ const struct brw_tracked_state brw_vs_surfaces = { BRW_NEW_BATCH), .cache = 0 }, - .prepare = prepare_vs_surfaces, - .emit = upload_vs_surfaces, + .emit = brw_upload_vs_surfaces, }; -- 1.7.7 ___ 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] i965 batch rollback: no more prepare() vs emit().
On 24 October 2011 14:16, Eric Anholt e...@anholt.net wrote: I did do some testing by making libdrm claim a smaller aperture size and thus trigger the rollback code, which caught one bug. Generally, piglit doesn't trigger rollback at all, which is a bit concerning from a testing coverage standpoint. For people reviewing, I think the interesting part to review is mostly making sure that my assertions about the incremental changes of moving things from prepare() to emit() are true. A particular risk would be if I moved something from prepare() time (before all emit() calls) to emit() time (after some emit() calls) without noticing the dependency by those emits() in between. No noticeable performance impact from the change, though I was hoping to drop CPU usage a bit. Oh well. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev I don't understand enough of the code to give a reviewed-by, but I've read through all of it, and other than the comments I've already made, nothing jumped out at me as a problem. Acked-by: Paul Berry stereotype...@gmail.com ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] glsl: Remove pointless uses of glsl_type::get_base_type().
These are effectively doing type-get_base_type()-base_type, which is equivalent to type-base_type. Just use that, as it's simpler. Signed-off-by: Kenneth Graunke kenn...@whitecape.org --- src/glsl/ir_print_visitor.cpp |4 +--- src/glsl/ir_reader.cpp|6 ++ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp index b713bd0..1471355 100644 --- a/src/glsl/ir_print_visitor.cpp +++ b/src/glsl/ir_print_visitor.cpp @@ -368,8 +368,6 @@ void ir_print_visitor::visit(ir_assignment *ir) void ir_print_visitor::visit(ir_constant *ir) { - const glsl_type *const base_type = ir-type-get_base_type(); - printf((constant ); print_type(ir-type); printf( (); @@ -390,7 +388,7 @@ void ir_print_visitor::visit(ir_constant *ir) for (unsigned i = 0; i ir-type-components(); i++) { if (i != 0) printf( ); -switch (base_type-base_type) { +switch (ir-type-base_type) { case GLSL_TYPE_UINT: printf(%u, ir-value.u[i]); break; case GLSL_TYPE_INT: printf(%d, ir-value.i[i]); break; case GLSL_TYPE_FLOAT: printf(%f, ir-value.f[i]); break; diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index afb06b3..3461c56 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -773,8 +773,6 @@ ir_reader::read_constant(s_expression *expr) return new(mem_ctx) ir_constant(type, elements); } - const glsl_type *const base_type = type-get_base_type(); - ir_constant_data data = { { 0 } }; // Read in list of values (at most 16). @@ -787,7 +785,7 @@ ir_reader::read_constant(s_expression *expr) s_expression *expr = (s_expression*) it.get(); - if (base_type-base_type == GLSL_TYPE_FLOAT) { + if (type-base_type == GLSL_TYPE_FLOAT) { s_number *value = SX_AS_NUMBER(expr); if (value == NULL) { ir_read_error(values, expected numbers); @@ -801,7 +799,7 @@ ir_reader::read_constant(s_expression *expr) return NULL; } -switch (base_type-base_type) { +switch (type-base_type) { case GLSL_TYPE_UINT: { data.u[k] = value-value(); break; -- 1.7.7 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] i965: Use the actual hardware g0 register for texel offset setup.
The idea here is to set up the message header with the Sampler State pointer which the hardware provides as part of the PS Thread Payload in register g0. Unfortunately, the existing code fs_reg(GRF, 0, BRW_REGISTER_TYPE_UD)) actually references virtual GRF 0 rather than the hardware g0. This is just some arbitrary GRF temporary which will get register allocated. So, we ended up setting up the header with garbage. Signed-off-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/brw_fs_visitor.cpp |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 215cdcd..b0f716f 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -1086,7 +1086,7 @@ fs_visitor::visit(ir_texture *ir) /* Explicitly set up the message header by copying g0 to msg reg m1. */ emit(BRW_OPCODE_MOV, fs_reg(MRF, 1, BRW_REGISTER_TYPE_UD), - fs_reg(GRF, 0, BRW_REGISTER_TYPE_UD)); + fs_reg(retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UD))); /* Then set the offset bits in DWord 2 of the message header. */ emit(BRW_OPCODE_MOV, -- 1.7.7 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] glsl: Implement GLSL 1.30's literal integer range restrictions.
On 26 October 2011 13:00, Eric Anholt e...@anholt.net wrote: From page 22 (28 of PDF) of GLSL 1.30 spec: It is an error to provide a literal integer whose magnitude is too large to store in a variable of matching signed or unsigned type. Unsigned integers have exactly 32 bits of precision. Signed integers use 32 bits, including a sign bit, in two's complement form. Fixes piglit int-literal-too-large-0[123].frag. v2: Take care with INT_MIN, use stroull, and make it a function. --- src/glsl/glsl_lexer.ll | 53 --- 1 files changed, 45 insertions(+), 8 deletions(-) diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll index cfd8926..e444536 100644 --- a/src/glsl/glsl_lexer.ll +++ b/src/glsl/glsl_lexer.ll @@ -22,6 +22,7 @@ * DEALINGS IN THE SOFTWARE. */ #include ctype.h +#include limits.h #include strtod.h #include ast.h #include glsl_parser_extras.h @@ -43,8 +44,6 @@ static int classify_identifier(struct _mesa_glsl_parse_state *, const char *); #define YY_USER_INIT yylineno = 0; yycolumn = 0; -#define IS_UINT (yytext[yyleng - 1] == 'u' || yytext[yyleng - 1] == 'U') - /* A macro for handling reserved words and keywords across language versions. * * Certain words start out as identifiers, become reserved words in @@ -81,6 +80,47 @@ static int classify_identifier(struct _mesa_glsl_parse_state *, const char *); * ...means the word is a legal keyword in GLSL ES 1.00. */ #define ES yyextra-es_shader + +static int +literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state, + YYSTYPE *lval, YYLTYPE *lloc, int base) +{ + bool is_uint = (text[len - 1] == 'u' || + text[len - 1] == 'U'); + const char *digits = text; + + /* Skip 0x */ + if (base == 16) + digits += 2; + + unsigned long long value = strtoull(digits, NULL, base); + + lval-n = (int)value; + + if (value UINT_MAX) { + /* Note that signed 0x is valid, not out of range! */ + if (state-language_version = 130) { +_mesa_glsl_error(lloc, state, + Literal value `%s' out of range, text); + } else { +_mesa_glsl_warning(lloc, state, + Literal value `%s' out of range, text); + } + } else if (base == 10 !is_uint (unsigned)value (unsigned)INT_MAX + 1) { + /* Tries to catch unintentionally providing a negative value. + * Note that -2147483648 is parsed as -(2147483648), so we don't + * want to warn for INT_MAX. + */ + _mesa_glsl_warning(lloc, state, +Signed literal value `%s' is interpreted as %d, +text, lval-n); + } + return is_uint ? UINTCONSTANT : INTCONSTANT; +} + +#define LITERAL_INTEGER(base) \ + literal_integer(yytext, yyleng, yyextra, yylval, yylloc, base) + %} %option bison-bridge bison-locations reentrant noyywrap @@ -292,16 +332,13 @@ layout{ -= return SUB_ASSIGN; [1-9][0-9]*[uU]? { - yylval-n = strtol(yytext, NULL, 10); - return IS_UINT ? UINTCONSTANT : INTCONSTANT; + return LITERAL_INTEGER(10); } 0[xX][0-9a-fA-F]+[uU]? { - yylval-n = strtol(yytext + 2, NULL, 16); - return IS_UINT ? UINTCONSTANT : INTCONSTANT; + return LITERAL_INTEGER(16); } 0[0-7]*[uU]? { - yylval-n = strtol(yytext, NULL, 8); - return IS_UINT ? UINTCONSTANT : INTCONSTANT; + return LITERAL_INTEGER(8); } [0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]? { -- 1.7.7 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev Reviewed-by: Paul Berry stereotype...@gmail.com ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] glsl: Implement GLSL 1.30's literal integer range restrictions.
On 10/26/2011 01:00 PM, Eric Anholt wrote: From page 22 (28 of PDF) of GLSL 1.30 spec: It is an error to provide a literal integer whose magnitude is too large to store in a variable of matching signed or unsigned type. Unsigned integers have exactly 32 bits of precision. Signed integers use 32 bits, including a sign bit, in two's complement form. Fixes piglit int-literal-too-large-0[123].frag. v2: Take care with INT_MIN, use stroull, and make it a function. Reviewed-by: Ian Romanick ian.d.roman...@intel.com --- src/glsl/glsl_lexer.ll | 53 --- 1 files changed, 45 insertions(+), 8 deletions(-) diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll index cfd8926..e444536 100644 --- a/src/glsl/glsl_lexer.ll +++ b/src/glsl/glsl_lexer.ll @@ -22,6 +22,7 @@ * DEALINGS IN THE SOFTWARE. */ #includectype.h +#includelimits.h #include strtod.h #include ast.h #include glsl_parser_extras.h @@ -43,8 +44,6 @@ static int classify_identifier(struct _mesa_glsl_parse_state *, const char *); #define YY_USER_INIT yylineno = 0; yycolumn = 0; -#define IS_UINT (yytext[yyleng - 1] == 'u' || yytext[yyleng - 1] == 'U') - /* A macro for handling reserved words and keywords across language versions. * * Certain words start out as identifiers, become reserved words in @@ -81,6 +80,47 @@ static int classify_identifier(struct _mesa_glsl_parse_state *, const char *); * ...means the word is a legal keyword in GLSL ES 1.00. */ #define ES yyextra-es_shader + +static int +literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state, + YYSTYPE *lval, YYLTYPE *lloc, int base) +{ + bool is_uint = (text[len - 1] == 'u' || + text[len - 1] == 'U'); + const char *digits = text; + + /* Skip 0x */ + if (base == 16) + digits += 2; + + unsigned long long value = strtoull(digits, NULL, base); + + lval-n = (int)value; + + if (value UINT_MAX) { + /* Note that signed 0x is valid, not out of range! */ + if (state-language_version= 130) { +_mesa_glsl_error(lloc, state, + Literal value `%s' out of range, text); + } else { +_mesa_glsl_warning(lloc, state, + Literal value `%s' out of range, text); + } + } else if (base == 10 !is_uint (unsigned)value (unsigned)INT_MAX + 1) { + /* Tries to catch unintentionally providing a negative value. + * Note that -2147483648 is parsed as -(2147483648), so we don't + * want to warn for INT_MAX. + */ + _mesa_glsl_warning(lloc, state, +Signed literal value `%s' is interpreted as %d, +text, lval-n); + } + return is_uint ? UINTCONSTANT : INTCONSTANT; +} + +#define LITERAL_INTEGER(base) \ + literal_integer(yytext, yyleng, yyextra, yylval, yylloc, base) + %} %option bison-bridge bison-locations reentrant noyywrap @@ -292,16 +332,13 @@ layout{ -=return SUB_ASSIGN; [1-9][0-9]*[uU]? { - yylval-n = strtol(yytext, NULL, 10); - return IS_UINT ? UINTCONSTANT : INTCONSTANT; + return LITERAL_INTEGER(10); } 0[xX][0-9a-fA-F]+[uU]?{ - yylval-n = strtol(yytext + 2, NULL, 16); - return IS_UINT ? UINTCONSTANT : INTCONSTANT; + return LITERAL_INTEGER(16); } 0[0-7]*[uU]? { - yylval-n = strtol(yytext, NULL, 8); - return IS_UINT ? UINTCONSTANT : INTCONSTANT; + return LITERAL_INTEGER(8); } [0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]? { ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] glsl: Remove pointless uses of glsl_type::get_base_type().
On 10/27/2011 10:48 AM, Kenneth Graunke wrote: These are effectively doing type-get_base_type()-base_type, which is equivalent to type-base_type. Just use that, as it's simpler. Signed-off-by: Kenneth Graunkekenn...@whitecape.org Reviewed-by: Ian Romanick ian.d.roman...@intel.com --- src/glsl/ir_print_visitor.cpp |4 +--- src/glsl/ir_reader.cpp|6 ++ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp index b713bd0..1471355 100644 --- a/src/glsl/ir_print_visitor.cpp +++ b/src/glsl/ir_print_visitor.cpp @@ -368,8 +368,6 @@ void ir_print_visitor::visit(ir_assignment *ir) void ir_print_visitor::visit(ir_constant *ir) { - const glsl_type *const base_type = ir-type-get_base_type(); - printf((constant ); print_type(ir-type); printf( (); @@ -390,7 +388,7 @@ void ir_print_visitor::visit(ir_constant *ir) for (unsigned i = 0; i ir-type-components(); i++) { if (i != 0) printf( ); -switch (base_type-base_type) { +switch (ir-type-base_type) { case GLSL_TYPE_UINT: printf(%u, ir-value.u[i]); break; case GLSL_TYPE_INT: printf(%d, ir-value.i[i]); break; case GLSL_TYPE_FLOAT: printf(%f, ir-value.f[i]); break; diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index afb06b3..3461c56 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -773,8 +773,6 @@ ir_reader::read_constant(s_expression *expr) return new(mem_ctx) ir_constant(type,elements); } - const glsl_type *const base_type = type-get_base_type(); - ir_constant_data data = { { 0 } }; // Read in list of values (at most 16). @@ -787,7 +785,7 @@ ir_reader::read_constant(s_expression *expr) s_expression *expr = (s_expression*) it.get(); - if (base_type-base_type == GLSL_TYPE_FLOAT) { + if (type-base_type == GLSL_TYPE_FLOAT) { s_number *value = SX_AS_NUMBER(expr); if (value == NULL) { ir_read_error(values, expected numbers); @@ -801,7 +799,7 @@ ir_reader::read_constant(s_expression *expr) return NULL; } -switch (base_type-base_type) { +switch (type-base_type) { case GLSL_TYPE_UINT: { data.u[k] = value-value(); break; ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] gallium: implement WGL_ARB_create_context
Margan, The code in the diff has wrapped-around and can't be applied automatically. Please re-send the patch as an attachment. Jose - Original Message - Here is the modified patch. I just checked if it works but doesn't have a good test case for it. But I will write one for sure! --- src/gallium/state_trackers/wgl/SConscript |1 + src/gallium/state_trackers/wgl/stw_context.c | 47 +++- src/gallium/state_trackers/wgl/stw_context.h |3 + src/gallium/state_trackers/wgl/stw_ext_context.c | 119 .../state_trackers/wgl/stw_getprocaddress.c|3 + 5 files changed, 166 insertions(+), 7 deletions(-) create mode 100644 src/gallium/state_trackers/wgl/stw_ext_context.c diff --git a/src/gallium/state_trackers/wgl/SConscript b/src/gallium/state_trackers/wgl/SConscript index 7cb953b..1014b45 100644 --- a/src/gallium/state_trackers/wgl/SConscript +++ b/src/gallium/state_trackers/wgl/SConscript @@ -22,6 +22,7 @@ if not env['gles']: sources = [ 'stw_context.c', 'stw_device.c', +'stw_ext_context.c', 'stw_ext_extensionsstring.c', 'stw_ext_gallium.c', 'stw_ext_pbuffer.c', diff --git a/src/gallium/state_trackers/wgl/stw_context.c b/src/gallium/state_trackers/wgl/stw_context.c index c2839fe..6cc8a83 100644 --- a/src/gallium/state_trackers/wgl/stw_context.c +++ b/src/gallium/state_trackers/wgl/stw_context.c @@ -27,6 +27,11 @@ #include windows.h +#define WGL_WGLEXT_PROTOTYPES + +#include GL/gl.h +#include GL/wglext.h + #include pipe/p_compiler.h #include pipe/p_context.h #include pipe/p_state.h @@ -121,23 +126,41 @@ DrvCreateLayerContext( HDC hdc, INT iLayerPlane ) { + return stw_create_context_attribs(hdc, iLayerPlane, 0, 1, 0, 0, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB); +} + +DHGLRC +stw_create_context_attribs( + HDC hdc, + INT iLayerPlane, + DHGLRC hShareContext, + int majorVersion, int minorVersion, + int contextFlags, int profileMask) +{ int iPixelFormat; const struct stw_pixelformat_info *pfi; struct st_context_attribs attribs; struct stw_context *ctx = NULL; - - if(!stw_dev) + struct stw_context *shareCtx = NULL; + + if (!stw_dev) return 0; - + if (iLayerPlane != 0) return 0; iPixelFormat = GetPixelFormat(hdc); if(!iPixelFormat) return 0; - + pfi = stw_pixelformat_get_info( iPixelFormat - 1 ); - + + if (hShareContext != 0) { + pipe_mutex_lock( stw_dev-ctx_mutex ); + shareCtx = stw_lookup_context_locked( hShareContext ); + pipe_mutex_unlock( stw_dev-ctx_mutex ); + } + ctx = CALLOC_STRUCT( stw_context ); if (ctx == NULL) goto no_ctx; @@ -148,10 +171,20 @@ DrvCreateLayerContext( memset(attribs, 0, sizeof(attribs)); attribs.profile = ST_PROFILE_DEFAULT; attribs.visual = pfi-stvis; + attribs.major = majorVersion; + attribs.minor = minorVersion; + if (contextFlags WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB) + attribs.flags |= ST_CONTEXT_FLAG_FORWARD_COMPATIBLE; + if (contextFlags WGL_CONTEXT_DEBUG_BIT_ARB) + attribs.flags |= ST_CONTEXT_FLAG_DEBUG; + if (profileMask WGL_CONTEXT_CORE_PROFILE_BIT_ARB) + attribs.flags |= ST_CONTEXT_FLAG_CORE_PROFILE; + if (profileMask WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) + attribs.flags |= ST_CONTEXT_FLAG_COMPATIBLE_PROFILE; ctx-st = stw_dev-stapi-create_context(stw_dev-stapi, - stw_dev-smapi, attribs, NULL); - if (ctx-st == NULL) + stw_dev-smapi, attribs, shareCtx ? shareCtx-st : NULL); + if (ctx-st == NULL) goto no_st_ctx; ctx-st-st_manager_private = (void *) ctx; diff --git a/src/gallium/state_trackers/wgl/stw_context.h b/src/gallium/state_trackers/wgl/stw_context.h index 0bbed84..07a5c7d 100644 --- a/src/gallium/state_trackers/wgl/stw_context.h +++ b/src/gallium/state_trackers/wgl/stw_context.h @@ -43,6 +43,9 @@ struct stw_context struct stw_framebuffer *current_framebuffer; }; +DHGLRC stw_create_context_attribs( HDC hdc, INT iLayerPlane, DHGLRC hShareContext, + int majorVersion, int minorVersion, int contextFlags, int profileMask ); + DHGLRC stw_get_current_context( void ); HDC stw_get_current_dc( void ); diff --git a/src/gallium/state_trackers/wgl/stw_ext_context.c b/src/gallium/state_trackers/wgl/stw_ext_context.c new file mode 100644 index 000..a3470ac --- /dev/null +++ b/src/gallium/state_trackers/wgl/stw_ext_context.c @@ -0,0 +1,119 @@ +/* + * Mesa 3-D graphics library + * Version: 7.11 + * + * Copyright (C) 2011 Morgan Armand morgan.de...@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
[Mesa-dev] [PATCH] mesa: Fix memory leak in out-of-memory path.
Fixes Coverity resource leak defect. --- src/mesa/main/pack.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c index ecdeaf5..539a06c 100644 --- a/src/mesa/main/pack.c +++ b/src/mesa/main/pack.c @@ -1983,6 +1983,7 @@ _mesa_pack_rgba_span_float(struct gl_context *ctx, GLuint n, GLfloat rgba[][4], break; default: _mesa_problem(ctx, bad type in _mesa_pack_rgba_span_float); + free(luminance); return; } -- 1.7.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/2] ir_to_mesa: Let check_resources halt compilation
From: Ian Romanick ian.d.roman...@intel.com Previously check_resources could fail, but we'd still try to optimize the shader, do device-specific code generation, etc. In some cases, this could explode (especially in the device-specific code generation). I haven't found that I could trigger this with the current code. When too many samplers were used with the new uniform handling code, I observed several crashes deep down in the driver. Signed-off-by: Ian Romanick ian.d.roman...@intel.com Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=41609 Cc: Eric Anholt e...@anholt.net --- src/mesa/program/ir_to_mesa.cpp | 23 +-- 1 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index bdbb6b9..81b7e14 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2546,7 +2546,7 @@ count_resources(struct gl_program *prog) * * XXX more checks are needed... */ -static void +static bool check_resources(const struct gl_context *ctx, struct gl_shader_program *shader_program, struct gl_program *prog) @@ -2586,6 +2586,8 @@ check_resources(const struct gl_context *ctx, default: _mesa_problem(ctx, unexpected program type in check_resources()); } + + return shader_program-LinkStatus; } class add_uniform_to_shader : public uniform_field_visitor { @@ -3168,9 +3170,7 @@ get_mesa_program(struct gl_context *ctx, } if (!shader_program-LinkStatus) { - free(mesa_instructions); - _mesa_reference_program(ctx, shader-Program, NULL); - return NULL; + goto fail_exit; } set_branchtargets(v, mesa_instructions, num_instructions); @@ -3191,10 +3191,16 @@ get_mesa_program(struct gl_context *ctx, prog-Instructions = mesa_instructions; prog-NumInstructions = num_instructions; + /* Setting this to NULL prevents a possible double free in the fail_exit +* path (far below). +*/ + mesa_instructions = NULL; + do_set_program_inouts(shader-ir, prog); count_resources(prog); - check_resources(ctx, shader_program, prog); + if (!check_resources(ctx, shader_program, prog)) + goto fail_exit; _mesa_reference_program(ctx, shader-Program, prog); @@ -3203,6 +3209,11 @@ get_mesa_program(struct gl_context *ctx, } return prog; + +fail_exit: + free(mesa_instructions); + _mesa_reference_program(ctx, shader-Program, NULL); + return NULL; } extern C { @@ -3301,7 +3312,7 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) _mesa_reference_program(ctx, linked_prog, NULL); } - return GL_TRUE; + return prog-LinkStatus; } -- 1.7.6.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 0/5] intel: Replace renderbuffer region with miptree
See the commit meesage for patch 5/5. Chad Versace (5): intel: Temporarily disable HiZ for textures intel: Define intel_miptree_create_for_renderbuffer() intel: Kill intel_framebuffer_get_hiz_region() intel: Move inline functions from intel_fbo.h to intel_fbo.c intel: Replace intel_renderbuffer::region with a miptree src/mesa/drivers/dri/i965/brw_misc_state.c| 29 +++-- src/mesa/drivers/dri/i965/brw_vtbl.c |2 +- src/mesa/drivers/dri/i965/brw_wm_surface_state.c |8 +- src/mesa/drivers/dri/i965/gen7_misc_state.c | 15 +- src/mesa/drivers/dri/i965/gen7_wm_surface_state.c |7 +- src/mesa/drivers/dri/intel/intel_blit.c | 21 ++- src/mesa/drivers/dri/intel/intel_buffer_objects.c |8 +- src/mesa/drivers/dri/intel/intel_buffers.c|9 +- src/mesa/drivers/dri/intel/intel_context.c| 55 +--- src/mesa/drivers/dri/intel/intel_fbo.c| 155 - src/mesa/drivers/dri/intel/intel_fbo.h| 41 +- src/mesa/drivers/dri/intel/intel_mipmap_tree.c| 21 +++ src/mesa/drivers/dri/intel/intel_mipmap_tree.h| 15 ++ src/mesa/drivers/dri/intel/intel_pixel_copy.c |5 +- src/mesa/drivers/dri/intel/intel_screen.c |3 +- src/mesa/drivers/dri/intel/intel_span.c | 30 +++-- src/mesa/drivers/dri/intel/intel_tex_copy.c | 14 ++- src/mesa/drivers/dri/intel/intel_tex_image.c |6 +- 18 files changed, 229 insertions(+), 215 deletions(-) -- 1.7.6.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/5] intel: Temporarily disable HiZ for textures
A great refactor thrashing begins after this commit. Removing code for texture HiZ will make that refactoring easier. HiZ was broken for textures anyway, so there's no regression here. Signed-off-by: Chad Versace c...@chad-versace.us --- src/mesa/drivers/dri/intel/intel_fbo.c | 62 ++-- 1 files changed, 3 insertions(+), 59 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c index 4537f1f..7a24d06 100644 --- a/src/mesa/drivers/dri/intel/intel_fbo.c +++ b/src/mesa/drivers/dri/intel/intel_fbo.c @@ -473,15 +473,9 @@ intel_framebuffer_renderbuffer(struct gl_context * ctx, } static bool -intel_update_tex_wrapper_regions(struct intel_context *intel, -struct intel_renderbuffer *irb, -struct intel_texture_image *intel_image); - -static bool intel_update_wrapper(struct gl_context *ctx, struct intel_renderbuffer *irb, struct gl_texture_image *texImage) { - struct intel_context *intel = intel_context(ctx); struct intel_texture_image *intel_image = intel_texture_image(texImage); int width, height, depth; @@ -507,70 +501,20 @@ intel_update_wrapper(struct gl_context *ctx, struct intel_renderbuffer *irb, if (intel_image-stencil_rb) { /* The tex image has packed depth/stencil format, but is using separate - * stencil. */ - - bool ok; - struct intel_renderbuffer *depth_irb = -intel_renderbuffer(intel_image-depth_rb); - - /* Update the hiz region if necessary. */ - ok = intel_update_tex_wrapper_regions(intel, depth_irb, intel_image); - if (!ok) { -return false; - } - - /* The tex image shares its embedded depth and stencil renderbuffers with - * the renderbuffer wrapper. */ + * stencil. It shares its embedded depth and stencil renderbuffers with + * the renderbuffer wrapper. + */ _mesa_reference_renderbuffer(irb-wrapped_depth, intel_image-depth_rb); _mesa_reference_renderbuffer(irb-wrapped_stencil, intel_image-stencil_rb); - - return true; } else { - return intel_update_tex_wrapper_regions(intel, irb, intel_image); - } -} - -/** - * FIXME: The handling of the hiz region is broken for mipmapped depth textures - * FIXME: because intel_finalize_mipmap_tree is unaware of it. - */ -static bool -intel_update_tex_wrapper_regions(struct intel_context *intel, -struct intel_renderbuffer *irb, -struct intel_texture_image *intel_image) -{ - struct gl_renderbuffer *rb = irb-Base; - - /* Point the renderbuffer's region to the texture's region. */ - if (irb-region != intel_image-mt-region) { intel_region_reference(irb-region, intel_image-mt-region); } - /* Allocate the texture's hiz region if necessary. */ - if (intel-vtbl.is_hiz_depth_format(intel, rb-Format) -!intel_image-mt-hiz_region) { - intel_image-mt-hiz_region = - intel_region_alloc(intel-intelScreen, -I915_TILING_Y, -_mesa_get_format_bytes(rb-Format), -rb-Width, -rb-Height, -true); - if (!intel_image-mt-hiz_region) - return false; - } - - /* Point the renderbuffer's hiz region to the texture's hiz region. */ - if (irb-hiz_region != intel_image-mt-hiz_region) { - intel_region_reference(irb-hiz_region, intel_image-mt-hiz_region); - } - return true; } - /** * When glFramebufferTexture[123]D is called this function sets up the * gl_renderbuffer wrapper around the texture image. -- 1.7.6.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/5] intel: Define intel_miptree_create_for_renderbuffer()
This function creates a miptree that is suitable as the storage for a non-texture renderbuffer. This commit is prerequisite for replacing intel_renderbuffer::region with a miptree. Signed-off-by: Chad Versace c...@chad-versace.us --- src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 21 + src/mesa/drivers/dri/intel/intel_mipmap_tree.h | 15 +++ 2 files changed, 36 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c index 19f151f..33247d2 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c @@ -171,6 +171,27 @@ intel_miptree_create_for_region(struct intel_context *intel, return mt; } +struct intel_mipmap_tree* +intel_miptree_create_for_renderbuffer(struct intel_context *intel, + gl_format format, + uint32_t tiling, + uint32_t cpp, + uint32_t width, + uint32_t height) +{ + struct intel_region *region; + struct intel_mipmap_tree *mt; + + region = intel_region_alloc(intel-intelScreen, + tiling, cpp, width, height, true); + if (!region) + return NULL; + + mt = intel_miptree_create_for_region(intel, GL_TEXTURE_2D, format, region); + intel_region_release(region); + return mt; +} + void intel_miptree_reference(struct intel_mipmap_tree **dst, struct intel_mipmap_tree *src) diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h index e29b943..611519d 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h @@ -151,6 +151,21 @@ intel_miptree_create_for_region(struct intel_context *intel, gl_format format, struct intel_region *region); +/** + * Create a miptree appropriate as the storage for a non-texture renderbuffer. + * The miptree has the following properties: + * - The target is GL_TEXTURE_2D. + * - There are no levels other than the base level 0. + * - Depth is 1. + */ +struct intel_mipmap_tree* +intel_miptree_create_for_renderbuffer(struct intel_context *intel, + gl_format format, + uint32_t tiling, + uint32_t cpp, + uint32_t width, + uint32_t height); + int intel_miptree_pitch_align (struct intel_context *intel, struct intel_mipmap_tree *mt, uint32_t tiling, -- 1.7.6.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 5/5] intel: Replace intel_renderbuffer::region with a miptree
This is in preparation for 1) fixing the implementation of glFramebufferTexture(GL_DEPTH_STENCIL) for separate stencil and 2) supporting HiZ for miptrees. As a nice benefit, this lays down some preliminary groundwork for easily texturing from any renderbuffer, even those of the window system. Without this patch, it is indeed possible to implement the above, but the code would be more difficult to work with. In addition, intel_mipmap_tree::hiz_region will also be replaced with a miptree by a future commit. No Piglit regressions on gen6. Signed-off-by: Chad Versace c...@chad-versace.us --- src/mesa/drivers/dri/i965/brw_misc_state.c| 29 +--- src/mesa/drivers/dri/i965/brw_vtbl.c |2 +- src/mesa/drivers/dri/i965/brw_wm_surface_state.c |8 +-- src/mesa/drivers/dri/i965/gen7_misc_state.c | 15 ++-- src/mesa/drivers/dri/i965/gen7_wm_surface_state.c |7 +- src/mesa/drivers/dri/intel/intel_blit.c | 21 -- src/mesa/drivers/dri/intel/intel_buffer_objects.c |8 +- src/mesa/drivers/dri/intel/intel_buffers.c|9 ++- src/mesa/drivers/dri/intel/intel_context.c| 55 ++- src/mesa/drivers/dri/intel/intel_fbo.c| 80 ++-- src/mesa/drivers/dri/intel/intel_fbo.h|6 +- src/mesa/drivers/dri/intel/intel_pixel_copy.c |5 +- src/mesa/drivers/dri/intel/intel_screen.c |3 +- src/mesa/drivers/dri/intel/intel_span.c | 30 + src/mesa/drivers/dri/intel/intel_tex_copy.c | 14 +++-- src/mesa/drivers/dri/intel/intel_tex_image.c |6 +- 16 files changed, 170 insertions(+), 128 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c b/src/mesa/drivers/dri/i965/brw_misc_state.c index 2e6780b..908feb8 100644 --- a/src/mesa/drivers/dri/i965/brw_misc_state.c +++ b/src/mesa/drivers/dri/i965/brw_misc_state.c @@ -33,6 +33,7 @@ #include intel_batchbuffer.h #include intel_fbo.h +#include intel_mipmap_tree.h #include intel_regions.h #include brw_context.h @@ -205,11 +206,11 @@ static void prepare_depthbuffer(struct brw_context *brw) struct intel_renderbuffer *srb = intel_get_renderbuffer(fb, BUFFER_STENCIL); if (drb) - brw_add_validated_bo(brw, drb-region-bo); - if (drb drb-hiz_region) - brw_add_validated_bo(brw, drb-hiz_region-bo); + brw_add_validated_bo(brw, drb-mt-region-bo); + if (drb drb-mt-hiz_region) + brw_add_validated_bo(brw, drb-mt-hiz_region-bo); if (srb) - brw_add_validated_bo(brw, srb-region-bo); + brw_add_validated_bo(brw, srb-mt-region-bo); } static void emit_depthbuffer(struct brw_context *brw) @@ -220,9 +221,14 @@ static void emit_depthbuffer(struct brw_context *brw) /* _NEW_BUFFERS */ struct intel_renderbuffer *depth_irb = intel_get_renderbuffer(fb, BUFFER_DEPTH); struct intel_renderbuffer *stencil_irb = intel_get_renderbuffer(fb, BUFFER_STENCIL); - struct intel_region *hiz_region = depth_irb ? depth_irb-hiz_region : NULL; + struct intel_region *hiz_region = NULL; unsigned int len; + if (depth_irb + depth_irb-mt) { + hiz_region = depth_irb-mt-hiz_region; + } + /* 3DSTATE_DEPTH_BUFFER, 3DSTATE_STENCIL_BUFFER are both * non-pipelined state that will need the PIPE_CONTROL workaround. */ @@ -288,6 +294,8 @@ static void emit_depthbuffer(struct brw_context *brw) * [DevGT]: This field must be set to the same value (enabled or * disabled) as Hierarchical Depth Buffer Enable */ + struct intel_region *region = stencil_irb-mt-region; + assert(intel-has_separate_stencil); assert(stencil_irb-Base.Format == MESA_FORMAT_S8); @@ -299,8 +307,8 @@ static void emit_depthbuffer(struct brw_context *brw) (BRW_TILEWALK_YMAJOR 26) | (BRW_SURFACE_2D 29)); OUT_BATCH(0); - OUT_BATCH(((stencil_irb-region-width - 1) 6) | -(2 * stencil_irb-region-height - 1) 19); + OUT_BATCH(((region-width - 1) 6) | +(2 * region-height - 1) 19); OUT_BATCH(0); OUT_BATCH(0); @@ -310,7 +318,7 @@ static void emit_depthbuffer(struct brw_context *brw) ADVANCE_BATCH(); } else { - struct intel_region *region = depth_irb-region; + struct intel_region *region = depth_irb-mt-region; unsigned int format; uint32_t tile_x, tile_y, offset; @@ -395,10 +403,11 @@ static void emit_depthbuffer(struct brw_context *brw) /* Emit stencil buffer. */ if (stencil_irb) { +struct intel_region *region = stencil_irb-mt-region; BEGIN_BATCH(3); OUT_BATCH((_3DSTATE_STENCIL_BUFFER 16) | (3 - 2)); -OUT_BATCH(stencil_irb-region-pitch * stencil_irb-region-cpp - 1); -OUT_RELOC(stencil_irb-region-bo, +OUT_BATCH(region-pitch * region-cpp - 1); +OUT_RELOC(region-bo, I915_GEM_DOMAIN_RENDER,
Re: [Mesa-dev] [PATCH 2/5] glsl: Extend s-expression parsing to handle infinity.
On 10/26/2011 06:42 PM, Paul Berry wrote: In order to implement the GLSL 1.30 isinf() function, it will be necessary to be able to represent infinity in the GLSL IR s-expression format. This patch extends the s-expression parser so that it treats the string #inf as a floating point value representing positive infinity. --- src/glsl/s_expression.cpp | 33 +++-- 1 files changed, 19 insertions(+), 14 deletions(-) Two kind of stupid comments: Scheme represents infinity as +inf.0 or -inf.0 and NaN as +nan.0. If you wanted to be more Scheme-like, you could do that (and also gain a representation of -infinity if you wanted...) Also...strtod() already accepts INF/INFINITY and NAN for these cases. Which actually kind of sucks because somebody could totally name their variables that (unlike #inf or +inf.0). That should be fixed someday. But there are a lot of things the reader can't do (like structs), so...not terribly important. It works well enough for now and we can always fix it when it actually matters. So, I guess you've got a few options: 1. Keep patch as is (#inf) 2. Switch to +inf.0, -inf.0, +nan.0 to be like Scheme 3. Drop this patch and just use INFINITY in the built-in files. I'm honestly okay with any of these. For the series: Reviewed-by: Kenneth Graunke kenn...@whitecape.org diff --git a/src/glsl/s_expression.cpp b/src/glsl/s_expression.cpp index e704a3b..4391488 100644 --- a/src/glsl/s_expression.cpp +++ b/src/glsl/s_expression.cpp @@ -64,21 +64,26 @@ read_atom(void *ctx, const char *src, char *symbol_buffer) if (n == 0) return NULL; // no atom - // Check if the atom is a number. - char *float_end = NULL; - double f = glsl_strtod(src, float_end); - if (float_end != src) { - char *int_end = NULL; - int i = strtol(src, int_end, 10); - // If strtod matched more characters, it must have a decimal part - if (float_end int_end) - expr = new(ctx) s_float(f); - else - expr = new(ctx) s_int(i); + // Check for the special symbol '#inf', which means +Infinity + if (n == 4 strncmp(src, #inf, 4) == 0) { + expr = new(ctx) s_float(INFINITY); } else { - // Not a number; return a symbol. - symbol_buffer[n] = '\0'; - expr = new(ctx) s_symbol(symbol_buffer, n); + // Check if the atom is a number. + char *float_end = NULL; + double f = glsl_strtod(src, float_end); + if (float_end != src) { + char *int_end = NULL; + int i = strtol(src, int_end, 10); + // If strtod matched more characters, it must have a decimal part + if (float_end int_end) +expr = new(ctx) s_float(f); + else +expr = new(ctx) s_int(i); + } else { + // Not a number; return a symbol. + symbol_buffer[n] = '\0'; + expr = new(ctx) s_symbol(symbol_buffer, n); + } } src += n; ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev