Commit Graph

107 Commits

Author SHA1 Message Date
Jake Turner e92a6a6527 For DXIL Disassembly change "." -> "_" in Instruction names
Disabled when DXC_COMPATIBLE_DISASM is enabled
The shader debugger treats "." in a variable name as a field separator
2024-07-27 14:34:29 +01:00
Jake Turner cce5d94c4a DXIL Disassembly changed Instruction::slot to be global unique SSA Id
Used by DXIL Debugger, new behaviour is disabled when DXC_COMPATIBLE_DISASM is enabled
2024-07-27 14:34:17 +01:00
Jake Turner 92a060ee70 Divide DXIL disassembly into two passes
First pass to settle the IDs common between disassembly styles
Second pass to display the disassembly
Divide existing MakeDXCDisassemblyString() method into helper methods to be shared
2024-04-18 16:12:05 +01:00
baldurk 9f4f0e6aa1 Update copyright years to 2024 2024-02-12 11:04:52 +00:00
baldurk 788f68a1f7 Improve DXIL bytecode editor
* Add helpers for creating DX op instructions with less boilerplate.
* On encode, strip any unused functions or globals to comply with strict
  DXIL validation requirements.
* Create attribute sets on demand to match functions.
* Add some extra helpers for creating constants, blocks, and patching
  runtime chunk.
2023-11-16 18:20:23 +00:00
baldurk 644157be56 0 is not a forward reference in DXIL phi nodes 2023-04-25 17:14:57 +01:00
baldurk 527caea7a8 Handle pointer types being missing from DXIL shaders
* Pointer types implicitly referenced by objects but not directly (like global
  variable or alloc/gep pointers) are not guaranteed to be present, so we need
  to add them ourselves to parse correctly and identically to LLVM.
2023-04-25 17:14:57 +01:00
baldurk e9708d909e Add handling for binop DXIL constants 2023-03-28 13:53:22 +01:00
baldurk 9c09f2879c Improve dxc-only disassembly annotations 2023-02-16 13:04:04 +00:00
baldurk 62aa7b49a5 Assign type IDs recursively for constants
* In case a type is only referenced via e.g. bitcast -> gep we need to recurse
  to assign type IDs in this case.
2023-02-16 13:04:04 +00:00
baldurk cc1709d16c Arguments are allowed to be unnamed in DXIL 2023-02-16 13:04:03 +00:00
baldurk 807a398126 Handle COMDAT entries in DXIL 2023-02-16 13:04:03 +00:00
baldurk 843972395b Display internal linkage functions in disassembly 2023-02-16 13:04:03 +00:00
baldurk deeb7fe3eb Handle non-void return instructions properly in DXIL 2023-02-16 13:04:03 +00:00
baldurk f5058dc292 32-bit compile fix 2023-02-14 20:36:31 +00:00
baldurk b42a1f9d1d Refactor DXIL parsing and handling to more closely mimic LLVM
* This file format is so obtuse that it enforces a code structure almost by
  design. This makes sense since it was never intended to be used anywhere
  outside of LLVM internals, so it makes sense that it maps precisely to LLVM's
  code structure and is hard to handle otherwise.
2023-02-14 19:36:10 +00:00
baldurk d47e79ae07 Update copyright years to 2023 2023-02-01 12:23:32 +00:00
baldurk abf613c173 Don't print an error when precaching common types 2023-01-16 10:27:17 +00:00
Benoit Dumesnil dfd00b1e38 Add support for shader model 6.6 bindless resources. 2022-03-21 11:30:47 +00:00
baldurk 1591ebcb1e Represent function types as plain func, not ptr-to-func
* This is not how LLVM does things, but sometimes DXIL blobs don't have the ptr-
  to-func types present, and we always access the real function type anyway so
  it should be safe to store the direct function type.
2022-03-17 23:49:09 +00:00
baldurk d645d5f0d6 Remove some unused STL includes 2022-03-01 12:25:31 +00:00
baldurk fcdea67879 Update copyright years to 2022 2022-02-17 17:38:32 +00:00
baldurk da979b23bc Don't omit opaque types for real empty structs in DXIL editing 2022-02-15 17:15:48 +00:00
baldurk 53b09724a1 Fix issues trying to patch simple/tiny DXIL shaders 2022-01-21 10:34:40 +00:00
baldurk 3cec544508 Patch quad overdraw shaders on D3D12 to follow rules. Closes #2356
* This is a stupid requirement as the quad overdraw shader doesn't use any
  interpolators, but the D3D12 runtime complains and refuses to create a PSO
  unless the PS has a matching signature. This works as long as the position was
  the first output from the previous stage, but if it isn't the PSO fails to
  create.
