Commit Graph

8712 Commits

Author SHA1 Message Date
baldurk b4e4fed40f Remove path to trust application flushes on coherent maps. Closes #2372
* We used to allow applications to call vkFlushMappedMemoryRanges on coherent
  memory to manually annotate regions of memory that are changed in persistent
  maps, thus avoiding the overhead of RenderDoc needing to check for changes on
  each submit.
* Unfortunately this means that if the application calls flush wrongly then
  changes will no longer appear, even though the application was completely
  correct, if misleading, since by the spec behaviour vkFlushMappedMemoryRanges
  is a no-op on coherent memory so incorrect calls to it make no difference.
* Since applications making use of this are rare or non-existant we just remove
  the optimisation.
2021-09-23 17:37:26 +01:00
baldurk 42fcc3820d Try to load DXC before doing DXIL patching, to validate in debug builds 2021-09-23 17:01:31 +01:00
baldurk e092607896 Patch feature flags chunk when adding UAVs on geometry stages 2021-09-23 16:59:34 +01:00
baldurk b4cf86c48c Fix compilation on mac 2021-09-21 18:48:43 +01:00
baldurk dc6bc12da7 Annotate handle creation with writes to track bindless use on D3D12 2021-09-21 18:04:58 +01:00
baldurk 8401ba26a0 Fix DXBC container offsets/length properly when stripping debug DXIL 2021-09-21 18:04:58 +01:00
baldurk 6ee985a067 Patch PSV chunk to fix dxil validation warning 2021-09-21 18:04:58 +01:00
baldurk 9efe0f5a83 Begin implementing DXIL shader patching for bindless feedback
* We don't annotate any bindless uses yet, this only declares the UAV and
  attempts to write into the first slot.
2021-09-21 18:04:58 +01:00
baldurk 0c0d6af93d Allow simple one-pass editing with DXIL
* DXIL's shape and necessity of pointers and relative addressing poses a
  challenge for editing. Currently we pre-reserve all arrays and take pointers
  to match DXIL's format and to allow edits to not require lots of index fixups.
  However this is a challenge when editing as the arrays may resize as things
  are inserted.
* The solution we take here is to copy all the arrays that will mutate to new
  storage and reserving enough for the edits, *while keeping the old array
  storage around*. We then assign all elements IDs, and after editing we do a
  fixup pass to find any pointers that are pointing into the old arrays and find
  them in the new arrays by ID.
* This means that pointers to the old storage remain valid and point to the
  right object even after we've resized for editing, and we only fix them up
  right at the end after all the edits so we can look up indices from pointers
  again.
* This approach may not work indefinitely sadly, and it does require
  conservative reservation. In future we might have to completely clone DXC's
  data storage as well (arena allocated and new everything, with no arrays for
  storage).
2021-09-21 18:04:58 +01:00
baldurk ed4a28049d Remove unused instruction pointer from Metadata 2021-09-21 18:04:58 +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 9efdf6920a Don't require stripping the blob to fetch editable non-debug DXIL chunk 2021-09-21 18:04:57 +01:00
baldurk ff6d495c45 On debug pass encoded DXIL through validator just in case 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 097e6657e8 Write attached metadata in functions 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 606c011aac Emit global symbol table 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 f6e8e78bbf Emit global var and function records in module
* The value IDs currently aren't fetched in LLVM-matching order so we don't have
  those yet for global var initialisers
2021-09-21 18:04:56 +01:00
baldurk 6d60d96fe6 Set up llvm encoder to handle abbrev selection, and write type lock 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 6535e3b20c Don't fetch GPU descriptor address for non-shader-visible heaps
* Silences a D3D12 debug warning
2021-09-17 14:29:23 +01:00
baldurk 1b42dcc05f Fix crash returning serialiser's structured file to dummy driver
* If we hit a fatal error during initialisation, the structured file pointer
  still points at the temporary serialiser's structured file. It's not until we
  finish loading that we swap it into the driver-stored file that we can safely
  return and detach ownership of.
2021-09-17 14:29:05 +01:00
baldurk 44abc701e0 Fix crash serialising glVertexArrayVertexBuffers with NULL buffer array 2021-09-17 12:50:39 +01:00
baldurk bcb70d3b9c Fix D3D11 debug messages being off by one event 2021-09-17 12:18:50 +01:00
baldurk a5dfc5b8b0 Properly reset all input assembly binding data in D3D11 pipeline state 2021-09-17 11:36:30 +01:00
baldurk fdaacf5f86 Add a couple of fatal error checks/protections around ExecuteIndirect 2021-09-16 17:05:52 +01:00
baldurk 5b18e4bdc6 Avoid crash when fetching vs out with expected index buffer unbound
* This is clearly invalid but it's trivial to protect against a divide by 0
  which we do on other APIs, so we do that here.
2021-09-16 11:45:36 +01:00
baldurk 36e17be519 Add some extra fatal error checks during early startup 2021-09-16 11:01:34 +01:00
baldurk 46ffa9de79 Ignore com.android activity that sometimes shows up in other packages 2021-09-15 11:31:54 +01:00
baldurk 3d785b9b68 Try to rebind user DC first when pushing/popping GL contexts. Refs #2361
* In the old codepath for a valid existing window we'd create a cloned DC and
  use that to pop with. However that DC is then released so we have created the
  'stale DC' situation. This can cause problems with subsequent context
  activations when we try to push/pop to populate GL hooks and fail to pop
  properly as the queried DC is invalid.
2021-09-14 17:54:48 +01:00
baldurk 0054e534f8 Fix triangle size overlays breaking when postvs data doesn't have W=1.0 2021-09-14 13:02:56 +01:00
baldurk 33d36788a6 Always check mapped memory for changes if it has BDA buffers
* Normally we only check mapped memory when it's referenced during capture by
  some binding, but for BDA we don't have bindings so we have to conservatively
  check it every time.
2021-09-13 19:13:30 +01:00
baldurk fbe7462dbd Mark parameter as important in vkCmdSetScissorWithCountEXT 2021-09-13 19:12:34 +01:00
baldurk 90f3417039 Don't generate potentially unsupported vertex formats to ignore W
* When using VS In we want to ignore the W component, but that already happens
  explicitly for vulkan/GL in the shader. Mirror that same solution to D3D
  instead of trying to force a 3-component format which may not be supported
  (e.g. on AMD R16G16B16_*)
2021-09-13 19:11:28 +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