Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
December 2019
- 73 participants
- 1394 messages
[PATCH 1/3] qedit/samplegrabber: Clean up the pins in sample_grabber_destroy().
by Zebediah Figura
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/qedit/samplegrabber.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/dlls/qedit/samplegrabber.c b/dlls/qedit/samplegrabber.c
index 63dab8f9ed5..115beec8822 100644
--- a/dlls/qedit/samplegrabber.c
+++ b/dlls/qedit/samplegrabber.c
@@ -109,6 +109,8 @@ static void sample_grabber_destroy(struct strmbase_filter *iface)
SG_Impl *filter = impl_from_strmbase_filter(iface);
SampleGrabber_cleanup(filter);
+ strmbase_sink_cleanup(&filter->sink);
+ strmbase_source_cleanup(&filter->source);
strmbase_filter_cleanup(&filter->filter);
CoTaskMemFree(filter);
}
--
2.24.0
Dec. 15, 2019
[PATCH] winegstreamer: Clear the "reader" and "allocator" fields if connection fails.
by Zebediah Figura
This fixes a regression introduced by dafe81dfcb2b8896024e9d071e4bf4553e4a4018.
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/winegstreamer/gstdemux.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c
index 3945d9da8f..869a15b619 100644
--- a/dlls/winegstreamer/gstdemux.c
+++ b/dlls/winegstreamer/gstdemux.c
@@ -1393,6 +1393,8 @@ static HRESULT gstdemux_sink_connect(struct strmbase_sink *iface, IPin *peer, co
if (FAILED(hr = IMemAllocator_Commit(filter->alloc)))
{
WARN("Failed to commit allocator, hr %#x.\n", hr);
+ IMemAllocator_Release(filter->alloc);
+ filter->alloc = NULL;
goto err;
}
@@ -1400,6 +1402,7 @@ static HRESULT gstdemux_sink_connect(struct strmbase_sink *iface, IPin *peer, co
err:
GST_RemoveOutputPins(filter);
IAsyncReader_Release(filter->reader);
+ filter->reader = NULL;
return hr;
}
--
2.24.1
Dec. 15, 2019
[PATCH] ntdll: Return -1 from Unix code page conversion functions if an error was encountered.
by Zebediah Figura
If 0 is returned, the caller has no way of determining this. This fixes a
test failure in kernel32:change introduced by f46fa9c92.
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/ntdll/locale.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/locale.c b/dlls/ntdll/locale.c
index 4c95169366..d9e4e8086e 100644
--- a/dlls/ntdll/locale.c
+++ b/dlls/ntdll/locale.c
@@ -643,7 +643,7 @@ int ntdll_umbstowcs( DWORD flags, const char *src, int srclen, WCHAR *dst, int d
if (!dstlen) dst = NULL;
status = RtlUTF8ToUnicodeN( dst, dstlen * sizeof(WCHAR), &reslen, src, srclen );
- if (status && status != STATUS_SOME_NOT_MAPPED) return 0;
+ if (status && status != STATUS_SOME_NOT_MAPPED) return -1;
reslen /= sizeof(WCHAR);
#ifdef __APPLE__ /* work around broken Mac OS X filesystem that enforces decomposed Unicode */
if (reslen && dst) RtlNormalizeString( NormalizationC, dst, reslen, dst, (int *)&reslen );
@@ -666,7 +666,7 @@ int ntdll_wcstoumbs( DWORD flags, const WCHAR *src, int srclen, char *dst, int d
if (used) *used = 0; /* all chars are valid for UTF-8 */
if (!dstlen) dst = NULL;
status = RtlUnicodeToUTF8N( dst, dstlen, &reslen, src, srclen * sizeof(WCHAR) );
- if (status && status != STATUS_SOME_NOT_MAPPED) return 0;
+ if (status && status != STATUS_SOME_NOT_MAPPED) return -1;
return reslen;
}
--
2.24.1
Dec. 15, 2019
[PATCH] rpcrt4: Fix RpcNetworkIsProtseqValid[AW] spec file entries
by André Hentschel
Signed-off-by: André Hentschel <nerv(a)dawncrow.de>
---
dlls/rpcrt4/rpcrt4.spec | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/rpcrt4/rpcrt4.spec b/dlls/rpcrt4/rpcrt4.spec
index 6d7d0fbf7ac..5d558bff753 100644
--- a/dlls/rpcrt4/rpcrt4.spec
+++ b/dlls/rpcrt4/rpcrt4.spec
@@ -413,8 +413,8 @@
@ stdcall RpcMgmtWaitServerListen()
@ stdcall RpcNetworkInqProtseqsA(ptr)
@ stdcall RpcNetworkInqProtseqsW(ptr)
-@ stdcall RpcNetworkIsProtseqValidA(ptr)
-@ stdcall RpcNetworkIsProtseqValidW(ptr)
+@ stdcall RpcNetworkIsProtseqValidA(str)
+@ stdcall RpcNetworkIsProtseqValidW(wstr)
@ stub RpcNsBindingInqEntryNameA
@ stub RpcNsBindingInqEntryNameW
@ stub RpcObjectInqType
--
2.17.1
Dec. 15, 2019
[PATCH] mapi32: Fix some spec file entries
by André Hentschel
Signed-off-by: André Hentschel <nerv(a)dawncrow.de>
---
dlls/mapi32/mapi32.spec | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/mapi32/mapi32.spec b/dlls/mapi32/mapi32.spec
index 0b5acbb7372..32d0b7a458b 100644
--- a/dlls/mapi32/mapi32.spec
+++ b/dlls/mapi32/mapi32.spec
@@ -95,7 +95,7 @@
152 stub OpenTnefStreamEx
153 stub GetTnefStreamCodepage(a)12
154 stub GetTnefStreamCodepage
-155 stdcall UlFromSzHex(a)4(ptr) UlFromSzHex
+155 stdcall UlFromSzHex(a)4(wstr) UlFromSzHex
156 stub UNKOBJ_ScAllocate(a)12
157 stub UNKOBJ_ScAllocateMore(a)16
158 stub UNKOBJ_Free(a)8
@@ -144,7 +144,7 @@
204 stub EncodeID(a)12
205 stub FDecodeID(a)12
206 stub CchOfEncoding(a)4
-207 stdcall CbOfEncoded(a)4(ptr) CbOfEncoded
+207 stdcall CbOfEncoded(a)4(str) CbOfEncoded
208 stdcall MAPISendDocuments(long str str str long)
209 stdcall MAPILogon(long str str long long ptr)
210 stdcall MAPILogoff(ptr long long long)
--
2.17.1
Dec. 15, 2019
Re: [PATCH] kernel32: Fix some spec file entries
by Marvin
Hi,
While running your changed tests, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at:
https://testbot.winehq.org/JobDetails.pl?Key=62183
Your paranoid android.
=== debian10 (32 bit report) ===
kernel32:
debugger: Timeout
=== debian10 (32 bit Chinese:China report) ===
kernel32:
debugger.c:320: Test failed: GetThreadContext failed: 5
=== debian10 (32 bit WoW report) ===
kernel32:
debugger: Timeout
Dec. 15, 2019
Re: [PATCH vkd3d 1/2] vkd3d: Add queries for KHR_timeline_semaphore extension.
by Sveinar Søpler
On 13.12.2019 17:25, Sveinar Søpler wrote:
> On 12.12.2019 20:02, Rémi Bernon wrote:
>> +
>> +Â Â Â timeline_semaphore = &info->timeline_semaphore_properties;
>> +Â Â Â TRACE(" VkPhysicalDeviceTimelineSemaphorePropertiesKHR:\n");
>> +Â Â Â TRACE("Â Â Â maxTimelineSemaphoreValueDifference: %u.\n",
>> timeline_semaphore->maxTimelineSemaphoreValueDifference);
>
> Should it be %lu? (Atleast seems to compile fine when changed to %lu.)
>
>
> libs/vkd3d/device.c:1039:11: warning: format ‘%u’ expects argument of
> type ‘unsigned int’, but argument 4 has type ‘uint64_t’ {aka ‘const
> long unsigned int’} [-Wformat=]
> 1039 | TRACE(" maxTimelineSemaphoreValueDifference: %u.\n",
> timeline_semaphore->maxTimelineSemaphoreValueDifference);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> | uint64_t {aka const long unsigned int}
>
>
Or rather it could be:
+
+Â Â Â timeline_semaphore = &info->timeline_semaphore_properties;
+Â Â Â TRACE("Â VkPhysicalDeviceTimelineSemaphorePropertiesKHR:\n");
+Â Â Â TRACE("Â Â Â maxTimelineSemaphoreValueDifference: %" PRIu64 ".\n",
timeline_semaphore->maxTimelineSemaphoreValueDifference);
 }
since it seems as "compile fine" was not correct for 32-bit... 64-bit
was fine with %lu, but 32-bit seems to want this to be %llu. For some
reason uint64_t is "long unsigned int" for 64-bit and "long long
unsigned int" for 32-bit for my compiler. Dunno if this is some weird
"ubuntu spesific" thing, or actually correct?
Sveinar
Dec. 15, 2019
[PATCH] kernel32: Fix some spec file entries
by André Hentschel
Signed-off-by: André Hentschel <nerv(a)dawncrow.de>
---
dlls/kernel32/kernel32.spec | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec
index 408ea415401..b62058a0a8b 100644
--- a/dlls/kernel32/kernel32.spec
+++ b/dlls/kernel32/kernel32.spec
@@ -1558,8 +1558,8 @@
@ stdcall -ret64 VerSetConditionMask(long long long long) ntdll.VerSetConditionMask
@ stdcall VerifyConsoleIoHandle(long)
# @ stub VerifyScripts
-@ stdcall VerifyVersionInfoA(long long int64)
-@ stdcall VerifyVersionInfoW(long long int64)
+@ stdcall VerifyVersionInfoA(ptr long int64)
+@ stdcall VerifyVersionInfoW(ptr long int64)
@ stdcall -import VirtualAlloc(ptr long long long)
@ stdcall -import VirtualAllocEx(long ptr long long long)
@ stdcall -import VirtualAllocExNuma(long ptr long long long long)
@@ -1632,7 +1632,7 @@
@ stdcall WritePrivateProfileStructW(wstr wstr ptr long wstr)
@ stdcall -import WriteProcessMemory(long ptr ptr long ptr)
@ stdcall WriteProfileSectionA(str str)
-@ stdcall WriteProfileSectionW(str str)
+@ stdcall WriteProfileSectionW(wstr wstr)
@ stdcall WriteProfileStringA(str str str)
@ stdcall WriteProfileStringW(wstr wstr wstr)
@ stdcall WriteTapemark(ptr long long long)
--
2.17.1
Dec. 15, 2019
Re: [PATCH] dmusic: Use wide-char string literals
by Michael Stefaniuc
On 12/14/19 2:50 PM, Ruslan Kabatsayev wrote:
> Is Code Hygiene [1] page in the WineHQ Wiki outdated? Has Wine begun
> using wide literals? If yes, what made this switch possible?
Not totally outdated yet.
Modules that are compiled now with mingw no longer depend on system
libraries and thus can use wide-char string literals. Those modules have
'EXTRADLLFLAGS = -mno-cygwin' in their Makefile.
bye
michael
> (I'm sorry if I've missed a previous announcement on this topic;
> googling doesn't reveal anything relevant.)
>
> [1]: https://wiki.winehq.org/Code_Hygiene#Constants_as_Character_Arrays
>
> On Fri, 13 Dec 2019 at 21:00, Michael Stefaniuc <mstefani(a)winehq.org> wrote:
>>
>> Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
>> ---
>> dlls/dmusic/dmusic.c | 8 +++-----
>> dlls/dmusic/tests/dmusic.c | 5 ++---
>> 2 files changed, 5 insertions(+), 8 deletions(-)
>>
>> diff --git a/dlls/dmusic/dmusic.c b/dlls/dmusic/dmusic.c
>> index cc798ce4d9..1916fb7bd9 100644
>> --- a/dlls/dmusic/dmusic.c
>> +++ b/dlls/dmusic/dmusic.c
>> @@ -343,20 +343,18 @@ static HRESULT WINAPI IDirectMusic8Impl_EnumMasterClock(LPDIRECTMUSIC8 iface, DW
>> if (!index)
>> {
>> static const GUID guid_system_clock = { 0x58d58419, 0x71b4, 0x11d1, { 0xa7, 0x4c, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12 } };
>> - static const WCHAR name_system_clock[] = { 'S','y','s','t','e','m',' ','C','l','o','c','k',0 };
>>
>> clock_info->ctType = 0;
>> clock_info->guidClock = guid_system_clock;
>> - lstrcpyW(clock_info->wszDescription, name_system_clock);
>> + lstrcpyW(clock_info->wszDescription, L"System Clock");
>> }
>> else
>> {
>> static const GUID guid_dsound_clock = { 0x58d58420, 0x71b4, 0x11d1, { 0xa7, 0x4c, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12 } };
>> - static const WCHAR name_dsound_clock[] = { 'D','i','r','e','c','t','S','o','u','n','d',' ','C','l','o','c','k',0 };
>>
>> clock_info->ctType = 0;
>> clock_info->guidClock = guid_dsound_clock;
>> - lstrcpyW(clock_info->wszDescription, name_dsound_clock);
>> + lstrcpyW(clock_info->wszDescription, L"DirectSound Clock");
>> }
>>
>> return S_OK;
>> @@ -496,7 +494,7 @@ static const IDirectMusic8Vtbl DirectMusic8_Vtbl = {
>>
>> static void create_system_ports_list(IDirectMusic8Impl* object)
>> {
>> - static const WCHAR emulated[] = {' ','[','E','m','u','l','a','t','e','d',']',0};
>> + static const WCHAR emulated[] = L" [Emulated]";
>> port_info * port;
>> ULONG nb_ports;
>> ULONG nb_midi_out;
>> diff --git a/dlls/dmusic/tests/dmusic.c b/dlls/dmusic/tests/dmusic.c
>> index f6c417af30..776f9d0ec9 100644
>> --- a/dlls/dmusic/tests/dmusic.c
>> +++ b/dlls/dmusic/tests/dmusic.c
>> @@ -639,7 +639,6 @@ static void test_parsedescriptor(void)
>> IStream *stream;
>> DMUS_OBJECTDESC desc = {0};
>> HRESULT hr;
>> - const WCHAR s_inam[] = {'I','N','A','M','\0'};
>> const FOURCC alldesc[] =
>> {
>> FOURCC_RIFF, FOURCC_DLS, DMUS_FOURCC_CATEGORY_CHUNK, FOURCC_LIST,
>> @@ -735,7 +734,7 @@ static void test_parsedescriptor(void)
>> ok(hr == S_OK, "ParseDescriptor failed: %08x, expected S_OK\n", hr);
>> ok(desc.dwValidData == (DMUS_OBJ_CLASS | DMUS_OBJ_NAME),
>> "Got valid data %#x, expected DMUS_OBJ_CLASS | DMUS_OBJ_NAME\n", desc.dwValidData);
>> - ok(!memcmp(desc.wszName, s_inam, sizeof(s_inam)), "Got name '%s', expected 'INAM'\n",
>> + ok(!lstrcmpW(desc.wszName, L"INAM"), "Got name '%s', expected 'INAM'\n",
>> wine_dbgstr_w(desc.wszName));
>> IStream_Release(stream);
>>
>> @@ -747,7 +746,7 @@ static void test_parsedescriptor(void)
>> ok(desc.dwValidData == (DMUS_OBJ_CLASS | DMUS_OBJ_NAME | DMUS_OBJ_VERSION),
>> "Got valid data %#x, expected DMUS_OBJ_CLASS | DMUS_OBJ_NAME | DMUS_OBJ_VERSION\n",
>> desc.dwValidData);
>> - ok(!memcmp(desc.wszName, s_inam, sizeof(s_inam)), "Got name '%s', expected 'INAM'\n",
>> + ok(!lstrcmpW(desc.wszName, L"INAM"), "Got name '%s', expected 'INAM'\n",
>> wine_dbgstr_w(desc.wszName));
>> IStream_Release(stream);
>>
>> --
>> 2.23.0
>>
>>
>
Dec. 14, 2019
Re: [PATCH] dmusic: Use wide-char string literals
by Ruslan Kabatsayev
Is Code Hygiene [1] page in the WineHQ Wiki outdated? Has Wine begun
using wide literals? If yes, what made this switch possible?
(I'm sorry if I've missed a previous announcement on this topic;
googling doesn't reveal anything relevant.)
[1]: https://wiki.winehq.org/Code_Hygiene#Constants_as_Character_Arrays
On Fri, 13 Dec 2019 at 21:00, Michael Stefaniuc <mstefani(a)winehq.org> wrote:
>
> Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
> ---
> dlls/dmusic/dmusic.c | 8 +++-----
> dlls/dmusic/tests/dmusic.c | 5 ++---
> 2 files changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/dlls/dmusic/dmusic.c b/dlls/dmusic/dmusic.c
> index cc798ce4d9..1916fb7bd9 100644
> --- a/dlls/dmusic/dmusic.c
> +++ b/dlls/dmusic/dmusic.c
> @@ -343,20 +343,18 @@ static HRESULT WINAPI IDirectMusic8Impl_EnumMasterClock(LPDIRECTMUSIC8 iface, DW
> if (!index)
> {
> static const GUID guid_system_clock = { 0x58d58419, 0x71b4, 0x11d1, { 0xa7, 0x4c, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12 } };
> - static const WCHAR name_system_clock[] = { 'S','y','s','t','e','m',' ','C','l','o','c','k',0 };
>
> clock_info->ctType = 0;
> clock_info->guidClock = guid_system_clock;
> - lstrcpyW(clock_info->wszDescription, name_system_clock);
> + lstrcpyW(clock_info->wszDescription, L"System Clock");
> }
> else
> {
> static const GUID guid_dsound_clock = { 0x58d58420, 0x71b4, 0x11d1, { 0xa7, 0x4c, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12 } };
> - static const WCHAR name_dsound_clock[] = { 'D','i','r','e','c','t','S','o','u','n','d',' ','C','l','o','c','k',0 };
>
> clock_info->ctType = 0;
> clock_info->guidClock = guid_dsound_clock;
> - lstrcpyW(clock_info->wszDescription, name_dsound_clock);
> + lstrcpyW(clock_info->wszDescription, L"DirectSound Clock");
> }
>
> return S_OK;
> @@ -496,7 +494,7 @@ static const IDirectMusic8Vtbl DirectMusic8_Vtbl = {
>
> static void create_system_ports_list(IDirectMusic8Impl* object)
> {
> - static const WCHAR emulated[] = {' ','[','E','m','u','l','a','t','e','d',']',0};
> + static const WCHAR emulated[] = L" [Emulated]";
> port_info * port;
> ULONG nb_ports;
> ULONG nb_midi_out;
> diff --git a/dlls/dmusic/tests/dmusic.c b/dlls/dmusic/tests/dmusic.c
> index f6c417af30..776f9d0ec9 100644
> --- a/dlls/dmusic/tests/dmusic.c
> +++ b/dlls/dmusic/tests/dmusic.c
> @@ -639,7 +639,6 @@ static void test_parsedescriptor(void)
> IStream *stream;
> DMUS_OBJECTDESC desc = {0};
> HRESULT hr;
> - const WCHAR s_inam[] = {'I','N','A','M','\0'};
> const FOURCC alldesc[] =
> {
> FOURCC_RIFF, FOURCC_DLS, DMUS_FOURCC_CATEGORY_CHUNK, FOURCC_LIST,
> @@ -735,7 +734,7 @@ static void test_parsedescriptor(void)
> ok(hr == S_OK, "ParseDescriptor failed: %08x, expected S_OK\n", hr);
> ok(desc.dwValidData == (DMUS_OBJ_CLASS | DMUS_OBJ_NAME),
> "Got valid data %#x, expected DMUS_OBJ_CLASS | DMUS_OBJ_NAME\n", desc.dwValidData);
> - ok(!memcmp(desc.wszName, s_inam, sizeof(s_inam)), "Got name '%s', expected 'INAM'\n",
> + ok(!lstrcmpW(desc.wszName, L"INAM"), "Got name '%s', expected 'INAM'\n",
> wine_dbgstr_w(desc.wszName));
> IStream_Release(stream);
>
> @@ -747,7 +746,7 @@ static void test_parsedescriptor(void)
> ok(desc.dwValidData == (DMUS_OBJ_CLASS | DMUS_OBJ_NAME | DMUS_OBJ_VERSION),
> "Got valid data %#x, expected DMUS_OBJ_CLASS | DMUS_OBJ_NAME | DMUS_OBJ_VERSION\n",
> desc.dwValidData);
> - ok(!memcmp(desc.wszName, s_inam, sizeof(s_inam)), "Got name '%s', expected 'INAM'\n",
> + ok(!lstrcmpW(desc.wszName, L"INAM"), "Got name '%s', expected 'INAM'\n",
> wine_dbgstr_w(desc.wszName));
> IStream_Release(stream);
>
> --
> 2.23.0
>
>
Dec. 14, 2019
Wine staging 5.0 rc1 release
by Alistair Leslie-Hughes
Binary packages for various distributions will be available from:
https://www.winehq.org/download
Summary since last release
* Rebased to current wine 5.0 rc1 (825 patches are applied to wine vanilla)
Upstreamed (Either directly from staging or fixed with a similar patch).
* kernel32: Convert scsi device type in SCSI_getprocentry.
* kernel32: Add support for reading scsi devices from sysfs.
* wusa: Implement basic installation logic.
* wusa: Ignore systemProtection subkey of registry key.
* wusa: Treat empty update list as error.
* wusa: Implement WOW64 support.
* wusa: Improve tracing of installation process.
* wusa: Print warning when encountering msdelta compressed files.
* wined3d: Silence extremely noisy FIXME in
wined3d_texture_add_dirty_region.
* ole32: Correctly parse unicode property storage dictionaries.
Added:
* none
Updated:
* d2d1-ID2D1Factory1
* Compiler_Warnings
* kernelbase-ReOpenFile
* wintab32-improvements
* winebuild-Fake_Dlls patchset
Where can you help
* Run Steam/Battle.net/GOG/UPlay/Epic
* Test your favorite game.
* Test your favorite applications.
* Improve staging patches and get them accepted upstream.
As always, if you find a bug, please report it via
https://bugs.winehq.org
Best Regards
Alistair.
Dec. 14, 2019
[PATCH v3 5/5] d3d9: Stop setting the device state when setting the default ZENABLE state.
by Zebediah Figura
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/d3d9/device.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index b77f516546..3229008722 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -1020,8 +1020,6 @@ static HRESULT d3d9_device_reset(struct d3d9_device *device,
device->auto_mipmaps = 0;
wined3d_stateblock_set_render_state(device->state, WINED3D_RS_ZENABLE,
!!swapchain_desc.enable_auto_depth_stencil);
- wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ZENABLE,
- !!swapchain_desc.enable_auto_depth_stencil);
device_reset_viewport_state(device);
}
@@ -4673,8 +4671,6 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
wined3d_stateblock_set_render_state(device->state, WINED3D_RS_ZENABLE,
!!swapchain_desc->enable_auto_depth_stencil);
- wined3d_device_set_render_state(device->wined3d_device,
- WINED3D_RS_ZENABLE, !!swapchain_desc->enable_auto_depth_stencil);
device_reset_viewport_state(device);
if (FAILED(hr = d3d9_device_get_swapchains(device)))
--
2.24.0
Dec. 13, 2019
[PATCH v3 4/5] d3d9: Stop setting the device state in d3d9_device_SetRenderState().
by Zebediah Figura
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/d3d9/device.c | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 14d2a0cc25..b77f516546 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -2331,22 +2331,11 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_SetRenderState(IDirect3DDevi
D3DRENDERSTATETYPE state, DWORD value)
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
- struct wined3d_color factor;
TRACE("iface %p, state %#x, value %#x.\n", iface, state, value);
wined3d_mutex_lock();
wined3d_stateblock_set_render_state(device->update_state, state, value);
- if (!device->recording)
- {
- if (state == D3DRS_BLENDFACTOR)
- {
- wined3d_color_from_d3dcolor(&factor, value);
- wined3d_device_set_blend_state(device->wined3d_device, NULL, &factor);
- }
- else
- wined3d_device_set_render_state(device->wined3d_device, state, value);
- }
if (state == D3DRS_POINTSIZE && value == WINED3D_RESZ_CODE)
resolve_depth_buffer(device);
wined3d_mutex_unlock();
--
2.24.0
Dec. 13, 2019
[PATCH v3 3/5] d3d9: Handle multisample depth resolve in d3d9_device_SetRenderState().
by Zebediah Figura
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
v3: fix the call to wined3d_check_device_multisample_type() and move the
implementation of resolve_depth_buffer() back to d3d9.
dlls/d3d9/device.c | 30 ++++++++++++++++++++++++++++++
dlls/d3d9/directx.c | 14 ++++++++++++--
include/wine/wined3d.h | 2 ++
3 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index be9c2a9d5a..14d2a0cc25 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -2299,6 +2299,34 @@ static HRESULT WINAPI d3d9_device_GetClipPlane(IDirect3DDevice9Ex *iface, DWORD
return hr;
}
+static void resolve_depth_buffer(struct d3d9_device *device)
+{
+ const struct wined3d_stateblock_state *state = wined3d_stateblock_get_state(device->state);
+ struct wined3d_rendertarget_view *wined3d_dsv;
+ struct wined3d_resource *dst_resource;
+ struct wined3d_texture *dst_texture;
+ struct wined3d_resource_desc desc;
+ struct d3d9_surface *d3d9_dsv;
+
+ if (!(dst_texture = state->textures[0]))
+ return;
+ dst_resource = wined3d_texture_get_resource(dst_texture);
+ wined3d_resource_get_desc(dst_resource, &desc);
+ if (desc.format != WINED3DFMT_D24_UNORM_S8_UINT
+ && desc.format != WINED3DFMT_X8D24_UNORM
+ && desc.format != WINED3DFMT_DF16
+ && desc.format != WINED3DFMT_DF24
+ && desc.format != WINED3DFMT_INTZ)
+ return;
+
+ if (!(wined3d_dsv = wined3d_device_get_depth_stencil_view(device->wined3d_device)))
+ return;
+ d3d9_dsv = wined3d_rendertarget_view_get_sub_resource_parent(wined3d_dsv);
+
+ wined3d_device_resolve_sub_resource(device->wined3d_device, dst_resource, 0,
+ wined3d_rendertarget_view_get_resource(wined3d_dsv), d3d9_dsv->sub_resource_idx, desc.format);
+}
+
static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_SetRenderState(IDirect3DDevice9Ex *iface,
D3DRENDERSTATETYPE state, DWORD value)
{
@@ -2319,6 +2347,8 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_SetRenderState(IDirect3DDevi
else
wined3d_device_set_render_state(device->wined3d_device, state, value);
}
+ if (state == D3DRS_POINTSIZE && value == WINED3D_RESZ_CODE)
+ resolve_depth_buffer(device);
wined3d_mutex_unlock();
return D3D_OK;
diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c
index 1d3754adf8..fd22259e17 100644
--- a/dlls/d3d9/directx.c
+++ b/dlls/d3d9/directx.c
@@ -289,8 +289,18 @@ static HRESULT WINAPI d3d9_CheckDeviceFormat(IDirect3D9Ex *iface, UINT adapter,
}
wined3d_mutex_lock();
- hr = wined3d_check_device_format(d3d9->wined3d, adapter, device_type, wined3dformat_from_d3dformat(adapter_format),
- usage, bind_flags, wined3d_rtype, wined3dformat_from_d3dformat(format));
+ if ((enum wined3d_format_id)format == WINED3DFMT_RESZ)
+ {
+ DWORD levels;
+ hr = wined3d_check_device_multisample_type(d3d9->wined3d, adapter, device_type,
+ WINED3DFMT_D24_UNORM_S8_UINT, FALSE, WINED3D_MULTISAMPLE_NON_MASKABLE, &levels);
+ if (SUCCEEDED(hr) && !levels)
+ hr = D3DERR_NOTAVAILABLE;
+ }
+ else
+ hr = wined3d_check_device_format(d3d9->wined3d, adapter, device_type,
+ wined3dformat_from_d3dformat(adapter_format), usage, bind_flags,
+ wined3d_rtype, wined3dformat_from_d3dformat(format));
wined3d_mutex_unlock();
return hr;
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 4306f5ae21..d313c7aec8 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -267,6 +267,8 @@ enum wined3d_format_id
WINED3DFMT_R16 = WINEMAKEFOURCC(' ','R','1','6'),
WINED3DFMT_AL16 = WINEMAKEFOURCC('A','L','1','6'),
WINED3DFMT_NV12 = WINEMAKEFOURCC('N','V','1','2'),
+ WINED3DFMT_DF16 = WINEMAKEFOURCC('D','F','1','6'),
+ WINED3DFMT_DF24 = WINEMAKEFOURCC('D','F','2','4'),
WINED3DFMT_FORCE_DWORD = 0xffffffff
};
--
2.24.0
Dec. 13, 2019
[PATCH v3 2/5] d3d9: Apply the device state before executing a draw call.
by Zebediah Figura
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/d3d9/device.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 82fba25ce7..be9c2a9d5a 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -1821,6 +1821,7 @@ static HRESULT WINAPI d3d9_device_ColorFill(IDirect3DDevice9Ex *iface,
return D3DERR_INVALIDCALL;
}
+ wined3d_device_apply_stateblock(device->wined3d_device, device->state);
rtv = d3d9_surface_acquire_rendertarget_view(surface_impl);
hr = wined3d_device_clear_rendertarget_view(device->wined3d_device,
rtv, rect, WINED3DCLEAR_TARGET, &c, 0.0f, 0);
@@ -2071,6 +2072,7 @@ static HRESULT WINAPI d3d9_device_Clear(IDirect3DDevice9Ex *iface, DWORD rect_co
wined3d_color_from_d3dcolor(&c, color);
wined3d_mutex_lock();
+ wined3d_device_apply_stateblock(device->wined3d_device, device->state);
hr = wined3d_device_clear(device->wined3d_device, rect_count, (const RECT *)rects, flags, &c, z, stencil);
if (SUCCEEDED(hr))
d3d9_rts_flag_auto_gen_mipmap(device);
@@ -2654,6 +2656,7 @@ static HRESULT WINAPI d3d9_device_ValidateDevice(IDirect3DDevice9Ex *iface, DWOR
TRACE("iface %p, pass_count %p.\n", iface, pass_count);
wined3d_mutex_lock();
+ wined3d_device_apply_stateblock(device->wined3d_device, device->state);
hr = wined3d_device_validate_device(device->wined3d_device, pass_count);
wined3d_mutex_unlock();
@@ -2885,6 +2888,7 @@ static HRESULT WINAPI d3d9_device_DrawPrimitive(IDirect3DDevice9Ex *iface,
WARN("Called without a valid vertex declaration set.\n");
return D3DERR_INVALIDCALL;
}
+ wined3d_device_apply_stateblock(device->wined3d_device, device->state);
vertex_count = vertex_count_from_primitive_count(primitive_type, primitive_count);
d3d9_device_upload_sysmem_vertex_buffers(device, 0, start_vertex, vertex_count);
d3d9_generate_auto_mipmaps(device);
@@ -2917,6 +2921,7 @@ static HRESULT WINAPI d3d9_device_DrawIndexedPrimitive(IDirect3DDevice9Ex *iface
WARN("Called without a valid vertex declaration set.\n");
return D3DERR_INVALIDCALL;
}
+ wined3d_device_apply_stateblock(device->wined3d_device, device->state);
index_count = vertex_count_from_primitive_count(primitive_type, primitive_count);
d3d9_device_upload_sysmem_vertex_buffers(device, base_vertex_idx, min_vertex_idx, vertex_count);
d3d9_device_upload_sysmem_index_buffer(device, start_idx, index_count);
@@ -3003,6 +3008,7 @@ static HRESULT WINAPI d3d9_device_DrawPrimitiveUP(IDirect3DDevice9Ex *iface,
return D3DERR_INVALIDCALL;
}
+ wined3d_device_apply_stateblock(device->wined3d_device, device->state);
hr = d3d9_device_prepare_vertex_buffer(device, size);
if (FAILED(hr))
goto done;
@@ -3119,6 +3125,7 @@ static HRESULT WINAPI d3d9_device_DrawIndexedPrimitiveUP(IDirect3DDevice9Ex *ifa
return D3DERR_INVALIDCALL;
}
+ wined3d_device_apply_stateblock(device->wined3d_device, device->state);
hr = d3d9_device_prepare_vertex_buffer(device, vtx_size);
if (FAILED(hr))
goto done;
@@ -3203,6 +3210,8 @@ static HRESULT WINAPI d3d9_device_ProcessVertices(IDirect3DDevice9Ex *iface,
wined3d_mutex_lock();
+ wined3d_device_apply_stateblock(device->wined3d_device, device->state);
+
/* Note that an alternative approach would be to simply create these
* buffers with WINED3D_RESOURCE_ACCESS_MAP_R and update them here like we
* do for draws. In some regards that would be easier, but it seems less
--
2.24.0
Dec. 13, 2019
[PATCH v3 1/5] wined3d: Introduce wined3d_device_apply_stateblock().
by Zebediah Figura
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
v3: Only push modified constants.
This series may not necessarily be safe for code freeze, but I'm submitting it
at least to finish the review process.
dlls/wined3d/device.c | 193 ++++++++++++++++++++++++++++++++++++++
dlls/wined3d/wined3d.spec | 1 +
include/wine/wined3d.h | 1 +
3 files changed, 195 insertions(+)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 8913420724..8e20e31d3f 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3829,6 +3829,199 @@ struct wined3d_texture * CDECL wined3d_device_get_texture(const struct wined3d_d
return device->state.textures[stage];
}
+void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
+ struct wined3d_stateblock *stateblock)
+{
+ const struct wined3d_d3d_info *d3d_info = &stateblock->device->adapter->d3d_info;
+ const struct wined3d_stateblock_state *state = &stateblock->stateblock_state;
+ unsigned int i, j, count;
+
+ TRACE("device %p, stateblock %p.\n", device, stateblock);
+
+ if (stateblock->changed.vertexShader)
+ wined3d_device_set_vertex_shader(device, state->vs);
+ if (stateblock->changed.pixelShader)
+ wined3d_device_set_pixel_shader(device, state->ps);
+
+ count = 0;
+ for (i = 0; i < d3d_info->limits.vs_uniform_count; ++i)
+ {
+ if (stateblock->changed.vs_consts_f[i])
+ ++count;
+ else if (count)
+ {
+ wined3d_device_set_vs_consts_f(device, i - count, count, state->vs_consts_f + i - count);
+ count = 0;
+ }
+ }
+ if (count)
+ wined3d_device_set_vs_consts_f(device, i - count, count, state->vs_consts_f + i - count);
+
+ count = 0;
+ for (i = 0; i < WINED3D_MAX_CONSTS_B; ++i)
+ {
+ if (stateblock->changed.vertexShaderConstantsB & (1u << i))
+ ++count;
+ else if (count)
+ {
+ wined3d_device_set_vs_consts_b(device, i - count, count, state->vs_consts_b + i - count);
+ count = 0;
+ }
+ }
+ if (count)
+ wined3d_device_set_vs_consts_b(device, i - count, count, state->vs_consts_b + i - count);
+
+ count = 0;
+ for (i = 0; i < WINED3D_MAX_CONSTS_I; ++i)
+ {
+ if (stateblock->changed.vertexShaderConstantsI & (1u << i))
+ ++count;
+ else if (count)
+ {
+ wined3d_device_set_vs_consts_i(device, i - count, count, state->vs_consts_i + i - count);
+ count = 0;
+ }
+ }
+ if (count)
+ wined3d_device_set_vs_consts_i(device, i - count, count, state->vs_consts_i + i - count);
+
+ count = 0;
+ for (i = 0; i < d3d_info->limits.ps_uniform_count; ++i)
+ {
+ if (stateblock->changed.ps_consts_f[i])
+ ++count;
+ else if (count)
+ {
+ wined3d_device_set_ps_consts_f(device, i - count, count, state->ps_consts_f + i - count);
+ count = 0;
+ }
+ }
+ if (count)
+ wined3d_device_set_ps_consts_f(device, i - count, count, state->ps_consts_f + i - count);
+
+ count = 0;
+ for (i = 0; i < WINED3D_MAX_CONSTS_B; ++i)
+ {
+ if (stateblock->changed.pixelShaderConstantsB & (1u << i))
+ ++count;
+ else if (count)
+ {
+ wined3d_device_set_ps_consts_b(device, i - count, count, state->ps_consts_b + i - count);
+ count = 0;
+ }
+ }
+ if (count)
+ wined3d_device_set_ps_consts_b(device, i - count, count, state->ps_consts_b + i - count);
+
+ count = 0;
+ for (i = 0; i < WINED3D_MAX_CONSTS_I; ++i)
+ {
+ if (stateblock->changed.pixelShaderConstantsI & (1u << i))
+ ++count;
+ else if (count)
+ {
+ wined3d_device_set_ps_consts_i(device, i - count, count, state->ps_consts_i + i - count);
+ count = 0;
+ }
+ }
+ if (count)
+ wined3d_device_set_ps_consts_i(device, i - count, count, state->ps_consts_i + i - count);
+
+ for (i = 0; i < ARRAY_SIZE(state->light_state->light_map); ++i)
+ {
+ const struct wined3d_light_info *light;
+
+ LIST_FOR_EACH_ENTRY(light, &state->light_state->light_map[i], struct wined3d_light_info, entry)
+ {
+ wined3d_device_set_light(device, light->OriginalIndex, &light->OriginalParms);
+ wined3d_device_set_light_enable(device, light->OriginalIndex, light->glIndex != -1);
+ }
+ }
+
+ for (i = 0; i < ARRAY_SIZE(state->rs); ++i)
+ {
+ if (stateblock->changed.renderState[i >> 5] & (1u << (i & 0x1f)))
+ {
+ if (i == WINED3D_RS_BLENDFACTOR)
+ {
+ struct wined3d_color color;
+ wined3d_color_from_d3dcolor(&color, state->rs[i]);
+ wined3d_device_set_blend_state(device, NULL, &color);
+ }
+ else
+ wined3d_device_set_render_state(device, i, state->rs[i]);
+ }
+ }
+
+ for (i = 0; i < ARRAY_SIZE(state->texture_states); ++i)
+ {
+ for (j = 0; j < ARRAY_SIZE(state->texture_states[i]); ++j)
+ {
+ if (stateblock->changed.textureState[i] & (1u << j))
+ wined3d_device_set_texture_stage_state(device, i, j, state->texture_states[i][j]);
+ }
+ }
+
+ for (i = 0; i < ARRAY_SIZE(state->sampler_states); ++i)
+ {
+ DWORD stage = i;
+ if (stage >= WINED3D_MAX_FRAGMENT_SAMPLERS)
+ stage += WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS;
+ for (j = 0; j < ARRAY_SIZE(state->sampler_states[j]); ++j)
+ {
+ if (stateblock->changed.samplerState[i] & (1 << j))
+ wined3d_device_set_sampler_state(device, stage, j, state->sampler_states[i][j]);
+ }
+ }
+
+ for (i = 0; i < ARRAY_SIZE(state->transforms); ++i)
+ {
+ if (stateblock->changed.transform[i >> 5] & (1u << (i & 0x1f)))
+ wined3d_device_set_transform(device, i, &state->transforms[i]);
+ }
+
+ if (stateblock->changed.indices)
+ wined3d_device_set_index_buffer(device, state->index_buffer, state->index_format, 0);
+ wined3d_device_set_base_vertex_index(device, state->base_vertex_index);
+ if (stateblock->changed.vertexDecl)
+ wined3d_device_set_vertex_declaration(device, state->vertex_declaration);
+ if (stateblock->changed.material)
+ wined3d_device_set_material(device, &state->material);
+ if (stateblock->changed.viewport)
+ wined3d_device_set_viewports(device, 1, &state->viewport);
+ if (stateblock->changed.scissorRect)
+ wined3d_device_set_scissor_rects(device, 1, &state->scissor_rect);
+
+ for (i = 0; i < ARRAY_SIZE(state->streams); ++i)
+ {
+ if (stateblock->changed.streamSource & (1u << i))
+ wined3d_device_set_stream_source(device, i, state->streams[i].buffer,
+ state->streams[i].offset, state->streams[i].stride);
+ if (stateblock->changed.streamFreq & (1u << i))
+ wined3d_device_set_stream_source_freq(device, i,
+ state->streams[i].frequency | state->streams[i].flags);
+ }
+
+ for (i = 0; i < ARRAY_SIZE(state->textures); ++i)
+ {
+ DWORD stage = i;
+ if (stage >= WINED3D_MAX_FRAGMENT_SAMPLERS)
+ stage += WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS;
+ if (stateblock->changed.textures & (1u << i))
+ wined3d_device_set_texture(device, stage, state->textures[i]);
+ }
+
+ for (i = 0; i < ARRAY_SIZE(state->clip_planes); ++i)
+ {
+ if (stateblock->changed.clipplane & (1u << i))
+ wined3d_device_set_clip_plane(device, i, &state->clip_planes[i]);
+ }
+
+ memset(&stateblock->changed, 0, sizeof(stateblock->changed));
+
+ TRACE("Applied stateblock %p.\n", stateblock);
+}
+
HRESULT CDECL wined3d_device_get_device_caps(const struct wined3d_device *device, struct wined3d_caps *caps)
{
TRACE("device %p, caps %p.\n", device, caps);
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index e03c57055b..c8ef442c72 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -37,6 +37,7 @@
@ cdecl wined3d_buffer_incref(ptr)
@ cdecl wined3d_device_acquire_focus_window(ptr ptr)
+@ cdecl wined3d_device_apply_stateblock(ptr ptr)
@ cdecl wined3d_device_begin_scene(ptr)
@ cdecl wined3d_device_clear(ptr long ptr long ptr float long)
@ cdecl wined3d_device_clear_rendertarget_view(ptr ptr ptr long ptr float long)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 9cdf18633c..4306f5ae21 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2289,6 +2289,7 @@ struct wined3d_resource * __cdecl wined3d_buffer_get_resource(struct wined3d_buf
ULONG __cdecl wined3d_buffer_incref(struct wined3d_buffer *buffer);
HRESULT __cdecl wined3d_device_acquire_focus_window(struct wined3d_device *device, HWND window);
+void __cdecl wined3d_device_apply_stateblock(struct wined3d_device *device, struct wined3d_stateblock *stateblock);
HRESULT __cdecl wined3d_device_begin_scene(struct wined3d_device *device);
HRESULT __cdecl wined3d_device_clear(struct wined3d_device *device, DWORD rect_count, const RECT *rects, DWORD flags,
const struct wined3d_color *color, float z, DWORD stencil);
--
2.24.0
Dec. 13, 2019
[PATCH 5/5] wined3d: Implement mapping Vulkan buffers.
by Henri Verbeet
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/adapter_vk.c | 56 ++++++++++--
dlls/wined3d/context.c | 195 ++++++++++++++++++++++++++++++++++++++++-
dlls/wined3d/resource.c | 26 ++++++
dlls/wined3d/wined3d_private.h | 23 +++++
4 files changed, 293 insertions(+), 7 deletions(-)
diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c
index 7d501b4b08f..87e21b0b41f 100644
--- a/dlls/wined3d/adapter_vk.c
+++ b/dlls/wined3d/adapter_vk.c
@@ -233,6 +233,7 @@ static HRESULT adapter_vk_create_device(struct wined3d *wined3d, const struct wi
device_vk->vk_device = vk_device;
VK_CALL(vkGetDeviceQueue(vk_device, queue_family_index, 0, &device_vk->vk_queue));
+ device_vk->vk_queue_family_index = queue_family_index;
device_vk->vk_info = *vk_info;
#define LOAD_DEVICE_PFN(name) \
@@ -490,20 +491,65 @@ static void adapter_vk_uninit_3d(struct wined3d_device *device)
static void *adapter_vk_map_bo_address(struct wined3d_context *context,
const struct wined3d_bo_address *data, size_t size, uint32_t bind_flags, uint32_t map_flags)
{
- if (data->buffer_object)
+ struct wined3d_context_vk *context_vk = wined3d_context_vk(context);
+ const struct wined3d_vk_info *vk_info;
+ struct wined3d_device_vk *device_vk;
+ VkCommandBuffer vk_command_buffer;
+ VkBufferMemoryBarrier vk_barrier;
+ struct wined3d_bo_vk *bo;
+ void *map_ptr;
+ VkResult vr;
+
+ if (!(bo = (struct wined3d_bo_vk *)data->buffer_object))
+ return data->addr;
+
+ vk_info = context_vk->vk_info;
+ device_vk = wined3d_device_vk(context->device);
+
+ if (!(vk_command_buffer = wined3d_context_vk_get_command_buffer(context_vk)))
+ {
+ ERR("Failed to get command buffer.\n");
+ return NULL;
+ }
+
+ vk_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
+ vk_barrier.pNext = NULL;
+ vk_barrier.srcAccessMask = vk_access_mask_from_bind_flags(bind_flags);
+ vk_barrier.dstAccessMask = VK_ACCESS_HOST_READ_BIT;
+ vk_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
+ vk_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
+ vk_barrier.buffer = bo->vk_buffer;
+ vk_barrier.offset = (uintptr_t)data->addr;
+ vk_barrier.size = size;
+ VK_CALL(vkCmdPipelineBarrier(vk_command_buffer, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
+ VK_PIPELINE_STAGE_HOST_BIT, 0, 0, NULL, 1, &vk_barrier, 0, NULL));
+
+ wined3d_context_vk_submit_command_buffer(context_vk);
+ wined3d_context_vk_wait_command_buffer(context_vk, context_vk->current_command_buffer.id - 1);
+
+ if ((vr = VK_CALL(vkMapMemory(device_vk->vk_device, bo->vk_memory,
+ (uintptr_t)data->addr, size, 0, &map_ptr))) < 0)
{
- ERR("Unsupported buffer object %#lx.\n", data->buffer_object);
+ ERR("Failed to map buffer, vr %s.\n", wined3d_debug_vkresult(vr));
return NULL;
}
- return data->addr;
+ return map_ptr;
}
static void adapter_vk_unmap_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data,
uint32_t bind_flags, unsigned int range_count, const struct wined3d_map_range *ranges)
{
- if (data->buffer_object)
- ERR("Unsupported buffer object %#lx.\n", data->buffer_object);
+ const struct wined3d_vk_info *vk_info;
+ struct wined3d_device_vk *device_vk;
+ struct wined3d_bo_vk *bo;
+
+ if (!(bo = (struct wined3d_bo_vk *)data->buffer_object))
+ return;
+
+ vk_info = wined3d_context_vk(context)->vk_info;
+ device_vk = wined3d_device_vk(context->device);
+ VK_CALL(vkUnmapMemory(device_vk->vk_device, bo->vk_memory));
}
static void adapter_vk_copy_bo_address(struct wined3d_context *context,
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 5d88d4463f9..e4eee88a37e 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -1561,8 +1561,52 @@ void wined3d_context_vk_destroy_bo(struct wined3d_context_vk *context_vk, const
VK_CALL(vkFreeMemory(device_vk->vk_device, bo->vk_memory, NULL));
}
+static void wined3d_context_vk_cleanup_resources(struct wined3d_context_vk *context_vk)
+{
+ struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
+ const struct wined3d_vk_info *vk_info = context_vk->vk_info;
+ struct wined3d_command_buffer_vk *buffer;
+ SIZE_T i = 0;
+
+ while (i < context_vk->submitted.buffer_count)
+ {
+ buffer = &context_vk->submitted.buffers[i];
+ if (VK_CALL(vkGetFenceStatus(device_vk->vk_device, buffer->vk_fence)) == VK_NOT_READY)
+ {
+ ++i;
+ continue;
+ }
+
+ TRACE("Command buffer %p with id 0x%s has finished.\n",
+ buffer->vk_command_buffer, wine_dbgstr_longlong(buffer->id));
+ VK_CALL(vkDestroyFence(device_vk->vk_device, buffer->vk_fence, NULL));
+ VK_CALL(vkFreeCommandBuffers(device_vk->vk_device,
+ context_vk->vk_command_pool, 1, &buffer->vk_command_buffer));
+
+ if (buffer->id > context_vk->completed_command_buffer_id)
+ context_vk->completed_command_buffer_id = buffer->id;
+ *buffer = context_vk->submitted.buffers[--context_vk->submitted.buffer_count];
+ }
+}
+
void wined3d_context_vk_cleanup(struct wined3d_context_vk *context_vk)
{
+ struct wined3d_command_buffer_vk *buffer = &context_vk->current_command_buffer;
+ struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
+ const struct wined3d_vk_info *vk_info = context_vk->vk_info;
+
+ if (buffer->vk_command_buffer)
+ {
+ VK_CALL(vkFreeCommandBuffers(device_vk->vk_device,
+ context_vk->vk_command_pool, 1, &buffer->vk_command_buffer));
+ buffer->vk_command_buffer = VK_NULL_HANDLE;
+ }
+ VK_CALL(vkDestroyCommandPool(device_vk->vk_device, context_vk->vk_command_pool, NULL));
+
+ wined3d_context_vk_wait_command_buffer(context_vk, buffer->id - 1);
+ context_vk->completed_command_buffer_id = buffer->id;
+ wined3d_context_vk_cleanup_resources(context_vk);
+ heap_free(context_vk->submitted.buffers);
wined3d_context_cleanup(&context_vk->c);
}
@@ -1965,6 +2009,135 @@ HGLRC context_create_wgl_attribs(const struct wined3d_gl_info *gl_info, HDC hdc,
return ctx;
}
+VkCommandBuffer wined3d_context_vk_get_command_buffer(struct wined3d_context_vk *context_vk)
+{
+ struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
+ const struct wined3d_vk_info *vk_info = context_vk->vk_info;
+ VkCommandBufferAllocateInfo command_buffer_info;
+ struct wined3d_command_buffer_vk *buffer;
+ VkCommandBufferBeginInfo begin_info;
+ VkResult vr;
+
+ TRACE("context_vk %p.\n", context_vk);
+
+ buffer = &context_vk->current_command_buffer;
+ if (buffer->vk_command_buffer)
+ {
+ TRACE("Returning existing command buffer %p with id 0x%s.\n",
+ buffer->vk_command_buffer, wine_dbgstr_longlong(buffer->id));
+ return buffer->vk_command_buffer;
+ }
+
+ command_buffer_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
+ command_buffer_info.pNext = NULL;
+ command_buffer_info.commandPool = context_vk->vk_command_pool;
+ command_buffer_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
+ command_buffer_info.commandBufferCount = 1;
+ if ((vr = VK_CALL(vkAllocateCommandBuffers(device_vk->vk_device,
+ &command_buffer_info, &buffer->vk_command_buffer))) < 0)
+ {
+ WARN("Failed to allocate Vulkan command buffer, vr %s.\n", wined3d_debug_vkresult(vr));
+ return VK_NULL_HANDLE;
+ }
+
+ begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ begin_info.pNext = NULL;
+ begin_info.flags = 0;
+ begin_info.pInheritanceInfo = NULL;
+ if ((vr = VK_CALL(vkBeginCommandBuffer(buffer->vk_command_buffer, &begin_info))) < 0)
+ {
+ WARN("Failed to begin command buffer, vr %s.\n", wined3d_debug_vkresult(vr));
+ VK_CALL(vkFreeCommandBuffers(device_vk->vk_device, context_vk->vk_command_pool,
+ 1, &buffer->vk_command_buffer));
+ return buffer->vk_command_buffer = VK_NULL_HANDLE;
+ }
+
+ TRACE("Created new command buffer %p with id 0x%s.\n",
+ buffer->vk_command_buffer, wine_dbgstr_longlong(buffer->id));
+
+ return buffer->vk_command_buffer;
+}
+
+void wined3d_context_vk_submit_command_buffer(struct wined3d_context_vk *context_vk)
+{
+ struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
+ const struct wined3d_vk_info *vk_info = context_vk->vk_info;
+ struct wined3d_command_buffer_vk *buffer;
+ VkFenceCreateInfo fence_desc;
+ VkSubmitInfo submit_info;
+ VkResult vr;
+
+ TRACE("context_vk %p.\n", context_vk);
+
+ buffer = &context_vk->current_command_buffer;
+ if (!buffer->vk_command_buffer)
+ return;
+
+ TRACE("Submitting command buffer %p with id 0x%s.\n",
+ buffer->vk_command_buffer, wine_dbgstr_longlong(buffer->id));
+
+ VK_CALL(vkEndCommandBuffer(buffer->vk_command_buffer));
+
+ fence_desc.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
+ fence_desc.pNext = NULL;
+ fence_desc.flags = 0;
+ if ((vr = VK_CALL(vkCreateFence(device_vk->vk_device, &fence_desc, NULL, &buffer->vk_fence))) < 0)
+ ERR("Failed to create fence, vr %s.\n", wined3d_debug_vkresult(vr));
+
+ submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ submit_info.pNext = NULL;
+ submit_info.waitSemaphoreCount = 0;
+ submit_info.pWaitSemaphores = NULL;
+ submit_info.pWaitDstStageMask = NULL;
+ submit_info.commandBufferCount = 1;
+ submit_info.pCommandBuffers = &buffer->vk_command_buffer;
+ submit_info.signalSemaphoreCount = 0;
+ submit_info.pSignalSemaphores = NULL;
+
+ if ((vr = VK_CALL(vkQueueSubmit(device_vk->vk_queue, 1, &submit_info, buffer->vk_fence))) < 0)
+ ERR("Failed to submit command buffer %p, vr %s.\n",
+ buffer->vk_command_buffer, wined3d_debug_vkresult(vr));
+
+ if (!wined3d_array_reserve((void **)&context_vk->submitted.buffers, &context_vk->submitted.buffers_size,
+ context_vk->submitted.buffer_count + 1, sizeof(*context_vk->submitted.buffers)))
+ ERR("Failed to grow submitted command buffer array.\n");
+
+ context_vk->submitted.buffers[context_vk->submitted.buffer_count++] = *buffer;
+
+ buffer->vk_command_buffer = VK_NULL_HANDLE;
+ /* We don't expect this to ever happen, but handle it anyway. */
+ if (!++buffer->id)
+ {
+ wined3d_context_vk_wait_command_buffer(context_vk, buffer->id - 1);
+ context_vk->completed_command_buffer_id = 0;
+ buffer->id = 1;
+ }
+ wined3d_context_vk_cleanup_resources(context_vk);
+}
+
+void wined3d_context_vk_wait_command_buffer(struct wined3d_context_vk *context_vk, uint64_t id)
+{
+ struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
+ const struct wined3d_vk_info *vk_info = context_vk->vk_info;
+ SIZE_T i;
+
+ if (id <= context_vk->completed_command_buffer_id)
+ return;
+
+ for (i = 0; i < context_vk->submitted.buffer_count; ++i)
+ {
+ if (context_vk->submitted.buffers[i].id != id)
+ continue;
+
+ VK_CALL(vkWaitForFences(device_vk->vk_device, 1,
+ &context_vk->submitted.buffers[i].vk_fence, VK_TRUE, UINT64_MAX));
+ wined3d_context_vk_cleanup_resources(context_vk);
+ return;
+ }
+
+ ERR("Failed to find fence for command buffer with id 0x%s.\n", wine_dbgstr_longlong(id));
+}
+
static void wined3d_context_init(struct wined3d_context *context, struct wined3d_swapchain *swapchain)
{
struct wined3d_device *device = swapchain->device;
@@ -2412,13 +2585,31 @@ fail:
HRESULT wined3d_context_vk_init(struct wined3d_context_vk *context_vk, struct wined3d_swapchain *swapchain)
{
+ VkCommandPoolCreateInfo command_pool_info;
+ const struct wined3d_vk_info *vk_info;
struct wined3d_adapter_vk *adapter_vk;
+ struct wined3d_device_vk *device_vk;
+ VkResult vr;
TRACE("context_vk %p, swapchain %p.\n", context_vk, swapchain);
wined3d_context_init(&context_vk->c, swapchain);
- adapter_vk = wined3d_adapter_vk(swapchain->device->adapter);
- context_vk->vk_info = &adapter_vk->vk_info;
+ device_vk = wined3d_device_vk(swapchain->device);
+ adapter_vk = wined3d_adapter_vk(device_vk->d.adapter);
+ context_vk->vk_info = vk_info = &adapter_vk->vk_info;
+
+ command_pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
+ command_pool_info.pNext = NULL;
+ command_pool_info.flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT;
+ command_pool_info.queueFamilyIndex = device_vk->vk_queue_family_index;
+ if ((vr = VK_CALL(vkCreateCommandPool(device_vk->vk_device,
+ &command_pool_info, NULL, &context_vk->vk_command_pool))) < 0)
+ {
+ ERR("Failed to create Vulkan command pool, vr %s.\n", wined3d_debug_vkresult(vr));
+ wined3d_context_cleanup(&context_vk->c);
+ return E_FAIL;
+ }
+ context_vk->current_command_buffer.id = 1;
return WINED3D_OK;
}
diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index bba940f42cb..bbb892b328d 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -549,3 +549,29 @@ unsigned int wined3d_resource_get_sample_count(const struct wined3d_resource *re
return resource->multisample_type;
}
+
+VkAccessFlags vk_access_mask_from_bind_flags(uint32_t bind_flags)
+{
+ VkAccessFlags flags = 0;
+
+ if (bind_flags & WINED3D_BIND_VERTEX_BUFFER)
+ flags |= VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT;
+ if (bind_flags & WINED3D_BIND_INDEX_BUFFER)
+ flags |= VK_ACCESS_INDEX_READ_BIT;
+ if (bind_flags & WINED3D_BIND_CONSTANT_BUFFER)
+ flags |= VK_ACCESS_UNIFORM_READ_BIT;
+ if (bind_flags & WINED3D_BIND_SHADER_RESOURCE)
+ flags |= VK_ACCESS_SHADER_READ_BIT;
+ if (bind_flags & WINED3D_BIND_UNORDERED_ACCESS)
+ flags |= VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
+ if (bind_flags & WINED3D_BIND_INDIRECT_BUFFER)
+ flags |= VK_ACCESS_INDIRECT_COMMAND_READ_BIT;
+ if (bind_flags & WINED3D_BIND_RENDER_TARGET)
+ flags |= VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
+ if (bind_flags & WINED3D_BIND_DEPTH_STENCIL)
+ flags |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
+ if (bind_flags & WINED3D_BIND_STREAM_OUTPUT)
+ FIXME("Ignoring some bind flags %#x.\n", bind_flags);
+
+ return flags;
+}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 934a422ede1..5beaa927d77 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -294,6 +294,7 @@ extern const struct min_lookup minMipLookup[WINED3D_TEXF_LINEAR + 1] DECLSPEC_HI
extern const GLenum magLookup[WINED3D_TEXF_LINEAR + 1] DECLSPEC_HIDDEN;
GLenum wined3d_gl_compare_func(enum wined3d_cmp_func f) DECLSPEC_HIDDEN;
+VkAccessFlags vk_access_mask_from_bind_flags(uint32_t bind_flags) DECLSPEC_HIDDEN;
static inline enum wined3d_cmp_func wined3d_sanitize_cmp_func(enum wined3d_cmp_func func)
{
@@ -2158,11 +2159,29 @@ void wined3d_context_gl_unmap_bo_address(struct wined3d_context_gl *context_gl,
void wined3d_context_gl_update_stream_sources(struct wined3d_context_gl *context_gl,
const struct wined3d_state *state) DECLSPEC_HIDDEN;
+struct wined3d_command_buffer_vk
+{
+ uint64_t id;
+ VkCommandBuffer vk_command_buffer;
+ VkFence vk_fence;
+};
+
struct wined3d_context_vk
{
struct wined3d_context c;
const struct wined3d_vk_info *vk_info;
+
+ VkCommandPool vk_command_pool;
+ struct wined3d_command_buffer_vk current_command_buffer;
+ uint64_t completed_command_buffer_id;
+
+ struct
+ {
+ struct wined3d_command_buffer_vk *buffers;
+ SIZE_T buffers_size;
+ SIZE_T buffer_count;
+ } submitted;
};
static inline struct wined3d_context_vk *wined3d_context_vk(struct wined3d_context *context)
@@ -2175,8 +2194,11 @@ BOOL wined3d_context_vk_create_bo(struct wined3d_context_vk *context_vk, VkDevic
VkBufferUsageFlags usage, VkMemoryPropertyFlags memory_type, struct wined3d_bo_vk *bo) DECLSPEC_HIDDEN;
void wined3d_context_vk_destroy_bo(struct wined3d_context_vk *context_vk,
const struct wined3d_bo_vk *bo) DECLSPEC_HIDDEN;
+VkCommandBuffer wined3d_context_vk_get_command_buffer(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
HRESULT wined3d_context_vk_init(struct wined3d_context_vk *context_vk,
struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
+void wined3d_context_vk_submit_command_buffer(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
+void wined3d_context_vk_wait_command_buffer(struct wined3d_context_vk *context_vk, uint64_t id) DECLSPEC_HIDDEN;
typedef void (*APPLYSTATEFUNC)(struct wined3d_context *ctx, const struct wined3d_state *state, DWORD state_id);
@@ -3350,6 +3372,7 @@ struct wined3d_device_vk
VkDevice vk_device;
VkQueue vk_queue;
+ uint32_t vk_queue_family_index;
struct wined3d_vk_info vk_info;
};
--
2.11.0
Dec. 13, 2019
[PATCH 4/5] wined3d: Get gl_info from the context in wined3d_device_create_primary_opengl_context_cs().
by Henri Verbeet
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/device.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 89134207243..cdc65a6fa71 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1002,13 +1002,15 @@ void wined3d_device_create_primary_opengl_context_cs(void *object)
context_release(context);
return;
}
- wined3d_ffp_blitter_create(&device->blitter, &device->adapter->gl_info);
+
+ context_gl = wined3d_context_gl(context);
+
+ wined3d_ffp_blitter_create(&device->blitter, context_gl->gl_info);
if (!wined3d_glsl_blitter_create(&device->blitter, device))
wined3d_arbfp_blitter_create(&device->blitter, device);
- wined3d_fbo_blitter_create(&device->blitter, &device->adapter->gl_info);
- wined3d_raw_blitter_create(&device->blitter, &device->adapter->gl_info);
+ wined3d_fbo_blitter_create(&device->blitter, context_gl->gl_info);
+ wined3d_raw_blitter_create(&device->blitter, context_gl->gl_info);
- context_gl = wined3d_context_gl(context);
wined3d_device_gl_create_dummy_textures(wined3d_device_gl(device), context_gl);
wined3d_device_create_default_samplers(device, context);
context_release(context);
--
2.11.0
Dec. 13, 2019
[PATCH 3/5] wined3d: Store a gl_info pointer in struct shader_arb_ctx_priv.
by Henri Verbeet
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/arb_program_shader.c | 7 +++++--
dlls/wined3d/shader.c | 1 -
dlls/wined3d/wined3d_private.h | 2 +-
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 9d98c79ce51..14ca883e761 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -237,6 +237,7 @@ struct shader_arb_ctx_priv
NV3
} target_version;
+ const struct wined3d_gl_info *gl_info;
const struct arb_vs_compile_args *cur_vs_args;
const struct arb_ps_compile_args *cur_ps_args;
const struct arb_ps_compiled_shader *compiled_fprog;
@@ -1438,7 +1439,7 @@ static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD
case WINED3D_SHADER_RESOURCE_TEXTURE_2D:
if (pshader && priv->cur_ps_args->super.np2_fixup & (1u << sampler_idx)
- && ins->ctx->gl_info->supported[ARB_TEXTURE_RECTANGLE])
+ && priv->gl_info->supported[ARB_TEXTURE_RECTANGLE])
tex_type = "RECT";
else
tex_type = "2D";
@@ -3301,7 +3302,7 @@ static void shader_hw_ret(const struct wined3d_shader_instruction *ins)
if(vshader)
{
if (priv->in_main_func) vshader_add_footer(priv, shader->backend_data,
- priv->cur_vs_args, ins->ctx->reg_maps, ins->ctx->gl_info, buffer);
+ priv->cur_vs_args, ins->ctx->reg_maps, priv->gl_info, buffer);
}
shader_addline(buffer, "RET;\n");
@@ -3555,6 +3556,7 @@ static GLuint shader_arb_generate_pshader(const struct wined3d_shader *shader,
/* Create the hw ARB shader */
memset(&priv_ctx, 0, sizeof(priv_ctx));
+ priv_ctx.gl_info = gl_info;
priv_ctx.cur_ps_args = args;
priv_ctx.compiled_fprog = compiled;
priv_ctx.cur_np2fixup_info = &compiled->np2fixup_info;
@@ -4113,6 +4115,7 @@ static GLuint shader_arb_generate_vshader(const struct wined3d_shader *shader,
unsigned int i;
memset(&priv_ctx, 0, sizeof(priv_ctx));
+ priv_ctx.gl_info = gl_info;
priv_ctx.cur_vs_args = args;
list_init(&priv_ctx.control_frames);
init_output_registers(shader, ps_input_sig, &priv_ctx, compiled);
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index 3b9a96abc69..757631a73ef 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -2624,7 +2624,6 @@ HRESULT shader_generate_code(const struct wined3d_shader *shader, struct wined3d
state.in_subroutine = FALSE;
ctx.shader = shader;
- ctx.gl_info = &device->adapter->gl_info;
ctx.reg_maps = reg_maps;
ctx.buffer = buffer;
ctx.tex_mx = &tex_mx;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 583d970eca8..934a422ede1 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -79,6 +79,7 @@
struct wined3d_fragment_pipe_ops;
struct wined3d_adapter;
struct wined3d_context;
+struct wined3d_gl_info;
struct wined3d_state;
struct wined3d_swapchain_gl;
struct wined3d_texture_gl;
@@ -1084,7 +1085,6 @@ struct wined3d_shader_parser_state
struct wined3d_shader_context
{
const struct wined3d_shader *shader;
- const struct wined3d_gl_info *gl_info;
const struct wined3d_shader_reg_maps *reg_maps;
struct wined3d_string_buffer *buffer;
struct wined3d_shader_tex_mx *tex_mx;
--
2.11.0
Dec. 13, 2019
[PATCH 2/5] wined3d: Store a gl_info pointer in struct shader_glsl_ctx_priv.
by Henri Verbeet
Since the one in struct wined3d_shader_context is going away.
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/glsl_shader.c | 43 +++++++++++++++++++++++++++++--------------
1 file changed, 29 insertions(+), 14 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index f05631ec595..25e97723255 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -271,7 +271,9 @@ struct glsl_program_key
GLuint cs_id;
};
-struct shader_glsl_ctx_priv {
+struct shader_glsl_ctx_priv
+{
+ const struct wined3d_gl_info *gl_info;
const struct vs_compile_args *cur_vs_args;
const struct ds_compile_args *cur_ds_args;
const struct ps_compile_args *cur_ps_args;
@@ -2651,8 +2653,9 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
const struct wined3d_shader *shader = ctx->shader;
const struct wined3d_shader_reg_maps *reg_maps = ctx->reg_maps;
const struct wined3d_shader_version *version = ®_maps->shader_version;
- const struct wined3d_gl_info *gl_info = ctx->gl_info;
+ const struct shader_glsl_ctx_priv *priv = ctx->backend_data;
const char *prefix = shader_glsl_get_prefix(version->type);
+ const struct wined3d_gl_info *gl_info = priv->gl_info;
struct glsl_src_param rel_param0, rel_param1;
if (reg->idx[0].offset != ~0u && reg->idx[0].rel_addr)
@@ -2674,8 +2677,6 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register *
case WINED3DSPR_INCONTROLPOINT:
if (version->type == WINED3D_SHADER_TYPE_VERTEX)
{
- struct shader_glsl_ctx_priv *priv = ctx->backend_data;
-
if (reg->idx[0].rel_addr)
FIXME("VS3 input registers relative addressing.\n");
if (is_swizzled && priv->cur_vs_args->swizzle_map & (1u << reg->idx[0].offset))
@@ -3353,7 +3354,7 @@ static void shader_glsl_get_sample_function(const struct wined3d_shader_context
{
enum wined3d_shader_resource_type resource_type;
struct shader_glsl_ctx_priv *priv = ctx->backend_data;
- const struct wined3d_gl_info *gl_info = ctx->gl_info;
+ const struct wined3d_gl_info *gl_info = priv->gl_info;
BOOL shadow = glsl_is_shadow_sampler(ctx->shader, priv->cur_ps_args, resource_idx, sampler_idx);
BOOL projected = flags & WINED3D_GLSL_SAMPLE_PROJECTED;
BOOL texrect = ctx->reg_maps->shader_version.type == WINED3D_SHADER_TYPE_PIXEL
@@ -3854,8 +3855,9 @@ static void shader_glsl_udiv(const struct wined3d_shader_instruction *ins)
/* Process the WINED3DSIO_MOV opcode using GLSL (dst = src) */
static void shader_glsl_mov(const struct wined3d_shader_instruction *ins)
{
- const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
+ const struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data;
struct wined3d_string_buffer *buffer = ins->ctx->buffer;
+ const struct wined3d_gl_info *gl_info = priv->gl_info;
struct glsl_src_param src0_param;
DWORD write_mask;
@@ -4979,9 +4981,10 @@ static void shader_glsl_emit(const struct wined3d_shader_instruction *ins)
{
unsigned int stream = ins->handler_idx == WINED3DSIH_EMIT ? 0 : ins->src[0].reg.idx[0].offset;
const struct wined3d_shader_reg_maps *reg_maps = ins->ctx->reg_maps;
+ const struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data;
shader_addline(ins->ctx->buffer, "setup_gs_output(gs_out);\n");
- if (!ins->ctx->gl_info->supported[ARB_CLIP_CONTROL])
+ if (!priv->gl_info->supported[ARB_CLIP_CONTROL])
shader_glsl_fixup_position(ins->ctx->buffer, reg_maps->viewport_array);
if (!stream)
@@ -5186,7 +5189,8 @@ static void shader_glsl_tex(const struct wined3d_shader_instruction *ins)
static void shader_glsl_texldd(const struct wined3d_shader_instruction *ins)
{
- const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
+ const struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data;
+ const struct wined3d_gl_info *gl_info = priv->gl_info;
struct glsl_src_param coord_param, dx_param, dy_param;
struct glsl_sample_function sample_function;
DWORD sampler_idx;
@@ -5214,7 +5218,8 @@ static void shader_glsl_texldd(const struct wined3d_shader_instruction *ins)
static void shader_glsl_texldl(const struct wined3d_shader_instruction *ins)
{
const struct wined3d_shader_version *shader_version = &ins->ctx->reg_maps->shader_version;
- const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
+ const struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data;
+ const struct wined3d_gl_info *gl_info = priv->gl_info;
struct glsl_src_param coord_param, lod_param;
struct glsl_sample_function sample_function;
DWORD swizzle = ins->src[1].swizzle;
@@ -5769,8 +5774,9 @@ static BOOL is_mipmapped(enum wined3d_shader_resource_type resource_type)
static void shader_glsl_resinfo(const struct wined3d_shader_instruction *ins)
{
const struct wined3d_shader_version *version = &ins->ctx->reg_maps->shader_version;
- const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
+ const struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data;
struct wined3d_string_buffer *buffer = ins->ctx->buffer;
+ const struct wined3d_gl_info *gl_info = priv->gl_info;
enum wined3d_shader_resource_type resource_type;
enum wined3d_shader_register_type reg_type;
unsigned int resource_idx, bind_idx, i;
@@ -5858,7 +5864,8 @@ static void shader_glsl_resinfo(const struct wined3d_shader_instruction *ins)
static void shader_glsl_sample_info(const struct wined3d_shader_instruction *ins)
{
const struct wined3d_shader_reg_maps *reg_maps = ins->ctx->reg_maps;
- const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
+ const struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data;
+ const struct wined3d_gl_info *gl_info = priv->gl_info;
struct wined3d_string_buffer *buffer = ins->ctx->buffer;
const struct wined3d_shader_dst_param *dst = ins->dst;
const struct wined3d_shader_src_param *src = ins->src;
@@ -6060,9 +6067,10 @@ static void shader_glsl_gen_sample_c_lz_emulation(const struct wined3d_shader_in
static void shader_glsl_sample_c(const struct wined3d_shader_instruction *ins)
{
- const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
+ const struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data;
unsigned int resource_idx, sampler_idx, sampler_bind_idx;
const struct wined3d_shader_resource_info *resource_info;
+ const struct wined3d_gl_info *gl_info = priv->gl_info;
struct glsl_src_param coord_param, compare_param;
struct glsl_sample_function sample_function;
const char *lod_param = NULL;
@@ -6110,8 +6118,9 @@ static void shader_glsl_gather4(const struct wined3d_shader_instruction *ins)
unsigned int resource_param_idx, resource_idx, sampler_idx, sampler_bind_idx, component_idx;
const struct wined3d_shader_reg_maps *reg_maps = ins->ctx->reg_maps;
const char *prefix = shader_glsl_get_prefix(reg_maps->shader_version.type);
+ const struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data;
struct glsl_src_param coord_param, compare_param, offset_param;
- const struct wined3d_gl_info *gl_info = ins->ctx->gl_info;
+ const struct wined3d_gl_info *gl_info = priv->gl_info;
const struct wined3d_shader_resource_info *resource_info;
struct wined3d_string_buffer *buffer = ins->ctx->buffer;
unsigned int coord_size, offset_size;
@@ -7574,6 +7583,7 @@ static GLuint shader_glsl_generate_fragment_shader(const struct wined3d_context_
DWORD map;
memset(&priv_ctx, 0, sizeof(priv_ctx));
+ priv_ctx.gl_info = gl_info;
priv_ctx.cur_ps_args = args;
priv_ctx.cur_np2fixup_info = np2fixup_info;
priv_ctx.string_buffers = string_buffers;
@@ -7927,6 +7937,7 @@ static GLuint shader_glsl_generate_vertex_shader(const struct wined3d_context_gl
unsigned int i;
memset(&priv_ctx, 0, sizeof(priv_ctx));
+ priv_ctx.gl_info = gl_info;
priv_ctx.cur_vs_args = args;
priv_ctx.string_buffers = string_buffers;
@@ -8071,6 +8082,7 @@ static GLuint shader_glsl_generate_hull_shader(const struct wined3d_context_gl *
unsigned int i;
memset(&priv_ctx, 0, sizeof(priv_ctx));
+ priv_ctx.gl_info = gl_info;
priv_ctx.string_buffers = string_buffers;
shader_glsl_add_version_declaration(buffer, gl_info);
@@ -8164,6 +8176,7 @@ static GLuint shader_glsl_generate_domain_shader(const struct wined3d_context_gl
GLuint shader_id;
memset(&priv_ctx, 0, sizeof(priv_ctx));
+ priv_ctx.gl_info = gl_info;
priv_ctx.cur_ds_args = args;
priv_ctx.string_buffers = string_buffers;
@@ -8262,6 +8275,7 @@ static GLuint shader_glsl_generate_geometry_shader(const struct wined3d_context_
GLuint shader_id;
memset(&priv_ctx, 0, sizeof(priv_ctx));
+ priv_ctx.gl_info = gl_info;
priv_ctx.string_buffers = string_buffers;
shader_glsl_add_version_declaration(buffer, gl_info);
@@ -8351,7 +8365,7 @@ static GLuint shader_glsl_generate_geometry_shader(const struct wined3d_context_
static void shader_glsl_generate_shader_epilogue(const struct wined3d_shader_context *ctx)
{
const struct shader_glsl_ctx_priv *priv = ctx->backend_data;
- const struct wined3d_gl_info *gl_info = ctx->gl_info;
+ const struct wined3d_gl_info *gl_info = priv->gl_info;
struct wined3d_string_buffer *buffer = ctx->buffer;
const struct wined3d_shader *shader = ctx->shader;
@@ -8388,6 +8402,7 @@ static GLuint shader_glsl_generate_compute_shader(const struct wined3d_context_g
unsigned int i;
memset(&priv_ctx, 0, sizeof(priv_ctx));
+ priv_ctx.gl_info = gl_info;
priv_ctx.string_buffers = string_buffers;
shader_glsl_add_version_declaration(buffer, gl_info);
--
2.11.0
Dec. 13, 2019
[PATCH 1/5] wined3d: Create Vulkan buffers.
by Henri Verbeet
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/adapter_vk.c | 17 ++++++++++
dlls/wined3d/buffer.c | 66 ++++++++++++++++++++++++++++++++++++--
dlls/wined3d/context.c | 72 ++++++++++++++++++++++++++++++++++++++++++
dlls/wined3d/wined3d_private.h | 21 ++++++++++++
4 files changed, 173 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c
index 4ec68013017..7d501b4b08f 100644
--- a/dlls/wined3d/adapter_vk.c
+++ b/dlls/wined3d/adapter_vk.c
@@ -555,6 +555,23 @@ static void adapter_vk_destroy_swapchain(struct wined3d_swapchain *swapchain)
heap_free(swapchain);
}
+unsigned int wined3d_adapter_vk_get_memory_type_index(const struct wined3d_adapter_vk *adapter_vk,
+ uint32_t memory_type_mask, VkMemoryPropertyFlags flags)
+{
+ const VkPhysicalDeviceMemoryProperties *memory_info = &adapter_vk->memory_properties;
+ unsigned int i;
+
+ for (i = 0; i < memory_info->memoryTypeCount; ++i)
+ {
+ if (!(memory_type_mask & (1u << i)))
+ continue;
+ if ((memory_info->memoryTypes[i].propertyFlags & flags) == flags)
+ return i;
+ }
+
+ return ~0u;
+}
+
static HRESULT adapter_vk_create_buffer(struct wined3d_device *device,
const struct wined3d_buffer_desc *desc, const struct wined3d_sub_resource_data *data,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_buffer **buffer)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index 5da6aec4fb8..4f3c28fe0b1 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -1554,6 +1554,44 @@ HRESULT wined3d_buffer_gl_init(struct wined3d_buffer_gl *buffer_gl, struct wined
return wined3d_buffer_init(&buffer_gl->b, device, desc, data, parent, parent_ops, &wined3d_buffer_gl_ops);
}
+static BOOL wined3d_buffer_vk_create_buffer_object(struct wined3d_buffer_vk *buffer_vk,
+ struct wined3d_context_vk *context_vk)
+{
+ struct wined3d_resource *resource = &buffer_vk->b.resource;
+ uint32_t bind_flags = resource->bind_flags;
+ VkMemoryPropertyFlags memory_type;
+ VkBufferUsageFlags usage;
+
+ usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT;
+ if (bind_flags & WINED3D_BIND_VERTEX_BUFFER)
+ usage |= VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
+ if (bind_flags & WINED3D_BIND_INDEX_BUFFER)
+ usage |= VK_BUFFER_USAGE_INDEX_BUFFER_BIT;
+ if (bind_flags & WINED3D_BIND_CONSTANT_BUFFER)
+ usage |= VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
+ if (bind_flags & WINED3D_BIND_SHADER_RESOURCE)
+ usage |= VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT;
+ if (bind_flags & WINED3D_BIND_UNORDERED_ACCESS)
+ usage |= VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT;
+ if (bind_flags & WINED3D_BIND_INDIRECT_BUFFER)
+ usage |= VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT;
+ if (bind_flags & (WINED3D_BIND_STREAM_OUTPUT | WINED3D_BIND_RENDER_TARGET | WINED3D_BIND_DEPTH_STENCIL))
+ FIXME("Ignoring some bind flags %#x.\n", bind_flags);
+ memory_type = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
+ | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
+ | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
+ if (!(wined3d_context_vk_create_bo(context_vk, resource->size, usage, memory_type, &buffer_vk->bo)))
+ {
+ WARN("Failed to create Vulkan buffer.\n");
+ return FALSE;
+ }
+
+ buffer_vk->b.buffer_object = (uintptr_t)&buffer_vk->bo;
+ buffer_invalidate_bo_range(&buffer_vk->b, 0, 0);
+
+ return TRUE;
+}
+
static BOOL wined3d_buffer_vk_prepare_location(struct wined3d_buffer *buffer,
struct wined3d_context *context, unsigned int location)
{
@@ -1563,8 +1601,10 @@ static BOOL wined3d_buffer_vk_prepare_location(struct wined3d_buffer *buffer,
return wined3d_resource_prepare_sysmem(&buffer->resource);
case WINED3D_LOCATION_BUFFER:
- /* The Vulkan buffer is created during resource creation. */
- return TRUE;
+ if (buffer->buffer_object)
+ return TRUE;
+
+ return wined3d_buffer_vk_create_buffer_object(wined3d_buffer_vk(buffer), wined3d_context_vk(context));
default:
FIXME("Unhandled location %s.\n", wined3d_debug_location(location));
@@ -1575,7 +1615,24 @@ static BOOL wined3d_buffer_vk_prepare_location(struct wined3d_buffer *buffer,
static void wined3d_buffer_vk_unload_location(struct wined3d_buffer *buffer,
struct wined3d_context *context, unsigned int location)
{
- FIXME("buffer %p, context %p, location %s.\n", buffer, context, wined3d_debug_location(location));
+ struct wined3d_context_vk *context_vk = wined3d_context_vk(context);
+ struct wined3d_buffer_vk *buffer_vk = wined3d_buffer_vk(buffer);
+
+ TRACE("buffer %p, context %p, location %s.\n", buffer, context, wined3d_debug_location(location));
+
+ switch (location)
+ {
+ case WINED3D_LOCATION_BUFFER:
+ wined3d_context_vk_destroy_bo(context_vk, &buffer_vk->bo);
+ buffer_vk->bo.vk_buffer = VK_NULL_HANDLE;
+ buffer_vk->bo.vk_memory = VK_NULL_HANDLE;
+ buffer_vk->b.buffer_object = 0u;
+ break;
+
+ default:
+ ERR("Unhandled location %s.\n", wined3d_debug_location(location));
+ break;
+ }
}
static void wined3d_buffer_vk_upload_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context,
@@ -1605,6 +1662,9 @@ HRESULT wined3d_buffer_vk_init(struct wined3d_buffer_vk *buffer_vk, struct wined
TRACE("buffer_vk %p, device %p, desc %p, data %p, parent %p, parent_ops %p.\n",
buffer_vk, device, desc, data, parent, parent_ops);
+ if (desc->access & WINED3D_RESOURCE_ACCESS_GPU)
+ buffer_vk->b.flags |= WINED3D_BUFFER_USE_BO;
+
return wined3d_buffer_init(&buffer_vk->b, device, desc, data, parent, parent_ops, &wined3d_buffer_vk_ops);
}
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 95769014af6..5d88d4463f9 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -1493,6 +1493,74 @@ static void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl)
wined3d_context_cleanup(&context_gl->c);
}
+BOOL wined3d_context_vk_create_bo(struct wined3d_context_vk *context_vk, VkDeviceSize size,
+ VkBufferUsageFlags usage, VkMemoryPropertyFlags memory_type, struct wined3d_bo_vk *bo)
+{
+ struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
+ const struct wined3d_vk_info *vk_info = context_vk->vk_info;
+ VkMemoryRequirements memory_requirements;
+ struct wined3d_adapter_vk *adapter_vk;
+ VkMemoryAllocateInfo allocate_info;
+ VkBufferCreateInfo create_info;
+ VkResult vr;
+
+ adapter_vk = wined3d_adapter_vk(device_vk->d.adapter);
+
+ create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
+ create_info.pNext = NULL;
+ create_info.flags = 0;
+ create_info.size = size;
+ create_info.usage = usage;
+ create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
+ create_info.queueFamilyIndexCount = 0;
+ create_info.pQueueFamilyIndices = NULL;
+
+ if ((vr = VK_CALL(vkCreateBuffer(device_vk->vk_device, &create_info, NULL, &bo->vk_buffer))) < 0)
+ {
+ ERR("Failed to create Vulkan buffer, vr %s.\n", wined3d_debug_vkresult(vr));
+ return FALSE;
+ }
+
+ VK_CALL(vkGetBufferMemoryRequirements(device_vk->vk_device, bo->vk_buffer, &memory_requirements));
+
+ allocate_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
+ allocate_info.pNext = NULL;
+ allocate_info.allocationSize = memory_requirements.size;
+ allocate_info.memoryTypeIndex = wined3d_adapter_vk_get_memory_type_index(adapter_vk,
+ memory_requirements.memoryTypeBits, memory_type);
+ if (allocate_info.memoryTypeIndex == ~0u)
+ {
+ ERR("Failed to find suitable memory type.\n");
+ VK_CALL(vkDestroyBuffer(device_vk->vk_device, bo->vk_buffer, NULL));
+ return FALSE;
+ }
+ if ((vr = VK_CALL(vkAllocateMemory(device_vk->vk_device, &allocate_info, NULL, &bo->vk_memory))) < 0)
+ {
+ ERR("Failed to allocate buffer memory, vr %s.\n", wined3d_debug_vkresult(vr));
+ VK_CALL(vkDestroyBuffer(device_vk->vk_device, bo->vk_buffer, NULL));
+ return FALSE;
+ }
+
+ if ((vr = VK_CALL(vkBindBufferMemory(device_vk->vk_device, bo->vk_buffer, bo->vk_memory, 0))) < 0)
+ {
+ ERR("Failed to bind buffer memory, vr %s.\n", wined3d_debug_vkresult(vr));
+ VK_CALL(vkFreeMemory(device_vk->vk_device, bo->vk_memory, NULL));
+ VK_CALL(vkDestroyBuffer(device_vk->vk_device, bo->vk_buffer, NULL));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+void wined3d_context_vk_destroy_bo(struct wined3d_context_vk *context_vk, const struct wined3d_bo_vk *bo)
+{
+ struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
+ const struct wined3d_vk_info *vk_info = context_vk->vk_info;
+
+ VK_CALL(vkDestroyBuffer(device_vk->vk_device, bo->vk_buffer, NULL));
+ VK_CALL(vkFreeMemory(device_vk->vk_device, bo->vk_memory, NULL));
+}
+
void wined3d_context_vk_cleanup(struct wined3d_context_vk *context_vk)
{
wined3d_context_cleanup(&context_vk->c);
@@ -2344,9 +2412,13 @@ fail:
HRESULT wined3d_context_vk_init(struct wined3d_context_vk *context_vk, struct wined3d_swapchain *swapchain)
{
+ struct wined3d_adapter_vk *adapter_vk;
+
TRACE("context_vk %p, swapchain %p.\n", context_vk, swapchain);
wined3d_context_init(&context_vk->c, swapchain);
+ adapter_vk = wined3d_adapter_vk(swapchain->device->adapter);
+ context_vk->vk_info = &adapter_vk->vk_info;
return WINED3D_OK;
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 21f17736ec7..583d970eca8 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1512,6 +1512,12 @@ do { \
#define checkGLcall(A) do {} while(0)
#endif
+struct wined3d_bo_vk
+{
+ VkBuffer vk_buffer;
+ VkDeviceMemory vk_memory;
+};
+
struct wined3d_bo_address
{
UINT_PTR buffer_object;
@@ -2155,9 +2161,20 @@ void wined3d_context_gl_update_stream_sources(struct wined3d_context_gl *context
struct wined3d_context_vk
{
struct wined3d_context c;
+
+ const struct wined3d_vk_info *vk_info;
};
+static inline struct wined3d_context_vk *wined3d_context_vk(struct wined3d_context *context)
+{
+ return CONTAINING_RECORD(context, struct wined3d_context_vk, c);
+}
+
void wined3d_context_vk_cleanup(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
+BOOL wined3d_context_vk_create_bo(struct wined3d_context_vk *context_vk, VkDeviceSize size,
+ VkBufferUsageFlags usage, VkMemoryPropertyFlags memory_type, struct wined3d_bo_vk *bo) DECLSPEC_HIDDEN;
+void wined3d_context_vk_destroy_bo(struct wined3d_context_vk *context_vk,
+ const struct wined3d_bo_vk *bo) DECLSPEC_HIDDEN;
HRESULT wined3d_context_vk_init(struct wined3d_context_vk *context_vk,
struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
@@ -2929,6 +2946,8 @@ static inline struct wined3d_adapter_vk *wined3d_adapter_vk(struct wined3d_adapt
struct wined3d_adapter *wined3d_adapter_vk_create(unsigned int ordinal,
unsigned int wined3d_creation_flags) DECLSPEC_HIDDEN;
+unsigned int wined3d_adapter_vk_get_memory_type_index(const struct wined3d_adapter_vk *adapter_vk,
+ uint32_t memory_type_mask, VkMemoryPropertyFlags flags) DECLSPEC_HIDDEN;
struct wined3d_caps_gl_ctx
{
@@ -4208,6 +4227,8 @@ HRESULT wined3d_buffer_gl_init(struct wined3d_buffer_gl *buffer_gl, struct wined
struct wined3d_buffer_vk
{
struct wined3d_buffer b;
+
+ struct wined3d_bo_vk bo;
};
static inline struct wined3d_buffer_vk *wined3d_buffer_vk(struct wined3d_buffer *buffer)
--
2.11.0
Dec. 13, 2019
[PATCH] dmloader: Use wide-char string literals
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/dmloader/loader.c | 8 ++++----
dlls/dmloader/tests/loader.c | 23 +++++++++++------------
2 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/dlls/dmloader/loader.c b/dlls/dmloader/loader.c
index a267d2d6b2..66c0f92b1b 100644
--- a/dlls/dmloader/loader.c
+++ b/dlls/dmloader/loader.c
@@ -609,7 +609,6 @@ static HRESULT WINAPI IDirectMusicLoaderImpl_SetSearchDirectory(IDirectMusicLoad
static HRESULT WINAPI IDirectMusicLoaderImpl_ScanDirectory(IDirectMusicLoader8 *iface, REFGUID rguidClass, WCHAR *pwzFileExtension, WCHAR *pwzScanFileName)
{
IDirectMusicLoaderImpl *This = impl_from_IDirectMusicLoader8(iface);
- static const WCHAR wszAny[] = {'*',0};
WIN32_FIND_DATAW FileData;
HANDLE hSearch;
WCHAR wszSearchString[MAX_PATH];
@@ -631,11 +630,12 @@ static HRESULT WINAPI IDirectMusicLoaderImpl_ScanDirectory(IDirectMusicLoader8 *
p = wszSearchString + lstrlenW(wszSearchString);
if (p > wszSearchString && p[-1] != '\\') *p++ = '\\';
*p++ = '*'; /* any file */
- if (lstrcmpW (pwzFileExtension, wszAny)) *p++ = '.'; /* if we have actual extension, put a dot */
+ if (lstrcmpW (pwzFileExtension, L"*"))
+ *p++ = '.'; /* if we have actual extension, put a dot */
lstrcpyW (p, pwzFileExtension);
-
+
TRACE(": search string: %s\n", debugstr_w(wszSearchString));
-
+
hSearch = FindFirstFileW (wszSearchString, &FileData);
if (hSearch == INVALID_HANDLE_VALUE) {
TRACE(": no files found\n");
diff --git a/dlls/dmloader/tests/loader.c b/dlls/dmloader/tests/loader.c
index 0ab2e9eaba..bd6797f135 100644
--- a/dlls/dmloader/tests/loader.c
+++ b/dlls/dmloader/tests/loader.c
@@ -48,23 +48,22 @@ static void test_directory(void)
{
IDirectMusicLoader8 *loader = NULL;
HRESULT hr;
- WCHAR con[] = {'c', 'o', 'n', 0};
WCHAR path[MAX_PATH];
- WCHAR empty[] = {0};
- WCHAR invalid_path[] = {'/', 'i', 'n', 'v', 'a', 'l', 'i', 'd', ' ', 'p', 'a', 't', 'h', 0};
hr = CoCreateInstance(&CLSID_DirectMusicLoader, NULL, CLSCTX_INPROC, &IID_IDirectMusicLoader8,
(void**)&loader);
ok(hr == S_OK, "Couldn't create Loader %#x\n", hr);
/* ScanDirectory without a previous SetSearchDirectory isn't failing */
- hr = IDirectMusicLoader_ScanDirectory(loader, &CLSID_DirectMusicContainer, con, NULL);
+ hr = IDirectMusicLoader_ScanDirectory(loader, &CLSID_DirectMusicContainer,
+ (WCHAR *)L"con", NULL);
ok(hr == S_FALSE, "ScanDirectory for \"con\" files failed with %#x\n", hr);
/* SetSearchDirectory with invalid path */
hr = IDirectMusicLoader_SetSearchDirectory(loader, &GUID_DirectMusicAllTypes, NULL, 0);
ok(hr == E_POINTER, "SetSearchDirectory failed with %#x\n", hr);
- hr = IDirectMusicLoader_SetSearchDirectory(loader, &GUID_DirectMusicAllTypes, invalid_path, 0);
+ hr = IDirectMusicLoader_SetSearchDirectory(loader, &GUID_DirectMusicAllTypes,
+ (WCHAR *)L"/invalid path", 0);
ok(hr == DMUS_E_LOADER_BADPATH, "SetSearchDirectory failed with %#x\n", hr);
/* SetSearchDirectory with the current directory */
@@ -88,7 +87,7 @@ static void test_directory(void)
IDirectMusicLoader_SetSearchDirectory(loader, NULL, path, 0); /* Crashes on Windows */
hr = IDirectMusicLoader_SetSearchDirectory(loader, &IID_IDirectMusicLoader8, path, 0);
ok(hr == S_OK, "SetSearchDirectory failed with %#x\n", hr);
- hr = IDirectMusicLoader_ScanDirectory(loader, &GUID_DirectMusicAllTypes, con, NULL);
+ hr = IDirectMusicLoader_ScanDirectory(loader, &GUID_DirectMusicAllTypes, (WCHAR *)L"con", NULL);
ok(hr == REGDB_E_CLASSNOTREG, "ScanDirectory failed, received %#x\n", hr);
/* NULL extension is not an error */
@@ -101,11 +100,12 @@ static void test_directory(void)
hr = CoCreateInstance(&CLSID_DirectMusicLoader, NULL, CLSCTX_INPROC, &IID_IDirectMusicLoader8,
(void**)&loader);
ok(hr == S_OK, "Couldn't create Loader %#x\n", hr);
- hr = IDirectMusicLoader_SetSearchDirectory(loader, &GUID_DirectMusicAllTypes, empty, 0);
+ hr = IDirectMusicLoader_SetSearchDirectory(loader, &GUID_DirectMusicAllTypes, (WCHAR *)L"", 0);
ok(hr == S_OK, "SetSearchDirectory failed with %#x\n", hr);
- hr = IDirectMusicLoader_SetSearchDirectory(loader, &GUID_DirectMusicAllTypes, empty, 0);
+ hr = IDirectMusicLoader_SetSearchDirectory(loader, &GUID_DirectMusicAllTypes, (WCHAR *)L"", 0);
ok(hr == S_FALSE, "SetSearchDirectory failed with %#x\n", hr);
- hr = IDirectMusicLoader_ScanDirectory(loader, &CLSID_DirectMusicContainer, con, NULL);
+ hr = IDirectMusicLoader_ScanDirectory(loader, &CLSID_DirectMusicContainer,
+ (WCHAR *)L"con", NULL);
ok(hr == S_FALSE, "ScanDirectory for \"con\" files failed with %#x\n", hr);
IDirectMusicLoader_Release(loader);
}
@@ -477,7 +477,6 @@ static void test_parsedescriptor(void)
DMUS_OBJECTDESC desc;
HRESULT hr;
DWORD valid;
- const WCHAR s_unam[] = {'U','N','A','M','\0'};
const FOURCC alldesc[] =
{
FOURCC_RIFF, DMUS_FOURCC_CONTAINER_FORM, DMUS_FOURCC_CATEGORY_CHUNK, FOURCC_LIST,
@@ -562,7 +561,7 @@ static void test_parsedescriptor(void)
wine_dbgstr_guid(&desc.guidClass));
ok(IsEqualGUID(&desc.guidObject, &GUID_NULL), "Got object guid %s, expected GUID_NULL\n",
wine_dbgstr_guid(&desc.guidClass));
- ok(!memcmp(desc.wszName, s_unam, sizeof(s_unam)), "Got name '%s', expected 'UNAM'\n",
+ ok(!lstrcmpW(desc.wszName, L"UNAM"), "Got name '%s', expected 'UNAM'\n",
wine_dbgstr_w(desc.wszName));
IStream_Release(stream);
@@ -596,7 +595,7 @@ static void test_parsedescriptor(void)
ok(hr == S_OK, "ParseDescriptor failed: %08x, expected S_OK\n", hr);
valid = DMUS_OBJ_OBJECT|DMUS_OBJ_CLASS|DMUS_OBJ_NAME|DMUS_OBJ_CATEGORY|DMUS_OBJ_VERSION;
ok(desc.dwValidData == valid, "Got valid data %#x, expected %#x\n", desc.dwValidData, valid);
- ok(!memcmp(desc.wszName, s_unam, sizeof(s_unam)), "Got name '%s', expected 'UNAM'\n",
+ ok(!lstrcmpW(desc.wszName, L"UNAM"), "Got name '%s', expected 'UNAM'\n",
wine_dbgstr_w(desc.wszName));
IStream_Release(stream);
--
2.23.0
Dec. 13, 2019
[PATCH] dmusic: Use wide-char string literals
by Michael Stefaniuc
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/dmusic/dmusic.c | 8 +++-----
dlls/dmusic/tests/dmusic.c | 5 ++---
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/dlls/dmusic/dmusic.c b/dlls/dmusic/dmusic.c
index cc798ce4d9..1916fb7bd9 100644
--- a/dlls/dmusic/dmusic.c
+++ b/dlls/dmusic/dmusic.c
@@ -343,20 +343,18 @@ static HRESULT WINAPI IDirectMusic8Impl_EnumMasterClock(LPDIRECTMUSIC8 iface, DW
if (!index)
{
static const GUID guid_system_clock = { 0x58d58419, 0x71b4, 0x11d1, { 0xa7, 0x4c, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12 } };
- static const WCHAR name_system_clock[] = { 'S','y','s','t','e','m',' ','C','l','o','c','k',0 };
clock_info->ctType = 0;
clock_info->guidClock = guid_system_clock;
- lstrcpyW(clock_info->wszDescription, name_system_clock);
+ lstrcpyW(clock_info->wszDescription, L"System Clock");
}
else
{
static const GUID guid_dsound_clock = { 0x58d58420, 0x71b4, 0x11d1, { 0xa7, 0x4c, 0x00, 0x00, 0xf8, 0x75, 0xac, 0x12 } };
- static const WCHAR name_dsound_clock[] = { 'D','i','r','e','c','t','S','o','u','n','d',' ','C','l','o','c','k',0 };
clock_info->ctType = 0;
clock_info->guidClock = guid_dsound_clock;
- lstrcpyW(clock_info->wszDescription, name_dsound_clock);
+ lstrcpyW(clock_info->wszDescription, L"DirectSound Clock");
}
return S_OK;
@@ -496,7 +494,7 @@ static const IDirectMusic8Vtbl DirectMusic8_Vtbl = {
static void create_system_ports_list(IDirectMusic8Impl* object)
{
- static const WCHAR emulated[] = {' ','[','E','m','u','l','a','t','e','d',']',0};
+ static const WCHAR emulated[] = L" [Emulated]";
port_info * port;
ULONG nb_ports;
ULONG nb_midi_out;
diff --git a/dlls/dmusic/tests/dmusic.c b/dlls/dmusic/tests/dmusic.c
index f6c417af30..776f9d0ec9 100644
--- a/dlls/dmusic/tests/dmusic.c
+++ b/dlls/dmusic/tests/dmusic.c
@@ -639,7 +639,6 @@ static void test_parsedescriptor(void)
IStream *stream;
DMUS_OBJECTDESC desc = {0};
HRESULT hr;
- const WCHAR s_inam[] = {'I','N','A','M','\0'};
const FOURCC alldesc[] =
{
FOURCC_RIFF, FOURCC_DLS, DMUS_FOURCC_CATEGORY_CHUNK, FOURCC_LIST,
@@ -735,7 +734,7 @@ static void test_parsedescriptor(void)
ok(hr == S_OK, "ParseDescriptor failed: %08x, expected S_OK\n", hr);
ok(desc.dwValidData == (DMUS_OBJ_CLASS | DMUS_OBJ_NAME),
"Got valid data %#x, expected DMUS_OBJ_CLASS | DMUS_OBJ_NAME\n", desc.dwValidData);
- ok(!memcmp(desc.wszName, s_inam, sizeof(s_inam)), "Got name '%s', expected 'INAM'\n",
+ ok(!lstrcmpW(desc.wszName, L"INAM"), "Got name '%s', expected 'INAM'\n",
wine_dbgstr_w(desc.wszName));
IStream_Release(stream);
@@ -747,7 +746,7 @@ static void test_parsedescriptor(void)
ok(desc.dwValidData == (DMUS_OBJ_CLASS | DMUS_OBJ_NAME | DMUS_OBJ_VERSION),
"Got valid data %#x, expected DMUS_OBJ_CLASS | DMUS_OBJ_NAME | DMUS_OBJ_VERSION\n",
desc.dwValidData);
- ok(!memcmp(desc.wszName, s_inam, sizeof(s_inam)), "Got name '%s', expected 'INAM'\n",
+ ok(!lstrcmpW(desc.wszName, L"INAM"), "Got name '%s', expected 'INAM'\n",
wine_dbgstr_w(desc.wszName));
IStream_Release(stream);
--
2.23.0
Dec. 13, 2019
Re: win32 on macOS
by Fabian Maurer
Hello Thomas,
very interesting stuff, thanks for the insights! I didn't know Apple actually
has support for 32Bit code segments, let's hope they keep that in.
Regards,
Fabian Maurer
Dec. 13, 2019
[PATCH 2/2] winemac.drv: Support VK_EXT_metal_surface.
by Chip Davis
Prefer it to VK_MVK_macos_surface when present.
MoltenVK has deprecated VK_MVK_macos_surface in favor of
VK_EXT_metal_surface. It's likely that this extension will vanish at
some point.
Signed-off-by: Chip Davis <cdavis(a)codeweavers.com>
---
dlls/winemac.drv/vulkan.c | 66 +++++++++++++++++++++++++++++++++------
1 file changed, 57 insertions(+), 9 deletions(-)
diff --git a/dlls/winemac.drv/vulkan.c b/dlls/winemac.drv/vulkan.c
index 21e93827c15..60f3dcda6af 100644
--- a/dlls/winemac.drv/vulkan.c
+++ b/dlls/winemac.drv/vulkan.c
@@ -50,6 +50,9 @@ WINE_DECLARE_DEBUG_CHANNEL(fps);
typedef VkFlags VkMacOSSurfaceCreateFlagsMVK;
#define VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK 1000123000
+typedef VkFlags VkMetalSurfaceCreateFlagsEXT;
+#define VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT 1000217000
+
struct wine_vk_surface
{
macdrv_metal_device device;
@@ -65,9 +68,18 @@ typedef struct VkMacOSSurfaceCreateInfoMVK
const void *pView; /* NSView */
} VkMacOSSurfaceCreateInfoMVK;
+typedef struct VkMetalSurfaceCreateInfoEXT
+{
+ VkStructureType sType;
+ const void *pNext;
+ VkMetalSurfaceCreateFlagsEXT flags;
+ const void *pLayer; /* CAMetalLayer */
+} VkMetalSurfaceCreateInfoEXT;
+
static VkResult (*pvkCreateInstance)(const VkInstanceCreateInfo *, const VkAllocationCallbacks *, VkInstance *);
static VkResult (*pvkCreateSwapchainKHR)(VkDevice, const VkSwapchainCreateInfoKHR *, const VkAllocationCallbacks *, VkSwapchainKHR *);
static VkResult (*pvkCreateMacOSSurfaceMVK)(VkInstance, const VkMacOSSurfaceCreateInfoMVK*, const VkAllocationCallbacks *, VkSurfaceKHR *);
+static VkResult (*pvkCreateMetalSurfaceEXT)(VkInstance, const VkMetalSurfaceCreateInfoEXT*, const VkAllocationCallbacks *, VkSurfaceKHR *);
static void (*pvkDestroyInstance)(VkInstance, const VkAllocationCallbacks *);
static void (*pvkDestroySurfaceKHR)(VkInstance, VkSurfaceKHR, const VkAllocationCallbacks *);
static void (*pvkDestroySwapchainKHR)(VkDevice, VkSwapchainKHR, const VkAllocationCallbacks *);
@@ -103,6 +115,7 @@ static BOOL WINAPI wine_vk_init(INIT_ONCE *once, void *param, void **context)
LOAD_FUNCPTR(vkCreateInstance)
LOAD_FUNCPTR(vkCreateSwapchainKHR)
LOAD_FUNCPTR(vkCreateMacOSSurfaceMVK)
+ LOAD_FUNCPTR(vkCreateMetalSurfaceEXT)
LOAD_FUNCPTR(vkDestroyInstance)
LOAD_FUNCPTR(vkDestroySurfaceKHR)
LOAD_FUNCPTR(vkDestroySwapchainKHR)
@@ -159,7 +172,7 @@ static VkResult wine_vk_instance_convert_create_info(const VkInstanceCreateInfo
*/
if (!strcmp(src->ppEnabledExtensionNames[i], "VK_KHR_win32_surface"))
{
- enabled_extensions[i] = "VK_MVK_macos_surface";
+ enabled_extensions[i] = pvkCreateMetalSurfaceEXT ? "VK_EXT_metal_surface" : "VK_MVK_macos_surface";
}
else
{
@@ -239,7 +252,6 @@ static VkResult macdrv_vkCreateWin32SurfaceKHR(VkInstance instance,
const VkAllocationCallbacks *allocator, VkSurfaceKHR *surface)
{
VkResult res;
- VkMacOSSurfaceCreateInfoMVK create_info_host;
struct wine_vk_surface *mac_surface;
struct macdrv_win_data *data;
@@ -279,12 +291,26 @@ static VkResult macdrv_vkCreateWin32SurfaceKHR(VkInstance instance,
goto err;
}
- create_info_host.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
- create_info_host.pNext = NULL;
- create_info_host.flags = 0; /* reserved */
- create_info_host.pView = macdrv_view_get_metal_layer(mac_surface->view);
+ if (pvkCreateMetalSurfaceEXT)
+ {
+ VkMetalSurfaceCreateInfoEXT create_info_host;
+ create_info_host.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT;
+ create_info_host.pNext = NULL;
+ create_info_host.flags = 0; /* reserved */
+ create_info_host.pLayer = macdrv_view_get_metal_layer(mac_surface->view);
- res = pvkCreateMacOSSurfaceMVK(instance, &create_info_host, NULL /* allocator */, &mac_surface->surface);
+ res = pvkCreateMetalSurfaceEXT(instance, &create_info_host, NULL /* allocator */, &mac_surface->surface);
+ }
+ else
+ {
+ VkMacOSSurfaceCreateInfoMVK create_info_host;
+ create_info_host.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
+ create_info_host.pNext = NULL;
+ create_info_host.flags = 0; /* reserved */
+ create_info_host.pView = macdrv_view_get_metal_layer(mac_surface->view);
+
+ res = pvkCreateMacOSSurfaceMVK(instance, &create_info_host, NULL /* allocator */, &mac_surface->surface);
+ }
if (res != VK_SUCCESS)
{
ERR("Failed to create MoltenVK surface, res=%d\n", res);
@@ -341,7 +367,7 @@ static void macdrv_vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapcha
static VkResult macdrv_vkEnumerateInstanceExtensionProperties(const char *layer_name,
uint32_t *count, VkExtensionProperties* properties)
{
- unsigned int i;
+ unsigned int i, mvk_surface = -1, ext_surface = -1;
VkResult res;
TRACE("layer_name %s, count %p, properties %p\n", debugstr_a(layer_name), count, properties);
@@ -364,14 +390,36 @@ static VkResult macdrv_vkEnumerateInstanceExtensionProperties(const char *layer_
for (i = 0; i < *count; i++)
{
- /* For now the only MoltenVK extension we need to fixup. Long-term we may need an array. */
+ /* For now the only MoltenVK extensions we need to fixup. Long-term we may need an array. */
if (!strcmp(properties[i].extensionName, "VK_MVK_macos_surface"))
{
+ if (ext_surface != -1)
+ {
+ /* If we've already seen EXT_metal_surface, just hide this one. */
+ memcpy(properties + i, properties + i + 1, (--(*count) - i) * sizeof(VkExtensionProperties));
+ continue;
+ }
TRACE("Substituting VK_MVK_macos_surface for VK_KHR_win32_surface\n");
snprintf(properties[i].extensionName, sizeof(properties[i].extensionName),
VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
properties[i].specVersion = VK_KHR_WIN32_SURFACE_SPEC_VERSION;
+ mvk_surface = i;
+ }
+ if (!strcmp(properties[i].extensionName, "VK_EXT_metal_surface"))
+ {
+ if (mvk_surface != -1)
+ {
+ /* If we've already seen MVK_macos_surface, just hide this one. */
+ memcpy(properties + i, properties + i + 1, (--(*count) - i) * sizeof(VkExtensionProperties));
+ continue;
+ }
+ TRACE("Substituting VK_EXT_metal_surface for VK_KHR_win32_surface\n");
+
+ snprintf(properties[i].extensionName, sizeof(properties[i].extensionName),
+ VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
+ properties[i].specVersion = VK_KHR_WIN32_SURFACE_SPEC_VERSION;
+ ext_surface = i;
}
}
--
2.24.0
Dec. 13, 2019