Wine-Devel
Threads by month
- ----- 2026 -----
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- 1 participants
- 84530 discussions
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com>
---
include/sqlucode.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/sqlucode.h b/include/sqlucode.h
index c87348cd8b5..1286216f902 100644
--- a/include/sqlucode.h
+++ b/include/sqlucode.h
@@ -27,6 +27,9 @@
extern "C" {
#endif
+#define SQL_WVARCHAR (-9)
+#define SQL_WLONGVARCHAR (-10)
+
SQLRETURN WINAPI SQLConnectW(SQLHDBC ConnectionHandle,
SQLWCHAR *ServerName, SQLSMALLINT NameLength1,
SQLWCHAR *UserName, SQLSMALLINT NameLength2,
--
2.30.0
1
0
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/wbemdisp/locator.c | 237 ++++++++++++++++++++++++++++++-
dlls/wbemdisp/main.c | 3 +
dlls/wbemdisp/tests/wbemdisp.c | 12 ++
dlls/wbemdisp/wbemdisp_private.h | 1 +
include/wbemdisp.idl | 11 ++
5 files changed, 263 insertions(+), 1 deletion(-)
diff --git a/dlls/wbemdisp/locator.c b/dlls/wbemdisp/locator.c
index 28c8e5b4120..bbb0625f4e8 100644
--- a/dlls/wbemdisp/locator.c
+++ b/dlls/wbemdisp/locator.c
@@ -47,6 +47,7 @@ enum type_id
ISWbemPropertySet_tid,
ISWbemServices_tid,
ISWbemSecurity_tid,
+ ISWbemNamedValueSet_tid,
last_tid
};
@@ -61,7 +62,8 @@ static REFIID wbemdisp_tid_id[] =
&IID_ISWbemProperty,
&IID_ISWbemPropertySet,
&IID_ISWbemServices,
- &IID_ISWbemSecurity
+ &IID_ISWbemSecurity,
+ &IID_ISWbemNamedValueSet,
};
static HRESULT get_typeinfo( enum type_id tid, ITypeInfo **ret )
@@ -2456,3 +2458,236 @@ static HRESULT ISWbemSecurity_create( ISWbemSecurity **obj )
TRACE( "returning iface %p\n", *obj );
return S_OK;
}
+
+struct namedvalueset
+{
+ ISWbemNamedValueSet ISWbemNamedValueSet_iface;
+ LONG refs;
+};
+
+static struct namedvalueset *impl_from_ISWbemNamedValueSet( ISWbemNamedValueSet *iface )
+{
+ return CONTAINING_RECORD( iface, struct namedvalueset, ISWbemNamedValueSet_iface );
+}
+
+static HRESULT WINAPI namedvalueset_QueryInterface(
+ ISWbemNamedValueSet *iface,
+ REFIID riid,
+ void **ppvObject )
+{
+ struct namedvalueset *set = impl_from_ISWbemNamedValueSet( iface );
+
+ TRACE( "%p, %s, %p\n", set, debugstr_guid( riid ), ppvObject );
+
+ if (IsEqualGUID( riid, &IID_ISWbemNamedValueSet ) ||
+ IsEqualGUID( riid, &IID_IDispatch ) ||
+ IsEqualGUID( riid, &IID_IUnknown ))
+ {
+ *ppvObject = iface;
+ }
+ else
+ {
+ FIXME( "interface %s not implemented\n", debugstr_guid(riid) );
+ return E_NOINTERFACE;
+ }
+ ISWbemNamedValueSet_AddRef( iface );
+ return S_OK;
+}
+
+static ULONG WINAPI namedvalueset_AddRef(
+ ISWbemNamedValueSet *iface )
+{
+ struct namedvalueset *set = impl_from_ISWbemNamedValueSet( iface );
+ return InterlockedIncrement( &set->refs );
+}
+
+static ULONG WINAPI namedvalueset_Release(
+ ISWbemNamedValueSet *iface )
+{
+ struct namedvalueset *set = impl_from_ISWbemNamedValueSet( iface );
+ LONG refs = InterlockedDecrement( &set->refs );
+ if (!refs)
+ {
+ TRACE( "destroying %p\n", set );
+ heap_free( set );
+ }
+ return refs;
+}
+
+static HRESULT WINAPI namedvalueset_GetTypeInfoCount(
+ ISWbemNamedValueSet *iface,
+ UINT *count )
+{
+ struct namedvalueset *set = impl_from_ISWbemNamedValueSet( iface );
+ TRACE( "%p, %p\n", set, count );
+
+ *count = 1;
+ return S_OK;
+}
+
+static HRESULT WINAPI namedvalueset_GetTypeInfo(
+ ISWbemNamedValueSet *iface,
+ UINT index,
+ LCID lcid,
+ ITypeInfo **info )
+{
+ struct namedvalueset *set = impl_from_ISWbemNamedValueSet( iface );
+
+ TRACE( "%p, %u, %u, %p\n", set, index, lcid, info );
+
+ return get_typeinfo( ISWbemNamedValueSet_tid, info );
+}
+
+static HRESULT WINAPI namedvalueset_GetIDsOfNames(
+ ISWbemNamedValueSet *iface,
+ REFIID riid,
+ LPOLESTR *names,
+ UINT count,
+ LCID lcid,
+ DISPID *dispid )
+{
+ struct namedvalueset *set = impl_from_ISWbemNamedValueSet( iface );
+ ITypeInfo *typeinfo;
+ HRESULT hr;
+
+ TRACE( "%p, %s, %p, %u, %u, %p\n", set, debugstr_guid(riid), names, count, lcid, dispid );
+
+ if (!names || !count || !dispid) return E_INVALIDARG;
+
+ hr = get_typeinfo( ISWbemNamedValueSet_tid, &typeinfo );
+ if (SUCCEEDED(hr))
+ {
+ hr = ITypeInfo_GetIDsOfNames( typeinfo, names, count, dispid );
+ ITypeInfo_Release( typeinfo );
+ }
+ return hr;
+}
+
+static HRESULT WINAPI namedvalueset_Invoke(
+ ISWbemNamedValueSet *iface,
+ DISPID member,
+ REFIID riid,
+ LCID lcid,
+ WORD flags,
+ DISPPARAMS *params,
+ VARIANT *result,
+ EXCEPINFO *excep_info,
+ UINT *arg_err )
+{
+ struct namedvalueset *set = impl_from_ISWbemNamedValueSet( iface );
+ ITypeInfo *typeinfo;
+ HRESULT hr;
+
+ TRACE( "%p, %d, %s, %d, %d, %p, %p, %p, %p\n", set, member, debugstr_guid(riid),
+ lcid, flags, params, result, excep_info, arg_err );
+
+ hr = get_typeinfo( ISWbemNamedValueSet_tid, &typeinfo );
+ if (SUCCEEDED(hr))
+ {
+ hr = ITypeInfo_Invoke( typeinfo, &set->ISWbemNamedValueSet_iface, member, flags,
+ params, result, excep_info, arg_err );
+ ITypeInfo_Release( typeinfo );
+ }
+ return hr;
+}
+
+static HRESULT WINAPI namedvalueset_get__NewEnum(
+ ISWbemNamedValueSet *iface,
+ IUnknown **unk )
+{
+ FIXME("\n");
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI namedvalueset_Item(
+ ISWbemNamedValueSet *iface,
+ BSTR name,
+ LONG flags,
+ ISWbemNamedValue **value )
+{
+ FIXME("\n");
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI namedvalueset_Count(
+ ISWbemNamedValueSet *iface,
+ LONG *count )
+{
+ FIXME("\n");
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI namedvalueset_Add(
+ ISWbemNamedValueSet *iface,
+ BSTR name,
+ VARIANT *value,
+ LONG flags,
+ ISWbemNamedValue **namedvalue )
+{
+ FIXME("\n");
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI namedvalueset_Remove(
+ ISWbemNamedValueSet *iface,
+ BSTR name,
+ LONG flags )
+{
+ FIXME("\n");
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI namedvalueset_Clone(
+ ISWbemNamedValueSet *iface,
+ ISWbemNamedValueSet **valueset )
+{
+ FIXME("\n");
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI namedvalueset_DeleteAll(
+ ISWbemNamedValueSet *iface )
+{
+ FIXME("\n");
+
+ return E_NOTIMPL;
+}
+
+static const ISWbemNamedValueSetVtbl namedvalueset_vtbl =
+{
+ namedvalueset_QueryInterface,
+ namedvalueset_AddRef,
+ namedvalueset_Release,
+ namedvalueset_GetTypeInfoCount,
+ namedvalueset_GetTypeInfo,
+ namedvalueset_GetIDsOfNames,
+ namedvalueset_Invoke,
+ namedvalueset_get__NewEnum,
+ namedvalueset_Item,
+ namedvalueset_Count,
+ namedvalueset_Add,
+ namedvalueset_Remove,
+ namedvalueset_Clone,
+ namedvalueset_DeleteAll,
+};
+
+HRESULT SWbemNamedValueSet_create( void **obj )
+{
+ struct namedvalueset *set;
+
+ TRACE( "%p\n", obj );
+
+ if (!(set = heap_alloc_zero( sizeof(*set) ))) return E_OUTOFMEMORY;
+ set->ISWbemNamedValueSet_iface.lpVtbl = &namedvalueset_vtbl;
+ set->refs = 1;
+
+ *obj = &set->ISWbemNamedValueSet_iface;
+ TRACE( "returning iface %p\n", *obj );
+ return S_OK;
+}
diff --git a/dlls/wbemdisp/main.c b/dlls/wbemdisp/main.c
index cfaf7d787eb..b0064582187 100644
--- a/dlls/wbemdisp/main.c
+++ b/dlls/wbemdisp/main.c
@@ -262,6 +262,7 @@ static const struct IClassFactoryVtbl factory_vtbl =
};
static struct factory swbem_locator_cf = { { &factory_vtbl }, SWbemLocator_create };
+static struct factory swbem_namedvalueset_cf = { { &factory_vtbl }, SWbemNamedValueSet_create };
static struct factory winmgmts_cf = { { &factory_vtbl }, WinMGMTS_create };
BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
@@ -289,6 +290,8 @@ HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID iid, LPVOID *obj )
cf = &swbem_locator_cf.IClassFactory_iface;
else if (IsEqualGUID( rclsid, &CLSID_WinMGMTS ))
cf = &winmgmts_cf.IClassFactory_iface;
+ else if (IsEqualGUID( rclsid, &CLSID_SWbemNamedValueSet ))
+ cf = &swbem_namedvalueset_cf.IClassFactory_iface;
else
return CLASS_E_CLASSNOTAVAILABLE;
diff --git a/dlls/wbemdisp/tests/wbemdisp.c b/dlls/wbemdisp/tests/wbemdisp.c
index fa51ce6d756..24225ad1ac1 100644
--- a/dlls/wbemdisp/tests/wbemdisp.c
+++ b/dlls/wbemdisp/tests/wbemdisp.c
@@ -402,12 +402,24 @@ static void test_locator(void)
ISWbemLocator_Release( locator );
}
+static void test_namedvalueset(void)
+{
+ ISWbemNamedValueSet *set;
+ HRESULT hr;
+
+ hr = CoCreateInstance( &CLSID_SWbemNamedValueSet, NULL, CLSCTX_INPROC_SERVER, &IID_ISWbemNamedValueSet, (void **)&set );
+ ok( hr == S_OK, "got %x\n", hr );
+
+ ISWbemNamedValueSet_Release(set);
+}
+
START_TEST(wbemdisp)
{
CoInitialize( NULL );
test_ParseDisplayName();
test_locator();
+ test_namedvalueset();
CoUninitialize();
}
diff --git a/dlls/wbemdisp/wbemdisp_private.h b/dlls/wbemdisp/wbemdisp_private.h
index b03a13e2ea0..1648843fcba 100644
--- a/dlls/wbemdisp/wbemdisp_private.h
+++ b/dlls/wbemdisp/wbemdisp_private.h
@@ -17,3 +17,4 @@
*/
HRESULT SWbemLocator_create(LPVOID *) DECLSPEC_HIDDEN;
+HRESULT SWbemNamedValueSet_create(void **) DECLSPEC_HIDDEN;
diff --git a/include/wbemdisp.idl b/include/wbemdisp.idl
index 8ccdd0ca5e2..6f09f7ee154 100644
--- a/include/wbemdisp.idl
+++ b/include/wbemdisp.idl
@@ -1196,4 +1196,15 @@ coclass SWbemLocator
interface ISWbemLocator;
}
+[
+ threading(apartment),
+ uuid(9aed384e-ce8b-11d1-8b05-00600806d9b6),
+ progid("WbemScripting.SWbemNamedValueSet.1"),
+ vi_progid("WbemScripting.SWbemNamedValueSet")
+]
+coclass SWbemNamedValueSet
+{
+ interface ISWbemNamedValueSet;
+}
+
} /* WbemScripting */
--
2.30.0
2
1
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/wbemprox/main.c | 5 +
dlls/wbemprox/services.c | 175 +++++++++++++++++++++++++++++++
dlls/wbemprox/tests/services.c | 12 +++
dlls/wbemprox/wbemprox.idl | 7 ++
dlls/wbemprox/wbemprox_private.h | 1 +
include/wbemcli.idl | 9 ++
6 files changed, 209 insertions(+)
diff --git a/dlls/wbemprox/main.c b/dlls/wbemprox/main.c
index 09084414983..0ebbd55aba9 100644
--- a/dlls/wbemprox/main.c
+++ b/dlls/wbemprox/main.c
@@ -112,6 +112,7 @@ static const struct IClassFactoryVtbl wbemprox_cf_vtbl =
};
static wbemprox_cf wbem_locator_cf = { { &wbemprox_cf_vtbl }, WbemLocator_create };
+static wbemprox_cf wbem_context_cf = { { &wbemprox_cf_vtbl }, WbemContext_create };
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
@@ -139,6 +140,10 @@ HRESULT WINAPI DllGetClassObject( REFCLSID rclsid, REFIID iid, LPVOID *ppv )
{
cf = &wbem_locator_cf.IClassFactory_iface;
}
+ else if (IsEqualGUID( rclsid, &CLSID_WbemContext ))
+ {
+ cf = &wbem_context_cf.IClassFactory_iface;
+ }
if (!cf) return CLASS_E_CLASSNOTAVAILABLE;
return IClassFactory_QueryInterface( cf, iid, ppv );
}
diff --git a/dlls/wbemprox/services.c b/dlls/wbemprox/services.c
index ab7146db2d8..965f1b168f1 100644
--- a/dlls/wbemprox/services.c
+++ b/dlls/wbemprox/services.c
@@ -954,3 +954,178 @@ HRESULT WbemServices_create( const WCHAR *namespace, LPVOID *ppObj )
TRACE("returning iface %p\n", *ppObj);
return S_OK;
}
+
+struct wbem_context
+{
+ IWbemContext IWbemContext_iface;
+ LONG refs;
+};
+
+static struct wbem_context *impl_from_IWbemContext( IWbemContext *iface )
+{
+ return CONTAINING_RECORD( iface, struct wbem_context, IWbemContext_iface );
+}
+
+static HRESULT WINAPI wbem_context_QueryInterface(
+ IWbemContext *iface,
+ REFIID riid,
+ void **obj)
+{
+ TRACE("%p, %s, %p\n", iface, debugstr_guid( riid ), obj );
+
+ if ( IsEqualGUID( riid, &IID_IWbemContext ) ||
+ IsEqualGUID( riid, &IID_IUnknown ) )
+ {
+ *obj = iface;
+ }
+ else
+ {
+ FIXME("interface %s not implemented\n", debugstr_guid(riid));
+ return E_NOINTERFACE;
+ }
+
+ IWbemContext_AddRef( iface );
+ return S_OK;
+}
+
+static ULONG WINAPI wbem_context_AddRef(
+ IWbemContext *iface )
+{
+ struct wbem_context *context = impl_from_IWbemContext( iface );
+ return InterlockedIncrement( &context->refs );
+}
+
+static ULONG WINAPI wbem_context_Release(
+ IWbemContext *iface )
+{
+ struct wbem_context *context = impl_from_IWbemContext( iface );
+ LONG refs = InterlockedDecrement( &context->refs );
+
+ if (!refs)
+ {
+ TRACE("destroying %p\n", context);
+ heap_free( context );
+ }
+ return refs;
+}
+
+static HRESULT WINAPI wbem_context_Clone(
+ IWbemContext *iface,
+ IWbemContext **newcopy )
+{
+ FIXME("%p, %p\n", iface, newcopy);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI wbem_context_GetNames(
+ IWbemContext *iface,
+ LONG flags,
+ SAFEARRAY **names )
+{
+ FIXME("%p, %#x, %p\n", iface, flags, names);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI wbem_context_BeginEnumeration(
+ IWbemContext *iface,
+ LONG flags )
+{
+ FIXME("%p, %#x\n", iface, flags);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI wbem_context_Next(
+ IWbemContext *iface,
+ LONG flags,
+ BSTR *name,
+ VARIANT *value )
+{
+ FIXME("%p, %#x, %p, %p\n", iface, flags, name, value);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI wbem_context_EndEnumeration(
+ IWbemContext *iface )
+{
+ FIXME("%p\n", iface);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI wbem_context_SetValue(
+ IWbemContext *iface,
+ LPCWSTR name,
+ LONG flags,
+ VARIANT *value )
+{
+ FIXME("%p, %s, %#x, %p\n", iface, debugstr_w(name), flags, value);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI wbem_context_GetValue(
+ IWbemContext *iface,
+ LPCWSTR name,
+ LONG flags,
+ VARIANT *value )
+{
+ FIXME("%p, %s, %#x, %p\n", iface, debugstr_w(name), flags, value);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI wbem_context_DeleteValue(
+ IWbemContext *iface,
+ LPCWSTR name,
+ LONG flags )
+{
+ FIXME("%p, %s, %#x\n", iface, debugstr_w(name), flags);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI wbem_context_DeleteAll(
+ IWbemContext *iface )
+{
+ FIXME("%p\n", iface);
+
+ return E_NOTIMPL;
+}
+
+static const IWbemContextVtbl wbem_context_vtbl =
+{
+ wbem_context_QueryInterface,
+ wbem_context_AddRef,
+ wbem_context_Release,
+ wbem_context_Clone,
+ wbem_context_GetNames,
+ wbem_context_BeginEnumeration,
+ wbem_context_Next,
+ wbem_context_EndEnumeration,
+ wbem_context_SetValue,
+ wbem_context_GetValue,
+ wbem_context_DeleteValue,
+ wbem_context_DeleteAll,
+};
+
+HRESULT WbemContext_create( void **obj )
+{
+ struct wbem_context *context;
+
+ TRACE("(%p)\n", obj);
+
+ context = heap_alloc( sizeof(*context) );
+ if (!context) return E_OUTOFMEMORY;
+
+ context->IWbemContext_iface.lpVtbl = &wbem_context_vtbl;
+ context->refs = 1;
+
+ *obj = &context->IWbemContext_iface;
+
+ TRACE("returning iface %p\n", *obj);
+ return S_OK;
+}
diff --git a/dlls/wbemprox/tests/services.c b/dlls/wbemprox/tests/services.c
index cf45ed712b6..a60d39f1ef2 100644
--- a/dlls/wbemprox/tests/services.c
+++ b/dlls/wbemprox/tests/services.c
@@ -149,10 +149,22 @@ static void test_IWbemLocator(void)
IWbemLocator_Release( locator );
}
+static void test_IWbemContext(void)
+{
+ IWbemContext *context;
+ HRESULT hr;
+
+ hr = CoCreateInstance( &CLSID_WbemContext, NULL, CLSCTX_INPROC_SERVER, &IID_IWbemContext, (void **)&context );
+ ok(hr == S_OK, "Failed to create context object, hr %#x.\n", hr);
+
+ IWbemContext_Release( context );
+}
+
START_TEST(services)
{
CoInitialize( NULL );
test_IClientSecurity();
test_IWbemLocator();
+ test_IWbemContext();
CoUninitialize();
}
diff --git a/dlls/wbemprox/wbemprox.idl b/dlls/wbemprox/wbemprox.idl
index 5c6255a39dc..32fee800ee4 100644
--- a/dlls/wbemprox/wbemprox.idl
+++ b/dlls/wbemprox/wbemprox.idl
@@ -27,6 +27,13 @@
]
coclass WbemLocator { interface IWbemLocator; }
+[
+ helpstring("WBEM Call Context"),
+ threading(both),
+ uuid(674b6698-ee92-11d0-ad71-00c04fd8fdff)
+]
+coclass WbemContext { interface IWbemContext; }
+
[
helpstring("WBEM Administrative Locator"),
threading(both),
diff --git a/dlls/wbemprox/wbemprox_private.h b/dlls/wbemprox/wbemprox_private.h
index ff9a7f6ff82..ac857b859e8 100644
--- a/dlls/wbemprox/wbemprox_private.h
+++ b/dlls/wbemprox/wbemprox_private.h
@@ -237,6 +237,7 @@ HRESULT create_signature( const WCHAR *, const WCHAR *, enum param_direction,
HRESULT WbemLocator_create(LPVOID *) DECLSPEC_HIDDEN;
HRESULT WbemServices_create(const WCHAR *, LPVOID *) DECLSPEC_HIDDEN;
+HRESULT WbemContext_create(void **) DECLSPEC_HIDDEN;
HRESULT create_class_object(const WCHAR *, IEnumWbemClassObject *, UINT,
struct record *, IWbemClassObject **) DECLSPEC_HIDDEN;
HRESULT EnumWbemClassObject_create(struct query *, LPVOID *) DECLSPEC_HIDDEN;
diff --git a/include/wbemcli.idl b/include/wbemcli.idl
index 4a2c1f785c9..f5c7f1bf44a 100644
--- a/include/wbemcli.idl
+++ b/include/wbemcli.idl
@@ -936,3 +936,12 @@ coclass WbemRefresher
interface IWbemRefresher;
interface IWbemConfigureRefresher;
};
+
+[
+ restricted,
+ uuid(674b6698-ee92-11d0-ad71-00c04fd8fdff)
+]
+coclass WbemContext
+{
+ interface IWbemContext;
+}
--
2.30.0
2
1
[PATCH] ntdll/tests: Avoid passing an uninitialized timeout to NtNotifyChangeKey().
by Zebediah Figura Feb. 24, 2021
by Zebediah Figura Feb. 24, 2021
Feb. 24, 2021
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/ntdll/tests/reg.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/dlls/ntdll/tests/reg.c b/dlls/ntdll/tests/reg.c
index ac1dec9f2f8..7463f98aa29 100644
--- a/dlls/ntdll/tests/reg.c
+++ b/dlls/ntdll/tests/reg.c
@@ -1850,7 +1850,7 @@ static void test_NtQueryKey(void)
static void test_notify(void)
{
OBJECT_ATTRIBUTES attr;
- LARGE_INTEGER timeout;
+ static const LARGE_INTEGER timeout;
IO_STATUS_BLOCK iosb;
UNICODE_STRING str;
HANDLE key, key2, events[4], subkey;
@@ -1952,7 +1952,6 @@ static void test_notify(void)
status = pNtNotifyChangeMultipleKeys(key, 0, NULL, events[0], NULL, NULL, &iosb, REG_NOTIFY_CHANGE_NAME, FALSE, NULL, 0, TRUE);
ok(status == STATUS_PENDING, "NtNotifyChangeKey returned %x\n", status);
- timeout.QuadPart = 0;
status = pNtWaitForSingleObject(events[0], FALSE, &timeout);
ok(status == STATUS_TIMEOUT, "NtWaitForSingleObject returned %x\n", status);
--
2.20.1
1
0
And use it in a few more places.
Signed-off-by: Jacek Caban <jacek(a)codeweavers.com>
---
dlls/ntdll/unix/signal_x86_64.c | 16 ++++++----------
dlls/ntdll/unix/system.c | 2 +-
dlls/ntdll/unix/unix_private.h | 1 +
3 files changed, 8 insertions(+), 11 deletions(-)
1
1
[PATCH 5/5] d3d11: Always return the rectangle count in d3d11_immediate_context_RSGetScissorRects().
by Henri Verbeet Feb. 23, 2021
by Henri Verbeet Feb. 23, 2021
Feb. 23, 2021
From: Rémi Bernon <rbernon(a)codeweavers.com>
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
This supersedes patch 200186.
dlls/d3d11/device.c | 9 ++-------
dlls/d3d11/tests/d3d11.c | 6 +++---
2 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index a5d9dc1aa7be..c8ec35a59c0f 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -2270,14 +2270,9 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetScissorRects(ID3D11De
wined3d_device_get_scissor_rects(device->wined3d_device, &actual_count, rects);
wined3d_mutex_unlock();
- if (!rects)
- {
- *rect_count = actual_count;
- return;
- }
-
- if (*rect_count > actual_count)
+ if (rects && *rect_count > actual_count)
memset(&rects[actual_count], 0, (*rect_count - actual_count) * sizeof(*rects));
+ *rect_count = actual_count;
}
static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetShaderResources(ID3D11DeviceContext1 *iface,
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 2eff98fe8fcf..32a9dc2e5306 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -7235,7 +7235,7 @@ static void test_device_context_state(void)
memset(tmp_rect, 0xa5, sizeof(tmp_rect));
count = 2;
ID3D11DeviceContext1_RSGetScissorRects(context, &count, tmp_rect);
- todo_wine ok(count == 0, "Got unexpected scissor rect count %u.\n", count);
+ ok(count == 0, "Got unexpected scissor rect count %u.\n", count);
tmp_sob = (ID3D11Buffer *)0xdeadbeef;
ID3D11DeviceContext1_SOGetTargets(context, 1, &tmp_sob);
@@ -7514,7 +7514,7 @@ static void test_device_context_state(void)
memset(tmp_rect, 0xa5, sizeof(tmp_rect));
count = 2;
ID3D11DeviceContext1_RSGetScissorRects(context, &count, tmp_rect);
- todo_wine ok(count == 1, "Got scissor rect count %u, expected 1.\n", count);
+ ok(count == 1, "Got scissor rect count %u, expected 1.\n", count);
ok(!memcmp(tmp_rect, &rect, sizeof(rect)), "Got scissor rect %s, expected %s.\n",
wine_dbgstr_rect(tmp_rect), wine_dbgstr_rect(&rect));
@@ -7962,7 +7962,7 @@ static void test_device_context_state(void)
memset(tmp_rect, 0xa5, sizeof(tmp_rect));
count = 2;
ID3D11DeviceContext1_RSGetScissorRects(context, &count, tmp_rect);
- todo_wine ok(count == 1, "Got scissor rect count %u, expected 1.\n", count);
+ ok(count == 1, "Got scissor rect count %u, expected 1.\n", count);
ok(!memcmp(tmp_rect, &rect, sizeof(rect)), "Got scissor rect %s, expected %s.\n",
wine_dbgstr_rect(tmp_rect), wine_dbgstr_rect(&rect));
--
2.20.1
2
1
[PATCH vkd3d v2 1/3] vkd3d-shader: Implement hlsl_error() and hlsl_warning().
by Zebediah Figura Feb. 23, 2021
by Zebediah Figura Feb. 23, 2021
Feb. 23, 2021
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
Makefile.am | 1 -
libs/vkd3d-shader/hlsl.c | 18 +-
libs/vkd3d-shader/hlsl.h | 8 +-
libs/vkd3d-shader/hlsl.l | 3 +-
libs/vkd3d-shader/hlsl.y | 204 ++++++++++++-----------
libs/vkd3d-shader/vkd3d_shader_private.h | 18 ++
6 files changed, 147 insertions(+), 105 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 065b9817..3c219e8a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -246,7 +246,6 @@ XFAIL_TESTS = \
tests/conditional.shader_test \
tests/hlsl-array-dimension.shader_test \
tests/hlsl-comma.shader_test \
- tests/hlsl-invalid.shader_test \
tests/hlsl-majority-pragma.shader_test \
tests/hlsl-majority-typedef.shader_test \
tests/hlsl-return-implicit-conversion.shader_test \
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c
index 9e1eb7ee..1f9a3927 100644
--- a/libs/vkd3d-shader/hlsl.c
+++ b/libs/vkd3d-shader/hlsl.c
@@ -31,16 +31,26 @@ void hlsl_note(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc,
/* FIXME */
}
-void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, const char *fmt, ...)
+void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc,
+ enum vkd3d_shader_error error, const char *fmt, ...)
{
- /* FIXME */
+ va_list args;
+
+ va_start(args, fmt);
+ vkd3d_shader_verror(ctx->message_context, &loc, error, fmt, args);
+ va_end(args);
ctx->failed = true;
}
-void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, const char *fmt, ...)
+void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc,
+ enum vkd3d_shader_error error, const char *fmt, ...)
{
- /* FIXME */
+ va_list args;
+
+ va_start(args, fmt);
+ vkd3d_shader_vwarning(ctx->message_context, &loc, error, fmt, args);
+ va_end(args);
}
bool hlsl_add_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, bool local_var)
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h
index 56b8e2a8..9122b097 100644
--- a/libs/vkd3d-shader/hlsl.h
+++ b/libs/vkd3d-shader/hlsl.h
@@ -546,10 +546,10 @@ struct hlsl_ir_load *hlsl_new_var_load(struct hlsl_ir_var *var, const struct vkd
void hlsl_message(const char *fmt, ...) VKD3D_PRINTF_FUNC(1,2) DECLSPEC_HIDDEN;
-void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc,
- const char *fmt, ...) VKD3D_PRINTF_FUNC(3, 4) DECLSPEC_HIDDEN;
-void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc,
- const char *fmt, ...) VKD3D_PRINTF_FUNC(3, 4) DECLSPEC_HIDDEN;
+void hlsl_error(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, enum vkd3d_shader_error error,
+ const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5) DECLSPEC_HIDDEN;
+void hlsl_warning(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, enum vkd3d_shader_error error,
+ const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5) DECLSPEC_HIDDEN;
void hlsl_note(struct hlsl_ctx *ctx, const struct vkd3d_shader_location loc, enum vkd3d_shader_log_level level,
const char *fmt, ...) VKD3D_PRINTF_FUNC(4, 5) DECLSPEC_HIDDEN;
diff --git a/libs/vkd3d-shader/hlsl.l b/libs/vkd3d-shader/hlsl.l
index 933c9b88..4cc0a3ea 100644
--- a/libs/vkd3d-shader/hlsl.l
+++ b/libs/vkd3d-shader/hlsl.l
@@ -65,7 +65,8 @@ ANY (.)
{RESERVED4} {
struct hlsl_ctx *ctx = yyget_extra(yyscanner);
- hlsl_error(ctx, *yylloc, "Reserved keyword \"%s\" used.\n", yytext);
+ hlsl_error(ctx, *yylloc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX,
+ "Reserved keyword \"%s\" used.", yytext);
}
BlendState {return KW_BLENDSTATE; }
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index c33d97c6..b6d03243 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -113,7 +113,7 @@ int yylex(HLSL_YYSTYPE *yylval_param, HLSL_YYLTYPE *yylloc_param, void *yyscanne
static void yyerror(YYLTYPE *loc, void *scanner, struct hlsl_ctx *ctx, const char *s)
{
- hlsl_error(ctx, *loc, "%s", s);
+ hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "%s", s);
}
static struct hlsl_ir_node *node_from_list(struct list *list)
@@ -124,7 +124,8 @@ static struct hlsl_ir_node *node_from_list(struct list *list)
static void check_invalid_matrix_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, struct vkd3d_shader_location loc)
{
if (modifiers & HLSL_MODIFIERS_MAJORITY_MASK)
- hlsl_error(ctx, loc, "'row_major' or 'column_major' modifiers are only allowed for matrices.");
+ hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
+ "'row_major' and 'column_major' modifiers are only allowed for matrices.");
}
static bool convertible_data_type(struct hlsl_type *type)
@@ -257,14 +258,16 @@ static struct hlsl_ir_node *add_implicit_conversion(struct hlsl_ctx *ctx, struct
char *src_string = hlsl_type_to_string(src_type), *dst_string = hlsl_type_to_string(dst_type);
if (src_string && dst_string)
- hlsl_error(ctx, *loc, "Can't implicitly convert from %s to %s.", src_string, dst_string);
+ hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
+ "Can't implicitly convert from %s to %s.", src_string, dst_string);
vkd3d_free(src_string);
vkd3d_free(dst_string);
return NULL;
}
if (dst_type->dimx * dst_type->dimy < src_type->dimx * src_type->dimy)
- hlsl_warning(ctx, *loc, "implicit truncation of vector type");
+ hlsl_warning(ctx, *loc, VKD3D_SHADER_WARNING_HLSL_IMPLICIT_TRUNCATION, "Implicit truncation of %s type.",
+ src_type->type == HLSL_CLASS_VECTOR ? "vector" : "matrix");
if (!(cast = hlsl_new_cast(node, dst_type, loc)))
return NULL;
@@ -289,14 +292,15 @@ static bool declare_variable(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, boo
char *string;
if ((string = hlsl_modifiers_to_string(invalid)))
- hlsl_error(ctx, decl->loc,
+ hlsl_error(ctx, decl->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
"Modifiers '%s' are not allowed on local variables.", string);
vkd3d_free(string);
}
if (decl->semantic)
{
- hlsl_error(ctx, decl->loc, "semantics are not allowed on local variables");
+ hlsl_error(ctx, decl->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC,
+ "Semantics are not allowed on local variables.");
return false;
}
}
@@ -304,7 +308,8 @@ static bool declare_variable(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, boo
{
if (hlsl_get_function(ctx, decl->name))
{
- hlsl_error(ctx, decl->loc, "redefinition of '%s'", decl->name);
+ hlsl_error(ctx, decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
+ "Variable '%s' is already defined as a function.", decl->name);
return false;
}
}
@@ -313,8 +318,9 @@ static bool declare_variable(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, boo
{
struct hlsl_ir_var *old = hlsl_get_var(ctx->cur_scope, decl->name);
- hlsl_error(ctx, decl->loc, "\"%s\" already declared", decl->name);
- hlsl_note(ctx, old->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously declared here", old->name);
+ hlsl_error(ctx, decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
+ "Variable \"%s\" was already declared in this scope.", decl->name);
+ hlsl_note(ctx, old->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously declared here.", old->name);
return false;
}
return true;
@@ -327,13 +333,15 @@ static DWORD add_modifiers(struct hlsl_ctx *ctx, DWORD modifiers, DWORD mod, con
char *string;
if ((string = hlsl_modifiers_to_string(mod)))
- hlsl_error(ctx, loc, "Modifier '%s' was already specified.", string);
+ hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
+ "Modifier '%s' was already specified.", string);
vkd3d_free(string);
return modifiers;
}
if ((mod & HLSL_MODIFIERS_MAJORITY_MASK) && (modifiers & HLSL_MODIFIERS_MAJORITY_MASK))
{
- hlsl_error(ctx, loc, "more than one matrix majority keyword");
+ hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
+ "'row_major' and 'column_major' modifiers are mutually exclusive.");
return modifiers;
}
return modifiers | mod;
@@ -541,7 +549,7 @@ static struct hlsl_ir_jump *add_return(struct hlsl_ctx *ctx, struct list *instrs
}
else if (!hlsl_type_is_void(return_type))
{
- hlsl_error(ctx, loc, "non-void function must return a value");
+ hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_RETURN, "Non-void function must return a value.");
return NULL;
}
@@ -631,9 +639,9 @@ static struct hlsl_ir_load *add_array_load(struct hlsl_ctx *ctx, struct list *in
else
{
if (expr_type->type == HLSL_CLASS_SCALAR)
- hlsl_error(ctx, loc, "array-indexed expression is scalar");
+ hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_INDEX, "Scalar expressions cannot be array-indexed.");
else
- hlsl_error(ctx, loc, "expression is not array-indexable");
+ hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_INDEX, "Expression cannot be array-indexed.");
return NULL;
}
@@ -733,7 +741,7 @@ static struct list *gen_struct_fields(struct hlsl_ctx *ctx, struct hlsl_type *ty
field->semantic = v->semantic;
if (v->initializer.args_count)
{
- hlsl_error(ctx, v->loc, "struct field with an initializer.\n");
+ hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Illegal initializer on a struct field.\n");
free_parse_initializer(&v->initializer);
}
list_add_tail(list, &field->entry);
@@ -768,12 +776,13 @@ static bool add_typedef(struct hlsl_ctx *ctx, DWORD modifiers, struct hlsl_type
if ((type->modifiers & HLSL_MODIFIER_COLUMN_MAJOR)
&& (type->modifiers & HLSL_MODIFIER_ROW_MAJOR))
- hlsl_error(ctx, v->loc, "more than one matrix majority keyword");
+ hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
+ "'row_major' and 'column_major' modifiers are mutually exclusive.");
ret = hlsl_scope_add_type(ctx->cur_scope, type);
if (!ret)
- hlsl_error(ctx, v->loc,
- "redefinition of custom type '%s'", v->name);
+ hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
+ "Type '%s' is already defined.", v->name);
vkd3d_free(v);
}
vkd3d_free(list);
@@ -1009,7 +1018,8 @@ static struct hlsl_type *expr_common_type(struct hlsl_ctx *ctx, struct hlsl_type
if (t1->type > HLSL_CLASS_LAST_NUMERIC || t2->type > HLSL_CLASS_LAST_NUMERIC)
{
- hlsl_error(ctx, *loc, "non scalar/vector/matrix data type in expression");
+ hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
+ "Non-numeric types cannot be used in expressions.");
return NULL;
}
@@ -1018,7 +1028,8 @@ static struct hlsl_type *expr_common_type(struct hlsl_ctx *ctx, struct hlsl_type
if (!expr_compatible_data_types(t1, t2))
{
- hlsl_error(ctx, *loc, "expression data types are incompatible");
+ hlsl_error(ctx, *loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
+ "Expression data types are incompatible.");
return NULL;
}
@@ -1121,9 +1132,9 @@ static struct hlsl_ir_expr *add_expr(struct hlsl_ctx *ctx, struct list *instrs,
continue;
if (operands[i]->data_type->dimx * operands[i]->data_type->dimy != 1
&& operands[i]->data_type->dimx * operands[i]->data_type->dimy != type->dimx * type->dimy)
- {
- hlsl_warning(ctx, operands[i]->loc, "implicit truncation of vector/matrix type");
- }
+ hlsl_warning(ctx, operands[i]->loc, VKD3D_SHADER_WARNING_HLSL_IMPLICIT_TRUNCATION,
+ "Implicit truncation of %s type.",
+ operands[i]->data_type->type == HLSL_CLASS_VECTOR ? "vector" : "matrix");
if (!(cast = hlsl_new_cast(operands[i], type, &operands[i]->loc)))
return NULL;
@@ -1261,7 +1272,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
hlsl_src_from_node(&swizzle->val, rhs);
if (!invert_swizzle(&swizzle->swizzle, &writemask, &width))
{
- hlsl_error(ctx, lhs->loc, "invalid writemask");
+ hlsl_error(ctx, lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_WRITEMASK, "Invalid writemask.");
vkd3d_free(assign);
return NULL;
}
@@ -1272,7 +1283,7 @@ static struct hlsl_ir_node *add_assignment(struct hlsl_ctx *ctx, struct list *in
}
else
{
- hlsl_error(ctx, lhs->loc, "invalid lvalue");
+ hlsl_error(ctx, lhs->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_LVALUE, "Invalid lvalue.");
vkd3d_free(assign);
return NULL;
}
@@ -1308,7 +1319,8 @@ static void struct_var_initializer(struct hlsl_ctx *ctx, struct list *list, stru
if (initializer_size(initializer) != hlsl_type_component_count(type))
{
- hlsl_error(ctx, var->loc, "structure initializer mismatch");
+ hlsl_error(ctx, var->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
+ "Wrong number of parameters in struct initializer.");
free_parse_initializer(initializer);
return;
}
@@ -1396,7 +1408,8 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
if (type->modifiers & HLSL_MODIFIER_CONST && !(var->modifiers & HLSL_STORAGE_UNIFORM) && !v->initializer.args_count)
{
- hlsl_error(ctx, v->loc, "const variable without initializer");
+ hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_INITIALIZER,
+ "Const variable \"%s\" is missing an initializer.", var->name);
hlsl_free_var(var);
vkd3d_free(v);
continue;
@@ -1420,8 +1433,8 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
{
if (size < type->dimx * type->dimy)
{
- hlsl_error(ctx, v->loc,
- "'%s' initializer does not match", v->name);
+ hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
+ "Wrong number of parameters in numeric initializer.");
free_parse_initializer(&v->initializer);
vkd3d_free(v);
continue;
@@ -1430,8 +1443,8 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
if ((type->type == HLSL_CLASS_STRUCT || type->type == HLSL_CLASS_ARRAY)
&& hlsl_type_component_count(type) != size)
{
- hlsl_error(ctx, v->loc,
- "'%s' initializer does not match", v->name);
+ hlsl_error(ctx, v->loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
+ "Wrong number of parameters in initializer.");
free_parse_initializer(&v->initializer);
vkd3d_free(v);
continue;
@@ -1710,14 +1723,14 @@ hlsl_prog:
{
if (decl->body && $2.decl->body)
{
- hlsl_error(ctx, $2.decl->loc,
- "redefinition of function \"%s\"", $2.name);
+ hlsl_error(ctx, $2.decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
+ "Function \"%s\" is already defined.", $2.name);
YYABORT;
}
else if (!hlsl_type_compare(decl->return_type, $2.decl->return_type))
{
- hlsl_error(ctx, $2.decl->loc,
- "redefining function \"%s\" with a different return type", $2.name);
+ hlsl_error(ctx, $2.decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
+ "Function \"%s\" was already declared with a different return type.", $2.name);
hlsl_note(ctx, decl->loc, VKD3D_SHADER_LOG_ERROR,
"\"%s\" previously declared here", $2.name);
YYABORT;
@@ -1725,10 +1738,8 @@ hlsl_prog:
}
if (hlsl_type_is_void($2.decl->return_type) && $2.decl->semantic)
- {
- hlsl_error(ctx, $2.decl->loc,
- "void function with a semantic");
- }
+ hlsl_error(ctx, $2.decl->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC,
+ "Semantics are not allowed on void functions.");
hlsl_add_function(&ctx->functions, $2.name, $2.decl, false);
}
@@ -1772,15 +1783,11 @@ struct_declaration:
if (!$3)
{
if (!$2->name)
- {
- hlsl_error(ctx, @2,
- "anonymous struct declaration with no variables");
- }
+ hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX,
+ "Anonymous struct type must declare a variable.");
if (modifiers)
- {
- hlsl_error(ctx, @1,
- "modifier not allowed on struct type declaration");
- }
+ hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
+ "Modifiers are not allowed on struct type declataions.");
}
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, @1)))
@@ -1801,14 +1808,14 @@ named_struct_spec:
if (hlsl_get_var(ctx->cur_scope, $2))
{
- hlsl_error(ctx, @2, "redefinition of '%s'", $2);
+ hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "\"%s\" is already declared as a variable.", $2);
YYABORT;
}
ret = hlsl_scope_add_type(ctx->cur_scope, $$);
if (!ret)
{
- hlsl_error(ctx, @2, "redefinition of struct '%s'", $2);
+ hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "Struct \"%s\" is already defined.", $2);
YYABORT;
}
}
@@ -1841,7 +1848,8 @@ fields_list:
ret = add_struct_field($$, field);
if (ret == false)
{
- hlsl_error(ctx, @2, "redefinition of '%s'", field->name);
+ hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
+ "Field \"%s\" is already defined.", field->name);
vkd3d_free(field);
}
}
@@ -1882,17 +1890,19 @@ func_prototype:
{
if ($1)
{
- hlsl_error(ctx, @1, "unexpected modifiers on a function");
+ hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
+ "Modifiers are not allowed on functions.");
YYABORT;
}
if (hlsl_get_var(ctx->globals, $3))
{
- hlsl_error(ctx, @3, "redefinition of '%s'\n", $3);
+ hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "Function \"%s\" is already defined.", $3);
YYABORT;
}
if (hlsl_type_is_void($2) && $7.semantic)
{
- hlsl_error(ctx, @7, "void function with a semantic");
+ hlsl_error(ctx, @7, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC,
+ "Semantics are not allowed on void functions.");
}
if ($7.reg_reservation)
@@ -1995,7 +2005,8 @@ param_list:
$$ = $1;
if (!add_func_parameter(ctx, $$, &$3, @3))
{
- hlsl_error(ctx, @3, "duplicate parameter %s", $3.name);
+ hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
+ "Parameter \"%s\" is already declared.", $3.name);
YYABORT;
}
}
@@ -2026,8 +2037,7 @@ input_mods:
{
if ($1 & $2)
{
- hlsl_error(ctx, @2,
- "duplicate input-output modifiers");
+ hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Duplicate modifiers specified.");
YYABORT;
}
$$ = $1 | $2;
@@ -2056,14 +2066,14 @@ type:
{
if ($3->type != HLSL_CLASS_SCALAR)
{
- hlsl_error(ctx, @3,
- "vectors of non-scalar types are not allowed\n");
+ hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
+ "Vectors of non-scalar types are not allowed.");
YYABORT;
}
if ($5 < 1 || $5 > 4)
{
- hlsl_error(ctx, @5,
- "vector size must be between 1 and 4\n");
+ hlsl_error(ctx, @5, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
+ "Vector size must be between 1 and 4.");
YYABORT;
}
@@ -2073,20 +2083,20 @@ type:
{
if ($3->type != HLSL_CLASS_SCALAR)
{
- hlsl_error(ctx, @3,
- "matrices of non-scalar types are not allowed\n");
+ hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
+ "Matrices of non-scalar types are not allowed.");
YYABORT;
}
if ($5 < 1 || $5 > 4)
{
- hlsl_error(ctx, @5,
- "matrix row count must be between 1 and 4\n");
+ hlsl_error(ctx, @5, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
+ "Matrix row count must be between 1 and 4.");
YYABORT;
}
if ($7 < 1 || $7 > 4)
{
- hlsl_error(ctx, @7,
- "matrix column count must be between 1 and 4\n");
+ hlsl_error(ctx, @7, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
+ "Matrix column count must be between 1 and 4.");
YYABORT;
}
@@ -2127,7 +2137,7 @@ base_type:
{
$$ = hlsl_get_type(ctx->cur_scope, $2, true);
if ($$->type != HLSL_CLASS_STRUCT)
- hlsl_error(ctx, @1, "'%s' redefined as a structure\n", $2);
+ hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_REDEFINED, "\"%s\" redefined as a structure.", $2);
vkd3d_free($2);
}
@@ -2151,7 +2161,8 @@ typedef:
if ($2 & ~HLSL_TYPE_MODIFIERS_MASK)
{
struct parse_variable_def *v, *v_next;
- hlsl_error(ctx, @1, "modifier not allowed on typedefs");
+ hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
+ "Storage modifiers are not allowed on typedefs.");
LIST_FOR_EACH_ENTRY_SAFE(v, v_next, $4, struct parse_variable_def, entry)
vkd3d_free(v);
vkd3d_free($4);
@@ -2248,15 +2259,15 @@ array:
if (!size)
{
- hlsl_error(ctx, @2,
- "array size is not a positive integer constant\n");
+ hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
+ "Array size is not a positive integer constant.");
YYABORT;
}
if (size > 65536)
{
- hlsl_error(ctx, @2,
- "array size must be between 1 and 65536");
+ hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE,
+ "Array size must be between 1 and 65536.");
YYABORT;
}
$$ = size;
@@ -2408,8 +2419,8 @@ selection_statement:
vkd3d_free($5.then_instrs);
vkd3d_free($5.else_instrs);
if (condition->data_type->dimx > 1 || condition->data_type->dimy > 1)
- hlsl_error(ctx, instr->node.loc,
- "if condition requires a scalar");
+ hlsl_error(ctx, instr->node.loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
+ "if condition requires a scalar.");
$$ = $3;
list_add_tail($$, &instr->node.entry);
}
@@ -2498,7 +2509,7 @@ primary_expr:
if (!(var = hlsl_get_var(ctx->cur_scope, $1)))
{
- hlsl_error(ctx, @1, "variable '%s' is not declared\n", $1);
+ hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Variable \"%s\" is not defined.", $1);
YYABORT;
}
if ((load = hlsl_new_var_load(var, @1)))
@@ -2522,7 +2533,7 @@ postfix_expr:
if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST)
{
- hlsl_error(ctx, @2, "modifying a const expression");
+ hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, "Statement modifies a const expression.");
YYABORT;
}
inc = hlsl_new_unary_expr(HLSL_IR_UNOP_POSTINC, node_from_list($1), @2);
@@ -2537,7 +2548,7 @@ postfix_expr:
if (node_from_list($1)->data_type->modifiers & HLSL_MODIFIER_CONST)
{
- hlsl_error(ctx, @2, "modifying a const expression");
+ hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, "Statement modifies a const expression.");
YYABORT;
}
inc = hlsl_new_unary_expr(HLSL_IR_UNOP_POSTDEC, node_from_list($1), @2);
@@ -2568,7 +2579,7 @@ postfix_expr:
}
if (!$$)
{
- hlsl_error(ctx, @3, "invalid subscript \"%s\"", $3);
+ hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED, "Field \"%s\" is not defined.", $3);
YYABORT;
}
}
@@ -2578,14 +2589,14 @@ postfix_expr:
if (!(swizzle = get_swizzle(ctx, node, $3, &@3)))
{
- hlsl_error(ctx, @3, "invalid swizzle \"%s\"", $3);
+ hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Invalid swizzle \"%s\".", $3);
YYABORT;
}
$$ = append_unop($1, &swizzle->node);
}
else
{
- hlsl_error(ctx, @3, "invalid subscript \"%s\"", $3);
+ hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Invalid subscript \"%s\".", $3);
YYABORT;
}
}
@@ -2598,7 +2609,7 @@ postfix_expr:
if (index->data_type->type != HLSL_CLASS_SCALAR)
{
- hlsl_error(ctx, @3, "array index is not scalar");
+ hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Array index is not scalar.");
hlsl_free_instr_list($1);
YYABORT;
}
@@ -2623,20 +2634,20 @@ postfix_expr:
if ($1)
{
- hlsl_error(ctx, @1,
- "unexpected modifier on a constructor\n");
+ hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
+ "Modifiers are not allowed on constructors.");
YYABORT;
}
if ($2->type > HLSL_CLASS_LAST_NUMERIC)
{
- hlsl_error(ctx, @2,
- "constructors may only be used with numeric data types\n");
+ hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
+ "Constructors may only be used with numeric data types.");
YYABORT;
}
if ($2->dimx * $2->dimy != initializer_size(&$4))
{
- hlsl_error(ctx, @4,
- "expected %u components in constructor, but got %u\n",
+ hlsl_error(ctx, @4, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
+ "Expected %u components in constructor, but got %u.",
$2->dimx * $2->dimy, initializer_size(&$4));
YYABORT;
}
@@ -2654,7 +2665,8 @@ postfix_expr:
if (arg->data_type->type == HLSL_CLASS_OBJECT)
{
- hlsl_error(ctx, arg->loc, "invalid constructor argument");
+ hlsl_error(ctx, arg->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
+ "Invalid type for constructor argument.");
continue;
}
width = hlsl_type_component_count(arg->data_type);
@@ -2687,7 +2699,7 @@ unary_expr:
{
if (node_from_list($2)->data_type->modifiers & HLSL_MODIFIER_CONST)
{
- hlsl_error(ctx, @1, "modifying a const expression");
+ hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, "Statement modifies a const expression.");
YYABORT;
}
$$ = append_unop($2, hlsl_new_unary_expr(HLSL_IR_UNOP_PREINC, node_from_list($2), @1));
@@ -2696,7 +2708,7 @@ unary_expr:
{
if (node_from_list($2)->data_type->modifiers & HLSL_MODIFIER_CONST)
{
- hlsl_error(ctx, @1, "modifying a const expression");
+ hlsl_error(ctx, @1, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, "Statement modifies a const expression.");
YYABORT;
}
$$ = append_unop($2, hlsl_new_unary_expr(HLSL_IR_UNOP_PREDEC, node_from_list($2), @1));
@@ -2720,7 +2732,8 @@ unary_expr:
if ($2)
{
- hlsl_error(ctx, @3, "unexpected modifier in a cast");
+ hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
+ "Modifiers are not allowed on casts.");
YYABORT;
}
@@ -2734,7 +2747,8 @@ unary_expr:
char *src_string = hlsl_type_to_string(src_type), *dst_string = hlsl_type_to_string(dst_type);
if (src_string && dst_string)
- hlsl_error(ctx, @3, "Can't cast from %s to %s.", src_string, dst_string);
+ hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, "Can't cast from %s to %s.",
+ src_string, dst_string);
vkd3d_free(src_string);
vkd3d_free(dst_string);
YYABORT;
@@ -2879,7 +2893,7 @@ assignment_expr:
if (lhs->data_type->modifiers & HLSL_MODIFIER_CONST)
{
- hlsl_error(ctx, @2, "l-value is const");
+ hlsl_error(ctx, @2, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, "Statement modifies a const expression.");
YYABORT;
}
list_move_tail($3, $1);
@@ -3103,8 +3117,8 @@ int hlsl_parser_compile(struct hlsl_ctx *ctx, const char *entrypoint)
if (!hlsl_type_is_void(entry_func->return_type)
&& entry_func->return_type->type != HLSL_CLASS_STRUCT && !entry_func->semantic)
{
- hlsl_error(ctx, entry_func->loc,
- "entry point \"%s\" is missing a return value semantic", entry_func->func->name);
+ hlsl_error(ctx, entry_func->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC,
+ "Entry point \"%s\" is missing a return value semantic.", entry_func->func->name);
}
list_move_head(entry_func->body, &ctx->static_initializers);
diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h
index 6101c385..2d7eb05b 100644
--- a/libs/vkd3d-shader/vkd3d_shader_private.h
+++ b/libs/vkd3d-shader/vkd3d_shader_private.h
@@ -91,6 +91,24 @@ enum vkd3d_shader_error
VKD3D_SHADER_WARNING_PP_UNTERMINATED_MACRO = 4304,
VKD3D_SHADER_WARNING_PP_UNTERMINATED_IF = 4305,
VKD3D_SHADER_WARNING_PP_DIV_BY_ZERO = 4306,
+
+ VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX = 5000,
+ VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER = 5001,
+ VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE = 5002,
+ VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST = 5003,
+ VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC = 5004,
+ VKD3D_SHADER_ERROR_HLSL_NOT_DEFINED = 5005,
+ VKD3D_SHADER_ERROR_HLSL_REDEFINED = 5006,
+ VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT = 5007,
+ VKD3D_SHADER_ERROR_HLSL_INVALID_SIZE = 5008,
+ VKD3D_SHADER_ERROR_HLSL_MISSING_INITIALIZER = 5009,
+ VKD3D_SHADER_ERROR_HLSL_INVALID_LVALUE = 5010,
+ VKD3D_SHADER_ERROR_HLSL_INVALID_WRITEMASK = 5011,
+ VKD3D_SHADER_ERROR_HLSL_INVALID_INDEX = 5012,
+ VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC = 5013,
+ VKD3D_SHADER_ERROR_HLSL_INVALID_RETURN = 5014,
+
+ VKD3D_SHADER_WARNING_HLSL_IMPLICIT_TRUNCATION = 5300,
};
enum vkd3d_shader_opcode
--
2.30.1
3
8
[PATCH 4/5] d3d11: Implement d3d11_immediate_context_SwapDeviceContextState() on top of wined3d_device_set_state().
by Henri Verbeet Feb. 23, 2021
by Henri Verbeet Feb. 23, 2021
Feb. 23, 2021
Based on a patch by Rémi Bernon.
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
This supersedes patch 200188.
dlls/d3d11/d3d11_private.h | 36 ++---
dlls/d3d11/device.c | 293 +++++++++++++++++++++++--------------
dlls/d3d11/tests/d3d11.c | 140 +++++++-----------
3 files changed, 250 insertions(+), 219 deletions(-)
diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h
index 650b5c358716..a64d6975f857 100644
--- a/dlls/d3d11/d3d11_private.h
+++ b/dlls/d3d11/d3d11_private.h
@@ -516,6 +516,12 @@ struct d3d_query *unsafe_impl_from_ID3D11Query(ID3D11Query *iface) DECLSPEC_HIDD
struct d3d_query *unsafe_impl_from_ID3D10Query(ID3D10Query *iface) DECLSPEC_HIDDEN;
struct d3d_query *unsafe_impl_from_ID3D11Asynchronous(ID3D11Asynchronous *iface) DECLSPEC_HIDDEN;
+struct d3d_device_context_state_entry
+{
+ struct d3d_device *device;
+ struct wined3d_state *wined3d_state;
+};
+
/* ID3DDeviceContextState */
struct d3d_device_context_state
{
@@ -523,30 +529,12 @@ struct d3d_device_context_state
LONG refcount, private_refcount;
struct wined3d_private_store private_store;
- struct
- {
- ID3D11VertexShader *shader;
- ID3D11SamplerState *samplers[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT];
- ID3D11ShaderResourceView *srvs[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
- ID3D11Buffer *cbs[D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT];
- } vs;
- struct
- {
- ID3D11GeometryShader *shader;
- ID3D11SamplerState *samplers[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT];
- ID3D11ShaderResourceView *srvs[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
- ID3D11Buffer *cbs[D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT];
- } gs;
- struct
- {
- ID3D11PixelShader *shader;
- ID3D11SamplerState *samplers[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT];
- ID3D11ShaderResourceView *srvs[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
- ID3D11Buffer *cbs[D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT];
- } ps;
-
GUID emulated_interface;
+ struct d3d_device_context_state_entry *entries;
+ SIZE_T entries_size;
+ SIZE_T entry_count;
+
struct wined3d_device *wined3d_device;
ID3D11Device2 *device;
};
@@ -585,6 +573,10 @@ struct d3d_device
struct wine_rb_tree depthstencil_states;
struct wine_rb_tree rasterizer_states;
struct wine_rb_tree sampler_states;
+
+ struct d3d_device_context_state **context_states;
+ SIZE_T context_states_size;
+ SIZE_T context_state_count;
};
static inline struct d3d_device *impl_from_ID3D11Device(ID3D11Device *iface)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index b0041c858816..a5d9dc1aa7be 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -22,6 +22,32 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d11);
+static BOOL d3d_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size)
+{
+ SIZE_T max_capacity, new_capacity;
+ void *new_elements;
+
+ if (count <= *capacity)
+ return TRUE;
+
+ max_capacity = ~(SIZE_T)0 / size;
+ if (count > max_capacity)
+ return FALSE;
+
+ new_capacity = max(1, *capacity);
+ while (new_capacity < count && new_capacity <= max_capacity / 2)
+ new_capacity *= 2;
+ if (new_capacity < count)
+ new_capacity = count;
+
+ if (!(new_elements = heap_realloc(*elements, new_capacity * size)))
+ return FALSE;
+
+ *elements = new_elements;
+ *capacity = new_capacity;
+ return TRUE;
+}
+
static void STDMETHODCALLTYPE d3d_null_wined3d_object_destroyed(void *parent) {}
static const struct wined3d_parent_ops d3d_null_wined3d_parent_ops =
@@ -88,9 +114,27 @@ static ULONG STDMETHODCALLTYPE d3d_device_context_state_AddRef(ID3DDeviceContext
return refcount;
}
+static void d3d_device_remove_context_state(struct d3d_device *device, struct d3d_device_context_state *state)
+{
+ unsigned int i;
+
+ for (i = 0; i < device->context_state_count; ++i)
+ {
+ if (device->context_states[i] != state)
+ continue;
+
+ if (i != device->context_state_count - 1)
+ device->context_states[i] = device->context_states[device->context_state_count - 1];
+ --device->context_state_count;
+ break;
+ }
+}
+
static void d3d_device_context_state_private_release(struct d3d_device_context_state *state)
{
ULONG refcount = InterlockedDecrement(&state->private_refcount);
+ struct d3d_device_context_state_entry *entry;
+ struct d3d_device *device;
unsigned int i;
TRACE("%p decreasing private refcount to %u.\n", state, refcount);
@@ -98,27 +142,17 @@ static void d3d_device_context_state_private_release(struct d3d_device_context_s
if (!refcount)
{
wined3d_private_store_cleanup(&state->private_store);
- if (state->vs.shader) ID3D11VertexShader_Release(state->vs.shader);
- if (state->gs.shader) ID3D11GeometryShader_Release(state->gs.shader);
- if (state->ps.shader) ID3D11PixelShader_Release(state->ps.shader);
- for (i = 0; i < D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT; ++i)
- {
- if (state->vs.samplers[i]) ID3D11SamplerState_Release(state->vs.samplers[i]);
- if (state->gs.samplers[i]) ID3D11SamplerState_Release(state->gs.samplers[i]);
- if (state->ps.samplers[i]) ID3D11SamplerState_Release(state->ps.samplers[i]);
- }
- for (i = 0; i < D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; ++i)
+ for (i = 0; i < state->entry_count; ++i)
{
- if (state->vs.srvs[i]) ID3D11ShaderResourceView_Release(state->vs.srvs[i]);
- if (state->gs.srvs[i]) ID3D11ShaderResourceView_Release(state->gs.srvs[i]);
- if (state->ps.srvs[i]) ID3D11ShaderResourceView_Release(state->ps.srvs[i]);
- }
- for (i = 0; i < D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++i)
- {
- if (state->vs.cbs[i]) ID3D11Buffer_Release(state->vs.cbs[i]);
- if (state->gs.cbs[i]) ID3D11Buffer_Release(state->gs.cbs[i]);
- if (state->ps.cbs[i]) ID3D11Buffer_Release(state->ps.cbs[i]);
+ entry = &state->entries[i];
+ device = entry->device;
+
+ if (entry->wined3d_state != wined3d_device_get_state(device->wined3d_device))
+ wined3d_state_destroy(entry->wined3d_state);
+
+ d3d_device_remove_context_state(device, state);
}
+ heap_free(state->entries);
wined3d_device_decref(state->wined3d_device);
heap_free(state);
}
@@ -194,6 +228,85 @@ static const struct ID3DDeviceContextStateVtbl d3d_device_context_state_vtbl =
/* ID3DDeviceContextState methods */
};
+static struct d3d_device_context_state_entry *d3d_device_context_state_get_entry(
+ struct d3d_device_context_state *state, struct d3d_device *device)
+{
+ unsigned int i;
+
+ for (i = 0; i < state->entry_count; ++i)
+ {
+ if (state->entries[i].device == device)
+ return &state->entries[i];
+ }
+
+ return NULL;
+}
+
+static BOOL d3d_device_context_state_add_entry(struct d3d_device_context_state *state,
+ struct d3d_device *device, struct wined3d_state *wined3d_state)
+{
+ struct d3d_device_context_state_entry *entry;
+
+ if (!d3d_array_reserve((void **)&state->entries, &state->entries_size,
+ state->entry_count + 1, sizeof(*state->entries)))
+ return FALSE;
+
+ if (!d3d_array_reserve((void **)&device->context_states, &device->context_states_size,
+ device->context_state_count + 1, sizeof(*device->context_states)))
+ return FALSE;
+
+ entry = &state->entries[state->entry_count++];
+ entry->device = device;
+ entry->wined3d_state = wined3d_state;
+
+ device->context_states[device->context_state_count++] = state;
+
+ return TRUE;
+}
+
+static void d3d_device_context_state_remove_entry(struct d3d_device_context_state *state, struct d3d_device *device)
+{
+ struct d3d_device_context_state_entry *entry;
+ unsigned int i;
+
+ for (i = 0; i < state->entry_count; ++i)
+ {
+ entry = &state->entries[i];
+ if (entry->device != device)
+ continue;
+
+ if (entry->wined3d_state != wined3d_device_get_state(device->wined3d_device))
+ wined3d_state_destroy(entry->wined3d_state);
+
+ if (i != state->entry_count)
+ state->entries[i] = state->entries[state->entry_count - 1];
+ --state->entry_count;
+
+ break;
+ }
+}
+
+static struct wined3d_state *d3d_device_context_state_get_wined3d_state(struct d3d_device_context_state *state,
+ struct d3d_device *device)
+{
+ struct d3d_device_context_state_entry *entry;
+ struct wined3d_state *wined3d_state;
+
+ if ((entry = d3d_device_context_state_get_entry(state, device)))
+ return entry->wined3d_state;
+
+ if (FAILED(wined3d_state_create(device->wined3d_device, &wined3d_state)))
+ return NULL;
+
+ if (!d3d_device_context_state_add_entry(state, device, wined3d_state))
+ {
+ wined3d_state_destroy(wined3d_state);
+ return NULL;
+ }
+
+ return wined3d_state;
+}
+
static void d3d_device_context_state_init(struct d3d_device_context_state *state, struct d3d_device *device,
REFIID emulated_interface)
{
@@ -201,9 +314,6 @@ static void d3d_device_context_state_init(struct d3d_device_context_state *state
state->refcount = state->private_refcount = 0;
wined3d_private_store_init(&state->private_store);
- memset(&state->vs, 0, sizeof(state->vs));
- memset(&state->gs, 0, sizeof(state->gs));
- memset(&state->ps, 0, sizeof(state->ps));
state->emulated_interface = *emulated_interface;
wined3d_device_incref(state->wined3d_device = device->wined3d_device);
@@ -2722,98 +2832,39 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetConstantBuffers1(ID3D
iface, start_slot, buffer_count, buffers, first_constant, num_constants);
}
-static void d3d11_immediate_context_capture_state(ID3D11DeviceContext1 *iface, struct d3d_device_context_state *state)
+static void STDMETHODCALLTYPE d3d11_immediate_context_SwapDeviceContextState(ID3D11DeviceContext1 *iface,
+ ID3DDeviceContextState *state, ID3DDeviceContextState **prev)
{
- wined3d_mutex_lock();
-
- d3d11_immediate_context_VSGetShader(iface, &state->vs.shader, NULL, 0);
- d3d11_immediate_context_VSGetSamplers(iface, 0,
- D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->vs.samplers);
- d3d11_immediate_context_VSGetShaderResources(iface, 0,
- D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->vs.srvs);
- d3d11_immediate_context_VSGetConstantBuffers(iface, 0,
- D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->vs.cbs);
-
- d3d11_immediate_context_GSGetShader(iface, &state->gs.shader, NULL, 0);
- d3d11_immediate_context_GSGetSamplers(iface, 0,
- D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->gs.samplers);
- d3d11_immediate_context_GSGetShaderResources(iface, 0,
- D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->gs.srvs);
- d3d11_immediate_context_GSGetConstantBuffers(iface, 0,
- D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->gs.cbs);
+ struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface);
+ struct d3d_device_context_state *state_impl, *prev_impl;
+ struct wined3d_state *wined3d_state;
- d3d11_immediate_context_PSGetShader(iface, &state->ps.shader, NULL, 0);
- d3d11_immediate_context_PSGetSamplers(iface, 0,
- D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->ps.samplers);
- d3d11_immediate_context_PSGetShaderResources(iface, 0,
- D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->ps.srvs);
- d3d11_immediate_context_PSGetConstantBuffers(iface, 0,
- D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->ps.cbs);
+ FIXME("iface %p, state %p, prev %p semi-stub!\n", iface, state, prev);
- wined3d_mutex_unlock();
-}
+ if (!state)
+ {
+ if (prev)
+ *prev = NULL;
+ return;
+ }
-static void d3d11_immediate_context_restore_state(ID3D11DeviceContext1 *iface, struct d3d_device_context_state *state)
-{
wined3d_mutex_lock();
- d3d11_immediate_context_VSSetShader(iface, state->vs.shader, NULL, 0);
- d3d11_immediate_context_VSSetSamplers(iface, 0,
- D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->vs.samplers);
- d3d11_immediate_context_VSSetShaderResources(iface, 0,
- D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->vs.srvs);
- d3d11_immediate_context_VSSetConstantBuffers(iface, 0,
- D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->vs.cbs);
+ prev_impl = device->state;
+ state_impl = impl_from_ID3DDeviceContextState(state);
+ if (!(wined3d_state = d3d_device_context_state_get_wined3d_state(state_impl, device)))
+ ERR("Failed to get wined3d state for device context state %p.\n", state_impl);
+ wined3d_device_set_state(device->wined3d_device, wined3d_state);
- d3d11_immediate_context_GSSetShader(iface, state->gs.shader, NULL, 0);
- d3d11_immediate_context_GSSetSamplers(iface, 0,
- D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->gs.samplers);
- d3d11_immediate_context_GSSetShaderResources(iface, 0,
- D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->gs.srvs);
- d3d11_immediate_context_GSSetConstantBuffers(iface, 0,
- D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->gs.cbs);
+ if (prev)
+ ID3DDeviceContextState_AddRef(*prev = &prev_impl->ID3DDeviceContextState_iface);
- d3d11_immediate_context_PSSetShader(iface, state->ps.shader, NULL, 0);
- d3d11_immediate_context_PSSetSamplers(iface, 0,
- D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, state->ps.samplers);
- d3d11_immediate_context_PSSetShaderResources(iface, 0,
- D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, state->ps.srvs);
- d3d11_immediate_context_PSSetConstantBuffers(iface, 0,
- D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, state->ps.cbs);
+ d3d_device_context_state_private_addref(state_impl);
+ device->state = state_impl;
+ d3d_device_context_state_private_release(prev_impl);
- wined3d_mutex_unlock();
-}
-
-static void STDMETHODCALLTYPE d3d11_immediate_context_SwapDeviceContextState(ID3D11DeviceContext1 *iface,
- ID3DDeviceContextState *state, ID3DDeviceContextState **prev_state)
-{
- struct d3d_device_context_state *state_impl;
- struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface);
-
- FIXME("iface %p, state %p, prev_state %p semi-stub!\n", iface, state, prev_state);
-
- if (prev_state) *prev_state = NULL;
- if (!state) return;
-
- wined3d_mutex_lock();
- if (prev_state)
- {
- *prev_state = NULL;
- if ((state_impl = heap_alloc(sizeof(*state_impl))))
- {
- d3d_device_context_state_init(state_impl, device, &device->state->emulated_interface);
- d3d11_immediate_context_capture_state(iface, state_impl);
- *prev_state = &state_impl->ID3DDeviceContextState_iface;
- }
- }
-
- if ((state_impl = impl_from_ID3DDeviceContextState(state)))
- {
- d3d11_immediate_context_restore_state(iface, state_impl);
- device->state->emulated_interface = state_impl->emulated_interface;
- if (d3d_device_is_d3d10_active(device))
- FIXME("D3D10 interface emulation not fully implemented yet!\n");
- }
+ if (d3d_device_is_d3d10_active(device))
+ FIXME("D3D10 interface emulation not fully implemented yet!\n");
wined3d_mutex_unlock();
}
@@ -4027,9 +4078,12 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDeviceContextState(ID3D11Dev
if (state)
{
- *state = NULL;
- if (!(state_impl = heap_alloc(sizeof(*state_impl))))
+ if (!(state_impl = heap_alloc_zero(sizeof(*state_impl))))
+ {
+ *state = NULL;
return E_OUTOFMEMORY;
+ }
+
d3d_device_context_state_init(state_impl, device, emulated_interface);
*state = &state_impl->ID3DDeviceContextState_iface;
}
@@ -4211,12 +4265,19 @@ static ULONG STDMETHODCALLTYPE d3d_device_inner_Release(IUnknown *iface)
{
struct d3d_device *device = impl_from_IUnknown(iface);
ULONG refcount = InterlockedDecrement(&device->refcount);
+ unsigned int i;
TRACE("%p decreasing refcount to %u.\n", device, refcount);
if (!refcount)
{
- if (device->state) d3d_device_context_state_private_release(device->state);
+ if (device->state)
+ d3d_device_context_state_private_release(device->state);
+ for (i = 0; i < device->context_state_count; ++i)
+ {
+ d3d_device_context_state_remove_entry(device->context_states[i], device);
+ }
+ heap_free(device->context_states);
d3d11_immediate_context_destroy(&device->immediate_context);
if (device->wined3d_device)
{
@@ -6394,6 +6455,7 @@ static void CDECL device_parent_wined3d_device_created(struct wined3d_device_par
struct wined3d_device *wined3d_device)
{
struct d3d_device *device = device_from_wined3d_device_parent(device_parent);
+ struct wined3d_state *wined3d_state;
ID3DDeviceContextState *state;
HRESULT hr;
@@ -6407,13 +6469,18 @@ static void CDECL device_parent_wined3d_device_created(struct wined3d_device_par
if (FAILED(hr = d3d11_device_CreateDeviceContextState(&device->ID3D11Device2_iface, 0, &device->feature_level,
1, D3D11_SDK_VERSION, device->d3d11_only ? &IID_ID3D11Device2 : &IID_ID3D10Device1, NULL,
&state)))
- ERR("Failed to create the initial device context state, hr %#x.\n", hr);
- else
{
- device->state = impl_from_ID3DDeviceContextState(state);
- d3d_device_context_state_private_addref(device->state);
- ID3DDeviceContextState_Release(state);
+ ERR("Failed to create the initial device context state, hr %#x.\n", hr);
+ return;
}
+
+ device->state = impl_from_ID3DDeviceContextState(state);
+ wined3d_state = wined3d_device_get_state(device->wined3d_device);
+ if (!d3d_device_context_state_add_entry(device->state, device, wined3d_state))
+ ERR("Failed to add entry for wined3d state %p, device %p.\n", wined3d_state, device);
+
+ d3d_device_context_state_private_addref(device->state);
+ ID3DDeviceContextState_Release(state);
}
static void CDECL device_parent_mode_changed(struct wined3d_device_parent *device_parent)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 1505b3fddbc7..2eff98fe8fcf 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -7083,7 +7083,7 @@ static void test_device_context_state(void)
ID3D11DeviceContext1_SwapDeviceContextState(context, context_state, &previous_context_state);
ok(previous_context_state != NULL, "Failed to get previous context state\n");
refcount = get_refcount(vs);
- todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
+ ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
hr = ID3DDeviceContextState_SetPrivateData(context_state, &test_guid, sizeof(constant), &constant);
ok(hr == S_OK, "Failed to set private data, hr %#x.\n", hr);
@@ -7093,9 +7093,9 @@ static void test_device_context_state(void)
data_size = sizeof(data);
memset(data, 0xa5, sizeof(data));
hr = ID3DDeviceContextState_GetPrivateData(context_state, &test_guid, &data_size, data);
- todo_wine ok(hr == S_OK, "Failed to get private data, hr %#x.\n", hr);
- todo_wine ok(data_size == sizeof(constant), "Got private data size %x, expected %x.\n", data_size, sizeof(constant));
- todo_wine ok(!memcmp(data, &constant, sizeof(constant)), "Got unexpected private data.\n");
+ ok(hr == S_OK, "Failed to get private data, hr %#x.\n", hr);
+ ok(data_size == sizeof(constant), "Got private data size %x, expected %x.\n", data_size, sizeof(constant));
+ ok(!memcmp(data, &constant, sizeof(constant)), "Got unexpected private data.\n");
ID3D11DeviceContext1_SwapDeviceContextState(context, context_state, NULL);
context_type = ID3D11DeviceContext1_GetType(context);
@@ -7142,118 +7142,96 @@ static void test_device_context_state(void)
tmp_cb = (ID3D11Buffer *)0xdeadbeef;
ID3D11DeviceContext1_HSGetConstantBuffers(context, 0, 1, &tmp_cb);
- todo_wine ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb);
- if (tmp_cb) ID3D11Buffer_Release(tmp_cb);
+ ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb);
tmp_sampler = (ID3D11SamplerState *)0xdeadbeef;
ID3D11DeviceContext1_HSGetSamplers(context, 0, 1, &tmp_sampler);
- todo_wine ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler);
- if (tmp_sampler) ID3D11SamplerState_Release(tmp_sampler);
+ ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler);
tmp_hs = (ID3D11HullShader *)0xdeadbeef;
ID3D11DeviceContext1_HSGetShader(context, &tmp_hs, NULL, NULL);
- if (hs) todo_wine ok(!tmp_hs, "Got unexpected shader %p.\n", tmp_hs);
- if (tmp_hs) ID3D11HullShader_Release(tmp_hs);
+ if (hs) ok(!tmp_hs, "Got unexpected shader %p.\n", tmp_hs);
tmp_srv = (ID3D11ShaderResourceView *)0xdeadbeef;
ID3D11DeviceContext1_HSGetShaderResources(context, 0, 1, &tmp_srv);
- todo_wine ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv);
- if (tmp_srv) ID3D11ShaderResourceView_Release(tmp_srv);
+ ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv);
tmp_cb = (ID3D11Buffer *)0xdeadbeef;
ID3D11DeviceContext1_DSGetConstantBuffers(context, 0, 1, &tmp_cb);
- todo_wine ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb);
- if (tmp_cb) ID3D11Buffer_Release(tmp_cb);
+ ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb);
tmp_sampler = (ID3D11SamplerState *)0xdeadbeef;
ID3D11DeviceContext1_DSGetSamplers(context, 0, 1, &tmp_sampler);
- todo_wine ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler);
- if (tmp_sampler) ID3D11SamplerState_Release(tmp_sampler);
+ ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler);
tmp_ds = (ID3D11DomainShader *)0xdeadbeef;
ID3D11DeviceContext1_DSGetShader(context, &tmp_ds, NULL, NULL);
- if (ds) todo_wine ok(!tmp_ds, "Got unexpected shader %p.\n", tmp_ds);
- if (tmp_ds) ID3D11DomainShader_Release(tmp_ds);
+ if (ds) ok(!tmp_ds, "Got unexpected shader %p.\n", tmp_ds);
tmp_srv = (ID3D11ShaderResourceView *)0xdeadbeef;
ID3D11DeviceContext1_DSGetShaderResources(context, 0, 1, &tmp_srv);
- todo_wine ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv);
- if (tmp_srv) ID3D11ShaderResourceView_Release(tmp_srv);
+ ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv);
tmp_cb = (ID3D11Buffer *)0xdeadbeef;
ID3D11DeviceContext1_CSGetConstantBuffers(context, 0, 1, &tmp_cb);
- todo_wine ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb);
- if (tmp_cb) ID3D11Buffer_Release(tmp_cb);
+ ok(!tmp_cb, "Got unexpected buffer %p.\n", tmp_cb);
tmp_sampler = (ID3D11SamplerState *)0xdeadbeef;
ID3D11DeviceContext1_CSGetSamplers(context, 0, 1, &tmp_sampler);
- todo_wine ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler);
- if (tmp_sampler) ID3D11SamplerState_Release(tmp_sampler);
+ ok(!tmp_sampler, "Got unexpected sampler %p.\n", tmp_sampler);
tmp_cs = (ID3D11ComputeShader *)0xdeadbeef;
ID3D11DeviceContext1_CSGetShader(context, &tmp_cs, NULL, NULL);
- if (cs) todo_wine ok(!tmp_cs, "Got unexpected shader %p.\n", tmp_cs);
- if (tmp_cs) ID3D11ComputeShader_Release(tmp_cs);
+ if (cs) ok(!tmp_cs, "Got unexpected shader %p.\n", tmp_cs);
tmp_srv = (ID3D11ShaderResourceView *)0xdeadbeef;
ID3D11DeviceContext1_CSGetShaderResources(context, 0, 1, &tmp_srv);
- todo_wine ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv);
- if (tmp_srv) ID3D11ShaderResourceView_Release(tmp_srv);
+ ok(!tmp_srv, "Got unexpected srv %p.\n", tmp_srv);
tmp_uav = (ID3D11UnorderedAccessView *)0xdeadbeef;
ID3D11DeviceContext1_CSGetUnorderedAccessViews(context, 0, 1, &tmp_uav);
- todo_wine ok(!tmp_uav, "Got unexpected uav %p.\n", tmp_uav);
- if (tmp_uav) ID3D11UnorderedAccessView_Release(tmp_uav);
+ ok(!tmp_uav, "Got unexpected uav %p.\n", tmp_uav);
topo = 0xdeadbeef;
ID3D11DeviceContext1_IAGetPrimitiveTopology(context, &topo);
- todo_wine ok(topo == D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED, "Got unexpected topology %#x.\n", topo);
+ ok(topo == D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED, "Got unexpected topology %#x.\n", topo);
tmp_il = (ID3D11InputLayout *)0xdeadbeef;
ID3D11DeviceContext1_IAGetInputLayout(context, &tmp_il);
- todo_wine ok(!tmp_il, "Got unexpected input layout %p.\n", tmp_il);
- if (tmp_il) ID3D11InputLayout_Release(tmp_il);
+ ok(!tmp_il, "Got unexpected input layout %p.\n", tmp_il);
tmp_ib = (ID3D11Buffer *)0xdeadbeef;
format = 0xdeadbeef;
offset = 0xdeadbeef;
ID3D11DeviceContext1_IAGetIndexBuffer(context, &tmp_ib, &format, &offset);
- todo_wine ok(!tmp_ib, "Got unexpected input buffer %p.\n", tmp_ib);
- if (tmp_ib) ID3D11Buffer_Release(tmp_ib);
- todo_wine ok(format == DXGI_FORMAT_UNKNOWN, "Got unexpected input buffer format %#x.\n", format);
- todo_wine ok(offset == 0, "Got unexpected input buffer offset %#x.\n", offset);
+ ok(!tmp_ib, "Got unexpected input buffer %p.\n", tmp_ib);
+ ok(format == DXGI_FORMAT_UNKNOWN, "Got unexpected input buffer format %#x.\n", format);
+ ok(offset == 0, "Got unexpected input buffer offset %#x.\n", offset);
tmp_vb = (ID3D11Buffer *)0xdeadbeef;
stride = 0xdeadbeef;
offset = 0xdeadbeef;
ID3D11DeviceContext1_IAGetVertexBuffers(context, 0, 1, &tmp_vb, &stride, &offset);
- todo_wine ok(!tmp_vb, "Got unexpected vertex buffer %p.\n", tmp_vb);
- if (tmp_vb) ID3D11Buffer_Release(tmp_vb);
- todo_wine ok(stride == 0, "Got unexpected vertex buffer stride %#x.\n", stride);
- todo_wine ok(offset == 0, "Got unexpected vertex buffer offset %#x.\n", offset);
+ ok(!tmp_vb, "Got unexpected vertex buffer %p.\n", tmp_vb);
+ ok(stride == 0, "Got unexpected vertex buffer stride %#x.\n", stride);
+ ok(offset == 0, "Got unexpected vertex buffer offset %#x.\n", offset);
tmp_rtv = (ID3D11RenderTargetView *)0xdeadbeef;
tmp_dsv = (ID3D11DepthStencilView *)0xdeadbeef;
tmp_uav = (ID3D11UnorderedAccessView *)0xdeadbeef;
ID3D11DeviceContext1_OMGetRenderTargetsAndUnorderedAccessViews(context, 1, &tmp_rtv, &tmp_dsv, 1, 1, &tmp_uav);
- todo_wine ok(!tmp_rtv, "Got unexpected rendertarget view %p.\n", tmp_rtv);
- if (tmp_rtv) ID3D11RenderTargetView_Release(tmp_rtv);
- todo_wine ok(!tmp_dsv, "Got unexpected depth/stencil view %p.\n", tmp_dsv);
- if (tmp_dsv) ID3D11DepthStencilView_Release(tmp_dsv);
- todo_wine ok(!tmp_uav, "Got unexpected unordered access view %p.\n", tmp_uav);
- if (tmp_uav) ID3D11UnorderedAccessView_Release(tmp_uav);
+ ok(!tmp_rtv, "Got unexpected rendertarget view %p.\n", tmp_rtv);
+ ok(!tmp_dsv, "Got unexpected depth/stencil view %p.\n", tmp_dsv);
+ ok(!tmp_uav, "Got unexpected unordered access view %p.\n", tmp_uav);
tmp_bs = (ID3D11BlendState *)0xdeadbeef;
memset(blend_factor, 0xcd, sizeof(blend_factor));
sample_mask = 0xdeadbeef;
ID3D11DeviceContext1_OMGetBlendState(context, &tmp_bs, blend_factor, &sample_mask);
- todo_wine ok(!tmp_bs, "Got unexpected blend state %p.\n", tmp_bs);
- if (tmp_bs) ID3D11BlendState_Release(tmp_bs);
- todo_wine ok(!memcmp(blend_factor, default_blend_factor, sizeof(blend_factor)),
+ ok(!tmp_bs, "Got unexpected blend state %p.\n", tmp_bs);
+ ok(!memcmp(blend_factor, default_blend_factor, sizeof(blend_factor)),
"Got unexpected blend factor %f,%f,%f,%f.\n",
blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3]);
- todo_wine ok(sample_mask == ~0, "Got unexpected sample mask %#x.\n", sample_mask);
+ ok(sample_mask == ~0, "Got unexpected sample mask %#x.\n", sample_mask);
tmp_dss = (ID3D11DepthStencilState *)0xdeadbeef;
stencil_ref = 0xdeadbeef;
ID3D11DeviceContext1_OMGetDepthStencilState(context, &tmp_dss, &stencil_ref);
- todo_wine ok(!tmp_dss, "Got unexpected depth/stencil state %p.\n", tmp_dss);
- if (tmp_dss) ID3D11DepthStencilState_Release(tmp_dss);
- todo_wine ok(stencil_ref == 0, "Got unexpected stencil ref %#x.\n", stencil_ref);
+ ok(!tmp_dss, "Got unexpected depth/stencil state %p.\n", tmp_dss);
+ ok(stencil_ref == 0, "Got unexpected stencil ref %#x.\n", stencil_ref);
tmp_rs = (ID3D11RasterizerState *)0xdeadbeef;
ID3D11DeviceContext1_RSGetState(context, &tmp_rs);
- todo_wine ok(!tmp_rs, "Got unexpected rasterizer state %p.\n", tmp_rs);
- if (tmp_rs) ID3D11RasterizerState_Release(tmp_rs);
+ ok(!tmp_rs, "Got unexpected rasterizer state %p.\n", tmp_rs);
memset(tmp_vp, 0xa5, sizeof(tmp_vp));
count = 2;
ID3D11DeviceContext1_RSGetViewports(context, &count, tmp_vp);
- todo_wine ok(count == 0, "Got unexpected viewport count %u.\n", count);
+ ok(count == 0, "Got unexpected viewport count %u.\n", count);
memset(tmp_rect, 0xa5, sizeof(tmp_rect));
count = 2;
ID3D11DeviceContext1_RSGetScissorRects(context, &count, tmp_rect);
@@ -7261,15 +7239,13 @@ static void test_device_context_state(void)
tmp_sob = (ID3D11Buffer *)0xdeadbeef;
ID3D11DeviceContext1_SOGetTargets(context, 1, &tmp_sob);
- todo_wine ok(!tmp_sob, "Got unexpected stream output buffer %p.\n", tmp_sob);
- if (tmp_sob) ID3D11Buffer_Release(tmp_sob);
+ ok(!tmp_sob, "Got unexpected stream output buffer %p.\n", tmp_sob);
tmp_pred = (ID3D11Predicate *)0xdeadbeef;
pred_value = 0xdeadbeef;
ID3D11DeviceContext1_GetPredication(context, &tmp_pred, &pred_value);
- todo_wine ok(!tmp_pred, "Got unexpected predicate %p.\n", tmp_pred);
- if (tmp_pred) ID3D11Predicate_Release(tmp_pred);
- todo_wine ok(!pred_value, "Got unexpected predicate value %d.\n", pred_value);
+ ok(!tmp_pred, "Got unexpected predicate %p.\n", tmp_pred);
+ ok(!pred_value, "Got unexpected predicate value %d.\n", pred_value);
/* updating the device context should also update the device context state */
hr = ID3D11Device1_CreateVertexShader(device, simple_vs, sizeof(simple_vs), NULL, &vs2);
@@ -7277,14 +7253,13 @@ static void test_device_context_state(void)
ID3D11DeviceContext1_VSSetShader(context, vs2, NULL, 0);
ID3D11DeviceContext1_SwapDeviceContextState(context, context_state, &tmp_context_state);
refcount = ID3DDeviceContextState_Release(tmp_context_state);
- todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
- todo_wine ok(tmp_context_state == context_state, "Got unexpected state pointer.\n");
+ ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
+ ok(tmp_context_state == context_state, "Got unexpected state pointer.\n");
tmp_vs = (ID3D11VertexShader *)0xdeadbeef;
ID3D11DeviceContext1_VSGetShader(context, &tmp_vs, NULL, NULL);
- todo_wine ok(tmp_vs == vs2, "Got shader %p, expected %p.\n", tmp_vs, vs2);
- if (tmp_vs) refcount = ID3D11VertexShader_Release(tmp_vs);
- else refcount = 0;
- todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
+ ok(tmp_vs == vs2, "Got shader %p, expected %p.\n", tmp_vs, vs2);
+ refcount = ID3D11VertexShader_Release(tmp_vs);
+ ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
/* context states may be used with other devices instances too */
d3d11_device2 = create_device(NULL);
@@ -7305,17 +7280,16 @@ static void test_device_context_state(void)
/* updating context2 vertex shader doesn't update other contexts using the same state */
ID3D11DeviceContext1_VSSetShader(context2, vs, NULL, 0);
ID3D11DeviceContext1_VSGetShader(context, &tmp_vs, NULL, NULL);
- todo_wine ok(tmp_vs == vs2, "Got shader %p, expected %p.\n", tmp_vs, vs2);
- if (tmp_vs) refcount = ID3D11VertexShader_Release(tmp_vs);
- else refcount = 0;
- todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
+ ok(tmp_vs == vs2, "Got shader %p, expected %p.\n", tmp_vs, vs2);
+ refcount = ID3D11VertexShader_Release(tmp_vs);
+ ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
ID3D11DeviceContext1_SwapDeviceContextState(context2, tmp_context_state, &context_state2);
refcount = ID3DDeviceContextState_Release(tmp_context_state);
ok(refcount == 0, "Got refcount %u, expected 1.\n", refcount);
refcount = ID3DDeviceContextState_Release(context_state2);
- todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
- todo_wine ok(context_state2 == context_state, "Got unexpected state pointer.\n");
+ ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
+ ok(context_state2 == context_state, "Got unexpected state pointer.\n");
/* swapping the default state on context2 effectively clears the vertex shader */
tmp_vs = (ID3D11VertexShader *)0xdeadbeef;
@@ -7333,19 +7307,17 @@ static void test_device_context_state(void)
ok(refcount == 0, "Got refcount %u, expected 0.\n", refcount);
tmp_vs = (ID3D11VertexShader *)0xdeadbeef;
ID3D11DeviceContext1_VSGetShader(context2, &tmp_vs, NULL, NULL);
- todo_wine ok(tmp_vs == vs, "Got shader %p, expected %p.\n", tmp_vs, vs);
- if (tmp_vs) refcount = ID3D11VertexShader_Release(tmp_vs);
- else refcount = 0;
- todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
+ ok(tmp_vs == vs, "Got shader %p, expected %p.\n", tmp_vs, vs);
+ refcount = ID3D11VertexShader_Release(tmp_vs);
+ ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
/* even after swapping it again */
ID3D11DeviceContext1_SwapDeviceContextState(context2, context_state, NULL);
tmp_vs = (ID3D11VertexShader *)0xdeadbeef;
ID3D11DeviceContext1_VSGetShader(context2, &tmp_vs, NULL, NULL);
- todo_wine ok(tmp_vs == vs, "Got shader %p, expected %p.\n", tmp_vs, vs);
- if (tmp_vs) refcount = ID3D11VertexShader_Release(tmp_vs);
- else refcount = 0;
- todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
+ ok(tmp_vs == vs, "Got shader %p, expected %p.\n", tmp_vs, vs);
+ refcount = ID3D11VertexShader_Release(tmp_vs);
+ ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
/* swapping the initial state on context2 doesn't have side effect on context either */
ID3D11DeviceContext1_SwapDeviceContextState(context2, previous_context_state, NULL);
@@ -7362,10 +7334,10 @@ static void test_device_context_state(void)
refcount = ID3DDeviceContextState_Release(previous_context_state);
ok(!refcount, "Got refcount %u, expected 0.\n", refcount);
refcount = ID3DDeviceContextState_Release(tmp_context_state);
- todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
+ ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
refcount = ID3DDeviceContextState_Release(context_state);
ok(!refcount, "Got refcount %u, expected 0.\n", refcount);
- todo_wine ok(tmp_context_state == context_state, "Got unexpected state pointer.\n");
+ ok(tmp_context_state == context_state, "Got unexpected state pointer.\n");
refcount = get_refcount(vs);
ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
--
2.20.1
2
1
[PATCH 3/5] wined3d: Introduce public API to set a wined3d_state object on a device.
by Henri Verbeet Feb. 23, 2021
by Henri Verbeet Feb. 23, 2021
Feb. 23, 2021
From: Rémi Bernon <rbernon(a)codeweavers.com>
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
This supersedes patches 200183 and 200187.
dlls/wined3d/device.c | 139 ++++++++++++++++++++++++++++++++++++--
dlls/wined3d/stateblock.c | 22 ++++++
dlls/wined3d/wined3d.spec | 5 ++
include/wine/wined3d.h | 6 ++
4 files changed, 167 insertions(+), 5 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index c9df09b53483..7405a38e13b8 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -251,7 +251,7 @@ void wined3d_device_cleanup(struct wined3d_device *device)
wine_rb_destroy(&device->depth_stencil_states, device_leftover_depth_stencil_state, NULL);
wine_rb_destroy(&device->so_descs, device_free_so_desc, NULL);
- heap_free(device->state);
+ wined3d_state_destroy(device->state);
device->state = NULL;
wined3d_decref(device->wined3d);
device->wined3d = NULL;
@@ -1926,6 +1926,136 @@ void CDECL wined3d_device_get_scissor_rects(const struct wined3d_device *device,
*rect_count = state->scissor_rect_count;
}
+void CDECL wined3d_device_set_state(struct wined3d_device *device, struct wined3d_state *state)
+{
+ const struct wined3d_light_info *light;
+ unsigned int i, j;
+
+ TRACE("device %p, state %p.\n", device, state);
+
+ device->state = state;
+
+ for (i = 0; i < WINED3D_MAX_RENDER_TARGETS; ++i)
+ {
+ wined3d_cs_emit_set_rendertarget_view(device->cs, i, state->fb.render_targets[i]);
+ }
+
+ wined3d_cs_emit_set_depth_stencil_view(device->cs, state->fb.depth_stencil);
+ wined3d_cs_emit_set_vertex_declaration(device->cs, state->vertex_declaration);
+
+ for (i = 0; i < WINED3D_MAX_STREAM_OUTPUT_BUFFERS; ++i)
+ {
+ wined3d_cs_emit_set_stream_output(device->cs, i,
+ state->stream_output[i].buffer, state->stream_output[i].offset);
+ }
+
+ for (i = 0; i < WINED3D_MAX_STREAMS; ++i)
+ {
+ wined3d_cs_emit_set_stream_source(device->cs, i, state->streams[i].buffer,
+ state->streams[i].offset, state->streams[i].stride);
+ }
+
+ wined3d_cs_emit_set_index_buffer(device->cs, state->index_buffer, state->index_format, state->index_offset);
+
+ wined3d_cs_emit_set_predication(device->cs, state->predicate, state->predicate_value);
+
+ for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
+ {
+ wined3d_cs_emit_set_shader(device->cs, i, state->shader[i]);
+ for (j = 0; j < MAX_CONSTANT_BUFFERS; ++j)
+ {
+ wined3d_cs_emit_set_constant_buffer(device->cs, i, j, state->cb[i][j]);
+ }
+ for (j = 0; j < MAX_SAMPLER_OBJECTS; ++j)
+ {
+ wined3d_cs_emit_set_sampler(device->cs, i, j, state->sampler[i][j]);
+ }
+ for (j = 0; j < MAX_SHADER_RESOURCE_VIEWS; ++j)
+ {
+ wined3d_cs_emit_set_shader_resource_view(device->cs, i, j, state->shader_resource_view[i][j]);
+ }
+ }
+
+ for (i = 0; i < WINED3D_PIPELINE_COUNT; ++i)
+ {
+ for (j = 0; j < MAX_UNORDERED_ACCESS_VIEWS; ++j)
+ {
+ wined3d_cs_emit_set_unordered_access_view(device->cs, i, j, state->unordered_access_view[i][j], ~0);
+ }
+ }
+
+ wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_VS_F,
+ 0, WINED3D_MAX_VS_CONSTS_F, state->vs_consts_f);
+ wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_VS_I,
+ 0, WINED3D_MAX_CONSTS_I, state->vs_consts_i);
+ wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_VS_B,
+ 0, WINED3D_MAX_CONSTS_B, state->vs_consts_b);
+
+ wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_PS_F,
+ 0, WINED3D_MAX_PS_CONSTS_F, state->ps_consts_f);
+ wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_PS_I,
+ 0, WINED3D_MAX_CONSTS_I, state->ps_consts_i);
+ wined3d_cs_push_constants(device->cs, WINED3D_PUSH_CONSTANTS_PS_B,
+ 0, WINED3D_MAX_CONSTS_B, state->ps_consts_b);
+
+ for (i = 0; i < WINED3D_MAX_COMBINED_SAMPLERS; ++i)
+ {
+ wined3d_cs_emit_set_texture(device->cs, i, state->textures[i]);
+ for (j = 0; j < WINED3D_HIGHEST_SAMPLER_STATE + 1; ++j)
+ {
+ wined3d_cs_emit_set_sampler_state(device->cs, i, j, state->sampler_states[i][j]);
+ }
+ }
+
+ for (i = 0; i < WINED3D_MAX_TEXTURES; ++i)
+ {
+ for (j = 0; j < WINED3D_HIGHEST_TEXTURE_STATE + 1; ++j)
+ {
+ wined3d_cs_emit_set_texture_state(device->cs, i, j, state->texture_states[i][j]);
+ }
+ }
+
+ for (i = 0; i < WINED3D_HIGHEST_TRANSFORM_STATE + 1; ++i)
+ {
+ wined3d_cs_emit_set_transform(device->cs, i, state->transforms + i);
+ }
+
+ for (i = 0; i < WINED3D_MAX_CLIP_DISTANCES; ++i)
+ {
+ wined3d_cs_emit_set_clip_plane(device->cs, i, state->clip_planes + i);
+ }
+
+ wined3d_cs_emit_set_material(device->cs, &state->material);
+
+ wined3d_cs_emit_set_viewports(device->cs, state->viewport_count, state->viewports);
+ wined3d_cs_emit_set_scissor_rects(device->cs, state->scissor_rect_count, state->scissor_rects);
+
+ for (i = 0; i < LIGHTMAP_SIZE; ++i)
+ {
+ LIST_FOR_EACH_ENTRY(light, &state->light_state.light_map[i], struct wined3d_light_info, entry)
+ {
+ wined3d_device_set_light(device, light->OriginalIndex, &light->OriginalParms);
+ wined3d_cs_emit_set_light_enable(device->cs, light->OriginalIndex, light->glIndex != -1);
+ }
+ }
+
+ for (i = 0; i < WINEHIGHEST_RENDER_STATE + 1; ++i)
+ {
+ wined3d_cs_emit_set_render_state(device->cs, i, state->render_states[i]);
+ }
+
+ wined3d_cs_emit_set_blend_state(device->cs, state->blend_state, &state->blend_factor, state->sample_mask);
+ wined3d_cs_emit_set_depth_stencil_state(device->cs, state->depth_stencil_state, state->stencil_ref);
+ wined3d_cs_emit_set_rasterizer_state(device->cs, state->rasterizer_state);
+}
+
+struct wined3d_state * CDECL wined3d_device_get_state(struct wined3d_device *device)
+{
+ TRACE("device %p.\n", device);
+
+ return device->state;
+}
+
void CDECL wined3d_device_set_vertex_declaration(struct wined3d_device *device,
struct wined3d_vertex_declaration *declaration)
{
@@ -5952,12 +6082,11 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined
return hr;
}
- if (!(state = heap_alloc_zero(sizeof(*state))))
+ if (FAILED(hr = wined3d_state_create(device, &state)))
{
- hr = E_OUTOFMEMORY;
+ ERR("Failed to create device state, hr %#x.\n", hr);
goto err;
}
- state_init(state, &adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
device->state = state;
device->max_frame_latency = 3;
@@ -5974,7 +6103,7 @@ HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined
err:
if (state)
- heap_free(state);
+ wined3d_state_destroy(state);
for (i = 0; i < ARRAY_SIZE(device->multistate_funcs); ++i)
{
heap_free(device->multistate_funcs[i]);
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 52124583c90c..97020e1cd407 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -1885,6 +1885,28 @@ void state_init(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_
state_init_default(state, d3d_info);
}
+HRESULT CDECL wined3d_state_create(struct wined3d_device *device, struct wined3d_state **state)
+{
+ struct wined3d_state *object;
+
+ TRACE("device %p, state %p.\n", device, state);
+
+ if (!(object = heap_alloc_zero(sizeof(*object))))
+ return E_OUTOFMEMORY;
+ state_init(object, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT);
+
+ *state = object;
+ return S_OK;
+}
+
+void CDECL wined3d_state_destroy(struct wined3d_state *state)
+{
+ TRACE("state %p.\n", state);
+
+ state_cleanup(state);
+ heap_free(state);
+}
+
static void stateblock_state_init_default(struct wined3d_stateblock_state *state,
const struct wined3d_d3d_info *d3d_info)
{
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 44008119a8dd..6b6480cec8f0 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -98,6 +98,7 @@
@ cdecl wined3d_device_get_rendertarget_view(ptr long)
@ cdecl wined3d_device_get_scissor_rects(ptr ptr ptr)
@ cdecl wined3d_device_get_software_vertex_processing(ptr)
+@ cdecl wined3d_device_get_state(ptr)
@ cdecl wined3d_device_get_stream_output(ptr long ptr)
@ cdecl wined3d_device_get_stream_source(ptr long ptr ptr ptr)
@ cdecl wined3d_device_get_swapchain(ptr long)
@@ -151,6 +152,7 @@
@ cdecl wined3d_device_set_rendertarget_view(ptr long ptr long)
@ cdecl wined3d_device_set_scissor_rects(ptr long ptr)
@ cdecl wined3d_device_set_software_vertex_processing(ptr long)
+@ cdecl wined3d_device_set_state(ptr ptr)
@ cdecl wined3d_device_set_stream_output(ptr long ptr long)
@ cdecl wined3d_device_set_stream_source(ptr long ptr long long)
@ cdecl wined3d_device_set_unordered_access_view(ptr long ptr long)
@@ -237,6 +239,9 @@
@ cdecl wined3d_shader_resource_view_get_parent(ptr)
@ cdecl wined3d_shader_resource_view_incref(ptr)
+@ cdecl wined3d_state_create(ptr ptr)
+@ cdecl wined3d_state_destroy(ptr)
+
@ cdecl wined3d_stateblock_apply(ptr ptr)
@ cdecl wined3d_stateblock_capture(ptr ptr)
@ cdecl wined3d_stateblock_create(ptr ptr long ptr)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 96cb6fc1d863..0d67e8c89d17 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2223,6 +2223,7 @@ struct wined3d_resource;
struct wined3d_sampler;
struct wined3d_shader;
struct wined3d_shader_resource_view;
+struct wined3d_state;
struct wined3d_stateblock;
struct wined3d_swapchain;
struct wined3d_swapchain_state;
@@ -2432,6 +2433,7 @@ struct wined3d_rendertarget_view * __cdecl wined3d_device_get_rendertarget_view(
void __cdecl wined3d_device_get_scissor_rects(const struct wined3d_device *device, unsigned int *rect_count,
RECT *rect);
BOOL __cdecl wined3d_device_get_software_vertex_processing(const struct wined3d_device *device);
+struct wined3d_state * __cdecl wined3d_device_get_state(struct wined3d_device *device);
struct wined3d_buffer * __cdecl wined3d_device_get_stream_output(struct wined3d_device *device,
UINT idx, UINT *offset);
HRESULT __cdecl wined3d_device_get_stream_source(const struct wined3d_device *device,
@@ -2522,6 +2524,7 @@ HRESULT __cdecl wined3d_device_set_rendertarget_view(struct wined3d_device *devi
void __cdecl wined3d_device_set_scissor_rects(struct wined3d_device *device,
unsigned int rect_count, const RECT *rect);
void __cdecl wined3d_device_set_software_vertex_processing(struct wined3d_device *device, BOOL software);
+void __cdecl wined3d_device_set_state(struct wined3d_device *device, struct wined3d_state *state);
void __cdecl wined3d_device_set_stream_output(struct wined3d_device *device, UINT idx,
struct wined3d_buffer *buffer, UINT offset);
HRESULT __cdecl wined3d_device_set_stream_source(struct wined3d_device *device,
@@ -2730,6 +2733,9 @@ void __cdecl wined3d_shader_resource_view_generate_mipmaps(struct wined3d_shader
void * __cdecl wined3d_shader_resource_view_get_parent(const struct wined3d_shader_resource_view *view);
ULONG __cdecl wined3d_shader_resource_view_incref(struct wined3d_shader_resource_view *view);
+HRESULT __cdecl wined3d_state_create(struct wined3d_device *device, struct wined3d_state **state);
+void __cdecl wined3d_state_destroy(struct wined3d_state *state);
+
void __cdecl wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock,
struct wined3d_stateblock *device_state);
void __cdecl wined3d_stateblock_capture(struct wined3d_stateblock *stateblock,
--
2.20.1
1
0
[PATCH 2/5] wined3d: Unbind framebuffer state in state_unbind_resources().
by Henri Verbeet Feb. 23, 2021
by Henri Verbeet Feb. 23, 2021
Feb. 23, 2021
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
---
dlls/wined3d/device.c | 13 -------------
dlls/wined3d/stateblock.c | 16 ++++++++++++++++
2 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 792263ca7d8b..c9df09b53483 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1196,7 +1196,6 @@ void wined3d_device_uninit_3d(struct wined3d_device *device)
struct wined3d_resource *resource, *cursor;
struct wined3d_rendertarget_view *view;
struct wined3d_texture *texture;
- unsigned int i;
TRACE("device %p.\n", device);
@@ -1224,10 +1223,6 @@ void wined3d_device_uninit_3d(struct wined3d_device *device)
wined3d_cs_emit_reset_state(device->cs);
state_cleanup(state);
- for (i = 0; i < device->adapter->d3d_info.limits.max_rt_count; ++i)
- {
- wined3d_device_set_rendertarget_view(device, i, NULL, FALSE);
- }
wine_rb_clear(&device->samplers, device_free_sampler, NULL);
wine_rb_clear(&device->rasterizer_states, device_free_rasterizer_state, NULL);
@@ -1243,14 +1238,6 @@ void wined3d_device_uninit_3d(struct wined3d_device *device)
device->adapter->adapter_ops->adapter_uninit_3d(device);
device->d3d_initialized = FALSE;
- if ((view = state->fb.depth_stencil))
- {
- TRACE("Releasing depth/stencil view %p.\n", view);
-
- state->fb.depth_stencil = NULL;
- wined3d_rendertarget_view_decref(view);
- }
-
if ((view = device->auto_depth_stencil_view))
{
device->auto_depth_stencil_view = NULL;
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 46588fa4246c..52124583c90c 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -374,6 +374,7 @@ void state_unbind_resources(struct wined3d_state *state)
struct wined3d_shader_resource_view *srv;
struct wined3d_vertex_declaration *decl;
struct wined3d_blend_state *blend_state;
+ struct wined3d_rendertarget_view *rtv;
struct wined3d_sampler *sampler;
struct wined3d_texture *texture;
struct wined3d_buffer *buffer;
@@ -473,6 +474,21 @@ void state_unbind_resources(struct wined3d_state *state)
state->blend_state = NULL;
wined3d_blend_state_decref(blend_state);
}
+
+ for (i = 0; i < ARRAY_SIZE(state->fb.render_targets); ++i)
+ {
+ if ((rtv = state->fb.render_targets[i]))
+ {
+ state->fb.render_targets[i] = NULL;
+ wined3d_rendertarget_view_decref(rtv);
+ }
+ }
+
+ if ((rtv = state->fb.depth_stencil))
+ {
+ state->fb.depth_stencil = NULL;
+ wined3d_rendertarget_view_decref(rtv);
+ }
}
void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state *state)
--
2.20.1
1
0