Wine-devel
Threads by month
- ----- 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
June 2018
- 68 participants
- 583 discussions
26 Jun '18
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
---
dlls/shlwapi/tests/assoc.c | 8 +++---
dlls/shlwapi/tests/clist.c | 6 ++---
dlls/shlwapi/tests/istream.c | 6 ++---
dlls/shlwapi/tests/ordinal.c | 56 +++++++++++++++++++--------------------
dlls/shlwapi/tests/path.c | 20 +++++++-------
dlls/shlwapi/tests/string.c | 62 ++++++++++++++++++++++----------------------
dlls/shlwapi/tests/url.c | 42 +++++++++++++++---------------
7 files changed, 99 insertions(+), 101 deletions(-)
diff --git a/dlls/shlwapi/tests/assoc.c b/dlls/shlwapi/tests/assoc.c
index 266f3fd44a..4b461128dc 100644
--- a/dlls/shlwapi/tests/assoc.c
+++ b/dlls/shlwapi/tests/assoc.c
@@ -62,7 +62,7 @@ static void test_getstring_bad(void)
"Unexpected result : %08x\n", hr);
ok(len == 0xdeadbeef, "got %u\n", len);
- len = sizeof(buf)/sizeof(buf[0]);
+ len = ARRAY_SIZE(buf);
hr = pAssocQueryStringW(0, ASSOCSTR_EXECUTABLE, dotBad, open, buf, &len);
ok(hr == E_FAIL ||
hr == HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION) /* Win9x/WinMe/NT4/W2K/Vista/W2K8 */ ||
@@ -70,8 +70,8 @@ static void test_getstring_bad(void)
"Unexpected result : %08x\n", hr);
if (hr == S_OK)
{
- ok(len < sizeof(buf)/sizeof(buf[0]), "got %u\n", len);
- ok(!lstrcmpiW(buf + len - sizeof(openwith)/sizeof(openwith[0]), openwith), "wrong data\n");
+ ok(len < ARRAY_SIZE(buf), "got %u\n", len);
+ ok(!lstrcmpiW(buf + len - ARRAY_SIZE(openwith), openwith), "wrong data\n");
}
len = 0xdeadbeef;
@@ -105,7 +105,7 @@ static void test_getstring_bad(void)
hr == HRESULT_FROM_WIN32(ERROR_NOT_FOUND) /* Win8 */ ||
hr == S_FALSE, /* Win10 */
"Unexpected result : %08x\n", hr);
- ok((hr == S_FALSE && len < sizeof(buf)/sizeof(buf[0])) || len == 0xdeadbeef,
+ ok((hr == S_FALSE && len < ARRAY_SIZE(buf)) || len == 0xdeadbeef,
"got hr=%08x and len=%u\n", hr, len);
len = 0xdeadbeef;
diff --git a/dlls/shlwapi/tests/clist.c b/dlls/shlwapi/tests/clist.c
index b930470806..0adb0d47c0 100644
--- a/dlls/shlwapi/tests/clist.c
+++ b/dlls/shlwapi/tests/clist.c
@@ -362,8 +362,7 @@ static void test_CList(void)
if (hRet == S_OK)
{
/* 1 call for each element, + 1 for OK (use our null element for this) */
- ok(streamobj.writecalls == sizeof(SHLWAPI_CLIST_items)/sizeof(SHLWAPI_CLIST),
- "wrong call count\n");
+ ok(streamobj.writecalls == ARRAY_SIZE(SHLWAPI_CLIST_items), "wrong call count\n");
ok(streamobj.readcalls == 0,"called Read() in write\n");
ok(streamobj.seekcalls == 0,"called Seek() in write\n");
}
@@ -433,8 +432,7 @@ static void test_CList(void)
{
ok(streamobj.readbeyondend == FALSE, "read beyond end\n");
/* 2 calls per item, but only 1 for the terminator */
- ok(streamobj.readcalls == sizeof(SHLWAPI_CLIST_items)/sizeof(SHLWAPI_CLIST)*2-1,
- "wrong call count\n");
+ ok(streamobj.readcalls == ARRAY_SIZE(SHLWAPI_CLIST_items) * 2 - 1, "wrong call count\n");
ok(streamobj.writecalls == 0, "called Write() from create\n");
ok(streamobj.seekcalls == 0,"called Seek() from create\n");
diff --git a/dlls/shlwapi/tests/istream.c b/dlls/shlwapi/tests/istream.c
index 926f2f8157..300e9b9c00 100644
--- a/dlls/shlwapi/tests/istream.c
+++ b/dlls/shlwapi/tests/istream.c
@@ -726,12 +726,12 @@ START_TEST(istream)
int i, j, k;
- for (i = 0; i != sizeof(stgm_access)/sizeof(stgm_access[0]); i++) {
- for (j = 0; j != sizeof(stgm_sharing)/sizeof(stgm_sharing[0]); j ++) {
+ for (i = 0; i != ARRAY_SIZE(stgm_access); i++) {
+ for (j = 0; j != ARRAY_SIZE(stgm_sharing); j ++) {
test_SHCreateStreamOnFileA(stgm_access[i], stgm_sharing[j]);
test_SHCreateStreamOnFileW(stgm_access[i], stgm_sharing[j]);
- for (k = 0; k != sizeof(stgm_flags)/sizeof(stgm_flags[0]); k++)
+ for (k = 0; k != ARRAY_SIZE(stgm_flags); k++)
test_SHCreateStreamOnFileEx(stgm_access[i], stgm_sharing[j] | stgm_flags[k]);
}
}
diff --git a/dlls/shlwapi/tests/ordinal.c b/dlls/shlwapi/tests/ordinal.c
index db59e625f8..97e4606443 100644
--- a/dlls/shlwapi/tests/ordinal.c
+++ b/dlls/shlwapi/tests/ordinal.c
@@ -1862,14 +1862,14 @@ if (0)
/* all combinations documented as invalid succeeded */
flags = FDTF_SHORTTIME | FDTF_LONGTIME;
SetLastError(0xdeadbeef);
- ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
+ ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
flags = FDTF_SHORTDATE | FDTF_LONGDATE;
SetLastError(0xdeadbeef);
- ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
+ ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %d\n", GetLastError());
@@ -1877,7 +1877,7 @@ if (0)
flags = FDTF_SHORTDATE | FDTF_LTRDATE | FDTF_RTLDATE;
SetLastError(0xdeadbeef);
buff[0] = 0; /* NT4 doesn't clear the buffer on failure */
- ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
+ ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
ok(GetLastError() == 0xdeadbeef,
@@ -1885,67 +1885,67 @@ if (0)
/* now check returned strings */
flags = FDTF_SHORTTIME;
- ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
+ ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
SetLastError(0xdeadbeef);
- ret = GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, buff2, sizeof(buff2)/sizeof(WCHAR));
+ ret = GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, buff2, ARRAY_SIZE(buff2));
ok(ret == lstrlenW(buff2)+1, "expected %d, got %d\n", lstrlenW(buff2)+1, ret);
ok(lstrcmpW(buff, buff2) == 0, "expected equal strings\n");
flags = FDTF_LONGTIME;
- ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
+ ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
- ret = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, buff2, sizeof(buff2)/sizeof(WCHAR));
+ ret = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, buff2, ARRAY_SIZE(buff2));
ok(ret == lstrlenW(buff2)+1, "expected %d, got %d\n", lstrlenW(buff2)+1, ret);
ok(lstrcmpW(buff, buff2) == 0, "expected equal strings\n");
/* both time flags */
flags = FDTF_LONGTIME | FDTF_SHORTTIME;
- ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
+ ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
- ret = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, buff2, sizeof(buff2)/sizeof(WCHAR));
+ ret = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, buff2, ARRAY_SIZE(buff2));
ok(ret == lstrlenW(buff2)+1, "expected %d, got %d\n", lstrlenW(buff2)+1, ret);
ok(lstrcmpW(buff, buff2) == 0, "expected equal string\n");
flags = FDTF_SHORTDATE;
- ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
+ ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
- ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, buff2, sizeof(buff2)/sizeof(WCHAR));
+ ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, buff2, ARRAY_SIZE(buff2));
ok(ret == lstrlenW(buff2)+1, "expected %d, got %d\n", lstrlenW(buff2)+1, ret);
ok(lstrcmpW(buff, buff2) == 0, "expected equal strings\n");
flags = FDTF_LONGDATE;
- ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
+ ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
- ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, sizeof(buff2)/sizeof(WCHAR));
+ ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, ARRAY_SIZE(buff2));
ok(ret == lstrlenW(buff2)+1, "expected %d, got %d\n", lstrlenW(buff2)+1, ret);
ok(lstrcmpW(buff, buff2) == 0, "expected equal strings\n");
/* both date flags */
flags = FDTF_LONGDATE | FDTF_SHORTDATE;
- ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
+ ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
- ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, sizeof(buff2)/sizeof(WCHAR));
+ ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, ARRAY_SIZE(buff2));
ok(ret == lstrlenW(buff2)+1, "expected %d, got %d\n", lstrlenW(buff2)+1, ret);
ok(lstrcmpW(buff, buff2) == 0, "expected equal strings\n");
/* various combinations of date/time flags */
flags = FDTF_LONGDATE | FDTF_SHORTTIME;
- ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
+ ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
- ret = GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, buff3, sizeof(buff3)/sizeof(WCHAR));
+ ret = GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, buff3, ARRAY_SIZE(buff3));
ok(ret == lstrlenW(buff3)+1, "expected %d, got %d\n", lstrlenW(buff3)+1, ret);
ok(lstrcmpW(buff3, buff + lstrlenW(buff) - lstrlenW(buff3)) == 0,
"expected (%s), got (%s) for time part\n",
wine_dbgstr_w(buff3), wine_dbgstr_w(buff + lstrlenW(buff) - lstrlenW(buff3)));
- ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, sizeof(buff2)/sizeof(WCHAR));
+ ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, ARRAY_SIZE(buff2));
ok(ret == lstrlenW(buff2)+1, "expected %d, got %d\n", lstrlenW(buff2)+1, ret);
p1 = buff;
p2 = buff2;
@@ -1963,15 +1963,15 @@ if (0)
wine_dbgstr_w(buff2), wine_dbgstr_w(buff));
flags = FDTF_LONGDATE | FDTF_LONGTIME;
- ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
+ ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
- ret = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, buff3, sizeof(buff3)/sizeof(WCHAR));
+ ret = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, buff3, ARRAY_SIZE(buff3));
ok(ret == lstrlenW(buff3)+1, "expected %d, got %d\n", lstrlenW(buff3)+1, ret);
ok(lstrcmpW(buff3, buff + lstrlenW(buff) - lstrlenW(buff3)) == 0,
"expected (%s), got (%s) for time part\n",
wine_dbgstr_w(buff3), wine_dbgstr_w(buff + lstrlenW(buff) - lstrlenW(buff3)));
- ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, sizeof(buff2)/sizeof(WCHAR));
+ ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, buff2, ARRAY_SIZE(buff2));
ok(ret == lstrlenW(buff2)+1, "expected %d, got %d\n", lstrlenW(buff2)+1, ret);
p1 = buff;
p2 = buff2;
@@ -1989,25 +1989,25 @@ if (0)
wine_dbgstr_w(buff2), wine_dbgstr_w(buff));
flags = FDTF_SHORTDATE | FDTF_SHORTTIME;
- ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
+ ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
- ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, buff2, sizeof(buff2)/sizeof(WCHAR));
+ ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, buff2, ARRAY_SIZE(buff2));
ok(ret == lstrlenW(buff2)+1, "expected %d, got %d\n", lstrlenW(buff2)+1, ret);
lstrcatW(buff2, spaceW);
- ret = GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, buff3, sizeof(buff3)/sizeof(WCHAR));
+ ret = GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, buff3, ARRAY_SIZE(buff3));
ok(ret == lstrlenW(buff3)+1, "expected %d, got %d\n", lstrlenW(buff3)+1, ret);
lstrcatW(buff2, buff3);
ok(lstrcmpW(buff, buff2) == 0, "expected equal strings\n");
flags = FDTF_SHORTDATE | FDTF_LONGTIME;
- ret = pSHFormatDateTimeW(&filetime, &flags, buff, sizeof(buff)/sizeof(WCHAR));
+ ret = pSHFormatDateTimeW(&filetime, &flags, buff, ARRAY_SIZE(buff));
ok(ret == lstrlenW(buff)+1 || ret == lstrlenW(buff),
"expected %d or %d, got %d\n", lstrlenW(buff)+1, lstrlenW(buff), ret);
- ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, buff2, sizeof(buff2)/sizeof(WCHAR));
+ ret = GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, buff2, ARRAY_SIZE(buff2));
ok(ret == lstrlenW(buff2)+1, "expected %d, got %d\n", lstrlenW(buff2)+1, ret);
lstrcatW(buff2, spaceW);
- ret = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, buff3, sizeof(buff3)/sizeof(WCHAR));
+ ret = GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, buff3, ARRAY_SIZE(buff3));
ok(ret == lstrlenW(buff3)+1, "expected %d, got %d\n", lstrlenW(buff3)+1, ret);
lstrcatW(buff2, buff3);
ok(lstrcmpW(buff, buff2) == 0, "expected equal strings\n");
@@ -2068,7 +2068,7 @@ static void test_SHGetObjectCompatFlags(void)
{
int j;
- for (j = 0; j < sizeof(values)/sizeof(struct compat_value); j++)
+ for (j = 0; j < ARRAY_SIZE(values); j++)
if (lstrcmpA(values[j].nameA, valueA) == 0)
{
expected |= values[j].value;
diff --git a/dlls/shlwapi/tests/path.c b/dlls/shlwapi/tests/path.c
index 91c66b7ef3..d25620b3d5 100644
--- a/dlls/shlwapi/tests/path.c
+++ b/dlls/shlwapi/tests/path.c
@@ -283,7 +283,7 @@ static void test_PathCreateFromUrl(void)
ok(len == 0xdeca, "got %x expected 0xdeca\n", len);
/* Test the decoding itself */
- for(i = 0; i < sizeof(TEST_PATHFROMURL) / sizeof(TEST_PATHFROMURL[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(TEST_PATHFROMURL); i++) {
len = INTERNET_MAX_URL_LENGTH;
ret = pPathCreateFromUrlA(TEST_PATHFROMURL[i].url, ret_path, &len, 0);
todo_wine_if (TEST_PATHFROMURL[i].todo & 0x1)
@@ -350,7 +350,7 @@ static void test_PathIsUrl(void)
size_t i;
BOOL ret;
- for(i = 0; i < sizeof(TEST_PATH_IS_URL)/sizeof(TEST_PATH_IS_URL[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(TEST_PATH_IS_URL); i++) {
ret = PathIsURLA(TEST_PATH_IS_URL[i].path);
ok(ret == TEST_PATH_IS_URL[i].expect,
"returned %d from path %s, expected %d\n", ret, TEST_PATH_IS_URL[i].path,
@@ -1403,7 +1403,7 @@ static void test_PathCommonPrefixA(void)
static void test_PathUnquoteSpaces(void)
{
int i;
- for(i = 0; i < sizeof(TEST_PATH_UNQUOTE_SPACES) / sizeof(TEST_PATH_UNQUOTE_SPACES[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(TEST_PATH_UNQUOTE_SPACES); i++)
{
char *path = strdupA(TEST_PATH_UNQUOTE_SPACES[i].path);
WCHAR *pathW = GetWideString(TEST_PATH_UNQUOTE_SPACES[i].path);
@@ -1484,10 +1484,10 @@ static void test_PathUnExpandEnvStrings(void)
ret = pPathUnExpandEnvStringsA(envvarA, buff, sizeof(buff));
ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, GetLastError());
- ret = GetEnvironmentVariableW(computernameW, envvarW, sizeof(envvarW)/sizeof(WCHAR));
+ ret = GetEnvironmentVariableW(computernameW, envvarW, ARRAY_SIZE(envvarW));
ok(ret, "got %d\n", ret);
SetLastError(0xdeadbeef);
- ret = pPathUnExpandEnvStringsW(envvarW, buffW, sizeof(buffW)/sizeof(WCHAR));
+ ret = pPathUnExpandEnvStringsW(envvarW, buffW, ARRAY_SIZE(buffW));
ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, GetLastError());
/* something that can't be represented with env var */
@@ -1559,7 +1559,7 @@ static void test_PathUnExpandEnvStrings(void)
lstrcpyW(pathW, nonpathW);
buffW[0] = 'x'; buffW[1] = 0;
SetLastError(0xdeadbeef);
- ret = pPathUnExpandEnvStringsW(pathW, buffW, sizeof(buffW)/sizeof(WCHAR));
+ ret = pPathUnExpandEnvStringsW(pathW, buffW, ARRAY_SIZE(buffW));
ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, GetLastError());
ok(buffW[0] == 'x', "wrong return string %s\n", wine_dbgstr_w(buffW));
@@ -1580,13 +1580,13 @@ static void test_PathUnExpandEnvStrings(void)
/* buffer size is enough to hold variable name only */
buffW[0] = 'x'; buffW[1] = 0;
SetLastError(0xdeadbeef);
- ret = pPathUnExpandEnvStringsW(pathW, buffW, sizeof(sysrootW)/sizeof(WCHAR));
+ ret = pPathUnExpandEnvStringsW(pathW, buffW, ARRAY_SIZE(sysrootW));
ok(!ret && GetLastError() == 0xdeadbeef, "got %d, error %d\n", ret, GetLastError());
ok(buffW[0] == 'x', "wrong return string %s\n", wine_dbgstr_w(buffW));
/* enough size */
buffW[0] = 0;
- ret = pPathUnExpandEnvStringsW(pathW, buffW, sizeof(buffW)/sizeof(WCHAR));
+ ret = pPathUnExpandEnvStringsW(pathW, buffW, ARRAY_SIZE(buffW));
ok(ret, "got %d\n", ret);
ok(!memcmp(buffW, sysrootW, sizeof(sysrootW) - sizeof(WCHAR)), "wrong return string %s\n", wine_dbgstr_w(buffW));
@@ -1626,7 +1626,7 @@ static void test_PathIsRelativeA(void)
return;
}
- num = sizeof(test_path_is_relative) / sizeof(test_path_is_relative[0]);
+ num = ARRAY_SIZE(test_path_is_relative);
for (i = 0; i < num; i++) {
ret = pPathIsRelativeA(test_path_is_relative[i].path);
ok(ret == test_path_is_relative[i].expect,
@@ -1646,7 +1646,7 @@ static void test_PathIsRelativeW(void)
return;
}
- num = sizeof(test_path_is_relative) / sizeof(test_path_is_relative[0]);
+ num = ARRAY_SIZE(test_path_is_relative);
for (i = 0; i < num; i++) {
path = GetWideString(test_path_is_relative[i].path);
diff --git a/dlls/shlwapi/tests/string.c b/dlls/shlwapi/tests/string.c
index 7f069a4849..c7a2f5d346 100644
--- a/dlls/shlwapi/tests/string.c
+++ b/dlls/shlwapi/tests/string.c
@@ -412,7 +412,7 @@ static void test_StrCpyW(void)
while(result->value)
{
- MultiByteToWideChar(CP_ACP,0,result->byte_size_64,-1,szSrc,sizeof(szSrc)/sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, result->byte_size_64, -1, szSrc, ARRAY_SIZE(szSrc));
lpRes = StrCpyW(szBuff, szSrc);
ok(!StrCmpW(szSrc, szBuff) && lpRes == szBuff, "Copied string %s wrong\n", result->byte_size_64);
@@ -476,7 +476,7 @@ static void test_StrToIntW(void)
while (result->string)
{
- MultiByteToWideChar(CP_ACP,0,result->string,-1,szBuff,sizeof(szBuff)/sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, result->string, -1, szBuff, ARRAY_SIZE(szBuff));
return_val = StrToIntW(szBuff);
ok(return_val == result->str_to_int, "converted '%s' wrong (%d)\n",
result->string, return_val);
@@ -526,7 +526,7 @@ static void test_StrToIntExW(void)
while (result->string)
{
return_val = -1;
- MultiByteToWideChar(CP_ACP,0,result->string,-1,szBuff,sizeof(szBuff)/sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, result->string, -1, szBuff, ARRAY_SIZE(szBuff));
bRet = StrToIntExW(szBuff, 0, &return_val);
ok(!bRet || return_val != -1, "No result returned from '%s'\n",
result->string);
@@ -540,7 +540,7 @@ static void test_StrToIntExW(void)
while (result->string)
{
return_val = -1;
- MultiByteToWideChar(CP_ACP,0,result->string,-1,szBuff,sizeof(szBuff)/sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, result->string, -1, szBuff, ARRAY_SIZE(szBuff));
bRet = StrToIntExW(szBuff, STIF_SUPPORT_HEX, &return_val);
ok(!bRet || return_val != -1, "No result returned from '%s'\n",
result->string);
@@ -605,7 +605,7 @@ static void test_StrToInt64ExW(void)
while (result->string)
{
return_val = -1;
- MultiByteToWideChar(CP_ACP,0,result->string,-1,szBuff,sizeof(szBuff)/sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, result->string, -1, szBuff, ARRAY_SIZE(szBuff));
bRet = pStrToInt64ExW(szBuff, 0, &return_val);
ok(!bRet || return_val != -1, "No result returned from '%s'\n",
result->string);
@@ -619,7 +619,7 @@ static void test_StrToInt64ExW(void)
while (result->string)
{
return_val = -1;
- MultiByteToWideChar(CP_ACP,0,result->string,-1,szBuff,sizeof(szBuff)/sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, result->string, -1, szBuff, ARRAY_SIZE(szBuff));
bRet = pStrToInt64ExW(szBuff, STIF_SUPPORT_HEX, &return_val);
ok(!bRet || return_val != -1, "No result returned from '%s'\n",
result->string);
@@ -865,7 +865,7 @@ static void test_StrCpyNXA(void)
}
memset(dest, '\n', sizeof(dest));
- lpszRes = pStrCpyNXA(dest, lpSrc, sizeof(dest)/sizeof(dest[0]));
+ lpszRes = pStrCpyNXA(dest, lpSrc, ARRAY_SIZE(dest));
ok(lpszRes == dest + 5 && !memcmp(dest, "hello\0\n\n", sizeof(dest)),
"StrCpyNXA: expected %p, \"hello\\0\\n\\n\", got %p, \"%d,%d,%d,%d,%d,%d,%d,%d\"\n",
dest + 5, lpszRes, dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
@@ -886,7 +886,7 @@ static void test_StrCpyNXW(void)
}
memcpy(dest, lpInit, sizeof(lpInit));
- lpszRes = pStrCpyNXW(dest, lpSrc, sizeof(dest)/sizeof(dest[0]));
+ lpszRes = pStrCpyNXW(dest, lpSrc, ARRAY_SIZE(dest));
ok(lpszRes == dest + 5 && !memcmp(dest, lpRes, sizeof(dest)),
"StrCpyNXW: expected %p, \"hello\\0\\n\\n\", got %p, \"%d,%d,%d,%d,%d,%d,%d,%d\"\n",
dest + 5, lpszRes, dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
@@ -949,7 +949,7 @@ static void test_SHAnsiToAnsi(void)
}
memset(dest, '\n', sizeof(dest));
- dwRet = pSHAnsiToAnsi("hello", dest, sizeof(dest)/sizeof(dest[0]));
+ dwRet = pSHAnsiToAnsi("hello", dest, ARRAY_SIZE(dest));
ok(dwRet == 6 && !memcmp(dest, "hello\0\n\n", sizeof(dest)),
"SHAnsiToAnsi: expected 6, \"hello\\0\\n\\n\", got %d, \"%d,%d,%d,%d,%d,%d,%d,%d\"\n",
dwRet, dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
@@ -976,7 +976,7 @@ static void test_SHUnicodeToUnicode(void)
}
memcpy(dest, lpInit, sizeof(lpInit));
- dwRet = pSHUnicodeToUnicode(lpSrc, dest, sizeof(dest)/sizeof(dest[0]));
+ dwRet = pSHUnicodeToUnicode(lpSrc, dest, ARRAY_SIZE(dest));
ok(dwRet == 6 && !memcmp(dest, lpRes, sizeof(dest)),
"SHUnicodeToUnicode: expected 6, \"hello\\0\\n\\n\", got %d, \"%d,%d,%d,%d,%d,%d,%d,%d\"\n",
dwRet, dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
@@ -1158,7 +1158,7 @@ static void test_StrStrA(void)
ret = StrStrA("", "");
ok(!ret, "Expected StrStrA to return NULL, got %p\n", ret);
- for (i = 0; i < sizeof(StrStrA_cases)/sizeof(StrStrA_cases[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(StrStrA_cases); i++)
{
ret = StrStrA(deadbeefA, StrStrA_cases[i].search);
ok(ret == StrStrA_cases[i].expect,
@@ -1212,7 +1212,7 @@ static void test_StrStrW(void)
ret = StrStrW(emptyW, emptyW);
ok(!ret, "Expected StrStrW to return NULL, got %p\n", ret);
- for (i = 0; i < sizeof(StrStrW_cases)/sizeof(StrStrW_cases[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(StrStrW_cases); i++)
{
ret = StrStrW(deadbeefW, StrStrW_cases[i].search);
ok(ret == StrStrW_cases[i].expect,
@@ -1260,7 +1260,7 @@ static void test_StrStrIA(void)
ret = StrStrIA("", "");
ok(!ret, "Expected StrStrIA to return NULL, got %p\n", ret);
- for (i = 0; i < sizeof(StrStrIA_cases)/sizeof(StrStrIA_cases[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(StrStrIA_cases); i++)
{
ret = StrStrIA(deadbeefA, StrStrIA_cases[i].search);
ok(ret == StrStrIA_cases[i].expect,
@@ -1316,7 +1316,7 @@ static void test_StrStrIW(void)
ret = StrStrIW(emptyW, emptyW);
ok(!ret, "Expected StrStrIW to return NULL, got %p\n", ret);
- for (i = 0; i < sizeof(StrStrIW_cases)/sizeof(StrStrIW_cases[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(StrStrIW_cases); i++)
{
ret = StrStrIW(deadbeefW, StrStrIW_cases[i].search);
ok(ret == StrStrIW_cases[i].expect,
@@ -1343,13 +1343,13 @@ static void test_StrStrNW(void)
const WCHAR *expect;
} StrStrNW_cases[] =
{
- {emptyW, sizeof(deadbeefW)/sizeof(WCHAR), NULL},
- {deadW, sizeof(deadbeefW)/sizeof(WCHAR), deadbeefW},
- {dead_lowerW, sizeof(deadbeefW)/sizeof(WCHAR), NULL},
- {adbeW, sizeof(deadbeefW)/sizeof(WCHAR), deadbeefW + 2},
- {adbe_lowerW, sizeof(deadbeefW)/sizeof(WCHAR), NULL},
- {beefW, sizeof(deadbeefW)/sizeof(WCHAR), deadbeefW + 4},
- {beef_lowerW, sizeof(deadbeefW)/sizeof(WCHAR), NULL},
+ {emptyW, ARRAY_SIZE(deadbeefW), NULL},
+ {deadW, ARRAY_SIZE(deadbeefW), deadbeefW},
+ {dead_lowerW, ARRAY_SIZE(deadbeefW), NULL},
+ {adbeW, ARRAY_SIZE(deadbeefW), deadbeefW + 2},
+ {adbe_lowerW, ARRAY_SIZE(deadbeefW), NULL},
+ {beefW, ARRAY_SIZE(deadbeefW), deadbeefW + 4},
+ {beef_lowerW, ARRAY_SIZE(deadbeefW), NULL},
{beefW, 0, NULL},
{beefW, 1, NULL},
{beefW, 2, NULL},
@@ -1386,7 +1386,7 @@ static void test_StrStrNW(void)
ret = pStrStrNW(emptyW, emptyW, 10);
ok(!ret, "Expected StrStrNW to return NULL, got %p\n", ret);
- for (i = 0; i < sizeof(StrStrNW_cases)/sizeof(StrStrNW_cases[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(StrStrNW_cases); i++)
{
ret = pStrStrNW(deadbeefW, StrStrNW_cases[i].search, StrStrNW_cases[i].count);
ok(ret == StrStrNW_cases[i].expect,
@@ -1426,14 +1426,14 @@ static void test_StrStrNIW(void)
const WCHAR *expect;
} StrStrNIW_cases[] =
{
- {emptyW, sizeof(deadbeefW)/sizeof(WCHAR), NULL},
- {deadW, sizeof(deadbeefW)/sizeof(WCHAR), deadbeefW},
- {dead_lowerW, sizeof(deadbeefW)/sizeof(WCHAR), deadbeefW},
- {adbeW, sizeof(deadbeefW)/sizeof(WCHAR), deadbeefW + 2},
- {adbe_lowerW, sizeof(deadbeefW)/sizeof(WCHAR), deadbeefW + 2},
- {beefW, sizeof(deadbeefW)/sizeof(WCHAR), deadbeefW + 4},
- {beef_lowerW, sizeof(deadbeefW)/sizeof(WCHAR), deadbeefW + 4},
- {cafeW, sizeof(deadbeefW)/sizeof(WCHAR), NULL},
+ {emptyW, ARRAY_SIZE(deadbeefW), NULL},
+ {deadW, ARRAY_SIZE(deadbeefW), deadbeefW},
+ {dead_lowerW, ARRAY_SIZE(deadbeefW), deadbeefW},
+ {adbeW, ARRAY_SIZE(deadbeefW), deadbeefW + 2},
+ {adbe_lowerW, ARRAY_SIZE(deadbeefW), deadbeefW + 2},
+ {beefW, ARRAY_SIZE(deadbeefW), deadbeefW + 4},
+ {beef_lowerW, ARRAY_SIZE(deadbeefW), deadbeefW + 4},
+ {cafeW, ARRAY_SIZE(deadbeefW), NULL},
{beefW, 0, NULL},
{beefW, 1, NULL},
{beefW, 2, NULL},
@@ -1480,7 +1480,7 @@ static void test_StrStrNIW(void)
ret = pStrStrNIW(emptyW, emptyW, 10);
ok(!ret, "Expected StrStrNIW to return NULL, got %p\n", ret);
- for (i = 0; i < sizeof(StrStrNIW_cases)/sizeof(StrStrNIW_cases[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(StrStrNIW_cases); i++)
{
ret = pStrStrNIW(deadbeefW, StrStrNIW_cases[i].search, StrStrNIW_cases[i].count);
ok(ret == StrStrNIW_cases[i].expect,
diff --git a/dlls/shlwapi/tests/url.c b/dlls/shlwapi/tests/url.c
index ac896b06e4..d30737f60a 100644
--- a/dlls/shlwapi/tests/url.c
+++ b/dlls/shlwapi/tests/url.c
@@ -539,7 +539,7 @@ static void test_UrlApplyScheme(void)
return;
}
- for(i = 0; i < sizeof(TEST_APPLY)/sizeof(TEST_APPLY[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(TEST_APPLY); i++) {
len = TEST_APPLY_MAX_LENGTH;
lstrcpyA(newurl, untouchedA);
res = pUrlApplySchemeA(TEST_APPLY[i].url, newurl, &len, TEST_APPLY[i].flags);
@@ -916,7 +916,7 @@ static void test_UrlEscapeA(void)
"got %d, expected %d\n", size, 1);
ok(empty_string[0] == 127, "String has changed, empty_string[0] = %d\n", empty_string[0]);
- for(i=0; i<sizeof(TEST_ESCAPE)/sizeof(TEST_ESCAPE[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(TEST_ESCAPE); i++) {
CHAR ret_url[INTERNET_MAX_URL_LENGTH];
size = INTERNET_MAX_URL_LENGTH;
@@ -983,7 +983,7 @@ static void test_UrlEscapeW(void)
/* Check actual escaping */
- size = sizeof(overwrite)/sizeof(WCHAR);
+ size = ARRAY_SIZE(overwrite);
ret = pUrlEscapeW(overwrite, overwrite, &size, URL_ESCAPE_SPACES_ONLY);
ok(ret == S_OK, "got %x, expected S_OK\n", ret);
ok(size == 9, "got %d, expected 9\n", size);
@@ -997,12 +997,12 @@ static void test_UrlEscapeW(void)
ok(wc == 127, "String has changed, wc = %d\n", wc);
/* non-ASCII range */
- size = sizeof(ret_urlW)/sizeof(WCHAR);
+ size = ARRAY_SIZE(ret_urlW);
ret = pUrlEscapeW(naW, ret_urlW, &size, 0);
ok(ret == S_OK, "got %x, expected S_OK\n", ret);
ok(!lstrcmpW(naescapedW, ret_urlW), "got %s, expected %s\n", wine_dbgstr_w(ret_urlW), wine_dbgstr_w(naescapedW));
- for (i = 0; i < sizeof(TEST_ESCAPE)/sizeof(TEST_ESCAPE[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(TEST_ESCAPE); i++) {
WCHAR *urlW, *expected_urlW;
@@ -1018,7 +1018,7 @@ static void test_UrlEscapeW(void)
FreeWideString(expected_urlW);
}
- for(i=0; i<sizeof(TEST_ESCAPEW)/sizeof(TEST_ESCAPEW[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(TEST_ESCAPEW); i++) {
WCHAR ret_url[INTERNET_MAX_URL_LENGTH];
size = INTERNET_MAX_URL_LENGTH;
@@ -1113,7 +1113,7 @@ static void test_UrlCanonicalizeA(void)
test_url_canonicalize(-1, "", 0, S_OK, S_FALSE /* Vista/win2k8 */, "", FALSE);
/* test url-modification */
- for(i=0; i<sizeof(TEST_CANONICALIZE)/sizeof(TEST_CANONICALIZE[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(TEST_CANONICALIZE); i++) {
test_url_canonicalize(i, TEST_CANONICALIZE[i].url, TEST_CANONICALIZE[i].flags,
TEST_CANONICALIZE[i].expectret, TEST_CANONICALIZE[i].expectret, TEST_CANONICALIZE[i].expecturl,
TEST_CANONICALIZE[i].todo);
@@ -1185,7 +1185,7 @@ static void test_UrlCanonicalizeW(void)
BOOL choped;
int pos;
- MultiByteToWideChar(CP_ACP, 0, "http://www.winehq.org/X", -1, szUrl, sizeof(szUrl)/sizeof(szUrl[0]));
+ MultiByteToWideChar(CP_ACP, 0, "http://www.winehq.org/X", -1, szUrl, ARRAY_SIZE(szUrl));
pos = lstrlenW(szUrl) - 1;
szUrl[pos] = i;
urllen = INTERNET_MAX_URL_LENGTH;
@@ -1267,7 +1267,7 @@ static void test_url_combine(const char *szUrl1, const char *szUrl2, DWORD dwFla
static void test_UrlCombine(void)
{
unsigned int i;
- for(i=0; i<sizeof(TEST_COMBINE)/sizeof(TEST_COMBINE[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(TEST_COMBINE); i++) {
test_url_combine(TEST_COMBINE[i].url1, TEST_COMBINE[i].url2, TEST_COMBINE[i].flags,
TEST_COMBINE[i].expectret, TEST_COMBINE[i].expecturl);
}
@@ -1288,7 +1288,7 @@ static void test_UrlCreateFromPath(void)
return;
}
- for(i = 0; i < sizeof(TEST_URLFROMPATH) / sizeof(TEST_URLFROMPATH[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(TEST_URLFROMPATH); i++) {
len = INTERNET_MAX_URL_LENGTH;
ret = pUrlCreateFromPathA(TEST_URLFROMPATH[i].path, ret_url, &len, 0);
ok(ret == TEST_URLFROMPATH[i].ret, "ret %08x from path %s\n", ret, TEST_URLFROMPATH[i].path);
@@ -1342,8 +1342,8 @@ static void test_UrlIs(void)
test_UrlIs_null(URLIS_OPAQUE);
test_UrlIs_null(URLIS_URL);
- for(i = 0; i < sizeof(TEST_PATH_IS_URL) / sizeof(TEST_PATH_IS_URL[0]); i++) {
- MultiByteToWideChar(CP_ACP, 0, TEST_PATH_IS_URL[i].path, -1, wurl, sizeof(wurl)/sizeof(*wurl));
+ for (i = 0; i < ARRAY_SIZE(TEST_PATH_IS_URL); i++) {
+ MultiByteToWideChar(CP_ACP, 0, TEST_PATH_IS_URL[i].path, -1, wurl, ARRAY_SIZE(wurl));
ret = pUrlIsA( TEST_PATH_IS_URL[i].path, URLIS_URL );
ok( ret == TEST_PATH_IS_URL[i].expect,
@@ -1357,8 +1357,8 @@ static void test_UrlIs(void)
TEST_PATH_IS_URL[i].path, TEST_PATH_IS_URL[i].expect );
}
}
- for(i = 0; i < sizeof(TEST_URLIS_ATTRIBS) / sizeof(TEST_URLIS_ATTRIBS[0]); i++) {
- MultiByteToWideChar(CP_ACP, 0, TEST_URLIS_ATTRIBS[i].url, -1, wurl, sizeof(wurl)/sizeof(*wurl));
+ for (i = 0; i < ARRAY_SIZE(TEST_URLIS_ATTRIBS); i++) {
+ MultiByteToWideChar(CP_ACP, 0, TEST_URLIS_ATTRIBS[i].url, -1, wurl, ARRAY_SIZE(wurl));
ret = pUrlIsA( TEST_URLIS_ATTRIBS[i].url, URLIS_OPAQUE);
ok( ret == TEST_URLIS_ATTRIBS[i].expectOpaque,
@@ -1403,7 +1403,7 @@ static void test_UrlUnescape(void)
win_skip("UrlUnescapeA not found\n");
return;
}
- for(i=0; i<sizeof(TEST_URL_UNESCAPE)/sizeof(TEST_URL_UNESCAPE[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(TEST_URL_UNESCAPE); i++) {
dwEscaped=INTERNET_MAX_URL_LENGTH;
res = pUrlUnescapeA(TEST_URL_UNESCAPE[i].url, szReturnUrl, &dwEscaped, 0);
ok(res == S_OK,
@@ -1494,7 +1494,7 @@ static void test_ParseURL(void)
PARSEDURLW parsedw;
HRESULT hres;
- for(test = parse_url_tests; test < parse_url_tests + sizeof(parse_url_tests)/sizeof(*parse_url_tests); test++) {
+ for (test = parse_url_tests; test < parse_url_tests + ARRAY_SIZE(parse_url_tests); test++) {
memset(&parseda, 0xd0, sizeof(parseda));
parseda.cbSize = sizeof(parseda);
hres = pParseURLA(test->url, &parseda);
@@ -1516,7 +1516,7 @@ static void test_ParseURL(void)
ok(parseda.nScheme == 0xd0d0d0d0, "nScheme = %d\n", parseda.nScheme);
}
- MultiByteToWideChar(CP_ACP, 0, test->url, -1, url, sizeof(url)/sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, test->url, -1, url, ARRAY_SIZE(url));
memset(&parsedw, 0xd0, sizeof(parsedw));
parsedw.cbSize = sizeof(parsedw);
@@ -1595,23 +1595,23 @@ static void test_HashData(void)
"Expected HashData to return E_INVALIDARG, got 0x%08x\n", res);
/* Test passing valid pointers with sizes of zero. */
- for (i = 0; i < sizeof(input)/sizeof(BYTE); i++)
+ for (i = 0; i < ARRAY_SIZE(input); i++)
input[i] = 0x00;
- for (i = 0; i < sizeof(output)/sizeof(BYTE); i++)
+ for (i = 0; i < ARRAY_SIZE(output); i++)
output[i] = 0xFF;
res = pHashData(input, 0, output, 0);
ok(res == S_OK, "Expected HashData to return S_OK, got 0x%08x\n", res);
/* The buffers should be unchanged. */
- for (i = 0; i < sizeof(input)/sizeof(BYTE); i++)
+ for (i = 0; i < ARRAY_SIZE(input); i++)
{
ok(input[i] == 0x00, "Expected the input buffer to be unchanged\n");
if(input[i] != 0x00) break;
}
- for (i = 0; i < sizeof(output)/sizeof(BYTE); i++)
+ for (i = 0; i < ARRAY_SIZE(output); i++)
{
ok(output[i] == 0xFF, "Expected the output buffer to be unchanged\n");
if(output[i] != 0xFF) break;
--
2.14.4
1
0
[PATCH vkd3d 10/12] libs/vkd3d: Add support for 2D array render target views.
by Józef Kucia 26 Jun '18
by Józef Kucia 26 Jun '18
26 Jun '18
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d/command.c | 41 +++++++++++++++++++++++------------------
libs/vkd3d/resource.c | 8 ++++++--
libs/vkd3d/vkd3d_private.h | 2 ++
3 files changed, 31 insertions(+), 20 deletions(-)
diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c
index 82a99fda2511..ee1d3f6e1018 100644
--- a/libs/vkd3d/command.c
+++ b/libs/vkd3d/command.c
@@ -1583,7 +1583,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_command_list_ClearState(ID3D12GraphicsCom
}
static void d3d12_command_list_get_fb_extent(struct d3d12_command_list *list,
- uint32_t *width, uint32_t *height)
+ uint32_t *width, uint32_t *height, uint32_t *layer_count)
{
struct d3d12_device *device = list->device;
@@ -1591,11 +1591,15 @@ static void d3d12_command_list_get_fb_extent(struct d3d12_command_list *list,
{
*width = list->fb_width;
*height = list->fb_height;
+ if (layer_count)
+ *layer_count = list->fb_layer_count;
}
else
{
*width = device->vk_info.device_limits.maxFramebufferWidth;
*height = device->vk_info.device_limits.maxFramebufferHeight;
+ if (layer_count)
+ *layer_count = 1;
}
}
@@ -1620,8 +1624,7 @@ static bool d3d12_command_list_update_current_framebuffer(struct d3d12_command_l
fb_desc.renderPass = list->state->u.graphics.render_pass;
fb_desc.attachmentCount = list->state->u.graphics.attachment_count;
fb_desc.pAttachments = &list->views[start_idx];
- d3d12_command_list_get_fb_extent(list, &fb_desc.width, &fb_desc.height);
- fb_desc.layers = 1;
+ d3d12_command_list_get_fb_extent(list, &fb_desc.width, &fb_desc.height, &fb_desc.layers);
if ((vr = VK_CALL(vkCreateFramebuffer(device->vk_device, &fb_desc, NULL, &vk_framebuffer))) < 0)
{
WARN("Failed to create Vulkan framebuffer, vr %d.\n", vr);
@@ -2212,7 +2215,7 @@ static bool d3d12_command_list_begin_render_pass(struct d3d12_command_list *list
begin_desc.renderArea.offset.x = 0;
begin_desc.renderArea.offset.y = 0;
d3d12_command_list_get_fb_extent(list,
- &begin_desc.renderArea.extent.width, &begin_desc.renderArea.extent.height);
+ &begin_desc.renderArea.extent.width, &begin_desc.renderArea.extent.height, NULL);
begin_desc.clearValueCount = 0;
begin_desc.pClearValues = NULL;
VK_CALL(vkCmdBeginRenderPass(list->vk_command_buffer, &begin_desc, VK_SUBPASS_CONTENTS_INLINE));
@@ -3438,6 +3441,7 @@ static void STDMETHODCALLTYPE d3d12_command_list_OMSetRenderTargets(ID3D12Graphi
list->fb_width = 0;
list->fb_height = 0;
+ list->fb_layer_count = 0;
for (i = 0; i < render_target_descriptor_count; ++i)
{
if (single_descriptor_handle)
@@ -3448,10 +3452,9 @@ static void STDMETHODCALLTYPE d3d12_command_list_OMSetRenderTargets(ID3D12Graphi
d3d12_command_list_track_resource_usage(list, rtv_desc->resource);
list->views[i + 1] = rtv_desc->vk_view;
- if (rtv_desc->width > list->fb_width)
- list->fb_width = rtv_desc->width;
- if (rtv_desc->height > list->fb_height)
- list->fb_height = rtv_desc->height;
+ list->fb_width = max(list->fb_width, rtv_desc->width);
+ list->fb_height = max(list->fb_height, rtv_desc->height);
+ list->fb_layer_count = max(list->fb_layer_count, rtv_desc->layer_count);
}
if (depth_stencil_descriptor)
@@ -3460,10 +3463,9 @@ static void STDMETHODCALLTYPE d3d12_command_list_OMSetRenderTargets(ID3D12Graphi
d3d12_command_list_track_resource_usage(list, dsv_desc->resource);
- if (dsv_desc->width > list->fb_width)
- list->fb_width = dsv_desc->width;
- if (dsv_desc->height > list->fb_height)
- list->fb_height = dsv_desc->height;
+ list->fb_width = max(list->fb_width, dsv_desc->width);
+ list->fb_height = max(list->fb_height, dsv_desc->height);
+ list->fb_layer_count = max(list->fb_layer_count, 1);
list->views[0] = dsv_desc->vk_view;
}
@@ -3471,9 +3473,10 @@ static void STDMETHODCALLTYPE d3d12_command_list_OMSetRenderTargets(ID3D12Graphi
d3d12_command_list_invalidate_current_framebuffer(list);
}
-static void d3d12_command_list_clear(struct d3d12_command_list *list, const struct vkd3d_vk_device_procs *vk_procs,
- const struct VkAttachmentDescription *attachment_desc, const struct VkAttachmentReference *color_reference,
- const struct VkAttachmentReference *ds_reference, VkImageView vk_view, size_t width, size_t height,
+static void d3d12_command_list_clear(struct d3d12_command_list *list,
+ const struct vkd3d_vk_device_procs *vk_procs, const struct VkAttachmentDescription *attachment_desc,
+ const struct VkAttachmentReference *color_reference, const struct VkAttachmentReference *ds_reference,
+ VkImageView vk_view, size_t width, size_t height, unsigned int layer_count,
const union VkClearValue *clear_value, unsigned int rect_count, const D3D12_RECT *rects)
{
struct VkSubpassDescription sub_pass_desc;
@@ -3538,7 +3541,7 @@ static void d3d12_command_list_clear(struct d3d12_command_list *list, const stru
fb_desc.pAttachments = &vk_view;
fb_desc.width = width;
fb_desc.height = height;
- fb_desc.layers = 1;
+ fb_desc.layers = layer_count;
if ((vr = VK_CALL(vkCreateFramebuffer(list->device->vk_device, &fb_desc, NULL, &vk_framebuffer))) < 0)
{
WARN("Failed to create Vulkan framebuffer, vr %d.\n", vr);
@@ -3615,7 +3618,7 @@ static void STDMETHODCALLTYPE d3d12_command_list_ClearDepthStencilView(ID3D12Gra
ds_reference.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
d3d12_command_list_clear(list, &list->device->vk_procs, &attachment_desc, NULL, &ds_reference,
- dsv_desc->vk_view, dsv_desc->width, dsv_desc->height, &clear_value, rect_count, rects);
+ dsv_desc->vk_view, dsv_desc->width, dsv_desc->height, 1, &clear_value, rect_count, rects);
}
static void STDMETHODCALLTYPE d3d12_command_list_ClearRenderTargetView(ID3D12GraphicsCommandList *iface,
@@ -3646,7 +3649,8 @@ static void STDMETHODCALLTYPE d3d12_command_list_ClearRenderTargetView(ID3D12Gra
color_reference.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
d3d12_command_list_clear(list, &list->device->vk_procs, &attachment_desc, &color_reference, NULL,
- rtv_desc->vk_view, rtv_desc->width, rtv_desc->height, &clear_value, rect_count, rects);
+ rtv_desc->vk_view, rtv_desc->width, rtv_desc->height, rtv_desc->layer_count,
+ &clear_value, rect_count, rects);
}
static void STDMETHODCALLTYPE d3d12_command_list_ClearUnorderedAccessViewUint(ID3D12GraphicsCommandList *iface,
@@ -4005,6 +4009,7 @@ static HRESULT d3d12_command_list_init(struct d3d12_command_list *list, struct d
memset(list->views, 0, sizeof(list->views));
list->fb_width = 0;
list->fb_height = 0;
+ list->fb_layer_count = 0;
list->current_framebuffer = VK_NULL_HANDLE;
list->current_pipeline = VK_NULL_HANDLE;
diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c
index 2ccb84797514..e45c90083229 100644
--- a/libs/vkd3d/resource.c
+++ b/libs/vkd3d/resource.c
@@ -1534,6 +1534,7 @@ void d3d12_rtv_desc_create_rtv(struct d3d12_rtv_desc *rtv_desc, struct d3d12_dev
struct d3d12_resource *resource, const D3D12_RENDER_TARGET_VIEW_DESC *desc)
{
const struct vkd3d_format *format;
+ VkImageViewType vk_view_type;
uint32_t miplevel_idx;
d3d12_rtv_desc_destroy(rtv_desc, device);
@@ -1566,13 +1567,16 @@ void d3d12_rtv_desc_create_rtv(struct d3d12_rtv_desc *rtv_desc, struct d3d12_dev
FIXME("Ignoring plane slice %u.\n", desc->u.Texture2D.PlaneSlice);
miplevel_idx = desc ? desc->u.Texture2D.MipSlice : 0;
- if (vkd3d_create_texture_view(device, resource, format, VK_IMAGE_VIEW_TYPE_2D,
- miplevel_idx, 1, 0, 1, false, &rtv_desc->vk_view) < 0)
+ vk_view_type = resource->desc.DepthOrArraySize > 1
+ ? VK_IMAGE_VIEW_TYPE_2D_ARRAY : VK_IMAGE_VIEW_TYPE_2D;
+ if (vkd3d_create_texture_view(device, resource, format, vk_view_type,
+ miplevel_idx, 1, 0, VK_REMAINING_ARRAY_LAYERS, false, &rtv_desc->vk_view) < 0)
return;
rtv_desc->format = format->vk_format;
rtv_desc->width = d3d12_resource_desc_get_width(&resource->desc, miplevel_idx);
rtv_desc->height = d3d12_resource_desc_get_height(&resource->desc, miplevel_idx);
+ rtv_desc->layer_count = resource->desc.DepthOrArraySize;
rtv_desc->magic = VKD3D_DESCRIPTOR_MAGIC_RTV;
rtv_desc->resource = resource;
}
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index 7506471fbe6c..38f0bf38e215 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -287,6 +287,7 @@ struct d3d12_rtv_desc
VkFormat format;
uint64_t width;
unsigned int height;
+ unsigned int layer_count;
VkImageView vk_view;
struct d3d12_resource *resource;
};
@@ -587,6 +588,7 @@ struct d3d12_command_list
VkImageView views[D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT + 1];
unsigned int fb_width;
unsigned int fb_height;
+ unsigned int fb_layer_count;
VkFramebuffer current_framebuffer;
VkPipeline current_pipeline;
--
2.16.4
2
1
26 Jun '18
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
tests/d3d12.c | 210 ++++++++++++++++++++++++++++++++++++++++++++++-
tests/vkd3d_d3d12_test.h | 6 +-
2 files changed, 211 insertions(+), 5 deletions(-)
diff --git a/tests/d3d12.c b/tests/d3d12.c
index 0e35fc866bbc..a761c0d3cad4 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -663,7 +663,7 @@ static void check_sub_resource_float_(unsigned int line, ID3D12Resource *texture
{
struct resource_readback rb;
- get_texture_readback_with_command_list(texture, 0, &rb, queue, command_list);
+ get_texture_readback_with_command_list(texture, sub_resource_idx, &rb, queue, command_list);
check_readback_data_float_(line, &rb, NULL, expected, max_diff);
release_resource_readback(&rb);
}
@@ -745,7 +745,7 @@ static void check_sub_resource_uint16_(unsigned int line, ID3D12Resource *textur
{
struct resource_readback rb;
- get_texture_readback_with_command_list(texture, 0, &rb, queue, command_list);
+ get_texture_readback_with_command_list(texture, sub_resource_idx, &rb, queue, command_list);
check_readback_data_uint16_(line, &rb, NULL, expected, max_diff);
release_resource_readback(&rb);
}
@@ -17034,6 +17034,211 @@ static void test_geometry_shader(void)
destroy_test_context(&context);
}
+static void test_layered_rendering(void)
+{
+ D3D12_GRAPHICS_PIPELINE_STATE_DESC pso_desc;
+ ID3D12GraphicsCommandList *command_list;
+ D3D12_INPUT_LAYOUT_DESC input_layout;
+ struct test_context_desc desc;
+ D3D12_VERTEX_BUFFER_VIEW vbv;
+ struct test_context context;
+ ID3D12CommandQueue *queue;
+ ID3D12PipelineState *pso;
+ ID3D12Device *device;
+ ID3D12Resource *vb;
+ HRESULT hr;
+
+ static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ static const struct
+ {
+ uint32_t color;
+ struct vec4 position;
+ uint32_t layer;
+ }
+ vertices[] =
+ {
+ {0x00000000, {-1.0f, -1.0f, 0.0f, 1.0f}, 2},
+ {0x00000000, {-1.0f, 1.0f, 0.0f, 1.0f}, 2},
+ {0x00000000, { 1.0f, -1.0f, 0.0f, 1.0f}, 2},
+ {0x00000000, { 1.0f, 1.0f, 0.0f, 1.0f}, 2},
+ {0xff00ff00, {-1.0f, -1.0f, 0.0f, 1.0f}, 0},
+ {0xff00ff00, {-1.0f, 1.0f, 0.0f, 1.0f}, 0},
+ {0xff00ff00, { 1.0f, -1.0f, 0.0f, 1.0f}, 0},
+ {0xff00ff00, { 1.0f, 1.0f, 0.0f, 1.0f}, 0},
+ {0xffffff00, {-1.0f, -1.0f, 0.0f, 1.0f}, 3},
+ {0xffffff00, {-1.0f, 1.0f, 0.0f, 1.0f}, 3},
+ {0xffffff00, { 1.0f, -1.0f, 0.0f, 1.0f}, 3},
+ {0xffffff00, { 1.0f, 1.0f, 0.0f, 1.0f}, 3},
+ };
+ static const D3D12_INPUT_ELEMENT_DESC layout_desc[] =
+ {
+ {"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0},
+ {"SV_POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 4, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0},
+ {"LAYER", 0, DXGI_FORMAT_R32_UINT, 0, 20, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0},
+ };
+ static const DWORD vs_code[] =
+ {
+#if 0
+ struct vertex
+ {
+ float4 color : COLOR;
+ float4 position : SV_Position;
+ uint layer : LAYER;
+ };
+
+ struct vertex main(in vertex v)
+ {
+ return v;
+ }
+#endif
+ 0x43425844, 0x96d7f39a, 0x03d06cd5, 0x32c1fa04, 0xd509128f, 0x00000001, 0x000001ac, 0x00000003,
+ 0x0000002c, 0x0000009c, 0x0000010c, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000056, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000001, 0x00000f0f, 0x00000062, 0x00000000, 0x00000000, 0x00000001, 0x00000002,
+ 0x00000101, 0x4f4c4f43, 0x56530052, 0x736f505f, 0x6f697469, 0x414c006e, 0x00524559, 0x4e47534f,
+ 0x00000068, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
+ 0x0000000f, 0x00000056, 0x00000000, 0x00000001, 0x00000003, 0x00000001, 0x0000000f, 0x00000062,
+ 0x00000000, 0x00000000, 0x00000001, 0x00000002, 0x00000e01, 0x4f4c4f43, 0x56530052, 0x736f505f,
+ 0x6f697469, 0x414c006e, 0x00524559, 0x58454853, 0x00000098, 0x00010050, 0x00000026, 0x0100086a,
+ 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x0300005f, 0x00101012,
+ 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000001, 0x00000001,
+ 0x03000065, 0x00102012, 0x00000002, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000,
+ 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001, 0x05000036, 0x00102012, 0x00000002,
+ 0x0010100a, 0x00000002, 0x0100003e,
+ };
+ static const D3D12_SHADER_BYTECODE vs = {vs_code, sizeof(vs_code)};
+ static const DWORD gs_code[] =
+ {
+#if 0
+ struct gs_in
+ {
+ float4 color : COLOR;
+ float4 position : SV_Position;
+ uint layer : LAYER;
+ };
+
+ struct gs_out
+ {
+ float4 color : COLOR;
+ float4 position : SV_Position;
+ uint layer : SV_RenderTargetArrayIndex;
+ };
+
+ [maxvertexcount(3)]
+ void main(triangle gs_in vin[3], inout TriangleStream<gs_out> vout)
+ {
+ gs_out o;
+
+ o.color = vin[0].color;
+ o.position = vin[0].position;
+ o.layer = vin[0].layer;
+ vout.Append(o);
+
+ o.color = vin[1].color;
+ o.position = vin[1].position;
+ o.layer = vin[1].layer;
+ vout.Append(o);
+
+ o.color = vin[2].color;
+ o.position = vin[2].position;
+ o.layer = vin[2].layer;
+ vout.Append(o);
+ }
+#endif
+ 0x43425844, 0x29d7c0a0, 0xcf146fd1, 0x5cd36ca7, 0xab2b10ff, 0x00000001, 0x000002bc, 0x00000003,
+ 0x0000002c, 0x0000009c, 0x0000012c, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000056, 0x00000000, 0x00000001,
+ 0x00000003, 0x00000001, 0x00000f0f, 0x00000062, 0x00000000, 0x00000000, 0x00000001, 0x00000002,
+ 0x00000101, 0x4f4c4f43, 0x56530052, 0x736f505f, 0x6f697469, 0x414c006e, 0x00524559, 0x3547534f,
+ 0x00000088, 0x00000003, 0x00000008, 0x00000000, 0x0000005c, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000000, 0x0000000f, 0x00000000, 0x00000062, 0x00000000, 0x00000001, 0x00000003, 0x00000001,
+ 0x0000000f, 0x00000000, 0x0000006e, 0x00000000, 0x00000004, 0x00000001, 0x00000002, 0x00000e01,
+ 0x4f4c4f43, 0x56530052, 0x736f505f, 0x6f697469, 0x5653006e, 0x6e65525f, 0x54726564, 0x65677261,
+ 0x72724174, 0x6e497961, 0x00786564, 0x58454853, 0x00000188, 0x00020050, 0x00000062, 0x0100086a,
+ 0x0400005f, 0x002010f2, 0x00000003, 0x00000000, 0x05000061, 0x002010f2, 0x00000003, 0x00000001,
+ 0x00000001, 0x0400005f, 0x00201012, 0x00000003, 0x00000002, 0x0100185d, 0x0300008f, 0x00110000,
+ 0x00000000, 0x0100285c, 0x03000065, 0x001020f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000001,
+ 0x00000001, 0x04000067, 0x00102012, 0x00000002, 0x00000004, 0x0200005e, 0x00000003, 0x06000036,
+ 0x001020f2, 0x00000000, 0x00201e46, 0x00000000, 0x00000000, 0x06000036, 0x001020f2, 0x00000001,
+ 0x00201e46, 0x00000000, 0x00000001, 0x06000036, 0x00102012, 0x00000002, 0x0020100a, 0x00000000,
+ 0x00000002, 0x03000075, 0x00110000, 0x00000000, 0x06000036, 0x001020f2, 0x00000000, 0x00201e46,
+ 0x00000001, 0x00000000, 0x06000036, 0x001020f2, 0x00000001, 0x00201e46, 0x00000001, 0x00000001,
+ 0x06000036, 0x00102012, 0x00000002, 0x0020100a, 0x00000001, 0x00000002, 0x03000075, 0x00110000,
+ 0x00000000, 0x06000036, 0x001020f2, 0x00000000, 0x00201e46, 0x00000002, 0x00000000, 0x06000036,
+ 0x001020f2, 0x00000001, 0x00201e46, 0x00000002, 0x00000001, 0x06000036, 0x00102012, 0x00000002,
+ 0x0020100a, 0x00000002, 0x00000002, 0x03000075, 0x00110000, 0x00000000, 0x0100003e,
+ };
+ static const D3D12_SHADER_BYTECODE gs = {gs_code, sizeof(gs_code)};
+ static const DWORD ps_code[] =
+ {
+#if 0
+ float4 main(float4 color : COLOR) : SV_Target0
+ {
+ return color;
+ }
+#endif
+ 0x43425844, 0xdccf00bf, 0xcc96375e, 0xba21f157, 0xe47b8b1c, 0x00000001, 0x000000d4, 0x00000003,
+ 0x0000002c, 0x0000005c, 0x00000090, 0x4e475349, 0x00000028, 0x00000001, 0x00000008, 0x00000020,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x4f4c4f43, 0xabab0052, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000003c, 0x00000050, 0x0000000f,
+ 0x0100086a, 0x03001062, 0x001010f2, 0x00000000, 0x03000065, 0x001020f2, 0x00000000, 0x05000036,
+ 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
+ };
+ static const D3D12_SHADER_BYTECODE ps = {ps_code, sizeof(ps_code)};
+
+ memset(&desc, 0, sizeof(desc));
+ desc.rt_array_size = 4;
+ desc.root_signature_flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT;
+ desc.no_pipeline = true;
+ if (!init_test_context(&context, &desc))
+ return;
+ device = context.device;
+ command_list = context.list;
+ queue = context.queue;
+
+ input_layout.pInputElementDescs = layout_desc;
+ input_layout.NumElements = ARRAY_SIZE(layout_desc);
+
+ init_pipeline_state_desc(&pso_desc, context.root_signature,
+ context.render_target_desc.Format, &vs, &ps, &input_layout);
+ pso_desc.GS = gs;
+ hr = ID3D12Device_CreateGraphicsPipelineState(device, &pso_desc,
+ &IID_ID3D12PipelineState, (void **)&pso);
+ ok(hr == S_OK, "Failed to create graphics pipeline state, hr %#x.\n", hr);
+
+ vb = create_upload_buffer(context.device, sizeof(vertices), vertices);
+ vbv.BufferLocation = ID3D12Resource_GetGPUVirtualAddress(vb);
+ vbv.StrideInBytes = sizeof(*vertices);
+ vbv.SizeInBytes = sizeof(vertices);
+
+ ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, white, 0, NULL);
+
+ ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, FALSE, NULL);
+ ID3D12GraphicsCommandList_RSSetScissorRects(command_list, 1, &context.scissor_rect);
+ ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context.viewport);
+ ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature);
+ ID3D12GraphicsCommandList_SetPipelineState(command_list, pso);
+ ID3D12GraphicsCommandList_IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
+ ID3D12GraphicsCommandList_IASetVertexBuffers(command_list, 0, 1, &vbv);
+ ID3D12GraphicsCommandList_DrawInstanced(command_list, 12, 1, 0, 0);
+
+ transition_resource_state(command_list, context.render_target,
+ D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
+
+ check_sub_resource_uint(context.render_target, 0, queue, command_list, 0xff00ff00, 0);
+ reset_command_list(command_list, context.allocator);
+ check_sub_resource_uint(context.render_target, 1, queue, command_list, 0xffffffff, 0);
+ reset_command_list(command_list, context.allocator);
+ check_sub_resource_uint(context.render_target, 2, queue, command_list, 0x00000000, 0);
+ reset_command_list(command_list, context.allocator);
+ check_sub_resource_uint(context.render_target, 3, queue, command_list, 0xffffff00, 0);
+
+ ID3D12Resource_Release(vb);
+ ID3D12PipelineState_Release(pso);
+ destroy_test_context(&context);
+}
+
static void test_render_a8(void)
{
static const float black[] = {0.0f, 0.0f, 0.0f, 0.0f};
@@ -17191,5 +17396,6 @@ START_TEST(d3d12)
run_test(test_face_culling);
run_test(test_multithread_command_queue_exec);
run_test(test_geometry_shader);
+ run_test(test_layered_rendering);
run_test(test_render_a8);
}
diff --git a/tests/vkd3d_d3d12_test.h b/tests/vkd3d_d3d12_test.h
index 538479e922c1..b4a9a442a5d2 100644
--- a/tests/vkd3d_d3d12_test.h
+++ b/tests/vkd3d_d3d12_test.h
@@ -313,7 +313,7 @@ static void check_sub_resource_uint_(unsigned int line, ID3D12Resource *texture,
{
struct resource_readback rb;
- get_texture_readback_with_command_list(texture, 0, &rb, queue, command_list);
+ get_texture_readback_with_command_list(texture, sub_resource_idx, &rb, queue, command_list);
check_readback_data_uint_(line, &rb, NULL, expected, max_diff);
release_resource_readback(&rb);
}
@@ -492,7 +492,7 @@ static ID3D12PipelineState *create_pipeline_state_(unsigned int line, ID3D12Devi
struct test_context_desc
{
- unsigned int rt_width, rt_height;
+ unsigned int rt_width, rt_height, rt_array_size;
DXGI_FORMAT rt_format;
unsigned int rt_descriptor_count;
unsigned int root_signature_flags;
@@ -540,7 +540,7 @@ static void create_render_target_(unsigned int line, struct test_context *contex
resource_desc.Alignment = 0;
resource_desc.Width = desc && desc->rt_width ? desc->rt_width : 32;
resource_desc.Height = desc && desc->rt_height ? desc->rt_height : 32;
- resource_desc.DepthOrArraySize = 1;
+ resource_desc.DepthOrArraySize = desc && desc->rt_array_size ? desc->rt_array_size : 1;
resource_desc.MipLevels = 1;
resource_desc.Format = desc && desc->rt_format ? desc->rt_format : DXGI_FORMAT_R8G8B8A8_UNORM;
resource_desc.SampleDesc.Count = 1;
--
2.16.4
2
1
[PATCH vkd3d 12/12] libs/vkd3d-shader: Fix returning multiple components from dot product instructions.
by Józef Kucia 26 Jun '18
by Józef Kucia 26 Jun '18
26 Jun '18
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d-shader/spirv.c | 76 +++++++++++++++++++++++++----------------------
tests/d3d12.c | 23 ++++++++++++++
2 files changed, 64 insertions(+), 35 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c
index a5e51c9643cb..bfa2bc0dacf7 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -2219,6 +2219,35 @@ static uint32_t vkd3d_dxbc_compiler_emit_array_variable(struct vkd3d_dxbc_compil
return vkd3d_spirv_build_op_variable(builder, stream, ptr_type_id, storage_class, 0);
}
+static uint32_t vkd3d_dxbc_compiler_emit_construct_vector(struct vkd3d_dxbc_compiler *compiler,
+ enum vkd3d_component_type component_type, unsigned int component_count,
+ uint32_t val_id, unsigned int val_component_idx, unsigned int val_component_count)
+{
+ struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
+ uint32_t components[VKD3D_VEC4_SIZE];
+ uint32_t type_id, result_id;
+ unsigned int i;
+
+ assert(val_component_idx < val_component_count);
+
+ type_id = vkd3d_spirv_get_type_id(builder, component_type, component_count);
+ if (val_component_count == 1)
+ {
+ for (i = 0; i < component_count; ++i)
+ components[i] = val_id;
+ result_id = vkd3d_spirv_build_op_composite_construct(builder,
+ type_id, components, component_count);
+ }
+ else
+ {
+ for (i = 0; i < component_count; ++i)
+ components[i] = val_component_idx;
+ result_id = vkd3d_spirv_build_op_vector_shuffle(builder,
+ type_id, val_id, val_id, components, component_count);
+ }
+ return result_id;
+}
+
static uint32_t vkd3d_dxbc_compiler_emit_load_src(struct vkd3d_dxbc_compiler *compiler,
const struct vkd3d_shader_src_param *src, DWORD write_mask);
@@ -4202,11 +4231,13 @@ static void vkd3d_dxbc_compiler_emit_dot(struct vkd3d_dxbc_compiler *compiler,
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
const struct vkd3d_shader_dst_param *dst = instruction->dst;
const struct vkd3d_shader_src_param *src = instruction->src;
+ enum vkd3d_component_type component_type;
uint32_t type_id, val_id, src_ids[2];
+ unsigned int component_count, i;
DWORD write_mask;
- unsigned int i;
- assert(vkd3d_write_mask_component_count(dst->write_mask) == 1);
+ component_count = vkd3d_write_mask_component_count(dst->write_mask);
+ component_type = vkd3d_component_type_from_data_type(dst->reg.data_type);
if (instruction->handler_idx == VKD3DSIH_DP4)
write_mask = VKD3DSP_WRITEMASK_ALL;
@@ -4219,11 +4250,15 @@ static void vkd3d_dxbc_compiler_emit_dot(struct vkd3d_dxbc_compiler *compiler,
for (i = 0; i < ARRAY_SIZE(src_ids); ++i)
src_ids[i] = vkd3d_dxbc_compiler_emit_load_src(compiler, &src[i], write_mask);
- type_id = vkd3d_spirv_get_type_id(builder,
- vkd3d_component_type_from_data_type(dst->reg.data_type), 1);
+ type_id = vkd3d_spirv_get_type_id(builder, component_type, 1);
val_id = vkd3d_spirv_build_op_tr2(builder, &builder->function_stream,
SpvOpDot, type_id, src_ids[0], src_ids[1]);
+ if (component_count > 1)
+ {
+ val_id = vkd3d_dxbc_compiler_emit_construct_vector(compiler,
+ component_type, component_count, val_id, 0, 1);
+ }
vkd3d_dxbc_compiler_emit_store_dst(compiler, dst, val_id);
}
@@ -5270,35 +5305,6 @@ static void vkd3d_dxbc_compiler_emit_ld_raw_structured(struct vkd3d_dxbc_compile
}
}
-static uint32_t vkd3d_dxbc_compiler_emit_construct_vec4(struct vkd3d_dxbc_compiler *compiler,
- uint32_t val_id, enum vkd3d_component_type component_type,
- unsigned int component_idx, unsigned int component_count)
-{
- struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
- uint32_t components[VKD3D_VEC4_SIZE];
- uint32_t type_id, result_id;
- unsigned int i;
-
- assert(component_idx < component_count);
-
- type_id = vkd3d_spirv_get_type_id(builder, component_type, VKD3D_VEC4_SIZE);
- if (component_count == 1)
- {
- for (i = 0; i < VKD3D_VEC4_SIZE; ++i)
- components[i] = val_id;
- result_id = vkd3d_spirv_build_op_composite_construct(builder,
- type_id, components, VKD3D_VEC4_SIZE);
- }
- else
- {
- for (i = 0; i < VKD3D_VEC4_SIZE; ++i)
- components[i] = component_idx;
- result_id = vkd3d_spirv_build_op_vector_shuffle(builder,
- type_id, val_id, val_id, components, VKD3D_VEC4_SIZE);
- }
- return result_id;
-}
-
static void vkd3d_dxbc_compiler_emit_store_uav_raw_structured(struct vkd3d_dxbc_compiler *compiler,
const struct vkd3d_shader_instruction *instruction)
{
@@ -5325,8 +5331,8 @@ static void vkd3d_dxbc_compiler_emit_store_uav_raw_structured(struct vkd3d_dxbc_
for (component_idx = 0; component_idx < component_count; ++component_idx)
{
/* Mesa Vulkan drivers require the texel parameter to be a vector. */
- texel_id = vkd3d_dxbc_compiler_emit_construct_vec4(compiler,
- val_id, VKD3D_TYPE_UINT, component_idx, component_count);
+ texel_id = vkd3d_dxbc_compiler_emit_construct_vector(compiler,
+ VKD3D_TYPE_UINT, VKD3D_VEC4_SIZE, val_id, component_idx, component_count);
coordinate_id = base_coordinate_id;
if (component_idx)
diff --git a/tests/d3d12.c b/tests/d3d12.c
index a761c0d3cad4..c6220aa0113d 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -4919,6 +4919,26 @@ static void test_shader_instructions(void)
0x00000000, 0x0100003e,
};
static const D3D12_SHADER_BYTECODE ps_dot2 = {ps_dot2_code, sizeof(ps_dot2_code)};
+ static const DWORD ps_dot3_code[] =
+ {
+#if 0
+ float4 src0;
+ float3 src1;
+
+ float4 main() : SV_Target
+ {
+ return dot(src0, src1);
+ }
+#endif
+ 0x43425844, 0xa75a4a95, 0x5d09936e, 0xdc5c694f, 0x68b6b04f, 0x00000001, 0x000000c8, 0x00000003,
+ 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000050, 0x00000050, 0x00000014,
+ 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000002, 0x03000065, 0x001020f2, 0x00000000,
+ 0x09000010, 0x001020f2, 0x00000000, 0x00208246, 0x00000000, 0x00000000, 0x00208246, 0x00000000,
+ 0x00000001, 0x0100003e,
+ };
+ static const D3D12_SHADER_BYTECODE ps_dot3 = {ps_dot3_code, sizeof(ps_dot3_code)};
static const DWORD ps_eq_code[] =
{
#if 0
@@ -6119,6 +6139,9 @@ static void test_shader_instructions(void)
{&ps_dot2, {{1.0f, 1.0f}, {1.0f, 1.0f}}, {{2.0f}}},
{&ps_dot2, {{1.0f, 1.0f}, {2.0f, 3.0f}}, {{5.0f}}},
+ {&ps_dot3, {{1.0f, 2.0f, 3.0f, 4.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}, {{6.0f, 6.0f, 6.0f, 6.0f}}},
+ {&ps_dot3, {{1.0f, 2.0f, 3.0f}, {3.0f, 1.0f, 2.0f}}, {{11.0f, 11.0f, 11.0f, 11.0f}}},
+
{&ps_eq, {{0.0f}, {0.0f}}, {.u = {0xffffffff}}},
{&ps_eq, {{1.0f}, {0.0f}}, {.u = {0x00000000}}},
{&ps_eq, {{0.0f}, {1.0f}}, {.u = {0x00000000}}},
--
2.16.4
2
1
[PATCH vkd3d 09/12] libs/vkd3d-shader: Do not emit output setup for ret in geometry shaders.
by Józef Kucia 26 Jun '18
by Józef Kucia 26 Jun '18
26 Jun '18
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d-shader/spirv.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c
index 1961ba62f202..a5e51c9643cb 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -4541,7 +4541,8 @@ static void vkd3d_dxbc_compiler_emit_return(struct vkd3d_dxbc_compiler *compiler
{
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
- vkd3d_dxbc_compiler_emit_output_setup_invocation(compiler);
+ if (compiler->shader_type != VKD3D_SHADER_TYPE_GEOMETRY)
+ vkd3d_dxbc_compiler_emit_output_setup_invocation(compiler);
vkd3d_spirv_build_op_return(builder);
}
--
2.16.4
2
1
[PATCH vkd3d 08/12] libs/vkd3d-shader: Generate correct SPIR-V code for arrayed shader inputs.
by Józef Kucia 26 Jun '18
by Józef Kucia 26 Jun '18
26 Jun '18
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d-shader/spirv.c | 41 ++++++++++++++++++++++++++++-------------
1 file changed, 28 insertions(+), 13 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c
index 881f8109ea3d..1961ba62f202 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -2983,16 +2983,17 @@ static uint32_t vkd3d_dxbc_compiler_emit_input(struct vkd3d_dxbc_compiler *compi
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
const struct vkd3d_shader_signature_element *signature_element;
const struct vkd3d_shader_register *reg = &dst->reg;
+ uint32_t type_id, ptr_type_id, float_type_id;
const struct vkd3d_spirv_builtin *builtin;
enum vkd3d_component_type component_type;
uint32_t val_id, input_id, var_id;
- uint32_t type_id, float_type_id;
struct vkd3d_symbol reg_symbol;
SpvStorageClass storage_class;
struct rb_entry *entry = NULL;
bool use_private_var = false;
unsigned int array_size;
unsigned int reg_idx;
+ uint32_t i, index;
assert(!reg->idx[0].rel_addr);
assert(!reg->idx[1].rel_addr);
@@ -3071,22 +3072,36 @@ static uint32_t vkd3d_dxbc_compiler_emit_input(struct vkd3d_dxbc_compiler *compi
if (use_private_var)
{
type_id = vkd3d_spirv_get_type_id(builder, component_type, input_component_count);
- val_id = vkd3d_spirv_build_op_load(builder, type_id, input_id, SpvMemoryAccessMaskNone);
+ for (i = 0; i < max(array_size, 1); ++i)
+ {
+ struct vkd3d_shader_register dst_reg = *reg;
- if (builtin && builtin->fixup_pfn)
- val_id = builtin->fixup_pfn(compiler, val_id);
+ val_id = input_id;
+ if (array_size)
+ {
+ ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, SpvStorageClassInput, type_id);
+ index = vkd3d_dxbc_compiler_get_constant_uint(compiler, i);
+ val_id = vkd3d_spirv_build_op_in_bounds_access_chain(builder,
+ ptr_type_id, input_id, &index, 1);
+ dst_reg.idx[0].offset = i;
+ }
+ val_id = vkd3d_spirv_build_op_load(builder, type_id, val_id, SpvMemoryAccessMaskNone);
- if (component_type != VKD3D_TYPE_FLOAT)
- {
- float_type_id = vkd3d_spirv_get_type_id(builder, VKD3D_TYPE_FLOAT, input_component_count);
- val_id = vkd3d_spirv_build_op_bitcast(builder, float_type_id, val_id);
- }
+ if (builtin && builtin->fixup_pfn)
+ val_id = builtin->fixup_pfn(compiler, val_id);
- if (input_component_count != component_count)
- val_id = vkd3d_dxbc_compiler_emit_swizzle(compiler,
- val_id, VKD3D_TYPE_FLOAT, VKD3D_NO_SWIZZLE, dst->write_mask);
+ if (component_type != VKD3D_TYPE_FLOAT)
+ {
+ float_type_id = vkd3d_spirv_get_type_id(builder, VKD3D_TYPE_FLOAT, input_component_count);
+ val_id = vkd3d_spirv_build_op_bitcast(builder, float_type_id, val_id);
+ }
- vkd3d_dxbc_compiler_emit_store_reg(compiler, reg, dst->write_mask, val_id);
+ if (input_component_count != component_count)
+ val_id = vkd3d_dxbc_compiler_emit_swizzle(compiler,
+ val_id, VKD3D_TYPE_FLOAT, VKD3D_NO_SWIZZLE, dst->write_mask);
+
+ vkd3d_dxbc_compiler_emit_store_reg(compiler, &dst_reg, dst->write_mask, val_id);
+ }
}
return input_id;
--
2.16.4
2
1
[PATCH vkd3d 07/12] libs/vkd3d-shader: Pass register index to vkd3d_find_signature_element_for_reg().
by Józef Kucia 26 Jun '18
by Józef Kucia 26 Jun '18
26 Jun '18
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d-shader/spirv.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c
index 28cfb8977ea2..881f8109ea3d 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -2949,13 +2949,13 @@ static const struct vkd3d_spirv_builtin *vkd3d_get_spirv_builtin(enum vkd3d_shad
static const struct vkd3d_shader_signature_element *vkd3d_find_signature_element_for_reg(
const struct vkd3d_shader_signature *signature, unsigned int *signature_element_index,
- const struct vkd3d_shader_register *reg, DWORD write_mask)
+ unsigned int reg_idx, DWORD write_mask)
{
unsigned int signature_idx;
for (signature_idx = 0; signature_idx < signature->element_count; ++signature_idx)
{
- if (signature->elements[signature_idx].register_index == reg->idx[0].offset
+ if (signature->elements[signature_idx].register_index == reg_idx
&& (signature->elements[signature_idx].mask & 0xff) == write_mask)
{
if (signature_element_index)
@@ -2965,7 +2965,7 @@ static const struct vkd3d_shader_signature_element *vkd3d_find_signature_element
}
FIXME("Could not find shader signature element (register %u, write mask %#x).\n",
- reg->idx[0].offset, write_mask);
+ reg_idx, write_mask);
if (signature_element_index)
*signature_element_index = ~0u;
return NULL;
@@ -3020,7 +3020,7 @@ static uint32_t vkd3d_dxbc_compiler_emit_input(struct vkd3d_dxbc_compiler *compi
else
{
signature_element = vkd3d_find_signature_element_for_reg(compiler->input_signature,
- NULL, reg, dst->write_mask);
+ NULL, reg_idx, dst->write_mask);
component_type = signature_element ? signature_element->component_type : VKD3D_TYPE_FLOAT;
input_component_count = component_count;
}
@@ -3164,7 +3164,7 @@ static uint32_t vkd3d_dxbc_compiler_emit_output(struct vkd3d_dxbc_compiler *comp
uint32_t id, var_id;
signature_element = vkd3d_find_signature_element_for_reg(compiler->output_signature,
- &signature_idx, reg, dst->write_mask);
+ &signature_idx, reg->idx[0].offset, dst->write_mask);
builtin = vkd3d_get_spirv_builtin(dst->reg.type, sysval);
component_idx = vkd3d_write_mask_get_component_idx(dst->write_mask);
--
2.16.4
2
1
[PATCH vkd3d 06/12] libs/vkd3d-shader: Simplify vkd3d_dxbc_compiler_emit_input().
by Józef Kucia 26 Jun '18
by Józef Kucia 26 Jun '18
26 Jun '18
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d-shader/spirv.c | 40 ++++++++++++++++++----------------------
1 file changed, 18 insertions(+), 22 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c
index f2a1b1141e23..28cfb8977ea2 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -2985,7 +2985,7 @@ static uint32_t vkd3d_dxbc_compiler_emit_input(struct vkd3d_dxbc_compiler *compi
const struct vkd3d_shader_register *reg = &dst->reg;
const struct vkd3d_spirv_builtin *builtin;
enum vkd3d_component_type component_type;
- uint32_t val_id = 0, input_id, var_id;
+ uint32_t val_id, input_id, var_id;
uint32_t type_id, float_type_id;
struct vkd3d_symbol reg_symbol;
SpvStorageClass storage_class;
@@ -3043,26 +3043,7 @@ static uint32_t vkd3d_dxbc_compiler_emit_input(struct vkd3d_dxbc_compiler *compi
vkd3d_spirv_build_op_decorate1(builder, input_id, SpvDecorationComponent, component_idx);
}
- if (component_type != VKD3D_TYPE_FLOAT || component_count != VKD3D_VEC4_SIZE)
- {
- type_id = vkd3d_spirv_get_type_id(builder, component_type, input_component_count);
- val_id = vkd3d_spirv_build_op_load(builder, type_id, input_id, SpvMemoryAccessMaskNone);
-
- if (builtin && builtin->fixup_pfn)
- val_id = builtin->fixup_pfn(compiler, val_id);
-
- if (component_type != VKD3D_TYPE_FLOAT)
- {
- float_type_id = vkd3d_spirv_get_type_id(builder, VKD3D_TYPE_FLOAT, input_component_count);
- val_id = vkd3d_spirv_build_op_bitcast(builder, float_type_id, val_id);
- }
-
- use_private_var = true;
- }
-
- if (val_id && input_component_count != component_count)
- val_id = vkd3d_dxbc_compiler_emit_swizzle(compiler,
- val_id, VKD3D_TYPE_FLOAT, VKD3D_NO_SWIZZLE, dst->write_mask);
+ use_private_var = component_type != VKD3D_TYPE_FLOAT || component_count != VKD3D_VEC4_SIZE;
vkd3d_symbol_make_register(®_symbol, reg);
@@ -3089,7 +3070,22 @@ static uint32_t vkd3d_dxbc_compiler_emit_input(struct vkd3d_dxbc_compiler *compi
if (use_private_var)
{
- assert(val_id);
+ type_id = vkd3d_spirv_get_type_id(builder, component_type, input_component_count);
+ val_id = vkd3d_spirv_build_op_load(builder, type_id, input_id, SpvMemoryAccessMaskNone);
+
+ if (builtin && builtin->fixup_pfn)
+ val_id = builtin->fixup_pfn(compiler, val_id);
+
+ if (component_type != VKD3D_TYPE_FLOAT)
+ {
+ float_type_id = vkd3d_spirv_get_type_id(builder, VKD3D_TYPE_FLOAT, input_component_count);
+ val_id = vkd3d_spirv_build_op_bitcast(builder, float_type_id, val_id);
+ }
+
+ if (input_component_count != component_count)
+ val_id = vkd3d_dxbc_compiler_emit_swizzle(compiler,
+ val_id, VKD3D_TYPE_FLOAT, VKD3D_NO_SWIZZLE, dst->write_mask);
+
vkd3d_dxbc_compiler_emit_store_reg(compiler, reg, dst->write_mask, val_id);
}
--
2.16.4
2
1
[PATCH vkd3d 05/12] libs/vkd3d-shader: Enable "geometry" capability for SpvBuiltInLayer.
by Józef Kucia 26 Jun '18
by Józef Kucia 26 Jun '18
26 Jun '18
From: Józef Kucia <jkucia(a)codeweavers.com>
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d-shader/spirv.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c
index cf4fbf6d7a3a..f2a1b1141e23 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -2770,8 +2770,21 @@ static void vkd3d_dxbc_compiler_decorate_builtin(struct vkd3d_dxbc_compiler *com
{
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
- if (compiler->shader_type == VKD3D_SHADER_TYPE_PIXEL && builtin == SpvBuiltInPosition)
- builtin = SpvBuiltInFragCoord;
+ switch (builtin)
+ {
+ case SpvBuiltInPosition:
+ if (compiler->shader_type == VKD3D_SHADER_TYPE_PIXEL)
+ builtin = SpvBuiltInFragCoord;
+ break;
+ case SpvBuiltInFragDepth:
+ vkd3d_spirv_enable_depth_replacing(builder);
+ break;
+ case SpvBuiltInLayer:
+ vkd3d_spirv_enable_capability(builder, SpvCapabilityGeometry);
+ break;
+ default:
+ break;
+ }
vkd3d_spirv_build_op_decorate1(builder, target_id, SpvDecorationBuiltIn, builtin);
}
@@ -3228,9 +3241,6 @@ static uint32_t vkd3d_dxbc_compiler_emit_output(struct vkd3d_dxbc_compiler *comp
compiler->output_setup_function_id = vkd3d_spirv_alloc_id(builder);
}
- if (builtin && builtin->spirv_builtin == SpvBuiltInFragDepth)
- vkd3d_spirv_enable_depth_replacing(builder);
-
return id;
}
--
2.16.4
2
1
[PATCH vkd3d 04/12] libs/vkd3d-shader: Do not force input register type to float4.
by Józef Kucia 26 Jun '18
by Józef Kucia 26 Jun '18
26 Jun '18
From: Józef Kucia <jkucia(a)codeweavers.com>
Produces slightly smaller and cleaner SPIR-V code.
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
libs/vkd3d-shader/spirv.c | 76 +++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 70 insertions(+), 6 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c
index 71db4be6b493..cf4fbf6d7a3a 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -2886,26 +2886,51 @@ vkd3d_register_builtins[] =
{VKD3DSPR_DEPTHOUT, {VKD3D_TYPE_FLOAT, 1, SpvBuiltInFragDepth}},
};
-static const struct vkd3d_spirv_builtin *vkd3d_get_spirv_builtin(enum vkd3d_shader_register_type reg_type,
+static const struct vkd3d_spirv_builtin *get_spirv_builtin_for_sysval(
enum vkd3d_shader_input_sysval_semantic sysval)
{
unsigned int i;
+ if (!sysval)
+ return NULL;
+
for (i = 0; i < ARRAY_SIZE(vkd3d_system_value_builtins); ++i)
{
if (vkd3d_system_value_builtins[i].sysval == sysval)
return &vkd3d_system_value_builtins[i].builtin;
}
+ FIXME("Unhandled builtin (sysval %#x).\n", sysval);
+
+ return NULL;
+}
+
+static const struct vkd3d_spirv_builtin *get_spirv_builtin_for_register(
+ enum vkd3d_shader_register_type reg_type)
+{
+ unsigned int i;
+
for (i = 0; i < ARRAY_SIZE(vkd3d_register_builtins); ++i)
{
if (vkd3d_register_builtins[i].reg_type == reg_type)
return &vkd3d_register_builtins[i].builtin;
}
- if (sysval != VKD3D_SIV_NONE
- || (reg_type != VKD3DSPR_INPUT && reg_type != VKD3DSPR_OUTPUT && reg_type != VKD3DSPR_COLOROUT))
- FIXME("Unhandled builtin (register type %#x, semantic %#x).\n", reg_type, sysval);
+ return NULL;
+}
+
+static const struct vkd3d_spirv_builtin *vkd3d_get_spirv_builtin(enum vkd3d_shader_register_type reg_type,
+ enum vkd3d_shader_input_sysval_semantic sysval)
+{
+ const struct vkd3d_spirv_builtin *builtin;
+
+ if ((builtin = get_spirv_builtin_for_sysval(sysval)))
+ return builtin;
+ if ((builtin = get_spirv_builtin_for_register(reg_type)))
+ return builtin;
+
+ if (sysval != VKD3D_SIV_NONE || (reg_type != VKD3DSPR_OUTPUT && reg_type != VKD3DSPR_COLOROUT))
+ FIXME("Unhandled builtin (register type %#x, sysval %#x).\n", reg_type, sysval);
return NULL;
}
@@ -2970,7 +2995,7 @@ static uint32_t vkd3d_dxbc_compiler_emit_input(struct vkd3d_dxbc_compiler *compi
reg_idx = reg->idx[0].offset;
}
- builtin = vkd3d_get_spirv_builtin(reg->type, sysval);
+ builtin = get_spirv_builtin_for_sysval(sysval);
component_idx = vkd3d_write_mask_get_component_idx(dst->write_mask);
component_count = vkd3d_write_mask_component_count(dst->write_mask);
@@ -3058,6 +3083,40 @@ static uint32_t vkd3d_dxbc_compiler_emit_input(struct vkd3d_dxbc_compiler *compi
return input_id;
}
+static void vkd3d_dxbc_compiler_emit_input_register(struct vkd3d_dxbc_compiler *compiler,
+ const struct vkd3d_shader_dst_param *dst)
+{
+ struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
+ const struct vkd3d_shader_register *reg = &dst->reg;
+ const struct vkd3d_spirv_builtin *builtin;
+ struct vkd3d_symbol reg_symbol;
+ uint32_t input_id;
+
+ assert(!reg->idx[0].rel_addr);
+ assert(!reg->idx[1].rel_addr);
+ assert(reg->idx[1].offset == ~0u);
+
+ if (!(builtin = get_spirv_builtin_for_register(reg->type)))
+ {
+ FIXME("Unhandled register %#x.\n", reg->type);
+ return;
+ }
+
+ input_id = vkd3d_dxbc_compiler_emit_variable(compiler,
+ &builder->global_stream, SpvStorageClassInput,
+ builtin->component_type, builtin->component_count);
+ vkd3d_spirv_add_iface_variable(builder, input_id);
+ vkd3d_dxbc_compiler_decorate_builtin(compiler, input_id, builtin->spirv_builtin);
+
+ vkd3d_symbol_make_register(®_symbol, reg);
+ reg_symbol.id = input_id;
+ reg_symbol.info.reg.storage_class = SpvStorageClassInput;
+ reg_symbol.info.reg.component_type = builtin->component_type;
+ reg_symbol.info.reg.write_mask = vkd3d_write_mask_from_component_count(builtin->component_count);
+ vkd3d_dxbc_compiler_put_symbol(compiler, ®_symbol);
+ vkd3d_dxbc_compiler_emit_register_debug_name(builder, input_id, reg);
+}
+
static unsigned int vkd3d_dxbc_compiler_get_output_variable_index(
struct vkd3d_dxbc_compiler *compiler, unsigned int register_idx)
{
@@ -3649,7 +3708,12 @@ static void vkd3d_dxbc_compiler_emit_dcl_tgsm_structured(struct vkd3d_dxbc_compi
static void vkd3d_dxbc_compiler_emit_dcl_input(struct vkd3d_dxbc_compiler *compiler,
const struct vkd3d_shader_instruction *instruction)
{
- vkd3d_dxbc_compiler_emit_input(compiler, &instruction->declaration.dst, VKD3D_SIV_NONE);
+ const struct vkd3d_shader_dst_param *dst = &instruction->declaration.dst;
+
+ if (dst->reg.type != VKD3DSPR_INPUT)
+ vkd3d_dxbc_compiler_emit_input_register(compiler, dst);
+ else
+ vkd3d_dxbc_compiler_emit_input(compiler, dst, VKD3D_SIV_NONE);
}
static void vkd3d_dxbc_compiler_emit_interpolation_decorations(struct vkd3d_dxbc_compiler *compiler,
--
2.16.4
2
1