Commit Graph

5264 Commits

Author SHA1 Message Date
baldurk cbc27222e2 Add qrenderdoc python SWIG bindings, for the stable/clean interface 2017-04-18 14:57:43 +01:00
baldurk 7a5bf26325 Add conversions for certain Qt types to/from python native types 2017-04-18 14:57:43 +01:00
baldurk 094c4164dc Refactor qrenderdoc to provide stable, clean and deliberate API
* Note, this API is still in-flux and beta, so there may still be some
  more changes before it's 'stable', and even then it will still be
  subject to some amount of change.
* This API is then exposed to python via SWIG bindings and hides
  internals that don't need to be visible, and means the actual API is
  easier to work with.
* We also use this API to reduce inter-dependencies between different
  windows that need to interact with each other at a high level.
* The naming is python/standard RenderDoc TitleCase method names, not
  Qt style camelCase methods.

# Conflicts:
#	qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.cpp
#	qrenderdoc/Windows/TextureViewer.cpp
2017-04-18 14:57:43 +01:00
baldurk 6969b5b677 Fix refcounting and lifetime management around async python callbacks
* We need to keep a PythonContext (and its globals Dict) around while
  we still have some pending callbacks happening. So now the external
  code creates a PythonContext and then releases it when it's done, but
  the context will hang around until the global redirector object is
  destructed, which is responsible for deleting the context.
* The global redirector is deleted when a refcounting cycle is detected
  and the dict is unreachable, which only happens after the context is
  released.
* Any time a callback is passed to something and converted to a
  std::function we add a reference on the global redirector to keep it
  alive. When the callback has finished executing we remove the ref.
* This way, any pending callbacks that have been called but not finished
  or converted (queued) and not called yet asynchronously will keep the
  context object alive to be able to output, handle exceptions, etc.
* Additionally we need to detect when we're being called asynchronously
  and handle exceptions separately instead of trying to propagate up the
  call chain, because there might not be any more python code up the
  chain (e.g. the render manager calling a python callback).
2017-04-18 14:57:42 +01:00
baldurk c49670cfad Add a __str__ function for ResourceId 2017-04-18 14:57:42 +01:00
baldurk 3e1275ed50 Pass PyObject *self along with conversion functions
* We need this object to properly convert any object/pointer to a new
  python owned instance of that type.
2017-04-18 14:57:42 +01:00
baldurk c698fe194e Generalise rdctype typemaps so they can be invoked for multiple types 2017-04-18 14:57:42 +01:00
baldurk dc1ee62730 Generalise function ConvertList to ConvertInPlace
* We'll use the same function for maps and we want to be able to reuse
  the typemaps and things there.
2017-04-18 14:57:42 +01:00
baldurk ab6a868057 Don't rely on TypeName just for error messages calling python callbacks 2017-04-18 14:57:42 +01:00
baldurk 6e1ebf2978 Convert strings directly without using SWIG_AsCharPtrAndSize
* This function is optionally compiled into bindings files so it might
  not be present, there's no need to depend upon it.
2017-04-18 14:57:42 +01:00
baldurk 8c5a2ca34e Remove unused /MANIFESTDEPENDENCY option 2017-04-18 14:57:41 +01:00
baldurk 5adce29b44 Add support for documenting bindings API directly in code 2017-04-18 14:57:41 +01:00
baldurk bfa1153a40 Handle prints of lines over 4k characters 2017-04-18 14:57:41 +01:00
baldurk 2e2a58950a Integrate pyside2/shiboken2 to be able to bind Qt to python
* On linux we make it optional since it's too large a project to add
  as a build step via ExternalProject_add.
2017-04-18 14:57:41 +01:00
baldurk 849f5b443d Change python handling from sub-interpreters to per-context globals
* Using a separate dict for globals/locals for each interpreter means we
  still get separation of variables and no persistence where we don't
  want it, but removing sub-interpreters means pyside can work as it
  uses the PyGILState_ APIs which do not support sub-interpreters.
* We import everything up front then duplicate the __main__ each time we
  create a new context so we keep the __main__ pristine and muck up an
  individual copy.
