Skip to content
Snippets Groups Projects
  1. Jul 11, 2018
  2. May 17, 2018
    • LoopDawg's avatar
      HLSL: allow self-type cast (as no-op passthrough) · c5991671
      LoopDawg authored
      Previously, casting an object of a struct type to an identical type
      would produce an error.  This PR allows this case.
      
      As a side-effect of the change, several self-type casts in existing
      tests go away.  For example:
      
          0:10          Construct float ( temp float)
          0:10            'f' ( in float)
      
      becomes this (without the unneeded constructor op):
      
          0:10          'f' ( in float)
      
      For vector or array types this can result in somewhat less overall code.
      
      Fixes: #1218
      c5991671
  3. May 16, 2018
  4. May 15, 2018
    • LoopDawg's avatar
      HLSL: Allow stream output Append() method after entry point. · 1326b8c7
      LoopDawg authored
      Append() method is special: unlike most outputs, it does not copy
      some temporary data to a symbol in the entry point epilogue, but
      rather uses an emit builtin after each write to the output stream.
      
      This had been handled by remembering the special output symbol for
      the stream as it was declared in the shader entry point before
      symbol sanitization.  However the prior code was too simple and
      only handled cases where the Append() method happened after the
      entry point, so that the output symbol had been seen.
      
      This PR adds a patching step so that the Append()s may appear in
      any order WRT the entry point.  They are patched in an epilogue,
      whereupon it is guaranteed in a well formed shader that we have
      seen the appropriate declaration.
      
      Fixes #1217.
      1326b8c7
  5. Mar 29, 2018
  6. Mar 06, 2018
  7. Feb 22, 2018
  8. Feb 18, 2018
    • LoopDawg's avatar
      HLSL: Add conversions for image ops during SPV construction · 4425f245
      LoopDawg authored
      HLSL allows image and texture types to be templatized on sub-vec4 types,
      or even structures.  This was mostly handled already during creation of
      sampling operations.  However, for operator[] which can generate image
      loads, this wasn't happening.
      
      It also isn't very easy to do at that point in time, because operator[]
      does not know where the results it produces will end up.  They may be
      an lvalue or an rvalue, and there's a post-process to convert loads to
      stores.  They may end up in atomic ops.
      
      To bypass that difficulty, GlslangToSpv now looks for this case and
      adds the appropriate conversion.  LIMITATION: this only works for
      cases for which a simple conversion opcode suffices.  That is to say,
      it will not work if the type is templatized on a struct.
      4425f245
  9. Feb 01, 2018
    • John Kessenich's avatar
      HLSL: Refactor attribute implementation. · e18fd20d
      John Kessenich authored
      - make it sharable with GLSL
      - correct the case insensitivity
      - remove the map; queries are not needed, all entries need processing
      - make it easier to build bottom up (will help GLSL parsing)
      - support semantic checking and reporting
      - allow front-end dependent semantics and attribute name mapping
      e18fd20d
  10. Dec 08, 2017
  11. Dec 06, 2017
  12. Nov 28, 2017
    • LoopDawg's avatar
      HLSL: allow keyword-identifiers as cbuffer/struct names. · 7ee29ba7
      LoopDawg authored
      Issue #791 was partially fixed by PR #1161 (the mat mul implicit
      truncations were its main point), but it still wouldn't compile due to
      the use of ConstantBuffer as an identifier.  Apparently those fall into
      the same class as "float float", where float is both a type and an
      identifier.
      
      This allows struct definitions with such keyword-identifiers,
      and adds ConstantBuffer to the set.  'cbuffer int' is legal in HLSL,
      and 'struct int' appears to only be rejected due to the redefinition
      of the 'int' type.
      
      Fixes #791
      7ee29ba7
  13. Nov 27, 2017
  14. Nov 22, 2017
  15. Nov 16, 2017
  16. Nov 15, 2017
  17. Nov 14, 2017
  18. Nov 09, 2017
    • LoopDawg's avatar
      HLSL: implement TextureBuffer<type> · e5530b92
      LoopDawg authored
      Almost equivalent to tbuffer, except members not at global scope.
      So, reference is "TextureBuffer_var.member", not simply "member".
      e5530b92
  19. Oct 19, 2017
  20. Oct 12, 2017
  21. Oct 07, 2017
  22. Oct 06, 2017
    • Sebastian Tafuri's avatar
      4f6865f4
    • LoopDawg's avatar
      HLSL: split textures used for both shadow and non-shadow modes · 73c57bbe
      LoopDawg authored
      A single texture can statically appear in code mixed with a shadow sampler
      and a non-shadow sampler.  This would be create invalid SPIR-V, unless
      one of them is provably dead.
      
      The previous detection of this happened before DCE, so some shaders would
      trigger the error even though they wouldn't after DCE.  To handle that
      case, this PR splits the texture into two: one with each mode.  It sets
      "needsLegalization" (if that happens for any texture) to warn that this shader
      will need post-compilation legalization.
      
      If the texture is only used with one of the two modes, behavior is as it
      was before.
      73c57bbe
  23. Oct 04, 2017
  24. Oct 02, 2017
    • LoopDawg's avatar
      HLSL: add subpass input types and methods · 7f93d56e
      LoopDawg authored
      Add support for Subpass Input proposal of issue #1069.
      
      Subpass input types are given as:
      
          layout(input_attachment_index = 1) SubpassInput<float4> subpass_f;
          layout(input_attachment_index = 2) SubpassInput<int4>   subpass_i;
          layout(input_attachment_index = 3) SubpassInput<uint4>  subpass_u;
      
          layout(input_attachment_index = 1) SubpassInputMS<float4> subpass_ms_f;
          layout(input_attachment_index = 2) SubpassInputMS<int4>   subpass_ms_i;
          layout(input_attachment_index = 3) SubpassInputMS<uint4>  subpass_ms_u;
      
      The input attachment may also be specified using attribute syntax:
      
          [[vk::input_attachment_index(7)]] SubpassInput subpass_2;
      
      The template type may be a shorter-than-vec4 vector, but currently user
      structs are not supported.  (An unimplemented error will be issued).
      
      The load operations are methods on objects of the above type:
      
          float4 result = subpass_f.SubpassLoad();
          int4   result = subpass_i.SubpassLoad();
          uint4  result = subpass_u.SubpassLoad();
      
          float4 result = subpass_ms_f.SubpassLoad(samp);
          int4   result = subpass_ms_i.SubpassLoad(samp);
          uint4  result = subpass_ms_u.SubpassLoad(samp);
      
      Additionally, the AST printer could not print EOpSubpass* nodes.  Now it can.
      
      Fixes #1069
      7f93d56e
  25. Sep 30, 2017
  26. Sep 28, 2017
  27. Sep 27, 2017
    • GregF's avatar
      Enable HLSL legalization · cd1f169c
      GregF authored
      Also added known-good mechanism to fetch latest validated spirv-tools.
      Also added -Od and -Os to disable optimizer and optimize for size.
      
      Fetching spirv-tools is optional for both glsl and hlsl. Legalization
      of hlsl is done by default if spirv-opt is present at cmake time.
      Optimization for glsl is currently done through the option -Os.
      
      Legalization testing is currently only done on four existing shaders.
      A separate baseLegalResults directory holds those results. All previous
      testing is done with the optimizer disabled.
      cd1f169c
  28. Sep 14, 2017
    • LoopDawg's avatar
      HLSL: handle split InputPatch templat type in patch constant functions · 4a145dbf
      LoopDawg authored
      InputPatch parameters to patch constant functions were not using the
      internal (temporary) variable type.  That could cause validation errors
      if the input patch had a mixture of builtins and user qualified members.
      
      This uses the entry point's internal form.
      
      There is currently a limitation: if an InputPatch is used in a PCF,
      it must also have appeared in the main entry point's parameter list.
      That is not a limitation of HLSL.  Currently that situation is detected
      and an "implemented" error results.  The limitation can be addressed,
      but isn't yet in the current form of the PR.
      4a145dbf
    • LoopDawg's avatar
      HLSL: allow mixed user & builtin members in hull shader output structure · a5d86164
      LoopDawg authored
      Hull shaders have an implicitly arrayed output.  This is handled by creating an arrayed form of the
      provided output type, and writing to the element of it indexed by InvocationID.
      
      The implicit indirection into that array was causing some troubles when copying to a split
      structure.  handleAssign was able to handle simple symbol lvalues, but not an lvalue composed
      of an indirection into an array.
      a5d86164
  29. Sep 06, 2017
    • LoopDawg's avatar
      Fix lvalue check in SPIR-V generation · 76117921
      LoopDawg authored
      There were several locations in TGlslangToSpvTraverser::handleUserFunctionCall testing for
      whether a fn argument should be in the lvalue or rvalue array.  They must get the same
      result for indexing sanity, but had slightly different logic.
      
      They're now forced into the same test.
      76117921
  30. Aug 31, 2017
    • LoopDawg's avatar
      HLSL: add geometry stage support for clip/cull distance · 5e5b12e9
      LoopDawg authored
      Changes:
      
      (1) Allow clip/cull builtins as both input and output in the same shader stage.  Previously,
      not enough data was tracked to handle this.
      
      (2) Handle the extra array dimension in GS inputs.  The synthesized external variable can
      now be created with the extra array dimension if needed, and the form conversion code is
      able to handle it as well.
      
      For example, both of these GS inputs would result in the same synthesized external type:
      
          triangle in float4 clip[3] : SV_ClipDistance
      
          triangle in float2 clip[3][2] : SV_ClipDistance
      
      In the second case, the inner array dimension packs with the 2-vector of floats into an array[4],
      which there is an array[3] of due to the triangle geometry.
      5e5b12e9
  31. Aug 28, 2017
  32. Aug 24, 2017
    • LoopDawg's avatar
      HLSL: handle clip and cull distance input builtin type conversion · e2cda3c2
      LoopDawg authored
      HLSL allows a range of types for clip and cull distances.  There are
      three dimensions, including arrayness, vectorness, and semantic ID.
      SPIR-V requires clip and cull distance be a single array of floats in
      all cases.
      
      This code provides input side conversion between the SPIR-V form and
      the HLSL form.  (Output conversion was added in PR #947 and #997).
      
      This PR extends HlslParseContext::assignClipCullDistance to cope with
      the input side conversion.  Not as much changed as appears: there was
      also a lot of renaming to reflect the fact that the code now handles
      either direction.
      
      Currently, non-{frag,vert} stages are not handled, and are explicitly
      rejected.
      
      Fixes #1026.
      e2cda3c2
  33. Aug 15, 2017
    • LoopDawg's avatar
      HLSL: add methods to track user structure in texture return type. · 5ee05891
      LoopDawg authored
      Some languages allow a restricted set of user structure types returned from texture sampling
      operations.  Restrictions include the total vector size of all components may not exceed 4,
      and the basic types of all members must be identical.
      
      This adds underpinnings for that ability.  Because storing a whole TType or even a simple
      TTypeList in the TSampler would be expensive, the structure definition is held in a
      table outside the TType.  The TSampler contains a small bitfield index, currently 4 bits
      to support up to 15 separate texture template structure types, but that can be adjusted
      up or down.  Vector returns are handled as before.
      
      There are abstraction methods accepting and returning a TType (such as may have been parsed
      from a grammar).  The new methods will accept a texture template type and set the
      sampler to the structure if possible, checking a range of error conditions such as whether
      the total structure vector components exceed 4, or whether their basic types differe, or
      whether the struct contains non-vector-or-scalar members.  Another query returns the
      appropriate TType for the sampler.
      
      High level summary of design:
      
      In the TSampler, this holds an index into the texture structure return type table:
      
          unsigned int structReturnIndex : structReturnIndexBits;
      
      These are the methods to set or get the return type from the TSampler.  They work for vector or structure returns, and potentially could be expanded to handle other things (small arrays?) if ever needed.
      
          bool setTextureReturnType(TSampler& sampler, const TType& retType, const TSourceLoc& loc);
          void getTextureReturnType(const TSampler& sampler, const TType& retType, const TSourceLoc& loc) const;
      
      The ``convertReturn`` lambda in ``HlslParseContext::decomposeSampleMethods`` is greatly expanded to know how to copy a vec4 sample return to whatever the structure type should be.  This is a little awkward since it involves introducing a comma expression to return the proper aggregate value after a set of memberwise copies.
      5ee05891
Loading