Commit Graph

13293 Commits

Author SHA1 Message Date
Jake Turner 97efa7cf04 Capture support for the presented MTLDrawable
Generate the capture thumbnail image from the presented `MTLTexture`
Serialize the capture `PresentedImage` ID in the `CaptureEnd` chunk.
2022-07-21 10:32:32 +01:00
Jake Turner 9e8be2400f Deleted ObjC::CAMetalLayer_Set_framebufferOnly
Use the metal-cpp implementation instead of the helper version
2022-07-21 10:32:32 +01:00
Jake Turner 8a0af20c1e metal-cpp : add CA::MetalLayer::setFramebufferOnly
Minor code formatting tidy on a couple of previous changes to better match the surrounding code style
2022-07-21 10:32:32 +01:00
Nicola Cerone 43462ea3c9 Fix arcball navigation by updating the basis matrix. 2022-07-20 10:38:38 +01:00
baldurk 3b00cf247e Fix crash when structured exporting on D3D 2022-07-19 10:11:31 +01:00
Ryan Houdek fb91e7360a Add support for vulkan layer suffixes
While Renderdoc already supported multiarch for where to install the
libraries with the LIB_SUFFIX option. The Vulkan layer was left out of
this loop.

Vulkan layers living in `/usr/share/vulkan/implicit_layer.d/` will use a
suffix before the `.json` to separate libraries of different
architectures. These layer files will then point to the architecture
specific `library_path` inside that json file.

Also updates the check in `LayerRegistrationPath` so it handles the
suffix as well. This way `renderdoccmd` won't complain about conflicting
json files.
2022-07-18 19:40:55 +01:00
Jake Turner fca14eac32 Apple minimal Nuklear implementation using AppKit 2022-07-18 13:13:37 +01:00
Jake Turner 2d6290bab1 Basic Metal capture support
Captures can be manually triggered from renderdoccmd capture <application> using F12 or from the UI on the in-development Metal replay branch.
The captures can be loaded and replayed on the in-development Metal replay branch.

The command buffer tracking and serialization are done by GPU submission order which is not necessarily the same as CPU commit order. The command buffer tracking for GPU submission order is currently using an rdcarray, this might change in the future to use a linked list if the performance of appending and deleting from the rdcarray becomes a performance bottleneck.

Does not include support for the presented MTLDrawable ie.
* Thumbnail generation of the final presented image.
* Serializing the presented texture ID.

Does not include support for initial state data.
No MTLBuffer data contents are serialized.

There is a lot missing and a lot of TODOs. 
This is the basic structure for capturing which is then built upon. 

Includes:
* register the Metal device as a frame capturer ie. AddDeviceFrameCapturer
* logic for triggering captures at Present ie. AddActiveDriver, StartFrameCapture, EndFrameCapture.
* Stopped declaring MetalResourceManager as a friend of WrappedMTLDevice which meant making the initial state-related APIs public instead of private.
* IFrameCapturer interface APIs
* Command buffer tracking for including in the output capture CaptureCmdBufCommit and CaptureCmdBufEnqueue.
* Serialise_MTLCreateSystemDefaultDevice(SerialiserType &ser)
* A helper class MetalCapturer which is derived from IFrameCapturer and registered with the RenderDoc instance. This is because Wrapped Metal classes can't have virtual tables as a requirement for how the C++ and Objective C overlay is implemented.
* The frame capture chunk and API AddFrameCaptureRecordChunk
* MetalInitParams data and serialization.

Helper Methods and Members in MTLDevice
* WaitForGPU()
* MTL::CommandQueue *m_mtlCommandQueue which is used to implement WaitForGPU()
* CaptureClearSubmittedCmdBuffers() & CaptureCmdBufSubmit()
* RegisterMetalLayer() & UnregisterMetalLayer() used to track active Metal swapchains

Details on the memory lifetime for WrappedMTLCommandBuffer

retain the real resource in WrappedMTLCommandBuffer::commit()
release the real resource when no longer needed to be tracked: for background capture in during WrappedMTLDevice::CaptureCmdBufSubmit, for active capture in WrappedMTLDevice::EndFrameCapture.

During capture (Background or Active)
* AddRef() record when command buffer is enqueued (explicit or implicit)
* Delete() record at end of command buffer submit

During Active capture
* AddRef() record in command buffer submit
* Delete() submitted command buffers as part of finalizing the capture