* Because sys is now shared, the output redirectors that overwrite
  sys.stdout and sys.stderr have a NULL context, and instead they look
  up a specific global which contains the actual context pointer.
2017-04-18 14:57:41 +01:00
baldurk cb510298d8 Add wrapper around tracking a python context and executing scripts 2017-04-18 14:57:41 +01:00
baldurk 12472d93bc Link against python in qrenderdoc 2017-04-18 14:57:41 +01:00
baldurk 5853344015 Note the requirements for C++14 in CONTRIBUTING.md, update travis build 2017-04-18 14:57:41 +01:00
baldurk 66353de7fb Add support for SWIG wrapping python callbacks as std::functions 2017-04-18 14:57:41 +01:00
baldurk 940d3662eb Add SWIG file to generate python bindings for internal replay API
* SWIG outputs two files - renderdoc_python.cpp with the main actual
  wrapping code, and renderdoc.py a small module that does some
  bootstrapping on python side.
* We use a custom version of SWIG that generates strong/typed enums in
  python based on enum classes, so in cmake we add this custom swig
  fork as an external project and compile it before generating the
  wrappers. On windows there's a committed version of the SWIG binary
  that gets run directly from the .pro or .vcxproj.
* The renderdoc.py gets embedded as a resource on windows or as a C
  generated unsigned char array via include-bin on other platforms, so
  that we can insert it into the python context without needing it to
  sit around on disk somewhere in sys.path
2017-04-18 14:57:40 +01:00
baldurk 7c45218df9 Since we no longer use anything from qmake on windows, don't set dirs 2017-04-18 14:57:40 +01:00
baldurk 3e74683a70 Fix qrenderdoc compilation on Win32 2017-04-18 14:57:40 +01:00
baldurk 2e87ca4531 Require qt creator to locate the cmake project to build on non-windows
* Previously the cmake build would put librenderdoc.so in a /bin folder
  in the source folder so the qt creator project could link against a
  fixed path when just opening the project solo.
* This won't scale though for fetching the SWIG outputs from cmake, and
  it's ugly to modify the source folder for out-of-source builds.
* Instead we have cmake generate a qt creator include file with all of
  the settings and paths needed, and pass the CMAKE_BINARY_DIR into
  qmake when building. This does mean that when opening the project in
  qt creator you need to specify CMAKE_DIR=/path/to/build though.
* As a bonus, this means we can let cmake identify where python is and
  have qt creator link against it rather than having to hardcode include
  paths etc.
2017-04-18 14:57:40 +01:00
baldurk fd6fce7a78 Refactor pipeline states to expose opaque string properties as enums.
* Things like addressing modes, stencil operations, and other things the
  UI didn't need to know about previously were only exposed as string
  values to be passed through and displayed.
* Now we describe these with enums so the API can be properly
  introspected and used by consumers that might want to know the actual
  values of these states.
2017-04-18 14:57:40 +01:00
baldurk ebb398ae00 Refactor pipeline states to use in-class initialisers, not constructors 2017-04-18 14:57:38 +01:00
baldurk 8262bd2770 Refactor viewport to have X/Y separate members instead of TopLeft[2] 2017-04-18 14:57:38 +01:00
baldurk f1df7423e2 Standardise pipeline object names with name/customName where relevant 2017-04-18 14:57:38 +01:00
baldurk 42b599ff70 Remove legacy ElementOffset/ElementWidth from D3D11 pipeline state 2017-04-18 14:57:38 +01:00
baldurk 587fba0b68 Rename DirectoryFile/FileProperty to Path, and re-use struct in OS code
* They describe directories or files, and really describe a single path
  on the remote system.
2017-04-18 14:57:38 +01:00
baldurk 637d4089e2 Rename colour to color in public API code
* Following the principle of least surprise, color tends to be more
  commonly used in APIs and graphics code even outside the USA.
