Commit Graph

99 Commits

Author SHA1 Message Date
baldurk 026da176bb Update copyright years to 2021 2021-01-13 13:56:10 +00:00
baldurk e1fe211f3c Rename Shutdown to RemoveHooks in in-application API. Version is 1.4.1
* This is a binary and source backwards compatible change.
2020-01-30 13:02:23 +00:00
baldurk 2916c0f9f7 Update copyright years to 2020 2020-01-06 16:20:45 +00:00
baldurk bd9f4fc389 Remove use of vector/string from core project
* This also affects the drivers via interfaces e.g. IReplayDriver and some
  utility functions.
2019-12-16 18:10:31 +00:00
baldurk 86ff87863e Update copyright years to 2019 2019-02-01 18:32:13 +00:00
baldurk 9999ec25b8 Remove temporary compatibility hook helpers 2018-07-06 22:44:22 +01:00
baldurk c70c116bd7 Refactor hooks towards more unified/clean approach
* Hooking is now done the same way across platform, with different OS
  implementations.
* Regardless of how exactly hooks are implemented, we register libraries to hook
  and functions to hook within those libraries, and provide a location to store
  the original/onwards function pointer. This allows hooking to work whether
  it's done using import hooking that doesn't modify target libraries (so using
  dlsym or GetProcAddress will return the same value for the onwards function
  pointer) or whether it's implemented with prologue patching and trampolines,
  where we'd create an infinite loop if we did that.
* We also provide stronger guarantees - the original function pointers will
  _always_ be made available as soon as the library is loaded, whether hooked or
  not, no exceptions. This means less uncertainty in hooking code about when or
  how onward functions will be available.
* OS-specific hook functions are changed to just be implementations of
  LibraryHooks functions rather than indirected through macros and pre-processor
  definitions.
* In this commit we provide some temporary functions providing the old interface
  to reduce churn - the library-specific hook code will be updated shortly after
2018-07-06 22:44:20 +01:00
baldurk edd6ab4faa Hook initialisation can't fail, because it's just a registration
* Hooking no longer does anything active immediately when initialised, it just
  registers a function to be hooked, which is then deferred and/or continually
  re-hooked depending on platform-specific functionality.
2018-07-06 22:44:20 +01:00
baldurk 6a30e63a46 LibraryHook classes self-register, without library name
* The libName parameter to CreateHooks isn't yet deleted since it's used as a
  hack in the GL hooks to have multiple paths through a function.
2018-07-06 22:44:19 +01:00
baldurk 9ecad14932 Provide default implementation for LibraryHook::OptionsUpdated 2018-07-06 22:44:19 +01:00
baldurk b47ce7d413 Remove the ability to enable/disable hooks
* This wasn't very well supported after D3D11 anyway, and modern tools
  (VSGD/PIX/etc) don't respect D3DPERF_SetOptions which was the only route that
  actually needed to globally enable/disable hooks.
* D3D11CreateDevices's flag still works to prevent hooking.
2018-07-06 22:44:19 +01:00
baldurk 047bff7261 Add an new android hooking method using JDWP to inject & PLT hooks
* This is based on the GAPID method of injection, using the same steps
  to connect with JDWP and debug the application, breakpointing on key
  init-time steps to patch vulkan layer search paths and load libraries
  from our installed apk.
* We diverge by then using PLT hooks instead of trampolines to hook the
  EGL/GL calls - and so we also hook dlopen.
* This should work on any debuggable application - not currently checked
  but does not replace/break any of the previous injection, which can
  still work.
2018-01-26 21:19:13 +00:00
baldurk e305029ddd Update copyright years to 2018 2018-01-01 17:55:29 +00:00
baldurk 82a0e055ba Change how replay programs are identified, from filename to sym export
* Instead of checking on the filename, we look for a specially named
  exported symbol somewhere in a module that's already loaded.
* This allows us to mark the python module as a replay program, so if
  it's loaded into the python interpreter it will be able to use the
  replay API.
2017-08-31 18:34:19 +01:00
baldurk 030cbfde9a Batch update copyright years everywhere 2017-01-06 12:13:31 +00:00
baldurk 8d0915401f Unify feature macro handling 2016-11-07 18:14:49 +01:00
baldurk 8f4a55a3b5 Set all processes under a given UI instance to log to the same file.
* Using OS-specific append writing functions instead of simple fopen/
  fwrite/fclose we can guarantee that multiple processes writing to the
  same log file won't trash or interleave their log output.
* To make the logs readable the PID is now included along with the
  project/timestamp.
* After that, we make sure that when we launch a program we set the
  output log to the same file as the parent UI. This keeps all the logs
  together and removes user confusion over which logfile is needed.
* We also move all of RenderDoc's temporary files under a RenderDoc
  folder in the temp folder, instead of scattering the files in the root
