Mesa (master): mesa: Expose GLSL interpolation qualifiers in gl_fragment_program.
Module: Mesa Branch: master Commit: cf45949d6a896651a5f3864d3b195e26d59eee74 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cf45949d6a896651a5f3864d3b195e26d59eee74 Author: Paul Berry stereotype...@gmail.com Date: Tue Oct 25 18:06:37 2011 -0700 mesa: Expose GLSL interpolation qualifiers in gl_fragment_program. This patch makes GLSL interpolation qualifiers visible to drivers via the array InterpQualifier[] in gl_fragment_program, so that they can easily be used by driver back-ends to select the correct interpolation mode. Previous to this patch, the GLSL compiler was using the enum ir_variable_interpolation to represent interpolation types. Rather than make a duplicate enum in core mesa to represent the same thing, I moved the enum into mtypes.h and renamed it to be more consistent with the other enums defined there. Reviewed-by: Brian Paul bri...@vmware.com Reviewed-by: Kenneth Graunke kenn...@whitecape.org Reviewed-by: Eric Anholt e...@anholt.net --- src/glsl/ast_to_hir.cpp|8 ++-- src/glsl/ir.cpp|8 ++-- src/glsl/ir.h | 10 ++ src/glsl/ir_reader.cpp |6 ++-- src/glsl/ir_set_program_inouts.cpp | 47 src/mesa/main/mtypes.h | 19 +++ src/mesa/program/ir_to_mesa.cpp|2 +- src/mesa/state_tracker/st_glsl_to_tgsi.cpp |2 +- 8 files changed, 69 insertions(+), 33 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 70afb67..d090d31 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1962,11 +1962,11 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, } if (qual-flags.q.flat) - var-interpolation = ir_var_flat; + var-interpolation = INTERP_QUALIFIER_FLAT; else if (qual-flags.q.noperspective) - var-interpolation = ir_var_noperspective; + var-interpolation = INTERP_QUALIFIER_NOPERSPECTIVE; else - var-interpolation = ir_var_smooth; + var-interpolation = INTERP_QUALIFIER_SMOOTH; var-pixel_center_integer = qual-flags.q.pixel_center_integer; var-origin_upper_left = qual-flags.q.origin_upper_left; @@ -2630,7 +2630,7 @@ ast_declarator_list::hir(exec_list *instructions, state-current_function == NULL var-type-is_integer() var-mode == ir_var_out - var-interpolation != ir_var_flat) { + var-interpolation != INTERP_QUALIFIER_FLAT) { _mesa_glsl_error(loc, state, If a vertex output is an integer, then it must be qualified with 'flat'); diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index d968890..046ce25 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -1320,7 +1320,7 @@ ir_swizzle::variable_referenced() const ir_variable::ir_variable(const struct glsl_type *type, const char *name, ir_variable_mode mode) : max_array_access(0), read_only(false), centroid(false), invariant(false), - mode(mode), interpolation(ir_var_smooth) + mode(mode), interpolation(INTERP_QUALIFIER_SMOOTH) { this-ir_type = ir_type_variable; this-type = type; @@ -1343,9 +1343,9 @@ const char * ir_variable::interpolation_string() const { switch (this-interpolation) { - case ir_var_smooth:return smooth; - case ir_var_flat: return flat; - case ir_var_noperspective: return noperspective; + case INTERP_QUALIFIER_SMOOTH:return smooth; + case INTERP_QUALIFIER_FLAT: return flat; + case INTERP_QUALIFIER_NOPERSPECTIVE: return noperspective; } assert(!Should not get here.); diff --git a/src/glsl/ir.h b/src/glsl/ir.h index b707634..4ea8764 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -34,6 +34,7 @@ #include list.h #include ir_visitor.h #include ir_hierarchical_visitor.h +#include main/mtypes.h /** * \defgroup IR Intermediate representation nodes @@ -227,12 +228,6 @@ enum ir_variable_mode { ir_var_temporary/** Temporary variable generated during compilation. */ }; -enum ir_variable_interpolation { - ir_var_smooth = 0, - ir_var_flat, - ir_var_noperspective -}; - /** * \brief Layout qualifiers for gl_FragDepth. * @@ -1679,7 +1674,8 @@ extern bool ir_has_call(ir_instruction *ir); extern void -do_set_program_inouts(exec_list *instructions, struct gl_program *prog); +do_set_program_inouts(exec_list *instructions, struct gl_program *prog, + bool is_fragment_shader); extern char * prototype_string(const glsl_type *return_type, const char *name, diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index afb06b3..e3a3ed9 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -405,11 +405,11 @@ ir_reader::read_declaration(s_expression *expr) } else if (strcmp(qualifier-value(), inout) == 0) { var-mode = ir_var_inout
Mesa (master): glsl: Distinguish between no interpolation qualifier and ' smooth'
Module: Mesa Branch: master Commit: c488150dea083a9677429b4185c6b20d7facd52b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c488150dea083a9677429b4185c6b20d7facd52b Author: Paul Berry stereotype...@gmail.com Date: Fri Oct 21 07:40:37 2011 -0700 glsl: Distinguish between no interpolation qualifier and 'smooth' Previously, we treated the 'smooth' qualifier as equivalent to no qualifier at all. However, this is incorrect for the built-in color variables (gl_FrontColor, gl_BackColor, gl_FrontSecondaryColor, and gl_BackSecondaryColor). For those variables, if there is no qualifier at all, interpolation should be flat if the shade model is GL_FLAT, and smooth if the shade model is GL_SMOOTH. To make this possible, I added a new value to the glsl_interp_qualifier enum, INTERP_QUALIFIER_NONE. Reviewed-by: Kenneth Graunke kenn...@whitecape.org Reviewed-by: Eric Anholt e...@anholt.net --- src/glsl/ast_to_hir.cpp |4 +++- src/glsl/ir.cpp |3 ++- src/glsl/ir.h |4 src/mesa/main/mtypes.h |6 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index d090d31..fa6206e 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1965,8 +1965,10 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, var-interpolation = INTERP_QUALIFIER_FLAT; else if (qual-flags.q.noperspective) var-interpolation = INTERP_QUALIFIER_NOPERSPECTIVE; - else + else if (qual-flags.q.smooth) var-interpolation = INTERP_QUALIFIER_SMOOTH; + else + var-interpolation = INTERP_QUALIFIER_NONE; var-pixel_center_integer = qual-flags.q.pixel_center_integer; var-origin_upper_left = qual-flags.q.origin_upper_left; diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 046ce25..9aad0fc 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -1320,7 +1320,7 @@ ir_swizzle::variable_referenced() const ir_variable::ir_variable(const struct glsl_type *type, const char *name, ir_variable_mode mode) : max_array_access(0), read_only(false), centroid(false), invariant(false), - mode(mode), interpolation(INTERP_QUALIFIER_SMOOTH) + mode(mode), interpolation(INTERP_QUALIFIER_NONE) { this-ir_type = ir_type_variable; this-type = type; @@ -1343,6 +1343,7 @@ const char * ir_variable::interpolation_string() const { switch (this-interpolation) { + case INTERP_QUALIFIER_NONE: return no; case INTERP_QUALIFIER_SMOOTH:return smooth; case INTERP_QUALIFIER_FLAT: return flat; case INTERP_QUALIFIER_NOPERSPECTIVE: return noperspective; diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 4ea8764..0c0cccb 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -283,6 +283,10 @@ public: * \return The string that would be used in a shader to specify \c * mode will be returned. * +* This function is used to generate error messages of the form shader +* uses %s interpolation qualifier, so in the case where there is no +* interpolation qualifier, it returns no. +* * This function should only be used on a shader input or output variable. */ const char *interpolation_string() const; diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 9410e3f..aa3fa6a 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1793,9 +1793,13 @@ typedef enum /** * The possible interpolation qualifiers that can be applied to a fragment * shader input in GLSL. + * + * Note: INTERP_QUALIFIER_NONE must be 0 so that memsetting the + * gl_fragment_program data structure to 0 causes the default behavior. */ enum glsl_interp_qualifier { + INTERP_QUALIFIER_NONE = 0, INTERP_QUALIFIER_SMOOTH, INTERP_QUALIFIER_FLAT, INTERP_QUALIFIER_NOPERSPECTIVE @@ -1906,7 +1910,7 @@ struct gl_fragment_program /** * GLSL interpolation qualifier associated with each fragment shader input. * For inputs that do not have an interpolation qualifier specified in -* GLSL, the value is INTERP_QUALIFIER_SMOOTH. +* GLSL, the value is INTERP_QUALIFIER_NONE. */ enum glsl_interp_qualifier InterpQualifier[FRAG_ATTRIB_MAX]; }; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): glsl: add ir_variable::determine_interpolation_mode() function.
Module: Mesa Branch: master Commit: baf7f99fd7a092a1390b7a145e09caa5325a8116 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=baf7f99fd7a092a1390b7a145e09caa5325a8116 Author: Paul Berry stereotype...@gmail.com Date: Fri Oct 21 07:55:48 2011 -0700 glsl: add ir_variable::determine_interpolation_mode() function. This function determines how a variable should be interpolated based both on interpolation qualifiers and the current shade model. Reviewed-by: Kenneth Graunke kenn...@whitecape.org Reviewed-by: Eric Anholt e...@anholt.net --- src/glsl/ir.cpp | 15 +++ src/glsl/ir.h | 11 +++ 2 files changed, 26 insertions(+), 0 deletions(-) diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 9aad0fc..ef7300e 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -1354,6 +1354,21 @@ ir_variable::interpolation_string() const } +glsl_interp_qualifier +ir_variable::determine_interpolation_mode(bool flat_shade) +{ + if (this-interpolation != INTERP_QUALIFIER_NONE) + return (glsl_interp_qualifier) this-interpolation; + int location = this-location; + bool is_gl_Color = + location == FRAG_ATTRIB_COL0 || location == FRAG_ATTRIB_COL1; + if (flat_shade is_gl_Color) + return INTERP_QUALIFIER_FLAT; + else + return INTERP_QUALIFIER_SMOOTH; +} + + ir_function_signature::ir_function_signature(const glsl_type *return_type) : return_type(return_type), is_defined(false), _function(NULL) { diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 0c0cccb..404d4cf 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -292,6 +292,17 @@ public: const char *interpolation_string() const; /** +* Determine how this variable should be interpolated based on its +* interpolation qualifier (if present), whether it is gl_Color or +* gl_SecondaryColor, and whether flatshading is enabled in the current GL +* state. +* +* The return value will always be either INTERP_QUALIFIER_SMOOTH, +* INTERP_QUALIFIER_NOPERSPECTIVE, or INTERP_QUALIFIER_FLAT. +*/ + glsl_interp_qualifier determine_interpolation_mode(bool flat_shade); + + /** * Delcared name of the variable */ const char *name; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965/fs: Fix split_virtual_grfs() when delta_xy not in a virtual register.
Module: Mesa Branch: master Commit: 102bdd26e1acf1ebf75ef85b62df2400239fd480 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=102bdd26e1acf1ebf75ef85b62df2400239fd480 Author: Paul Berry stereotype...@gmail.com Date: Fri Oct 21 14:16:25 2011 -0700 i965/fs: Fix split_virtual_grfs() when delta_xy not in a virtual register. This patch modifies the special case in fs_visitor::split_virtual_grfs() that prevents splitting from being applied to the delta_x/delta_y register pair (this register pair needs to remain contiguous so that it can be used by the PLN instruction). When gen=6, this register pair is in a fixed location, not a virtual register, so it was in no danger of being split. And split_virtual_grfs' attempt not to split it was preventing some other unrelated register from being split. Reviewed-by: Eric Anholt e...@anholt.net --- src/mesa/drivers/dri/i965/brw_fs.cpp |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index c0d93c0..3848915 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -768,7 +768,7 @@ fs_visitor::split_virtual_grfs() split_grf[i] = false; } - if (brw-has_pln) { + if (brw-has_pln this-delta_x.file == GRF) { /* PLN opcodes rely on the delta_xy being contiguous. */ split_grf[this-delta_x.reg] = false; } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965/gen6+: Parameterize barycentric interpolation modes.
Module: Mesa Branch: master Commit: e04bdeae82797dbdcf6f544a997a4626fdfd4aee URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e04bdeae82797dbdcf6f544a997a4626fdfd4aee Author: Paul Berry stereotype...@gmail.com Date: Fri Oct 21 17:20:32 2011 -0700 i965/gen6+: Parameterize barycentric interpolation modes. This patch modifies the fragment shader back-end so that instead of using a single delta_x/delta_y register pair to store barycentric coordinates, it uses an array of such register pairs, one for each possible intepolation mode. When setting up the WM, we intstruct it to only provide the barycentric coordinates that are actually needed by the fragment shader--that is computed by brw_compute_barycentric_interp_modes(). Currently this function returns just BRW_WM_PERSPECTIVE_PIXEL_BARYCENTRIC, because this is the only interpolation mode we support. However, that will change in a later patch. Reviewed-by: Eric Anholt e...@anholt.net --- src/mesa/drivers/dri/i965/brw_context.h |5 ++ src/mesa/drivers/dri/i965/brw_defines.h | 18 ++--- src/mesa/drivers/dri/i965/brw_fs.cpp | 25 +--- src/mesa/drivers/dri/i965/brw_fs.h|4 +- src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp | 11 +- src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 29 +- src/mesa/drivers/dri/i965/brw_wm.c| 42 - src/mesa/drivers/dri/i965/brw_wm.h|1 + src/mesa/drivers/dri/i965/gen6_wm_state.c |3 +- src/mesa/drivers/dri/i965/gen7_wm_state.c |3 +- 10 files changed, 103 insertions(+), 38 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index ff25b09..4ae8580 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -976,6 +976,11 @@ void brw_compute_vue_map(struct brw_vue_map *vue_map, GLbitfield64 outputs_written); gl_clip_plane *brw_select_clip_planes(struct gl_context *ctx); +/* brw_wm.c */ +unsigned +brw_compute_barycentric_interp_modes(void); + + /*== * Inline conversion functions. These are better-typed than the diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h index 61a739c..d302a61 100644 --- a/src/mesa/drivers/dri/i965/brw_defines.h +++ b/src/mesa/drivers/dri/i965/brw_defines.h @@ -1215,6 +1215,16 @@ enum brw_message_target { /* DW12: attr 0-7 wrap shortest enables */ /* DW13: attr 8-16 wrap shortest enables */ +enum brw_wm_barycentric_interp_mode { + BRW_WM_PERSPECTIVE_PIXEL_BARYCENTRIC= 0, + BRW_WM_PERSPECTIVE_CENTROID_BARYCENTRIC = 1, + BRW_WM_PERSPECTIVE_SAMPLE_BARYCENTRIC = 2, + BRW_WM_NONPERSPECTIVE_PIXEL_BARYCENTRIC = 3, + BRW_WM_NONPERSPECTIVE_CENTROID_BARYCENTRIC = 4, + BRW_WM_NONPERSPECTIVE_SAMPLE_BARYCENTRIC= 5, + BRW_WM_BARYCENTRIC_INTERP_MODE_COUNT = 6 +}; + #define _3DSTATE_WM0x7814 /* GEN6+ */ /* DW1: kernel pointer */ /* DW2 */ @@ -1269,6 +1279,7 @@ enum brw_message_target { # define GEN6_WM_PERSPECTIVE_SAMPLE_BARYCENTRIC(1 12) # define GEN6_WM_PERSPECTIVE_CENTROID_BARYCENTRIC (1 11) # define GEN6_WM_PERSPECTIVE_PIXEL_BARYCENTRIC (1 10) +# define GEN6_WM_BARYCENTRIC_INTERPOLATION_MODE_SHIFT 10 # define GEN6_WM_POINT_RASTRULE_UPPER_RIGHT(1 9) # define GEN6_WM_MSRAST_OFF_PIXEL (0 1) # define GEN6_WM_MSRAST_OFF_PATTERN(1 1) @@ -1306,12 +1317,7 @@ enum brw_message_target { # define GEN7_WM_POSITION_ZW_PIXEL (0 17) # define GEN7_WM_POSITION_ZW_CENTROID (2 17) # define GEN7_WM_POSITION_ZW_SAMPLE(3 17) -# define GEN7_WM_NONPERSPECTIVE_SAMPLE_BARYCENTRIC (1 16) -# define GEN7_WM_NONPERSPECTIVE_CENTROID_BARYCENTRIC (1 15) -# define GEN7_WM_NONPERSPECTIVE_PIXEL_BARYCENTRIC (1 14) -# define GEN7_WM_PERSPECTIVE_SAMPLE_BARYCENTRIC(1 13) -# define GEN7_WM_PERSPECTIVE_CENTROID_BARYCENTRIC (1 12) -# define GEN7_WM_PERSPECTIVE_PIXEL_BARYCENTRIC (1 11) +# define GEN7_WM_BARYCENTRIC_INTERPOLATION_MODE_SHIFT 11 # define GEN7_WM_USES_INPUT_COVERAGE_MASK (1 10) # define GEN7_WM_LINE_END_CAP_AA_WIDTH_0_5 (0 8) # define GEN7_WM_LINE_END_CAP_AA_WIDTH_1_0 (1 8) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 3848915..b3ad505 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -407,8 +407,10 @@ fs_visitor::emit_fragcoord_interpolation(ir_variable *ir) emit(BRW_OPCODE_MOV, wpos, fs_reg(brw_vec8_grf(c-source_depth_reg, 0))); } else { - emit(FS_OPCODE_LINTERP
Mesa (master): i965/fs: use determine_interpolation_mode().
Module: Mesa Branch: master Commit: f8386a29f07c6a41c4afb99fc3ecd9f18e9151e8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f8386a29f07c6a41c4afb99fc3ecd9f18e9151e8 Author: Paul Berry stereotype...@gmail.com Date: Fri Oct 21 07:56:08 2011 -0700 i965/fs: use determine_interpolation_mode(). This patch changes how fs_visitor::emit_general_interpolation() decides what kind of interpolation to do. Previously, it used the shade model to determine how to interpolate colors, and used smooth interpolation on everything else. Now it uses ir_variable::determine_interpolation_mode(), so that it respects GLSL 1.30 interpolation qualifiers. Fixes piglit tests interpolation-flat-*-smooth-{distance,fixed,vertex} and interpolation-flat-other-flat-{distance,fixed,vertex}. Reviewed-by: Eric Anholt e...@anholt.net --- src/mesa/drivers/dri/i965/brw_fs.cpp |8 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index b3ad505..185e00d 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -442,6 +442,9 @@ fs_visitor::emit_general_interpolation(ir_variable *ir) type = ir-type; } + glsl_interp_qualifier interpolation_mode = + ir-determine_interpolation_mode(c-key.flat_shade); + int location = ir-location; for (unsigned int i = 0; i array_elements; i++) { for (unsigned int j = 0; j type-matrix_columns; j++) { @@ -454,10 +457,7 @@ fs_visitor::emit_general_interpolation(ir_variable *ir) continue; } -bool is_gl_Color = - location == FRAG_ATTRIB_COL0 || location == FRAG_ATTRIB_COL1; - -if (c-key.flat_shade is_gl_Color) { +if (interpolation_mode == INTERP_QUALIFIER_FLAT) { /* Constant interpolation (flat shading) case. The SF has * handed us defined values in only the constant offset * field of the setup reg. ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965/gen6+: Rename GEN6_CLIP_BARYCENTRIC_ENABLE.
Module: Mesa Branch: master Commit: 4d563ec1cc912e4b3f02e71ad72d7b08f001d4d7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4d563ec1cc912e4b3f02e71ad72d7b08f001d4d7 Author: Paul Berry stereotype...@gmail.com Date: Sat Oct 22 09:33:12 2011 -0700 i965/gen6+: Rename GEN6_CLIP_BARYCENTRIC_ENABLE. The name was misleading. The actual effect of the bit is to cause the clipper to emit *non-perspective* barycentric coordinate information (which is only needed when doing noperspective interpolation). Reviewed-by: Kenneth Graunke kenn...@whitecape.org Reviewed-by: Eric Anholt e...@anholt.net --- src/mesa/drivers/dri/i965/brw_defines.h |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h index d302a61..746c89f 100644 --- a/src/mesa/drivers/dri/i965/brw_defines.h +++ b/src/mesa/drivers/dri/i965/brw_defines.h @@ -1108,7 +1108,7 @@ enum brw_message_target { # define GEN6_CLIP_MODE_REJECT_ALL (3 13) # define GEN6_CLIP_MODE_ACCEPT_ALL (4 13) # define GEN6_CLIP_PERSPECTIVE_DIVIDE_DISABLE (1 9) -# define GEN6_CLIP_BARYCENTRIC_ENABLE (1 8) +# define GEN6_CLIP_NON_PERSPECTIVE_BARYCENTRIC_ENABLE (1 8) # define GEN6_CLIP_TRI_PROVOKE_SHIFT 4 # define GEN6_CLIP_LINE_PROVOKE_SHIFT 2 # define GEN6_CLIP_TRIFAN_PROVOKE_SHIFT0 ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965/gen6+: Add support for noperspective interpolation.
Module: Mesa Branch: master Commit: 5aa96286e7e1a5380673eb75e8653616b48751fd URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5aa96286e7e1a5380673eb75e8653616b48751fd Author: Paul Berry stereotype...@gmail.com Date: Sat Oct 22 09:33:16 2011 -0700 i965/gen6+: Add support for noperspective interpolation. This required the following changes: - WM setup now makes the appropriate set of barycentric coordinates (perspective vs. noperspective) available to the fragment shader, based on whether the shader requires perspective interpolation, noperspective interpolation, both, or neither. - The fragment shader backend now uses the appropriate set of barycentric coordiantes when interpolating, based on the interpolation mode returned by ir_variable::determine_interpolation_mode(). - SF setup now uses gl_fragment_program::InterpQualifier to determine which attributes are to be flat shaded (as opposed to the old logic, which only flat shaded colors). - CLIP setup now ensures that the clipper outputs non-perspective barycentric coordinates when they are needed by the fragment shader. Fixes the remaining piglit tests of interpolation qualifiers that were failing: - interpolation-flat-*-smooth-none - interpolation-flat-other-flat-none - interpolation-noperspective-* - interpolation-smooth-gl_*Color-flat-* Reviewed-by: Eric Anholt e...@anholt.net --- src/mesa/drivers/dri/i965/brw_context.h |7 - src/mesa/drivers/dri/i965/brw_fs.cpp|9 -- src/mesa/drivers/dri/i965/brw_wm.c | 40 --- src/mesa/drivers/dri/i965/gen6_clip_state.c | 32 +- src/mesa/drivers/dri/i965/gen6_sf_state.c | 21 +++--- src/mesa/drivers/dri/i965/gen6_wm_state.c |9 -- src/mesa/drivers/dri/i965/gen7_clip_state.c | 12 +++- src/mesa/drivers/dri/i965/gen7_sf_state.c | 21 +++--- src/mesa/drivers/dri/i965/gen7_wm_state.c | 10 --- 9 files changed, 122 insertions(+), 39 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 4ae8580..1d6e58b 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -978,7 +978,12 @@ gl_clip_plane *brw_select_clip_planes(struct gl_context *ctx); /* brw_wm.c */ unsigned -brw_compute_barycentric_interp_modes(void); +brw_compute_barycentric_interp_modes(bool shade_model_flat, + const struct gl_fragment_program *fprog); + +/* gen6_clip_state.c */ +bool +brw_fprog_uses_noperspective(const struct gl_fragment_program *fprog); diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 185e00d..31c3116 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -469,7 +469,7 @@ fs_visitor::emit_general_interpolation(ir_variable *ir) attr.reg_offset++; } } else { - /* Perspective interpolation case. */ + /* Smooth/noperspective interpolation case. */ for (unsigned int k = 0; k type-vector_elements; k++) { /* FINISHME: At some point we probably want to push * this farther by giving similar treatment to the @@ -483,8 +483,11 @@ fs_visitor::emit_general_interpolation(ir_variable *ir) emit(BRW_OPCODE_MOV, attr, fs_reg(1.0f)); } else { struct brw_reg interp = interp_reg(location, k); - brw_wm_barycentric_interp_mode barycoord_mode = - BRW_WM_PERSPECTIVE_PIXEL_BARYCENTRIC; + brw_wm_barycentric_interp_mode barycoord_mode; + if (interpolation_mode == INTERP_QUALIFIER_SMOOTH) + barycoord_mode = BRW_WM_PERSPECTIVE_PIXEL_BARYCENTRIC; + else + barycoord_mode = BRW_WM_NONPERSPECTIVE_PIXEL_BARYCENTRIC; emit(FS_OPCODE_LINTERP, attr, this-delta_x[barycoord_mode], this-delta_y[barycoord_mode], fs_reg(interp)); diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c index 81dad4f..63c770d 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.c +++ b/src/mesa/drivers/dri/i965/brw_wm.c @@ -129,10 +129,41 @@ brw_wm_non_glsl_emit(struct brw_context *brw, struct brw_wm_compile *c) * (see enum brw_wm_barycentric_interp_mode) is needed by the fragment shader. */ unsigned -brw_compute_barycentric_interp_modes(void) +brw_compute_barycentric_interp_modes(bool shade_model_flat, + const struct gl_fragment_program *fprog) { - /* At the moment the only interpolation mode we support is perspective. */ - return (1 BRW_WM_PERSPECTIVE_PIXEL_BARYCENTRIC); + unsigned barycentric_interp_modes = 0; + int attr; + + /* Loop through all fragment shader inputs to figure out
Mesa (master): glsl: Fix copy-paste error in constant_expression_value( ir_binop_nequal)
Module: Mesa Branch: master Commit: b726639e1be0614fb6bbb75a6f07c63eacc6d787 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b726639e1be0614fb6bbb75a6f07c63eacc6d787 Author: Paul Berry stereotype...@gmail.com Date: Thu Oct 6 11:28:42 2011 -0700 glsl: Fix copy-paste error in constant_expression_value(ir_binop_nequal) 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 '=='. Fixes piglit tests {fs,vs}-inline-notequal. --- src/glsl/ir_constant_expression.cpp |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 83f084d..492be32 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -719,7 +719,7 @@ ir_expression::constant_expression_value() } break; case ir_binop_nequal: - assert(op[0]-type != op[1]-type); + assert(op[0]-type == op[1]-type); for (unsigned c = 0; c components; c++) { switch (op[0]-type-base_type) { case GLSL_TYPE_UINT: ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): glsl: Add '.ir' extension to builtin IR files
Module: Mesa Branch: master Commit: b6f32bbe12e1082e78951b6ef073bf244ba0b8b7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b6f32bbe12e1082e78951b6ef073bf244ba0b8b7 Author: Paul Berry stereotype...@gmail.com Date: Thu Oct 6 10:31:34 2011 -0700 glsl: Add '.ir' extension to builtin IR files This patch adds the extension '.ir' to all the files in src/glsl/builtins/ir/, and changes generate_builtins.py so that it no longer globs on '*' to find the files to build. This prevents spurious files (such as EMACS' infamous *~ backup files) from breaking the build. --- src/glsl/builtins/ir/{abs = abs.ir} |0 src/glsl/builtins/ir/{acos = acos.ir} |0 src/glsl/builtins/ir/{acosh = acosh.ir} |0 src/glsl/builtins/ir/{all = all.ir} |0 src/glsl/builtins/ir/{any = any.ir} |0 src/glsl/builtins/ir/{asin = asin.ir} |0 src/glsl/builtins/ir/{asinh = asinh.ir} |0 src/glsl/builtins/ir/{atan = atan.ir} |0 src/glsl/builtins/ir/{atanh = atanh.ir} |0 src/glsl/builtins/ir/{ceil = ceil.ir} |0 src/glsl/builtins/ir/{clamp = clamp.ir} |0 src/glsl/builtins/ir/{cos = cos.ir} |0 src/glsl/builtins/ir/{cosh = cosh.ir} |0 src/glsl/builtins/ir/{cross = cross.ir} |0 src/glsl/builtins/ir/{dFdx = dFdx.ir} |0 src/glsl/builtins/ir/{dFdy = dFdy.ir} |0 src/glsl/builtins/ir/{degrees = degrees.ir} |0 src/glsl/builtins/ir/{distance = distance.ir} |0 src/glsl/builtins/ir/{dot = dot.ir} |0 src/glsl/builtins/ir/{equal = equal.ir} |0 src/glsl/builtins/ir/{exp = exp.ir} |0 src/glsl/builtins/ir/{exp2 = exp2.ir} |0 .../builtins/ir/{faceforward = faceforward.ir}|0 src/glsl/builtins/ir/{floor = floor.ir} |0 src/glsl/builtins/ir/{fract = fract.ir} |0 src/glsl/builtins/ir/{ftransform = ftransform.ir} |0 src/glsl/builtins/ir/{fwidth = fwidth.ir} |0 .../builtins/ir/{greaterThan = greaterThan.ir}|0 .../ir/{greaterThanEqual = greaterThanEqual.ir} |0 .../builtins/ir/{inversesqrt = inversesqrt.ir}|0 src/glsl/builtins/ir/{length = length.ir} |0 src/glsl/builtins/ir/{lessThan = lessThan.ir} |0 .../ir/{lessThanEqual = lessThanEqual.ir} |0 src/glsl/builtins/ir/{log = log.ir} |0 src/glsl/builtins/ir/{log2 = log2.ir} |0 .../ir/{matrixCompMult = matrixCompMult.ir} |0 src/glsl/builtins/ir/{max = max.ir} |0 src/glsl/builtins/ir/{min = min.ir} |0 src/glsl/builtins/ir/{mix = mix.ir} |0 src/glsl/builtins/ir/{mod = mod.ir} |0 src/glsl/builtins/ir/{modf = modf.ir} |0 src/glsl/builtins/ir/{noise1 = noise1.ir} |0 src/glsl/builtins/ir/{noise2 = noise2.ir} |0 src/glsl/builtins/ir/{noise3 = noise3.ir} |0 src/glsl/builtins/ir/{noise4 = noise4.ir} |0 src/glsl/builtins/ir/{normalize = normalize.ir} |0 src/glsl/builtins/ir/{not = not.ir} |0 src/glsl/builtins/ir/{notEqual = notEqual.ir} |0 .../builtins/ir/{outerProduct = outerProduct.ir} |0 src/glsl/builtins/ir/{pow = pow.ir} |0 src/glsl/builtins/ir/{radians = radians.ir} |0 src/glsl/builtins/ir/{reflect = reflect.ir} |0 src/glsl/builtins/ir/{refract = refract.ir} |0 src/glsl/builtins/ir/{round = round.ir} |0 src/glsl/builtins/ir/{roundEven = roundEven.ir} |0 src/glsl/builtins/ir/{sign = sign.ir} |0 src/glsl/builtins/ir/{sin = sin.ir} |0 src/glsl/builtins/ir/{sinh = sinh.ir} |0 src/glsl/builtins/ir/{smoothstep = smoothstep.ir} |0 src/glsl/builtins/ir/{sqrt = sqrt.ir} |0 src/glsl/builtins/ir/{step = step.ir} |0 src/glsl/builtins/ir/{tan = tan.ir} |0 src/glsl/builtins/ir/{tanh = tanh.ir} |0 src/glsl/builtins/ir/{transpose = transpose.ir} |0 src/glsl/builtins/ir/{trunc = trunc.ir} |0 src/glsl/builtins/tools/generate_builtins.py | 12 +--- 66 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/glsl/builtins/ir/abs b/src/glsl/builtins/ir/abs.ir similarity index 100% rename from src/glsl/builtins/ir/abs rename to src/glsl/builtins/ir/abs.ir diff --git a/src/glsl/builtins/ir/acos b/src/glsl/builtins/ir/acos.ir similarity index 100% rename from src/glsl/builtins/ir/acos rename to src/glsl/builtins/ir/acos.ir diff --git a/src/glsl/builtins/ir/acosh b/src/glsl/builtins/ir/acosh.ir similarity index 100% rename from src/glsl
Mesa (master): glsl: Add isinf() and isnan() builtins.
Module: Mesa Branch: master Commit: ede60bc4670a8d9c14921c77abee1ac57fc0e6bf URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ede60bc4670a8d9c14921c77abee1ac57fc0e6bf Author: Paul Berry stereotype...@gmail.com Date: Thu Oct 6 10:20:10 2011 -0700 glsl: Add isinf() and isnan() builtins. The implementations are as follows: isinf(x) = (abs(x) == +infinity) isnan(x) = (x != x) Note: the latter formula is not necessarily obvious. It works because NaN is the only floating point number that does not equal itself. Fixes piglit tests isinf-and-isnan fs_basic and isinf-and-isnan vs_basic. --- src/glsl/builtins/ir/isinf.ir | 17 + src/glsl/builtins/ir/isnan.ir | 17 + src/glsl/builtins/profiles/130.frag |2 -- src/glsl/builtins/profiles/130.vert |2 -- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/glsl/builtins/ir/isinf.ir b/src/glsl/builtins/ir/isinf.ir new file mode 100644 index 000..92922f6 --- /dev/null +++ b/src/glsl/builtins/ir/isinf.ir @@ -0,0 +1,17 @@ +((function isinf + (signature bool + (parameters + (declare (in) float x)) + ((return (expression bool == (expression float abs (var_ref x)) (constant float (+INF)) + (signature bvec2 + (parameters + (declare (in) vec2 x)) + ((return (expression bvec2 == (expression vec2 abs (var_ref x)) (constant vec2 (+INF +INF)) + (signature bvec3 + (parameters + (declare (in) vec3 x)) + ((return (expression bvec3 == (expression vec3 abs (var_ref x)) (constant vec3 (+INF +INF +INF)) + (signature bvec4 + (parameters + (declare (in) vec4 x)) + ((return (expression bvec4 == (expression vec4 abs (var_ref x)) (constant vec4 (+INF +INF +INF +INF diff --git a/src/glsl/builtins/ir/isnan.ir b/src/glsl/builtins/ir/isnan.ir new file mode 100644 index 000..b67349f --- /dev/null +++ b/src/glsl/builtins/ir/isnan.ir @@ -0,0 +1,17 @@ +((function isnan + (signature bool + (parameters + (declare (in) float x)) + ((return (expression bool != (var_ref x) (var_ref x) + (signature bvec2 + (parameters + (declare (in) vec2 x)) + ((return (expression bvec2 != (var_ref x) (var_ref x) + (signature bvec3 + (parameters + (declare (in) vec3 x)) + ((return (expression bvec3 != (var_ref x) (var_ref x) + (signature bvec4 + (parameters + (declare (in) vec4 x)) + ((return (expression bvec4 != (var_ref x) (var_ref x))) diff --git a/src/glsl/builtins/profiles/130.frag b/src/glsl/builtins/profiles/130.frag index c121859..1f212c1 100644 --- a/src/glsl/builtins/profiles/130.frag +++ b/src/glsl/builtins/profiles/130.frag @@ -288,7 +288,6 @@ vec2 smoothstep(float edge0, float edge1, vec2 x); vec3 smoothstep(float edge0, float edge1, vec3 x); vec4 smoothstep(float edge0, float edge1, vec4 x); -#if 0 bool isnan(float x); bvec2 isnan(vec2 x); bvec3 isnan(vec3 x); @@ -298,7 +297,6 @@ bool isinf(float x); bvec2 isinf(vec2 x); bvec3 isinf(vec3 x); bvec4 isinf(vec4 x); -#endif /* * 8.4 - Geometric Functions diff --git a/src/glsl/builtins/profiles/130.vert b/src/glsl/builtins/profiles/130.vert index ebd9a50..df17ede 100644 --- a/src/glsl/builtins/profiles/130.vert +++ b/src/glsl/builtins/profiles/130.vert @@ -288,7 +288,6 @@ vec2 smoothstep(float edge0, float edge1, vec2 x); vec3 smoothstep(float edge0, float edge1, vec3 x); vec4 smoothstep(float edge0, float edge1, vec4 x); -#if 0 bool isnan(float x); bvec2 isnan(vec2 x); bvec3 isnan(vec3 x); @@ -298,7 +297,6 @@ bool isinf(float x); bvec2 isinf(vec2 x); bvec3 isinf(vec3 x); bvec4 isinf(vec4 x); -#endif /* * 8.4 - Geometric Functions ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965/gen6+: Switch GLSL from ALT to IEEE floating point mode
Module: Mesa Branch: master Commit: f40c6b2a992f3ca796826a47743c0c80232d7ab2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f40c6b2a992f3ca796826a47743c0c80232d7ab2 Author: Paul Berry stereotype...@gmail.com Date: Fri Oct 7 17:37:32 2011 -0700 i965/gen6+: Switch GLSL from ALT to IEEE floating point mode i965 graphics hardware has two floating point modes: ALT and IEEE. In ALT mode, floating-point operations never generate infinities or NaNs, and MOV instructions translate infinities and NaNs to finite values. In IEEE mode, infinities and NaNs behave as specified in the IEEE 754 spec. Previously, we used ALT mode for all vertex and fragment programs, whether they were GLSL programs or ARB programs. The GLSL spec is sufficiently vague about how infs and nans are to be handled that it was unclear whether this mode was compliant with the GLSL 1.30 spec or not, and it made it very difficult to test the isinf() and isnan() functions. This patch changes i965 GLSL programs to use IEEE floating-point mode, which is clearly compliant with GLSL 1.30's inf/nan requirements. In addition to making the Piglit isinf and isnan tests pass, this paves the way for future support of the ARB_shader_precision extension. Unfortunately we still have to use ALT floating-point mode when executing ARB programs, because those programs require 0^0 == 1, and i965 hardware generates 0^0 == NaN in IEEE mode. Fixes piglit tests isinf-and-isnan fs_fbo, isinf-and-isnan vs_fbo, and {fs,vs}-{isinf,isnan}-{vec2,vec3,vec4}. --- src/mesa/drivers/dri/i965/gen6_vs_state.c |9 - src/mesa/drivers/dri/i965/gen6_wm_state.c |7 +-- src/mesa/drivers/dri/i965/gen7_vs_state.c |9 - src/mesa/drivers/dri/i965/gen7_wm_state.c |7 +-- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/i965/gen6_vs_state.c b/src/mesa/drivers/dri/i965/gen6_vs_state.c index e06c7b4..e22fd39 100644 --- a/src/mesa/drivers/dri/i965/gen6_vs_state.c +++ b/src/mesa/drivers/dri/i965/gen6_vs_state.c @@ -131,6 +131,7 @@ static void upload_vs_state(struct brw_context *brw) { struct intel_context *intel = brw-intel; + uint32_t floating_point_mode = 0; if (brw-vs.push_const_size == 0) { /* Disable the push constant buffers. */ @@ -157,11 +158,17 @@ upload_vs_state(struct brw_context *brw) ADVANCE_BATCH(); } + /* Use ALT floating point mode for ARB vertex programs, because they +* require 0^0 == 1. +*/ + if (intel-ctx.Shader.CurrentVertexProgram == NULL) + floating_point_mode = GEN6_VS_FLOATING_POINT_MODE_ALT; + BEGIN_BATCH(6); OUT_BATCH(_3DSTATE_VS 16 | (6 - 2)); OUT_BATCH(brw-vs.prog_offset); OUT_BATCH((0 GEN6_VS_SAMPLER_COUNT_SHIFT) | -GEN6_VS_FLOATING_POINT_MODE_ALT | + floating_point_mode | (brw-vs.nr_surfaces GEN6_VS_BINDING_TABLE_ENTRY_COUNT_SHIFT)); if (brw-vs.prog_data-total_scratch) { diff --git a/src/mesa/drivers/dri/i965/gen6_wm_state.c b/src/mesa/drivers/dri/i965/gen6_wm_state.c index 25e0fa2..714d594 100644 --- a/src/mesa/drivers/dri/i965/gen6_wm_state.c +++ b/src/mesa/drivers/dri/i965/gen6_wm_state.c @@ -134,8 +134,11 @@ upload_wm_state(struct brw_context *brw) dw5 |= GEN6_WM_LINE_AA_WIDTH_1_0; dw5 |= GEN6_WM_LINE_END_CAP_AA_WIDTH_0_5; - /* OpenGL non-ieee floating point mode */ - dw2 |= GEN6_WM_FLOATING_POINT_MODE_ALT; + /* Use ALT floating point mode for ARB fragment programs, because they +* require 0^0 == 1. +*/ + if (ctx-Shader.CurrentFragmentProgram == NULL) + dw2 |= GEN6_WM_FLOATING_POINT_MODE_ALT; /* BRW_NEW_NR_WM_SURFACES */ dw2 |= brw-wm.nr_surfaces GEN6_WM_BINDING_TABLE_ENTRY_COUNT_SHIFT; diff --git a/src/mesa/drivers/dri/i965/gen7_vs_state.c b/src/mesa/drivers/dri/i965/gen7_vs_state.c index 4ef9c68..dbf9346 100644 --- a/src/mesa/drivers/dri/i965/gen7_vs_state.c +++ b/src/mesa/drivers/dri/i965/gen7_vs_state.c @@ -33,6 +33,7 @@ static void upload_vs_state(struct brw_context *brw) { struct intel_context *intel = brw-intel; + uint32_t floating_point_mode = 0; BEGIN_BATCH(2); OUT_BATCH(_3DSTATE_BINDING_TABLE_POINTERS_VS 16 | (2 - 2)); @@ -65,11 +66,17 @@ upload_vs_state(struct brw_context *brw) ADVANCE_BATCH(); } + /* Use ALT floating point mode for ARB vertex programs, because they +* require 0^0 == 1. +*/ + if (intel-ctx.Shader.CurrentVertexProgram == NULL) + floating_point_mode = GEN6_VS_FLOATING_POINT_MODE_ALT; + BEGIN_BATCH(6); OUT_BATCH(_3DSTATE_VS 16 | (6 - 2)); OUT_BATCH(brw-vs.prog_offset); OUT_BATCH((0 GEN6_VS_SAMPLER_COUNT_SHIFT) | -GEN6_VS_FLOATING_POINT_MODE_ALT | + floating_point_mode | (brw-vs.nr_surfaces GEN6_VS_BINDING_TABLE_ENTRY_COUNT_SHIFT)); if (brw-vs.prog_data-total_scratch) { diff --git a/src/mesa/drivers/dri/i965/gen7_wm_state.c b/src/mesa/drivers/dri/i965/gen7_wm_state.c index
Mesa (master): mesa: Add glsl_type::get_scalar_type() function.
Module: Mesa Branch: master Commit: fa0066ae2b2d304065ee8d93d9b5ecc8b457425a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fa0066ae2b2d304065ee8d93d9b5ecc8b457425a Author: Paul Berry stereotype...@gmail.com Date: Tue Oct 25 16:24:03 2011 -0700 mesa: Add glsl_type::get_scalar_type() function. This function is similar to get_base_type(), but when called on arrays, it returns the scalar type composing the array. For example, glsl_type(vec4[]) = float_type. Acked-by: Kenneth Graunke kenn...@whitecape.org --- src/glsl/glsl_types.cpp | 23 +++ src/glsl/glsl_types.h | 11 +++ 2 files changed, 34 insertions(+), 0 deletions(-) diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index c94aec0..03e9987 100644 --- a/src/glsl/glsl_types.cpp +++ b/src/glsl/glsl_types.cpp @@ -258,6 +258,29 @@ const glsl_type *glsl_type::get_base_type() const } +const glsl_type *glsl_type::get_scalar_type() const +{ + const glsl_type *type = this; + + /* Handle arrays */ + while (type-base_type == GLSL_TYPE_ARRAY) + type = type-fields.array; + + /* Handle vectors and matrices */ + switch (type-base_type) { + case GLSL_TYPE_UINT: + return uint_type; + case GLSL_TYPE_INT: + return int_type; + case GLSL_TYPE_FLOAT: + return float_type; + default: + /* Handle everything else */ + return type; + } +} + + void _mesa_glsl_release_types(void) { diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h index 0486966..2f849af 100644 --- a/src/glsl/glsl_types.h +++ b/src/glsl/glsl_types.h @@ -178,6 +178,17 @@ struct glsl_type { const glsl_type *get_base_type() const; /** +* Get the basic scalar type which this type aggregates. +* +* If the type is a numeric or boolean scalar, vector, or matrix, or an +* array of any of those, this function gets the scalar type of the +* individual components. For structs and arrays of structs, this function +* returns the struct type. For samplers and arrays of samplers, this +* function returns the sampler type. +*/ + const glsl_type *get_scalar_type() const; + + /** * Query the type of elements in an array * * \return ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965: Fix flat integral varyings.
Module: Mesa Branch: master Commit: 9734bd05608c00a1d84851f3d46d5deb52e75d5e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9734bd05608c00a1d84851f3d46d5deb52e75d5e Author: Paul Berry stereotype...@gmail.com Date: Mon Oct 24 17:46:26 2011 -0700 i965: Fix flat integral varyings. Previously, the vertex and fragment shader back-ends assumed that all varyings were floats. In GLSL 1.30 this is no longer true--they can also be of integral types provided that they have an interpolation qualifier of flat. This required two changes in each back-end: assigning the correct type to the register that holds the varying value during shader execution, and assigning the correct type to the register that ties the varying value to the rest of the graphics pipeline (the message register in the case of VS, and the payload register in the case of FS). Fixes piglit tests fs-int-interpolation and fs-uint-interpolation. Acked-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/brw_fs.cpp |4 ++-- src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp |4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 31c3116..e58545b 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -424,8 +424,7 @@ fs_reg * fs_visitor::emit_general_interpolation(ir_variable *ir) { fs_reg *reg = new(this-mem_ctx) fs_reg(this, ir-type); - /* Interpolation is always in floating point regs. */ - reg-type = BRW_REGISTER_TYPE_F; + reg-type = brw_type_for_base_type(ir-type-get_scalar_type()); fs_reg attr = *reg; unsigned int array_elements; @@ -465,6 +464,7 @@ fs_visitor::emit_general_interpolation(ir_variable *ir) for (unsigned int k = 0; k type-vector_elements; k++) { struct brw_reg interp = interp_reg(location, k); interp = suboffset(interp, 3); + interp.type = reg-type; emit(FS_OPCODE_CINTERP, attr, fs_reg(interp)); attr.reg_offset++; } diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index 1312c0d..e5d5997 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -853,7 +853,8 @@ vec4_visitor::visit(ir_variable *ir) for (int i = 0; i type_size(ir-type); i++) { output_reg[ir-location + i] = *reg; output_reg[ir-location + i].reg_offset = i; -output_reg[ir-location + i].type = BRW_REGISTER_TYPE_F; +output_reg[ir-location + i].type = +brw_type_for_base_type(ir-type-get_scalar_type()); output_reg_annotation[ir-location + i] = ir-name; } break; @@ -1915,6 +1916,7 @@ void vec4_visitor::emit_generic_urb_slot(dst_reg reg, int vert_result) { assert (vert_result VERT_RESULT_MAX); + reg.type = output_reg[vert_result].type; current_annotation = output_reg_annotation[vert_result]; /* Copy the register, saturating if necessary */ vec4_instruction *inst = emit(MOV(reg, ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): glsl: Fix type mismatch when incrementing or decrementing uint.
Module: Mesa Branch: master Commit: 9abda92b270596fd3a5e2e8b74e3fc3255da70ce URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9abda92b270596fd3a5e2e8b74e3fc3255da70ce Author: Paul Berry stereotype...@gmail.com Date: Mon Oct 31 18:22:48 2011 -0700 glsl: Fix type mismatch when incrementing or decrementing uint. When converting an expression like ++x to GLSL IR we were failing to account for the possibility that x might be an unsigned integral type. As a result the user would receive a bogus error message Could not implicitly convert operands to arithmetic operator. Fixes piglit tests {vs,fs}-{increment,decrement}-uint. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/glsl/ast_to_hir.cpp | 32 1 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 7584fdf..ebdbbc1 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -935,6 +935,28 @@ check_builtin_array_max_size(const char *name, unsigned size, return false; } +/** + * Create the constant 1, of a which is appropriate for incrementing and + * decrementing values of the given GLSL type. For example, if type is vec4, + * this creates a constant value of 1.0 having type float. + * + * If the given type is invalid for increment and decrement operators, return + * a floating point 1--the error will be detected later. + */ +static ir_rvalue * +constant_one_for_inc_dec(void *ctx, const glsl_type *type) +{ + switch (type-base_type) { + case GLSL_TYPE_UINT: + return new(ctx) ir_constant((unsigned) 1); + case GLSL_TYPE_INT: + return new(ctx) ir_constant(1); + default: + case GLSL_TYPE_FLOAT: + return new(ctx) ir_constant(1.0f); + } +} + ir_rvalue * ast_expression::hir(exec_list *instructions, struct _mesa_glsl_parse_state *state) @@ -1442,10 +1464,7 @@ ast_expression::hir(exec_list *instructions, case ast_pre_inc: case ast_pre_dec: { op[0] = this-subexpressions[0]-hir(instructions, state); - if (op[0]-type-base_type == GLSL_TYPE_FLOAT) -op[1] = new(ctx) ir_constant(1.0f); - else -op[1] = new(ctx) ir_constant(1); + op[1] = constant_one_for_inc_dec(ctx, op[0]-type); type = arithmetic_result_type(op[0], op[1], false, state, loc); @@ -1463,10 +1482,7 @@ ast_expression::hir(exec_list *instructions, case ast_post_inc: case ast_post_dec: { op[0] = this-subexpressions[0]-hir(instructions, state); - if (op[0]-type-base_type == GLSL_TYPE_FLOAT) -op[1] = new(ctx) ir_constant(1.0f); - else -op[1] = new(ctx) ir_constant(1); + op[1] = constant_one_for_inc_dec(ctx, op[0]-type); error_emitted = op[0]-type-is_error() || op[1]-type-is_error(); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Set the Integer field of gl_client_array properly.
Module: Mesa Branch: master Commit: 8f84c237b360be69f9b6ac51465c729b3ada196a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8f84c237b360be69f9b6ac51465c729b3ada196a Author: Paul Berry stereotype...@gmail.com Date: Mon Oct 31 17:29:17 2011 -0700 mesa: Set the Integer field of gl_client_array properly. This patch ensures that gl_client_array::Integer is properly set to GL_TRUE for vertex attributes specified using glVertexAttribIPointer, and to GL_FALSE for vertex attributes specified using glVertexAttribPointer, so that the vertex attributes can be interpreted properly by driver back-ends. Reviewed-by: Kenneth Graunke kenn...@whitecape.org Reviewed-by: Eric Anholt e...@anholt.net --- src/mesa/main/arrayobj.c |1 + src/mesa/main/varray.c|1 + src/mesa/vbo/vbo_split_copy.c |1 + 3 files changed, 3 insertions(+), 0 deletions(-) diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c index 78f56ab..1283940 100644 --- a/src/mesa/main/arrayobj.c +++ b/src/mesa/main/arrayobj.c @@ -208,6 +208,7 @@ init_array(struct gl_context *ctx, array-Ptr = NULL; array-Enabled = GL_FALSE; array-Normalized = GL_FALSE; + array-Integer = GL_FALSE; array-_ElementSize = size * _mesa_sizeof_type(type); #if FEATURE_ARB_vertex_buffer_object /* Vertex array buffers */ diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 13b3405..f1a57c1 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -212,6 +212,7 @@ update_array(struct gl_context *ctx, array-Stride = stride; array-StrideB = stride ? stride : elementSize; array-Normalized = normalized; + array-Integer = integer; array-Ptr = (const GLubyte *) ptr; array-_ElementSize = elementSize; diff --git a/src/mesa/vbo/vbo_split_copy.c b/src/mesa/vbo/vbo_split_copy.c index 40906e3..4dcf71e 100644 --- a/src/mesa/vbo/vbo_split_copy.c +++ b/src/mesa/vbo/vbo_split_copy.c @@ -518,6 +518,7 @@ replay_init( struct copy_context *copy ) dst-Ptr = copy-dstbuf + offset; dst-Enabled = GL_TRUE; dst-Normalized = src-Normalized; + dst-Integer = src-Integer; dst-BufferObj = ctx-Shared-NullBufferObj; dst-_ElementSize = src-_ElementSize; dst-_MaxElement = copy-dstbuf_size; /* may be less! */ ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965: Add support for integral vertex attributes.
Module: Mesa Branch: master Commit: 29e2bc8b13be0f7ec48f8514e47322353e041365 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=29e2bc8b13be0f7ec48f8514e47322353e041365 Author: Paul Berry stereotype...@gmail.com Date: Mon Oct 31 17:31:16 2011 -0700 i965: Add support for integral vertex attributes. When a vertex shader input attribute is declared with an integral type (e.g. ivec4), we need to ensure that the generated vertex shader code addresses the vertex attribute register using the proper register type. (Previously, we assumed all vertex shader input attributes were floating-point). In addition, when uploading vertex data that was specified with VertexAttribIPointer, we need to instruct the vertex fetch unit to convert the data to signed or unsigned int, rather than float. And when filling in the implied w=1 on a vector with less than 4 components, we need to fill it in with the integer representation of 1 rather than the floating-point representation of 1. Fixes piglit tests vs-attrib-{ivec4,uvec4}-precision. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/brw_draw_upload.c| 69 ++-- src/mesa/drivers/dri/i965/brw_vec4_emit.cpp|1 + src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp |1 + 3 files changed, 67 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index b7ae4cd..db0cb18 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -65,6 +65,14 @@ static GLuint half_float_types[5] = { BRW_SURFACEFORMAT_R16G16B16A16_FLOAT }; +static GLuint uint_types_direct[5] = { + 0, + BRW_SURFACEFORMAT_R32_UINT, + BRW_SURFACEFORMAT_R32G32_UINT, + BRW_SURFACEFORMAT_R32G32B32_UINT, + BRW_SURFACEFORMAT_R32G32B32A32_UINT +}; + static GLuint uint_types_norm[5] = { 0, BRW_SURFACEFORMAT_R32_UNORM, @@ -81,6 +89,14 @@ static GLuint uint_types_scale[5] = { BRW_SURFACEFORMAT_R32G32B32A32_USCALED }; +static GLuint int_types_direct[5] = { + 0, + BRW_SURFACEFORMAT_R32_SINT, + BRW_SURFACEFORMAT_R32G32_SINT, + BRW_SURFACEFORMAT_R32G32B32_SINT, + BRW_SURFACEFORMAT_R32G32B32A32_SINT +}; + static GLuint int_types_norm[5] = { 0, BRW_SURFACEFORMAT_R32_SNORM, @@ -97,6 +113,14 @@ static GLuint int_types_scale[5] = { BRW_SURFACEFORMAT_R32G32B32A32_SSCALED }; +static GLuint ushort_types_direct[5] = { + 0, + BRW_SURFACEFORMAT_R16_UINT, + BRW_SURFACEFORMAT_R16G16_UINT, + BRW_SURFACEFORMAT_R16G16B16A16_UINT, + BRW_SURFACEFORMAT_R16G16B16A16_UINT +}; + static GLuint ushort_types_norm[5] = { 0, BRW_SURFACEFORMAT_R16_UNORM, @@ -113,6 +137,14 @@ static GLuint ushort_types_scale[5] = { BRW_SURFACEFORMAT_R16G16B16A16_USCALED }; +static GLuint short_types_direct[5] = { + 0, + BRW_SURFACEFORMAT_R16_SINT, + BRW_SURFACEFORMAT_R16G16_SINT, + BRW_SURFACEFORMAT_R16G16B16A16_SINT, + BRW_SURFACEFORMAT_R16G16B16A16_SINT +}; + static GLuint short_types_norm[5] = { 0, BRW_SURFACEFORMAT_R16_SNORM, @@ -129,6 +161,14 @@ static GLuint short_types_scale[5] = { BRW_SURFACEFORMAT_R16G16B16A16_SSCALED }; +static GLuint ubyte_types_direct[5] = { + 0, + BRW_SURFACEFORMAT_R8_UINT, + BRW_SURFACEFORMAT_R8G8_UINT, + BRW_SURFACEFORMAT_R8G8B8A8_UINT, + BRW_SURFACEFORMAT_R8G8B8A8_UINT +}; + static GLuint ubyte_types_norm[5] = { 0, BRW_SURFACEFORMAT_R8_UNORM, @@ -145,6 +185,14 @@ static GLuint ubyte_types_scale[5] = { BRW_SURFACEFORMAT_R8G8B8A8_USCALED }; +static GLuint byte_types_direct[5] = { + 0, + BRW_SURFACEFORMAT_R8_SINT, + BRW_SURFACEFORMAT_R8G8_SINT, + BRW_SURFACEFORMAT_R8G8B8A8_SINT, + BRW_SURFACEFORMAT_R8G8B8A8_SINT +}; + static GLuint byte_types_norm[5] = { 0, BRW_SURFACEFORMAT_R8_SNORM, @@ -168,13 +216,24 @@ static GLuint byte_types_scale[5] = { * Format will be GL_RGBA or possibly GL_BGRA for GLubyte[4] color arrays. */ static GLuint get_surface_type( GLenum type, GLuint size, -GLenum format, bool normalized ) +GLenum format, bool normalized, bool integer ) { if (unlikely(INTEL_DEBUG DEBUG_VERTS)) printf(type %s size %d normalized %d\n, _mesa_lookup_enum_by_nr(type), size, normalized); - if (normalized) { + if (integer) { + assert(format == GL_RGBA); /* sanity check */ + switch (type) { + case GL_INT: return int_types_direct[size]; + case GL_SHORT: return short_types_direct[size]; + case GL_BYTE: return byte_types_direct[size]; + case GL_UNSIGNED_INT: return uint_types_direct[size]; + case GL_UNSIGNED_SHORT: return ushort_types_direct[size]; + case GL_UNSIGNED_BYTE: return ubyte_types_direct[size]; + default: assert(0); return 0; + } + } else if (normalized) { switch (type) { case GL_DOUBLE: return double_types[size
Mesa (master): i965: Fix constant propagation into 32-bit integer MUL.
Module: Mesa Branch: master Commit: 8fad0f99989866eeb72889a84f12f6f817334ddb URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8fad0f99989866eeb72889a84f12f6f817334ddb Author: Paul Berry stereotype...@gmail.com Date: Tue Nov 1 20:35:23 2011 -0700 i965: Fix constant propagation into 32-bit integer MUL. i965's MUL instruction can't take an immediate value as its first argument. So normally, if constant propagation wants to propagate a constant into the first argument of a MUL instruction, it swaps the order of the two arguments. This doesn't work for 32-bit integer (and unsigned integer) multiplies, because the MUL operation is asymmetric in that case (it multiplies 16 bits of one operand by 32 bits of the other). Fixes piglit tests {vs,fs}-multiply-const-{ivec4,uvec4}. Reviewed-by: Eric Anholt e...@anholt.net --- src/mesa/drivers/dri/i965/brw_fs.cpp |9 - .../drivers/dri/i965/brw_vec4_copy_propagation.cpp |8 +++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index e58545b..b66febb 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -1127,7 +1127,14 @@ fs_visitor::propagate_constants() scan_inst-src[i] = inst-src[0]; progress = true; } else if (i == 0 scan_inst-src[1].file != IMM) { - /* Fit this constant in by commuting the operands */ + /* Fit this constant in by commuting the operands. + * Exception: we can't do this for 32-bit integer MUL + * because it's asymmetric. + */ + if (scan_inst-opcode == BRW_OPCODE_MUL + (scan_inst-src[1].type == BRW_REGISTER_TYPE_D || + scan_inst-src[1].type == BRW_REGISTER_TYPE_UD)) +break; scan_inst-src[0] = scan_inst-src[1]; scan_inst-src[1] = inst-src[0]; progress = true; diff --git a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp index c3a9dee..93ae3d6 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp @@ -101,7 +101,13 @@ try_constant_propagation(vec4_instruction *inst, int arg, src_reg *values[4]) inst-src[arg] = value; return true; } else if (arg == 0 inst-src[1].file != IMM) { -/* Fit this constant in by commuting the operands */ +/* Fit this constant in by commuting the operands. Exception: we + * can't do this for 32-bit integer MUL because it's asymmetric. + */ +if (inst-opcode == BRW_OPCODE_MUL +(inst-src[1].type == BRW_REGISTER_TYPE_D || + inst-src[1].type == BRW_REGISTER_TYPE_UD)) + break; inst-src[0] = inst-src[1]; inst-src[1] = value; return true; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): glsl: Assign transform feedback varying slots in linker.
Module: Mesa Branch: master Commit: 871ddb919b424293894a23a8f83200fed572d6a9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=871ddb919b424293894a23a8f83200fed572d6a9 Author: Paul Berry stereotype...@gmail.com Date: Sat Nov 5 11:17:32 2011 -0700 glsl: Assign transform feedback varying slots in linker. This patch modifies the GLSL linker to assign additional slots for varying variables used by transform feedback, and record the varying slots used by transform feedback for use by the driver back-end. This required modifying assign_varying_locations() so that it assigns a varying location if either (a) the varying is used by the next stage of the GL pipeline, or (b) the varying is required by transform feedback. In order to avoid duplicating the code to assign a single varying location, I moved it into its own function, assign_varying_location(). In addition, to support transform feedback in the case where there is no fragment shader, it is now possible to call assign_varying_locations() with a consumer of NULL. Reviewed-by: Marek Olšák mar...@gmail.com Tested-by: Marek Olšák mar...@gmail.com --- src/glsl/linker.cpp| 553 ++-- src/mesa/main/mtypes.h | 13 ++ 2 files changed, 503 insertions(+), 63 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 0306b7a..351680d 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1369,10 +1369,359 @@ demote_shader_inputs_and_outputs(gl_shader *sh, enum ir_variable_mode mode) } +/** + * Data structure tracking information about a transform feedback declaration + * during linking. + */ +class tfeedback_decl +{ +public: + bool init(struct gl_shader_program *prog, const void *mem_ctx, + const char *input); + static bool is_same(const tfeedback_decl x, const tfeedback_decl y); + bool assign_location(struct gl_context *ctx, struct gl_shader_program *prog, +ir_variable *output_var); + bool store(struct gl_shader_program *prog, + struct gl_transform_feedback_info *info, unsigned buffer) const; + + + /** +* True if assign_location() has been called for this object. +*/ + bool is_assigned() const + { + return this-location != -1; + } + + /** +* Determine whether this object refers to the variable var. +*/ + bool matches_var(ir_variable *var) const + { + return strcmp(var-name, this-var_name) == 0; + } + + /** +* The total number of varying components taken up by this variable. Only +* valid if is_assigned() is true. +*/ + unsigned num_components() const + { + return this-vector_elements * this-matrix_columns; + } + +private: + /** +* The name that was supplied to glTransformFeedbackVaryings. Used for +* error reporting. +*/ + const char *orig_name; + + /** +* The name of the variable, parsed from orig_name. +*/ + char *var_name; + + /** +* True if the declaration in orig_name represents an array. +*/ + bool is_array; + + /** +* If is_array is true, the array index that was specified in orig_name. +*/ + unsigned array_index; + + /** +* The vertex shader output location that the linker assigned for this +* variable. -1 if a location hasn't been assigned yet. +*/ + int location; + + /** +* If location != -1, the number of vector elements in this variable, or 1 +* if this variable is a scalar. +*/ + unsigned vector_elements; + + /** +* If location != -1, the number of matrix columns in this variable, or 1 +* if this variable is not a matrix. +*/ + unsigned matrix_columns; +}; + + +/** + * Initialize this object based on a string that was passed to + * glTransformFeedbackVaryings. If there is a parse error, the error is + * reported using linker_error(), and false is returned. + */ +bool +tfeedback_decl::init(struct gl_shader_program *prog, const void *mem_ctx, + const char *input) +{ + /* 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. +*/ + + this-location = -1; + this-orig_name = input; + + const char *bracket = strrchr(input, '['); + + if (bracket) { + this-var_name = ralloc_strndup(mem_ctx, input, bracket - input); + if (sscanf(bracket, [%u], this-array_index) == 1) { + this-is_array = true; + return true; + } + } else { + this-var_name = ralloc_strdup(mem_ctx, input); + this-is_array = false; + return true; + } + + linker_error(prog, Cannot parse transform feedback varying %s, input); + return false; +} + + +/** + * Determine whether two tfeedback_decl objects refer to the same variable and + * array index (if applicable). + */ +bool +tfeedback_decl::is_same(const tfeedback_decl x, const tfeedback_decl y) +{ + if (strcmp(x.var_name, y.var_name) != 0
Mesa (master): r200: remove dangling radeon.h symlink.
Module: Mesa Branch: master Commit: 01ccddbed6ff970e1018c250ba9044bf06671d25 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=01ccddbed6ff970e1018c250ba9044bf06671d25 Author: Paul Berry stereotype...@gmail.com Date: Tue Nov 8 07:50:56 2011 -0800 r200: remove dangling radeon.h symlink. Commit 1401b96b (radeon: cleanup radeon shared code after r300 and r600 classic drivers removal) removed the file src/mesa/drivers/dri/radeon/server/radeon.h, but it left behind the symlink which was used to share that file into the src/mesa/drivers/dri/r200/server directory. This patch removes the dangling symlink. Reviewed-by: Alex Deucher alexdeuc...@gmail.com --- src/mesa/drivers/dri/r200/server/radeon.h |1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/src/mesa/drivers/dri/r200/server/radeon.h b/src/mesa/drivers/dri/r200/server/radeon.h deleted file mode 12 index 81274a5..000 --- a/src/mesa/drivers/dri/r200/server/radeon.h +++ /dev/null @@ -1 +0,0 @@ -../../radeon/server/radeon.h \ No newline at end of file ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Track changes to transform feedback state.
Module: Mesa Branch: master Commit: a98ceee0ee3692783047c6f8f9f6bf6afbf4dd3b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a98ceee0ee3692783047c6f8f9f6bf6afbf4dd3b Author: Paul Berry stereotype...@gmail.com Date: Tue Nov 22 11:53:46 2011 -0800 mesa: Track changes to transform feedback state. This patch adds a new bit to the ctx-NewState bitfield, _NEW_TRANSFORM_FEEDBACK, to track state changes that affect ctx-TransformFeedback. This bit can be used by driver back-ends to avoid expensive recomputations when transform feedback state has not been modified. Reviewed-by: Kenneth Graunke kenn...@whitecape.org Reviewed-by: Eric Anholt e...@anholt.net --- src/mesa/main/mtypes.h|1 + src/mesa/main/transformfeedback.c |9 - 2 files changed, 9 insertions(+), 1 deletions(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 33b00c6..fc494f7 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3051,6 +3051,7 @@ struct gl_matrix_stack #define _NEW_PROGRAM_CONSTANTS (1 27) #define _NEW_BUFFER_OBJECT (1 28) #define _NEW_FRAG_CLAMP(1 29) +#define _NEW_TRANSFORM_FEEDBACK (1 30) /** gl_context::TransformFeedback */ #define _NEW_ALL ~0 /*@}*/ diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index 11abd03..799245d 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -376,6 +376,7 @@ _mesa_BeginTransformFeedback(GLenum mode) return; } + FLUSH_VERTICES(ctx, _NEW_TRANSFORM_FEEDBACK); obj-Active = GL_TRUE; ctx-TransformFeedback.Mode = mode; @@ -398,6 +399,7 @@ _mesa_EndTransformFeedback(void) return; } + FLUSH_VERTICES(ctx, _NEW_TRANSFORM_FEEDBACK); ctx-TransformFeedback.CurrentObject-Active = GL_FALSE; assert(ctx-Driver.EndTransformFeedback); @@ -415,6 +417,7 @@ bind_buffer_range(struct gl_context *ctx, GLuint index, { struct gl_transform_feedback_object *obj = ctx-TransformFeedback.CurrentObject; + FLUSH_VERTICES(ctx, _NEW_TRANSFORM_FEEDBACK); /* The general binding point */ _mesa_reference_buffer_object(ctx, @@ -650,7 +653,9 @@ _mesa_TransformFeedbackVaryings(GLuint program, GLsizei count, shProg-TransformFeedback.BufferMode = bufferMode; - /* The varyings won't be used until shader link time */ + /* No need to set _NEW_TRANSFORM_FEEDBACK (or invoke FLUSH_VERTICES) since +* the varyings won't be used until shader link time. +*/ } @@ -874,6 +879,7 @@ _mesa_PauseTransformFeedback(void) return; } + FLUSH_VERTICES(ctx, _NEW_TRANSFORM_FEEDBACK); obj-Paused = GL_TRUE; assert(ctx-Driver.PauseTransformFeedback); @@ -899,6 +905,7 @@ _mesa_ResumeTransformFeedback(void) return; } + FLUSH_VERTICES(ctx, _NEW_TRANSFORM_FEEDBACK); obj-Paused = GL_FALSE; assert(ctx-Driver.ResumeTransformFeedback); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965 gs: Remove unnecessary mapping of key-primitive.
Module: Mesa Branch: master Commit: fcae281f067f933d95734a932e66d3111d9f2192 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fcae281f067f933d95734a932e66d3111d9f2192 Author: Paul Berry stereotype...@gmail.com Date: Tue Nov 22 10:30:36 2011 -0800 i965 gs: Remove unnecessary mapping of key-primitive. Previously, GS generation code contained a lookup table that mapped primitive types POLYGON, TRISTRIP, and TRIFAN to TRILIST, mapped LINESTRIP to LINELIST, and left all other primitives unchanged. This was silly, because we never generate a GS program for those primitive types anyhow. This patch removes the unnecessary lookup table. Reviewed-by: Eric Anholt e...@anholt.net Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/brw_gs.c | 16 +--- src/mesa/drivers/dri/i965/brw_gs.h |7 ++- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c index 91f8d0b..e72ff5e 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.c +++ b/src/mesa/drivers/dri/i965/brw_gs.c @@ -122,20 +122,6 @@ static void compile_gs_prog( struct brw_context *brw, ralloc_free(mem_ctx); } -static const GLenum gs_prim[] = { - [_3DPRIM_POINTLIST] = _3DPRIM_POINTLIST, - [_3DPRIM_LINELIST] = _3DPRIM_LINELIST, - [_3DPRIM_LINELOOP] = _3DPRIM_LINELOOP, - [_3DPRIM_LINESTRIP] = _3DPRIM_LINELIST, - [_3DPRIM_TRILIST]= _3DPRIM_TRILIST, - [_3DPRIM_TRISTRIP] = _3DPRIM_TRILIST, - [_3DPRIM_TRIFAN] = _3DPRIM_TRILIST, - [_3DPRIM_QUADLIST] = _3DPRIM_QUADLIST, - [_3DPRIM_QUADSTRIP] = _3DPRIM_QUADSTRIP, - [_3DPRIM_POLYGON]= _3DPRIM_TRILIST, - [_3DPRIM_RECTLIST] = _3DPRIM_RECTLIST, -}; - static void populate_key( struct brw_context *brw, struct brw_gs_prog_key *key ) { @@ -148,7 +134,7 @@ static void populate_key( struct brw_context *brw, key-attrs = brw-vs.prog_data-outputs_written; /* BRW_NEW_PRIMITIVE */ - key-primitive = gs_prim[brw-primitive]; + key-primitive = brw-primitive; /* _NEW_LIGHT */ key-pv_first = (ctx-Light.ProvokingVertex == GL_FIRST_VERTEX_CONVENTION); diff --git a/src/mesa/drivers/dri/i965/brw_gs.h b/src/mesa/drivers/dri/i965/brw_gs.h index 0e4ff3f..12889a6 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.h +++ b/src/mesa/drivers/dri/i965/brw_gs.h @@ -41,7 +41,12 @@ struct brw_gs_prog_key { GLbitfield64 attrs; - GLuint primitive:8; /** Hardware primitive, such as _3DPRIM_TRILIST. */ + + /** +* Hardware primitive type being drawn, e.g. _3DPRIM_TRILIST. +*/ + GLuint primitive:8; + GLuint pv_first:1; GLuint need_gs_prog:1; GLuint userclip_active:1; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965: Set the maximum number of GS URB entries on Sandybridge.
Module: Mesa Branch: master Commit: 7a63a311e56fd492823b4b44e526df5a8dc0a021 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7a63a311e56fd492823b4b44e526df5a8dc0a021 Author: Kenneth Graunke kenn...@whitecape.org Date: Mon Nov 14 19:13:27 2011 -0800 i965: Set the maximum number of GS URB entries on Sandybridge. We never filled this in before because we didn't care. I'm skeptical these are correct; my sources indicate that both the VS and GS # of entries are 256 on both GT1 and GT2. I'm also loathe to change it and break stuff. Reviewed-by: Paul Berry stereotype...@gmail.com --- src/mesa/drivers/dri/i965/brw_context.c |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 1163007..f971649 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -284,12 +284,14 @@ brwCreateContext(int api, brw-max_gs_threads = 60; brw-urb.size = 64;/* volume 5c.5 section 5.1 */ brw-urb.max_vs_entries = 256; /* volume 2a (see 3DSTATE_URB) */ +brw-urb.max_gs_entries = 256; } else { brw-max_wm_threads = 40; brw-max_vs_threads = 24; brw-max_gs_threads = 21; /* conservative; 24 if rendering disabled */ brw-urb.size = 32;/* volume 5c.5 section 5.1 */ brw-urb.max_vs_entries = 128; /* volume 2a (see 3DSTATE_URB) */ +brw-urb.max_gs_entries = 256; } } else if (intel-gen == 5) { brw-urb.size = 1024; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965: Only convert if/else to conditional adds prior to Gen6 .
Module: Mesa Branch: master Commit: dabe15da4f81546b5c9fca8c208d31bfe98ada9f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=dabe15da4f81546b5c9fca8c208d31bfe98ada9f Author: Paul Berry stereotype...@gmail.com Date: Thu Nov 24 21:41:07 2011 -0800 i965: Only convert if/else to conditional adds prior to Gen6. Normally when outputting instructions in SPF (single program flow) mode, we convert IF and ELSE instructions to conditional ADD instructions applied to the IP register. On platforms prior to Gen6, flow control instructions cause an implied thread switch, so this is a significant savings. However, according to the SandyBridge PRM (Volume 4 part 2, p79): [Errata DevSNB{WA}] - When SPF is ON, IP may not be updated by non-flow control instructions. So we have to disable this optimization on Gen6. On later platforms, there is no significant benefit to converting flow control instructions to ADDs, so for the sake of consistency, this patch disables the optimization on later platforms too. The reason we never noticed this problem before is that so far we haven't needed to use SPF mode on Gen6. However, later patches in this series will introduce a Gen6 GS program which uses SPF mode. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/brw_eu_emit.c | 30 -- 1 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c index 9d8c701..a46a81b 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c @@ -1047,7 +1047,21 @@ patch_IF_ELSE(struct brw_compile *p, { struct intel_context *intel = p-brw-intel; - assert(!p-single_program_flow); + /* We shouldn't be patching IF and ELSE instructions in single program flow +* mode when gen 6, because in single program flow mode on those +* platforms, we convert flow control instructions to conditional ADDs that +* operate on IP (see brw_ENDIF). +* +* However, on Gen6, writing to IP doesn't work in single program flow mode +* (see the SandyBridge PRM, Volume 4 part 2, p79: When SPF is ON, IP may +* not be updated by non-flow control instructions.). And on later +* platforms, there is no significant benefit to converting control flow +* instructions to conditional ADDs. So we do patch IF and ELSE +* instructions in single program flow mode on those platforms. +*/ + if (intel-gen 6) + assert(!p-single_program_flow); + assert(if_inst != NULL if_inst-header.opcode == BRW_OPCODE_IF); assert(endif_inst != NULL); assert(else_inst == NULL || else_inst-header.opcode == BRW_OPCODE_ELSE); @@ -1161,7 +1175,19 @@ brw_ENDIF(struct brw_compile *p) } if_inst = p-if_stack[p-if_stack_depth]; - if (p-single_program_flow) { + /* In single program flow mode, we can express IF and ELSE instructions +* equivalently as ADD instructions that operate on IP. On platforms prior +* to Gen6, flow control instructions cause an implied thread switch, so +* this is a significant savings. +* +* However, on Gen6, writing to IP doesn't work in single program flow mode +* (see the SandyBridge PRM, Volume 4 part 2, p79: When SPF is ON, IP may +* not be updated by non-flow control instructions.). And on later +* platforms, there is no significant benefit to converting control flow +* instructions to conditional ADDs. So we only do this trick on Gen4 and +* Gen5. +*/ + if (intel-gen 6 p-single_program_flow) { /* ENDIF is useless; don't bother emitting it. */ convert_IF_ELSE_to_ADD(p, if_inst, else_inst); return; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965 gen6: Allocate URB space for GS
Module: Mesa Branch: master Commit: 43e39b58c705714c01919e5b4b5566e82e803d58 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=43e39b58c705714c01919e5b4b5566e82e803d58 Author: Paul Berry stereotype...@gmail.com Date: Wed Dec 7 09:56:42 2011 -0800 i965 gen6: Allocate URB space for GS When the GS is not in use, the entire URB space is available for the VS. When the GS is in use, we split the URB space 50/50. The 50/50 split is probably not optimal--we'll probably want tune this for performance in a future patch. For example, in most situations, it's probably worth allocating more than 50% of the space to the VS, since VS space is used for vertex caching. But for now this is good enough. Based on previous work by: Kenneth Graunke kenn...@whitecape.org Reviewed-by: Eric Anholt e...@anholt.net --- src/mesa/drivers/dri/i965/brw_context.c |1 + src/mesa/drivers/dri/i965/brw_context.h |5 ++ src/mesa/drivers/dri/i965/gen6_urb.c| 69 +- 3 files changed, 63 insertions(+), 12 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index f971649..faa02bf 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -293,6 +293,7 @@ brwCreateContext(int api, brw-urb.max_vs_entries = 128; /* volume 2a (see 3DSTATE_URB) */ brw-urb.max_gs_entries = 256; } + brw-urb.gen6_gs_previously_active = false; } else if (intel-gen == 5) { brw-urb.size = 1024; brw-max_vs_threads = 72; diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 171f3ef..70a45c7 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -708,6 +708,11 @@ struct brw_context GLuint sf_start; GLuint cs_start; GLuint size; /* Hardware URB size, in KB. */ + + /* gen6: True if the most recently sent _3DSTATE_URB message allocated + * URB space for the GS. + */ + bool gen6_gs_previously_active; } urb; diff --git a/src/mesa/drivers/dri/i965/gen6_urb.c b/src/mesa/drivers/dri/i965/gen6_urb.c index d045bf2..2d69cbe 100644 --- a/src/mesa/drivers/dri/i965/gen6_urb.c +++ b/src/mesa/drivers/dri/i965/gen6_urb.c @@ -31,35 +31,64 @@ #include brw_state.h #include brw_defines.h +/** + * When the GS is not in use, we assign the entire URB space to the VS. When + * the GS is in use, we split the URB space evenly between the VS and the GS. + * This is not ideal, but it's simple. + * + * URB size / 2 URB size / 2 + * _-__ _-__ + * /\ /\ + * +-+ + * | Vertex Shader Entries| Geometry Shader Entries | + * +-+ + * + * Sandybridge GT1 has 32kB of URB space, while GT2 has 64kB. + * (See the Sandybridge PRM, Volume 2, Part 1, Section 1.4.7: 3DSTATE_URB.) + */ static void gen6_upload_urb( struct brw_context *brw ) { struct intel_context *intel = brw-intel; - int nr_vs_entries; + int nr_vs_entries, nr_gs_entries; + int total_urb_size = brw-urb.size * 1024; /* in bytes */ /* CACHE_NEW_VS_PROG */ brw-urb.vs_size = MAX2(brw-vs.prog_data-urb_entry_size, 1); - /* Calculate how many VS URB entries fit in the total URB size */ - nr_vs_entries = (brw-urb.size * 1024) / (brw-urb.vs_size * 128); + /* We use the same VUE layout for VS outputs and GS outputs (as it's what +* the SF and Clipper expect), so we can simply make the GS URB entry size +* the same as for the VS. This may technically be too large in cases +* where we have few vertex attributes and a lot of varyings, since the VS +* size is determined by the larger of the two. For now, it's safe. +*/ + brw-urb.gs_size = brw-urb.vs_size; + + /* Calculate how many entries fit in each stage's section of the URB */ + if (brw-gs.prog_active) { + nr_vs_entries = (total_urb_size/2) / (brw-urb.vs_size * 128); + nr_gs_entries = (total_urb_size/2) / (brw-urb.gs_size * 128); + } else { + nr_vs_entries = total_urb_size / (brw-urb.vs_size * 128); + nr_gs_entries = 0; + } + /* Then clamp to the maximum allowed by the hardware */ if (nr_vs_entries brw-urb.max_vs_entries) nr_vs_entries = brw-urb.max_vs_entries; - /* According to volume 2a, nr_vs_entries must be a multiple of 4. */ - brw-urb.nr_vs_entries = ROUND_DOWN_TO(nr_vs_entries, 4); + if (nr_gs_entries brw-urb.max_gs_entries) + nr_gs_entries = brw-urb.max_gs_entries; - /* Since we currently don't support Geometry Shaders, we always put the -* GS unit in passthrough mode and don't allocate it any URB space. -*/ - brw-urb.nr_gs_entries = 0; - brw-urb.gs_size = 1
Mesa (master): i965 gs: Clean up dodgy register re-use, at the cost of a few MOVs.
Module: Mesa Branch: master Commit: 3f2283172bcaf3db00a99baad0319bc7e0be5fc2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3f2283172bcaf3db00a99baad0319bc7e0be5fc2 Author: Paul Berry stereotype...@gmail.com Date: Tue Nov 29 14:54:02 2011 -0800 i965 gs: Clean up dodgy register re-use, at the cost of a few MOVs. Prior to this patch, in the Gen4 and Gen5 GS, we used GRF 0 (called R0 in the code) as a staging area to prepare the message header for the FF_SYNC and URB_WRITE messages. This cleverly avoided an unnecessary MOV operation (since the initial value of GRF 0 contains data that needs to be included in the message header), but it made the code confusing, since GRF 0 could no longer be relied upon to contain its initial value once the GS started preparing its first message. This patch avoids confusion by using a separate register (header) as the staging area, at the cost of one MOV instruction. Worse yet, prior to this patch, the GS would completely overwrite the contents of GRF 0 with the writeback data it received from a completed FF_SYNC or URB_WRITE message. It did this because DWORD 0 of the writeback data contains the new URB handle, and that neds to be included in DWORD 0 of the next URB_WRITE message header. However, that caused the rest of the message header to be corrupted either with undefined data or zeros. Astonishingly, this did not produce any known failures (probably by dumb luck). However, it seems really dodgy--corrupting FFTID in particular seems likely to cause GPU hangs. This patch avoids the corruption by storing the writeback data in a temporary register and then copying just DWORD 0 to the header for the next message. This costs one extra MOV instruction per message sent, except for the final message. Also, this patch moves the logic for overriding DWORD 2 of the header (which contains PrimType, PrimStart, PrimEnd, and some other data that we don't care about yet). This logic is now in the function brw_gs_overwrite_header_dw2() rather than in brw_gs_emit_vue(). This saves one MOV instruction in brw_gs_quads() and brw_gs_quad_strip(), and paves the way for the Gen6 GS, which will need more complex logic to override DWORD 2 of the header. Finally, the function brw_gs_alloc_regs() contained a benign bug: it neglected to increment the register counter when allocating space for the temp register. This turned out not to have any effect because the temp register wasn't used on Gen4 and Gen5, the only hardware models (so far) to require a GS program. Now, all the registers allocated by brw_gs_alloc_regs() are actually used, and properly accounted for. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/brw_gs.h |1 + src/mesa/drivers/dri/i965/brw_gs_emit.c | 175 +++ 2 files changed, 111 insertions(+), 65 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_gs.h b/src/mesa/drivers/dri/i965/brw_gs.h index 12889a6..93448a7 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.h +++ b/src/mesa/drivers/dri/i965/brw_gs.h @@ -60,6 +60,7 @@ struct brw_gs_compile { struct { struct brw_reg R0; struct brw_reg vertex[MAX_GS_VERTS]; + struct brw_reg header; struct brw_reg temp; } reg; diff --git a/src/mesa/drivers/dri/i965/brw_gs_emit.c b/src/mesa/drivers/dri/i965/brw_gs_emit.c index e9875cd..6d39df1 100644 --- a/src/mesa/drivers/dri/i965/brw_gs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_gs_emit.c @@ -58,35 +58,66 @@ static void brw_gs_alloc_regs( struct brw_gs_compile *c, i += c-nr_regs; } - c-reg.temp = brw_vec8_grf(i, 0); + c-reg.header = retype(brw_vec8_grf(i++, 0), BRW_REGISTER_TYPE_UD); + c-reg.temp = retype(brw_vec8_grf(i++, 0), BRW_REGISTER_TYPE_UD); c-prog_data.urb_read_length = c-nr_regs; c-prog_data.total_grf = i; } +/** + * Set up the initial value of c-reg.header register based on c-reg.R0. + * + * The following information is passed to the GS thread in R0, and needs to be + * included in the first URB_WRITE or FF_SYNC message sent by the GS: + * + * - DWORD 0 [31:0] handle info (Gen4 only) + * - DWORD 5 [7:0] FFTID + * - DWORD 6 [31:0] Debug info + * - DWORD 7 [31:0] Debug info + * + * This function sets up the above data by copying by copying the contents of + * R0 to the header register. + */ +static void brw_gs_initialize_header(struct brw_gs_compile *c) +{ + struct brw_compile *p = c-func; + brw_MOV(p, c-reg.header, c-reg.R0); +} + +/** + * Overwrite DWORD 2 of c-reg.header with the given immediate unsigned value. + * + * In URB_WRITE messages, DWORD 2 contains the fields PrimType, PrimStart, + * PrimEnd, Increment CL_INVOCATIONS, and SONumPrimsWritten, many of which we + * need to be able to update on a per-vertex basis. + */ +static void brw_gs_overwrite_header_dw2(struct brw_gs_compile *c, +unsigned dw2) +{ + struct brw_compile *p = c-func; + brw_MOV(p
Mesa (master): i965: Clean up misleading defines for DWORD 2 of URB_WRITE header.
Module: Mesa Branch: master Commit: 2252e5e3f1e8caece5c73df82f3ddf306baa2c91 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2252e5e3f1e8caece5c73df82f3ddf306baa2c91 Author: Paul Berry stereotype...@gmail.com Date: Fri Dec 2 14:38:52 2011 -0800 i965: Clean up misleading defines for DWORD 2 of URB_WRITE header. R02_PRIM_END and R02_PRIM_START don't actually refer to bits in DWORD 2 of R0 (as the name, and comments in the code, would seem to indicate). Actually they refer to bits in DWORD 2 of the header for URB_WRITE messages. This patch renames the defines to reflect what they actually mean. It also addes a define URB_WRITE_PRIM_TYPE_SHIFT, which previously was just hardcoded in .c files. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/brw_clip_line.c |8 +++- src/mesa/drivers/dri/i965/brw_clip_tri.c | 11 -- src/mesa/drivers/dri/i965/brw_clip_unfilled.c | 12 +-- src/mesa/drivers/dri/i965/brw_defines.h |8 ++-- src/mesa/drivers/dri/i965/brw_gs_emit.c | 44 ++--- 5 files changed, 59 insertions(+), 24 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_clip_line.c b/src/mesa/drivers/dri/i965/brw_clip_line.c index 75c64c0..614849a 100644 --- a/src/mesa/drivers/dri/i965/brw_clip_line.c +++ b/src/mesa/drivers/dri/i965/brw_clip_line.c @@ -254,8 +254,12 @@ static void clip_and_emit_line( struct brw_clip_compile *c ) brw_clip_interp_vertex(c, newvtx0, vtx0, vtx1, c-reg.t0, false); brw_clip_interp_vertex(c, newvtx1, vtx1, vtx0, c-reg.t1, false); - brw_clip_emit_vue(c, newvtx0, 1, 0, (_3DPRIM_LINESTRIP 2) | R02_PRIM_START); - brw_clip_emit_vue(c, newvtx1, 0, 1, (_3DPRIM_LINESTRIP 2) | R02_PRIM_END); + brw_clip_emit_vue(c, newvtx0, 1, 0, +(_3DPRIM_LINESTRIP URB_WRITE_PRIM_TYPE_SHIFT) +| URB_WRITE_PRIM_START); + brw_clip_emit_vue(c, newvtx1, 0, 1, +(_3DPRIM_LINESTRIP URB_WRITE_PRIM_TYPE_SHIFT) +| URB_WRITE_PRIM_END); } brw_ENDIF(p); brw_clip_kill_thread(c); diff --git a/src/mesa/drivers/dri/i965/brw_clip_tri.c b/src/mesa/drivers/dri/i965/brw_clip_tri.c index ffbfe94..12d6724 100644 --- a/src/mesa/drivers/dri/i965/brw_clip_tri.c +++ b/src/mesa/drivers/dri/i965/brw_clip_tri.c @@ -422,14 +422,17 @@ void brw_clip_tri_emit_polygon(struct brw_clip_compile *c) brw_MOV(p, get_addr_reg(vptr), brw_address(c-reg.inlist)); brw_MOV(p, get_addr_reg(v0), deref_1uw(vptr, 0)); - brw_clip_emit_vue(c, v0, 1, 0, ((_3DPRIM_TRIFAN 2) | R02_PRIM_START)); + brw_clip_emit_vue(c, v0, 1, 0, +((_3DPRIM_TRIFAN URB_WRITE_PRIM_TYPE_SHIFT) + | URB_WRITE_PRIM_START)); brw_ADD(p, get_addr_reg(vptr), get_addr_reg(vptr), brw_imm_uw(2)); brw_MOV(p, get_addr_reg(v0), deref_1uw(vptr, 0)); loop = brw_DO(p, BRW_EXECUTE_1); { -brw_clip_emit_vue(c, v0, 1, 0, (_3DPRIM_TRIFAN 2)); +brw_clip_emit_vue(c, v0, 1, 0, + (_3DPRIM_TRIFAN URB_WRITE_PRIM_TYPE_SHIFT)); brw_ADD(p, get_addr_reg(vptr), get_addr_reg(vptr), brw_imm_uw(2)); brw_MOV(p, get_addr_reg(v0), deref_1uw(vptr, 0)); @@ -439,7 +442,9 @@ void brw_clip_tri_emit_polygon(struct brw_clip_compile *c) } brw_WHILE(p, loop); - brw_clip_emit_vue(c, v0, 0, 1, ((_3DPRIM_TRIFAN 2) | R02_PRIM_END)); + brw_clip_emit_vue(c, v0, 0, 1, +((_3DPRIM_TRIFAN URB_WRITE_PRIM_TYPE_SHIFT) + | URB_WRITE_PRIM_END)); } brw_ENDIF(p); } diff --git a/src/mesa/drivers/dri/i965/brw_clip_unfilled.c b/src/mesa/drivers/dri/i965/brw_clip_unfilled.c index ae84e19..01f14b0 100644 --- a/src/mesa/drivers/dri/i965/brw_clip_unfilled.c +++ b/src/mesa/drivers/dri/i965/brw_clip_unfilled.c @@ -321,8 +321,12 @@ static void emit_lines(struct brw_clip_compile *c, brw_imm_f(0)); brw_IF(p, BRW_EXECUTE_1); { -brw_clip_emit_vue(c, v0, 1, 0, (_3DPRIM_LINESTRIP 2) | R02_PRIM_START); -brw_clip_emit_vue(c, v1, 1, 0, (_3DPRIM_LINESTRIP 2) | R02_PRIM_END); +brw_clip_emit_vue(c, v0, 1, 0, + (_3DPRIM_LINESTRIP URB_WRITE_PRIM_TYPE_SHIFT) + | URB_WRITE_PRIM_START); +brw_clip_emit_vue(c, v1, 1, 0, + (_3DPRIM_LINESTRIP URB_WRITE_PRIM_TYPE_SHIFT) + | URB_WRITE_PRIM_END); } brw_ENDIF(p); @@ -363,7 +367,9 @@ static void emit_points(struct brw_clip_compile *c, if (do_offset) apply_one_offset(c, v0); -brw_clip_emit_vue(c, v0, 1, 0, (_3DPRIM_POINTLIST 2) | R02_PRIM_START | R02_PRIM_END); +brw_clip_emit_vue(c, v0, 1, 0, + (_3DPRIM_POINTLIST URB_WRITE_PRIM_TYPE_SHIFT
Mesa (master): i965 gen6: Implement pass-through GS for transform feedback.
Module: Mesa Branch: master Commit: d4976158c7f32705b48c773c3abd1b22bebe9c16 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d4976158c7f32705b48c773c3abd1b22bebe9c16 Author: Paul Berry stereotype...@gmail.com Date: Tue Nov 29 14:51:03 2011 -0800 i965 gen6: Implement pass-through GS for transform feedback. In Gen6, transform feedback is accomplished by having the geometry shader send vertex data to the data port using Streamed Vertex Buffer Write messages, while simultaneously passing vertices through to the rest of the graphics pipeline (if rendering is enabled). This patch adds a geometry shader program that simply passes vertices through to the rest of the graphics pipeline. The rest of transform feedback functionality will be added in future patches. To make the new geometry shader easier to test, I've added an environment variable INTEL_FORCE_GS. If this environment variable is enabled, then the pass-through geometry shader will always be used, regardless of whether transform feedback is in effect. On my Sandy Bridge laptop, I'm able to enable INTEL_FORCE_GS with no Piglit regressions. Reviewed-by: Kenneth Graunke kenn...@whitecape.org Acked-by: Eric Anholt e...@anholt.net --- src/mesa/drivers/dri/i965/brw_defines.h |3 + src/mesa/drivers/dri/i965/brw_eu.h|5 ++ src/mesa/drivers/dri/i965/brw_gs.c| 106 + src/mesa/drivers/dri/i965/brw_gs.h|2 + src/mesa/drivers/dri/i965/brw_gs_emit.c | 92 + src/mesa/drivers/dri/i965/gen6_gs_state.c | 46 - 6 files changed, 208 insertions(+), 46 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h index d949231..95039aa 100644 --- a/src/mesa/drivers/dri/i965/brw_defines.h +++ b/src/mesa/drivers/dri/i965/brw_defines.h @@ -1075,6 +1075,9 @@ enum brw_message_target { # define GEN6_GS_SVBI_POSTINCREMENT_VALUE_MASK INTEL_MASK(25, 16) # define GEN6_GS_ENABLE(1 15) +# define BRW_GS_EDGE_INDICATOR_0 (1 8) +# define BRW_GS_EDGE_INDICATOR_1 (1 9) + #define _3DSTATE_HS 0x781B /* GEN7+ */ #define _3DSTATE_TE 0x781C /* GEN7+ */ #define _3DSTATE_DS 0x781D /* GEN7+ */ diff --git a/src/mesa/drivers/dri/i965/brw_eu.h b/src/mesa/drivers/dri/i965/brw_eu.h index dcb1fc9..596be02 100644 --- a/src/mesa/drivers/dri/i965/brw_eu.h +++ b/src/mesa/drivers/dri/i965/brw_eu.h @@ -650,6 +650,11 @@ static INLINE struct brw_reg get_element_ud( struct brw_reg reg, GLuint elt ) return vec1(suboffset(retype(reg, BRW_REGISTER_TYPE_UD), elt)); } +static INLINE struct brw_reg get_element_d( struct brw_reg reg, GLuint elt ) +{ + return vec1(suboffset(retype(reg, BRW_REGISTER_TYPE_D), elt)); +} + static INLINE struct brw_reg brw_swizzle( struct brw_reg reg, GLuint x, diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c index e72ff5e..69ffa19 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.c +++ b/src/mesa/drivers/dri/i965/brw_gs.c @@ -53,12 +53,6 @@ static void compile_gs_prog( struct brw_context *brw, void *mem_ctx; GLuint program_size; - /* Gen6: VF has already converted into polygon, and LINELOOP is -* converted to LINESTRIP at the beginning of the 3D pipeline. -*/ - if (intel-gen = 6) - return; - memset(c, 0, sizeof(c)); c.key = *key; @@ -80,24 +74,60 @@ static void compile_gs_prog( struct brw_context *brw, */ brw_set_mask_control(c.func, BRW_MASK_DISABLE); - - /* Note that primitives which don't require a GS program have -* already been weeded out by this stage: -*/ - - switch (key-primitive) { - case _3DPRIM_QUADLIST: - brw_gs_quads( c, key ); - break; - case _3DPRIM_QUADSTRIP: - brw_gs_quad_strip( c, key ); - break; - case _3DPRIM_LINELOOP: - brw_gs_lines( c ); - break; - default: - ralloc_free(mem_ctx); - return; + if (intel-gen = 6) { + unsigned num_verts; + bool check_edge_flag; + /* On Sandybridge, we use the GS for implementing transform feedback + * (called Stream Out in the PRM). + */ + switch (key-primitive) { + case _3DPRIM_POINTLIST: + num_verts = 1; + check_edge_flag = false; +break; + case _3DPRIM_LINELIST: + case _3DPRIM_LINESTRIP: + case _3DPRIM_LINELOOP: + num_verts = 2; + check_edge_flag = false; +break; + case _3DPRIM_TRILIST: + case _3DPRIM_TRIFAN: + case _3DPRIM_TRISTRIP: + case _3DPRIM_RECTLIST: +num_verts = 3; + check_edge_flag = false; + break; + case _3DPRIM_QUADLIST: + case _3DPRIM_QUADSTRIP: + case _3DPRIM_POLYGON: + num_verts = 3
Mesa (master): mesa: Record transform feedback strides/ offsets in linker output.
Module: Mesa Branch: master Commit: 942d452047431f7463d3fad5e7cb92dfd81fd0ac URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=942d452047431f7463d3fad5e7cb92dfd81fd0ac Author: Paul Berry stereotype...@gmail.com Date: Tue Dec 6 14:16:59 2011 -0800 mesa: Record transform feedback strides/offsets in linker output. This patch adds two new fields to the gl_transform_feedback_info struct: - BufferStride records the total number of components (per vertex) that transform feedback is being instructed to store in each buffer. - Outputs[i].DstOffset records the offset within the interleaved structure of each transform feedback output. These values are needed by the i965 gen6 and r600g back-ends, so it seems better to have the linker provide them rather than force each back-end to compute them independently. Also, DstOffset helps pave the way for supporting ARB_transform_feedback3, which allows the transform feedback output to contain holes between attributes by specifying gl_SkipComponents{1,2,3,4} as the varying name. Reviewed-by: Marek Olšák mar...@gmail.com --- src/glsl/linker.cpp|5 - src/mesa/main/mtypes.h | 10 ++ 2 files changed, 14 insertions(+), 1 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index b8a7126..6587008 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1598,7 +1598,9 @@ tfeedback_decl::store(struct gl_shader_program *prog, info-Outputs[info-NumOutputs].OutputRegister = this-location + v; info-Outputs[info-NumOutputs].NumComponents = this-vector_elements; info-Outputs[info-NumOutputs].OutputBuffer = buffer; + info-Outputs[info-NumOutputs].DstOffset = info-BufferStride[buffer]; ++info-NumOutputs; + info-BufferStride[buffer] += this-vector_elements; } return true; } @@ -1863,7 +1865,8 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog, tfeedback_decl *tfeedback_decls) { unsigned total_tfeedback_components = 0; - prog-LinkedTransformFeedback.NumOutputs = 0; + memset(prog-LinkedTransformFeedback, 0, + sizeof(prog-LinkedTransformFeedback)); for (unsigned i = 0; i num_tfeedback_decls; ++i) { unsigned buffer = prog-TransformFeedback.BufferMode == GL_SEPARATE_ATTRIBS ? i : 0; diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 0e29dc0..93bf04e 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1821,7 +1821,17 @@ struct gl_transform_feedback_info { unsigned OutputRegister; unsigned OutputBuffer; unsigned NumComponents; + + /** offset (in DWORDs) of this output within the interleaved structure */ + unsigned DstOffset; } Outputs[MAX_PROGRAM_OUTPUTS]; + + /** +* Total number of components stored in each buffer. This may be used by +* hardware back-ends to determine the correct stride when interleaving +* multiple transform feedback outputs in the same buffer. +*/ + unsigned BufferStride[MAX_FEEDBACK_ATTRIBS]; }; /** ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Fix off-by-one error in transform feedback size check.
Module: Mesa Branch: master Commit: 38b118d49ddbc8bd5d96cc0d23d681887fca045e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=38b118d49ddbc8bd5d96cc0d23d681887fca045e Author: Paul Berry stereotype...@gmail.com Date: Thu Dec 8 11:23:22 2011 -0800 mesa: Fix off-by-one error in transform feedback size check. In _mesa_BindBufferRange(), we need to verify that the offset and size specified by the client do not exceed the size of the underlying buffer. We were accidentally doing this check using = rather than , so we were generating a bogus error if the client specified an offset and size that fit exactly in the underlying buffer. Reviewed-by: Brian Paul bri...@vmware.com Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/main/transformfeedback.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index 824f66a..b0b75ea 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -473,7 +473,7 @@ _mesa_BindBufferRange(GLenum target, GLuint index, return; } - if (offset + size = bufObj-Size) { + if (offset + size bufObj-Size) { _mesa_error(ctx, GL_INVALID_VALUE, glBindBufferRange(offset + size %d buffer size %d), (int) (offset + size), (int) (bufObj-Size)); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965 gen6+: Use 1-wide null operands for IF instructions
Module: Mesa Branch: master Commit: fd5d0c8b12a0e144aa8e95540c0da2161d8e089a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fd5d0c8b12a0e144aa8e95540c0da2161d8e089a Author: Paul Berry stereotype...@gmail.com Date: Mon Dec 5 13:52:16 2011 -0800 i965 gen6+: Use 1-wide null operands for IF instructions The Sandy Bridge PRM, volume 4, part 2, section 5.3.10 (5.3.10 Register Region Restrictions) contains the following restriction on the execution size and operand width of instructions: 3. ExecSize must be equal to or greater than Width. When emitting an IF instruction in single program flow mode on Gen6+, we use an ExecSize of 1, therefore the Width of each operand must also be 1. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/brw_eu_emit.c |8 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c index a46a81b..d48753c 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c @@ -941,11 +941,11 @@ brw_IF(struct brw_compile *p, GLuint execute_size) } else if (intel-gen == 6) { brw_set_dest(p, insn, brw_imm_w(0)); insn-bits1.branch_gen6.jump_count = 0; - brw_set_src0(p, insn, retype(brw_null_reg(), BRW_REGISTER_TYPE_D)); - brw_set_src1(p, insn, retype(brw_null_reg(), BRW_REGISTER_TYPE_D)); + brw_set_src0(p, insn, vec1(retype(brw_null_reg(), BRW_REGISTER_TYPE_D))); + brw_set_src1(p, insn, vec1(retype(brw_null_reg(), BRW_REGISTER_TYPE_D))); } else { - brw_set_dest(p, insn, retype(brw_null_reg(), BRW_REGISTER_TYPE_D)); - brw_set_src0(p, insn, retype(brw_null_reg(), BRW_REGISTER_TYPE_D)); + brw_set_dest(p, insn, vec1(retype(brw_null_reg(), BRW_REGISTER_TYPE_D))); + brw_set_src0(p, insn, vec1(retype(brw_null_reg(), BRW_REGISTER_TYPE_D))); brw_set_src1(p, insn, brw_imm_ud(0)); insn-bits3.break_cont.jip = 0; insn-bits3.break_cont.uip = 0; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965 gs: Move vue_map to brw_gs_compile.
Module: Mesa Branch: master Commit: 1413f955ebe213037a9d893e0b7391cac4ba3a57 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1413f955ebe213037a9d893e0b7391cac4ba3a57 Author: Paul Berry stereotype...@gmail.com Date: Wed Dec 7 07:14:56 2011 -0800 i965 gs: Move vue_map to brw_gs_compile. This patch stores the geometry shader VUE map from a local variable in compile_gs_prog() to a field in the brw_gs_compile struct, so that it will be available while compiling the geometry shader. This is necessary in order to support transform feedback on Gen6, because the Gen6 geometry shader code that supports transform feedback needs to be able to inspect the VUE map in order to find the correct vertex data to output. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/brw_gs.c |5 ++--- src/mesa/drivers/dri/i965/brw_gs.h |2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c index 69ffa19..f5d5898 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.c +++ b/src/mesa/drivers/dri/i965/brw_gs.c @@ -57,9 +57,8 @@ static void compile_gs_prog( struct brw_context *brw, c.key = *key; /* The geometry shader needs to access the entire VUE. */ - struct brw_vue_map vue_map; - brw_compute_vue_map(vue_map, intel, c.key.userclip_active, c.key.attrs); - c.nr_regs = (vue_map.num_slots + 1)/2; + brw_compute_vue_map(c.vue_map, intel, c.key.userclip_active, c.key.attrs); + c.nr_regs = (c.vue_map.num_slots + 1)/2; mem_ctx = NULL; diff --git a/src/mesa/drivers/dri/i965/brw_gs.h b/src/mesa/drivers/dri/i965/brw_gs.h index abcb0b2..ecab3ef 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.h +++ b/src/mesa/drivers/dri/i965/brw_gs.h @@ -66,6 +66,8 @@ struct brw_gs_compile { /* Number of registers used to store vertex data */ GLuint nr_regs; + + struct brw_vue_map vue_map; }; #define ATTR_SIZE (4*4) ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965 gen6: Initial implementation of transform feedback.
Module: Mesa Branch: master Commit: 9308f298300beaa757194a0db8ed50924754c011 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9308f298300beaa757194a0db8ed50924754c011 Author: Paul Berry stereotype...@gmail.com Date: Mon Nov 28 06:55:01 2011 -0800 i965 gen6: Initial implementation of transform feedback. This patch adds basic transform feedback capability for Gen6 hardware. This consists of several related pieces of functionality: (1) In gen6_sol.c, we set up binding table entries for use by transform feedback. We use one binding table entry per transform feedback varying (this allows us to avoid doing pointer arithmetic in the shader, since we can set up the binding table entries with the appropriate offsets and surface pitches to place each varying at the correct address). (2) In brw_context.c, we advertise the hardware capabilities, which are as follows: MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 64 MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS4 MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS16 OpenGL 3.0 requires these values to be at least 64, 4, and 4, respectively. The reason we advertise a larger value than required for MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS is that we have already set aside 64 binding table entries, so we might as well make them all available in both separate attribs and interleaved modes. (3) We set aside a single SVBI (streamed vertex buffer index) for use by transform feedback. The hardware supports four independent SVBI's, but we only need one, since vertices are added to all transform feedback buffers at the same rate. Note: at the moment this index is reset to 0 only when the driver is initialized. It needs to be reset to 0 whenever BeginTransformFeedback() is called, and otherwise preserved. (4) In brw_gs_emit.c and brw_gs.c, we modify the geometry shader program to output transform feedback data as a side effect. (5) In gen6_gs_state.c, we configure the geometry shader stage to handle the SVBI pointer correctly. Note: ordering of vertices is not yet correct for triangle strips (alternate triangles are improperly oriented). This will be addressed in a future patch. Reviewed-by: Kenneth Graunke kenn...@whitecape.org Reviewed-by: Eric Anholt e...@anholt.net --- src/mesa/drivers/dri/i965/Makefile.sources |1 + src/mesa/drivers/dri/i965/brw_context.c | 20 + src/mesa/drivers/dri/i965/brw_context.h | 47 +++- src/mesa/drivers/dri/i965/brw_defines.h |6 ++ src/mesa/drivers/dri/i965/brw_eu.h |7 ++ src/mesa/drivers/dri/i965/brw_eu_emit.c | 39 + src/mesa/drivers/dri/i965/brw_gs.c | 26 ++- src/mesa/drivers/dri/i965/brw_gs.h | 20 + src/mesa/drivers/dri/i965/brw_gs_emit.c | 93 - src/mesa/drivers/dri/i965/brw_misc_state.c |2 +- src/mesa/drivers/dri/i965/brw_state.h|1 + src/mesa/drivers/dri/i965/brw_state_upload.c |1 + src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 85 src/mesa/drivers/dri/i965/gen6_gs_state.c|8 ++- src/mesa/drivers/dri/i965/gen6_sol.c | 71 15 files changed, 417 insertions(+), 10 deletions(-) diff --git a/src/mesa/drivers/dri/i965/Makefile.sources b/src/mesa/drivers/dri/i965/Makefile.sources index cd6a8f4..e50f9c3 100644 --- a/src/mesa/drivers/dri/i965/Makefile.sources +++ b/src/mesa/drivers/dri/i965/Makefile.sources @@ -93,6 +93,7 @@ i965_C_SOURCES := \ gen6_sampler_state.c \ gen6_scissor_state.c \ gen6_sf_state.c \ +gen6_sol.c \ gen6_urb.c \ gen6_viewport_state.c \ gen6_vs_state.c \ diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 5e9cb1f..d8cad54 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -178,6 +178,26 @@ brwCreateContext(int api, ctx-Const.MaxTextureMaxAnisotropy = 16.0; + /* Hardware only supports a limited number of transform feedback buffers. +* So we need to override the Mesa default (which is based only on software +* limits). +*/ + ctx-Const.MaxTransformFeedbackSeparateAttribs = BRW_MAX_SOL_BUFFERS; + + /* On Gen6, in the worst case, we use up one binding table entry per +* transform feedback component (see comments above the definition of +* BRW_MAX_SOL_BINDINGS, in brw_context.h), so we need to advertise a value +* for MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS equal to +* BRW_MAX_SOL_BINDINGS. +* +* In separate components mode, we need to divide this value by +* BRW_MAX_SOL_BUFFERS, so that the total number of binding table entries +* used up by all buffers will not exceed BRW_MAX_SOL_BINDINGS. +*/ + ctx-Const.MaxTransformFeedbackInterleavedComponents = BRW_MAX_SOL_BINDINGS; + ctx
Mesa (master): i965 gen6: Turn on transform feedback extension.
Module: Mesa Branch: master Commit: 6ca61441b5cea8a2996c1adb4cc300a3c2be3ec9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6ca61441b5cea8a2996c1adb4cc300a3c2be3ec9 Author: Paul Berry stereotype...@gmail.com Date: Sat Nov 12 16:25:22 2011 -0800 i965 gen6: Turn on transform feedback extension. This patch advertises support for EXT_transform_feedback on Intel Gen6. Since transform feedback support is not completely finished yet, for now we only advertise support for it when MESA_GL_VERSION_OVERRIDE is 3.0 or greater (since transform feedback is required by GL version 3.0). Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/intel/intel_extensions.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_extensions.c b/src/mesa/drivers/dri/intel/intel_extensions.c index 2e2a31f..76954d1 100644 --- a/src/mesa/drivers/dri/intel/intel_extensions.c +++ b/src/mesa/drivers/dri/intel/intel_extensions.c @@ -104,6 +104,9 @@ intelInitExtensions(struct gl_context *ctx) ctx-Const.GLSLVersion = 120; _mesa_override_glsl_version(ctx); + if (intel-gen == 6 override_version = 30) + ctx-Extensions.EXT_transform_feedback = true; + if (intel-gen = 5) ctx-Extensions.EXT_timer_query = true; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965 gen6+: Make intel_batchbuffer_emit_mi_flush() actually flush.
Module: Mesa Branch: master Commit: c3161b629f342b21756f4fdb4414417b82d3e033 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c3161b629f342b21756f4fdb4414417b82d3e033 Author: Paul Berry stereotype...@gmail.com Date: Fri Dec 9 16:39:10 2011 -0800 i965 gen6+: Make intel_batchbuffer_emit_mi_flush() actually flush. Previous to this patch, the function intel_batchbuffer_emit_mi_flush() was a bit of a misnomer. On Gen4+, when not using the blit engine, it didn't actually flush the pipeline--it simply generated a PIPE_CONTROL command with the necessary bits set to flush GPU caches. This was usually sufficient, since in most situations where intel_batchbuffer_emit_mi_flush() was called, all we really care about was ensuring cache coherency. However, with the advent of OpenGL 3.0, there are two cases in which data output by one stage of the pipeline might be consumed, in a later draw operation, by an earlier stage of the pipeline: (a) When using textures in the vertex shader. (b) When using drawing with a vertex buffer that was previously generated using transform feedback. This patch addresses case (a) by changing intel_batchbuffer_emit_mi_flush() so that on Gen6+, it sets the PIPE_CONTROL_CS_STALL bit (this forces the pipeline to actually flush). (Case (b) will be addressed by the next patch in the series). This is not an ideal solution--in a perfect world, the driver would have some buffer dependency tracking so that we would only have to flush the pipeline in the two cases above. Until that dependency tracking is implemented, however, it seems prudent to have intel_batchbuffer_emit_mi_flush() actually flush the pipeline, so that we get correct rendering, at the expense of a (hopefully small) performance hit. The change is only applied to Gen6+, since at the moment only Gen6+ supports the OpenGL 3.0 features that make a full pipeline flush necessary. Reviewed-by: Kenneth Graunke kenn...@whitecape.org Reviewed-by: Eric Anholt e...@anholt.net --- src/mesa/drivers/dri/intel/intel_batchbuffer.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c index 6991db8..4ff098a 100644 --- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c @@ -461,7 +461,8 @@ intel_batchbuffer_emit_mi_flush(struct intel_context *intel) PIPE_CONTROL_WRITE_FLUSH | PIPE_CONTROL_DEPTH_CACHE_FLUSH | PIPE_CONTROL_TC_FLUSH | - PIPE_CONTROL_NO_WRITE); + PIPE_CONTROL_NO_WRITE | + PIPE_CONTROL_CS_STALL); OUT_BATCH(0); /* write address */ OUT_BATCH(0); /* write data */ ADVANCE_BATCH(); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965: Flush pipeline on EndTransformFeedback.
Module: Mesa Branch: master Commit: 63cf7fad13fc9cfdd2ae7b031426f79107000300 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=63cf7fad13fc9cfdd2ae7b031426f79107000300 Author: Paul Berry stereotype...@gmail.com Date: Fri Dec 9 16:40:32 2011 -0800 i965: Flush pipeline on EndTransformFeedback. A common use case for transform feedback is to perform one draw operation that writes transform feedback output to a buffer, followed by a second draw operation that consumes that buffer as vertex input. Since vertex input is consumed at an earlier pipeline stage than writing transform feedback output, we need to flush the pipeline to ensure that the transform feedback output is completely written before the data is consumed. In an ideal world, we would do some dependency tracking, so that we would only flush the pipeline if the next draw call was about to consume data generated by a previous draw call in the same batch. However, since we don't have that sort of dependency tracking infrastructure right now, we just unconditionally flush the buffer every time glEndTransformFeedback() is called. This will cause a performance hit compared to the ideal case (since we will sometimes flush the pipeline unnecessarily), but fortunately the performance hit will be confined to circumstances where transform feedback is in use. Reviewed-by: Kenneth Graunke kenn...@whitecape.org Reviewed-by: Eric Anholt e...@anholt.net --- src/mesa/drivers/dri/i965/brw_context.c |1 + src/mesa/drivers/dri/i965/brw_context.h |5 + src/mesa/drivers/dri/i965/gen6_sol.c| 16 3 files changed, 22 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index d8cad54..2096be9 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -117,6 +117,7 @@ static void brwInitDriverFunctions( struct dd_function_table *functions ) brw_init_queryobj_functions(functions); functions-PrepareExecBegin = brwPrepareExecBegin; + functions-EndTransformFeedback = brw_end_transform_feedback; } bool diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index febd4fe..6fa71a3 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -1076,6 +1076,11 @@ brw_update_sol_surface(struct brw_context *brw, bool brw_fprog_uses_noperspective(const struct gl_fragment_program *fprog); +/* gen6_sol.c */ +void +brw_end_transform_feedback(struct gl_context *ctx, + struct gl_transform_feedback_object *obj); + /*== diff --git a/src/mesa/drivers/dri/i965/gen6_sol.c b/src/mesa/drivers/dri/i965/gen6_sol.c index 491b39c..38aedcc 100644 --- a/src/mesa/drivers/dri/i965/gen6_sol.c +++ b/src/mesa/drivers/dri/i965/gen6_sol.c @@ -27,6 +27,7 @@ */ #include brw_context.h +#include intel_batchbuffer.h #include brw_defines.h static void @@ -69,3 +70,18 @@ const struct brw_tracked_state gen6_sol_surface = { }, .emit = gen6_update_sol_surfaces, }; + +void +brw_end_transform_feedback(struct gl_context *ctx, + struct gl_transform_feedback_object *obj) +{ + /* After EndTransformFeedback, it's likely that the client program will try +* to draw using the contents of the transform feedback buffer as vertex +* input. In order for this to work, we need to flush the data through at +* least the GS stage of the pipeline, and flush out the render cache. For +* simplicity, just do a full flush. +*/ + struct brw_context *brw = brw_context(ctx); + struct intel_context *intel = brw-intel; + intel_batchbuffer_emit_mi_flush(intel); +} ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965: Implement bounds checking for transform feedback output.
Module: Mesa Branch: master Commit: 21504b462acda4977c5fdfffc192e73273b8fb26 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=21504b462acda4977c5fdfffc192e73273b8fb26 Author: Kenneth Graunke kenn...@whitecape.org Date: Tue Dec 13 22:53:53 2011 -0800 i965: Implement bounds checking for transform feedback output. Signed-off-by: Kenneth Graunke kenn...@whitecape.org Reviewed-by: Paul Berry stereotype...@gmail.com --- src/mesa/drivers/dri/i965/brw_context.c |1 + src/mesa/drivers/dri/i965/brw_context.h |3 ++ src/mesa/drivers/dri/i965/brw_gs_emit.c | 10 src/mesa/drivers/dri/i965/gen6_sol.c| 38 +++ 4 files changed, 52 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 2096be9..f5c9d7a 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -117,6 +117,7 @@ static void brwInitDriverFunctions( struct dd_function_table *functions ) brw_init_queryobj_functions(functions); functions-PrepareExecBegin = brwPrepareExecBegin; + functions-BeginTransformFeedback = brw_begin_transform_feedback; functions-EndTransformFeedback = brw_end_transform_feedback; } diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 6fa71a3..e8ebea8 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -1078,6 +1078,9 @@ brw_fprog_uses_noperspective(const struct gl_fragment_program *fprog); /* gen6_sol.c */ void +brw_begin_transform_feedback(struct gl_context *ctx, GLenum mode, +struct gl_transform_feedback_object *obj); +void brw_end_transform_feedback(struct gl_context *ctx, struct gl_transform_feedback_object *obj); diff --git a/src/mesa/drivers/dri/i965/brw_gs_emit.c b/src/mesa/drivers/dri/i965/brw_gs_emit.c index 3062c33..269a495 100644 --- a/src/mesa/drivers/dri/i965/brw_gs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_gs_emit.c @@ -337,6 +337,15 @@ gen6_sol_program(struct brw_gs_compile *c, struct brw_gs_prog_key *key, */ brw_MOV(p, get_element_ud(c-reg.header, 5), get_element_ud(c-reg.SVBI, 0)); + + /* Make sure that the buffers have enough room for all the vertices. */ + brw_ADD(p, get_element_ud(c-reg.temp, 0), +get_element_ud(c-reg.SVBI, 0), brw_imm_ud(num_verts)); + brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_LE, +get_element_ud(c-reg.temp, 0), +get_element_ud(c-reg.SVBI, 4)); + brw_IF(p, BRW_EXECUTE_1); + /* For each vertex, generate code to output each varying using the * appropriate binding table entry. */ @@ -377,6 +386,7 @@ gen6_sol_program(struct brw_gs_compile *c, struct brw_gs_prog_key *key, get_element_ud(c-reg.header, 5), brw_imm_ud(1)); } } + brw_ENDIF(p); /* Now, reinitialize the header register from R0 to restore the parts of * the register that we overwrote while streaming out transform feedback diff --git a/src/mesa/drivers/dri/i965/gen6_sol.c b/src/mesa/drivers/dri/i965/gen6_sol.c index 38aedcc..2f2051b 100644 --- a/src/mesa/drivers/dri/i965/gen6_sol.c +++ b/src/mesa/drivers/dri/i965/gen6_sol.c @@ -26,6 +26,7 @@ * Code to initialize the binding table entries used by transform feedback. */ +#include main/macros.h #include brw_context.h #include intel_batchbuffer.h #include brw_defines.h @@ -72,6 +73,43 @@ const struct brw_tracked_state gen6_sol_surface = { }; void +brw_begin_transform_feedback(struct gl_context *ctx, GLenum mode, +struct gl_transform_feedback_object *obj) +{ + struct intel_context *intel = intel_context(ctx); + const struct gl_shader_program *vs_prog = + ctx-Shader.CurrentVertexProgram; + const struct gl_transform_feedback_info *linked_xfb_info = + vs_prog-LinkedTransformFeedback; + struct gl_transform_feedback_object *xfb_obj = + ctx-TransformFeedback.CurrentObject; + + unsigned max_index = 0x; + + /* Compute the maximum number of vertices that we can write without +* overflowing any of the buffers currently being used for feedback. +*/ + for (int i = 0; i BRW_MAX_SOL_BUFFERS; ++i) { + unsigned stride = linked_xfb_info-BufferStride[i]; + + /* Skip any inactive buffers, which have a stride of 0. */ + if (stride == 0) +continue; + + unsigned max_for_this_buffer = xfb_obj-Size[i] / (4 * stride); + max_index = MIN2(max_index, max_for_this_buffer); + } + + /* Initialize the SVBI 0 register to zero and set the maximum index. */ + BEGIN_BATCH(4); + OUT_BATCH(_3DSTATE_GS_SVB_INDEX 16 | (4 - 2)); + OUT_BATCH(0); /* SVBI 0 */ + OUT_BATCH(0); + OUT_BATCH(max_index); + ADVANCE_BATCH(); +} + +void
Mesa (master): i965 gen6: Implement rasterizer discard.
Module: Mesa Branch: master Commit: 7d2ff0bf0b7422c34676c2f47dbe754f57edb51e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7d2ff0bf0b7422c34676c2f47dbe754f57edb51e Author: Paul Berry stereotype...@gmail.com Date: Wed Dec 14 10:44:49 2011 -0800 i965 gen6: Implement rasterizer discard. This patch enables rasterizer discard functionality (a part of transform feedback) in Gen6, by generating an alternate GS program when rasterizer discard is active. Instead of forwarding vertices down the pipeline, the alternate GS program uses a URB Write message to deallocate the URB entry that was allocated by FF sync and terminate the thread. Note: parts of the Sandy Bridge PRM seem to imply that we could do this more efficiently, by clearing the GEN6_GS_RENDERING_ENABLE bit, and not allocating a URB entry at all. However, it's not clear how we are supposed to terminate the thread if we do that. Volume 2 part 1, section 4.5.4, says GS threads must terminate by sending a URB_WRITE message with the EOT and Complete bits set., and my experiments so far confirm that. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/brw_gs.c |6 ++ src/mesa/drivers/dri/i965/brw_gs.h |1 + src/mesa/drivers/dri/i965/brw_gs_emit.c | 30 ++ 3 files changed, 37 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c index 1e605ef..ee3f94c 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.c +++ b/src/mesa/drivers/dri/i965/brw_gs.c @@ -208,6 +208,12 @@ static void populate_key( struct brw_context *brw, linked_xfb_info-Outputs[i].OutputRegister; } } + /* On Gen6, GS is also used for rasterizer discard. */ + /* _NEW_TRANSFORM_FEEDBACK */ + if (ctx-TransformFeedback.RasterDiscard) { + key-need_gs_prog = true; + key-rasterizer_discard = true; + } } else { /* Pre-gen6, GS is used to transform QUADLIST, QUADSTRIP, and LINELOOP * into simpler primitives. diff --git a/src/mesa/drivers/dri/i965/brw_gs.h b/src/mesa/drivers/dri/i965/brw_gs.h index 33d8d7a..7bf2248 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.h +++ b/src/mesa/drivers/dri/i965/brw_gs.h @@ -50,6 +50,7 @@ struct brw_gs_prog_key { GLuint pv_first:1; GLuint need_gs_prog:1; GLuint userclip_active:1; + GLuint rasterizer_discard:1; /** * Number of varyings that are output to transform feedback. diff --git a/src/mesa/drivers/dri/i965/brw_gs_emit.c b/src/mesa/drivers/dri/i965/brw_gs_emit.c index 269a495..1f96a16 100644 --- a/src/mesa/drivers/dri/i965/brw_gs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_gs_emit.c @@ -193,6 +193,28 @@ static void brw_gs_emit_vue(struct brw_gs_compile *c, } /** + * De-allocate the URB entry that was previously allocated to this thread + * (without writing any vertex data to it), and terminate the thread. This is + * used to implement RASTERIZER_DISCARD functionality. + */ +static void brw_gs_terminate(struct brw_gs_compile *c) +{ + struct brw_compile *p = c-func; + brw_urb_WRITE(p, + retype(brw_null_reg(), BRW_REGISTER_TYPE_UD), /* dest */ + 0, /* msg_reg_nr */ + c-reg.header, /* src0 */ + false, /* allocate */ + false, /* used */ + 1, /* msg_length */ + 0, /* response_length */ + true, /* eot */ + true, /* writes_complete */ + 0, /* offset */ + BRW_URB_SWIZZLE_NONE); +} + +/** * Send an FF_SYNC message to ensure that all previously spawned GS threads * have finished sending primitives down the pipeline, and to allocate a URB * entry for the first output vertex. Only needed when intel-needs_ff_sync @@ -409,6 +431,14 @@ gen6_sol_program(struct brw_gs_compile *c, struct brw_gs_prog_key *key, brw_gs_ff_sync(c, 1); + /* If RASTERIZER_DISCARD is enabled, we have nothing further to do, so +* release the URB that was just allocated, and terminate the thread. +*/ + if (key-rasterizer_discard) { + brw_gs_terminate(c); + return; + } + brw_gs_overwrite_header_dw2_from_r0(c); switch (num_verts) { case 1: ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Remove unnecessary FLUSH_VERTICES in bind_buffer_range
Module: Mesa Branch: master Commit: 291ae4e6396872679fef72ed4fdd46fb7f945c3d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=291ae4e6396872679fef72ed4fdd46fb7f945c3d Author: Paul Berry stereotype...@gmail.com Date: Fri Dec 16 13:55:37 2011 -0800 mesa: Remove unnecessary FLUSH_VERTICES in bind_buffer_range It isn't necessary to call FLUSH_VERTICES from bind_buffer_range, because transform feedback buffers are not allowed to be changed when transform feedback is active. Thanks to Marek Olšák for pointing out this bug. Reviewed-by: Marek Olšák mar...@gmail.com --- src/mesa/main/transformfeedback.c |6 +- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index b0b75ea..53c09e2 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -404,7 +404,11 @@ bind_buffer_range(struct gl_context *ctx, GLuint index, { struct gl_transform_feedback_object *obj = ctx-TransformFeedback.CurrentObject; - FLUSH_VERTICES(ctx, _NEW_TRANSFORM_FEEDBACK); + + /* Note: no need to FLUSH_VERTICES or flag _NEW_TRANSFORM_FEEDBACK, because +* transform feedback buffers can't be changed while transform feedback is +* active. +*/ /* The general binding point */ _mesa_reference_buffer_object(ctx, ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Add count_tessellated_primitives() function.
Module: Mesa Branch: master Commit: dc7b6d7d6defdfe4f79fb682d3378a3bed8b5db9 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=dc7b6d7d6defdfe4f79fb682d3378a3bed8b5db9 Author: Paul Berry stereotype...@gmail.com Date: Mon Dec 19 11:47:14 2011 -0800 mesa: Add count_tessellated_primitives() function. This function computes the number of primitives that will be generated when the given drawing operation is performed. It accounts for the tessellation that is performed on line strips, line loops, triangle strips, triangle fans, quads, quad strips, and polygons, so it is suitable for implementing the primitive counters needed by transform feedback. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/vbo/vbo.h |3 ++ src/mesa/vbo/vbo_exec.c | 48 +++ 2 files changed, 51 insertions(+), 0 deletions(-) diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h index f357657..7384790 100644 --- a/src/mesa/vbo/vbo.h +++ b/src/mesa/vbo/vbo.h @@ -137,6 +137,9 @@ void vbo_check_buffers_are_unmapped(struct gl_context *ctx); void vbo_bind_arrays(struct gl_context *ctx); +size_t +count_tessellated_primitives(const struct _mesa_prim *prim); + void GLAPIENTRY _es_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a); diff --git a/src/mesa/vbo/vbo_exec.c b/src/mesa/vbo/vbo_exec.c index e8d5b39..05c3ec1 100644 --- a/src/mesa/vbo/vbo_exec.c +++ b/src/mesa/vbo/vbo_exec.c @@ -90,3 +90,51 @@ void vbo_exec_invalidate_state( struct gl_context *ctx, GLuint new_state ) _ae_invalidate_state(ctx, new_state); } + + +/** + * Figure out the number of transform feedback primitives that will be output + * by the given _mesa_prim command, assuming that no geometry shading is done + * and primitive restart is not used. + * + * This is intended for use by driver back-ends in implementing the + * PRIMITIVES_GENERATED and TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN queries. + */ +size_t +count_tessellated_primitives(const struct _mesa_prim *prim) +{ + size_t num_primitives; + switch (prim-mode) { + case GL_POINTS: + num_primitives = prim-count; + break; + case GL_LINE_STRIP: + num_primitives = prim-count = 2 ? prim-count - 1 : 0; + break; + case GL_LINE_LOOP: + num_primitives = prim-count = 2 ? prim-count : 0; + break; + case GL_LINES: + num_primitives = prim-count / 2; + break; + case GL_TRIANGLE_STRIP: + case GL_TRIANGLE_FAN: + case GL_POLYGON: + num_primitives = prim-count = 3 ? prim-count - 2 : 0; + break; + case GL_TRIANGLES: + num_primitives = prim-count / 3; + break; + case GL_QUAD_STRIP: + num_primitives = prim-count = 4 ? ((prim-count / 2) - 1) * 2 : 0; + break; + case GL_QUADS: + num_primitives = (prim-count / 4) * 2; + break; + default: + assert(!Unexpected primitive type in count_tessellated_primitives); + num_primitives = 0; + break; + } + return num_primitives * prim-num_instances; +} ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965 gen6: Ensure correct transform feedback indices on new batch.
Module: Mesa Branch: master Commit: f8328c998b4d68c62ba939165390c2c22c5b5740 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f8328c998b4d68c62ba939165390c2c22c5b5740 Author: Paul Berry stereotype...@gmail.com Date: Mon Dec 19 12:59:04 2011 -0800 i965 gen6: Ensure correct transform feedback indices on new batch. We don't currently have kernel support for saving GPU registers on a context switch, so if multiple processes are performing transform feedback at the same time, their SVBI registers will interfere with each other. To avoid this situation, we keep a software shadow of the state of the SVBI 0 register (which is the only register we use), and re-upload it on every new batch. The function that updates the shadow state of SVBI 0 is called brw_update_primitive_count, since it will also be used to update the counters for the PRIMITIVES_GENERATED and TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN queries. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/brw_context.h |7 + src/mesa/drivers/dri/i965/brw_draw.c | 33 ++ src/mesa/drivers/dri/i965/brw_state.h|1 + src/mesa/drivers/dri/i965/brw_state_upload.c |1 + src/mesa/drivers/dri/i965/gen6_sol.c | 38 - 5 files changed, 72 insertions(+), 8 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index e8ebea8..8840a83 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -145,6 +145,7 @@ enum brw_state_id { BRW_STATE_PROGRAM_CACHE, BRW_STATE_STATE_BASE_ADDRESS, BRW_STATE_HIZ, + BRW_STATE_SOL_INDICES, }; #define BRW_NEW_URB_FENCE (1 BRW_STATE_URB_FENCE) @@ -174,6 +175,7 @@ enum brw_state_id { #define BRW_NEW_PROGRAM_CACHE (1 BRW_STATE_PROGRAM_CACHE) #define BRW_NEW_STATE_BASE_ADDRESS (1 BRW_STATE_STATE_BASE_ADDRESS) #define BRW_NEW_HIZ(1 BRW_STATE_HIZ) +#define BRW_NEW_SOL_INDICES(1 BRW_STATE_SOL_INDICES) struct brw_state_flags { /** State update flags signalled by mesa internals */ @@ -983,6 +985,11 @@ struct brw_context struct gl_renderbuffer *depth_rb; } hiz; + struct brw_sol_state { + uint32_t svbi_0_starting_index; + uint32_t svbi_0_max_index; + } sol; + uint32_t render_target_format[MESA_FORMAT_COUNT]; bool format_supported_as_render_target[MESA_FORMAT_COUNT]; }; diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index 6627a48..774a5ca 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -33,10 +33,12 @@ #include main/samplerobj.h #include main/state.h #include main/enums.h +#include main/macros.h #include tnl/tnl.h #include vbo/vbo_context.h #include swrast/swrast.h #include swrast_setup/swrast_setup.h +#include drivers/common/meta.h #include brw_draw.h #include brw_defines.h @@ -377,6 +379,34 @@ static void brw_postdraw_set_buffers_need_resolve(struct brw_context *brw) } } +/** + * Update internal counters based on the the drawing operation described in + * prim. + */ +static void +brw_update_primitive_count(struct brw_context *brw, + const struct _mesa_prim *prim) +{ + uint32_t count = count_tessellated_primitives(prim); + if (brw-intel.ctx.TransformFeedback.CurrentObject-Active) { + /* Update brw-sol.svbi_0_max_index to reflect the amount by which the + * hardware is going to increment SVBI 0 when this drawing operation + * occurs. This is necessary because the kernel does not (yet) save and + * restore GPU registers when context switching, so we'll need to be + * able to reload SVBI 0 with the correct value in case we have to start + * a new batch buffer. + */ + unsigned svbi_postincrement_value = + brw-gs.prog_data-svbi_postincrement_value; + uint32_t space_avail = + (brw-sol.svbi_0_max_index - brw-sol.svbi_0_starting_index) + / svbi_postincrement_value; + uint32_t primitives_written = MIN2 (space_avail, count); + brw-sol.svbi_0_starting_index += + svbi_postincrement_value * primitives_written; + } +} + /* May fail if out of video memory for texture or vbo upload, or on * fallback conditions. */ @@ -498,6 +528,9 @@ retry: } } } + + if (!_mesa_meta_in_progress(ctx)) + brw_update_primitive_count(brw, prim[i]); } if (intel-always_flush_batch) diff --git a/src/mesa/drivers/dri/i965/brw_state.h b/src/mesa/drivers/dri/i965/brw_state.h index a3a470f..d271569 100644 --- a/src/mesa/drivers/dri/i965/brw_state.h +++ b/src/mesa/drivers/dri/i965/brw_state.h @@ -92,6 +92,7 @@ extern const struct brw_tracked_state gen6_gs_state; extern const struct brw_tracked_state gen6_renderbuffer_surfaces; extern const struct
Mesa (master): mesa: Add a function to query whether a meta-op is in progress.
Module: Mesa Branch: master Commit: 163611d7b21670de6074c09d37bdf93bad494036 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=163611d7b21670de6074c09d37bdf93bad494036 Author: Paul Berry stereotype...@gmail.com Date: Mon Dec 19 14:28:32 2011 -0800 mesa: Add a function to query whether a meta-op is in progress. This is needed by i965 to ensure that transform feedback counters are not incremented during meta-ops. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/common/meta.c | 10 ++ src/mesa/drivers/common/meta.h |3 +++ 2 files changed, 13 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 1683c85..c5c59eb 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -985,6 +985,16 @@ _mesa_meta_end(struct gl_context *ctx) /** + * Determine whether Mesa is currently in a meta state. + */ +GLboolean +_mesa_meta_in_progress(struct gl_context *ctx) +{ + return ctx-Meta-SaveStackDepth != 0; +} + + +/** * Convert Z from a normalized value in the range [0, 1] to an object-space * Z coordinate in [-1, +1] so that drawing at the new Z position with the * default/identity ortho projection results in the original Z value. diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h index 7198139..d13796e 100644 --- a/src/mesa/drivers/common/meta.h +++ b/src/mesa/drivers/common/meta.h @@ -69,6 +69,9 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state); extern void _mesa_meta_end(struct gl_context *ctx); +extern GLboolean +_mesa_meta_in_progress(struct gl_context *ctx); + extern void _mesa_meta_BlitFramebuffer(struct gl_context *ctx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965: Convert if/else to switch statements in brw_queryobj.c
Module: Mesa Branch: master Commit: c5e17a84983d7799fd842a62daaece3d97a670be URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c5e17a84983d7799fd842a62daaece3d97a670be Author: Paul Berry stereotype...@gmail.com Date: Mon Dec 19 11:53:52 2011 -0800 i965: Convert if/else to switch statements in brw_queryobj.c Previously, i965 only supported two query types: GL_TIME_ELAPSED_EXT and GL_SAMPLES_PASSED_ARB, and it distinguished between the two using if/else statements that compared query-Base.Target to GL_TIME_ELAPSED_EXT. This patch changes the if/else statements to switch statements so that we can add more query types without having to have a chain of else-ifs. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/brw_queryobj.c | 36 +- 1 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_queryobj.c b/src/mesa/drivers/dri/i965/brw_queryobj.c index 8875541..3ad522d 100644 --- a/src/mesa/drivers/dri/i965/brw_queryobj.c +++ b/src/mesa/drivers/dri/i965/brw_queryobj.c @@ -60,16 +60,24 @@ brw_queryobj_get_results(struct gl_context *ctx, drm_intel_bo_map(query-bo, false); results = query-bo-virtual; - if (query-Base.Target == GL_TIME_ELAPSED_EXT) { + switch (query-Base.Target) { + case GL_TIME_ELAPSED_EXT: if (intel-gen = 6) query-Base.Result += 80 * (results[1] - results[0]); else query-Base.Result += 1000 * ((results[1] 32) - (results[0] 32)); - } else { + break; + + case GL_SAMPLES_PASSED_ARB: /* Map and count the pixels from the current query BO */ for (i = query-first_index; i = query-last_index; i++) { query-Base.Result += results[i * 2 + 1] - results[i * 2]; } + break; + + default: + assert(!Unrecognized query target in brw_queryobj_get_results()); + break; } drm_intel_bo_unmap(query-bo); @@ -108,7 +116,8 @@ brw_begin_query(struct gl_context *ctx, struct gl_query_object *q) struct intel_context *intel = intel_context(ctx); struct brw_query_object *query = (struct brw_query_object *)q; - if (query-Base.Target == GL_TIME_ELAPSED_EXT) { + switch (query-Base.Target) { + case GL_TIME_ELAPSED_EXT: drm_intel_bo_unreference(query-bo); query-bo = drm_intel_bo_alloc(intel-bufmgr, timer query, 4096, 4096); @@ -136,7 +145,9 @@ brw_begin_query(struct gl_context *ctx, struct gl_query_object *q) OUT_BATCH(0); ADVANCE_BATCH(); } - } else { + break; + + case GL_SAMPLES_PASSED_ARB: /* Reset our driver's tracking of query state. */ drm_intel_bo_unreference(query-bo); query-bo = NULL; @@ -145,6 +156,11 @@ brw_begin_query(struct gl_context *ctx, struct gl_query_object *q) brw-query.obj = query; intel-stats_wm++; + break; + + default: + assert(!Unrecognized query target in brw_begin_query()); + break; } } @@ -158,7 +174,8 @@ brw_end_query(struct gl_context *ctx, struct gl_query_object *q) struct intel_context *intel = intel_context(ctx); struct brw_query_object *query = (struct brw_query_object *)q; - if (query-Base.Target == GL_TIME_ELAPSED_EXT) { + switch (query-Base.Target) { + case GL_TIME_ELAPSED_EXT: if (intel-gen = 6) { BEGIN_BATCH(4); OUT_BATCH(_3DSTATE_PIPE_CONTROL); @@ -184,7 +201,9 @@ brw_end_query(struct gl_context *ctx, struct gl_query_object *q) } intel_batchbuffer_flush(intel); - } else { + break; + + case GL_SAMPLES_PASSED_ARB: /* Flush the batchbuffer in case it has writes to our query BO. * Have later queries write to a new query BO so that further rendering * doesn't delay the collection of our results. @@ -200,6 +219,11 @@ brw_end_query(struct gl_context *ctx, struct gl_query_object *q) brw-query.obj = NULL; intel-stats_wm--; + break; + + default: + assert(!Unrecognized query target in brw_end_query()); + break; } } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965 gen6: Implement transform feedback queries.
Module: Mesa Branch: master Commit: c59393b7069f59ca2a13bfb6500f2a5360c38031 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c59393b7069f59ca2a13bfb6500f2a5360c38031 Author: Paul Berry stereotype...@gmail.com Date: Thu Dec 15 14:57:57 2011 -0800 i965 gen6: Implement transform feedback queries. This patch adds software-based PRIMITIVES_GENERATED and TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN queries that work by keeping track of the number of primitives that are sent down the pipeline, and adjusting as necessary to account for the way each primitive type is tessellated. In the long run we'll want to replace this with a hardware-based implementation, because the software approach won't work with geometry shaders or primitive restart. However, at the moment, we don't have the necessary kernel support to implement a hardware-based query (we would need the kernel to save GPU registers when context switching, so that drawing performed by another process doesn't get counted). Fixes Piglit tests EXT_transform_feedback/query-primitives_generated-* and EXT_transform_feedback/query-primitives-written-*. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/brw_context.h |2 + src/mesa/drivers/dri/i965/brw_draw.c |4 ++ src/mesa/drivers/dri/i965/brw_queryobj.c | 48 ++ 3 files changed, 54 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 8840a83..15a781b 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -988,6 +988,8 @@ struct brw_context struct brw_sol_state { uint32_t svbi_0_starting_index; uint32_t svbi_0_max_index; + uint32_t primitives_generated; + uint32_t primitives_written; } sol; uint32_t render_target_format[MESA_FORMAT_COUNT]; diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index 774a5ca..082bb9a 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -388,6 +388,7 @@ brw_update_primitive_count(struct brw_context *brw, const struct _mesa_prim *prim) { uint32_t count = count_tessellated_primitives(prim); + brw-sol.primitives_generated += count; if (brw-intel.ctx.TransformFeedback.CurrentObject-Active) { /* Update brw-sol.svbi_0_max_index to reflect the amount by which the * hardware is going to increment SVBI 0 when this drawing operation @@ -404,6 +405,9 @@ brw_update_primitive_count(struct brw_context *brw, uint32_t primitives_written = MIN2 (space_avail, count); brw-sol.svbi_0_starting_index += svbi_postincrement_value * primitives_written; + + /* And update the TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN query. */ + brw-sol.primitives_written += primitives_written; } } diff --git a/src/mesa/drivers/dri/i965/brw_queryobj.c b/src/mesa/drivers/dri/i965/brw_queryobj.c index 3ad522d..72b83f4 100644 --- a/src/mesa/drivers/dri/i965/brw_queryobj.c +++ b/src/mesa/drivers/dri/i965/brw_queryobj.c @@ -75,6 +75,14 @@ brw_queryobj_get_results(struct gl_context *ctx, } break; + case GL_PRIMITIVES_GENERATED: + case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: + /* We don't actually query the hardware for this value, so query-bo + * should always be NULL and execution should never reach here. + */ + assert(!Unreachable); + break; + default: assert(!Unrecognized query target in brw_queryobj_get_results()); break; @@ -158,6 +166,20 @@ brw_begin_query(struct gl_context *ctx, struct gl_query_object *q) intel-stats_wm++; break; + case GL_PRIMITIVES_GENERATED: + /* We don't actually query the hardware for this value; we keep track of + * it a software counter. So just reset the counter. + */ + brw-sol.primitives_generated = 0; + break; + + case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: + /* We don't actually query the hardware for this value; we keep track of + * it a software counter. So just reset the counter. + */ + brw-sol.primitives_written = 0; + break; + default: assert(!Unrecognized query target in brw_begin_query()); break; @@ -221,6 +243,32 @@ brw_end_query(struct gl_context *ctx, struct gl_query_object *q) intel-stats_wm--; break; + case GL_PRIMITIVES_GENERATED: + /* We don't actually query the hardware for this value; we keep track of + * it in a software counter. So just read the counter and store it in + * the query object. + */ + query-Base.Result = brw-sol.primitives_generated; + + /* And set brw-query.obj to NULL so that this query won't try to wait + * for any rendering to complete. + */ + query-bo = NULL; + break; + + case
Mesa (master): i965 gen6: Turn on transform feedback extension unconditionally.
Module: Mesa Branch: master Commit: 3a2e71874b630fe5d7ec36bbbd69a6dacab7cd15 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3a2e71874b630fe5d7ec36bbbd69a6dacab7cd15 Author: Paul Berry stereotype...@gmail.com Date: Mon Dec 19 15:15:49 2011 -0800 i965 gen6: Turn on transform feedback extension unconditionally. Previously, we only enabled transform feedback when MESA_GL_VERSION_OVERRIDE was 3.0 or greater, since transform feedback support was not completely finished, so it didn't make sense to advertise support for it unless absolutely necessary. Now that transform feedback is fully implemented on gen6, we can enable this extension unconditionally. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/intel/intel_extensions.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_extensions.c b/src/mesa/drivers/dri/intel/intel_extensions.c index 76954d1..7ab5d90 100644 --- a/src/mesa/drivers/dri/intel/intel_extensions.c +++ b/src/mesa/drivers/dri/intel/intel_extensions.c @@ -104,7 +104,7 @@ intelInitExtensions(struct gl_context *ctx) ctx-Const.GLSLVersion = 120; _mesa_override_glsl_version(ctx); - if (intel-gen == 6 override_version = 30) + if (intel-gen == 6) ctx-Extensions.EXT_transform_feedback = true; if (intel-gen = 5) ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Move RasterDiscard to toplevel of gl_context.
Module: Mesa Branch: master Commit: aee96806f049c17384a8edc11acce76257d98a57 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=aee96806f049c17384a8edc11acce76257d98a57 Author: Paul Berry stereotype...@gmail.com Date: Tue Dec 20 16:18:39 2011 -0800 mesa: Move RasterDiscard to toplevel of gl_context. Previously we were storing the RasterDiscard flag (for GL_RASTERIZER_DISCARD) in gl_context::TransformFeedback. This was confusing, because we use the _NEW_TRANSFORM flag (not _NEW_TRANSFORM_FEEDBACK) to track state updates to it, and because rasterizer discard has effects even when transform feedback is not in use. This patch makes RasterDiscard a toplevel element in gl_context rather than a subfield of gl_context::TransformFeedback. Note: We can't put RasterDiscard inside gl_context::Transform, since all items inside gl_context::Transform need to be pieces of state that are saved and restored using PushAttrib and PopAttrib. Reviewed-by: Kenneth Graunke kenn...@whitecape.org Reviewed-by: Ian Romanick ian.d.roman...@intel.com Reviewed-by: Marek Olšák mar...@gmail.com --- src/mesa/drivers/dri/i965/brw_gs.c |2 +- src/mesa/main/accum.c |2 +- src/mesa/main/clear.c | 14 +++--- src/mesa/main/drawpix.c |6 +++--- src/mesa/main/enable.c |6 +++--- src/mesa/main/get.c |2 +- src/mesa/main/mtypes.h |4 ++-- src/mesa/state_tracker/st_atom_rasterizer.c |2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c index ee3f94c..2495ad5 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.c +++ b/src/mesa/drivers/dri/i965/brw_gs.c @@ -210,7 +210,7 @@ static void populate_key( struct brw_context *brw, } /* On Gen6, GS is also used for rasterizer discard. */ /* _NEW_TRANSFORM_FEEDBACK */ - if (ctx-TransformFeedback.RasterDiscard) { + if (ctx-RasterDiscard) { key-need_gs_prog = true; key-rasterizer_discard = true; } diff --git a/src/mesa/main/accum.c b/src/mesa/main/accum.c index eb06bbb..a8c30c2 100644 --- a/src/mesa/main/accum.c +++ b/src/mesa/main/accum.c @@ -100,7 +100,7 @@ _mesa_Accum( GLenum op, GLfloat value ) return; } - if (ctx-TransformFeedback.RasterDiscard) + if (ctx-RasterDiscard) return; if (ctx-RenderMode == GL_RENDER) { diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c index 2e27c95..bd5c012 100644 --- a/src/mesa/main/clear.c +++ b/src/mesa/main/clear.c @@ -200,7 +200,7 @@ _mesa_Clear( GLbitfield mask ) ctx-DrawBuffer-_Ymin = ctx-DrawBuffer-_Ymax) return; - if (ctx-TransformFeedback.RasterDiscard) + if (ctx-RasterDiscard) return; if (ctx-RenderMode == GL_RENDER) { @@ -338,7 +338,7 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value) drawbuffer); return; } - else if (!ctx-TransformFeedback.RasterDiscard) { + else if (!ctx-RasterDiscard) { /* Save current stencil clear value, set to 'value', do the * stencil clear and restore the clear value. * XXX in the future we may have a new ctx-Driver.ClearBuffer() @@ -362,7 +362,7 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value) drawbuffer); return; } - else if (mask !ctx-TransformFeedback.RasterDiscard) { + else if (mask !ctx-RasterDiscard) { union gl_color_union clearSave; /* save color */ @@ -432,7 +432,7 @@ _mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value) drawbuffer); return; } - else if (mask !ctx-TransformFeedback.RasterDiscard) { + else if (mask !ctx-RasterDiscard) { union gl_color_union clearSave; /* save color */ @@ -513,7 +513,7 @@ _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value) drawbuffer); return; } - else if (!ctx-TransformFeedback.RasterDiscard) { + else if (!ctx-RasterDiscard) { /* Save current depth clear value, set to 'value', do the * depth clear and restore the clear value. * XXX in the future we may have a new ctx-Driver.ClearBuffer() @@ -538,7 +538,7 @@ _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value) drawbuffer); return; } - else if (mask !ctx-TransformFeedback.RasterDiscard) { + else if (mask !ctx-RasterDiscard) { union gl_color_union clearSave; /* save color */ @@ -615,7 +615,7 @@ _mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer, return; } - if (ctx
Mesa (master): mesa: Add _NEW_RASTERIZER_DISCARD as synonym for _NEW_TRANSFORM.
Module: Mesa Branch: master Commit: d44878e754e65550c0725feb76fe0cbab0ae5d93 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d44878e754e65550c0725feb76fe0cbab0ae5d93 Author: Paul Berry stereotype...@gmail.com Date: Tue Dec 20 16:23:17 2011 -0800 mesa: Add _NEW_RASTERIZER_DISCARD as synonym for _NEW_TRANSFORM. This makes it easier to keep track of which dirty bits correspond to which pieces of context, since it makes _NEW_RASTERIZER_DISCARD correspond with ctx-RasterDiscard. Reviewed-by: Kenneth Graunke kenn...@whitecape.org Reviewed-by: Ian Romanick ian.d.roman...@intel.com Reviewed-by: Marek Olšák mar...@gmail.com --- src/mesa/drivers/dri/i965/brw_gs.c |5 +++-- src/mesa/main/enable.c |2 +- src/mesa/main/mtypes.h |6 ++ src/mesa/state_tracker/st_atom_rasterizer.c |4 ++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c index 2495ad5..886bf98 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.c +++ b/src/mesa/drivers/dri/i965/brw_gs.c @@ -209,7 +209,7 @@ static void populate_key( struct brw_context *brw, } } /* On Gen6, GS is also used for rasterizer discard. */ - /* _NEW_TRANSFORM_FEEDBACK */ + /* _NEW_RASTERIZER_DISCARD */ if (ctx-RasterDiscard) { key-need_gs_prog = true; key-rasterizer_discard = true; @@ -258,7 +258,8 @@ const struct brw_tracked_state brw_gs_prog = { .dirty = { .mesa = (_NEW_LIGHT | _NEW_TRANSFORM | -_NEW_TRANSFORM_FEEDBACK), +_NEW_TRANSFORM_FEEDBACK | +_NEW_RASTERIZER_DISCARD), .brw = BRW_NEW_PRIMITIVE, .cache = CACHE_NEW_VS_PROG }, diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 749ae98..270b240 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -890,7 +890,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) case GL_RASTERIZER_DISCARD: CHECK_EXTENSION(EXT_transform_feedback, cap); if (ctx-RasterDiscard != state) { -FLUSH_VERTICES(ctx, _NEW_TRANSFORM); +FLUSH_VERTICES(ctx, _NEW_RASTERIZER_DISCARD); ctx-RasterDiscard = state; } break; diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index ff97ea9..3d3b006 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3073,6 +3073,12 @@ struct gl_matrix_stack #define _NEW_FRAG_CLAMP(1 29) #define _NEW_TRANSFORM_FEEDBACK (1 30) /** gl_context::TransformFeedback */ #define _NEW_ALL ~0 + +/** + * We use _NEW_TRANSFORM for GL_RASTERIZER_DISCARD. This #define is for + * clarity. + */ +#define _NEW_RASTERIZER_DISCARD _NEW_TRANSFORM /*@}*/ diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index 7ebc872..2d6ad45 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -258,7 +258,7 @@ static void update_raster_state( struct st_context *st ) raster-clamp_fragment_color = ctx-Color._ClampFragmentColor; raster-gl_rasterization_rules = 1; - /* _NEW_TRANSFORM */ + /* _NEW_RASTERIZER_DISCARD */ raster-rasterizer_discard = ctx-RasterDiscard; cso_set_rasterizer(st-cso_context, raster); @@ -276,7 +276,7 @@ const struct st_tracked_state st_update_rasterizer = { _NEW_PROGRAM | _NEW_SCISSOR | _NEW_FRAG_CLAMP | - _NEW_TRANSFORM), /* mesa state dependencies*/ + _NEW_RASTERIZER_DISCARD), /* mesa state dependencies*/ ST_NEW_VERTEX_PROGRAM, /* state tracker dependencies */ }, update_raster_state /* update function */ ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Save and restore GL_RASTERIZER_DISCARD state during meta ops.
Module: Mesa Branch: master Commit: a3a4d01e415404e1bab76d440466952f4ab6171b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a3a4d01e415404e1bab76d440466952f4ab6171b Author: Paul Berry stereotype...@gmail.com Date: Wed Dec 21 10:13:40 2011 -0800 mesa: Save and restore GL_RASTERIZER_DISCARD state during meta ops. During meta-operations (such as _mesa_meta_GenerateMipmap()), we need to be able to draw even if GL_RASTERIZER_DISCARD is enabled. This patch causes _mesa_meta_begin() to save the state of GL_RASTERIZER_DISCARD and disable it (so that drawing can be done during the meta-op), and causes _mesa_meta_end() to restore it. Fixes piglit test EXT_transform_feedback/generatemipmap discard on i965 Gen6. Reviewed-by: Brian Paul bri...@vmare.com Reviewed-by: Eric Anholt e...@anholt.net Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/common/meta.c |7 +++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index c5c59eb..144fa12 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -180,6 +180,7 @@ struct save_state /** Miscellaneous (always disabled) */ GLboolean Lighting; + GLboolean RasterDiscard; }; /** @@ -702,6 +703,9 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) save-Lighting = ctx-Light.Enabled; if (ctx-Light.Enabled) _mesa_set_enable(ctx, GL_LIGHTING, GL_FALSE); + save-RasterDiscard = ctx-RasterDiscard; + if (ctx-RasterDiscard) + _mesa_set_enable(ctx, GL_RASTERIZER_DISCARD, GL_FALSE); } } @@ -981,6 +985,9 @@ _mesa_meta_end(struct gl_context *ctx) if (save-Lighting) { _mesa_set_enable(ctx, GL_LIGHTING, GL_TRUE); } + if (save-RasterDiscard) { + _mesa_set_enable(ctx, GL_RASTERIZER_DISCARD, GL_TRUE); + } } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Ensure that Paused is reset to false on EndTransformFeedback.
Module: Mesa Branch: master Commit: 08ce48733d9441e1daa779027dbea1ce9964cc77 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=08ce48733d9441e1daa779027dbea1ce9964cc77 Author: Paul Berry stereotype...@gmail.com Date: Wed Dec 21 11:02:50 2011 -0800 mesa: Ensure that Paused is reset to false on EndTransformFeedback. If a client calls BeginTransformFeedback(), then PauseTransformFeedback(), then EndTransformFeedback(), we need to make sure that the transform feedback object is not left in a paused state, otherwise the next call to BeginTransformFeedback() will leave transform feedback paused. Reviewed-by: Brian Paul bri...@vmare.com Reviewed-by: Eric Anholt e...@anholt.net Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/main/transformfeedback.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index 53c09e2..fea711a 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -387,6 +387,7 @@ _mesa_EndTransformFeedback(void) FLUSH_VERTICES(ctx, _NEW_TRANSFORM_FEEDBACK); ctx-TransformFeedback.CurrentObject-Active = GL_FALSE; + ctx-TransformFeedback.CurrentObject-Paused = GL_FALSE; ctx-TransformFeedback.CurrentObject-EndedAnytime = GL_TRUE; assert(ctx-Driver.EndTransformFeedback); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Disable certain error checks when transform feedback is paused
Module: Mesa Branch: master Commit: 87c7e5fb876bf280d8693ef3b0f4351b1d2eec3b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=87c7e5fb876bf280d8693ef3b0f4351b1d2eec3b Author: Paul Berry stereotype...@gmail.com Date: Wed Dec 21 11:03:11 2011 -0800 mesa: Disable certain error checks when transform feedback is paused When transform feedback is paused, it is legal to change programs or to perform drawing operations using a drawing mode that doesn't match the transform feedback mode. Reviewed-by: Brian Paul bri...@vmare.com Reviewed-by: Eric Anholt e...@anholt.net Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/main/shaderapi.c |5 +++-- src/mesa/main/transformfeedback.c |3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index c4d01ab..b71b44b 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1436,7 +1436,7 @@ _mesa_UseProgramObjectARB(GLhandleARB program) ASSERT_OUTSIDE_BEGIN_END(ctx); - if (obj-Active) { + if (obj-Active !obj-Paused) { _mesa_error(ctx, GL_INVALID_OPERATION, glUseProgram(transform feedback active)); return; @@ -1638,7 +1638,8 @@ _mesa_UseShaderProgramEXT(GLenum type, GLuint program) return; } - if (ctx-TransformFeedback.CurrentObject-Active) { + if (ctx-TransformFeedback.CurrentObject-Active + !ctx-TransformFeedback.CurrentObject-Paused) { _mesa_error(ctx, GL_INVALID_OPERATION, glUseShaderProgramEXT(transform feedback is active)); return; diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index fea711a..be0d0ff 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -98,7 +98,8 @@ reference_transform_feedback_object(struct gl_transform_feedback_object **ptr, GLboolean _mesa_validate_primitive_mode(struct gl_context *ctx, GLenum mode) { - if (ctx-TransformFeedback.CurrentObject-Active) { + if (ctx-TransformFeedback.CurrentObject-Active + !ctx-TransformFeedback.CurrentObject-Paused) { switch (mode) { case GL_POINTS: return ctx-TransformFeedback.Mode == GL_POINTS; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965 gen6: Implement transform feedback pause/ resume functionality.
Module: Mesa Branch: master Commit: 772d4fef42d79c5efb3a7eb255ff0e1fdb88ada3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=772d4fef42d79c5efb3a7eb255ff0e1fdb88ada3 Author: Paul Berry stereotype...@gmail.com Date: Wed Dec 21 11:04:21 2011 -0800 i965 gen6: Implement transform feedback pause/resume functionality. Although i965 gen6 does not yet support ARB_transform_feedback2 or NV_transform_feedback2, it needs to support pause/resume functionality so that meta-ops will work correctly. Reviewed-by: Eric Anholt e...@anholt.net Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/brw_draw.c |3 ++- src/mesa/drivers/dri/i965/brw_gs.c |3 ++- src/mesa/drivers/dri/i965/gen6_sol.c |3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index 082bb9a..93f27d7 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -389,7 +389,8 @@ brw_update_primitive_count(struct brw_context *brw, { uint32_t count = count_tessellated_primitives(prim); brw-sol.primitives_generated += count; - if (brw-intel.ctx.TransformFeedback.CurrentObject-Active) { + if (brw-intel.ctx.TransformFeedback.CurrentObject-Active + !brw-intel.ctx.TransformFeedback.CurrentObject-Paused) { /* Update brw-sol.svbi_0_max_index to reflect the amount by which the * hardware is going to increment SVBI 0 when this drawing operation * occurs. This is necessary because the kernel does not (yet) save and diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c index 886bf98..850d7b4 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.c +++ b/src/mesa/drivers/dri/i965/brw_gs.c @@ -183,7 +183,8 @@ static void populate_key( struct brw_context *brw, } else if (intel-gen == 6) { /* On Gen6, GS is used for transform feedback. */ /* _NEW_TRANSFORM_FEEDBACK */ - if (ctx-TransformFeedback.CurrentObject-Active) { + if (ctx-TransformFeedback.CurrentObject-Active + !ctx-TransformFeedback.CurrentObject-Paused) { const struct gl_shader_program *shaderprog = ctx-Shader.CurrentVertexProgram; const struct gl_transform_feedback_info *linked_xfb_info = diff --git a/src/mesa/drivers/dri/i965/gen6_sol.c b/src/mesa/drivers/dri/i965/gen6_sol.c index 5d11481..32f56d3 100644 --- a/src/mesa/drivers/dri/i965/gen6_sol.c +++ b/src/mesa/drivers/dri/i965/gen6_sol.c @@ -47,7 +47,8 @@ gen6_update_sol_surfaces(struct brw_context *brw) for (i = 0; i BRW_MAX_SOL_BINDINGS; ++i) { const int surf_index = SURF_INDEX_SOL_BINDING(i); - if (xfb_obj-Active i linked_xfb_info-NumOutputs) { + if (xfb_obj-Active !xfb_obj-Paused + i linked_xfb_info-NumOutputs) { unsigned buffer = linked_xfb_info-Outputs[i].OutputBuffer; unsigned buffer_offset = xfb_obj-Offset[buffer] / 4 + ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Pause transform feedback during meta ops.
Module: Mesa Branch: master Commit: cb045880b113b0042d8dfb7e4cdf76e6cc76c1d1 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cb045880b113b0042d8dfb7e4cdf76e6cc76c1d1 Author: Paul Berry stereotype...@gmail.com Date: Wed Dec 21 11:08:51 2011 -0800 mesa: Pause transform feedback during meta ops. Fixes piglit tests EXT_transform_feedback/generatemipmap buffer and EXT_transform_feedback/generatemipmap prims_written on i965 Gen6. Reviewed-by: Brian Paul bri...@vmare.com Reviewed-by: Eric Anholt e...@anholt.net Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/common/meta.c | 13 + 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 144fa12..e622673 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -65,6 +65,7 @@ #include main/teximage.h #include main/texparam.h #include main/texstate.h +#include main/transformfeedback.h #include main/uniforms.h #include main/varray.h #include main/viewport.h @@ -181,6 +182,7 @@ struct save_state /** Miscellaneous (always disabled) */ GLboolean Lighting; GLboolean RasterDiscard; + GLboolean TransformFeedbackNeedsResume; }; /** @@ -423,6 +425,15 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) memset(save, 0, sizeof(*save)); save-SavedState = state; + /* Pausing transform feedback needs to be done early, or else we won't be +* able to change other state. +*/ + save-TransformFeedbackNeedsResume = + ctx-TransformFeedback.CurrentObject-Active + !ctx-TransformFeedback.CurrentObject-Paused; + if (save-TransformFeedbackNeedsResume) + _mesa_PauseTransformFeedback(); + if (state MESA_META_ALPHA_TEST) { save-AlphaEnabled = ctx-Color.AlphaEnabled; save-AlphaFunc = ctx-Color.AlphaFunc; @@ -988,6 +999,8 @@ _mesa_meta_end(struct gl_context *ctx) if (save-RasterDiscard) { _mesa_set_enable(ctx, GL_RASTERIZER_DISCARD, GL_TRUE); } + if (save-TransformFeedbackNeedsResume) + _mesa_ResumeTransformFeedback(); } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965: Rename BRW_NEW_WM_SURFACES to BRW_NEW_SURFACES.
Module: Mesa Branch: master Commit: 9cfa8a74ce484d5305b6581608b66b1cc53bc88b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9cfa8a74ce484d5305b6581608b66b1cc53bc88b Author: Paul Berry stereotype...@gmail.com Date: Thu Dec 22 13:39:30 2011 -0800 i965: Rename BRW_NEW_WM_SURFACES to BRW_NEW_SURFACES. The surface states tracked by BRW_NEW_WM_SURFACES are no longer used for just WM. They are also used for vertex texturing and transform feedback. To avoid confusion, this patch renames BRW_NEW_WM_SURFACES to BRW_NEW_SURFACES. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/brw_context.h |4 ++-- src/mesa/drivers/dri/i965/brw_state_upload.c |2 +- src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 12 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 15a781b..fb41fd1 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -131,7 +131,7 @@ enum brw_state_id { BRW_STATE_CONTEXT, BRW_STATE_WM_INPUT_DIMENSIONS, BRW_STATE_PSP, - BRW_STATE_WM_SURFACES, + BRW_STATE_SURFACES, BRW_STATE_VS_BINDING_TABLE, BRW_STATE_GS_BINDING_TABLE, BRW_STATE_PS_BINDING_TABLE, @@ -158,7 +158,7 @@ enum brw_state_id { #define BRW_NEW_CONTEXT (1 BRW_STATE_CONTEXT) #define BRW_NEW_WM_INPUT_DIMENSIONS (1 BRW_STATE_WM_INPUT_DIMENSIONS) #define BRW_NEW_PSP (1 BRW_STATE_PSP) -#define BRW_NEW_WM_SURFACES(1 BRW_STATE_WM_SURFACES) +#define BRW_NEW_SURFACES (1 BRW_STATE_SURFACES) #define BRW_NEW_VS_BINDING_TABLE (1 BRW_STATE_VS_BINDING_TABLE) #define BRW_NEW_GS_BINDING_TABLE (1 BRW_STATE_GS_BINDING_TABLE) #define BRW_NEW_PS_BINDING_TABLE (1 BRW_STATE_PS_BINDING_TABLE) diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c index 74d01d8..a8bda5a 100644 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c @@ -360,7 +360,7 @@ static struct dirty_bit_map brw_bits[] = { DEFINE_BIT(BRW_NEW_WM_INPUT_DIMENSIONS), DEFINE_BIT(BRW_NEW_PROGRAM_CACHE), DEFINE_BIT(BRW_NEW_PSP), - DEFINE_BIT(BRW_NEW_WM_SURFACES), + DEFINE_BIT(BRW_NEW_SURFACES), DEFINE_BIT(BRW_NEW_INDICES), DEFINE_BIT(BRW_NEW_INDEX_BUFFER), DEFINE_BIT(BRW_NEW_VERTICES), diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index 3801c09..e908430 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -828,7 +828,7 @@ brw_upload_wm_pull_constants(struct brw_context *brw) drm_intel_bo_unreference(brw-wm.const_bo); brw-wm.const_bo = NULL; brw-bind.surf_offset[surf_index] = 0; -brw-state.dirty.brw |= BRW_NEW_WM_SURFACES; +brw-state.dirty.brw |= BRW_NEW_SURFACES; } return; } @@ -850,7 +850,7 @@ brw_upload_wm_pull_constants(struct brw_context *brw) params-NumParameters, brw-bind.surf_offset[surf_index]); - brw-state.dirty.brw |= BRW_NEW_WM_SURFACES; + brw-state.dirty.brw |= BRW_NEW_SURFACES; } const struct brw_tracked_state brw_wm_pull_constants = { @@ -1004,7 +1004,7 @@ brw_update_renderbuffer_surfaces(struct brw_context *brw) } else { intel-vtbl.update_null_renderbuffer_surface(brw, 0); } - brw-state.dirty.brw |= BRW_NEW_WM_SURFACES; + brw-state.dirty.brw |= BRW_NEW_SURFACES; } const struct brw_tracked_state brw_renderbuffer_surfaces = { @@ -1046,7 +1046,7 @@ brw_update_texture_surfaces(struct brw_context *brw) } } - brw-state.dirty.brw |= BRW_NEW_WM_SURFACES; + brw-state.dirty.brw |= BRW_NEW_SURFACES; } const struct brw_tracked_state brw_texture_surfaces = { @@ -1075,7 +1075,7 @@ brw_upload_binding_table(struct brw_context *brw) sizeof(uint32_t) * BRW_MAX_SURFACES, 32, brw-bind.bo_offset); - /* BRW_NEW_WM_SURFACES and BRW_NEW_VS_CONSTBUF */ + /* BRW_NEW_SURFACES and BRW_NEW_VS_CONSTBUF */ for (i = 0; i BRW_MAX_SURFACES; i++) { bind[i] = brw-bind.surf_offset[i]; } @@ -1089,7 +1089,7 @@ const struct brw_tracked_state brw_binding_table = { .mesa = 0, .brw = (BRW_NEW_BATCH | BRW_NEW_VS_CONSTBUF | - BRW_NEW_WM_SURFACES), + BRW_NEW_SURFACES), .cache = 0 }, .emit = brw_upload_binding_table, ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965 Gen6+: Invalidate VF address-based cache on flush
Module: Mesa Branch: master Commit: f2f14bc4a9a408b1d7cb2b04e8049f951ffb431e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f2f14bc4a9a408b1d7cb2b04e8049f951ffb431e Author: Paul Berry stereotype...@gmail.com Date: Thu Dec 22 11:58:51 2011 -0800 i965 Gen6+: Invalidate VF address-based cache on flush Although there is not much documentation of this fact, there are in fact two separate VF caches: - an index-based cache (described in the Sandy Bridge PRM, vol 2 part 1, section 2.1.2 Vertex Cache). This cache stores URB handles of vertex shader outputs; its purpose is to avoid redundant invocations of the vertex shader when drawing in random access mode (e.g. glDrawElements()), and the same vertex index is specified multiple times. It is automatically invalidated between 3D_PRIMITIVE commands and between instances within a single 3D_PRIMITIVE command. - an address-based cache (mentioned briefly in vol 2 part 1, section 1.7.4 PIPE_CONTROL Command). This cache stores the data read from vertex buffers; its purpose is to avoid redundant memory accesses when doing instanced drawing or when multiple 3D_PRIMITIVE commands access the same vertex data. It needs to be manually invalidated whenever new data is written to a buffer that is used for vertex data. Previous to this patch, it was not necessary for Mesa to explicitly invalidate the address-based cache, because there were no reasonable use cases in which the GPU would write to a vertex data buffer during a batch, and inter-batch flushing was taken care of by the kernel. However, with transform feedback, there is now a reasonable use case: vertex data is written to a buffer using transform feedback, and then that data is immediately re-used as vertex input in the next drawing operation. To make this use case work, we need to flush the address-based VF cache between transform feedback and the next draw operation. Since we are already calling intel_batchbuffer_emit_mi_flush() when transform feedback completes, and intel_batchbuffer_emit_mi_flush() is intended to invalidate all caches, it seems reasonable to add VF cache invalidation to this function. As with commit 63cf7fad13fc9cfdd2ae7b031426f79107000300 (i965: Flush pipeline on EndTransformFeedback), this is not an ideal solution. It would be preferable to only invalidate the VF cache if the next draw call was about to consume data generated by a previous draw call in the same batch. However, since we don't have the necessary dependency tracking infrastructure to figure that out right now, we have to overzealously invalidate the cache. Fixes Piglit test EXT_transform_feedback/immediate-reuse. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/intel/intel_batchbuffer.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c index 4ff098a..cb23dbc 100644 --- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c @@ -460,6 +460,7 @@ intel_batchbuffer_emit_mi_flush(struct intel_context *intel) OUT_BATCH(PIPE_CONTROL_INSTRUCTION_FLUSH | PIPE_CONTROL_WRITE_FLUSH | PIPE_CONTROL_DEPTH_CACHE_FLUSH | + PIPE_CONTROL_VF_CACHE_INVALIDATE | PIPE_CONTROL_TC_FLUSH | PIPE_CONTROL_NO_WRITE | PIPE_CONTROL_CS_STALL); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965 gen6: Resend binding table pointer after updating SOL bindings.
Module: Mesa Branch: master Commit: e25c4d09262e4aad7260d3b3b0eb6486755e4eea URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e25c4d09262e4aad7260d3b3b0eb6486755e4eea Author: Paul Berry stereotype...@gmail.com Date: Thu Dec 22 11:57:41 2011 -0800 i965 gen6: Resend binding table pointer after updating SOL bindings. After creating new binding table entries for transform feedback, we need to set the dirty flag BRW_NEW_SURFACES, so that a new binding table pointer will be sent to the hardware. Otherwise the new binding table entries will not take effect. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/gen6_sol.c |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/dri/i965/gen6_sol.c b/src/mesa/drivers/dri/i965/gen6_sol.c index 32f56d3..437b3ae 100644 --- a/src/mesa/drivers/dri/i965/gen6_sol.c +++ b/src/mesa/drivers/dri/i965/gen6_sol.c @@ -61,6 +61,8 @@ gen6_update_sol_surfaces(struct brw_context *brw) brw-bind.surf_offset[surf_index] = 0; } } + + brw-state.dirty.brw |= BRW_NEW_SURFACES; } const struct brw_tracked_state gen6_sol_surface = { ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965 gen6: Fix incorrect order of dwords in gen6_update_sol_indices()
Module: Mesa Branch: master Commit: e6e9becd5016df649d3c19a3e81e85bd63b895b7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e6e9becd5016df649d3c19a3e81e85bd63b895b7 Author: Paul Berry stereotype...@gmail.com Date: Fri Dec 23 13:56:07 2011 -0800 i965 gen6: Fix incorrect order of dwords in gen6_update_sol_indices() When updating SOL indices, we were accidentally putting the starting index in dword 1 and the SVBI number to increment in dword 2--these should be reversed. Usually both of these values are zero, so we didn't see any problem. However, if a transform feedback operation spans multiple batch buffers, the starting index will be nonzero. Fixes piglit test EXT_transform_feedback/intervening-read output. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/gen6_sol.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/mesa/drivers/dri/i965/gen6_sol.c b/src/mesa/drivers/dri/i965/gen6_sol.c index 437b3ae..f724802 100644 --- a/src/mesa/drivers/dri/i965/gen6_sol.c +++ b/src/mesa/drivers/dri/i965/gen6_sol.c @@ -82,8 +82,8 @@ gen6_update_sol_indices(struct brw_context *brw) BEGIN_BATCH(4); OUT_BATCH(_3DSTATE_GS_SVB_INDEX 16 | (4 - 2)); - OUT_BATCH(brw-sol.svbi_0_starting_index); /* BRW_NEW_SOL_INDICES */ OUT_BATCH(0); + OUT_BATCH(brw-sol.svbi_0_starting_index); /* BRW_NEW_SOL_INDICES */ OUT_BATCH(brw-sol.svbi_0_max_index); /* BRW_NEW_SOL_INDICES */ ADVANCE_BATCH(); } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): swrast: Remove dead code in _swrast_clear_depth_buffer()
Module: Mesa Branch: master Commit: 7cbcce383c4aef1bd17850a4487805e30d84613a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7cbcce383c4aef1bd17850a4487805e30d84613a Author: Paul Berry stereotype...@gmail.com Date: Thu Dec 29 10:15:43 2011 -0800 swrast: Remove dead code in _swrast_clear_depth_buffer() This code was generating the gcc warning: variable ‘clearValue’ set but not used [-Wunused-but-set-variable] Reviewed-by: Brian Paul bri...@vmare.com --- src/mesa/swrast/s_depth.c |9 - 1 files changed, 0 insertions(+), 9 deletions(-) diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c index f87adaa..53f21cb 100644 --- a/src/mesa/swrast/s_depth.c +++ b/src/mesa/swrast/s_depth.c @@ -489,7 +489,6 @@ _swrast_clear_depth_buffer(struct gl_context *ctx) { struct gl_renderbuffer *rb = ctx-DrawBuffer-Attachment[BUFFER_DEPTH].Renderbuffer; - GLuint clearValue; GLint x, y, width, height; GLubyte *map; GLint rowStride, i, j; @@ -500,14 +499,6 @@ _swrast_clear_depth_buffer(struct gl_context *ctx) return; } - /* compute integer clearing value */ - if (ctx-Depth.Clear == 1.0) { - clearValue = ctx-DrawBuffer-_DepthMax; - } - else { - clearValue = (GLuint) (ctx-Depth.Clear * ctx-DrawBuffer-_DepthMaxF); - } - /* compute region to clear */ x = ctx-DrawBuffer-_Xmin; y = ctx-DrawBuffer-_Ymin; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Fix typos in transform feedback error messages.
Module: Mesa Branch: master Commit: 1979e22e13dd28553bcc67cc51e56684e6ee4768 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1979e22e13dd28553bcc67cc51e56684e6ee4768 Author: Paul Berry stereotype...@gmail.com Date: Fri Dec 30 11:02:31 2011 -0800 mesa: Fix typos in transform feedback error messages. Reviewed-by: Brian Paul bri...@vmware.com Reviewed-by: Ian Romanick ian.d.roman...@intel.com Reviewed-by: Eric Anholt e...@anholt.net --- src/mesa/main/shaderapi.c |2 +- src/mesa/main/transformfeedback.c |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index b71b44b..52a9bd4 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -751,7 +751,7 @@ link_program(struct gl_context *ctx, GLuint program) || shProg == ctx-Shader.CurrentGeometryProgram || shProg == ctx-Shader.CurrentFragmentProgram)) { _mesa_error(ctx, GL_INVALID_OPERATION, - glLinkProgram(transform feedback active); + glLinkProgram(transform feedback active)); return; } diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index be0d0ff..305589d 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -461,7 +461,7 @@ _mesa_BindBufferRange(GLenum target, GLuint index, if ((size = 0) || (size 0x3)) { /* must be positive and multiple of four */ - _mesa_error(ctx, GL_INVALID_VALUE, glBindBufferRange(size%d), (int) size); + _mesa_error(ctx, GL_INVALID_VALUE, glBindBufferRange(size=%d), (int) size); return; } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Check that all buffers are bound in BeginTransformFeedback.
Module: Mesa Branch: master Commit: ebfad9f6a125738b9bfc5d5f7d09a8b57856674a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ebfad9f6a125738b9bfc5d5f7d09a8b57856674a Author: Paul Berry stereotype...@gmail.com Date: Thu Dec 29 15:55:01 2011 -0800 mesa: Check that all buffers are bound in BeginTransformFeedback. From the EXT_transform_feedback spec: The error INVALID_OPERATION is generated by BeginTransformFeedbackEXT if any transform feedback buffer object binding point used in transform feedback mode does not have a buffer object bound. This required adding a new NumBuffers field to the gl_transform_feedback_info struct, to keep track of how many transform feedback buffers are required by the current program. Fixes Piglit tests: - EXT_transform_feedback/api-errors interleaved_unbound - EXT_transform_feedback/api-errors separate_unbound_0_1 - EXT_transform_feedback/api-errors separate_unbound_0_2 - EXT_transform_feedback/api-errors separate_unbound_1_2 Reviewed-by: Brian Paul bri...@vmware.com Reviewed-by: Ian Romanick ian.d.roman...@intel.com Reviewed-by: Eric Anholt e...@anholt.net --- src/glsl/linker.cpp |7 +-- src/mesa/main/mtypes.h|5 + src/mesa/main/transformfeedback.c | 12 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 6587008..9e8975e 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1865,11 +1865,14 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog, tfeedback_decl *tfeedback_decls) { unsigned total_tfeedback_components = 0; + bool separate_attribs_mode = + prog-TransformFeedback.BufferMode == GL_SEPARATE_ATTRIBS; memset(prog-LinkedTransformFeedback, 0, sizeof(prog-LinkedTransformFeedback)); + prog-LinkedTransformFeedback.NumBuffers = + separate_attribs_mode ? num_tfeedback_decls : 1; for (unsigned i = 0; i num_tfeedback_decls; ++i) { - unsigned buffer = - prog-TransformFeedback.BufferMode == GL_SEPARATE_ATTRIBS ? i : 0; + unsigned buffer = separate_attribs_mode ? i : 0; if (!tfeedback_decls[i].store(prog, prog-LinkedTransformFeedback, buffer)) return false; diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 107371e..35458e3 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1821,6 +1821,11 @@ struct gl_uniform_list; struct gl_transform_feedback_info { unsigned NumOutputs; + /** +* Number of transform feedback buffers in use by this program. +*/ + unsigned NumBuffers; + struct { unsigned OutputRegister; unsigned OutputBuffer; diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index 305589d..6e93b3b 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -342,9 +342,12 @@ void GLAPIENTRY _mesa_BeginTransformFeedback(GLenum mode) { struct gl_transform_feedback_object *obj; + struct gl_transform_feedback_info *info; + int i; GET_CURRENT_CONTEXT(ctx); obj = ctx-TransformFeedback.CurrentObject; + info = ctx-Shader.CurrentVertexProgram-LinkedTransformFeedback; switch (mode) { case GL_POINTS: @@ -363,6 +366,15 @@ _mesa_BeginTransformFeedback(GLenum mode) return; } + for (i = 0; i info-NumBuffers; ++i) { + if (obj-BufferNames[i] == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + glBeginTransformFeedback(binding point %d does not have + a buffer object bound), i); + return; + } + } + FLUSH_VERTICES(ctx, _NEW_TRANSFORM_FEEDBACK); obj-Active = GL_TRUE; ctx-TransformFeedback.Mode = mode; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Additional error checks for transform feedback.
Module: Mesa Branch: master Commit: 86bb45ffc36280263ba99fdca0c341489ad99e7f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=86bb45ffc36280263ba99fdca0c341489ad99e7f Author: Paul Berry stereotype...@gmail.com Date: Fri Dec 30 10:14:35 2011 -0800 mesa: Additional error checks for transform feedback. From the EXT_transform_feedback spec: The error INVALID_OPERATION is also generated by BeginTransformFeedbackEXT if no binding points would be used, either because no program object is active or because the active program object has specified no varying variables to record. ... The error INVALID_VALUE is generated by BindBufferRangeEXT or BindBufferOffsetEXT if offset is not word-aligned. Fixes Piglit tests: - EXT_transform_feedback/api-errors no_prog_active - EXT_transform_feedback/api-errors interleaved_no_varyings - EXT_transform_feedback/api-errors separate_no_varyings - EXT_transform_feedback/api-errors bind_offset_offset_1 - EXT_transform_feedback/api-errors bind_offset_offset_2 - EXT_transform_feedback/api-errors bind_offset_offset_3 - EXT_transform_feedback/api-errors bind_offset_offset_5 Reviewed-by: Brian Paul bri...@vmware.com Reviewed-by: Ian Romanick ian.d.roman...@intel.com Reviewed-by: Eric Anholt e...@anholt.net --- src/mesa/main/transformfeedback.c | 20 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index 6e93b3b..02681c6 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -347,8 +347,21 @@ _mesa_BeginTransformFeedback(GLenum mode) GET_CURRENT_CONTEXT(ctx); obj = ctx-TransformFeedback.CurrentObject; + + if (ctx-Shader.CurrentVertexProgram == NULL) { + _mesa_error(ctx, GL_INVALID_OPERATION, + glBeginTransformFeedback(no program active)); + return; + } + info = ctx-Shader.CurrentVertexProgram-LinkedTransformFeedback; + if (info-NumOutputs == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + glBeginTransformFeedback(no varyings to record)); + return; + } + switch (mode) { case GL_POINTS: case GL_LINES: @@ -581,6 +594,13 @@ _mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer, return; } + if (offset 0x3) { + /* must be multiple of four */ + _mesa_error(ctx, GL_INVALID_VALUE, + glBindBufferOffsetEXT(offset=%d), (int) offset); + return; + } + bufObj = _mesa_lookup_bufferobj(ctx, buffer); if (!bufObj) { _mesa_error(ctx, GL_INVALID_OPERATION, ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Fix extra memset in store_tfeedback_info()
Module: Mesa Branch: master Commit: 1be0fd8c86cac0775fd4451eb332effc70ccdbe5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1be0fd8c86cac0775fd4451eb332effc70ccdbe5 Author: Paul Berry stereotype...@gmail.com Date: Thu Jan 5 13:06:36 2012 -0800 mesa: Fix extra memset in store_tfeedback_info() Commit 9d36c96d6ec9f2c05c8e0b9ef18c5462cddee8c1 (mesa: Fix glGetTransformFeedbackVarying()) accidentally added an extra memset() call to the store_tfeedback_info() function, causing prog-LinkedTransformFeedback.NumBuffers to be erased. This patch removes the extra memset and rearranges the other operations in store_tfeedback_info() to be in the correct order. Fixes piglit tests EXT_transform_feedback/api-errors *unbound* Reviewed-by: Eric Anholt e...@anholt.net --- src/glsl/linker.cpp |7 +++ 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 3dd0883..128bbd5 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1884,16 +1884,15 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog, unsigned total_tfeedback_components = 0; bool separate_attribs_mode = prog-TransformFeedback.BufferMode == GL_SEPARATE_ATTRIBS; - memset(prog-LinkedTransformFeedback, 0, - sizeof(prog-LinkedTransformFeedback)); - prog-LinkedTransformFeedback.NumBuffers = - separate_attribs_mode ? num_tfeedback_decls : 1; ralloc_free(prog-LinkedTransformFeedback.Varyings); memset(prog-LinkedTransformFeedback, 0, sizeof(prog-LinkedTransformFeedback)); + prog-LinkedTransformFeedback.NumBuffers = + separate_attribs_mode ? num_tfeedback_decls : 1; + prog-LinkedTransformFeedback.Varyings = rzalloc_array(prog-LinkedTransformFeedback.Varyings, struct gl_transform_feedback_varying_info, ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965: Fix transform feedback of gl_PointSize.
Module: Mesa Branch: master Commit: 15f4bca2df47fed8af322217d62b35189f5ca4ab URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=15f4bca2df47fed8af322217d62b35189f5ca4ab Author: Paul Berry stereotype...@gmail.com Date: Mon Dec 26 13:58:46 2011 -0800 i965: Fix transform feedback of gl_PointSize. On i965 Gen6 and above, gl_PointSize is stored in component W of the first VUE slot (which corresponds to VERT_RESULT_PSIZ in the VUE map). Normally we store varying floats in component X of a VUE slot, so we need special case logic for gl_PointSize. For Gen6, we do this with a . swizzle in the GS. For Gen7, we shift the component mask by 3 to select the W component. Fixes Piglit test EXT_transform_feedback/builtin-varyings gl_PointSize. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/brw_gs_emit.c|5 + src/mesa/drivers/dri/i965/gen7_sol_state.c | 11 +-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_gs_emit.c b/src/mesa/drivers/dri/i965/brw_gs_emit.c index 607ee75..4074501 100644 --- a/src/mesa/drivers/dri/i965/brw_gs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_gs_emit.c @@ -446,8 +446,13 @@ gen6_sol_program(struct brw_gs_compile *c, struct brw_gs_prog_key *key, struct brw_reg vertex_slot = c-reg.vertex[vertex]; vertex_slot.nr += slot / 2; vertex_slot.subnr = (slot % 2) * 16; +/* gl_PointSize is stored in VERT_RESULT_PSIZ.w. */ +vertex_slot.dw1.bits.swizzle = vert_result == VERT_RESULT_PSIZ + ? BRW_SWIZZLE_ : BRW_SWIZZLE_NOOP; +brw_set_access_mode(p, BRW_ALIGN_16); brw_MOV(p, stride(c-reg.header, 4, 4, 1), retype(vertex_slot, BRW_REGISTER_TYPE_UD)); +brw_set_access_mode(p, BRW_ALIGN_1); brw_svb_write(p, final_write ? c-reg.temp : brw_null_reg(), /* dest */ 1, /* msg_reg_nr */ diff --git a/src/mesa/drivers/dri/i965/gen7_sol_state.c b/src/mesa/drivers/dri/i965/gen7_sol_state.c index 7346866..df6b9ee 100644 --- a/src/mesa/drivers/dri/i965/gen7_sol_state.c +++ b/src/mesa/drivers/dri/i965/gen7_sol_state.c @@ -122,14 +122,21 @@ upload_3dstate_so_decl_list(struct brw_context *brw, int buffer = linked_xfb_info-Outputs[i].OutputBuffer; uint16_t decl = 0; int vert_result = linked_xfb_info-Outputs[i].OutputRegister; + unsigned component_mask = + (1 linked_xfb_info-Outputs[i].NumComponents) - 1; + + /* gl_PointSize is stored in VERT_RESULT_PSIZ.w. */ + if (vert_result == VERT_RESULT_PSIZ) { + assert(linked_xfb_info-Outputs[i].NumComponents == 1); + component_mask = 3; + } buffer_mask |= 1 buffer; decl |= buffer SO_DECL_OUTPUT_BUFFER_SLOT_SHIFT; decl |= vue_map-vert_result_to_slot[vert_result] SO_DECL_REGISTER_INDEX_SHIFT; - decl |= ((1 linked_xfb_info-Outputs[i].NumComponents) - 1) -SO_DECL_COMPONENT_MASK_SHIFT; + decl |= component_mask SO_DECL_COMPONENT_MASK_SHIFT; /* This assert should be true until GL_ARB_transform_feedback_instanced * is added and we start using the hole flag. ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965: Fix transform feedback of gl_ClipVertex.
Module: Mesa Branch: master Commit: 989b5722dc350b01c4148b1cd978b71ec4bcfe81 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=989b5722dc350b01c4148b1cd978b71ec4bcfe81 Author: Paul Berry stereotype...@gmail.com Date: Mon Dec 26 14:20:47 2011 -0800 i965: Fix transform feedback of gl_ClipVertex. Previously, on i965 Gen6 and above, we weren't allocating space for gl_ClipVertex in the VUE, since the VS was automatically converting it to clip distances. This prevented transform feedback from being able to capture gl_ClipVertex. This patch goes aheads and allocates space for gl_ClipVertex in the VUE on Gen6 and above. The old behavior is retained on Gen5 and below, since (a) transform feedback is not yet supported on those platforms, and (b) those platforms don't currently support gl_ClipVertex anyhow. Note: this constitutes a slight waste of VUE space for shaders that use gl_ClipVertex and don't use transform feedback to capture it. However, that seems preferable to making the VUE map (and all of the state that depends on it) dependent on transform feedback settings. Fixes Piglit test EXT_transform_feedback/builtin-varyings gl_ClipVertex. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/brw_vs.c | 13 - 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c index be1ed00..7fc7dcc 100644 --- a/src/mesa/drivers/dri/i965/brw_vs.c +++ b/src/mesa/drivers/dri/i965/brw_vs.c @@ -139,14 +139,17 @@ brw_compute_vue_map(struct brw_vue_map *vue_map, * assign them contiguously. Don't reassign outputs that already have a * slot. * -* Also, don't assign a slot for VERT_RESULT_CLIP_VERTEX, since it is -* unsupported in pre-GEN6, and in GEN6+ the vertex shader converts it into -* clip distances. +* Also, prior to Gen6, don't assign a slot for VERT_RESULT_CLIP_VERTEX, +* since it is unsupported. In Gen6 and above, VERT_RESULT_CLIP_VERTEX may +* be needed for transform feedback; since we don't want to have to +* recompute the VUE map (and everything that depends on it) when transform +* feedback is enabled or disabled, just go ahead and assign a slot for it. */ for (int i = 0; i VERT_RESULT_MAX; ++i) { + if (intel-gen 6 i == VERT_RESULT_CLIP_VERTEX) + continue; if ((outputs_written BITFIELD64_BIT(i)) - vue_map-vert_result_to_slot[i] == -1 - i != VERT_RESULT_CLIP_VERTEX) { + vue_map-vert_result_to_slot[i] == -1) { assign_vue_slot(vue_map, i); } } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Add gl_transform_feedback_info::ComponentOffset.
Module: Mesa Branch: master Commit: 2169331d40e915d0d1065477a5c81d59f222a5c8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2169331d40e915d0d1065477a5c81d59f222a5c8 Author: Paul Berry stereotype...@gmail.com Date: Mon Dec 26 19:30:10 2011 -0800 mesa: Add gl_transform_feedback_info::ComponentOffset. When using transform feedback, there are three circumstances in which it is useful for Mesa to instruct a driver to stream out just a portion of a varying slot (rather than the whole vec4): (a) When a varying is smaller than a vec4, Mesa needs to instruct the driver to stream out just the first one, two, or three components of the varying slot. (b) In the future, when we implement varying packing, some varyings will be offset within the vec4, so Mesa will have to instruct the driver to stream out an arbitrary contiguous subset of the components of the varying slot (e.g. .yzw or .yz). (c) On drivers that set gl_shader_compiler_options::LowerClipDistance, if the client requests that an element of gl_ClipDistance be streamed out using transform feedback, Mesa will have to instruct the driver to stream out a single component of one of the gl_ClipDistance varying slots. Previous to this patch, only (a) was possible, since gl_transform_feedback_info specified only the number of components of the varying slot to stream out. This patch adds gl_transform_feedback_info::ComponentOffset, which indicates which components should be streamed out. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/glsl/linker.cpp|1 + src/mesa/main/mtypes.h |7 +++ 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 128bbd5..ef6a6e3 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1606,6 +1606,7 @@ tfeedback_decl::store(struct gl_shader_program *prog, info-Outputs[info-NumOutputs].NumComponents = this-vector_elements; info-Outputs[info-NumOutputs].OutputBuffer = buffer; info-Outputs[info-NumOutputs].DstOffset = info-BufferStride[buffer]; + info-Outputs[info-NumOutputs].ComponentOffset = 0; ++info-NumOutputs; info-BufferStride[buffer] += this-vector_elements; } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 332b80a..dcb9871 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1839,6 +1839,13 @@ struct gl_transform_feedback_info { /** offset (in DWORDs) of this output within the interleaved structure */ unsigned DstOffset; + + /** + * Offset into the output register of the data to output. For example, + * if NumComponents is 2 and ComponentOffset is 1, then the data to + * offset is in the y and z components of the output register. + */ + unsigned ComponentOffset; } Outputs[MAX_PROGRAM_OUTPUTS]; /** Transform feedback varyings used for the linking of this shader program. ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965: Make use of gl_transform_feedback_info:: ComponentOffset.
Module: Mesa Branch: master Commit: e8357cb03d354756d238e99101998b028db63f0f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e8357cb03d354756d238e99101998b028db63f0f Author: Paul Berry stereotype...@gmail.com Date: Mon Dec 26 19:31:20 2011 -0800 i965: Make use of gl_transform_feedback_info::ComponentOffset. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/brw_gs.c |9 + src/mesa/drivers/dri/i965/brw_gs.h |7 +++ src/mesa/drivers/dri/i965/brw_gs_emit.c|2 +- src/mesa/drivers/dri/i965/gen7_sol_state.c |2 ++ 4 files changed, 19 insertions(+), 1 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c index 850d7b4..f9c4f6a 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.c +++ b/src/mesa/drivers/dri/i965/brw_gs.c @@ -154,6 +154,13 @@ static void compile_gs_prog( struct brw_context *brw, static void populate_key( struct brw_context *brw, struct brw_gs_prog_key *key ) { + static const unsigned swizzle_for_offset[4] = { + BRW_SWIZZLE4(0, 1, 2, 3), + BRW_SWIZZLE4(1, 2, 3, 3), + BRW_SWIZZLE4(2, 3, 3, 3), + BRW_SWIZZLE4(3, 3, 3, 3) + }; + struct gl_context *ctx = brw-intel.ctx; struct intel_context *intel = brw-intel; @@ -207,6 +214,8 @@ static void populate_key( struct brw_context *brw, for (i = 0; i key-num_transform_feedback_bindings; ++i) { key-transform_feedback_bindings[i] = linked_xfb_info-Outputs[i].OutputRegister; +key-transform_feedback_swizzles[i] = + swizzle_for_offset[linked_xfb_info-Outputs[i].ComponentOffset]; } } /* On Gen6, GS is also used for rasterizer discard. */ diff --git a/src/mesa/drivers/dri/i965/brw_gs.h b/src/mesa/drivers/dri/i965/brw_gs.h index 2ab8b72..f2597c8 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.h +++ b/src/mesa/drivers/dri/i965/brw_gs.h @@ -63,6 +63,13 @@ struct brw_gs_prog_key { * entry. */ unsigned char transform_feedback_bindings[BRW_MAX_SOL_BINDINGS]; + + /** +* Map from the index of a transform feedback binding table entry to the +* swizzles that should be used when streaming out data through that +* binding table entry. +*/ + unsigned char transform_feedback_swizzles[BRW_MAX_SOL_BINDINGS]; }; struct brw_gs_compile { diff --git a/src/mesa/drivers/dri/i965/brw_gs_emit.c b/src/mesa/drivers/dri/i965/brw_gs_emit.c index 4074501..501cee4 100644 --- a/src/mesa/drivers/dri/i965/brw_gs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_gs_emit.c @@ -448,7 +448,7 @@ gen6_sol_program(struct brw_gs_compile *c, struct brw_gs_prog_key *key, vertex_slot.subnr = (slot % 2) * 16; /* gl_PointSize is stored in VERT_RESULT_PSIZ.w. */ vertex_slot.dw1.bits.swizzle = vert_result == VERT_RESULT_PSIZ - ? BRW_SWIZZLE_ : BRW_SWIZZLE_NOOP; + ? BRW_SWIZZLE_ : key-transform_feedback_swizzles[binding]; brw_set_access_mode(p, BRW_ALIGN_16); brw_MOV(p, stride(c-reg.header, 4, 4, 1), retype(vertex_slot, BRW_REGISTER_TYPE_UD)); diff --git a/src/mesa/drivers/dri/i965/gen7_sol_state.c b/src/mesa/drivers/dri/i965/gen7_sol_state.c index df6b9ee..674e14f 100644 --- a/src/mesa/drivers/dri/i965/gen7_sol_state.c +++ b/src/mesa/drivers/dri/i965/gen7_sol_state.c @@ -129,6 +129,8 @@ upload_3dstate_so_decl_list(struct brw_context *brw, if (vert_result == VERT_RESULT_PSIZ) { assert(linked_xfb_info-Outputs[i].NumComponents == 1); component_mask = 3; + } else { + component_mask = linked_xfb_info-Outputs[i].ComponentOffset; } buffer_mask |= 1 buffer; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): gallium: Make use of gl_transform_feedback_info:: ComponentOffset.
Module: Mesa Branch: master Commit: 367b83f890f6f7922bc8f9aa528ab50f55674e9e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=367b83f890f6f7922bc8f9aa528ab50f55674e9e Author: Paul Berry stereotype...@gmail.com Date: Mon Dec 26 19:31:44 2011 -0800 gallium: Make use of gl_transform_feedback_info::ComponentOffset. Reviewed-by: Marek Olšák mar...@gmail.com Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/state_tracker/st_glsl_to_tgsi.cpp |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 500e662..9e61c65 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -5191,7 +5191,8 @@ st_translate_stream_output_info(struct glsl_to_tgsi_visitor *glsl_to_tgsi, so-output[i].register_index = outputMapping[info-Outputs[i].OutputRegister]; so-output[i].register_mask = - comps_to_mask[info-Outputs[i].NumComponents]; + comps_to_mask[info-Outputs[i].NumComponents] + info-Outputs[i].ComponentOffset; so-output[i].output_buffer = info-Outputs[i].OutputBuffer; } so-num_outputs = info-NumOutputs; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Make tfeedback_decl::var_name a const char *.
Module: Mesa Branch: master Commit: 913a5c238b76a84616917dd47c3c7f627c892e58 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=913a5c238b76a84616917dd47c3c7f627c892e58 Author: Paul Berry stereotype...@gmail.com Date: Tue Dec 27 08:24:57 2011 -0800 mesa: Make tfeedback_decl::var_name a const char *. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/glsl/linker.cpp |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index ef6a6e3..e98b4ca 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1421,7 +1421,7 @@ private: /** * The name of the variable, parsed from orig_name. */ - char *var_name; + const char *var_name; /** * True if the declaration in orig_name represents an array. ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Fix transform feedback of gl_ClipDistance.
Module: Mesa Branch: master Commit: 456279bb33e09679de61d560aeafa74bb902fe43 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=456279bb33e09679de61d560aeafa74bb902fe43 Author: Paul Berry stereotype...@gmail.com Date: Mon Dec 26 19:39:25 2011 -0800 mesa: Fix transform feedback of gl_ClipDistance. On drivers that set gl_shader_compiler_options::LowerClipDistance (for example i965), references to gl_ClipDistance (a float[8] array) will be converted to references to gl_ClipDistanceMESA (a vec4[2] array). This patch modifies the linker so that requests for transform feedback of gl_ClipDistance are similarly converted. Fixes Piglit test EXT_transform_feedback/builtin-varyings gl_ClipDistance. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/glsl/linker.cpp | 59 +++--- 1 files changed, 41 insertions(+), 18 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index e98b4ca..c778d9a 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1376,8 +1376,8 @@ demote_shader_inputs_and_outputs(gl_shader *sh, enum ir_variable_mode mode) class tfeedback_decl { public: - bool init(struct gl_shader_program *prog, const void *mem_ctx, - const char *input); + bool init(struct gl_context *ctx, struct gl_shader_program *prog, + const void *mem_ctx, const char *input); static bool is_same(const tfeedback_decl x, const tfeedback_decl y); bool assign_location(struct gl_context *ctx, struct gl_shader_program *prog, ir_variable *output_var); @@ -1434,6 +1434,13 @@ private: unsigned array_index; /** +* Which component to extract from the vertex shader output location that +* the linker assigned to this variable. -1 if all components should be +* extracted. +*/ + int single_component; + + /** * The vertex shader output location that the linker assigned for this * variable. -1 if a location hasn't been assigned yet. */ @@ -1462,8 +1469,8 @@ private: * reported using linker_error(), and false is returned. */ bool -tfeedback_decl::init(struct gl_shader_program *prog, const void *mem_ctx, - const char *input) +tfeedback_decl::init(struct gl_context *ctx, struct gl_shader_program *prog, + const void *mem_ctx, const char *input) { /* 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. @@ -1471,23 +1478,34 @@ tfeedback_decl::init(struct gl_shader_program *prog, const void *mem_ctx, this-location = -1; this-orig_name = input; + this-single_component = -1; const char *bracket = strrchr(input, '['); if (bracket) { this-var_name = ralloc_strndup(mem_ctx, input, bracket - input); - if (sscanf(bracket, [%u], this-array_index) == 1) { - this-is_array = true; - return true; + if (sscanf(bracket, [%u], this-array_index) != 1) { + linker_error(prog, Cannot parse transform feedback varying %s, input); + return false; } + this-is_array = true; } else { this-var_name = ralloc_strdup(mem_ctx, input); this-is_array = false; - return true; } - linker_error(prog, Cannot parse transform feedback varying %s, input); - return false; + /* For drivers that lower gl_ClipDistance to gl_ClipDistanceMESA, we need +* to convert a request for gl_ClipDistance[n] into a request for a +* component of gl_ClipDistanceMESA[n/4]. +*/ + if (ctx-ShaderCompilerOptions[MESA_SHADER_VERTEX].LowerClipDistance + strcmp(this-var_name, gl_ClipDistance) == 0) { + this-var_name = gl_ClipDistanceMESA; + this-single_component = this-array_index % 4; + this-array_index /= 4; + } + + return true; } @@ -1504,6 +1522,8 @@ tfeedback_decl::is_same(const tfeedback_decl x, const tfeedback_decl y) return false; if (x.is_array x.array_index != y.array_index) return false; + if (x.single_component != y.single_component) + return false; return true; } @@ -1602,13 +1622,16 @@ tfeedback_decl::store(struct gl_shader_program *prog, return false; } for (unsigned v = 0; v this-matrix_columns; ++v) { + unsigned num_components = + this-single_component = 0 ? 1 : this-vector_elements; info-Outputs[info-NumOutputs].OutputRegister = this-location + v; - info-Outputs[info-NumOutputs].NumComponents = this-vector_elements; + info-Outputs[info-NumOutputs].NumComponents = num_components; info-Outputs[info-NumOutputs].OutputBuffer = buffer; info-Outputs[info-NumOutputs].DstOffset = info-BufferStride[buffer]; - info-Outputs[info-NumOutputs].ComponentOffset = 0; + info-Outputs[info-NumOutputs].ComponentOffset = + this-single_component = 0 ? this-single_component : 0; ++info-NumOutputs
Mesa (master): mesa: Avoid segfault when getting an unbound transform feedback buffer name.
Module: Mesa Branch: master Commit: 4357f8b4dcaaef4843d4b34923383a2b045638b1 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4357f8b4dcaaef4843d4b34923383a2b045638b1 Author: Paul Berry stereotype...@gmail.com Date: Tue Jan 3 13:59:13 2012 -0800 mesa: Avoid segfault when getting an unbound transform feedback buffer name. Previously we were using gl_transform_feedback_object::Buffers[i]-Name to service an indexed get request for GL_TRANSFORM_FEEDBACK_BUFFER_BINDING. However, if no buffer has been bound, gl_transform_feedback_object::Buffers[i] is NULL, so this was causing a segfault. This patch switches to using gl_transform_feedback_object::BufferNames[i], which is equal to gl_transform_feedback_object::Buffers[i]-Name if gl_transform_feedback_object::Buffers[i] is not NULL, and 0 if it is NULL. Fixes piglit test EXT_transform_feedback/get-buffer-state indexed_binding. Reviewed-by: Eric Anholt e...@anholt.net Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/main/get.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 0c9d6b3..5ad6012 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -2498,7 +2498,7 @@ find_value_indexed(const char *func, GLenum pname, int index, union value *v) goto invalid_value; if (!ctx-Extensions.EXT_transform_feedback) goto invalid_enum; - v-value_int = ctx-TransformFeedback.CurrentObject-Buffers[index]-Name; + v-value_int = ctx-TransformFeedback.CurrentObject-BufferNames[index]; return TYPE_INT; } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): Add . gitignore files to exclude unit test build artifacts from git
Module: Mesa Branch: master Commit: cab179a165af7690344c78c80f239d6e31d7699c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cab179a165af7690344c78c80f239d6e31d7699c Author: Paul Berry stereotype...@gmail.com Date: Mon Jan 2 21:05:43 2012 -0800 Add .gitignore files to exclude unit test build artifacts from git With the addition of unit tests in commit 3ef3ba4d2eee36f64062a21ce030c3f4d8c4cac4, several additional build artifacts are created: bin/depcomp bin/missing tests/Makefile tests/Makefile.in tests/glx/Makefile tests/glx/Makefile.in tests/glx/.deps/ tests/glx/.gitignore This patch adds all of these files to .gitignore. Acked-by: Kenneth Graunke kenn...@whitecape.org Reviewed-by: Ian Romanick ian.d.roman...@intel.com --- bin/.gitignore |2 ++ tests/.gitignore |3 +++ tests/glx/.gitignore |1 + 3 files changed, 6 insertions(+), 0 deletions(-) diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 000..3b3f168 --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1,2 @@ +/depcomp +/missing diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 000..a963aad --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,3 @@ +Makefile +Makefile.in +.deps/ diff --git a/tests/glx/.gitignore b/tests/glx/.gitignore new file mode 100644 index 000..dab7e97 --- /dev/null +++ b/tests/glx/.gitignore @@ -0,0 +1 @@ +/glx_unittest ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Fix transform feedback of unsubscripted arrays.
Module: Mesa Branch: master Commit: 33fe02111605ec8897dbc1c989c137b6e38c02f8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=33fe02111605ec8897dbc1c989c137b6e38c02f8 Author: Paul Berry stereotype...@gmail.com Date: Tue Jan 3 20:41:34 2012 -0800 mesa: Fix transform feedback of unsubscripted arrays. It is not explicitly stated in the GL 3.0 spec that transform feedback can be performed on a whole varying array (without supplying a subscript). However, it seems clear from context that this was the intent. Section 2.15 (TransformFeedback) says this: When writing varying variables that are arrays, individual array elements are written in order. And section 2.20.3 (Shader Variables), says this, in the description of GetTransformFeedbackVarying: For the selected varying variable, its type is returned into type. The size of the varying is returned into size. The value in size is in units of the type returned in type. If it were not possible to perform transform feedback on an unsubscripted array, the returned size would always be 1. This patch fixes the linker so that transform feedback on an unsubscripted array is supported. Fixes piglit tests EXT_transform_feedback/builtin-varyings gl_ClipDistance[{4,8}]-no-subscript and EXT_transform_feedback/output_type *[2]-no-subscript. Note: on back-ends that set gl_shader_compiler_options::LowerClipDistance (for example i965), tests EXT_transform_feedback/builtin-varyings gl_ClipDistance[{1,2,3,5,6,7}] still fail. I hope to address this in a later patch. Reviewed-by: Kenneth Graunke kenn...@whitecape.org Reviewed-by: Ian Romanick ian.d.roman...@intel.com --- src/glsl/linker.cpp | 99 --- 1 files changed, 54 insertions(+), 45 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index c778d9a..88c81c4 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1426,12 +1426,12 @@ private: /** * True if the declaration in orig_name represents an array. */ - bool is_array; + bool is_subscripted; /** -* If is_array is true, the array index that was specified in orig_name. +* If is_subscripted is true, the subscript that was specified in orig_name. */ - unsigned array_index; + unsigned array_subscript; /** * Which component to extract from the vertex shader output location that @@ -1460,6 +1460,12 @@ private: /** Type of the varying returned by glGetTransformFeedbackVarying() */ GLenum type; + + /** +* If location != -1, the size that should be returned by +* glGetTransformFeedbackVarying(). +*/ + unsigned size; }; @@ -1484,14 +1490,14 @@ tfeedback_decl::init(struct gl_context *ctx, struct gl_shader_program *prog, if (bracket) { this-var_name = ralloc_strndup(mem_ctx, input, bracket - input); - if (sscanf(bracket, [%u], this-array_index) != 1) { + if (sscanf(bracket, [%u], this-array_subscript) != 1) { linker_error(prog, Cannot parse transform feedback varying %s, input); return false; } - this-is_array = true; + this-is_subscripted = true; } else { this-var_name = ralloc_strdup(mem_ctx, input); - this-is_array = false; + this-is_subscripted = false; } /* For drivers that lower gl_ClipDistance to gl_ClipDistanceMESA, we need @@ -1501,8 +1507,10 @@ tfeedback_decl::init(struct gl_context *ctx, struct gl_shader_program *prog, if (ctx-ShaderCompilerOptions[MESA_SHADER_VERTEX].LowerClipDistance strcmp(this-var_name, gl_ClipDistance) == 0) { this-var_name = gl_ClipDistanceMESA; - this-single_component = this-array_index % 4; - this-array_index /= 4; + if (this-is_subscripted) { + this-single_component = this-array_subscript % 4; + this-array_subscript /= 4; + } } return true; @@ -1518,9 +1526,9 @@ tfeedback_decl::is_same(const tfeedback_decl x, const tfeedback_decl y) { if (strcmp(x.var_name, y.var_name) != 0) return false; - if (x.is_array != y.is_array) + if (x.is_subscripted != y.is_subscripted) return false; - if (x.is_array x.array_index != y.array_index) + if (x.is_subscripted x.array_subscript != y.array_subscript) return false; if (x.single_component != y.single_component) return false; @@ -1542,37 +1550,39 @@ tfeedback_decl::assign_location(struct gl_context *ctx, { if (output_var-type-is_array()) { /* Array variable */ - if (!this-is_array) { - linker_error(prog, Transform feedback varying %s found, - but array dereference required for varying %s[%d])., - this-orig_name, - output_var-name, output_var-type-length); - return false; - } - /* Check array bounds. */ - if (this-array_index = - (unsigned) output_var-type-array_size()) { - linker_error
Mesa (master): mesa: Fix bogus transform feedback error message when subscripting non-array.
Module: Mesa Branch: master Commit: 108cba21dec82a7e10962cf01f2835e7b950ff74 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=108cba21dec82a7e10962cf01f2835e7b950ff74 Author: Paul Berry stereotype...@gmail.com Date: Wed Jan 4 15:17:52 2012 -0800 mesa: Fix bogus transform feedback error message when subscripting non-array. Previous to this patch, if the client requested transform feedback using a subscript, but the variable was not an array (e.g. gl_FrontColor[0]), we would produce a bogus error message like Transform feedback varying gl_FrontColor[0] found, but it's an array ([] expected). Changed the error message to e.g. Transfrorm feedback varying gl_FrontColor[0] requested, but gl_FrontColor is not an array. Reviewed-by: Kenneth Graunke kenn...@whitecape.org Reviewed-by: Eric Anholt e...@anholt.net Reviewed-by: Ian Romanick ian.d.roman...@intel.com --- src/glsl/linker.cpp |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 88c81c4..e8472d4 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1576,9 +1576,9 @@ tfeedback_decl::assign_location(struct gl_context *ctx, } else { /* Regular variable (scalar, vector, or matrix) */ if (this-is_subscripted) { - linker_error(prog, Transform feedback varying %s found, - but it's an array ([] expected)., - this-orig_name); + linker_error(prog, Transform feedback varying %s requested, + but %s is not an array., + this-orig_name, this-var_name); return false; } this-location = output_var-location; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Fix computation of transform feedback num_components.
Module: Mesa Branch: master Commit: be4e9f7a0ccb7aa0edef5e5b589bdbbfd4eab3cb URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=be4e9f7a0ccb7aa0edef5e5b589bdbbfd4eab3cb Author: Paul Berry stereotype...@gmail.com Date: Wed Jan 4 12:21:55 2012 -0800 mesa: Fix computation of transform feedback num_components. The function tfeedback_decl::num_components() was not correctly accounting for transform feedback of whole arrays and gl_ClipDistance. The bug was hard to notice in tests, because it only affected the checks for MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS and MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS. This patch fixes the computation, and adds an assertion to verify num_components() even when MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS and MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS are not exceeded. The assertion requires keeping track of components_so_far in tfeedback_decl::store(); this will be useful in a future patch to fix non-multiple-of-4-sized gl_ClipDistance. Reviewed-by: Eric Anholt e...@anholt.net --- src/glsl/linker.cpp |8 +++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index e8472d4..f32c217 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1408,7 +1408,10 @@ public: */ unsigned num_components() const { - return this-vector_elements * this-matrix_columns; + if (this-single_component == -1) + return this-vector_elements * this-matrix_columns * this-size; + else + return 1; } private: @@ -1631,6 +1634,7 @@ tfeedback_decl::store(struct gl_shader_program *prog, this-orig_name); return false; } + unsigned components_so_far = 0; for (unsigned index = 0; index this-size; ++index) { for (unsigned v = 0; v this-matrix_columns; ++v) { unsigned num_components = @@ -1644,8 +1648,10 @@ tfeedback_decl::store(struct gl_shader_program *prog, this-single_component = 0 ? this-single_component : 0; ++info-NumOutputs; info-BufferStride[buffer] += num_components; + components_so_far += num_components; } } + assert(components_so_far == this-num_components()); info-Varyings[varying].Name = ralloc_strdup(prog, this-orig_name); info-Varyings[varying].Type = this-type; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Fix transform feedback of unsubscripted gl_ClipDistance array.
Module: Mesa Branch: master Commit: 642e5b413e0890b2070ba78fde42db381eaf02e5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=642e5b413e0890b2070ba78fde42db381eaf02e5 Author: Paul Berry stereotype...@gmail.com Date: Wed Jan 4 13:57:52 2012 -0800 mesa: Fix transform feedback of unsubscripted gl_ClipDistance array. On drivers that set gl_shader_compiler_options::LowerClipDistance (for example i965), we need to handle transform feedback of gl_ClipDistance specially, to account for the fact that the hardware represents it as an array of vec4's rather than an array of floats. The previous way this was accounted for (translating the request for gl_ClipDistance[n] to a request for a component of gl_ClipDistanceMESA[n/4]) doesn't work when performing transform feedback on the whole unsubscripted array, because we need to keep track of the size of the gl_ClipDistance array prior to the lowering pass. So I replaced it with a boolean is_clip_distance_mesa, which switches on the special logic that is needed to handle the lowered version of gl_ClipDistance. Fixes Piglit tests EXT_transform_feedback/builtin-varyings gl_ClipDistance[{1,2,3,5,6,7}]-no-subscript. Reviewed-by: Eric Anholt e...@anholt.net --- src/glsl/linker.cpp| 89 ++-- src/mesa/main/mtypes.h |2 + 2 files changed, 58 insertions(+), 33 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index f32c217..39a9c46 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -246,7 +246,8 @@ count_attribute_slots(const glsl_type *t) /** * Verify that a vertex shader executable meets all semantic requirements. * - * Also sets prog-Vert.UsesClipDistance as a side effect. + * Also sets prog-Vert.UsesClipDistance and prog-Vert.ClipDistanceArraySize + * as a side effect. * * \param shader Vertex shader executable to be verified */ @@ -264,6 +265,8 @@ validate_vertex_shader_executable(struct gl_shader_program *prog, return false; } + prog-Vert.ClipDistanceArraySize = 0; + if (prog-Version = 130) { /* From section 7.1 (Vertex Shader Special Variables) of the * GLSL 1.30 spec: @@ -282,6 +285,10 @@ validate_vertex_shader_executable(struct gl_shader_program *prog, return false; } prog-Vert.UsesClipDistance = clip_distance.variable_found(); + ir_variable *clip_distance_var = + shader-symbols-get_variable(gl_ClipDistance); + if (clip_distance_var) + prog-Vert.ClipDistanceArraySize = clip_distance_var-type-length; } return true; @@ -1399,7 +1406,10 @@ public: */ bool matches_var(ir_variable *var) const { - return strcmp(var-name, this-var_name) == 0; + if (this-is_clip_distance_mesa) + return strcmp(var-name, gl_ClipDistanceMESA) == 0; + else + return strcmp(var-name, this-var_name) == 0; } /** @@ -1408,10 +1418,10 @@ public: */ unsigned num_components() const { - if (this-single_component == -1) - return this-vector_elements * this-matrix_columns * this-size; + if (this-is_clip_distance_mesa) + return this-size; else - return 1; + return this-vector_elements * this-matrix_columns * this-size; } private: @@ -1437,11 +1447,10 @@ private: unsigned array_subscript; /** -* Which component to extract from the vertex shader output location that -* the linker assigned to this variable. -1 if all components should be -* extracted. +* True if the variable is gl_ClipDistance and the driver lowers +* gl_ClipDistance to gl_ClipDistanceMESA. */ - int single_component; + bool is_clip_distance_mesa; /** * The vertex shader output location that the linker assigned for this @@ -1487,7 +1496,7 @@ tfeedback_decl::init(struct gl_context *ctx, struct gl_shader_program *prog, this-location = -1; this-orig_name = input; - this-single_component = -1; + this-is_clip_distance_mesa = false; const char *bracket = strrchr(input, '['); @@ -1503,17 +1512,13 @@ tfeedback_decl::init(struct gl_context *ctx, struct gl_shader_program *prog, this-is_subscripted = false; } - /* For drivers that lower gl_ClipDistance to gl_ClipDistanceMESA, we need -* to convert a request for gl_ClipDistance[n] into a request for a -* component of gl_ClipDistanceMESA[n/4]. + /* For drivers that lower gl_ClipDistance to gl_ClipDistanceMESA, this +* class must behave specially to account for the fact that gl_ClipDistance +* is converted from a float[8] to a vec4[2]. */ if (ctx-ShaderCompilerOptions[MESA_SHADER_VERTEX].LowerClipDistance strcmp(this-var_name, gl_ClipDistance) == 0) { - this-var_name = gl_ClipDistanceMESA; - if (this-is_subscripted) { - this-single_component = this-array_subscript % 4; - this-array_subscript /= 4
Mesa (master): mesa: Move transform feedback error check to reduce array overflow risk.
Module: Mesa Branch: master Commit: d3150ebc8c1833322daf24b2cd47e31a5b2f8a1f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d3150ebc8c1833322daf24b2cd47e31a5b2f8a1f Author: Paul Berry stereotype...@gmail.com Date: Mon Jan 9 11:25:14 2012 -0800 mesa: Move transform feedback error check to reduce array overflow risk. Previous to this patch, we didn't do the limit check for MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS until the end of the store_tfeedback_info() function, *after* storing all of the transform feedback info in the gl_transform_feedback_info::Outputs array. This meant that the limit check wouldn't prevent us from overflowing the array and corrupting memory. This patch moves the limit check to the top of tfeedback_decl::store() so that there is no risk of overflowing the array. It also adds assertions to verify that the checks for MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS and MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS are sufficient to avoid array overflow. Note: strictly speaking this patch isn't necessary, since the maximum possible number of varyings is MAX_VARYING (16), whereas the size of the Outputs array is MAX_PROGRAM_OUTPUTS (64), so it's impossible to have enough varyings to overflow the array. However it seems prudent to do the limit check before the array access in case these limits change in the future. Reviewed-by: Ian Romanick ian.d.roman...@intel.com --- src/glsl/linker.cpp | 52 +++--- 1 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 39a9c46..0d85aee 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -1388,7 +1388,7 @@ public: static bool is_same(const tfeedback_decl x, const tfeedback_decl y); bool assign_location(struct gl_context *ctx, struct gl_shader_program *prog, ir_variable *output_var); - bool store(struct gl_shader_program *prog, + bool store(struct gl_context *ctx, struct gl_shader_program *prog, struct gl_transform_feedback_info *info, unsigned buffer, unsigned varying) const; @@ -1631,7 +1631,7 @@ tfeedback_decl::assign_location(struct gl_context *ctx, * is returned. */ bool -tfeedback_decl::store(struct gl_shader_program *prog, +tfeedback_decl::store(struct gl_context *ctx, struct gl_shader_program *prog, struct gl_transform_feedback_info *info, unsigned buffer, unsigned varying) const { @@ -1647,6 +1647,35 @@ tfeedback_decl::store(struct gl_shader_program *prog, this-orig_name); return false; } + + /* From GL_EXT_transform_feedback: +* A program will fail to link if: +* +* * the total number of components to capture is greater than +* the constant MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT +* and the buffer mode is INTERLEAVED_ATTRIBS_EXT. +*/ + if (prog-TransformFeedback.BufferMode == GL_INTERLEAVED_ATTRIBS + info-BufferStride[buffer] + this-num_components() + ctx-Const.MaxTransformFeedbackInterleavedComponents) { + linker_error(prog, The MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS + limit has been exceeded.); + return false; + } + + /* Verify that the checks on MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS +* and MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS are sufficient to prevent +* overflow of info-Outputs[]. In worst case we generate one entry in +* Outputs[] per component so a conservative check is to verify that the +* size of the array is greater than or equal to both +* MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS and +* MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS. +*/ + assert(Elements(info-Outputs) = + ctx-Const.MaxTransformFeedbackInterleavedComponents); + assert(Elements(info-Outputs) = + ctx-Const.MaxTransformFeedbackSeparateComponents); + unsigned translated_size = this-size; if (this-is_clip_distance_mesa) translated_size = (translated_size + 3) / 4; @@ -1943,7 +1972,6 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog, unsigned num_tfeedback_decls, tfeedback_decl *tfeedback_decls) { - unsigned total_tfeedback_components = 0; bool separate_attribs_mode = prog-TransformFeedback.BufferMode == GL_SEPARATE_ATTRIBS; @@ -1962,25 +1990,9 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog, for (unsigned i = 0; i num_tfeedback_decls; ++i) { unsigned buffer = separate_attribs_mode ? i : 0; - if (!tfeedback_decls[i].store(prog, prog-LinkedTransformFeedback, + if (!tfeedback_decls[i].store(ctx, prog, prog-LinkedTransformFeedback, buffer, i)) return false; - total_tfeedback_components += tfeedback_decls[i
Mesa (master): glx: Suppress unused variable warning for cmdlen
Module: Mesa Branch: master Commit: 765ed3a6a9317607311bac1dcb0edee13ebcee16 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=765ed3a6a9317607311bac1dcb0edee13ebcee16 Author: Paul Berry stereotype...@gmail.com Date: Mon Jan 9 11:24:17 2012 -0800 glx: Suppress unused variable warning for cmdlen No functional change. In the function __indirect_glAreTexturesResident(), the variable cmdlen is only used if USE_XCB is not defined. This patch avoids a compile warning in the event that USE_XCB is defined. v2: just move cmdlen declaration inside the #else part. Reviewed-by: Ian Romanick ian.d.roman...@intel.com Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/glx/single2.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/glx/single2.c b/src/glx/single2.c index 66281fa..259c4fe 100644 --- a/src/glx/single2.c +++ b/src/glx/single2.c @@ -887,7 +887,6 @@ __indirect_glAreTexturesResident(GLsizei n, const GLuint * textures, struct glx_context *const gc = __glXGetCurrentContext(); Display *const dpy = gc-currentDpy; GLboolean retval = (GLboolean) 0; - const GLuint cmdlen = 4 + __GLX_PAD((n * 4)); if (__builtin_expect((n = 0) (dpy != NULL), 1)) { #ifdef USE_XCB xcb_connection_t *c = XGetXCBConnection(dpy); @@ -903,6 +902,7 @@ __indirect_glAreTexturesResident(GLsizei n, const GLuint * textures, retval = reply-ret_val; free(reply); #else + const GLuint cmdlen = 4 + __GLX_PAD((n * 4)); GLubyte const *pc = __glXSetupSingleRequest(gc, X_GLsop_AreTexturesResident, cmdlen); (void) memcpy((void *) (pc + 0), (void *) (n), 4); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965 gen4-6: Fix off-by-one errors brw_create_constant_surface()
Module: Mesa Branch: master Commit: f6f43bd5a276990c58c021bc047e60f9763df479 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f6f43bd5a276990c58c021bc047e60f9763df479 Author: Paul Berry stereotype...@gmail.com Date: Mon Jan 9 14:45:04 2012 -0800 i965 gen4-6: Fix off-by-one errors brw_create_constant_surface() Commit 9bdc44a52804a64219a0ca1a061b18596863e524 (i965: Replace struct with bit shifting for WM pull constant surfaces) accidentally introduced off-by-one errors into the calculation of the surface width, height, and depth. This patch restores the correct computation. The reason this wasn't noticed by Piglit tests is that the size of our constant surfaces is always less than 2^20, therefore the off-by-one error was causing the depth field of the surface to be set to all 1's. The hardware interpreted this as an extremely large surface, so overflow checking was effectively disabled. No Piglit regressions on Sandy Bridge. NOTE: This is a candidate for the 7.11 and 8.0 branches. Reviewed-by: Eric Anholt e...@anholt.net Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/brw_wm_surface_state.c |6 +++--- 1 files changed, 3 insertions(+), 3 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 dedf594..b40f5e1 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -698,10 +698,10 @@ brw_create_constant_surface(struct brw_context *brw, surf[1] = bo-offset; /* reloc */ - surf[2] = (((w 0x7f) - 1) BRW_SURFACE_WIDTH_SHIFT | - (((w 7) 0x1fff) - 1) BRW_SURFACE_HEIGHT_SHIFT); + surf[2] = ((w 0x7f) BRW_SURFACE_WIDTH_SHIFT | + ((w 7) 0x1fff) BRW_SURFACE_HEIGHT_SHIFT); - surf[3] = w 20) 0x7f) - 1) BRW_SURFACE_DEPTH_SHIFT | + surf[3] = (((w 20) 0x7f) BRW_SURFACE_DEPTH_SHIFT | (width * 16 - 1) BRW_SURFACE_PITCH_SHIFT); surf[4] = 0; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965: Set pitch of pull constant buffers to 16.
Module: Mesa Branch: master Commit: fcd5af4a916b4ba7860ba27eb47404934bde0d08 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fcd5af4a916b4ba7860ba27eb47404934bde0d08 Author: Paul Berry stereotype...@gmail.com Date: Mon Jan 9 15:36:27 2012 -0800 i965: Set pitch of pull constant buffers to 16. We always access pull constant buffers using the message types OWord Block Read or OWord Dual Block Read. According to the Sandy Bridge PRM, Vol 4 Part 1, pages 214 and 218, when using these messages: the surface pitch is ignored, the surface is treated as a 1-dimensional surface. An element size (pitch) of 16 bytes is used to determine the size of the buffer for out-of-bounds checking if using the surface state model. Previously we were setting the pitch for pull constant buffers to the size of the whole constant buffer--this made no sense and would have led to incorrect behavior if it were not for the fact that the pitch is ignored. For clarity, this patch sets the pitch for pull constant buffers to 16 bytes, consistent with the hardware's behavior. v2: Clarify the meaning of the ignored values by writing them as (16 - 1). Reviewed-by: Eric Anholt e...@anholt.net Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/brw_wm_surface_state.c |2 +- src/mesa/drivers/dri/i965/gen7_wm_surface_state.c |2 +- 2 files changed, 2 insertions(+), 2 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 b40f5e1..159509b 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -702,7 +702,7 @@ brw_create_constant_surface(struct brw_context *brw, ((w 7) 0x1fff) BRW_SURFACE_HEIGHT_SHIFT); surf[3] = (((w 20) 0x7f) BRW_SURFACE_DEPTH_SHIFT | - (width * 16 - 1) BRW_SURFACE_PITCH_SHIFT); + (16 - 1) BRW_SURFACE_PITCH_SHIFT); /* ignored */ surf[4] = 0; surf[5] = 0; diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c index 1c0183b..aed0b5d 100644 --- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c @@ -157,7 +157,7 @@ gen7_create_constant_surface(struct brw_context *brw, surf-ss2.width = w 0x7f;/* bits 6:0 of size or width */ surf-ss2.height = (w 7) 0x1fff; /* bits 19:7 of size or width */ surf-ss3.depth = (w 20) 0x7f;/* bits 26:20 of size or width */ - surf-ss3.pitch = (width * 16) - 1; /* ignored?? */ + surf-ss3.pitch = (16 - 1); /* ignored */ gen7_set_surface_tiling(surf, I915_TILING_NONE); /* tiling now allowed */ /* Emit relocation to surface contents. Section 5.1.1 of the gen4 ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965: Add . gitignore file to exclude automake build artifacts from git.
Module: Mesa Branch: master Commit: c03ad08e8dff99c3042a4ab3b6b979cf428aa6fa URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c03ad08e8dff99c3042a4ab3b6b979cf428aa6fa Author: Paul Berry stereotype...@gmail.com Date: Tue Jan 17 12:35:38 2012 -0800 i965: Add .gitignore file to exclude automake build artifacts from git. With the conversion to automake in commit e326480e4ebe8687948041c2dc5f5b7595559a2e, several additional build artifacts are created: src/mesa/drivers/dri/i965/.deps/ src/mesa/drivers/dri/i965/.libs/ src/mesa/drivers/dri/i965/Makefile src/mesa/drivers/dri/i965/Makefile.in src/mesa/drivers/dri/i965/i965_dri.la src/mesa/drivers/dri/i965/i965_symbols_test This patch adds all of these files to .gitignore. Reviewed-by: Matt Turner matts...@gmail.com Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/.gitignore |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/dri/i965/.gitignore b/src/mesa/drivers/dri/i965/.gitignore new file mode 100644 index 000..1557571 --- /dev/null +++ b/src/mesa/drivers/dri/i965/.gitignore @@ -0,0 +1,6 @@ +.deps +.libs +Makefile +Makefile.in +i965_dri.la +i965_symbols_test ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965/vs: Fix bogus assertion in emit_block_move()
Module: Mesa Branch: master Commit: e2274aa7398d6d710683c1a2518353750700bcc0 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e2274aa7398d6d710683c1a2518353750700bcc0 Author: Paul Berry stereotype...@gmail.com Date: Thu Jan 19 15:49:43 2012 -0800 i965/vs: Fix bogus assertion in emit_block_move() i965 processes assignments of whole structures using vec4_visitor::emit_block_move, a recursive function which visits each element of a structure or array (to arbitrary nesting depth) and copies it from the source to the destination. Then it increments the source and destination register numbers so that further recursive invocations will copy the rest of the structure. In addition, it sets the swizzle field for the source register to an appropriate value of swizzle_for_size(...) for the size of each element being copied, so that later optimization passes won't be fooled into thinking that unused vector elements are live. This all works fine. However, emit_block_move also contains an assertion to verify, before setting the swizzle field for the source register, that the source register doesn't already contain a nontrivial swizzle. The intention is to make sure that the caller of emit_block_move hasn't already done some swizzling of the data before the call, which emit_block_move would then counteract when it overwrites the swizzle field. But the assertion is at the lowest level of nesting of emit_block_move, which means that after the first element is copied, instead of checking the swizzle field set by the caller, it checks the swizzle field used when moving the previous element. That means that if the structure contains elements of different vector sizes (which therefore require different swizzles), the assertion will erroneously fire. This patch moves the assertion from emit_block_move to the calling function, vec4_visitor::visit(ir_assignment *). Since the caller is non-recursive, the assertion will only happen once, and won't be fooled by emit_block_move's modification of the swizzle field. This patch also reverts commit fe006a7 (i965/vs: Fix swizzle related assertion), which attempted to fix the bug by making the assertion more lenient, but only worked properly for structures, arrays, and matrices in which each constituent vector is the same size. This fixes the problem described in comment 9 of https://bugs.freedesktop.org/show_bug.cgi?id=40865. Unfortunately, it doesn't fix the whole bug, since the test in question is also failing due to lack of register spilling support in the VS. Fixes piglit test vs-assign-varied-struct. No piglit regressions on Sandy Bridge. This is a candidate for the 8.0 release branch. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=40865#c9 Reviewed-by: Eric Anholt e...@anholt.net Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 12 +--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index 898e78d..13ba18b 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -1546,9 +1546,6 @@ vec4_visitor::emit_block_move(dst_reg *dst, src_reg *src, dst-writemask = (1 type-vector_elements) - 1; - /* Do we need to worry about swizzling a swizzle? */ - assert(src-swizzle == BRW_SWIZZLE_NOOP - || src-swizzle == swizzle_for_size(type-vector_elements)); src-swizzle = swizzle_for_size(type-vector_elements); vec4_instruction *inst = emit(MOV(*dst, *src)); @@ -1631,6 +1628,15 @@ vec4_visitor::visit(ir_assignment *ir) emit_bool_to_cond_code(ir-condition, predicate); } + /* emit_block_move doesn't account for swizzles in the source register. + * This should be ok, since the source register is a structure or an + * array, and those can't be swizzled. But double-check to be sure. + */ + assert(src.swizzle == + (ir-rhs-type-is_matrix() + ? swizzle_for_size(ir-rhs-type-vector_elements) + : BRW_SWIZZLE_NOOP)); + emit_block_move(dst, src, ir-rhs-type, predicate); return; } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965/gen6: Fix segfault in transform feedback to DYNAMIC_DRAW buffers.
Module: Mesa Branch: master Commit: 6bc08ee56991ac3ca0fa0728c3907835282332b8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6bc08ee56991ac3ca0fa0728c3907835282332b8 Author: Paul Berry stereotype...@gmail.com Date: Mon Jan 23 16:11:05 2012 -0800 i965/gen6: Fix segfault in transform feedback to DYNAMIC_DRAW buffers. When storing data in a buffer of type DYNAMIC_DRAW, we don't create a drm_intel_bo for it; instead we store the data in system memory and defer allocation of the GPU buffer until it is needed. Therefore, in brw_update_sol_surface(), we can't just consult the buffer field of the intel_buffer_object structure; we need to call intel_bufferobj_buffer() to ensure that the deferred allocation occurs. This parallels a similar fix for gen7 (see commit ba6f4c9). Fixes piglit test EXT_transform_feedback/buffer-usage on gen6. This is a candidate for the 8.0 release branch. Reviewed-by: Eric Anholt e...@anholt.net --- src/mesa/drivers/dri/i965/brw_wm_surface_state.c |5 - 1 files changed, 4 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 7fd83ea..c77d83a 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -730,7 +730,10 @@ brw_update_sol_surface(struct brw_context *brw, uint32_t *out_offset, unsigned num_vector_components, unsigned stride_dwords, unsigned offset_dwords) { - drm_intel_bo *bo = intel_buffer_object(buffer_obj)-buffer; + struct intel_context *intel = brw-intel; + struct intel_buffer_object *intel_bo = intel_buffer_object(buffer_obj); + drm_intel_bo *bo = + intel_bufferobj_buffer(intel, intel_bo, INTEL_WRITE_PART); uint32_t *surf = brw_state_batch(brw, AUB_TRACE_SURFACE_STATE, 6 * 4, 32, out_offset); uint32_t pitch_minus_1 = 4*stride_dwords - 1; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965/gen6/GT1: Increase max_vs_entries to 256.
Module: Mesa Branch: master Commit: dc435ae774b1deed3d00b7c7d33133c08b626737 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=dc435ae774b1deed3d00b7c7d33133c08b626737 Author: Paul Berry stereotype...@gmail.com Date: Tue Jan 24 12:16:29 2012 -0800 i965/gen6/GT1: Increase max_vs_entries to 256. Previously, max_vs_entries was set to 128 for GT1, and 256 for GT2, based on the PRM (see Vol2, part1, p28). However, Bspec section 1.6.5 indicates that the maximum number of VS entries is 256 for GT1. No piglit regressions on GT1. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i965/brw_context.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index eb152f9..87ea1a5 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -328,7 +328,7 @@ brwCreateContext(int api, brw-max_vs_threads = 24; brw-max_gs_threads = 21; /* conservative; 24 if rendering disabled */ brw-urb.size = 32;/* volume 5c.5 section 5.1 */ -brw-urb.max_vs_entries = 128; /* volume 2a (see 3DSTATE_URB) */ +brw-urb.max_vs_entries = 256; /* volume 2a (see 3DSTATE_URB) */ brw-urb.max_gs_entries = 256; } brw-urb.gen6_gs_previously_active = false; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): glsl: Fix optimization tests after converting src/ glsl to automake.
Module: Mesa Branch: master Commit: ffe376d5a74dee837dc1a421de29ae551087630f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ffe376d5a74dee837dc1a421de29ae551087630f Author: Paul Berry stereotype...@gmail.com Date: Mon Jan 30 18:53:09 2012 -0800 glsl: Fix optimization tests after converting src/glsl to automake. Commit 99476561 (automake: src/glsl and src/glsl/glcpp) changed the build system so that src/glsl/glsl_test is not built by default. This inadvertently broke make check, since the tests in src/glsl/tests/lower_jumps (which are run by make check) rely on glsl_test. This patch ensures that make check builds glsl_test before running any tests. Reviewed-by: Matt Turner matts...@gmail.com --- Makefile |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/Makefile b/Makefile index 1fa369a..e593e7f 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,7 @@ doxygen: cd doxygen $(MAKE) check: + cd src/glsl $(MAKE) check cd src/glsl/tests/ ./optimization-test make -C tests check ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i915: Fix type of specoffset variable.
Module: Mesa Branch: master Commit: 6b0a07f9ce844a8a96e2583bd37ed8453bf151c6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6b0a07f9ce844a8a96e2583bd37ed8453bf151c6 Author: Paul Berry stereotype...@gmail.com Date: Fri Feb 10 19:51:55 2012 -0800 i915: Fix type of specoffset variable. Commit 2e5a1a2 (intel: Convert from GLboolean to 'bool' from stdbool.h.) converted the specoffset local variable (in intel_tris.c) from a GLboolean to a bool. However, GLboolean was the wrong type for specoffset--it should have been a GLuint (to match the declaration of specoffset in struct intel_context). This patch changes specoffset to the proper type. Fixes piglit test general/two-sided-lighting-separate-specular. This is a candidate for stable branches. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=45917 Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/mesa/drivers/dri/i915/intel_tris.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/mesa/drivers/dri/i915/intel_tris.c b/src/mesa/drivers/dri/i915/intel_tris.c index 23de6ea..a36011a 100644 --- a/src/mesa/drivers/dri/i915/intel_tris.c +++ b/src/mesa/drivers/dri/i915/intel_tris.c @@ -663,7 +663,7 @@ do { \ struct intel_context *intel = intel_context(ctx); \ GLuint color[n] = { 0, }, spec[n] = { 0, }; \ GLuint coloroffset = intel-coloroffset;\ - bool specoffset = intel-specoffset;\ + GLuint specoffset = intel-specoffset; \ (void) color; (void) spec; (void) coloroffset; (void) specoffset; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i915: Initialize swrast_texture_image structure fields.
Module: Mesa Branch: master Commit: 80513ec8b4c812b9c6249cc5824337a5f04ab34c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=80513ec8b4c812b9c6249cc5824337a5f04ab34c Author: Paul Berry stereotype...@gmail.com Date: Thu Feb 16 16:00:45 2012 -0800 i915: Initialize swrast_texture_image structure fields. Commit 980f6f1 (mesa: move gl_texture_image::Width/Height/DepthScale fields to swrast) moved the initialization of the Width, Height, and DepthScale fields to _swrast_alloc_texture_image_buffer(). However, i915 doesn't call this function because it performs its own buffer allocation. As a result, the Width, Height, and DepthScale fields weren't getting initialized properly, and some operations requiring swrast would fail. This patch ensures that Width, Height, and DepthScale are properly initialized by separating the code that sets them into a new function, _swrast_init_texture_image(), which is called by intel_alloc_texture_image_buffer() as well as _swrast_alloc_texture_image_buffer(). It also moves the initialization of _IsPowerOfTwo into this function. Fixes piglit test fbo/fbo-cubemap on i915. Partially fixes https://bugs.freedesktop.org/show_bug.cgi?id=41216 This is a candidate for the 8.0 branch. Reviewed-and-tested-by: Ian Romanick ian.d.roman...@intel.com Reviewed-by: Eric Anholt e...@anholt.net --- src/mesa/drivers/dri/intel/intel_tex.c |2 ++ src/mesa/swrast/s_texture.c| 21 +++-- src/mesa/swrast/swrast.h |4 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_tex.c b/src/mesa/drivers/dri/intel/intel_tex.c index 2ebd654..b3ac226 100644 --- a/src/mesa/drivers/dri/intel/intel_tex.c +++ b/src/mesa/drivers/dri/intel/intel_tex.c @@ -84,6 +84,8 @@ intel_alloc_texture_image_buffer(struct gl_context *ctx, assert(!intel_image-base.ImageOffsets); intel_image-base.ImageOffsets = malloc(slices * sizeof(GLuint)); + _swrast_init_texture_image(image, width, height, depth); + if (intel_texobj-mt intel_miptree_match_image(intel_texobj-mt, image)) { intel_miptree_reference(intel_image-mt, intel_texobj-mt); diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c index 72d3093..9718367 100644 --- a/src/mesa/swrast/s_texture.c +++ b/src/mesa/swrast/s_texture.c @@ -96,6 +96,25 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx, swImg-ImageOffsets[i] = i * width * height; } + _swrast_init_texture_image(texImage, width, height, depth); + + return GL_TRUE; +} + + +/** + * Code that overrides ctx-Driver.AllocTextureImageBuffer may use this to + * initialize the fields of swrast_texture_image without allocating the image + * buffer or initializing ImageOffsets or RowStride. + * + * Returns GL_TRUE on success, GL_FALSE on memory allocation failure. + */ +void +_swrast_init_texture_image(struct gl_texture_image *texImage, GLsizei width, + GLsizei height, GLsizei depth) +{ + struct swrast_texture_image *swImg = swrast_texture_image(texImage); + if ((width == 1 || _mesa_is_pow_two(texImage-Width2)) (height == 1 || _mesa_is_pow_two(texImage-Height2)) (depth == 1 || _mesa_is_pow_two(texImage-Depth2))) @@ -115,8 +134,6 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx, swImg-HeightScale = (GLfloat) texImage-Height; swImg-DepthScale = (GLfloat) texImage-Depth; } - - return GL_TRUE; } diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h index 468d22f..ad19eee 100644 --- a/src/mesa/swrast/swrast.h +++ b/src/mesa/swrast/swrast.h @@ -192,6 +192,10 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx, GLsizei height, GLsizei depth); extern void +_swrast_init_texture_image(struct gl_texture_image *texImage, GLsizei width, + GLsizei height, GLsizei depth); + +extern void _swrast_free_texture_image_buffer(struct gl_context *ctx, struct gl_texture_image *texImage); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): glapi: Fix incorrect enum value.
Module: Mesa Branch: master Commit: bc39de8c0b6bb19e411cfa8606f189c4868a5f01 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bc39de8c0b6bb19e411cfa8606f189c4868a5f01 Author: Paul Berry stereotype...@gmail.com Date: Wed Feb 15 10:35:10 2012 -0800 glapi: Fix incorrect enum value. From http://www.opengl.org/registry/specs/ARB/seamless_cube_map.txt: Accepted by the cap parameter of Enable, Disable and IsEnabled, and by the pname parameter of GetBooleanv, GetIntegerv, GetFloatv and GetDoublev: TEXTURE_CUBE_MAP_SEAMLESS 0x884F This caused a change in enums.c, which is manually built from the .xml files. Reviewed-by: Ian Romanick ian.d.roman...@intel.com --- src/mapi/glapi/gen/ARB_seamless_cube_map.xml |2 +- src/mesa/main/enums.c|7 --- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_seamless_cube_map.xml b/src/mapi/glapi/gen/ARB_seamless_cube_map.xml index 8dc827c..84e8aa8 100644 --- a/src/mapi/glapi/gen/ARB_seamless_cube_map.xml +++ b/src/mapi/glapi/gen/ARB_seamless_cube_map.xml @@ -4,7 +4,7 @@ OpenGLAPI category name=GL_ARB_seamless_cube_map number=65 -enum name=TEXTURE_CUBE_MAP_SEAMLESS count=1 value=0x88F4 +enum name=TEXTURE_CUBE_MAP_SEAMLESS count=1 value=0x884F size name=Get mode=get/ /enum /category diff --git a/src/mesa/main/enums.c b/src/mesa/main/enums.c index b00a738..c92a9a1 100644 --- a/src/mesa/main/enums.c +++ b/src/mesa/main/enums.c @@ -4460,7 +4460,7 @@ static const enum_elt all_enums[2340] = { 45645, 0x8519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */ { 45676, 0x8519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB */ { 45711, 0x8519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES */ - { 45746, 0x88F4 }, /* GL_TEXTURE_CUBE_MAP_SEAMLESS */ + { 45746, 0x884F }, /* GL_TEXTURE_CUBE_MAP_SEAMLESS */ { 45775, 0x8071 }, /* GL_TEXTURE_DEPTH */ { 45792, 0x884A }, /* GL_TEXTURE_DEPTH_SIZE */ { 45814, 0x884A }, /* GL_TEXTURE_DEPTH_SIZE_ARB */ @@ -4723,7 +4723,7 @@ static const enum_elt all_enums[2340] = { 52477, 0x0D17 }, /* GL_ZOOM_Y */ }; -static const unsigned reduced_enums[1571] = +static const unsigned reduced_enums[1572] = { 556, /* GL_FALSE */ 853, /* GL_LINES */ @@ -5806,6 +5806,7 @@ static const unsigned reduced_enums[1571] = 2038, /* GL_TEXTURE_COMPARE_MODE */ 2036, /* GL_TEXTURE_COMPARE_FUNC */ 284, /* GL_COMPARE_REF_TO_TEXTURE */ + 2079, /* GL_TEXTURE_CUBE_MAP_SEAMLESS */ 1400, /* GL_POINT_SPRITE */ 347, /* GL_COORD_REPLACE */ 1405, /* GL_POINT_SPRITE_R_MODE_NV */ @@ -5917,7 +5918,7 @@ static const unsigned reduced_enums[1571] = 1368, /* GL_PIXEL_UNPACK_BUFFER_BINDING */ 400, /* GL_DEPTH24_STENCIL8 */ 2134, /* GL_TEXTURE_STENCIL_SIZE */ - 2079, /* GL_TEXTURE_CUBE_MAP_SEAMLESS */ + 1096, /* GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ 1094, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */ 1097, /* GL_MAX_PROGRAM_IF_DEPTH_NV */ 1101, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */ ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): i965: fix mask used to write to clip distance registers when gen6
Module: Mesa Branch: master Commit: 95c2e0b601fd333cc73d7f214a3cd949f7e45aac URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=95c2e0b601fd333cc73d7f214a3cd949f7e45aac Author: Paul Berry stereotype...@gmail.com Date: Sun Jun 12 10:47:46 2011 -0700 i965: fix mask used to write to clip distance registers when gen6 In gen6 and above, clip distances 0-3 are written to message register 3's xyzw components, and 4-7 to message register 4's xyzw components. Therefore when when writing the clip distances we need to examine the lower 2 bits of the clip distance index to see which component to write to. emit_vertex_write() was examining the lower 3 bits, causing clip distances 4-7 not to be written correctly. Fixes piglit test vs-clip-vertex-01.shader_test --- src/mesa/drivers/dri/i965/brw_vs_emit.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c index b6c9e5a..9d73334 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c @@ -1635,7 +1635,7 @@ static void emit_vertex_write( struct brw_vs_compile *c) else m = brw_message_reg(4); - brw_DP4(p, brw_writemask(m, (1 (i 7))),pos, c-userplane[i]); + brw_DP4(p, brw_writemask(m, (1 (i 3))),pos, c-userplane[i]); } } } else if ((c-prog_data.outputs_written ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): glsl: permit explicit locations on fragment shader outputs, not inputs
Module: Mesa Branch: master Commit: b078aad8ab22d840456688480a8c27d4664297ce URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b078aad8ab22d840456688480a8c27d4664297ce Author: Paul Berry stereotype...@gmail.com Date: Tue Jun 28 09:42:24 2011 -0700 glsl: permit explicit locations on fragment shader outputs, not inputs From the OpenGL docs for GL_ARB_explicit_attrib_location: This extension provides a method to pre-assign attribute locations to named vertex shader inputs and color numbers to named fragment shader outputs. This was accidentally implemented for fragment shader inputs. This patch fixes it to apply to fragment shader outputs. Fixes piglit tests spec/ARB_explicit_attrib_location/1.{10,20}/compiler/layout-{01,03,06,07,08,09,10}.frag Reviewed-by: Ian Romanick ian.d.roman...@intel.com NOTE: This is a candidate for the 7.10 and 7.11 branches. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=38624 --- src/glsl/ast_to_hir.cpp |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 3b87f0d..35cb206 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1940,7 +1940,7 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual, break; case fragment_shader: -if (!global_scope || (var-mode != ir_var_in)) { +if (!global_scope || (var-mode != ir_var_out)) { fail = true; string = output; } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): glsl: Rewrote _mesa_glsl_process_extension to use table-driven logic.
Module: Mesa Branch: master Commit: 3097715d41da4b725b7ce9f9d5bbc0f684cbf0a6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3097715d41da4b725b7ce9f9d5bbc0f684cbf0a6 Author: Paul Berry stereotype...@gmail.com Date: Fri Jun 24 15:34:04 2011 -0700 glsl: Rewrote _mesa_glsl_process_extension to use table-driven logic. Instead of using a chain of manually maintained if/else blocks to handle #extension directives, we now consult a table that specifies, for each extension, the circumstances under which it is available, and what flags in _mesa_glsl_parse_state need to be set in order to activate it. This makes it easier to add new GLSL extensions in the future, and fixes the following bugs: - Previously, _mesa_glsl_process_extension would sometimes set the _enable and _warn flags for an extension before checking whether the extension was supported by the driver; as a result, specifying enable behavior for an unsupported extension would sometimes cause front-end support for that extension to be switched on in spite of the fact that back-end support was not available, leading to strange failures, such as those in https://bugs.freedesktop.org/show_bug.cgi?id=38015. - #extension all: warn and #extension all: disable had no effect. Notes: - All extensions are currently marked as unavailable in geometry shaders. This should not have any adverse effects since geometry shaders aren't supported yet. When we return to working on geometry shader support, we'll need to update the table for those extensions that are available in geometry shaders. - Previous to this commit, if a shader mentioned ARB_shader_texture_lod, extension ARB_texture_rectangle would be automatically turned on in order to ensure that the types sampler2DRect and sampler2DRectShadow would be defined. This was unnecessary, because (a) ARB_shader_texture_lod works perfectly well without those types provided that the builtin functions that reference them are not called, and (b) ARB_texture_rectangle is enabled by default in non-ES contexts anyway. I eliminated this unnecessary behavior in order to make the behavior of all extensions consistent. NOTE: This is a candidate for the 7.10 and 7.11 branches. Reviewed-by: Ian Romanick ian.d.roman...@intel.com --- src/glsl/glsl_parser_extras.cpp | 327 ++- 1 files changed, 218 insertions(+), 109 deletions(-) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index d9aa300..cc78137 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -165,133 +165,242 @@ _mesa_glsl_warning(const YYLTYPE *locp, _mesa_glsl_parse_state *state, } +/** + * Enum representing the possible behaviors that can be specified in + * an #extension directive. + */ +enum ext_behavior { + extension_disable, + extension_enable, + extension_require, + extension_warn +}; + +/** + * Element type for _mesa_glsl_supported_extensions + */ +struct _mesa_glsl_extension { + /** +* Name of the extension when referred to in a GLSL extension +* statement +*/ + const char *name; + + /** True if this extension is available to vertex shaders */ + bool avail_in_VS; + + /** True if this extension is available to geometry shaders */ + bool avail_in_GS; + + /** True if this extension is available to fragment shaders */ + bool avail_in_FS; + + /** True if this extension is available to desktop GL shaders */ + bool avail_in_GL; + + /** True if this extension is available to GLES shaders */ + bool avail_in_ES; + + /** +* Flag in the gl_extensions struct indicating whether this +* extension is supported by the driver, or +* gl_extensions::dummy_true if supported by all drivers. +* +* Note: the type (GLboolean gl_extensions::*) is a pointer to +* member type, the type-safe alternative to the offsetof macro. +* In a nutshell: +* +* - foo bar::* p declares p to be an offset to a field of type +* foo that exists within struct bar +* - bar::baz computes the offset of field baz within struct bar +* - x.*p accesses the field of x that exists at offset p +* - x-*p is equivalent to (*x).*p +*/ + const GLboolean gl_extensions::* supported_flag; + + /** +* Flag in the _mesa_glsl_parse_state struct that should be set +* when this extension is enabled. +* +* See note in _mesa_glsl_extension::supported_flag about pointer +* to member types. +*/ + bool _mesa_glsl_parse_state::* enable_flag; + + /** +* Flag in the _mesa_glsl_parse_state struct that should be set +* when the shader requests warn behavior for this extension. +* +* See note in _mesa_glsl_extension::supported_flag about pointer +* to member types. +*/ + bool _mesa_glsl_parse_state::* warn_flag; + + + bool compatible_with_state(const _mesa_glsl_parse_state *state) const; + void set_flags
Mesa (master): glsl: Changed extension enable bits to bools.
Module: Mesa Branch: master Commit: 9c4445de6e69d021491361d884bf172c05189d61 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9c4445de6e69d021491361d884bf172c05189d61 Author: Paul Berry stereotype...@gmail.com Date: Fri Jun 24 12:33:30 2011 -0700 glsl: Changed extension enable bits to bools. These were previously 1-bit-wide bitfields. Changing them to bools has a negligible performance impact, and allows them to be accessed by offset as well as by direct structure access. NOTE: This is a candidate for the 7.10 and 7.11 branches. Reviewed-by: Ian Romanick ian.d.roman...@intel.com --- src/glsl/glsl_parser_extras.h | 44 1 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index 878d2ae..2f4d3cb 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -156,28 +156,28 @@ struct _mesa_glsl_parse_state { * \name Enable bits for GLSL extensions */ /*@{*/ - unsigned ARB_draw_buffers_enable:1; - unsigned ARB_draw_buffers_warn:1; - unsigned ARB_draw_instanced_enable:1; - unsigned ARB_draw_instanced_warn:1; - unsigned ARB_explicit_attrib_location_enable:1; - unsigned ARB_explicit_attrib_location_warn:1; - unsigned ARB_fragment_coord_conventions_enable:1; - unsigned ARB_fragment_coord_conventions_warn:1; - unsigned ARB_texture_rectangle_enable:1; - unsigned ARB_texture_rectangle_warn:1; - unsigned EXT_texture_array_enable:1; - unsigned EXT_texture_array_warn:1; - unsigned ARB_shader_texture_lod_enable:1; - unsigned ARB_shader_texture_lod_warn:1; - unsigned ARB_shader_stencil_export_enable:1; - unsigned ARB_shader_stencil_export_warn:1; - unsigned AMD_conservative_depth_enable:1; - unsigned AMD_conservative_depth_warn:1; - unsigned AMD_shader_stencil_export_enable:1; - unsigned AMD_shader_stencil_export_warn:1; - unsigned OES_texture_3D_enable:1; - unsigned OES_texture_3D_warn:1; + bool ARB_draw_buffers_enable; + bool ARB_draw_buffers_warn; + bool ARB_draw_instanced_enable; + bool ARB_draw_instanced_warn; + bool ARB_explicit_attrib_location_enable; + bool ARB_explicit_attrib_location_warn; + bool ARB_fragment_coord_conventions_enable; + bool ARB_fragment_coord_conventions_warn; + bool ARB_texture_rectangle_enable; + bool ARB_texture_rectangle_warn; + bool EXT_texture_array_enable; + bool EXT_texture_array_warn; + bool ARB_shader_texture_lod_enable; + bool ARB_shader_texture_lod_warn; + bool ARB_shader_stencil_export_enable; + bool ARB_shader_stencil_export_warn; + bool AMD_conservative_depth_enable; + bool AMD_conservative_depth_warn; + bool AMD_shader_stencil_export_enable; + bool AMD_shader_stencil_export_warn; + bool OES_texture_3D_enable; + bool OES_texture_3D_warn; /*@}*/ /** Extensions supported by the OpenGL implementation. */ ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): glsl: Remove unused function prototypes.
Module: Mesa Branch: master Commit: 5fb79fc69f56cf2d8d44e4c6c2d8b862bc631139 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5fb79fc69f56cf2d8d44e4c6c2d8b862bc631139 Author: Paul Berry stereotype...@gmail.com Date: Tue Jul 5 11:29:40 2011 -0700 glsl: Remove unused function prototypes. No functional change. Remove prototypes for do_mod_to_fract() and do_sub_to_add_neg(), which haven't existed since November 2010. --- src/glsl/ir_optimization.h |2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h index dd26567..59a0407 100644 --- a/src/glsl/ir_optimization.h +++ b/src/glsl/ir_optimization.h @@ -56,10 +56,8 @@ bool do_if_simplification(exec_list *instructions); bool do_discard_simplification(exec_list *instructions); bool lower_if_to_cond_assign(exec_list *instructions, unsigned max_depth = 0); bool do_mat_op_to_vec(exec_list *instructions); -bool do_mod_to_fract(exec_list *instructions); bool do_noop_swizzle(exec_list *instructions); bool do_structure_splitting(exec_list *instructions); -bool do_sub_to_add_neg(exec_list *instructions); bool do_swizzle_swizzle(exec_list *instructions); bool do_tree_grafting(exec_list *instructions); bool do_vec_index_to_cond_assign(exec_list *instructions); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): glsl: Make ir_reader able to read plain (return) statements.
Module: Mesa Branch: master Commit: f4830be938c8fa33086f73cab19a53ab3e14cb9c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f4830be938c8fa33086f73cab19a53ab3e14cb9c Author: Paul Berry stereotype...@gmail.com Date: Wed Jun 29 15:30:40 2011 -0700 glsl: Make ir_reader able to read plain (return) statements. Previously ir_reader was only able to handle return of non-void. This patch is necessary in order to allow optimization passes to be tested in isolation. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/glsl/ir_reader.cpp | 24 +--- 1 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index 30df257..f3a6217 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -482,19 +482,21 @@ ir_reader::read_return(s_expression *expr) { s_expression *s_retval; - s_pattern pat[] = { return, s_retval}; - if (!MATCH(expr, pat)) { - ir_read_error(expr, expected (return rvalue)); - return NULL; - } - - ir_rvalue *retval = read_rvalue(s_retval); - if (retval == NULL) { - ir_read_error(NULL, when reading return value); + s_pattern return_value_pat[] = { return, s_retval}; + s_pattern return_void_pat[] = { return }; + if (MATCH(expr, return_value_pat)) { + ir_rvalue *retval = read_rvalue(s_retval); + if (retval == NULL) { + ir_read_error(NULL, when reading return value); + return NULL; + } + return new(mem_ctx) ir_return(retval); + } else if (MATCH(expr, return_void_pat)) { + return new(mem_ctx) ir_return; + } else { + ir_read_error(expr, expected (return rvalue) or (return)); return NULL; } - - return new(mem_ctx) ir_return(retval); } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): glsl: Refactor logic for determining whether to lower return statements.
Module: Mesa Branch: master Commit: dbaa2e627effbe1361e1a69c23cf247cf86f2709 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=dbaa2e627effbe1361e1a69c23cf247cf86f2709 Author: Paul Berry stereotype...@gmail.com Date: Fri Jul 1 11:59:32 2011 -0700 glsl: Refactor logic for determining whether to lower return statements. Previously, do_lower_jumps.cpp determined whether to lower return statements in ir_lower_jumps_visitor::should_lower_jumps(). Moved this logic to ir_lower_jumps_visitor::visit(ir_function_signature *), so that it can be used in determining whether to lower a return statement at the end of a function. --- src/glsl/lower_jumps.cpp | 19 --- 1 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/glsl/lower_jumps.cpp b/src/glsl/lower_jumps.cpp index da85c6b..fa247c6 100644 --- a/src/glsl/lower_jumps.cpp +++ b/src/glsl/lower_jumps.cpp @@ -210,16 +210,17 @@ struct function_record ir_function_signature* signature; ir_variable* return_flag; /* used to break out of all loops and then jump to the return instruction */ ir_variable* return_value; - bool is_main; + bool lower_return; unsigned nesting_depth; - function_record(ir_function_signature* p_signature = 0) + function_record(ir_function_signature* p_signature = 0, + bool lower_return = false) { this-signature = p_signature; this-return_flag = 0; this-return_value = 0; this-nesting_depth = 0; - this-is_main = this-signature (strcmp(this-signature-function_name(), main) == 0); + this-lower_return = lower_return; } ir_variable* get_return_flag() @@ -398,10 +399,8 @@ struct ir_lower_jumps_visitor : public ir_control_flow_visitor { /* never lower return at the end of a this-function */ if(this-function.nesting_depth == 0 ir-get_next()-is_tail_sentinel()) lower = false; - else if (this-function.is_main) -lower = lower_main_return; else -lower = lower_sub_return; +lower = this-function.lower_return; break; } return lower; @@ -833,9 +832,15 @@ lower_continue: assert(!this-function.signature); assert(!this-loop.loop); + bool lower_return; + if (strcmp(ir-function_name(), main) == 0) + lower_return = lower_main_return; + else + lower_return = lower_sub_return; + function_record saved_function = this-function; loop_record saved_loop = this-loop; - this-function = function_record(ir); + this-function = function_record(ir, lower_return); this-loop = loop_record(ir); assert(!this-loop.loop); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): glsl: Add explanatory comments to lower_jumps.cpp.
Module: Mesa Branch: master Commit: e2c748aec5363981a05f21f26a0c4d37ccf6419d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e2c748aec5363981a05f21f26a0c4d37ccf6419d Author: Paul Berry stereotype...@gmail.com Date: Wed Jun 29 10:28:40 2011 -0700 glsl: Add explanatory comments to lower_jumps.cpp. No functional change. Reviewed-by: Kenneth Graunke kenn...@whitecape.org --- src/glsl/lower_jumps.cpp | 336 -- 1 files changed, 322 insertions(+), 14 deletions(-) diff --git a/src/glsl/lower_jumps.cpp b/src/glsl/lower_jumps.cpp index dd2601d..da85c6b 100644 --- a/src/glsl/lower_jumps.cpp +++ b/src/glsl/lower_jumps.cpp @@ -60,12 +60,76 @@ #include string.h #include ir.h +/** + * Enum recording the result of analyzing how control flow might exit + * an IR node. + * + * Each possible value of jump_strength indicates a strictly stronger + * guarantee on control flow than the previous value. + * + * The ordering of strengths roughly reflects the way jumps are + * lowered: jumps with higher strength tend to be lowered to jumps of + * lower strength. Accordingly, strength is used as a heuristic to + * determine which lowering to perform first. + * + * This enum is also used by get_jump_strength() to categorize + * instructions as either break, continue, return, or other. When + * used in this fashion, strength_always_clears_execute_flag is not + * used. + * + * The control flow analysis made by this optimization pass makes two + * simplifying assumptions: + * + * - It ignores discard instructions, since they are lowered by a + * separate pass (lower_discard.cpp). + * + * - It assumes it is always possible for control to flow from a loop + * to the instruction immediately following it. Technically, this + * is not true (since all execution paths through the loop might + * jump back to the top, or return from the function). + * + * Both of these simplifying assumtions are safe, since they can never + * cause reachable code to be incorrectly classified as unreachable; + * they can only do the opposite. + */ enum jump_strength { + /** +* Analysis has produced no guarantee on how control flow might +* exit this IR node. It might fall out the bottom (with or +* without clearing the execute flag, if present), or it might +* continue to the top of the innermost enclosing loop, break out +* of it, or return from the function. +*/ strength_none, + + /** +* The only way control can fall out the bottom of this node is +* through a code path that clears the execute flag. It might also +* continue to the top of the innermost enclosing loop, break out +* of it, or return from the function. +*/ strength_always_clears_execute_flag, + + /** +* Control cannot fall out the bottom of this node. It might +* continue to the top of the innermost enclosing loop, break out +* of it, or return from the function. +*/ strength_continue, + + /** +* Control cannot fall out the bottom of this node, or continue the +* top of the innermost enclosing loop. It can only break out of +* it or return from the function. +*/ strength_break, + + /** +* Control cannot fall out the bottom of this node, continue to the +* top of the innermost enclosing loop, or break out of it. It can +* only return from the function. +*/ strength_return }; @@ -180,6 +244,27 @@ struct function_record }; struct ir_lower_jumps_visitor : public ir_control_flow_visitor { + /* Postconditions: on exit of any visit() function: +* +* ANALYSIS: this-block.min_strength, +* this-block.may_clear_execute_flag, and +* this-loop.may_set_return_flag are updated to reflect the +* characteristics of the visited statement. +* +* DEAD_CODE_ELIMINATION: If this-block.min_strength is not +* strength_none, the visited node is at the end of its exec_list. +* In other words, any unreachable statements that follow the +* visited statement in its exec_list have been removed. +* +* CONTAINED_JUMPS_LOWERED: If the visited statement contains other +* statements, then should_lower_jump() is false for all of the +* return, break, or continue statements it contains. +* +* Note that visiting a jump does not lower it. That is the +* responsibility of the statement (or function signature) that +* contains the jump. +*/ + bool progress; struct function_record function; @@ -220,18 +305,57 @@ struct ir_lower_jumps_visitor : public ir_control_flow_visitor { virtual void visit(class ir_loop_jump * ir) { + /* Eliminate all instructions after each one, since they are + * unreachable. This satisfies the DEAD_CODE_ELIMINATION + * postcondition. + */ truncate_after_instruction(ir); + + /* Set this-block.min_strength based on this instruction. This + * satisfies the ANALYSIS
Mesa (master): glsl: lower unconditional returns and continues in loops.
Module: Mesa Branch: master Commit: 03145ba655ad9173a74b853843eccaae78ff392f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=03145ba655ad9173a74b853843eccaae78ff392f Author: Paul Berry stereotype...@gmail.com Date: Fri Jul 1 18:26:05 2011 -0700 glsl: lower unconditional returns and continues in loops. Previously, lower_jumps.cpp would only lower return and continue statements that appeared inside conditionals. This patch makes it lower unconditional returns and continue statements that occur inside a loop. Such unconditional flow control statements would be unlikely to be explicitly coded by a reasonable user, however they might arise as a result of other optimizations. Without this patch, lower_jumps.cpp might not lower certain return and continue statements, causing some backends to fail. Fixes unit tests test_lower_return_void_at_end_of_loop and test_remove_continue_at_end_of_loop. --- src/glsl/lower_jumps.cpp | 62 -- 1 files changed, 54 insertions(+), 8 deletions(-) diff --git a/src/glsl/lower_jumps.cpp b/src/glsl/lower_jumps.cpp index eceba09..cbdd8ea 100644 --- a/src/glsl/lower_jumps.cpp +++ b/src/glsl/lower_jumps.cpp @@ -304,6 +304,43 @@ struct ir_lower_jumps_visitor : public ir_control_flow_visitor { } } + /** +* Insert the instructions necessary to lower a return statement, +* before the given return instruction. +*/ + void insert_lowered_return(ir_return *ir) + { + ir_variable* return_flag = this-function.get_return_flag(); + if(!this-function.signature-return_type-is_void()) { + ir_variable* return_value = this-function.get_return_value(); + ir-insert_before( +new(ir) ir_assignment( + new (ir) ir_dereference_variable(return_value), + ir-value)); + } + ir-insert_before( + new(ir) ir_assignment( +new (ir) ir_dereference_variable(return_flag), +new (ir) ir_constant(true))); + this-loop.may_set_return_flag = true; + } + + /** +* If the given instruction is a return, lower it to instructions +* that store the return value (if there is one), set the return +* flag, and then break. +* +* It is safe to pass NULL to this function. +*/ + void lower_return_unconditionally(ir_instruction *ir) + { + if (get_jump_strength(ir) != strength_return) { + return; + } + insert_lowered_return((ir_return*)ir); + ir-replace_with(new(ir) ir_loop_jump(ir_loop_jump::jump_break)); + } + virtual void visit(class ir_loop_jump * ir) { /* Eliminate all instructions after each one, since they are @@ -532,13 +569,7 @@ retry: /* we get here if we put code after the if inside a branch */ * that: 1. store the return value (if this function has a * non-void return) and 2. set the return flag */ -ir_variable* return_flag = this-function.get_return_flag(); -if(!this-function.signature-return_type-is_void()) { - ir_variable* return_value = this-function.get_return_value(); - jumps[lower]-insert_before(new(ir) ir_assignment(new (ir) ir_dereference_variable(return_value), ((ir_return*)jumps[lower])-value, NULL)); -} -jumps[lower]-insert_before(new(ir) ir_assignment(new (ir) ir_dereference_variable(return_flag), new (ir) ir_constant(true), NULL)); -this-loop.may_set_return_flag = true; +insert_lowered_return((ir_return*)jumps[lower]); if(this-loop.loop) { /* If we are in a loop, replace the return instruction * with a break instruction, and then loop so that the @@ -761,10 +792,25 @@ lower_continue: /* Recursively lower nested jumps. This satisfies the * CONTAINED_JUMPS_LOWERED postcondition, except in the case of * an unconditional continue or return at the bottom of the - * loop. + * loop, which are handled below. */ block_record body = visit_block(ir-body_instructions); + /* If the loop ends in an unconditional continue, eliminate it + * because it is redundant. + */ + ir_instruction *ir_last + = (ir_instruction *) ir-body_instructions.get_tail(); + if (get_jump_strength(ir_last) == strength_continue) { + ir_last-remove(); + } + + /* If the loop ends in an unconditional return, and we are + * lowering returns, lower it. + */ + if (this-function.lower_return) + lower_return_unconditionally(ir_last); + if(body.min_strength = strength_break) { /* FINISHME: If the min_strength of the loop body is * strength_break or strength_return, that means that it ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa
Mesa (master): glsl: Lower unconditional return statements.
Module: Mesa Branch: master Commit: afc9a50fba39df520046019c6993d7b7559329ea URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=afc9a50fba39df520046019c6993d7b7559329ea Author: Paul Berry stereotype...@gmail.com Date: Fri Jul 1 12:14:07 2011 -0700 glsl: Lower unconditional return statements. Previously, lower_jumps.cpp only lowered return statements that appeared inside of an if statement. Without this patch, lower_jumps.cpp might not lower certain return statements, causing some back-ends to fail (as in bug #36669). Fixes unit test test_lower_returns_1. --- src/glsl/lower_jumps.cpp | 14 ++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/src/glsl/lower_jumps.cpp b/src/glsl/lower_jumps.cpp index fa247c6..eceba09 100644 --- a/src/glsl/lower_jumps.cpp +++ b/src/glsl/lower_jumps.cpp @@ -851,6 +851,20 @@ lower_continue: */ visit_block(ir-body); + /* If the body ended in an unconditional return of non-void, + * then we don't need to lower it because it's the one canonical + * return. + * + * If the body ended in a return of void, eliminate it because + * it is redundant. + */ + if (ir-return_type-is_void() + get_jump_strength((ir_instruction *) ir-body.get_tail())) { + ir_jump *jump = (ir_jump *) ir-body.get_tail(); + assert (jump-ir_type == ir_type_return); + jump-remove(); + } + if(this-function.return_value) ir-body.push_tail(new(ir) ir_return(new (ir) ir_dereference_variable(this-function.return_value))); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): glsl: In lower_jumps.cpp, lower both branches of a conditional.
Module: Mesa Branch: master Commit: e71b4ab8a64bf978b2036976a41e30996eebb0c8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e71b4ab8a64bf978b2036976a41e30996eebb0c8 Author: Paul Berry stereotype...@gmail.com Date: Fri Jul 1 15:33:36 2011 -0700 glsl: In lower_jumps.cpp, lower both branches of a conditional. Previously, lower_jumps.cpp would break out of its loop after lowering a jump instruction in just the then- or else-branch of a conditional, and it would fail to lower a jump instruction occurring in the other branch. Without this patch, lower_jumps.cpp may require multiple passes in order to lower all jumps. This results in sub-optimal output because lower_jumps.cpp produces a brand new set of temporary variables each time it is run, and the redundant temporary variables are not guaranteed to be eliminated by later optimization passes. Fixes unit test test_lower_returns_4. --- src/glsl/lower_jumps.cpp |5 - 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/src/glsl/lower_jumps.cpp b/src/glsl/lower_jumps.cpp index 199a018..0789782 100644 --- a/src/glsl/lower_jumps.cpp +++ b/src/glsl/lower_jumps.cpp @@ -638,7 +638,10 @@ lower_continue: block_records[lower].min_strength = strength_always_clears_execute_flag; block_records[lower].may_clear_execute_flag = true; this-progress = true; -break; + +/* Let the loop run again, in case the other branch of the + * if needs to be lowered too. + */ } } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): glsl: Lower break instructions when necessary at the end of a loop.
Module: Mesa Branch: master Commit: 067c9d7bd776260298ceabda026425ed7e4eb161 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=067c9d7bd776260298ceabda026425ed7e4eb161 Author: Paul Berry stereotype...@gmail.com Date: Fri Jul 1 17:29:35 2011 -0700 glsl: Lower break instructions when necessary at the end of a loop. Normally lower_jumps.cpp doesn't need to lower a break instruction that occurs at the end of a loop, because all back-ends can produce proper GPU instructions for a break instruction in this canonical location. However, if other break instructions within the loop are already being lowered, then a break instruction at the end of the loop needs to be lowered too, since after the optimization is complete a new conditional break will be inserted at the end of the loop. Without this patch, lower_jumps.cpp may require multiple passes in order to lower all jumps. This results in sub-optimal output because lower_jumps.cpp produces a brand new set of temporary variables each time it is run, and the redundant temporary variables are not guaranteed to be eliminated by later optimization passes. Fixes unit test test_lower_breaks_6. --- src/glsl/lower_jumps.cpp | 55 +- 1 files changed, 54 insertions(+), 1 deletions(-) diff --git a/src/glsl/lower_jumps.cpp b/src/glsl/lower_jumps.cpp index 0789782..6187499 100644 --- a/src/glsl/lower_jumps.cpp +++ b/src/glsl/lower_jumps.cpp @@ -341,6 +341,50 @@ struct ir_lower_jumps_visitor : public ir_control_flow_visitor { ir-replace_with(new(ir) ir_loop_jump(ir_loop_jump::jump_break)); } + /** +* Create the necessary instruction to replace a break instruction. +*/ + ir_instruction *create_lowered_break() + { + void *ctx = this-function.signature; + return new(ctx) ir_assignment( + new(ctx) ir_dereference_variable(this-loop.get_break_flag()), + new(ctx) ir_constant(true), + 0); + } + + /** +* If the given instruction is a break, lower it to an instruction +* that sets the break flag, without consulting +* should_lower_jump(). +* +* It is safe to pass NULL to this function. +*/ + void lower_break_unconditionally(ir_instruction *ir) + { + if (get_jump_strength(ir) != strength_break) { + return; + } + ir-replace_with(create_lowered_break()); + } + + /** +* If the block ends in a conditional or unconditional break, lower +* it, even though should_lower_jump() says it needn't be lowered. +*/ + void lower_final_breaks(exec_list *block) + { + ir_instruction *ir = (ir_instruction *) block-get_tail(); + lower_break_unconditionally(ir); + ir_if *ir_if = ir-as_if(); + if (ir_if) { + lower_break_unconditionally( + (ir_instruction *) ir_if-then_instructions.get_tail()); + lower_break_unconditionally( + (ir_instruction *) ir_if-else_instructions.get_tail()); + } + } + virtual void visit(class ir_loop_jump * ir) { /* Eliminate all instructions after each one, since they are @@ -616,7 +660,7 @@ retry: /* we get here if we put code after the if inside a branch */ * The visit() function for the loop will ensure that the * break flag is checked after executing the loop body. */ -jumps[lower]-insert_before(new(ir) ir_assignment(new (ir) ir_dereference_variable(this-loop.get_break_flag()), new (ir) ir_constant(true), 0)); +jumps[lower]-insert_before(create_lowered_break()); goto lower_continue; } else if(jump_strengths[lower] == strength_continue) { lower_continue: @@ -836,6 +880,9 @@ lower_continue: } if(this-loop.break_flag) { + /* We only get here if we are lowering breaks */ + assert (lower_break); + /* If a break flag was generated while visiting the body of * the loop, then at least one break was lowered, so we need * to generate an if statement at the end of the loop that @@ -843,7 +890,13 @@ lower_continue: * generate won't violate the CONTAINED_JUMPS_LOWERED * postcondition, because should_lower_jump() always returns * false for a break that happens at the end of a loop. + * + * However, if the loop already ends in a conditional or + * unconditional break, then we need to lower that break, + * because it won't be at the end of the loop anymore. */ + lower_final_breaks(ir-body_instructions); + ir_if* break_if = new(ir) ir_if(new(ir) ir_dereference_variable(this-loop.break_flag)); break_if-then_instructions.push_tail(new(ir) ir_loop_jump(ir_loop_jump::jump_break)); ir-body_instructions.push_tail(break_if); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http
Mesa (master): glsl: Ensure that sampler declarations are always uniform or in parameters.
Module: Mesa Branch: master Commit: f07221056e1822187546b76387714b3172f9b2c5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f07221056e1822187546b76387714b3172f9b2c5 Author: Paul Berry stereotype...@gmail.com Date: Tue Jul 12 12:03:02 2011 -0700 glsl: Ensure that sampler declarations are always uniform or in parameters. This brings us into compliance with page 17 (page 22 of the PDF) of the GLSL 1.20 spec: [Sampler types] can only be declared as function parameters or uniform variables (see Section 4.3.5 Uniform). ... [Samplers] cannot be used as out or inout function parameters. The spec isn't explicit about whether this rule applies to structs/arrays containing shaders, but the intent seems to be to ensure that it can always be determined at compile time which sampler is being used in each texture lookup. So to avoid creating a loophole, the rule needs to apply to structs/arrays containing shaders as well. Fixes piglit tests spec/glsl-1.10/compiler/samplers/*.frag, and fixes bug 38987. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=38987 Reviewed-by: Ian Romanick ian.d.roman...@intel.com --- src/glsl/ast_to_hir.cpp | 35 +++ 1 files changed, 35 insertions(+), 0 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 2e54e8c..2312c29 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -2704,6 +2704,17 @@ ast_declarator_list::hir(exec_list *instructions, : and integer); } + /* From page 17 (page 23 of the PDF) of the GLSL 1.20 spec: + * + *[Sampler types] can only be declared as function + *parameters or uniform variables (see Section 4.3.5 + *Uniform). + */ + if (var_type-contains_sampler() + !this-type-qualifier.flags.q.uniform) { + _mesa_glsl_error(loc, state, samplers must be declared uniform); + } + /* Process the initializer and add its instructions to a temporary * list. This list will be added to the instruction stream (below) after * the declaration is added. This is done because in some cases (such as @@ -2864,6 +2875,18 @@ ast_parameter_declarator::hir(exec_list *instructions, */ apply_type_qualifier_to_variable( this-type-qualifier, var, state, loc); + /* From page 17 (page 23 of the PDF) of the GLSL 1.20 spec: +* +*Samplers cannot be treated as l-values; hence cannot be used +*as out or inout function parameters, nor can they be assigned +*into. +*/ + if ((var-mode == ir_var_inout || var-mode == ir_var_out) +type-contains_sampler()) { + _mesa_glsl_error(loc, state, out and inout parameters cannot contain samplers); + type = glsl_type::error_type; + } + instructions-push_tail(var); /* Parameter declarations do not have r-values. @@ -2992,6 +3015,18 @@ ast_function::hir(exec_list *instructions, function `%s' return type has qualifiers, name); } + /* From page 17 (page 23 of the PDF) of the GLSL 1.20 spec: +* +*[Sampler types] can only be declared as function parameters +*or uniform variables (see Section 4.3.5 Uniform). +*/ + if (return_type-contains_sampler()) { + YYLTYPE loc = this-get_location(); + _mesa_glsl_error(loc, state, + function `%s' return type can't contain a sampler, + name); + } + /* Verify that this function's signature either doesn't match a previously * seen signature for a function with the same name, or, if a match is found, * that the previously seen signature does not have an associated definition. ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: Add an ifndef guard around the definition of the INLINE macro
Module: Mesa Branch: master Commit: 12c22cab77f35a887d9f6790e0de4a8fa4b3b575 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=12c22cab77f35a887d9f6790e0de4a8fa4b3b575 Author: Paul Berry stereotype...@gmail.com Date: Thu Jul 7 13:03:45 2011 -0700 mesa: Add an ifndef guard around the definition of the INLINE macro Several Mesa headers redundantly define the INLINE macro. Adding this guard prevents the compiler from complaining about macro redefinition. Reviewed-by: Brian Paul bri...@vmware.com Reviewed-by: Kenneth Graunke kenn...@whitecape.org Reviewed-by: Chad Versace c...@chad-versace.us --- src/mesa/main/compiler.h | 42 ++ 1 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h index 743841b..d736fdf 100644 --- a/src/mesa/main/compiler.h +++ b/src/mesa/main/compiler.h @@ -139,26 +139,28 @@ extern C { /** * Function inlining */ -#if defined(__GNUC__) -# define INLINE __inline__ -#elif defined(__MSC__) -# define INLINE __inline -#elif defined(_MSC_VER) -# define INLINE __inline -#elif defined(__ICL) -# define INLINE __inline -#elif defined(__INTEL_COMPILER) -# define INLINE inline -#elif defined(__WATCOMC__) (__WATCOMC__ = 1100) -# define INLINE __inline -#elif defined(__SUNPRO_C) defined(__C99FEATURES__) -# define INLINE inline -# define __inline inline -# define __inline__ inline -#elif (__STDC_VERSION__ = 199901L) /* C99 */ -# define INLINE inline -#else -# define INLINE +#ifndef INLINE +# if defined(__GNUC__) +#define INLINE __inline__ +# elif defined(__MSC__) +#define INLINE __inline +# elif defined(_MSC_VER) +#define INLINE __inline +# elif defined(__ICL) +#define INLINE __inline +# elif defined(__INTEL_COMPILER) +#define INLINE inline +# elif defined(__WATCOMC__) (__WATCOMC__ = 1100) +#define INLINE __inline +# elif defined(__SUNPRO_C) defined(__C99FEATURES__) +#define INLINE inline +#define __inline inline +#define __inline__ inline +# elif (__STDC_VERSION__ = 199901L) /* C99 */ +#define INLINE inline +# else +#define INLINE +# endif #endif ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit