summaryrefslogtreecommitdiff
path: root/wddm/umd/qxlum.c
blob: 992e54e4ffcdfd8a4c8b16ac2c1fa878ed798937 (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
66
67
68
69
70
71
72
73
74
75
76
77
#include <stdio.h>

#include <winerror.h>
#include <windows.h>
#include <windef.h>
#include <crtdbg.h>

/* TODO: fix this
 * Copy NTSTATUS & PHYSICAL_ADDRESS typedefs from ntdef.h over here because it
 * conflicts with winnt.h which is required by windows.h (not directly) */
typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS;
typedef LONG NTSTATUS;

#include <d3dtypes.h>
#ifdef DEFINE_OPENADAPTER
#include <d3dumddi.h>
#endif
#include <d3d10umddi.h>

static void log_file_v(const char *format, va_list ap)
{
    static HANDLE h;
    char buf[2048];
    DWORD bytes_written;
    int n;

    if (h == 0) {
        h = CreateFile("c:\\qxlum.log", FILE_WRITE_DATA | FILE_APPEND_DATA, 0, NULL, OPEN_ALWAYS,
                       FILE_ATTRIBUTE_NORMAL, NULL);
        if (h == INVALID_HANDLE_VALUE) {
            return; // TODO - log this..
        }
        SetFilePointer(h, 0, NULL, FILE_END);
    }
    if (h == INVALID_HANDLE_VALUE) {
        return; // TODO - log this..
    }
    n = _vsnprintf_s(buf, sizeof(buf), _TRUNCATE, format, ap);
    WriteFile(h, buf, n, &bytes_written, NULL);
}

static void log_file(const char *format, ...)
{
    va_list ap;

    va_start(ap, format);
    log_file_v(format, ap);
    va_end(ap);
}

// TODO: mingw ifdef to __func__
#define QXL_FUNCTION __FUNCTION__

// Required for Directx 9 - not sure if we can forgoe this, let's try
#ifdef DEFINE_OPENADAPTER
__declspec(dllexport) HRESULT OpenAdapter(
          D3DDDIARG_OPENADAPTER *pOpenData
        )
{
    log_file("%s: TODO\n", QXL_FUNCTION);
    // return S_OK;
    return E_OUTOFMEMORY;
}
#endif

__declspec(dllexport) HRESULT OpenAdapter10(
        D3D10DDIARG_OPENADAPTER *pOpenData
        )
{
    const D3DDDI_ADAPTERCALLBACKS *adapter_callbacks = pOpenData->pAdapterCallbacks;
    void *adapter = pOpenData->hRTAdapter.handle;
    D3DDDICB_QUERYADAPTERINFO info;

    log_file("%s: TODO\n", QXL_FUNCTION);
    adapter_callbacks->pfnQueryAdapterInfoCb(adapter, &info);
    return S_OK;
}