ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
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
List overview
Download
Ros-diffs
January 2018
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
37 participants
372 discussions
Start a n
N
ew thread
01/01: [QEDIT] Sync with Wine 3.0. CORE-14225
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=defffcf1f0dfcb9442746…
commit defffcf1f0dfcb944274654ffa03017f6bfd0a4d Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sun Jan 21 22:31:34 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sun Jan 21 22:31:34 2018 +0100 [QEDIT] Sync with Wine 3.0. CORE-14225 --- dll/directx/wine/qedit/timeline.c | 195 ++++++++++++++++++++++++++++++++++++++ media/doc/README.WINE | 2 +- 2 files changed, 196 insertions(+), 1 deletion(-) diff --git a/dll/directx/wine/qedit/timeline.c b/dll/directx/wine/qedit/timeline.c index 9735c3b838..52ef234f41 100644 --- a/dll/directx/wine/qedit/timeline.c +++ b/dll/directx/wine/qedit/timeline.c @@ -38,6 +38,7 @@ static inline TimelineImpl *impl_from_IAMTimeline(IAMTimeline *iface) typedef struct { IAMTimelineObj IAMTimelineObj_iface; + IAMTimelineGroup IAMTimelineGroup_iface; LONG ref; TIMELINE_MAJOR_TYPE timeline_type; } TimelineObjImpl; @@ -47,7 +48,13 @@ static inline TimelineObjImpl *impl_from_IAMTimelineObj(IAMTimelineObj *iface) return CONTAINING_RECORD(iface, TimelineObjImpl, IAMTimelineObj_iface); } +static inline TimelineObjImpl *impl_from_IAMTimelineGroup(IAMTimelineGroup *iface) +{ + return CONTAINING_RECORD(iface, TimelineObjImpl, IAMTimelineGroup_iface); +} + static const IAMTimelineObjVtbl IAMTimelineObj_VTable; +static const IAMTimelineGroupVtbl IAMTimelineGroup_VTable; /* Timeline inner IUnknown */ @@ -157,6 +164,7 @@ static HRESULT WINAPI Timeline_IAMTimeline_CreateEmptyNode(IAMTimeline *iface, I obj_impl->ref = 1; obj_impl->IAMTimelineObj_iface.lpVtbl = &IAMTimelineObj_VTable; + obj_impl->IAMTimelineGroup_iface.lpVtbl = &IAMTimelineGroup_VTable; obj_impl->timeline_type = type; *obj = &obj_impl->IAMTimelineObj_iface; @@ -440,6 +448,8 @@ static HRESULT WINAPI TimelineObj_QueryInterface(IAMTimelineObj *iface, REFIID r *ppv = NULL; if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IAMTimelineObj)) *ppv = &This->IAMTimelineObj_iface; + else if (IsEqualIID(riid, &IID_IAMTimelineGroup)) + *ppv = &This->IAMTimelineGroup_iface; else WARN("(%p, %s,%p): not found\n", This, debugstr_guid(riid), ppv); @@ -790,3 +800,188 @@ static const IAMTimelineObjVtbl IAMTimelineObj_VTable = TimelineObj_GetGroupIBelongTo, TimelineObj_GetEmbedDepth, }; + +static HRESULT WINAPI timelinegrp_QueryInterface(IAMTimelineGroup *iface, REFIID riid, void **object) +{ + TimelineObjImpl *This = impl_from_IAMTimelineGroup(iface); + return IAMTimelineObj_QueryInterface(&This->IAMTimelineObj_iface, riid, object); +} + +static ULONG WINAPI timelinegrp_AddRef(IAMTimelineGroup *iface) +{ + TimelineObjImpl *This = impl_from_IAMTimelineGroup(iface); + return IAMTimelineObj_AddRef(&This->IAMTimelineObj_iface); +} + +static ULONG WINAPI timelinegrp_Release(IAMTimelineGroup *iface) +{ + TimelineObjImpl *This = impl_from_IAMTimelineGroup(iface); + return IAMTimelineObj_Release(&This->IAMTimelineObj_iface); +} + +static HRESULT WINAPI timelinegrp_SetTimeline(IAMTimelineGroup *iface, IAMTimeline *timeline) +{ + TimelineObjImpl *This = impl_from_IAMTimelineGroup(iface); + FIXME("(%p)->(%p)\n", This, timeline); + return E_NOTIMPL; +} + +static HRESULT WINAPI timelinegrp_GetTimeline(IAMTimelineGroup *iface, IAMTimeline **timeline) +{ + TimelineObjImpl *This = impl_from_IAMTimelineGroup(iface); + FIXME("(%p)->(%p)\n", This, timeline); + return E_NOTIMPL; +} + +static HRESULT WINAPI timelinegrp_GetPriority(IAMTimelineGroup *iface, LONG *priority) +{ + TimelineObjImpl *This = impl_from_IAMTimelineGroup(iface); + FIXME("(%p)->(%p)\n", This, priority); + return E_NOTIMPL; +} + +static HRESULT WINAPI timelinegrp_GetMediaType(IAMTimelineGroup *iface, AM_MEDIA_TYPE *mediatype) +{ + TimelineObjImpl *This = impl_from_IAMTimelineGroup(iface); + FIXME("(%p)->(%p)\n", This, mediatype); + return E_NOTIMPL; +} + +static HRESULT WINAPI timelinegrp_SetMediaType(IAMTimelineGroup *iface, AM_MEDIA_TYPE *mediatype) +{ + TimelineObjImpl *This = impl_from_IAMTimelineGroup(iface); + FIXME("(%p)->(%p)\n", This, mediatype); + return E_NOTIMPL; +} + +static HRESULT WINAPI timelinegrp_SetOutputFPS(IAMTimelineGroup *iface, double fps) +{ + TimelineObjImpl *This = impl_from_IAMTimelineGroup(iface); + FIXME("(%p)->(%f)\n", This, fps); + return E_NOTIMPL; +} + +static HRESULT WINAPI timelinegrp_GetOutputFPS(IAMTimelineGroup *iface, double *fps) +{ + TimelineObjImpl *This = impl_from_IAMTimelineGroup(iface); + FIXME("(%p)->(%p)\n", This, fps); + return E_NOTIMPL; +} + +static HRESULT WINAPI timelinegrp_SetGroupName(IAMTimelineGroup *iface, BSTR name) +{ + TimelineObjImpl *This = impl_from_IAMTimelineGroup(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(name)); + return E_NOTIMPL; +} + +static HRESULT WINAPI timelinegrp_GetGroupName(IAMTimelineGroup *iface, BSTR *name) +{ + TimelineObjImpl *This = impl_from_IAMTimelineGroup(iface); + FIXME("(%p)->(%p)\n", This, name); + return E_NOTIMPL; +} + +static HRESULT WINAPI timelinegrp_SetPreviewMode(IAMTimelineGroup *iface, BOOL preview) +{ + TimelineObjImpl *This = impl_from_IAMTimelineGroup(iface); + FIXME("(%p)->(%d)\n", This, preview); + return E_NOTIMPL; +} + +static HRESULT WINAPI timelinegrp_GetPreviewMode(IAMTimelineGroup *iface, BOOL *preview) +{ + TimelineObjImpl *This = impl_from_IAMTimelineGroup(iface); + FIXME("(%p)->(%p)\n", This, preview); + return E_NOTIMPL; +} + +static HRESULT WINAPI timelinegrp_SetMediaTypeForVB(IAMTimelineGroup *iface, LONG type) +{ + TimelineObjImpl *This = impl_from_IAMTimelineGroup(iface); + FIXME("(%p)->(%d)\n", This, type); + return E_NOTIMPL; +} + +static HRESULT WINAPI timelinegrp_GetOutputBuffering(IAMTimelineGroup *iface, int *buffer) +{ + TimelineObjImpl *This = impl_from_IAMTimelineGroup(iface); + FIXME("(%p)->(%p)\n", This, buffer); + return E_NOTIMPL; +} + +static HRESULT WINAPI timelinegrp_SetOutputBuffering(IAMTimelineGroup *iface, int buffer) +{ + TimelineObjImpl *This = impl_from_IAMTimelineGroup(iface); + FIXME("(%p)->(%d)\n", This, buffer); + return E_NOTIMPL; +} + +static HRESULT WINAPI timelinegrp_SetSmartRecompressFormat(IAMTimelineGroup *iface, LONG *format) +{ + TimelineObjImpl *This = impl_from_IAMTimelineGroup(iface); + FIXME("(%p)->(%p)\n", This, format); + return E_NOTIMPL; +} + +static HRESULT WINAPI timelinegrp_GetSmartRecompressFormat(IAMTimelineGroup *iface, LONG **format) +{ + TimelineObjImpl *This = impl_from_IAMTimelineGroup(iface); + FIXME("(%p)->(%p)\n", This, format); + return E_NOTIMPL; +} + +static HRESULT WINAPI timelinegrp_IsSmartRecompressFormatSet(IAMTimelineGroup *iface, BOOL *set) +{ + TimelineObjImpl *This = impl_from_IAMTimelineGroup(iface); + FIXME("(%p)->(%p)\n", This, set); + return E_NOTIMPL; +} + +static HRESULT WINAPI timelinegrp_IsRecompressFormatDirty(IAMTimelineGroup *iface, BOOL *dirty) +{ + TimelineObjImpl *This = impl_from_IAMTimelineGroup(iface); + FIXME("(%p)->(%p)\n", This, dirty); + return E_NOTIMPL; +} + +static HRESULT WINAPI timelinegrp_ClearRecompressFormatDirty(IAMTimelineGroup *iface) +{ + TimelineObjImpl *This = impl_from_IAMTimelineGroup(iface); + FIXME("(%p)->()\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI timelinegrp_SetRecompFormatFromSource(IAMTimelineGroup *iface, IAMTimelineSrc *source) +{ + TimelineObjImpl *This = impl_from_IAMTimelineGroup(iface); + FIXME("(%p)->(%p)\n", This, source); + return E_NOTIMPL; +} + +static const IAMTimelineGroupVtbl IAMTimelineGroup_VTable = +{ + timelinegrp_QueryInterface, + timelinegrp_AddRef, + timelinegrp_Release, + timelinegrp_SetTimeline, + timelinegrp_GetTimeline, + timelinegrp_GetPriority, + timelinegrp_GetMediaType, + timelinegrp_SetMediaType, + timelinegrp_SetOutputFPS, + timelinegrp_GetOutputFPS, + timelinegrp_SetGroupName, + timelinegrp_GetGroupName, + timelinegrp_SetPreviewMode, + timelinegrp_GetPreviewMode, + timelinegrp_SetMediaTypeForVB, + timelinegrp_GetOutputBuffering, + timelinegrp_SetOutputBuffering, + timelinegrp_SetSmartRecompressFormat, + timelinegrp_GetSmartRecompressFormat, + timelinegrp_IsSmartRecompressFormatSet, + timelinegrp_IsRecompressFormatDirty, + timelinegrp_ClearRecompressFormatDirty, + timelinegrp_SetRecompFormatFromSource +}; diff --git a/media/doc/README.WINE b/media/doc/README.WINE index e22e0ed4d5..bebb2f97bc 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -38,7 +38,7 @@ reactos/dll/directx/wine/dplayx # Synced to WineStaging-2.16 reactos/dll/directx/wine/dsound # Synced to Wine-1.3.29 reactos/dll/directx/wine/dxdiagn # Synced to Wine-3.0 reactos/dll/directx/wine/msdmo # Synced to WineStaging-2.9 -reactos/dll/directx/wine/qedit # Synced to WineStaging-2.9 +reactos/dll/directx/wine/qedit # Synced to Wine-3.0 reactos/dll/directx/wine/quartz # Synced to WineStaging-2.16 reactos/dll/directx/wine/wined3d # Synced to Wine-3.0
6 years, 11 months
1
0
0
0
01/01: [DXDIAGN_WINETEST] Sync with Wine 3.0. CORE-14225
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=09527f87fb6ea583a15df…
commit 09527f87fb6ea583a15dfa4ad17e171e87ad6955 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sun Jan 21 22:30:36 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sun Jan 21 22:30:36 2018 +0100 [DXDIAGN_WINETEST] Sync with Wine 3.0. CORE-14225 --- modules/rostests/winetests/dxdiagn/container.c | 166 +------------------------ 1 file changed, 1 insertion(+), 165 deletions(-) diff --git a/modules/rostests/winetests/dxdiagn/container.c b/modules/rostests/winetests/dxdiagn/container.c index 795907d245..3da9985b8d 100644 --- a/modules/rostests/winetests/dxdiagn/container.c +++ b/modules/rostests/winetests/dxdiagn/container.c @@ -36,11 +36,6 @@ static IDxDiagContainer *pddc; static const WCHAR DxDiag_SystemInfo[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','I','n','f','o',0}; static const WCHAR DxDiag_DisplayDevices[] = {'D','x','D','i','a','g','_','D','i','s','p','l','a','y','D','e','v','i','c','e','s',0}; -static const WCHAR DxDiag_SoundDevices[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','S','o','u','n','d','.', - 'D','x','D','i','a','g','_','S','o','u','n','d','D','e','v','i','c','e','s',0}; -static const WCHAR DxDiag_SoundCaptureDevices[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','S','o','u','n','d','.', - 'D','x','D','i','a','g','_','S','o','u','n','d','C','a','p','t','u','r','e', - 'D','e','v','i','c','e','s',0}; /* Based on debugstr_variant in dlls/jscript/jsutils.c. */ static const char *debugstr_variant(const VARIANT *var) @@ -901,8 +896,7 @@ static void test_DxDiag_SystemInfo(void) {szProcessorEnglish, VT_BSTR}, }; - IDxDiagContainer *container, *container2; - static const WCHAR empty[] = {0}; + IDxDiagContainer *container; HRESULT hr; if (!create_root_IDxDiagContainer()) @@ -911,9 +905,6 @@ static void test_DxDiag_SystemInfo(void) return; } - hr = IDxDiagContainer_GetChildContainer(pddc, empty, &container2); - ok(hr == E_INVALIDARG, "Expected IDxDiagContainer::GetChildContainer to return E_INVALIDARG, got 0x%08x\n", hr); - hr = IDxDiagContainer_GetChildContainer(pddc, DxDiag_SystemInfo, &container); ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr); @@ -921,14 +912,6 @@ static void test_DxDiag_SystemInfo(void) { trace("Testing container DxDiag_SystemInfo\n"); test_container_properties(container, property_tests, sizeof(property_tests)/sizeof(property_tests[0])); - - container2 = NULL; - hr = IDxDiagContainer_GetChildContainer(container, empty, &container2); - ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr); - ok(container2 != NULL, "Expected container2 != NULL\n"); - ok(container2 != container, "Expected container != container2\n"); - if (hr == S_OK) IDxDiagContainer_Release(container2); - IDxDiagContainer_Release(container); } @@ -959,7 +942,6 @@ static void test_DxDiag_DisplayDevices(void) static const WCHAR b3DAccelerationExists[] = {'b','3','D','A','c','c','e','l','e','r','a','t','i','o','n','E','x','i','s','t','s',0}; static const WCHAR b3DAccelerationEnabled[] = {'b','3','D','A','c','c','e','l','e','r','a','t','i','o','n','E','n','a','b','l','e','d',0}; static const WCHAR bDDAccelerationEnabled[] = {'b','D','D','A','c','c','e','l','e','r','a','t','i','o','n','E','n','a','b','l','e','d',0}; - static const WCHAR iAdapter[] = {'i','A','d','a','p','t','e','r',0}; static const struct property_test property_tests[] = { @@ -984,7 +966,6 @@ static void test_DxDiag_DisplayDevices(void) {b3DAccelerationExists, VT_BOOL}, {b3DAccelerationEnabled, VT_BOOL}, {bDDAccelerationEnabled, VT_BOOL}, - {iAdapter, VT_UI4}, }; IDxDiagContainer *display_cont = NULL; @@ -1039,149 +1020,6 @@ cleanup: IDxDiagProvider_Release(pddp); } -static void test_DxDiag_SoundDevices(void) -{ - static const WCHAR szDescription[] = {'s','z','D','e','s','c','r','i','p','t','i','o','n',0}; - static const WCHAR szGuidDeviceID[] = {'s','z','G','u','i','d','D','e','v','i','c','e','I','D',0}; - static const WCHAR szDriverPath[] = {'s','z','D','r','i','v','e','r','P','a','t','h',0}; - static const WCHAR szDriverName[] = {'s','z','D','r','i','v','e','r','N','a','m','e',0}; - static const WCHAR empty[] = {0}; - - static const struct property_test property_tests[] = - { - {szDescription, VT_BSTR}, - {szGuidDeviceID, VT_BSTR}, - {szDriverName, VT_BSTR}, - {szDriverPath, VT_BSTR}, - }; - - IDxDiagContainer *sound_cont = NULL; - DWORD count, i; - HRESULT hr; - - if (!create_root_IDxDiagContainer()) - { - skip("Unable to create the root IDxDiagContainer\n"); - return; - } - - hr = IDxDiagContainer_GetChildContainer(pddc, DxDiag_SoundDevices, &sound_cont); - ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr); - - if (hr != S_OK) - goto cleanup; - - hr = IDxDiagContainer_GetNumberOfProps(sound_cont, &count); - ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfProps to return S_OK, got 0x%08x\n", hr); - if (hr == S_OK) - ok(count == 0, "Expected count to be 0, got %u\n", count); - - hr = IDxDiagContainer_GetNumberOfChildContainers(sound_cont, &count); - ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08x\n", hr); - - if (hr != S_OK) - goto cleanup; - - for (i = 0; i < count; i++) - { - WCHAR child_container[256]; - IDxDiagContainer *child, *child2; - - hr = IDxDiagContainer_EnumChildContainerNames(sound_cont, i, child_container, sizeof(child_container)/sizeof(WCHAR)); - ok(hr == S_OK, "Expected IDxDiagContainer::EnumChildContainerNames to return S_OK, got 0x%08x\n", hr); - - hr = IDxDiagContainer_GetChildContainer(sound_cont, child_container, &child); - ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr); - - if (hr == S_OK) - { - trace("Testing container %s\n", wine_dbgstr_w(child_container)); - test_container_properties(child, property_tests, sizeof(property_tests)/sizeof(property_tests[0])); - } - - child2 = NULL; - hr = IDxDiagContainer_GetChildContainer(child, empty, &child2); - ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr); - ok(child2 != NULL, "Expected child2 != NULL\n"); - ok(child2 != child, "Expected child != child2\n"); - if (hr == S_OK) IDxDiagContainer_Release(child2); - - IDxDiagContainer_Release(child); - } - -cleanup: - if (sound_cont) IDxDiagContainer_Release(sound_cont); - IDxDiagContainer_Release(pddc); - IDxDiagProvider_Release(pddp); -} - -static void test_DxDiag_SoundCaptureDevices(void) -{ - static const WCHAR szDescription[] = {'s','z','D','e','s','c','r','i','p','t','i','o','n',0}; - static const WCHAR szGuidDeviceID[] = {'s','z','G','u','i','d','D','e','v','i','c','e','I','D',0}; - static const WCHAR szDriverPath[] = {'s','z','D','r','i','v','e','r','P','a','t','h',0}; - static const WCHAR szDriverName[] = {'s','z','D','r','i','v','e','r','N','a','m','e',0}; - - static const struct property_test property_tests[] = - { - {szDescription, VT_BSTR}, - {szGuidDeviceID, VT_BSTR}, - {szDriverName, VT_BSTR}, - {szDriverPath, VT_BSTR}, - }; - - IDxDiagContainer *sound_cont = NULL; - DWORD count, i; - HRESULT hr; - - if (!create_root_IDxDiagContainer()) - { - skip("Unable to create the root IDxDiagContainer\n"); - return; - } - - hr = IDxDiagContainer_GetChildContainer(pddc, DxDiag_SoundCaptureDevices, &sound_cont); - ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr); - - if (hr != S_OK) - goto cleanup; - - hr = IDxDiagContainer_GetNumberOfProps(sound_cont, &count); - ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfProps to return S_OK, got 0x%08x\n", hr); - if (hr == S_OK) - ok(count == 0, "Expected count to be 0, got %u\n", count); - - hr = IDxDiagContainer_GetNumberOfChildContainers(sound_cont, &count); - ok(hr == S_OK, "Expected IDxDiagContainer::GetNumberOfChildContainers to return S_OK, got 0x%08x\n", hr); - - if (hr != S_OK) - goto cleanup; - - for (i = 0; i < count; i++) - { - WCHAR child_container[256]; - IDxDiagContainer *child; - - hr = IDxDiagContainer_EnumChildContainerNames(sound_cont, i, child_container, sizeof(child_container)/sizeof(WCHAR)); - ok(hr == S_OK, "Expected IDxDiagContainer::EnumChildContainerNames to return S_OK, got 0x%08x\n", hr); - - hr = IDxDiagContainer_GetChildContainer(sound_cont, child_container, &child); - ok(hr == S_OK, "Expected IDxDiagContainer::GetChildContainer to return S_OK, got 0x%08x\n", hr); - - if (hr == S_OK) - { - trace("Testing container %s\n", wine_dbgstr_w(child_container)); - test_container_properties(child, property_tests, sizeof(property_tests)/sizeof(property_tests[0])); - } - IDxDiagContainer_Release(child); - } - -cleanup: - if (sound_cont) IDxDiagContainer_Release(sound_cont); - IDxDiagContainer_Release(pddc); - IDxDiagProvider_Release(pddp); -} - START_TEST(container) { CoInitialize(NULL); @@ -1196,7 +1034,5 @@ START_TEST(container) test_root_children(); test_DxDiag_SystemInfo(); test_DxDiag_DisplayDevices(); - test_DxDiag_SoundDevices(); - test_DxDiag_SoundCaptureDevices(); CoUninitialize(); }
6 years, 11 months
1
0
0
0
01/01: [DXDIAGN] Sync with Wine 3.0. CORE-14225
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=92f11cd7c04b306026dcc…
commit 92f11cd7c04b306026dcc45ddffea79c5bbba8a0 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sun Jan 21 22:29:51 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sun Jan 21 22:29:51 2018 +0100 [DXDIAGN] Sync with Wine 3.0. CORE-14225 --- dll/directx/wine/dxdiagn/container.c | 12 +- dll/directx/wine/dxdiagn/provider.c | 249 ----------------------------------- media/doc/README.WINE | 2 +- 3 files changed, 3 insertions(+), 260 deletions(-) diff --git a/dll/directx/wine/dxdiagn/container.c b/dll/directx/wine/dxdiagn/container.c index d13db45119..dd587c382b 100644 --- a/dll/directx/wine/dxdiagn/container.c +++ b/dll/directx/wine/dxdiagn/container.c @@ -155,14 +155,6 @@ static HRESULT WINAPI IDxDiagContainerImpl_GetChildContainer(IDxDiagContainer *i if (NULL == tmp) return E_FAIL; lstrcpynW(tmp, pwszContainer, tmp_len); - /* special handling for an empty string and leaf container */ - if (!tmp[0] && list_empty(&pContainer->subContainers)) { - hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, pContainer, This->pProv, (void **)ppInstance); - if (SUCCEEDED(hr)) - TRACE("Succeeded in getting the container instance\n"); - goto out; - } - cur = strchrW(tmp, '.'); while (NULL != cur) { *cur = '\0'; /* cut tmp string to '.' */ @@ -170,7 +162,7 @@ static HRESULT WINAPI IDxDiagContainerImpl_GetChildContainer(IDxDiagContainer *i TRACE("Trying to get parent container %s\n", debugstr_w(tmp)); hr = IDxDiagContainerImpl_GetChildContainerInternal(pContainer, tmp, &pContainer); if (FAILED(hr)) - goto out; + goto on_error; cur++; /* go after '.' (just replaced by \0) */ tmp = cur; cur = strchrW(tmp, '.'); @@ -184,7 +176,7 @@ static HRESULT WINAPI IDxDiagContainerImpl_GetChildContainer(IDxDiagContainer *i TRACE("Succeeded in getting the container instance\n"); } -out: +on_error: HeapFree(GetProcessHeap(), 0, orig_tmp); return hr; } diff --git a/dll/directx/wine/dxdiagn/provider.c b/dll/directx/wine/dxdiagn/provider.c index 27277b803f..638dc23ccb 100644 --- a/dll/directx/wine/dxdiagn/provider.c +++ b/dll/directx/wine/dxdiagn/provider.c @@ -48,8 +48,6 @@ static const WCHAR dwHeight[] = {'d','w','H','e','i','g','h','t',0}; static const WCHAR dwBpp[] = {'d','w','B','p','p',0}; static const WCHAR szDisplayMemoryLocalized[] = {'s','z','D','i','s','p','l','a','y','M','e','m','o','r','y','L','o','c','a','l','i','z','e','d',0}; static const WCHAR szDisplayMemoryEnglish[] = {'s','z','D','i','s','p','l','a','y','M','e','m','o','r','y','E','n','g','l','i','s','h',0}; -static const WCHAR szDisplayModeLocalized[] = {'s','z','D','i','s','p','l','a','y','M','o','d','e','L','o','c','a','l','i','z','e','d',0}; -static const WCHAR szDisplayModeEnglish[] = {'s','z','D','i','s','p','l','a','y','M','o','d','e','E','n','g','l','i','s','h',0}; static const WCHAR szDriverName[] = {'s','z','D','r','i','v','e','r','N','a','m','e',0}; static const WCHAR szDriverVersion[] = {'s','z','D','r','i','v','e','r','V','e','r','s','i','o','n',0}; static const WCHAR szSubSysId[] = {'s','z','S','u','b','S','y','s','I','d',0}; @@ -59,30 +57,6 @@ static const WCHAR szManufacturer[] = {'s','z','M','a','n','u','f','a','c','t',' static const WCHAR szChipType[] = {'s','z','C','h','i','p','T','y','p','e',0}; static const WCHAR szDACType[] = {'s','z','D','A','C','T','y','p','e',0}; static const WCHAR szRevision[] = {'s','z','R','e','v','i','s','i','o','n',0}; -static const WCHAR szMonitorName[] = {'s','z','M','o','n','i','t','o','r','N','a','m','e',0}; -static const WCHAR szMonitorMaxRes[] = {'s','z','M','o','n','i','t','o','r','M','a','x','R','e','s',0}; -static const WCHAR szDriverAttributes[] = {'s','z','D','r','i','v','e','r','A','t','t','r','i','b','u','t','e','s',0}; -static const WCHAR szDriverLanguageEnglish[] = {'s','z','D','r','i','v','e','r','L','a','n','g','u','a','g','e','E','n','g','l','i','s','h',0}; -static const WCHAR szDriverLanguageLocalized[] = {'s','z','D','r','i','v','e','r','L','a','n','g','u','a','g','e','L','o','c','a','l','i','z','e','d',0}; -static const WCHAR szDriverDateEnglish[] = {'s','z','D','r','i','v','e','r','D','a','t','e','E','n','g','l','i','s','h',0}; -static const WCHAR szDriverDateLocalized[] = {'s','z','D','r','i','v','e','r','D','a','t','e','L','o','c','a','l','i','z','e','d',0}; -static const WCHAR lDriverSize[] = {'l','D','r','i','v','e','r','S','i','z','e',0}; -static const WCHAR szMiniVdd[] = {'s','z','M','i','n','i','V','d','d',0}; -static const WCHAR szMiniVddDateLocalized[] = {'s','z','M','i','n','i','V','d','d','D','a','t','e','L','o','c','a','l','i','z','e','d',0}; -static const WCHAR szMiniVddDateEnglish[] = {'s','z','M','i','n','i','V','d','d','D','a','t','e','E','n','g','l','i','s','h',0}; -static const WCHAR lMiniVddSize[] = {'l','M','i','n','i','V','d','d','S','i','z','e',0}; -static const WCHAR szVdd[] = {'s','z','V','d','d',0}; -static const WCHAR bCanRenderWindow[] = {'b','C','a','n','R','e','n','d','e','r','W','i','n','d','o','w',0}; -static const WCHAR bDriverBeta[] = {'b','D','r','i','v','e','r','B','e','t','a',0}; -static const WCHAR bDriverDebug[] = {'b','D','r','i','v','e','r','D','e','b','u','g',0}; -static const WCHAR bDriverSigned[] = {'b','D','r','i','v','e','r','S','i','g','n','e','d',0}; -static const WCHAR bDriverSignedValid[] = {'b','D','r','i','v','e','r','S','i','g','n','e','d','V','a','l','i','d',0}; -static const WCHAR szDriverSignDate[] = {'s','z','D','r','i','v','e','r','S','i','g','n','D','a','t','e',0}; -static const WCHAR dwDDIVersion[] = {'d','w','D','D','I','V','e','r','s','i','o','n',0}; -static const WCHAR szDDIVersionEnglish[] = {'s','z','D','D','I','V','e','r','s','i','o','n','E','n','g','l','i','s','h',0}; -static const WCHAR szDDIVersionLocalized[] = {'s','z','D','D','I','V','e','r','s','i','o','n','L','o','c','a','l','i','z','e','d',0}; -static const WCHAR iAdapter[] = {'i','A','d','a','p','t','e','r',0}; -static const WCHAR dwWHQLLevel[] = {'d','w','W','H','Q','L','L','e','v','e','l',0}; struct IDxDiagProviderImpl { @@ -340,23 +314,6 @@ static inline HRESULT add_ui4_property(IDxDiagContainerImpl_Container *node, con return S_OK; } -static inline HRESULT add_i4_property(IDxDiagContainerImpl_Container *node, const WCHAR *propName, LONG data) -{ - IDxDiagContainerImpl_Property *prop; - - prop = allocate_property_information(propName); - if (!prop) - return E_OUTOFMEMORY; - - V_VT(&prop->vProp) = VT_I4; - V_I4(&prop->vProp) = data; - - list_add_tail(&node->properties, &prop->entry); - ++node->nProperties; - - return S_OK; -} - static inline HRESULT add_bool_property(IDxDiagContainerImpl_Container *node, const WCHAR *propName, BOOL data) { IDxDiagContainerImpl_Property *prop; @@ -956,15 +913,6 @@ static HRESULT fill_display_information_d3d(IDxDiagContainerImpl_Container *node static const WCHAR b3DAccelerationEnabled[] = {'b','3','D','A','c','c','e','l','e','r','a','t','i','o','n','E','n','a','b','l','e','d',0}; static const WCHAR bDDAccelerationEnabled[] = {'b','D','D','A','c','c','e','l','e','r','a','t','i','o','n','E','n','a','b','l','e','d',0}; static const WCHAR bNoHardware[] = {'b','N','o','H','a','r','d','w','a','r','e',0}; - static const WCHAR mode_fmtW[] = {'%','d',' ','x',' ','%','d',' ','(','%','d',' ','b','i','t',')',' ','(','%','d','H','z',')',0}; - static const WCHAR gernericPNPMonitorW[] = {'G','e','n','e','r','i','c',' ','P','n','P',' ','M','o','n','i','t','o','r',0}; - static const WCHAR failedToGetParameterW[] = {'F','a','i','l','e','d',' ','t','o',' ','g','e','t',' ','p','a','r','a','m','e','t','e','r',0}; - static const WCHAR driverAttributesW[] = {'F','i','n','a','l',' ','R','e','t','a','i','l',0}; - static const WCHAR englishW[] = {'E','n','g','l','i','s','h',0}; - static const WCHAR driverDateEnglishW[] = {'1','/','1','/','2','0','1','6',' ','1','0',':','0','0',':','0','0',0}; - static const WCHAR driverDateLocalW[] = {'1','/','1','/','2','0','1','6',' ','1','0',':','0','0',':','0','0',' ','A','M',0}; - static const WCHAR naW[] = {'n','/','a',0}; - static const WCHAR ddi11W[] = {'1','1',0}; D3DADAPTER_IDENTIFIER9 adapter_info; D3DDISPLAYMODE adapter_mode; @@ -1061,17 +1009,6 @@ static HRESULT fill_display_information_d3d(IDxDiagContainerImpl_Container *node hr = add_ui4_property(display_adapter, dwBpp, depth_for_pixelformat(adapter_mode.Format)); if (FAILED(hr)) goto cleanup; - - snprintfW(buffer, sizeof(buffer)/sizeof(WCHAR), mode_fmtW, adapter_mode.Width, adapter_mode.Height, - depth_for_pixelformat(adapter_mode.Format), adapter_mode.RefreshRate); - - hr = add_bstr_property(display_adapter, szDisplayModeLocalized, buffer); - if (FAILED(hr)) - goto cleanup; - - hr = add_bstr_property(display_adapter, szDisplayModeEnglish, buffer); - if (FAILED(hr)) - goto cleanup; } hr = add_bstr_property(display_adapter, szKeyDeviceKey, szEmpty); @@ -1125,102 +1062,6 @@ static HRESULT fill_display_information_d3d(IDxDiagContainerImpl_Container *node hr = add_bool_property(display_adapter, bNoHardware, FALSE); if (FAILED(hr)) goto cleanup; - - hr = add_bool_property(display_adapter, bCanRenderWindow, TRUE); - if (FAILED(hr)) - goto cleanup; - - hr = add_bstr_property(display_adapter, szMonitorName, gernericPNPMonitorW); - if (FAILED(hr)) - goto cleanup; - - hr = add_bstr_property(display_adapter, szMonitorMaxRes, failedToGetParameterW); - if (FAILED(hr)) - goto cleanup; - - hr = add_bstr_property(display_adapter, szDriverAttributes, driverAttributesW); - if (FAILED(hr)) - goto cleanup; - - hr = add_bstr_property(display_adapter, szDriverLanguageEnglish, englishW); - if (FAILED(hr)) - goto cleanup; - - hr = add_bstr_property(display_adapter, szDriverLanguageLocalized, englishW); - if (FAILED(hr)) - goto cleanup; - - hr = add_bstr_property(display_adapter, szDriverDateEnglish, driverDateEnglishW); - if (FAILED(hr)) - goto cleanup; - - hr = add_bstr_property(display_adapter, szDriverDateLocalized, driverDateLocalW); - if (FAILED(hr)) - goto cleanup; - - hr = add_i4_property(display_adapter, lDriverSize, 10 * 1024 * 1024); - if (FAILED(hr)) - goto cleanup; - - hr = add_bstr_property(display_adapter, szMiniVdd, naW); - if (FAILED(hr)) - goto cleanup; - - hr = add_bstr_property(display_adapter, szMiniVddDateLocalized, naW); - if (FAILED(hr)) - goto cleanup; - - hr = add_bstr_property(display_adapter, szMiniVddDateEnglish, naW); - if (FAILED(hr)) - goto cleanup; - - hr = add_i4_property(display_adapter, lMiniVddSize, 0); - if (FAILED(hr)) - goto cleanup; - - hr = add_bstr_property(display_adapter, szVdd, naW); - if (FAILED(hr)) - goto cleanup; - - hr = add_bool_property(display_adapter, bDriverBeta, FALSE); - if (FAILED(hr)) - goto cleanup; - - hr = add_bool_property(display_adapter, bDriverDebug, FALSE); - if (FAILED(hr)) - goto cleanup; - - hr = add_bool_property(display_adapter, bDriverSigned, TRUE); - if (FAILED(hr)) - goto cleanup; - - hr = add_bool_property(display_adapter, bDriverSignedValid, TRUE); - if (FAILED(hr)) - goto cleanup; - - hr = add_bstr_property(display_adapter, szDriverSignDate, naW); - if (FAILED(hr)) - goto cleanup; - - hr = add_ui4_property(display_adapter, dwDDIVersion, 11); - if (FAILED(hr)) - goto cleanup; - - hr = add_bstr_property(display_adapter, szDDIVersionEnglish, ddi11W); - if (FAILED(hr)) - goto cleanup; - - hr = add_bstr_property(display_adapter, szDDIVersionLocalized, ddi11W); - if (FAILED(hr)) - goto cleanup; - - hr = add_ui4_property(display_adapter, iAdapter, index); - if (FAILED(hr)) - goto cleanup; - - hr = add_ui4_property(display_adapter, dwWHQLLevel, 0); - if (FAILED(hr)) - goto cleanup; } hr = S_OK; @@ -1342,85 +1183,11 @@ static HRESULT build_displaydevices_tree(IDxDiagContainerImpl_Container *node) return fill_display_information_fallback(node); } -struct enum_context -{ - IDxDiagContainerImpl_Container *cont; - HRESULT hr; - int index; -}; - -static const WCHAR szGUIDFmt[] = -{ - '%','0','8','x','-','%','0','4','x','-','%','0','4','x','-','%','0', - '2','x','%','0','2','x','-','%','0','2','x','%','0','2','x','%','0','2', - 'x','%','0','2','x','%','0','2','x','%','0','2','x',0 -}; - -static LPWSTR guid_to_string(LPWSTR lpwstr, REFGUID lpcguid) -{ - wsprintfW(lpwstr, szGUIDFmt, lpcguid->Data1, lpcguid->Data2, - lpcguid->Data3, lpcguid->Data4[0], lpcguid->Data4[1], - lpcguid->Data4[2], lpcguid->Data4[3], lpcguid->Data4[4], - lpcguid->Data4[5], lpcguid->Data4[6], lpcguid->Data4[7]); - - return lpwstr; -} - -BOOL CALLBACK dsound_enum(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID context) -{ - static const WCHAR deviceid_fmtW[] = {'%','u',0}; - static const WCHAR szGuidDeviceID[] = {'s','z','G','u','i','d','D','e','v','i','c','e','I','D',0}; - static const WCHAR szDriverPath[] = {'s','z','D','r','i','v','e','r','P','a','t','h',0}; - - struct enum_context *enum_ctx = context; - IDxDiagContainerImpl_Container *device; - WCHAR buffer[256]; - const WCHAR *p, *name; - - /* the default device is enumerated twice, one time without GUID */ - if (!guid) return TRUE; - - snprintfW(buffer, sizeof(buffer)/sizeof(WCHAR), deviceid_fmtW, enum_ctx->index); - device = allocate_information_node(buffer); - if (!device) - { - enum_ctx->hr = E_OUTOFMEMORY; - return FALSE; - } - - add_subcontainer(enum_ctx->cont, device); - - guid_to_string(buffer, guid); - enum_ctx->hr = add_bstr_property(device, szGuidDeviceID, buffer); - if (FAILED(enum_ctx->hr)) - return FALSE; - - enum_ctx->hr = add_bstr_property(device, szDescription, desc); - if (FAILED(enum_ctx->hr)) - return FALSE; - - enum_ctx->hr = add_bstr_property(device, szDriverPath, module); - if (FAILED(enum_ctx->hr)) - return FALSE; - - name = module; - if ((p = strrchrW(name, '\\'))) name = p + 1; - if ((p = strrchrW(name, '/'))) name = p + 1; - - enum_ctx->hr = add_bstr_property(device, szDriverName, name); - if (FAILED(enum_ctx->hr)) - return FALSE; - - enum_ctx->index++; - return TRUE; -} - static HRESULT build_directsound_tree(IDxDiagContainerImpl_Container *node) { static const WCHAR DxDiag_SoundDevices[] = {'D','x','D','i','a','g','_','S','o','u','n','d','D','e','v','i','c','e','s',0}; static const WCHAR DxDiag_SoundCaptureDevices[] = {'D','x','D','i','a','g','_','S','o','u','n','d','C','a','p','t','u','r','e','D','e','v','i','c','e','s',0}; - struct enum_context enum_ctx; IDxDiagContainerImpl_Container *cont; cont = allocate_information_node(DxDiag_SoundDevices); @@ -1429,28 +1196,12 @@ static HRESULT build_directsound_tree(IDxDiagContainerImpl_Container *node) add_subcontainer(node, cont); - enum_ctx.cont = cont; - enum_ctx.hr = S_OK; - enum_ctx.index = 0; - - DirectSoundEnumerateW(dsound_enum, &enum_ctx); - if (FAILED(enum_ctx.hr)) - return enum_ctx.hr; - cont = allocate_information_node(DxDiag_SoundCaptureDevices); if (!cont) return E_OUTOFMEMORY; add_subcontainer(node, cont); - enum_ctx.cont = cont; - enum_ctx.hr = S_OK; - enum_ctx.index = 0; - - DirectSoundCaptureEnumerateW(dsound_enum, &enum_ctx); - if (FAILED(enum_ctx.hr)) - return enum_ctx.hr; - return S_OK; } diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 20b10fbddb..e22e0ed4d5 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -36,7 +36,7 @@ reactos/dll/directx/wine/dmusic # Synced to WineStaging-2.9 reactos/dll/directx/wine/dplay # Synced to WineStaging-2.9 reactos/dll/directx/wine/dplayx # Synced to WineStaging-2.16 reactos/dll/directx/wine/dsound # Synced to Wine-1.3.29 -reactos/dll/directx/wine/dxdiagn # Synced to WineStaging-2.9 +reactos/dll/directx/wine/dxdiagn # Synced to Wine-3.0 reactos/dll/directx/wine/msdmo # Synced to WineStaging-2.9 reactos/dll/directx/wine/qedit # Synced to WineStaging-2.9 reactos/dll/directx/wine/quartz # Synced to WineStaging-2.16
6 years, 11 months
1
0
0
0
01/01: [DPLAYX_WINETEST] Sync with Wine 3.0. CORE-14225
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2fe88c2eddc589c66895e…
commit 2fe88c2eddc589c66895ef3a34bd9dffcacfc1bd Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sun Jan 21 22:28:27 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sun Jan 21 22:28:27 2018 +0100 [DPLAYX_WINETEST] Sync with Wine 3.0. CORE-14225 --- modules/rostests/winetests/dplayx/dplayx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/rostests/winetests/dplayx/dplayx.c b/modules/rostests/winetests/dplayx/dplayx.c index 0786d166a5..f4e7301da7 100644 --- a/modules/rostests/winetests/dplayx/dplayx.c +++ b/modules/rostests/winetests/dplayx/dplayx.c @@ -6951,7 +6951,7 @@ START_TEST(dplayx) if (!winetest_interactive) { skip("Run in interactive mode to run all dplayx tests.\n"); - return; + goto done; } trace("Running in interactive mode, tests will take a while\n"); @@ -6991,6 +6991,8 @@ START_TEST(dplayx) test_remote_data_replication(); test_host_migration(); +done: FreeLibrary(module); CoUninitialize(); + if (firewall_enabled) set_firewall(APP_REMOVE); }
6 years, 11 months
1
0
0
0
01/01: [DINPUT_WINETEST] Sync with Wine 3.0. CORE-14225
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c557dfb7b8959ca2af0e8…
commit c557dfb7b8959ca2af0e80d2f036100c3724ab67 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sun Jan 21 22:27:32 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sun Jan 21 22:27:32 2018 +0100 [DINPUT_WINETEST] Sync with Wine 3.0. CORE-14225 --- modules/rostests/winetests/dinput/mouse.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/rostests/winetests/dinput/mouse.c b/modules/rostests/winetests/dinput/mouse.c index 5c7209ccab..791300db2d 100644 --- a/modules/rostests/winetests/dinput/mouse.c +++ b/modules/rostests/winetests/dinput/mouse.c @@ -19,6 +19,7 @@ #include "precomp.h" + static const HRESULT SetCoop_null_window[16] = { E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_INVALIDARG, E_HANDLE, E_HANDLE, E_INVALIDARG, @@ -82,7 +83,6 @@ static void test_acquire(IDirectInputA *pDI, HWND hwnd) DIPROPDWORD di_op; DIDEVICEOBJECTDATA mouse_state; DWORD cnt; - MSG msg; int i; if (! SetForegroundWindow(hwnd)) @@ -121,12 +121,9 @@ static void test_acquire(IDirectInputA *pDI, HWND hwnd) hwnd2 = CreateWindowA("static", "Temporary", WS_VISIBLE, 10, 210, 200, 200, NULL, NULL, NULL, NULL); ok(hwnd2 != NULL, "CreateWindowA failed with %u\n", GetLastError()); - while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); hr = IDirectInputDevice_GetDeviceState(pMouse, sizeof(m_state), &m_state); ok(hr == DIERR_NOTACQUIRED, "GetDeviceState() should have failed: %08x\n", hr); - /* Workaround so we can test other things. Remove when Wine is fixed */ - IDirectInputDevice_Unacquire(pMouse); hr = IDirectInputDevice_Acquire(pMouse); ok(hr == DIERR_OTHERAPPHASPRIO, "Acquire() should have failed: %08x\n", hr);
6 years, 11 months
1
0
0
0
01/01: [DINPUT] Sync with Wine 3.0. CORE-14225
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0b35adc27414fd45e974f…
commit 0b35adc27414fd45e974f3a495ba775bc9a2c1e5 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sun Jan 21 22:26:41 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sun Jan 21 22:26:41 2018 +0100 [DINPUT] Sync with Wine 3.0. CORE-14225 --- dll/directx/wine/dinput/device.c | 8 ++++---- dll/directx/wine/dinput/dinput_main.c | 35 ++++++++++++++------------------ dll/directx/wine/dinput/dinput_private.h | 2 +- dll/directx/wine/dinput/joystick_osx.c | 8 +++++++- media/doc/README.WINE | 2 +- 5 files changed, 28 insertions(+), 27 deletions(-) diff --git a/dll/directx/wine/dinput/device.c b/dll/directx/wine/dinput/device.c index a67e24403c..d9f95b913b 100644 --- a/dll/directx/wine/dinput/device.c +++ b/dll/directx/wine/dinput/device.c @@ -976,9 +976,9 @@ HRESULT WINAPI IDirectInputDevice2WImpl_Acquire(LPDIRECTINPUTDEVICE8W iface) EnterCriticalSection(&This->crit); res = This->acquired ? S_FALSE : DI_OK; This->acquired = 1; - LeaveCriticalSection(&This->crit); if (res == DI_OK) - check_dinput_hooks(iface, TRUE); + check_dinput_hooks(iface); + LeaveCriticalSection(&This->crit); return res; } @@ -1004,9 +1004,9 @@ HRESULT WINAPI IDirectInputDevice2WImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface) EnterCriticalSection(&This->crit); res = !This->acquired ? DI_NOEFFECT : DI_OK; This->acquired = 0; - LeaveCriticalSection(&This->crit); if (res == DI_OK) - check_dinput_hooks(iface, FALSE); + check_dinput_hooks(iface); + LeaveCriticalSection(&This->crit); return res; } diff --git a/dll/directx/wine/dinput/dinput_main.c b/dll/directx/wine/dinput/dinput_main.c index e480af77ea..8b106808c5 100644 --- a/dll/directx/wine/dinput/dinput_main.c +++ b/dll/directx/wine/dinput/dinput_main.c @@ -1637,7 +1637,7 @@ static DWORD WINAPI hook_thread_proc(void *param) /* Force creation of the message queue */ PeekMessageW( &msg, 0, 0, 0, PM_NOREMOVE ); - SetEvent(param); + SetEvent(*(LPHANDLE)param); while (GetMessageW( &msg, 0, 0, 0 )) { @@ -1705,7 +1705,6 @@ static DWORD WINAPI hook_thread_proc(void *param) } static DWORD hook_thread_id; -static HANDLE hook_thread_event; static CRITICAL_SECTION_DEBUG dinput_critsect_debug = { @@ -1724,21 +1723,24 @@ static BOOL check_hook_thread(void) TRACE("IDirectInputs left: %d\n", list_count(&direct_input_list)); if (!list_empty(&direct_input_list) && !hook_thread) { - hook_thread_event = CreateEventW(NULL, FALSE, FALSE, NULL); - hook_thread = CreateThread(NULL, 0, hook_thread_proc, hook_thread_event, 0, &hook_thread_id); + HANDLE event; + + event = CreateEventW(NULL, FALSE, FALSE, NULL); + hook_thread = CreateThread(NULL, 0, hook_thread_proc, &event, 0, &hook_thread_id); + if (event && hook_thread) + { + HANDLE handles[2]; + handles[0] = event; + handles[1] = hook_thread; + WaitForMultipleObjects(2, handles, FALSE, INFINITE); + } LeaveCriticalSection(&dinput_hook_crit); + CloseHandle(event); } else if (list_empty(&direct_input_list) && hook_thread) { DWORD tid = hook_thread_id; - if (hook_thread_event) /* if thread is not started yet */ - { - WaitForSingleObject(hook_thread_event, INFINITE); - CloseHandle(hook_thread_event); - hook_thread_event = NULL; - } - hook_thread_id = 0; PostThreadMessageW(tid, WM_USER+0x10, 0, 0); LeaveCriticalSection(&dinput_hook_crit); @@ -1754,7 +1756,7 @@ static BOOL check_hook_thread(void) return hook_thread_id != 0; } -void check_dinput_hooks(LPDIRECTINPUTDEVICE8W iface, BOOL acquired) +void check_dinput_hooks(LPDIRECTINPUTDEVICE8W iface) { static HHOOK callwndproc_hook; static ULONG foreground_cnt; @@ -1764,7 +1766,7 @@ void check_dinput_hooks(LPDIRECTINPUTDEVICE8W iface, BOOL acquired) if (dev->dwCoopLevel & DISCL_FOREGROUND) { - if (acquired) + if (dev->acquired) foreground_cnt++; else foreground_cnt--; @@ -1779,13 +1781,6 @@ void check_dinput_hooks(LPDIRECTINPUTDEVICE8W iface, BOOL acquired) callwndproc_hook = NULL; } - if (hook_thread_event) /* if thread is not started yet */ - { - WaitForSingleObject(hook_thread_event, INFINITE); - CloseHandle(hook_thread_event); - hook_thread_event = NULL; - } - PostThreadMessageW( hook_thread_id, WM_USER+0x10, 1, 0 ); LeaveCriticalSection(&dinput_hook_crit); diff --git a/dll/directx/wine/dinput/dinput_private.h b/dll/directx/wine/dinput/dinput_private.h index 7a35be2c11..fb8c32ef17 100644 --- a/dll/directx/wine/dinput/dinput_private.h +++ b/dll/directx/wine/dinput/dinput_private.h @@ -85,7 +85,7 @@ extern const struct dinput_device joystick_linux_device DECLSPEC_HIDDEN; extern const struct dinput_device joystick_linuxinput_device DECLSPEC_HIDDEN; extern const struct dinput_device joystick_osx_device DECLSPEC_HIDDEN; -extern void check_dinput_hooks(LPDIRECTINPUTDEVICE8W, BOOL) DECLSPEC_HIDDEN; +extern void check_dinput_hooks(LPDIRECTINPUTDEVICE8W) DECLSPEC_HIDDEN; extern void check_dinput_events(void) DECLSPEC_HIDDEN; typedef int (*DI_EVENT_PROC)(LPDIRECTINPUTDEVICE8A, WPARAM, LPARAM); diff --git a/dll/directx/wine/dinput/joystick_osx.c b/dll/directx/wine/dinput/joystick_osx.c index e1358493cb..67b1d63320 100644 --- a/dll/directx/wine/dinput/joystick_osx.c +++ b/dll/directx/wine/dinput/joystick_osx.c @@ -640,14 +640,20 @@ static void get_osx_device_elements(JoystickImpl *device, int axis_map[8]) { IOHIDElementRef element = ( IOHIDElementRef ) CFArrayGetValueAtIndex( elements, idx ); int type = IOHIDElementGetType( element ); + int usage_page = IOHIDElementGetUsagePage( element ); TRACE("element %s\n", debugstr_element(element)); + if (usage_page >= kHIDPage_VendorDefinedStart) + { + /* vendor pages can repurpose type ids, resulting in incorrect case matches below (e.g. ds4 controllers) */ + continue; + } + switch(type) { case kIOHIDElementTypeInput_Button: { - int usage_page = IOHIDElementGetUsagePage( element ); TRACE("kIOHIDElementTypeInput_Button usage_page %d\n", usage_page); if (usage_page != kHIDPage_Button) { diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 5e73bf3471..20b10fbddb 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -30,7 +30,7 @@ reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to Wine-3.0 reactos/dll/directx/wine/d3dxof # Synced to WineStaging-2.9 reactos/dll/directx/wine/ddraw # Synced to Wine-3.0 reactos/dll/directx/wine/devenum # Synced to Wine-3.0 -reactos/dll/directx/wine/dinput # Synced to WineStaging-2.16 +reactos/dll/directx/wine/dinput # Synced to Wine-3.0 reactos/dll/directx/wine/dinput8 # Synced to WineStaging-2.9 reactos/dll/directx/wine/dmusic # Synced to WineStaging-2.9 reactos/dll/directx/wine/dplay # Synced to WineStaging-2.9
6 years, 11 months
1
0
0
0
01/01: [DEVENUM] Sync with Wine 3.0. CORE-14225
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=56fc552f24958f3e048ee…
commit 56fc552f24958f3e048ee250fb9b22d4ab74db1a Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sun Jan 21 22:25:39 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sun Jan 21 22:25:39 2018 +0100 [DEVENUM] Sync with Wine 3.0. CORE-14225 --- dll/directx/wine/devenum/createdevenum.c | 70 -------------------------------- media/doc/README.WINE | 2 +- 2 files changed, 1 insertion(+), 71 deletions(-) diff --git a/dll/directx/wine/devenum/createdevenum.c b/dll/directx/wine/devenum/createdevenum.c index 3cb58cadb3..a4d0df5a34 100644 --- a/dll/directx/wine/devenum/createdevenum.c +++ b/dll/directx/wine/devenum/createdevenum.c @@ -109,7 +109,6 @@ static BOOL IsSpecialCategory(const CLSID *clsid) IsEqualGUID(clsid, &CLSID_AudioInputDeviceCategory) || IsEqualGUID(clsid, &CLSID_VideoInputDeviceCategory) || IsEqualGUID(clsid, &CLSID_VideoCompressorCategory) || - IsEqualGUID(clsid, &CLSID_AudioCompressorCategory) || IsEqualGUID(clsid, &CLSID_MidiRendererCategory); } @@ -634,72 +633,6 @@ static void register_vfw_codecs(void) RegCloseKey(basekey); } -static BOOL WINAPI acm_driver_callback(HACMDRIVERID hadid, DWORD_PTR user, DWORD support) -{ - static const WCHAR CLSIDW[] = {'C','L','S','I','D',0}; - static const WCHAR AcmIdW[] = {'A','c','m','I','d',0}; - static const WCHAR FriendlyNameW[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0}; - static const WCHAR fmtW[] = {'%','u','%','s',0}; - - WCHAR acmwrapper_clsid_str[CHARS_IN_GUID], buffer[MAX_PATH]; - HKEY key, basekey = (HKEY) user; - ACMFORMATTAGDETAILSW format; - ACMDRIVERDETAILSW driver; - HACMDRIVER had; - DWORD i, res; - - StringFromGUID2(&CLSID_ACMWrapper, acmwrapper_clsid_str, sizeof(acmwrapper_clsid_str)/sizeof(WCHAR)); - - driver.cbStruct = sizeof(driver); - if (acmDriverDetailsW(hadid, &driver, 0) != MMSYSERR_NOERROR) - return TRUE; - - if (acmDriverOpen(&had, hadid, 0) != MMSYSERR_NOERROR) - return TRUE; - - for (i = 0; i < driver.cFormatTags; i++) - { - memset(&format, 0, sizeof(format)); - format.cbStruct = sizeof(format); - format.dwFormatTagIndex = i; - - if (acmFormatTagDetailsW(had, &format, ACM_FORMATTAGDETAILSF_INDEX) != MMSYSERR_NOERROR) - continue; - - snprintfW(buffer, sizeof(buffer)/sizeof(WCHAR), fmtW, format.dwFormatTag, format.szFormatTag); - - res = RegCreateKeyW(basekey, buffer, &key); - if (res != ERROR_SUCCESS) continue; - - RegSetValueExW(key, CLSIDW, 0, REG_SZ, (BYTE*)acmwrapper_clsid_str, sizeof(acmwrapper_clsid_str)); - RegSetValueExW(key, AcmIdW, 0, REG_DWORD, (BYTE*)&format.dwFormatTag, sizeof(DWORD)); - RegSetValueExW(key, FriendlyNameW, 0, REG_SZ, (BYTE*)format.szFormatTag, (strlenW(format.szFormatTag)+1)*sizeof(WCHAR)); - /* FIXME: Set FilterData values */ - - RegCloseKey(key); - } - - acmDriverClose(had, 0); - - return TRUE; -} - -static void register_acm_codecs(void) -{ - HKEY basekey; - - basekey = open_special_category_key(&CLSID_AudioCompressorCategory, TRUE); - if (!basekey) - { - ERR("Could not create key\n"); - return; - } - - acmDriverEnum(acm_driver_callback, (DWORD_PTR)basekey, 0); - - RegCloseKey(basekey); -} - static HANDLE DEVENUM_populate_handle; static const WCHAR DEVENUM_populate_handle_nameW[] = {'_','_','W','I','N','E','_', @@ -752,8 +685,6 @@ static HRESULT DEVENUM_CreateSpecialCategories(void) RegDeleteTreeW(basekey, path); if (SUCCEEDED(DEVENUM_GetCategoryKey(&CLSID_VideoCompressorCategory, &basekey, path, MAX_PATH))) RegDeleteTreeW(basekey, path); - if (SUCCEEDED(DEVENUM_GetCategoryKey(&CLSID_AudioCompressorCategory, &basekey, path, MAX_PATH))) - RegDeleteTreeW(basekey, path); rf2.dwVersion = 2; rf2.dwMerit = MERIT_PREFERRED; @@ -1035,7 +966,6 @@ static HRESULT DEVENUM_CreateSpecialCategories(void) IFilterMapper2_Release(pMapper); register_vfw_codecs(); - register_acm_codecs(); SetEvent(DEVENUM_populate_handle); return res; diff --git a/media/doc/README.WINE b/media/doc/README.WINE index cdd6f78ab4..5e73bf3471 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -29,7 +29,7 @@ reactos/dll/directx/wine/d3drm # Synced to WineStaging-2.16 reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to Wine-3.0 reactos/dll/directx/wine/d3dxof # Synced to WineStaging-2.9 reactos/dll/directx/wine/ddraw # Synced to Wine-3.0 -reactos/dll/directx/wine/devenum # Synced to WineStaging-2.9 +reactos/dll/directx/wine/devenum # Synced to Wine-3.0 reactos/dll/directx/wine/dinput # Synced to WineStaging-2.16 reactos/dll/directx/wine/dinput8 # Synced to WineStaging-2.9 reactos/dll/directx/wine/dmusic # Synced to WineStaging-2.9
6 years, 11 months
1
0
0
0
01/01: [D3DX9_24=>43] Sync with Wine 3.0. CORE-14225
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=65bd988c4043e0144547c…
commit 65bd988c4043e0144547cb7cdad55ac690ec2144 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sun Jan 21 22:24:27 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sun Jan 21 22:24:27 2018 +0100 [D3DX9_24=>43] Sync with Wine 3.0. CORE-14225 --- dll/directx/wine/d3dx9_36/d3dx9_36.spec | 6 +- dll/directx/wine/d3dx9_36/d3dx9_36_private.h | 1 + dll/directx/wine/d3dx9_36/effect.c | 113 +++-- dll/directx/wine/d3dx9_36/font.c | 246 +--------- dll/directx/wine/d3dx9_36/mesh.c | 159 ++++--- dll/directx/wine/d3dx9_36/preshader.c | 4 +- dll/directx/wine/d3dx9_36/shader.c | 644 +++++++++------------------ dll/directx/wine/d3dx9_36/skin.c | 108 +---- dll/directx/wine/d3dx9_36/sprite.c | 2 +- dll/directx/wine/d3dx9_36/surface.c | 203 +-------- dll/directx/wine/d3dx9_36/texture.c | 13 +- dll/directx/wine/d3dx9_36/util.c | 1 - dll/directx/wine/d3dx9_36/xfile.c | 4 +- media/doc/README.WINE | 2 +- 14 files changed, 398 insertions(+), 1108 deletions(-) diff --git a/dll/directx/wine/d3dx9_36/d3dx9_36.spec b/dll/directx/wine/d3dx9_36/d3dx9_36.spec index e073d6e537..e487aa12ec 100644 --- a/dll/directx/wine/d3dx9_36/d3dx9_36.spec +++ b/dll/directx/wine/d3dx9_36/d3dx9_36.spec @@ -22,9 +22,9 @@ @ stdcall -stub D3DXComputeIMTFromPerVertexSignal(ptr ptr long long long ptr ptr ptr) @ stdcall -stub D3DXComputeIMTFromSignal(ptr long long long long ptr ptr ptr ptr ptr) @ stdcall -stub D3DXComputeIMTFromTexture(ptr ptr long long ptr ptr ptr) -@ stdcall D3DXComputeNormalMap(ptr ptr ptr long long float) +@ stdcall -stub D3DXComputeNormalMap(ptr ptr ptr long long float) @ stdcall D3DXComputeNormals(ptr ptr) -@ stdcall D3DXComputeTangent(ptr long long long long ptr) +@ stdcall -stub D3DXComputeTangent(ptr long long long long ptr) @ stdcall -stub D3DXComputeTangentFrame(ptr long) @ stdcall D3DXComputeTangentFrameEx(ptr long long long long long long long long long ptr float float float ptr ptr) @ stdcall -stub D3DXConcatenateMeshes(ptr long long ptr ptr ptr ptr ptr) @@ -229,7 +229,7 @@ @ stdcall D3DXMatrixTranslation(ptr float float float) @ stdcall D3DXMatrixTranspose(ptr ptr) @ stdcall D3DXOptimizeFaces(ptr long long long ptr) -@ stdcall D3DXOptimizeVertices(ptr long long long ptr) +@ stdcall -stub D3DXOptimizeVertices(ptr long long long ptr) @ stdcall D3DXPlaneFromPointNormal(ptr ptr ptr) @ stdcall D3DXPlaneFromPoints(ptr ptr ptr ptr) @ stdcall D3DXPlaneIntersectLine(ptr ptr ptr ptr) diff --git a/dll/directx/wine/d3dx9_36/d3dx9_36_private.h b/dll/directx/wine/d3dx9_36/d3dx9_36_private.h index 72b1c9d38d..ddc38225e0 100644 --- a/dll/directx/wine/d3dx9_36/d3dx9_36_private.h +++ b/dll/directx/wine/d3dx9_36/d3dx9_36_private.h @@ -25,6 +25,7 @@ #include <config.h> #include <wine/port.h> +#include <assert.h> #include <stdarg.h> #define WIN32_NO_STATUS diff --git a/dll/directx/wine/d3dx9_36/effect.c b/dll/directx/wine/d3dx9_36/effect.c index 039ab42232..7a5975a706 100644 --- a/dll/directx/wine/d3dx9_36/effect.c +++ b/dll/directx/wine/d3dx9_36/effect.c @@ -20,7 +20,6 @@ #include "d3dx9_36_private.h" #include <d3dcompiler.h> -#include <initguid.h> /* Constants for special INT/FLOAT conversation */ #define INT_FLOAT_MULTI 255.0f @@ -100,6 +99,7 @@ struct d3dx_object UINT size; void *data; struct d3dx_parameter *param; + BOOL creation_failed; }; struct d3dx_state @@ -1140,21 +1140,17 @@ static HRESULT d3dx9_base_effect_get_pass_desc(struct d3dx9_base_effect *base, void *param_value; BOOL param_dirty; HRESULT hr; + void *data; if (FAILED(hr = d3dx9_get_param_value_ptr(pass, &pass->states[i], ¶m_value, ¶m, FALSE, ¶m_dirty))) return hr; - if (!param->object_id) - { - FIXME("Zero object ID in shader parameter.\n"); - return E_FAIL; - } - + data = param->object_id ? base->objects[param->object_id].data : NULL; if (state_table[state->operation].class == SC_VERTEXSHADER) - desc->pVertexShaderFunction = base->objects[param->object_id].data; + desc->pVertexShaderFunction = data; else - desc->pPixelShaderFunction = base->objects[param->object_id].data; + desc->pPixelShaderFunction = data; } } @@ -3938,48 +3934,59 @@ static D3DXHANDLE WINAPI ID3DXEffectImpl_GetCurrentTechnique(ID3DXEffect *iface) static HRESULT WINAPI ID3DXEffectImpl_ValidateTechnique(ID3DXEffect* iface, D3DXHANDLE technique) { - struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface); + struct ID3DXEffectImpl *effect = impl_from_ID3DXEffect(iface); + struct d3dx9_base_effect *base = &effect->base_effect; + struct d3dx_technique *tech = get_valid_technique(base, technique); + HRESULT ret = D3D_OK; + unsigned int i, j; - FIXME("(%p)->(%p): stub\n", This, technique); + FIXME("iface %p, technique %p semi-stub.\n", iface, technique); - return D3D_OK; -} + if (!tech) + { + ret = D3DERR_INVALIDCALL; + goto done; + } + for (i = 0; i < tech->pass_count; ++i) + { + struct d3dx_pass *pass = &tech->passes[i]; -static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect *iface, - D3DXHANDLE technique, D3DXHANDLE *next_technique) -{ - struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface); - struct d3dx9_base_effect *base_effect = &This->base_effect; - UINT i = 0; + for (j = 0; j < pass->state_count; ++j) + { + struct d3dx_state *state = &pass->states[j]; - TRACE("iface %p, technique %p, next_technique %p\n", iface, technique, next_technique); + if (state_table[state->operation].class == SC_VERTEXSHADER + || state_table[state->operation].class == SC_PIXELSHADER) + { + struct d3dx_parameter *param; + void *param_value; + BOOL param_dirty; + HRESULT hr; - if (!next_technique) - return D3DERR_INVALIDCALL; + if (FAILED(hr = d3dx9_get_param_value_ptr(pass, &pass->states[j], ¶m_value, ¶m, + FALSE, ¶m_dirty))) + return hr; - if (technique) - { - for (; i < base_effect->technique_count; i++) - { - if (technique == get_technique_handle(&base_effect->techniques[i])) - { - i++; /* Go to next technique */ - break; + if (param->object_id && base->objects[param->object_id].creation_failed) + { + ret = E_FAIL; + goto done; + } } } } +done: + TRACE("Returning %#x.\n", ret); + return ret; +} - for (; i < base_effect->technique_count; i++) - { - if (SUCCEEDED(iface->lpVtbl->ValidateTechnique(iface, get_technique_handle(&base_effect->techniques[i])))) - { - *next_technique = get_technique_handle(&base_effect->techniques[i]); - return D3D_OK; - } - } +static HRESULT WINAPI ID3DXEffectImpl_FindNextValidTechnique(ID3DXEffect* iface, D3DXHANDLE technique, D3DXHANDLE* next_technique) +{ + struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface); + + FIXME("(%p)->(%p, %p): stub\n", This, technique, next_technique); - *next_technique = NULL; - return S_FALSE; + return E_NOTIMPL; } static BOOL walk_parameter_dep(struct d3dx_parameter *param, walk_parameter_dep_func param_func, @@ -4340,7 +4347,6 @@ static HRESULT WINAPI ID3DXEffectImpl_ApplyParameterBlock(ID3DXEffect* iface, D3 return E_NOTIMPL; } -#if _D3DX9_VER >= 26 static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D3DXHANDLE parameter_block) { struct ID3DXEffectImpl *This = impl_from_ID3DXEffect(iface); @@ -4349,7 +4355,6 @@ static HRESULT WINAPI ID3DXEffectImpl_DeleteParameterBlock(ID3DXEffect* iface, D return E_NOTIMPL; } -#endif static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect *iface, struct IDirect3DDevice9 *device, struct ID3DXEffect **effect) @@ -4358,15 +4363,9 @@ static HRESULT WINAPI ID3DXEffectImpl_CloneEffect(ID3DXEffect *iface, FIXME("(%p)->(%p, %p): stub\n", This, device, effect); - if (!effect) - return D3DXERR_INVALIDDATA; - - iface->lpVtbl->AddRef(iface); - *effect = iface; - return S_OK; + return E_NOTIMPL; } -#if _D3DX9_VER >= 27 static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect *iface, D3DXHANDLE parameter, const void *data, UINT byte_offset, UINT bytes) { @@ -4375,7 +4374,6 @@ static HRESULT WINAPI ID3DXEffectImpl_SetRawValue(ID3DXEffect *iface, return E_NOTIMPL; } -#endif static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl = { @@ -4458,13 +4456,9 @@ static const struct ID3DXEffectVtbl ID3DXEffect_Vtbl = ID3DXEffectImpl_BeginParameterBlock, ID3DXEffectImpl_EndParameterBlock, ID3DXEffectImpl_ApplyParameterBlock, -#if _D3DX9_VER >= 26 ID3DXEffectImpl_DeleteParameterBlock, -#endif ID3DXEffectImpl_CloneEffect, -#if _D3DX9_VER >= 27 ID3DXEffectImpl_SetRawValue -#endif }; static inline struct ID3DXEffectCompilerImpl *impl_from_ID3DXEffectCompiler(ID3DXEffectCompiler *iface) @@ -5976,7 +5970,7 @@ static HRESULT d3dx9_create_object(struct d3dx9_base_effect *base, struct d3dx_o (IDirect3DVertexShader9 **)param->data))) { WARN("Failed to create vertex shader.\n"); - return D3D_OK; + object->creation_failed = TRUE; } break; case D3DXPT_PIXELSHADER: @@ -5984,7 +5978,7 @@ static HRESULT d3dx9_create_object(struct d3dx9_base_effect *base, struct d3dx_o (IDirect3DPixelShader9 **)param->data))) { WARN("Failed to create pixel shader.\n"); - return D3D_OK; + object->creation_failed = TRUE; } break; default: @@ -6457,6 +6451,11 @@ static HRESULT d3dx9_base_effect_init(struct d3dx9_base_effect *base, char *skip_constants_buffer = NULL; const char **skip_constants = NULL; unsigned int skip_constants_count = 0; +#if D3DX_SDK_VERSION <= 36 + UINT compile_flags = D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY; +#else + UINT compile_flags = 0; +#endif unsigned int i, j; TRACE("base %p, data %p, data_size %lu, effect %p, pool %p, skip_constants %s.\n", @@ -6473,7 +6472,7 @@ static HRESULT d3dx9_base_effect_init(struct d3dx9_base_effect *base, { TRACE("HLSL ASCII effect, trying to compile it.\n"); hr = D3DCompile(data, data_size, NULL, defines, include, - "main", "fx_2_0", 0, eflags, &bytecode, &temp_errors); + "main", "fx_2_0", compile_flags, eflags, &bytecode, &temp_errors); if (FAILED(hr)) { WARN("Failed to compile ASCII effect.\n"); diff --git a/dll/directx/wine/d3dx9_36/font.c b/dll/directx/wine/d3dx9_36/font.c index 231cdb1790..575e80d0bb 100644 --- a/dll/directx/wine/d3dx9_36/font.c +++ b/dll/directx/wine/d3dx9_36/font.c @@ -29,29 +29,8 @@ struct d3dx_font HDC hdc; HFONT hfont; - - UINT tex_width; - UINT tex_height; - IDirect3DTexture9 *texture; - HBITMAP bitmap; - BYTE *bits; }; -/* Returns the smallest power of 2 which is greater than or equal to num */ -static UINT make_pow2(UINT num) -{ - UINT result = 1; - - /* In the unlikely event somebody passes a large value, make sure we don't enter an infinite loop */ - if (num >= 0x80000000) - return 0x80000000; - - while (result < num) - result <<= 1; - - return result; -} - static inline struct d3dx_font *impl_from_ID3DXFont(ID3DXFont *iface) { return CONTAINING_RECORD(iface, struct d3dx_font, ID3DXFont_iface); @@ -78,27 +57,19 @@ static HRESULT WINAPI ID3DXFontImpl_QueryInterface(ID3DXFont *iface, REFIID riid static ULONG WINAPI ID3DXFontImpl_AddRef(ID3DXFont *iface) { struct d3dx_font *This = impl_from_ID3DXFont(iface); - ULONG ref = InterlockedIncrement(&This->ref); - + ULONG ref=InterlockedIncrement(&This->ref); TRACE("%p increasing refcount to %u\n", iface, ref); - return ref; } static ULONG WINAPI ID3DXFontImpl_Release(ID3DXFont *iface) { struct d3dx_font *This = impl_from_ID3DXFont(iface); - ULONG ref = InterlockedDecrement(&This->ref); + ULONG ref=InterlockedDecrement(&This->ref); TRACE("%p decreasing refcount to %u\n", iface, ref); - if (!ref) - { - if (This->texture) - { - IDirect3DTexture9_Release(This->texture); - DeleteObject(This->bitmap); - } + if(ref==0) { DeleteObject(This->hfont); DeleteDC(This->hdc); IDirect3DDevice9_Release(This->device); @@ -201,187 +172,17 @@ static HRESULT WINAPI ID3DXFontImpl_PreloadTextW(ID3DXFont *iface, const WCHAR * static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite, const char *string, INT count, RECT *rect, DWORD format, D3DCOLOR color) { - LPWSTR stringW; - INT countW, ret = 0; - - TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x\n", + FIXME("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x stub!\n", iface, sprite, debugstr_a(string), count, wine_dbgstr_rect(rect), format, color); - - if (!string || count == 0) - return 0; - - if (count < 0) - count = -1; - - countW = MultiByteToWideChar(CP_ACP, 0, string, count, NULL, 0); - stringW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR)); - if (stringW) - { - MultiByteToWideChar(CP_ACP, 0, string, count, stringW, countW); - ret = ID3DXFont_DrawTextW(iface, sprite, stringW, countW, rect, format, color); - HeapFree(GetProcessHeap(), 0, stringW); - } - - return ret; + return 1; } static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, const WCHAR *string, INT count, RECT *rect, DWORD format, D3DCOLOR color) { - struct d3dx_font *This = impl_from_ID3DXFont(iface); - RECT calc_rect; - INT height; - - TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x\n", + FIXME("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x stub!\n", iface, sprite, debugstr_w(string), count, wine_dbgstr_rect(rect), format, color); - - if (!string || count == 0) - return 0; - - if (count < 0) - count = lstrlenW(string); - - /* Strip terminating NULL characters */ - while (count > 0 && !string[count-1]) - count--; - - if (rect) - calc_rect = *rect; - - height = DrawTextW(This->hdc, string, count, &calc_rect, format | DT_CALCRECT); - - if (format & DT_CALCRECT) - { - if (rect) - *rect = calc_rect; - return height; - } - - if (format & DT_CENTER) - { - UINT new_width = calc_rect.right - calc_rect.left; - calc_rect.left = (rect->right + rect->left - new_width) / 2; - calc_rect.right = calc_rect.left + new_width; - } - - if (height && (calc_rect.left < calc_rect.right)) - { - D3DLOCKED_RECT locked_rect; - D3DXVECTOR3 position; - UINT text_width, text_height; - RECT text_rect; - ID3DXSprite *target = sprite; - HRESULT hr; - int i, j; - - /* Get rect position and dimensions */ - position.x = calc_rect.left; - position.y = calc_rect.top; - position.z = 0; - text_width = calc_rect.right - calc_rect.left; - text_height = calc_rect.bottom - calc_rect.top; - text_rect.left = 0; - text_rect.top = 0; - text_rect.right = text_width; - text_rect.bottom = text_height; - - /* We need to flush as it seems all draws in the begin/end sequence use only the latest updated texture */ - if (sprite) - ID3DXSprite_Flush(sprite); - - /* Extend texture and DIB section to contain text */ - if ((text_width > This->tex_width) || (text_height > This->tex_height)) - { - BITMAPINFOHEADER header; - - if (text_width > This->tex_width) - This->tex_width = make_pow2(text_width); - if (text_height > This->tex_height) - This->tex_height = make_pow2(text_height); - - if (This->texture) - { - IDirect3DTexture9_Release(This->texture); - DeleteObject(This->bitmap); - } - - hr = D3DXCreateTexture(This->device, This->tex_width, This->tex_height, 1, 0, - D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &This->texture); - if (FAILED(hr)) - { - This->texture = NULL; - return 0; - } - - header.biSize = sizeof(header); - header.biWidth = This->tex_width; - header.biHeight = -This->tex_height; - header.biPlanes = 1; - header.biBitCount = 32; - header.biCompression = BI_RGB; - header.biSizeImage = sizeof(DWORD) * This->tex_width * This->tex_height; - header.biXPelsPerMeter = 0; - header.biYPelsPerMeter = 0; - header.biClrUsed = 0; - header.biClrImportant = 0; - - This->bitmap = CreateDIBSection(This->hdc, (const BITMAPINFO*)&header, - DIB_RGB_COLORS, (void**)&This->bits, NULL, 0); - if (!This->bitmap) - { - IDirect3DTexture9_Release(This->texture); - This->texture = NULL; - return 0; - } - - SelectObject(This->hdc, This->bitmap); - } - - if (FAILED(IDirect3DTexture9_LockRect(This->texture, 0, &locked_rect, &text_rect, D3DLOCK_DISCARD))) - return 0; - - /* Clear rect */ - for (i = 0; i < text_height; i++) - memset(This->bits + i * This->tex_width * sizeof(DWORD), 0, - text_width * sizeof(DWORD)); - - DrawTextW(This->hdc, string, count, &text_rect, format); - - /* All RGB components are equal so take one as alpha and set RGB - * color to white, so it can be modulated with color parameter */ - for (i = 0; i < text_height; i++) - { - DWORD *src = (DWORD *)This->bits + i * This->tex_width; - DWORD *dst = (DWORD *)((BYTE *)locked_rect.pBits + i * locked_rect.Pitch); - for (j = 0; j < text_width; j++) - { - *dst++ = (*src++ << 24) | 0xFFFFFF; - } - } - - IDirect3DTexture9_UnlockRect(This->texture, 0); - - if (!sprite) - { - hr = D3DXCreateSprite(This->device, &target); - if (FAILED(hr)) - return 0; - ID3DXSprite_Begin(target, 0); - } - - hr = target->lpVtbl->Draw(target, This->texture, &text_rect, NULL, &position, color); - - if (!sprite) - { - ID3DXSprite_End(target); - ID3DXSprite_Release(target); - } - - if (FAILED(hr)) - return 0; - } - - return height; + return 1; } static HRESULT WINAPI ID3DXFontImpl_OnLostDevice(ID3DXFont *iface) @@ -495,55 +296,46 @@ HRESULT WINAPI D3DXCreateFontIndirectW(IDirect3DDevice9 *device, const D3DXFONT_ TRACE("(%p, %p, %p)\n", device, desc, font); - if (!device || !desc || !font) return D3DERR_INVALIDCALL; - - TRACE("desc: %d %d %d %d %d %d %d %d %d %s\n", desc->Height, desc->Width, desc->Weight, desc->MipLevels, desc->Italic, - desc->CharSet, desc->OutputPrecision, desc->Quality, desc->PitchAndFamily, debugstr_w(desc->FaceName)); + if( !device || !desc || !font ) return D3DERR_INVALIDCALL; - /* The device MUST support D3DFMT_A8R8G8B8 */ + /* the device MUST support D3DFMT_A8R8G8B8 */ IDirect3DDevice9_GetDirect3D(device, &d3d); IDirect3DDevice9_GetCreationParameters(device, &cpars); IDirect3DDevice9_GetDisplayMode(device, 0, &mode); hr = IDirect3D9_CheckDeviceFormat(d3d, cpars.AdapterOrdinal, cpars.DeviceType, mode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_A8R8G8B8); - if (FAILED(hr)) - { + if(FAILED(hr)) { IDirect3D9_Release(d3d); return D3DXERR_INVALIDDATA; } IDirect3D9_Release(d3d); - object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct d3dx_font)); - if (!object) - { - *font = NULL; + object = HeapAlloc(GetProcessHeap(), 0, sizeof(struct d3dx_font)); + if(object==NULL) { + *font=NULL; return E_OUTOFMEMORY; } object->ID3DXFont_iface.lpVtbl = &D3DXFont_Vtbl; - object->ref = 1; - object->device = device; - object->desc = *desc; + object->ref=1; + object->device=device; + object->desc=*desc; object->hdc = CreateCompatibleDC(NULL); - if (!object->hdc) - { + if( !object->hdc ) { HeapFree(GetProcessHeap(), 0, object); return D3DXERR_INVALIDDATA; } object->hfont = CreateFontW(desc->Height, desc->Width, 0, 0, desc->Weight, desc->Italic, FALSE, FALSE, desc->CharSet, desc->OutputPrecision, CLIP_DEFAULT_PRECIS, desc->Quality, desc->PitchAndFamily, desc->FaceName); - if (!object->hfont) - { + if( !object->hfont ) { DeleteDC(object->hdc); HeapFree(GetProcessHeap(), 0, object); return D3DXERR_INVALIDDATA; } SelectObject(object->hdc, object->hfont); - SetTextColor(object->hdc, 0x00ffffff); - SetBkColor(object->hdc, 0x00000000); IDirect3DDevice9_AddRef(device); - *font = &object->ID3DXFont_iface; + *font=&object->ID3DXFont_iface; return D3D_OK; } diff --git a/dll/directx/wine/d3dx9_36/mesh.c b/dll/directx/wine/d3dx9_36/mesh.c index 2f9615eed4..57b2aeb1a1 100644 --- a/dll/directx/wine/d3dx9_36/mesh.c +++ b/dll/directx/wine/d3dx9_36/mesh.c @@ -26,13 +26,10 @@ #include "d3dx9_36_private.h" -#include <assert.h> #ifdef HAVE_FLOAT_H # include <float.h> #endif -#undef MAKE_DDHRESULT -#include "dxfile.h" #include "rmxfguid.h" #include "rmxftmpl.h" @@ -1691,7 +1688,11 @@ static HRESULT WINAPI d3dx9_mesh_OptimizeInplace(ID3DXMesh *iface, DWORD flags, if (FAILED(hr)) goto cleanup; } else if (flags & D3DXMESHOPT_ATTRSORT) { if (!(flags & D3DXMESHOPT_IGNOREVERTS)) + { FIXME("D3DXMESHOPT_ATTRSORT vertex reordering not implemented.\n"); + hr = E_NOTIMPL; + goto cleanup; + } hr = iface->lpVtbl->LockAttributeBuffer(iface, 0, &attrib_buffer); if (FAILED(hr)) goto cleanup; @@ -3324,13 +3325,6 @@ static HRESULT parse_mesh(ID3DXFileData *filedata, struct mesh_data *mesh_data, goto end; } - if ((provide_flags & PROVIDE_SKININFO) && !mesh_data->skin_info) - { - hr = create_dummy_skin(&mesh_data->skin_info); - if (FAILED(hr)) - goto end; - } - hr = D3D_OK; end: @@ -4045,12 +4039,6 @@ HRESULT WINAPI D3DXFrameDestroy(D3DXFRAME *frame, ID3DXAllocateHierarchy *alloc_ return D3D_OK; } -D3DXFRAME* WINAPI D3DXFrameFind(const D3DXFRAME *frame_root, const char *name) -{ - FIXME("frame_root %p, name %s stub.\n", frame_root, debugstr_a(name)); - return NULL; -} - HRESULT WINAPI D3DXLoadMeshFromXA(const char *filename, DWORD options, struct IDirect3DDevice9 *device, struct ID3DXBuffer **adjacency, struct ID3DXBuffer **materials, struct ID3DXBuffer **effect_instances, DWORD *num_materials, struct ID3DXMesh **mesh) @@ -5171,7 +5159,7 @@ HRESULT WINAPI D3DXCreateTeapot(struct IDirect3DDevice9 *device, { FIXME("(%p, %p, %p): stub\n", device, mesh, adjacency); - return D3DXCreateSphere(device, 1.0f, 4, 4, mesh, adjacency); + return E_NOTIMPL; } HRESULT WINAPI D3DXCreateTextA(struct IDirect3DDevice9 *device, HDC hdc, const char *text, float deviation, @@ -7189,33 +7177,6 @@ cleanup: return hr; } - -/************************************************************************* - * D3DXOptimizeVertices (D3DX9_36.@) - */ -HRESULT WINAPI D3DXOptimizeVertices(const void *indices, UINT num_faces, - UINT num_vertices, BOOL indices_are_32bit, DWORD *vertex_remap) -{ - UINT i; - - FIXME("indices %p, num_faces %u, num_vertices %u, indices_are_32bit %#x, vertex_remap %p semi-stub.\n", - indices, num_faces, num_vertices, indices_are_32bit, vertex_remap); - - if (!vertex_remap) - { - WARN("vertex remap pointer is NULL.\n"); - return D3DERR_INVALIDCALL; - } - - for (i = 0; i < num_vertices; i++) - { - vertex_remap[i] = i; - } - - return D3D_OK; -} - - /************************************************************************* * D3DXOptimizeFaces (D3DX9_36.@) * @@ -7539,24 +7500,6 @@ done: return hr; } -/************************************************************************* - * D3DXComputeTangent (D3DX9_36.@) - */ -HRESULT WINAPI D3DXComputeTangent(ID3DXMesh *mesh, DWORD stage_idx, DWORD tangent_idx, - DWORD binorm_idx, DWORD wrap, const DWORD *adjacency) -{ - TRACE("mesh %p, stage_idx %d, tangent_idx %d, binorm_idx %d, wrap %d, adjacency %p.\n", - mesh, stage_idx, tangent_idx, binorm_idx, wrap, adjacency); - - return D3DXComputeTangentFrameEx( mesh, D3DDECLUSAGE_TEXCOORD, stage_idx, - ( binorm_idx == D3DX_DEFAULT ) ? D3DX_DEFAULT : D3DDECLUSAGE_BINORMAL, - binorm_idx, - ( tangent_idx == D3DX_DEFAULT ) ? D3DX_DEFAULT : D3DDECLUSAGE_TANGENT, - tangent_idx, D3DX_DEFAULT, 0, - ( wrap ? D3DXTANGENT_WRAP_UV : 0 ) | D3DXTANGENT_GENERATE_IN_PLACE | D3DXTANGENT_ORTHOGONALIZE_FROM_U, - adjacency, -1.01f, -0.01f, -1.01f, NULL, NULL); -} - /************************************************************************* * D3DXComputeNormals (D3DX9_36.@) */ @@ -7576,18 +7519,6 @@ HRESULT WINAPI D3DXComputeNormals(struct ID3DXBaseMesh *mesh, const DWORD *adjac adjacency, -1.01f, -0.01f, -1.01f, NULL, NULL); } -/************************************************************************* - * D3DXComputeNormalMap (D3DX9_36.@) - */ -HRESULT WINAPI D3DXComputeNormalMap(IDirect3DTexture9 *texture, IDirect3DTexture9 *src_texture, - const PALETTEENTRY *src_palette, DWORD flags, DWORD channel, FLOAT amplitude) -{ - FIXME("texture %p, src_texture %p, src_palette %p, flags %#x, channel %u, amplitude %f stub.\n", - texture, src_texture, src_palette, flags, channel, amplitude); - - return D3D_OK; -} - /************************************************************************* * D3DXIntersect (D3DX9_36.@) */ @@ -7617,3 +7548,83 @@ HRESULT WINAPI D3DXConvertMeshSubsetToSingleStrip(struct ID3DXBaseMesh *mesh_in, return E_NOTIMPL; } + +struct frame_node +{ + struct list entry; + D3DXFRAME *frame; +}; + +static BOOL queue_frame_node(struct list *queue, D3DXFRAME *frame) +{ + struct frame_node *node; + + if (!frame->pFrameFirstChild) + return TRUE; + + node = HeapAlloc(GetProcessHeap(), 0, sizeof(*node)); + if (!node) + return FALSE; + + node->frame = frame; + list_add_tail(queue, &node->entry); + + return TRUE; +} + +static void empty_frame_queue(struct list *queue) +{ + struct frame_node *cur, *cur2; + LIST_FOR_EACH_ENTRY_SAFE(cur, cur2, queue, struct frame_node, entry) + { + list_remove(&cur->entry); + HeapFree(GetProcessHeap(), 0, cur); + } +} + +D3DXFRAME * WINAPI D3DXFrameFind(const D3DXFRAME *root, const char *name) +{ + D3DXFRAME *found = NULL, *frame; + struct list queue; + + TRACE("root frame %p, name %s.\n", root, debugstr_a(name)); + + if (!root) + return NULL; + + list_init(&queue); + + frame = (D3DXFRAME *)root; + + for (;;) + { + struct frame_node *node; + + while (frame) + { + if ((name && frame->Name && !strcmp(frame->Name, name)) || (!name && !frame->Name)) + { + found = frame; + goto cleanup; + } + + if (!queue_frame_node(&queue, frame)) + goto cleanup; + + frame = frame->pFrameSibling; + } + + if (list_empty(&queue)) + break; + + node = LIST_ENTRY(list_head(&queue), struct frame_node, entry); + list_remove(&node->entry); + frame = node->frame->pFrameFirstChild; + HeapFree(GetProcessHeap(), 0, node); + } + +cleanup: + empty_frame_queue(&queue); + + return found; +} diff --git a/dll/directx/wine/d3dx9_36/preshader.c b/dll/directx/wine/d3dx9_36/preshader.c index a8a5858950..416f05b15a 100644 --- a/dll/directx/wine/d3dx9_36/preshader.c +++ b/dll/directx/wine/d3dx9_36/preshader.c @@ -18,8 +18,6 @@ #include "d3dx9_36_private.h" -#include <assert.h> - /* ReactOS FIXME: Insect */ #define fmin min #define fmax max @@ -537,6 +535,8 @@ static HRESULT get_ctab_constant_desc(ID3DXConstantTable *ctab, D3DXHANDLE hc, D if (!constant) { FIXME("Could not get constant desc.\n"); + if (constantinfo_reserved) + *constantinfo_reserved = 0; return D3DERR_INVALIDCALL; } *desc = constant->desc; diff --git a/dll/directx/wine/d3dx9_36/shader.c b/dll/directx/wine/d3dx9_36/shader.c index 71c0122481..48e49a2982 100644 --- a/dll/directx/wine/d3dx9_36/shader.c +++ b/dll/directx/wine/d3dx9_36/shader.c @@ -1,7 +1,6 @@ /* * Copyright 2008 Luis Busquets * Copyright 2009 Matteo Bruni - * Copyright 2010, 2013, 2016 Christian Costa * Copyright 2011 Travis Athougies * * This library is free software; you can redistribute it and/or @@ -441,41 +440,6 @@ HRESULT WINAPI D3DXCompileShader(const char *data, UINT length, const D3DXMACRO } } - /* Filter out D3DCompile warning messages that are not present with D3DCompileShader */ - if (SUCCEEDED(hr) && error_msgs && *error_msgs) - { - char *messages = ID3DXBuffer_GetBufferPointer(*error_msgs); - DWORD size = ID3DXBuffer_GetBufferSize(*error_msgs); - - /* Ensure messages are null terminated for safe processing */ - if (size) messages[size - 1] = 0; - - while (size > 1) - { - char *prev, *next; - - /* Warning has the form "warning X3206: ... implicit truncation of vector type" - but we only search for "X3206:" in case d3dcompiler_43 has localization */ - prev = next = strstr(messages, "X3206:"); - if (!prev) break; - - /* get pointer to beginning and end of current line */ - while (prev > messages && *(prev - 1) != '\n') prev--; - while (next < messages + size - 1 && *next != '\n') next++; - if (next < messages + size - 1 && *next == '\n') next++; - - memmove(prev, next, messages + size - next); - size -= (next - prev); - } - - /* Only return a buffer if the resulting string is not empty as some apps depend on that */ - if (size <= 1) - { - ID3DXBuffer_Release(*error_msgs); - *error_msgs = NULL; - } - } - return hr; } @@ -2177,334 +2141,10 @@ HRESULT WINAPI D3DXGetShaderSamplers(const DWORD *byte_code, const char **sample return D3D_OK; } - -static const char *decl_usage[] = { "position", "blendweight", "blendindices", "normal", "psize", "texcoord", - "tangent", "binormal", "tessfactor", "positiont", "color" }; - -static const char *tex_type[] = { "", "1d", "2d", "cube", "volume" }; - -static int add_modifier(char *buffer, DWORD param) -{ - char *buf = buffer; - DWORD dst_mod = param & D3DSP_DSTMOD_MASK; - - if (dst_mod & D3DSPDM_SATURATE) - buf += sprintf(buf, "_sat"); - if (dst_mod & D3DSPDM_PARTIALPRECISION) - buf += sprintf(buf, "_pp"); - if (dst_mod & D3DSPDM_MSAMPCENTROID) - buf += sprintf(buf, "_centroid"); - - return buf - buffer; -} - -static int add_register(char *buffer, DWORD param, BOOL dst, BOOL ps) -{ - char *buf = buffer; - DWORD reg_type = ((param & D3DSP_REGTYPE_MASK2) >> D3DSP_REGTYPE_SHIFT2) - | ((param & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT); - DWORD reg_num = param & D3DSP_REGNUM_MASK; - - if (reg_type == D3DSPR_INPUT) - buf += sprintf(buf, "v%d", reg_num); - else if (reg_type == D3DSPR_CONST) - buf += sprintf(buf, "c%d", reg_num); - else if (reg_type == D3DSPR_TEMP) - buf += sprintf(buf, "r%d", reg_num); - else if (reg_type == D3DSPR_ADDR) - buf += sprintf(buf, "%s%d", ps ? "t" : "a", reg_num); - else if (reg_type == D3DSPR_SAMPLER) - buf += sprintf(buf, "s%d", reg_num); - else if (reg_type == D3DSPR_RASTOUT) - buf += sprintf(buf, "oPos"); - else if (reg_type == D3DSPR_COLOROUT) - buf += sprintf(buf, "oC%d", reg_num); - else if (reg_type == D3DSPR_TEXCRDOUT) - buf += sprintf(buf, "oT%d", reg_num); - else if (reg_type == D3DSPR_ATTROUT) - buf += sprintf(buf, "oD%d", reg_num); - else - buf += sprintf(buf, "? (%d)", reg_type); - - if (dst) - { - if ((param & D3DSP_WRITEMASK_ALL) != D3DSP_WRITEMASK_ALL) - { - buf += sprintf(buf, ".%s%s%s%s", param & D3DSP_WRITEMASK_0 ? "x" : "", - param & D3DSP_WRITEMASK_1 ? "y" : "", - param & D3DSP_WRITEMASK_2 ? "z" : "", - param & D3DSP_WRITEMASK_3 ? "w" : ""); - } - } - else - { - if ((param & D3DVS_SWIZZLE_MASK) != D3DVS_NOSWIZZLE) - { - if ( ((param & D3DSP_SWIZZLE_MASK) == (D3DVS_X_X | D3DVS_Y_X | D3DVS_Z_X | D3DVS_W_X)) || - ((param & D3DSP_SWIZZLE_MASK) == (D3DVS_X_Y | D3DVS_Y_Y | D3DVS_Z_Y | D3DVS_W_Y)) || - ((param & D3DSP_SWIZZLE_MASK) == (D3DVS_X_Z | D3DVS_Y_Z | D3DVS_Z_Z | D3DVS_W_Z)) || - ((param & D3DSP_SWIZZLE_MASK) == (D3DVS_X_W | D3DVS_Y_W | D3DVS_Z_W | D3DVS_W_W)) ) - buf += sprintf(buf, ".%c", 'w' + (((param >> D3DVS_SWIZZLE_SHIFT) + 1) & 0x3)); - else - buf += sprintf(buf, ".%c%c%c%c", 'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+0)) + 1) & 0x3), - 'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+2)) + 1) & 0x3), - 'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+4)) + 1) & 0x3), - 'w' + (((param >> (D3DVS_SWIZZLE_SHIFT+6)) + 1) & 0x3)); - } - } - - return buf - buffer; -} - -struct instr_info -{ - DWORD opcode; - const char *name; - int length; - int (*function)(const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps); - WORD min_version; - WORD max_version; -}; - -static int instr_comment(const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps) -{ - *ptr += 1 + ((**ptr & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT); - return 0; -} - -static int instr_def(const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps) -{ - int len = sprintf(buffer, " def c%d, %g, %g, %g, %g\n", *(*ptr+1) & D3DSP_REGNUM_MASK, - (double)*(float*)(*ptr+2), (double)*(float*)(*ptr+3), - (double)*(float*)(*ptr+4), (double)*(float*)(*ptr+5)); - *ptr += 6; - return len; -} - -static int instr_dcl(const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps) -{ - DWORD param1 = *++*ptr; - DWORD param2 = *++*ptr; - DWORD usage = (param1 & D3DSP_DCL_USAGE_MASK) >> D3DSP_DCL_USAGE_SHIFT; - DWORD usage_index = (param1 & D3DSP_DCL_USAGEINDEX_MASK) >> D3DSP_DCL_USAGEINDEX_SHIFT; - char *buf = buffer; - - buf += sprintf(buf, " dcl"); - if (ps) - { - if (param1 & D3DSP_TEXTURETYPE_MASK) - buf += sprintf(buf, "_%s", (usage <= D3DSTT_VOLUME) ? - tex_type[(param1 & D3DSP_TEXTURETYPE_MASK) >> D3DSP_TEXTURETYPE_SHIFT] : "???"); - } - else - { - buf += sprintf(buf, "_%s", (usage <= D3DDECLUSAGE_COLOR) ? decl_usage[usage] : "???"); - if (usage_index) - buf += sprintf(buf, "%d", usage_index); - } - - buf += add_modifier(buf, param2); - buf += sprintf(buf, " "); - buf += add_register(buf, param2, TRUE, TRUE); - buf += sprintf(buf, "\n"); - (*ptr)++; - return buf - buffer; -} - -static int instr_generic(const struct instr_info *info, DWORD **ptr, char *buffer, BOOL ps) -{ - char *buf = buffer; - int j; - - buf += sprintf(buf, " %s", info->name); - (*ptr)++; - - if (info->length) - { - buf += add_modifier(buf, **ptr); - - for (j = 0; j < info->length; j++) - { - buf += sprintf(buf, "%s ", j ? "," : ""); - - if ((j != 0) && ((**ptr & D3DSP_SRCMOD_MASK) != D3DSPSM_NONE)) - { - if ((**ptr & D3DSP_SRCMOD_MASK) == D3DSPSM_NEG) - buf += sprintf(buf, "-"); - else - buf += sprintf(buf, "*"); - } - - buf += add_register(buf, **ptr, j == 0, ps); - - if (*(*ptr)++ & D3DVS_ADDRESSMODE_MASK) - { - buf += sprintf(buf, "["); - buf += add_register(buf, **ptr, FALSE, FALSE); - buf += sprintf(buf, "]"); - (*ptr)++; - } - } - } - buf += sprintf(buf, "\n"); - return buf - buffer; -} - -const struct instr_info instructions[] = -{ - { D3DSIO_NOP, "nop", 0, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_MOV, "mov", 2, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_ADD, "add", 3, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_SUB, "sub", 3, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_MAD, "mad", 4, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_MUL, "mul", 3, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_RCP, "rcp", 2, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_RSQ, "rsq", 2, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_DP3, "dp3", 3, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_DP4, "dp4", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 1.2 for PS */ - { D3DSIO_MIN, "min", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_MAX, "max", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_SLT, "slt", 3, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_SGE, "sge", 3, instr_generic, 0x0100, 0xFFFF }, /* VS only */ - { D3DSIO_EXP, "exp", 2, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_LOG, "log", 2, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_LIT, "lit", 2, instr_generic, 0x0100, 0xFFFF }, /* VS only */ - { D3DSIO_DST, "dst", 3, instr_generic, 0x0100, 0xFFFF }, /* VS only */ - { D3DSIO_LRP, "lrp", 4, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for VS */ - { D3DSIO_FRC, "frc", 2, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_M4x4, "m4x4", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_M4x3, "m4x3", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_M3x4, "m3x4", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_M3x3, "m3x3", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_M3x2, "m3x2", 3, instr_generic, 0x0100, 0xFFFF }, /* >= 2.0 for PS */ - { D3DSIO_CALL, "call", 1, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_CALLNZ, "callnz", 2, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_LOOP, "loop", 2, instr_generic, 0x0200, 0xFFFF }, /* >= 3.0 for PS */ - { D3DSIO_RET, "ret", 0, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_ENDLOOP, "endloop", 1, instr_generic, 0x0200, 0xFFFF }, /* >= 3.0 for PS */ - { D3DSIO_LABEL, "label", 1, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_DCL, "dcl", 1, instr_dcl, 0x0100, 0xFFFF }, - { D3DSIO_POW, "pow", 3, instr_generic, 0x0200, 0xFFFF }, - { D3DSIO_CRS, "crs", 3, instr_generic, 0x0200, 0xFFFF }, - { D3DSIO_SGN, "sgn", 4, instr_generic, 0x0200, 0xFFFF }, /* VS only */ - { D3DSIO_ABS, "abs", 2, instr_generic, 0x0200, 0xFFFF }, - { D3DSIO_NRM, "nrm", 2, instr_generic, 0x0200, 0xFFFF }, - { D3DSIO_SINCOS, "sincos", 4, instr_generic, 0x0200, 0x02FF }, - { D3DSIO_SINCOS, "sincos", 2, instr_generic, 0x0300, 0xFFFF }, - { D3DSIO_REP, "rep", 1, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_ENDREP, "endrep", 0, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_IF, "if", 1, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_IFC, "if_comp", 2, instr_generic, 0x0200, 0xFFFF }, - { D3DSIO_ELSE, "else", 0, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_ENDIF, "endif", 0, instr_generic, 0x0200, 0xFFFF }, /* >= 2.a for PS */ - { D3DSIO_BREAK, "break", 0, instr_generic, 0x0201, 0xFFFF }, - { D3DSIO_BREAKC, "break_comp", 2, instr_generic, 0x0201, 0xFFFF }, - { D3DSIO_MOVA, "mova", 2, instr_generic, 0x0200, 0xFFFF }, /* VS only */ - { D3DSIO_DEFB, "defb", 2, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_DEFI, "defi", 2, instr_generic, 0x0100, 0xFFFF }, - { D3DSIO_TEXCOORD, "texcoord", 1, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXCOORD, "texcrd", 2, instr_generic, 0x0104, 0x0104 }, /* PS only */ - { D3DSIO_TEXKILL, "texkill", 1, instr_generic, 0x0100, 0xFFFF }, /* PS only */ - { D3DSIO_TEX, "tex", 1, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEX, "texld", 2, instr_generic, 0x0104, 0x0104 }, /* PS only */ - { D3DSIO_TEX, "texld", 3, instr_generic, 0x0200, 0xFFFF }, /* PS only */ - { D3DSIO_TEXBEM, "texbem", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXBEML, "texbeml", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXREG2AR, "texreg2ar", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXREG2GB, "texreg2gb", 2, instr_generic, 0x0102, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x2PAD, "texm3x2pad", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x2TEX, "texm3x2tex", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x3PAD, "texm3x3pad", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x3TEX, "texm3x3tex", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x3DIFF, "texm3x3diff", 2, instr_generic, 0x0100, 0xFFFF }, /* PS only - Not documented */ - { D3DSIO_TEXM3x3SPEC, "texm3x3spec", 3, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x3VSPEC, "texm3x3vspec", 2, instr_generic, 0x0100, 0x0103 }, /* PS only */ - { D3DSIO_EXPP, "expp", 2, instr_generic, 0x0100, 0xFFFF }, /* VS only */ - { D3DSIO_LOGP, "logp", 2, instr_generic, 0x0100, 0xFFFF }, /* VS only */ - { D3DSIO_CND, "cnd", 4, instr_generic, 0x0100, 0x0104 }, /* PS only */ - { D3DSIO_DEF, "def", 5, instr_def, 0x0100, 0xFFFF }, - { D3DSIO_TEXREG2RGB, "texreg2rgb", 2, instr_generic, 0x0102, 0x0103 }, /* PS only */ - { D3DSIO_TEXDP3TEX, "texdp3tex", 2, instr_generic, 0x0102, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x2DEPTH, "texm3x2depth", 2, instr_generic, 0x0103, 0x0103 }, /* PS only */ - { D3DSIO_TEXDP3, "texdp3", 2, instr_generic, 0x0102, 0x0103 }, /* PS only */ - { D3DSIO_TEXM3x3, "texm3x3", 2, instr_generic, 0x0102, 0x0103 }, /* PS only */ - { D3DSIO_TEXDEPTH, "texdepth", 1, instr_generic, 0x0104, 0x0104 }, /* PS only */ - { D3DSIO_CMP, "cmp", 4, instr_generic, 0x0102, 0xFFFF }, /* PS only */ - { D3DSIO_BEM, "bem", 3, instr_generic, 0x0104, 0x0104 }, /* PS only */ - { D3DSIO_DP2ADD, "dp2add", 4, instr_generic, 0x0200, 0xFFFF }, /* PS only */ - { D3DSIO_DSX, "dsx", 2, instr_generic, 0x0201, 0xFFFF }, /* PS only */ - { D3DSIO_DSY, "dsy", 2, instr_generic, 0x0201, 0xFFFF }, /* PS only */ - { D3DSIO_TEXLDD, "texldd", 5, instr_generic, 0x0201, 0xFFFF }, /* PS only - not existing for 2.b */ - { D3DSIO_SETP, "setp_comp", 3, instr_generic, 0x0201, 0xFFFF }, - { D3DSIO_TEXLDL, "texldl", 3, instr_generic, 0x0300, 0xFFFF }, - { D3DSIO_BREAKP, "breakp", 1, instr_generic, 0x0201, 0xFFFF }, - { D3DSIO_PHASE, "phase", 0, instr_generic, 0x0104, 0x0104 }, /* PS only */ - { D3DSIO_COMMENT, "", 0, instr_comment, 0x0100, 0xFFFF } -}; - HRESULT WINAPI D3DXDisassembleShader(const DWORD *shader, BOOL colorcode, const char *comments, ID3DXBuffer **disassembly) { - DWORD *ptr = (DWORD *)shader; - char *buffer, *buf; - UINT capacity = 4096; - BOOL ps; - WORD version; - HRESULT hr; - - TRACE("%p %d %s %p\n", shader, colorcode, debugstr_a(comments), disassembly); - - if (!shader || !disassembly) - return D3DERR_INVALIDCALL; - - buf = buffer = HeapAlloc(GetProcessHeap(), 0, capacity); - if (!buffer) - return E_OUTOFMEMORY; - - ps = (*ptr >> 16) & 1; - version = *ptr & 0xFFFF; - buf += sprintf(buf, " %s_%d_%d\n", ps ? "ps" : "vs", D3DSHADER_VERSION_MAJOR(*ptr), D3DSHADER_VERSION_MINOR(*ptr)); - ptr++; - - while (*ptr != D3DSIO_END) - { - DWORD index; - - if ((buf - buffer + 128) > capacity) - { - UINT count = buf - buffer; - char *new_buffer = HeapReAlloc(GetProcessHeap(), 0, buffer, capacity * 2); - if (!new_buffer) - { - HeapFree(GetProcessHeap(), 0, buffer); - return E_OUTOFMEMORY; - } - capacity *= 2; - buffer = new_buffer; - buf = buffer + count; - } - - for (index = 0; index < sizeof(instructions)/sizeof(instructions[0]); index++) - if (((*ptr & D3DSI_OPCODE_MASK) == instructions[index].opcode) && - (version >= instructions[index].min_version) && (version <= instructions[index].max_version)) - break; - - if (index != sizeof(instructions)/sizeof(instructions[0])) - { - buf += instructions[index].function(&(instructions[index]), &ptr, buf, ps); - } - else - { - buf += sprintf(buf, " ??? (Unknown opcode %x)\n", *ptr); - while (*++ptr & (1u << 31)); - } - } - - hr = D3DXCreateBuffer(buf - buffer + 1 , disassembly); - if (SUCCEEDED(hr)) - strcpy(ID3DXBuffer_GetBufferPointer(*disassembly), buffer); - HeapFree(GetProcessHeap(), 0, buffer); - - return hr; + FIXME("%p %d %s %p: stub\n", shader, colorcode, debugstr_a(comments), disassembly); + return E_OUTOFMEMORY; } struct d3dx9_texture_shader @@ -2774,112 +2414,248 @@ HRESULT WINAPI D3DXCreateTextureShader(const DWORD *function, ID3DXTextureShader return D3D_OK; } -static const DWORD* skip_instruction(const DWORD *byte_code, UINT shader_model) +static unsigned int get_instr_length(const DWORD *byte_code, unsigned int major, unsigned int minor) { - TRACE("Shader model %u\n", shader_model); + unsigned int len = 0; - /* Handle all special instructions whose arguments may contain D3DSIO_DCL */ - if ((*byte_code & D3DSI_OPCODE_MASK) == D3DSIO_COMMENT) - { - byte_code += 1 + ((*byte_code & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT); - } - else if (shader_model >= 2) - { - byte_code += 1 + ((*byte_code & D3DSI_INSTLENGTH_MASK) >> D3DSI_INSTLENGTH_SHIFT); - } - else if ((*byte_code & D3DSI_OPCODE_MASK) == D3DSIO_DEF) - { - byte_code += 1 + 5; - } - else + if (major > 1) + return (*byte_code & D3DSI_INSTLENGTH_MASK) >> D3DSI_INSTLENGTH_SHIFT; + + switch (*byte_code & 0xffff) { - /* Handle remaining safe instructions */ - while (*++byte_code & (1u << 31)); + case D3DSIO_END: + ERR("Unexpected END token.\n"); + return 0; + case D3DSIO_COMMENT: + return (*byte_code & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT; + case D3DSIO_DEF: + case D3DSIO_DEFI: + return 5; + case D3DSIO_DEFB: + return 2; + default: + ++byte_code; + while (*byte_code & 0x80000000) + { + ++byte_code; + ++len; + } } - return byte_code; + return len; } -static UINT get_shader_semantics(const DWORD *byte_code, D3DXSEMANTIC *semantics, DWORD type) -{ - const DWORD *ptr = byte_code; - UINT shader_model = (*ptr >> 8) & 0xff; - UINT i = 0; +static HRESULT get_shader_semantics(const DWORD *byte_code, D3DXSEMANTIC *semantics, UINT *count, BOOL output) +{ + static const D3DDECLUSAGE regtype_usage[] = + { + D3DDECLUSAGE_COLOR, + D3DDECLUSAGE_COLOR, + 0, + D3DDECLUSAGE_TEXCOORD, + 0, + D3DDECLUSAGE_COLOR, + D3DDECLUSAGE_TEXCOORD, + 0, + 0, + D3DDECLUSAGE_DEPTH + }; + static const D3DDECLUSAGE rast_usage[] = + { + D3DDECLUSAGE_POSITION, + D3DDECLUSAGE_FOG, + D3DDECLUSAGE_PSIZE + }; + DWORD reg_type, usage, index, version_token = *byte_code; + BOOL is_ps = version_token >> 16 == 0xffff; + unsigned int major, minor, i = 0, j; + BYTE colors = 0, rastout = 0; + BOOL has_dcl, depth = 0; + WORD texcoords = 0; + + if ((version_token & 0xffff0000) != 0xfffe0000 && (version_token & 0xffff0000) != 0xffff0000) + return D3DXERR_INVALIDDATA; + + major = version_token >> 8 & 0xff; + minor = version_token & 0xff; - TRACE("Shader version: %#x\n", *ptr); - ptr++; + TRACE("%s shader, version %u.%u.\n", is_ps ? "Pixel" : "Vertex", major, minor); + ++byte_code; - while (*ptr != D3DSIO_END) + has_dcl = (!is_ps && (!output || major == 3)) || (is_ps && !output && major >= 2); + + while (*byte_code != D3DSIO_END) { - if (*ptr & (1u << 31)) - { - FIXME("Opcode expected but got %#x\n", *ptr); - return 0; - } - else if ((*ptr & D3DSI_OPCODE_MASK) == D3DSIO_DCL) + if (has_dcl && (*byte_code & 0xffff) == D3DSIO_DCL) { - DWORD param1 = *++ptr; - DWORD param2 = *++ptr; - DWORD usage = (param1 & D3DSP_DCL_USAGE_MASK) >> D3DSP_DCL_USAGE_SHIFT; - DWORD usage_index = (param1 & D3DSP_DCL_USAGEINDEX_MASK) >> D3DSP_DCL_USAGEINDEX_SHIFT; - DWORD reg_type = ((param2 & D3DSP_REGTYPE_MASK2) >> D3DSP_REGTYPE_SHIFT2) - | ((param2 & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT); + DWORD usage_token = byte_code[1]; + DWORD reg = byte_code[2]; - TRACE("D3DSIO_DCL param1: %#x, param2: %#x, usage: %u, usage_index: %u, reg_type: %u\n", - param1, param2, usage, usage_index, reg_type); + reg_type = ((reg & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT) + | ((reg & D3DSP_REGTYPE_MASK2) >> D3DSP_REGTYPE_SHIFT2); - if (reg_type == type) + if (is_ps && !output && major == 2) { + /* dcl with no explicit usage, look at the register. */ + reg_type = ((reg & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT) + | ((reg & D3DSP_REGTYPE_MASK2) >> D3DSP_REGTYPE_SHIFT2); + index = reg & D3DSP_REGNUM_MASK; + if (reg_type >= ARRAY_SIZE(regtype_usage)) + { + WARN("Invalid register type %u.\n", reg_type); + reg_type = 0; + } + usage = regtype_usage[reg_type]; if (semantics) { semantics[i].Usage = usage; - semantics[i].UsageIndex = usage_index; + semantics[i].UsageIndex = index; } - i++; + ++i; } + else if ((!output && reg_type == D3DSPR_INPUT) || (output && reg_type == D3DSPR_OUTPUT)) + { + if (semantics) + { + semantics[i].Usage = + (usage_token & D3DSP_DCL_USAGE_MASK) >> D3DSP_DCL_USAGE_SHIFT; + semantics[i].UsageIndex = + (usage_token & D3DSP_DCL_USAGEINDEX_MASK) >> D3DSP_DCL_USAGEINDEX_SHIFT; + } + ++i; + } + byte_code += 3; + } + else if (!has_dcl) + { + unsigned int len = get_instr_length(byte_code, major, minor) + 1; - ptr++; + switch (*byte_code & 0xffff) + { + case D3DSIO_COMMENT: + case D3DSIO_DEF: + case D3DSIO_DEFB: + case D3DSIO_DEFI: + byte_code += len; + break; + default: + ++byte_code; + while (*byte_code & 0x80000000) + { + reg_type = ((*byte_code & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT) + | ((*byte_code & D3DSP_REGTYPE_MASK2) >> D3DSP_REGTYPE_SHIFT2); + index = *byte_code & D3DSP_REGNUM_MASK; + + if ((reg_type == D3DSPR_TEMP && is_ps && major == 1) + || (reg_type == D3DSPR_INPUT && is_ps) + || (reg_type == D3DSPR_TEXTURE && is_ps && !output) + || reg_type == D3DSPR_RASTOUT + || reg_type == D3DSPR_ATTROUT + || reg_type == D3DSPR_OUTPUT + || reg_type == D3DSPR_DEPTHOUT) + { + if (reg_type == D3DSPR_RASTOUT) + rastout |= 1u << index; + else if (reg_type == D3DSPR_DEPTHOUT) + depth = TRUE; + else if (reg_type == D3DSPR_TEXTURE || reg_type == D3DSPR_OUTPUT) + texcoords |= 1u << index; + else + colors |= 1u << index; + } + ++byte_code; + } + } } else { - ptr = skip_instruction(ptr, shader_model); + byte_code += get_instr_length(byte_code, major, minor) + 1; } } - return i; -} - -HRESULT WINAPI D3DXGetShaderInputSemantics(const DWORD *byte_code, D3DXSEMANTIC *semantics, UINT *count) -{ - UINT nb_semantics; - - TRACE("byte_code %p, semantics %p, count %p\n", byte_code, semantics, count); - - if (!byte_code) - return D3DERR_INVALIDCALL; - - nb_semantics = get_shader_semantics(byte_code, semantics, D3DSPR_INPUT); + if (!has_dcl) + { + i = j = 0; + while (texcoords) + { + if (texcoords & 1) + { + if (semantics) + { + semantics[i].Usage = D3DDECLUSAGE_TEXCOORD; + semantics[i].UsageIndex = j; + } + ++i; + } + texcoords >>= 1; + ++j; + } + j = 0; + while (colors) + { + if (colors & 1) + { + if (semantics) + { + semantics[i].Usage = D3DDECLUSAGE_COLOR; + semantics[i].UsageIndex = j; + } + ++i; + } + colors >>= 1; + ++j; + } + j = 0; + while (rastout) + { + if (rastout & 1) + { + if (j >= ARRAY_SIZE(rast_usage)) + { + WARN("Invalid RASTOUT register index.\n"); + usage = 0; + } + else + { + usage = rast_usage[j]; + } + if (semantics) + { + semantics[i].Usage = usage; + semantics[i].UsageIndex = 0; + } + ++i; + } + rastout >>= 1; + ++j; + } + if (depth) + { + if (semantics) + { + semantics[i].Usage = D3DDECLUSAGE_DEPTH; + semantics[i].UsageIndex = 0; + } + ++i; + } + } if (count) - *count = nb_semantics; + *count = i; return D3D_OK; } - -HRESULT WINAPI D3DXGetShaderOutputSemantics(const DWORD *byte_code, D3DXSEMANTIC *semantics, UINT *count) +HRESULT WINAPI D3DXGetShaderInputSemantics(const DWORD *byte_code, D3DXSEMANTIC *semantics, UINT *count) { - UINT nb_semantics; - - TRACE("byte_code %p, semantics %p, count %p\n", byte_code, semantics, count); - - if (!byte_code) - return D3DERR_INVALIDCALL; + TRACE("byte_code %p, semantics %p, count %p.\n", byte_code, semantics, count); - nb_semantics = get_shader_semantics(byte_code, semantics, D3DSPR_OUTPUT); + return get_shader_semantics(byte_code, semantics, count, FALSE); +} - if (count) - *count = nb_semantics; +HRESULT WINAPI D3DXGetShaderOutputSemantics(const DWORD *byte_code, D3DXSEMANTIC *semantics, UINT *count) +{ + TRACE("byte_code %p, semantics %p, count %p.\n", byte_code, semantics, count); - return D3D_OK; + return get_shader_semantics(byte_code, semantics, count, TRUE); } diff --git a/dll/directx/wine/d3dx9_36/skin.c b/dll/directx/wine/d3dx9_36/skin.c index e3f8bf2572..309241ccc0 100644 --- a/dll/directx/wine/d3dx9_36/skin.c +++ b/dll/directx/wine/d3dx9_36/skin.c @@ -2,7 +2,6 @@ * Skin Info operations specific to D3DX9. * * Copyright (C) 2011 Dylan Smith - * Copyright (C) 2013 Christian Costa * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -90,7 +89,7 @@ static ULONG WINAPI d3dx9_skin_info_Release(ID3DXSkinInfo *iface) HeapFree(GetProcessHeap(), 0, skin->bones[i].vertices); HeapFree(GetProcessHeap(), 0, skin->bones[i].weights); } - if (skin->bones) HeapFree(GetProcessHeap(), 0, skin->bones); + HeapFree(GetProcessHeap(), 0, skin->bones); HeapFree(GetProcessHeap(), 0, skin); } @@ -373,89 +372,10 @@ static HRESULT WINAPI d3dx9_skin_info_GetDeclaration(ID3DXSkinInfo *iface, static HRESULT WINAPI d3dx9_skin_info_UpdateSkinnedMesh(ID3DXSkinInfo *iface, const D3DXMATRIX *bone_transforms, const D3DXMATRIX *bone_inv_transpose_transforms, const void *src_vertices, void *dst_vertices) { - struct d3dx9_skin_info *skin = impl_from_ID3DXSkinInfo(iface); - DWORD size = D3DXGetFVFVertexSize(skin->fvf); - DWORD i, j; - - TRACE("iface %p, bone_transforms %p, bone_inv_transpose_transforms %p, src_vertices %p, dst_vertices %p\n", - skin, bone_transforms, bone_inv_transpose_transforms, src_vertices, dst_vertices); - - if (bone_inv_transpose_transforms) - FIXME("Skinning vertices with two position elements not supported\n"); - - if ((skin->fvf & D3DFVF_POSITION_MASK) != D3DFVF_XYZ) { - FIXME("Vertex type %#x not supported\n", skin->fvf & D3DFVF_POSITION_MASK); - return E_FAIL; - } - - /* Reset all positions */ - for (i = 0; i < skin->num_vertices; i++) { - D3DXVECTOR3 *position = (D3DXVECTOR3*)((BYTE*)dst_vertices + size * i); - position->x = 0.0f; - position->y = 0.0f; - position->z = 0.0f; - } - - /* Update positions that are influenced by bones */ - for (i = 0; i < skin->num_bones; i++) { - D3DXMATRIX bone_inverse, matrix; - - D3DXMatrixInverse(&bone_inverse, NULL, &skin->bones[i].transform); - D3DXMatrixMultiply(&matrix, &bone_transforms[i], &bone_inverse); - D3DXMatrixMultiply(&matrix, &matrix, &skin->bones[i].transform); - - for (j = 0; j < skin->bones[i].num_influences; j++) { - D3DXVECTOR3 position; - D3DXVECTOR3 *position_src = (D3DXVECTOR3*)((BYTE*)src_vertices + size * skin->bones[i].vertices[j]); - D3DXVECTOR3 *position_dest = (D3DXVECTOR3*)((BYTE*)dst_vertices + size * skin->bones[i].vertices[j]); - FLOAT weight = skin->bones[i].weights[j]; - - D3DXVec3TransformCoord(&position, position_src, &matrix); - position_dest->x += weight * position.x; - position_dest->y += weight * position.y; - position_dest->z += weight * position.z; - } - } - - if (skin->fvf & D3DFVF_NORMAL) { - /* Reset all normals */ - for (i = 0; i < skin->num_vertices; i++) { - D3DXVECTOR3 *normal = (D3DXVECTOR3*)((BYTE*)dst_vertices + size * i + sizeof(D3DXVECTOR3)); - normal->x = 0.0f; - normal->y = 0.0f; - normal->z = 0.0f; - } - - /* Update normals that are influenced by bones */ - for (i = 0; i < skin->num_bones; i++) { - D3DXMATRIX bone_inverse, matrix; - - D3DXMatrixInverse(&bone_inverse, NULL, &skin->bones[i].transform); - D3DXMatrixMultiply(&matrix, &skin->bones[i].transform, &bone_transforms[i]); - - for (j = 0; j < skin->bones[i].num_influences; j++) { - D3DXVECTOR3 normal; - D3DXVECTOR3 *normal_src = (D3DXVECTOR3*)((BYTE*)src_vertices + size * skin->bones[i].vertices[j] + sizeof(D3DXVECTOR3)); - D3DXVECTOR3 *normal_dest = (D3DXVECTOR3*)((BYTE*)dst_vertices + size * skin->bones[i].vertices[j] + sizeof(D3DXVECTOR3)); - FLOAT weight = skin->bones[i].weights[j]; - - D3DXVec3TransformNormal(&normal, normal_src, &bone_inverse); - D3DXVec3TransformNormal(&normal, &normal, &matrix); - normal_dest->x += weight * normal.x; - normal_dest->y += weight * normal.y; - normal_dest->z += weight * normal.z; - } - } - - /* Normalize all normals that are influenced by bones*/ - for (i = 0; i < skin->num_vertices; i++) { - D3DXVECTOR3 *normal_dest = (D3DXVECTOR3*)((BYTE*)dst_vertices + (i * size) + sizeof(D3DXVECTOR3)); - if ((normal_dest->x != 0.0f) && (normal_dest->y != 0.0f) && (normal_dest->z != 0.0f)) - D3DXVec3Normalize(normal_dest, normal_dest); - } - } + FIXME("iface %p, bone_transforms %p, bone_inv_transpose_transforms %p, src_vertices %p, dst_vertices %p stub!\n", + iface, bone_transforms, bone_inv_transpose_transforms, src_vertices, dst_vertices); - return D3D_OK; + return E_NOTIMPL; } static HRESULT WINAPI d3dx9_skin_info_ConvertToBlendedMesh(ID3DXSkinInfo *iface, ID3DXMesh *mesh_in, @@ -570,23 +490,3 @@ HRESULT WINAPI D3DXCreateSkinInfoFVF(DWORD num_vertices, DWORD fvf, DWORD num_bo return D3DXCreateSkinInfo(num_vertices, declaration, num_bones, skin_info); } - -HRESULT create_dummy_skin(ID3DXSkinInfo **iface) -{ - static const D3DVERTEXELEMENT9 empty_declaration = D3DDECL_END(); - struct d3dx9_skin_info *object = NULL; - - object = HeapAlloc(GetProcessHeap(), 0, sizeof(*object)); - if (!object) return E_OUTOFMEMORY; - - object->ID3DXSkinInfo_iface.lpVtbl = &d3dx9_skin_info_vtbl; - object->ref = 1; - object->num_vertices = 0; - object->num_bones = 0; - object->vertex_declaration[0] = empty_declaration; - object->fvf = 0; - object->bones = NULL; - - *iface = &object->ID3DXSkinInfo_iface; - return D3D_OK; -} diff --git a/dll/directx/wine/d3dx9_36/sprite.c b/dll/directx/wine/d3dx9_36/sprite.c index 06b08c191a..ba7181b42e 100644 --- a/dll/directx/wine/d3dx9_36/sprite.c +++ b/dll/directx/wine/d3dx9_36/sprite.c @@ -204,7 +204,7 @@ static void set_states(struct d3dx9_sprite *object) IDirect3DDevice9_SetRenderState(object->device, D3DRS_ALPHATESTENABLE, object->alphacmp_caps); IDirect3DDevice9_SetRenderState(object->device, D3DRS_BLENDOP, D3DBLENDOP_ADD); IDirect3DDevice9_SetRenderState(object->device, D3DRS_CLIPPING, TRUE); - IDirect3DDevice9_SetRenderState(object->device, D3DRS_CLIPPLANEENABLE, FALSE); + IDirect3DDevice9_SetRenderState(object->device, D3DRS_CLIPPLANEENABLE, 0); IDirect3DDevice9_SetRenderState(object->device, D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED); IDirect3DDevice9_SetRenderState(object->device, D3DRS_CULLMODE, D3DCULL_NONE); diff --git a/dll/directx/wine/d3dx9_36/surface.c b/dll/directx/wine/d3dx9_36/surface.c index f9c4b579f5..321265fbaa 100644 --- a/dll/directx/wine/d3dx9_36/surface.c +++ b/dll/directx/wine/d3dx9_36/surface.c @@ -106,7 +106,6 @@ static const GUID *d3dformat_to_wic_guid(D3DFORMAT format) #define DDS_PF_RGB 0x40 #define DDS_PF_YUV 0x200 #define DDS_PF_LUMINANCE 0x20000 -#define DDS_PF_BUMPLUMINANCE 0x40000 #define DDS_PF_BUMPDUDV 0x80000 struct dds_pixel_format @@ -262,17 +261,6 @@ static D3DFORMAT dds_bump_to_d3dformat(const struct dds_pixel_format *pixel_form return D3DFMT_UNKNOWN; } -static D3DFORMAT dds_bump_luminance_to_d3dformat(const struct dds_pixel_format *pixel_format) -{ - if (pixel_format->bpp == 32 && pixel_format->rmask == 0x000000ff && pixel_format->gmask == 0x0000ff00 - && pixel_format->bmask == 0x00ff0000) - return D3DFMT_X8L8V8U8; - - WARN("Unknown bump pixel format (%u, %#x, %#x, %#x, %#x)\n", pixel_format->bpp, - pixel_format->rmask, pixel_format->gmask, pixel_format->bmask, pixel_format->amask); - return D3DFMT_UNKNOWN; -} - static D3DFORMAT dds_pixel_format_to_d3dformat(const struct dds_pixel_format *pixel_format) { TRACE("pixel_format: size %u, flags %#x, fourcc %#x, bpp %u.\n", pixel_format->size, @@ -290,8 +278,6 @@ static D3DFORMAT dds_pixel_format_to_d3dformat(const struct dds_pixel_format *pi return dds_alpha_to_d3dformat(pixel_format); if (pixel_format->flags & DDS_PF_BUMPDUDV) return dds_bump_to_d3dformat(pixel_format); - if (pixel_format->flags & DDS_PF_BUMPLUMINANCE) - return dds_bump_luminance_to_d3dformat(pixel_format); WARN("Unknown pixel format (flags %#x, fourcc %#x, bpp %u, r %#x, g %#x, b %#x, a %#x)\n", pixel_format->flags, pixel_format->fourcc, pixel_format->bpp, @@ -322,14 +308,6 @@ static HRESULT d3dformat_to_dds_pixel_format(struct dds_pixel_format *pixel_form } } - /* Reuse dds_fourcc_to_d3dformat as D3DFORMAT and FOURCC are DWORD with same values */ - if (dds_fourcc_to_d3dformat(d3dformat) != D3DFMT_UNKNOWN) - { - pixel_format->flags |= DDS_PF_FOURCC; - pixel_format->fourcc = d3dformat; - return D3D_OK; - } - WARN("Unknown pixel format %#x\n", d3dformat); return E_NOTIMPL; } @@ -538,68 +516,6 @@ static HRESULT save_dds_surface_to_memory(ID3DXBuffer **dst_buffer, IDirect3DSur return D3D_OK; } -static HRESULT get_surface(D3DRESOURCETYPE type, struct IDirect3DBaseTexture9 *tex, - int face, UINT level, struct IDirect3DSurface9 **surf) -{ - switch (type) - { - case D3DRTYPE_TEXTURE: - return IDirect3DTexture9_GetSurfaceLevel((IDirect3DTexture9*) tex, level, surf); - case D3DRTYPE_CUBETEXTURE: - return IDirect3DCubeTexture9_GetCubeMapSurface((IDirect3DCubeTexture9*) tex, face, level, surf); - default: - ERR("Unexpected texture type\n"); - return E_NOTIMPL; - } -} - -HRESULT save_dds_texture_to_memory(ID3DXBuffer **dst_buffer, IDirect3DBaseTexture9 *src_texture, const PALETTEENTRY *src_palette) -{ - HRESULT hr; - D3DRESOURCETYPE type; - UINT mip_levels; - IDirect3DSurface9 *surface; - - type = IDirect3DBaseTexture9_GetType(src_texture); - - if ((type != D3DRTYPE_TEXTURE) && (type != D3DRTYPE_CUBETEXTURE) && (type != D3DRTYPE_VOLUMETEXTURE)) - return D3DERR_INVALIDCALL; - - if (type == D3DRTYPE_CUBETEXTURE) - { - FIXME("Cube texture not supported yet\n"); - return E_NOTIMPL; - } - else if (type == D3DRTYPE_VOLUMETEXTURE) - { - FIXME("Volume texture not supported yet\n"); - return E_NOTIMPL; - } - - mip_levels = IDirect3DTexture9_GetLevelCount(src_texture); - - if (mip_levels > 1) - { - FIXME("Mipmap not supported yet\n"); - return E_NOTIMPL; - } - - if (src_palette) - { - FIXME("Saving surfaces with palettized pixel formats not implemented yet\n"); - return E_NOTIMPL; - } - - hr = get_surface(type, src_texture, D3DCUBEMAP_FACE_POSITIVE_X, 0, &surface); - - if (SUCCEEDED(hr)) - { - hr = save_dds_surface_to_memory(dst_buffer, surface, NULL); - IDirect3DSurface9_Release(surface); - } - - return hr; -} HRESULT load_volume_from_dds(IDirect3DVolume9 *dst_volume, const PALETTEENTRY *dst_palette, const D3DBOX *dst_box, const void *src_data, const D3DBOX *src_box, DWORD filter, D3DCOLOR color_key, const D3DXIMAGE_INFO *src_info) @@ -967,24 +883,6 @@ HRESULT WINAPI D3DXGetImageInfoFromFileInMemory(const void *data, UINT datasize, } } - /* For 32 bpp BMP, windowscodecs.dll never returns a format with alpha while - * d3dx9_xx.dll returns one if at least 1 pixel has a non zero alpha component */ - if (SUCCEEDED(hr) && (info->Format == D3DFMT_X8R8G8B8) && (info->ImageFileFormat == D3DXIFF_BMP)) { - DWORD size = sizeof(DWORD) * info->Width * info->Height; - BYTE *buffer = HeapAlloc(GetProcessHeap(), 0, size); - hr = IWICBitmapFrameDecode_CopyPixels(frame, NULL, sizeof(DWORD) * info->Width, size, buffer); - if (SUCCEEDED(hr)) { - DWORD i; - for (i = 0; i < info->Width * info->Height; i++) { - if (buffer[i*4+3]) { - info->Format = D3DFMT_A8R8G8B8; - break; - } - } - } - HeapFree(GetProcessHeap(), 0, buffer); - } - if (frame) IWICBitmapFrameDecode_Release(frame); @@ -1813,27 +1711,6 @@ void point_filter_argb_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slic } } -typedef BOOL (*dxtn_conversion_func)(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, - enum wined3d_format_id format, unsigned int w, unsigned int h); - -static dxtn_conversion_func get_dxtn_conversion_func(D3DFORMAT format, BOOL encode) -{ - switch (format) - { - case D3DFMT_DXT1: - if (!wined3d_dxtn_supported()) return NULL; - return encode ? wined3d_dxt1_encode : wined3d_dxt1_decode; - case D3DFMT_DXT3: - if (!wined3d_dxtn_supported()) return NULL; - return encode ? wined3d_dxt3_encode : wined3d_dxt3_decode; - case D3DFMT_DXT5: - if (!wined3d_dxtn_supported()) return NULL; - return encode ? wined3d_dxt5_encode : wined3d_dxt5_decode; - default: - return NULL; - } -} - /************************************************************ * D3DXLoadSurfaceFromMemory * @@ -1875,7 +1752,6 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, D3DSURFACE_DESC surfdesc; D3DLOCKED_RECT lockrect; struct volume src_size, dst_size; - HRESULT ret = D3D_OK; TRACE("(%p, %p, %s, %p, %#x, %u, %p, %s, %#x, 0x%08x)\n", dst_surface, dst_palette, wine_dbgstr_rect(dst_rect), src_memory, src_format, @@ -1957,15 +1833,8 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, } else /* Stretching or format conversion. */ { - dxtn_conversion_func pre_convert, post_convert; - void *tmp_src_memory = NULL, *tmp_dst_memory = NULL; - UINT tmp_src_pitch, tmp_dst_pitch; - - pre_convert = get_dxtn_conversion_func(srcformatdesc->format, FALSE); - post_convert = get_dxtn_conversion_func(destformatdesc->format, TRUE); - - if ((!pre_convert && !is_conversion_from_supported(srcformatdesc)) || - (!post_convert && !is_conversion_to_supported(destformatdesc))) + if (!is_conversion_from_supported(srcformatdesc) + || !is_conversion_to_supported(destformatdesc)) { FIXME("Unsupported format conversion %#x -> %#x.\n", src_format, surfdesc.Format); return E_NOTIMPL; @@ -1974,52 +1843,10 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, if (FAILED(IDirect3DSurface9_LockRect(dst_surface, &lockrect, dst_rect, 0))) return D3DXERR_INVALIDDATA; - /* handle pre-conversion */ - if (pre_convert) - { - tmp_src_memory = HeapAlloc(GetProcessHeap(), 0, src_size.width * src_size.height * sizeof(DWORD)); - if (!tmp_src_memory) - { - ret = E_OUTOFMEMORY; - goto error; - } - tmp_src_pitch = src_size.width * sizeof(DWORD); - if (!pre_convert(src_memory, tmp_src_memory, src_pitch, tmp_src_pitch, - WINED3DFMT_B8G8R8A8_UNORM, src_size.width, src_size.height)) - { - ret = E_FAIL; - goto error; - } - srcformatdesc = get_format_info(D3DFMT_A8R8G8B8); - } - else - { - tmp_src_memory = (void *)src_memory; - tmp_src_pitch = src_pitch; - } - - /* handle post-conversion */ - if (post_convert) - { - tmp_dst_memory = HeapAlloc(GetProcessHeap(), 0, dst_size.width * dst_size.height * sizeof(DWORD)); - if (!tmp_dst_memory) - { - ret = E_OUTOFMEMORY; - goto error; - } - tmp_dst_pitch = dst_size.width * sizeof(DWORD); - destformatdesc = get_format_info(D3DFMT_A8R8G8B8); - } - else - { - tmp_dst_memory = lockrect.pBits; - tmp_dst_pitch = lockrect.Pitch; - } - if ((filter & 0xf) == D3DX_FILTER_NONE) { - convert_argb_pixels(tmp_src_memory, tmp_src_pitch, 0, &src_size, srcformatdesc, - tmp_dst_memory, tmp_dst_pitch, 0, &dst_size, destformatdesc, color_key, src_palette); + convert_argb_pixels(src_memory, src_pitch, 0, &src_size, srcformatdesc, + lockrect.pBits, lockrect.Pitch, 0, &dst_size, destformatdesc, color_key, src_palette); } else /* if ((filter & 0xf) == D3DX_FILTER_POINT) */ { @@ -2028,30 +1855,14 @@ HRESULT WINAPI D3DXLoadSurfaceFromMemory(IDirect3DSurface9 *dst_surface, /* Always apply a point filter until D3DX_FILTER_LINEAR, * D3DX_FILTER_TRIANGLE and D3DX_FILTER_BOX are implemented. */ - point_filter_argb_pixels(tmp_src_memory, tmp_src_pitch, 0, &src_size, srcformatdesc, - tmp_dst_memory, tmp_dst_pitch, 0, &dst_size, destformatdesc, color_key, src_palette); + point_filter_argb_pixels(src_memory, src_pitch, 0, &src_size, srcformatdesc, + lockrect.pBits, lockrect.Pitch, 0, &dst_size, destformatdesc, color_key, src_palette); } - /* handle post-conversion */ - if (post_convert) - { - if (!post_convert(tmp_dst_memory, lockrect.pBits, tmp_dst_pitch, lockrect.Pitch, - WINED3DFMT_B8G8R8A8_UNORM, dst_size.width, dst_size.height)) - { - ret = E_FAIL; - goto error; - } - } - -error: - if (pre_convert) - HeapFree(GetProcessHeap(), 0, tmp_src_memory); - if (post_convert) - HeapFree(GetProcessHeap(), 0, tmp_dst_memory); IDirect3DSurface9_UnlockRect(dst_surface); } - return ret; + return D3D_OK; } /************************************************************ diff --git a/dll/directx/wine/d3dx9_36/texture.c b/dll/directx/wine/d3dx9_36/texture.c index d33b4634a5..f4e3231483 100644 --- a/dll/directx/wine/d3dx9_36/texture.c +++ b/dll/directx/wine/d3dx9_36/texture.c @@ -330,10 +330,10 @@ HRESULT WINAPI D3DXCheckTextureRequirements(struct IDirect3DDevice9 *device, UIN if (fmt->block_width != 1 || fmt->block_height != 1) { - if (w % fmt->block_width) - w += fmt->block_width - w % fmt->block_width; - if (h % fmt->block_height) - h += fmt->block_height - h % fmt->block_height; + if (w < fmt->block_width) + w = fmt->block_width; + if (h < fmt->block_height) + h = fmt->block_height; } if ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) && (!is_pow2(w))) @@ -1887,7 +1887,10 @@ HRESULT WINAPI D3DXSaveTextureToFileInMemory(ID3DXBuffer **dst_buffer, D3DXIMAGE if (!dst_buffer || !src_texture) return D3DERR_INVALIDCALL; if (file_format == D3DXIFF_DDS) - return save_dds_texture_to_memory(dst_buffer, src_texture, src_palette); + { + FIXME("DDS file format isn't supported yet\n"); + return E_NOTIMPL; + } type = IDirect3DBaseTexture9_GetType(src_texture); switch (type) diff --git a/dll/directx/wine/d3dx9_36/util.c b/dll/directx/wine/d3dx9_36/util.c index 90b4705c03..47f9637d83 100644 --- a/dll/directx/wine/d3dx9_36/util.c +++ b/dll/directx/wine/d3dx9_36/util.c @@ -85,7 +85,6 @@ static const struct pixel_format_desc formats[] = {D3DFMT_G32R32F, { 0, 32, 32, 0}, { 0, 0, 32, 0}, 8, 1, 1, 8, FORMAT_ARGBF, NULL, NULL }, {D3DFMT_A32B32G32R32F, {32, 32, 32, 32}, {96, 0, 32, 64}, 16, 1, 1, 16, FORMAT_ARGBF, NULL, NULL }, {D3DFMT_P8, { 8, 8, 8, 8}, { 0, 0, 0, 0}, 1, 1, 1, 1, FORMAT_INDEX, NULL, index_to_rgba}, - {D3DFMT_X8L8V8U8, { 0, 8, 8, 8}, { 0, 0, 8, 16}, 4, 1, 1, 4, FORMAT_ARGB, NULL, NULL }, /* marks last element */ {D3DFMT_UNKNOWN, { 0, 0, 0, 0}, { 0, 0, 0, 0}, 0, 1, 1, 0, FORMAT_UNKNOWN, NULL, NULL }, }; diff --git a/dll/directx/wine/d3dx9_36/xfile.c b/dll/directx/wine/d3dx9_36/xfile.c index f8c5a2d98d..795b7bc3ff 100644 --- a/dll/directx/wine/d3dx9_36/xfile.c +++ b/dll/directx/wine/d3dx9_36/xfile.c @@ -19,9 +19,7 @@ #include "d3dx9_36_private.h" -#include "d3dx9xof.h" -#undef MAKE_DDHRESULT -#include "dxfile.h" +#include <dxfile.h> static HRESULT error_dxfile_to_d3dxfile(HRESULT error) { diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 98995a1c54..cdd6f78ab4 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -26,7 +26,7 @@ reactos/dll/directx/wine/d3d8 # Synced to Wine-3.0 reactos/dll/directx/wine/d3d9 # Synced to Wine-3.0 reactos/dll/directx/wine/d3dcompiler_43 # Synced to Wine-3.0 reactos/dll/directx/wine/d3drm # Synced to WineStaging-2.16 -reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to WineStaging-2.16 +reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to Wine-3.0 reactos/dll/directx/wine/d3dxof # Synced to WineStaging-2.9 reactos/dll/directx/wine/ddraw # Synced to Wine-3.0 reactos/dll/directx/wine/devenum # Synced to WineStaging-2.9
6 years, 11 months
1
0
0
0
01/01: [D3DCOMPILER_43] Sync with Wine 3.0. CORE-14225
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a18d16dcb59287e218c6d…
commit a18d16dcb59287e218c6d57754d83457fe823b46 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sun Jan 21 22:22:20 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sun Jan 21 22:22:20 2018 +0100 [D3DCOMPILER_43] Sync with Wine 3.0. CORE-14225 --- dll/directx/wine/d3dcompiler_43/hlsl.tab.c | 743 ++++++++++++++--------------- dll/directx/wine/d3dcompiler_43/hlsl.tab.h | 10 +- dll/directx/wine/d3dcompiler_43/hlsl.y | 6 +- media/doc/README.WINE | 2 +- 4 files changed, 371 insertions(+), 390 deletions(-) diff --git a/dll/directx/wine/d3dcompiler_43/hlsl.tab.c b/dll/directx/wine/d3dcompiler_43/hlsl.tab.c index 1252270035..5b6d4d7f6b 100644 --- a/dll/directx/wine/d3dcompiler_43/hlsl.tab.c +++ b/dll/directx/wine/d3dcompiler_43/hlsl.tab.c @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 3.0.2. */ +/* A Bison parser, made by GNU Bison 3.0. */ /* Bison implementation for Yacc-like parsers in C @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.0.2" +#define YYBISON_VERSION "3.0" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -73,6 +73,7 @@ /* Copy the first part of user declarations. */ #line 21 "hlsl.y" /* yacc.c:339 */ + #include "d3dcompiler_private.h" WINE_DEFAULT_DEBUG_CHANNEL(hlsl_parser); @@ -950,13 +951,13 @@ static const struct hlsl_ir_function_decl *get_overloaded_func(struct wine_rb_tr } -#line 959 "hlsl.tab.c" /* yacc.c:339 */ +#line 955 "hlsl.tab.c" /* yacc.c:339 */ -# ifndef YY_NULLPTR +# ifndef YY_NULL # if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULLPTR nullptr +# define YY_NULL nullptr # else -# define YY_NULLPTR 0 +# define YY_NULL 0 # endif # endif @@ -968,7 +969,10 @@ static const struct hlsl_ir_function_decl *get_overloaded_func(struct wine_rb_tr # define YYERROR_VERBOSE 1 #endif - +/* In a future release of Bison, this section will be replaced + by #include "hlsl.tab.h". */ +#ifndef YY_HLSL_E_REACTOSSYNC3_0_GCC_DLL_DIRECTX_WINE_D3DCOMPILER_43_HLSL_TAB_H_INCLUDED +# define YY_HLSL_E_REACTOSSYNC3_0_GCC_DLL_DIRECTX_WINE_D3DCOMPILER_43_HLSL_TAB_H_INCLUDED /* Debug traces. */ #ifndef YYDEBUG # define YYDEBUG 0 @@ -1092,7 +1096,7 @@ extern int hlsl_debug; typedef union YYSTYPE YYSTYPE; union YYSTYPE { -#line 910 "hlsl.y" /* yacc.c:355 */ +#line 906 "hlsl.y" /* yacc.c:355 */ struct hlsl_type *type; INT intval; @@ -1112,7 +1116,7 @@ union YYSTYPE struct reg_reservation *reg_reservation; struct parse_colon_attribute colon_attribute; -#line 1121 "hlsl.tab.c" /* yacc.c:355 */ +#line 1120 "hlsl.tab.c" /* yacc.c:355 */ }; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 @@ -1137,11 +1141,11 @@ extern YYSTYPE hlsl_lval; extern YYLTYPE hlsl_lloc; int hlsl_parse (void); - +#endif /* !YY_HLSL_E_REACTOSSYNC3_0_GCC_DLL_DIRECTX_WINE_D3DCOMPILER_43_HLSL_TAB_H_INCLUDED */ /* Copy the second part of user declarations. */ -#line 1150 "hlsl.tab.c" /* yacc.c:358 */ +#line 1149 "hlsl.tab.c" /* yacc.c:358 */ #ifdef short # undef short @@ -1198,30 +1202,11 @@ typedef short int yytype_int16; # endif #endif -#ifndef YY_ATTRIBUTE -# if (defined __GNUC__ \ - && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ - || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C -# define YY_ATTRIBUTE(Spec) __attribute__(Spec) -# else -# define YY_ATTRIBUTE(Spec) /* empty */ -# endif -#endif - -#ifndef YY_ATTRIBUTE_PURE -# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) -#endif - -#ifndef YY_ATTRIBUTE_UNUSED -# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) -#endif - -#if !defined _Noreturn \ - && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) -# if defined _MSC_VER && 1200 <= _MSC_VER -# define _Noreturn __declspec (noreturn) -# else -# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +#ifndef __attribute__ +/* This feature is available in gcc versions 2.5 and later. */ +# if (! defined __GNUC__ || __GNUC__ < 2 \ + || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)) +# define __attribute__(Spec) /* empty */ # endif #endif @@ -1450,24 +1435,24 @@ static const yytype_uint8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 1095, 1095, 1097, 1134, 1138, 1141, 1146, 1168, 1185, - 1186, 1188, 1214, 1224, 1225, 1226, 1229, 1233, 1252, 1256, - 1261, 1268, 1275, 1305, 1310, 1317, 1321, 1322, 1325, 1329, - 1334, 1340, 1346, 1351, 1360, 1365, 1370, 1384, 1398, 1409, - 1412, 1423, 1427, 1431, 1436, 1440, 1459, 1479, 1483, 1488, - 1493, 1498, 1503, 1508, 1516, 1534, 1535, 1536, 1547, 1555, - 1564, 1570, 1576, 1584, 1590, 1593, 1598, 1604, 1610, 1619, - 1632, 1635, 1643, 1646, 1650, 1654, 1658, 1662, 1666, 1670, - 1674, 1678, 1682, 1686, 1691, 1697, 1701, 1706, 1711, 1717, - 1723, 1727, 1732, 1736, 1743, 1744, 1745, 1746, 1747, 1748, - 1751, 1774, 1798, 1803, 1809, 1824, 1839, 1847, 1859, 1864, - 1872, 1886, 1900, 1914, 1925, 1930, 1944, 1948, 1967, 1986, - 2040, 2100, 2136, 2140, 2156, 2172, 2192, 2224, 2228, 2232, - 2236, 2241, 2245, 2252, 2259, 2267, 2271, 2278, 2286, 2290, - 2294, 2299, 2303, 2310, 2317, 2324, 2332, 2336, 2343, 2351, - 2355, 2360, 2364, 2369, 2373, 2378, 2382, 2387, 2391, 2396, - 2400, 2405, 2409, 2426, 2430, 2434, 2438, 2442, 2446, 2450, - 2454, 2458, 2462, 2466, 2471, 2475 + 0, 1091, 1091, 1093, 1130, 1134, 1137, 1142, 1164, 1181, + 1182, 1184, 1210, 1220, 1221, 1222, 1225, 1229, 1248, 1252, + 1257, 1264, 1271, 1301, 1306, 1313, 1317, 1318, 1321, 1325, + 1330, 1336, 1342, 1347, 1356, 1361, 1366, 1380, 1394, 1405, + 1408, 1419, 1423, 1427, 1432, 1436, 1455, 1475, 1479, 1484, + 1489, 1494, 1499, 1504, 1512, 1530, 1531, 1532, 1543, 1551, + 1560, 1566, 1572, 1580, 1586, 1589, 1594, 1600, 1606, 1615, + 1628, 1631, 1639, 1642, 1646, 1650, 1654, 1658, 1662, 1666, + 1670, 1674, 1678, 1682, 1687, 1693, 1697, 1702, 1707, 1713, + 1719, 1723, 1728, 1732, 1739, 1740, 1741, 1742, 1743, 1744, + 1747, 1770, 1794, 1799, 1805, 1820, 1835, 1843, 1855, 1860, + 1868, 1882, 1896, 1910, 1921, 1926, 1940, 1944, 1963, 1982, + 2036, 2096, 2132, 2136, 2152, 2168, 2188, 2220, 2224, 2228, + 2232, 2237, 2241, 2248, 2255, 2263, 2267, 2274, 2282, 2286, + 2290, 2295, 2299, 2306, 2313, 2320, 2328, 2332, 2339, 2347, + 2351, 2356, 2360, 2365, 2369, 2374, 2378, 2383, 2387, 2392, + 2396, 2401, 2405, 2422, 2426, 2430, 2434, 2438, 2442, 2446, + 2450, 2454, 2458, 2462, 2467, 2471 }; #endif @@ -1518,7 +1503,7 @@ static const char *const yytname[] = "mul_expr", "add_expr", "shift_expr", "relational_expr", "equality_expr", "bitand_expr", "bitxor_expr", "bitor_expr", "logicand_expr", "logicor_expr", "conditional_expr", "assignment_expr", "assign_op", - "expr", YY_NULLPTR + "expr", YY_NULL }; #endif @@ -2004,7 +1989,7 @@ do { \ /* Print *YYLOCP on YYO. Private, do not rely on its existence. */ -YY_ATTRIBUTE_UNUSED +__attribute__((__unused__)) static unsigned yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp) { @@ -2267,11 +2252,11 @@ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { - YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); YYSIZE_T yysize = yysize0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ - const char *yyformat = YY_NULLPTR; + const char *yyformat = YY_NULL; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per @@ -2328,7 +2313,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, } yyarg[yycount++] = yytname[yyx]; { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; @@ -2685,14 +2670,14 @@ yyreduce: switch (yyn) { case 2: -#line 1095 "hlsl.y" /* yacc.c:1646 */ +#line 1091 "hlsl.y" /* yacc.c:1646 */ { } -#line 2697 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2677 "hlsl.tab.c" /* yacc.c:1646 */ break; case 3: -#line 1098 "hlsl.y" /* yacc.c:1646 */ +#line 1094 "hlsl.y" /* yacc.c:1646 */ { const struct hlsl_ir_function_decl *decl; @@ -2729,34 +2714,34 @@ yyreduce: TRACE("Adding function '%s' to the function list.\n", (yyvsp[0].function).name); add_function_decl(&hlsl_ctx.functions, (yyvsp[0].function).name, (yyvsp[0].function).decl, FALSE); } -#line 2738 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2718 "hlsl.tab.c" /* yacc.c:1646 */ break; case 4: -#line 1135 "hlsl.y" /* yacc.c:1646 */ +#line 1131 "hlsl.y" /* yacc.c:1646 */ { TRACE("Declaration statement parsed.\n"); } -#line 2746 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2726 "hlsl.tab.c" /* yacc.c:1646 */ break; case 5: -#line 1139 "hlsl.y" /* yacc.c:1646 */ +#line 1135 "hlsl.y" /* yacc.c:1646 */ { } -#line 2753 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2733 "hlsl.tab.c" /* yacc.c:1646 */ break; case 6: -#line 1142 "hlsl.y" /* yacc.c:1646 */ +#line 1138 "hlsl.y" /* yacc.c:1646 */ { TRACE("Skipping stray semicolon.\n"); } -#line 2761 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2741 "hlsl.tab.c" /* yacc.c:1646 */ break; case 7: -#line 1147 "hlsl.y" /* yacc.c:1646 */ +#line 1143 "hlsl.y" /* yacc.c:1646 */ { const char **new_array = NULL; @@ -2764,7 +2749,7 @@ yyreduce: hlsl_ctx.line_no = (yyvsp[-1].intval); if (strcmp((yyvsp[0].name), hlsl_ctx.source_file)) new_array = d3dcompiler_realloc(hlsl_ctx.source_files, - sizeof(*hlsl_ctx.source_files) * hlsl_ctx.source_files_count + 1); + sizeof(*hlsl_ctx.source_files) * (hlsl_ctx.source_files_count + 1)); if (new_array) { @@ -2777,11 +2762,11 @@ yyreduce: d3dcompiler_free((yyvsp[0].name)); } } -#line 2786 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2766 "hlsl.tab.c" /* yacc.c:1646 */ break; case 8: -#line 1169 "hlsl.y" /* yacc.c:1646 */ +#line 1165 "hlsl.y" /* yacc.c:1646 */ { struct source_location loc; @@ -2797,11 +2782,11 @@ yyreduce: } (yyval.list) = declare_vars((yyvsp[-2].type), 0, (yyvsp[-1].list)); } -#line 2806 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2786 "hlsl.tab.c" /* yacc.c:1646 */ break; case 11: -#line 1189 "hlsl.y" /* yacc.c:1646 */ +#line 1185 "hlsl.y" /* yacc.c:1646 */ { BOOL ret; struct source_location loc; @@ -2826,11 +2811,11 @@ yyreduce: return 1; } } -#line 2835 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2815 "hlsl.tab.c" /* yacc.c:1646 */ break; case 12: -#line 1215 "hlsl.y" /* yacc.c:1646 */ +#line 1211 "hlsl.y" /* yacc.c:1646 */ { struct source_location loc; @@ -2839,20 +2824,20 @@ yyreduce: check_invalid_matrix_modifiers((yyvsp[-4].modifiers), &loc); (yyval.type) = new_struct_type(NULL, (yyvsp[-4].modifiers), (yyvsp[-1].list)); } -#line 2848 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2828 "hlsl.tab.c" /* yacc.c:1646 */ break; case 16: -#line 1229 "hlsl.y" /* yacc.c:1646 */ +#line 1225 "hlsl.y" /* yacc.c:1646 */ { (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list))); list_init((yyval.list)); } -#line 2857 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2837 "hlsl.tab.c" /* yacc.c:1646 */ break; case 17: -#line 1234 "hlsl.y" /* yacc.c:1646 */ +#line 1230 "hlsl.y" /* yacc.c:1646 */ { BOOL ret; struct hlsl_struct_field *field, *next; @@ -2870,48 +2855,48 @@ yyreduce: } d3dcompiler_free((yyvsp[0].list)); } -#line 2879 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2859 "hlsl.tab.c" /* yacc.c:1646 */ break; case 18: -#line 1253 "hlsl.y" /* yacc.c:1646 */ +#line 1249 "hlsl.y" /* yacc.c:1646 */ { (yyval.list) = gen_struct_fields((yyvsp[-2].type), (yyvsp[-3].modifiers), (yyvsp[-1].list)); } -#line 2887 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2867 "hlsl.tab.c" /* yacc.c:1646 */ break; case 19: -#line 1257 "hlsl.y" /* yacc.c:1646 */ +#line 1253 "hlsl.y" /* yacc.c:1646 */ { (yyval.list) = gen_struct_fields((yyvsp[-2].type), 0, (yyvsp[-1].list)); } -#line 2895 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2875 "hlsl.tab.c" /* yacc.c:1646 */ break; case 20: -#line 1262 "hlsl.y" /* yacc.c:1646 */ +#line 1258 "hlsl.y" /* yacc.c:1646 */ { TRACE("Function %s parsed.\n", (yyvsp[-1].function).name); (yyval.function) = (yyvsp[-1].function); (yyval.function).decl->body = (yyvsp[0].list); pop_scope(&hlsl_ctx); } -#line 2906 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2886 "hlsl.tab.c" /* yacc.c:1646 */ break; case 21: -#line 1269 "hlsl.y" /* yacc.c:1646 */ +#line 1265 "hlsl.y" /* yacc.c:1646 */ { TRACE("Function prototype for %s.\n", (yyvsp[-1].function).name); (yyval.function) = (yyvsp[-1].function); pop_scope(&hlsl_ctx); } -#line 2916 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2896 "hlsl.tab.c" /* yacc.c:1646 */ break; case 22: -#line 1276 "hlsl.y" /* yacc.c:1646 */ +#line 1272 "hlsl.y" /* yacc.c:1646 */ { if (get_variable(hlsl_ctx.globals, (yyvsp[-4].name))) { @@ -2940,81 +2925,81 @@ yyreduce: (yyval.function).decl->semantic = (yyvsp[0].colon_attribute).semantic; set_location(&(yyval.function).decl->node.loc, &(yylsp[-4])); } -#line 2949 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2929 "hlsl.tab.c" /* yacc.c:1646 */ break; case 23: -#line 1306 "hlsl.y" /* yacc.c:1646 */ +#line 1302 "hlsl.y" /* yacc.c:1646 */ { (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list))); list_init((yyval.list)); } -#line 2958 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2938 "hlsl.tab.c" /* yacc.c:1646 */ break; case 24: -#line 1311 "hlsl.y" /* yacc.c:1646 */ +#line 1307 "hlsl.y" /* yacc.c:1646 */ { pop_scope(&hlsl_ctx); (yyval.list) = (yyvsp[-1].list); } -#line 2967 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2947 "hlsl.tab.c" /* yacc.c:1646 */ break; case 25: -#line 1317 "hlsl.y" /* yacc.c:1646 */ +#line 1313 "hlsl.y" /* yacc.c:1646 */ { push_scope(&hlsl_ctx); } -#line 2975 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2955 "hlsl.tab.c" /* yacc.c:1646 */ break; case 28: -#line 1325 "hlsl.y" /* yacc.c:1646 */ +#line 1321 "hlsl.y" /* yacc.c:1646 */ { (yyval.colon_attribute).semantic = NULL; (yyval.colon_attribute).reg_reservation = NULL; } -#line 2984 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2964 "hlsl.tab.c" /* yacc.c:1646 */ break; case 29: -#line 1330 "hlsl.y" /* yacc.c:1646 */ +#line 1326 "hlsl.y" /* yacc.c:1646 */ { (yyval.colon_attribute).semantic = (yyvsp[0].name); (yyval.colon_attribute).reg_reservation = NULL; } -#line 2993 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2973 "hlsl.tab.c" /* yacc.c:1646 */ break; case 30: -#line 1335 "hlsl.y" /* yacc.c:1646 */ +#line 1331 "hlsl.y" /* yacc.c:1646 */ { (yyval.colon_attribute).semantic = NULL; (yyval.colon_attribute).reg_reservation = (yyvsp[0].reg_reservation); } -#line 3002 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2982 "hlsl.tab.c" /* yacc.c:1646 */ break; case 31: -#line 1341 "hlsl.y" /* yacc.c:1646 */ +#line 1337 "hlsl.y" /* yacc.c:1646 */ { (yyval.name) = (yyvsp[0].name); } -#line 3010 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2990 "hlsl.tab.c" /* yacc.c:1646 */ break; case 32: -#line 1347 "hlsl.y" /* yacc.c:1646 */ +#line 1343 "hlsl.y" /* yacc.c:1646 */ { (yyval.reg_reservation) = parse_reg_reservation((yyvsp[-1].name)); d3dcompiler_free((yyvsp[-1].name)); } -#line 3019 "hlsl.tab.c" /* yacc.c:1646 */ +#line 2999 "hlsl.tab.c" /* yacc.c:1646 */ break; case 33: -#line 1352 "hlsl.y" /* yacc.c:1646 */ +#line 1348 "hlsl.y" /* yacc.c:1646 */ { FIXME("Ignoring shader target %s in a register reservation.\n", debugstr_a((yyvsp[-3].name))); d3dcompiler_free((yyvsp[-3].name)); @@ -3022,28 +3007,28 @@ yyreduce: (yyval.reg_reservation) = parse_reg_reservation((yyvsp[-1].name)); d3dcompiler_free((yyvsp[-1].name)); } -#line 3031 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3011 "hlsl.tab.c" /* yacc.c:1646 */ break; case 34: -#line 1361 "hlsl.y" /* yacc.c:1646 */ +#line 1357 "hlsl.y" /* yacc.c:1646 */ { (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list))); list_init((yyval.list)); } -#line 3040 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3020 "hlsl.tab.c" /* yacc.c:1646 */ break; case 35: -#line 1366 "hlsl.y" /* yacc.c:1646 */ +#line 1362 "hlsl.y" /* yacc.c:1646 */ { (yyval.list) = (yyvsp[0].list); } -#line 3048 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3028 "hlsl.tab.c" /* yacc.c:1646 */ break; case 36: -#line 1371 "hlsl.y" /* yacc.c:1646 */ +#line 1367 "hlsl.y" /* yacc.c:1646 */ { struct source_location loc; @@ -3057,11 +3042,11 @@ yyreduce: return -1; } } -#line 3066 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3046 "hlsl.tab.c" /* yacc.c:1646 */ break; case 37: -#line 1385 "hlsl.y" /* yacc.c:1646 */ +#line 1381 "hlsl.y" /* yacc.c:1646 */ { struct source_location loc; @@ -3074,11 +3059,11 @@ yyreduce: return 1; } } -#line 3083 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3063 "hlsl.tab.c" /* yacc.c:1646 */ break; case 38: -#line 1399 "hlsl.y" /* yacc.c:1646 */ +#line 1395 "hlsl.y" /* yacc.c:1646 */ { (yyval.parameter).modifiers = (yyvsp[-4].modifiers) ? (yyvsp[-4].modifiers) : HLSL_MODIFIER_IN; (yyval.parameter).modifiers |= (yyvsp[-3].modifiers); @@ -3087,19 +3072,19 @@ yyreduce: (yyval.parameter).semantic = (yyvsp[0].colon_attribute).semantic; (yyval.parameter).reg_reservation = (yyvsp[0].colon_attribute).reg_reservation; } -#line 3096 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3076 "hlsl.tab.c" /* yacc.c:1646 */ break; case 39: -#line 1409 "hlsl.y" /* yacc.c:1646 */ +#line 1405 "hlsl.y" /* yacc.c:1646 */ { (yyval.modifiers) = 0; } -#line 3104 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3084 "hlsl.tab.c" /* yacc.c:1646 */ break; case 40: -#line 1413 "hlsl.y" /* yacc.c:1646 */ +#line 1409 "hlsl.y" /* yacc.c:1646 */ { if ((yyvsp[-1].modifiers) & (yyvsp[0].modifiers)) { @@ -3109,43 +3094,43 @@ yyreduce: } (yyval.modifiers) = (yyvsp[-1].modifiers) | (yyvsp[0].modifiers); } -#line 3118 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3098 "hlsl.tab.c" /* yacc.c:1646 */ break; case 41: -#line 1424 "hlsl.y" /* yacc.c:1646 */ +#line 1420 "hlsl.y" /* yacc.c:1646 */ { (yyval.modifiers) = HLSL_MODIFIER_IN; } -#line 3126 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3106 "hlsl.tab.c" /* yacc.c:1646 */ break; case 42: -#line 1428 "hlsl.y" /* yacc.c:1646 */ +#line 1424 "hlsl.y" /* yacc.c:1646 */ { (yyval.modifiers) = HLSL_MODIFIER_OUT; } -#line 3134 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3114 "hlsl.tab.c" /* yacc.c:1646 */ break; case 43: -#line 1432 "hlsl.y" /* yacc.c:1646 */ +#line 1428 "hlsl.y" /* yacc.c:1646 */ { (yyval.modifiers) = HLSL_MODIFIER_IN | HLSL_MODIFIER_OUT; } -#line 3142 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3122 "hlsl.tab.c" /* yacc.c:1646 */ break; case 44: -#line 1437 "hlsl.y" /* yacc.c:1646 */ +#line 1433 "hlsl.y" /* yacc.c:1646 */ { (yyval.type) = (yyvsp[0].type); } -#line 3150 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3130 "hlsl.tab.c" /* yacc.c:1646 */ break; case 45: -#line 1441 "hlsl.y" /* yacc.c:1646 */ +#line 1437 "hlsl.y" /* yacc.c:1646 */ { if ((yyvsp[-3].type)->type != HLSL_CLASS_SCALAR) { @@ -3164,11 +3149,11 @@ yyreduce: (yyval.type) = new_hlsl_type(NULL, HLSL_CLASS_VECTOR, (yyvsp[-3].type)->base_type, (yyvsp[-1].intval), 1); } -#line 3173 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3153 "hlsl.tab.c" /* yacc.c:1646 */ break; case 46: -#line 1460 "hlsl.y" /* yacc.c:1646 */ +#line 1456 "hlsl.y" /* yacc.c:1646 */ { if ((yyvsp[-5].type)->type != HLSL_CLASS_SCALAR) { @@ -3187,64 +3172,64 @@ yyreduce: (yyval.type) = new_hlsl_type(NULL, HLSL_CLASS_MATRIX, (yyvsp[-5].type)->base_type, (yyvsp[-3].intval), (yyvsp[-1].intval)); } -#line 3196 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3176 "hlsl.tab.c" /* yacc.c:1646 */ break; case 47: -#line 1480 "hlsl.y" /* yacc.c:1646 */ +#line 1476 "hlsl.y" /* yacc.c:1646 */ { (yyval.type) = new_hlsl_type(d3dcompiler_strdup("void"), HLSL_CLASS_OBJECT, HLSL_TYPE_VOID, 1, 1); } -#line 3204 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3184 "hlsl.tab.c" /* yacc.c:1646 */ break; case 48: -#line 1484 "hlsl.y" /* yacc.c:1646 */ +#line 1480 "hlsl.y" /* yacc.c:1646 */ { (yyval.type) = new_hlsl_type(d3dcompiler_strdup("sampler"), HLSL_CLASS_OBJECT, HLSL_TYPE_SAMPLER, 1, 1); (yyval.type)->sampler_dim = HLSL_SAMPLER_DIM_GENERIC; } -#line 3213 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3193 "hlsl.tab.c" /* yacc.c:1646 */ break; case 49: -#line 1489 "hlsl.y" /* yacc.c:1646 */ +#line 1485 "hlsl.y" /* yacc.c:1646 */ { (yyval.type) = new_hlsl_type(d3dcompiler_strdup("sampler1D"), HLSL_CLASS_OBJECT, HLSL_TYPE_SAMPLER, 1, 1); (yyval.type)->sampler_dim = HLSL_SAMPLER_DIM_1D; } -#line 3222 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3202 "hlsl.tab.c" /* yacc.c:1646 */ break; case 50: -#line 1494 "hlsl.y" /* yacc.c:1646 */ +#line 1490 "hlsl.y" /* yacc.c:1646 */ { (yyval.type) = new_hlsl_type(d3dcompiler_strdup("sampler2D"), HLSL_CLASS_OBJECT, HLSL_TYPE_SAMPLER, 1, 1); (yyval.type)->sampler_dim = HLSL_SAMPLER_DIM_2D; } -#line 3231 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3211 "hlsl.tab.c" /* yacc.c:1646 */ break; case 51: -#line 1499 "hlsl.y" /* yacc.c:1646 */ +#line 1495 "hlsl.y" /* yacc.c:1646 */ { (yyval.type) = new_hlsl_type(d3dcompiler_strdup("sampler3D"), HLSL_CLASS_OBJECT, HLSL_TYPE_SAMPLER, 1, 1); (yyval.type)->sampler_dim = HLSL_SAMPLER_DIM_3D; } -#line 3240 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3220 "hlsl.tab.c" /* yacc.c:1646 */ break; case 52: -#line 1504 "hlsl.y" /* yacc.c:1646 */ +#line 1500 "hlsl.y" /* yacc.c:1646 */ { (yyval.type) = new_hlsl_type(d3dcompiler_strdup("samplerCUBE"), HLSL_CLASS_OBJECT, HLSL_TYPE_SAMPLER, 1, 1); (yyval.type)->sampler_dim = HLSL_SAMPLER_DIM_CUBE; } -#line 3249 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3229 "hlsl.tab.c" /* yacc.c:1646 */ break; case 53: -#line 1509 "hlsl.y" /* yacc.c:1646 */ +#line 1505 "hlsl.y" /* yacc.c:1646 */ { struct hlsl_type *type; @@ -3252,11 +3237,11 @@ yyreduce: (yyval.type) = type; d3dcompiler_free((yyvsp[0].name)); } -#line 3261 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3241 "hlsl.tab.c" /* yacc.c:1646 */ break; case 54: -#line 1517 "hlsl.y" /* yacc.c:1646 */ +#line 1513 "hlsl.y" /* yacc.c:1646 */ { struct hlsl_type *type; @@ -3273,11 +3258,11 @@ yyreduce: } d3dcompiler_free((yyvsp[0].name)); } -#line 3282 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3262 "hlsl.tab.c" /* yacc.c:1646 */ break; case 57: -#line 1537 "hlsl.y" /* yacc.c:1646 */ +#line 1533 "hlsl.y" /* yacc.c:1646 */ { (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list))); if (!(yyval.list)) @@ -3287,11 +3272,11 @@ yyreduce: } list_init((yyval.list)); } -#line 3296 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3276 "hlsl.tab.c" /* yacc.c:1646 */ break; case 58: -#line 1548 "hlsl.y" /* yacc.c:1646 */ +#line 1544 "hlsl.y" /* yacc.c:1646 */ { struct source_location loc; @@ -3299,11 +3284,11 @@ yyreduce: if (!add_typedef((yyvsp[-3].modifiers), (yyvsp[-2].type), (yyvsp[-1].list), &loc)) return 1; } -#line 3308 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3288 "hlsl.tab.c" /* yacc.c:1646 */ break; case 59: -#line 1556 "hlsl.y" /* yacc.c:1646 */ +#line 1552 "hlsl.y" /* yacc.c:1646 */ { struct source_location loc; @@ -3311,84 +3296,84 @@ yyreduce: if (!add_typedef(0, (yyvsp[-2].type), (yyvsp[-1].list), &loc)) return 1; } -#line 3320 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3300 "hlsl.tab.c" /* yacc.c:1646 */ break; case 60: -#line 1565 "hlsl.y" /* yacc.c:1646 */ +#line 1561 "hlsl.y" /* yacc.c:1646 */ { (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list))); list_init((yyval.list)); list_add_head((yyval.list), &(yyvsp[0].variable_def)->entry); } -#line 3330 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3310 "hlsl.tab.c" /* yacc.c:1646 */ break; case 61: -#line 1571 "hlsl.y" /* yacc.c:1646 */ +#line 1567 "hlsl.y" /* yacc.c:1646 */ { (yyval.list) = (yyvsp[-2].list); list_add_tail((yyval.list), &(yyvsp[0].variable_def)->entry); } -#line 3339 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3319 "hlsl.tab.c" /* yacc.c:1646 */ break; case 62: -#line 1577 "hlsl.y" /* yacc.c:1646 */ +#line 1573 "hlsl.y" /* yacc.c:1646 */ { (yyval.variable_def) = d3dcompiler_alloc(sizeof(*(yyval.variable_def))); set_location(&(yyval.variable_def)->loc, &(yylsp[-1])); (yyval.variable_def)->name = (yyvsp[-1].name); (yyval.variable_def)->array_size = (yyvsp[0].intval); } -#line 3350 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3330 "hlsl.tab.c" /* yacc.c:1646 */ break; case 63: -#line 1585 "hlsl.y" /* yacc.c:1646 */ +#line 1581 "hlsl.y" /* yacc.c:1646 */ { (yyval.list) = declare_vars((yyvsp[-2].type), (yyvsp[-3].modifiers), (yyvsp[-1].list)); } -#line 3358 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3338 "hlsl.tab.c" /* yacc.c:1646 */ break; case 64: -#line 1590 "hlsl.y" /* yacc.c:1646 */ +#line 1586 "hlsl.y" /* yacc.c:1646 */ { (yyval.list) = NULL; } -#line 3366 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3346 "hlsl.tab.c" /* yacc.c:1646 */ break; case 65: -#line 1594 "hlsl.y" /* yacc.c:1646 */ +#line 1590 "hlsl.y" /* yacc.c:1646 */ { (yyval.list) = (yyvsp[0].list); } -#line 3374 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3354 "hlsl.tab.c" /* yacc.c:1646 */ break; case 66: -#line 1599 "hlsl.y" /* yacc.c:1646 */ +#line 1595 "hlsl.y" /* yacc.c:1646 */ { (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list))); list_init((yyval.list)); list_add_head((yyval.list), &(yyvsp[0].variable_def)->entry); } -#line 3384 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3364 "hlsl.tab.c" /* yacc.c:1646 */ break; case 67: -#line 1605 "hlsl.y" /* yacc.c:1646 */ +#line 1601 "hlsl.y" /* yacc.c:1646 */ { (yyval.list) = (yyvsp[-2].list); list_add_tail((yyval.list), &(yyvsp[0].variable_def)->entry); } -#line 3393 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3373 "hlsl.tab.c" /* yacc.c:1646 */ break; case 68: -#line 1611 "hlsl.y" /* yacc.c:1646 */ +#line 1607 "hlsl.y" /* yacc.c:1646 */ { (yyval.variable_def) = d3dcompiler_alloc(sizeof(*(yyval.variable_def))); set_location(&(yyval.variable_def)->loc, &(yylsp[-2])); @@ -3397,11 +3382,11 @@ yyreduce: (yyval.variable_def)->semantic = (yyvsp[0].colon_attribute).semantic; (yyval.variable_def)->reg_reservation = (yyvsp[0].colon_attribute).reg_reservation; } -#line 3406 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3386 "hlsl.tab.c" /* yacc.c:1646 */ break; case 69: -#line 1620 "hlsl.y" /* yacc.c:1646 */ +#line 1616 "hlsl.y" /* yacc.c:1646 */ { TRACE("Declaration with initializer.\n"); (yyval.variable_def) = d3dcompiler_alloc(sizeof(*(yyval.variable_def))); @@ -3412,212 +3397,212 @@ yyreduce: (yyval.variable_def)->reg_reservation = (yyvsp[-2].colon_attribute).reg_reservation; (yyval.variable_def)->initializer = (yyvsp[0].list); } -#line 3421 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3401 "hlsl.tab.c" /* yacc.c:1646 */ break; case 70: -#line 1632 "hlsl.y" /* yacc.c:1646 */ +#line 1628 "hlsl.y" /* yacc.c:1646 */ { (yyval.intval) = 0; } -#line 3429 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3409 "hlsl.tab.c" /* yacc.c:1646 */ break; case 71: -#line 1636 "hlsl.y" /* yacc.c:1646 */ +#line 1632 "hlsl.y" /* yacc.c:1646 */ { FIXME("Array.\n"); (yyval.intval) = 0; free_instr((yyvsp[-1].instr)); } -#line 3439 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3419 "hlsl.tab.c" /* yacc.c:1646 */ break; case 72: -#line 1643 "hlsl.y" /* yacc.c:1646 */ +#line 1639 "hlsl.y" /* yacc.c:1646 */ { (yyval.modifiers) = 0; } -#line 3447 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3427 "hlsl.tab.c" /* yacc.c:1646 */ break; case 73: -#line 1647 "hlsl.y" /* yacc.c:1646 */ +#line 1643 "hlsl.y" /* yacc.c:1646 */ { (yyval.modifiers) = add_modifier((yyvsp[0].modifiers), HLSL_STORAGE_EXTERN, &(yylsp[-1])); } -#line 3455 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3435 "hlsl.tab.c" /* yacc.c:1646 */ break; case 74: -#line 1651 "hlsl.y" /* yacc.c:1646 */ +#line 1647 "hlsl.y" /* yacc.c:1646 */ { (yyval.modifiers) = add_modifier((yyvsp[0].modifiers), HLSL_STORAGE_NOINTERPOLATION, &(yylsp[-1])); } -#line 3463 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3443 "hlsl.tab.c" /* yacc.c:1646 */ break; case 75: -#line 1655 "hlsl.y" /* yacc.c:1646 */ +#line 1651 "hlsl.y" /* yacc.c:1646 */ { (yyval.modifiers) = add_modifier((yyvsp[0].modifiers), HLSL_MODIFIER_PRECISE, &(yylsp[-1])); } -#line 3471 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3451 "hlsl.tab.c" /* yacc.c:1646 */ break; case 76: -#line 1659 "hlsl.y" /* yacc.c:1646 */ +#line 1655 "hlsl.y" /* yacc.c:1646 */ { (yyval.modifiers) = add_modifier((yyvsp[0].modifiers), HLSL_STORAGE_SHARED, &(yylsp[-1])); } -#line 3479 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3459 "hlsl.tab.c" /* yacc.c:1646 */ break; case 77: -#line 1663 "hlsl.y" /* yacc.c:1646 */ +#line 1659 "hlsl.y" /* yacc.c:1646 */ { (yyval.modifiers) = add_modifier((yyvsp[0].modifiers), HLSL_STORAGE_GROUPSHARED, &(yylsp[-1])); } -#line 3487 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3467 "hlsl.tab.c" /* yacc.c:1646 */ break; case 78: -#line 1667 "hlsl.y" /* yacc.c:1646 */ +#line 1663 "hlsl.y" /* yacc.c:1646 */ { (yyval.modifiers) = add_modifier((yyvsp[0].modifiers), HLSL_STORAGE_STATIC, &(yylsp[-1])); } -#line 3495 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3475 "hlsl.tab.c" /* yacc.c:1646 */ break; case 79: -#line 1671 "hlsl.y" /* yacc.c:1646 */ +#line 1667 "hlsl.y" /* yacc.c:1646 */ { (yyval.modifiers) = add_modifier((yyvsp[0].modifiers), HLSL_STORAGE_UNIFORM, &(yylsp[-1])); } -#line 3503 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3483 "hlsl.tab.c" /* yacc.c:1646 */ break; case 80: -#line 1675 "hlsl.y" /* yacc.c:1646 */ +#line 1671 "hlsl.y" /* yacc.c:1646 */ { (yyval.modifiers) = add_modifier((yyvsp[0].modifiers), HLSL_STORAGE_VOLATILE, &(yylsp[-1])); } -#line 3511 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3491 "hlsl.tab.c" /* yacc.c:1646 */ break; case 81: -#line 1679 "hlsl.y" /* yacc.c:1646 */ +#line 1675 "hlsl.y" /* yacc.c:1646 */ { (yyval.modifiers) = add_modifier((yyvsp[0].modifiers), HLSL_MODIFIER_CONST, &(yylsp[-1])); } -#line 3519 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3499 "hlsl.tab.c" /* yacc.c:1646 */ break; case 82: -#line 1683 "hlsl.y" /* yacc.c:1646 */ +#line 1679 "hlsl.y" /* yacc.c:1646 */ { (yyval.modifiers) = add_modifier((yyvsp[0].modifiers), HLSL_MODIFIER_ROW_MAJOR, &(yylsp[-1])); } -#line 3527 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3507 "hlsl.tab.c" /* yacc.c:1646 */ break; case 83: -#line 1687 "hlsl.y" /* yacc.c:1646 */ +#line 1683 "hlsl.y" /* yacc.c:1646 */ { (yyval.modifiers) = add_modifier((yyvsp[0].modifiers), HLSL_MODIFIER_COLUMN_MAJOR, &(yylsp[-1])); } -#line 3535 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3515 "hlsl.tab.c" /* yacc.c:1646 */ break; case 84: -#line 1692 "hlsl.y" /* yacc.c:1646 */ +#line 1688 "hlsl.y" /* yacc.c:1646 */ { (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list))); list_init((yyval.list)); list_add_head((yyval.list), &(yyvsp[0].instr)->entry); } -#line 3545 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3525 "hlsl.tab.c" /* yacc.c:1646 */ break; case 85: -#line 1698 "hlsl.y" /* yacc.c:1646 */ +#line 1694 "hlsl.y" /* yacc.c:1646 */ { (yyval.list) = (yyvsp[-1].list); } -#line 3553 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3533 "hlsl.tab.c" /* yacc.c:1646 */ break; case 86: -#line 1702 "hlsl.y" /* yacc.c:1646 */ +#line 1698 "hlsl.y" /* yacc.c:1646 */ { (yyval.list) = (yyvsp[-2].list); } -#line 3561 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3541 "hlsl.tab.c" /* yacc.c:1646 */ break; case 87: -#line 1707 "hlsl.y" /* yacc.c:1646 */ +#line 1703 "hlsl.y" /* yacc.c:1646 */ { (yyval.instr) = (yyvsp[0].instr); } -#line 3569 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3549 "hlsl.tab.c" /* yacc.c:1646 */ break; case 88: -#line 1712 "hlsl.y" /* yacc.c:1646 */ +#line 1708 "hlsl.y" /* yacc.c:1646 */ { (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list))); list_init((yyval.list)); list_add_head((yyval.list), &(yyvsp[0].instr)->entry); } -#line 3579 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3559 "hlsl.tab.c" /* yacc.c:1646 */ break; case 89: -#line 1718 "hlsl.y" /* yacc.c:1646 */ +#line 1714 "hlsl.y" /* yacc.c:1646 */ { (yyval.list) = (yyvsp[-2].list); list_add_tail((yyval.list), &(yyvsp[0].instr)->entry); } -#line 3588 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3568 "hlsl.tab.c" /* yacc.c:1646 */ break; case 90: -#line 1724 "hlsl.y" /* yacc.c:1646 */ +#line 1720 "hlsl.y" /* yacc.c:1646 */ { (yyval.boolval) = TRUE; } -#line 3596 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3576 "hlsl.tab.c" /* yacc.c:1646 */ break; case 91: -#line 1728 "hlsl.y" /* yacc.c:1646 */ +#line 1724 "hlsl.y" /* yacc.c:1646 */ { (yyval.boolval) = FALSE; } -#line 3604 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3584 "hlsl.tab.c" /* yacc.c:1646 */ break; case 92: -#line 1733 "hlsl.y" /* yacc.c:1646 */ +#line 1729 "hlsl.y" /* yacc.c:1646 */ { (yyval.list) = (yyvsp[0].list); } -#line 3612 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3592 "hlsl.tab.c" /* yacc.c:1646 */ break; case 93: -#line 1737 "hlsl.y" /* yacc.c:1646 */ +#line 1733 "hlsl.y" /* yacc.c:1646 */ { (yyval.list) = (yyvsp[-1].list); list_move_tail((yyval.list), (yyvsp[0].list)); d3dcompiler_free((yyvsp[0].list)); } -#line 3622 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3602 "hlsl.tab.c" /* yacc.c:1646 */ break; case 100: -#line 1752 "hlsl.y" /* yacc.c:1646 */ +#line 1748 "hlsl.y" /* yacc.c:1646 */ { struct hlsl_ir_jump *jump = d3dcompiler_alloc(sizeof(*jump)); if (!jump) @@ -3639,11 +3624,11 @@ yyreduce: list_init((yyval.list)); list_add_tail((yyval.list), &jump->node.entry); } -#line 3648 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3628 "hlsl.tab.c" /* yacc.c:1646 */ break; case 101: -#line 1775 "hlsl.y" /* yacc.c:1646 */ +#line 1771 "hlsl.y" /* yacc.c:1646 */ { struct hlsl_ir_if *instr = d3dcompiler_alloc(sizeof(*instr)); if (!instr) @@ -3666,29 +3651,29 @@ yyreduce: list_init((yyval.list)); list_add_head((yyval.list), &instr->node.entry); } -#line 3675 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3655 "hlsl.tab.c" /* yacc.c:1646 */ break; case 102: -#line 1799 "hlsl.y" /* yacc.c:1646 */ +#line 1795 "hlsl.y" /* yacc.c:1646 */ { (yyval.if_body).then_instrs = (yyvsp[0].list); (yyval.if_body).else_instrs = NULL; } -#line 3684 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3664 "hlsl.tab.c" /* yacc.c:1646 */ break; case 103: -#line 1804 "hlsl.y" /* yacc.c:1646 */ +#line 1800 "hlsl.y" /* yacc.c:1646 */ { (yyval.if_body).then_instrs = (yyvsp[-2].list); (yyval.if_body).else_instrs = (yyvsp[0].list); } -#line 3693 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3673 "hlsl.tab.c" /* yacc.c:1646 */ break; case 104: -#line 1810 "hlsl.y" /* yacc.c:1646 */ +#line 1806 "hlsl.y" /* yacc.c:1646 */ { struct source_location loc; struct list *cond = d3dcompiler_alloc(sizeof(*cond)); @@ -3703,11 +3688,11 @@ yyreduce: set_location(&loc, &(yylsp[-4])); (yyval.list) = create_loop(LOOP_WHILE, NULL, cond, NULL, (yyvsp[0].list), &loc); } -#line 3712 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3692 "hlsl.tab.c" /* yacc.c:1646 */ break; case 105: -#line 1825 "hlsl.y" /* yacc.c:1646 */ +#line 1821 "hlsl.y" /* yacc.c:1646 */ { struct source_location loc; struct list *cond = d3dcompiler_alloc(sizeof(*cond)); @@ -3722,11 +3707,11 @@ yyreduce: set_location(&loc, &(yylsp[-6])); (yyval.list) = create_loop(LOOP_DO_WHILE, NULL, cond, NULL, (yyvsp[-5].list), &loc); } -#line 3731 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3711 "hlsl.tab.c" /* yacc.c:1646 */ break; case 106: -#line 1840 "hlsl.y" /* yacc.c:1646 */ +#line 1836 "hlsl.y" /* yacc.c:1646 */ { struct source_location loc; @@ -3734,11 +3719,11 @@ yyreduce: (yyval.list) = create_loop(LOOP_FOR, (yyvsp[-4].list), (yyvsp[-3].list), (yyvsp[-2].instr), (yyvsp[0].list), &loc); pop_scope(&hlsl_ctx); } -#line 3743 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3723 "hlsl.tab.c" /* yacc.c:1646 */ break; case 107: -#line 1848 "hlsl.y" /* yacc.c:1646 */ +#line 1844 "hlsl.y" /* yacc.c:1646 */ { struct source_location loc; @@ -3749,31 +3734,31 @@ yyreduce: (yyval.list) = create_loop(LOOP_FOR, (yyvsp[-4].list), (yyvsp[-3].list), (yyvsp[-2].instr), (yyvsp[0].list), &loc); pop_scope(&hlsl_ctx); } -#line 3758 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3738 "hlsl.tab.c" /* yacc.c:1646 */ break; case 108: -#line 1860 "hlsl.y" /* yacc.c:1646 */ +#line 1856 "hlsl.y" /* yacc.c:1646 */ { (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list))); list_init((yyval.list)); } -#line 3767 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3747 "hlsl.tab.c" /* yacc.c:1646 */ break; case 109: -#line 1865 "hlsl.y" /* yacc.c:1646 */ +#line 1861 "hlsl.y" /* yacc.c:1646 */ { (yyval.list) = d3dcompiler_alloc(sizeof(*(yyval.list))); list_init((yyval.list)); if ((yyvsp[-1].instr)) list_add_head((yyval.list), &(yyvsp[-1].instr)->entry); } -#line 3778 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3758 "hlsl.tab.c" /* yacc.c:1646 */ break; case 110: -#line 1873 "hlsl.y" /* yacc.c:1646 */ +#line 1869 "hlsl.y" /* yacc.c:1646 */ { struct hlsl_ir_constant *c = d3dcompiler_alloc(sizeof(*c)); if (!c) @@ -3787,11 +3772,11 @@ yyreduce: c->v.value.f[0] = (yyvsp[0].floatval); (yyval.instr) = &c->node; } -#line 3796 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3776 "hlsl.tab.c" /* yacc.c:1646 */ break; case 111: -#line 1887 "hlsl.y" /* yacc.c:1646 */ +#line 1883 "hlsl.y" /* yacc.c:1646 */ { struct hlsl_ir_constant *c = d3dcompiler_alloc(sizeof(*c)); if (!c) @@ -3805,11 +3790,11 @@ yyreduce: c->v.value.i[0] = (yyvsp[0].intval); (yyval.instr) = &c->node; } -#line 3814 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3794 "hlsl.tab.c" /* yacc.c:1646 */ break; case 112: -#line 1901 "hlsl.y" /* yacc.c:1646 */ +#line 1897 "hlsl.y" /* yacc.c:1646 */ { struct hlsl_ir_constant *c = d3dcompiler_alloc(sizeof(*c)); if (!c) @@ -3823,11 +3808,11 @@ yyreduce: c->v.value.b[0] = (yyvsp[0].boolval); (yyval.instr) = &c->node; } -#line 3832 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3812 "hlsl.tab.c" /* yacc.c:1646 */ break; case 113: -#line 1915 "hlsl.y" /* yacc.c:1646 */ +#line 1911 "hlsl.y" /* yacc.c:1646 */ { struct hlsl_ir_deref *deref = new_var_deref((yyvsp[0].var)); if (deref) @@ -3838,19 +3823,19 @@ yyreduce: else (yyval.instr) = NULL; } -#line 3847 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3827 "hlsl.tab.c" /* yacc.c:1646 */ break; case 114: -#line 1926 "hlsl.y" /* yacc.c:1646 */ +#line 1922 "hlsl.y" /* yacc.c:1646 */ { (yyval.instr) = (yyvsp[-1].instr); } -#line 3855 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3835 "hlsl.tab.c" /* yacc.c:1646 */ break; case 115: -#line 1931 "hlsl.y" /* yacc.c:1646 */ +#line 1927 "hlsl.y" /* yacc.c:1646 */ { struct hlsl_ir_var *var; var = get_variable(hlsl_ctx.cur_scope, (yyvsp[0].name)); @@ -3863,19 +3848,19 @@ yyreduce: } (yyval.var) = var; } -#line 3872 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3852 "hlsl.tab.c" /* yacc.c:1646 */ break; case 116: -#line 1945 "hlsl.y" /* yacc.c:1646 */ +#line 1941 "hlsl.y" /* yacc.c:1646 */ { (yyval.instr) = (yyvsp[0].instr); } -#line 3880 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3860 "hlsl.tab.c" /* yacc.c:1646 */ break; case 117: -#line 1949 "hlsl.y" /* yacc.c:1646 */ +#line 1945 "hlsl.y" /* yacc.c:1646 */ { struct hlsl_ir_node *operands[3]; struct source_location loc; @@ -3894,11 +3879,11 @@ yyreduce: (yyval.instr)->data_type = clone_hlsl_type((yyval.instr)->data_type); (yyval.instr)->data_type->modifiers |= HLSL_MODIFIER_CONST; } -#line 3903 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3883 "hlsl.tab.c" /* yacc.c:1646 */ break; case 118: -#line 1968 "hlsl.y" /* yacc.c:1646 */ +#line 1964 "hlsl.y" /* yacc.c:1646 */ { struct hlsl_ir_node *operands[3]; struct source_location loc; @@ -3917,11 +3902,11 @@ yyreduce: (yyval.instr)->data_type = clone_hlsl_type((yyval.instr)->data_type); (yyval.instr)->data_type->modifiers |= HLSL_MODIFIER_CONST; } -#line 3926 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3906 "hlsl.tab.c" /* yacc.c:1646 */ break; case 119: -#line 1987 "hlsl.y" /* yacc.c:1646 */ +#line 1983 "hlsl.y" /* yacc.c:1646 */ { struct source_location loc; @@ -3975,11 +3960,11 @@ yyreduce: return 1; } } -#line 3984 "hlsl.tab.c" /* yacc.c:1646 */ +#line 3964 "hlsl.tab.c" /* yacc.c:1646 */ break; case 120: -#line 2041 "hlsl.y" /* yacc.c:1646 */ +#line 2037 "hlsl.y" /* yacc.c:1646 */ { /* This may be an array dereference or a vector/matrix * subcomponent access. @@ -4037,11 +4022,11 @@ yyreduce: (yyval.instr) = &deref->node; } -#line 4046 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4026 "hlsl.tab.c" /* yacc.c:1646 */ break; case 121: -#line 2101 "hlsl.y" /* yacc.c:1646 */ +#line 2097 "hlsl.y" /* yacc.c:1646 */ { struct hlsl_ir_constructor *constructor; @@ -4076,19 +4061,19 @@ yyreduce: (yyval.instr) = &constructor->node; } -#line 4085 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4065 "hlsl.tab.c" /* yacc.c:1646 */ break; case 122: -#line 2137 "hlsl.y" /* yacc.c:1646 */ +#line 2133 "hlsl.y" /* yacc.c:1646 */ { (yyval.instr) = (yyvsp[0].instr); } -#line 4093 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4073 "hlsl.tab.c" /* yacc.c:1646 */ break; case 123: -#line 2141 "hlsl.y" /* yacc.c:1646 */ +#line 2137 "hlsl.y" /* yacc.c:1646 */ { struct hlsl_ir_node *operands[3]; struct source_location loc; @@ -4104,11 +4089,11 @@ yyreduce: operands[1] = operands[2] = NULL; (yyval.instr) = &new_expr(HLSL_IR_UNOP_PREINC, operands, &loc)->node; } -#line 4113 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4093 "hlsl.tab.c" /* yacc.c:1646 */ break; case 124: -#line 2157 "hlsl.y" /* yacc.c:1646 */ +#line 2153 "hlsl.y" /* yacc.c:1646 */ { struct hlsl_ir_node *operands[3]; struct source_location loc; @@ -4124,11 +4109,11 @@ yyreduce: operands[1] = operands[2] = NULL; (yyval.instr) = &new_expr(HLSL_IR_UNOP_PREDEC, operands, &loc)->node; } -#line 4133 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4113 "hlsl.tab.c" /* yacc.c:1646 */ break; case 125: -#line 2173 "hlsl.y" /* yacc.c:1646 */ +#line 2169 "hlsl.y" /* yacc.c:1646 */ { enum hlsl_ir_expr_op ops[] = {0, HLSL_IR_UNOP_NEG, HLSL_IR_UNOP_LOGIC_NOT, HLSL_IR_UNOP_BIT_NOT}; @@ -4147,11 +4132,11 @@ yyreduce: (yyval.instr) = &new_expr(ops[(yyvsp[-1].unary_op)], operands, &loc)->node; } } -#line 4156 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4136 "hlsl.tab.c" /* yacc.c:1646 */ break; case 126: -#line 2193 "hlsl.y" /* yacc.c:1646 */ +#line 2189 "hlsl.y" /* yacc.c:1646 */ { struct hlsl_ir_expr *expr; struct hlsl_type *src_type = (yyvsp[0].instr)->data_type; @@ -4182,324 +4167,324 @@ yyreduce: expr = new_cast((yyvsp[0].instr), dst_type, &loc); (yyval.instr) = expr ? &expr->node : NULL; } -#line 4191 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4171 "hlsl.tab.c" /* yacc.c:1646 */ break; case 127: -#line 2225 "hlsl.y" /* yacc.c:1646 */ +#line 2221 "hlsl.y" /* yacc.c:1646 */ { (yyval.unary_op) = UNARY_OP_PLUS; } -#line 4199 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4179 "hlsl.tab.c" /* yacc.c:1646 */ break; case 128: -#line 2229 "hlsl.y" /* yacc.c:1646 */ +#line 2225 "hlsl.y" /* yacc.c:1646 */ { (yyval.unary_op) = UNARY_OP_MINUS; } -#line 4207 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4187 "hlsl.tab.c" /* yacc.c:1646 */ break; case 129: -#line 2233 "hlsl.y" /* yacc.c:1646 */ +#line 2229 "hlsl.y" /* yacc.c:1646 */ { (yyval.unary_op) = UNARY_OP_LOGICNOT; } -#line 4215 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4195 "hlsl.tab.c" /* yacc.c:1646 */ break; case 130: -#line 2237 "hlsl.y" /* yacc.c:1646 */ +#line 2233 "hlsl.y" /* yacc.c:1646 */ { (yyval.unary_op) = UNARY_OP_BITNOT; } -#line 4223 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4203 "hlsl.tab.c" /* yacc.c:1646 */ break; case 131: -#line 2242 "hlsl.y" /* yacc.c:1646 */ +#line 2238 "hlsl.y" /* yacc.c:1646 */ { (yyval.instr) = (yyvsp[0].instr); } -#line 4231 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4211 "hlsl.tab.c" /* yacc.c:1646 */ break; case 132: -#line 2246 "hlsl.y" /* yacc.c:1646 */ +#line 2242 "hlsl.y" /* yacc.c:1646 */ { struct source_location loc; set_location(&loc, &(yylsp[-1])); (yyval.instr) = &hlsl_mul((yyvsp[-2].instr), (yyvsp[0].instr), &loc)->node; } -#line 4242 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4222 "hlsl.tab.c" /* yacc.c:1646 */ break; case 133: -#line 2253 "hlsl.y" /* yacc.c:1646 */ +#line 2249 "hlsl.y" /* yacc.c:1646 */ { struct source_location loc; set_location(&loc, &(yylsp[-1])); (yyval.instr) = &hlsl_div((yyvsp[-2].instr), (yyvsp[0].instr), &loc)->node; } -#line 4253 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4233 "hlsl.tab.c" /* yacc.c:1646 */ break; case 134: -#line 2260 "hlsl.y" /* yacc.c:1646 */ +#line 2256 "hlsl.y" /* yacc.c:1646 */ { struct source_location loc; set_location(&loc, &(yylsp[-1])); (yyval.instr) = &hlsl_mod((yyvsp[-2].instr), (yyvsp[0].instr), &loc)->node; } -#line 4264 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4244 "hlsl.tab.c" /* yacc.c:1646 */ break; case 135: -#line 2268 "hlsl.y" /* yacc.c:1646 */ +#line 2264 "hlsl.y" /* yacc.c:1646 */ { (yyval.instr) = (yyvsp[0].instr); } -#line 4272 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4252 "hlsl.tab.c" /* yacc.c:1646 */ break; case 136: -#line 2272 "hlsl.y" /* yacc.c:1646 */ +#line 2268 "hlsl.y" /* yacc.c:1646 */ { struct source_location loc; set_location(&loc, &(yylsp[-1])); (yyval.instr) = &hlsl_add((yyvsp[-2].instr), (yyvsp[0].instr), &loc)->node; } -#line 4283 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4263 "hlsl.tab.c" /* yacc.c:1646 */ break; case 137: -#line 2279 "hlsl.y" /* yacc.c:1646 */ +#line 2275 "hlsl.y" /* yacc.c:1646 */ { struct source_location loc; set_location(&loc, &(yylsp[-1])); (yyval.instr) = &hlsl_sub((yyvsp[-2].instr), (yyvsp[0].instr), &loc)->node; } -#line 4294 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4274 "hlsl.tab.c" /* yacc.c:1646 */ break; case 138: -#line 2287 "hlsl.y" /* yacc.c:1646 */ +#line 2283 "hlsl.y" /* yacc.c:1646 */ { (yyval.instr) = (yyvsp[0].instr); } -#line 4302 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4282 "hlsl.tab.c" /* yacc.c:1646 */ break; case 139: -#line 2291 "hlsl.y" /* yacc.c:1646 */ +#line 2287 "hlsl.y" /* yacc.c:1646 */ { FIXME("Left shift\n"); } -#line 4310 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4290 "hlsl.tab.c" /* yacc.c:1646 */ break; case 140: -#line 2295 "hlsl.y" /* yacc.c:1646 */ +#line 2291 "hlsl.y" /* yacc.c:1646 */ { FIXME("Right shift\n"); } -#line 4318 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4298 "hlsl.tab.c" /* yacc.c:1646 */ break; case 141: -#line 2300 "hlsl.y" /* yacc.c:1646 */ +#line 2296 "hlsl.y" /* yacc.c:1646 */ { (yyval.instr) = (yyvsp[0].instr); } -#line 4326 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4306 "hlsl.tab.c" /* yacc.c:1646 */ break; case 142: -#line 2304 "hlsl.y" /* yacc.c:1646 */ +#line 2300 "hlsl.y" /* yacc.c:1646 */ { struct source_location loc; set_location(&loc, &(yylsp[-1])); (yyval.instr) = &hlsl_lt((yyvsp[-2].instr), (yyvsp[0].instr), &loc)->node; } -#line 4337 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4317 "hlsl.tab.c" /* yacc.c:1646 */ break; case 143: -#line 2311 "hlsl.y" /* yacc.c:1646 */ +#line 2307 "hlsl.y" /* yacc.c:1646 */ { struct source_location loc; set_location(&loc, &(yylsp[-1])); (yyval.instr) = &hlsl_gt((yyvsp[-2].instr), (yyvsp[0].instr), &loc)->node; } -#line 4348 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4328 "hlsl.tab.c" /* yacc.c:1646 */ break; case 144: -#line 2318 "hlsl.y" /* yacc.c:1646 */ +#line 2314 "hlsl.y" /* yacc.c:1646 */ { struct source_location loc; set_location(&loc, &(yylsp[-1])); (yyval.instr) = &hlsl_le((yyvsp[-2].instr), (yyvsp[0].instr), &loc)->node; } -#line 4359 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4339 "hlsl.tab.c" /* yacc.c:1646 */ break; case 145: -#line 2325 "hlsl.y" /* yacc.c:1646 */ +#line 2321 "hlsl.y" /* yacc.c:1646 */ { struct source_location loc; set_location(&loc, &(yylsp[-1])); (yyval.instr) = &hlsl_ge((yyvsp[-2].instr), (yyvsp[0].instr), &loc)->node; } -#line 4370 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4350 "hlsl.tab.c" /* yacc.c:1646 */ break; case 146: -#line 2333 "hlsl.y" /* yacc.c:1646 */ +#line 2329 "hlsl.y" /* yacc.c:1646 */ { (yyval.instr) = (yyvsp[0].instr); } -#line 4378 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4358 "hlsl.tab.c" /* yacc.c:1646 */ break; case 147: -#line 2337 "hlsl.y" /* yacc.c:1646 */ +#line 2333 "hlsl.y" /* yacc.c:1646 */ { struct source_location loc; set_location(&loc, &(yylsp[-1])); (yyval.instr) = &hlsl_eq((yyvsp[-2].instr), (yyvsp[0].instr), &loc)->node; } -#line 4389 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4369 "hlsl.tab.c" /* yacc.c:1646 */ break; case 148: -#line 2344 "hlsl.y" /* yacc.c:1646 */ +#line 2340 "hlsl.y" /* yacc.c:1646 */ { struct source_location loc; set_location(&loc, &(yylsp[-1])); (yyval.instr) = &hlsl_ne((yyvsp[-2].instr), (yyvsp[0].instr), &loc)->node; } -#line 4400 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4380 "hlsl.tab.c" /* yacc.c:1646 */ break; case 149: -#line 2352 "hlsl.y" /* yacc.c:1646 */ +#line 2348 "hlsl.y" /* yacc.c:1646 */ { (yyval.instr) = (yyvsp[0].instr); } -#line 4408 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4388 "hlsl.tab.c" /* yacc.c:1646 */ break; case 150: -#line 2356 "hlsl.y" /* yacc.c:1646 */ +#line 2352 "hlsl.y" /* yacc.c:1646 */ { FIXME("bitwise AND\n"); } -#line 4416 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4396 "hlsl.tab.c" /* yacc.c:1646 */ break; case 151: -#line 2361 "hlsl.y" /* yacc.c:1646 */ +#line 2357 "hlsl.y" /* yacc.c:1646 */ { (yyval.instr) = (yyvsp[0].instr); } -#line 4424 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4404 "hlsl.tab.c" /* yacc.c:1646 */ break; case 152: -#line 2365 "hlsl.y" /* yacc.c:1646 */ +#line 2361 "hlsl.y" /* yacc.c:1646 */ { FIXME("bitwise XOR\n"); } -#line 4432 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4412 "hlsl.tab.c" /* yacc.c:1646 */ break; case 153: -#line 2370 "hlsl.y" /* yacc.c:1646 */ +#line 2366 "hlsl.y" /* yacc.c:1646 */ { (yyval.instr) = (yyvsp[0].instr); } -#line 4440 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4420 "hlsl.tab.c" /* yacc.c:1646 */ break; case 154: -#line 2374 "hlsl.y" /* yacc.c:1646 */ +#line 2370 "hlsl.y" /* yacc.c:1646 */ { FIXME("bitwise OR\n"); } -#line 4448 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4428 "hlsl.tab.c" /* yacc.c:1646 */ break; case 155: -#line 2379 "hlsl.y" /* yacc.c:1646 */ +#line 2375 "hlsl.y" /* yacc.c:1646 */ { (yyval.instr) = (yyvsp[0].instr); } -#line 4456 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4436 "hlsl.tab.c" /* yacc.c:1646 */ break; case 156: -#line 2383 "hlsl.y" /* yacc.c:1646 */ +#line 2379 "hlsl.y" /* yacc.c:1646 */ { FIXME("logic AND\n"); } -#line 4464 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4444 "hlsl.tab.c" /* yacc.c:1646 */ break; case 157: -#line 2388 "hlsl.y" /* yacc.c:1646 */ +#line 2384 "hlsl.y" /* yacc.c:1646 */ { (yyval.instr) = (yyvsp[0].instr); } -#line 4472 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4452 "hlsl.tab.c" /* yacc.c:1646 */ break; case 158: -#line 2392 "hlsl.y" /* yacc.c:1646 */ +#line 2388 "hlsl.y" /* yacc.c:1646 */ { FIXME("logic OR\n"); } -#line 4480 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4460 "hlsl.tab.c" /* yacc.c:1646 */ break; case 159: -#line 2397 "hlsl.y" /* yacc.c:1646 */ +#line 2393 "hlsl.y" /* yacc.c:1646 */ { (yyval.instr) = (yyvsp[0].instr); } -#line 4488 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4468 "hlsl.tab.c" /* yacc.c:1646 */ break; case 160: -#line 2401 "hlsl.y" /* yacc.c:1646 */ +#line 2397 "hlsl.y" /* yacc.c:1646 */ { FIXME("ternary operator\n"); } -#line 4496 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4476 "hlsl.tab.c" /* yacc.c:1646 */ break; case 161: -#line 2406 "hlsl.y" /* yacc.c:1646 */ +#line 2402 "hlsl.y" /* yacc.c:1646 */ { (yyval.instr) = (yyvsp[0].instr); } -#line 4504 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4484 "hlsl.tab.c" /* yacc.c:1646 */ break; case 162: -#line 2410 "hlsl.y" /* yacc.c:1646 */ +#line 2406 "hlsl.y" /* yacc.c:1646 */ { struct source_location loc; @@ -4515,115 +4500,115 @@ yyreduce: return 1; (yyval.instr)->loc = loc; } -#line 4524 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4504 "hlsl.tab.c" /* yacc.c:1646 */ break; case 163: -#line 2427 "hlsl.y" /* yacc.c:1646 */ +#line 2423 "hlsl.y" /* yacc.c:1646 */ { (yyval.assign_op) = ASSIGN_OP_ASSIGN; } -#line 4532 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4512 "hlsl.tab.c" /* yacc.c:1646 */ break; case 164: -#line 2431 "hlsl.y" /* yacc.c:1646 */ +#line 2427 "hlsl.y" /* yacc.c:1646 */ { (yyval.assign_op) = ASSIGN_OP_ADD; } -#line 4540 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4520 "hlsl.tab.c" /* yacc.c:1646 */ break; case 165: -#line 2435 "hlsl.y" /* yacc.c:1646 */ +#line 2431 "hlsl.y" /* yacc.c:1646 */ { (yyval.assign_op) = ASSIGN_OP_SUB; } -#line 4548 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4528 "hlsl.tab.c" /* yacc.c:1646 */ break; case 166: -#line 2439 "hlsl.y" /* yacc.c:1646 */ +#line 2435 "hlsl.y" /* yacc.c:1646 */ { (yyval.assign_op) = ASSIGN_OP_MUL; } -#line 4556 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4536 "hlsl.tab.c" /* yacc.c:1646 */ break; case 167: -#line 2443 "hlsl.y" /* yacc.c:1646 */ +#line 2439 "hlsl.y" /* yacc.c:1646 */ { (yyval.assign_op) = ASSIGN_OP_DIV; } -#line 4564 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4544 "hlsl.tab.c" /* yacc.c:1646 */ break; case 168: -#line 2447 "hlsl.y" /* yacc.c:1646 */ +#line 2443 "hlsl.y" /* yacc.c:1646 */ { (yyval.assign_op) = ASSIGN_OP_MOD; } -#line 4572 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4552 "hlsl.tab.c" /* yacc.c:1646 */ break; case 169: -#line 2451 "hlsl.y" /* yacc.c:1646 */ +#line 2447 "hlsl.y" /* yacc.c:1646 */ { (yyval.assign_op) = ASSIGN_OP_LSHIFT; } -#line 4580 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4560 "hlsl.tab.c" /* yacc.c:1646 */ break; case 170: -#line 2455 "hlsl.y" /* yacc.c:1646 */ +#line 2451 "hlsl.y" /* yacc.c:1646 */ { (yyval.assign_op) = ASSIGN_OP_RSHIFT; } -#line 4588 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4568 "hlsl.tab.c" /* yacc.c:1646 */ break; case 171: -#line 2459 "hlsl.y" /* yacc.c:1646 */ +#line 2455 "hlsl.y" /* yacc.c:1646 */ { (yyval.assign_op) = ASSIGN_OP_AND; } -#line 4596 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4576 "hlsl.tab.c" /* yacc.c:1646 */ break; case 172: -#line 2463 "hlsl.y" /* yacc.c:1646 */ +#line 2459 "hlsl.y" /* yacc.c:1646 */ { (yyval.assign_op) = ASSIGN_OP_OR; } -#line 4604 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4584 "hlsl.tab.c" /* yacc.c:1646 */ break; case 173: -#line 2467 "hlsl.y" /* yacc.c:1646 */ +#line 2463 "hlsl.y" /* yacc.c:1646 */ { (yyval.assign_op) = ASSIGN_OP_XOR; } -#line 4612 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4592 "hlsl.tab.c" /* yacc.c:1646 */ break; case 174: -#line 2472 "hlsl.y" /* yacc.c:1646 */ +#line 2468 "hlsl.y" /* yacc.c:1646 */ { (yyval.instr) = (yyvsp[0].instr); } -#line 4620 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4600 "hlsl.tab.c" /* yacc.c:1646 */ break; case 175: -#line 2476 "hlsl.y" /* yacc.c:1646 */ +#line 2472 "hlsl.y" /* yacc.c:1646 */ { FIXME("Comma expression\n"); } -#line 4628 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4608 "hlsl.tab.c" /* yacc.c:1646 */ break; -#line 4632 "hlsl.tab.c" /* yacc.c:1646 */ +#line 4612 "hlsl.tab.c" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -4858,7 +4843,7 @@ yyreturn: #endif return yyresult; } -#line 2480 "hlsl.y" /* yacc.c:1906 */ +#line 2476 "hlsl.y" /* yacc.c:1906 */ static void set_location(struct source_location *loc, const struct YYLTYPE *l) diff --git a/dll/directx/wine/d3dcompiler_43/hlsl.tab.h b/dll/directx/wine/d3dcompiler_43/hlsl.tab.h index c9fa66dfc7..8ca95d0a65 100644 --- a/dll/directx/wine/d3dcompiler_43/hlsl.tab.h +++ b/dll/directx/wine/d3dcompiler_43/hlsl.tab.h @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 3.0.2. */ +/* A Bison parser, made by GNU Bison 3.0. */ /* Bison interface for Yacc-like parsers in C @@ -30,8 +30,8 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ -#ifndef YY_HLSL_HLSL_TAB_H_INCLUDED -# define YY_HLSL_HLSL_TAB_H_INCLUDED +#ifndef YY_HLSL_E_REACTOSSYNC3_0_GCC_DLL_DIRECTX_WINE_D3DCOMPILER_43_HLSL_TAB_H_INCLUDED +# define YY_HLSL_E_REACTOSSYNC3_0_GCC_DLL_DIRECTX_WINE_D3DCOMPILER_43_HLSL_TAB_H_INCLUDED /* Debug traces. */ #ifndef YYDEBUG # define YYDEBUG 0 @@ -155,7 +155,7 @@ extern int hlsl_debug; typedef union YYSTYPE YYSTYPE; union YYSTYPE { -#line 910 "hlsl.y" /* yacc.c:1909 */ +#line 906 "hlsl.y" /* yacc.c:1909 */ struct hlsl_type *type; INT intval; @@ -200,4 +200,4 @@ extern YYSTYPE hlsl_lval; extern YYLTYPE hlsl_lloc; int hlsl_parse (void); -#endif /* !YY_HLSL_HLSL_TAB_H_INCLUDED */ +#endif /* !YY_HLSL_E_REACTOSSYNC3_0_GCC_DLL_DIRECTX_WINE_D3DCOMPILER_43_HLSL_TAB_H_INCLUDED */ diff --git a/dll/directx/wine/d3dcompiler_43/hlsl.y b/dll/directx/wine/d3dcompiler_43/hlsl.y index c5f66d6a1b..f8bcdab979 100644 --- a/dll/directx/wine/d3dcompiler_43/hlsl.y +++ b/dll/directx/wine/d3dcompiler_43/hlsl.y @@ -19,10 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ %{ -#include "config.h" -#include "wine/debug.h" - -#include <stdio.h> #include "d3dcompiler_private.h" @@ -1151,7 +1147,7 @@ preproc_directive: PRE_LINE STRING hlsl_ctx.line_no = $1; if (strcmp($2, hlsl_ctx.source_file)) new_array = d3dcompiler_realloc(hlsl_ctx.source_files, - sizeof(*hlsl_ctx.source_files) * hlsl_ctx.source_files_count + 1); + sizeof(*hlsl_ctx.source_files) * (hlsl_ctx.source_files_count + 1)); if (new_array) { diff --git a/media/doc/README.WINE b/media/doc/README.WINE index a8bf774a0e..98995a1c54 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -24,7 +24,7 @@ The following libraries are shared with Wine. reactos/dll/directx/wine/amstream # Synced to Wine-3.0 reactos/dll/directx/wine/d3d8 # Synced to Wine-3.0 reactos/dll/directx/wine/d3d9 # Synced to Wine-3.0 -reactos/dll/directx/wine/d3dcompiler_43 # Synced to WineStaging-2.16 +reactos/dll/directx/wine/d3dcompiler_43 # Synced to Wine-3.0 reactos/dll/directx/wine/d3drm # Synced to WineStaging-2.16 reactos/dll/directx/wine/d3dx9_24 => 43 # Synced to WineStaging-2.16 reactos/dll/directx/wine/d3dxof # Synced to WineStaging-2.9
6 years, 11 months
1
0
0
0
01/01: [D3D9][WINED3D] Sync with Wine 3.0. CORE-14225
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d6ac0a71ade77d2496489…
commit d6ac0a71ade77d24964892390956db78bff3531e Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sun Jan 21 22:20:57 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sun Jan 21 22:20:57 2018 +0100 [D3D9][WINED3D] Sync with Wine 3.0. CORE-14225 --- dll/directx/wine/d3d9/d3d9_private.h | 3 +- dll/directx/wine/d3d9/device.c | 75 +- dll/directx/wine/d3d9/directx.c | 3 +- dll/directx/wine/d3d9/query.c | 6 +- dll/directx/wine/d3d9/texture.c | 24 +- dll/directx/wine/wined3d/arb_program_shader.c | 30 +- dll/directx/wine/wined3d/buffer.c | 75 +- dll/directx/wine/wined3d/context.c | 222 +- dll/directx/wine/wined3d/cs.c | 385 +- dll/directx/wine/wined3d/device.c | 227 +- dll/directx/wine/wined3d/directx.c | 185 +- dll/directx/wine/wined3d/drawprim.c | 190 +- dll/directx/wine/wined3d/glsl_shader.c | 1063 ++- dll/directx/wine/wined3d/query.c | 102 +- dll/directx/wine/wined3d/resource.c | 129 +- dll/directx/wine/wined3d/sampler.c | 4 +- dll/directx/wine/wined3d/shader.c | 196 +- dll/directx/wine/wined3d/shader_sm4.c | 17 +- dll/directx/wine/wined3d/state.c | 224 +- dll/directx/wine/wined3d/stateblock.c | 26 +- dll/directx/wine/wined3d/surface.c | 452 +- dll/directx/wine/wined3d/swapchain.c | 13 +- dll/directx/wine/wined3d/texture.c | 686 +- dll/directx/wine/wined3d/utils.c | 562 +- dll/directx/wine/wined3d/vertexdeclaration.c | 9 - dll/directx/wine/wined3d/view.c | 153 +- dll/directx/wine/wined3d/wined3d.spec | 14 +- dll/directx/wine/wined3d/wined3d_gl.h | 6 +- dll/directx/wine/wined3d/wined3d_main.c | 25 +- dll/directx/wine/wined3d/wined3d_private.h | 304 +- media/doc/README.WINE | 4 +- sdk/include/reactos/wine/wgl.h | 11400 +++++++++++------------- sdk/include/reactos/wine/wgl_driver.h | 5819 ++++++------ sdk/include/reactos/wine/wined3d.h | 54 +- 34 files changed, 10583 insertions(+), 12104 deletions(-) diff --git a/dll/directx/wine/d3d9/d3d9_private.h b/dll/directx/wine/d3d9/d3d9_private.h index 2649a5bc96..d34dd73137 100644 --- a/dll/directx/wine/d3d9/d3d9_private.h +++ b/dll/directx/wine/d3d9/d3d9_private.h @@ -37,7 +37,6 @@ #define COBJMACROS #include <windef.h> #include <winbase.h> -#include <winuser.h> #include <wingdi.h> #include <wine/debug.h> @@ -104,6 +103,8 @@ struct d3d9_device BOOL in_scene; BOOL has_vertex_declaration; + unsigned int max_user_clip_planes; + UINT implicit_swapchain_count; struct d3d9_swapchain **implicit_swapchains; }; diff --git a/dll/directx/wine/d3d9/device.c b/dll/directx/wine/d3d9/device.c index 459a24ddf0..b3e085f34d 100644 --- a/dll/directx/wine/d3d9/device.c +++ b/dll/directx/wine/d3d9/device.c @@ -22,6 +22,8 @@ #include "d3d9_private.h" +#include <winuser.h> + static void STDMETHODCALLTYPE d3d9_null_wined3d_object_destroyed(void *parent) {} const struct wined3d_parent_ops d3d9_null_wined3d_parent_ops = @@ -236,8 +238,6 @@ static BOOL wined3d_swapchain_desc_from_present_parameters(struct wined3d_swapch = wined3dformat_from_d3dformat(present_parameters->AutoDepthStencilFormat); swapchain_desc->flags = (present_parameters->Flags & D3DPRESENTFLAGS_MASK) | WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH; - if (is_gdi_compat_wined3dformat(swapchain_desc->backbuffer_format)) - swapchain_desc->flags |= WINED3D_SWAPCHAIN_GDI_COMPATIBLE; swapchain_desc->refresh_rate = present_parameters->FullScreen_RefreshRateInHz; swapchain_desc->swap_interval = present_parameters->PresentationInterval; swapchain_desc->auto_restore_display_mode = TRUE; @@ -811,11 +811,13 @@ static HRESULT d3d9_device_get_swapchains(struct d3d9_device *device) static HRESULT d3d9_device_reset(struct d3d9_device *device, D3DPRESENT_PARAMETERS *present_parameters, D3DDISPLAYMODEEX *mode) { + BOOL extended = device->d3d_parent->extended; struct wined3d_swapchain_desc swapchain_desc; struct wined3d_display_mode wined3d_mode; HRESULT hr; - if (!device->d3d_parent->extended && device->device_state == D3D9_DEVICE_STATE_LOST) + + if (!extended && device->device_state == D3D9_DEVICE_STATE_LOST) { WARN("App not active, returning D3DERR_DEVICELOST.\n"); return D3DERR_DEVICELOST; @@ -830,8 +832,7 @@ static HRESULT d3d9_device_reset(struct d3d9_device *device, wined3d_mode.scanline_ordering = mode->ScanLineOrdering; } - if (!wined3d_swapchain_desc_from_present_parameters(&swapchain_desc, present_parameters, - device->d3d_parent->extended)) + if (!wined3d_swapchain_desc_from_present_parameters(&swapchain_desc, present_parameters, extended)) return D3DERR_INVALIDCALL; wined3d_mutex_lock(); @@ -851,10 +852,16 @@ static HRESULT d3d9_device_reset(struct d3d9_device *device, } if (SUCCEEDED(hr = wined3d_device_reset(device->wined3d_device, &swapchain_desc, - mode ? &wined3d_mode : NULL, reset_enum_callback, !device->d3d_parent->extended))) + mode ? &wined3d_mode : NULL, reset_enum_callback, !extended))) { HeapFree(GetProcessHeap(), 0, device->implicit_swapchains); + if (!extended) + { + wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ZENABLE, + !!swapchain_desc.enable_auto_depth_stencil); + } + if (FAILED(hr = d3d9_device_get_swapchains(device))) { device->device_state = D3D9_DEVICE_STATE_NOT_RESET; @@ -870,7 +877,7 @@ static HRESULT d3d9_device_reset(struct d3d9_device *device, device->device_state = D3D9_DEVICE_STATE_OK; } } - else if (!device->d3d_parent->extended) + else if (!extended) { device->device_state = D3D9_DEVICE_STATE_NOT_RESET; } @@ -1392,20 +1399,35 @@ static HRESULT WINAPI d3d9_device_UpdateSurface(IDirect3DDevice9Ex *iface, struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); struct d3d9_surface *src = unsafe_impl_from_IDirect3DSurface9(src_surface); struct d3d9_surface *dst = unsafe_impl_from_IDirect3DSurface9(dst_surface); + struct wined3d_sub_resource_desc src_desc, dst_desc; struct wined3d_box src_box; HRESULT hr; TRACE("iface %p, src_surface %p, src_rect %p, dst_surface %p, dst_point %p.\n", iface, src_surface, src_rect, dst_surface, dst_point); + wined3d_mutex_lock(); + + wined3d_texture_get_sub_resource_desc(src->wined3d_texture, src->sub_resource_idx, &src_desc); + wined3d_texture_get_sub_resource_desc(dst->wined3d_texture, dst->sub_resource_idx, &dst_desc); + if (src_desc.format != dst_desc.format) + { + wined3d_mutex_unlock(); + WARN("Surface formats (%#x/%#x) don't match.\n", + d3dformat_from_wined3dformat(src_desc.format), + d3dformat_from_wined3dformat(dst_desc.format)); + return D3DERR_INVALIDCALL; + } + if (src_rect) wined3d_box_set(&src_box, src_rect->left, src_rect->top, src_rect->right, src_rect->bottom, 0, 1); + else + wined3d_box_set(&src_box, 0, 0, src_desc.width, src_desc.height, 0, 1); - wined3d_mutex_lock(); hr = wined3d_device_copy_sub_resource_region(device->wined3d_device, wined3d_texture_get_resource(dst->wined3d_texture), dst->sub_resource_idx, dst_point ? dst_point->x : 0, dst_point ? dst_point->y : 0, 0, wined3d_texture_get_resource(src->wined3d_texture), - src->sub_resource_idx, src_rect ? &src_box : NULL); + src->sub_resource_idx, &src_box); wined3d_mutex_unlock(); if (FAILED(hr)) @@ -2014,6 +2036,8 @@ static HRESULT WINAPI d3d9_device_SetClipPlane(IDirect3DDevice9Ex *iface, DWORD TRACE("iface %p, index %u, plane %p.\n", iface, index, plane); + index = min(index, device->max_user_clip_planes - 1); + wined3d_mutex_lock(); hr = wined3d_device_set_clip_plane(device->wined3d_device, index, (const struct wined3d_vec4 *)plane); wined3d_mutex_unlock(); @@ -2028,6 +2052,8 @@ static HRESULT WINAPI d3d9_device_GetClipPlane(IDirect3DDevice9Ex *iface, DWORD TRACE("iface %p, index %u, plane %p.\n", iface, index, plane); + index = min(index, device->max_user_clip_planes - 1); + wined3d_mutex_lock(); hr = wined3d_device_get_clip_plane(device->wined3d_device, index, (struct wined3d_vec4 *)plane); wined3d_mutex_unlock(); @@ -3547,9 +3573,12 @@ static HRESULT WINAPI d3d9_device_CheckResourceResidency(IDirect3DDevice9Ex *ifa static HRESULT WINAPI d3d9_device_SetMaximumFrameLatency(IDirect3DDevice9Ex *iface, UINT max_latency) { - FIXME("iface %p, max_latency %u stub!\n", iface, max_latency); + TRACE("iface %p, max_latency %u.\n", iface, max_latency); - return E_NOTIMPL; + if (max_latency) + FIXME("Ignoring max_latency %u.\n", max_latency); + + return S_OK; } static HRESULT WINAPI d3d9_device_GetMaximumFrameLatency(IDirect3DDevice9Ex *iface, UINT *max_latency) @@ -3919,6 +3948,9 @@ static HRESULT CDECL device_parent_create_swapchain_texture(struct wined3d_devic if (container_parent == device_parent) container_parent = &device->IDirect3DDevice9Ex_iface; + if (is_gdi_compat_wined3dformat(desc->format)) + texture_flags |= WINED3D_TEXTURE_CREATE_GET_DC; + if (FAILED(hr = wined3d_texture_create(device->wined3d_device, desc, 1, 1, texture_flags | WINED3D_TEXTURE_CREATE_MAPPABLE, NULL, container_parent, &d3d9_null_wined3d_parent_ops, texture))) @@ -3990,7 +4022,8 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine D3DPRESENT_PARAMETERS *parameters, D3DDISPLAYMODEEX *mode) { struct wined3d_swapchain_desc *swapchain_desc; - UINT i, count = 1; + unsigned i, count = 1; + WINED3DCAPS caps; HRESULT hr; if (mode) @@ -4003,22 +4036,18 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine if (!(flags & D3DCREATE_FPU_PRESERVE)) setup_fpu(); wined3d_mutex_lock(); - hr = wined3d_device_create(wined3d, adapter, device_type, focus_window, flags, 4, - &device->device_parent, &device->wined3d_device); - if (FAILED(hr)) + if (FAILED(hr = wined3d_device_create(wined3d, adapter, device_type, focus_window, flags, 4, + &device->device_parent, &device->wined3d_device))) { WARN("Failed to create wined3d device, hr %#x.\n", hr); wined3d_mutex_unlock(); return hr; } + wined3d_get_device_caps(wined3d, adapter, device_type, &caps); + device->max_user_clip_planes = caps.MaxUserClipPlanes; if (flags & D3DCREATE_ADAPTERGROUP_DEVICE) - { - WINED3DCAPS caps; - - wined3d_get_device_caps(wined3d, adapter, device_type, &caps); count = caps.NumberOfAdaptersInGroup; - } if (flags & D3DCREATE_MULTITHREADED) wined3d_device_set_multithreaded(device->wined3d_device); @@ -4069,8 +4098,7 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine } } - hr = wined3d_device_init_3d(device->wined3d_device, swapchain_desc); - if (FAILED(hr)) + if (FAILED(hr = wined3d_device_init_3d(device->wined3d_device, swapchain_desc))) { WARN("Failed to initialize 3D, hr %#x.\n", hr); wined3d_device_release_focus_window(device->wined3d_device); @@ -4080,6 +4108,9 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine return hr; } + wined3d_device_set_render_state(device->wined3d_device, + WINED3D_RS_ZENABLE, !!swapchain_desc->enable_auto_depth_stencil); + if (FAILED(hr = d3d9_device_get_swapchains(device))) { wined3d_device_uninit_3d(device->wined3d_device); diff --git a/dll/directx/wine/d3d9/directx.c b/dll/directx/wine/d3d9/directx.c index 9eec0abeca..ab153a9030 100644 --- a/dll/directx/wine/d3d9/directx.c +++ b/dll/directx/wine/d3d9/directx.c @@ -577,7 +577,8 @@ BOOL d3d9_init(struct d3d9 *d3d9, BOOL extended) { DWORD flags = WINED3D_PRESENT_CONVERSION | WINED3D_HANDLE_RESTORE | WINED3D_PIXEL_CENTER_INTEGER | WINED3D_SRGB_READ_WRITE_CONTROL | WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR - | WINED3D_NO_PRIMITIVE_RESTART | WINED3D_LEGACY_CUBEMAP_FILTERING | WINED3D_LIMIT_VIEWPORT; + | WINED3D_NO_PRIMITIVE_RESTART | WINED3D_LEGACY_CUBEMAP_FILTERING + | WINED3D_NORMALIZED_DEPTH_BIAS; if (!extended) flags |= WINED3D_VIDMEM_ACCOUNTING; diff --git a/dll/directx/wine/d3d9/query.c b/dll/directx/wine/d3d9/query.c index 90187566bd..8681502c49 100644 --- a/dll/directx/wine/d3d9/query.c +++ b/dll/directx/wine/d3d9/query.c @@ -184,7 +184,11 @@ HRESULT query_init(struct d3d9_query *query, struct d3d9_device *device, D3DQUER if (type > D3DQUERYTYPE_MEMORYPRESSURE) { - WARN("Invalid query type %#x.\n", type); + if (type == 0x16) + FIXME("Undocumented query %#x created.\n", type); + else + WARN("Invalid query type %#x.\n", type); + return D3DERR_NOTAVAILABLE; } diff --git a/dll/directx/wine/d3d9/texture.c b/dll/directx/wine/d3d9/texture.c index 5e9979a4ce..16909d6888 100644 --- a/dll/directx/wine/d3d9/texture.c +++ b/dll/directx/wine/d3d9/texture.c @@ -22,17 +22,17 @@ static inline struct d3d9_texture *impl_from_IDirect3DTexture9(IDirect3DTexture9 *iface) { - return CONTAINING_RECORD((IDirect3DBaseTexture9 *)iface, struct d3d9_texture, IDirect3DBaseTexture9_iface); + return CONTAINING_RECORD(iface, struct d3d9_texture, IDirect3DBaseTexture9_iface); } static inline struct d3d9_texture *impl_from_IDirect3DCubeTexture9(IDirect3DCubeTexture9 *iface) { - return CONTAINING_RECORD((IDirect3DBaseTexture9 *)iface, struct d3d9_texture, IDirect3DBaseTexture9_iface); + return CONTAINING_RECORD(iface, struct d3d9_texture, IDirect3DBaseTexture9_iface); } static inline struct d3d9_texture *impl_from_IDirect3DVolumeTexture9(IDirect3DVolumeTexture9 *iface) { - return CONTAINING_RECORD((IDirect3DBaseTexture9 *)iface, struct d3d9_texture, IDirect3DBaseTexture9_iface); + return CONTAINING_RECORD(iface, struct d3d9_texture, IDirect3DBaseTexture9_iface); } static HRESULT WINAPI d3d9_texture_2d_QueryInterface(IDirect3DTexture9 *iface, REFIID riid, void **out) @@ -270,13 +270,7 @@ static D3DTEXTUREFILTERTYPE WINAPI d3d9_texture_2d_GetAutoGenFilterType(IDirect3 static void WINAPI d3d9_texture_2d_GenerateMipSubLevels(IDirect3DTexture9 *iface) { - struct d3d9_texture *texture = impl_from_IDirect3DTexture9(iface); - TRACE("iface %p.\n", iface); - - wined3d_mutex_lock(); - wined3d_texture_generate_mipmaps(texture->wined3d_texture); - wined3d_mutex_unlock(); } static HRESULT WINAPI d3d9_texture_2d_GetLevelDesc(IDirect3DTexture9 *iface, UINT level, D3DSURFACE_DESC *desc) @@ -655,13 +649,7 @@ static D3DTEXTUREFILTERTYPE WINAPI d3d9_texture_cube_GetAutoGenFilterType(IDirec static void WINAPI d3d9_texture_cube_GenerateMipSubLevels(IDirect3DCubeTexture9 *iface) { - struct d3d9_texture *texture = impl_from_IDirect3DCubeTexture9(iface); - TRACE("iface %p.\n", iface); - - wined3d_mutex_lock(); - wined3d_texture_generate_mipmaps(texture->wined3d_texture); - wined3d_mutex_unlock(); } static HRESULT WINAPI d3d9_texture_cube_GetLevelDesc(IDirect3DCubeTexture9 *iface, UINT level, D3DSURFACE_DESC *desc) @@ -1052,13 +1040,7 @@ static D3DTEXTUREFILTERTYPE WINAPI d3d9_texture_3d_GetAutoGenFilterType(IDirect3 static void WINAPI d3d9_texture_3d_GenerateMipSubLevels(IDirect3DVolumeTexture9 *iface) { - struct d3d9_texture *texture = impl_from_IDirect3DVolumeTexture9(iface); - TRACE("iface %p.\n", iface); - - wined3d_mutex_lock(); - wined3d_texture_generate_mipmaps(texture->wined3d_texture); - wined3d_mutex_unlock(); } static HRESULT WINAPI d3d9_texture_3d_GetLevelDesc(IDirect3DVolumeTexture9 *iface, UINT level, D3DVOLUME_DESC *desc) diff --git a/dll/directx/wine/wined3d/arb_program_shader.c b/dll/directx/wine/wined3d/arb_program_shader.c index ba5ccb38ca..00a260f21d 100644 --- a/dll/directx/wine/wined3d/arb_program_shader.c +++ b/dll/directx/wine/wined3d/arb_program_shader.c @@ -872,7 +872,7 @@ static void shader_generate_arb_declarations(const struct wined3d_shader *shader /* After subtracting privately used constants from the hardware limit(they are loaded as * local constants), make sure the shader doesn't violate the env constant limit */ - if(pshader) + if (pshader) { max_constantsF = min(max_constantsF, gl_info->limits.arb_ps_float_constants); } @@ -900,10 +900,7 @@ static void shader_generate_arb_declarations(const struct wined3d_shader *shader { for (i = 0; i < max_constantsF; ++i) { - DWORD idx, mask; - idx = i >> 5; - mask = 1u << (i & 0x1fu); - if (!shader_constant_is_local(shader, i) && (reg_maps->constf[idx] & mask)) + if (!shader_constant_is_local(shader, i) && wined3d_extract_bits(reg_maps->constf, i, 1)) { shader_addline(buffer, "PARAM C%d = program.env[%d];\n",i, i); } @@ -1188,8 +1185,6 @@ static void shader_arb_get_register_name(const struct wined3d_shader_instruction sprintf(register_name, "%s", rastout_reg_names[reg->idx[0].offset]); break; - case WINED3DSPR_DEPTHOUT_GREATER_EQUAL: - case WINED3DSPR_DEPTHOUT_LESS_EQUAL: case WINED3DSPR_DEPTHOUT: strcpy(register_name, "result.depth"); break; @@ -4490,7 +4485,7 @@ static void find_arb_vs_compile_args(const struct wined3d_state *state, int i; WORD int_skip; - find_vs_compile_args(state, shader, context->stream_info.swizzle_map, &args->super, d3d_info); + find_vs_compile_args(state, shader, context->stream_info.swizzle_map, &args->super, context); args->clip.boolclip_compare = 0; if (use_ps(state)) @@ -5089,6 +5084,7 @@ static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABL /* WINED3DSIH_DSY */ shader_hw_dsy, /* WINED3DSIH_DSY_COARSE */ NULL, /* WINED3DSIH_DSY_FINE */ NULL, + /* WINED3DSIH_EVAL_SAMPLE_INDEX */ NULL, /* WINED3DSIH_ELSE */ shader_hw_else, /* WINED3DSIH_EMIT */ NULL, /* WINED3DSIH_EMIT_STREAM */ NULL, @@ -7705,6 +7701,14 @@ static BOOL arbfp_blit_supported(const struct wined3d_gl_info *gl_info, if (!gl_info->supported[ARB_FRAGMENT_PROGRAM]) return FALSE; + if (blit_op == WINED3D_BLIT_OP_RAW_BLIT && dst_format->id == src_format->id) + { + if (dst_format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)) + blit_op = WINED3D_BLIT_OP_DEPTH_BLIT; + else + blit_op = WINED3D_BLIT_OP_COLOR_BLIT; + } + switch (blit_op) { case WINED3D_BLIT_OP_COLOR_BLIT_CKEY: @@ -7778,7 +7782,7 @@ static BOOL arbfp_blit_supported(const struct wined3d_gl_info *gl_info, } } -static void arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_op op, +static DWORD arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit_op op, struct wined3d_context *context, struct wined3d_surface *src_surface, DWORD src_location, const RECT *src_rect, struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect, const struct wined3d_color_key *color_key, enum wined3d_texture_filter_type filter) @@ -7796,9 +7800,8 @@ static void arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bli dst_texture->resource.pool, dst_texture->resource.format, dst_location)) { if ((next = blitter->next)) - next->ops->blitter_blit(next, op, context, src_surface, src_location, + return next->ops->blitter_blit(next, op, context, src_surface, src_location, src_rect, dst_surface, dst_location, dst_rect, color_key, filter); - return; } arbfp_blitter = CONTAINING_RECORD(blitter, struct wined3d_arbfp_blitter, blitter); @@ -7873,6 +7876,8 @@ static void arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bli if (wined3d_settings.strict_draw_ordering || (dst_texture->swapchain && (dst_texture->swapchain->front_buffer == dst_texture))) context->gl_info->gl_ops.gl.p_glFlush(); /* Flush to ensure ordering across contexts. */ + + return dst_location; } static void arbfp_blitter_clear(struct wined3d_blitter *blitter, struct wined3d_device *device, @@ -7905,6 +7910,9 @@ void wined3d_arbfp_blitter_create(struct wined3d_blitter **next, const struct wi if (!gl_info->supported[ARB_FRAGMENT_PROGRAM]) return; + if (!gl_info->supported[WINED3D_GL_LEGACY_CONTEXT]) + return; + if (!(blitter = HeapAlloc(GetProcessHeap(), 0, sizeof(*blitter)))) { ERR("Failed to allocate blitter.\n"); diff --git a/dll/directx/wine/wined3d/buffer.c b/dll/directx/wine/wined3d/buffer.c index 02d081d938..0e8f5a3e01 100644 --- a/dll/directx/wine/wined3d/buffer.c +++ b/dll/directx/wine/wined3d/buffer.c @@ -529,7 +529,7 @@ ULONG CDECL wined3d_buffer_incref(struct wined3d_buffer *buffer) /* Context activation is done by the caller. */ static void wined3d_buffer_upload_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context, - const void *data, unsigned int range_count, const struct wined3d_map_range *ranges) + const void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_map_range *ranges) { const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_map_range *range; @@ -540,7 +540,7 @@ static void wined3d_buffer_upload_ranges(struct wined3d_buffer *buffer, struct w { range = &ranges[range_count]; GL_EXTCALL(glBufferSubData(buffer->buffer_type_hint, - range->offset, range->size, (BYTE *)data + range->offset)); + range->offset, range->size, (BYTE *)data + range->offset - data_offset)); } checkGLcall("glBufferSubData"); } @@ -596,7 +596,7 @@ static void buffer_conversion_upload(struct wined3d_buffer *buffer, struct wined } } - wined3d_buffer_upload_ranges(buffer, context, data, buffer->modified_areas, buffer->maps); + wined3d_buffer_upload_ranges(buffer, context, data, 0, buffer->modified_areas, buffer->maps); HeapFree(GetProcessHeap(), 0, data); } @@ -680,7 +680,7 @@ BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer, case WINED3D_LOCATION_BUFFER: if (!buffer->conversion_map) wined3d_buffer_upload_ranges(buffer, context, buffer->resource.heap_memory, - buffer->modified_areas, buffer->maps); + 0, buffer->modified_areas, buffer->maps); else buffer_conversion_upload(buffer, context); break; @@ -1212,41 +1212,23 @@ void wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_off wined3d_buffer_invalidate_range(dst_buffer, ~dst_location, dst_offset, size); } -HRESULT wined3d_buffer_upload_data(struct wined3d_buffer *buffer, +void wined3d_buffer_upload_data(struct wined3d_buffer *buffer, struct wined3d_context *context, const struct wined3d_box *box, const void *data) { - UINT offset, size; -#if defined(STAGING_CSMT) - DWORD flags = 0; -#endif /* STAGING_CSMT */ - HRESULT hr; - BYTE *ptr; + struct wined3d_map_range range; if (box) { - offset = box->left; - size = box->right - box->left; + range.offset = box->left; + range.size = box->right - box->left; } else { - offset = 0; - size = buffer->resource.size; + range.offset = 0; + range.size = buffer->resource.size; } -#if !defined(STAGING_CSMT) - if (FAILED(hr = wined3d_buffer_map(buffer, offset, size, &ptr, 0))) -#else /* STAGING_CSMT */ - if (offset == 0 && size == buffer->resource.size) - flags = WINED3D_MAP_DISCARD; - - if (FAILED(hr = wined3d_buffer_map(buffer, offset, size, &ptr, flags))) -#endif /* STAGING_CSMT */ - return hr; - - memcpy(ptr, data, size); - - wined3d_buffer_unmap(buffer); - return WINED3D_OK; + wined3d_buffer_upload_ranges(buffer, context, data, range.offset, 1, &range); } static ULONG buffer_resource_incref(struct wined3d_resource *resource) @@ -1294,24 +1276,6 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc return wined3d_buffer_map(buffer, offset, size, (BYTE **)&map_desc->data, flags); } -static HRESULT buffer_resource_sub_resource_map_info(struct wined3d_resource *resource, unsigned int sub_resource_idx, - struct wined3d_map_info *info, DWORD flags) -{ - struct wined3d_buffer *buffer = buffer_from_resource(resource); - - if (sub_resource_idx) - { - WARN("Invalid sub_resource_idx %u.\n", sub_resource_idx); - return E_INVALIDARG; - } - - info->row_pitch = buffer->desc.byte_width; - info->slice_pitch = buffer->desc.byte_width; - info->size = buffer->resource.size; - - return WINED3D_OK; -} - static HRESULT buffer_resource_sub_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx) { if (sub_resource_idx) @@ -1331,7 +1295,6 @@ static const struct wined3d_resource_ops buffer_resource_ops = buffer_resource_preload, buffer_unload, buffer_resource_sub_resource_map, - buffer_resource_sub_resource_map_info, buffer_resource_sub_resource_unmap, }; @@ -1452,7 +1415,6 @@ HRESULT CDECL wined3d_buffer_create(struct wined3d_device *device, const struct struct wined3d_buffer **buffer) { struct wined3d_buffer *object; - enum wined3d_pool pool; HRESULT hr; TRACE("device %p, desc %p, data %p, parent %p, parent_ops %p, buffer %p.\n", @@ -1463,21 +1425,8 @@ HRESULT CDECL wined3d_buffer_create(struct wined3d_device *device, const struct FIXME("Ignoring access flags (pool).\n"); - /* Some applications map the whole buffer even if they - * only update a small portion of it. If we pin such a - * buffer into system memory things get very slow as - * we upload the whole buffer even though just parts of - * it changed. Most drivers can handle this case more - * efficient using the OpenGL map functions. Applications - * affected by this problem are Banished and Witcher 3. - */ - if (desc->byte_width > 0x10000) - pool = WINED3D_POOL_DEFAULT; - else - pool = WINED3D_POOL_MANAGED; - if (FAILED(hr = buffer_init(object, device, desc->byte_width, desc->usage, WINED3DFMT_UNKNOWN, - pool, desc->bind_flags, data, parent, parent_ops))) + WINED3D_POOL_MANAGED, desc->bind_flags, data, parent, parent_ops))) { WARN("Failed to initialize buffer, hr %#x.\n", hr); HeapFree(GetProcessHeap(), 0, object); diff --git a/dll/directx/wine/wined3d/context.c b/dll/directx/wine/wined3d/context.c index 80164c0011..bd0ae564fb 100644 --- a/dll/directx/wine/wined3d/context.c +++ b/dll/directx/wine/wined3d/context.c @@ -131,8 +131,7 @@ static void context_attach_gl_texture_fbo(struct wined3d_context *context, gl_info->fbo_ops.glFramebufferTexture(fbo_target, attachment, resource->object, resource->level); } - else if (resource->target == GL_TEXTURE_1D_ARRAY || resource->target == GL_TEXTURE_2D_ARRAY || - resource->target == GL_TEXTURE_3D) + else if (resource->target == GL_TEXTURE_2D_ARRAY || resource->target == GL_TEXTURE_3D) { if (!gl_info->fbo_ops.glFramebufferTextureLayer) { @@ -143,12 +142,6 @@ static void context_attach_gl_texture_fbo(struct wined3d_context *context, gl_info->fbo_ops.glFramebufferTextureLayer(fbo_target, attachment, resource->object, resource->level, resource->layer); } - else if (resource->target == GL_TEXTURE_1D) - { - gl_info->fbo_ops.glFramebufferTexture1D(fbo_target, attachment, - resource->target, resource->object, resource->level); - checkGLcall("glFramebufferTexture1D()"); - } else { gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, attachment, @@ -288,7 +281,7 @@ static void context_dump_fbo_attachment(const struct wined3d_gl_info *gl_info, G unsigned int i; tex_type_str = NULL; - for (i = 0; i < sizeof(texture_type) / sizeof(*texture_type); ++i) + for (i = 0; i < ARRAY_SIZE(texture_type); ++i) { if (!gl_info->supported[texture_type[i].extension]) continue; @@ -1706,7 +1699,6 @@ void context_bind_dummy_textures(const struct wined3d_device *device, const stru GL_EXTCALL(glActiveTexture(GL_TEXTURE0 + i)); checkGLcall("glActiveTexture"); - gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D, device->dummy_textures.tex_1d); gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, device->dummy_textures.tex_2d); if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) @@ -1722,10 +1714,7 @@ void context_bind_dummy_textures(const struct wined3d_device *device, const stru gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, device->dummy_textures.tex_cube_array); if (gl_info->supported[EXT_TEXTURE_ARRAY]) - { - gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D_ARRAY, device->dummy_textures.tex_1d_array); gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D_ARRAY, device->dummy_textures.tex_2d_array); - } if (gl_info->supported[ARB_TEXTURE_BUFFER_OBJECT]) gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_BUFFER, device->dummy_textures.tex_buffer); @@ -2326,10 +2315,13 @@ static void set_blit_dimension(const struct wined3d_gl_info *gl_info, UINT width -1.0, -1.0, -1.0, 1.0, }; - gl_info->gl_ops.gl.p_glMatrixMode(GL_PROJECTION); - checkGLcall("glMatrixMode(GL_PROJECTION)"); - gl_info->gl_ops.gl.p_glLoadMatrixd(projection); - checkGLcall("glLoadMatrixd"); + if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT]) + { + gl_info->gl_ops.gl.p_glMatrixMode(GL_PROJECTION); + checkGLcall("glMatrixMode(GL_PROJECTION)"); + gl_info->gl_ops.gl.p_glLoadMatrixd(projection); + checkGLcall("glLoadMatrixd"); + } gl_info->gl_ops.gl.p_glViewport(0, 0, width, height); checkGLcall("glViewport"); } @@ -2355,6 +2347,33 @@ static void context_get_rt_size(const struct wined3d_context *context, SIZE *siz size->cy = wined3d_texture_get_level_height(rt, level); } +void context_enable_clip_distances(struct wined3d_context *context, unsigned int enable_mask) +{ + const struct wined3d_gl_info *gl_info = context->gl_info; + unsigned int clip_distance_count = gl_info->limits.user_clip_distances; + unsigned int i, disable_mask, current_mask; + + disable_mask = ~enable_mask; + enable_mask &= (1u << clip_distance_count) - 1; + disable_mask &= (1u << clip_distance_count) - 1; + current_mask = context->clip_distance_mask; + context->clip_distance_mask = enable_mask; + + enable_mask &= ~current_mask; + for (i = 0; enable_mask; enable_mask >>= 1, ++i) + { + if (enable_mask & 1) + gl_info->gl_ops.gl.p_glEnable(GL_CLIP_DISTANCE0 + i); + } + disable_mask &= current_mask; + for (i = 0; disable_mask; disable_mask >>= 1, ++i) + { + if (disable_mask & 1) + gl_info->gl_ops.gl.p_glDisable(GL_CLIP_DISTANCE0 + i); + } + checkGLcall("toggle clip distances"); +} + /***************************************************************************** * SetupForBlit * @@ -2374,10 +2393,10 @@ static void context_get_rt_size(const struct wined3d_context *context, SIZE *siz /* Context activation is done by the caller. */ static void SetupForBlit(const struct wined3d_device *device, struct wined3d_context *context) { - int i; const struct wined3d_gl_info *gl_info = context->gl_info; DWORD sampler; SIZE rt_size; + int i; TRACE("Setting up context %p for blitting\n", context); @@ -2398,17 +2417,46 @@ static void SetupForBlit(const struct wined3d_device *device, struct wined3d_con } context->last_was_blit = TRUE; - /* Disable all textures. The caller can then bind a texture it wants to blit - * from - * - * The blitting code uses (for now) the fixed function pipeline, so make sure to reset all fixed - * function texture unit. No need to care for higher samplers - */ - for (i = gl_info->limits.textures - 1; i > 0 ; --i) + if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT]) { - sampler = context->rev_tex_unit_map[i]; - context_active_texture(context, gl_info, i); + /* Disable all textures. The caller can then bind a texture it wants to blit + * from + * + * The blitting code uses (for now) the fixed function pipeline, so make sure to reset all fixed + * function texture unit. No need to care for higher samplers + */ + for (i = gl_info->limits.textures - 1; i > 0 ; --i) + { + sampler = context->rev_tex_unit_map[i]; + context_active_texture(context, gl_info, i); + + if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) + { + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB); + checkGLcall("glDisable GL_TEXTURE_CUBE_MAP_ARB"); + } + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D); + checkGLcall("glDisable GL_TEXTURE_3D"); + if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) + { + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_RECTANGLE_ARB); + checkGLcall("glDisable GL_TEXTURE_RECTANGLE_ARB"); + } + gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D); + checkGLcall("glDisable GL_TEXTURE_2D"); + gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);"); + + if (sampler != WINED3D_UNMAPPED_STAGE) + { + if (sampler < MAX_TEXTURES) + context_invalidate_state(context, STATE_TEXTURESTAGE(sampler, WINED3D_TSS_COLOR_OP)); + context_invalidate_state(context, STATE_SAMPLER(sampler)); + } + } + + context_active_texture(context, gl_info, 0); if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) { gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB); @@ -2425,50 +2473,43 @@ static void SetupForBlit(const struct wined3d_device *device, struct wined3d_con checkGLcall("glDisable GL_TEXTURE_2D"); gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);"); - if (sampler != WINED3D_UNMAPPED_STAGE) + gl_info->gl_ops.gl.p_glMatrixMode(GL_TEXTURE); + checkGLcall("glMatrixMode(GL_TEXTURE)"); + gl_info->gl_ops.gl.p_glLoadIdentity(); + checkGLcall("glLoadIdentity()"); + + if (gl_info->supported[EXT_TEXTURE_LOD_BIAS]) { - if (sampler < MAX_TEXTURES) - context_invalidate_state(context, STATE_TEXTURESTAGE(sampler, WINED3D_TSS_COLOR_OP)); - context_invalidate_state(context, STATE_SAMPLER(sampler)); + gl_info->gl_ops.gl.p_glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, + GL_TEXTURE_LOD_BIAS_EXT, 0.0f); + checkGLcall("glTexEnvf GL_TEXTURE_LOD_BIAS_EXT ..."); } + + /* Setup transforms */ + gl_info->gl_ops.gl.p_glMatrixMode(GL_MODELVIEW); + checkGLcall("glMatrixMode(GL_MODELVIEW)"); + gl_info->gl_ops.gl.p_glLoadIdentity(); + checkGLcall("glLoadIdentity()"); + context_invalidate_state(context, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0))); + + /* Other misc states */ + gl_info->gl_ops.gl.p_glDisable(GL_ALPHA_TEST); + checkGLcall("glDisable(GL_ALPHA_TEST)"); + context_invalidate_state(context, STATE_RENDER(WINED3D_RS_ALPHATESTENABLE)); + gl_info->gl_ops.gl.p_glDisable(GL_LIGHTING); + checkGLcall("glDisable GL_LIGHTING"); + context_invalidate_state(context, STATE_RENDER(WINED3D_RS_LIGHTING)); + glDisableWINE(GL_FOG); + checkGLcall("glDisable GL_FOG"); + context_invalidate_state(context, STATE_RENDER(WINED3D_RS_FOGENABLE)); } + if (gl_info->supported[ARB_SAMPLER_OBJECTS]) GL_EXTCALL(glBindSampler(0, 0)); context_active_texture(context, gl_info, 0); sampler = context->rev_tex_unit_map[0]; - - if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) - { - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB); - checkGLcall("glDisable GL_TEXTURE_CUBE_MAP_ARB"); - } - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_3D); - checkGLcall("glDisable GL_TEXTURE_3D"); - if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) - { - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_RECTANGLE_ARB); - checkGLcall("glDisable GL_TEXTURE_RECTANGLE_ARB"); - } - gl_info->gl_ops.gl.p_glDisable(GL_TEXTURE_2D); - checkGLcall("glDisable GL_TEXTURE_2D"); - - gl_info->gl_ops.gl.p_glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - - gl_info->gl_ops.gl.p_glMatrixMode(GL_TEXTURE); - checkGLcall("glMatrixMode(GL_TEXTURE)"); - gl_info->gl_ops.gl.p_glLoadIdentity(); - checkGLcall("glLoadIdentity()"); - - if (gl_info->supported[EXT_TEXTURE_LOD_BIAS]) - { - gl_info->gl_ops.gl.p_glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, - GL_TEXTURE_LOD_BIAS_EXT, 0.0f); - checkGLcall("glTexEnvf GL_TEXTURE_LOD_BIAS_EXT ..."); - } - if (sampler != WINED3D_UNMAPPED_STAGE) { if (sampler < MAX_TEXTURES) @@ -2480,18 +2521,9 @@ static void SetupForBlit(const struct wined3d_device *device, struct wined3d_con } /* Other misc states */ - gl_info->gl_ops.gl.p_glDisable(GL_ALPHA_TEST); - checkGLcall("glDisable(GL_ALPHA_TEST)"); - context_invalidate_state(context, STATE_RENDER(WINED3D_RS_ALPHATESTENABLE)); - gl_info->gl_ops.gl.p_glDisable(GL_LIGHTING); - checkGLcall("glDisable GL_LIGHTING"); - context_invalidate_state(context, STATE_RENDER(WINED3D_RS_LIGHTING)); gl_info->gl_ops.gl.p_glDisable(GL_DEPTH_TEST); checkGLcall("glDisable GL_DEPTH_TEST"); context_invalidate_state(context, STATE_RENDER(WINED3D_RS_ZENABLE)); - glDisableWINE(GL_FOG); - checkGLcall("glDisable GL_FOG"); - context_invalidate_state(context, STATE_RENDER(WINED3D_RS_FOGENABLE)); gl_info->gl_ops.gl.p_glDisable(GL_BLEND); checkGLcall("glDisable GL_BLEND"); context_invalidate_state(context, STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE)); @@ -2512,8 +2544,10 @@ static void SetupForBlit(const struct wined3d_device *device, struct wined3d_con } gl_info->gl_ops.gl.p_glColorMask(GL_TRUE, GL_TRUE,GL_TRUE,GL_TRUE); checkGLcall("glColorMask"); - for (i = 0; i < MAX_RENDER_TARGETS; ++i) - context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITE(i))); + context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE)); + context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1)); + context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2)); + context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3)); if (gl_info->supported[EXT_SECONDARY_COLOR]) { gl_info->gl_ops.gl.p_glDisable(GL_COLOR_SUM_EXT); @@ -2521,22 +2555,10 @@ static void SetupForBlit(const struct wined3d_device *device, struct wined3d_con checkGLcall("glDisable(GL_COLOR_SUM_EXT)"); } - /* Setup transforms */ - gl_info->gl_ops.gl.p_glMatrixMode(GL_MODELVIEW); - checkGLcall("glMatrixMode(GL_MODELVIEW)"); - gl_info->gl_ops.gl.p_glLoadIdentity(); - checkGLcall("glLoadIdentity()"); - context_invalidate_state(context, STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0))); - context->last_was_rhw = TRUE; context_invalidate_state(context, STATE_VDECL); /* because of last_was_rhw = TRUE */ - gl_info->gl_ops.gl.p_glDisable(GL_CLIP_PLANE0); checkGLcall("glDisable(clip plane 0)"); - gl_info->gl_ops.gl.p_glDisable(GL_CLIP_PLANE1); checkGLcall("glDisable(clip plane 1)"); - gl_info->gl_ops.gl.p_glDisable(GL_CLIP_PLANE2); checkGLcall("glDisable(clip plane 2)"); - gl_info->gl_ops.gl.p_glDisable(GL_CLIP_PLANE3); checkGLcall("glDisable(clip plane 3)"); - gl_info->gl_ops.gl.p_glDisable(GL_CLIP_PLANE4); checkGLcall("glDisable(clip plane 4)"); - gl_info->gl_ops.gl.p_glDisable(GL_CLIP_PLANE5); checkGLcall("glDisable(clip plane 5)"); + context_enable_clip_distances(context, 0); context_invalidate_state(context, STATE_RENDER(WINED3D_RS_CLIPPING)); /* FIXME: Make draw_textured_quad() able to work with a upper left origin. */ @@ -2673,14 +2695,6 @@ void context_bind_texture(struct wined3d_context *context, GLenum target, GLuint case GL_NONE: /* nothing to do */ break; - case GL_TEXTURE_1D: - gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D, device->dummy_textures.tex_1d); - checkGLcall("glBindTexture"); - break; - case GL_TEXTURE_1D_ARRAY: - gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D_ARRAY, device->dummy_textures.tex_1d_array); - checkGLcall("glBindTexture"); - break; case GL_TEXTURE_2D: gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_2D, device->dummy_textures.tex_2d); checkGLcall("glBindTexture"); @@ -3086,16 +3100,8 @@ static DWORD find_draw_buffers_mask(const struct wined3d_context *context, const else if (!context->render_offscreen) return context_generate_rt_mask_from_resource(rts[0]->resource); - /* If we attach more buffers than supported in dual blend mode, the NVIDIA - * driver generates the following error: - * GL_INVALID_OPERATION error generated. State(s) are invalid: blend. - * DX11 does not treat this configuration as invalid, so disable the unused ones. - */ rt_mask = ps ? ps->reg_maps.rt_mask : 1; - if (wined3d_dualblend_enabled(state, context->gl_info)) - rt_mask &= context->d3d_info->valid_dual_rt_mask; - else - rt_mask &= context->d3d_info->valid_rt_mask; + rt_mask &= context->d3d_info->valid_rt_mask; rt_mask_bits = rt_mask; i = 0; while (rt_mask_bits) @@ -4008,6 +4014,16 @@ void context_apply_compute_state(struct wined3d_context *context, context->update_unordered_access_view_bindings = 1; } + /* Updates to currently bound render targets aren't necessarily coherent + * between the graphics and compute pipelines. Unbind any currently bound + * FBO here to ensure preceding updates to its attachments by the graphics + * pipeline are visible to the compute pipeline. + * + * Without this, the bloom effect in Nier:Automata is too bright on the + * Mesa radeonsi driver, and presumably on other Mesa based drivers. */ + context_bind_fbo(context, GL_FRAMEBUFFER, 0); + context_invalidate_state(context, STATE_FRAMEBUFFER); + context->last_was_blit = FALSE; } diff --git a/dll/directx/wine/wined3d/cs.c b/dll/directx/wine/wined3d/cs.c index 2ef67aaade..d264d1c940 100644 --- a/dll/directx/wine/wined3d/cs.c +++ b/dll/directx/wine/wined3d/cs.c @@ -69,7 +69,7 @@ enum wined3d_cs_op WINED3D_CS_OP_ADD_DIRTY_TEXTURE_REGION, WINED3D_CS_OP_CLEAR_UNORDERED_ACCESS_VIEW, WINED3D_CS_OP_COPY_UAV_COUNTER, - WINED3D_CS_OP_COPY_SUB_RESOURCE, + WINED3D_CS_OP_GENERATE_MIPMAPS, WINED3D_CS_OP_STOP, }; @@ -396,9 +396,6 @@ struct wined3d_cs_update_sub_resource unsigned int sub_resource_idx; struct wined3d_box box; struct wined3d_sub_resource_data data; -#if defined(STAGING_CSMT) - BYTE copy_data[1]; -#endif /* STAGING_CSMT */ }; struct wined3d_cs_add_dirty_texture_region @@ -423,15 +420,10 @@ struct wined3d_cs_copy_uav_counter struct wined3d_unordered_access_view *view; }; -struct wined3d_cs_copy_sub_resource +struct wined3d_cs_generate_mipmaps { enum wined3d_cs_op opcode; - struct wined3d_resource *dst_resource; - unsigned int dst_sub_resource_idx; - struct wined3d_box dst_box; - struct wined3d_resource *src_resource; - unsigned int src_sub_resource_idx; - struct wined3d_box src_box; + struct wined3d_shader_resource_view *view; }; struct wined3d_cs_stop @@ -766,10 +758,24 @@ void wined3d_cs_emit_dispatch_indirect(struct wined3d_cs *cs, static void wined3d_cs_exec_draw(struct wined3d_cs *cs, const void *data) { + const struct wined3d_gl_info *gl_info = &cs->device->adapter->gl_info; struct wined3d_state *state = &cs->state; const struct wined3d_cs_draw *op = data; + int load_base_vertex_idx; unsigned int i; + /* ARB_draw_indirect always supports a base vertex offset. */ + if (!op->parameters.indirect && !gl_info->supported[ARB_DRAW_ELEMENTS_BASE_VERTEX]) + load_base_vertex_idx = op->parameters.u.direct.base_vertex_idx; + else + load_base_vertex_idx = 0; + + if (state->load_base_vertex_index != load_base_vertex_idx) + { + state->load_base_vertex_index = load_base_vertex_idx; + device_invalidate_state(cs->device, STATE_BASEVERTEXINDEX); + } + if (state->gl_primitive_type != op->primitive_type) { if (state->gl_primitive_type == GL_POINTS || op->primitive_type == GL_POINTS) @@ -778,26 +784,14 @@ static void wined3d_cs_exec_draw(struct wined3d_cs *cs, const void *data) } state->gl_patch_vertices = op->patch_vertex_count; - if (!op->parameters.indirect) - { - const struct wined3d_direct_draw_parameters *p = &op->parameters.u.direct; - - if (!cs->device->adapter->gl_info.supported[ARB_DRAW_ELEMENTS_BASE_VERTEX] - && state->load_base_vertex_index != p->base_vertex_idx) - { - state->load_base_vertex_index = p->base_vertex_idx; - device_invalidate_state(cs->device, STATE_BASEVERTEXINDEX); - } - } - draw_primitive(cs->device, state, &op->parameters); if (op->parameters.indirect) { - const struct wined3d_indirect_draw_parameters *p = &op->parameters.u.indirect; - - wined3d_resource_release(&p->buffer->resource); + struct wined3d_buffer *buffer = op->parameters.u.indirect.buffer; + wined3d_resource_release(&buffer->resource); } + if (op->parameters.indexed) wined3d_resource_release(&state->index_buffer->resource); for (i = 0; i < ARRAY_SIZE(state->streams); ++i) @@ -815,7 +809,7 @@ static void wined3d_cs_exec_draw(struct wined3d_cs *cs, const void *data) if (state->textures[i]) wined3d_resource_release(&state->textures[i]->resource); } - for (i = 0; i < cs->device->adapter->gl_info.limits.buffers; ++i) + for (i = 0; i < gl_info->limits.buffers; ++i) { if (state->fb->render_targets[i]) wined3d_resource_release(state->fb->render_targets[i]->resource); @@ -827,26 +821,11 @@ static void wined3d_cs_exec_draw(struct wined3d_cs *cs, const void *data) state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]); } -void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, unsigned int patch_vertex_count, - int base_vertex_idx, unsigned int start_idx, unsigned int index_count, - unsigned int start_instance, unsigned int instance_count, BOOL indexed) +static void acquire_graphics_pipeline_resources(const struct wined3d_state *state, + BOOL indexed, const struct wined3d_gl_info *gl_info) { - const struct wined3d_state *state = &cs->device->state; - struct wined3d_cs_draw *op; unsigned int i; - op = cs->ops->require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); - op->opcode = WINED3D_CS_OP_DRAW; - op->primitive_type = primitive_type; - op->patch_vertex_count = patch_vertex_count; - op->parameters.indirect = FALSE; - op->parameters.u.direct.base_vertex_idx = base_vertex_idx; - op->parameters.u.direct.start_idx = start_idx; - op->parameters.u.direct.index_count = index_count; - op->parameters.u.direct.start_instance = start_instance; - op->parameters.u.direct.instance_count = instance_count; - op->parameters.indexed = indexed; - if (indexed) wined3d_resource_acquire(&state->index_buffer->resource); for (i = 0; i < ARRAY_SIZE(state->streams); ++i) @@ -864,7 +843,7 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, unsigned if (state->textures[i]) wined3d_resource_acquire(&state->textures[i]->resource); } - for (i = 0; i < cs->device->adapter->gl_info.limits.buffers; ++i) + for (i = 0; i < gl_info->limits.buffers; ++i) { if (state->fb->render_targets[i]) wined3d_resource_acquire(state->fb->render_targets[i]->resource); @@ -874,6 +853,29 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, unsigned acquire_shader_resources(state, ~(1u << WINED3D_SHADER_TYPE_COMPUTE)); acquire_unordered_access_resources(state->shader[WINED3D_SHADER_TYPE_PIXEL], state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]); +} + +void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, unsigned int patch_vertex_count, + int base_vertex_idx, unsigned int start_idx, unsigned int index_count, + unsigned int start_instance, unsigned int instance_count, BOOL indexed) +{ + const struct wined3d_gl_info *gl_info = &cs->device->adapter->gl_info; + const struct wined3d_state *state = &cs->device->state; + struct wined3d_cs_draw *op; + + op = cs->ops->require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); + op->opcode = WINED3D_CS_OP_DRAW; + op->primitive_type = primitive_type; + op->patch_vertex_count = patch_vertex_count; + op->parameters.indirect = FALSE; + op->parameters.u.direct.base_vertex_idx = base_vertex_idx; + op->parameters.u.direct.start_idx = start_idx; + op->parameters.u.direct.index_count = index_count; + op->parameters.u.direct.start_instance = start_instance; + op->parameters.u.direct.instance_count = instance_count; + op->parameters.indexed = indexed; + + acquire_graphics_pipeline_resources(state, indexed, gl_info); cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT); } @@ -881,9 +883,9 @@ void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, unsigned void wined3d_cs_emit_draw_indirect(struct wined3d_cs *cs, GLenum primitive_type, unsigned int patch_vertex_count, struct wined3d_buffer *buffer, unsigned int offset, BOOL indexed) { + const struct wined3d_gl_info *gl_info = &cs->device->adapter->gl_info; const struct wined3d_state *state = &cs->device->state; struct wined3d_cs_draw *op; - unsigned int i; op = cs->ops->require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); op->opcode = WINED3D_CS_OP_DRAW; @@ -894,36 +896,9 @@ void wined3d_cs_emit_draw_indirect(struct wined3d_cs *cs, GLenum primitive_type, op->parameters.u.indirect.offset = offset; op->parameters.indexed = indexed; + acquire_graphics_pipeline_resources(state, indexed, gl_info); wined3d_resource_acquire(&buffer->resource); - if (indexed) - wined3d_resource_acquire(&state->index_buffer->resource); - for (i = 0; i < ARRAY_SIZE(state->streams); ++i) - { - if (state->streams[i].buffer) - wined3d_resource_acquire(&state->streams[i].buffer->resource); - } - for (i = 0; i < ARRAY_SIZE(state->stream_output); ++i) - { - if (state->stream_output[i].buffer) - wined3d_resource_acquire(&state->stream_output[i].buffer->resource); - } - for (i = 0; i < ARRAY_SIZE(state->textures); ++i) - { - if (state->textures[i]) - wined3d_resource_acquire(&state->textures[i]->resource); - } - for (i = 0; i < cs->device->adapter->gl_info.limits.buffers; ++i) - { - if (state->fb->render_targets[i]) - wined3d_resource_acquire(state->fb->render_targets[i]->resource); - } - if (state->fb->depth_stencil) - wined3d_resource_acquire(state->fb->depth_stencil->resource); - acquire_shader_resources(state, ~(1u << WINED3D_SHADER_TYPE_COMPUTE)); - acquire_unordered_access_resources(state->shader[WINED3D_SHADER_TYPE_PIXEL], - state->unordered_access_view[WINED3D_PIPELINE_GRAPHICS]); - cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT); } @@ -945,6 +920,7 @@ void wined3d_cs_emit_flush(struct wined3d_cs *cs) op->opcode = WINED3D_CS_OP_FLUSH; cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT); + cs->queries_flushed = TRUE; } static void wined3d_cs_exec_set_predication(struct wined3d_cs *cs, const void *data) @@ -1054,8 +1030,7 @@ static void wined3d_cs_exec_set_depth_stencil_view(struct wined3d_cs *cs, const device_invalidate_state(device, STATE_RENDER(WINED3D_RS_STENCILWRITEMASK)); device_invalidate_state(device, STATE_RENDER(WINED3D_RS_DEPTHBIAS)); } - else if (prev && (prev->format_flags & WINED3DFMT_FLAG_FLOAT) - != (op->view->format_flags & WINED3DFMT_FLAG_FLOAT)) + else if (prev && prev->format->depth_bias_scale != op->view->format->depth_bias_scale) { device_invalidate_state(device, STATE_RENDER(WINED3D_RS_DEPTHBIAS)); } @@ -1931,6 +1906,7 @@ void wined3d_cs_emit_query_issue(struct wined3d_cs *cs, struct wined3d_query *qu op->flags = flags; cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT); + cs->queries_flushed = FALSE; } static void wined3d_cs_exec_preload_resource(struct wined3d_cs *cs, const void *data) @@ -2073,14 +2049,14 @@ static void wined3d_cs_exec_blt_sub_resource(struct wined3d_cs *cs, const void * struct wined3d_context *context; struct wined3d_bo_address addr; - if (op->flags) + if (op->flags & ~WINED3D_BLT_RAW) { FIXME("Flags %#x not implemented for %s resources.\n", op->flags, debug_d3dresourcetype(op->dst_resource->type)); goto error; } - if (op->src_resource->format != op->dst_resource->format) + if (!(op->flags & WINED3D_BLT_RAW) && op->src_resource->format != op->dst_resource->format) { FIXME("Format conversion not implemented for %s resources.\n", debug_d3dresourcetype(op->dst_resource->type)); @@ -2176,6 +2152,8 @@ void wined3d_cs_emit_blt_sub_resource(struct wined3d_cs *cs, struct wined3d_reso op->flags = flags; if (fx) op->fx = *fx; + else + memset(&op->fx, 0, sizeof(op->fx)); op->filter = filter; wined3d_resource_acquire(dst_resource); @@ -2199,11 +2177,18 @@ static void wined3d_cs_exec_update_sub_resource(struct wined3d_cs *cs, const voi if (op->resource->type == WINED3D_RTYPE_BUFFER) { struct wined3d_buffer *buffer = buffer_from_resource(op->resource); - HRESULT hr; - if (FAILED(hr = wined3d_buffer_upload_data(buffer, box, op->data.data))) - WARN("Failed to update buffer data, hr %#x.\n", hr); + context = context_acquire(op->resource->device, NULL, 0); + if (!wined3d_buffer_load_location(buffer, context, WINED3D_LOCATION_BUFFER)) + { + ERR("Failed to load buffer location.\n"); + context_release(context); + goto done; + } + wined3d_buffer_upload_data(buffer, context, box, op->data.data); + wined3d_buffer_invalidate_location(buffer, ~WINED3D_LOCATION_BUFFER); + context_release(context); goto done; } @@ -2244,53 +2229,6 @@ void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_r unsigned int slice_pitch) { struct wined3d_cs_update_sub_resource *op; -#if defined(STAGING_CSMT) - size_t data_size, size; - - if (resource->type != WINED3D_RTYPE_BUFFER && resource->format_flags & WINED3DFMT_FLAG_BLOCKS) - goto no_async; - - data_size = 0; - switch (resource->type) - { - case WINED3D_RTYPE_TEXTURE_3D: - data_size += (box->back - box->front - 1) * slice_pitch; - /* fall-through */ - case WINED3D_RTYPE_TEXTURE_2D: - data_size += (box->bottom - box->top - 1) * row_pitch; - /* fall-through */ - case WINED3D_RTYPE_TEXTURE_1D: - data_size += (box->right - box->left) * resource->format->byte_count; - break; - case WINED3D_RTYPE_BUFFER: - data_size = box->right - box->left; - break; - case WINED3D_RTYPE_NONE: - return; - } - - size = FIELD_OFFSET(struct wined3d_cs_update_sub_resource, copy_data[data_size]); - if (!cs->ops->check_space(cs, size, WINED3D_CS_QUEUE_DEFAULT)) - goto no_async; - - op = cs->ops->require_space(cs, size, WINED3D_CS_QUEUE_DEFAULT); - op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE; - op->resource = resource; - op->sub_resource_idx = sub_resource_idx; - op->box = *box; - op->data.row_pitch = row_pitch; - op->data.slice_pitch = slice_pitch; - op->data.data = op->copy_data; - memcpy(op->copy_data, data, data_size); - - wined3d_resource_acquire(resource); - - cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT); - return; - -no_async: - wined3d_resource_wait_idle(resource); -#endif /* STAGING_CSMT */ op = cs->ops->require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_MAP); op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE; @@ -2304,10 +2242,8 @@ no_async: wined3d_resource_acquire(resource); cs->ops->submit(cs, WINED3D_CS_QUEUE_MAP); -#if !defined(STAGING_CSMT) /* The data pointer may go away, so we need to wait until it is read. * Copying the data may be faster if it's small. */ -#endif /* STAGING_CSMT */ cs->ops->finish(cs, WINED3D_CS_QUEUE_MAP); } @@ -2386,7 +2322,6 @@ static void wined3d_cs_exec_copy_uav_counter(struct wined3d_cs *cs, const void * context_release(context); wined3d_resource_release(&op->buffer->resource); - wined3d_resource_release(view->resource); } void wined3d_cs_emit_copy_uav_counter(struct wined3d_cs *cs, struct wined3d_buffer *dst_buffer, @@ -2401,149 +2336,28 @@ void wined3d_cs_emit_copy_uav_counter(struct wined3d_cs *cs, struct wined3d_buff op->view = uav; wined3d_resource_acquire(&dst_buffer->resource); - wined3d_resource_acquire(uav->resource); cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT); } -static void wined3d_cs_exec_copy_sub_resource(struct wined3d_cs *cs, const void *data) +static void wined3d_cs_exec_generate_mipmaps(struct wined3d_cs *cs, const void *data) { - struct wined3d_cs_copy_sub_resource *op = (void*)data; - - if (op->dst_resource->type == WINED3D_RTYPE_BUFFER) - { - wined3d_buffer_copy(buffer_from_resource(op->dst_resource), op->dst_box.left, - buffer_from_resource(op->src_resource), op->src_box.left, - op->src_box.right - op->src_box.left); - } - else if (op->dst_resource->type == WINED3D_RTYPE_TEXTURE_1D || - op->dst_resource->type == WINED3D_RTYPE_TEXTURE_2D || - op->dst_resource->type == WINED3D_RTYPE_TEXTURE_3D) - { - struct wined3d_texture *dst_texture, *src_texture; - struct gl_texture *gl_tex_src, *gl_tex_dst; - unsigned int update_w, update_h, update_d; - const struct wined3d_gl_info *gl_info; - unsigned int src_level, src_layer; - unsigned int dst_level, dst_layer; - struct wined3d_context *context; - BOOL partial_update = FALSE; - - update_w = op->dst_box.right - op->dst_box.left; - update_h = op->dst_box.bottom - op->dst_box.top; - update_d = op->dst_box.back - op->dst_box.front; - - dst_texture = texture_from_resource(op->dst_resource); - src_texture = texture_from_resource(op->src_resource); - - context = context_acquire(cs->device, NULL, 0); - gl_info = context->gl_info; - - if (!wined3d_texture_load_location(src_texture, op->src_sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB)) - { - FIXME("Failed to load source sub-resource into WINED3D_LOCATION_TEXTURE_RGB.\n"); - context_release(context); - goto error; - } - - src_level = op->src_sub_resource_idx % src_texture->level_count; - src_layer = op->src_sub_resource_idx / src_texture->level_count; - dst_level = op->dst_sub_resource_idx % dst_texture->level_count; - dst_layer = op->dst_sub_resource_idx / dst_texture->level_count; - - switch (op->dst_resource->type) - { - case WINED3D_RTYPE_TEXTURE_3D: - partial_update |= (update_d != wined3d_texture_get_level_depth(dst_texture, dst_level)); - case WINED3D_RTYPE_TEXTURE_2D: - partial_update |= (update_h != wined3d_texture_get_level_height(dst_texture, dst_level)); - case WINED3D_RTYPE_TEXTURE_1D: - partial_update |= (update_w != wined3d_texture_get_level_width(dst_texture, dst_level)); - default: - break; - } - - if (!partial_update) - { - wined3d_texture_prepare_texture(dst_texture, context, FALSE); - } - else if (!wined3d_texture_load_location(dst_texture, op->dst_sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB)) - { - FIXME("Failed to load destination sub-resource.\n"); - context_release(context); - goto error; - } - - switch (op->dst_resource->type) - { - case WINED3D_RTYPE_TEXTURE_1D: - op->src_box.top = src_layer; - op->dst_box.top = dst_layer; - break; - case WINED3D_RTYPE_TEXTURE_2D: - op->src_box.front = src_layer; - op->dst_box.front = dst_layer; - break; - default: - break; - } - - gl_tex_src = wined3d_texture_get_gl_texture(src_texture, FALSE); - gl_tex_dst = wined3d_texture_get_gl_texture(dst_texture, FALSE); - - GL_EXTCALL(glCopyImageSubData(gl_tex_src->name, src_texture->target, src_level, - op->src_box.left, op->src_box.top, op->src_box.front, - gl_tex_dst->name, dst_texture->target, dst_level, - op->dst_box.left, op->dst_box.top, op->dst_box.front, - update_w, update_h, update_d)); - checkGLcall("Copy texture content"); + const struct wined3d_cs_generate_mipmaps *op = data; + struct wined3d_shader_resource_view *view = op->view; - wined3d_texture_validate_location(dst_texture, op->dst_sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB); - wined3d_texture_invalidate_location(dst_texture, op->dst_sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB); - - context_release(context); - } - else - { - FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(op->dst_resource->type)); - } - -error: - wined3d_resource_release(op->src_resource); - wined3d_resource_release(op->dst_resource); + shader_resource_view_generate_mipmaps(view); + wined3d_resource_release(view->resource); } -void wined3d_cs_emit_copy_sub_resource(struct wined3d_cs *cs, struct wined3d_resource *dst_resource, - unsigned int dst_sub_resource_idx, const struct wined3d_box *dst_box, struct wined3d_resource *src_resource, - unsigned int src_sub_resource_idx, const struct wined3d_box *src_box) +void wined3d_cs_emit_generate_mipmaps(struct wined3d_cs *cs, struct wined3d_shader_resource_view *view) { - const struct wined3d_gl_info *gl_info = &cs->device->adapter->gl_info; - struct wined3d_cs_blt_sub_resource *op; - - if (!gl_info->supported[ARB_TEXTURE_VIEW] && src_resource->format->id != dst_resource->format->id) - { - FIXME("ARB_TEXTURE_VIEW not supported, cannot copy sub-resource.\n"); - return; - } - - if (!gl_info->supported[ARB_COPY_IMAGE]) - { - wined3d_cs_emit_blt_sub_resource(cs, dst_resource, dst_sub_resource_idx, dst_box, - src_resource, src_sub_resource_idx, src_box, 0, NULL, WINED3D_TEXF_POINT); - return; - } + struct wined3d_cs_generate_mipmaps *op; op = cs->ops->require_space(cs, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); - op->opcode = WINED3D_CS_OP_COPY_SUB_RESOURCE; - op->dst_resource = dst_resource; - op->dst_sub_resource_idx = dst_sub_resource_idx; - op->dst_box = *dst_box; - op->src_resource = src_resource; - op->src_sub_resource_idx = src_sub_resource_idx; - op->src_box = *src_box; + op->opcode = WINED3D_CS_OP_GENERATE_MIPMAPS; + op->view = view; - wined3d_resource_acquire(dst_resource); - wined3d_resource_acquire(src_resource); + wined3d_resource_acquire(view->resource); cs->ops->submit(cs, WINED3D_CS_QUEUE_DEFAULT); } @@ -2606,16 +2420,9 @@ static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void /* WINED3D_CS_OP_ADD_DIRTY_TEXTURE_REGION */ wined3d_cs_exec_add_dirty_texture_region, /* WINED3D_CS_OP_CLEAR_UNORDERED_ACCESS_VIEW */ wined3d_cs_exec_clear_unordered_access_view, /* WINED3D_CS_OP_COPY_UAV_COUNTER */ wined3d_cs_exec_copy_uav_counter, - /* WINED3D_CS_OP_COPY_SUB_RESOURCE */ wined3d_cs_exec_copy_sub_resource, + /* WINED3D_CS_OP_GENERATE_MIPMAPS */ wined3d_cs_exec_generate_mipmaps, }; -#if defined(STAGING_CSMT) -static BOOL wined3d_cs_st_check_space(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id) -{ - return TRUE; -} - -#endif /* STAGING_CSMT */ static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id) { if (size > (cs->data_size - cs->end)) @@ -2669,9 +2476,6 @@ static void wined3d_cs_st_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id static const struct wined3d_cs_ops wined3d_cs_st_ops = { -#if defined(STAGING_CSMT) - wined3d_cs_st_check_space, -#endif /* STAGING_CSMT */ wined3d_cs_st_require_space, wined3d_cs_st_submit, wined3d_cs_st_finish, @@ -2708,21 +2512,6 @@ static void wined3d_cs_mt_submit(struct wined3d_cs *cs, enum wined3d_cs_queue_id wined3d_cs_queue_submit(&cs->queue[queue_id], cs); } -#if defined(STAGING_CSMT) -static BOOL wined3d_cs_queue_check_space(struct wined3d_cs_queue *queue, size_t size) -{ - size_t queue_size = ARRAY_SIZE(queue->data); - size_t header_size, packet_size, remaining; - - header_size = FIELD_OFFSET(struct wined3d_cs_packet, data[0]); - size = (size + header_size - 1) & ~(header_size - 1); - packet_size = FIELD_OFFSET(struct wined3d_cs_packet, data[size]); - - remaining = queue_size - queue->head; - return (remaining >= packet_size); -} - -#endif /* STAGING_CSMT */ static void *wined3d_cs_queue_require_space(struct wined3d_cs_queue *queue, size_t size, struct wined3d_cs *cs) { size_t queue_size = ARRAY_SIZE(queue->data); @@ -2784,16 +2573,6 @@ static void *wined3d_cs_queue_require_space(struct wined3d_cs_queue *queue, size return packet->data; } -#if defined(STAGING_CSMT) -static BOOL wined3d_cs_mt_check_space(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id) -{ - if (cs->thread_id == GetCurrentThreadId()) - return wined3d_cs_st_check_space(cs, size, queue_id); - - return wined3d_cs_queue_check_space(&cs->queue[queue_id], size); -} - -#endif /* STAGING_CSMT */ static void *wined3d_cs_mt_require_space(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id) { if (cs->thread_id == GetCurrentThreadId()) @@ -2816,9 +2595,6 @@ static void wined3d_cs_mt_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id static const struct wined3d_cs_ops wined3d_cs_mt_ops = { -#if defined(STAGING_CSMT) - wined3d_cs_mt_check_space, -#endif /* STAGING_CSMT */ wined3d_cs_mt_require_space, wined3d_cs_mt_submit, wined3d_cs_mt_finish, @@ -2866,11 +2642,16 @@ static DWORD WINAPI wined3d_cs_run(void *ctx) unsigned int spin_count = 0; struct wined3d_cs *cs = ctx; enum wined3d_cs_op opcode; + HMODULE wined3d_module; unsigned int poll = 0; LONG tail; TRACE("Started.\n"); + /* Copy the module handle to a local variable to avoid racing with the + * thread freeing "cs" before the FreeLibraryAndExitThread() call. */ + wined3d_module = cs->wined3d_module; + list_init(&cs->query_poll_list); cs->thread_id = GetCurrentThreadId(); for (;;) @@ -2918,7 +2699,7 @@ static DWORD WINAPI wined3d_cs_run(void *ctx) cs->queue[WINED3D_CS_QUEUE_MAP].tail = cs->queue[WINED3D_CS_QUEUE_MAP].head; cs->queue[WINED3D_CS_QUEUE_DEFAULT].tail = cs->queue[WINED3D_CS_QUEUE_DEFAULT].head; TRACE("Stopped.\n"); - FreeLibraryAndExitThread(cs->wined3d_module, 0); + FreeLibraryAndExitThread(wined3d_module, 0); } struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device) diff --git a/dll/directx/wine/wined3d/device.c b/dll/directx/wine/wined3d/device.c index 224324ebde..fdc4f957af 100644 --- a/dll/directx/wine/wined3d/device.c +++ b/dll/directx/wine/wined3d/device.c @@ -374,8 +374,10 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c } gl_info->gl_ops.gl.p_glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - for (i = 0; i < MAX_RENDER_TARGETS; ++i) - context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITE(i))); + context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE)); + context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1)); + context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2)); + context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3)); gl_info->gl_ops.gl.p_glClearColor(color->r, color->g, color->b, color->a); checkGLcall("glClearColor"); clear_mask = clear_mask | GL_COLOR_BUFFER_BIT; @@ -478,7 +480,7 @@ ULONG CDECL wined3d_device_decref(struct wined3d_device *device) state_cleanup(&device->state); - for (i = 0; i < sizeof(device->multistate_funcs) / sizeof(device->multistate_funcs[0]); ++i) + for (i = 0; i < ARRAY_SIZE(device->multistate_funcs); ++i) { HeapFree(GetProcessHeap(), 0, device->multistate_funcs[i]); device->multistate_funcs[i] = NULL; @@ -610,17 +612,6 @@ static void create_dummy_textures(struct wined3d_device *device, struct wined3d_ * to each texture stage when the currently set D3D texture is NULL. */ context_active_texture(context, gl_info, 0); - gl_info->gl_ops.gl.p_glGenTextures(1, &device->dummy_textures.tex_1d); - checkGLcall("glGenTextures"); - TRACE("Dummy 1D texture given name %u.\n", device->dummy_textures.tex_1d); - - gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D, device->dummy_textures.tex_1d); - checkGLcall("glBindTexture"); - - gl_info->gl_ops.gl.p_glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA8, 1, 0, - GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, &color); - checkGLcall("glTexImage1D"); - gl_info->gl_ops.gl.p_glGenTextures(1, &device->dummy_textures.tex_2d); checkGLcall("glGenTextures"); TRACE("Dummy 2D texture given name %u.\n", device->dummy_textures.tex_2d); @@ -697,17 +688,6 @@ static void create_dummy_textures(struct wined3d_device *device, struct wined3d_ if (gl_info->supported[EXT_TEXTURE_ARRAY]) { - gl_info->gl_ops.gl.p_glGenTextures(1, &device->dummy_textures.tex_1d_array); - checkGLcall("glGenTextures"); - TRACE("Dummy 1D array texture given name %u.\n", device->dummy_textures.tex_1d_array); - - gl_info->gl_ops.gl.p_glBindTexture(GL_TEXTURE_1D_ARRAY, device->dummy_textures.tex_1d_array); - checkGLcall("glBindTexture"); - - gl_info->gl_ops.gl.p_glTexImage2D(GL_TEXTURE_1D_ARRAY, 0, GL_RGBA8, 1, 1, 0, - GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, &color); - checkGLcall("glTexImage2D"); - gl_info->gl_ops.gl.p_glGenTextures(1, &device->dummy_textures.tex_2d_array); checkGLcall("glGenTextures"); TRACE("Dummy 2D array texture given name %u.\n", device->dummy_textures.tex_2d_array); @@ -755,10 +735,7 @@ static void destroy_dummy_textures(struct wined3d_device *device, struct wined3d gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_buffer); if (gl_info->supported[EXT_TEXTURE_ARRAY]) - { gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_2d_array); - gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_1d_array); - } if (gl_info->supported[ARB_TEXTURE_CUBE_MAP_ARRAY]) gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_cube_array); @@ -773,7 +750,6 @@ static void destroy_dummy_textures(struct wined3d_device *device, struct wined3d gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_rect); gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_2d); - gl_info->gl_ops.gl.p_glDeleteTextures(1, &device->dummy_textures.tex_1d); checkGLcall("Delete dummy textures"); @@ -965,7 +941,7 @@ void CDECL wined3d_device_release_focus_window(struct wined3d_device *device) static void device_init_swapchain_state(struct wined3d_device *device, struct wined3d_swapchain *swapchain) { - BOOL ds_enable = !!swapchain->desc.enable_auto_depth_stencil; + BOOL ds_enable = swapchain->desc.enable_auto_depth_stencil; unsigned int i; if (device->fb.render_targets) @@ -979,7 +955,6 @@ static void device_init_swapchain_state(struct wined3d_device *device, struct wi } wined3d_device_set_depth_stencil_view(device, ds_enable ? device->auto_depth_stencil_view : NULL); - wined3d_device_set_render_state(device, WINED3D_RS_ZENABLE, ds_enable); } static void wined3d_device_delete_opengl_contexts_cs(void *object) @@ -1046,6 +1021,7 @@ static void wined3d_device_create_primary_opengl_context_cs(void *object) wined3d_ffp_blitter_create(&device->blitter, &device->adapter->gl_info); wined3d_arbfp_blitter_create(&device->blitter, device); wined3d_fbo_blitter_create(&device->blitter, &device->adapter->gl_info); + wined3d_raw_blitter_create(&device->blitter, &device->adapter->gl_info); swapchain = device->swapchains[0]; target = swapchain->back_buffers ? swapchain->back_buffers[0] : swapchain->front_buffer; @@ -1223,9 +1199,6 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device) wine_rb_clear(&device->samplers, device_free_sampler, NULL); -#if defined(STAGING_CSMT) - context_set_current(NULL); -#endif /* STAGING_CSMT */ wined3d_device_delete_opengl_contexts(device); if (device->fb.depth_stencil) @@ -1311,33 +1284,8 @@ void CDECL wined3d_device_set_multithreaded(struct wined3d_device *device) UINT CDECL wined3d_device_get_available_texture_mem(const struct wined3d_device *device) { - /* const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; */ - TRACE("device %p.\n", device); - /* We can not acquire the context unless there is a swapchain. */ - /* - if (device->swapchains && gl_info->supported[NVX_GPU_MEMORY_INFO] && - !wined3d_settings.emulated_textureram) - { - GLint vram_free_kb; - UINT64 vram_free; - - struct wined3d_context *context = context_acquire(device, NULL, 0); - gl_info->gl_ops.gl.p_glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &vram_free_kb); - vram_free = (UINT64)vram_free_kb * 1024; - context_release(context); - - TRACE("Total 0x%s bytes. emulation 0x%s left, driver 0x%s left.\n", - wine_dbgstr_longlong(device->adapter->vram_bytes), - wine_dbgstr_longlong(device->adapter->vram_bytes - device->adapter->vram_bytes_used), - wine_dbgstr_longlong(vram_free)); - - vram_free = min(vram_free, device->adapter->vram_bytes - device->adapter->vram_bytes_used); - return min(UINT_MAX, vram_free); - } - */ - TRACE("Emulating 0x%s bytes. 0x%s used, returning 0x%s left.\n", wine_dbgstr_longlong(device->adapter->vram_bytes), wine_dbgstr_longlong(device->adapter->vram_bytes_used), @@ -1800,7 +1748,6 @@ HRESULT CDECL wined3d_device_set_clip_plane(struct wined3d_device *device, { TRACE("device %p, plane_idx %u, plane %p.\n", device, plane_idx, plane); - /* Validate plane_idx. */ if (plane_idx >= device->adapter->gl_info.limits.user_clip_distances) { TRACE("Application has requested clipplane this device doesn't support.\n"); @@ -1829,7 +1776,6 @@ HRESULT CDECL wined3d_device_get_clip_plane(const struct wined3d_device *device, { TRACE("device %p, plane_idx %u, plane %p.\n", device, plane_idx, plane); - /* Validate plane_idx. */ if (plane_idx >= device->adapter->gl_info.limits.user_clip_distances) { TRACE("Application has requested clipplane this device doesn't support.\n"); @@ -2076,7 +2022,7 @@ void CDECL wined3d_device_set_sampler_state(struct wined3d_device *device, if (sampler_idx >= WINED3DVERTEXTEXTURESAMPLER0 && sampler_idx <= WINED3DVERTEXTEXTURESAMPLER3) sampler_idx -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS); - if (sampler_idx >= sizeof(device->state.sampler_states) / sizeof(*device->state.sampler_states)) + if (sampler_idx >= ARRAY_SIZE(device->state.sampler_states)) { WARN("Invalid sampler %u.\n", sampler_idx); return; /* Windows accepts overflowing this array ... we do not. */ @@ -2111,7 +2057,7 @@ DWORD CDECL wined3d_device_get_sampler_state(const struct wined3d_device *device if (sampler_idx >= WINED3DVERTEXTEXTURESAMPLER0 && sampler_idx <= WINED3DVERTEXTEXTURESAMPLER3) sampler_idx -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS); - if (sampler_idx >= sizeof(device->state.sampler_states) / sizeof(*device->state.sampler_states)) + if (sampler_idx >= ARRAY_SIZE(device->state.sampler_states)) { WARN("Invalid sampler %u.\n", sampler_idx); return 0; /* Windows accepts overflowing this array ... we do not. */ @@ -3467,7 +3413,7 @@ HRESULT CDECL wined3d_device_set_texture(struct wined3d_device *device, stage -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS); /* Windows accepts overflowing this array... we do not. */ - if (stage >= sizeof(device->state.textures) / sizeof(*device->state.textures)) + if (stage >= ARRAY_SIZE(device->state.textures)) { WARN("Ignoring invalid stage %u.\n", stage); return WINED3D_OK; @@ -3511,7 +3457,7 @@ struct wined3d_texture * CDECL wined3d_device_get_texture(const struct wined3d_d if (stage >= WINED3DVERTEXTEXTURESAMPLER0 && stage <= WINED3DVERTEXTEXTURESAMPLER3) stage -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS); - if (stage >= sizeof(device->state.textures) / sizeof(*device->state.textures)) + if (stage >= ARRAY_SIZE(device->state.textures)) { WARN("Ignoring invalid stage %u.\n", stage); return NULL; /* Windows accepts overflowing this array ... we do not. */ @@ -3522,17 +3468,10 @@ struct wined3d_texture * CDECL wined3d_device_get_texture(const struct wined3d_d HRESULT CDECL wined3d_device_get_device_caps(const struct wined3d_device *device, WINED3DCAPS *caps) { - HRESULT hr; - TRACE("device %p, caps %p.\n", device, caps); - hr = wined3d_get_device_caps(device->wined3d, device->adapter->ordinal, + return wined3d_get_device_caps(device->wined3d, device->adapter->ordinal, device->create_parms.device_type, caps); - - if (SUCCEEDED(hr) && use_software_vertex_processing(device)) - caps->MaxVertexBlendMatrixIndex = 255; - - return hr; } HRESULT CDECL wined3d_device_get_display_mode(const struct wined3d_device *device, UINT swapchain_idx, @@ -3962,15 +3901,31 @@ HRESULT CDECL wined3d_device_validate_device(const struct wined3d_device *device void CDECL wined3d_device_set_software_vertex_processing(struct wined3d_device *device, BOOL software) { + static BOOL warned; + TRACE("device %p, software %#x.\n", device, software); + if (!warned) + { + FIXME("device %p, software %#x stub!\n", device, software); + warned = TRUE; + } + device->softwareVertexProcessing = software; } BOOL CDECL wined3d_device_get_software_vertex_processing(const struct wined3d_device *device) { + static BOOL warned; + TRACE("device %p.\n", device); + if (!warned) + { + TRACE("device %p stub!\n", device); + warned = TRUE; + } + return device->softwareVertexProcessing; } @@ -4027,12 +3982,6 @@ void CDECL wined3d_device_copy_uav_counter(struct wined3d_device *device, TRACE("device %p, dst_buffer %p, offset %u, uav %p.\n", device, dst_buffer, offset, uav); - if (offset + sizeof(GLuint) > dst_buffer->resource.size) - { - WARN("Offset %u too large.\n", offset); - return; - } - wined3d_cs_emit_copy_uav_counter(device->cs, dst_buffer, offset, uav); } @@ -4069,12 +4018,10 @@ void CDECL wined3d_device_copy_resource(struct wined3d_device *device, return; } - if (src_resource->format->id != dst_resource->format->id && - (src_resource->format->typeless_id != dst_resource->format->typeless_id || - src_resource->format->gl_view_class != dst_resource->format->gl_view_class || - !src_resource->format->typeless_id)) + if (src_resource->format->typeless_id != dst_resource->format->typeless_id + || (!src_resource->format->typeless_id && src_resource->format->id != dst_resource->format->id)) { - WARN("Resource formats (%s / %s) don't match.\n", + WARN("Resource formats %s and %s are incompatible.\n", debug_d3dformat(dst_resource->format->id), debug_d3dformat(src_resource->format->id)); return; @@ -4083,7 +4030,8 @@ void CDECL wined3d_device_copy_resource(struct wined3d_device *device, if (dst_resource->type == WINED3D_RTYPE_BUFFER) { wined3d_box_set(&box, 0, 0, src_resource->size, 1, 0, 1); - wined3d_cs_emit_copy_sub_resource(device->cs, dst_resource, 0, &box, src_resource, 0, &box); + wined3d_cs_emit_blt_sub_resource(device->cs, dst_resource, 0, &box, + src_resource, 0, &box, WINED3D_BLT_RAW, NULL, WINED3D_TEXF_POINT); return; } @@ -4109,7 +4057,8 @@ void CDECL wined3d_device_copy_resource(struct wined3d_device *device, { unsigned int idx = j * dst_texture->level_count + i; - wined3d_cs_emit_copy_sub_resource(device->cs, dst_resource, idx, &box, src_resource, idx, &box); + wined3d_cs_emit_blt_sub_resource(device->cs, dst_resource, idx, &box, + src_resource, idx, &box, WINED3D_BLT_RAW, NULL, WINED3D_TEXF_POINT); } } } @@ -4140,12 +4089,10 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev return WINED3DERR_INVALIDCALL; } - if (src_resource->format->id != dst_resource->format->id && - (src_resource->format->typeless_id != dst_resource->format->typeless_id || - src_resource->format->gl_view_class != dst_resource->format->gl_view_class || - !src_resource->format->typeless_id)) + if (src_resource->format->typeless_id != dst_resource->format->typeless_id + || (!src_resource->format->typeless_id && src_resource->format->id != dst_resource->format->id)) { - WARN("Resource formats (%s / %s) don't match.\n", + WARN("Resource formats %s and %s are incompatible.\n", debug_d3dformat(dst_resource->format->id), debug_d3dformat(src_resource->format->id)); return WINED3DERR_INVALIDCALL; @@ -4167,7 +4114,10 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev if (!src_box) { - wined3d_box_set(&b, 0, 0, src_resource->size, 1, 0, 1); + unsigned int dst_w; + + dst_w = dst_resource->size - dst_x; + wined3d_box_set(&b, 0, 0, min(src_resource->size, dst_w), 1, 0, 1); src_box = &b; } else if ((src_box->left >= src_box->right @@ -4206,7 +4156,6 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev return WINED3DERR_INVALIDCALL; } -#if !defined(STAGING_CSMT) if (dst_texture->sub_resources[dst_sub_resource_idx].map_count) { WARN("Destination sub-resource %u is mapped.\n", dst_sub_resource_idx); @@ -4217,25 +4166,20 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev { WARN("Source sub-resource %u is mapped.\n", src_sub_resource_idx); return WINED3DERR_INVALIDCALL; -#else /* STAGING_CSMT */ - if (dst_texture->sub_resources[dst_sub_resource_idx].map_count || - src_texture->sub_resources[src_sub_resource_idx].map_count) - { - struct wined3d_device *device = dst_texture->resource.device; - device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT); - if (dst_texture->sub_resources[dst_sub_resource_idx].map_count || - src_texture->sub_resources[src_sub_resource_idx].map_count) - { - WARN("Destination or source sub-resource is mapped.\n"); - return WINEDDERR_SURFACEBUSY; - } -#endif /* STAGING_CSMT */ } if (!src_box) { - wined3d_box_set(&b, 0, 0, wined3d_texture_get_level_width(src_texture, src_level), - wined3d_texture_get_level_height(src_texture, src_level), 0, 1); + unsigned int src_w, src_h, dst_w, dst_h, dst_level; + + src_w = wined3d_texture_get_level_width(src_texture, src_level); + src_h = wined3d_texture_get_level_height(src_texture, src_level); + + dst_level = dst_sub_resource_idx % dst_texture->level_count; + dst_w = wined3d_texture_get_level_width(dst_texture, dst_level) - dst_x; + dst_h = wined3d_texture_get_level_height(dst_texture, dst_level) - dst_y; + + wined3d_box_set(&b, 0, 0, min(src_w, dst_w), min(src_h, dst_h), 0, 1); src_box = &b; } else if (FAILED(wined3d_texture_check_box_dimensions(src_texture, src_level, src_box))) @@ -4259,8 +4203,8 @@ HRESULT CDECL wined3d_device_copy_sub_resource_region(struct wined3d_device *dev return WINED3DERR_INVALIDCALL; } - wined3d_cs_emit_copy_sub_resource(device->cs, dst_resource, dst_sub_resource_idx, &dst_box, - src_resource, src_sub_resource_idx, src_box); + wined3d_cs_emit_blt_sub_resource(device->cs, dst_resource, dst_sub_resource_idx, &dst_box, + src_resource, src_sub_resource_idx, src_box, WINED3D_BLT_RAW, NULL, WINED3D_TEXF_POINT); return WINED3D_OK; } @@ -4287,8 +4231,7 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str height = 1; depth = 1; } - else if (resource->type == WINED3D_RTYPE_TEXTURE_1D || - resource->type == WINED3D_RTYPE_TEXTURE_2D || resource->type == WINED3D_RTYPE_TEXTURE_3D) + else if (resource->type == WINED3D_RTYPE_TEXTURE_2D || resource->type == WINED3D_RTYPE_TEXTURE_3D) { struct wined3d_texture *texture = texture_from_resource(resource); unsigned int level; @@ -4323,10 +4266,8 @@ void CDECL wined3d_device_update_sub_resource(struct wined3d_device *device, str return; } -#if !defined(STAGING_CSMT) wined3d_resource_wait_idle(resource); -#endif /* STAGING_CSMT */ wined3d_cs_emit_update_sub_resource(device->cs, resource, sub_resource_idx, box, data, row_pitch, depth_pitch); } @@ -5054,7 +4995,6 @@ void device_resource_released(struct wined3d_device *device, struct wined3d_reso switch (type) { - case WINED3D_RTYPE_TEXTURE_1D: case WINED3D_RTYPE_TEXTURE_2D: case WINED3D_RTYPE_TEXTURE_3D: for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i) @@ -5187,7 +5127,7 @@ HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d, return WINED3D_OK; err: - for (i = 0; i < sizeof(device->multistate_funcs) / sizeof(device->multistate_funcs[0]); ++i) + for (i = 0; i < ARRAY_SIZE(device->multistate_funcs); ++i) { HeapFree(GetProcessHeap(), 0, device->multistate_funcs[i]); } @@ -5275,58 +5215,3 @@ LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL else return CallWindowProcA(proc, window, message, wparam, lparam); } -#if defined(STAGING_CSMT) - -/* Context activation is done by the caller */ -struct wined3d_gl_bo *wined3d_device_get_bo(struct wined3d_device *device, UINT size, GLenum gl_usage, - GLenum type_hint, struct wined3d_context *context) -{ - struct wined3d_gl_bo *ret; - const struct wined3d_gl_info *gl_info; - - TRACE("device %p, size %u, gl_usage %u, type_hint %u\n", device, size, gl_usage, - type_hint); - - ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ret)); - if(!ret) - return NULL; - ret->type_hint = type_hint; - ret->size = size; - ret->usage = gl_usage; - - gl_info = context->gl_info; - - GL_EXTCALL(glGenBuffers(1, &ret->name)); - if (type_hint == GL_ELEMENT_ARRAY_BUFFER) - context_invalidate_state(context, STATE_INDEXBUFFER); - GL_EXTCALL(glBindBuffer(type_hint, ret->name)); - GL_EXTCALL(glBufferData(type_hint, size, NULL, gl_usage)); - GL_EXTCALL(glBindBuffer(type_hint, 0)); - checkGLcall("Create buffer object"); - - TRACE("Successfully created and set up buffer %u\n", ret->name); - return ret; -} - -/* Context activation is done by the caller */ -static void wined3d_device_destroy_bo(struct wined3d_device *device, const struct wined3d_context *context, - struct wined3d_gl_bo *bo) -{ - const struct wined3d_gl_info *gl_info = context->gl_info; - TRACE("device %p, bo %p, GL bo %u\n", device, bo, bo->name); - - GL_EXTCALL(glDeleteBuffers(1, &bo->name)); - checkGLcall("glDeleteBuffers"); - - HeapFree(GetProcessHeap(), 0, bo); -} - -/* Context activation is done by the caller */ -void wined3d_device_release_bo(struct wined3d_device *device, struct wined3d_gl_bo *bo, - const struct wined3d_context *context) -{ - TRACE("device %p, bo %p, GL bo %u\n", device, bo, bo->name); - - wined3d_device_destroy_bo(device, context, bo); -} -#endif /* STAGING_CSMT */ diff --git a/dll/directx/wine/wined3d/directx.c b/dll/directx/wine/wined3d/directx.c index fa09d60b62..40262bbe59 100644 --- a/dll/directx/wine/wined3d/directx.c +++ b/dll/directx/wine/wined3d/directx.c @@ -116,9 +116,9 @@ static const struct wined3d_extension_map gl_extension_map[] = {"GL_ARB_conservative_depth", ARB_CONSERVATIVE_DEPTH }, {"GL_ARB_copy_buffer", ARB_COPY_BUFFER }, {"GL_ARB_copy_image", ARB_COPY_IMAGE }, + {"GL_ARB_cull_distance", ARB_CULL_DISTANCE }, {"GL_ARB_debug_output", ARB_DEBUG_OUTPUT }, {"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT }, - {"GL_ARB_depth_clamp", ARB_DEPTH_CLAMP }, {"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE }, {"GL_ARB_derivative_control", ARB_DERIVATIVE_CONTROL }, {"GL_ARB_draw_buffers", ARB_DRAW_BUFFERS }, @@ -176,6 +176,7 @@ static const struct wined3d_extension_map gl_extension_map[] = {"GL_ARB_texture_cube_map_array", ARB_TEXTURE_CUBE_MAP_ARRAY }, {"GL_ARB_texture_env_combine", ARB_TEXTURE_ENV_COMBINE }, {"GL_ARB_texture_env_dot3", ARB_TEXTURE_ENV_DOT3 }, + {"GL_ARB_texture_filter_anisotropic", ARB_TEXTURE_FILTER_ANISOTROPIC}, {"GL_ARB_texture_float", ARB_TEXTURE_FLOAT }, {"GL_ARB_texture_gather", ARB_TEXTURE_GATHER }, {"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT }, @@ -234,7 +235,7 @@ static const struct wined3d_extension_map gl_extension_map[] = {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC }, {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE }, {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3 }, - {"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC}, + {"GL_EXT_texture_filter_anisotropic", ARB_TEXTURE_FILTER_ANISOTROPIC}, {"GL_EXT_texture_integer", EXT_TEXTURE_INTEGER }, {"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS }, {"GL_EXT_texture_mirror_clamp", EXT_TEXTURE_MIRROR_CLAMP }, @@ -264,7 +265,6 @@ static const struct wined3d_extension_map gl_extension_map[] = {"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2 }, {"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION }, {"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3 }, - {"GL_NVX_gpu_memory_info", NVX_GPU_MEMORY_INFO }, /* SGI */ {"GL_SGIS_generate_mipmap", SGIS_GENERATE_MIPMAP }, @@ -581,7 +581,7 @@ static void test_pbo_functionality(struct wined3d_gl_info *gl_info) 0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff, 0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff }; - unsigned int check[sizeof(pattern) / sizeof(pattern[0])]; + unsigned int check[ARRAY_SIZE(pattern)]; /* No PBO -> No point in testing them. */ if (!gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]) return; @@ -1338,7 +1338,6 @@ static const struct gpu_description gpu_description_table[] = {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX550, "NVIDIA GeForce GTX 550 Ti", DRIVER_NVIDIA_GEFORCE8, 1024}, {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GT555M, "NVIDIA GeForce GT 555M", DRIVER_NVIDIA_GEFORCE8, 1024}, {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560TI, "NVIDIA GeForce GTX 560 Ti", DRIVER_NVIDIA_GEFORCE8, 1024}, - {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560M, "NVIDIA GeForce GTX 560M", DRIVER_NVIDIA_GEFORCE8, 3072}, {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX560, "NVIDIA GeForce GTX 560", DRIVER_NVIDIA_GEFORCE8, 1024}, {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX570, "NVIDIA GeForce GTX 570", DRIVER_NVIDIA_GEFORCE8, 1280}, {HW_VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX580, "NVIDIA GeForce GTX 580", DRIVER_NVIDIA_GEFORCE8, 1536}, @@ -1486,6 +1485,7 @@ static const struct gpu_description gpu_description_table[] = {HW_VENDOR_INTEL, CARD_INTEL_IVBS, "Intel(R) HD Graphics Family", DRIVER_INTEL_HD4000, 1536}, {HW_VENDOR_INTEL, CARD_INTEL_HWD, "Intel(R) HD Graphics 4600", DRIVER_INTEL_HD4000, 1536}, {HW_VENDOR_INTEL, CARD_INTEL_HWM, "Intel(R) HD Graphics 4600", DRIVER_INTEL_HD4000, 1536}, + {HW_VENDOR_INTEL, CARD_INTEL_HD5000, "Intel(R) HD Graphics 5000", DRIVER_INTEL_HD4000, 1536}, {HW_VENDOR_INTEL, CARD_INTEL_I5100_1, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536}, {HW_VENDOR_INTEL, CARD_INTEL_I5100_2, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536}, {HW_VENDOR_INTEL, CARD_INTEL_I5100_3, "Intel(R) Iris(TM) Graphics 5100", DRIVER_INTEL_HD4000, 1536}, @@ -1527,7 +1527,7 @@ static const struct driver_version_information *get_driver_version_info(enum win unsigned int i; TRACE("Looking up version info for driver=%d driver_model=%d\n", driver, driver_model); - for (i = 0; i < (sizeof(driver_version_table) / sizeof(driver_version_table[0])); i++) + for (i = 0; i < ARRAY_SIZE(driver_version_table); ++i) { const struct driver_version_information *entry = &driver_version_table[i]; @@ -1547,7 +1547,7 @@ static const struct gpu_description *get_gpu_description(enum wined3d_pci_vendor { unsigned int i; - for (i = 0; i < (sizeof(gpu_description_table) / sizeof(*gpu_description_table)); ++i) + for (i = 0; i < ARRAY_SIZE(gpu_description_table); ++i) { if (vendor == gpu_description_table[i].vendor && device == gpu_description_table[i].card) return &gpu_description_table[i]; @@ -1576,15 +1576,6 @@ static const struct gpu_description *query_gpu_description(const struct wined3d_ TRACE("Card reports vendor PCI ID 0x%04x, device PCI ID 0x%04x, 0x%s bytes of video memory.\n", vendor, device, wine_dbgstr_longlong(*vram_bytes)); } - else if (gl_info->supported[NVX_GPU_MEMORY_INFO]) - { - GLint vram_kb; - gl_info->gl_ops.gl.p_glGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, &vram_kb); - - *vram_bytes = (UINT64)vram_kb * 1024; - TRACE("Got 0x%s as video memory from NVX_GPU_MEMORY_INFO extension.\n", - wine_dbgstr_longlong(*vram_bytes)); - } if (wined3d_settings.pci_vendor_id != PCI_VENDOR_NONE) { @@ -1696,13 +1687,11 @@ static void init_driver_info(struct wined3d_driver_info *driver_info, * In order to avoid this application bug we limit the amount of video memory * to LONG_MAX for older Windows versions. */ -#ifdef __i386__ if (driver_model < DRIVER_MODEL_NT6X && driver_info->vram_bytes > LONG_MAX) { TRACE("Limiting amount of video memory to %#lx bytes for OS version older than Vista.\n", LONG_MAX); driver_info->vram_bytes = LONG_MAX; } -#endif /* Try to obtain driver version information for the current Windows version. This fails in * some cases: @@ -1744,7 +1733,7 @@ static void fixup_extensions(struct wined3d_gl_info *gl_info, struct wined3d_cap { unsigned int i; - for (i = 0; i < (sizeof(quirk_table) / sizeof(*quirk_table)); ++i) + for (i = 0; i < ARRAY_SIZE(quirk_table); ++i) { if (!quirk_table[i].match(gl_info, ctx, gl_renderer, gl_vendor, card_vendor, device)) continue; TRACE("Applying driver quirk \"%s\".\n", quirk_table[i].description); @@ -1799,7 +1788,6 @@ static enum wined3d_gl_vendor wined3d_guess_gl_vendor(const struct wined3d_gl_in return GL_VENDOR_FGLRX; if (strstr(gl_vendor_string, "Mesa") - || strstr(gl_vendor_string, "Brian Paul") || strstr(gl_vendor_string, "X.Org") || strstr(gl_vendor_string, "Advanced Micro Devices, Inc.") || strstr(gl_vendor_string, "DRI R300 Project") @@ -1954,7 +1942,6 @@ cards_nvidia_binary[] = {"GTX 580", CARD_NVIDIA_GEFORCE_GTX580}, /* Geforce 500 - highend */ {"GTX 570", CARD_NVIDIA_GEFORCE_GTX570}, /* Geforce 500 - midend high */ {"GTX 560 Ti", CARD_NVIDIA_GEFORCE_GTX560TI}, /* Geforce 500 - midend */ - {"GTX 560M", CARD_NVIDIA_GEFORCE_GTX560M}, /* Geforce 500 - midend mobile */ {"GTX 560", CARD_NVIDIA_GEFORCE_GTX560}, /* Geforce 500 - midend */ {"GT 555M", CARD_NVIDIA_GEFORCE_GT555M}, /* Geforce 500 - midend mobile */ {"GTX 550 Ti", CARD_NVIDIA_GEFORCE_GTX550}, /* Geforce 500 - midend */ @@ -2167,6 +2154,7 @@ cards_intel[] = /* Haswell */ {"Iris Pro 5200", CARD_INTEL_IP5200_1}, {"Iris 5100", CARD_INTEL_I5100_1}, + {"HD Graphics 5000", CARD_INTEL_HD5000}, /* MacOS */ {"Haswell Mobile", CARD_INTEL_HWM}, {"Iris OpenGL Engine", CARD_INTEL_HWM}, /* MacOS */ /* Ivybridge */ @@ -2494,16 +2482,16 @@ static const struct card_vendor_table[] = { {HW_VENDOR_AMD, "AMD", amd_gl_vendor_table, - sizeof(amd_gl_vendor_table) / sizeof(*amd_gl_vendor_table), + ARRAY_SIZE(amd_gl_vendor_table), card_fallback_amd}, {HW_VENDOR_NVIDIA, "Nvidia", nvidia_gl_vendor_table, - sizeof(nvidia_gl_vendor_table) / sizeof(*nvidia_gl_vendor_table), + ARRAY_SIZE(nvidia_gl_vendor_table), card_fallback_nvidia}, {HW_VENDOR_VMWARE, "VMware", vmware_gl_vendor_table, - sizeof(vmware_gl_vendor_table) / sizeof(*vmware_gl_vendor_table), + ARRAY_SIZE(vmware_gl_vendor_table), card_fallback_amd}, {HW_VENDOR_INTEL, "Intel", intel_gl_vendor_table, - sizeof(intel_gl_vendor_table) / sizeof(*intel_gl_vendor_table), + ARRAY_SIZE(intel_gl_vendor_table), card_fallback_intel}, }; @@ -2565,7 +2553,7 @@ static enum wined3d_pci_device wined3d_guess_card(const struct shader_caps *shad enum wined3d_d3d_level d3d_level = d3d_level_from_caps(shader_caps, fragment_caps, glsl_version); enum wined3d_pci_device device; - for (i = 0; i < (sizeof(card_vendor_table) / sizeof(*card_vendor_table)); ++i) + for (i = 0; i < ARRAY_SIZE(card_vendor_table); ++i) { if (card_vendor_table[i].card_vendor != *card_vendor) continue; @@ -3524,12 +3512,6 @@ static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info) gl_info->limits.buffers = gl_max; TRACE("Max draw buffers: %u.\n", gl_max); } - if (gl_info->supported[ARB_BLEND_FUNC_EXTENDED]) - { - gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_DUAL_SOURCE_DRAW_BUFFERS, &gl_max); - gl_info->limits.dual_buffers = gl_max; - TRACE("Max dual source draw buffers: %u.\n", gl_max); - } if (gl_info->supported[ARB_MULTITEXTURE]) { if (gl_info->supported[WINED3D_GL_LEGACY_CONTEXT]) @@ -3625,9 +3607,9 @@ static void wined3d_adapter_init_limits(struct wined3d_gl_info *gl_info) gl_info->limits.texture3d_size = gl_max; TRACE("Max texture3D size: %d.\n", gl_info->limits.texture3d_size); } - if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC]) + if (gl_info->supported[ARB_TEXTURE_FILTER_ANISOTROPIC]) { - gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_max); + gl_info->gl_ops.gl.p_glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY, &gl_max); gl_info->limits.anisotropy = gl_max; TRACE("Max anisotropy: %d.\n", gl_info->limits.anisotropy); } @@ -3906,6 +3888,8 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter, {ARB_ES2_COMPATIBILITY, MAKEDWORD_VERSION(4, 1)}, {ARB_VIEWPORT_ARRAY, MAKEDWORD_VERSION(4, 1)}, + {ARB_BASE_INSTANCE, MAKEDWORD_VERSION(4, 2)}, + {ARB_CONSERVATIVE_DEPTH, MAKEDWORD_VERSION(4, 2)}, {ARB_INTERNALFORMAT_QUERY, MAKEDWORD_VERSION(4, 2)}, {ARB_MAP_BUFFER_ALIGNMENT, MAKEDWORD_VERSION(4, 2)}, {ARB_SHADER_ATOMIC_COUNTERS, MAKEDWORD_VERSION(4, 2)}, @@ -3932,9 +3916,11 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter, {ARB_CLEAR_TEXTURE, MAKEDWORD_VERSION(4, 4)}, {ARB_CLIP_CONTROL, MAKEDWORD_VERSION(4, 5)}, + {ARB_CULL_DISTANCE, MAKEDWORD_VERSION(4, 5)}, {ARB_DERIVATIVE_CONTROL, MAKEDWORD_VERSION(4, 5)}, {ARB_PIPELINE_STATISTICS_QUERY, MAKEDWORD_VERSION(4, 6)}, + {ARB_TEXTURE_FILTER_ANISOTROPIC, MAKEDWORD_VERSION(4, 6)}, }; struct wined3d_driver_info *driver_info = &adapter->driver_info; const char *gl_vendor_str, *gl_renderer_str, *gl_version_str; @@ -4004,13 +3990,11 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter, ERR("Received a NULL GL_EXTENSIONS.\n"); return FALSE; } - parse_extension_string(gl_info, gl_extensions, gl_extension_map, - sizeof(gl_extension_map) / sizeof(*gl_extension_map)); + parse_extension_string(gl_info, gl_extensions, gl_extension_map, ARRAY_SIZE(gl_extension_map)); } else { - enumerate_gl_extensions(gl_info, gl_extension_map, - sizeof(gl_extension_map) / sizeof(*gl_extension_map)); + enumerate_gl_extensions(gl_info, gl_extension_map, ARRAY_SIZE(gl_extension_map)); } hdc = wglGetCurrentDC(); @@ -4020,8 +4004,7 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter, if (!WGL_Extensions) WARN("WGL extensions not supported.\n"); else - parse_extension_string(gl_info, WGL_Extensions, wgl_extension_map, - sizeof(wgl_extension_map) / sizeof(*wgl_extension_map)); + parse_extension_string(gl_info, WGL_Extensions, wgl_extension_map, ARRAY_SIZE(wgl_extension_map)); for (i = 0; i < ARRAY_SIZE(core_extensions); ++i) { @@ -4233,9 +4216,17 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter, if (gl_info->supported[ARB_TEXTURE_STORAGE] && gl_info->supported[APPLE_YCBCR_422]) { /* AFAIK APPLE_ycbcr_422 is only available in legacy contexts so we shouldn't ever hit this. */ - FIXME("Disabling APPLE_ycbcr_422 because of ARB_texture_storage.\n"); + ERR("Disabling APPLE_ycbcr_422 because of ARB_texture_storage.\n"); gl_info->supported[APPLE_YCBCR_422] = FALSE; } + if (gl_info->supported[ARB_DRAW_INDIRECT] && !gl_info->supported[ARB_BASE_INSTANCE]) + { + /* If ARB_base_instance is not supported the baseInstance field + * in indirect draw parameters must be 0 or behavior is undefined. + */ + WARN("Disabling ARB_draw_indirect because ARB_base_instance is not supported.\n"); + gl_info->supported[ARB_DRAW_INDIRECT] = FALSE; + } wined3d_adapter_init_limits(gl_info); @@ -4293,10 +4284,6 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter, for (i = 0; i < gl_info->limits.buffers; ++i) adapter->d3d_info.valid_rt_mask |= (1u << i); - adapter->d3d_info.valid_dual_rt_mask = 0; - for (i = 0; i < gl_info->limits.dual_buffers; ++i) - adapter->d3d_info.valid_dual_rt_mask |= (1u << i); - if (!adapter->d3d_info.shader_color_key) { /* We do not want to deal with re-creating immutable texture storage for color keying emulation. */ @@ -5257,6 +5244,13 @@ static BOOL wined3d_check_surface_capability(const struct wined3d_format *format return TRUE; } + if ((format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & (WINED3DFMT_FLAG_EXTENSION | WINED3DFMT_FLAG_TEXTURE)) + == (WINED3DFMT_FLAG_EXTENSION | WINED3DFMT_FLAG_TEXTURE)) + { + TRACE("[OK]\n"); + return TRUE; + } + /* Reject other formats */ TRACE("[FAILED]\n"); return FALSE; @@ -5276,10 +5270,9 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad { const struct wined3d_adapter *adapter = &wined3d->adapters[adapter_idx]; const struct wined3d_gl_info *gl_info = &adapter->gl_info; - const struct wined3d_format *adapter_format = wined3d_get_format(gl_info, adapter_format_id, - WINED3DUSAGE_RENDERTARGET); - const struct wined3d_format *format = wined3d_get_format(gl_info, check_format_id, usage); + const struct wined3d_format *adapter_format, *format; enum wined3d_gl_resource_type gl_type, gl_type_end; + BOOL mipmap_autogen_supported; DWORD format_flags = 0; DWORD allowed_usage; @@ -5292,28 +5285,18 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad if (adapter_idx >= wined3d->adapter_count) return WINED3DERR_INVALIDCALL; + adapter_format = wined3d_get_format(gl_info, adapter_format_id, WINED3DUSAGE_RENDERTARGET); + format = wined3d_get_format(gl_info, check_format_id, usage); + switch (resource_type) { case WINED3D_RTYPE_NONE: allowed_usage = WINED3DUSAGE_DEPTHSTENCIL | WINED3DUSAGE_RENDERTARGET; - gl_type = WINED3D_GL_RES_TYPE_TEX_1D; + gl_type = WINED3D_GL_RES_TYPE_TEX_2D; gl_type_end = WINED3D_GL_RES_TYPE_TEX_3D; break; - case WINED3D_RTYPE_TEXTURE_1D: - allowed_usage = WINED3DUSAGE_DYNAMIC - | WINED3DUSAGE_SOFTWAREPROCESSING - | WINED3DUSAGE_TEXTURE - | WINED3DUSAGE_QUERY_FILTER - | WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING - | WINED3DUSAGE_QUERY_SRGBREAD - | WINED3DUSAGE_QUERY_SRGBWRITE - | WINED3DUSAGE_QUERY_VERTEXTEXTURE - | WINED3DUSAGE_QUERY_WRAPANDMIP; - gl_type = gl_type_end = WINED3D_GL_RES_TYPE_TEX_1D; - break; - case WINED3D_RTYPE_TEXTURE_2D: allowed_usage = WINED3DUSAGE_DEPTHSTENCIL | WINED3DUSAGE_RENDERTARGET @@ -5370,12 +5353,6 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad gl_type = gl_type_end = WINED3D_GL_RES_TYPE_TEX_3D; break; - case WINED3D_RTYPE_BUFFER: - allowed_usage = WINED3DUSAGE_DYNAMIC - | WINED3DUSAGE_QUERY_VERTEXTEXTURE; - gl_type = gl_type_end = WINED3D_GL_RES_TYPE_BUFFER; - break; - default: FIXME("Unhandled resource type %s.\n", debug_d3dresourcetype(resource_type)); return WINED3DERR_NOTAVAILABLE; @@ -5409,12 +5386,7 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad return WINED3DERR_NOTAVAILABLE; } - if ((usage & WINED3DUSAGE_AUTOGENMIPMAP) && !gl_info->supported[SGIS_GENERATE_MIPMAP]) - { - TRACE("No WINED3DUSAGE_AUTOGENMIPMAP support, returning WINED3DOK_NOAUTOGEN.\n"); - return WINED3DOK_NOAUTOGEN; - } - + mipmap_autogen_supported = gl_info->supported[SGIS_GENERATE_MIPMAP]; for (; gl_type <= gl_type_end; ++gl_type) { if ((format->flags[gl_type] & format_flags) != format_flags) @@ -5443,6 +5415,18 @@ HRESULT CDECL wined3d_check_device_format(const struct wined3d *wined3d, UINT ad debug_d3dformat(check_format_id)); return WINED3DERR_NOTAVAILABLE; } + + if ((format->flags[gl_type] & (WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FILTERING)) + != (WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_FILTERING)) + { + mipmap_autogen_supported = FALSE; + } + } + + if ((usage & WINED3DUSAGE_AUTOGENMIPMAP) && !mipmap_autogen_supported) + { + TRACE("No WINED3DUSAGE_AUTOGENMIPMAP support, returning WINED3DOK_NOAUTOGEN.\n"); + return WINED3DOK_NOAUTOGEN; } return WINED3D_OK; @@ -5678,7 +5662,7 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapte WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS | WINED3DPRASTERCAPS_DEPTHBIAS; - if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC]) + if (gl_info->supported[ARB_TEXTURE_FILTER_ANISOTROPIC]) { caps->RasterCaps |= WINED3DPRASTERCAPS_ANISOTROPY | WINED3DPRASTERCAPS_ZBIAS | @@ -5797,7 +5781,7 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapte WINED3DPTFILTERCAPS_MIPNEAREST | WINED3DPTFILTERCAPS_NEAREST; - if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC]) + if (gl_info->supported[ARB_TEXTURE_FILTER_ANISOTROPIC]) { caps->TextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC | WINED3DPTFILTERCAPS_MINFANISOTROPIC; @@ -5818,7 +5802,7 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapte WINED3DPTFILTERCAPS_MIPNEAREST | WINED3DPTFILTERCAPS_NEAREST; - if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC]) + if (gl_info->supported[ARB_TEXTURE_FILTER_ANISOTROPIC]) { caps->CubeTextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC | WINED3DPTFILTERCAPS_MINFANISOTROPIC; @@ -5978,10 +5962,7 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapte caps->MaxUserClipPlanes = vertex_caps.max_user_clip_planes; caps->MaxActiveLights = vertex_caps.max_active_lights; caps->MaxVertexBlendMatrices = vertex_caps.max_vertex_blend_matrices; - if (device_type == WINED3D_DEVICE_TYPE_HAL) - caps->MaxVertexBlendMatrixIndex = vertex_caps.max_vertex_blend_matrix_index; - else - caps->MaxVertexBlendMatrixIndex = 255; + caps->MaxVertexBlendMatrixIndex = vertex_caps.max_vertex_blend_matrix_index; caps->VertexProcessingCaps = vertex_caps.vertex_processing_caps; caps->FVFCaps = vertex_caps.fvf_caps; caps->RasterCaps |= vertex_caps.raster_caps; @@ -6550,30 +6531,35 @@ static void wined3d_adapter_init_fb_cfgs(struct wined3d_adapter *adapter, HDC dc } } -static BOOL has_extension(const char *list, const char *ext) +static DWORD get_max_gl_version(const struct wined3d_gl_info *gl_info, DWORD flags) { - size_t len = strlen(ext); - while (list) - { - while (*list == ' ') list++; - if (!strncmp(list, ext, len) && (!list[len] || list[len] == ' ')) return TRUE; - list = strchr(list, ' '); - } - return FALSE; + const char *gl_vendor, *gl_renderer; + + if (wined3d_settings.explicit_gl_version || (flags & WINED3D_PIXEL_CENTER_INTEGER)) + return wined3d_settings.max_gl_version; + + gl_vendor = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_VENDOR); + gl_renderer = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_RENDERER); + if (!gl_vendor || !gl_renderer + || wined3d_guess_card_vendor(gl_vendor, gl_renderer) == HW_VENDOR_NVIDIA) + return wined3d_settings.max_gl_version; + + return MAKEDWORD_VERSION(4, 4); } static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, UINT ordinal, DWORD wined3d_creation_flags) { static const DWORD supported_gl_versions[] = { + MAKEDWORD_VERSION(4, 4), MAKEDWORD_VERSION(3, 2), MAKEDWORD_VERSION(1, 0), }; struct wined3d_gl_info *gl_info = &adapter->gl_info; struct wined3d_caps_gl_ctx caps_gl_ctx = {0}; - DWORD max_gl_version = wined3d_settings.max_gl_version; - DISPLAY_DEVICEW display_device; unsigned int i; + DISPLAY_DEVICEW display_device; + DWORD max_gl_version; TRACE("adapter %p, ordinal %u.\n", adapter, ordinal); @@ -6618,16 +6604,7 @@ static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, UINT ordinal, return FALSE; } - if (wined3d_creation_flags & WINED3D_REQUEST_D3D10) - { - const char *gl_extensions = (const char *)gl_info->gl_ops.gl.p_glGetString(GL_EXTENSIONS); - if (!has_extension(gl_extensions, "GL_ARB_compatibility")) - { - ERR_(winediag)("GL_ARB_compatibility not supported, requesting context with GL version 3.2.\n"); - max_gl_version = MAKEDWORD_VERSION(3, 2); - } - } - + max_gl_version = get_max_gl_version(gl_info, wined3d_creation_flags); for (i = 0; i < ARRAY_SIZE(supported_gl_versions); ++i) { if (supported_gl_versions[i] <= max_gl_version) @@ -6681,10 +6658,6 @@ static BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, UINT ordinal, return FALSE; } - gl_info->fixed_polyoffset_scale = wined3d_adapter_find_polyoffset_scale(&caps_gl_ctx, GL_DEPTH_COMPONENT); - if (gl_info->supported[ARB_DEPTH_BUFFER_FLOAT]) - gl_info->float_polyoffset_scale = wined3d_adapter_find_polyoffset_scale(&caps_gl_ctx, GL_DEPTH32F_STENCIL8); - adapter->vram_bytes = adapter->driver_info.vram_bytes; adapter->vram_bytes_used = 0; TRACE("Emulating 0x%s bytes of video ram.\n", wine_dbgstr_longlong(adapter->vram_bytes)); diff --git a/dll/directx/wine/wined3d/drawprim.c b/dll/directx/wine/wined3d/drawprim.c index e876ba3368..fa6d508327 100644 --- a/dll/directx/wine/wined3d/drawprim.c +++ b/dll/directx/wine/wined3d/drawprim.c @@ -162,133 +162,6 @@ static void draw_primitive_arrays(struct wined3d_context *context, const struct } } -/* Context activation is done by the caller. */ -static void draw_primitive_arrays_indirect(struct wined3d_context *context, const struct wined3d_state *state, - const void *idx_data, unsigned int idx_size, struct wined3d_buffer *buffer, unsigned int offset) -{ - const struct wined3d_gl_info *gl_info = context->gl_info; - - if (!gl_info->supported[ARB_DRAW_INDIRECT]) - { - FIXME("Indirect draw not supported.\n"); - return; - } - - wined3d_buffer_load(buffer, context, state); - GL_EXTCALL(glBindBuffer(GL_DRAW_INDIRECT_BUFFER, buffer->buffer_object)); - - if (idx_size) - { - GLenum idx_type = (idx_size == 2) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT; - - GL_EXTCALL(glDrawElementsIndirect(state->gl_primitive_type, idx_type, - (const BYTE *)NULL + offset)); - } - else - { - GL_EXTCALL(glDrawArraysIndirect(state->gl_primitive_type, - (const BYTE *)NULL + offset)); - } - - GL_EXTCALL(glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0)); - checkGLcall("draw indirect"); -} - -static const BYTE *software_vertex_blending(struct wined3d_context *context, - const struct wined3d_state *state, const struct wined3d_stream_info *si, - unsigned int element_idx, unsigned int stride_idx, float *result) -{ -#define SI_FORMAT(idx) (si->elements[(idx)].format->emit_idx) -#define SI_PTR(idx1, idx2) (si->elements[(idx1)].data.addr + si->elements[(idx1)].stride * (idx2)) - - const float *data = (const float *)SI_PTR(element_idx, stride_idx); - float vector[4] = {0.0f, 0.0f, 0.0f, 1.0f}; - float cur_weight, weight_sum = 0.0f; - struct wined3d_matrix m; - const BYTE *blend_index; - const float *weights; - int i, num_weights; - - if (element_idx != WINED3D_FFP_POSITION && element_idx != WINED3D_FFP_NORMAL) - return (BYTE *)data; - - if (!use_indexed_vertex_blending(state, si) || !use_software_vertex_processing(context->device)) - return (BYTE *)data; - - if (!si->elements[WINED3D_FFP_BLENDINDICES].data.addr || - !si->elements[WINED3D_FFP_BLENDWEIGHT].data.addr) - { - FIXME("no blend indices / weights set\n"); - return (BYTE *)data; - } - - if (SI_FORMAT(WINED3D_FFP_BLENDINDICES) != WINED3D_FFP_EMIT_UBYTE4) - { - FIXME("unsupported blend index format: %u\n", SI_FORMAT(WINED3D_FFP_BLENDINDICES)); - return (BYTE *)data; - } - - /* FIXME: validate weight format */ - switch (state->render_states[WINED3D_RS_VERTEXBLEND]) - { - case WINED3D_VBF_0WEIGHTS: num_weights = 0; break; - case WINED3D_VBF_1WEIGHTS: num_weights = 1; break; - case WINED3D_VBF_2WEIGHTS: num_weights = 2; break; - case WINED3D_VBF_3WEIGHTS: num_weights = 3; break; - default: - FIXME("unsupported vertex blend render state: %u\n", state->render_states[WINED3D_RS_VERTEXBLEND]); - return (BYTE *)data; - } - - switch (SI_FORMAT(element_idx)) - { - case WINED3D_FFP_EMIT_FLOAT4: vector[3] = data[3]; - case WINED3D_FFP_EMIT_FLOAT3: vector[2] = data[2]; - case WINED3D_FFP_EMIT_FLOAT2: vector[1] = data[1]; - case WINED3D_FFP_EMIT_FLOAT1: vector[0] = data[0]; break; - default: - FIXME("unsupported value format: %u\n", SI_FORMAT(element_idx)); - return (BYTE *)data; - } - - blend_index = SI_PTR(WINED3D_FFP_BLENDINDICES, stride_idx); - weights = (const float *)SI_PTR(WINED3D_FFP_BLENDWEIGHT, stride_idx); - result[0] = result[1] = result[2] = result[3] = 0.0f; - - for (i = 0; i < num_weights + 1; i++) - { - cur_weight = (i < num_weights) ? weights[i] : 1.0f - weight_sum; - get_modelview_matrix(context, state, blend_index[i], &m); - - if (element_idx == WINED3D_FFP_POSITION) - { - result[0] += cur_weight * (vector[0] * m._11 + vector[1] * m._21 + vector[2] * m._31 + vector[3] * m._41); - result[1] += cur_weight * (vector[0] * m._12 + vector[1] * m._22 + vector[2] * m._32 + vector[3] * m._42); - result[2] += cur_weight * (vector[0] * m._13 + vector[1] * m._23 + vector[2] * m._33 + vector[3] * m._43); - result[3] += cur_weight * (vector[0] * m._14 + vector[1] * m._24 + vector[2] * m._34 + vector[3] * m._44); - } - else - { - if (context->d3d_info->wined3d_creation_flags & WINED3D_LEGACY_FFP_LIGHTING) - invert_matrix_3d(&m, &m); - else - invert_matrix(&m, &m); - - /* multiply with transposed M */ - result[0] += cur_weight * (vector[0] * m._11 + vector[1] * m._12 + vector[2] * m._13); - result[1] += cur_weight * (vector[0] * m._21 + vector[1] * m._22 + vector[2] * m._23); - result[2] += cur_weight * (vector[0] * m._31 + vector[1] * m._32 + vector[2] * m._33); - } - - weight_sum += weights[i]; - } - -#undef SI_FORMAT -#undef SI_PTR - - return (BYTE *)result; -} - static unsigned int get_stride_idx(const void *idx_data, unsigned int idx_size, unsigned int base_vertex_idx, unsigned int start_idx, unsigned int vertex_idx) { @@ -317,7 +190,6 @@ static void draw_primitive_immediate_mode(struct wined3d_context *context, const BOOL specular_fog = FALSE; BOOL ps = use_ps(state); const void *ptr; - float tmp[4]; static unsigned int once; @@ -354,7 +226,7 @@ static void draw_primitive_immediate_mode(struct wined3d_context *context, const if (!(use_map & 1u << element_idx)) continue; - ptr = software_vertex_blending(context, state, si, element_idx, stride_idx, tmp); + ptr = si->elements[element_idx].data.addr + si->elements[element_idx].stride * stride_idx; ops->generic[si->elements[element_idx].format->emit_idx](element_idx, ptr); } } @@ -466,7 +338,7 @@ static void draw_primitive_immediate_mode(struct wined3d_context *context, const if (normal) { - ptr = software_vertex_blending(context, state, si, WINED3D_FFP_NORMAL, stride_idx, tmp); + ptr = normal + stride_idx * si->elements[WINED3D_FFP_NORMAL].stride; ops->normal[si->elements[WINED3D_FFP_NORMAL].format->emit_idx](ptr); } @@ -511,7 +383,7 @@ static void draw_primitive_immediate_mode(struct wined3d_context *context, const if (position) { - ptr = software_vertex_blending(context, state, si, WINED3D_FFP_POSITION, stride_idx, tmp); + ptr = position + stride_idx * si->elements[WINED3D_FFP_POSITION].stride; ops->position[si->elements[WINED3D_FFP_POSITION].format->emit_idx](ptr); } } @@ -520,6 +392,39 @@ static void draw_primitive_immediate_mode(struct wined3d_context *context, const checkGLcall("glEnd and previous calls"); } +static void draw_indirect(struct wined3d_context *context, const struct wined3d_state *state, + const struct wined3d_indirect_draw_parameters *parameters, unsigned int idx_size) +{ + const struct wined3d_gl_info *gl_info = context->gl_info; + struct wined3d_buffer *buffer = parameters->buffer; + + if (!gl_info->supported[ARB_DRAW_INDIRECT]) + { + FIXME("OpenGL implementation does not support indirect draws.\n"); + return; + } + + GL_EXTCALL(glBindBuffer(GL_DRAW_INDIRECT_BUFFER, buffer->buffer_object)); + + if (idx_size) + { + GLenum idx_type = idx_size == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT; + if (state->index_offset) + FIXME("Ignoring index offset %u.\n", state->index_offset); + GL_EXTCALL(glDrawElementsIndirect(state->gl_primitive_type, idx_type, + (void *)(GLintptr)parameters->offset)); + } + else + { + GL_EXTCALL(glDrawArraysIndirect(state->gl_primitive_type, + (void *)(GLintptr)parameters->offset)); + } + + GL_EXTCALL(glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0)); + + checkGLcall("draw indirect"); +} + static void remove_vbos(struct wined3d_context *context, const struct wined3d_state *state, struct wined3d_stream_info *s) { @@ -637,7 +542,7 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s if (!(rtv = fb->render_targets[i]) || rtv->format->id == WINED3DFMT_NULL) continue; - if (state->render_states[WINED3D_RS_COLORWRITE(i)]) + if (state->render_states[WINED3D_RS_COLORWRITEENABLE]) { wined3d_rendertarget_view_load_location(rtv, context, rtv->resource->draw_binding); wined3d_rendertarget_view_invalidate_location(rtv, ~rtv->resource->draw_binding); @@ -663,6 +568,9 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s wined3d_rendertarget_view_prepare_location(dsv, context, location); } + if (parameters->indirect) + wined3d_buffer_load(parameters->u.indirect.buffer, context, state); + if (!context_apply_draw_state(context, device, state)) { context_release(context); @@ -726,11 +634,6 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s WARN_(d3d_perf)("Using software emulation because manual fog coordinates are provided.\n"); emulation = TRUE; } - else if (use_indexed_vertex_blending(state, stream_info) && use_software_vertex_processing(context->device)) - { - WARN_(d3d_perf)("Using software emulation because application requested SVP.\n"); - emulation = TRUE; - } if (emulation) { @@ -744,7 +647,7 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s { const struct wined3d_shader *shader = state->shader[WINED3D_SHADER_TYPE_GEOMETRY]; - if (shader->u.gs.so_desc.rasterizer_stream_idx == WINED3D_NO_RASTERIZER_STREAM) + if (is_rasterization_disabled(shader)) { glEnable(GL_RASTERIZER_DISCARD); checkGLcall("enable rasterizer discard"); @@ -774,11 +677,10 @@ void draw_primitive(struct wined3d_device *device, const struct wined3d_state *s if (parameters->indirect) { - if (context->use_immediate_mode_draw || emulation) - FIXME("Indirect draw with immediate mode/emulation is not supported.\n"); + if (!context->use_immediate_mode_draw && !emulation) + draw_indirect(context, state, ¶meters->u.indirect, idx_size); else - draw_primitive_arrays_indirect(context, state, idx_data, idx_size, - parameters->u.indirect.buffer, parameters->u.indirect.offset); + FIXME("Indirect draws with immediate mode/emulation are not supported.\n"); } else { @@ -845,6 +747,9 @@ void dispatch_compute(struct wined3d_device *device, const struct wined3d_state return; } + if (parameters->indirect) + wined3d_buffer_load(parameters->u.indirect.buffer, context, state); + context_apply_compute_state(context, device, state); if (!state->shader[WINED3D_SHADER_TYPE_COMPUTE]) @@ -859,7 +764,6 @@ void dispatch_compute(struct wined3d_device *device, const struct wined3d_state const struct wined3d_indirect_dispatch_parameters *indirect = ¶meters->u.indirect; struct wined3d_buffer *buffer = indirect->buffer; - wined3d_buffer_load(buffer, context, state); GL_EXTCALL(glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, buffer->buffer_object)); GL_EXTCALL(glDispatchComputeIndirect((GLintptr)indirect->offset)); GL_EXTCALL(glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, 0)); diff --git a/dll/directx/wine/wined3d/glsl_shader.c b/dll/directx/wine/wined3d/glsl_shader.c index 6d17358dac..3796865340 100644 --- a/dll/directx/wine/wined3d/glsl_shader.c +++ b/dll/directx/wine/wined3d/glsl_shader.c @@ -82,7 +82,6 @@ struct glsl_sample_function enum wined3d_data_type data_type; BOOL output_single_component; unsigned int offset_size; - enum wined3d_shader_resource_type emulate_lod; }; enum heap_node_op @@ -135,9 +134,9 @@ struct glsl_vs_program GLint uniform_b_locations[WINED3D_MAX_CONSTS_B]; GLint pos_fixup_location; - GLint modelview_matrix_location[MAX_VERTEX_INDEX_BLENDS]; - GLint normal_matrix_location[MAX_VERTEX_INDEX_BLENDS]; + GLint modelview_matrix_location[MAX_VERTEX_BLENDS]; GLint projection_matrix_location; + GLint normal_matrix_location; GLint texture_matrix_location[MAX_TEXTURES]; GLint material_ambient_location; GLint material_diffuse_location; @@ -233,7 +232,10 @@ struct glsl_shader_prog_link struct glsl_cs_program cs; GLuint id; DWORD constant_update_mask; - UINT constant_version; + unsigned int constant_version; + DWORD shader_controlled_clip_distances : 1; + DWORD clip_distance_mask : 8; /* MAX_CLIP_DISTANCES, 8 */ + DWORD padding : 23; }; struct glsl_program_key @@ -258,6 +260,7 @@ struct glsl_context_data { struct glsl_shader_prog_link *glsl_program; GLenum vertex_color_clamp; + BOOL rasterization_disabled; }; struct glsl_ps_compiled_shader @@ -378,7 +381,9 @@ static const char *shader_glsl_get_prefix(enum wined3d_shader_type type) static unsigned int shader_glsl_get_version(const struct wined3d_gl_info *gl_info) { - if (gl_info->glsl_version >= MAKEDWORD_VERSION(1, 50)) + if (gl_info->glsl_version >= MAKEDWORD_VERSION(4, 40)) + return 440; + else if (gl_info->glsl_version >= MAKEDWORD_VERSION(1, 50)) return 150; else if (gl_info->glsl_version >= MAKEDWORD_VERSION(1, 30)) return 130; @@ -828,12 +833,23 @@ static void shader_glsl_generate_transform_feedback_varyings(const struct wined3 if (e->component_idx || e->component_count != 4) { - FIXME("Unsupported component range %u-%u.\n", e->component_idx, e->component_count); - continue; - } + if (so_desc->rasterizer_stream_idx != WINED3D_NO_RASTERIZER_STREAM) + { + FIXME("Unsupported component range %u-%u.\n", e->component_idx, e->component_count); + append_transform_feedback_skip_components(varyings, &count, + &strings, &length, buffer, e->component_count); + continue; + } - string_buffer_sprintf(buffer, "shader_in_out.reg[%u]", e->register_idx); - append_transform_feedback_varying(varyings, &count, &strings, &length, buffer); + string_buffer_sprintf(buffer, "shader_in_out.reg%u_%u_%u", + e->register_idx, e->component_idx, e->component_idx + e->component_count - 1); + append_transform_feedback_varying(varyings, &count, &strings, &length, buffer); + } + else + { + string_buffer_sprintf(buffer, "shader_in_out.reg%u", e->register_idx); + append_transform_feedback_varying(varyings, &count, &strings, &length, buffer); + } } if (buffer_idx < so_desc->buffer_stride_count @@ -1212,6 +1228,320 @@ static void shader_glsl_load_np2fixup_constants(const struct glsl_ps_program *ps GL_EXTCALL(glUniform4fv(ps->np2_fixup_location, ps->np2_fixup_info->num_consts, &np2fixup_constants[0].sx)); } +/* Taken and adapted from Mesa. */ +static BOOL invert_matrix_3d(struct wined3d_matrix *out, const struct wined3d_matrix *in) +{ + float pos, neg, t, det; + struct wined3d_matrix temp; + + /* Calculate the determinant of upper left 3x3 submatrix and + * determine if the matrix is singular. */ + pos = neg = 0.0f; + t = in->_11 * in->_22 * in->_33; + if (t >= 0.0f) + pos += t; + else + neg += t; + + t = in->_21 * in->_32 * in->_13; + if (t >= 0.0f) + pos += t; + else + neg += t; + t = in->_31 * in->_12 * in->_23; + if (t >= 0.0f) + pos += t; + else + neg += t; + + t = -in->_31 * in->_22 * in->_13; + if (t >= 0.0f) + pos += t; + else + neg += t; + t = -in->_21 * in->_12 * in->_33; + if (t >= 0.0f) + pos += t; + else + neg += t; + + t = -in->_11 * in->_32 * in->_23; + if (t >= 0.0f) + pos += t; + else + neg += t; + + det = pos + neg; + + if (fabsf(det) < 1e-25f) + return FALSE; + + det = 1.0f / det; + temp._11 = (in->_22 * in->_33 - in->_32 * in->_23) * det; + temp._12 = -(in->_12 * in->_33 - in->_32 * in->_13) * det; + temp._13 = (in->_12 * in->_23 - in->_22 * in->_13) * det; + temp._21 = -(in->_21 * in->_33 - in->_31 * in->_23) * det; + temp._22 = (in->_11 * in->_33 - in->_31 * in->_13) * det; + temp._23 = -(in->_11 * in->_23 - in->_21 * in->_13) * det; + temp._31 = (in->_21 * in->_32 - in->_31 * in->_22) * det; + temp._32 = -(in->_11 * in->_32 - in->_31 * in->_12) * det; + temp._33 = (in->_11 * in->_22 - in->_21 * in->_12) * det; + + *out = temp; + return TRUE; +} + +static void swap_rows(float **a, float **b) +{ + float *tmp = *a; + + *a = *b; + *b = tmp; +} + +static BOOL invert_matrix(struct wined3d_matrix *out, const struct wined3d_matrix *m) +{ + float wtmp[4][8]; + float m0, m1, m2, m3, s; + float *r0, *r1, *r2, *r3; + + r0 = wtmp[0]; + r1 = wtmp[1]; + r2 = wtmp[2]; + r3 = wtmp[3]; + + r0[0] = m->_11; + r0[1] = m->_12; + r0[2] = m->_13; + r0[3] = m->_14; + r0[4] = 1.0f; + r0[5] = r0[6] = r0[7] = 0.0f; + + r1[0] = m->_21; + r1[1] = m->_22; + r1[2] = m->_23; + r1[3] = m->_24; + r1[5] = 1.0f; + r1[4] = r1[6] = r1[7] = 0.0f; + + r2[0] = m->_31; + r2[1] = m->_32; + r2[2] = m->_33; + r2[3] = m->_34; + r2[6] = 1.0f; + r2[4] = r2[5] = r2[7] = 0.0f; + + r3[0] = m->_41; + r3[1] = m->_42; + r3[2] = m->_43; + r3[3] = m->_44; + r3[7] = 1.0f; + r3[4] = r3[5] = r3[6] = 0.0f; + + /* Choose pivot - or die. */ + if (fabsf(r3[0]) > fabsf(r2[0])) + swap_rows(&r3, &r2); + if (fabsf(r2[0]) > fabsf(r1[0])) + swap_rows(&r2, &r1); + if (fabsf(r1[0]) > fabsf(r0[0])) + swap_rows(&r1, &r0); + if (r0[0] == 0.0f) + return FALSE; + + /* Eliminate first variable. */ + m1 = r1[0] / r0[0]; m2 = r2[0] / r0[0]; m3 = r3[0] / r0[0]; + s = r0[1]; r1[1] -= m1 * s; r2[1] -= m2 * s; r3[1] -= m3 * s; + s = r0[2]; r1[2] -= m1 * s; r2[2] -= m2 * s; r3[2] -= m3 * s; + s = r0[3]; r1[3] -= m1 * s; r2[3] -= m2 * s; r3[3] -= m3 * s; + s = r0[4]; + if (s != 0.0f) + { + r1[4] -= m1 * s; + r2[4] -= m2 * s; + r3[4] -= m3 * s; + } + s = r0[5]; + if (s != 0.0f) + { + r1[5] -= m1 * s; + r2[5] -= m2 * s; + r3[5] -= m3 * s; + } + s = r0[6]; + if (s != 0.0f) + { + r1[6] -= m1 * s; + r2[6] -= m2 * s; + r3[6] -= m3 * s; + } + s = r0[7]; + if (s != 0.0f) + { + r1[7] -= m1 * s; + r2[7] -= m2 * s; + r3[7] -= m3 * s; + } + + /* Choose pivot - or die. */ + if (fabsf(r3[1]) > fabsf(r2[1])) + swap_rows(&r3, &r2); + if (fabsf(r2[1]) > fabsf(r1[1])) + swap_rows(&r2, &r1); + if (r1[1] == 0.0f) + return FALSE; + + /* Eliminate second variable. */ + m2 = r2[1] / r1[1]; m3 = r3[1] / r1[1]; + r2[2] -= m2 * r1[2]; r3[2] -= m3 * r1[2]; + r2[3] -= m2 * r1[3]; r3[3] -= m3 * r1[3]; + s = r1[4]; + if (s != 0.0f) + { + r2[4] -= m2 * s; + r3[4] -= m3 * s; + } + s = r1[5]; + if (s != 0.0f) + { + r2[5] -= m2 * s; + r3[5] -= m3 * s; + } + s = r1[6]; + if (s != 0.0f) + { + r2[6] -= m2 * s; + r3[6] -= m3 * s; + } + s = r1[7]; + if (s != 0.0f) + { + r2[7] -= m2 * s; + r3[7] -= m3 * s; + } + + /* Choose pivot - or die. */ + if (fabsf(r3[2]) > fabsf(r2[2])) + swap_rows(&r3, &r2); + if (r2[2] == 0.0f) + return FALSE; + + /* Eliminate third variable. */ + m3 = r3[2] / r2[2]; + r3[3] -= m3 * r2[3]; + r3[4] -= m3 * r2[4]; + r3[5] -= m3 * r2[5]; + r3[6] -= m3 * r2[6]; + r3[7] -= m3 * r2[7]; + + /* Last check. */ + if (r3[3] == 0.0f) + return FALSE; + + /* Back substitute row 3. */ + s = 1.0f / r3[3]; + r3[4] *= s; + r3[5] *= s; + r3[6] *= s; + r3[7] *= s; + + /* Back substitute row 2. */ + m2 = r2[3]; + s = 1.0f / r2[2]; + r2[4] = s * (r2[4] - r3[4] * m2); + r2[5] = s * (r2[5] - r3[5] * m2); + r2[6] = s * (r2[6] - r3[6] * m2); + r2[7] = s * (r2[7] - r3[7] * m2); + m1 = r1[3]; + r1[4] -= r3[4] * m1; + r1[5] -= r3[5] * m1; + r1[6] -= r3[6] * m1; + r1[7] -= r3[7] * m1; + m0 = r0[3]; + r0[4] -= r3[4] * m0; + r0[5] -= r3[5] * m0; + r0[6] -= r3[6] * m0; + r0[7] -= r3[7] * m0; + + /* Back substitute row 1. */ + m1 = r1[2]; + s = 1.0f / r1[1]; + r1[4] = s * (r1[4] - r2[4] * m1); + r1[5] = s * (r1[5] - r2[5] * m1); + r1[6] = s * (r1[6] - r2[6] * m1); + r1[7] = s * (r1[7] - r2[7] * m1); + m0 = r0[2]; + r0[4] -= r2[4] * m0; + r0[5] -= r2[5] * m0; + r0[6] -= r2[6] * m0; + r0[7] -= r2[7] * m0; + + /* Back substitute row 0. */ + m0 = r0[1]; + s = 1.0f / r0[0]; + r0[4] = s * (r0[4] - r1[4] * m0); + r0[5] = s * (r0[5] - r1[5] * m0); + r0[6] = s * (r0[6] - r1[6] * m0); + r0[7] = s * (r0[7] - r1[7] * m0); + + out->_11 = r0[4]; + out->_12 = r0[5]; + out->_13 = r0[6]; + out->_14 = r0[7]; + out->_21 = r1[4]; + out->_22 = r1[5]; + out->_23 = r1[6]; + out->_24 = r1[7]; + out->_31 = r2[4]; + out->_32 = r2[5]; + out->_33 = r2[6]; + out->_34 = r2[7]; + out->_41 = r3[4]; + out->_42 = r3[5]; + out->_43 = r3[6]; + out->_44 = r3[7]; + + return TRUE; +} + +static void transpose_matrix(struct wined3d_matrix *out, const struct wined3d_matrix *m) +{ + struct wined3d_matrix temp; + unsigned int i, j; + + for (i = 0; i < 4; ++i) + for (j = 0; j < 4; ++j) + (&temp._11)[4 * j + i] = (&m->_11)[4 * i + j]; + + *out = temp; +} + +static void shader_glsl_ffp_vertex_normalmatrix_uniform(const struct wined3d_context *context, + const struct wined3d_state *state, struct glsl_shader_prog_link *prog) +{ + const struct wined3d_gl_info *gl_info = context->gl_info; + float mat[3 * 3]; + struct wined3d_matrix mv; + unsigned int i, j; + + if (prog->vs.normal_matrix_location == -1) + return; + + get_modelview_matrix(context, state, 0, &mv); + if (context->d3d_info->wined3d_creation_flags & WINED3D_LEGACY_FFP_LIGHTING) + invert_matrix_3d(&mv, &mv); + else + invert_matrix(&mv, &mv); + /* Tests show that singular modelview matrices are used unchanged as normal + * matrices on D3D3 and older. There seems to be no clearly consistent + * behavior on newer D3D versions so always follow older ddraw behavior. */ + for (i = 0; i < 3; ++i) + for (j = 0; j < 3; ++j) + mat[i * 3 + j] = (&mv._11)[j * 4 + i]; + + GL_EXTCALL(glUniformMatrix3fv(prog->vs.normal_matrix_location, 1, FALSE, mat)); + checkGLcall("glUniformMatrix3fv"); +} + static void shader_glsl_ffp_vertex_texmatrix_uniform(const struct wined3d_context *context, const struct wined3d_state *state, unsigned int tex, struct glsl_shader_prog_link *prog) { @@ -1382,13 +1712,18 @@ static void shader_glsl_clip_plane_uniform(const struct wined3d_context *context const struct wined3d_state *state, unsigned int index, struct glsl_shader_prog_link *prog) { const struct wined3d_gl_info *gl_info = context->gl_info; + struct wined3d_matrix matrix; struct wined3d_vec4 plane; + plane = state->clip_planes[index]; + /* Clip planes are affected by the view transform in d3d for FFP draws. */ if (!use_vs(state)) - multiply_vector_matrix(&plane, &state->clip_planes[index], &state->transforms[WINED3D_TS_VIEW]); - else - plane = state->clip_planes[index]; + { + invert_matrix(&matrix, &state->transforms[WINED3D_TS_VIEW]); + transpose_matrix(&matrix, &matrix); + multiply_vector_matrix(&plane, &plane, &matrix); + } GL_EXTCALL(glUniform4fv(prog->vs.clip_planes_location + index, 1, &plane.x)); } @@ -1404,23 +1739,6 @@ static void shader_glsl_load_color_key_constant(const struct glsl_ps_program *ps GL_EXTCALL(glUniform4fv(ps->color_key_location, 2, &float_key[0].r)); } -/* Context activation is done by the caller. */ -static void get_normal_matrix(struct wined3d_context *context, struct wined3d_matrix *mat, float *normal) -{ - int i, j; - - if (context->d3d_info->wined3d_creation_flags & WINED3D_LEGACY_FFP_LIGHTING) - invert_matrix_3d(mat, mat); - else - invert_matrix(mat, mat); - /* Tests show that singular modelview matrices are used unchanged as normal - * matrices on D3D3 and older. There seems to be no clearly consistent - * behavior on newer D3D versions so always follow older ddraw behavior. */ - for (i = 0; i < 3; ++i) - for (j = 0; j < 3; ++j) - normal[i * 3 + j] = (&mat->_11)[j * 4 + i]; -} - /* Context activation is done by the caller (state handler). */ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context *context, const struct wined3d_state *state) @@ -1431,7 +1749,6 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context const struct wined3d_gl_info *gl_info = context->gl_info; struct shader_glsl_priv *priv = shader_priv; float position_fixup[4]; - float normal[3 * 3]; DWORD update_mask; struct glsl_shader_prog_link *prog = ctx_data->glsl_program; @@ -1486,29 +1803,21 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context GL_EXTCALL(glUniformMatrix4fv(prog->vs.modelview_matrix_location[0], 1, FALSE, &mat._11)); checkGLcall("glUniformMatrix4fv"); - get_normal_matrix(context, &mat, normal); - GL_EXTCALL(glUniformMatrix3fv(prog->vs.normal_matrix_location[0], 1, FALSE, normal)); - checkGLcall("glUniformMatrix3fv"); + shader_glsl_ffp_vertex_normalmatrix_uniform(context, state, prog); } if (update_mask & WINED3D_SHADER_CONST_FFP_VERTEXBLEND) { struct wined3d_matrix mat; - for (i = 1; i < MAX_VERTEX_INDEX_BLENDS; ++i) + for (i = 1; i < MAX_VERTEX_BLENDS; ++i) { if (prog->vs.modelview_matrix_location[i] == -1) break; - if (!(update_mask & WINED3D_SHADER_CONST_FFP_VERTEXBLEND_INDEX(i))) - continue; get_modelview_matrix(context, state, i, &mat); GL_EXTCALL(glUniformMatrix4fv(prog->vs.modelview_matrix_location[i], 1, FALSE, &mat._11)); checkGLcall("glUniformMatrix4fv"); - - get_normal_matrix(context, &mat, normal); - GL_EXTCALL(glUniformMatrix3fv(prog->vs.normal_matrix_location[i], 1, FALSE, normal)); - checkGLcall("glUniformMatrix3fv"); } } @@ -1839,22 +2148,97 @@ static const char *shader_glsl_shader_output_name(const struct wined3d_gl_info * return shader_glsl_use_interface_blocks(gl_info) ? "shader_out.reg" : "ps_link"; } +static const char *shader_glsl_interpolation_qualifiers(enum wined3d_shader_interpolation_mode mode) +{ + switch (mode) + { + case WINED3DSIM_CONSTANT: + return "flat"; + case WINED3DSIM_LINEAR_NOPERSPECTIVE: + return "noperspective"; + default: + FIXME("Unhandled interpolation mode %#x.\n", mode); + case WINED3DSIM_NONE: + case WINED3DSIM_LINEAR: + return ""; + } +} + +static enum wined3d_shader_interpolation_mode wined3d_extract_interpolation_mode( + const DWORD *packed_interpolation_mode, unsigned int register_idx) +{ + return wined3d_extract_bits(packed_interpolation_mode, + register_idx * WINED3D_PACKED_INTERPOLATION_BIT_COUNT, WINED3D_PACKED_INTERPOLATION_BIT_COUNT); +} + static void shader_glsl_declare_shader_inputs(const struct wined3d_gl_info *gl_info, - struct wined3d_string_buffer *buffer, unsigned int element_count) + struct wined3d_string_buffer *buffer, unsigned int element_count, + const DWORD *interpolation_mode, BOOL unroll) { + enum wined3d_shader_interpolation_mode mode; + unsigned int i; + if (shader_glsl_use_interface_blocks(gl_info)) - shader_addline(buffer, "in shader_in_out { vec4 reg[%u]; } shader_in;\n", element_count); + { + if (unroll) + { + shader_addline(buffer, "in shader_in_out {\n"); + for (i = 0; i < element_count; ++i) + { + mode = wined3d_extract_interpolation_mode(interpolation_mode, i); + shader_addline(buffer, "%s vec4 reg%u;\n", shader_glsl_interpolation_qualifiers(mode), i); + } + shader_addline(buffer, "} shader_in;\n"); + } + else + { + shader_addline(buffer, "in shader_in_out { vec4 reg[%u]; } shader_in;\n", element_count); + } + } else + { declare_in_varying(gl_info, buffer, FALSE, "vec4 ps_link[%u];\n", element_count); + } } static void shader_glsl_declare_shader_outputs(const struct wined3d_gl_info *gl_info, - struct wined3d_string_buffer *buffer, unsigned int element_count) + struct wined3d_string_buffer *buffer, unsigned int element_count, BOOL rasterizer_setup, + const DWORD *interpolation_mode) { + enum wined3d_shader_interpolation_mode mode; + unsigned int i; + if (shader_glsl_use_interface_blocks(gl_info)) - shader_addline(buffer, "out shader_in_out { vec4 reg[%u]; } shader_out;\n", element_count); + { + if (rasterizer_setup) + { + shader_addline(buffer, "out shader_in_out {\n"); + for (i = 0; i < element_count; ++i) + { + const char *interpolation_qualifiers = ""; + if (needs_interpolation_qualifiers_for_shader_outputs(gl_info)) + { + mode = wined3d_extract_interpolation_mode(interpolation_mode, i); + interpolation_qualifiers = shader_glsl_interpolation_qualifiers(mode); + } + shader_addline(buffer, "%s vec4 reg%u;\n", interpolation_qualifiers, i); + } + shader_addline(buffer, "} shader_out;\n"); + } + else + { + shader_addline(buffer, "out shader_in_out { vec4 reg[%u]; } shader_out;\n", element_count); + } + } else + { declare_out_varying(gl_info, buffer, FALSE, "vec4 ps_link[%u];\n", element_count); + } +} + +static const char *get_fragment_output(const struct wined3d_gl_info *gl_info) +{ + return needs_legacy_glsl_syntax(gl_info) ? "gl_FragData" : "ps_out"; } static const char *glsl_primitive_type_from_d3d(enum wined3d_primitive_type primitive_type) @@ -2184,13 +2568,6 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont sampler_type = "samplerCube"; break; - case WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY: - if (shadow_sampler) - sampler_type = "sampler1DArrayShadow"; - else - sampler_type = "sampler1DArray"; - break; - case WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY: if (shadow_sampler) sampler_type = "sampler2DArrayShadow"; @@ -2347,12 +2724,6 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont } } -/***************************************************************************** - * Functions to generate GLSL strings from DirectX Shader bytecode begin here. - * - * For more information, see
http://wiki.winehq.org/DirectX-Shaders
- ****************************************************************************/ - /* Prototypes */ static void shader_glsl_add_src_param(const struct wined3d_shader_instruction *ins, const struct wined3d_shader_src_param *wined3d_src, DWORD mask, struct glsl_src_param *glsl_src); @@ -2441,7 +2812,8 @@ static void shader_glsl_fixup_scalar_register_variable(char *register_name, /** Writes the GLSL variable name that corresponds to the register that the * DX opcode parameter is trying to access */ static void shader_glsl_get_register_name(const struct wined3d_shader_register *reg, - char *register_name, BOOL *is_color, const struct wined3d_shader_instruction *ins) + enum wined3d_data_type data_type, char *register_name, BOOL *is_color, + const struct wined3d_shader_instruction *ins) { /* oPos, oFog and oPts in D3D */ static const char * const hwrastout_reg_names[] = {"vs_out[10]", "vs_out[11].x", "vs_out[11].y"}; @@ -2473,10 +2845,18 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register * struct shader_glsl_ctx_priv *priv = ins->ctx->backend_data; if (reg->idx[0].rel_addr) - FIXME("VS3+ input registers relative addressing.\n"); + FIXME("VS3 input registers relative addressing.\n"); if (priv->cur_vs_args->swizzle_map & (1u << reg->idx[0].offset)) *is_color = TRUE; - sprintf(register_name, "%s_in%u", prefix, reg->idx[0].offset); + if (reg->idx[0].rel_addr) + { + sprintf(register_name, "%s_in[%s + %u]", + prefix, rel_param0.param_str, reg->idx[0].offset); + } + else + { + sprintf(register_name, "%s_in%u", prefix, reg->idx[0].offset); + } break; } @@ -2610,22 +2990,20 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register * break; case WINED3DSPR_COLOROUT: - /* FIXME: should check dual_buffers when dual blending is enabled */ if (reg->idx[0].offset >= gl_info->limits.buffers) WARN("Write to render target %u, only %d supported.\n", reg->idx[0].offset, gl_info->limits.buffers); - sprintf(register_name, needs_legacy_glsl_syntax(gl_info) ? "gl_FragData[%u]" : "ps_out%u", - reg->idx[0].offset); + sprintf(register_name, "%s[%u]", get_fragment_output(gl_info), reg->idx[0].offset); break; case WINED3DSPR_RASTOUT: sprintf(register_name, "%s", hwrastout_reg_names[reg->idx[0].offset]); break; - case WINED3DSPR_DEPTHOUT_GREATER_EQUAL: - case WINED3DSPR_DEPTHOUT_LESS_EQUAL: case WINED3DSPR_DEPTHOUT: + case WINED3DSPR_DEPTHOUTGE: + case WINED3DSPR_DEPTHOUTLE: sprintf(register_name, "gl_FragDepth"); break; @@ -2668,7 +3046,7 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register * switch (reg->immconst_type) { case WINED3D_IMMCONST_SCALAR: - switch (reg->data_type) + switch (data_type) { case WINED3D_DATA_FLOAT: if (gl_info->supported[ARB_SHADER_BIT_ENCODING]) @@ -2685,13 +3063,13 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register * sprintf(register_name, "%#xu", reg->u.immconst_data[0]); break; default: - sprintf(register_name, "<unhandled data type %#x>", reg->data_type); + sprintf(register_name, "<unhandled data type %#x>", data_type); break; } break; case WINED3D_IMMCONST_VEC4: - switch (reg->data_type) + switch (data_type) { case WINED3D_DATA_FLOAT: if (gl_info->supported[ARB_SHADER_BIT_ENCODING]) @@ -2723,7 +3101,7 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register * reg->u.immconst_data[2], reg->u.immconst_data[3]); break; default: - sprintf(register_name, "<unhandled data type %#x>", reg->data_type); + sprintf(register_name, "<unhandled data type %#x>", data_type); break; } break; @@ -2967,7 +3345,7 @@ static void shader_glsl_add_src_param_ext(const struct wined3d_shader_instructio glsl_src->param_str[0] = '\0'; swizzle_str[0] = '\0'; - shader_glsl_get_register_name(&wined3d_src->reg, glsl_src->reg_name, &is_color, ins); + shader_glsl_get_register_name(&wined3d_src->reg, data_type, glsl_src->reg_name, &is_color, ins); shader_glsl_get_swizzle(wined3d_src, is_color, mask, swizzle_str); switch (wined3d_src->reg.type) @@ -3014,7 +3392,8 @@ static DWORD shader_glsl_add_dst_param(const struct wined3d_shader_instruction * glsl_dst->mask_str[0] = '\0'; glsl_dst->reg_name[0] = '\0'; - shader_glsl_get_register_name(&wined3d_dst->reg, glsl_dst->reg_name, &is_color, ins); + shader_glsl_get_register_name(&wined3d_dst->reg, wined3d_dst->reg.data_type, + glsl_dst->reg_name, &is_color, ins); return shader_glsl_get_write_mask(wined3d_dst, glsl_dst->mask_str); } @@ -3131,7 +3510,6 @@ static void shader_glsl_get_sample_function(const struct wined3d_shader_context enum wined3d_shader_resource_type resource_type = ctx->reg_maps->resource_info[resource_idx].type; struct shader_glsl_ctx_priv *priv = ctx->backend_data; const struct wined3d_gl_info *gl_info = ctx->gl_info; - BOOL legacy_syntax = needs_legacy_glsl_syntax(gl_info); BOOL shadow = glsl_is_shadow_sampler(ctx->shader, priv->cur_ps_args, resource_idx, sampler_idx); BOOL projected = flags & WINED3D_GLSL_SAMPLE_PROJECTED; BOOL texrect = ctx->reg_maps->shader_version.type == WINED3D_SHADER_TYPE_PIXEL @@ -3144,7 +3522,6 @@ static void shader_glsl_get_sample_function(const struct wined3d_shader_context unsigned int coord_size, deriv_size; sample_function->data_type = ctx->reg_maps->resource_info[resource_idx].data_type; - sample_function->emulate_lod = WINED3D_SHADER_RESOURCE_NONE; if (resource_type >= ARRAY_SIZE(resource_type_info)) { @@ -3156,30 +3533,7 @@ static void shader_glsl_get_sample_function(const struct wined3d_shader_context if (resource_type == WINED3D_SHADER_RESOURCE_TEXTURE_CUBE) projected = FALSE; - if (shadow && lod) - { - switch (resource_type) - { - /* emulate textureLod(sampler2DArrayShadow, ...) using textureGradOffset */ - case WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY: - sample_function->emulate_lod = resource_type; - grad = offset = TRUE; - lod = FALSE; - break; - - /* emulate textureLod(samplerCubeShadow, ...) using shadowCubeGrad */ - case WINED3D_SHADER_RESOURCE_TEXTURE_CUBE: - sample_function->emulate_lod = resource_type; - grad = legacy_syntax = TRUE; - lod = FALSE; - break; - - default: - break; - } - } - - if (legacy_syntax) + if (needs_legacy_glsl_syntax(gl_info)) { if (shadow) base = "shadow"; @@ -3219,7 +3573,7 @@ static void shader_glsl_get_sample_function(const struct wined3d_shader_context sample_function->offset_size = offset ? deriv_size : 0; sample_function->coord_mask = (1u << coord_size) - 1; sample_function->deriv_mask = (1u << deriv_size) - 1; - sample_function->output_single_component = shadow && !legacy_syntax; + sample_function->output_single_component = shadow && !needs_legacy_glsl_syntax(gl_info); } static void shader_glsl_release_sample_function(const struct wined3d_shader_context *ctx, @@ -3331,7 +3685,7 @@ static void shader_glsl_color_correction(const struct wined3d_shader_instruction char reg_name[256]; BOOL is_color; - shader_glsl_get_register_name(&ins->dst[0].reg, reg_name, &is_color, ins); + shader_glsl_get_register_name(&ins->dst[0].reg, ins->dst[0].reg.data_type, reg_name, &is_color, ins); shader_glsl_color_correction_ext(ins->ctx->buffer, reg_name, ins->dst[0].write_mask, fixup); } @@ -3340,7 +3694,6 @@ static void PRINTF_ATTR(9, 10) shader_glsl_gen_sample_code(const struct wined3d_ const char *dx, const char *dy, const char *bias, const struct wined3d_shader_texel_offset *offset, const char *coord_reg_fmt, ...) { - static const struct wined3d_shader_texel_offset dummy_offset = {0, 0, 0}; const struct wined3d_shader_version *version = &ins->ctx->reg_maps->shader_version; char dst_swizzle[6]; struct color_fixup_desc fixup; @@ -3409,26 +3762,6 @@ static void PRINTF_ATTR(9, 10) shader_glsl_gen_sample_code(const struct wined3d_ break; } } - if (sample_function->emulate_lod) - { - if (strcmp(bias, "0")) FIXME("Don't know how to emulate lod level %s\n", bias); - switch (sample_function->emulate_lod) - { - case WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY: - if (!dx) dx = "vec2(0.0, 0.0)"; - if (!dy) dy = "vec2(0.0, 0.0)"; - break; - - case WINED3D_SHADER_RESOURCE_TEXTURE_CUBE: - if (!dx) dx = "vec3(0.0, 0.0, 0.0)"; - if (!dy) dy = "vec3(0.0, 0.0, 0.0)"; - break; - - default: - break; - } - if (!offset) offset = &dummy_offset; - } if (dx && dy) shader_addline(ins->ctx->buffer, ", %s, %s", dx, dy); else if (bias) @@ -4750,13 +5083,20 @@ static void shader_glsl_default(const struct wined3d_shader_instruction *ins) shader_addline(ins->ctx->buffer, "default:\n"); } -static void shader_glsl_if(const struct wined3d_shader_instruction *ins) +static void shader_glsl_generate_conditional_op(const struct wined3d_shader_instruction *ins, + const char *op) { - const char *condition = (ins->flags == WINED3D_SHADER_CONDITIONAL_OP_NZ) ? "bool" : "!bool"; - struct glsl_src_param src0_param; + struct glsl_src_param src_param; + const char *condition; - shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_0, &src0_param); - shader_addline(ins->ctx->buffer, "if (%s(%s)) {\n", condition, src0_param.param_str); + condition = ins->flags == WINED3D_SHADER_CONDITIONAL_OP_NZ ? "bool" : "!bool"; + shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_0, &src_param); + shader_addline(ins->ctx->buffer, "if (%s(%s)) %s\n", condition, src_param.param_str, op); +} + +static void shader_glsl_if(const struct wined3d_shader_instruction *ins) +{ + shader_glsl_generate_conditional_op(ins, "{"); } static void shader_glsl_ifc(const struct wined3d_shader_instruction *ins) @@ -4810,22 +5150,19 @@ static void shader_glsl_breakc(const struct wined3d_shader_instruction *ins) static void shader_glsl_conditional_op(const struct wined3d_shader_instruction *ins) { - const char *condition = (ins->flags == WINED3D_SHADER_CONDITIONAL_OP_NZ) ? "bool" : "!bool"; - struct glsl_src_param src_param; const char *op; switch (ins->handler_idx) { - case WINED3DSIH_BREAKP: op = "break"; break; - case WINED3DSIH_CONTINUEP: op = "continue"; break; - case WINED3DSIH_RETP: op = "return"; break; + case WINED3DSIH_BREAKP: op = "break;"; break; + case WINED3DSIH_CONTINUEP: op = "continue;"; break; + case WINED3DSIH_RETP: op = "return;"; break; default: ERR("Unhandled opcode %#x.\n", ins->handler_idx); return; } - shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_0, &src_param); - shader_addline(ins->ctx->buffer, "if (%s(%s)) %s;\n", condition, src_param.param_str, op); + shader_glsl_generate_conditional_op(ins, op); } static void shader_glsl_continue(const struct wined3d_shader_instruction *ins) @@ -5704,9 +6041,41 @@ static void shader_glsl_sample(const struct wined3d_shader_instruction *ins) shader_glsl_release_sample_function(ins->ctx, &sample_function); } +/* GLSL doesn't provide a function to sample from level zero with depth + * comparison for array textures and cube textures. We use textureGrad*() + * to implement sample_c_lz. + */ +static void shader_glsl_gen_sample_c_lz(const struct wined3d_shader_instruction *ins, + unsigned int sampler_bind_idx, const struct glsl_sample_function *sample_function, + unsigned int coord_size, const char *coord_param, const char *ref_param) +{ + const struct wined3d_shader_version *version = &ins->ctx->reg_maps->shader_version; + unsigned int deriv_size = wined3d_popcount(sample_function->deriv_mask); + const struct wined3d_shader_texel_offset *offset = &ins->texel_offset; + struct wined3d_string_buffer *buffer = ins->ctx->buffer; + char dst_swizzle[6]; + + WARN("Emitting textureGrad() for sample_c_lz.\n"); + + shader_glsl_swizzle_to_str(WINED3DSP_NOSWIZZLE, FALSE, ins->dst[0].write_mask, dst_swizzle); + shader_glsl_append_dst_ext(buffer, ins, &ins->dst[0], sample_function->data_type); + shader_addline(buffer, "vec4(textureGrad%s(%s_sampler%u, vec%u(%s, %s), vec%u(0.0), vec%u(0.0)", + sample_function->offset_size ? "Offset" : "", + shader_glsl_get_prefix(version->type), sampler_bind_idx, + coord_size, coord_param, ref_param, deriv_size, deriv_size); + if (sample_function->offset_size) + { + int offset_immdata[4] = {offset->u, offset->v, offset->w}; + shader_addline(buffer, ", "); + shader_glsl_append_imm_ivec(buffer, offset_immdata, sample_function->offset_size); + } + shader_addline(buffer, "))%s);\n", dst_swizzle); +} + static void shader_glsl_sample_c(const struct wined3d_shader_instruction *ins) { unsigned int resource_idx, sampler_idx, sampler_bind_idx; + const struct wined3d_shader_resource_info *resource_info; struct glsl_src_param coord_param, compare_param; struct glsl_sample_function sample_function; const char *lod_param = NULL; @@ -5722,6 +6091,8 @@ static void shader_glsl_sample_c(const struct wined3d_shader_instruction *ins) if (wined3d_shader_instruction_has_texel_offset(ins)) flags |= WINED3D_GLSL_SAMPLE_OFFSET; + if (!(resource_info = shader_glsl_get_resource_info(ins, &ins->src[1].reg))) + return; resource_idx = ins->src[1].reg.idx[0].offset; sampler_idx = ins->src[2].reg.idx[0].offset; @@ -5730,9 +6101,19 @@ static void shader_glsl_sample_c(const struct wined3d_shader_instruction *ins) shader_glsl_add_src_param(ins, &ins->src[0], sample_function.coord_mask >> 1, &coord_param); shader_glsl_add_src_param(ins, &ins->src[3], WINED3DSP_WRITEMASK_0, &compare_param); sampler_bind_idx = shader_glsl_find_sampler(&ins->ctx->reg_maps->sampler_map, resource_idx, sampler_idx); - shader_glsl_gen_sample_code(ins, sampler_bind_idx, &sample_function, WINED3DSP_NOSWIZZLE, - NULL, NULL, lod_param, &ins->texel_offset, "vec%u(%s, %s)", - coord_size, coord_param.param_str, compare_param.param_str); + if (ins->handler_idx == WINED3DSIH_SAMPLE_C_LZ + && (resource_info->type == WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY + || resource_info->type == WINED3D_SHADER_RESOURCE_TEXTURE_CUBE)) + { + shader_glsl_gen_sample_c_lz(ins, sampler_bind_idx, &sample_function, + coord_size, coord_param.param_str, compare_param.param_str); + } + else + { + shader_glsl_gen_sample_code(ins, sampler_bind_idx, &sample_function, WINED3DSP_NOSWIZZLE, + NULL, NULL, lod_param, &ins->texel_offset, "vec%u(%s, %s)", + coord_size, coord_param.param_str, compare_param.param_str); + } shader_glsl_release_sample_function(ins->ctx, &sample_function); } @@ -6242,10 +6623,7 @@ static void shader_glsl_texkill(const struct wined3d_shader_instruction *ins) { if (ins->ctx->reg_maps->shader_version.major >= 4) { - struct glsl_src_param src_param; - - shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_0, &src_param); - shader_addline(ins->ctx->buffer, "if (bool(%s)) discard;\n", src_param.param_str); + shader_glsl_generate_conditional_op(ins, "discard;"); } else { @@ -6295,7 +6673,7 @@ static void shader_glsl_dp2add(const struct wined3d_shader_instruction *ins) static void shader_glsl_input_pack(const struct wined3d_shader *shader, struct wined3d_string_buffer *buffer, const struct wined3d_shader_signature *input_signature, const struct wined3d_shader_reg_maps *reg_maps, - const struct ps_compile_args *args, const struct wined3d_gl_info *gl_info) + const struct ps_compile_args *args, const struct wined3d_gl_info *gl_info, BOOL unroll) { unsigned int i; @@ -6342,7 +6720,7 @@ static void shader_glsl_input_pack(const struct wined3d_shader *shader, struct w { if (input->sysval_semantic) FIXME("Unhandled sysval semantic %#x.\n", input->sysval_semantic); - shader_addline(buffer, "ps_in[%u]%s = %s[%u]%s;\n", + shader_addline(buffer, unroll ? "ps_in[%u]%s = %s%u%s;\n" : "ps_in[%u]%s = %s[%u]%s;\n", shader->u.ps.input_reg_map[input->register_idx], reg_mask, shader_glsl_shader_input_name(gl_info), shader->u.ps.input_reg_map[input->register_idx], reg_mask); @@ -6536,7 +6914,8 @@ static void shader_glsl_setup_vs3_output(struct shader_glsl_priv *priv, static void shader_glsl_setup_sm4_shader_output(struct shader_glsl_priv *priv, unsigned int input_count, const struct wined3d_shader_signature *output_signature, - const struct wined3d_shader_reg_maps *reg_maps_out, const char *output_variable_name) + const struct wined3d_shader_reg_maps *reg_maps_out, const char *output_variable_name, + BOOL rasterizer_setup) { struct wined3d_string_buffer *buffer = &priv->shader_buffer; char reg_mask[6]; @@ -6557,11 +6936,34 @@ static void shader_glsl_setup_sm4_shader_output(struct shader_glsl_priv *priv, shader_glsl_write_mask_to_str(output->mask, reg_mask); - shader_addline(buffer, "%s.reg[%u]%s = outputs[%u]%s;\n", + shader_addline(buffer, + rasterizer_setup ? "%s.reg%u%s = outputs[%u]%s;\n" : "%s.reg[%u]%s = outputs[%u]%s;\n", output_variable_name, output->register_idx, reg_mask, output->register_idx, reg_mask); } } +static void shader_glsl_generate_clip_or_cull_distances(struct wined3d_string_buffer *buffer, + const struct wined3d_shader_signature_element *element, DWORD clip_or_cull_distance_mask) +{ + unsigned int i, clip_or_cull_index; + const char *name; + char reg_mask[6]; + + name = element->sysval_semantic == WINED3D_SV_CLIP_DISTANCE ? "Clip" : "Cull"; + /* Assign consecutive indices starting from 0. */ + clip_or_cull_index = element->semantic_idx ? wined3d_popcount(clip_or_cull_distance_mask & 0xf) : 0; + for (i = 0; i < 4; ++i) + { + if (!(element->mask & (WINED3DSP_WRITEMASK_0 << i))) + continue; + + shader_glsl_write_mask_to_str(WINED3DSP_WRITEMASK_0 << i, reg_mask); + shader_addline(buffer, "gl_%sDistance[%u] = outputs[%u]%s;\n", + name, clip_or_cull_index, element->register_idx, reg_mask); + ++clip_or_cull_index; + } +} + static void shader_glsl_setup_sm3_rasterizer_input(struct shader_glsl_priv *priv, const struct wined3d_gl_info *gl_info, const DWORD *map, const struct wined3d_shader_signature *input_signature, @@ -6571,7 +6973,7 @@ static void shader_glsl_setup_sm3_rasterizer_input(struct shader_glsl_priv *priv { struct wined3d_string_buffer *buffer = &priv->shader_buffer; const char *semantic_name; - UINT semantic_idx; + unsigned int semantic_idx; char reg_mask[6]; unsigned int i; @@ -6605,6 +7007,14 @@ static void shader_glsl_setup_sm3_rasterizer_input(struct shader_glsl_priv *priv shader_addline(buffer, "gl_Layer = floatBitsToInt(outputs[%u])%s;\n", output->register_idx, reg_mask); } + else if (output->sysval_semantic == WINED3D_SV_CLIP_DISTANCE) + { + shader_glsl_generate_clip_or_cull_distances(buffer, output, reg_maps_out->clip_distance_mask); + } + else if (output->sysval_semantic == WINED3D_SV_CULL_DISTANCE) + { + shader_glsl_generate_clip_or_cull_distances(buffer, output, reg_maps_out->cull_distance_mask); + } else if (output->sysval_semantic) { FIXME("Unhandled sysval semantic %#x.\n", output->sysval_semantic); @@ -6616,7 +7026,7 @@ static void shader_glsl_setup_sm3_rasterizer_input(struct shader_glsl_priv *priv shader_glsl_setup_vs3_output(priv, gl_info, map, input_signature, reg_maps_in, output_signature, reg_maps_out); else - shader_glsl_setup_sm4_shader_output(priv, input_count, output_signature, reg_maps_out, "shader_out"); + shader_glsl_setup_sm4_shader_output(priv, input_count, output_signature, reg_maps_out, "shader_out", TRUE); } /* Context activation is done by the caller. */ @@ -6748,7 +7158,7 @@ static GLuint shader_glsl_generate_vs3_rasterizer_input_setup(struct shader_glsl { unsigned int in_count = min(vec4_varyings(ps_major, gl_info), ps->limits->packed_input); - shader_glsl_declare_shader_outputs(gl_info, buffer, in_count); + shader_glsl_declare_shader_outputs(gl_info, buffer, in_count, FALSE, NULL); shader_addline(buffer, "void setup_vs_output(in vec4 outputs[%u])\n{\n", vs->limits->packed_output); shader_glsl_setup_sm3_rasterizer_input(priv, gl_info, ps->u.ps.input_reg_map, &ps->input_signature, &ps->reg_maps, 0, &vs->output_signature, &vs->reg_maps, per_vertex_point_size); @@ -6763,9 +7173,78 @@ static GLuint shader_glsl_generate_vs3_rasterizer_input_setup(struct shader_glsl return ret; } +static void shader_glsl_generate_stream_output_setup(struct shader_glsl_priv *priv, + const struct wined3d_shader *shader, const struct wined3d_stream_output_desc *so_desc) +{ + struct wined3d_string_buffer *buffer = &priv->shader_buffer; + unsigned int i; + + shader_addline(buffer, "out shader_in_out\n{\n"); + for (i = 0; i < so_desc->element_count; ++i) + { + const struct wined3d_stream_output_element *e = &so_desc->elements[i]; + + if (e->stream_idx) + { + FIXME("Unhandled stream %u.\n", e->stream_idx); + continue; + } + if (e->register_idx == WINED3D_STREAM_OUTPUT_GAP) + continue; + + if (e->component_idx || e->component_count != 4) + { + if (e->component_count == 1) + shader_addline(buffer, "float"); + else + shader_addline(buffer, "vec%u", e->component_count); + shader_addline(buffer, " reg%u_%u_%u;\n", + e->register_idx, e->component_idx, e->component_idx + e->component_count - 1); + } + else + { + shader_addline(buffer, "vec4 reg%u;\n", e->register_idx); + } + } + shader_addline(buffer, "} shader_out;\n"); + + shader_addline(buffer, "void setup_gs_output(in vec4 outputs[%u])\n{\n", + shader->limits->packed_output); + for (i = 0; i < so_desc->element_count; ++i) + { + const struct wined3d_stream_output_element *e = &so_desc->elements[i]; + + if (e->stream_idx) + { + FIXME("Unhandled stream %u.\n", e->stream_idx); + continue; + } + if (e->register_idx == WINED3D_STREAM_OUTPUT_GAP) + continue; + + if (e->component_idx || e->component_count != 4) + { + DWORD write_mask; + char str_mask[6]; + + write_mask = ((1u << e->component_count) - 1) << e->component_idx; + shader_glsl_write_mask_to_str(write_mask, str_mask); + shader_addline(buffer, "shader_out.reg%u_%u_%u = outputs[%u]%s;\n", + e->register_idx, e->component_idx, e->component_idx + e->component_count - 1, + e->register_idx, str_mask); + } + else + { + shader_addline(buffer, "shader_out.reg%u = outputs[%u];\n", + e->register_idx, e->register_idx); + } + } + shader_addline(buffer, "}\n"); +} + static void shader_glsl_generate_sm4_output_setup(struct shader_glsl_priv *priv, const struct wined3d_shader *shader, unsigned int input_count, - const struct wined3d_gl_info *gl_info, BOOL rasterizer_setup) + const struct wined3d_gl_info *gl_info, BOOL rasterizer_setup, const DWORD *interpolation_mode) { const char *prefix = shader_glsl_get_prefix(shader->reg_maps.shader_version.type); struct wined3d_string_buffer *buffer = &priv->shader_buffer; @@ -6774,7 +7253,7 @@ static void shader_glsl_generate_sm4_output_setup(struct shader_glsl_priv *priv, input_count = min(vec4_varyings(4, gl_info), input_count); if (input_count) - shader_glsl_declare_shader_outputs(gl_info, buffer, input_count); + shader_glsl_declare_shader_outputs(gl_info, buffer, input_count, rasterizer_setup, interpolation_mode); shader_addline(buffer, "void setup_%s_output(in vec4 outputs[%u])\n{\n", prefix, shader->limits->packed_output); @@ -6784,7 +7263,7 @@ static void shader_glsl_generate_sm4_output_setup(struct shader_glsl_priv *priv, NULL, input_count, &shader->output_signature, &shader->reg_maps, FALSE); else shader_glsl_setup_sm4_shader_output(priv, input_count, &shader->output_signature, - &shader->reg_maps, "shader_out"); + &shader->reg_maps, "shader_out", rasterizer_setup); shader_addline(buffer, "}\n"); } @@ -6865,20 +7344,20 @@ static void shader_glsl_generate_patch_constant_setup(struct wined3d_string_buff static void shader_glsl_generate_srgb_write_correction(struct wined3d_string_buffer *buffer, const struct wined3d_gl_info *gl_info) { - const char *output = needs_legacy_glsl_syntax(gl_info) ? "gl_FragData[0]" : "ps_out0"; + const char *output = get_fragment_output(gl_info); - shader_addline(buffer, "tmp0.xyz = pow(%s.xyz, vec3(srgb_const0.x));\n", output); + shader_addline(buffer, "tmp0.xyz = pow(%s[0].xyz, vec3(srgb_const0.x));\n", output); shader_addline(buffer, "tmp0.xyz = tmp0.xyz * vec3(srgb_const0.y) - vec3(srgb_const0.z);\n"); - shader_addline(buffer, "tmp1.xyz = %s.xyz * vec3(srgb_const0.w);\n", output); - shader_addline(buffer, "bvec3 srgb_compare = lessThan(%s.xyz, vec3(srgb_const1.x));\n", output); - shader_addline(buffer, "%s.xyz = mix(tmp0.xyz, tmp1.xyz, vec3(srgb_compare));\n", output); - shader_addline(buffer, "%s = clamp(%s, 0.0, 1.0);\n", output, output); + shader_addline(buffer, "tmp1.xyz = %s[0].xyz * vec3(srgb_const0.w);\n", output); + shader_addline(buffer, "bvec3 srgb_compare = lessThan(%s[0].xyz, vec3(srgb_const1.x));\n", output); + shader_addline(buffer, "%s[0].xyz = mix(tmp0.xyz, tmp1.xyz, vec3(srgb_compare));\n", output); + shader_addline(buffer, "%s[0] = clamp(%s[0], 0.0, 1.0);\n", output, output); } static void shader_glsl_generate_fog_code(struct wined3d_string_buffer *buffer, const struct wined3d_gl_info *gl_info, enum wined3d_ffp_ps_fog_mode mode) { - const char *output = needs_legacy_glsl_syntax(gl_info) ? "gl_FragData[0]" : "ps_out0"; + const char *output = get_fragment_output(gl_info); switch (mode) { @@ -6903,15 +7382,13 @@ static void shader_glsl_generate_fog_code(struct wined3d_string_buffer *buffer, return; } - shader_addline(buffer, "%s.xyz = mix(ffp_fog.color.xyz, %s.xyz, clamp(fog, 0.0, 1.0));\n", + shader_addline(buffer, "%s[0].xyz = mix(ffp_fog.color.xyz, %s[0].xyz, clamp(fog, 0.0, 1.0));\n", output, output); } static void shader_glsl_generate_alpha_test(struct wined3d_string_buffer *buffer, const struct wined3d_gl_info *gl_info, enum wined3d_cmp_func alpha_func) { - const char *output = needs_legacy_glsl_syntax(gl_info) ? "gl_FragData[0]" : "ps_out0"; - /* alpha_func is the PASS condition, not the DISCARD condition. Instead of * flipping all the operators here, just negate the comparison below. */ static const char * const comparison_operator[] = @@ -6930,14 +7407,16 @@ static void shader_glsl_generate_alpha_test(struct wined3d_string_buffer *buffer return; if (alpha_func != WINED3D_CMP_NEVER) - shader_addline(buffer, "if (!(%s.a %s alpha_test_ref))\n", - output, comparison_operator[alpha_func - WINED3D_CMP_NEVER]); + shader_addline(buffer, "if (!(%s[0].a %s alpha_test_ref))\n", + get_fragment_output(gl_info), comparison_operator[alpha_func - WINED3D_CMP_NEVER]); shader_addline(buffer, " discard;\n"); } static void shader_glsl_enable_extensions(struct wined3d_string_buffer *buffer, const struct wined3d_gl_info *gl_info) { + if (gl_info->supported[ARB_CULL_DISTANCE]) + shader_addline(buffer, "#extension GL_ARB_cull_distance : enable\n"); if (gl_info->supported[ARB_GPU_SHADER5]) shader_addline(buffer, "#extension GL_ARB_gpu_shader5 : enable\n"); if (gl_info->supported[ARB_SHADER_ATOMIC_COUNTERS]) @@ -6973,11 +7452,10 @@ static void shader_glsl_generate_ps_epilogue(const struct wined3d_gl_info *gl_in const struct ps_compile_args *args) { const struct wined3d_shader_reg_maps *reg_maps = &shader->reg_maps; - const char *output = needs_legacy_glsl_syntax(gl_info) ? "gl_FragData[0]" : "ps_out0"; /* Pixel shaders < 2.0 place the resulting color in R0 implicitly. */ if (reg_maps->shader_version.major < 2) - shader_addline(buffer, "%s = R0;\n", output); + shader_addline(buffer, "%s[0] = R0;\n", get_fragment_output(gl_info)); if (args->srgb_correction) shader_glsl_generate_srgb_write_correction(buffer, gl_info); @@ -7013,6 +7491,8 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context shader_glsl_add_version_declaration(buffer, gl_info); shader_glsl_enable_extensions(buffer, gl_info); + if (gl_info->supported[ARB_CONSERVATIVE_DEPTH]) + shader_addline(buffer, "#extension GL_ARB_conservative_depth : enable\n"); if (gl_info->supported[ARB_DERIVATIVE_CONTROL]) shader_addline(buffer, "#extension GL_ARB_derivative_control : enable\n"); if (shader_glsl_use_explicit_attrib_location(gl_info)) @@ -7027,17 +7507,15 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context * nvidia drivers write a warning if we don't do so. */ if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) shader_addline(buffer, "#extension GL_ARB_texture_rectangle : enable\n"); - if (gl_info->supported[ARB_CONSERVATIVE_DEPTH] && shader->u.ps.depth_compare) - shader_addline(buffer, "#extension GL_ARB_conservative_depth : enable\n"); /* Base Declarations */ shader_generate_glsl_declarations(context, buffer, shader, reg_maps, &priv_ctx); if (gl_info->supported[ARB_CONSERVATIVE_DEPTH]) { - if (shader->u.ps.depth_compare == WINED3DSPR_DEPTHOUT_GREATER_EQUAL) + if (shader->u.ps.depth_output == WINED3DSPR_DEPTHOUTGE) shader_addline(buffer, "layout (depth_greater) out float gl_FragDepth;\n"); - else if (shader->u.ps.depth_compare == WINED3DSPR_DEPTHOUT_LESS_EQUAL) + else if (shader->u.ps.depth_output == WINED3DSPR_DEPTHOUTLE) shader_addline(buffer, "layout (depth_less) out float gl_FragDepth;\n"); } @@ -7110,7 +7588,8 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context unsigned int in_count = min(vec4_varyings(version->major, gl_info), shader->limits->packed_input); if (args->vp_mode == vertexshader && reg_maps->input_registers) - shader_glsl_declare_shader_inputs(gl_info, buffer, in_count); + shader_glsl_declare_shader_inputs(gl_info, buffer, in_count, + shader->u.ps.interpolation_mode, version->major >= 4); shader_addline(buffer, "vec4 %s_in[%u];\n", prefix, in_count); } @@ -7166,24 +7645,9 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context if (!needs_legacy_glsl_syntax(gl_info)) { - if (args->dual_source_blend) - { - for (i = 0; i < gl_info->limits.dual_buffers * 2; i++) - { - if (shader_glsl_use_explicit_attrib_location(gl_info)) - shader_addline(buffer, "layout(location = %u, index = %u) ", i / 2, i % 2); - shader_addline(buffer, "out vec4 ps_out%u;\n", i); - } - } - else - { - for (i = 0; i < gl_info->limits.buffers; i++) - { - if (shader_glsl_use_explicit_attrib_location(gl_info)) - shader_addline(buffer, "layout(location = %u) ", i); - shader_addline(buffer, "out vec4 ps_out%u;\n", i); - } - } + if (shader_glsl_use_explicit_attrib_location(gl_info)) + shader_addline(buffer, "layout(location = 0) "); + shader_addline(buffer, "out vec4 ps_out[%u];\n", gl_info->limits.buffers); } if (shader->limits->constant_float + extra_constants_needed >= gl_info->limits.glsl_ps_float_constants) @@ -7256,7 +7720,8 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context /* Pack 3.0 inputs */ if (reg_maps->shader_version.major >= 3) - shader_glsl_input_pack(shader, buffer, &shader->input_signature, reg_maps, args, gl_info); + shader_glsl_input_pack(shader, buffer, &shader->input_signature, reg_maps, args, gl_info, + reg_maps->shader_version.major >= 4); /* Base Shader Body */ if (FAILED(shader_generate_code(shader, buffer, reg_maps, &priv_ctx, NULL, NULL))) @@ -7380,11 +7845,21 @@ static GLuint shader_glsl_generate_vshader(const struct wined3d_context *context if (reg_maps->shader_version.major >= 4) shader_glsl_generate_sm4_output_setup(priv, shader, args->next_shader_input_count, - gl_info, args->next_shader_type == WINED3D_SHADER_TYPE_PIXEL); + gl_info, args->next_shader_type == WINED3D_SHADER_TYPE_PIXEL, args->interpolation_mode); shader_addline(buffer, "void main()\n{\n"); - /* Base Shader Body */ + if (reg_maps->input_rel_addressing) + { + unsigned int highest_input_register = wined3d_log2i(reg_maps->input_registers); + shader_addline(buffer, "vec4 vs_in[%u];\n", highest_input_register + 1); + for (i = 0; i < shader->input_signature.element_count; ++i) + { + const struct wined3d_shader_signature_element *e = &shader->input_signature.elements[i]; + shader_addline(buffer, "vs_in[%u] = vs_in%u;\n", e->register_idx, e->register_idx); + } + } + if (FAILED(shader_generate_code(shader, buffer, reg_maps, &priv_ctx, NULL, NULL))) return 0; @@ -7485,7 +7960,7 @@ static GLuint shader_glsl_generate_hull_shader(const struct wined3d_context *con shader_addline(buffer, "void setup_hs_output(in vec4 outputs[%u])\n{\n", shader->limits->packed_output); shader_glsl_setup_sm4_shader_output(priv, shader->limits->packed_output, &shader->output_signature, - &shader->reg_maps, "shader_out[gl_InvocationID]"); + &shader->reg_maps, "shader_out[gl_InvocationID]", FALSE); shader_addline(buffer, "}\n"); } @@ -7621,7 +8096,7 @@ static GLuint shader_glsl_generate_domain_shader(const struct wined3d_context *c shader_addline(buffer, "uniform vec4 pos_fixup;\n"); shader_glsl_generate_sm4_output_setup(priv, shader, args->output_count, gl_info, - args->next_shader_type == WINED3D_SHADER_TYPE_PIXEL); + args->next_shader_type == WINED3D_SHADER_TYPE_PIXEL, args->interpolation_mode); shader_glsl_generate_patch_constant_setup(buffer, &shader->patch_constant_signature, TRUE); shader_addline(buffer, "void main()\n{\n"); @@ -7670,7 +8145,15 @@ static GLuint shader_glsl_generate_geometry_shader(const struct wined3d_context if (!gl_info->supported[ARB_CLIP_CONTROL]) shader_addline(buffer, "uniform vec4 pos_fixup;\n"); - shader_glsl_generate_sm4_output_setup(priv, shader, args->output_count, gl_info, TRUE); + if (is_rasterization_disabled(shader)) + { + shader_glsl_generate_stream_output_setup(priv, shader, &shader->u.gs.so_desc); + } + else + { + shader_glsl_generate_sm4_output_setup(priv, shader, args->output_count, + gl_info, TRUE, args->interpolation_mode); + } shader_addline(buffer, "void main()\n{\n"); if (FAILED(shader_generate_code(shader, buffer, reg_maps, &priv_ctx, NULL, NULL))) return 0; @@ -8234,7 +8717,8 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct shader_glsl_priv *pr { {"vec4", "ffp_attrib_position"}, /* WINED3D_FFP_POSITION */ {"vec4", "ffp_attrib_blendweight"}, /* WINED3D_FFP_BLENDWEIGHT */ - {"vec4", "ffp_attrib_blendindices"}, /* WINED3D_FFP_BLENDINDICES */ + /* TODO: Indexed vertex blending */ + {"float", ""}, /* WINED3D_FFP_BLENDINDICES */ {"vec3", "ffp_attrib_normal"}, /* WINED3D_FFP_NORMAL */ {"float", "ffp_attrib_psize"}, /* WINED3D_FFP_PSIZE */ {"vec4", "ffp_attrib_diffuse"}, /* WINED3D_FFP_DIFFUSE */ @@ -8246,7 +8730,6 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct shader_glsl_priv *pr BOOL legacy_lighting = priv->legacy_lighting; GLuint shader_obj; unsigned int i; - char var[64]; string_buffer_clear(buffer); @@ -8265,9 +8748,9 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct shader_glsl_priv *pr } shader_addline(buffer, "\n"); - shader_addline(buffer, "uniform mat4 ffp_modelview_matrix[%u];\n", MAX_VERTEX_INDEX_BLENDS); - shader_addline(buffer, "uniform mat3 ffp_normal_matrix[%u];\n", MAX_VERTEX_INDEX_BLENDS); + shader_addline(buffer, "uniform mat4 ffp_modelview_matrix[%u];\n", MAX_VERTEX_BLENDS); shader_addline(buffer, "uniform mat4 ffp_projection_matrix;\n"); + shader_addline(buffer, "uniform mat3 ffp_normal_matrix;\n"); shader_addline(buffer, "uniform mat4 ffp_texture_matrix[%u];\n", MAX_TEXTURES); shader_addline(buffer, "uniform struct\n{\n"); @@ -8352,22 +8835,12 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct shader_glsl_priv *pr } else { - if (!settings->sw_blending) - { - for (i = 0; i < settings->vertexblends; ++i) - shader_addline(buffer, "ffp_attrib_blendweight[%u] -= ffp_attrib_blendweight[%u];\n", settings->vertexblends, i); + for (i = 0; i < settings->vertexblends; ++i) + shader_addline(buffer, "ffp_attrib_blendweight[%u] -= ffp_attrib_blendweight[%u];\n", settings->vertexblends, i); - shader_addline(buffer, "vec4 ec_pos = vec4(0.0);\n"); - for (i = 0; i < settings->vertexblends + 1; ++i) - { - sprintf(var, settings->vb_indices ? "int(ffp_attrib_blendindices[%u] + 0.1)" : "%u", i); - shader_addline(buffer, "ec_pos += ffp_attrib_blendweight[%u] * (ffp_modelview_matrix[%s] * ffp_attrib_position);\n", i, var); - } - } - else - { - shader_addline(buffer, "vec4 ec_pos = ffp_attrib_position;\n"); - } + shader_addline(buffer, "vec4 ec_pos = vec4(0.0);\n"); + for (i = 0; i < settings->vertexblends + 1; ++i) + shader_addline(buffer, "ec_pos += ffp_attrib_blendweight[%u] * (ffp_modelview_matrix[%u] * ffp_attrib_position);\n", i, i); shader_addline(buffer, "gl_Position = ffp_projection_matrix * ec_pos;\n"); if (settings->clipping) @@ -8384,17 +8857,14 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct shader_glsl_priv *pr shader_addline(buffer, "vec3 normal = vec3(0.0);\n"); if (settings->normal) { - if (!settings->sw_blending) + if (!settings->vertexblends) { - for (i = 0; i < settings->vertexblends + 1; ++i) - { - sprintf(var, settings->vb_indices ? "int(ffp_attrib_blendindices[%u] + 0.1)" : "%u", i); - shader_addline(buffer, "normal += ffp_attrib_blendweight[%u] * (ffp_normal_matrix[%s] * ffp_attrib_normal);\n", i, var); - } + shader_addline(buffer, "normal = ffp_normal_matrix * ffp_attrib_normal;\n"); } else { - shader_addline(buffer, "normal = ffp_attrib_normal;\n"); + for (i = 0; i < settings->vertexblends + 1; ++i) + shader_addline(buffer, "normal += ffp_attrib_blendweight[%u] * (mat3(ffp_modelview_matrix[%u]) * ffp_attrib_normal);\n", i, i); } if (settings->normalize) @@ -8760,7 +9230,6 @@ static void shader_glsl_ffp_fragment_op(struct wined3d_string_buffer *buffer, un static GLuint shader_glsl_generate_ffp_fragment_shader(struct shader_glsl_priv *priv, const struct ffp_frag_settings *settings, const struct wined3d_context *context) { - const char *output = needs_legacy_glsl_syntax(context->gl_info) ? "gl_FragData[0]" : "ps_out0"; struct wined3d_string_buffer *tex_reg_name = string_buffer_get(&priv->string_buffers); enum wined3d_cmp_func alpha_test_func = settings->alpha_test_func + 1; struct wined3d_string_buffer *buffer = &priv->shader_buffer; @@ -8849,7 +9318,7 @@ static GLuint shader_glsl_generate_ffp_fragment_shader(struct shader_glsl_priv * { if (shader_glsl_use_explicit_attrib_location(gl_info)) shader_addline(buffer, "layout(location = 0) "); - shader_addline(buffer, "out vec4 ps_out0;\n"); + shader_addline(buffer, "out vec4 ps_out[1];\n"); } shader_addline(buffer, "vec4 tmp0, tmp1;\n"); @@ -9180,7 +9649,8 @@ static GLuint shader_glsl_generate_ffp_fragment_shader(struct shader_glsl_priv * } } - shader_addline(buffer, "%s = ffp_varying_specular * specular_enable + ret;\n", output); + shader_addline(buffer, "%s[0] = ffp_varying_specular * specular_enable + ret;\n", + get_fragment_output(gl_info)); if (settings->sRGB_write) shader_glsl_generate_srgb_write_correction(buffer, gl_info); @@ -9267,17 +9737,13 @@ static void shader_glsl_init_vs_uniform_locations(const struct wined3d_gl_info * vs->pos_fixup_location = GL_EXTCALL(glGetUniformLocation(program_id, "pos_fixup")); - for (i = 0; i < MAX_VERTEX_INDEX_BLENDS; ++i) + for (i = 0; i < MAX_VERTEX_BLENDS; ++i) { string_buffer_sprintf(name, "ffp_modelview_matrix[%u]", i); vs->modelview_matrix_location[i] = GL_EXTCALL(glGetUniformLocation(program_id, name->buffer)); } - for (i = 0; i < MAX_VERTEX_INDEX_BLENDS; ++i) - { - string_buffer_sprintf(name, "ffp_normal_matrix[%u]", i); - vs->normal_matrix_location[i] = GL_EXTCALL(glGetUniformLocation(program_id, name->buffer)); - } vs->projection_matrix_location = GL_EXTCALL(glGetUniformLocation(program_id, "ffp_projection_matrix")); + vs->normal_matrix_location = GL_EXTCALL(glGetUniformLocation(program_id, "ffp_normal_matrix")); for (i = 0; i < MAX_TEXTURES; ++i) { string_buffer_sprintf(name, "ffp_texture_matrix[%u]", i); @@ -9447,6 +9913,7 @@ static HRESULT shader_glsl_compile_compute_shader(struct shader_glsl_priv *priv, entry->ps.id = 0; entry->cs.id = shader_id; entry->constant_version = 0; + entry->shader_controlled_clip_distances = 0; entry->ps.np2_fixup_info = NULL; add_glsl_program_entry(priv, entry); @@ -9521,11 +9988,12 @@ static void set_glsl_compute_shader_program(const struct wined3d_context *contex static void set_glsl_shader_program(const struct wined3d_context *context, const struct wined3d_state *state, struct shader_glsl_priv *priv, struct glsl_context_data *ctx_data) { - const struct wined3d_gl_info *gl_info = context->gl_info; const struct wined3d_d3d_info *d3d_info = context->d3d_info; + const struct wined3d_gl_info *gl_info = context->gl_info; + const struct wined3d_shader *pre_rasterization_shader; const struct ps_np2fixup_info *np2fixup_info = NULL; - struct glsl_shader_prog_link *entry = NULL; struct wined3d_shader *hshader, *dshader, *gshader; + struct glsl_shader_prog_link *entry = NULL; struct wined3d_shader *vshader = NULL; struct wined3d_shader *pshader = NULL; GLuint reorder_shader_id = 0; @@ -9537,7 +10005,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const GLuint ds_id = 0; GLuint gs_id = 0; GLuint ps_id = 0; - struct list *ps_list = NULL, *vs_list = NULL; + struct list *ps_list, *vs_list; WORD attribs_map; struct wined3d_string_buffer *tmp_name; @@ -9555,7 +10023,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const vshader = state->shader[WINED3D_SHADER_TYPE_VERTEX]; - find_vs_compile_args(state, vshader, context->stream_info.swizzle_map, &vs_compile_args, d3d_info); + find_vs_compile_args(state, vshader, context->stream_info.swizzle_map, &vs_compile_args, context); vs_id = find_glsl_vshader(context, priv, vshader, &vs_compile_args); vs_list = &vshader->linked_programs; } @@ -9598,11 +10066,17 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const { struct gs_compile_args args; - find_gs_compile_args(state, gshader, &args); + find_gs_compile_args(state, gshader, &args, context); gs_id = find_glsl_geometry_shader(context, priv, gshader, &args); } - if (!(context->shader_update_mask & (1u << WINED3D_SHADER_TYPE_PIXEL)) && ctx_data->glsl_program) + /* A pixel shader is not used when rasterization is disabled. */ + if (is_rasterization_disabled(gshader)) + { + ps_id = 0; + ps_list = NULL; + } + else if (!(context->shader_update_mask & (1u << WINED3D_SHADER_TYPE_PIXEL)) && ctx_data->glsl_program) { ps_id = ctx_data->glsl_program->ps.id; ps_list = &ctx_data->glsl_program->ps.shader_entry; @@ -9657,6 +10131,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const entry->ps.id = ps_id; entry->cs.id = 0; entry->constant_version = 0; + entry->shader_controlled_clip_distances = 0; entry->ps.np2_fixup_info = np2fixup_info; /* Add the hash table entry */ add_glsl_program_entry(priv, entry); @@ -9728,26 +10203,8 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const if (!needs_legacy_glsl_syntax(gl_info)) { - char var[12]; - - if (wined3d_dualblend_enabled(state, gl_info)) - { - for (i = 0; i < gl_info->limits.dual_buffers * 2; i++) - { - sprintf(var, "ps_out%u", i); - GL_EXTCALL(glBindFragDataLocationIndexed(program_id, i / 2, i % 2, var)); - checkGLcall("glBindFragDataLocationIndexed"); - } - } - else - { - for (i = 0; i < gl_info->limits.buffers; i++) - { - sprintf(var, "ps_out%u", i); - GL_EXTCALL(glBindFragDataLocation(program_id, i, var)); - checkGLcall("glBindFragDataLocation"); - } - } + GL_EXTCALL(glBindFragDataLocation(program_id, 0, "ps_out")); + checkGLcall("glBindFragDataLocation"); } } @@ -9801,7 +10258,15 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const shader_glsl_init_gs_uniform_locations(gl_info, priv, program_id, &entry->gs); shader_glsl_init_ps_uniform_locations(gl_info, priv, program_id, &entry->ps, pshader ? pshader->limits->constant_float : 0); - checkGLcall("Find glsl program uniform locations"); + checkGLcall("find glsl program uniform locations"); + + pre_rasterization_shader = gshader ? gshader : dshader ? dshader : vshader; + if (pre_rasterization_shader && pre_rasterization_shader->reg_maps.shader_version.major >= 4) + { + unsigned int clip_distance_count = wined3d_popcount(pre_rasterization_shader->reg_maps.clip_distance_mask); + entry->shader_controlled_clip_distances = 1; + entry->clip_distance_mask = (1u << clip_distance_count) - 1; + } if (needs_legacy_glsl_syntax(gl_info)) { @@ -9846,7 +10311,7 @@ static void set_glsl_shader_program(const struct wined3d_context *context, const entry->constant_update_mask |= WINED3D_SHADER_CONST_FFP_MODELVIEW | WINED3D_SHADER_CONST_FFP_PROJ; - for (i = 1; i < MAX_VERTEX_INDEX_BLENDS; ++i) + for (i = 1; i < MAX_VERTEX_BLENDS; ++i) { if (entry->vs.modelview_matrix_location[i] != -1) { @@ -9957,6 +10422,7 @@ static void shader_glsl_select(void *shader_priv, struct wined3d_context *contex struct glsl_context_data *ctx_data = context->shader_backend_data; const struct wined3d_gl_info *gl_info = context->gl_info; struct shader_glsl_priv *priv = shader_priv; + struct glsl_shader_prog_link *glsl_program; GLenum current_vertex_color_clamp; GLuint program_id, prev_id; @@ -9964,13 +10430,15 @@ static void shader_glsl_select(void *shader_priv, struct wined3d_context *contex priv->fragment_pipe->enable_extension(gl_info, !use_ps(state)); prev_id = ctx_data->glsl_program ? ctx_data->glsl_program->id : 0; - set_glsl_shader_program(context, state, priv, ctx_data); + glsl_program = ctx_data->glsl_program; - if (ctx_data->glsl_program) + if (glsl_program) { - program_id = ctx_data->glsl_program->id; - current_vertex_color_clamp = ctx_data->glsl_program->vs.vertex_color_clamp; + program_id = glsl_program->id; + current_vertex_color_clamp = glsl_program->vs.vertex_color_clamp; + if (glsl_program->shader_controlled_clip_distances) + context_enable_clip_distances(context, glsl_program->clip_distance_mask); } else { @@ -9999,8 +10467,8 @@ static void shader_glsl_select(void *shader_priv, struct wined3d_context *contex GL_EXTCALL(glUseProgram(program_id)); checkGLcall("glUseProgram"); - if (program_id) - context->constant_update_mask |= ctx_data->glsl_program->constant_update_mask; + if (glsl_program) + context->constant_update_mask |= glsl_program->constant_update_mask; } context->shader_update_mask |= (1u << WINED3D_SHADER_TYPE_COMPUTE); @@ -10441,7 +10909,9 @@ static unsigned int shader_glsl_get_shader_model(const struct wined3d_gl_info *g if (shader_model_4 && gl_info->supported[ARB_COMPUTE_SHADER] + && gl_info->supported[ARB_CULL_DISTANCE] && gl_info->supported[ARB_DERIVATIVE_CONTROL] + && gl_info->supported[ARB_DRAW_INDIRECT] && gl_info->supported[ARB_GPU_SHADER5] && gl_info->supported[ARB_SHADER_ATOMIC_COUNTERS] && gl_info->supported[ARB_SHADER_IMAGE_LOAD_STORE] @@ -10560,7 +11030,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB /* WINED3DSIH_DCL_INPUT */ shader_glsl_nop, /* WINED3DSIH_DCL_INPUT_CONTROL_POINT_COUNT */ shader_glsl_nop, /* WINED3DSIH_DCL_INPUT_PRIMITIVE */ shader_glsl_nop, - /* WINED3DSIH_DCL_INPUT_PS */ NULL, + /* WINED3DSIH_DCL_INPUT_PS */ shader_glsl_nop, /* WINED3DSIH_DCL_INPUT_PS_SGV */ NULL, /* WINED3DSIH_DCL_INPUT_PS_SIV */ NULL, /* WINED3DSIH_DCL_INPUT_SGV */ shader_glsl_nop, @@ -10601,6 +11071,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB /* WINED3DSIH_DSY */ shader_glsl_map2gl, /* WINED3DSIH_DSY_COARSE */ shader_glsl_map2gl, /* WINED3DSIH_DSY_FINE */ shader_glsl_map2gl, + /* WINED3DSIH_EVAL_SAMPLE_INDEX */ NULL, /* WINED3DSIH_ELSE */ shader_glsl_else, /* WINED3DSIH_EMIT */ shader_glsl_emit, /* WINED3DSIH_EMIT_STREAM */ shader_glsl_emit, @@ -10808,7 +11279,7 @@ static void glsl_vertex_pipe_vp_get_caps(const struct wined3d_gl_info *gl_info, caps->ffp_generic_attributes = TRUE; caps->max_active_lights = MAX_ACTIVE_LIGHTS; caps->max_vertex_blend_matrices = MAX_VERTEX_BLENDS; - caps->max_vertex_blend_matrix_index = MAX_VERTEX_INDEX_BLENDS - 1; + caps->max_vertex_blend_matrix_index = 0; caps->vertex_processing_caps = WINED3DVTXPCAPS_TEXGEN | WINED3DVTXPCAPS_MATERIALSOURCE7 | WINED3DVTXPCAPS_VERTEXFOG @@ -10967,6 +11438,14 @@ static void glsl_vertex_pipe_hs(struct wined3d_context *context, static void glsl_vertex_pipe_geometry_shader(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { + struct glsl_context_data *ctx_data = context->shader_backend_data; + BOOL rasterization_disabled; + + rasterization_disabled = is_rasterization_disabled(state->shader[WINED3D_SHADER_TYPE_GEOMETRY]); + if (ctx_data->rasterization_disabled != rasterization_disabled) + context->shader_update_mask |= 1u << WINED3D_SHADER_TYPE_PIXEL; + ctx_data->rasterization_disabled = rasterization_disabled; + if (state->shader[WINED3D_SHADER_TYPE_DOMAIN]) context->shader_update_mask |= 1u << WINED3D_SHADER_TYPE_DOMAIN; else if (state->shader[WINED3D_SHADER_TYPE_VERTEX] @@ -10995,8 +11474,7 @@ static void glsl_vertex_pipe_world(struct wined3d_context *context, static void glsl_vertex_pipe_vertexblend(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) { - int i = state_id - STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(0)); - context->constant_update_mask |= WINED3D_SHADER_CONST_FFP_VERTEXBLEND_INDEX(i); + context->constant_update_mask |= WINED3D_SHADER_CONST_FFP_VERTEXBLEND; } static void glsl_vertex_pipe_view(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) @@ -11152,54 +11630,6 @@ static const struct StateEntryTemplate glsl_vertex_pipe_vp_states[] = {STATE_CLIPPLANE(6), {STATE_CLIPPLANE(6), clipplane }, WINED3D_GL_EXT_NONE }, {STATE_CLIPPLANE(7), {STATE_CLIPPLANE(7), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, {STATE_CLIPPLANE(7), {STATE_CLIPPLANE(7), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(8), {STATE_CLIPPLANE(8), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(8), {STATE_CLIPPLANE(8), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(9), {STATE_CLIPPLANE(9), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(9), {STATE_CLIPPLANE(9), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(10), {STATE_CLIPPLANE(10), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(10), {STATE_CLIPPLANE(10), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(11), {STATE_CLIPPLANE(11), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(11), {STATE_CLIPPLANE(11), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(12), {STATE_CLIPPLANE(12), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(12), {STATE_CLIPPLANE(12), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(13), {STATE_CLIPPLANE(13), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(13), {STATE_CLIPPLANE(13), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(14), {STATE_CLIPPLANE(14), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(14), {STATE_CLIPPLANE(14), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(15), {STATE_CLIPPLANE(15), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(15), {STATE_CLIPPLANE(15), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(16), {STATE_CLIPPLANE(16), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(16), {STATE_CLIPPLANE(16), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(17), {STATE_CLIPPLANE(17), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(17), {STATE_CLIPPLANE(17), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(18), {STATE_CLIPPLANE(18), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(18), {STATE_CLIPPLANE(18), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(19), {STATE_CLIPPLANE(19), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(19), {STATE_CLIPPLANE(19), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(20), {STATE_CLIPPLANE(20), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(20), {STATE_CLIPPLANE(20), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(21), {STATE_CLIPPLANE(21), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(21), {STATE_CLIPPLANE(21), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(22), {STATE_CLIPPLANE(22), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(22), {STATE_CLIPPLANE(22), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(23), {STATE_CLIPPLANE(23), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(23), {STATE_CLIPPLANE(23), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(24), {STATE_CLIPPLANE(24), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(24), {STATE_CLIPPLANE(24), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(25), {STATE_CLIPPLANE(25), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(25), {STATE_CLIPPLANE(25), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(26), {STATE_CLIPPLANE(26), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(26), {STATE_CLIPPLANE(26), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(27), {STATE_CLIPPLANE(27), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(27), {STATE_CLIPPLANE(27), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(28), {STATE_CLIPPLANE(28), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(28), {STATE_CLIPPLANE(28), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(29), {STATE_CLIPPLANE(29), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(29), {STATE_CLIPPLANE(29), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(30), {STATE_CLIPPLANE(30), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(30), {STATE_CLIPPLANE(30), clipplane }, WINED3D_GL_EXT_NONE }, - {STATE_CLIPPLANE(31), {STATE_CLIPPLANE(31), glsl_vertex_pipe_clip_plane}, WINED3D_GLSL_130 }, - {STATE_CLIPPLANE(31), {STATE_CLIPPLANE(31), clipplane }, WINED3D_GL_EXT_NONE }, /* Lights */ {STATE_LIGHT_TYPE, {STATE_RENDER(WINED3D_RS_FOGENABLE), NULL }, WINED3D_GL_EXT_NONE }, {STATE_ACTIVELIGHT(0), {STATE_ACTIVELIGHT(0), glsl_vertex_pipe_light }, WINED3D_GL_EXT_NONE }, @@ -11227,11 +11657,6 @@ static const struct StateEntryTemplate glsl_vertex_pipe_vp_states[] = {STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(1)), {STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(1)), glsl_vertex_pipe_vertexblend }, WINED3D_GL_EXT_NONE }, {STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(2)), {STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(2)), glsl_vertex_pipe_vertexblend }, WINED3D_GL_EXT_NONE }, {STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(3)), {STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(3)), glsl_vertex_pipe_vertexblend }, WINED3D_GL_EXT_NONE }, - {STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(4)), {STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(4)), glsl_vertex_pipe_vertexblend }, WINED3D_GL_EXT_NONE }, - {STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(5)), {STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(5)), glsl_vertex_pipe_vertexblend }, WINED3D_GL_EXT_NONE }, - {STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(6)), {STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(6)), glsl_vertex_pipe_vertexblend }, WINED3D_GL_EXT_NONE }, - {STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(7)), {STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(7)), glsl_vertex_pipe_vertexblend }, WINED3D_GL_EXT_NONE }, - {STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(8)), {STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(8)), glsl_vertex_pipe_vertexblend }, WINED3D_GL_EXT_NONE }, {STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), {STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), glsl_vertex_pipe_texmatrix}, WINED3D_GL_EXT_NONE }, {STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), {STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), glsl_vertex_pipe_texmatrix}, WINED3D_GL_EXT_NONE }, {STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), {STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), glsl_vertex_pipe_texmatrix}, WINED3D_GL_EXT_NONE }, diff --git a/dll/directx/wine/wined3d/query.c b/dll/directx/wine/wined3d/query.c index 428e841d4e..fe175d1a6d 100644 --- a/dll/directx/wine/wined3d/query.c +++ b/dll/directx/wine/wined3d/query.c @@ -387,7 +387,7 @@ HRESULT CDECL wined3d_query_get_data(struct wined3d_query *query, } else if (query->counter_main != query->counter_retrieved) { - if (flags & WINED3DGETDATA_FLUSH) + if (flags & WINED3DGETDATA_FLUSH && !query->device->cs->queries_flushed) wined3d_cs_emit_flush(query->device->cs); return S_FALSE; } @@ -911,34 +911,6 @@ static BOOL wined3d_pipeline_query_ops_issue(struct wined3d_query *query, DWORD return poll; } -static BOOL wined3d_statistics_query_ops_poll(struct wined3d_query *query, DWORD flags) -{ - TRACE("query %p, flags %#x.\n", query, flags); - - return TRUE; -} - -static BOOL wined3d_statistics_query_ops_issue(struct wined3d_query *query, DWORD flags) -{ - FIXME("query %p, flags %#x.\n", query, flags); - - return FALSE; -} - -static BOOL wined3d_overflow_query_ops_poll(struct wined3d_query *query, DWORD flags) -{ - TRACE("query %p, flags %#x.\n", query, flags); - - return TRUE; -} - -static BOOL wined3d_overflow_query_ops_issue(struct wined3d_query *query, DWORD flags) -{ - FIXME("query %p, flags %#x.\n", query, flags); - - return FALSE; -} - static void wined3d_event_query_ops_destroy(struct wined3d_query *query) { struct wined3d_event_query *event_query = wined3d_event_query_from_query(query); @@ -1223,72 +1195,6 @@ static HRESULT wined3d_pipeline_query_create(struct wined3d_device *device, return WINED3D_OK; } -static void wined3d_statistics_query_ops_destroy(struct wined3d_query *query) -{ - HeapFree(GetProcessHeap(), 0, query); -} - -static const struct wined3d_query_ops statistics_query_ops = -{ - wined3d_statistics_query_ops_poll, - wined3d_statistics_query_ops_issue, - wined3d_statistics_query_ops_destroy, -}; - -static HRESULT wined3d_statistics_query_create(struct wined3d_device *device, - enum wined3d_query_type type, void *parent, const struct wined3d_parent_ops *parent_ops, - struct wined3d_query **query) -{ - static const struct wined3d_query_data_so_statistics statistics = { 1, 1 }; - struct wined3d_query *object; - - FIXME("device %p, type %#x, parent %p, query %p.\n", device, type, parent, query); - - if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) - return E_OUTOFMEMORY; - - wined3d_query_init(object, device, type, &statistics, - sizeof(statistics), &statistics_query_ops, parent, parent_ops); - - TRACE("Created query %p.\n", object); - *query = object; - - return WINED3D_OK; -} - -static void wined3d_overflow_query_ops_destroy(struct wined3d_query *query) -{ - HeapFree(GetProcessHeap(), 0, query); -} - -static const struct wined3d_query_ops overflow_query_ops = -{ - wined3d_overflow_query_ops_poll, - wined3d_overflow_query_ops_issue, - wined3d_overflow_query_ops_destroy, -}; - -static HRESULT wined3d_overflow_query_create(struct wined3d_device *device, - enum wined3d_query_type type, void *parent, const struct wined3d_parent_ops *parent_ops, - struct wined3d_query **query) -{ - static const BOOL overflow = FALSE; - struct wined3d_query *object; - - FIXME("device %p, type %#x, parent %p, query %p.\n", device, type, parent, query); - - if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) - return E_OUTOFMEMORY; - - wined3d_query_init(object, device, type, &overflow, - sizeof(overflow), &overflow_query_ops, parent, parent_ops); - - TRACE("Created query %p.\n", object); - *query = object; - - return WINED3D_OK; -} - HRESULT CDECL wined3d_query_create(struct wined3d_device *device, enum wined3d_query_type type, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query) { @@ -1319,12 +1225,6 @@ HRESULT CDECL wined3d_query_create(struct wined3d_device *device, enum wined3d_q case WINED3D_QUERY_TYPE_PIPELINE_STATISTICS: return wined3d_pipeline_query_create(device, type, parent, parent_ops, query); - case WINED3D_QUERY_TYPE_SO_STATISTICS: - return wined3d_statistics_query_create(device, type, parent, parent_ops, query); - - case WINED3D_QUERY_TYPE_SO_OVERFLOW: - return wined3d_overflow_query_create(device, type, parent, parent_ops, query); - default: FIXME("Unhandled query type %#x.\n", type); return WINED3DERR_NOTAVAILABLE; diff --git a/dll/directx/wine/wined3d/resource.c b/dll/directx/wine/wined3d/resource.c index ffce012503..0788146106 100644 --- a/dll/directx/wine/wined3d/resource.c +++ b/dll/directx/wine/wined3d/resource.c @@ -48,7 +48,7 @@ static DWORD resource_access_from_pool(enum wined3d_pool pool) static void resource_check_usage(DWORD usage) { - static DWORD handled = WINED3DUSAGE_RENDERTARGET + static const DWORD handled = WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_DEPTHSTENCIL | WINED3DUSAGE_WRITEONLY | WINED3DUSAGE_DYNAMIC @@ -66,10 +66,7 @@ static void resource_check_usage(DWORD usage) * driver. */ if (usage & ~handled) - { FIXME("Unhandled usage flags %#x.\n", usage & ~handled); - handled |= usage; - } if ((usage & (WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_WRITEONLY)) == WINED3DUSAGE_DYNAMIC) WARN_(d3d_perf)("WINED3DUSAGE_DYNAMIC used without WINED3DUSAGE_WRITEONLY.\n"); } @@ -96,7 +93,6 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device * resource_types[] = { {WINED3D_RTYPE_BUFFER, 0, WINED3D_GL_RES_TYPE_BUFFER}, - {WINED3D_RTYPE_TEXTURE_1D, 0, WINED3D_GL_RES_TYPE_TEX_1D}, {WINED3D_RTYPE_TEXTURE_2D, 0, WINED3D_GL_RES_TYPE_TEX_2D}, {WINED3D_RTYPE_TEXTURE_2D, 0, WINED3D_GL_RES_TYPE_TEX_RECT}, {WINED3D_RTYPE_TEXTURE_2D, 0, WINED3D_GL_RES_TYPE_RB}, @@ -337,17 +333,19 @@ static DWORD wined3d_resource_sanitise_map_flags(const struct wined3d_resource * return 0; } } - else if ((flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE)) - == (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE)) + else if (flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE)) { - WARN("WINED3D_MAP_DISCARD and WINED3D_MAP_NOOVERWRITE used together, ignoring.\n"); - return 0; - } - else if (flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE) - && !(resource->usage & WINED3DUSAGE_DYNAMIC)) - { - WARN("DISCARD or NOOVERWRITE map on non-dynamic buffer, ignoring.\n"); - return 0; + if (!(resource->usage & WINED3DUSAGE_DYNAMIC)) + { + WARN("DISCARD or NOOVERWRITE map on non-dynamic buffer, ignoring.\n"); + return 0; + } + if ((flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE)) + == (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE)) + { + WARN("WINED3D_MAP_NOOVERWRITE used with WINED3D_MAP_DISCARD, ignoring WINED3D_MAP_DISCARD.\n"); + flags &= ~WINED3D_MAP_DISCARD; + } } return flags; @@ -365,14 +363,6 @@ HRESULT CDECL wined3d_resource_map(struct wined3d_resource *resource, unsigned i return wined3d_cs_map(resource->device->cs, resource, sub_resource_idx, map_desc, box, flags); } -HRESULT CDECL wined3d_resource_map_info(struct wined3d_resource *resource, unsigned int sub_resource_idx, - struct wined3d_map_info *info, DWORD flags) -{ - TRACE("resource %p, sub_resource_idx %u.\n", resource, sub_resource_idx); - - return resource->resource_ops->resource_map_info(resource, sub_resource_idx, info, flags); -} - HRESULT CDECL wined3d_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx) { TRACE("resource %p, sub_resource_idx %u.\n", resource, sub_resource_idx); @@ -380,99 +370,6 @@ HRESULT CDECL wined3d_resource_unmap(struct wined3d_resource *resource, unsigned return wined3d_cs_unmap(resource->device->cs, resource, sub_resource_idx); } -UINT CDECL wined3d_resource_update_info(struct wined3d_resource *resource, unsigned int sub_resource_idx, - const struct wined3d_box *box, unsigned int row_pitch, unsigned int depth_pitch) -{ - unsigned int width, height, depth; - struct wined3d_box b; - UINT data_size; - - TRACE("resource %p, sub_resource_idx %u, box %s, row_pitch %u, depth_pitch %u.\n", - resource, sub_resource_idx, debug_box(box), row_pitch, depth_pitch); - - if (resource->type == WINED3D_RTYPE_BUFFER) - { - if (sub_resource_idx > 0) - { - WARN("Invalid sub_resource_idx %u.\n", sub_resource_idx); - return 0; - } - - width = resource->size; - height = 1; - depth = 1; - } - else if (resource->type == WINED3D_RTYPE_TEXTURE_1D || - resource->type == WINED3D_RTYPE_TEXTURE_2D || resource->type == WINED3D_RTYPE_TEXTURE_3D) - { - struct wined3d_texture *texture = texture_from_resource(resource); - unsigned int level; - - if (sub_resource_idx >= texture->level_count * texture->layer_count) - { - WARN("Invalid sub_resource_idx %u.\n", sub_resource_idx); - return 0; - } - - level = sub_resource_idx % texture->level_count; - width = wined3d_texture_get_level_width(texture, level); - height = wined3d_texture_get_level_height(texture, level); - depth = wined3d_texture_get_level_depth(texture, level); - } - else - { - FIXME("Not implemented for %s resources.\n", debug_d3dresourcetype(resource->type)); - return 0; - } - - if (!box) - { - wined3d_box_set(&b, 0, 0, width, height, 0, depth); - box = &b; - } - else if (box->left >= box->right || box->right > width - || box->top >= box->bottom || box->bottom > height - || box->front >= box->back || box->back > depth) - { - WARN("Invalid box %s specified.\n", debug_box(box)); - return 0; - } - - if (resource->format_flags & WINED3DFMT_FLAG_BLOCKS) - { - if (resource->type != WINED3D_RTYPE_TEXTURE_2D) - { - FIXME("Calculation of block formats not implemented for %s resources.\n", debug_d3dresourcetype(resource->type)); - return 0; - } - - height = (box->bottom - box->top + resource->format->block_height - 1) / resource->format->block_height; - width = (box->right - box->left + resource->format->block_width - 1) / resource->format->block_width; - return (height - 1) * row_pitch + width * resource->format->block_byte_count; - } - - data_size = 0; - switch (resource->type) - { - case WINED3D_RTYPE_TEXTURE_3D: - data_size += (box->back - box->front - 1) * depth_pitch; - /* fall-through */ - case WINED3D_RTYPE_TEXTURE_2D: - data_size += (box->bottom - box->top - 1) * row_pitch; - /* fall-through */ - case WINED3D_RTYPE_TEXTURE_1D: - data_size += (box->right - box->left) * resource->format->byte_count; - break; - case WINED3D_RTYPE_BUFFER: - data_size = box->right - box->left; - break; - case WINED3D_RTYPE_NONE: - break; ... 22194 lines suppressed ...
6 years, 11 months
1
0
0
0
← Newer
1
...
11
12
13
14
15
16
17
...
38
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Results per page:
10
25
50
100
200