Commit Graph
86 Commits
Author SHA1 Message Date
baldurk cbb8399d3e Fix incorrect offset reading integer texture sampling results on D3D 2022-08-10 14:56:44 +01:00
baldurk 9603f5a925 Pre-compile shaders for math and sampling opcodes during shader debug
* D3D12 math shader was already precompiled, but on D3D11 we now allocate
  everything up front and on D3D12 we also up-front compile sampling.
* The only exception is const offsets which can't be variable, so we cache these
  (likely we'll only see a few variants per shader/capture) and create them on
  demand.
2022-06-30 13:51:27 +01:00
baldurk fcdea67879 Update copyright years to 2022 2022-02-17 17:38:32 +00:00
baldurk 161c16385a Reduce size of DXBC operation/declaration/operand structs 2021-07-09 16:27:45 +01:00
baldurk 7149302680 Rename 'draw' or 'drawcall' to action
* There's not a good accepted terminology for this kind of event, and for
  historical reasons 'drawcall' has been the accepted term, even though
  that can be quite confusing when a dispatch or a copy is a 'drawcall'.
* This is particularly highlighted by the event browser filters where
  $draw() includes draws and dispatches, but $dispatch() only includes
  dispatches, it's hard to intuitively understand why $draw() matches all
  of these calls.
* As a result we've defined the term 'action' to cover these types of
  events in the same way that we defined 'event' in the first place to
  mean a single atomic API call.
2021-07-01 15:15:05 +01:00
baldurk 026da176bb Update copyright years to 2021 2021-01-13 13:56:10 +00:00
baldurk b01c84f051 Implement proper handling for unbound views in shader debugging
* We force FetchUAV/FetchSRV to always return something, and it can be empty if
  the resource is unbound meaning we get proper OOB behaviour for it. The D3D12
  implementation still prints an error message for registers that don't
  correspond to the root signature at all, but for D3D11 we silently allow it.
2021-01-05 18:26:27 +00:00
baldurk 3aaccc4fda Use rdcfixedarray in parameters for functions instead of C arrays
* This maps better to tuples in python
2020-12-15 22:52:38 +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 1ab2047ecb Reset state in D3D shader debugging to before draw when fetching UAVs
* Debugging shaders with UAV access could(likely will) have side-effects on
  those UAV contents, so when ContinueDebug needs to fetch UAV contents we
  should replay back to before the draw to fetch them.
* This replay only happens once per ContinueDebug, and UAV contents are cached
  globally so we only do it once per UAV that's accessed, so the impact is low.
2020-12-07 15:41:03 +00:00
baldurk 03b7229bad Support choosing multiview viewport in vertex debugging on vulkan 2020-10-28 13:34:08 +00:00
baldurk bf567adea1 Fix backwards finite check in D3D11 shader debugging 2020-07-20 16:31:59 +01:00
baldurk ec6627af03 Use our own isinf/isnan over compiler provided ones that are unreliable
* Due to standards nonsense the availability of isinf/isnan in C++ is quite
  complex and varies a lot between compilers. Trying to access them reliably is
  quite brittle and they're easy to implement with bit-inspection of float
  patterns, so we do that instead.
2020-07-14 13:24:36 +01:00
baldurk a6d06642b5 Ensure we don't trash state while debugging 2020-06-16 15:27:40 +01:00
baldurk bdead116eb Handle NULL/out of bounds vertex buffer data in D3D11 shader debugging 2020-06-03 18:41:12 +01:00
baldurk f9c1f24c0c DDX/DDY are always float typed 2020-06-03 18:41:11 +01:00
baldurk 5a0134ed4b Free shader debugger in replay driver so it's proxied correctly 2020-05-15 19:03:27 +01:00
baldurk e9b92a5ca7 Fix handling of base vertex in D3D11. Closes #1862 2020-05-12 19:04:57 +01:00
baldurk 90c10ea1fc Handle boolean inputs in vulkan shader parameters
* We change to use VarType instead of CompType for signature parameters which
  allows us to represent different types of variables beyond just
  unsigned/signed integer and float.
2020-05-07 22:46:41 +01:00
Steve Karolewics a5583b83ee Add test for MSAA evals to D3D11_Shader_Debug_Zoo 2020-03-04 19:11:56 +00:00
baldurk a788e51733 32-bit compile fix 2020-03-02 18:55:50 +00:00
baldurk 38481d9cd7 Fix out of bounds vertex buffer fetching behaviour 2020-03-02 17:37:23 +00:00
baldurk 29f0ad9b60 Fix wrong state being used to populate cbuffers in debugging 2020-03-02 17:37:23 +00:00
Steve Karolewics c56373ed94 Add impls of GetBuffer/ResourceInfo for D3D12 shader debugging 2020-02-21 17:56:33 +00:00
baldurk c23825292d Remove redundant instOffset/vertOffset parameters from DebugVertex() 2020-02-20 19:07:29 +00:00
baldurk de7f9d8e1c Remove hasSourceMapping from ShaderDebugTrace
* We expect to always have source mapping, from reflection data if nothing else.
2020-02-20 19:07:29 +00:00
Steve Karolewics dfbe7fb6bf Remove primitive ID usage from pixel shader debugging when invalid
SV_PrimitiveID is only valid as a pixel shader input if there's either
no geometry shader, or the geometry shader emits SV_PrimitiveID. With
D3D11, the debug layer will complain but rendering will proceed. With
D3D12, the PSO fails to compile. For both APIs, pixel shader debugging
now checks whether this is true, and disables its usage if it isn't.
Added tests for various valid scenarios with SV_PrimitiveID.
2020-02-20 19:06:22 +00:00
Steve Karolewics 905aacafd0 Migrate DebugAPIWrapper resource info functions to binding slots
With SM5.1, the operand for instructions like resinfo provide two
indices - the logical identifier and the shader register. Lookup the
identifier to convert to binding slot.
2020-02-18 19:18:31 +00:00
baldurk baa058a7e8 Add some safety checks of edge case problems 2020-02-13 11:01:45 +00:00
baldurk 1b29d0d69c Respect interpolation modes on PS inputs when gathering debug data 2020-02-06 17:58:42 +00:00
baldurk 9436dbf8c3 Fix sampling program source for ld_ms sampling 2020-02-06 17:58:42 +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 fa9289c372 Remove dependency of DXBCDebug::State on ShaderDebugTrace
* This means the quad doesn't have a trace per thread. All per-thread data is in
  the State itself, and anything that's not per-thread is in the GlobalState.
2020-02-06 17:58:41 +00:00
baldurk c037aac6b3 Rename ShaderDebug namespace to DXBCDebug 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
baldurk 66cebe0a4c Refactor shader debug trace to have single mutable variable array
* Moving away from 'registers' explicitly being stored, we now have a single
  variable array where the shader representation is responsible for allocating
  it.
* In DXBC we calculate the number of each type of mutable variable (temps,
  indexable temps, and outputs) and assign slots linearly.
* We also update some naming - high-level variables aren't "locals" since they
  could be globals too, and debugging variables aren't "registers" but simply
  the variables we use for debugging which may be more complex than float4 for
  other APIs.
* The local variable matching by string name is unnecessary for this change
  but will be more useful in future after further refactors where there isn't
  a single list of variables to index into at the upper level.
2020-02-06 17:58:41 +00:00
baldurk 01461db738 Store mapping from instruction to disassembly line in shader debug trace
* This avoids having the UI need to do a scan and expecting to find
  "instruction:" on the start of a line.
* We also move the callstack to be stored per-step, and not in the line info
  mapping.
2020-02-06 17:58:41 +00:00
Steve Karolewics 1c764ca518 Fix constant buffer lookups with SM5.1 shader debugging
Constant buffers store some additional state when parsed from DXBC
to make it easier to fix the match and know the correct size. The
debug trace still stores a simple array of CBuffers, but the shader
debug code provides a BindingSlot and uses the ShaderBindpointMapping
to find the logical identifier that shader instructions will use to
reference the constant buffer.
2020-01-28 18:44:37 +00:00
Steve Karolewics 36e81aba5d Change SRV/UAV fetching to be on-demand, when needed by an instruction 2020-01-21 18:28:42 +00:00
baldurk d4e723bfd8 Fix bugs identified by using PVS Studio
* A few copy-paste errors, some tautological checks indicating errors, missing
  return value checks.
2020-01-17 19:53:38 +00:00
Steve Karolewics 654acb67f5 Add register space support for shader global state UAV/SRV data
Instead of fixed arrays, the global state stores a map of UAVs and
SRVs, with the key being a pair of the shader register and register
space. Switched D3D12 sampler/gather to use SM5.1 and handle register
spaces.
2020-01-17 19:53:23 +00:00
baldurk 2916c0f9f7 Update copyright years to 2020 2020-01-06 16:20:45 +00:00
baldurk 2c80a7206b Enable 'enum value not handled' warning on MSVC, fix issues
* Mostly we add an explicit default: break but in some cases we add explicit
  cases and/or error messages.
2019-12-17 18:02:10 +00:00
baldurk 05a70164f6 Remove use of legacy StringFormat::snprintf variants 2019-12-16 18:10:32 +00:00
baldurk b850abdfa0 Remove std::vector/std::string use from D3D11 driver 2019-12-16 18:10:32 +00:00
baldurk 1772222d66 Remove std::string/std::vector from shader projects 2019-12-16 18:10:31 +00:00
baldurk c4ca8cb1d1 Reduce reliance on big public headers where possible
* Mostly moving includes from common headers to cpp where possible, and removing
  includes of the whole thing where only enums or rdcstr etc are needed.
2019-12-16 17:06:16 +00:00
Steve Karolewics 9ff7b04f6f Move code to gather PSInput definitions to a separate function
The code to get initial values for PS debugging includes a step to
traverse the shader stage's inputs and previous stage's outputs, to
define a struct that is used in a replacement pixel shader to collect
the initial values. This logic is API-agnostic and can be moved to a
DXBC file to allow D3D12 to use it.
2019-11-25 09:54:08 +00:00
Steve Karolewics 5179c99f7d Add impl for creating a D3D12 global state for shader debugging. 2019-11-20 16:35:14 +00:00