Added TrackedCAMetalLayer & ObjCTrackedCAMetalLayer to track the lifetime of CA::MetalLayer.
The CA::MetalLayer is tracked in the hook for CAMetalLayer::nextDrawable(), with ObjCTrackedCAMetalLayer set as an association to the CAMetalLayer. Then ObjCTrackedCAMetalLayer::dealloc() triggers ending the tracking.
2022-07-18 12:41:44 +01:00
Jake Turner 2d34834a19 Add CAMetalLayer::device() to Metal-CPP 2022-07-18 12:41:44 +01:00
baldurk 234262649f Fix calculation of small mip co-ordinates for NPOT textures 2022-07-15 18:07:08 +01:00
baldurk 123509166e Compile shaders in debug when self-hosting captures 2022-07-15 18:00:38 +01:00
baldurk 1494a8f71e Checking for the upload location variable being set in CI
* This helps downstream forks to run CI without seeing a false negative in the
  mac release build due to being unable to upload the final package to the
  server.
2022-07-15 16:04:13 +01:00
baldurk c3a6a8a9d6 If there's no fixed data don't fetch the whole buffer 2022-07-14 14:01:08 +01:00
baldurk b3ad3a2031 Don't overwrite secondary command buffer renderpass state if inactive
* With dynamic rendering, secondary command buffers don't always inherit
  renderpass state from the primary, they can start their own.
2022-07-13 12:11:35 +01:00
baldurk 2833ea4a84 Handle state changes on first event in a command buffer. Closes #2648
* When selecting the first event in a command buffer the render state wouldn't
  properly be updated. This is particularly bad if the state that changed is
  being in/out of a renderpass.
2022-07-13 12:10:40 +01:00
baldurk c7e41000c3 Remove hacky 'validation' of draws in render passes
* This was an extremely old bit of code from before vulkan 1.0 to detect a
  common error. RenderDoc does not validate in general so delete this rather
  than keep it up to date.
2022-07-13 12:09:31 +01:00
baldurk bbe9624b95 Rejig some code around to avoid stack size explosion in vulkan serialise 2022-07-13 11:32:18 +01:00
baldurk 6095606b41 Don't replay initial states for GL texture buffers with no buffer 2022-07-12 14:36:46 +01:00
baldurk 7c68746fd9 Add missing reference to struct in python docs 2022-07-11 13:48:28 +01:00
baldurk 5ef8294375 Pass through include paths properly when compiling shaders. Closes #2646 2022-07-11 13:03:54 +01:00
baldurk c14fad42c0 Put quotes around the right parameter in disassembled debug printfs 2022-07-11 13:02:35 +01:00
baldurk 7bdf26d329 Implement location tracking and goto for GS printfs
* We can't debug geometry shaders but we can scroll to them, as long as we have
  the primitive. We can't differentiate instances currently without passing that
  data through from the VS (and through tessellation, if it exists).
* This also disables the debug and goto buttons for printfs from shader stages
  that don't support those operations.
2022-07-11 13:02:23 +01:00
baldurk d39197a499 Arrays of float3 with a stride of 12 is only possible in scalar packing
* Previously this would be treated as std430 due to being 'tight' array packed,
  even though std430 only allows as tight as the base alignment - which for a
  float3 is 16-bytes still.
2022-07-11 13:00:18 +01:00
baldurk 52c00efb75 Apply matrix stride to inner children for multi-dimensional arrays 2022-07-11 12:59:49 +01:00
baldurk 83bff08fd1 Don't enable global hook if short paths are unavailable. Closes #2645
* AppInit_DLLs requires short paths to be specified, if they can't be created on
  the volume we can't reliably enable the global hook.
* Detecting this programmatically is quite complex, but since we know the shim
  file is always longer than 8.3, if we detect that the short path is the same
  length as the long path we know short names weren't used.
2022-07-08 11:25:57 +01:00
baldurk 92971fb061 List the current EID when a fatal error is detected 2022-07-08 11:08:40 +01:00
baldurk 2307c3b088 Add explicit error message for fetching counters without developer mode
* Now that we can report proper error messages, also return more information and
  don't use a separate message box.
2022-07-08 11:08:40 +01:00
baldurk c395bb2cff Work around NV driver bug on D3D11 copying from >2GB buffer 2022-07-08 11:08:40 +01:00
Jake Turner 6d7832df6f Update testing docs with info about Apple
Adding note about using "--demos-binary" option to specify the filepath of the demos binary as an alternative to making sure the demos binary is in the PATH.

