Commit Graph

7653 Commits

Author SHA1 Message Date
baldurk 7ca23e7a87 Set all mips to valid when GenerateMipMaps is called 2018-07-09 16:27:58 +01:00
baldurk 30c8f01a25 Handle implementations on capture without ARB_vertex_binding 2018-07-09 16:27:58 +01:00
baldurk eff35de81b Handle case where an implementation can't readback 'native' format/type
* Sometimes a GLES implementation can refuse to copy back the 'native'
  format/type, most commonly if you want to read back from a GL_RGB texture it
  might require you to readback GL_RGBA.
* We handle this by just reading back the requested format in this case, and
  then copying only RGB tightly into the output buffer.
2018-07-09 16:27:57 +01:00
baldurk f2a2710823 save 'type' parameter as hint to internalformat
* Unfortunately it seems like sometimes in GL when creating an GL_RGB
  internalformat texture you can copy from another GL_RGB internalformat
  texture. Other times you can't.
* In particular the difference can just be the 'type' parameter passed when
  passing initial data, GL_UNSIGNED_BYTE vs eGL_UNSIGNED_SHORT_5_6_5
* We treat this as a 'soft' hint, so if it's not present we fall back to the old
  path.
2018-07-09 16:27:57 +01:00
baldurk 14cb449886 Support EGL_ANGLE_surface_orientation flipped backbuffers 2018-07-09 16:27:57 +01:00
baldurk 00985986d1 Implement missing stub on apple 2018-07-07 01:13:08 +01:00
baldurk 4e57f295b7 Disable GLES support on mac 2018-07-07 00:38:27 +01:00
baldurk ff61bf8def Fix case when GLES is enabled but GL is disabled on linux, or vice-versa 2018-07-07 00:00:04 +01:00
baldurk e5f6b24696 Declare proper calling convention for EGL hooks 2018-07-07 00:00:03 +01:00
baldurk c49888424f Disable GLES compilation for docs build 2018-07-07 00:00:03 +01:00
baldurk eeeba59058 Remove unnecessary GL/EGL link in qrenderdoc 2018-07-07 00:00:03 +01:00
baldurk 1665495289 ARB_viewport_array was not made core in GLES 3.2 2018-07-06 22:44:27 +01:00
baldurk 4040429fba Remove unnecessary link against libGL/libEGL in renderdoccmd
* This means it's easier to build with GLES support by default
2018-07-06 22:44:26 +01:00
baldurk a53797fc51 Remap EGLSurface back to native window pointer
* We need the native window pointer for registering frame capturers, and adding
  input window filters (on windows).
2018-07-06 22:44:26 +01:00
baldurk 296f84fb7e Change GL text rendering to be compatible with a wider set of versions
* In particular this will work with GLES 2.0
2018-07-06 22:44:26 +01:00
baldurk 08616c9ad1 Emulate ARB_program_interface_query using glslang's reflection
* In particular it wasn't added until GLES 3.1, and we need it during capture to
  determine the uniforms and other things, so we emulate the subset of queries
  that we need ourselves.
2018-07-06 22:44:26 +01:00
baldurk f00832f2f9 Fix vulkan shutdown crash, destroy GPUBuffer before device/instance 2018-07-06 22:44:25 +01:00
baldurk 178f61abd0 Separate out function to make shared context for vendor checks
* This is only to be used to make a temporary context to share with. We make
  sure to use the same visual/config as the parent context to ensure it will
  successfully share.
2018-07-06 22:44:25 +01:00
baldurk 44f9b08e71 Tweak some core versions for extensions
* ARB_geometry_shader4 was brought into desktop core GL in 3.2, not 4.1.
* Geometry shaders and viewport arrays were in GLES 3.2
2018-07-06 22:44:25 +01:00
baldurk 4bf028371d Check for geometry shaders before querying if framebuffer is layered 2018-07-06 22:44:25 +01:00
baldurk 5b0f51f9d9 Check extension for use of TEXTURE_BORDER_COLOR
* This wasn't supported on GLES until 3.2, or with OES_texture_border_color
2018-07-06 22:44:24 +01:00
baldurk 89a3da2171 Check for ARB_texture_multisample being available
* We need to hack around GLES, as it somehow added only part of the original
  extension - non-arrayed textures. So we conceptually split up the extension
  into two, and treat the real extension as a superset.
2018-07-06 22:44:24 +01:00
baldurk 3794d3facc Emulate glGetTexLevelParameter on GLES
* This function is not available until 3.1 so we can't rely on being able to use
  it - even if we get a valid function pointer for it.
* We emulate it by storing the data up front and allowing the emulation layer
  access to our texture info to look it up. It's a bit roundabout but it works.
2018-07-06 22:44:24 +01:00
baldurk 20273c3854 Ensure that glBlitFramebuffer for internal copies has correct state
* In particular we need to disable scissor (which can affect the blit) and any
  color/write masks.