2016-11-02 23:37:38 +01:00
baldurk aeb0f3a005 For libraries opened with RTLD_DEEPBIND, use plthook to hook dlopen
* Split out the hook functions into linux and apple/android (which are
  currently unimplemented).
2016-09-26 17:33:51 +02:00
baldurk 5f28b745a2 Format code according to newly added clang-format
_  /)
                 mo / )
                 |/)\)
                  /\_
                  \__|=
                 (    )
                 __)(__
           _____/      \\_____
          |  _     ___   _   ||
          | | \     |   | \  ||
          | |  |    |   |  | ||
          | |_/     |   |_/  ||
          | | \     |   |    ||
          | |  \    |   |    ||
          | |   \. _|_. | .  ||
          |                  ||
          |repository history||
          |                  ||
  *       | *   **    * **   |**      **
   \))ejm97/.,(//,,..,,\||(,,.,\\,.((//
2016-05-22 19:41:53 +02:00
baldurk 863dc1d259 Split 'linux' os-specific code into 'posix' and then 'linux'/'android'
* And eventually probably 'apple' as well.
2016-05-14 01:53:51 +02:00
baldurk 20625eeeba Add a LibraryHooks callback when capture options are changed 2016-04-30 17:18:45 +02:00
Michael Vance 8b1794456d Switch RENDERDOC_PLATFORM to RENDERDOC_PLATFORM_<PLAT>.
Notes
======
- With no clean way to do string comparisons in the C preprocessor, have a define per-platform. This avoids the clever string concatenation for determining the OS-specic bits, and allows SN-DBS to distribute builds without custom rewrite rules.
- Fix up instances of WIN32, etc., in non-3rdparty sources to refer to this.
- Move the per-platform specific bits into their own subdirs.
2016-04-15 13:59:59 -04:00
baldurk 2e0ffa7813 Batch update copyright years everywhere 2016-02-07 18:50:45 +01:00
baldurk 7b952c53ef Move loadmodule/getprocaddress code into os_specific 2016-02-07 18:44:53 +01:00
baldurk 079a44b4a9 Speculative fix - try to avoid crashes if hooked dlopen is called early
* This isn't particularly stable/nice, probably needs a complete rethink
2015-10-01 00:51:22 +02:00
baldurk 62f7362e92 Move dlopen to be hooked centrally on linux, to be multi-API friendly 2015-08-23 22:23:53 +02:00
baldurk bde6fabf7d Rearrange project structure, so that drivers can be easily disabled
* This is kind of arbitrary at the moment, but in future when D3D12 and
  Vulkan drivers appear, not everyone who builds RenderDoc will want to
  build all drivers, so making them separate projects makes it more easy
  to disable/remove them.
2015-06-29 20:04:47 +02:00
baldurk adaf3b25e6 Remove orphaned file 2015-06-19 22:37:30 +02:00
baldurk 1d96ac2b05 Simplify renderdoc_app.h to remove typedefs and dependency on stl 2015-06-19 22:34:57 +02:00
baldurk 6993052c31 Linux compile fixes 2015-04-14 08:05:13 +01:00
baldurk b41b5242d1 Support switching between multiple APIs in the same program. Closes #124
* The core class is now responsible for tracking the active window and
  cycling through, so it can cycle through multiple APIs.
* For GL we only set up associations for capturable windows, and only
  those that present (since helper windows are often created). Since
  GL doesn't really have a 'this window is done rendering' call, we just
  decay old windows that haven't presented in >5 seconds.
* Also on GL, legacy/uncapturable windows aren't associated so they will
  not cycle to at all.
* The embedding API now expects a device pointer and window handle to
  set active window or start/end a capture. You can still pass NULLs if
  there is only one API active.
2015-04-13 11:31:30 +01:00
baldurk 35fa1ce2bf Refuse to capture on old contexts, warn on compat profiles. Closes #125
* If CreateContextAttribs is not used to create the context, the overlay
  will run in super-duper old mode using immediate mode calls and fixed
  function pipeline. This way it should display on (in theory) any GL
  app. Capturing will be prevented.
* Compatibility profile contexts are still allowed, but a warning is
  displayed in the overlay.
* If CreateContextAttribs is used to create a < 3.2 version context, we
  go down the same path as for legacy contexts, except with an accurate
  overlay message (just that the version isn't supported).
2015-04-08 21:43:04 +01:00
baldurk 6cd1f70bb6 Fix several warnings for compiling on VS2015
* Note at the time of committing there are still some warnings in MS
  headers that you might need to suppress in a couple of files.
* 3rd party code just has the warnings suppressed for ease of merging.
* The majority of warning fixes were for local variables shadowing
  other locals, function parameters, or members. In most cases they
  weren't a problem, but in some cases it was potentially dangerous!
2015-03-13 10:16:19 +00:00
baldurk 446d7d6da5 Take our own copy of the X connection that we are passed
* We need to copy the X display (by fetching its connection string and
  calling XOpenDisplay), so that if the Display* we had gets closed then
  nothing will crash.
2015-02-25 22:26:45 +00:00
baldurk c9c52537f1 ARB_dsa part 1 - hook DSA functions, implement all but tex* & create*
* Doesn't compile yet! Just splitting this up logically so the change is
  a bit easier to digest.
* I've commented and organised a bit better the gl_hookset.h hook list.
* The function hooks are set up for all of the ARB_dsa entry points.
  Those that are semnatically identical to EXT_dsa are set up as aliases
  (with EXT_ being canonical, so we can fall back if ARB_dsa isn't
  supported - see comments in gl_hookset.h).
* Implemented the new functions except for the glTexture* family and the
  glCreate* family. No deduplication of code yet.
* As with EXT_dsa we "promote" to the DSA function for serialisation,
  but since unlike EXT_dsa we can't assume ARB_dsa is present, instead
  we emulate those functions that we might use unconditionally but may
  not be present.
2015-02-22 23:36:33 +00:00
baldurk ee37bca573 Implement Process::CreateAndInjectIntoProcess on linux
* It's not exactly feature parity but it's a start, and any UI would use
  this under the hood.
* This means at least linux has a semi user-friendly way to launch and
  capture programs - it's limited but you can just use
  $ ./bin/renderdoccmd -c /path/to/program "argument string"
  from the root of the repository.
* Logfile and capture options (which can't be set yet, but you could easily
  hack in something to set them in renderdoccmd.cpp) are passed via
  environment variables to the child process.
2015-01-04 01:02:05 +00:00
baldurk f1f72ec8ff Add process for programs to voluntarily remove renderdoc. Refs #115
* To remove renderdoc (e.g. if the API version doesn't match what is
  expected), user code can call RENDERDOC_Shutdown() to remove the running
  thread and undo any library hooks, then unload the dynamic library.
* This still isn't recommended as there could be unexpected side-effects,
  and it will definitely break if this happens after any APIs have been
  initialised, but it's an option.
2014-12-21 11:30:29 +00:00
baldurk de702ac1d9 Stop filtering wgl extensions, just return all we don't hook as-is
* I will assume for now that any wgl functions I don't explicitly hook have
  no effect on the captured frame and we can safely just let them straight
  through to the real function.
2014-12-20 19:54:46 +00:00
baldurk 3298905d1d Optimise/improve hookset.pl, return dummy function pointers
* Now instead of returning NULL for entry points that we don't support and
  hoping the application will handle that or error out, instead we return
  a function that will log an error if it is ever called, and then pass
  through to the real function. In most cases, the capture will probably be
  broken as whichever function isn't saved.
* hookset.pl is much faster too, it outputs the whole gl_hookset_defs.h
  file and doesn't do multiple searches over the whole set of headers in
  official/ for each function.
2014-12-20 19:54:46 +00:00
baldurk 652f3529a3 Track if a context is core or not, re-check vendor checks on core
* When a compatibility context is created (via the old CreateContext, or
  via an appropriate CreateContextAttribs call), we can still do the vendor
  checks but we want to make sure we perform them again if we ever create a
  core profile context. Note that actually *using* a compatibility context
  isn't supported at the moment, but this won't explicitly break that.
2014-12-14 12:17:41 +00:00
baldurk 2c12423975 Return some WGL extensions that we can easily support. 2014-12-14 00:29:16 +00:00
baldurk c207391b54 Linux compile fixes. 2014-12-12 00:15:45 +00:00
baldurk 5fe0354ce4 Drop use of CONTEXT_FORWARD_COMPATIBLE_BIT, add CORE_PROFILE_BIT 2014-12-11 22:41:11 +00:00
baldurk 12af78d535 Print out the attribs a context is created with 2014-12-11 22:39:35 +00:00
baldurk 11df77cdff Return wglGetSwapIntervalEXT straight 2014-12-11 21:08:19 +00:00
baldurk 9be802082f Add a vendor check to detect if FBOs or VAOs are actually shared
* This lets us detect if the FBO/VAO behaviour is different from the main
  spec, and so we won't miss deletes or other events if the context is
  different since we'll treat them as shared like any other object.
2014-12-11 20:30:34 +00:00
baldurk bda809f9dc Allow GL driver to switch current contexts when really necessary 2014-12-06 20:25:48 +00:00
baldurk 1d0ba67331 Fix for fetching "dll export" functions via getprocaddress on linux 2014-12-05 23:49:50 +00:00
baldurk d30ce5d6b2 Fixes for replay, and populating hooks (call through hooked func) 2014-12-03 18:16:06 +00:00
baldurk 185df924dc Use proper wglGetProcAddress hook 2014-12-03 16:52:37 +00:00