winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
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
List overview
wine-commits
May 2022
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
907 discussions
Start a n
N
ew thread
Paul Gofman : rsaenh: Factor out block_encrypt() function.
by Alexandre Julliard
16 May '22
16 May '22
Module: wine Branch: master Commit: dc9ab100fde217579185391c620445952babce54 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=dc9ab100fde217579185391c…
Author: Paul Gofman <pgofman(a)codeweavers.com> Date: Fri May 13 14:21:44 2022 -0500 rsaenh: Factor out block_encrypt() function. Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/rsaenh/rsaenh.c | 124 +++++++++++++++++++++++++++++---------------------- 1 file changed, 70 insertions(+), 54 deletions(-) diff --git a/dlls/rsaenh/rsaenh.c b/dlls/rsaenh/rsaenh.c index 140fdec40d5..76122be2756 100644 --- a/dlls/rsaenh/rsaenh.c +++ b/dlls/rsaenh/rsaenh.c @@ -96,7 +96,7 @@ typedef struct tagCRYPTKEY DWORD dwSaltLen; DWORD dwBlockLen; DWORD dwState; - KEY_CONTEXT context; + KEY_CONTEXT context; BYTE abKeyValue[RSAENH_MAX_KEY_SIZE]; BYTE abInitVector[RSAENH_MAX_BLOCK_SIZE]; BYTE abChainVector[RSAENH_MAX_BLOCK_SIZE]; @@ -526,6 +526,73 @@ static inline void init_data_blob(PCRYPT_DATA_BLOB pBlob) { pBlob->cbData = 0; } +/****************************************************************************** + * block_encrypt [Internal] + */ +BOOL block_encrypt(CRYPTKEY *key, BYTE *data, DWORD *data_len, DWORD buf_len, + BOOL final, KEY_CONTEXT *context, BYTE *chain_vector) +{ + BYTE *in, out[RSAENH_MAX_BLOCK_SIZE], o[RSAENH_MAX_BLOCK_SIZE]; + unsigned int encrypted_len, i, j, k; + + if (!final && (*data_len % key->dwBlockLen)) + { + SetLastError(NTE_BAD_DATA); + return FALSE; + } + + encrypted_len = (*data_len / key->dwBlockLen + (final ? 1 : 0)) * key->dwBlockLen; + + if (data == NULL) + { + *data_len = encrypted_len; + return TRUE; + } + if (encrypted_len > buf_len) + { + *data_len = encrypted_len; + SetLastError(ERROR_MORE_DATA); + return FALSE; + } + + /* Pad final block with length bytes */ + for (i = *data_len; i < encrypted_len; i++) data[i] = encrypted_len - *data_len; + *data_len = encrypted_len; + + for (i = 0, in = data; i < *data_len; i += key->dwBlockLen, in += key->dwBlockLen) + { + switch (key->dwMode) { + case CRYPT_MODE_ECB: + encrypt_block_impl(key->aiAlgid, 0, context, in, out, + RSAENH_ENCRYPT); + break; + case CRYPT_MODE_CBC: + for (j = 0; j < key->dwBlockLen; j++) + in[j] ^= chain_vector[j]; + encrypt_block_impl(key->aiAlgid, 0, context, in, out, + RSAENH_ENCRYPT); + memcpy(chain_vector, out, key->dwBlockLen); + break; + case CRYPT_MODE_CFB: + for (j = 0; j < key->dwBlockLen; j++) + { + encrypt_block_impl(key->aiAlgid, 0, context, + chain_vector, o, RSAENH_ENCRYPT); + out[j] = in[j] ^ o[0]; + for (k = 0; k < key->dwBlockLen - 1; k++) + chain_vector[k] = chain_vector[k+1]; + chain_vector[k] = out[j]; + } + break; + default: + SetLastError(NTE_BAD_ALGID); + return FALSE; + } + memcpy(in, out, key->dwBlockLen); + } + return TRUE; +} + /****************************************************************************** * free_hmac_info [Internal] * @@ -2515,8 +2582,6 @@ BOOL WINAPI RSAENH_CPEncrypt(HCRYPTPROV hProv, HCRYPTKEY hKey, HCRYPTHASH hHash, DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen, DWORD dwBufLen) { CRYPTKEY *pCryptKey; - BYTE *in, out[RSAENH_MAX_BLOCK_SIZE], o[RSAENH_MAX_BLOCK_SIZE]; - DWORD dwEncryptedLen, i, j, k; TRACE("(hProv=%08Ix, hKey=%08Ix, hHash=%08Ix, Final=%d, dwFlags=%08lx, pbData=%p, " "pdwDataLen=%p, dwBufLen=%ld)\n", hProv, hKey, hHash, Final, dwFlags, pbData, pdwDataLen, @@ -2554,58 +2619,9 @@ BOOL WINAPI RSAENH_CPEncrypt(HCRYPTPROV hProv, HCRYPTKEY hKey, HCRYPTHASH hHash, } if (GET_ALG_TYPE(pCryptKey->aiAlgid) == ALG_TYPE_BLOCK) { - if (!Final && (*pdwDataLen % pCryptKey->dwBlockLen)) { - SetLastError(NTE_BAD_DATA); + if (!block_encrypt(pCryptKey, pbData, pdwDataLen, dwBufLen, Final, + &pCryptKey->context, pCryptKey->abChainVector)) return FALSE; - } - - dwEncryptedLen = (*pdwDataLen/pCryptKey->dwBlockLen+(Final?1:0))*pCryptKey->dwBlockLen; - - if (pbData == NULL) { - *pdwDataLen = dwEncryptedLen; - return TRUE; - } - else if (dwEncryptedLen > dwBufLen) { - *pdwDataLen = dwEncryptedLen; - SetLastError(ERROR_MORE_DATA); - return FALSE; - } - - /* Pad final block with length bytes */ - for (i=*pdwDataLen; i<dwEncryptedLen; i++) pbData[i] = dwEncryptedLen - *pdwDataLen; - *pdwDataLen = dwEncryptedLen; - - for (i=0, in=pbData; i<*pdwDataLen; i+=pCryptKey->dwBlockLen, in+=pCryptKey->dwBlockLen) { - switch (pCryptKey->dwMode) { - case CRYPT_MODE_ECB: - encrypt_block_impl(pCryptKey->aiAlgid, 0, &pCryptKey->context, in, out, - RSAENH_ENCRYPT); - break; - - case CRYPT_MODE_CBC: - for (j=0; j<pCryptKey->dwBlockLen; j++) in[j] ^= pCryptKey->abChainVector[j]; - encrypt_block_impl(pCryptKey->aiAlgid, 0, &pCryptKey->context, in, out, - RSAENH_ENCRYPT); - memcpy(pCryptKey->abChainVector, out, pCryptKey->dwBlockLen); - break; - - case CRYPT_MODE_CFB: - for (j=0; j<pCryptKey->dwBlockLen; j++) { - encrypt_block_impl(pCryptKey->aiAlgid, 0, &pCryptKey->context, - pCryptKey->abChainVector, o, RSAENH_ENCRYPT); - out[j] = in[j] ^ o[0]; - for (k=0; k<pCryptKey->dwBlockLen-1; k++) - pCryptKey->abChainVector[k] = pCryptKey->abChainVector[k+1]; - pCryptKey->abChainVector[k] = out[j]; - } - break; - - default: - SetLastError(NTE_BAD_ALGID); - return FALSE; - } - memcpy(in, out, pCryptKey->dwBlockLen); - } } else if (GET_ALG_TYPE(pCryptKey->aiAlgid) == ALG_TYPE_STREAM) { if (pbData == NULL) { *pdwDataLen = dwBufLen;
1
0
0
0
Paul Gofman : rsaenh: Handle uneven hash data updates sizes for CALG_MAC.
by Alexandre Julliard
16 May '22
16 May '22
Module: wine Branch: master Commit: 6bb21c771b41655f4e3b4c653c9c3a7ef1fc1346 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=6bb21c771b41655f4e3b4c65…
Author: Paul Gofman <pgofman(a)codeweavers.com> Date: Fri May 13 10:25:08 2022 -0500 rsaenh: Handle uneven hash data updates sizes for CALG_MAC. Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/rsaenh/rsaenh.c | 59 +++++++++++++++++++++++++++++++++++++++------- dlls/rsaenh/tests/rsaenh.c | 30 ++++++++++++++++++++++- 2 files changed, 79 insertions(+), 10 deletions(-) diff --git a/dlls/rsaenh/rsaenh.c b/dlls/rsaenh/rsaenh.c index f9513d0533e..140fdec40d5 100644 --- a/dlls/rsaenh/rsaenh.c +++ b/dlls/rsaenh/rsaenh.c @@ -63,6 +63,7 @@ typedef struct tagCRYPTHASH BYTE abHashValue[RSAENH_MAX_HASH_SIZE]; PHMAC_INFO pHMACInfo; RSAENH_TLS1PRF_PARAMS tpPRFParams; + DWORD buffered_hash_bytes; } CRYPTHASH; /****************************************************************************** @@ -661,6 +662,7 @@ static inline BOOL init_hash(CRYPTHASH *pCryptHash) { static inline void update_hash(CRYPTHASH *pCryptHash, const BYTE *pbData, DWORD dwDataLen) { BYTE *pbTemp; + DWORD len; switch (pCryptHash->aiAlgid) { @@ -670,12 +672,49 @@ static inline void update_hash(CRYPTHASH *pCryptHash, const BYTE *pbData, DWORD break; case CALG_MAC: - pbTemp = malloc(dwDataLen); - if (!pbTemp) return; - memcpy(pbTemp, pbData, dwDataLen); - RSAENH_CPEncrypt(pCryptHash->hProv, pCryptHash->hKey, 0, FALSE, 0, - pbTemp, &dwDataLen, dwDataLen); - free(pbTemp); + if (pCryptHash->buffered_hash_bytes) + { + len = min(pCryptHash->dwHashSize - pCryptHash->buffered_hash_bytes, dwDataLen); + memcpy(pCryptHash->abHashValue + pCryptHash->buffered_hash_bytes, pbData, len); + pbData += len; + dwDataLen -= len; + pCryptHash->buffered_hash_bytes += len; + if (pCryptHash->buffered_hash_bytes < pCryptHash->dwHashSize) + return; + pCryptHash->buffered_hash_bytes = 0; + len = pCryptHash->dwHashSize; + if (!RSAENH_CPEncrypt(pCryptHash->hProv, pCryptHash->hKey, 0, FALSE, 0, + pCryptHash->abHashValue, &len, len)) + { + FIXME("RSAENH_CPEncrypt failed.\n"); + return; + } + } + len = dwDataLen - dwDataLen % pCryptHash->dwHashSize; + if (len) + { + pbTemp = malloc(len); + if (!pbTemp) + { + ERR("No memory.\n"); + return; + } + memcpy(pbTemp, pbData, len); + pbData += len; + dwDataLen -= len; + if (!RSAENH_CPEncrypt(pCryptHash->hProv, pCryptHash->hKey, 0, FALSE, 0, + pbTemp, &len, len)) + { + FIXME("RSAENH_CPEncrypt failed.\n"); + return; + } + free(pbTemp); + } + if (dwDataLen) + { + memcpy(pCryptHash->abHashValue, pbData, dwDataLen); + pCryptHash->buffered_hash_bytes = dwDataLen; + } break; default: @@ -715,9 +754,10 @@ static inline void finalize_hash(CRYPTHASH *pCryptHash) { break; case CALG_MAC: - dwDataLen = 0; - RSAENH_CPEncrypt(pCryptHash->hProv, pCryptHash->hKey, 0, TRUE, 0, - pCryptHash->abHashValue, &dwDataLen, pCryptHash->dwHashSize); + dwDataLen = pCryptHash->buffered_hash_bytes; + if (!RSAENH_CPEncrypt(pCryptHash->hProv, pCryptHash->hKey, 0, TRUE, 0, + pCryptHash->abHashValue, &dwDataLen, pCryptHash->dwHashSize)) + FIXME("RSAENH_CPEncrypt failed.\n"); break; default: @@ -2217,6 +2257,7 @@ BOOL WINAPI RSAENH_CPCreateHash(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey, pCryptHash->pHMACInfo = NULL; pCryptHash->hash_handle = NULL; pCryptHash->dwHashSize = peaAlgidInfo->dwDefaultLen >> 3; + pCryptHash->buffered_hash_bytes = 0; init_data_blob(&pCryptHash->tpPRFParams.blobLabel); init_data_blob(&pCryptHash->tpPRFParams.blobSeed); diff --git a/dlls/rsaenh/tests/rsaenh.c b/dlls/rsaenh/tests/rsaenh.c index f822c29bbc0..c9dbb72f427 100644 --- a/dlls/rsaenh/tests/rsaenh.c +++ b/dlls/rsaenh/tests/rsaenh.c @@ -1853,6 +1853,7 @@ static void test_mac(void) { DWORD dwLen; BYTE abData[256], abEnc[264]; static const BYTE mac_40[8] = { 0xb7, 0xa2, 0x46, 0xe9, 0x11, 0x31, 0xe0, 0xad}; + static const BYTE mac_40_2[8] = { 0xef, 0x22, 0x0a, 0x3b, 0xd0, 0xab, 0x48, 0x49}; int i; for (i=0; i < ARRAY_SIZE(abData); i++) abData[i] = (BYTE)i; @@ -1876,7 +1877,34 @@ static void test_mac(void) { ok(result && dwLen == 8, "%08lx, dwLen: %ld\n", GetLastError(), dwLen); ok(!memcmp(abData, mac_40, sizeof(mac_40)), "MAC failed!\n"); - + + for (i = 0; i < ARRAY_SIZE(abData); ++i) + abData[i] = (BYTE)i; + + result = CryptHashData(hHash, abData, 1, 0); + ok(!result && GetLastError() == NTE_BAD_HASH_STATE, "Unexpected result %d, error %#lx\n", result, GetLastError()); + + result = CryptDestroyHash(hHash); + ok(result, "%08lx\n", GetLastError()); + + result = CryptCreateHash(hProv, CALG_MAC, hKey, 0, &hHash); + ok(result, "%08lx\n", GetLastError()); + + result = CryptHashData(hHash, abData, 1, 0); + ok(result, "%08lx\n", GetLastError()); + result = CryptHashData(hHash, abData + 1, 1, 0); + ok(result, "%08lx\n", GetLastError()); + result = CryptHashData(hHash, abData + 2, 6, 0); + ok(result, "%08lx\n", GetLastError()); + result = CryptHashData(hHash, abData + 8, 9, 0); + ok(result, "%08lx\n", GetLastError()); + + dwLen = ARRAY_SIZE(abData); + result = CryptGetHashParam(hHash, HP_HASHVAL, abData, &dwLen, 0); + ok(result && dwLen == 8, "%08lx, dwLen %ld\n", GetLastError(), dwLen); + + ok(!memcmp(abData, mac_40_2, sizeof(mac_40)), "Hash does not match.\n"); + result = CryptDestroyHash(hHash); ok(result, "%08lx\n", GetLastError());
1
0
0
0
Paul Gofman : rsaenh: Use CRT memory allocators.
by Alexandre Julliard
16 May '22
16 May '22
Module: wine Branch: master Commit: cec9705008415382ab776b04d70fbe30f05a42f6 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=cec9705008415382ab776b04…
Author: Paul Gofman <pgofman(a)codeweavers.com> Date: Fri May 13 11:23:25 2022 -0500 rsaenh: Use CRT memory allocators. Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/rsaenh/handle.c | 11 ++++---- dlls/rsaenh/implglue.c | 15 ++++++----- dlls/rsaenh/mpi.c | 15 ++++++----- dlls/rsaenh/rsaenh.c | 71 +++++++++++++++++++++++++------------------------- 4 files changed, 58 insertions(+), 54 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=cec9705008415382ab77…
1
0
0
0
Stefan Dösinger : wined3d: Make normalized format handling more generic in wined3d_format_convert_from_float.
by Alexandre Julliard
16 May '22
16 May '22
Module: wine Branch: master Commit: d72942e9076b83c13ef0eb76cad7b0dc76def063 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=d72942e9076b83c13ef0eb76…
Author: Stefan Dösinger <stefan(a)codeweavers.com> Date: Mon May 16 12:58:07 2022 -0500 wined3d: Make normalized format handling more generic in wined3d_format_convert_from_float. Signed-off-by: Stefan Dösinger <stefan(a)codeweavers.com> Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/wined3d/utils.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 59a4fd29e51..088a904ffeb 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -6027,21 +6027,6 @@ void wined3d_format_convert_from_float(const struct wined3d_format *format, } float_conv[] = { - {WINED3DFMT_B8G8R8A8_UNORM, { 255.0f, 255.0f, 255.0f, 255.0f}, {16, 8, 0, 24}}, - {WINED3DFMT_B8G8R8X8_UNORM, { 255.0f, 255.0f, 255.0f, 255.0f}, {16, 8, 0, 24}}, - {WINED3DFMT_B8G8R8_UNORM, { 255.0f, 255.0f, 255.0f, 255.0f}, {16, 8, 0, 24}}, - {WINED3DFMT_B5G6R5_UNORM, { 31.0f, 63.0f, 31.0f, 0.0f}, {11, 5, 0, 0}}, - {WINED3DFMT_B5G5R5A1_UNORM, { 31.0f, 31.0f, 31.0f, 1.0f}, {10, 5, 0, 15}}, - {WINED3DFMT_B5G5R5X1_UNORM, { 31.0f, 31.0f, 31.0f, 1.0f}, {10, 5, 0, 15}}, - {WINED3DFMT_R8_UNORM, { 255.0f, 0.0f, 0.0f, 0.0f}, { 0, 0, 0, 0}}, - {WINED3DFMT_A8_UNORM, { 0.0f, 0.0f, 0.0f, 255.0f}, { 0, 0, 0, 0}}, - {WINED3DFMT_B4G4R4A4_UNORM, { 15.0f, 15.0f, 15.0f, 15.0f}, { 8, 4, 0, 12}}, - {WINED3DFMT_B4G4R4X4_UNORM, { 15.0f, 15.0f, 15.0f, 15.0f}, { 8, 4, 0, 12}}, - {WINED3DFMT_B2G3R3_UNORM, { 7.0f, 7.0f, 3.0f, 0.0f}, { 5, 2, 0, 0}}, - {WINED3DFMT_R8G8B8A8_UNORM, { 255.0f, 255.0f, 255.0f, 255.0f}, { 0, 8, 16, 24}}, - {WINED3DFMT_R8G8B8X8_UNORM, { 255.0f, 255.0f, 255.0f, 255.0f}, { 0, 8, 16, 24}}, - {WINED3DFMT_B10G10R10A2_UNORM, { 1023.0f, 1023.0f, 1023.0f, 3.0f}, {20, 10, 0, 30}}, - {WINED3DFMT_R10G10B10A2_UNORM, { 1023.0f, 1023.0f, 1023.0f, 3.0f}, { 0, 10, 20, 30}}, {WINED3DFMT_P8_UINT, { 0.0f, 0.0f, 0.0f, 255.0f}, { 0, 0, 0, 0}}, {WINED3DFMT_S1_UINT_D15_UNORM, { 32767.0f, 0.0f, 0.0f, 0.0f}, { 0, 0, 0, 0}}, {WINED3DFMT_D16_UNORM, { 65535.0f, 0.0f, 0.0f, 0.0f}, { 0, 0, 0, 0}}, @@ -6126,6 +6111,27 @@ void wined3d_format_convert_from_float(const struct wined3d_format *format, return; } + if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_NORMALISED) + { + uint32_t *ret_i = ret; + + idx.x = format->red_offset / 32; + idx.y = format->green_offset / 32; + idx.z = format->blue_offset / 32; + idx.w = format->alpha_offset / 32; + shift.x = format->red_offset % 32; + shift.y = format->green_offset % 32; + shift.z = format->blue_offset % 32; + shift.w = format->alpha_offset % 32; + + ret_i[idx.x] = ((uint32_t)((color->r * wined3d_mask_from_size(format->red_size)) + 0.5f)) << shift.x; + ret_i[idx.y] |= ((uint32_t)((color->g * wined3d_mask_from_size(format->green_size)) + 0.5f)) << shift.y; + ret_i[idx.z] |= ((uint32_t)((color->b * wined3d_mask_from_size(format->blue_size)) + 0.5f)) << shift.z; + ret_i[idx.w] |= ((uint32_t)((color->a * wined3d_mask_from_size(format->alpha_size)) + 0.5f)) << shift.w; + + return; + } + /* 32 bit float formats. We don't handle D32_FLOAT and D32_FLOAT_S8X24_UINT for now. */ if ((format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT) && format->red_size == 32) {
1
0
0
0
Stefan Dösinger : wined3d: Mark some d3d9 formats as normalized formats.
by Alexandre Julliard
16 May '22
16 May '22
Module: wine Branch: master Commit: 6cb0e8d025bb291fc8dca04122916c8e20649938 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=6cb0e8d025bb291fc8dca041…
Author: Stefan Dösinger <stefan(a)codeweavers.com> Date: Mon May 16 12:58:06 2022 -0500 wined3d: Mark some d3d9 formats as normalized formats. Signed-off-by: Stefan Dösinger <stefan(a)codeweavers.com> Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/wined3d/utils.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 892020e2aa9..59a4fd29e51 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -346,6 +346,16 @@ static const struct wined3d_format_base_flags format_base_flags[] = {WINED3DFMT_R32_UINT, WINED3DFMT_FLAG_CAST_TO_BLOCK | WINED3DFMT_FLAG_INDEX_BUFFER}, {WINED3DFMT_R32_SINT, WINED3DFMT_FLAG_CAST_TO_BLOCK}, {WINED3DFMT_R16_UINT, WINED3DFMT_FLAG_INDEX_BUFFER}, + {WINED3DFMT_A8_UNORM, WINED3DFMT_FLAG_NORMALISED}, + {WINED3DFMT_B10G10R10A2_UNORM, WINED3DFMT_FLAG_NORMALISED}, + {WINED3DFMT_B2G3R3_UNORM, WINED3DFMT_FLAG_NORMALISED}, + {WINED3DFMT_B4G4R4A4_UNORM, WINED3DFMT_FLAG_NORMALISED}, + {WINED3DFMT_B4G4R4X4_UNORM, WINED3DFMT_FLAG_NORMALISED}, + {WINED3DFMT_B5G5R5A1_UNORM, WINED3DFMT_FLAG_NORMALISED}, + {WINED3DFMT_B5G5R5X1_UNORM, WINED3DFMT_FLAG_NORMALISED}, + {WINED3DFMT_B5G6R5_UNORM, WINED3DFMT_FLAG_NORMALISED}, + {WINED3DFMT_B8G8R8_UNORM, WINED3DFMT_FLAG_NORMALISED}, + {WINED3DFMT_R10G10B10A2_UNORM, WINED3DFMT_FLAG_NORMALISED}, }; static void rgb888_from_rgb565(WORD rgb565, BYTE *r, BYTE *g, BYTE *b)
1
0
0
0
Stefan Dösinger : wined3d: Support CPU clear of float16 formats.
by Alexandre Julliard
16 May '22
16 May '22
Module: wine Branch: master Commit: e8c9588e2ad4168380fda86e7ebc3dfd56c3e863 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=e8c9588e2ad4168380fda86e…
Author: Stefan Dösinger <stefan(a)codeweavers.com> Date: Mon May 16 12:58:05 2022 -0500 wined3d: Support CPU clear of float16 formats. Signed-off-by: Stefan Dösinger <stefan(a)codeweavers.com> Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/wined3d/surface.c | 63 ----------------------------------- dlls/wined3d/utils.c | 25 ++++++++++++++ dlls/wined3d/wined3d_private.h | 75 ++++++++++++++++++++++++++++++++++++++---- 3 files changed, 93 insertions(+), 70 deletions(-) diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 0d4809ea55b..29bdef9844f 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -39,69 +39,6 @@ static void get_color_masks(const struct wined3d_format *format, uint32_t *masks masks[2] = wined3d_mask_from_size(format->blue_size) << format->blue_offset; } -/* See also float_16_to_32() in wined3d_private.h */ -static inline unsigned short float_32_to_16(const float *in) -{ - int exp = 0; - float tmp = fabsf(*in); - unsigned int mantissa; - unsigned short ret; - - /* Deal with special numbers */ - if (*in == 0.0f) - return 0x0000; - if (isnan(*in)) - return 0x7c01; - if (isinf(*in)) - return (*in < 0.0f ? 0xfc00 : 0x7c00); - - if (tmp < (float)(1u << 10)) - { - do - { - tmp = tmp * 2.0f; - exp--; - } while (tmp < (float)(1u << 10)); - } - else if (tmp >= (float)(1u << 11)) - { - do - { - tmp /= 2.0f; - exp++; - } while (tmp >= (float)(1u << 11)); - } - - mantissa = (unsigned int)tmp; - if (tmp - mantissa >= 0.5f) - ++mantissa; /* Round to nearest, away from zero. */ - - exp += 10; /* Normalize the mantissa. */ - exp += 15; /* Exponent is encoded with excess 15. */ - - if (exp > 30) /* too big */ - { - ret = 0x7c00; /* INF */ - } - else if (exp <= 0) - { - /* exp == 0: Non-normalized mantissa. Returns 0x0000 (=0.0) for too small numbers. */ - while (exp <= 0) - { - mantissa = mantissa >> 1; - ++exp; - } - ret = mantissa & 0x3ff; - } - else - { - ret = (exp << 10) | (mantissa & 0x3ff); - } - - ret |= ((*in < 0.0f ? 1 : 0) << 15); /* Add the sign */ - return ret; -} - static void convert_r32_float_r16_float(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h) { diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 6d785c461d4..892020e2aa9 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -6137,6 +6137,31 @@ void wined3d_format_convert_from_float(const struct wined3d_format *format, return; } + if ((format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT) && format->red_size == 16) + { + uint16_t *ret_s = ret; + + switch (format->byte_count) + { + case 8: + ret_s[3] = float_32_to_16(&color->a); + ret_s[2] = float_32_to_16(&color->b); + /* fall through */ + case 4: + ret_s[1] = float_32_to_16(&color->g); + /* fall through */ + case 2: + ret_s[0] = float_32_to_16(&color->r); + break; + + default: + ERR("Unexpected byte count %u, format %s.\n", format->byte_count, debug_d3dformat(format_id)); + break; + } + + return; + } + FIXME("Conversion for format %s not implemented.\n", debug_d3dformat(format_id)); } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 37cec7dd2c3..1d8bb40cec4 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -354,13 +354,12 @@ static inline GLenum wined3d_gl_min_mip_filter(enum wined3d_texture_filter_type return minMipLookup[min_filter].mip[mip_filter]; } -/* float_16_to_32() and float_32_to_16() (see implementation in - * surface_base.c) convert 16 bit floats in the FLOAT16 data type - * to standard C floats and vice versa. They do not depend on the encoding - * of the C float, so they are platform independent, but slow. On x86 and - * other IEEE 754 compliant platforms the conversion can be accelerated by - * bit shifting the exponent and mantissa. There are also some SSE-based - * assembly routines out there. +/* float_16_to_32() and float_32_to_16() convert 16 bit floats in the + * FLOAT16 data type to standard C floats and vice versa. They do not + * depend on the encoding of the C float, so they are platform independent, + * but slow. On x86 and other IEEE 754 compliant platforms the conversion + * can be accelerated by bit shifting the exponent and mantissa. There are + * also some SSE-based assembly routines out there. * * See GL_NV_half_float for a reference of the FLOAT16 / GL_HALF format */ @@ -404,6 +403,68 @@ static inline float float_24_to_32(DWORD in) } } +static inline unsigned short float_32_to_16(const float *in) +{ + int exp = 0; + float tmp = fabsf(*in); + unsigned int mantissa; + unsigned short ret; + + /* Deal with special numbers */ + if (*in == 0.0f) + return 0x0000; + if (isnan(*in)) + return 0x7c01; + if (isinf(*in)) + return (*in < 0.0f ? 0xfc00 : 0x7c00); + + if (tmp < (float)(1u << 10)) + { + do + { + tmp = tmp * 2.0f; + exp--; + } while (tmp < (float)(1u << 10)); + } + else if (tmp >= (float)(1u << 11)) + { + do + { + tmp /= 2.0f; + exp++; + } while (tmp >= (float)(1u << 11)); + } + + mantissa = (unsigned int)tmp; + if (tmp - mantissa >= 0.5f) + ++mantissa; /* Round to nearest, away from zero. */ + + exp += 10; /* Normalize the mantissa. */ + exp += 15; /* Exponent is encoded with excess 15. */ + + if (exp > 30) /* too big */ + { + ret = 0x7c00; /* INF */ + } + else if (exp <= 0) + { + /* exp == 0: Non-normalized mantissa. Returns 0x0000 (=0.0) for too small numbers. */ + while (exp <= 0) + { + mantissa = mantissa >> 1; + ++exp; + } + ret = mantissa & 0x3ff; + } + else + { + ret = (exp << 10) | (mantissa & 0x3ff); + } + + ret |= ((*in < 0.0f ? 1 : 0) << 15); /* Add the sign */ + return ret; +} + static inline unsigned int wined3d_popcount(unsigned int x) { #if defined(__MINGW32__)
1
0
0
0
Stefan Dösinger : wined3d: Add support for sysmem-clearing float32 formats.
by Alexandre Julliard
16 May '22
16 May '22
Module: wine Branch: master Commit: f6374144466d0b5087f63862c5137bd5140cfb04 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=f6374144466d0b5087f63862…
Author: Stefan Dösinger <stefan(a)codeweavers.com> Date: Mon May 16 12:58:04 2022 -0500 wined3d: Add support for sysmem-clearing float32 formats. Signed-off-by: Stefan Dösinger <stefan(a)codeweavers.com> Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/wined3d/resource.c | 7 +++++++ dlls/wined3d/utils.c | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index 073bc5b5834..7fefd516908 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -669,6 +669,13 @@ void wined3d_resource_memory_colour_fill(struct wined3d_resource *resource, } break; + case 8: + case 12: + case 16: + for (x = 0; x < w; ++x) + memcpy(((uint8_t *)map->data) + x * bpp, c, bpp); + break; + default: FIXME("Not implemented for bpp %u.\n", bpp); return; diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 6fe792c015f..6d785c461d4 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -6116,6 +6116,27 @@ void wined3d_format_convert_from_float(const struct wined3d_format *format, return; } + /* 32 bit float formats. We don't handle D32_FLOAT and D32_FLOAT_S8X24_UINT for now. */ + if ((format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_FLOAT) && format->red_size == 32) + { + float *ret_f = ret; + + switch (format->byte_count) + { + case 16: ret_f[3] = color->a; + case 12: ret_f[2] = color->b; + case 8: ret_f[1] = color->g; + case 4: ret_f[0] = color->r; + break; + + default: + ERR("Unexpected byte count %u, format %s.\n", format->byte_count, debug_d3dformat(format_id)); + break; + } + + return; + } + FIXME("Conversion for format %s not implemented.\n", debug_d3dformat(format_id)); }
1
0
0
0
Stefan Dösinger : wined3d: Prepare wined3d_format_convert_from_float for > 32bpp formats.
by Alexandre Julliard
16 May '22
16 May '22
Module: wine Branch: master Commit: 2465e1e1da03fc3ec5c6ab537d1d7549f932b280 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=2465e1e1da03fc3ec5c6ab53…
Author: Stefan Dösinger <stefan(a)codeweavers.com> Date: Mon May 16 12:58:03 2022 -0500 wined3d: Prepare wined3d_format_convert_from_float for > 32bpp formats. Signed-off-by: Stefan Dösinger <stefan(a)codeweavers.com> Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/wined3d/device.c | 4 +-- dlls/wined3d/resource.c | 16 +++++------ dlls/wined3d/utils.c | 60 +++++++++++++++++++++++++++++------------- dlls/wined3d/wined3d_private.h | 4 +-- 4 files changed, 54 insertions(+), 30 deletions(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 8937c7fc0fc..d39634c49fc 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3689,7 +3689,7 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO diffuse_colour = material_diffuse; } wined3d_color_clamp(&diffuse_colour, &diffuse_colour, 0.0f, 1.0f); - *((DWORD *)dest_ptr) = wined3d_format_convert_from_float(output_colour_format, &diffuse_colour); + wined3d_format_convert_from_float(output_colour_format, &diffuse_colour, dest_ptr); dest_ptr += sizeof(DWORD); } @@ -3713,7 +3713,7 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO } update_fog_factor(&specular_colour.a, &ls); wined3d_color_clamp(&specular_colour, &specular_colour, 0.0f, 1.0f); - *((DWORD *)dest_ptr) = wined3d_format_convert_from_float(output_colour_format, &specular_colour); + wined3d_format_convert_from_float(output_colour_format, &specular_colour, dest_ptr); dest_ptr += sizeof(DWORD); } diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index 7587a6455a4..073bc5b5834 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -621,7 +621,7 @@ void wined3d_resource_memory_colour_fill(struct wined3d_resource *resource, const struct wined3d_format *format = resource->format; unsigned int w, h, d, x, y, z, bpp; uint8_t *dst, *dst2; - uint32_t c; + uint32_t c[4]; w = box->right - box->left; h = box->bottom - box->top; @@ -632,7 +632,7 @@ void wined3d_resource_memory_colour_fill(struct wined3d_resource *resource, + ((box->top / format->block_height) * map->row_pitch) + ((box->left / format->block_width) * format->block_byte_count); - c = wined3d_format_convert_from_float(format, colour); + wined3d_format_convert_from_float(format, colour, c); bpp = format->byte_count; switch (bpp) @@ -640,14 +640,14 @@ void wined3d_resource_memory_colour_fill(struct wined3d_resource *resource, case 1: for (x = 0; x < w; ++x) { - dst[x] = c; + dst[x] = c[0]; } break; case 2: for (x = 0; x < w; ++x) { - ((uint16_t *)dst)[x] = c; + ((uint16_t *)dst)[x] = c[0]; } break; @@ -656,16 +656,16 @@ void wined3d_resource_memory_colour_fill(struct wined3d_resource *resource, dst2 = dst; for (x = 0; x < w; ++x, dst2 += 3) { - dst2[0] = (c ) & 0xff; - dst2[1] = (c >> 8) & 0xff; - dst2[2] = (c >> 16) & 0xff; + dst2[0] = (c[0] ) & 0xff; + dst2[1] = (c[0] >> 8) & 0xff; + dst2[2] = (c[0] >> 16) & 0xff; } break; } case 4: for (x = 0; x < w; ++x) { - ((uint32_t *)dst)[x] = c; + ((uint32_t *)dst)[x] = c[0]; } break; diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 401d815a365..6fe792c015f 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -6000,8 +6000,14 @@ uint32_t wined3d_format_pack(const struct wined3d_format *format, const struct w /* Note: It's the caller's responsibility to ensure values can be expressed * in the requested format. UNORM formats for example can only express values - * in the range 0.0f -> 1.0f. */ -DWORD wined3d_format_convert_from_float(const struct wined3d_format *format, const struct wined3d_color *color) + * in the range 0.0f -> 1.0f. + * + * The code below assumes that no component crosses the 32 bit boundary (like + * e.g. a hypothetical, and totally braindead, B30G30R4 format would). + * This function writes at least sizeof(uint32_t) bytes, or format->byte_count, + * whichever is larger. */ +void wined3d_format_convert_from_float(const struct wined3d_format *format, + const struct wined3d_color *color, void *ret) { static const struct { @@ -6044,10 +6050,11 @@ DWORD wined3d_format_convert_from_float(const struct wined3d_format *format, con }; enum wined3d_format_id format_id = format->id; struct wined3d_color colour_srgb; + struct wined3d_uvec4 idx, shift; unsigned int i; - DWORD ret; TRACE("Converting colour %s to format %s.\n", debug_color(color), debug_d3dformat(format_id)); + memset(ret, 0, max(sizeof(uint32_t), format->byte_count)); for (i = 0; i < ARRAY_SIZE(format_srgb_info); ++i) { @@ -6062,37 +6069,54 @@ DWORD wined3d_format_convert_from_float(const struct wined3d_format *format, con for (i = 0; i < ARRAY_SIZE(float_conv); ++i) { + uint32_t *ret_i = ret; + if (format_id != float_conv[i].format_id) continue; - ret = ((DWORD)((color->r * float_conv[i].mul.x) + 0.5f)) << float_conv[i].shift.x; - ret |= ((DWORD)((color->g * float_conv[i].mul.y) + 0.5f)) << float_conv[i].shift.y; - ret |= ((DWORD)((color->b * float_conv[i].mul.z) + 0.5f)) << float_conv[i].shift.z; - ret |= ((DWORD)((color->a * float_conv[i].mul.w) + 0.5f)) << float_conv[i].shift.w; + idx.x = float_conv[i].shift.x / 32; + idx.y = float_conv[i].shift.y / 32; + idx.z = float_conv[i].shift.z / 32; + idx.w = float_conv[i].shift.w / 32; + shift.x = float_conv[i].shift.x % 32; + shift.y = float_conv[i].shift.y % 32; + shift.z = float_conv[i].shift.z % 32; + shift.w = float_conv[i].shift.w % 32; - TRACE("Returning 0x%08x.\n", ret); + ret_i[idx.x] = ((uint32_t)((color->r * float_conv[i].mul.x) + 0.5f)) << shift.x; + ret_i[idx.y] |= ((uint32_t)((color->g * float_conv[i].mul.y) + 0.5f)) << shift.y; + ret_i[idx.z] |= ((uint32_t)((color->b * float_conv[i].mul.z) + 0.5f)) << shift.z; + ret_i[idx.w] |= ((uint32_t)((color->a * float_conv[i].mul.w) + 0.5f)) << shift.w; - return ret; + return; } for (i = 0; i < ARRAY_SIZE(double_conv); ++i) { + uint32_t *ret_i; + if (format_id != double_conv[i].format_id) continue; - ret = ((DWORD)((color->r * double_conv[i].mul.x) + 0.5)) << double_conv[i].shift.x; - ret |= ((DWORD)((color->g * double_conv[i].mul.y) + 0.5)) << double_conv[i].shift.y; - ret |= ((DWORD)((color->b * double_conv[i].mul.z) + 0.5)) << double_conv[i].shift.z; - ret |= ((DWORD)((color->a * double_conv[i].mul.w) + 0.5)) << double_conv[i].shift.w; + idx.x = double_conv[i].shift.x / 32; + idx.y = double_conv[i].shift.y / 32; + idx.z = double_conv[i].shift.z / 32; + idx.w = double_conv[i].shift.w / 32; + shift.x = double_conv[i].shift.x % 32; + shift.y = double_conv[i].shift.y % 32; + shift.z = double_conv[i].shift.z % 32; + shift.w = double_conv[i].shift.w % 32; + + ret_i = ret; + ret_i[idx.x] = ((uint32_t)((color->r * double_conv[i].mul.x) + 0.5)) << shift.x; + ret_i[idx.y] |= ((uint32_t)((color->g * double_conv[i].mul.y) + 0.5)) << shift.y; + ret_i[idx.z] |= ((uint32_t)((color->b * double_conv[i].mul.z) + 0.5)) << shift.z; + ret_i[idx.w] |= ((uint32_t)((color->a * double_conv[i].mul.w) + 0.5)) << shift.w; - TRACE("Returning 0x%08x.\n", ret); - - return ret; + return; } FIXME("Conversion for format %s not implemented.\n", debug_d3dformat(format_id)); - - return 0; } static float color_to_float(DWORD color, DWORD size, DWORD offset) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index ba1dc2169b0..37cec7dd2c3 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -6150,8 +6150,8 @@ void wined3d_format_calculate_pitch(const struct wined3d_format *format, unsigne unsigned int width, unsigned int height, unsigned int *row_pitch, unsigned int *slice_pitch) DECLSPEC_HIDDEN; UINT wined3d_format_calculate_size(const struct wined3d_format *format, UINT alignment, UINT width, UINT height, UINT depth) DECLSPEC_HIDDEN; -DWORD wined3d_format_convert_from_float(const struct wined3d_format *format, - const struct wined3d_color *color) DECLSPEC_HIDDEN; +void wined3d_format_convert_from_float(const struct wined3d_format *format, + const struct wined3d_color *color, void *ret) DECLSPEC_HIDDEN; void wined3d_format_copy_data(const struct wined3d_format *format, const uint8_t *src, unsigned int src_row_pitch, unsigned int src_slice_pitch, uint8_t *dst, unsigned int dst_row_pitch, unsigned int dst_slice_pitch, unsigned int w, unsigned int h, unsigned int d) DECLSPEC_HIDDEN;
1
0
0
0
Chip Davis : d3d11: Implement ID3D11Device1::CreateBlendState1().
by Alexandre Julliard
16 May '22
16 May '22
Module: wine Branch: master Commit: ff80861b4f5f0f915e28e0b3709421fe848b74cc URL:
https://source.winehq.org/git/wine.git/?a=commit;h=ff80861b4f5f0f915e28e0b3…
Author: Chip Davis <cdavis5x(a)gmail.com> Date: Mon May 16 12:58:02 2022 -0500 d3d11: Implement ID3D11Device1::CreateBlendState1(). Signed-off-by: Chip Davis <cdavis5x(a)gmail.com> Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/d3d11/d3d11_private.h | 12 +++--- dlls/d3d11/device.c | 65 +++++++++++++++++++---------- dlls/d3d11/state.c | 100 ++++++++++++++++++++++++++++++--------------- 3 files changed, 118 insertions(+), 59 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=ff80861b4f5f0f915e28…
1
0
0
0
Chip Davis : d3d11/tests: Test logic op.
by Alexandre Julliard
16 May '22
16 May '22
Module: wine Branch: master Commit: 5bdccb53ad05bf3afdf03f835b0e4fc2d0de96e8 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=5bdccb53ad05bf3afdf03f83…
Author: Chip Davis <cdavis5x(a)gmail.com> Date: Mon May 16 12:58:01 2022 -0500 d3d11/tests: Test logic op. Signed-off-by: Chip Davis <cdavis5x(a)gmail.com> Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/d3d11/tests/d3d11.c | 166 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index 6c0ae089f78..99f304e5b68 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -34034,6 +34034,171 @@ static void test_user_defined_annotation(void) release_test_context(&test_context); } +static void test_logic_op(void) +{ + D3D11_FEATURE_DATA_D3D11_OPTIONS options; + struct d3d11_test_context test_context; + D3D11_TEXTURE2D_DESC texture_desc; + ID3D11RenderTargetView *rtvs[8]; + ID3D11BlendState1 *blend_state; + ID3D11DeviceContext *context; + struct resource_readback rb; + ID3D11Texture2D *rts[8]; + ID3D11Device1 *device1; + ID3D11PixelShader *ps; + ID3D11Device *device; + unsigned int i, j; + DWORD color; + HRESULT hr; + + static const DWORD ps_code[] = + { +#if 0 + void main(float4 position : SV_Position, + out uint4 t0 : SV_Target0, out uint4 t1 : SV_Target1, + out uint4 t2 : SV_Target2, out uint4 t3 : SV_Target3, + out uint4 t4 : SV_Target4, out uint4 t5 : SV_Target5, + out uint4 t6 : SV_Target6, out uint4 t7 : SV_Target7) + { + t0 = t1 = t2 = t3 = t4 = t5 = t6 = t7 = uint4(0x00, 0x00, 0xff, 0xff); + } +#endif + 0x43425844, 0x4ed0bba7, 0x9f7d54c4, 0xba1e3dce, 0xc29634f8, 0x00000001, 0x000002b0, 0x00000003, + 0x0000002c, 0x00000060, 0x0000013c, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, + 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69, + 0x4e47534f, 0x000000d4, 0x00000008, 0x00000008, 0x000000c8, 0x00000000, 0x00000000, 0x00000001, + 0x00000000, 0x0000000f, 0x000000c8, 0x00000001, 0x00000000, 0x00000001, 0x00000001, 0x0000000f, + 0x000000c8, 0x00000002, 0x00000000, 0x00000001, 0x00000002, 0x0000000f, 0x000000c8, 0x00000003, + 0x00000000, 0x00000001, 0x00000003, 0x0000000f, 0x000000c8, 0x00000004, 0x00000000, 0x00000001, + 0x00000004, 0x0000000f, 0x000000c8, 0x00000005, 0x00000000, 0x00000001, 0x00000005, 0x0000000f, + 0x000000c8, 0x00000006, 0x00000000, 0x00000001, 0x00000006, 0x0000000f, 0x000000c8, 0x00000007, + 0x00000000, 0x00000001, 0x00000007, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, + 0x0000016c, 0x00000040, 0x0000005b, 0x03000065, 0x001020f2, 0x00000000, 0x03000065, 0x001020f2, + 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000003, 0x03000065, + 0x001020f2, 0x00000004, 0x03000065, 0x001020f2, 0x00000005, 0x03000065, 0x001020f2, 0x00000006, + 0x03000065, 0x001020f2, 0x00000007, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x00000000, + 0x00000000, 0x000000ff, 0x000000ff, 0x08000036, 0x001020f2, 0x00000001, 0x00004002, 0x00000000, + 0x00000000, 0x000000ff, 0x000000ff, 0x08000036, 0x001020f2, 0x00000002, 0x00004002, 0x00000000, + 0x00000000, 0x000000ff, 0x000000ff, 0x08000036, 0x001020f2, 0x00000003, 0x00004002, 0x00000000, + 0x00000000, 0x000000ff, 0x000000ff, 0x08000036, 0x001020f2, 0x00000004, 0x00004002, 0x00000000, + 0x00000000, 0x000000ff, 0x000000ff, 0x08000036, 0x001020f2, 0x00000005, 0x00004002, 0x00000000, + 0x00000000, 0x000000ff, 0x000000ff, 0x08000036, 0x001020f2, 0x00000006, 0x00004002, 0x00000000, + 0x00000000, 0x000000ff, 0x000000ff, 0x08000036, 0x001020f2, 0x00000007, 0x00004002, 0x00000000, + 0x00000000, 0x000000ff, 0x000000ff, 0x0100003e + }; + + D3D11_BLEND_DESC1 blend_desc = + { + .IndependentBlendEnable = TRUE, + .RenderTarget = + { + {FALSE, TRUE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, + D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, D3D11_LOGIC_OP_CLEAR, + D3D11_COLOR_WRITE_ENABLE_ALL}, + {FALSE, TRUE, D3D11_BLEND_ONE, D3D11_BLEND_ZERO, D3D11_BLEND_OP_ADD, + D3D11_BLEND_ZERO, D3D11_BLEND_ONE, D3D11_BLEND_OP_ADD, D3D11_LOGIC_OP_CLEAR, + D3D11_COLOR_WRITE_ENABLE_ALL}, + }, + }; + + static const struct + { + D3D11_LOGIC_OP op; + DWORD color; + } + tests[] = + { + {D3D11_LOGIC_OP_CLEAR, 0x00000000}, + {D3D11_LOGIC_OP_NOR, 0x000000ff}, + {D3D11_LOGIC_OP_AND_INVERTED, 0x0000ff00}, + {D3D11_LOGIC_OP_COPY_INVERTED, 0x0000ffff}, + {D3D11_LOGIC_OP_AND_REVERSE, 0x00ff0000}, + {D3D11_LOGIC_OP_INVERT, 0x00ff00ff}, + {D3D11_LOGIC_OP_XOR, 0x00ffff00}, + {D3D11_LOGIC_OP_NAND, 0x00ffffff}, + {D3D11_LOGIC_OP_AND, 0xff000000}, + {D3D11_LOGIC_OP_EQUIV, 0xff0000ff}, + {D3D11_LOGIC_OP_NOOP, 0xff00ff00}, + {D3D11_LOGIC_OP_OR_INVERTED, 0xff00ffff}, + {D3D11_LOGIC_OP_COPY, 0xffff0000}, + {D3D11_LOGIC_OP_OR_REVERSE, 0xffff00ff}, + {D3D11_LOGIC_OP_OR, 0xffffff00}, + {D3D11_LOGIC_OP_SET, 0xffffffff}, + }; + static const float clear_color[] = {0.0f, 255.0f, 0.0f, 255.0f}; + + if (!init_test_context(&test_context, NULL)) + return; + device = test_context.device; + context = test_context.immediate_context; + + if (FAILED(hr = ID3D11Device_CheckFeatureSupport(device, D3D11_FEATURE_D3D11_OPTIONS, &options, sizeof(options))) + || !options.OutputMergerLogicOp) + { + skip("Logic op is not supported.\n"); + release_test_context(&test_context); + return; + } + + hr = ID3D11Device_QueryInterface(device, &IID_ID3D11Device1, (void **)&device1); + ok(hr == S_OK, "Failed to get ID3D11Device1 interface, hr %#lx.\n", hr); + + hr = ID3D11Device_CreatePixelShader(device, ps_code, sizeof(ps_code), NULL, &ps); + ok(hr == S_OK, "Failed to create pixel shader, hr %#lx.\n", hr); + ID3D11DeviceContext_PSSetShader(context, ps, NULL, 0); + + hr = ID3D11Device1_CreateBlendState1(device1, &blend_desc, &blend_state); + ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr); + + blend_desc.IndependentBlendEnable = FALSE; + hr = ID3D11Device1_CreateBlendState1(device1, &blend_desc, &blend_state); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + ID3D11BlendState1_Release(blend_state); + + ID3D11Texture2D_GetDesc(test_context.backbuffer, &texture_desc); + texture_desc.Format = DXGI_FORMAT_R8G8B8A8_UINT; + for (i = 0; i < 8; ++i) + { + hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &rts[i]); + ok(hr == S_OK, "Failed to create texture %u, hr %#lx.\n", i, hr); + + hr = ID3D11Device_CreateRenderTargetView(device, (ID3D11Resource *)rts[i], NULL, &rtvs[i]); + ok(hr == S_OK, "Failed to create rendertarget view %u, hr %#lx.\n", i, hr); + } + + ID3D11DeviceContext_OMSetRenderTargets(context, 8, rtvs, NULL); + + for (i = 0; i < ARRAY_SIZE(tests); ++i) + { + blend_desc.RenderTarget[0].LogicOp = tests[i].op; + hr = ID3D11Device1_CreateBlendState1(device1, &blend_desc, &blend_state); + ok(hr == S_OK, "Failed to create blend state, hr %#lx.\n", hr); + ID3D11DeviceContext_OMSetBlendState(context, (ID3D11BlendState *)blend_state, NULL, D3D11_DEFAULT_SAMPLE_MASK); + ID3D11BlendState1_Release(blend_state); + + for (j = 0; j < 8; ++j) + ID3D11DeviceContext_ClearRenderTargetView(context, rtvs[j], clear_color); + draw_quad(&test_context); + + for (j = 0; j < 8; ++j) + { + get_texture_readback(rts[j], 0, &rb); + color = get_readback_color(&rb, 320, 240, 0); + ok(compare_color(color, tests[i].color, 1), "%u: Got unexpected color 0x%08lx.\n", i, color); + release_resource_readback(&rb); + } + } + + for (i = 0; i < 8; i++) + { + ID3D11Texture2D_Release(rts[i]); + ID3D11RenderTargetView_Release(rtvs[i]); + } + ID3D11PixelShader_Release(ps); + ID3D11Device1_Release(device1); + release_test_context(&test_context); +} + START_TEST(d3d11) { unsigned int argc, i; @@ -34214,6 +34379,7 @@ START_TEST(d3d11) queue_test(test_constant_buffer_offset); queue_test(test_dynamic_map_synchronization); queue_test(test_user_defined_annotation); + queue_test(test_logic_op); run_queued_tests();
1
0
0
0
← Newer
1
...
45
46
47
48
49
50
51
...
91
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
Results per page:
10
25
50
100
200