1. 02 Nov, 2012 1 commit
    • Kenneth Graunke's avatar
      glsl: Allow ir_if in the linker's move_non_declarations function. · 895a5873
      Kenneth Graunke authored
      
      
      Global initializers using the ?: operator with at least one non-constant
      operand generate ir_if statements.  For example,
      
         float foo = some_boolean ? 0.0 : 1.0;
      
      becomes:
      
         (declare (temporary) float conditional_tmp)
         (if (var_ref some_boolean)
             ((assign (x) (var_ref conditional_tmp) (constant float (0.0))))
             ((assign (x) (var_ref conditional_tmp) (constant float (1.0)))))
      
      This pattern is necessary because the second or third arguments could be
      function calls, which create statements (not expressions).
      
      The linker moves these global initializers into the main() function.
      However, it incorrectly had an assertion that global initializer
      statements were only assignments, calls, or temporary variable
      declarations.  As demonstrated above, they can be if statements too.
      
      Other than the assertion, everything works fine.  So remove it.
      
      Fixes new Piglit test condition-08.vert, as well as an upcoming
      game that will be released on Steam.
      
      NOTE: This is a candidate for stable release branches.
      Signed-off-by: Kenneth Graunke's avatarKenneth Graunke <kenneth@whitecape.org>
      Reviewed-by: Emma Anholt's avatarEric Anholt <eric@anholt.net>
      (cherry picked from commit b45a68ee)
      895a5873
  2. 31 Jul, 2012 1 commit
  3. 20 Jul, 2012 3 commits
  4. 12 Jul, 2012 1 commit
  5. 27 Jun, 2012 1 commit
    • Brian Paul's avatar
      glsl: be more careful about counting varying vars in the linker · 8fb1e4a4
      Brian Paul authored
      
      
      Previously, we were counting gl_FrontFacing, gl_FragCoord and gl_PointCoord
      against the limit of varying variables.  This prevented some valid shaders
      from linking.
      
      The other potential solution to this is to have the driver advertise
      more varying vars or set the GLSLSkipStrictMaxVaryingLimitCheck flag.
      But the above-mentioned variables aren't conventional varying attributes
      so it doesn't seem right to count them.
      Reviewed-by: Emma Anholt's avatarEric Anholt <eric@anholt.net>
      8fb1e4a4
  6. 15 May, 2012 1 commit
  7. 16 Apr, 2012 2 commits
  8. 13 Apr, 2012 1 commit
    • Dave Airlie's avatar
      glsl: add support for ARB_blend_func_extended (v3) · 1256a5dc
      Dave Airlie authored
      
      
      This adds index support to the GLSL compiler.
      
      I'm not 100% sure of my approach here, esp without how output ordering
      happens wrt location, index pairs, in the "mark" function.
      
      Since current hw doesn't ever have a location > 0 with an index > 0,
      we don't have to work out if the output ordering the hw requires is
      location, index, location, index or location, location, index, index.
      But we have no hw to know, so punt on it for now.
      
      v2: index requires layout - catch and error
          setup explicit index properly.
      
      v3: drop idx_offset stuff, assume index follow location
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      1256a5dc
  9. 02 Apr, 2012 2 commits
    • Kenneth Graunke's avatar
      glsl: Remove ir_call::get_callee() and set_callee(). · 82065fa2
      Kenneth Graunke authored
      
      
      Previously, set_callee() performed some assertions about the type of the
      ir_call; protecting the bare pointer ensured these checks would be run.
      
      However, ir_call no longer has a type, so the getter and setter methods
      don't actually do anything useful.  Remove them in favor of accessing
      callee directly, as is done with most other fields in our IR.
      Signed-off-by: Kenneth Graunke's avatarKenneth Graunke <kenneth@whitecape.org>
      Reviewed-by: Emma Anholt's avatarEric Anholt <eric@anholt.net>
      Reviewed-by: default avatarIan Romanick <ian.d.romanick@intel.com>
      82065fa2
    • Kenneth Graunke's avatar
      glsl: Convert ir_call to be a statement rather than a value. · d884f608
      Kenneth Graunke authored
      
      
      Aside from ir_call, our IR is cleanly split into two classes:
      - Statements (typeless; used for side effects, control flow)
      - Values (deeply nestable, pure, typed expression trees)
      
      Unfortunately, ir_call confused all this:
      - For void functions, we placed ir_call directly in the instruction
        stream, treating it as an untyped statement.  Yet, it was a subclass
        of ir_rvalue, and no other ir_rvalue could be used in this way.
      - For functions with a return value, ir_call could be placed in
        arbitrary expression trees.  While this fit naturally with the source
        language, it meant that expressions might not be pure, making it
        difficult to transform and optimize them.  To combat this, we always
        emitted ir_call directly in the RHS of an ir_assignment, only using
        a temporary variable in expression trees.  Many passes relied on this
        assumption; the acos and atan built-ins violated it.
      
      This patch makes ir_call a statement (ir_instruction) rather than a
      value (ir_rvalue).  Non-void calls now take a ir_dereference of a
      variable, and store the return value there---effectively a call and
      assignment rolled into one.  They cannot be embedded in expressions.
      
      All expression trees are now pure, without exception.
      Signed-off-by: Kenneth Graunke's avatarKenneth Graunke <kenneth@whitecape.org>
      Reviewed-by: Emma Anholt's avatarEric Anholt <eric@anholt.net>
      Reviewed-by: default avatarIan Romanick <ian.d.romanick@intel.com>
      d884f608
  10. 26 Mar, 2012 1 commit
  11. 21 Mar, 2012 2 commits
  12. 15 Mar, 2012 1 commit
  13. 03 Feb, 2012 1 commit
  14. 20 Jan, 2012 1 commit
  15. 18 Jan, 2012 1 commit
    • Emma Anholt's avatar
      glsl: Fix leak of LinkedTransformFeedback.Varyings. · 5a0f395b
      Emma Anholt authored
      I copy-and-pasted the thing I was allocating for as the context, so
      the first time it would be NULL (root of a ralloc context) and they'd
      chain off each other from then on.
      
      NOTE: This is a candidate for the 8.0 branch.
      5a0f395b
  16. 11 Jan, 2012 3 commits
    • Paul Berry's avatar
      mesa: Move transform feedback error check to reduce array overflow risk. · d3150ebc
      Paul Berry authored
      
      
      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: default avatarIan Romanick <ian.d.romanick@intel.com>
      d3150ebc
    • Paul Berry's avatar
      mesa: Fix transform feedback of unsubscripted gl_ClipDistance array. · 642e5b41
      Paul Berry authored
      
      
      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: Emma Anholt's avatarEric Anholt <eric@anholt.net>
      642e5b41
    • Paul Berry's avatar
      mesa: Fix computation of transform feedback num_components. · be4e9f7a
      Paul Berry authored
      
      
      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: Emma Anholt's avatarEric Anholt <eric@anholt.net>
      be4e9f7a
  17. 09 Jan, 2012 1 commit
  18. 05 Jan, 2012 6 commits
    • Paul Berry's avatar
      mesa: Fix transform feedback of unsubscripted arrays. · 33fe0211
      Paul Berry authored
      
      
      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's avatarKenneth Graunke <kenneth@whitecape.org>
      Reviewed-by: default avatarIan Romanick <ian.d.romanick@intel.com>
      33fe0211
    • Paul Berry's avatar
      mesa: Fix transform feedback of gl_ClipDistance. · 456279bb
      Paul Berry authored
      
      
      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's avatarKenneth Graunke <kenneth@whitecape.org>
      456279bb
    • Paul Berry's avatar
    • Paul Berry's avatar
      mesa: Add gl_transform_feedback_info::ComponentOffset. · 2169331d
      Paul Berry authored
      
      
      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's avatarKenneth Graunke <kenneth@whitecape.org>
      2169331d
    • Paul Berry's avatar
      mesa: Fix extra memset in store_tfeedback_info() · 1be0fd8c
      Paul Berry authored
      Commit 9d36c96d
      
       (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: Emma Anholt's avatarEric Anholt <eric@anholt.net>
      1be0fd8c
    • Emma Anholt's avatar
      mesa: Fix glGetTransformFeedbackVarying(). · 9d36c96d
      Emma Anholt authored
      
      
      The current implementation was totally broken -- it was looking in an
      unpopulated structure for varyings, and trying to do so using the
      current list of varying names, not the list used at link time.
      
      v2: Fix leaking of memory into the program per re-link.
      Reviewed-by: Paul Berry's avatarPaul Berry <stereotype441@gmail.com>
      9d36c96d
  19. 04 Jan, 2012 1 commit
    • Paul Berry's avatar
      mesa: Check that all buffers are bound in BeginTransformFeedback. · ebfad9f6
      Paul Berry authored
      
      
      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's avatarBrian Paul <brianp@vmware.com>
      Reviewed-by: default avatarIan Romanick <ian.d.romanick@intel.com>
      Reviewed-by: Emma Anholt's avatarEric Anholt <eric@anholt.net>
      ebfad9f6
  20. 20 Dec, 2011 1 commit
    • Paul Berry's avatar
      mesa: Record transform feedback strides/offsets in linker output. · 942d4520
      Paul Berry authored
      
      
      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's avatarMarek Olšák <maraeo@gmail.com>
      942d4520
  21. 13 Dec, 2011 1 commit
  22. 19 Nov, 2011 1 commit
  23. 14 Nov, 2011 1 commit
  24. 09 Nov, 2011 1 commit
    • Paul Berry's avatar
      glsl: Assign transform feedback varying slots in linker. · 871ddb91
      Paul Berry authored
      
      
      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's avatarMarek Olšák <maraeo@gmail.com>
      Tested-by: Marek Olšák's avatarMarek Olšák <maraeo@gmail.com>
      871ddb91
  25. 08 Nov, 2011 1 commit
  26. 07 Nov, 2011 3 commits