97 Commits

Author SHA1 Message Date
Jake Turner 82cdd8047c Add a UI panel to ShaderViewer to show the shader debug loading log
A button toggles the logging panel open/closed
2026-02-06 10:39:11 +13:00
qwmnerbvqwmn 67a6f20b6e Support #pragma once and multiple inclusions in HLSL editing 2026-01-23 03:02:57 +09:00
baldurk 9bef60d6c3 Display source variables mapped to OpUndef as <undefined value>
* Undefined values are still 0xccccccccc, since that value can propagate through
  operations. But source variables mapped directly to an OpUndef are displayed
  in a more semantically clear way.
2026-01-19 13:34:58 +00:00
baldurk 856c838def Update copyright years to 2026 and fix copyright ranges
* In a previous update in 2021 many copyright ranges were truncated
  accidentally, and some files have been copy-pasted with wrong years. These
  dates have been fixed based on git history and original copyright messages.
2026-01-05 14:17:28 +00:00
baldurk 3be544c51d Prevent infinite recursion when processing includes for shader edits 2025-07-29 13:05:07 +01:00
baldurk 2322e165de Update copyright years to 2025 2025-03-14 18:54:37 +00:00
Jake Turner 11870b184a ShaderViewer support for ShaderDirectAccess shader resources
i.e. D3D12 SM6.6 HLSL Dynamic resources which index directly into the resource/sampler heap and not via shader bindings.
2024-12-04 13:40:17 +00:00
Louis de Carufel 71ac13e9bf Bookmarks are now listed in menu. 2024-06-13 10:27:41 +01:00
baldurk 341f9a689b Fix shader viewer bookmarks to work with editing and viewing shaders
* Previously it was only applied for debugging shaders.
2024-05-31 15:26:07 +01:00
Louis de Carufel 0e64cc5368 Added shader viewer bookmarks and find shortcuts. 2024-05-24 10:35:06 +01:00
baldurk 2bbe1a8cd9 Update shader viewer and debugging with new reporting for shader binds
* This shifts from reporting from the old style bindset/bind to the new system
  of only referencing by shader interface and index (independent of binding
  model).
* The vulkan shader debugger re-uses the replay interface to cache descriptor
  access and descriptor contents in a fashion friendly to interface-index
  lookup.
2024-04-10 18:58:51 +01:00
baldurk 9f4f0e6aa1 Update copyright years to 2024 2024-02-12 11:04:52 +00:00
baldurk 19d7b038c2 Don't allow tooltip to display if context menu is shown in shader viewer 2023-08-04 17:06:02 +01:00
baldurk d47e79ae07 Update copyright years to 2023 2023-02-01 12:23:32 +00:00
baldurk e061ea3b2e Improve handling of compilers & command line for edited shaders
* We store the compiler used (when known) in shader debug info and use that to
  select the compiler for editing as even higher priority than the default for a
  given language/encoding combination.
* We also ensure that for known tools we add the input and output parameters
  last, after any custom parameters, so that they are always present regardless
  of what the user puts in.
2022-08-10 14:56:44 +01:00
baldurk db1f17476e Track variables being changed across steps/runs
* This allows us to more accurately display those that have been modified since
  the last step, when a source-level step covers multiple instruction-level
  steps.
* We also do our own sorting of source variables based on how recently they were
  updated. This applies in both directions, so stepping backwards and
  'reversing' a variable change will also count as a recent update.
2022-08-03 17:44:11 +01:00
baldurk 935fa49c98 Store source vars data per-instruction rather than per-state
* Since the source vars data doesn't change for a given instruction, we can pre-
  calculate it and save time on re-calculating per-state.
* Note callstack *can* change per-state on SPIR-V where the same instruction can
  be reached by different flow paths, so the callstack remains part of the per-
  state data.
2022-08-03 17:44:11 +01:00
baldurk b9e5e2fd5c Use QList for variables in ShaderViewer
* Using a linked list instead of a vector makes insert/erase operations for
  variables being created and destroyed significantly faster.
2022-06-30 13:24:36 +01:00
baldurk 20f42feab4 Improve mapping of breakpoints to disassembly & source
* We breakpoint directly on source/disassembly lines rather than trying to map
  to instructions that may get stepped over and skipped.