* To fix this, we take the existing shader and patch it by grafting the output
  signature from the last stage over onto the input signature, and patching up
  where the position is.
2021-10-20 17:22:43 +01:00
baldurk e1efc83fe3 Add shader entry tag to common header
* We also allow GetPointerType to silently return NULL when no pointer exists,
  as this will be useful for encoding when we want to check if a pointer type
  exists.
2021-09-21 18:04:57 +01:00
baldurk 42f508df85 Add i32/i8 helpers for DXIL 2021-09-21 18:04:57 +01:00
baldurk d15f264c81 Store values rather than indices for aliases/symtab to allow rebasing 2021-09-21 18:04:57 +01:00
baldurk fccaee058e Handle attribute sets with per-function-parameter attributes in DXIL
* This also fixes the string (not enum) attribute decoding
2021-09-21 18:04:57 +01:00
baldurk a67b0beb7f Don't warn on vector instructions - DXIL uses them sometimes 2021-09-21 18:04:57 +01:00
baldurk 012fedbb4a Fix basic block symtab entries 2021-09-21 18:04:57 +01:00
baldurk 1f68db5c08 Preserve value symtabs in exactly the order they come in
* Sometimes these are sorted, but that seems to be a recent dxc change.
2021-09-21 18:04:57 +01:00
baldurk 731c81e3c7 Fix encoding of constants with potential forward references 2021-09-21 18:04:57 +01:00
baldurk 976cb0e21a Preserve uselists through DXIL decode/encode 2021-09-21 18:04:57 +01:00
baldurk 29c16d17e8 Encode function instructions 2021-09-21 18:04:57 +01:00
baldurk 410ee1472b Start emitting function blocks, with attached metadata and constants
* We now track the values in a simple array so getting value IDs amounts to just
  getting an index in this array. This avoids the need to iterate in an llvm-
  identical way to enumerate values. That does mean that we need to insert new
  values into the array in the correct order, which isn't too bad.
2021-09-21 18:04:57 +01:00
baldurk 3b8dee0233 Refactor DXIL handling to rely on pointers instead of indexing
* The indexing works fine and handles forward references nicer, but once we
  start modifying things all the indices will need to be rebased.
2021-09-21 18:04:57 +01:00
baldurk 3ce8d68fba Emit metadata block 2021-09-21 18:04:57 +01:00
baldurk a2a5d8ec8a Emit the global constants block in DXIL 2021-09-21 18:04:56 +01:00
baldurk 045aad23ad Write param attr blocks
* We cheat slightly with the attributes - we combine these on load, so we lose
  information about multiple groups they may reference. So we save the groups
  that we read from and use that to write the attribute.
2021-09-21 18:04:56 +01:00
baldurk 9e3385d18d Emit root module block and blockinfo subblock
* It looks like LLVM (at DXC's version anyway) hardcodes a series of
  abbreviations, so we do the same
2021-09-21 18:04:56 +01:00
baldurk c77c9e8814 Add llvm bitstream writer 2021-09-21 18:04:56 +01:00
baldurk adb2b65951 Be more precise with handling pointer address spaces in DXIL 2021-09-09 12:37:55 +01:00
baldurk 44eee83aa2 Fix some differences with DXC's disassembly
* We also add an option to tweak our disassembly output to be more easily
  compared with dxc's
2021-09-09 12:35:19 +01:00
baldurk a42401c957 Unreachable instruction ends a block in DXIL 2021-09-09 12:29:09 +01:00
baldurk 410bcf2744 Fix crash if DXIL phi references itself 2021-01-28 15:25:25 +00:00
baldurk 026da176bb Update copyright years to 2021 2021-01-13 13:56:10 +00:00
baldurk 7ff7e0a71d Replace fixed C arrays with wrapper class in public interface
* These map more naturally to python tuples and are easier to wrap in and out.
* We also tidy up the FloatVecVal etc and standardise the members of
  ShaderValue.
2020-12-09 18:16:08 +00:00
baldurk d5a51dd145 Ignore uselist block in DXIL container 2020-11-09 16:29:39 +00:00
baldurk 17e80ae9cd Fix forward references in LLVM constants block 2020-10-20 14:33:46 +01:00