mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-11-21 16:46:54 -08:00
Added bcrypt-ECDHSecretAgreement patchset.
This commit is contained in:
parent
d68ab574f5
commit
37e000145f
@ -0,0 +1,537 @@
|
||||
From 04dd441ef89d4b8e07e35ae1c62ecb65c673970a Mon Sep 17 00:00:00 2001
|
||||
From: Derek Lesho <dlesho@codeweavers.com>
|
||||
Date: Tue, 7 Jan 2020 14:22:49 -0600
|
||||
Subject: [PATCH] bcrypt: Implement BCryptSecretAgreement with libgcrypt.
|
||||
|
||||
Signed-off-by: Derek Lesho <dlesho@codeweavers.com>
|
||||
---
|
||||
configure.ac | 14 ++
|
||||
dlls/bcrypt/Makefile.in | 1 +
|
||||
dlls/bcrypt/bcrypt_internal.h | 13 ++
|
||||
dlls/bcrypt/bcrypt_main.c | 86 +++++++++--
|
||||
dlls/bcrypt/gcrypt.c | 264 ++++++++++++++++++++++++++++++++++
|
||||
dlls/bcrypt/gnutls.c | 9 ++
|
||||
dlls/bcrypt/tests/bcrypt.c | 2 +-
|
||||
7 files changed, 378 insertions(+), 11 deletions(-)
|
||||
create mode 100644 dlls/bcrypt/gcrypt.c
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index dca0b165ba..cb6eedcdc9 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -46,6 +46,7 @@ AC_ARG_WITH(faudio, AS_HELP_STRING([--without-faudio],[do not use FAudio (XAu
|
||||
AC_ARG_WITH(float-abi, AS_HELP_STRING([--with-float-abi=abi],[specify the ABI (soft|softfp|hard) for ARM platforms]))
|
||||
AC_ARG_WITH(fontconfig,AS_HELP_STRING([--without-fontconfig],[do not use fontconfig]))
|
||||
AC_ARG_WITH(freetype, AS_HELP_STRING([--without-freetype],[do not use the FreeType library]))
|
||||
+AC_ARG_WITH(gcrypt, AS_HELP_STRING([--without-gcrypt],[do not use libgcrypt]))
|
||||
AC_ARG_WITH(gettext, AS_HELP_STRING([--without-gettext],[do not use gettext]))
|
||||
AC_ARG_WITH(gettextpo, AS_HELP_STRING([--with-gettextpo],[use the GetTextPO library to rebuild po files]),
|
||||
[if test "x$withval" = "xno"; then ac_cv_header_gettext_po_h=no; fi])
|
||||
@@ -2050,6 +2051,19 @@ WINE_NOTICE_WITH(vkd3d,[test "x$ac_cv_lib_soname_vkd3d" = "x"],
|
||||
[vkd3d ${notice_platform}development files not found (or too old), Direct3D 12 won't be supported.])
|
||||
test "x$ac_cv_lib_soname_vkd3d" != "x" || enable_d3d12=${enable_d3d12:-no}
|
||||
|
||||
+dnl **** Check for gcrypt ****
|
||||
+if test "x$with_gcrypt" != "xno"
|
||||
+then
|
||||
+ WINE_PACKAGE_FLAGS(GCRYPT,[libgcrypt],,,,
|
||||
+ [AC_CHECK_HEADERS([gcrypt.h])
|
||||
+ if test "$ac_cv_header_gcrypt_h" = "yes"
|
||||
+ then
|
||||
+ WINE_CHECK_SONAME(gcrypt,gcry_sexp_build,,,[$GCRYPT_LIBS])
|
||||
+ fi])
|
||||
+fi
|
||||
+WINE_NOTICE_WITH(gcrypt,[test "x$ac_cv_lib_soname_gcrypt" = "x"],
|
||||
+ [libgcrypt ${notice_platform}development files not found, GCRYPT won't be supported.])
|
||||
+
|
||||
dnl **** Check for gcc specific options ****
|
||||
|
||||
AC_SUBST(EXTRACFLAGS,"")
|
||||
diff --git a/dlls/bcrypt/Makefile.in b/dlls/bcrypt/Makefile.in
|
||||
index dd6d4a7664..ea3486a400 100644
|
||||
--- a/dlls/bcrypt/Makefile.in
|
||||
+++ b/dlls/bcrypt/Makefile.in
|
||||
@@ -5,6 +5,7 @@ EXTRAINCL = $(GNUTLS_CFLAGS)
|
||||
|
||||
C_SRCS = \
|
||||
bcrypt_main.c \
|
||||
+ gcrypt.c \
|
||||
gnutls.c \
|
||||
macos.c \
|
||||
md2.c \
|
||||
diff --git a/dlls/bcrypt/bcrypt_internal.h b/dlls/bcrypt/bcrypt_internal.h
|
||||
index 5cc2c249da..b16dfbdcd2 100644
|
||||
--- a/dlls/bcrypt/bcrypt_internal.h
|
||||
+++ b/dlls/bcrypt/bcrypt_internal.h
|
||||
@@ -25,6 +25,9 @@
|
||||
#include <gnutls/gnutls.h>
|
||||
#include <gnutls/crypto.h>
|
||||
#include <gnutls/abstract.h>
|
||||
+#ifdef SONAME_LIBGCRYPT
|
||||
+#include <gcrypt.h>
|
||||
+#endif
|
||||
#elif HAVE_COMMONCRYPTO_COMMONCRYPTOR_H
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <CommonCrypto/CommonCryptor.h>
|
||||
@@ -157,6 +160,12 @@ struct algorithm
|
||||
ULONG flags;
|
||||
};
|
||||
|
||||
+struct secret
|
||||
+{
|
||||
+ UCHAR *data;
|
||||
+ ULONG len;
|
||||
+};
|
||||
+
|
||||
#if defined(HAVE_GNUTLS_CIPHER_INIT)
|
||||
struct key_symmetric
|
||||
{
|
||||
@@ -251,6 +260,7 @@ NTSTATUS key_destroy( struct key * ) DECLSPEC_HIDDEN;
|
||||
BOOL key_is_symmetric( struct key * ) DECLSPEC_HIDDEN;
|
||||
NTSTATUS key_export_ecc( struct key *, UCHAR *, ULONG, ULONG * ) DECLSPEC_HIDDEN;
|
||||
NTSTATUS key_import_ecc( struct key *, UCHAR *, ULONG ) DECLSPEC_HIDDEN;
|
||||
+NTSTATUS compute_secret_ecc (struct key *pubkey_in, struct key *privkey_in, struct secret *secret) DECLSPEC_HIDDEN;
|
||||
|
||||
BOOL is_zero_vector( const UCHAR *, ULONG ) DECLSPEC_HIDDEN;
|
||||
BOOL is_equal_vector( const UCHAR *, ULONG, const UCHAR *, ULONG ) DECLSPEC_HIDDEN;
|
||||
@@ -258,4 +268,7 @@ BOOL is_equal_vector( const UCHAR *, ULONG, const UCHAR *, ULONG ) DECLSPEC_HIDD
|
||||
BOOL gnutls_initialize(void) DECLSPEC_HIDDEN;
|
||||
void gnutls_uninitialize(void) DECLSPEC_HIDDEN;
|
||||
|
||||
+BOOL gcrypt_initialize(void) DECLSPEC_HIDDEN;
|
||||
+void gcrypt_uninitialize(void) DECLSPEC_HIDDEN;
|
||||
+
|
||||
#endif /* __BCRYPT_INTERNAL_H */
|
||||
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
|
||||
index c2939ea815..15b934247d 100644
|
||||
--- a/dlls/bcrypt/bcrypt_main.c
|
||||
+++ b/dlls/bcrypt/bcrypt_main.c
|
||||
@@ -1349,6 +1349,12 @@ NTSTATUS key_import_ecc( struct key *key, UCHAR *input, ULONG len )
|
||||
ERR( "support for keys not available at build time\n" );
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
+
|
||||
+NTSTATUS compute_secret_ecc (struct key *pubkey_in, struct key *privkey_in, struct secret *secret)
|
||||
+{
|
||||
+ ERR( "support for secrets not available at build time\n" );
|
||||
+ return STATUS_NOT_IMPLEMENTED;
|
||||
+}
|
||||
#endif
|
||||
|
||||
NTSTATUS WINAPI BCryptGenerateSymmetricKey( BCRYPT_ALG_HANDLE algorithm, BCRYPT_KEY_HANDLE *handle,
|
||||
@@ -1714,27 +1720,81 @@ NTSTATUS WINAPI BCryptDeriveKeyPBKDF2( BCRYPT_ALG_HANDLE handle, UCHAR *pwd, ULO
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
-NTSTATUS WINAPI BCryptSecretAgreement(BCRYPT_KEY_HANDLE handle, BCRYPT_KEY_HANDLE key, BCRYPT_SECRET_HANDLE *secret, ULONG flags)
|
||||
+NTSTATUS WINAPI BCryptSecretAgreement(BCRYPT_KEY_HANDLE hPrivKey, BCRYPT_KEY_HANDLE hPubKey, BCRYPT_SECRET_HANDLE *secret_out, ULONG flags)
|
||||
{
|
||||
- FIXME( "%p, %p, %p, %08x\n", handle, key, secret, flags );
|
||||
+ struct key *privkey = hPrivKey;
|
||||
+ struct key *pubkey = hPubKey;
|
||||
+ struct secret *secret;
|
||||
+ NTSTATUS status;
|
||||
|
||||
- if(secret)
|
||||
- *secret = (BCRYPT_SECRET_HANDLE *)0xDEADFEED;
|
||||
+ TRACE( "%p, %p, %p, %08x\n", hPrivKey, hPubKey, secret_out, flags );
|
||||
|
||||
- return STATUS_SUCCESS;
|
||||
+ secret = heap_alloc( sizeof(*secret) );
|
||||
+
|
||||
+ if ((status = compute_secret_ecc(privkey, pubkey, secret)))
|
||||
+ {
|
||||
+ heap_free(secret);
|
||||
+ *secret_out = NULL;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ *secret_out = secret;
|
||||
+ }
|
||||
+
|
||||
+ return status;
|
||||
}
|
||||
|
||||
-NTSTATUS WINAPI BCryptDestroySecret(BCRYPT_SECRET_HANDLE secret)
|
||||
+NTSTATUS WINAPI BCryptDestroySecret(BCRYPT_SECRET_HANDLE hSecret)
|
||||
{
|
||||
- FIXME( "%p\n", secret );
|
||||
+ struct secret *secret = hSecret;
|
||||
+
|
||||
+ TRACE( "%p\n", hSecret );
|
||||
+
|
||||
+ if (!hSecret)
|
||||
+ {
|
||||
+ return STATUS_INVALID_HANDLE;
|
||||
+ }
|
||||
+
|
||||
+ heap_free(secret->data);
|
||||
+ heap_free(secret);
|
||||
+
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
-NTSTATUS WINAPI BCryptDeriveKey(BCRYPT_SECRET_HANDLE secret, LPCWSTR kdf, BCryptBufferDesc *parameter,
|
||||
+NTSTATUS WINAPI BCryptDeriveKey(BCRYPT_SECRET_HANDLE hSecret, LPCWSTR deriv_func, BCryptBufferDesc *parameter,
|
||||
PUCHAR derived, ULONG derived_size, ULONG *result, ULONG flags)
|
||||
{
|
||||
- FIXME( "%p, %s, %p, %p, %d, %p, %08x\n", secret, debugstr_w(kdf), parameter, derived, derived_size, result, flags );
|
||||
- return STATUS_INTERNAL_ERROR;
|
||||
+ struct secret *secret = hSecret;
|
||||
+
|
||||
+ TRACE( "%p, %s, %p, %p, %d, %p, %08x\n", secret, debugstr_w(deriv_func), parameter, derived, derived_size, result, flags );
|
||||
+
|
||||
+ if (!hSecret)
|
||||
+ {
|
||||
+ return STATUS_INVALID_HANDLE;
|
||||
+ }
|
||||
+
|
||||
+ if (!(strcmpW(deriv_func, BCRYPT_KDF_RAW_SECRET)))
|
||||
+ {
|
||||
+ ULONG n;
|
||||
+ ULONG secret_length = secret->len;
|
||||
+
|
||||
+ if (!derived)
|
||||
+ {
|
||||
+ *result = secret_length;
|
||||
+ return STATUS_SUCCESS;
|
||||
+ }
|
||||
+
|
||||
+ /* outputs in little endian for some reason */
|
||||
+ for (n = 0; n < secret_length && n < derived_size; n++)
|
||||
+ {
|
||||
+ derived[n] = secret->data[secret_length - n - 1];
|
||||
+ }
|
||||
+
|
||||
+ *result = n;
|
||||
+ return STATUS_SUCCESS;
|
||||
+ }
|
||||
+ FIXME( "Derivation function %s not supported.\n", debugstr_w(deriv_func) );
|
||||
+ return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
|
||||
@@ -1746,6 +1806,9 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
|
||||
DisableThreadLibraryCalls( hinst );
|
||||
#ifdef HAVE_GNUTLS_CIPHER_INIT
|
||||
gnutls_initialize();
|
||||
+#ifdef SONAME_LIBGCRYPT
|
||||
+ gcrypt_initialize();
|
||||
+#endif
|
||||
#endif
|
||||
break;
|
||||
|
||||
@@ -1753,6 +1816,9 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
|
||||
if (reserved) break;
|
||||
#ifdef HAVE_GNUTLS_CIPHER_INIT
|
||||
gnutls_uninitialize();
|
||||
+#ifdef SONAME_LIBGCRYPT
|
||||
+ gcrypt_uninitialize();
|
||||
+#endif
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
diff --git a/dlls/bcrypt/gcrypt.c b/dlls/bcrypt/gcrypt.c
|
||||
new file mode 100644
|
||||
index 0000000000..d7ed6eeddf
|
||||
--- /dev/null
|
||||
+++ b/dlls/bcrypt/gcrypt.c
|
||||
@@ -0,0 +1,264 @@
|
||||
+#include "config.h"
|
||||
+#include "wine/port.h"
|
||||
+
|
||||
+#include <stdarg.h>
|
||||
+#ifdef HAVE_GNUTLS_CIPHER_INIT
|
||||
+#include <gnutls/gnutls.h>
|
||||
+#include <gnutls/crypto.h>
|
||||
+#include <gnutls/abstract.h>
|
||||
+#ifdef HAVE_LIBGCRYPT
|
||||
+#include <libgcrypt/libgcrypt.h>
|
||||
+#endif
|
||||
+#endif
|
||||
+
|
||||
+#include "ntstatus.h"
|
||||
+#define WIN32_NO_STATUS
|
||||
+#include "windef.h"
|
||||
+#include "winbase.h"
|
||||
+#include "bcrypt.h"
|
||||
+
|
||||
+#include "bcrypt_internal.h"
|
||||
+
|
||||
+#include "wine/debug.h"
|
||||
+#include "wine/heap.h"
|
||||
+#include "wine/library.h"
|
||||
+#include "wine/unicode.h"
|
||||
+
|
||||
+#if defined(HAVE_GNUTLS_CIPHER_INIT) && defined(SONAME_LIBGCRYPT)
|
||||
+WINE_DEFAULT_DEBUG_CHANNEL(bcrypt);
|
||||
+WINE_DECLARE_DEBUG_CHANNEL(winediag);
|
||||
+
|
||||
+static void *libgcrypt_handle;
|
||||
+#define MAKE_FUNCPTR(f) static typeof(f) * p##f
|
||||
+MAKE_FUNCPTR(gcry_check_version);
|
||||
+MAKE_FUNCPTR(gcry_sexp_build);
|
||||
+MAKE_FUNCPTR(gcry_pk_encrypt);
|
||||
+MAKE_FUNCPTR(gcry_mpi_new);
|
||||
+MAKE_FUNCPTR(gcry_mpi_print);
|
||||
+MAKE_FUNCPTR(gcry_sexp_release);
|
||||
+MAKE_FUNCPTR(gcry_mpi_release);
|
||||
+MAKE_FUNCPTR(gcry_strsource);
|
||||
+MAKE_FUNCPTR(gcry_strerror);
|
||||
+MAKE_FUNCPTR(gcry_sexp_find_token);
|
||||
+MAKE_FUNCPTR(gcry_sexp_nth_mpi);
|
||||
+#undef MAKE_FUNCPTR
|
||||
+
|
||||
+BOOL gcrypt_initialize(void)
|
||||
+{
|
||||
+ if (!(libgcrypt_handle = wine_dlopen( SONAME_LIBGCRYPT, RTLD_NOW, NULL, 0 )))
|
||||
+ {
|
||||
+ ERR_(winediag)( "failed to load libgcrypt, no support for diffie hellman key exchange\n" );
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
+#define LOAD_FUNCPTR(f) \
|
||||
+ if (!(p##f = wine_dlsym( libgcrypt_handle, #f, NULL, 0 ))) \
|
||||
+ { \
|
||||
+ ERR( "failed to load %s\n", #f ); \
|
||||
+ goto fail; \
|
||||
+ }
|
||||
+
|
||||
+ LOAD_FUNCPTR(gcry_check_version);
|
||||
+ LOAD_FUNCPTR(gcry_sexp_build);
|
||||
+ LOAD_FUNCPTR(gcry_pk_encrypt);
|
||||
+ LOAD_FUNCPTR(gcry_mpi_new);
|
||||
+ LOAD_FUNCPTR(gcry_mpi_print);
|
||||
+ LOAD_FUNCPTR(gcry_sexp_release);
|
||||
+ LOAD_FUNCPTR(gcry_mpi_release);
|
||||
+ LOAD_FUNCPTR(gcry_strsource);
|
||||
+ LOAD_FUNCPTR(gcry_strerror);
|
||||
+ LOAD_FUNCPTR(gcry_sexp_find_token);
|
||||
+ LOAD_FUNCPTR(gcry_sexp_nth_mpi);
|
||||
+#undef LOAD_FUNCPTR
|
||||
+
|
||||
+ return TRUE;
|
||||
+
|
||||
+fail:
|
||||
+ wine_dlclose( libgcrypt_handle, NULL, 0 );
|
||||
+ libgcrypt_handle = NULL;
|
||||
+ return FALSE;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+void gcrypt_uninitialize(void)
|
||||
+{
|
||||
+ wine_dlclose( libgcrypt_handle, NULL, 0 );
|
||||
+ libgcrypt_handle = NULL;
|
||||
+}
|
||||
+
|
||||
+NTSTATUS extract_result_into_secret(gcry_sexp_t result, struct secret *secret)
|
||||
+{
|
||||
+ NTSTATUS status = STATUS_SUCCESS;
|
||||
+ gcry_mpi_t fullcoords = NULL;
|
||||
+ gcry_sexp_t fragment = NULL;
|
||||
+ UCHAR *tmp_buffer = NULL;
|
||||
+ gcry_error_t err;
|
||||
+ size_t size;
|
||||
+
|
||||
+ fragment = pgcry_sexp_find_token(result, "s", 0);
|
||||
+ if (!fragment)
|
||||
+ {
|
||||
+ status = STATUS_NO_MEMORY;
|
||||
+ goto done;
|
||||
+ }
|
||||
+
|
||||
+ fullcoords = pgcry_sexp_nth_mpi(fragment, 1, GCRYMPI_FMT_USG);
|
||||
+ if (!fullcoords)
|
||||
+ {
|
||||
+ status = STATUS_NO_MEMORY;
|
||||
+ goto done;
|
||||
+ }
|
||||
+
|
||||
+ if ((err = pgcry_mpi_print(GCRYMPI_FMT_USG, NULL, 0, &size, fullcoords)))
|
||||
+ {
|
||||
+ ERR("Error = %s/%s.\n", pgcry_strsource(err), pgcry_strerror(err));
|
||||
+ status = STATUS_INTERNAL_ERROR;
|
||||
+ goto done;
|
||||
+ }
|
||||
+
|
||||
+ tmp_buffer = heap_alloc(size);
|
||||
+ if ((err = pgcry_mpi_print(GCRYMPI_FMT_STD, tmp_buffer, size, NULL, fullcoords)))
|
||||
+ {
|
||||
+ ERR("Error = %s/%s.\n", pgcry_strsource(err), pgcry_strerror(err));
|
||||
+ status = STATUS_INTERNAL_ERROR;
|
||||
+ goto done;
|
||||
+ }
|
||||
+
|
||||
+ secret->data = heap_alloc(size / 2);
|
||||
+ memcpy(secret->data, tmp_buffer + size % 2, size / 2);
|
||||
+ secret->len = size / 2;
|
||||
+
|
||||
+done:
|
||||
+ heap_free(tmp_buffer);
|
||||
+
|
||||
+ pgcry_mpi_release(fullcoords);
|
||||
+ pgcry_sexp_release(fragment);
|
||||
+
|
||||
+ return status;
|
||||
+}
|
||||
+
|
||||
+/* this is necessary since GNUTLS doesn't support ECDH public key encryption, maybe we can replace this when it does:
|
||||
+ https://github.com/gnutls/gnutls/blob/cdc4fc288d87f91f974aa23b6e8595a53970ce00/lib/nettle/pk.c#L495 */
|
||||
+NTSTATUS compute_secret_ecc (struct key *privkey_in, struct key *pubkey_in, struct secret *secret)
|
||||
+{
|
||||
+ const char *pubkey_format;
|
||||
+ DWORD key_size;
|
||||
+ gcry_sexp_t pubkey = NULL;
|
||||
+ gcry_sexp_t privkey = NULL;
|
||||
+ gcry_sexp_t xchg_result = NULL;
|
||||
+ gcry_error_t err;
|
||||
+ NTSTATUS status = STATUS_SUCCESS;
|
||||
+
|
||||
+ if (!libgcrypt_handle)
|
||||
+ {
|
||||
+ ERR("Secrets not supported without gcrypt\n");
|
||||
+ return STATUS_INTERNAL_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ switch (pubkey_in->alg_id)
|
||||
+ {
|
||||
+ case ALG_ID_ECDH_P256:
|
||||
+ pubkey_format = "NIST P-256";
|
||||
+ key_size = 32;
|
||||
+ break;
|
||||
+ default:
|
||||
+ FIXME("Unsupported algorithm id: %u\n", pubkey_in->alg_id);
|
||||
+ return STATUS_INTERNAL_ERROR;
|
||||
+ }
|
||||
+
|
||||
+ /* import public key -
|
||||
+ copy public key into temporary buffer so we can prepend 0x04 (to indicate it is uncompressed) */
|
||||
+ {
|
||||
+ UCHAR *public_key_raw = heap_alloc((key_size * 2) + 1);
|
||||
+ public_key_raw[0] = 0x04;
|
||||
+ memcpy(public_key_raw + 1, pubkey_in->u.a.pubkey + sizeof(BCRYPT_ECCKEY_BLOB), key_size * 2);
|
||||
+
|
||||
+ err = pgcry_sexp_build(&pubkey, NULL,
|
||||
+ "(key-data(public-key(ecdh(curve %s)(q %b))))",
|
||||
+ pubkey_format,
|
||||
+ (key_size * 2) + 1,
|
||||
+ public_key_raw);
|
||||
+
|
||||
+ heap_free(public_key_raw);
|
||||
+ }
|
||||
+
|
||||
+ if (err)
|
||||
+ {
|
||||
+ ERR("Failed to build gcrypt public key\n");
|
||||
+ goto done;
|
||||
+ }
|
||||
+
|
||||
+ /* import private key */
|
||||
+ /* extract private key from blob structure */
|
||||
+ {
|
||||
+ UCHAR *private_key_raw = heap_alloc(key_size);
|
||||
+ UCHAR *key_blob;
|
||||
+ ULONG blob_size;
|
||||
+
|
||||
+ status = key_export_ecc( privkey_in, NULL, 0, &blob_size );
|
||||
+ if (status)
|
||||
+ goto done;
|
||||
+
|
||||
+ key_blob = heap_alloc(blob_size);
|
||||
+ status = key_export_ecc( privkey_in, key_blob, blob_size, &blob_size);
|
||||
+ if (status)
|
||||
+ {
|
||||
+ heap_free(private_key_raw);
|
||||
+ heap_free(key_blob);
|
||||
+ goto done;
|
||||
+ }
|
||||
+
|
||||
+ memcpy(private_key_raw, key_blob + sizeof(BCRYPT_ECCKEY_BLOB) + key_size * 2, key_size);
|
||||
+ heap_free(key_blob);
|
||||
+
|
||||
+ err = pgcry_sexp_build(&privkey, NULL,
|
||||
+ "(data(flags raw)(value %b))",
|
||||
+ key_size,
|
||||
+ private_key_raw);
|
||||
+
|
||||
+ heap_free(private_key_raw);
|
||||
+ }
|
||||
+
|
||||
+ if (err)
|
||||
+ {
|
||||
+ ERR("Failed to build gcrypt private key data\n");
|
||||
+ goto done;
|
||||
+ }
|
||||
+
|
||||
+ if ((err = pgcry_pk_encrypt(&xchg_result, privkey, pubkey)))
|
||||
+ {
|
||||
+ ERR("Failed to perform key exchange\n");
|
||||
+ goto done;
|
||||
+ }
|
||||
+
|
||||
+ status = extract_result_into_secret(xchg_result, secret);
|
||||
+ if (status)
|
||||
+ {
|
||||
+ ERR("Failed to extract secret key\n");
|
||||
+ goto done;
|
||||
+ }
|
||||
+
|
||||
+ if (secret->len != key_size)
|
||||
+ {
|
||||
+ ERR("got secret size %u, expected %u\n", secret->len, key_size);
|
||||
+ status = STATUS_INTERNAL_ERROR;
|
||||
+ goto done;
|
||||
+ }
|
||||
+
|
||||
+ done:
|
||||
+ pgcry_sexp_release(pubkey);
|
||||
+ pgcry_sexp_release(privkey);
|
||||
+ pgcry_sexp_release(xchg_result);
|
||||
+
|
||||
+ if (status)
|
||||
+ {
|
||||
+ return status;
|
||||
+ }
|
||||
+ if (err)
|
||||
+ {
|
||||
+ ERR("Error = %s/%s\n", pgcry_strsource (err), pgcry_strerror (err));
|
||||
+ return STATUS_INTERNAL_ERROR;
|
||||
+ }
|
||||
+ return STATUS_SUCCESS;
|
||||
+}
|
||||
+#endif
|
||||
diff --git a/dlls/bcrypt/gnutls.c b/dlls/bcrypt/gnutls.c
|
||||
index 1d78b9f4d1..59c98eed0c 100644
|
||||
--- a/dlls/bcrypt/gnutls.c
|
||||
+++ b/dlls/bcrypt/gnutls.c
|
||||
@@ -1297,4 +1297,13 @@ NTSTATUS key_destroy( struct key *key )
|
||||
heap_free( key );
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
+
|
||||
+#ifndef SONAME_LIBGCRYPT
|
||||
+NTSTATUS compute_secret_ecc (struct key *pubkey_in, struct key *privkey_in, struct secret *secret)
|
||||
+{
|
||||
+ ERR("support for secrets not available without gcrypt\n");
|
||||
+ return STATUS_NOT_IMPLEMENTED;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
#endif
|
||||
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
|
||||
index f7404057fa..d9509f2c49 100644
|
||||
--- a/dlls/bcrypt/tests/bcrypt.c
|
||||
+++ b/dlls/bcrypt/tests/bcrypt.c
|
||||
@@ -2067,7 +2067,7 @@ static void test_ECDH(void)
|
||||
goto raw_secret_end;
|
||||
}
|
||||
|
||||
- todo_wine ok(status == STATUS_SUCCESS, "got %08x\n", status);
|
||||
+ ok(status == STATUS_SUCCESS, "got %08x\n", status);
|
||||
|
||||
if (status != STATUS_SUCCESS)
|
||||
{
|
||||
--
|
||||
2.24.1
|
||||
|
@ -0,0 +1,149 @@
|
||||
From d0c4ac467f5e85e29ae407b29b6a93c85f375fd3 Mon Sep 17 00:00:00 2001
|
||||
From: Derek Lesho <dlesho@codeweavers.com>
|
||||
Date: Tue, 7 Jan 2020 14:22:49 -0600
|
||||
Subject: [PATCH] bcrypt: Implement BCRYPT_KDF_HASH.
|
||||
|
||||
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47699
|
||||
Signed-off-by: Derek Lesho <dlesho at codeweavers.com>
|
||||
---
|
||||
dlls/bcrypt/bcrypt_main.c | 110 +++++++++++++++++++++++++++++++++++++
|
||||
dlls/bcrypt/tests/bcrypt.c | 2 +-
|
||||
2 files changed, 111 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
|
||||
index 15b934247d..57d552a4c0 100644
|
||||
--- a/dlls/bcrypt/bcrypt_main.c
|
||||
+++ b/dlls/bcrypt/bcrypt_main.c
|
||||
@@ -1773,6 +1773,116 @@ NTSTATUS WINAPI BCryptDeriveKey(BCRYPT_SECRET_HANDLE hSecret, LPCWSTR deriv_func
|
||||
return STATUS_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
+ if (flags)
|
||||
+ {
|
||||
+ FIXME("flags ignored: %08x\n", flags);
|
||||
+ }
|
||||
+
|
||||
+ if (!(strcmpW(deriv_func, BCRYPT_KDF_HASH)))
|
||||
+ {
|
||||
+ unsigned int i;
|
||||
+ BCryptBuffer *hash_algorithm = NULL;
|
||||
+ BCryptBuffer *secret_prepend = NULL;
|
||||
+ BCryptBuffer *secret_append = NULL;
|
||||
+ enum alg_id hash_alg_id;
|
||||
+ ULONG hash_length;
|
||||
+ struct hash_impl hash;
|
||||
+ NTSTATUS status;
|
||||
+
|
||||
+ if (parameter)
|
||||
+ {
|
||||
+ for (i = 0; i < parameter->cBuffers; i++)
|
||||
+ {
|
||||
+ BCryptBuffer *cur_buffer = ¶meter->pBuffers[i];
|
||||
+ switch(cur_buffer->BufferType)
|
||||
+ {
|
||||
+ case KDF_HASH_ALGORITHM:
|
||||
+ if (hash_algorithm)
|
||||
+ FIXME("Duplicate KDF_HASH_ALGORITHM, untested\n");
|
||||
+ hash_algorithm = cur_buffer;
|
||||
+ break;
|
||||
+ case KDF_SECRET_PREPEND:
|
||||
+ if (secret_prepend)
|
||||
+ FIXME("Multiple prefixes unsupported\n");
|
||||
+ secret_prepend = cur_buffer;
|
||||
+ break;
|
||||
+ case KDF_SECRET_APPEND:
|
||||
+ if (secret_append)
|
||||
+ FIXME("Multiple suffixes unsupported\n");
|
||||
+ secret_append = cur_buffer;
|
||||
+ break;
|
||||
+ default:
|
||||
+ FIXME("Unsupported BCRYPT_KDF_HASH parameter type %x\n", cur_buffer->BufferType);
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!(hash_algorithm))
|
||||
+ hash_alg_id = ALG_ID_SHA1;
|
||||
+ else
|
||||
+ {
|
||||
+ for (i = 0; i < ARRAY_SIZE( builtin_algorithms ); i++)
|
||||
+ {
|
||||
+ if (!strcmpW( hash_algorithm->pvBuffer, builtin_algorithms[i].name))
|
||||
+ {
|
||||
+ hash_alg_id = i;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ if (i == ARRAY_SIZE(builtin_algorithms))
|
||||
+ {
|
||||
+ WARN("Algorithm %s not found\n", debugstr_w(hash_algorithm->pvBuffer));
|
||||
+ return STATUS_NOT_SUPPORTED;
|
||||
+ }
|
||||
+ if (builtin_algorithms[hash_alg_id].class != BCRYPT_HASH_INTERFACE)
|
||||
+ {
|
||||
+ return STATUS_NOT_SUPPORTED;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ hash_length = builtin_algorithms[hash_alg_id].hash_length;
|
||||
+
|
||||
+ if (!derived)
|
||||
+ {
|
||||
+ *result = hash_length;
|
||||
+ return STATUS_SUCCESS;
|
||||
+ }
|
||||
+
|
||||
+ if ((status = hash_init(&hash, hash_alg_id)))
|
||||
+ {
|
||||
+ return status;
|
||||
+ }
|
||||
+
|
||||
+ if (secret_prepend)
|
||||
+ {
|
||||
+ hash_update(&hash, hash_alg_id, secret_prepend->pvBuffer, secret_prepend->cbBuffer);
|
||||
+ }
|
||||
+
|
||||
+ hash_update(&hash, hash_alg_id, secret->data, secret->len);
|
||||
+
|
||||
+ if (secret_append)
|
||||
+ {
|
||||
+ hash_update(&hash, hash_alg_id, secret_append->pvBuffer, secret_append->cbBuffer);
|
||||
+ }
|
||||
+
|
||||
+ if (derived_size >= hash_length)
|
||||
+ {
|
||||
+ hash_finish(&hash, hash_alg_id, derived, derived_size);
|
||||
+ *result = hash_length;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ UCHAR *output = heap_alloc(hash_length);
|
||||
+ hash_finish(&hash, hash_alg_id, output, hash_length);
|
||||
+ memcpy(derived, output, derived_size);
|
||||
+ heap_free(output);
|
||||
+ *result = derived_size;
|
||||
+ }
|
||||
+
|
||||
+ return STATUS_SUCCESS;
|
||||
+ }
|
||||
+ else
|
||||
if (!(strcmpW(deriv_func, BCRYPT_KDF_RAW_SECRET)))
|
||||
{
|
||||
ULONG n;
|
||||
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
|
||||
index d9509f2c49..edc59a8a97 100644
|
||||
--- a/dlls/bcrypt/tests/bcrypt.c
|
||||
+++ b/dlls/bcrypt/tests/bcrypt.c
|
||||
@@ -2084,7 +2084,7 @@ static void test_ECDH(void)
|
||||
raw_secret_end:
|
||||
|
||||
status = pBCryptDeriveKey(secret, BCRYPT_KDF_HASH, &hash_params, NULL, 0, &size, 0);
|
||||
- todo_wine ok (status == STATUS_SUCCESS, "got %08x\n", status);
|
||||
+ ok (status == STATUS_SUCCESS, "got %08x\n", status);
|
||||
|
||||
if (status != STATUS_SUCCESS)
|
||||
{
|
||||
--
|
||||
2.24.1
|
||||
|
2
patches/bcrypt-ECDHSecretAgreement/definition
Normal file
2
patches/bcrypt-ECDHSecretAgreement/definition
Normal file
@ -0,0 +1,2 @@
|
||||
Fixes: [47699] Multiple games fail to connect to online services (missing BCryptSecretAgreement / BCryptDeriveKey implementation)
|
||||
|
@ -52,7 +52,7 @@ usage()
|
||||
# Get the upstream commit sha
|
||||
upstream_commit()
|
||||
{
|
||||
echo "0e7392040c910403e3418b4670e4cc30037025ed"
|
||||
echo "0f51b732e4eae54b13232e025d00f277d75f564b"
|
||||
}
|
||||
|
||||
# Show version information
|
||||
@ -91,6 +91,7 @@ patch_enable_all ()
|
||||
enable_advapi32_Token_Integrity_Level="$1"
|
||||
enable_api_ms_win_Stub_DLLs="$1"
|
||||
enable_atl_AtlAxDialogBox="$1"
|
||||
enable_bcrypt_ECDHSecretAgreement="$1"
|
||||
enable_cmd_launch_association="$1"
|
||||
enable_comctl32_Listview_DrawItem="$1"
|
||||
enable_comctl32_rebar_capture="$1"
|
||||
@ -384,6 +385,9 @@ patch_enable ()
|
||||
atl-AtlAxDialogBox)
|
||||
enable_atl_AtlAxDialogBox="$2"
|
||||
;;
|
||||
bcrypt-ECDHSecretAgreement)
|
||||
enable_bcrypt_ECDHSecretAgreement="$2"
|
||||
;;
|
||||
cmd-launch-association)
|
||||
enable_cmd_launch_association="$2"
|
||||
;;
|
||||
@ -2183,6 +2187,25 @@ if test "$enable_atl_AtlAxDialogBox" -eq 1; then
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
# Patchset bcrypt-ECDHSecretAgreement
|
||||
# |
|
||||
# | This patchset fixes the following Wine bugs:
|
||||
# | * [#47699] Multiple games fail to connect to online services (missing BCryptSecretAgreement / BCryptDeriveKey
|
||||
# | implementation)
|
||||
# |
|
||||
# | Modified files:
|
||||
# | * configure.ac, dlls/bcrypt/Makefile.in, dlls/bcrypt/bcrypt_internal.h, dlls/bcrypt/bcrypt_main.c, dlls/bcrypt/gcrypt.c,
|
||||
# | dlls/bcrypt/gnutls.c, dlls/bcrypt/tests/bcrypt.c
|
||||
# |
|
||||
if test "$enable_bcrypt_ECDHSecretAgreement" -eq 1; then
|
||||
patch_apply bcrypt-ECDHSecretAgreement/0001-bcrypt-Implement-BCryptSecretAgreement-with-libgcryp.patch
|
||||
patch_apply bcrypt-ECDHSecretAgreement/0002-bcrypt-Implement-BCRYPT_KDF_HASH.patch
|
||||
(
|
||||
printf '%s\n' '+ { "Derek Lesho", "bcrypt: Implement BCryptSecretAgreement with libgcrypt.", 1 },';
|
||||
printf '%s\n' '+ { "Derek Lesho", "bcrypt: Implement BCRYPT_KDF_HASH.", 1 },';
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
# Patchset cmd-launch-association
|
||||
# |
|
||||
# | This patchset fixes the following Wine bugs:
|
||||
|
@ -1,10 +1,9 @@
|
||||
From 8c237bdc4de7217318f57024df5e0f88c44f42ed Mon Sep 17 00:00:00 2001
|
||||
From c7e3f11716a564888a88de2d50fac3b201ca22f2 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Gofman <gofmanp@gmail.com>
|
||||
Date: Mon, 25 Feb 2019 13:17:01 +0300
|
||||
Subject: [PATCH 1/5] wined3d: Use UBO for vertex shader float constants if
|
||||
Subject: [PATCH] wined3d: Use UBO for vertex shader float constants if
|
||||
supported.
|
||||
|
||||
Signed-off-by: Paul Gofman <gofmanp@gmail.com>
|
||||
---
|
||||
dlls/d3d8/directx.c | 2 +-
|
||||
dlls/d3d9/directx.c | 2 +-
|
||||
@ -17,10 +16,10 @@ Signed-off-by: Paul Gofman <gofmanp@gmail.com>
|
||||
8 files changed, 148 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/dlls/d3d8/directx.c b/dlls/d3d8/directx.c
|
||||
index c5239844c3..274d5e14de 100644
|
||||
index d1f8872d12..fb3804f5e8 100644
|
||||
--- a/dlls/d3d8/directx.c
|
||||
+++ b/dlls/d3d8/directx.c
|
||||
@@ -416,7 +416,7 @@ BOOL d3d8_init(struct d3d8 *d3d8)
|
||||
@@ -417,7 +417,7 @@ BOOL d3d8_init(struct d3d8 *d3d8)
|
||||
DWORD flags = WINED3D_LEGACY_DEPTH_BIAS | WINED3D_VIDMEM_ACCOUNTING
|
||||
| WINED3D_HANDLE_RESTORE | WINED3D_PIXEL_CENTER_INTEGER
|
||||
| WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR | WINED3D_NO_PRIMITIVE_RESTART
|
||||
@ -30,10 +29,10 @@ index c5239844c3..274d5e14de 100644
|
||||
d3d8->IDirect3D8_iface.lpVtbl = &d3d8_vtbl;
|
||||
d3d8->refcount = 1;
|
||||
diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c
|
||||
index 1d3754adf8..f42c5ea622 100644
|
||||
index b552c3b910..04ff3fe5b6 100644
|
||||
--- a/dlls/d3d9/directx.c
|
||||
+++ b/dlls/d3d9/directx.c
|
||||
@@ -583,7 +583,7 @@ BOOL d3d9_init(struct d3d9 *d3d9, BOOL extended)
|
||||
@@ -593,7 +593,7 @@ BOOL d3d9_init(struct d3d9 *d3d9, BOOL extended)
|
||||
DWORD flags = WINED3D_PRESENT_CONVERSION | WINED3D_HANDLE_RESTORE | WINED3D_PIXEL_CENTER_INTEGER
|
||||
| WINED3D_SRGB_READ_WRITE_CONTROL | WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR
|
||||
| WINED3D_NO_PRIMITIVE_RESTART | WINED3D_LEGACY_CUBEMAP_FILTERING
|
||||
@ -43,10 +42,10 @@ index 1d3754adf8..f42c5ea622 100644
|
||||
if (!extended)
|
||||
flags |= WINED3D_VIDMEM_ACCOUNTING;
|
||||
diff --git a/dlls/wined3d/adapter_gl.c b/dlls/wined3d/adapter_gl.c
|
||||
index ed1022030b..57eb73a121 100644
|
||||
index a59edf4e36..eeec0e43bd 100644
|
||||
--- a/dlls/wined3d/adapter_gl.c
|
||||
+++ b/dlls/wined3d/adapter_gl.c
|
||||
@@ -3117,6 +3117,9 @@ static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info)
|
||||
@@ -3127,6 +3127,9 @@ static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info)
|
||||
gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_VERTEX] = min(gl_max, WINED3D_MAX_CBS);
|
||||
TRACE("Max vertex uniform blocks: %u (%d).\n",
|
||||
gl_info->limits.uniform_blocks[WINED3D_SHADER_TYPE_VERTEX], gl_max);
|
||||
@ -57,7 +56,7 @@ index ed1022030b..57eb73a121 100644
|
||||
}
|
||||
if (gl_info->supported[ARB_TESSELLATION_SHADER])
|
||||
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
|
||||
index 0e0977e1d4..3c705e0730 100644
|
||||
index 4a2fbce553..e306694533 100644
|
||||
--- a/dlls/wined3d/glsl_shader.c
|
||||
+++ b/dlls/wined3d/glsl_shader.c
|
||||
@@ -138,6 +138,10 @@ struct shader_glsl_priv
|
||||
@ -79,7 +78,7 @@ index 0e0977e1d4..3c705e0730 100644
|
||||
};
|
||||
|
||||
struct glsl_hs_program
|
||||
@@ -284,6 +289,7 @@ struct glsl_context_data
|
||||
@@ -286,6 +291,7 @@ struct glsl_context_data
|
||||
struct glsl_shader_prog_link *glsl_program;
|
||||
GLenum vertex_color_clamp;
|
||||
BOOL rasterization_disabled;
|
||||
@ -87,7 +86,7 @@ index 0e0977e1d4..3c705e0730 100644
|
||||
};
|
||||
|
||||
struct glsl_ps_compiled_shader
|
||||
@@ -1183,12 +1189,54 @@ static inline void walk_constant_heap_clamped(const struct wined3d_gl_info *gl_i
|
||||
@@ -1185,12 +1191,54 @@ static inline void walk_constant_heap_clamped(const struct wined3d_gl_info *gl_i
|
||||
checkGLcall("walk_constant_heap_clamped()");
|
||||
}
|
||||
|
||||
@ -143,7 +142,7 @@ index 0e0977e1d4..3c705e0730 100644
|
||||
|
||||
/* 1.X pshaders have the constants clamped to [-1;1] implicitly. */
|
||||
if (shader->reg_maps.shader_version.major == 1
|
||||
@@ -1523,7 +1571,7 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
|
||||
@@ -1525,7 +1573,7 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
|
||||
{
|
||||
const struct wined3d_shader *vshader = state->shader[WINED3D_SHADER_TYPE_VERTEX];
|
||||
const struct wined3d_shader *pshader = state->shader[WINED3D_SHADER_TYPE_PIXEL];
|
||||
@ -152,7 +151,7 @@ index 0e0977e1d4..3c705e0730 100644
|
||||
struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
|
||||
struct glsl_shader_prog_link *prog = ctx_data->glsl_program;
|
||||
const struct wined3d_gl_info *gl_info = context_gl->gl_info;
|
||||
@@ -1540,9 +1588,32 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
|
||||
@@ -1542,9 +1590,32 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
|
||||
constant_version = prog->constant_version;
|
||||
update_mask = context->constant_update_mask & prog->constant_update_mask;
|
||||
|
||||
@ -186,7 +185,7 @@ index 0e0977e1d4..3c705e0730 100644
|
||||
|
||||
if (update_mask & WINED3D_SHADER_CONST_VS_I)
|
||||
shader_glsl_load_constants_i(vshader, gl_info, state->vs_consts_i,
|
||||
@@ -1695,7 +1766,7 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
|
||||
@@ -1697,7 +1768,7 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
|
||||
|
||||
if (update_mask & WINED3D_SHADER_CONST_PS_F)
|
||||
shader_glsl_load_constants_f(pshader, gl_info, state->ps_consts_f,
|
||||
@ -195,7 +194,7 @@ index 0e0977e1d4..3c705e0730 100644
|
||||
|
||||
if (update_mask & WINED3D_SHADER_CONST_PS_I)
|
||||
shader_glsl_load_constants_i(pshader, gl_info, state->ps_consts_i,
|
||||
@@ -1834,6 +1905,12 @@ static void shader_glsl_update_float_vertex_constants(struct wined3d_device *dev
|
||||
@@ -1836,6 +1907,12 @@ static void shader_glsl_update_float_vertex_constants(struct wined3d_device *dev
|
||||
struct constant_heap *heap = &priv->vconst_heap;
|
||||
UINT i;
|
||||
|
||||
@ -208,7 +207,7 @@ index 0e0977e1d4..3c705e0730 100644
|
||||
for (i = start; i < count + start; ++i)
|
||||
{
|
||||
update_heap_entry(heap, i, priv->next_constant_version);
|
||||
@@ -1846,6 +1923,9 @@ static void shader_glsl_update_float_pixel_constants(struct wined3d_device *devi
|
||||
@@ -1848,6 +1925,9 @@ static void shader_glsl_update_float_pixel_constants(struct wined3d_device *devi
|
||||
struct constant_heap *heap = &priv->pconst_heap;
|
||||
UINT i;
|
||||
|
||||
@ -218,7 +217,7 @@ index 0e0977e1d4..3c705e0730 100644
|
||||
for (i = start; i < count + start; ++i)
|
||||
{
|
||||
update_heap_entry(heap, i, priv->next_constant_version);
|
||||
@@ -2155,6 +2235,7 @@ static void shader_generate_glsl_declarations(const struct wined3d_context_gl *c
|
||||
@@ -2165,6 +2245,7 @@ static void shader_generate_glsl_declarations(const struct wined3d_context_gl *c
|
||||
const struct wined3d_shader_reg_maps *reg_maps, const struct shader_glsl_ctx_priv *ctx_priv)
|
||||
{
|
||||
const struct wined3d_shader_version *version = ®_maps->shader_version;
|
||||
@ -226,7 +225,7 @@ index 0e0977e1d4..3c705e0730 100644
|
||||
const struct vs_compile_args *vs_args = ctx_priv->cur_vs_args;
|
||||
const struct ps_compile_args *ps_args = ctx_priv->cur_ps_args;
|
||||
const struct wined3d_gl_info *gl_info = context_gl->gl_info;
|
||||
@@ -2178,7 +2259,15 @@ static void shader_generate_glsl_declarations(const struct wined3d_context_gl *c
|
||||
@@ -2188,7 +2269,15 @@ static void shader_generate_glsl_declarations(const struct wined3d_context_gl *c
|
||||
}
|
||||
|
||||
/* Declare the constants (aka uniforms) */
|
||||
@ -243,7 +242,7 @@ index 0e0977e1d4..3c705e0730 100644
|
||||
{
|
||||
unsigned max_constantsF;
|
||||
|
||||
@@ -2243,11 +2332,12 @@ static void shader_generate_glsl_declarations(const struct wined3d_context_gl *c
|
||||
@@ -2253,11 +2342,12 @@ static void shader_generate_glsl_declarations(const struct wined3d_context_gl *c
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -258,7 +257,7 @@ index 0e0977e1d4..3c705e0730 100644
|
||||
}
|
||||
|
||||
/* Always declare the full set of constants, the compiler can remove the
|
||||
@@ -9848,17 +9938,36 @@ static struct glsl_ffp_fragment_shader *shader_glsl_find_ffp_fragment_shader(str
|
||||
@@ -9890,17 +9980,36 @@ static struct glsl_ffp_fragment_shader *shader_glsl_find_ffp_fragment_shader(str
|
||||
|
||||
|
||||
static void shader_glsl_init_vs_uniform_locations(const struct wined3d_gl_info *gl_info,
|
||||
@ -300,7 +299,7 @@ index 0e0977e1d4..3c705e0730 100644
|
||||
|
||||
for (i = 0; i < WINED3D_MAX_CONSTS_I; ++i)
|
||||
{
|
||||
@@ -10933,6 +11042,7 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
|
||||
@@ -10975,6 +11084,7 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
|
||||
const struct wined3d_fragment_pipe_ops *fragment_pipe)
|
||||
{
|
||||
SIZE_T stack_size = wined3d_log2i(max(WINED3D_MAX_VS_CONSTS_F, WINED3D_MAX_PS_CONSTS_F)) + 1;
|
||||
@ -308,7 +307,7 @@ index 0e0977e1d4..3c705e0730 100644
|
||||
struct fragment_caps fragment_caps;
|
||||
void *vertex_priv, *fragment_priv;
|
||||
struct shader_glsl_priv *priv;
|
||||
@@ -10940,6 +11050,8 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
|
||||
@@ -10982,6 +11092,8 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
|
||||
if (!(priv = heap_alloc_zero(sizeof(*priv))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
@ -317,7 +316,7 @@ index 0e0977e1d4..3c705e0730 100644
|
||||
string_buffer_list_init(&priv->string_buffers);
|
||||
|
||||
if (!(vertex_priv = vertex_pipe->vp_alloc(&glsl_shader_backend, priv)))
|
||||
@@ -10994,6 +11106,8 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
|
||||
@@ -11036,6 +11148,8 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
|
||||
device->fragment_priv = fragment_priv;
|
||||
device->shader_priv = priv;
|
||||
|
||||
@ -326,7 +325,7 @@ index 0e0977e1d4..3c705e0730 100644
|
||||
return WINED3D_OK;
|
||||
|
||||
fail:
|
||||
@@ -11021,6 +11135,13 @@ static void shader_glsl_free(struct wined3d_device *device, struct wined3d_conte
|
||||
@@ -11063,6 +11177,13 @@ static void shader_glsl_free(struct wined3d_device *device, struct wined3d_conte
|
||||
priv->fragment_pipe->free_private(device, context);
|
||||
priv->vertex_pipe->vp_free(device, context);
|
||||
|
||||
@ -341,7 +340,7 @@ index 0e0977e1d4..3c705e0730 100644
|
||||
device->shader_priv = NULL;
|
||||
}
|
||||
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
|
||||
index 3b9a96abc6..bf8e1c204f 100644
|
||||
index 757631a73e..a869b31a2c 100644
|
||||
--- a/dlls/wined3d/shader.c
|
||||
+++ b/dlls/wined3d/shader.c
|
||||
@@ -767,6 +767,8 @@ static BOOL shader_record_register_usage(struct wined3d_shader *shader, struct w
|
||||
@ -354,10 +353,10 @@ index 3b9a96abc6..bf8e1c204f 100644
|
||||
}
|
||||
}
|
||||
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
|
||||
index 4bc371b8e7..72d42ef446 100644
|
||||
index a4d88e1bfc..9de64777b1 100644
|
||||
--- a/dlls/wined3d/state.c
|
||||
+++ b/dlls/wined3d/state.c
|
||||
@@ -4386,6 +4386,11 @@ static void state_cb(struct wined3d_context *context, const struct wined3d_state
|
||||
@@ -4391,6 +4391,11 @@ static void state_cb(struct wined3d_context *context, const struct wined3d_state
|
||||
unsigned int i, base, count;
|
||||
|
||||
TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id);
|
||||
@ -370,10 +369,10 @@ index 4bc371b8e7..72d42ef446 100644
|
||||
if (STATE_IS_GRAPHICS_CONSTANT_BUFFER(state_id))
|
||||
shader_type = state_id - STATE_GRAPHICS_CONSTANT_BUFFER(0);
|
||||
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
|
||||
index 5ce23f85f6..a76103f6df 100644
|
||||
index 932f35d14e..e6a93d0f6d 100644
|
||||
--- a/dlls/wined3d/wined3d_private.h
|
||||
+++ b/dlls/wined3d/wined3d_private.h
|
||||
@@ -1072,6 +1072,7 @@ struct wined3d_shader_reg_maps
|
||||
@@ -1069,6 +1069,7 @@ struct wined3d_shader_reg_maps
|
||||
struct wined3d_shader_tgsm *tgsm;
|
||||
SIZE_T tgsm_capacity;
|
||||
unsigned int tgsm_count;
|
||||
@ -381,7 +380,7 @@ index 5ce23f85f6..a76103f6df 100644
|
||||
};
|
||||
|
||||
/* Keeps track of details for TEX_M#x# instructions which need to maintain
|
||||
@@ -2704,6 +2705,7 @@ struct wined3d_gl_limits
|
||||
@@ -2742,6 +2743,7 @@ struct wined3d_gl_limits
|
||||
UINT glsl_varyings;
|
||||
UINT glsl_vs_float_constants;
|
||||
UINT glsl_ps_float_constants;
|
||||
@ -390,10 +389,10 @@ index 5ce23f85f6..a76103f6df 100644
|
||||
UINT arb_vs_float_constants;
|
||||
UINT arb_vs_native_constants;
|
||||
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
|
||||
index 4543b882ac..8b6827ea95 100644
|
||||
index 908a1c9266..fd766fa6b3 100644
|
||||
--- a/include/wine/wined3d.h
|
||||
+++ b/include/wine/wined3d.h
|
||||
@@ -1332,6 +1332,7 @@ enum wined3d_shader_type
|
||||
@@ -1338,6 +1338,7 @@ enum wined3d_shader_type
|
||||
#define WINED3D_NO_PRIMITIVE_RESTART 0x00000800
|
||||
#define WINED3D_LEGACY_CUBEMAP_FILTERING 0x00001000
|
||||
#define WINED3D_NORMALIZED_DEPTH_BIAS 0x00002000
|
||||
@ -402,5 +401,5 @@ index 4543b882ac..8b6827ea95 100644
|
||||
#define WINED3D_RESZ_CODE 0x7fa05000
|
||||
|
||||
--
|
||||
2.21.0
|
||||
2.24.1
|
||||
|
||||
|
@ -1,14 +1,13 @@
|
||||
From 27e85f860100445fcce4bad975fc2cf3cfd9720c Mon Sep 17 00:00:00 2001
|
||||
From d02344d80cd0e34f23a091a73663a65abe8e5978 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Gofman <gofmanp@gmail.com>
|
||||
Date: Mon, 25 Feb 2019 14:24:50 +0300
|
||||
Subject: [PATCH] d3d9: Support SWVP vertex shader float constants limits.
|
||||
|
||||
Signed-off-by: Paul Gofman <gofmanp@gmail.com>
|
||||
---
|
||||
dlls/d3d9/d3d9_private.h | 3 ++-
|
||||
dlls/d3d9/device.c | 30 ++++++++++++++++++++++++------
|
||||
dlls/d3d9/device.c | 31 +++++++++++++++++++++++++------
|
||||
dlls/d3d9/directx.c | 2 +-
|
||||
3 files changed, 27 insertions(+), 8 deletions(-)
|
||||
3 files changed, 28 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h
|
||||
index bc9a3b98b2..95fe87df8a 100644
|
||||
@ -32,7 +31,7 @@ index bc9a3b98b2..95fe87df8a 100644
|
||||
struct d3d9
|
||||
{
|
||||
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
|
||||
index 1ff178881c..09cf444c24 100644
|
||||
index 8d85a43523..492a4e4603 100644
|
||||
--- a/dlls/d3d9/device.c
|
||||
+++ b/dlls/d3d9/device.c
|
||||
@@ -360,7 +360,7 @@ static BOOL wined3d_swapchain_desc_from_present_parameters(struct wined3d_swapch
|
||||
@ -81,7 +80,7 @@ index 1ff178881c..09cf444c24 100644
|
||||
|
||||
return hr;
|
||||
}
|
||||
@@ -3542,14 +3548,20 @@ static HRESULT WINAPI d3d9_device_SetVertexShaderConstantF(IDirect3DDevice9Ex *i
|
||||
@@ -3548,14 +3554,20 @@ static HRESULT WINAPI d3d9_device_SetVertexShaderConstantF(IDirect3DDevice9Ex *i
|
||||
UINT reg_idx, const float *data, UINT count)
|
||||
{
|
||||
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
|
||||
@ -104,7 +103,7 @@ index 1ff178881c..09cf444c24 100644
|
||||
return D3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
@@ -3565,14 +3577,20 @@ static HRESULT WINAPI d3d9_device_GetVertexShaderConstantF(IDirect3DDevice9Ex *i
|
||||
@@ -3571,14 +3583,21 @@ static HRESULT WINAPI d3d9_device_GetVertexShaderConstantF(IDirect3DDevice9Ex *i
|
||||
UINT start_idx, float *constants, UINT count)
|
||||
{
|
||||
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
|
||||
@ -122,6 +121,7 @@ index 1ff178881c..09cf444c24 100644
|
||||
+ max_constants = creation_parameters.flags
|
||||
+ & (WINED3DCREATE_SOFTWARE_VERTEXPROCESSING | WINED3DCREATE_MIXED_VERTEXPROCESSING)
|
||||
+ ? D3D9_MAX_VERTEX_SHADER_CONSTANTF_SWVP : D3D9_MAX_VERTEX_SHADER_CONSTANTF;
|
||||
+
|
||||
+ if (start_idx >= max_constants || count > max_constants - start_idx)
|
||||
{
|
||||
WARN("Trying to access %u constants, but d3d9 only supports %u\n",
|
||||
|
@ -1,10 +1,9 @@
|
||||
From 24b372e4dd0c5323668d3355d1f25301c988d6a1 Mon Sep 17 00:00:00 2001
|
||||
From 0979b6a7376d4026cd8deae26e6e19662e36e4d4 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Gofman <gofmanp@gmail.com>
|
||||
Date: Mon, 25 Feb 2019 14:47:28 +0300
|
||||
Subject: [PATCH 3/5] wined3d: Report actual vertex shader float constants
|
||||
limit for SWVP device.
|
||||
Subject: [PATCH] wined3d: Report actual vertex shader float constants limit
|
||||
for SWVP device.
|
||||
|
||||
Signed-off-by: Paul Gofman <gofmanp@gmail.com>
|
||||
---
|
||||
dlls/wined3d/adapter_gl.c | 3 ++-
|
||||
dlls/wined3d/device.c | 13 ++++++++++++-
|
||||
@ -14,10 +13,10 @@ Signed-off-by: Paul Gofman <gofmanp@gmail.com>
|
||||
5 files changed, 20 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/dlls/wined3d/adapter_gl.c b/dlls/wined3d/adapter_gl.c
|
||||
index 82c8270e66..62d147b90f 100644
|
||||
index eeec0e43bd..d71b61ca94 100644
|
||||
--- a/dlls/wined3d/adapter_gl.c
|
||||
+++ b/dlls/wined3d/adapter_gl.c
|
||||
@@ -5186,7 +5186,8 @@ static void wined3d_adapter_gl_init_d3d_info(struct wined3d_adapter_gl *adapter_
|
||||
@@ -5122,7 +5122,8 @@ static void wined3d_adapter_gl_init_d3d_info(struct wined3d_adapter_gl *adapter_
|
||||
d3d_info->limits.gs_version = shader_caps.gs_version;
|
||||
d3d_info->limits.ps_version = shader_caps.ps_version;
|
||||
d3d_info->limits.cs_version = shader_caps.cs_version;
|
||||
@ -28,10 +27,10 @@ index 82c8270e66..62d147b90f 100644
|
||||
d3d_info->limits.varying_count = shader_caps.varying_count;
|
||||
d3d_info->limits.ffp_textures = fragment_caps.MaxSimultaneousTextures;
|
||||
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
|
||||
index b0695547e1..9d3f3dc00f 100644
|
||||
index 3cf621ff46..9aa2c10bc7 100644
|
||||
--- a/dlls/wined3d/device.c
|
||||
+++ b/dlls/wined3d/device.c
|
||||
@@ -3855,10 +3855,21 @@ struct wined3d_texture * CDECL wined3d_device_get_texture(const struct wined3d_d
|
||||
@@ -4049,10 +4049,21 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
|
||||
|
||||
HRESULT CDECL wined3d_device_get_device_caps(const struct wined3d_device *device, struct wined3d_caps *caps)
|
||||
{
|
||||
@ -55,10 +54,10 @@ index b0695547e1..9d3f3dc00f 100644
|
||||
|
||||
HRESULT CDECL wined3d_device_get_display_mode(const struct wined3d_device *device, UINT swapchain_idx,
|
||||
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
|
||||
index 9e367eef15..bcb1fd98fa 100644
|
||||
index e306694533..4f7cc772be 100644
|
||||
--- a/dlls/wined3d/glsl_shader.c
|
||||
+++ b/dlls/wined3d/glsl_shader.c
|
||||
@@ -11241,7 +11241,10 @@ static void shader_glsl_get_caps(const struct wined3d_adapter *adapter, struct s
|
||||
@@ -11261,7 +11261,10 @@ static void shader_glsl_get_caps(const struct wined3d_adapter *adapter, struct s
|
||||
caps->vs_version = gl_info->supported[ARB_VERTEX_SHADER] ? caps->vs_version : 0;
|
||||
caps->ps_version = gl_info->supported[ARB_FRAGMENT_SHADER] ? caps->ps_version : 0;
|
||||
|
||||
@ -71,10 +70,10 @@ index 9e367eef15..bcb1fd98fa 100644
|
||||
caps->varying_count = gl_info->limits.glsl_varyings;
|
||||
|
||||
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
|
||||
index 49cc894c25..540e56d9f9 100644
|
||||
index e6a93d0f6d..73834233a9 100644
|
||||
--- a/dlls/wined3d/wined3d_private.h
|
||||
+++ b/dlls/wined3d/wined3d_private.h
|
||||
@@ -167,6 +167,7 @@ struct wined3d_d3d_limits
|
||||
@@ -173,6 +173,7 @@ struct wined3d_d3d_limits
|
||||
{
|
||||
unsigned int vs_version, hs_version, ds_version, gs_version, ps_version, cs_version;
|
||||
DWORD vs_uniform_count;
|
||||
@ -83,10 +82,10 @@ index 49cc894c25..540e56d9f9 100644
|
||||
unsigned int varying_count;
|
||||
unsigned int ffp_textures;
|
||||
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
|
||||
index fc62750480..d55719e961 100644
|
||||
index fd766fa6b3..3608d414d4 100644
|
||||
--- a/include/wine/wined3d.h
|
||||
+++ b/include/wine/wined3d.h
|
||||
@@ -1602,6 +1602,7 @@ enum wined3d_shader_type
|
||||
@@ -1606,6 +1606,7 @@ enum wined3d_shader_type
|
||||
#define WINED3D_MAX_CONSTS_I 16
|
||||
#define WINED3D_MAX_VS_CONSTS_F 256
|
||||
#define WINED3D_MAX_PS_CONSTS_F 224
|
||||
@ -95,5 +94,5 @@ index fc62750480..d55719e961 100644
|
||||
struct wined3d_display_mode
|
||||
{
|
||||
--
|
||||
2.23.0
|
||||
2.24.1
|
||||
|
||||
|
@ -1,10 +1,9 @@
|
||||
From 346f4479e046a8b786f4fb9df2a1706f3e1fddc5 Mon Sep 17 00:00:00 2001
|
||||
From 8d3eb0ab5a397762fec9a1b47e7e464828e1303a Mon Sep 17 00:00:00 2001
|
||||
From: Paul Gofman <gofmanp@gmail.com>
|
||||
Date: Mon, 25 Feb 2019 15:05:12 +0300
|
||||
Subject: [PATCH] wined3d: Support SWVP vertex shader constants limit in state
|
||||
tracking.
|
||||
|
||||
Signed-off-by: Paul Gofman <gofmanp@gmail.com>
|
||||
---
|
||||
dlls/d3d9/tests/device.c | 5 -----
|
||||
dlls/d3d9/tests/visual.c | 1 -
|
||||
@ -16,7 +15,7 @@ Signed-off-by: Paul Gofman <gofmanp@gmail.com>
|
||||
7 files changed, 30 insertions(+), 20 deletions(-)
|
||||
|
||||
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
|
||||
index 8c1ebc171..b60468e01 100644
|
||||
index 8c1ebc1719..b60468e013 100644
|
||||
--- a/dlls/d3d9/tests/device.c
|
||||
+++ b/dlls/d3d9/tests/device.c
|
||||
@@ -6413,13 +6413,10 @@ static void test_vertex_shader_constant(void)
|
||||
@ -50,7 +49,7 @@ index 8c1ebc171..b60468e01 100644
|
||||
hr = IDirect3DDevice9_SetVertexShaderConstantF(device, consts_swvp - 1, c, 1);
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
|
||||
index cb84ef6f2..2d6e1fa68 100644
|
||||
index cb84ef6f28..2d6e1fa688 100644
|
||||
--- a/dlls/d3d9/tests/visual.c
|
||||
+++ b/dlls/d3d9/tests/visual.c
|
||||
@@ -24884,7 +24884,6 @@ static void test_mvp_software_vertex_shaders(void)
|
||||
@ -62,7 +61,7 @@ index cb84ef6f2..2d6e1fa68 100644
|
||||
|
||||
hr = IDirect3DDevice9_BeginScene(device);
|
||||
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
|
||||
index 9aa2c10bc..3aa3d1331 100644
|
||||
index 9aa2c10bc7..3aa3d13314 100644
|
||||
--- a/dlls/wined3d/device.c
|
||||
+++ b/dlls/wined3d/device.c
|
||||
@@ -2269,13 +2269,17 @@ HRESULT CDECL wined3d_device_set_vs_consts_f(struct wined3d_device *device,
|
||||
@ -128,7 +127,7 @@ index 9aa2c10bc..3aa3d1331 100644
|
||||
if (wined3d_bitmap_is_set(changed->vs_consts_f, i))
|
||||
++count;
|
||||
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
|
||||
index 4f7cc772b..a88f92cc0 100644
|
||||
index 4f7cc772be..a88f92cc03 100644
|
||||
--- a/dlls/wined3d/glsl_shader.c
|
||||
+++ b/dlls/wined3d/glsl_shader.c
|
||||
@@ -1913,7 +1913,7 @@ static void shader_glsl_update_float_vertex_constants(struct wined3d_device *dev
|
||||
@ -141,7 +140,7 @@ index 4f7cc772b..a88f92cc0 100644
|
||||
update_heap_entry(heap, i, priv->next_constant_version);
|
||||
}
|
||||
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
|
||||
index 69210e1fb..7e7bb4d6a 100644
|
||||
index 69210e1fba..7e7bb4d6a9 100644
|
||||
--- a/dlls/wined3d/stateblock.c
|
||||
+++ b/dlls/wined3d/stateblock.c
|
||||
@@ -1331,12 +1331,16 @@ HRESULT CDECL wined3d_stateblock_set_vs_consts_f(struct wined3d_stateblock *stat
|
||||
@ -182,7 +181,7 @@ index 69210e1fb..7e7bb4d6a 100644
|
||||
|
||||
default:
|
||||
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
|
||||
index 73834233a..d07ac1ab0 100644
|
||||
index 73834233a9..d07ac1ab0b 100644
|
||||
--- a/dlls/wined3d/wined3d_private.h
|
||||
+++ b/dlls/wined3d/wined3d_private.h
|
||||
@@ -3201,7 +3201,7 @@ struct wined3d_state
|
||||
@ -204,7 +203,7 @@ index 73834233a..d07ac1ab0 100644
|
||||
DWORD indices : 1;
|
||||
DWORD material : 1;
|
||||
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
|
||||
index 3608d414d..8327f43ec 100644
|
||||
index 3608d414d4..8327f43ec6 100644
|
||||
--- a/include/wine/wined3d.h
|
||||
+++ b/include/wine/wined3d.h
|
||||
@@ -2149,7 +2149,7 @@ struct wined3d_stateblock_state
|
||||
@ -217,5 +216,5 @@ index 3608d414d..8327f43ec 100644
|
||||
BOOL vs_consts_b[WINED3D_MAX_CONSTS_B];
|
||||
|
||||
--
|
||||
2.25.0
|
||||
2.24.1
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
From 6f3d474a66928b4ceb1656db0823de8d47f9aa78 Mon Sep 17 00:00:00 2001
|
||||
From 8e28a42c30774c48cbc5bc4c627357c4d26ed4cd Mon Sep 17 00:00:00 2001
|
||||
From: Paul Gofman <gofmanp@gmail.com>
|
||||
Date: Mon, 25 Feb 2019 15:23:33 +0300
|
||||
Subject: [PATCH 5/5] wined3d: Support SWVP mode vertex shaders.
|
||||
Subject: [PATCH] wined3d: Support SWVP mode vertex shaders.
|
||||
|
||||
Signed-off-by: Paul Gofman <gofmanp@gmail.com>
|
||||
---
|
||||
dlls/d3d9/tests/device.c | 16 ++------
|
||||
dlls/d3d9/tests/visual.c | 5 +--
|
||||
@ -15,10 +14,10 @@ Signed-off-by: Paul Gofman <gofmanp@gmail.com>
|
||||
7 files changed, 104 insertions(+), 49 deletions(-)
|
||||
|
||||
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
|
||||
index 70b6ce01c0..05ba25f077 100644
|
||||
index b60468e013..6e031be27f 100644
|
||||
--- a/dlls/d3d9/tests/device.c
|
||||
+++ b/dlls/d3d9/tests/device.c
|
||||
@@ -6943,15 +6943,11 @@ float4 main(const float4 color : COLOR) : SV_TARGET
|
||||
@@ -6901,15 +6901,11 @@ float4 main(const float4 color : COLOR) : SV_TARGET
|
||||
|
||||
vs = NULL;
|
||||
hr = IDirect3DDevice9_CreateVertexShader(device, vs_1_256, &vs);
|
||||
@ -36,7 +35,7 @@ index 70b6ce01c0..05ba25f077 100644
|
||||
|
||||
refcount = IDirect3DDevice9_Release(device);
|
||||
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||
@@ -6968,20 +6964,16 @@ float4 main(const float4 color : COLOR) : SV_TARGET
|
||||
@@ -6926,20 +6922,16 @@ float4 main(const float4 color : COLOR) : SV_TARGET
|
||||
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IDirect3DDevice9_CreateVertexShader(device, vs_1_256, &vs);
|
||||
@ -60,10 +59,10 @@ index 70b6ce01c0..05ba25f077 100644
|
||||
cleanup:
|
||||
refcount = IDirect3DDevice9_Release(device);
|
||||
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
|
||||
index 2128331ca6..e5298ee3d1 100644
|
||||
index 2d6e1fa688..793b3f0c23 100644
|
||||
--- a/dlls/d3d9/tests/visual.c
|
||||
+++ b/dlls/d3d9/tests/visual.c
|
||||
@@ -24693,7 +24693,6 @@ static void test_mvp_software_vertex_shaders(void)
|
||||
@@ -24810,7 +24810,6 @@ static void test_mvp_software_vertex_shaders(void)
|
||||
hr = IDirect3DDevice9_CreateVertexShader(device, reladdr_shader_code, &reladdr_shader);
|
||||
ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_CreateVertexShader(device, pure_sw_shader_code, &pure_sw_shader);
|
||||
@ -71,7 +70,7 @@ index 2128331ca6..e5298ee3d1 100644
|
||||
ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
|
||||
hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, &vertex_declaration);
|
||||
ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
|
||||
@@ -24731,7 +24730,7 @@ static void test_mvp_software_vertex_shaders(void)
|
||||
@@ -24848,7 +24847,7 @@ static void test_mvp_software_vertex_shaders(void)
|
||||
|
||||
expected_color = 0x00ff0000; /* Color from vertex data and not from the shader. */
|
||||
color = getPixelColor(device, 5, 5);
|
||||
@ -80,7 +79,7 @@ index 2128331ca6..e5298ee3d1 100644
|
||||
expected_color, color);
|
||||
|
||||
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
|
||||
@@ -24750,7 +24749,6 @@ static void test_mvp_software_vertex_shaders(void)
|
||||
@@ -24867,7 +24866,6 @@ static void test_mvp_software_vertex_shaders(void)
|
||||
|
||||
expected_color = 0x00ffffff;
|
||||
color = getPixelColor(device, 5, 5);
|
||||
@ -88,7 +87,7 @@ index 2128331ca6..e5298ee3d1 100644
|
||||
ok(color == expected_color, "Expected color 0x%08x, got 0x%08x (sw shader in sw mode).\n",
|
||||
expected_color, color);
|
||||
|
||||
@@ -24800,7 +24798,6 @@ static void test_mvp_software_vertex_shaders(void)
|
||||
@@ -24917,7 +24915,6 @@ static void test_mvp_software_vertex_shaders(void)
|
||||
|
||||
expected_color = 0x0000ffff; /* c[256] is c_color for SW shader. */
|
||||
color = getPixelColor(device, 5, 5);
|
||||
@ -97,10 +96,10 @@ index 2128331ca6..e5298ee3d1 100644
|
||||
expected_color, color);
|
||||
|
||||
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
|
||||
index ed95996ef3..98aaddd589 100644
|
||||
index 3aa3d13314..4a9b9a7781 100644
|
||||
--- a/dlls/wined3d/device.c
|
||||
+++ b/dlls/wined3d/device.c
|
||||
@@ -4506,6 +4506,14 @@ void CDECL wined3d_device_set_software_vertex_processing(struct wined3d_device *
|
||||
@@ -4524,6 +4524,14 @@ void CDECL wined3d_device_set_software_vertex_processing(struct wined3d_device *
|
||||
warned = TRUE;
|
||||
}
|
||||
|
||||
@ -116,7 +115,7 @@ index ed95996ef3..98aaddd589 100644
|
||||
}
|
||||
|
||||
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
|
||||
index cee3621e0d..3d0e69b807 100644
|
||||
index a88f92cc03..4b151baf97 100644
|
||||
--- a/dlls/wined3d/glsl_shader.c
|
||||
+++ b/dlls/wined3d/glsl_shader.c
|
||||
@@ -140,7 +140,9 @@ struct shader_glsl_priv
|
||||
@ -139,7 +138,7 @@ index cee3621e0d..3d0e69b807 100644
|
||||
GLint uniform_i_locations[WINED3D_MAX_CONSTS_I];
|
||||
GLint uniform_b_locations[WINED3D_MAX_CONSTS_B];
|
||||
GLint pos_fixup_location;
|
||||
@@ -1193,7 +1195,7 @@ static void bind_and_orphan_consts_ubo(const struct wined3d_gl_info *gl_info, st
|
||||
@@ -1195,7 +1197,7 @@ static void bind_and_orphan_consts_ubo(const struct wined3d_gl_info *gl_info, st
|
||||
{
|
||||
GL_EXTCALL(glBindBuffer(GL_UNIFORM_BUFFER, priv->ubo_vs_c));
|
||||
checkGLcall("glBindBuffer");
|
||||
@ -148,7 +147,7 @@ index cee3621e0d..3d0e69b807 100644
|
||||
NULL, GL_STREAM_DRAW));
|
||||
checkGLcall("glBufferData");
|
||||
}
|
||||
@@ -1201,14 +1203,16 @@ static void bind_and_orphan_consts_ubo(const struct wined3d_gl_info *gl_info, st
|
||||
@@ -1203,14 +1205,16 @@ static void bind_and_orphan_consts_ubo(const struct wined3d_gl_info *gl_info, st
|
||||
/* Context activation is done by the caller. */
|
||||
static void shader_glsl_load_constants_f(const struct wined3d_shader *shader, const struct wined3d_gl_info *gl_info,
|
||||
const struct wined3d_vec4 *constants, const GLint *constant_locations, const struct constant_heap *heap,
|
||||
@ -166,7 +165,7 @@ index cee3621e0d..3d0e69b807 100644
|
||||
unsigned max_const_used;
|
||||
|
||||
if (priv->ubo_vs_c == -1)
|
||||
@@ -1218,22 +1222,32 @@ static void shader_glsl_load_constants_f(const struct wined3d_shader *shader, co
|
||||
@@ -1220,22 +1224,32 @@ static void shader_glsl_load_constants_f(const struct wined3d_shader *shader, co
|
||||
}
|
||||
|
||||
bind_and_orphan_consts_ubo(gl_info, priv);
|
||||
@ -205,7 +204,7 @@ index cee3621e0d..3d0e69b807 100644
|
||||
checkGLcall("glBufferSubData");
|
||||
return;
|
||||
}
|
||||
@@ -1601,7 +1615,7 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
|
||||
@@ -1603,7 +1617,7 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
|
||||
GL_EXTCALL(glGenBuffers(1, &priv->ubo_vs_c));
|
||||
GL_EXTCALL(glBindBuffer(GL_UNIFORM_BUFFER, priv->ubo_vs_c));
|
||||
checkGLcall("glBindBuffer (UBO)");
|
||||
@ -214,7 +213,7 @@ index cee3621e0d..3d0e69b807 100644
|
||||
NULL, GL_STREAM_DRAW));
|
||||
checkGLcall("glBufferData");
|
||||
}
|
||||
@@ -1613,7 +1627,8 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
|
||||
@@ -1615,7 +1629,8 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
|
||||
|
||||
if (update_mask & WINED3D_SHADER_CONST_VS_F)
|
||||
shader_glsl_load_constants_f(vshader, gl_info, state->vs_consts_f,
|
||||
@ -224,7 +223,7 @@ index cee3621e0d..3d0e69b807 100644
|
||||
|
||||
if (update_mask & WINED3D_SHADER_CONST_VS_I)
|
||||
shader_glsl_load_constants_i(vshader, gl_info, state->vs_consts_i,
|
||||
@@ -1766,7 +1781,8 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
|
||||
@@ -1768,7 +1783,8 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
|
||||
|
||||
if (update_mask & WINED3D_SHADER_CONST_PS_F)
|
||||
shader_glsl_load_constants_f(pshader, gl_info, state->ps_consts_f,
|
||||
@ -234,7 +233,7 @@ index cee3621e0d..3d0e69b807 100644
|
||||
|
||||
if (update_mask & WINED3D_SHADER_CONST_PS_I)
|
||||
shader_glsl_load_constants_i(pshader, gl_info, state->ps_consts_i,
|
||||
@@ -1911,7 +1927,7 @@ static void shader_glsl_update_float_vertex_constants(struct wined3d_device *dev
|
||||
@@ -1913,7 +1929,7 @@ static void shader_glsl_update_float_vertex_constants(struct wined3d_device *dev
|
||||
if (priv->consts_ubo)
|
||||
return;
|
||||
|
||||
@ -243,7 +242,7 @@ index cee3621e0d..3d0e69b807 100644
|
||||
{
|
||||
update_heap_entry(heap, i, priv->next_constant_version);
|
||||
}
|
||||
@@ -2265,7 +2281,7 @@ static void shader_generate_glsl_declarations(const struct wined3d_context_gl *c
|
||||
@@ -2275,7 +2291,7 @@ static void shader_generate_glsl_declarations(const struct wined3d_context_gl *c
|
||||
shader_addline(buffer,"layout(std140) uniform vs_c_ubo\n"
|
||||
"{ \n"
|
||||
" vec4 %s_c[%u];\n"
|
||||
@ -252,7 +251,7 @@ index cee3621e0d..3d0e69b807 100644
|
||||
}
|
||||
else if (shader->limits->constant_float > 0)
|
||||
{
|
||||
@@ -9961,12 +9977,13 @@ static void shader_glsl_init_vs_uniform_locations(const struct wined3d_gl_info *
|
||||
@@ -10003,12 +10019,13 @@ static void shader_glsl_init_vs_uniform_locations(const struct wined3d_gl_info *
|
||||
}
|
||||
else if (!priv->consts_ubo)
|
||||
{
|
||||
@ -268,7 +267,7 @@ index cee3621e0d..3d0e69b807 100644
|
||||
}
|
||||
|
||||
for (i = 0; i < WINED3D_MAX_CONSTS_I; ++i)
|
||||
@@ -10284,6 +10301,10 @@ static void set_glsl_shader_program(const struct wined3d_context_gl *context_gl,
|
||||
@@ -10326,6 +10343,10 @@ static void set_glsl_shader_program(const struct wined3d_context_gl *context_gl,
|
||||
vs_list = &ffp_shader->linked_programs;
|
||||
}
|
||||
|
||||
@ -279,7 +278,7 @@ index cee3621e0d..3d0e69b807 100644
|
||||
hshader = state->shader[WINED3D_SHADER_TYPE_HULL];
|
||||
if (!(context_gl->c.shader_update_mask & (1u << WINED3D_SHADER_TYPE_HULL)) && ctx_data->glsl_program)
|
||||
hs_id = ctx_data->glsl_program->hs.id;
|
||||
@@ -11041,7 +11062,7 @@ static void constant_heap_free(struct constant_heap *heap)
|
||||
@@ -11083,7 +11104,7 @@ static void constant_heap_free(struct constant_heap *heap)
|
||||
static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct wined3d_vertex_pipe_ops *vertex_pipe,
|
||||
const struct wined3d_fragment_pipe_ops *fragment_pipe)
|
||||
{
|
||||
@ -288,7 +287,7 @@ index cee3621e0d..3d0e69b807 100644
|
||||
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
||||
struct fragment_caps fragment_caps;
|
||||
void *vertex_priv, *fragment_priv;
|
||||
@@ -11052,6 +11073,18 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
|
||||
@@ -11094,6 +11115,18 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
|
||||
|
||||
priv->consts_ubo = (device->adapter->d3d_info.wined3d_creation_flags & WINED3D_LEGACY_SHADER_CONSTANTS)
|
||||
&& gl_info->supported[ARB_UNIFORM_BUFFER_OBJECT];
|
||||
@ -307,7 +306,7 @@ index cee3621e0d..3d0e69b807 100644
|
||||
string_buffer_list_init(&priv->string_buffers);
|
||||
|
||||
if (!(vertex_priv = vertex_pipe->vp_alloc(&glsl_shader_backend, priv)))
|
||||
@@ -11081,7 +11114,7 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
|
||||
@@ -11123,7 +11156,7 @@ static HRESULT shader_glsl_alloc(struct wined3d_device *device, const struct win
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -317,7 +316,7 @@ index cee3621e0d..3d0e69b807 100644
|
||||
ERR("Failed to initialize vertex shader constant heap\n");
|
||||
goto fail;
|
||||
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
|
||||
index bf8e1c204f..59d5a451cf 100644
|
||||
index a869b31a2c..b2145750d6 100644
|
||||
--- a/dlls/wined3d/shader.c
|
||||
+++ b/dlls/wined3d/shader.c
|
||||
@@ -592,7 +592,7 @@ static void shader_delete_constant_list(struct list *clist)
|
||||
@ -376,7 +375,7 @@ index bf8e1c204f..59d5a451cf 100644
|
||||
|
||||
if (!(reg_maps->constf = heap_calloc(((min(shader->limits->constant_float, constf_size) + 31) / 32),
|
||||
sizeof(*reg_maps->constf))))
|
||||
@@ -3325,7 +3338,7 @@ static unsigned int shader_max_version_from_feature_level(enum wined3d_feature_l
|
||||
@@ -3324,7 +3337,7 @@ static unsigned int shader_max_version_from_feature_level(enum wined3d_feature_l
|
||||
}
|
||||
|
||||
static HRESULT shader_set_function(struct wined3d_shader *shader, struct wined3d_device *device,
|
||||
@ -385,7 +384,7 @@ index bf8e1c204f..59d5a451cf 100644
|
||||
{
|
||||
const struct wined3d_d3d_info *d3d_info = &shader->device->adapter->d3d_info;
|
||||
struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
|
||||
@@ -3350,7 +3363,7 @@ static HRESULT shader_set_function(struct wined3d_shader *shader, struct wined3d
|
||||
@@ -3349,7 +3362,7 @@ static HRESULT shader_set_function(struct wined3d_shader *shader, struct wined3d
|
||||
shader_trace_init(fe, shader->frontend_data);
|
||||
|
||||
/* Second pass: figure out which registers are used, what the semantics are, etc. */
|
||||
@ -394,7 +393,7 @@ index bf8e1c204f..59d5a451cf 100644
|
||||
return hr;
|
||||
|
||||
if (version->type != type)
|
||||
@@ -3689,14 +3702,19 @@ static HRESULT vertex_shader_init(struct wined3d_shader *shader, struct wined3d_
|
||||
@@ -3688,14 +3701,19 @@ static HRESULT vertex_shader_init(struct wined3d_shader *shader, struct wined3d_
|
||||
const struct wined3d_shader_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops)
|
||||
{
|
||||
struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps;
|
||||
@ -415,7 +414,7 @@ index bf8e1c204f..59d5a451cf 100644
|
||||
{
|
||||
shader_cleanup(shader);
|
||||
return hr;
|
||||
@@ -3800,7 +3818,7 @@ static HRESULT geometry_shader_init_stream_output(struct wined3d_shader *shader,
|
||||
@@ -3799,7 +3817,7 @@ static HRESULT geometry_shader_init_stream_output(struct wined3d_shader *shader,
|
||||
{
|
||||
shader->reg_maps.shader_version = shader_version;
|
||||
shader->reg_maps.shader_version.type = WINED3D_SHADER_TYPE_GEOMETRY;
|
||||
@ -424,7 +423,7 @@ index bf8e1c204f..59d5a451cf 100644
|
||||
if (FAILED(hr = shader_scan_output_signature(shader)))
|
||||
return hr;
|
||||
}
|
||||
@@ -3853,7 +3871,7 @@ static HRESULT geometry_shader_init(struct wined3d_shader *shader, struct wined3
|
||||
@@ -3852,7 +3870,7 @@ static HRESULT geometry_shader_init(struct wined3d_shader *shader, struct wined3
|
||||
goto fail;
|
||||
|
||||
if (shader->function
|
||||
@ -433,7 +432,7 @@ index bf8e1c204f..59d5a451cf 100644
|
||||
goto fail;
|
||||
|
||||
return WINED3D_OK;
|
||||
@@ -4183,7 +4201,7 @@ static HRESULT pixel_shader_init(struct wined3d_shader *shader, struct wined3d_d
|
||||
@@ -4182,7 +4200,7 @@ static HRESULT pixel_shader_init(struct wined3d_shader *shader, struct wined3d_d
|
||||
return hr;
|
||||
|
||||
if (FAILED(hr = shader_set_function(shader, device,
|
||||
@ -442,7 +441,7 @@ index bf8e1c204f..59d5a451cf 100644
|
||||
{
|
||||
shader_cleanup(shader);
|
||||
return hr;
|
||||
@@ -4275,7 +4293,7 @@ HRESULT CDECL wined3d_shader_create_cs(struct wined3d_device *device, const stru
|
||||
@@ -4274,7 +4292,7 @@ HRESULT CDECL wined3d_shader_create_cs(struct wined3d_device *device, const stru
|
||||
return hr;
|
||||
}
|
||||
|
||||
@ -451,7 +450,7 @@ index bf8e1c204f..59d5a451cf 100644
|
||||
{
|
||||
shader_cleanup(object);
|
||||
heap_free(object);
|
||||
@@ -4309,7 +4327,7 @@ HRESULT CDECL wined3d_shader_create_ds(struct wined3d_device *device, const stru
|
||||
@@ -4308,7 +4326,7 @@ HRESULT CDECL wined3d_shader_create_ds(struct wined3d_device *device, const stru
|
||||
return hr;
|
||||
}
|
||||
|
||||
@ -460,7 +459,7 @@ index bf8e1c204f..59d5a451cf 100644
|
||||
{
|
||||
shader_cleanup(object);
|
||||
heap_free(object);
|
||||
@@ -4371,7 +4389,7 @@ HRESULT CDECL wined3d_shader_create_hs(struct wined3d_device *device, const stru
|
||||
@@ -4370,7 +4388,7 @@ HRESULT CDECL wined3d_shader_create_hs(struct wined3d_device *device, const stru
|
||||
return hr;
|
||||
}
|
||||
|
||||
@ -483,10 +482,10 @@ index 0c6bb93317..1051307e88 100644
|
||||
WARN("Invalid shader version %u.%u (%#x).\n", major, minor, *byte_code);
|
||||
return NULL;
|
||||
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
|
||||
index cfda378cc0..bc9e8a2aa4 100644
|
||||
index d07ac1ab0b..81dfb45ec5 100644
|
||||
--- a/dlls/wined3d/wined3d_private.h
|
||||
+++ b/dlls/wined3d/wined3d_private.h
|
||||
@@ -4860,6 +4860,13 @@ static inline BOOL shader_constant_is_local(const struct wined3d_shader *shader,
|
||||
@@ -4864,6 +4864,13 @@ static inline BOOL shader_constant_is_local(const struct wined3d_shader *shader,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -501,5 +500,5 @@ index cfda378cc0..bc9e8a2aa4 100644
|
||||
void get_modelview_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
|
||||
unsigned int index, struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
|
||||
--
|
||||
2.21.0
|
||||
2.24.1
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user