Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support for D3D11 #1698

Open
wants to merge 54 commits into
base: dev
Choose a base branch
from
Open

Initial support for D3D11 #1698

wants to merge 54 commits into from

Commits on Aug 30, 2024

  1. Generate globally unique anon union names

    Ensure that anonymous union names processed by CppHeaderParser are
    globally unique to avoid conflicts between anonymous unions defined in
    separate header files.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    730b740 View commit details
    Browse the repository at this point in the history
  2. DX11 encode code generation

    Updates to DX12 code generators to enable support for DX11, starting
    with the generated encoding code. Adds the DX11 header files for
    versions up to 11.0, 11.1, and 11.2 to the list of files to be processed
    by the DX code generator. Includes updates for DX11-specific syntax,
    types, and SAL annotations.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    76919d1 View commit details
    Browse the repository at this point in the history
  3. Update codegen for anon structs

    Ignore anonymous structs when generating API calls to process struct
    types.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    0bbf75d View commit details
    Browse the repository at this point in the history
  4. Add DX11 bitfield entry

    Add D3D11_VIDEO_PROCESSOR_COLOR_SPACE to BIT_FIELD_LIST.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    58cff1b View commit details
    Browse the repository at this point in the history
  5. DX11 decode code generation

    - Handle union decoding, with unions being treated as structs.
    - Handle 'get' functions that retrieve objects without returning an
      HRESULT value.
    - Handle object mapping for structs that contain arrays of objects.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    065f8ae View commit details
    Browse the repository at this point in the history
  6. Add DX11 enums to codegen bits list

    Add DX11 bitmask enums to the enum to string code generator's BITS_LIST
    list.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    a91b50a View commit details
    Browse the repository at this point in the history
  7. Add DX11 API call IDs

    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    06fb7cc View commit details
    Browse the repository at this point in the history
  8. Add d3d11.lib to linker input

    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    d2cb319 View commit details
    Browse the repository at this point in the history
  9. DX11 encoding utility code

    - Add DX11 dispatch table
    - Support encoding for API calls that create objects without returning
      an HRESULT value
    - Add info structures for D3D11 objects
    - Add a non-const overload for UnwrapObjects.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    0c17377 View commit details
    Browse the repository at this point in the history
  10. Custom DX11 encode/decode routines

    Custom encoding and decoding for unions and API calls receive resource
    data, requiring a special data size calculation.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    1e60ef3 View commit details
    Browse the repository at this point in the history
  11. DX11 decoding utility code

    - Add JSON conversion routine for HandlePointerDecoder value types,
      operating on a const reference.
    roberto-c authored and dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    bd788a1 View commit details
    Browse the repository at this point in the history
  12. Allocate output data for replay

    Update code generation to allocate output data for output pointers.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    ece0afd View commit details
    Browse the repository at this point in the history
  13. Add replay support for output string parameters

    Implement the same GetOutputPointer and AllocateOutputData interface
    used with PointerDecoder for replay of API calls with output parameters
    to BasicStringDecoder for D3D11 API calls that return strings with
    output parameters.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    9b23284 View commit details
    Browse the repository at this point in the history
  14. Add codegen inout parameter support

    Update the DX code generators to treat INOUT parameters as OUT
    parameters. All INOUT parameters are pointers to integers that specify
    and retrieve sizes for variable length arrays, where the input is the
    size of the array and the output is the total number of items copied to
    the array.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    b696048 View commit details
    Browse the repository at this point in the history
  15. Support D3D 'result_bytebuffer' case

    D3D output parameters with a SAL labl including the text
    'result_bytebuffer' and a size appear similar to arrays of bytes but are
    really a pointer to memory allocated internally by the implementation
    with the specified size. For this case, the following adjustments are
    made for capture and replay, where capture will continue to record the
    content of the retrieved memory and replay will allocate and retrieve a
    single pointer to the memory.
    - Update encoding for this case, where the type is void**, to
      dereference the pointer when invoking EncodeVoidArray.
    - Update replay to decode the array of bytes, but allocate a single
      pointer parameter for API call replay, using PointerDecoder<uint8_,
      void*> to represent the parameter.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    6fc9fe8 View commit details
    Browse the repository at this point in the history
  16. Add generated DX11 code

    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    699df68 View commit details
    Browse the repository at this point in the history
  17. Gen AddObject for non HRESULT case

    With D3D12, all functions that retrieve a COM object also return
    HRESULT. With D3D11, there are some functions that retrieve a COM object
    while returning void. The code generator has been updated to handle this
    case, generating calls to AddObject() for the COM objects retrieved by
    functions that don't return an HRESULT value.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    723faee View commit details
    Browse the repository at this point in the history
  18. Add d3d11.dll proxy

    Implement the proxy d3d11.dll, with intialization and release functions
    added to the core d3d12_capture.dll module.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    18298d3 View commit details
    Browse the repository at this point in the history
  19. Enable D3D11 API decoding

    Add the D3D11 API ID to the decoder's list of supported API IDs.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    af92a59 View commit details
    Browse the repository at this point in the history
  20. Initial resource tracking

    Add capture/replay support for resource uploads.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    c56a68d View commit details
    Browse the repository at this point in the history
  21. Add replay support for mapped memory updates

    Add Map/Unmap overrides to track mapped resource pointers.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    d6abf2e View commit details
    Browse the repository at this point in the history
  22. Add ID3D11DeviceContext::GetData replay override

    If GetData returned S_OK at capture and S_FALSE at replay, continue
    calling GetData until it returns S_OK or an error code.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    ce73160 View commit details
    Browse the repository at this point in the history
  23. Add DX 11.3 support

    - Add d3d11_3.h to codegen header list.
    - Add custom struct encoders for new union types.
    - Add custom API call encode/decode for new resource creation functions.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    2a34189 View commit details
    Browse the repository at this point in the history
  24. Add DX 11.4 support

    - Add d3d11_4.h to codegen header list.
    - Update enum to string generator to handle an aliasing case with YUV
      and RGB flags.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    75b12da View commit details
    Browse the repository at this point in the history
  25. Add custom d3d11 object wrapper for ID3D11Resource

    Add custom d3d11 object wrapper generator for the ID3D11Resource object,
    which can be retrieved from a view and must be wrapped.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    a3c89cc View commit details
    Browse the repository at this point in the history
  26. Adjust variable length output array sizes

    Update D3D12 repolay code generator to apply the same variable sized
    output array adjustment that is used for Vulkan. For API calls that have
    an optional output array parameter and a porinter to an integer size
    parameter, when the array parameter is NULL, store the retrieved size in
    the calling objects info struct, and then when the API call is made with
    a non-NULL array parameter, specify the size stored in the info struct
    when allocating the output array.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    8990592 View commit details
    Browse the repository at this point in the history
  27. Update codegen for arrays of COM pointers

    Add support for arrays of COM pointers to the replay consumer code
    generator:
    - Handle output arrays of COM pointers, adding them to the object table.
    - Support variable length arrays of output COM pointers.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    1e449ff View commit details
    Browse the repository at this point in the history
  28. Prevent array size null pointer dereference

    Update code generation to add a null check when dereferencing
    a pointer to an array size when encoding array data during capture and
    allocating array memory during replay. Added for cases where both the
    variable length array parameter and its associated size parameter are
    optional and are allowed to be null.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    92e8d61 View commit details
    Browse the repository at this point in the history
  29. Add d3d11on12 support

    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    f72c73c View commit details
    Browse the repository at this point in the history
  30. Add unique codegen names for replay object info

    Include the name of the object in the variable name generated for the
    object info structures that are created for replay overrides. This is
    needed for API calls that create more than one object.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    eaef443 View commit details
    Browse the repository at this point in the history
  31. Adjust discard mapped memory case

    - Allocate persistent memory when a resource is discarded, to skip
      memory allocation and copy for future discard/nooverwrite cases.
    - Add custom d3d11 resource destroy commands to free persistent memory
      allocations.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    813e378 View commit details
    Browse the repository at this point in the history
  32. Adjust exteral object/IUnknown handling

    - Add external object handling for the software rendering module handle
      parameter from D3D11CreateDevice, warning when the handle is not null.
    - Silence the CreateSwapchain warning that is printed when the IUnknown
      pointer cannot be converted to a D3D12 queue, if it is an ID3D11Device
      object.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    88e539e View commit details
    Browse the repository at this point in the history
  33. Make D3D11 view hold internal resource ref

    ID3D11View_Wrapper now holds an internal reference to its associated
    ID3D11Resource_wrapper, ensuring the wrapper is always valid so that
    the data stored in the wrapper is not lost if the resource is released
    and then later retrieved with ID3D11View::GetResource().
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    559ccff View commit details
    Browse the repository at this point in the history
  34. Add -1 count check to debug assert

    Update object array size assert to check both that the size parameter
    matches the decoded array size, or that the size parameter is -1, which
    has a special meaning for D3D11 APIs such as
    OMSetRenderTargetsAndUnorderedAccessViews to indicate that the RTVs and
    DSV should be preserved.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    290ed17 View commit details
    Browse the repository at this point in the history
  35. Update swap chain handling for D3D11

    - Store the ID3D11Device pointer in the swap chain info struct for
      D3D11.
    - Support internal reference counts for swap chain images acquired from
      swap chains chreated with the DISCARD and SEQUENTIAL swap effects.
    - Handle different FLIP_DISCARD behavior for D3D11, which behaves the
      same way as DISCARD.
    - Adjust child image tracking for cases that only allow the image at
      index 0 to be acquired (DISCARD and D3D11+FLIP_DISCARD).
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    87e4beb View commit details
    Browse the repository at this point in the history
  36. Handle D3D11 MipLevels = 0 texture creation case

    When a texture is created with MipLevels = 0, a full set of subtextures
    will be generated. The following has been added to support this case:
    - New utility function to calculate the number of mip levels from the
      texture creation parameters when MipLevels is specified as 0.
    - Updated utility functions that calculate the total number of
      subresources and individual subresource sizes from texture creation
      parameters to compute the total number of mip levels when MipLevels =
      0.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    9fa53c4 View commit details
    Browse the repository at this point in the history
  37. Handle uncommon map discard cases

    Update capture to support the following mapped mempry case:
    - Game calls Map with WRITE_DISCARD flag without ever calling Unmap,
      calling Map to retrieve a new allocation when the previous allocation
      is full.
    
    This involves the following:
    - Process mapped memory before draw/dispatch to ensure any writes are
      properly recorded.
    - On repeated calls to Map with WRITE_DISCARD, update the entry for the
      resource in the mapped memory tracker for the new allocation
      returned by the driver.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    55a756b View commit details
    Browse the repository at this point in the history
  38. Add swapchain init for CreateDeviceAndSwapChain

    Add initialization for swapchain objects created by
    D3D11CreateDeviceAndSwapChain.
    - Add custom post call capture action to pre-acquire swapchain images.
    - Add replay override to initialize swapchain info.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    31ebc23 View commit details
    Browse the repository at this point in the history
  39. Enable debug layer for D3D11

    Force enable the D3D11 debug layer for capture and replay, based on
    the associated capture/replay debug option.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    376c517 View commit details
    Browse the repository at this point in the history
  40. Support aligned copies for mapped texture updates

    Update ProcessFillMemoryCommand() to support copies for 1D, 2D, and 3D
    textures with different capture and replay row and/or depth alignments.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    386d2e6 View commit details
    Browse the repository at this point in the history
  41. Add DX11 screenshot support

    - Adds a new DX11ImageRenderer class to generate screenshots for DX11
      captures. Code that is common to both DX11 and DX12 screenshots was
      moved from the existing DX12ImageRenderer class to a shared base class
      that both DX11ImageRenderer and DX12ImageRenderer inherit from.
    - Updates both the capture and replay code responsible for generating
      DX12 screenshots to also support DX11 screenshots. The API to use for
      screenshot generation is determined based on the IDXGISwapChain
      creation parameters, which either include a ID3D12CommandQueue for
      DX12 or an ID3D11Device for DX11.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    6de279a View commit details
    Browse the repository at this point in the history
  42. Keep persistent memory in table for DX11

    Leave the persistent memory allocated for the D3D11_WRITE_DISCARD and
    D3D11_WRITE_NO_OVERWRITE DX11 map modes in the memory tracking table
    until the resources are released. Adds support for updating the
    mapped memory ID and pointer stored by PageGuardManager for use with
    DX11 resources mapped with the D3D11_MAP_DISCARD flag, which can
    return a new allocation for the resource.
    - Use separate values for the memory ID written to the capture file
      and the key used with the PageGuardManager table, allowing the ID to
      be updated without needing to add/remove the entry (the ID written
      to the capture file used to be the key).
    - Add a new PageGuardManager function to update the memory ID and
      pointer associated with a Resource, used to update the Resource entry
      with the new memory pointer returned with D3D11_MAP_DISCARD.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    e0348ce View commit details
    Browse the repository at this point in the history
  43. Custom ID3D11Device::CheckFeatureSupport routines

    Update ID3D11Device::CheckFeatureSupport encoding and decoding with
    special case processing for the pFeatureSupportData parameter, which has
    a void* type with the actual type determined by the accompanying
    D3D11_FEATURE parameter. The implementation matches the custom
    implementations created for ID3D12Device and IDXGIFactory5.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    9608828 View commit details
    Browse the repository at this point in the history
  44. Per-write metadata API ID specification

    Specify the API ID to use with metadata encoding as a parameter to the
    functions that write metadata instead of as a class member to support
    the use of multiple APIs from a single application.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    7a34447 View commit details
    Browse the repository at this point in the history
  45. DX11 support for gfxrecon-info

    - Write adapter and driver metadata for DX11 at device creation.
    - Update gfxrecon-info to collect and display DX11 info.
    - Collect all gfxrecon-info stats from a single pass.
    - Specify DX11 API ID for adatper metadata.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    486f589 View commit details
    Browse the repository at this point in the history
  46. Custom decoder for CheckFeatureSupport data param

    Adds a new DxFeatureDataDecoder type to encapsulate the
    PointerDecoder<T> and StructPointerDecoder<T> types needed to decode
    the CheckFeatureSupport pFeatureSupportData parameter in a generic type
    that can be provided to DX consumers. Provides the same pointer decoder
    interface as PointerDecoder/StructPointerDecoder for managing pointer
    data, as well as functions for accessing the internal
    PointerDecoder/StructPointerDecoder with a specific type. Also allows
    the output allocation to be performed by the consumer instead of the
    decoder, which matches the standard consumer behavior.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    c9ac977 View commit details
    Browse the repository at this point in the history
  47. Adjust system DLL loading

    - Look for the renamed system DLL in the same folder as the capture DLL,
      instead of the same folder as the target executable, before attempting
      to copy and rename the DLL found in the system folder. This allows the
      capture DLL to be installed in locations other than the folder
      containing the target executable.
    - Use the shell API to retrieve the path to the system folder, relying
      on the WIN32 API to translate the returned path to the appropriate
      path for the architecture of the current process. This repalces code
      that tried to determine if it should use \Windows\System32 or
      \Windows\SysWOW64 as the system folder. For ARM devices, there are
      additional folders that need to be considered.
    - Only copy the D3D12 redist DLL when initializing the D3D12 DLL, not
      when initializing the DXGI and D3D11 DLLs. The redist DLL copy is now
      generic, with the redist DLL name specified by the DLL being
      initialized.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    08def37 View commit details
    Browse the repository at this point in the history
  48. Fix ResizeBuffers replay with width/height = 0

    When IDXGISwapChain::ResizeBuffers is called with a width or height
    value that is equal to 0, that dimension will be resized to match the
    dimension of the client area of the target window. For this case, replay
    was resizing the window to have a width/height of 0, resulting in the
    client area no longer being visible. This change specifies the
    width/height of the window's client area to Window::SetSize, instead of
    0, when width/height are 0.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    d6b1e43 View commit details
    Browse the repository at this point in the history
  49. Fix gfxrecon-info ResizeBuffers usage

    When IDXGISwapChain::ResizeBuffers is called with a width or height
    value that is equal to 0, that dimension will be resized to match the
    dimension of the client area of the target window. When the stats
    consumer used by gfxrecon-info processesed a ResizeBuffers call with
    width and height equal to zero, it reported the swap chain size as 0x0.
    The stats conusmer has been updated to ignore the ResizeBuffers width
    and height with a value of zero when determining swap chain size.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    eae9eb0 View commit details
    Browse the repository at this point in the history
  50. Enable debug markers for DX11 replay

    Enable DX11 support for the replay --dx12-override-object-names option.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    b540828 View commit details
    Browse the repository at this point in the history
  51. Handle UpdateSubresource data pointer adjustment

    When ID3D11DeviceContext::UpdateSubresource is called from a deferred
    context with a driver that does not support command lists and the
    pDstBox parameter is non-null and the pDstBox parameter specifies a
    non-zero start offset for the update, the application is required to
    subtract the offset from the pSrcData parameter. Capture and replay have
    been updated to account for this adjustment. Note that this adjustment
    is not required for ID3D11DeviceContext1::UpdateSubresource1.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    b2e1be0 View commit details
    Browse the repository at this point in the history
  52. Fix DX11 compressed tex1d/3d subresource size calc

    When calculating the subresource size for block compressed 1D and 3D
    textures, apply the same pixel-to-block width/height conversion that
    is performed for 2D textures.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    734320b View commit details
    Browse the repository at this point in the history
  53. DX11 deferred context memory tracking optimization

    Adds a custom mapped memory tracker for DX11 deferred contexts, which
    only support mapping resources with the D3D11_MAP_WRITE_DISCARD and
    D3D11_MAP_WRITE_NO_OVERWRITE map types. Because these map types only
    support writing to mapped memory, meaning that shadow memory would not
    need to be synchronized with driver memory for reads, this custom memory
    tracker can use write watch with shadow allocations. Write watch-based
    tracking eliminates the need for a single exception handler that must be
    shared by all contexts, which is required when using guard pages,
    allowing each deferred context to have its own independent instance of
    the memory tracker. The immediate context continues to use the original
    guard page memory tracking as it must process both read and write
    operations.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    c0ef127 View commit details
    Browse the repository at this point in the history
  54. Make IDXGISwapChain buffer cast conditional

    Remove an unconditional cast of the object returned by
    IDXGISwapChain::GetBuffer to ID3D12Resource, as this method may return
    other resource types.
    dgraves committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    5a2c4fe View commit details
    Browse the repository at this point in the history