summaryrefslogtreecommitdiffstats
path: root/tools/gfx/d3d12/d3d12-posix-synchapi.h
blob: 15aef94181f5801fbe79ec52a9bab2c5b513346e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#pragma once

#include "slang.h"

#if SLANG_LINUX_FAMILY

#pragma push_macro("WIN32_LEAN_AND_MEAN")
#pragma push_macro("NOMINMAX")
#undef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#undef NOMINMAX
#define NOMINMAX
#include <windows.h>
#pragma pop_macro("NOMINMAX")
#pragma pop_macro("WIN32_LEAN_AND_MEAN")

////////////////////////////////////////////////////////////////
//
// It's important to note that due to platform constraints this can't be a
// totally faithful implementation of the Windows API.
//
// Notably, the "wait all" case in WaitForMultipleObjects can't be made correct
// on linux, as we can't atomically read from several fds and eventfd is the
// interface available from vkd3d-proton.
//
////////////////////////////////////////////////////////////////

//
// The synchapi types and macros used in gfx
//
#define INFINITE 0xffffffff

#define WAIT_FAILED 0xffffffff
#define WAIT_OBJECT_0 0

typedef struct _SECURITY_ATTRIBUTES* LPSECURITY_ATTRIBUTES;

#define CREATE_EVENT_MANUAL_RESET 1
#define CREATE_EVENT_INITIAL_SET 2

#define SYNCHRONIZE 0x00100000
#define STANDARD_RIGHTS_REQUIRED 0x000f0000
#define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3)

HANDLE CreateEventEx(
    LPSECURITY_ATTRIBUTES lpEventAttributes,
    LPCSTR lpName,
    DWORD dwFlags,
    DWORD dwDesiredAccess);

BOOL CloseHandle(HANDLE h);

BOOL ResetEvent(HANDLE h);

BOOL SetEvent(HANDLE h);

DWORD WaitForSingleObject(HANDLE h, DWORD ms);

DWORD WaitForMultipleObjects(
    DWORD nHandles,
    const HANDLE* handles,
    BOOL bWaitAll,
    DWORD dwMilliseconds);

#endif // SLANG_LINUX_FAMILY