2017-04-18 14:57:37 +01:00
baldurk d94f387399 Refactor bucketing code a little to use a record type enum 2017-04-18 14:57:37 +01:00
baldurk 4887ecc851 Remove InvocationIndex shader builtin and remap it
* We map it to either GSInstanceIndex or OutputControlPointIndex
2017-04-18 14:57:36 +01:00
baldurk 0ad5709df3 Remove poorly chosen 'Fetch' prefix from a few data structures.
* This goes all the way back to the first iterations where these were
  the only structures and 'Fetch' referred to them returning data from
  the core code to the UI.
2017-04-18 14:57:36 +01:00
baldurk bd199ca8e6 Remove declarations for C interface from renderdoc_replay.h header
* The functions are still exported and that's all renderdocui cares for.
* The interface is no longer to be used so gets in the way of the
  generated SWIG bindings.
2017-04-18 14:57:36 +01:00
baldurk 455ac56d5b Borrow a concept from an upcoming larger refactor to get typenames
* For SWIG bindings we need something that will go type -> string name
  so we can look up the SWIG type in a template to convert elements in
  arrays.
* An upcoming refactor will contain this kind of typename for proper
  reflection, so to minimise code churn and avoid adding multiple new
  solutions for the same kind of thing, we borrow the macro name and
  implement it for the API structs we need.
2017-04-18 14:57:35 +01:00
baldurk 1be8c70da6 Make ResourceId::id member private, add ResourceId::Null() 2017-04-18 14:57:35 +01:00
baldurk ce4a99b7b8 Rename ShaderResource::IsSRV to a more generic IsReadOnly property 2017-04-18 14:57:35 +01:00
baldurk 96f11095da Change type of FrameStatistics::recorded to bool32 to be more accurate 2017-04-18 14:57:35 +01:00
baldurk 018dcb073c Rename uavWrite to more generic directShaderWrite 2017-04-18 14:57:35 +01:00
baldurk b7c755192c Remove no-longer used 'context' member of APIEvent structure 2017-04-18 14:57:35 +01:00
baldurk 4f21c29258 Remove unused firstEvent value, since the first event is always 1 2017-04-18 14:57:34 +01:00
baldurk 36ed9fdc70 Remove unused rawType from SpecialFormat 2017-04-18 14:57:34 +01:00
baldurk c44f355380 Remove nested structs from D3D12 pipeline state and move to namespace 2017-04-18 14:57:34 +01:00
baldurk af33e5d296 Remove nested structs from Vulkan pipeline state and move to namespace 2017-04-18 14:57:34 +01:00
baldurk 9e23443356 Remove nested structs from GL pipeline state and move to namespace 2017-04-18 14:57:34 +01:00
baldurk b4d3401866 Remove nested structs from D3D11 pipeline state and move to namespace
* Moving into a namespace makes it easier to give the structs non-clumsy
  names while still being unique and not overlapping with the other API
  pipeline states.
2017-04-18 14:57:33 +01:00
baldurk b271eb3103 Remove nested structs in replay API (not including pipe states)
* SWIG doesn't handle nested structs conversion to python, so we are
  going to split out all structs. Mostly this is the case in the
  pipeline state structs, but this commit splits out a few in the rest
  of the API.
2017-04-18 14:57:33 +01:00
baldurk d40fc8471d Change API enums to enum class, remove now redundant prefixing
* This gives a little nicer syntax, a bit better type safety, and also
  reflects better for SWIG bindings. Overall it's a minor change but
  better.
* We don't update the C# UI at all, since it's soon to be removed and
  not worth the effort/code churn.
* For now so we're ABI compatible with C#, all enums are uint32_t, but
  that is an obvious optimisation in future to reduce struct packing.
* We avoid 'None' as an enum value, because it's a reserved word in
  python so will cause problems generating bindings.
2017-04-18 14:57:33 +01:00
Janos Pantos 71e779a08f Fix driver warnings during android replay
Eliminate driver warnings for invalid framebuffer attachments, blends
and image formats (in case of glBindImageTexture). Framebuffer
attachment data query and setter codes are also refactored a bit.
2017-04-18 06:56:37 -07:00
Janos Pantos 942a323b8e Add check for EXT_texture_filter_anisotropic extension 2017-04-18 06:56:37 -07:00