2018-07-06 22:44:24 +01:00
baldurk 3327b1f3e1 Don't set texture data when unbinding texture (name = 0) 2018-07-06 22:44:23 +01:00
baldurk b3eeadd256 Check for EXT_texture_sRGB_decode before using enums 2018-07-06 22:44:23 +01:00
baldurk 6f39bfd563 When capturing, only serialise current state after updating context
* We need to be sure the context pair has been updated before serialising the
  state, otherwise any resources we query out will be associated with
  potentially the wrong context.
2018-07-06 22:44:23 +01:00
baldurk a1f21696fa Don't try to release empty/NULL GL resources 2018-07-06 22:44:23 +01:00
baldurk 031d8fd0e5 Enable GLES by default on linux, and display API/winsys status in cmake 2018-07-06 22:44:22 +01:00
baldurk d0ca83bf6c Support creating OpenGL ES contexts via WGL/GLX. Closes #1009 2018-07-06 22:44:22 +01:00
baldurk 4299c29c8b Print message when registering library hooks 2018-07-06 22:44:22 +01:00
baldurk 9999ec25b8 Remove temporary compatibility hook helpers 2018-07-06 22:44:22 +01:00
baldurk a504389bd1 Add new cleaned up GL hooks
* This code was significantly different from the old code, enough that it made
  more sense to re-implement from scratch than modify the old code.
* Note it doesn't compile yet and is not included in any projects.
* We have a hookset per GL interface - WGL, GLX, and stubbed out CGL for mac. In
  addition we have EGL which can be compiled in at the same time as the others.
  Each interface has a dispatch table similar to GL for handling its hooks all
  together.
* The platform hooksets hook their platform-specific functions like
  createcontext, swapbuffers, and makecurrent. For getprocaddress they can call
  into a common function that looks up general GL hooks.
* EGL and GLX can populate the GL hooks using eglGetProcAddress /
  glXGetProcAddress as soon as the library is loaded, but for WGL we must wait
  until the first time a context becomes current.
* We also have an implementation of GLPlatform per type. This takes care of work
  that is platform specific - mostly during replay but also somewhat during
  capture. This is kept separate from the actual hooks.
* On replay we have a platform-specific replay create entry point which
  populuates the relevant dispatch table and calls into a general replay create.
  This will do most common work together but calls out to the GLPlatform
  implementation to do actual initialisation of the API.
2018-07-06 22:44:21 +01:00
baldurk ee853f7f33 Move CheckConstParam into common code 2018-07-06 22:44:21 +01:00
baldurk 426a6cf3ac Add a log print when a new context is created 2018-07-06 22:44:21 +01:00
baldurk d9f439fbbe Add python script to replace bash/perl scripts generating GL hooks 2018-07-06 22:44:21 +01:00
baldurk 28ec4e4fb8 Remove bool returns from GL hook functions that cannot meaningfully fail
* In particular, populating hooks can't fail because we're just fetching as many
  function pointers as we can. Any missing functions have to be handled
  elsewhere.
* This simplifies codepaths and makes it easier to track what's going on without
  needing to thinkg about failure conditions that can never happen.
2018-07-06 22:44:20 +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 75623b4487 Clean up D3D/DXGI hooks. Reduce duplication and separate replay code
* Previously we were going through the hooks for device/factory creation, which
  did barely anything actually useful. Instead we can call directly to the real
  function and wrap the result manually.
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 73e1f7e770 Refactor GL hookset to only a single shared hookset
* Rather than having a hookset created within the different bits of platform
  hooking code and then passed around everywhere, we just make a single global
  hookset object that's shared.
* There's no risk of conflict because our GL object handles all possible
  contexts, there's no separate instancing or anything.
* We also have places like the GL emulation or unsupported function hooks that
  do not handle two separate onward functions, and we undoubtedly have many
  assumptions that only one copy of RenderDoc will hook any given API. If we
  needed multiple hooksets within the same library a huge amount would need to
  change.
2018-07-06 22:44:18 +01:00
baldurk f849952ce9 Move global GL lock into common code 2018-07-06 22:44:18 +01:00
baldurk a7509dadb6 Remove Pre/Post Init/Shutdown of counters. Inline into normal flow 2018-07-06 22:44:18 +01:00
baldurk 152ebc2e2e Add handling for D3D12.1 - D3D12.3 interface UUIDs in queries 2018-07-06 22:44:18 +01:00
baldurk 02f3196935 Support integer and 16/32-bit alpha/intensity/luminance textures 2018-07-06 22:44:17 +01:00
baldurk 06d14ff62b Define safe comparisons for python bindings
* In particular this means that it's safe to compare a ResourceId or similar
  against None. It is always not-equal but it's useful to have the comparison
  work and return the expected result instead of throwing a null reference
  exception.
2018-07-06 22:44:17 +01:00
baldurk b873728d49 Copy trailing null byte to keep GCC warnings happy. Closes #1028 2018-07-06 22:44:17 +01:00