Skip to content
Snippets Groups Projects

vkd3d: Use atomic exchange for descriptor writes.

Merged Conor McCarthy requested to merge cmccarthy/vkd3d:atomic_descriptors into master
2 unresolved threads

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
3984 3984 return S_OK;
3985 3985 }
3986 3986
3987 STATIC_ASSERT(!(offsetof(struct d3d12_descriptor_heap, descriptors) & (sizeof(void *) - 1)));
  • Conor McCarthy added 4 commits

    added 4 commits

    • dc27af7c - vkd3d: Ensure descriptors are pointer aligned.
    • e7909216 - vkd3d: Delay writing Vulkan descriptors until submitted to a queue.
    • 1fbb464a - vkd3d: Use atomic exchange for descriptor writes.
    • 49de4e15 - vkd3d: Buffer descriptor writes.

    Compare with previous version

  • From patch 2/4:

    +# if HAVE_SYNC_COMPARE_AND_SWAP
    +static inline LONG InterlockedCompareExchange(LONG volatile *x, LONG xchg, LONG cmp)
    +{
    +    return __sync_val_compare_and_swap(x, cmp, xchg);
    +}
    +# else
    +#  error "InterlockedCompareExchange() not implemented for this platform"
    +# endif
    +# if HAVE_ATOMIC_EXCHANGE_N
    +static inline LONG InterlockedExchange(LONG volatile *x, LONG val)
    +{
    +    return __atomic_exchange_n(x, val, __ATOMIC_SEQ_CST);
    +}
    +# elif HAVE_SYNC_COMPARE_AND_SWAP
    +static inline LONG InterlockedExchange(LONG volatile *x, LONG val)
    +{
    +    LONG i;
    +    do
    +    {
    +        i = *x;
    +    } while (__sync_val_compare_and_swap(x, i, val) != i);
    +    return i;
    +}
    +# else
    +#   error "InterlockedExchange() not implemented for this platform"
    +# endif

    I imagine this follows the precedent set by InterlockedIncrement() and similar functions, but I think I'd prefer the approach taken for vkd3d_mutex_lock() and related functions, and introduce something like "vkd3d_atomic_compare_exchange()" and "vkd3d_atomic_exchange()" for these. Part of that is a style preference, but it would also avoid propagating Win32 types like LONG to the calling code.

    Somewhat relatedly, patch 3/4 introduces "PVOID", and I think we should just use "void *".

    Those comments aside, I'm inclined to approve this. I didn't do a very careful review of the locking; that means that if this were to break something, you'll get to fix it yourself. :)

  • Conor McCarthy added 64 commits

    added 64 commits

    • 49de4e15...b46df551 - 60 commits from branch wine:master
    • d0a0d09d - vkd3d: Ensure descriptors are pointer aligned.
    • f925fc10 - vkd3d: Delay writing Vulkan descriptors until submitted to a queue.
    • 205a8f44 - vkd3d: Use atomic exchange for descriptor writes.
    • b79f3db3 - vkd3d: Collect multiple descriptor writes in a buffer and update in one call.

    Compare with previous version

  • Henri Verbeet approved this merge request

    approved this merge request

  • Giovanni Mascellani
    Giovanni Mascellani @giomasce started a thread on an outdated change in commit d0a0d09d
  • 866 866 struct d3d12_descriptor_heap_vk_set vk_descriptor_sets[VKD3D_SET_INDEX_COUNT];
    867 867 struct vkd3d_mutex vk_sets_mutex;
    868 868
    869 BYTE descriptors[];
    869 BYTE DECLSPEC_ALIGN(8) descriptors[];
  • Conor McCarthy added 4 commits

    added 4 commits

    • 89cdb1fc - vkd3d: Ensure descriptors are pointer aligned.
    • b10ad5c3 - vkd3d: Delay writing Vulkan descriptors until submitted to a queue.
    • 124c1872 - vkd3d: Use atomic exchange for descriptor writes.
    • 7c668468 - vkd3d: Collect multiple descriptor writes in a buffer and update in one call.

    Compare with previous version

  • added 4 commits

    • 505c8c5a - vkd3d: Ensure descriptors are pointer aligned.
    • e63201a7 - vkd3d: Delay writing Vulkan descriptors until submitted to a queue.
    • f50e53e7 - vkd3d: Use atomic exchange for descriptor writes.
    • 06cc2e1a - vkd3d: Collect multiple descriptor writes in a buffer and update in one call.

    Compare with previous version

  • Alexandre Julliard approved this merge request

    approved this merge request

  • Please register or sign in to reply
    Loading