|
4 | 4 | #include "d3d11_context_imm.h" |
5 | 5 | #include "d3d11_device.h" |
6 | 6 |
|
| 7 | +#include "../util/util_win32_compat.h" |
7 | 8 | #include "../util/util_shared_res.h" |
8 | 9 |
|
9 | 10 | namespace dxvk { |
@@ -220,6 +221,14 @@ namespace dxvk { |
220 | 221 | return S_OK; |
221 | 222 | } |
222 | 223 |
|
| 224 | + D3DKMT_HANDLE global = texture->GetImage()->storage()->kmtGlobal(); |
| 225 | + if (global) { |
| 226 | + *pSharedHandle = (HANDLE)(uintptr_t)global; |
| 227 | + return S_OK; |
| 228 | + } |
| 229 | + |
| 230 | + /* try legacy Proton shared resource implementation */ |
| 231 | + |
223 | 232 | HANDLE kmtHandle = texture->GetImage()->sharedHandle(); |
224 | 233 |
|
225 | 234 | if (kmtHandle == INVALID_HANDLE_VALUE) |
@@ -281,6 +290,31 @@ namespace dxvk { |
281 | 290 | !(texture->Desc()->MiscFlags & D3D11_RESOURCE_MISC_SHARED_NTHANDLE)) |
282 | 291 | return E_INVALIDARG; |
283 | 292 |
|
| 293 | + OBJECT_ATTRIBUTES attr = { }; |
| 294 | + attr.Length = sizeof(attr); |
| 295 | + attr.SecurityDescriptor = (void *)pAttributes; |
| 296 | + |
| 297 | + WCHAR buffer[MAX_PATH]; |
| 298 | + UNICODE_STRING name; |
| 299 | + if (lpName) { |
| 300 | + DWORD session, len; |
| 301 | + |
| 302 | + ProcessIdToSessionId(GetCurrentProcessId(), &session); |
| 303 | + len = swprintf(buffer, ARRAYSIZE(buffer), L"\\Sessions\\%u\\BaseNamedObjects\\%s", session, name); |
| 304 | + name.MaximumLength = name.Length = len * sizeof(WCHAR); |
| 305 | + name.MaximumLength += sizeof(WCHAR); |
| 306 | + name.Buffer = buffer; |
| 307 | + |
| 308 | + attr.ObjectName = &name; |
| 309 | + attr.Attributes = OBJ_CASE_INSENSITIVE; |
| 310 | + } |
| 311 | + |
| 312 | + D3DKMT_HANDLE local = texture->GetImage()->storage()->kmtLocal(); |
| 313 | + if (!D3DKMTShareObjects(1, &local, &attr, dwAccess, pHandle)) |
| 314 | + return S_OK; |
| 315 | + |
| 316 | + /* try legacy Proton shared resource implementation */ |
| 317 | + |
284 | 318 | if (lpName) |
285 | 319 | Logger::warn("Naming shared resources not supported"); |
286 | 320 |
|
|
0 commit comments