2022-06-22 20:04:42 +01:00
baldurk abe645f031 Add support for saving and loading structure definitions 2022-05-20 14:15:30 +01:00
baldurk d9c98f44f6 Fix stepping backwards working incorrectly with multiple location maps 2022-04-28 16:34:44 +01:00
baldurk 7b4f535663 Refactor watch variables to support complex types including structs 2022-03-07 18:45:57 +00:00
baldurk 8e76069ecf Switch watch variables control from table to tree widget
* This will allow watching structs or arrays
2022-03-07 14:45:44 +00:00
baldurk 87f2adc829 Improve mapping of source locations to instructions in shader debugging 2022-03-07 14:45:44 +00:00
baldurk fcdea67879 Update copyright years to 2022 2022-02-17 17:38:32 +00:00
baldurk 7f130077da When source debugging, skip non-mapped instructions
* We entirely skip over any instructions that don't have a source mapping. These
  are assumed to be filler instructions or others that don't correspond usefully
  to anything in the source.
2022-02-04 16:45:15 +00:00
baldurk 3ac4bd0ebd Refactor custom shaders to abstract binding differences. Closes #2458
* Newly written shaders and any updated shaders can now use pre-defined macros
  to abstract away binding differences between APIs, so custom shaders will be
  more portable in particular shaders written in HLSL for D3D or GLSL on OpenGL
  won't break on vulkan because they refer to incorrect binds.
2022-01-31 19:14:08 +00:00
Mikkel Gjoel 41d39b58ce Pass range-min/max to ApplyCustomShader
Adding rangeminmax to globals, snippet support and updated docs to match