Fixed a typo "can'tbe" -> "can't be"
2022-07-08 11:08:18 +01:00
Jake Turner c83851e884 First Apple platform support for Vulkan demos
Uses Metal-CPP-Extensions code to create window and the event loop.
Does not include support for Nuklear
2022-07-08 11:08:18 +01:00
Jake Turner 4e13b1ad38 Update Metal CPP to support tests project
Copy Metal driver metal-cpp files to the tests project for use in the tests project

Add extensions from Learn Metal-cpp project: https://developer.apple.com/metal/cpp/

https://developer.apple.com/metal/LearnMetalCPP.zip

Custom additions to Metal CPP to get NSApplication, NSView, NSWindow, CAMetalLayer to work stand alone without requiring MetalKit library.
2022-07-08 11:08:18 +01:00
Orson Baines 420efa41a9 Only create one history item per event for now 2022-07-08 11:07:21 +01:00
John Kattukudiyil 988e7723fa Update OpenGL Pixel History with failed tests
- Use samples passed query to add pixel modification data per fragment
- detect draw events that failed culling, scissor, stencil, and depth tests
2022-07-08 11:07:21 +01:00
Jake Turner 01184079c3 Test editing vulkan compute shader
Replace existing HLSL compute shader with a GLSL compute shader
2022-07-05 13:37:47 +01:00
Jake Turner 5b2b988bb3 Test changing vulkan compute shader entry-point
Commit for original bug fix:
"Fix entry-point remapping when editing compute shaders on vulkan"
c81a522360
2022-07-05 13:37:47 +01:00
baldurk 530c8cf024 Don't call SPIR-V callback with optional IDs not present 2022-07-05 13:13:24 +01:00
baldurk 398a92baa2 Fix error introduced in 4ba631d where stencil byte offset was always 0 2022-07-05 13:13:24 +01:00
Jake Turner d361ebf7e1 Allow command line to override Apple cmake options
CMAKE_OSX_ARCHITECTURES
ENABLE_PYRENDERDOC
CMAKE_OSX_DEPLOYMENT_TARGET

Remove CMAKE_OSX_ARCHITECTURES default setting to build for multiple architectures.
Enable ENABLE_PYRENDERDOC to On by default for Apple.
2022-07-05 13:01:00 +01:00
Jake Turner 2f30ad3e27 Make METAL_NOT_HOOKED() be Fatal instead of Error 2022-07-05 11:23:03 +01:00
baldurk 049884f51b Don't make decisions based on legacy GL contexts
* This is especially relevant on Android where we fetch all function pointers at
  init time, so any that we replace via emulation are gone, but it is also
  generally true that we expect GL contexts to be representative.
2022-07-04 15:00:36 +01:00
baldurk 1fdb7db07e Don't use shader compile flags when editing decompiled shader 2022-07-04 14:22:59 +01:00
Jake Turner c56beb77c8 Added DeallocateObjCBridge(WrappedMTL<type> *)
This replaces WrappedMTLObject::Dealloc() which was not implemented or hooked up (it was a TODO).
Deleted WrappedMTLObject::Dealloc()
DeallocateObjCBridge calls resource manager ReleaseWrappedResource().
2022-07-04 10:15:25 +01:00
Jake Turner 8c41ff714e Added MetalResourceManager::ReleaseWrappedResource 2022-07-04 10:15:25 +01:00
Jake Turner c7dae679c1 Use objc_constructInstance in AllocateObjCBridge
This constructs in-place the ObjC bridge class.
This fixes a bug where the reference count of the ObjC bridge class was not guaranteed to be initialized on construction.
2022-07-04 10:15:25 +01:00
Jake Turner 02103a9669 Set non-replay state to BackgroundCapturing 2022-07-04 10:15:25 +01:00
baldurk 4dc80c1793 Use non-legacy ASIC to generate AMDIL
* This may break on drivers old enough to not recognise the first non-legacy
  ASIC, but that is much rarer than new drivers that have dropped support for
  the old ones.
2022-06-30 15:41:45 +01:00
baldurk c817b6f9ff Fix clang warning 2022-06-30 14:49:02 +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 8e4b44aed7 Add test of integer offsets on texture sample for D3D shader debug 2022-06-30 13:51:26 +01:00
baldurk de619024c8 Test for extended UAV support in D3D11 test 2022-06-30 13:51:26 +01:00