Fixes bug in replay_output.cpp, causing a crash due to missing texhandle
2021-11-03 20:26:18 +00:00
baldurk d4a5592780 Add functionality to reset an edited shader to original. Closes #2334
* We also add the ability to toggle on/off the replacement being active without
  needing to intentionally add a compile error (and this also makes it more
  explicitly clear when the shader replacement is enabled or not. This could be
  useful for quick A/B testing between the edited version and the original.
2021-11-02 14:09:50 +00:00
baldurk 124d0e71b6 Implement more flexible step/run options. Closes #2276 Closes #2312
* We split stepping for source debugging into step over/into/out depending on
  how it handles function calls. Step Into is the same behaviour as before - it
  steps to the next source line executed regardless of if it's inside a function
  call. Step Over is similar but will not enter function calls. We define that
  as the callstack growing (so staying the same or shrinking - returning from a
  function - is OK), and this is as accurate as the underlying debug
  information. Step Out will run until the callstack shrinks, i.e. returning
  from a function.
* This is a slight behaviour change of keyboard shortcuts - F10 was effectively
  doing step into and will now step over. F11 will step into which is the old
  behaviour.
* All these variants have backwards versions, and to remain consistent we keep
  the shift modifier as forwards/backwards. This differs from visal studio where
  step out is shift-F10.
* The seems like the best balance - using any other variant would likely confuse
  muscle memory of anyone used to visual studio (where these shortcuts are
  intended to mimick), if only because F10 would be step into whether or not F11
  is used for step over or some other key which would likely be even more
  confusing either way. Trying to twist to use Shift-F10 for step out would be
  inconsistent with the other backwards running operations and likely cause more
  confusion than it saves in matching VS's shortcuts exactly. Also an accidental
  Shift-F10 is not too destructive, the user can realise it didn't Step Out
  forwards, and press Ctrl-F10 or look up the button.
* The hope is that most likely people doing source debugging and familiar with
  these keys expect F10 to step over, so the previous behaviour was unexpected
  but easy to work around, and that changing the meaning of the key won't
  disrupt them. Or at least the disruption is less than other alternatives.
2021-07-21 13:39:26 +01:00
baldurk 71bbc53759 Implement double clicking to go to find-all results. Closes #2277 2021-07-20 16:59:11 +01:00
baldurk 331db5b4ba Fix custom shader edits to write the exact editor contents to disk 2021-05-17 13:47:58 +01:00
baldurk b4ec703d97 Expose shader printf messages in the UI 2021-05-11 16:15:31 +01:00
baldurk 026da176bb Update copyright years to 2021 2021-01-13 13:56:10 +00:00
baldurk 6b8ce92d88 Clean up docstrings in python interfaces to be strictly typed/formatted
* Also added a script that can run as part of CI to verify that the docstring
  matches, by generating a regex from the docstring documented parameter types
  and return type and making sure we find a match within the C headers. This
  ensures all parameters are documented with the right types, no extra
  parameters are documented, and the return type is correct.
* The script also checks proper scoping so that if qrenderdoc docstrings
  mention a renderdoc type, they need to scope it properly.
2020-12-07 17:44:51 +00:00
baldurk 806187f613 Save and load edited shaders as capture modifications
* When a shader edit is loaded with a capture, it's loaded as "pending" and not
  immediately applied.
2020-10-21 14:14:20 +01:00
baldurk 83f7a26ee9 Query which shader disassembly formats require a pipeline
* This allows us to be a bit more friendly in the UI when we don't have a
  particular pipeline associated with a shader.
2020-09-01 14:03:59 +01:00
baldurk a81994071f Wait for shader viewer background debugging, add cancel button
* Until we properly support background debugging we need to wait for it to
  complete, otherwise the user could close the window and we'd crash.
2020-05-15 20:31:42 +01:00
Steve Karolewics ef58d7e1f8 Extend info in accessed resources panel in the shader viewer 2020-05-08 20:43:04 +01:00
baldurk 1da60805e0 Allow source variable mappings to point to the root of a complex type
* For vulkan debugging where high-level variables are not scattered amongst
  vectors, there's no point in having the whole tree expanded for source mapping
  struct-to-struct or array-to-array.
2020-04-29 18:48:50 +01:00
Steve Karolewics 08d1189d99 Give ShaderViewer its own copy of bindpoint mappings
Previously this data was a reference to the current pipeline state, so
when the selected event changed, the ShaderViewer's bindpoint mappings
would be inaccurate.
2020-04-27 18:16:46 +01:00
Steve Karolewics 2c4f2a57a8 Add resource tracking to DXBC shader debugging
When a resource is accessed, it is now tracked by the debug step. The
shader viewer has a new panel to display resources accessed up to the
current step, with context menus to go to previous/next access of a
specific resource.
2020-04-27 18:16:46 +01:00
baldurk 97c7dd681f Add global samplers array to shader debug trace 2020-04-09 18:36:12 +01:00
baldurk 59c3a2fbd9 Implement matrix multiplication with matrix/vector/scalar 2020-04-08 18:39:02 +01:00
baldurk 9ba81634b4 Improve the title of shader edit windows 2020-04-03 15:19:28 +01:00
baldurk d58691bc16 Standardise debug and source variable naming conventions
* We standardise on definitions: source variable names contain the full path,
  and identify debug variable by full path. Debug variable members only contain
  the child element - so foo doesn't contain members foo[0] or foo.bar, it
  contains [0] or bar. Path walking happens when mapping source variable to
  debug variable.
* This works just as well for DXBC but works much better for SPIR-V where debug
  variables can be more complex.
2020-02-20 19:07:28 +00:00
baldurk 661ee35f30 Refactor ShaderDebugTrace to not return a single list of complete states
* The ShaderDebugTrace now only sets up the initial state of an opaque
  ShaderDebugger handle.
* This handle can then be passed to a new function - ContinueDebug - to
  iteratively return N more states. The number of states is implementation
  defined and may be a fixed number or it may run for a fixed time.
* The states themselves no longer contain a complete snapshot of all variables,
  but instead only the changed variables for that iteration. The changes are
  stored as before and after value to make it easier to step forwards and
  backwards (only the ShaderDebugState is needed to move forward or backwards,
  you don't have to search back for the last set value of a variable to 'undo' a
  change).
2020-02-06 17:58:42 +00:00
baldurk 410f9d86bd Remove register/HLSL handling from shader viewer, work agnostically
* The shader viewer shouldn't handle specifics of D3D bytecode, instead it now
  works generally with whatever the debug and source variables are.
* VarType::Unknown is used for D3D registers which are typeless.
2020-02-06 17:58:41 +00:00
baldurk fdb6617cb1 Pass back 'registers' for resource bindings in debug trace 2020-02-06 17:58:41 +00:00
baldurk 0e0ff8714c Add fake source-mapping information for constants in debug traces
* cbuffer and input registers no longer have any names elided into them, they
  are 'raw' registers. The source mapping provides the information of where they
  come from as best as possible.
* Since we're now using source-mapping for constants, fix some source mapping
  issues with arrays, nested structs/arrays, and matrix major-ness.
2020-02-06 17:58:41 +00:00