Compare commits

...

88 Commits

Author SHA1 Message Date
Aleksey Bragin
57e6f42fc2 [DDRAW]
- Jerome Gardou: Avoid buffer overrun in IDirectDraw::GetCaps().
See issue #5006 for more details.

svn path=/branches/reactx/; revision=48842
2010-09-21 08:24:15 +00:00
Kamil Hornicek
620afe9c34 - preparation for initial palette support
svn path=/branches/reactx/; revision=43813
2009-10-28 16:03:10 +00:00
Kamil Hornicek
8d8a0c408a - fix DDrawSurface_Release for now + more minor fixes
svn path=/branches/reactx/; revision=43812
2009-10-28 15:22:45 +00:00
Kamil Hornicek
3bd959b642 - sync ddraw with trunk
- if anyone wishes to work on it, do it in this branch please

svn path=/branches/reactx/; revision=43810
2009-10-28 13:23:03 +00:00
Kamil Hornicek
3d943c17be - add more pixel formats
svn path=/branches/reactx/; revision=39617
2009-02-15 22:32:41 +00:00
Kamil Hornicek
1934c18c7e - simplify GdiEntry2 a bit
- use wined3d for obtaining pixel format and display info

svn path=/branches/reactx/; revision=39612
2009-02-15 21:14:36 +00:00
Kamil Hornicek
d4108c9018 - sync wined3d/d3d8/d3d9 with trunk
- update gdi32 accordingly

svn path=/branches/reactx/; revision=39269
2009-02-01 16:18:22 +00:00
Kamil Hornicek
6941d14b46 - fix build after def -> spec change
svn path=/branches/reactx/; revision=39263
2009-02-01 12:39:52 +00:00
Ziliang Guo
590857e58d Convert dciman32 def to spec as requested by Magus, take 4. Reviewed by Kamil.
svn path=/branches/reactx/; revision=39064
2009-01-24 17:34:20 +00:00
Magnus Olsen
3785715869 Implement DCIEndAccess not tested in all case yet
svn path=/branches/reactx/; revision=38630
2009-01-07 14:22:38 +00:00
Magnus Olsen
ec8932bae4 Implement DCIBeginAccess not tested in all case yet
svn path=/branches/reactx/; revision=38628
2009-01-07 13:47:18 +00:00
Magnus Olsen
6ba7bd6b2d fix a bug inside WinWatchClose it did endless loop when it try remove a gpWatchList entry
svn path=/branches/reactx/; revision=38586
2009-01-05 17:17:36 +00:00
Magnus Olsen
bbf420d541 rename ddcs to gcsWinWatchLock
add global windows watch list call gpWinWatchList it will be use by DciBeginAccess and DciEndAccess.

Change behavior in WinWatchOpen so it store the new hww into gpWinWatchList.

Change behavior WinWatchClose so it remove the hww entry inside gpWinWatchList. 

svn path=/branches/reactx/; revision=38585
2009-01-05 17:10:21 +00:00
Magnus Olsen
7939e0da48 Rewrote
DllGetClassObject
DXDiagCF_LockServer
DXDiagCF_CreateInstance
DXDiagCF_Release
DXDiagCF_AddRef
DXDiagCF_QueryInterface
to make them more winodws NT compatible and the struct match better againts windows. If u type cast the COM interface pointer to _INT struct you will access the internal data, even overwrite function pointers to own. 

svn path=/branches/reactx/; revision=38326
2008-12-24 11:14:44 +00:00
Kamil Hornicek
935b9e944a fix build 2nd try:
- merge header changes from trunk
- add some missing files

svn path=/branches/reactx/; revision=38025
2008-12-11 21:39:50 +00:00
Kamil Hornicek
19e8a2afeb - fix build
svn path=/branches/reactx/; revision=38001
2008-12-10 19:55:38 +00:00
Kamil Hornicek
865d4ed6c2 - basic implementation of GdiEntry7 and GdiEntry8
svn path=/branches/reactx/; revision=37976
2008-12-09 18:33:34 +00:00
Kamil Hornicek
80aac286b0 - merge r37917, r37835 from trunk
svn path=/branches/reactx/; revision=37964
2008-12-09 14:05:35 +00:00
Kamil Hornicek
f4a968bab2 - don't set DDCAPS2_CERTIFIED, ddraw refuses to believe us
svn path=/branches/reactx/; revision=37810
2008-12-02 16:04:56 +00:00
Kamil Hornicek
eb187e9be0 - according to msdn a handle to the global ddraw object should be returned when hdc is 0
- fixes 2 ddrawapi tests

svn path=/branches/reactx/; revision=37807
2008-12-02 10:48:30 +00:00
KJK::Hyperion
9fddbfd8ba Merge r37254-r37781 from trunk
svn path=/branches/reactx/; revision=37785
2008-12-01 01:16:20 +00:00
Magnus Olsen
c917873957 Add more dump data for ddraw
svn path=/branches/reactx/; revision=37770
2008-11-30 17:14:21 +00:00
Kamil Hornicek
dafc9aa54d - store the wined3d device pointer in the right place
svn path=/branches/reactx/; revision=37760
2008-11-30 10:02:54 +00:00
Magnus Olsen
ae02056b26 cleanup the code a bit in DdCreateSurface and comment up what left todo
svn path=/branches/reactx/; revision=37741
2008-11-29 20:10:56 +00:00
Magnus Olsen
d431dc5f6f sorry forget cleanup the code a bit in CReatesurface
svn path=/branches/reactx/; revision=37738
2008-11-29 19:24:40 +00:00
Magnus Olsen
4e6baaefd3 Createsurface now detect if it screen res or desc size it should use, and which level each surface are create in.
svn path=/branches/reactx/; revision=37737
2008-11-29 19:21:30 +00:00
Magnus Olsen
5eb93a6b21 trying implement DdCreateSurface for wined3d
svn path=/branches/reactx/; revision=37735
2008-11-29 17:53:51 +00:00
Kamil Hornicek
c4201ee532 - create wined3d device in GdiEntry2
svn path=/branches/reactx/; revision=37733
2008-11-29 16:27:59 +00:00
Magnus Olsen
ac1acafa42 Implement DdCanCreateSurface for wined3d
svn path=/branches/reactx/; revision=37731
2008-11-29 16:09:06 +00:00
Magnus Olsen
813d435db0 update comment in config.template what REACTX_EMU does and how it works
svn path=/branches/reactx/; revision=37730
2008-11-29 15:16:54 +00:00
Magnus Olsen
270543fe55 Make Gdientry2 return a fourcc list
svn path=/branches/reactx/; revision=37729
2008-11-29 14:34:58 +00:00
Magnus Olsen
8753114e79 BugFix GdiEntry 2 : Do not fill in pHalInfo when it is NULL
svn path=/branches/reactx/; revision=37728
2008-11-29 13:33:49 +00:00
Kamil Hornicek
09c887e314 - reshuffle the code a bit, fix formatting, no actual code change
svn path=/branches/reactx/; revision=37727
2008-11-29 12:58:12 +00:00
Kamil Hornicek
4d014e450e - "implement" GdiEntry10
svn path=/branches/reactx/; revision=37722
2008-11-29 11:24:08 +00:00
Magnus Olsen
8d5b573060 add GdiGetBitmapBitsSize it is a new api from windows xp sp3, the code have been tested in vs2003
svn path=/branches/reactx/; revision=37720
2008-11-29 10:29:37 +00:00
Kamil Hornicek
a8ff649aa8 - fix some checks
- add stub traces
- avoid being "Naughty Application!"

svn path=/branches/reactx/; revision=37708
2008-11-28 18:56:24 +00:00
Magnus Olsen
94e477b8fa setup wined3d Caps for D3DHAL_GLOBALDRIVERDATA inside DdQueryDirectDrawObject
Bugfix so it return right return value if anything fails

svn path=/branches/reactx/; revision=37686
2008-11-27 12:26:06 +00:00
Magnus Olsen
f930d4d1c4 setup wined3d Caps for HALLINFO inside DdQueryDirectDrawObject
svn path=/branches/reactx/; revision=37685
2008-11-27 10:02:24 +00:00
Magnus Olsen
caeb27c5c3 convert parts of DdQueryDirectDrawObject (gdientry 2) to use wined3d. and fixing a hdc leak
svn path=/branches/reactx/; revision=37682
2008-11-27 08:55:13 +00:00
Magnus Olsen
78d5aba68d convert parts of DdQueryDirectDrawObject (gdientry 2) to use wined3d.
svn path=/branches/reactx/; revision=37680
2008-11-27 08:34:16 +00:00
Magnus Olsen
2d9fcb3ed5 fix a typo
svn path=/branches/reactx/; revision=37679
2008-11-27 04:37:14 +00:00
Magnus Olsen
d7225a0934 convert parts of DdQueryDirectDrawObject (gdientry 2) to use wined3d.
svn path=/branches/reactx/; revision=37678
2008-11-27 04:23:05 +00:00
Kamil Hornicek
a4996648b8 - fix a typo
svn path=/branches/reactx/; revision=37662
2008-11-26 15:38:43 +00:00
Kamil Hornicek
cf1e690e94 - use dynamic linking for wined3d, fixes boot
svn path=/branches/reactx/; revision=37660
2008-11-26 14:59:30 +00:00
Magnus Olsen
a86a1d6f93 start convert DdQueryDirectDrawObject (gdientry 2) to use wined3d.
svn path=/branches/reactx/; revision=37655
2008-11-26 09:01:45 +00:00
Magnus Olsen
0c58849801 Convert gdientry 1 to using wined3d
svn path=/branches/reactx/; revision=37654
2008-11-26 07:58:33 +00:00
Magnus Olsen
d800df0c22 rename a fileto better name
svn path=/branches/reactx/; revision=37650
2008-11-26 06:44:48 +00:00
Magnus Olsen
484bd93b43 fix gdi32 build wrong rbuild syntax
svn path=/branches/reactx/; revision=37648
2008-11-26 06:42:39 +00:00
Magnus Olsen
e7e197736f part 2 of 2
This is a experiment with opengl over gdientry1-16, we do not known if this experiment is good or bad idea. if it works fine and show it is good idea, it will mabe be in trunk later 

svn path=/branches/reactx/; revision=37647
2008-11-26 06:31:28 +00:00
Magnus Olsen
442af13eec part 1 of 2
This is a experiment with opengl over gdientry1-16, we do not known if this experiment is good or bad idea. if it works fine and show it is good idea, it will mabe be in trunk later 

svn path=/branches/reactx/; revision=37646
2008-11-26 06:30:33 +00:00
Magnus Olsen
4b4bfa08dd Implement WinWatchGetClipList.
Update WinWatchClose thx to WinWatchGetClipList
ToDO Now only two api left to implement DCIEndAccess and DCIBeginAccess

svn path=/branches/reactx/; revision=37607
2008-11-24 07:21:33 +00:00
Magnus Olsen
e2328d4bf5 Implement WinWatchDidStatusChange
svn path=/branches/reactx/; revision=37596
2008-11-23 17:50:15 +00:00
Magnus Olsen
e0b17f2cc3 Implement WinWatchClose
svn path=/branches/reactx/; revision=37595
2008-11-23 17:11:52 +00:00
Magnus Olsen
6f655fc41c Implement WinWatchOpen
svn path=/branches/reactx/; revision=37587
2008-11-23 13:50:47 +00:00
Magnus Olsen
f2b711b20b Implement GetWindowRegionData
svn path=/branches/reactx/; revision=37585
2008-11-23 12:35:08 +00:00
Magnus Olsen
e33987d5ed Implement GetDCRegionData
svn path=/branches/reactx/; revision=37584
2008-11-23 11:34:58 +00:00
Magnus Olsen
6780d55c9f Sorry fix a typo
svn path=/branches/reactx/; revision=37582
2008-11-23 11:02:22 +00:00
Magnus Olsen
b181b5af88 Finish Implement DCIDestroy() it free all alloc res now.
svn path=/branches/reactx/; revision=37581
2008-11-23 11:00:11 +00:00
Gregor Brunmar
b890b9ddc0 Build and use native d3d9 module and not wine's wrapper
svn path=/branches/reactx/; revision=37580
2008-11-23 10:14:09 +00:00
Magnus Olsen
7064c5723c Impement part of DCIDestroy
Implement DCISetClipList
Implement DCISetSrcDestClip
Implement WinWatchNotify.
BugFix : DciCreatePrimary. forget check see if hal support create surface or not. 

svn path=/branches/reactx/; revision=37577
2008-11-23 09:54:48 +00:00
Gregor Brunmar
751b750ae1 Fixed build when including the native d3d9 project
svn path=/branches/reactx/; revision=37576
2008-11-23 09:33:41 +00:00
Magnus Olsen
742e08eece Remove the spec file with def file, no stack coruptions now.
implement   DCICreateOffscreen, DCICreateOverlay,  DCIDraw, DCIEnum, DCISetDestination

svn path=/branches/reactx/; revision=37573
2008-11-23 07:58:18 +00:00
Magnus Olsen
79a38ab49b Implement lite more of DCICreatePrimary, now it is working. it is few thing left to deal with
svn path=/branches/reactx/; revision=37572
2008-11-23 07:10:03 +00:00
Magnus Olsen
f08248485a implement bit more of DCICreatePrimary, it is not finish or tested yet, and comment up the code.
svn path=/branches/reactx/; revision=37560
2008-11-22 17:08:55 +00:00
Magnus Olsen
f4bc3937df start implement DCICreatePrimary, it is not finish or tested yet.
svn path=/branches/reactx/; revision=37557
2008-11-22 16:10:53 +00:00
Magnus Olsen
c2c5ce9185 Add Threadlock for DDraw_AddRef
Add Threadlock for DDraw_Release
Add Threadlock for DDraw->Compact
BugFix : Remove wrong zeromemory in StartDirectDrawHel discovery by Pigglesworth
Cleanup : reactivate hal support in DDrawSurface->Lock and DDrawSurface->UnLock 

svn path=/branches/reactx/; revision=37509
2008-11-21 12:42:25 +00:00
Magnus Olsen
f2a659b1f0 From old code when I started on DCIMAN
Implement DllMain
Implement DCIOpenProvider
Implement DCICloseProvider

svn path=/branches/reactx/; revision=37505
2008-11-21 10:17:34 +00:00
Kamil Hornicek
24660aadf9 - fix some checks, verified in win xp
svn path=/branches/reactx/; revision=37503
2008-11-21 09:58:07 +00:00
Magnus Olsen
e61de69db3 Copied dciman.h and dciddi.h from psdk to ddk for they are same
svn path=/branches/reactx/; revision=37501
2008-11-21 09:12:27 +00:00
Magnus Olsen
8293570ccc Copied dciman.h and dciddi.h from psdk to ddk for they are same
svn path=/branches/reactx/; revision=37500
2008-11-21 09:12:25 +00:00
Magnus Olsen
1a462a43be delete the dciddi.h we got in ddk, it is same as psdk header
svn path=/branches/reactx/; revision=37499
2008-11-21 09:09:06 +00:00
Magnus Olsen
5ceb1f47cb update the dciddi and dciman header.
it does not missing any data now. 

svn path=/branches/reactx/; revision=37498
2008-11-21 09:07:20 +00:00
Magnus Olsen
c3682af094 Cleanup lite for the dump functions for dumping internal value in ddraw.dll and add some new dumping function have been add.
svn path=/branches/reactx/; revision=37481
2008-11-20 12:25:27 +00:00
Magnus Olsen
1d76a5cae6 Fixed one smaller bug in hel DdLock and DdUnlock now the lock and the unlcok using the windows hdc to draw the data on
svn path=/branches/reactx/; revision=37463
2008-11-19 19:04:19 +00:00
Magnus Olsen
71aea5bb22 Fixed hack so DdUnlock hel does not leak memory,
ToDO : DdLock hel captuer the screen outside the client area, DdUnlock also need write back to the client area. 

svn path=/branches/reactx/; revision=37461
2008-11-19 18:28:34 +00:00
Magnus Olsen
a621149a91 Fixed bug in hel surface lock.
Now we truly get back a buffer with bitmap data for specify bitmap area. and few other mirror bugfix for DdLock hel function

svn path=/branches/reactx/; revision=37460
2008-11-19 17:56:56 +00:00
Magnus Olsen
373edab107 Fixed a old typo HelDdSurfLock it should be DIB_RGB_* not DIB_PAL_* when it try getting rgb bitmap pixel data
Ported old experiment code for HelDdSurfUnLock it is not completed and can be very buggy

Fixed smaller bug in Main_DDrawSurface_Unlock the rest of visrgn can fail on real hw. if it fail, it was not supported by the hw drv for most case. so it is safe to ignore if it fails

svn path=/branches/reactx/; revision=37408
2008-11-17 15:52:02 +00:00
Magnus Olsen
e5c84f2992 remove a comment that is not true.
svn path=/branches/reactx/; revision=37406
2008-11-17 15:01:43 +00:00
Magnus Olsen
39d851edea ported old version of HEL lock surface for ddraw I wrote long time ago. It is not complete and can contain bugs.
svn path=/branches/reactx/; revision=37405
2008-11-17 15:00:28 +00:00
Magnus Olsen
367de0f0a2 1. Fixed one Crash in DdBlt when the Dest was NULL we should return invaild param
2. Move include of pseh header to rosdraw.h
3. Ported partly old code for Hel DdBlt for ddraw
4. Fixed Bug in Hel startup process, but the code is not finish

svn path=/branches/reactx/; revision=37386
2008-11-16 11:04:11 +00:00
Magnus Olsen
b9df9b069d Comment out old test that does not work right yet.
svn path=/branches/reactx/; revision=37377
2008-11-15 17:26:03 +00:00
Magnus Olsen
e9d669603a port a really old test I have for ddraw.dll, this test testing see if the internal value are right when u create the com interface
svn path=/branches/reactx/; revision=37376
2008-11-15 17:00:58 +00:00
Magnus Olsen
4eded7dbcd Bugfix : Do not link to LPDDRAWI_DIRECTDRAW_INT->lpLink when we do not have any LPDDRAWI_DIRECTDRAW_INT->lpLcl
svn path=/branches/reactx/; revision=37343
2008-11-13 19:52:20 +00:00
Magnus Olsen
e874cfdf4b Adding a old test for ddraw, that have lying around for awhile now, small rewrite have been done so it can be compile with reactos
svn path=/branches/reactx/; revision=37337
2008-11-13 09:43:46 +00:00
Magnus Olsen
f021eb65d6 port a really old test I have for ddraw.dll, this test testing see if the internal value are right when u create the com interface
svn path=/branches/reactx/; revision=37312
2008-11-12 18:48:24 +00:00
Magnus Olsen
d6127fcce3 Fix a bug for vista dx. I did have time exam vista for a while now. And it contain the file dxg.sys and it start dx driver almost same way as XP does. and it seam the interface are same.
svn path=/branches/reactx/; revision=37311
2008-11-12 17:53:54 +00:00
Magnus Olsen
634bbe4768 Fix smaller bug in ddraw, This allow our ddraw.dll works with our demo apps in rosapps, The DDRAWILCL_SETCOOPCALLED was wrong checked if it was set or not in Internal_CreateSurface
svn path=/branches/reactx/; revision=37290
2008-11-11 17:37:58 +00:00
Magnus Olsen
fe96f60306 Old code lying around.
Adding more test to NtGdiCreateBitmap

svn path=/branches/reactx/; revision=37257
2008-11-09 13:26:15 +00:00
419 changed files with 31978 additions and 18876 deletions

View File

@@ -1,91 +0,0 @@
Made by Vicmarcal 23/11/08
THIS FILE HELPS TO EXPLAIN HOW REN IS NOW IMPLEMENTED.
****************************************************************
(Please change or add latest modifications)
****************************************************************
Before detailing the Rem code just 3 things:
1)Ren can be used in 3 different ways:
WAY #1:Full Path Way:
ren c:\ie\hello.txt c:\ie\hi.txt
rename command will change the name of hello.txt->hi.txt. We have to be sure that both paths(c:\ie\ ) be the same.Since rename cant move files within Directories (MSDN).
WAY #2:Semi Path Way:
ren c:\ie\hello.txt hi.txt
This is a special feature,since this does the same as Way #1 but without telling the Destiny path.So this feature must be implemented also.
WAY #3: Just file
ren hello.txt hi.txt
So it changes the name of hello.txt in the current directory.
2)Also can be used Wildcards.So be careful ;)
3)Syntax errors:
-Way #1 with different Subdirectories path: ren c:\ie\hello.txt c:\hi\hi.txt, this is not possible.Since ren doesnt move files,just rename them.
-Way #2 semi path in destiny: ren hello.txt c:\ie\hi.txt. This feature isnt available.
**************************************************
Explaining code:
srcPattern: here is stored Source Argument (C:\ie\hello.txt)
srcPath: here is stored Source Path(C:\ie)
srcFILE: here is stored FILE name(hello.txt)
dstPattern: here is stored Destiny Argument (C:\ie\hi.txt)
dstPath: here is stored Destiny Path(C:\i)
dstFILE: here is stored FILE re-name(hi.txt)
1)We begin retrieving arguments from command line and fulffilling dstPattern and srcPattern
2)If srcPattern contains "\" then:
-we activate bPath, since srcPattern has a path inside of it.
-we explit the srcPattern to srcFile and srcPath.
-Now we check the dstPattern <20>does it contain a Path?:
-If does: we divide it in dstPath and dstFile.AND ALSO CHECK THAT dstPath and srcPath it<69>s the same(see syntax error).If they aren the same we launch an error.
-If doesnt then we copy srcPath to dstPath(see #way2) and also saving dstPattern as dstFile.
3)If srcPattern doesnt contain "\" then:
-srcPattern is copied in srcFile(we dont need a previous split,because it<69>s just a name)
-Now we check the dstPattern <20>does it contains a Path?
-If does: we launch an error (see syntax error 2)
-If doesnt: we copy dstPattern to dstFile(we dont need a previous split because it<69>s just a name)
4)Now we are entering in the do...while:
"p" will store a REAL name file(It uses f.cFileName)
Real name file is the name that FindFile returns us.FindFile return NULL if it doesnt find the Source File that we want to rename.And returns the name if finds it.
Do while is used to manage Wildcards.So we can iterate Finding all the files with the Wildcards in it.
But wildcards (? and *) has different behavior so we have to be carefull.
"q" stores the srcFile(this can be a real name file but ALSO A NAME FULL OF WILDCARDS)(p always has a REAL NAME)(This is the most difficult point to understand the code)
"r" is the Name File after aplying the Mask (q)(it<69>s stored in dstLast).
If we are just renaming one file,then we dont make the while loop.The do..while loop is made when some files are renamed: i.e ren *.lol *.rem
5)Now we have to check our Boolean.
bPath==TRUE means that Source Argument was a Path so now we have to Join again the Path with the Name File:
-srcFINAL: srcPath+f.cFileName
-dstFINAL: dstPath+dstFile
bPath==False then Souce wasn a Path an we dont need to join anything.
-srcFINAL:f.cFileName
-dstFINAL:dstFile
At last we just make a MoveFile(srcFinal, dstFinal)):
Also there are a Bunch of Flags (the options)
.It makes the code more difficult to understand.But they are just option flags that show or hides errors,that prevents system files to be renamed...and so.

View File

@@ -141,7 +141,7 @@ dll\directx\quartz\quartz.dll 1
dll\directx\qedit\qedit.dll 1 dll\directx\qedit\qedit.dll 1
dll\directx\wine\d3d8\d3d8.dll 1 dll\directx\wine\d3d8\d3d8.dll 1
dll\directx\wine\wined3d\wined3d.dll 1 dll\directx\wine\wined3d\wined3d.dll 1
dll\directx\wine\d3d9\d3d9.dll 1 dll\directx\d3d9\d3d9.dll 1
dll\keyboard\kbda1\kbda1.dll 1 dll\keyboard\kbda1\kbda1.dll 1
dll\keyboard\kbda2\kbda2.dll 1 dll\keyboard\kbda2\kbda2.dll 1

View File

@@ -85,4 +85,26 @@
--> -->
<property name="_ELF_" value="0" /> <property name="_ELF_" value="0" />
<!--
Activate gdi32.dll DirectX/ReactX OpenGL emulations for ReactX,
this is a exprement and will not fullywork yet, It is not a
replacement for real hardware support for ReactX, It is for
graphice card that does not support DirectX/ReactX hal, if
the graphice card support hardware acclartions of OpenGL
this will take over ReactX/DirectX Hal support or if
the graphice card does not support OpenGL Hardware acclartions
or DirectX/ReactX hardware acclartions ReactOS fallback mesa3D
ICD interface will do the work.
Waring to activate only REACTX_EMU you are force to activate
NSWPAT as well, if we do not have hardware acclartions driver
install for OpenGL, When the graphic card are runing on
Mesa3D you are force to activate NSWPAT as well to support
compress texture (DXT1, DXT2, DXT3, DXT4, DXT5),
other wise REACTX_EMU will not work proper and can not decompress
texture/surface.
-->
<property name="REACTX_EMU" value="1" />
</group> </group>

View File

@@ -6,7 +6,6 @@
* PROGRAMERS: Gregor Brunmar <gregor (dot) brunmar (at) home (dot) se> * PROGRAMERS: Gregor Brunmar <gregor (dot) brunmar (at) home (dot) se>
*/ */
#define _WIN32_WINNT 0x0502
#include "d3d9_common.h" #include "d3d9_common.h"
#include <d3d9.h> #include <d3d9.h>
#include <ddraw.h> #include <ddraw.h>

View File

@@ -102,7 +102,7 @@ Main_DirectDraw_GetCaps( LPDDRAWI_DIRECTDRAW_INT This, LPDDCAPS pDriverCaps,
if (CoreCaps->dwSize == sizeof(DDCORECAPS)) if (CoreCaps->dwSize == sizeof(DDCORECAPS))
{ {
memcpy(&myCaps->dwCaps, &CoreCaps->dwCaps, sizeof(DDCAPS_DX3)); memcpy(myCaps, CoreCaps, sizeof(DDCAPS_DX3));
} }
myCaps->dwVidMemFree = dwFree; myCaps->dwVidMemFree = dwFree;
@@ -127,7 +127,7 @@ Main_DirectDraw_GetCaps( LPDDRAWI_DIRECTDRAW_INT This, LPDDCAPS pDriverCaps,
if (CoreCaps->dwSize == sizeof(DDCORECAPS)) if (CoreCaps->dwSize == sizeof(DDCORECAPS))
{ {
memcpy(&myCaps->dwCaps, &CoreCaps->dwCaps, sizeof(DDCORECAPS)); memcpy(myCaps, CoreCaps, sizeof(DDCORECAPS));
} }
myCaps->dwVidMemFree = dwFree; myCaps->dwVidMemFree = dwFree;
@@ -153,7 +153,7 @@ Main_DirectDraw_GetCaps( LPDDRAWI_DIRECTDRAW_INT This, LPDDCAPS pDriverCaps,
if (CoreCaps->dwSize == sizeof(DDCORECAPS)) if (CoreCaps->dwSize == sizeof(DDCORECAPS))
{ {
memcpy(&myCaps->dwCaps, &CoreCaps->dwCaps, sizeof(DDCORECAPS)); memcpy(myCaps, CoreCaps, sizeof(DDCORECAPS));
} }
myCaps->dwVidMemFree = dwFree; myCaps->dwVidMemFree = dwFree;
@@ -209,7 +209,7 @@ Main_DirectDraw_GetCaps( LPDDRAWI_DIRECTDRAW_INT This, LPDDCAPS pDriverCaps,
if (CoreCaps->dwSize == sizeof(DDCORECAPS)) if (CoreCaps->dwSize == sizeof(DDCORECAPS))
{ {
memcpy(&myCaps->dwCaps, &CoreCaps->dwCaps, sizeof(DDCAPS_DX3)); memcpy(myCaps, CoreCaps, sizeof(DDCAPS_DX3));
} }
myCaps->dwVidMemFree = dwFree; myCaps->dwVidMemFree = dwFree;
@@ -234,7 +234,7 @@ Main_DirectDraw_GetCaps( LPDDRAWI_DIRECTDRAW_INT This, LPDDCAPS pDriverCaps,
if (CoreCaps->dwSize == sizeof(DDCORECAPS)) if (CoreCaps->dwSize == sizeof(DDCORECAPS))
{ {
memcpy(&myCaps->dwCaps, &CoreCaps->dwCaps, sizeof(DDCORECAPS)); memcpy(myCaps, CoreCaps, sizeof(DDCORECAPS));
} }
myCaps->dwVidMemFree = dwFree; myCaps->dwVidMemFree = dwFree;
@@ -260,7 +260,7 @@ Main_DirectDraw_GetCaps( LPDDRAWI_DIRECTDRAW_INT This, LPDDCAPS pDriverCaps,
if (CoreCaps->dwSize == sizeof(DDCORECAPS)) if (CoreCaps->dwSize == sizeof(DDCORECAPS))
{ {
memcpy(&myCaps->dwCaps, &CoreCaps->dwCaps, sizeof(DDCORECAPS)); memcpy(myCaps, CoreCaps, sizeof(DDCORECAPS));
} }
myCaps->dwVidMemFree = dwFree; myCaps->dwVidMemFree = dwFree;

View File

@@ -117,7 +117,7 @@ Main_DirectDraw_QueryInterface (LPDDRAWI_DIRECTDRAW_INT This,
else else
{ {
*obj = NULL; *obj = NULL;
DX_STUB_str("E_NOINTERFACE"); DX_STUB_str("E_NOINTERFACE\n");
retVal = E_NOINTERFACE; retVal = E_NOINTERFACE;
} }
} }
@@ -129,6 +129,19 @@ Main_DirectDraw_QueryInterface (LPDDRAWI_DIRECTDRAW_INT This,
return retVal; return retVal;
} }
/*++
* @name DDraw->AddRef
* @implemented
*
* The function DDraw->AddRef manages all ref counters in the COM object DDraw->
* @return
* Returns the local Ref counter value for the COM object
*
* @remarks.
* none
*
*--*/
ULONG WINAPI ULONG WINAPI
Main_DirectDraw_AddRef (LPDDRAWI_DIRECTDRAW_INT This) Main_DirectDraw_AddRef (LPDDRAWI_DIRECTDRAW_INT This)
{ {
@@ -136,13 +149,20 @@ Main_DirectDraw_AddRef (LPDDRAWI_DIRECTDRAW_INT This)
DX_WINDBG_trace(); DX_WINDBG_trace();
/* Lock the thread */
AcquireDDThreadLock();
_SEH2_TRY _SEH2_TRY
{ {
/* Increment the internal ref counter */
This->dwIntRefCnt++; This->dwIntRefCnt++;
/* Increment the local internal ref counter */
This->lpLcl->dwLocalRefCnt++; This->lpLcl->dwLocalRefCnt++;
if (This->lpLcl->lpGbl != NULL) if (This->lpLcl->lpGbl != NULL)
{ {
/* Increment the gobal internal ref counter */
This->lpLcl->lpGbl->dwRefCnt++; This->lpLcl->lpGbl->dwRefCnt++;
} }
} }
@@ -161,6 +181,10 @@ Main_DirectDraw_AddRef (LPDDRAWI_DIRECTDRAW_INT This)
} }
_SEH2_END; _SEH2_END;
/* Release the thread lock */
ReleaseDDThreadLock();
/* Return the local Ref counter */
return retValue; return retValue;
} }
@@ -173,6 +197,10 @@ Main_DirectDraw_Release (LPDDRAWI_DIRECTDRAW_INT This)
ULONG Counter = 0; ULONG Counter = 0;
DX_WINDBG_trace(); DX_WINDBG_trace();
/* Lock the thread */
AcquireDDThreadLock();
_SEH2_TRY _SEH2_TRY
{ {
if (This!=NULL) if (This!=NULL)
@@ -208,30 +236,47 @@ Main_DirectDraw_Release (LPDDRAWI_DIRECTDRAW_INT This)
{ {
} }
_SEH2_END; _SEH2_END;
/* Release the thread lock */
ReleaseDDThreadLock();
return Counter; return Counter;
} }
HRESULT WINAPI HRESULT WINAPI
Main_DirectDraw_Initialize (LPDDRAWI_DIRECTDRAW_INT This, LPGUID lpGUID) Main_DirectDraw_Initialize (LPDDRAWI_DIRECTDRAW_INT This, LPGUID lpGUID)
{ {
return DDERR_ALREADYINITIALIZED; return DDERR_ALREADYINITIALIZED;
} }
/*
* Main_DirectDraw_Compact /*++
* ms say this one is not implement but it return DDERR_NOEXCLUSIVEMODE * @name DDraw->Compact
* when no exclusive owner are set in corpativelevel * @implemented
*/ *
* In exlusive mode the function DDraw->Compact returns DERR_NOEXCLUSIVEMODE, otherwise it returns DD_OK
*
* @return
* Returns only error code DD_OK or DERR_NOEXCLUSIVEMODE
*
* @remarks.
* Microsoft says Compact is not implemented in ddraw.dll, but it returns DDERR_NOEXCLUSIVEMODE or DD_OK
*
*--*/
HRESULT WINAPI HRESULT WINAPI
Main_DirectDraw_Compact(LPDDRAWI_DIRECTDRAW_INT This) Main_DirectDraw_Compact(LPDDRAWI_DIRECTDRAW_INT This)
{ {
HRESULT retVal = DD_OK; HRESULT retVal = DD_OK;
DX_WINDBG_trace(); DX_WINDBG_trace();
// EnterCriticalSection(&ddcs);
/* Lock the thread */
AcquireDDThreadLock();
_SEH2_TRY _SEH2_TRY
{ {
/* Check if Exclusive mode has been activated */
if (This->lpLcl->lpGbl->lpExclusiveOwner != This->lpLcl) if (This->lpLcl->lpGbl->lpExclusiveOwner != This->lpLcl)
{ {
retVal = DDERR_NOEXCLUSIVEMODE; retVal = DDERR_NOEXCLUSIVEMODE;
@@ -241,7 +286,10 @@ Main_DirectDraw_Compact(LPDDRAWI_DIRECTDRAW_INT This)
{ {
} }
_SEH2_END; _SEH2_END;
// LeaveCriticalSection(&ddcs);
/* Release the thread lock */
ReleaseDDThreadLock();
return retVal; return retVal;
} }
@@ -485,6 +533,9 @@ Main_DirectDraw_CreateSurface4(LPDDRAWI_DIRECTDRAW_INT This, LPDDSURFACEDESC2 pD
} }
_SEH2_END; _SEH2_END;
if(*ppSurf != NULL)
Main_DirectDraw_AddRef(This);
LeaveCriticalSection(&ddcs); LeaveCriticalSection(&ddcs);
return ret; return ret;
} }
@@ -492,11 +543,3 @@ Main_DirectDraw_CreateSurface4(LPDDRAWI_DIRECTDRAW_INT This, LPDDSURFACEDESC2 pD
/* 5 of 31 DirectDraw7_Vtable api are working simluare to windows */ /* 5 of 31 DirectDraw7_Vtable api are working simluare to windows */
/* 8 of 31 DirectDraw7_Vtable api are under devloping / testing */ /* 8 of 31 DirectDraw7_Vtable api are under devloping / testing */

View File

@@ -102,7 +102,7 @@ Main_DirectDraw_SetCooperativeLevel (LPDDRAWI_DIRECTDRAW_INT This, HWND hwnd, DW
_SEH2_LEAVE; _SEH2_LEAVE;
} }
if( (GetWindowLong(hwnd, GWL_STYLE) & WS_CHILD) ) if( (GetWindowLongPtr(hwnd, GWL_STYLE) & WS_CHILD) )
{ {
retVal = DDERR_INVALIDPARAMS; retVal = DDERR_INVALIDPARAMS;
_SEH2_LEAVE; _SEH2_LEAVE;

View File

@@ -0,0 +1,114 @@
/* $Id: palette.c $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS DirectX
* FILE: ddraw/Palette/palette.c
* PURPOSE: IDirectDrawPalette Implementation
* PROGRAMMER: Kamil Hornicek
*
*/
#include "rosdraw.h"
LPDDRAWI_DDRAWPALETTE_INT
internal_directdrawpalette_int_alloc(LPDDRAWI_DDRAWPALETTE_INT This)
{
LPDDRAWI_DDRAWPALETTE_INT newThis;
DxHeapMemAlloc(newThis, sizeof(DDRAWI_DDRAWPALETTE_INT));
if (newThis)
{
newThis->lpLcl = This->lpLcl;
newThis->lpLink = This;
}
return newThis;
}
ULONG WINAPI
Main_DirectDrawPalette_AddRef(LPDIRECTDRAWPALETTE iface)
{
LPDDRAWI_DDRAWPALETTE_INT This = (LPDDRAWI_DDRAWPALETTE_INT)iface;
ULONG ref = 0;
AcquireDDThreadLock();
_SEH2_TRY
{
ref = ++This->dwIntRefCnt;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
}
_SEH2_END
ReleaseDDThreadLock();
return ref;
}
HRESULT WINAPI
Main_DirectDrawPalette_QueryInterface(LPDIRECTDRAWPALETTE iface, REFIID refiid, LPVOID *ppObj)
{
HRESULT retVal = DD_OK;
*ppObj = NULL;
LPDDRAWI_DDRAWPALETTE_INT This = (LPDDRAWI_DDRAWPALETTE_INT) iface;
DX_WINDBG_trace();
_SEH2_TRY
{
if (IsEqualGUID(refiid, &IID_IUnknown) || IsEqualGUID(refiid, &IID_IDirectDrawPalette))
{
if (This->lpVtbl != &DirectDrawPalette_Vtable)
{
This = internal_directdrawpalette_int_alloc(This);
if (!This)
{
retVal = DDERR_OUTOFVIDEOMEMORY;
_SEH2_LEAVE;
}
}
This->lpVtbl = &DirectDrawPalette_Vtable;
*ppObj = This;
Main_DirectDrawPalette_AddRef((LPDIRECTDRAWPALETTE)This);
}
else
{
DX_STUB_str("E_NOINTERFACE\n");
retVal = E_NOINTERFACE;
}
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
}
_SEH2_END;
return retVal;
}
ULONG WINAPI
Main_DirectDrawPalette_Release(LPDIRECTDRAWPALETTE iface)
{
ULONG ref = 0;
LPDDRAWI_DDRAWPALETTE_INT This = (LPDDRAWI_DDRAWPALETTE_INT)iface;
AcquireDDThreadLock();
_SEH2_TRY
{
This->dwIntRefCnt--;
ref = This->dwIntRefCnt;
if(ref == 0)
{
DxHeapMemFree(This);
}
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
}
_SEH2_END
ReleaseDDThreadLock();
return ref;
}

View File

@@ -10,24 +10,8 @@
#include "rosdraw.h" #include "rosdraw.h"
ULONG WINAPI
DirectDrawPalette_Release( LPDIRECTDRAWPALETTE iface)
{
DX_WINDBG_trace();
DX_STUB;
}
ULONG WINAPI
DirectDrawPalette_AddRef( LPDIRECTDRAWPALETTE iface)
{
DX_WINDBG_trace();
DX_STUB;
}
HRESULT WINAPI HRESULT WINAPI
DirectDrawPalette_Initialize( LPDIRECTDRAWPALETTE iface, Main_DirectDrawPalette_Initialize( LPDIRECTDRAWPALETTE iface,
LPDIRECTDRAW ddraw, LPDIRECTDRAW ddraw,
DWORD dwFlags, DWORD dwFlags,
LPPALETTEENTRY palent) LPPALETTEENTRY palent)
@@ -37,7 +21,7 @@ DirectDrawPalette_Initialize( LPDIRECTDRAWPALETTE iface,
} }
HRESULT WINAPI HRESULT WINAPI
DirectDrawPalette_GetEntries( LPDIRECTDRAWPALETTE iface, Main_DirectDrawPalette_GetEntries( LPDIRECTDRAWPALETTE iface,
DWORD dwFlags, DWORD dwFlags,
DWORD dwStart, DWORD dwCount, DWORD dwStart, DWORD dwCount,
LPPALETTEENTRY palent) LPPALETTEENTRY palent)
@@ -47,7 +31,7 @@ DirectDrawPalette_GetEntries( LPDIRECTDRAWPALETTE iface,
} }
HRESULT WINAPI HRESULT WINAPI
DirectDrawPalette_SetEntries( LPDIRECTDRAWPALETTE iface, Main_DirectDrawPalette_SetEntries( LPDIRECTDRAWPALETTE iface,
DWORD dwFlags, DWORD dwFlags,
DWORD dwStart, DWORD dwStart,
DWORD dwCount, DWORD dwCount,
@@ -57,29 +41,9 @@ DirectDrawPalette_SetEntries( LPDIRECTDRAWPALETTE iface,
DX_STUB; DX_STUB;
} }
HRESULT WINAPI HRESULT WINAPI
DirectDrawPalette_GetCaps( LPDIRECTDRAWPALETTE iface, Main_DirectDrawPalette_GetCaps( LPDIRECTDRAWPALETTE iface,
LPDWORD lpdwCaps) LPDWORD lpdwCaps)
{ {
DX_WINDBG_trace(); DX_WINDBG_trace();
DX_STUB; DX_STUB;
} }
HRESULT WINAPI
DirectDrawPalette_QueryInterface( LPDIRECTDRAWPALETTE iface,
REFIID refiid,
LPVOID *obj)
{
DX_WINDBG_trace();
DX_STUB;
}
IDirectDrawPaletteVtbl DirectDrawPalette_Vtable =
{
DirectDrawPalette_QueryInterface,
DirectDrawPalette_AddRef,
DirectDrawPalette_Release,
DirectDrawPalette_GetCaps,
DirectDrawPalette_GetEntries,
DirectDrawPalette_Initialize,
DirectDrawPalette_SetEntries
};

View File

@@ -17,7 +17,31 @@ DWORD CALLBACK HelDdSurfAddAttachedSurface(LPDDHAL_ADDATTACHEDSURFACEDATA lpDest
DWORD CALLBACK HelDdSurfBlt(LPDDHAL_BLTDATA lpBltData) DWORD CALLBACK HelDdSurfBlt(LPDDHAL_BLTDATA lpBltData)
{ {
DX_STUB; DX_WINDBG_trace();
if (lpBltData->dwFlags & DDBLT_COLORFILL)
{
HBRUSH hbr = CreateSolidBrush(lpBltData->bltFX.dwFillColor );
FillRect( (HDC)lpBltData->lpDDDestSurface->lpSurfMore->lpDD_lcl->hDC,
(CONST RECT *)&lpBltData->rDest,
hbr);
DeleteObject(hbr);
lpBltData->ddRVal = DD_OK;
}
else if (lpBltData->dwFlags & DDBLT_ROP)
{
BitBlt( (HDC)lpBltData->lpDDDestSurface->lpSurfMore->lpDD_lcl->hDC,
lpBltData->rDest.top,
lpBltData->rDest.left,
lpBltData->rDest.right,
lpBltData->rDest.bottom,
(HDC)lpBltData->lpDDSrcSurface->lpSurfMore->lpDD_lcl->hDC,
lpBltData->rSrc.top,
lpBltData->rSrc.right,
lpBltData->bltFX.dwROP);
lpBltData->ddRVal = DD_OK;
}
return DDHAL_DRIVER_HANDLED;
} }
DWORD CALLBACK HelDdSurfDestroySurface(LPDDHAL_DESTROYSURFACEDATA lpDestroySurfaceData) DWORD CALLBACK HelDdSurfDestroySurface(LPDDHAL_DESTROYSURFACEDATA lpDestroySurfaceData)
@@ -42,17 +66,105 @@ DWORD CALLBACK HelDdSurfGetFlipStatus(LPDDHAL_GETFLIPSTATUSDATA lpGetFlipStatusD
DWORD CALLBACK HelDdSurfLock(LPDDHAL_LOCKDATA lpLockData) DWORD CALLBACK HelDdSurfLock(LPDDHAL_LOCKDATA lpLockData)
{ {
DX_STUB;
}
HDC hDC;
HBITMAP hImage = NULL;
LONG cbBuffer = 0;
LPDWORD pixels = NULL;
HDC hMemDC = NULL;
HBITMAP hDCBmp = NULL;
BITMAP bm = {0};
DX_WINDBG_trace();
/* ToDo tell ddraw internal this surface is locked */
/* ToDo add support for dwFlags */
/* Get our hdc for the active window */
hDC = GetDC((HWND)lpLockData->lpDDSurface->lpSurfMore->lpDD_lcl->hFocusWnd);
if (hDC != NULL)
{
/* Create a memory bitmap to store a copy of current hdc surface */
if (!lpLockData->bHasRect)
{
hImage = CreateCompatibleBitmap (hDC, lpLockData->lpDDSurface->lpGbl->wWidth, lpLockData->lpDDSurface->lpGbl->wHeight);
}
else
{
hImage = CreateCompatibleBitmap (hDC, lpLockData->rArea.right, lpLockData->rArea.bottom);
}
/* Create a memory hdc so we can draw on our current memory bitmap */
hMemDC = CreateCompatibleDC(hDC);
if (hMemDC != NULL)
{
/* Select our memory bitmap to our memory hdc */
hDCBmp = (HBITMAP) SelectObject (hMemDC, hImage);
/* Get our memory bitmap information */
GetObject(hImage, sizeof(BITMAP), &bm);
if (!lpLockData->bHasRect)
{
BitBlt (hMemDC, 0, 0, bm.bmWidth, bm.bmHeight, hDC, 0, 0, SRCCOPY);
}
else
{
BitBlt (hMemDC, lpLockData->rArea.top, lpLockData->rArea.left, lpLockData->rArea.right, lpLockData->rArea.bottom, hDC, 0, 0, SRCCOPY);
}
SelectObject (hMemDC, hDCBmp);
/* Allocate memory buffer for the bitmap pixel data */
cbBuffer = bm.bmWidthBytes * bm.bmHeight ;
pixels = (PDWORD) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cbBuffer );
if (pixels != NULL)
{
/* Get the bitmap bits */
GetBitmapBits(hImage,cbBuffer,pixels);
/* Fixme HACK - check which member stores the HEL bitmap buffer */
lpLockData->lpDDSurface->lpSurfMore->lpDDRAWReserved2 = pixels;
/* Setup return value */
lpLockData->ddRVal = DD_OK;
lpLockData->lpSurfData = pixels;
}
}
}
/* Free the pixels buffer if we fail */
if ( (pixels != NULL) &&
(lpLockData->ddRVal != DD_OK) )
{
HeapFree(GetProcessHeap(), 0, pixels );
}
/* Cleanup after us */
if (hImage != NULL)
{
DeleteObject (hImage);
}
if (hMemDC != NULL)
{
DeleteDC (hMemDC);
}
return DDHAL_DRIVER_HANDLED;
}
DWORD CALLBACK HelDdSurfreserved4(DWORD *lpPtr) DWORD CALLBACK HelDdSurfreserved4(DWORD *lpPtr)
{ {
/* /* This api is not doucmented by MS, keep it stubbed */
This api is not doucment by MS So I leave it
as stub.
*/
DX_STUB; DX_STUB;
} }
@@ -78,7 +190,64 @@ DWORD CALLBACK HelDdSurfSetPalette(LPDDHAL_SETPALETTEDATA lpSetPaletteData)
DWORD CALLBACK HelDdSurfUnlock(LPDDHAL_UNLOCKDATA lpUnLockData) DWORD CALLBACK HelDdSurfUnlock(LPDDHAL_UNLOCKDATA lpUnLockData)
{ {
DX_STUB; HDC hDC;
HBITMAP hImage = NULL;
HDC hMemDC = NULL;
HBITMAP hDCBmp = NULL;
BITMAP bm = {0};
DX_WINDBG_trace();
/* Get our hdc for the active window */
hDC = GetDC((HWND)lpUnLockData->lpDDSurface->lpSurfMore->lpDD_lcl->hFocusWnd);
if (hDC != NULL)
{
/* Create a memory bitmap to store a copy of current hdc surface */
/* fixme the rcarea are not store in the struct yet so the data will look corupted */
hImage = CreateCompatibleBitmap (hDC, lpUnLockData->lpDDSurface->lpGbl->wWidth, lpUnLockData->lpDDSurface->lpGbl->wHeight);
/* Create a memory hdc so we can draw on our current memory bitmap */
hMemDC = CreateCompatibleDC(hDC);
if (hMemDC != NULL)
{
/* Select our memory bitmap to our memory hdc */
hDCBmp = (HBITMAP) SelectObject (hMemDC, hImage);
/* Get our memory bitmap information */
GetObject(hImage, sizeof(BITMAP), &bm);
SetBitmapBits(hImage,bm.bmWidthBytes * bm.bmHeight, lpUnLockData->lpDDSurface->lpSurfMore->lpDDRAWReserved2);
BitBlt (hDC, 0, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
SelectObject (hMemDC, hDCBmp);
/* Setup return value */
lpUnLockData->ddRVal = DD_OK;
}
}
/* Cleanup after us */
if (hImage != NULL)
{
DeleteObject (hImage);
}
if (hMemDC != NULL)
{
DeleteDC (hMemDC);
}
if (lpUnLockData->lpDDSurface->lpSurfMore->lpDDRAWReserved2 != NULL)
{
HeapFree(GetProcessHeap(), 0, lpUnLockData->lpDDSurface->lpSurfMore->lpDDRAWReserved2 );
}
return DDHAL_DRIVER_HANDLED;
} }
DWORD CALLBACK HelDdSurfUpdateOverlay(LPDDHAL_UPDATEOVERLAYDATA lpUpDateOveryLayData) DWORD CALLBACK HelDdSurfUpdateOverlay(LPDDHAL_UPDATEOVERLAYDATA lpUpDateOveryLayData)

View File

@@ -35,7 +35,7 @@ Internal_CreateSurface( LPDDRAWI_DIRECTDRAW_INT pDDraw, LPDDSURFACEDESC2 pDDSD,
DWORD count; DWORD count;
HRESULT ret; HRESULT ret;
if(pDDraw->lpLcl->dwLocalFlags != DDRAWILCL_SETCOOPCALLED) if((pDDraw->lpLcl->dwLocalFlags & DDRAWILCL_SETCOOPCALLED) != DDRAWILCL_SETCOOPCALLED)
{ {
return DDERR_NOCOOPERATIVELEVELSET; return DDERR_NOCOOPERATIVELEVELSET;
} }
@@ -45,7 +45,7 @@ Internal_CreateSurface( LPDDRAWI_DIRECTDRAW_INT pDDraw, LPDDSURFACEDESC2 pDDSD,
return CLASS_E_NOAGGREGATION; return CLASS_E_NOAGGREGATION;
} }
if(!pDDSD->dwFlags & DDSD_CAPS) if(!(pDDSD->dwFlags & DDSD_CAPS))
{ {
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
} }
@@ -60,14 +60,14 @@ Internal_CreateSurface( LPDDRAWI_DIRECTDRAW_INT pDDraw, LPDDSURFACEDESC2 pDDSD,
return DDERR_INVALIDCAPS; return DDERR_INVALIDCAPS;
} }
if(!(pDDSD->dwFlags & DDSD_HEIGHT) && !(pDDSD->dwFlags & DDSD_HEIGHT) if((!(pDDSD->dwFlags & DDSD_HEIGHT) || !(pDDSD->dwFlags & DDSD_WIDTH))
&& !(pDDSD->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)) && !(pDDSD->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
{ {
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
} }
else if(pDDSD->dwFlags & DDSD_HEIGHT && pDDSD->dwFlags & DDSD_HEIGHT else if(((pDDSD->dwFlags & DDSD_HEIGHT) || (pDDSD->dwFlags & DDSD_WIDTH))
&& pDDSD->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) && (pDDSD->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
{ {
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
} }

View File

@@ -264,137 +264,189 @@ Main_DDrawSurface_QueryInterface(LPDDRAWI_DDRAWSURFACE_INT This, REFIID riid, LP
ULONG WINAPI Main_DDrawSurface_Release(LPDDRAWI_DDRAWSURFACE_INT This) ULONG WINAPI Main_DDrawSurface_Release(LPDDRAWI_DDRAWSURFACE_INT This)
{ {
ULONG ref = 0;
/* FIXME AcquireDDThreadLock();
This is not right exiame how it should be done
*/ _SEH2_TRY
DX_STUB_str("FIXME This is not right exiame how it should be done\n"); {
return This->dwIntRefCnt; This->dwIntRefCnt--;
ref = This->dwIntRefCnt;
if(!ref)
{
DxHeapMemFree(This);
}
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
}
_SEH2_END
ReleaseDDThreadLock();
return ref;
} }
HRESULT WINAPI Main_DDrawSurface_Blt(LPDDRAWI_DDRAWSURFACE_INT ThisDest, LPRECT rdst, HRESULT WINAPI Main_DDrawSurface_Blt(LPDDRAWI_DDRAWSURFACE_INT ThisDest, LPRECT rdst,
LPDDRAWI_DDRAWSURFACE_INT ThisSrc, LPRECT rsrc, DWORD dwFlags, LPDDBLTFX lpbltfx) LPDDRAWI_DDRAWSURFACE_INT ThisSrc, LPRECT rsrc, DWORD dwFlags, LPDDBLTFX lpbltfx)
{ {
DDHAL_BLTDATA mDdBlt;
DDHAL_BLTDATA mDdBlt; DX_WINDBG_trace();
DX_WINDBG_trace(); if (ThisDest == NULL)
{
return DDERR_INVALIDPARAMS;
}
if (( ThisDest->lpLcl->lpGbl->lpDD->lpDDCBtmp->HALDDSurface.dwFlags /* Zero out members in DDHAL_BLTDATA */
& DDHAL_SURFCB32_BLT) != DDHAL_SURFCB32_BLT) ZeroMemory(&mDdBlt, sizeof(DDHAL_BLTDATA));
{ ZeroMemory(&mDdBlt.bltFX, sizeof(DDBLTFX));
return DDERR_GENERIC;
}
ZeroMemory(&mDdBlt, sizeof(DDHAL_BLTDATA)); /* Check if we got HAL support for this api */
ZeroMemory(&mDdBlt.bltFX, sizeof(DDBLTFX)); if (( ThisDest->lpLcl->lpGbl->lpDD->lpDDCBtmp->HALDDSurface.dwFlags &
DDHAL_SURFCB32_BLT) == DDHAL_SURFCB32_BLT)
{
mDdBlt.Blt = ThisDest->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HALDDSurface.Blt;
}
/* Check if we got HEL support for this api */
else if (( ThisDest->lpLcl->lpGbl->lpDD->lpDDCBtmp->HELDDSurface.dwFlags &
DDHAL_SURFCB32_BLT) == DDHAL_SURFCB32_BLT)
{
mDdBlt.Blt = ThisDest->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HELDDSurface.Blt;
}
if (!DdResetVisrgn( ThisDest->lpLcl->lpSurfMore->slist[0], NULL)) if (mDdBlt.Blt == NULL)
{ {
DX_STUB_str("DdResetVisrgn failed"); /* This API is unsupported */
} return DDERR_UNSUPPORTED;
}
mDdBlt.lpDD = ThisDest->lpLcl->lpSurfMore->lpDD_lcl->lpGbl; /* Prepare for draw, if we do not reset the DdResetVisrgn some graphics card will not draw on the screen */
mDdBlt.Blt = ThisDest->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HALDDSurface.Blt; if (!DdResetVisrgn( ThisDest->lpLcl->lpSurfMore->slist[0], NULL))
mDdBlt.lpDDDestSurface = ThisDest->lpLcl->lpSurfMore->slist[0]; {
DX_STUB_str("DdResetVisrgn failed");
}
ThisDest->lpLcl->lpSurfMore->slist[0]->hDC = mDdBlt.lpDD = ThisDest->lpLcl->lpSurfMore->lpDD_lcl->lpGbl;
ThisDest->lpLcl->lpSurfMore->lpDD_lcl->hDC; mDdBlt.lpDDDestSurface = ThisDest->lpLcl->lpSurfMore->slist[0];
ThisDest->lpLcl->lpSurfMore->slist[0]->hDC = ThisDest->lpLcl->lpSurfMore->lpDD_lcl->hDC;
/* Setup Src */ /* Setup Src */
if (ThisSrc != NULL) if (( ThisSrc != NULL ) )
{ {
mDdBlt.lpDDSrcSurface = ThisSrc->lpLcl->lpSurfMore->slist[0];
ThisSrc->lpLcl->lpSurfMore->slist[0]->hDC = mDdBlt.lpDDSrcSurface = ThisSrc->lpLcl->lpSurfMore->slist[0];
ThisSrc->lpLcl->lpSurfMore->lpDD_lcl->hDC; ThisSrc->lpLcl->lpSurfMore->slist[0]->hDC = ThisSrc->lpLcl->lpSurfMore->lpDD_lcl->hDC;
if (rsrc != NULL) if (rsrc != NULL)
{ {
memmove(&mDdBlt.rSrc, rsrc, sizeof (RECTL)); memmove(&mDdBlt.rSrc, rsrc, sizeof (RECTL));
} }
else else
{ {
if(!GetWindowRect((HWND)ThisSrc->lpLcl->lpSurfMore->lpDD_lcl->hWnd, if(!GetWindowRect((HWND)ThisSrc->lpLcl->lpSurfMore->lpDD_lcl->hWnd,
(RECT *)&mDdBlt.rSrc)) (RECT *)&mDdBlt.rSrc))
{ {
DX_STUB_str("GetWindowRect failed"); DX_STUB_str("GetWindowRect failed");
} }
} }
/* FIXME /* FIXME
* compare so we do not write to far * compare so we do not write too far
* ThisDest->lpLcl->lpGbl->wWidth; <- surface max width * ThisDest->lpLcl->lpGbl->wWidth; <- surface max width
* ThisDest->lpLcl->lpGbl->wHeight <- surface max heght * ThisDest->lpLcl->lpGbl->wHeight <- surface max heght
* ThisDest->lpLcl->lpGbl->lPitch <- surface bpp * ThisDest->lpLcl->lpGbl->lPitch <- surface bpp
*/ */
} }
/* Setup dest */ /* Setup dest */
if (rdst != NULL) if (rdst != NULL)
{ {
memmove(&mDdBlt.rDest, rdst, sizeof (RECTL)); memmove(&mDdBlt.rDest, rdst, sizeof (RECTL));
} }
else else
{ {
if(!GetWindowRect((HWND)ThisDest->lpLcl->lpSurfMore->lpDD_lcl->hWnd, if (!GetWindowRect((HWND)ThisDest->lpLcl->lpSurfMore->lpDD_lcl->hWnd,
(RECT *)&mDdBlt.rDest)) (RECT *)&mDdBlt.rDest))
{ {
DX_STUB_str("GetWindowRect failed"); DX_STUB_str("GetWindowRect failed");
} }
}
} /* FIXME
* compare so we do not write too far
/* FIXME * ThisDest->lpLcl->lpGbl->wWidth; <- surface max width
* compare so we do not write to far * ThisDest->lpLcl->lpGbl->wHeight <- surface max heght
* ThisDest->lpLcl->lpGbl->wWidth; <- surface max width * ThisDest->lpLcl->lpGbl->lPitch <- surface bpp
* ThisDest->lpLcl->lpGbl->wHeight <- surface max heght */
* ThisDest->lpLcl->lpGbl->lPitch <- surface bpp
*/
/* setup bltFX */ /* setup bltFX */
if (lpbltfx != NULL) if (lpbltfx != NULL)
{ {
memmove(&mDdBlt.bltFX, lpbltfx, sizeof (DDBLTFX)); memmove(&mDdBlt.bltFX, lpbltfx, sizeof (DDBLTFX));
} }
/* setup value that are not config yet */ /* setup value that are not config yet */
mDdBlt.dwFlags = dwFlags; mDdBlt.dwFlags = dwFlags;
mDdBlt.IsClipped = FALSE; mDdBlt.IsClipped = FALSE;
mDdBlt.bltFX.dwSize = sizeof(DDBLTFX); mDdBlt.bltFX.dwSize = sizeof(DDBLTFX);
/* FIXME /* FIXME
BltData.dwRectCnt BltData.dwRectCnt
BltData.dwROPFlags BltData.dwROPFlags
BltData.IsClipped BltData.IsClipped
BltData.prDestRects BltData.prDestRects
BltData.rOrigDest BltData.rOrigDest
BltData.rOrigSrc BltData.rOrigSrc
BltData.ddRVal BltData.ddRVal
*/ */
if (mDdBlt.Blt(&mDdBlt) != DDHAL_DRIVER_HANDLED) if (mDdBlt.Blt(&mDdBlt) != DDHAL_DRIVER_HANDLED)
{ {
DX_STUB_str("mDdBlt DDHAL_DRIVER_HANDLED"); DX_STUB_str("mDdBlt DDHAL_DRIVER_HANDLED");
return DDERR_NOBLTHW; return DDERR_NOBLTHW;
} }
return mDdBlt.ddRVal; return mDdBlt.ddRVal;
} }
HRESULT WINAPI HRESULT WINAPI
Main_DDrawSurface_Lock (LPDDRAWI_DDRAWSURFACE_INT This, LPRECT prect, Main_DDrawSurface_Lock (LPDDRAWI_DDRAWSURFACE_INT ThisDest, LPRECT prect,
LPDDSURFACEDESC2 pDDSD, DWORD flags, HANDLE events) LPDDSURFACEDESC2 pDDSD, DWORD flags, HANDLE events)
{ {
DDHAL_LOCKDATA mdLock; DDHAL_LOCKDATA mdLock;
DX_WINDBG_trace(); DX_WINDBG_trace();
DX_WINDBG_trace_res( (DWORD)This->lpLcl->lpGbl->wWidth, (DWORD)This->lpLcl->lpGbl->wHeight, (DWORD)This->lpLcl->lpGbl->lPitch, (DWORD) 0); DX_WINDBG_trace_res( (DWORD)ThisDest->lpLcl->lpGbl->wWidth, (DWORD)ThisDest->lpLcl->lpGbl->wHeight, (DWORD)ThisDest->lpLcl->lpGbl->lPitch, (DWORD) 0);
/* Zero out members in DDHAL_LOCKDATA */
ZeroMemory(&mdLock, sizeof(DDHAL_LOCKDATA));
/* Check if we got HAL support for this api */
if (( ThisDest->lpLcl->lpGbl->lpDD->lpDDCBtmp->HALDDSurface.dwFlags &
DDHAL_SURFCB32_LOCK) == DDHAL_SURFCB32_LOCK)
{
mdLock.Lock = ThisDest->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HALDDSurface.Lock;
}
/* Check if we got HEL support for this api */
else if (( ThisDest->lpLcl->lpGbl->lpDD->lpDDCBtmp->HELDDSurface.dwFlags &
DDHAL_SURFCB32_LOCK) == DDHAL_SURFCB32_LOCK)
{
mdLock.Lock = ThisDest->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HELDDSurface.Lock;
}
if (mdLock.Lock == NULL)
{
/* This api are unsupported */
return DDERR_UNSUPPORTED;
}
if (events != NULL) if (events != NULL)
{ {
@@ -415,21 +467,19 @@ Main_DDrawSurface_Lock (LPDDRAWI_DDRAWSURFACE_INT This, LPRECT prect,
//FIXME check if it primary or not and use primary or pixelformat data, at moment it is hardcode to primary //FIXME check if it primary or not and use primary or pixelformat data, at moment it is hardcode to primary
mdLock.ddRVal = DDERR_NOTPALETTIZED; mdLock.ddRVal = DDERR_CANTLOCKSURFACE;
mdLock.Lock = This->lpLcl->lpSurfMore->lpDD_lcl->lpDDCB->HALDDSurface.Lock;
mdLock.dwFlags = flags; mdLock.dwFlags = flags;
mdLock.lpDDSurface = This->lpLcl->lpSurfMore->slist[0]; mdLock.lpDDSurface = ThisDest->lpLcl->lpSurfMore->slist[0];
mdLock.lpDD = This->lpLcl->lpSurfMore->lpDD_lcl->lpGbl; mdLock.lpDD = ThisDest->lpLcl->lpSurfMore->lpDD_lcl->lpGbl;
mdLock.lpSurfData = NULL; mdLock.lpSurfData = NULL;
if (!DdResetVisrgn(This->lpLcl->lpSurfMore->slist[0], NULL)) if (!DdResetVisrgn(ThisDest->lpLcl->lpSurfMore->slist[0], NULL))
{ {
DX_STUB_str("Here DdResetVisrgn lock"); DX_STUB_str("Here DdResetVisrgn lock");
return DDERR_UNSUPPORTED; // return DDERR_UNSUPPORTED;
} }
if (mdLock.Lock(&mdLock)!= DDHAL_DRIVER_HANDLED) if (mdLock.Lock(&mdLock)!= DDHAL_DRIVER_HANDLED)
{ {
DX_STUB_str("Here DDHAL_DRIVER_HANDLED lock"); DX_STUB_str("Here DDHAL_DRIVER_HANDLED lock");
@@ -460,11 +510,11 @@ Main_DDrawSurface_Lock (LPDDRAWI_DDRAWSURFACE_INT This, LPRECT prect,
pDDSD->lpSurface = (LPVOID) mdLock.lpSurfData; pDDSD->lpSurface = (LPVOID) mdLock.lpSurfData;
pDDSD->dwHeight = This->lpLcl->lpGbl->wHeight; pDDSD->dwHeight = ThisDest->lpLcl->lpGbl->wHeight;
pDDSD->dwWidth = This->lpLcl->lpGbl->wWidth; pDDSD->dwWidth = ThisDest->lpLcl->lpGbl->wWidth;
pDDSD->ddpfPixelFormat.dwRGBBitCount = This->lpLcl->lpGbl->lpDD->lpModeInfo->dwBPP;// .lpModeInfo->dwBPP; //This->lpLcl->lpGbl->lPitch/ 8; pDDSD->ddpfPixelFormat.dwRGBBitCount = ThisDest->lpLcl->lpGbl->lpDD->lpModeInfo->dwBPP;// .lpModeInfo->dwBPP; //This->lpLcl->lpGbl->lPitch/ 8;
pDDSD->lPitch = This->lpLcl->lpGbl->lPitch; pDDSD->lPitch = ThisDest->lpLcl->lpGbl->lPitch;
pDDSD->dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH; pDDSD->dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PITCH;
} }
@@ -474,30 +524,45 @@ Main_DDrawSurface_Lock (LPDDRAWI_DDRAWSURFACE_INT This, LPRECT prect,
HRESULT WINAPI Main_DDrawSurface_Unlock (LPDDRAWI_DDRAWSURFACE_INT This, LPRECT pRect) HRESULT WINAPI Main_DDrawSurface_Unlock (LPDDRAWI_DDRAWSURFACE_INT This, LPRECT pRect)
{ {
DDHAL_UNLOCKDATA mdUnLock; DDHAL_UNLOCKDATA mdUnLock;
DX_WINDBG_trace(); DX_WINDBG_trace();
if (!This->lpLcl->lpSurfMore->lpDD_lcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags & DDHAL_SURFCB32_UNLOCK) /* Zero out members in DDHAL_UNLOCKDATA */
{ ZeroMemory(&mdUnLock, sizeof(DDHAL_UNLOCKDATA));
DX_STUB_str("DDERR_UNSUPPORTED");
return DDERR_UNSUPPORTED; /* Check if we got HAL support for this api */
} if (( This->lpLcl->lpGbl->lpDD->lpDDCBtmp->HALDDSurface.dwFlags &
DDHAL_SURFCB32_UNLOCK) == DDHAL_SURFCB32_UNLOCK)
{
mdUnLock.Unlock = This->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HALDDSurface.Unlock;
}
/* Check if we got HEL support for this api */
else if (( This->lpLcl->lpGbl->lpDD->lpDDCBtmp->HELDDSurface.dwFlags &
DDHAL_SURFCB32_UNLOCK) == DDHAL_SURFCB32_UNLOCK)
{
mdUnLock.Unlock = This->lpLcl->lpSurfMore->lpDD_lcl->lpGbl->lpDDCBtmp->HELDDSurface.Unlock;
}
if (mdUnLock.Unlock == NULL)
{
/* This api are unsupported */
return DDERR_UNSUPPORTED;
}
mdUnLock.ddRVal = DDERR_NOTPALETTIZED; mdUnLock.ddRVal = DDERR_NOTPALETTIZED;
mdUnLock.lpDD = This->lpLcl->lpSurfMore->lpDD_lcl->lpGbl; mdUnLock.lpDD = This->lpLcl->lpSurfMore->lpDD_lcl->lpGbl;
mdUnLock.lpDDSurface = This->lpLcl->lpSurfMore->slist[0]; mdUnLock.lpDDSurface = This->lpLcl->lpSurfMore->slist[0];
mdUnLock.Unlock = This->lpLcl->lpSurfMore->lpDD_lcl->lpDDCB->HALDDSurface.Unlock;
if (!DdResetVisrgn( mdUnLock.lpDDSurface, NULL)) if (!DdResetVisrgn( mdUnLock.lpDDSurface, NULL))
{ {
DX_STUB_str("DDERR_UNSUPPORTED"); DX_STUB_str("DdResetVisrgn fail");
return DDERR_UNSUPPORTED; //return DDERR_UNSUPPORTED; /* this can fail */
} }
if (mdUnLock.Unlock(&mdUnLock)!= DDHAL_DRIVER_HANDLED) if (mdUnLock.Unlock(&mdUnLock)!= DDHAL_DRIVER_HANDLED)
{ {
DX_STUB_str("unLock fail"); DX_STUB_str("unLock fail");
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
@@ -539,7 +604,7 @@ Main_DDrawSurface_GetBltStatus(LPDDRAWI_DDRAWSURFACE_INT This, DWORD dwFlags)
DX_WINDBG_trace(); DX_WINDBG_trace();
if (!This->lpLcl->lpGbl->lpDD->lpDDCBtmp->cbDDSurfaceCallbacks.dwFlags & DDHAL_SURFCB32_FLIP) if (!(This->lpLcl->lpGbl->lpDD->lpDDCBtmp->cbDDSurfaceCallbacks.dwFlags & DDHAL_SURFCB32_FLIP))
{ {
return DDERR_GENERIC; return DDERR_GENERIC;
} }

View File

@@ -260,7 +260,7 @@ Main_DDrawSurface_UpdateOverlayDisplay (LPDDRAWI_DDRAWSURFACE_INT This,
DX_WINDBG_trace(); DX_WINDBG_trace();
if (!This->lpLcl->lpGbl->lpDD->lpDDCBtmp->cbDDSurfaceCallbacks.dwFlags & DDHAL_SURFCB32_UPDATEOVERLAY) if (!(This->lpLcl->lpGbl->lpDD->lpDDCBtmp->cbDDSurfaceCallbacks.dwFlags & DDHAL_SURFCB32_UPDATEOVERLAY))
{ {
return DDERR_GENERIC; return DDERR_GENERIC;
} }

View File

@@ -0,0 +1,36 @@
#include <windows.h>
#include <stdio.h>
#include <ddraw.h>
#include <ddrawi.h>
#include <d3dhal.h>
#include <ddrawgdi.h>
#if defined(_WIN32) && !defined(_NO_COM )
#define COM_NO_WINDOWS_H
#include <objbase.h>
#else
#define IUnknown void
#if !defined(NT_BUILD_ENVIRONMENT) && !defined(WINNT)
#define CO_E_NOTINITIALIZED 0x800401F0
#endif
#endif
ULONG WINAPI Main_DirectDrawPalette_Release(LPDIRECTDRAWPALETTE iface);
ULONG WINAPI Main_DirectDrawPalette_AddRef(LPDIRECTDRAWPALETTE iface);
HRESULT WINAPI Main_DirectDrawPalette_Initialize(LPDIRECTDRAWPALETTE iface, LPDIRECTDRAW ddraw, DWORD dwFlags, LPPALETTEENTRY palent);
HRESULT WINAPI Main_DirectDrawPalette_GetEntries(LPDIRECTDRAWPALETTE iface, DWORD dwFlags, DWORD dwStart, DWORD dwCount, LPPALETTEENTRY palent);
HRESULT WINAPI Main_DirectDrawPalette_SetEntries(LPDIRECTDRAWPALETTE iface, DWORD dwFlags, DWORD dwStart, DWORD dwCount, LPPALETTEENTRY palent);
HRESULT WINAPI Main_DirectDrawPalette_GetCaps(LPDIRECTDRAWPALETTE iface, LPDWORD lpdwCaps);
HRESULT WINAPI Main_DirectDrawPalette_QueryInterface(LPDIRECTDRAWPALETTE iface, REFIID refiid, LPVOID *obj);
IDirectDrawPaletteVtbl DirectDrawPalette_Vtable =
{
Main_DirectDrawPalette_QueryInterface,
Main_DirectDrawPalette_AddRef,
Main_DirectDrawPalette_Release,
Main_DirectDrawPalette_GetCaps,
Main_DirectDrawPalette_GetEntries,
Main_DirectDrawPalette_Initialize,
Main_DirectDrawPalette_SetEntries
};

View File

@@ -1,23 +0,0 @@
EXPORTS
AcquireDDThreadLock@0
D3DParseUnknownCommand@8
ReleaseDDThreadLock@0
;CompleteCreateSysmemSurface
;DDGetAttachedSurfaceLcl@12
;DDInternalLock@8
;DDInternalUnlock@4
;DSoundHelp@12
DirectDrawCreate@12
DirectDrawCreateClipper@12
DirectDrawCreateEx@16
DirectDrawEnumerateA@8
DirectDrawEnumerateW@8
DirectDrawEnumerateExA@12
DirectDrawEnumerateExW@12
;DllCanUnloadNow
;DllGetClassObject
;GetDDSurfaceLocal@12
;GetOLEThunkData
;GetSurfaceFromDC@12
;RegisterSpecialCase

View File

@@ -1,7 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd"> <!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
<module name="ddraw" type="win32dll" installbase="system32" installname="ddraw.dll" allowwarnings ="true" unicode="yes"> <module name="ddraw" type="win32dll" installbase="system32" installname="ddraw.dll" unicode="yes" crt="msvcrt">
<importlibrary definition="ddraw.def" /> <importlibrary definition="ddraw.spec" />
<include base="ddraw">.</include> <include base="ddraw">.</include>
<library>kernel32</library> <library>kernel32</library>
<library>user32</library> <library>user32</library>
@@ -9,7 +9,7 @@
<library>d3d8thk</library> <library>d3d8thk</library>
<library>dxguid</library> <library>dxguid</library>
<library>ole32</library> <library>ole32</library>
<library>user32</library> <library>uuid</library>
<library>advapi32</library> <library>advapi32</library>
<library>pseh</library> <library>pseh</library>
@@ -50,6 +50,7 @@
<file>kernel_stubs.c</file> <file>kernel_stubs.c</file>
</directory> </directory>
<directory name="Palette"> <directory name="Palette">
<file>palette_main.c</file>
<file>palette_stubs.c</file> <file>palette_stubs.c</file>
</directory> </directory>
<directory name="Videoport"> <directory name="Videoport">
@@ -60,6 +61,7 @@
<file>DirectDraw4_Vtable.c</file> <file>DirectDraw4_Vtable.c</file>
<file>DirectDraw2_Vtable.c</file> <file>DirectDraw2_Vtable.c</file>
<file>DirectDraw_Vtable.c</file> <file>DirectDraw_Vtable.c</file>
<file>DirectDrawPalette_Vtable.c</file>
<file>DirectDrawSurface7_Vtable.c</file> <file>DirectDrawSurface7_Vtable.c</file>
<file>DirectDrawSurface4_Vtable.c</file> <file>DirectDrawSurface4_Vtable.c</file>
<file>DirectDrawSurface3_Vtable.c</file> <file>DirectDrawSurface3_Vtable.c</file>
@@ -71,5 +73,5 @@
<file>DirectD3D7_Vtable.c</file> <file>DirectD3D7_Vtable.c</file>
</directory> </directory>
<!-- See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38054#c7 --> <!-- See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38054#c7 -->
<compilerflag>-fno-unit-at-a-time</compilerflag> <compilerflag compilerset="gcc">-fno-unit-at-a-time</compilerflag>
</module> </module>

View File

@@ -0,0 +1,21 @@
@ stdcall AcquireDDThreadLock()
@ stdcall D3DParseUnknownCommand(ptr ptr)
@ stdcall ReleaseDDThreadLock()
#@ stdcall CompleteCreateSysmemSurface
#@ stdcall DDGetAttachedSurfaceLcl@12
#@ stdcall DDInternalLock@8
#@ stdcall DDInternalUnlock@4
#@ stdcall DSoundHelp@12
@ stdcall DirectDrawCreate(ptr ptr ptr)
@ stdcall DirectDrawCreateClipper(long ptr ptr)
@ stdcall DirectDrawCreateEx(ptr ptr ptr ptr)
@ stdcall DirectDrawEnumerateA(ptr ptr)
@ stdcall DirectDrawEnumerateW(ptr ptr)
@ stdcall DirectDrawEnumerateExA(ptr ptr long)
@ stdcall DirectDrawEnumerateExW(ptr ptr long)
#@ stdcall DllCanUnloadNow()
#@ stdcall DllGetClassObject(ptr ptr ptr)
#@ stdcall GetDDSurfaceLocal
#@ stdcall GetOLEThunkData
#@ stdcall GetSurfaceFromDC
#@ stdcall RegisterSpecialCase

View File

@@ -8,6 +8,7 @@
#include <ddrawi.h> #include <ddrawi.h>
#include <d3dhal.h> #include <d3dhal.h>
#include <ddrawgdi.h> #include <ddrawgdi.h>
#include <pseh/pseh.h>
#include <pseh/pseh2.h> #include <pseh/pseh2.h>

View File

@@ -33,8 +33,8 @@ Create_DirectDraw (LPGUID pGUID, LPDIRECTDRAW* pIface,
This = (LPDDRAWI_DIRECTDRAW_INT)*pIface; This = (LPDDRAWI_DIRECTDRAW_INT)*pIface;
/* fixme linking too second link when we shall not doing it */ if ( (IsBadWritePtr(This,sizeof(LPDDRAWI_DIRECTDRAW_INT)) != 0) ||
if (IsBadReadPtr(This,sizeof(LPDIRECTDRAW))) (IsBadWritePtr(This->lpLcl,sizeof(LPDDRAWI_DIRECTDRAW_LCL)) != 0) )
{ {
/* We do not have a DirectDraw interface, we need alloc it*/ /* We do not have a DirectDraw interface, we need alloc it*/
LPDDRAWI_DIRECTDRAW_INT memThis; LPDDRAWI_DIRECTDRAW_INT memThis;
@@ -136,7 +136,7 @@ Create_DirectDraw (LPGUID pGUID, LPDIRECTDRAW* pIface,
{ {
DX_STUB_str("Got iface\n"); DX_STUB_str("Got iface\n");
if (StartDirectDraw((LPDIRECTDRAW)This, pGUID, FALSE) == DD_OK); if (StartDirectDraw((LPDIRECTDRAW)This, pGUID, FALSE) == DD_OK)
{ {
/* /*
RtlZeroMemory(&wnd_class, sizeof(wnd_class)); RtlZeroMemory(&wnd_class, sizeof(wnd_class));
@@ -190,9 +190,6 @@ StartDirectDraw(LPDIRECTDRAW iface, LPGUID lpGuid, BOOL reenable)
ddgbl.lpDriverHandle = &ddgbl; ddgbl.lpDriverHandle = &ddgbl;
ddgbl.hDDVxd = -1; ddgbl.hDDVxd = -1;
if (reenable == FALSE) if (reenable == FALSE)
{ {
if ((!IsBadReadPtr(This->lpLink,sizeof(LPDIRECTDRAW))) && (This->lpLink == NULL)) if ((!IsBadReadPtr(This->lpLink,sizeof(LPDIRECTDRAW))) && (This->lpLink == NULL))
@@ -236,8 +233,6 @@ StartDirectDraw(LPDIRECTDRAW iface, LPGUID lpGuid, BOOL reenable)
RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7); RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7);
RtlCopyMemory(&ddgbl.cDriverName,&"DISPLAY",7); RtlCopyMemory(&ddgbl.cDriverName,&"DISPLAY",7);
dwFlags |= DDRAWI_DISPLAYDRV | DDRAWI_GDIDRV; dwFlags |= DDRAWI_DISPLAYDRV | DDRAWI_GDIDRV;
} }
else if (lpGuid == (LPGUID) DDCREATE_HARDWAREONLY) else if (lpGuid == (LPGUID) DDCREATE_HARDWAREONLY)
{ {
@@ -289,7 +284,6 @@ StartDirectDraw(LPDIRECTDRAW iface, LPGUID lpGuid, BOOL reenable)
/* Startup HEL and HAL */ /* Startup HEL and HAL */
This->lpLcl->lpDDCB = This->lpLcl->lpGbl->lpDDCBtmp; This->lpLcl->lpDDCB = This->lpLcl->lpGbl->lpDDCBtmp;
This->lpLcl->dwProcessId = GetCurrentProcessId(); This->lpLcl->dwProcessId = GetCurrentProcessId();
switch (devicetypes) switch (devicetypes)
{ {
case 2: case 2:
@@ -305,6 +299,7 @@ StartDirectDraw(LPDIRECTDRAW iface, LPGUID lpGuid, BOOL reenable)
default: default:
hal_ret = StartDirectDrawHal(iface, reenable); hal_ret = StartDirectDrawHal(iface, reenable);
hel_ret = StartDirectDrawHel(iface, reenable); hel_ret = StartDirectDrawHel(iface, reenable);
break;
} }
if (hal_ret!=DD_OK) if (hal_ret!=DD_OK)
@@ -362,18 +357,30 @@ StartDirectDrawHel(LPDIRECTDRAW iface, BOOL reenable)
{ {
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface; LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
This->lpLcl->lpGbl->lpDDCBtmp->HELDD.CanCreateSurface = HelDdCanCreateSurface; if (reenable == FALSE)
This->lpLcl->lpGbl->lpDDCBtmp->HELDD.CreateSurface = HelDdCreateSurface; {
This->lpLcl->lpGbl->lpDDCBtmp->HELDD.CreatePalette = HelDdCreatePalette; if (ddgbl.lpDDCBtmp == NULL)
This->lpLcl->lpGbl->lpDDCBtmp->HELDD.DestroyDriver = HelDdDestroyDriver; {
This->lpLcl->lpGbl->lpDDCBtmp->HELDD.FlipToGDISurface = HelDdFlipToGDISurface; DxHeapMemAlloc(ddgbl.lpDDCBtmp, sizeof(DDHAL_CALLBACKS));
This->lpLcl->lpGbl->lpDDCBtmp->HELDD.GetScanLine = HelDdGetScanLine; if ( ddgbl.lpDDCBtmp == NULL)
This->lpLcl->lpGbl->lpDDCBtmp->HELDD.SetColorKey = HelDdSetColorKey; {
This->lpLcl->lpGbl->lpDDCBtmp->HELDD.SetExclusiveMode = HelDdSetExclusiveMode; return DD_FALSE;
This->lpLcl->lpGbl->lpDDCBtmp->HELDD.SetMode = HelDdSetMode; }
This->lpLcl->lpGbl->lpDDCBtmp->HELDD.WaitForVerticalBlank = HelDdWaitForVerticalBlank; }
}
This->lpLcl->lpGbl->lpDDCBtmp->HELDD.dwFlags = DDHAL_CB32_CANCREATESURFACE | ddgbl.lpDDCBtmp->HELDD.CanCreateSurface = HelDdCanCreateSurface;
ddgbl.lpDDCBtmp->HELDD.CreateSurface = HelDdCreateSurface;
ddgbl.lpDDCBtmp->HELDD.CreatePalette = HelDdCreatePalette;
ddgbl.lpDDCBtmp->HELDD.DestroyDriver = HelDdDestroyDriver;
ddgbl.lpDDCBtmp->HELDD.FlipToGDISurface = HelDdFlipToGDISurface;
ddgbl.lpDDCBtmp->HELDD.GetScanLine = HelDdGetScanLine;
ddgbl.lpDDCBtmp->HELDD.SetColorKey = HelDdSetColorKey;
ddgbl.lpDDCBtmp->HELDD.SetExclusiveMode = HelDdSetExclusiveMode;
ddgbl.lpDDCBtmp->HELDD.SetMode = HelDdSetMode;
ddgbl.lpDDCBtmp->HELDD.WaitForVerticalBlank = HelDdWaitForVerticalBlank;
ddgbl.lpDDCBtmp->HELDD.dwFlags = DDHAL_CB32_CANCREATESURFACE |
DDHAL_CB32_CREATESURFACE | DDHAL_CB32_CREATESURFACE |
DDHAL_CB32_CREATEPALETTE | DDHAL_CB32_CREATEPALETTE |
DDHAL_CB32_DESTROYDRIVER | DDHAL_CB32_DESTROYDRIVER |
@@ -384,23 +391,23 @@ StartDirectDrawHel(LPDIRECTDRAW iface, BOOL reenable)
DDHAL_CB32_SETMODE | DDHAL_CB32_SETMODE |
DDHAL_CB32_WAITFORVERTICALBLANK ; DDHAL_CB32_WAITFORVERTICALBLANK ;
This->lpLcl->lpGbl->lpDDCBtmp->HELDD.dwSize = sizeof(This->lpLcl->lpDDCB->HELDD); ddgbl.lpDDCBtmp->HELDD.dwSize = sizeof(This->lpLcl->lpDDCB->HELDD);
This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.AddAttachedSurface = HelDdSurfAddAttachedSurface; ddgbl.lpDDCBtmp->HELDDSurface.AddAttachedSurface = HelDdSurfAddAttachedSurface;
This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.Blt = HelDdSurfBlt; ddgbl.lpDDCBtmp->HELDDSurface.Blt = HelDdSurfBlt;
This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.DestroySurface = HelDdSurfDestroySurface; ddgbl.lpDDCBtmp->HELDDSurface.DestroySurface = HelDdSurfDestroySurface;
This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.Flip = HelDdSurfFlip; ddgbl.lpDDCBtmp->HELDDSurface.Flip = HelDdSurfFlip;
This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.GetBltStatus = HelDdSurfGetBltStatus; ddgbl.lpDDCBtmp->HELDDSurface.GetBltStatus = HelDdSurfGetBltStatus;
This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.GetFlipStatus = HelDdSurfGetFlipStatus; ddgbl.lpDDCBtmp->HELDDSurface.GetFlipStatus = HelDdSurfGetFlipStatus;
This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.Lock = HelDdSurfLock; ddgbl.lpDDCBtmp->HELDDSurface.Lock = HelDdSurfLock;
This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.reserved4 = HelDdSurfreserved4; ddgbl.lpDDCBtmp->HELDDSurface.reserved4 = HelDdSurfreserved4;
This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.SetClipList = HelDdSurfSetClipList; ddgbl.lpDDCBtmp->HELDDSurface.SetClipList = HelDdSurfSetClipList;
This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.SetColorKey = HelDdSurfSetColorKey; ddgbl.lpDDCBtmp->HELDDSurface.SetColorKey = HelDdSurfSetColorKey;
This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.SetOverlayPosition = HelDdSurfSetOverlayPosition; ddgbl.lpDDCBtmp->HELDDSurface.SetOverlayPosition = HelDdSurfSetOverlayPosition;
This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.SetPalette = HelDdSurfSetPalette; ddgbl.lpDDCBtmp->HELDDSurface.SetPalette = HelDdSurfSetPalette;
This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.Unlock = HelDdSurfUnlock; ddgbl.lpDDCBtmp->HELDDSurface.Unlock = HelDdSurfUnlock;
This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.UpdateOverlay = HelDdSurfUpdateOverlay; ddgbl.lpDDCBtmp->HELDDSurface.UpdateOverlay = HelDdSurfUpdateOverlay;
This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.dwFlags = DDHAL_SURFCB32_ADDATTACHEDSURFACE | ddgbl.lpDDCBtmp->HELDDSurface.dwFlags = DDHAL_SURFCB32_ADDATTACHEDSURFACE |
DDHAL_SURFCB32_BLT | DDHAL_SURFCB32_BLT |
DDHAL_SURFCB32_DESTROYSURFACE | DDHAL_SURFCB32_DESTROYSURFACE |
DDHAL_SURFCB32_FLIP | DDHAL_SURFCB32_FLIP |
@@ -415,7 +422,7 @@ StartDirectDrawHel(LPDIRECTDRAW iface, BOOL reenable)
DDHAL_SURFCB32_UNLOCK | DDHAL_SURFCB32_UNLOCK |
DDHAL_SURFCB32_UPDATEOVERLAY; DDHAL_SURFCB32_UPDATEOVERLAY;
This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.dwSize = sizeof(This->lpLcl->lpDDCB->HELDDSurface); ddgbl.lpDDCBtmp->HELDDSurface.dwSize = sizeof(This->lpLcl->lpDDCB->HELDDSurface);
/* /*
This->lpLcl->lpDDCB->HELDDPalette.DestroyPalette = HelDdPalDestroyPalette; This->lpLcl->lpDDCB->HELDDPalette.DestroyPalette = HelDdPalDestroyPalette;

View File

@@ -1,6 +1,9 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!DOCTYPE group SYSTEM "../../tools/rbuild/project.dtd"> <!DOCTYPE group SYSTEM "../../tools/rbuild/project.dtd">
<group xmlns:xi="http://www.w3.org/2001/XInclude"> <group xmlns:xi="http://www.w3.org/2001/XInclude">
<directory name="d3d9">
<xi:include href="d3d9/d3d9.rbuild" />
</directory>
<directory name="d3d8thk"> <directory name="d3d8thk">
<xi:include href="d3d8thk/d3d8thk.rbuild" /> <xi:include href="d3d8thk/d3d8thk.rbuild" />
</directory> </directory>

View File

@@ -48,7 +48,7 @@ ULONG WINAPI IDxDiagContainerImpl_AddRef(PDXDIAGCONTAINER iface) {
TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1); TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
DXDIAGN_LockModule(); //DXDIAGN_LockModule();
return refCount; return refCount;
} }
@@ -63,7 +63,7 @@ ULONG WINAPI IDxDiagContainerImpl_Release(PDXDIAGCONTAINER iface) {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
DXDIAGN_UnlockModule(); //DXDIAGN_UnlockModule();
return refCount; return refCount;
} }

View File

@@ -23,9 +23,38 @@
#include "dxdiag_private.h" #include "dxdiag_private.h"
#include "wine/debug.h" #include "wine/debug.h"
#define INITGUID
DWORD g_cComponents;
DWORD g_cServerLocks;
WINE_DEFAULT_DEBUG_CHANNEL(dxdiag); WINE_DEFAULT_DEBUG_CHANNEL(dxdiag);
LONG DXDIAGN_refCount = 0; IClassFactoryVtbl DXDiagCF_Vtbl =
{
DXDiagCF_QueryInterface,
DXDiagCF_AddRef,
DXDiagCF_Release,
DXDiagCF_CreateInstance,
DXDiagCF_LockServer
};
IDxDiagProviderVtbl DxDiagProvider_Vtbl =
{
IDxDiagProviderImpl_QueryInterface,
IDxDiagProviderImpl_AddRef,
IDxDiagProviderImpl_Release,
IDxDiagProviderImpl_Initialize,
IDxDiagProviderImpl_GetRootContainer
};
IDxDiagProviderPrivateVtbl DxDiagProvider_PrivateVtbl =
{
IDxDiagProviderImpl_QueryInterface,
IDxDiagProviderImpl_AddRef,
IDxDiagProviderImpl_Release,
IDxDiagProviderImpl_ExecMethod
};
/* At process attach */ /* At process attach */
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved) BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
@@ -40,69 +69,132 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
/******************************************************************************* /*******************************************************************************
* DXDiag ClassFactory * DXDiag ClassFactory
*/ */
typedef struct {
const IClassFactoryVtbl *lpVtbl;
REFCLSID rclsid;
HRESULT (*pfnCreateInstanceFactory)(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj);
} IClassFactoryImpl;
static HRESULT WINAPI DXDiagCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { HRESULT
FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid)); WINAPI
DXDiagCF_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj)
{
LPICLASSFACTORY_INT This = (LPICLASSFACTORY_INT) iface;
HRESULT retValue = S_OK;
if (ppobj == NULL) return E_POINTER; if (ppobj == NULL)
{
return E_NOINTERFACE; retValue = E_INVALIDARG;
}
else
{
if ( ( IsEqualGUID( riid, &IID_IUnknown) ) ||
( IsEqualGUID( riid, &IID_IClassFactory) ) )
{
*ppobj = This;
IClassFactory_AddRef( iface );
}
else
{
*ppobj = NULL;
retValue = E_NOINTERFACE;
}
}
return retValue;
} }
static ULONG WINAPI DXDiagCF_AddRef(LPCLASSFACTORY iface) { ULONG
DXDIAGN_LockModule(); WINAPI
DXDiagCF_AddRef(LPCLASSFACTORY iface)
return 2; /* non-heap based object */ {
LPICLASSFACTORY_INT This = (LPICLASSFACTORY_INT) iface;
return (ULONG) InterlockedIncrement( (LONG *) &This->RefCount );
} }
static ULONG WINAPI DXDiagCF_Release(LPCLASSFACTORY iface) { ULONG
DXDIAGN_UnlockModule(); WINAPI
DXDiagCF_Release(LPCLASSFACTORY iface)
{
LPICLASSFACTORY_INT This = (LPICLASSFACTORY_INT) iface;
ULONG RefCount = 0;
return 1; /* non-heap based object */ RefCount = InterlockedDecrement( (LONG *) &This->RefCount );
if (RefCount <= 0)
{
if (This->RefCount == 0)
{
HeapFree(GetProcessHeap(), 0, This);
}
RefCount = 0;
}
return RefCount;
} }
static HRESULT WINAPI DXDiagCF_CreateInstance(LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj) {
IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
return This->pfnCreateInstanceFactory(iface, pOuter, riid, ppobj); HRESULT
WINAPI
DXDiagCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
{
HRESULT retValue = S_OK;
if ( *ppobj != NULL )
{
*ppobj = NULL;
}
if ( pOuter == NULL )
{
if ( IsEqualGUID( riid, &CLSID_DxDiagProvider ) )
{
LPDXDIAGPROVIDER_INT myDxDiagProvider_int = (LPDXDIAGPROVIDER_INT) HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(DXDIAGPROVIDER_INT));
if ( myDxDiagProvider_int == NULL)
{
*ppobj = NULL;
retValue = E_OUTOFMEMORY;
}
else
{
myDxDiagProvider_int->lpVbl = (LPVOID) &DxDiagProvider_Vtbl;
myDxDiagProvider_int->lpVbl_private = (LPVOID) &DxDiagProvider_PrivateVtbl;
IDxDiagProviderImpl_AddRef( (LPDXDIAGPROVIDER) myDxDiagProvider_int );
InterlockedIncrement( (LONG *)&g_cComponents);
retValue = IDxDiagProvider_QueryInterface( (LPDXDIAGPROVIDER) myDxDiagProvider_int, riid, ppobj );
IDxDiagProvider_Release( (LPDXDIAGPROVIDER) myDxDiagProvider_int );
*ppobj = (LPVOID) myDxDiagProvider_int;
}
}
else
{
retValue = CLASS_E_CLASSNOTAVAILABLE;
}
}
return retValue;
} }
static HRESULT WINAPI DXDiagCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { HRESULT
TRACE("(%d)\n", dolock); WINAPI
DXDiagCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
{
if (dolock) if (dolock == TRUE)
DXDIAGN_LockModule(); {
else InterlockedIncrement( (LONG *)&g_cServerLocks);
DXDIAGN_UnlockModule(); }
return S_OK; return S_OK;
} }
static const IClassFactoryVtbl DXDiagCF_Vtbl = {
DXDiagCF_QueryInterface,
DXDiagCF_AddRef,
DXDiagCF_Release,
DXDiagCF_CreateInstance,
DXDiagCF_LockServer
};
static IClassFactoryImpl DXDiag_CFS[] = {
{ &DXDiagCF_Vtbl, &CLSID_DxDiagProvider, DXDiag_CreateDXDiagProvider },
{ NULL, NULL, NULL }
};
/*********************************************************************** /***********************************************************************
* DllCanUnloadNow (DXDIAGN.@) * DllCanUnloadNow (DXDIAGN.@)
*/ */
HRESULT WINAPI DllCanUnloadNow(void) HRESULT WINAPI DllCanUnloadNow(void)
{ {
return DXDIAGN_refCount != 0 ? S_FALSE : S_OK; return S_OK;
} }
/*********************************************************************** /***********************************************************************
@@ -110,18 +202,42 @@ HRESULT WINAPI DllCanUnloadNow(void)
*/ */
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
{ {
int i = 0; HRESULT retValue = S_OK;
LPICLASSFACTORY_INT myIClassFactory_int;
LPCLASSFACTORY This;
TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv); if ( IsEqualGUID( rclsid, &CLSID_DxDiagProvider) )
while (NULL != DXDiag_CFS[i].rclsid) { {
if (IsEqualGUID(rclsid, DXDiag_CFS[i].rclsid)) { myIClassFactory_int = (LPICLASSFACTORY_INT) HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ICLASSFACTORY_INT));
DXDiagCF_AddRef((IClassFactory*) &DXDiag_CFS[i]);
*ppv = &DXDiag_CFS[i]; if (myIClassFactory_int != NULL)
return S_OK; {
} myIClassFactory_int->lpVbl = (LPVOID) &DXDiagCF_Vtbl;
++i;
} This = (LPCLASSFACTORY) myIClassFactory_int;
DXDiagCF_AddRef( This );
retValue = IClassFactory_QueryInterface( This, riid, ppv );
IClassFactory_AddRef( This );
*ppv = (LPVOID) This;
}
else
{
retValue = E_OUTOFMEMORY;
*ppv = NULL;
}
}
else
{
retValue = CLASS_E_CLASSNOTAVAILABLE;
*ppv = NULL;
}
return retValue;
FIXME("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
return CLASS_E_CLASSNOTAVAILABLE;
} }

View File

@@ -21,16 +21,27 @@
#ifndef __WINE_DXDIAG_PRIVATE_H #ifndef __WINE_DXDIAG_PRIVATE_H
#define __WINE_DXDIAG_PRIVATE_H #define __WINE_DXDIAG_PRIVATE_H
#include <stdarg.h> #define COBJMACROS
#include "windef.h" #include <windows.h>
#include "winbase.h" #if defined(_WIN32) && !defined(_NO_COM )
#include "wingdi.h" #define COM_NO_WINDOWS_H
#include "winuser.h"
#include "objbase.h"
#include "oleauto.h"
#include "dxdiag.h" #include <objbase.h>
#else
#define IUnknown void
#if !defined(NT_BUILD_ENVIRONMENT) && !defined(WINNT)
#define CO_E_NOTINITIALIZED 0x800401F0
#endif
#endif
#include <dxdiag.h>
/* DXDiag Interfaces: */ /* DXDiag Interfaces: */
typedef struct IDxDiagProviderImpl IDxDiagProviderImpl; typedef struct IDxDiagProviderImpl IDxDiagProviderImpl;
@@ -43,15 +54,33 @@ typedef struct IDxDiagContainerImpl IDxDiagContainerImpl;
/***************************************************************************** /*****************************************************************************
* IDxDiagProvider implementation structure * IDxDiagProvider implementation structure
*/ */
struct IDxDiagProviderImpl {
/* IUnknown fields */ typedef struct _DXDIAGPROVIDER_INT
const IDxDiagProviderVtbl *lpVtbl; {
LONG ref; /*0x00 */ LPVOID lpVbl;
/* IDxDiagProvider fields */ /*0x04 */ LPVOID lpVbl_private;
BOOL init; /*0x08 */ DWORD Unkonwn1;
DXDIAG_INIT_PARAMS params; /*0x0C */ DWORD Unkonwn2;
IDxDiagContainer* pRootContainer; /*0x10 */ DWORD RefCount;
}; /*0x0C */ DWORD Unkonwn3;
/*0x20 */ CHAR Unkonwn4;
/*0x21 */ CHAR Unkonwn5;
/*0x22 */ CHAR Unkonwn6;
/*0x23 */ CHAR Unkonwn7;
/*0x24 */ CHAR Unkonwn8;
/*0x25 */ CHAR Unkonwn9;
/*0x26 */ CHAR Unkonwn10;
/*0x27 */ CHAR Unkonwn11;
/*0x28 */ CHAR Unkonwn12;
/*0x29 */ CHAR Unkonwn13;
/*0x2A */ CHAR Unkonwn14;
/*0x2C */ CHAR Unkonwn15;
/* wine */
/* IDxDiagProvider fields */
BOOL init;
DXDIAG_INIT_PARAMS params;
IDxDiagContainer* pRootContainer;
} DXDIAGPROVIDER_INT, *LPDXDIAGPROVIDER_INT;
/* IUnknown: */ /* IUnknown: */
extern HRESULT WINAPI IDxDiagProviderImpl_QueryInterface(PDXDIAGPROVIDER iface, REFIID riid, LPVOID *ppobj); extern HRESULT WINAPI IDxDiagProviderImpl_QueryInterface(PDXDIAGPROVIDER iface, REFIID riid, LPVOID *ppobj);
@@ -101,10 +130,6 @@ extern ULONG WINAPI IDxDiagContainerImpl_AddRef(PDXDIAGCONTAINER iface);
extern HRESULT WINAPI IDxDiagContainerImpl_AddProp(PDXDIAGCONTAINER iface, LPCWSTR pwszPropName, VARIANT* pVarProp); extern HRESULT WINAPI IDxDiagContainerImpl_AddProp(PDXDIAGCONTAINER iface, LPCWSTR pwszPropName, VARIANT* pVarProp);
extern HRESULT WINAPI IDxDiagContainerImpl_AddChildContainer(PDXDIAGCONTAINER iface, LPCWSTR pszContName, PDXDIAGCONTAINER pSubCont); extern HRESULT WINAPI IDxDiagContainerImpl_AddChildContainer(PDXDIAGCONTAINER iface, LPCWSTR pszContName, PDXDIAGCONTAINER pSubCont);
/**
* factories
*/
extern HRESULT DXDiag_CreateDXDiagProvider(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj);
/** internal factory */ /** internal factory */
extern HRESULT DXDiag_CreateDXDiagContainer(REFIID riid, LPVOID *ppobj); extern HRESULT DXDiag_CreateDXDiagContainer(REFIID riid, LPVOID *ppobj);
@@ -113,8 +138,61 @@ extern HRESULT DXDiag_InitRootDXDiagContainer(IDxDiagContainer* pRootCont);
/********************************************************************** /**********************************************************************
* Dll lifetime tracking declaration for dxdiagn.dll * Dll lifetime tracking declaration for dxdiagn.dll
*/ */
extern LONG DXDIAGN_refCount;
static inline void DXDIAGN_LockModule(void) { InterlockedIncrement( &DXDIAGN_refCount ); }
static inline void DXDIAGN_UnlockModule(void) { InterlockedDecrement( &DXDIAGN_refCount ); }
/*****************************************************************************
* IClassFactoryImpl implementation structure
*/
HRESULT WINAPI DXDiagCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj);
ULONG WINAPI DXDiagCF_AddRef(LPCLASSFACTORY iface);
ULONG WINAPI DXDiagCF_Release(LPCLASSFACTORY iface);
HRESULT WINAPI DXDiagCF_CreateInstance(LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj);
HRESULT WINAPI DXDiagCF_LockServer(LPCLASSFACTORY iface,BOOL dolock);
typedef struct _ICLASSFACTORY_INT
{
LPVOID lpVbl;
DWORD RefCount;
LPVOID Unknown1;
LPVOID Unknown2;
} ICLASSFACTORY_INT, *LPICLASSFACTORY_INT;
ULONG WINAPI IDxDiagProviderImpl_ExecMethod(PDXDIAGPROVIDER iface);
#if defined( _WIN32 ) && !defined( _NO_COM )
#undef INTERFACE
#define INTERFACE IDxDiagProviderPrivate
DECLARE_INTERFACE_( IDxDiagProviderPrivate, IUnknown )
{
STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
STDMETHOD_(ULONG,ExecMethod) (THIS) PURE;
};
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDxDiagProviderPrivate_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b)
#define IDxDiagProviderPrivate_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDxDiagProviderPrivate_Release(p) (p)->lpVtbl->Release(p)
#define IDxDiagProviderPrivate_ExecMethod(p) (p)->lpVtbl->ExecMethod(p)
#else
#define IDxDiagProviderPrivate_QueryInterface(p, a, b) (p)->QueryInterface(a, b)
#define IDxDiagProviderPrivate_AddRef(p) (p)->AddRef()
#define IDxDiagProviderPrivate_Release(p) (p)->Release()
#define IDxDiagProviderPrivate_ExecMethod(p) (p)->ExecMethod()
#endif
#endif
typedef struct IDxDiagProviderPrivateVtbl DXDIAGPROVIDERPRIVARECALLBACK;
typedef DXDIAGPROVIDERPRIVARECALLBACK *LPDXDIAGPROVIDERPRIVARECALLBACK;
#endif #endif

View File

@@ -42,24 +42,29 @@ HRESULT WINAPI IDxDiagProviderImpl_QueryInterface(PDXDIAGPROVIDER iface, REFIID
} }
ULONG WINAPI IDxDiagProviderImpl_AddRef(PDXDIAGPROVIDER iface) { ULONG WINAPI IDxDiagProviderImpl_AddRef(PDXDIAGPROVIDER iface) {
IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface; LPDXDIAGPROVIDER_INT This = (LPDXDIAGPROVIDER_INT) iface;
TRACE("(%p) : AddRef from %ld\n", This, This->ref); TRACE("(%p) : AddRef from %ld\n", This, This->RefCount);
return ++(This->ref); return ++(This->RefCount);
} }
ULONG WINAPI IDxDiagProviderImpl_Release(PDXDIAGPROVIDER iface) { ULONG WINAPI IDxDiagProviderImpl_Release(PDXDIAGPROVIDER iface) {
IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface; LPDXDIAGPROVIDER_INT This = (LPDXDIAGPROVIDER_INT) iface;
ULONG ref = --This->ref; ULONG ref = --This->RefCount;
TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref); TRACE("(%p) : ReleaseRef to %ld\n", This, This->RefCount);
if (ref == 0) { if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
return ref; return ref;
} }
ULONG WINAPI IDxDiagProviderImpl_ExecMethod(PDXDIAGPROVIDER iface) {
return 0;
}
/* IDxDiagProvider Interface follow: */ /* IDxDiagProvider Interface follow: */
HRESULT WINAPI IDxDiagProviderImpl_Initialize(PDXDIAGPROVIDER iface, DXDIAG_INIT_PARAMS* pParams) { HRESULT WINAPI IDxDiagProviderImpl_Initialize(PDXDIAGPROVIDER iface, DXDIAG_INIT_PARAMS* pParams) {
IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface; LPDXDIAGPROVIDER_INT This = (LPDXDIAGPROVIDER_INT) iface;
TRACE("(%p,%p)\n", iface, pParams); TRACE("(%p,%p)\n", iface, pParams);
if (NULL == pParams) { if (NULL == pParams) {
@@ -76,7 +81,7 @@ HRESULT WINAPI IDxDiagProviderImpl_Initialize(PDXDIAGPROVIDER iface, DXDIAG_INIT
HRESULT WINAPI IDxDiagProviderImpl_GetRootContainer(PDXDIAGPROVIDER iface, IDxDiagContainer** ppInstance) { HRESULT WINAPI IDxDiagProviderImpl_GetRootContainer(PDXDIAGPROVIDER iface, IDxDiagContainer** ppInstance) {
HRESULT hr = S_OK; HRESULT hr = S_OK;
IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface; LPDXDIAGPROVIDER_INT This = (LPDXDIAGPROVIDER_INT) iface;
TRACE("(%p,%p)\n", iface, ppInstance); TRACE("(%p,%p)\n", iface, ppInstance);
if (NULL == ppInstance) { if (NULL == ppInstance) {
@@ -94,26 +99,5 @@ HRESULT WINAPI IDxDiagProviderImpl_GetRootContainer(PDXDIAGPROVIDER iface, IDxDi
return IDxDiagContainerImpl_QueryInterface((PDXDIAGCONTAINER)This->pRootContainer, &IID_IDxDiagContainer, (void**) ppInstance); return IDxDiagContainerImpl_QueryInterface((PDXDIAGCONTAINER)This->pRootContainer, &IID_IDxDiagContainer, (void**) ppInstance);
} }
IDxDiagProviderVtbl DxDiagProvider_Vtbl =
{
IDxDiagProviderImpl_QueryInterface,
IDxDiagProviderImpl_AddRef,
IDxDiagProviderImpl_Release,
IDxDiagProviderImpl_Initialize,
IDxDiagProviderImpl_GetRootContainer
};
HRESULT DXDiag_CreateDXDiagProvider(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) {
IDxDiagProviderImpl* provider;
TRACE("(%p, %s, %p)\n", punkOuter, debugstr_guid(riid), ppobj);
provider = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDxDiagProviderImpl));
if (NULL == provider) {
*ppobj = NULL;
return E_OUTOFMEMORY;
}
provider->lpVtbl = &DxDiagProvider_Vtbl;
provider->ref = 0; /* will be inited with QueryInterface */
return IDxDiagProviderImpl_QueryInterface ((PDXDIAGPROVIDER)provider, riid, ppobj);
}

View File

@@ -34,4 +34,6 @@
<file>volume.c</file> <file>volume.c</file>
<file>volumetexture.c</file> <file>volumetexture.c</file>
<file>version.rc</file> <file>version.rc</file>
<dependency>wineheaders</dependency>
</module> </module>

View File

@@ -33,7 +33,7 @@
#include "wingdi.h" #include "wingdi.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "d3d8.h" #include "d3d8.h"
#include "wine/wined3d_interface.h" #include "wine/wined3d.h"
/* Device caps */ /* Device caps */
#define INITIAL_SHADER_HANDLE_TABLE_SIZE 64 #define INITIAL_SHADER_HANDLE_TABLE_SIZE 64
@@ -160,6 +160,7 @@ struct IDirect3D8Impl
* Predeclare the interface implementation structures * Predeclare the interface implementation structures
*/ */
extern const IDirect3DDevice8Vtbl Direct3DDevice8_Vtbl; extern const IDirect3DDevice8Vtbl Direct3DDevice8_Vtbl;
extern const IWineD3DDeviceParentVtbl d3d8_wined3d_device_parent_vtbl;
/***************************************************************************** /*****************************************************************************
* IDirect3DDevice8 implementation structure * IDirect3DDevice8 implementation structure
@@ -170,13 +171,14 @@ typedef void * shader_handle;
struct FvfToDecl struct FvfToDecl
{ {
DWORD fvf; DWORD fvf;
IWineD3DVertexDeclaration *decl; struct IDirect3DVertexDeclaration8 *decl;
}; };
struct IDirect3DDevice8Impl struct IDirect3DDevice8Impl
{ {
/* IUnknown fields */ /* IUnknown fields */
const IDirect3DDevice8Vtbl *lpVtbl; const IDirect3DDevice8Vtbl *lpVtbl;
const IWineD3DDeviceParentVtbl *device_parent_vtbl;
LONG ref; LONG ref;
/* But what about baseVertexIndex in state blocks? hmm... it may be a better idea to pass this to wined3d */ /* But what about baseVertexIndex in state blocks? hmm... it may be a better idea to pass this to wined3d */
IWineD3DDevice *WineD3DDevice; IWineD3DDevice *WineD3DDevice;
@@ -200,6 +202,7 @@ struct IDirect3DDevice8Impl
/***************************************************************************** /*****************************************************************************
* IDirect3DVolume8 implementation structure * IDirect3DVolume8 implementation structure
*/ */
extern const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl;
struct IDirect3DVolume8Impl struct IDirect3DVolume8Impl
{ {
/* IUnknown fields */ /* IUnknown fields */
@@ -531,11 +534,12 @@ typedef struct {
DWORD elements_size; /* Size of elements, in bytes */ DWORD elements_size; /* Size of elements, in bytes */
IWineD3DVertexDeclaration *wined3d_vertex_declaration; IWineD3DVertexDeclaration *wined3d_vertex_declaration;
DWORD shader_handle;
} IDirect3DVertexDeclaration8Impl; } IDirect3DVertexDeclaration8Impl;
/***************************************************************************** /*****************************************************************************
* IDirect3DVertexShader9 interface * IDirect3DVertexShader8 interface
*/ */
#define INTERFACE IDirect3DVertexShader8 #define INTERFACE IDirect3DVertexShader8
DECLARE_INTERFACE_(IDirect3DVertexShader8, IUnknown) DECLARE_INTERFACE_(IDirect3DVertexShader8, IUnknown)
@@ -544,9 +548,6 @@ DECLARE_INTERFACE_(IDirect3DVertexShader8, IUnknown)
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE; STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE; STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** IDirect3DVertexShader9 methods ***/
STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice8** ppDevice) PURE;
STDMETHOD(GetFunction)(THIS_ void*, UINT* pSizeOfData) PURE;
}; };
#undef INTERFACE #undef INTERFACE
@@ -554,16 +555,13 @@ DECLARE_INTERFACE_(IDirect3DVertexShader8, IUnknown)
#define IDirect3DVertexShader8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) #define IDirect3DVertexShader8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirect3DVertexShader8_AddRef(p) (p)->lpVtbl->AddRef(p) #define IDirect3DVertexShader8_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirect3DVertexShader8_Release(p) (p)->lpVtbl->Release(p) #define IDirect3DVertexShader8_Release(p) (p)->lpVtbl->Release(p)
/*** IDirect3DVertexShader8 methods ***/
#define IDirect3DVertexShader8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
#define IDirect3DVertexShader8_GetFunction(p,a,b) (p)->lpVtbl->GetFunction(p,a,b)
/* ------------------------- */ /* ------------------------- */
/* IDirect3DVertexShader8Impl */ /* IDirect3DVertexShader8Impl */
/* ------------------------- */ /* ------------------------- */
/***************************************************************************** /*****************************************************************************
* IDirect3DPixelShader9 interface * IDirect3DPixelShader8 interface
*/ */
#define INTERFACE IDirect3DPixelShader8 #define INTERFACE IDirect3DPixelShader8
DECLARE_INTERFACE_(IDirect3DPixelShader8,IUnknown) DECLARE_INTERFACE_(IDirect3DPixelShader8,IUnknown)
@@ -572,9 +570,6 @@ DECLARE_INTERFACE_(IDirect3DPixelShader8,IUnknown)
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE; STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE; STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** IDirect3DPixelShader8 methods ***/
STDMETHOD(GetDevice)(THIS_ struct IDirect3DDevice8** ppDevice) PURE;
STDMETHOD(GetFunction)(THIS_ void*, UINT* pSizeOfData) PURE;
}; };
#undef INTERFACE #undef INTERFACE
@@ -582,10 +577,6 @@ DECLARE_INTERFACE_(IDirect3DPixelShader8,IUnknown)
#define IDirect3DPixelShader8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) #define IDirect3DPixelShader8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDirect3DPixelShader8_AddRef(p) (p)->lpVtbl->AddRef(p) #define IDirect3DPixelShader8_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDirect3DPixelShader8_Release(p) (p)->lpVtbl->Release(p) #define IDirect3DPixelShader8_Release(p) (p)->lpVtbl->Release(p)
/*** IDirect3DPixelShader8 methods ***/
#define IDirect3DPixelShader8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
#define IDirect3DPixelShader8_GetFunction(p,a,b) (p)->lpVtbl->GetFunction(p,a,b)
/***************************************************************************** /*****************************************************************************
* Predeclare the interface implementation structures * Predeclare the interface implementation structures
@@ -600,7 +591,6 @@ struct IDirect3DVertexShader8Impl {
const IDirect3DVertexShader8Vtbl *lpVtbl; const IDirect3DVertexShader8Vtbl *lpVtbl;
LONG ref; LONG ref;
DWORD handle;
IDirect3DVertexDeclaration8 *vertex_declaration; IDirect3DVertexDeclaration8 *vertex_declaration;
IWineD3DVertexShader *wineD3DVertexShader; IWineD3DVertexShader *wineD3DVertexShader;
}; };
@@ -624,7 +614,6 @@ typedef struct IDirect3DPixelShader8Impl {
LONG ref; LONG ref;
DWORD handle; DWORD handle;
/* The device, to be replaced by an IDirect3DDeviceImpl */
IWineD3DPixelShader *wineD3DPixelShader; IWineD3DPixelShader *wineD3DPixelShader;
} IDirect3DPixelShader8Impl; } IDirect3DPixelShader8Impl;
@@ -638,34 +627,10 @@ UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3d8_elem
size_t parse_token(const DWORD* pToken); size_t parse_token(const DWORD* pToken);
/* Callbacks */ /* Callbacks */
extern HRESULT WINAPI D3D8CB_CreateSurface(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
WINED3DFORMAT Format, DWORD Usage, WINED3DPOOL Pool, UINT Level,
WINED3DCUBEMAP_FACES Face, IWineD3DSurface** ppSurface,
HANDLE* pSharedHandle);
extern HRESULT WINAPI D3D8CB_CreateVolume(IUnknown *pDevice, IUnknown *pSuperior, UINT Width, UINT Height, UINT Depth,
WINED3DFORMAT Format, WINED3DPOOL Pool, DWORD Usage,
IWineD3DVolume **ppVolume,
HANDLE * pSharedHandle);
extern HRESULT WINAPI D3D8CB_CreateDepthStencilSurface(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
WINED3DFORMAT Format, WINED3DMULTISAMPLE_TYPE MultiSample,
DWORD MultisampleQuality, BOOL Discard,
IWineD3DSurface** ppSurface, HANDLE* pSharedHandle);
extern HRESULT WINAPI D3D8CB_CreateRenderTarget(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
WINED3DFORMAT Format, WINED3DMULTISAMPLE_TYPE MultiSample,
DWORD MultisampleQuality, BOOL Lockable,
IWineD3DSurface** ppSurface, HANDLE* pSharedHandle);
extern ULONG WINAPI D3D8CB_DestroySwapChain (IWineD3DSwapChain *pSwapChain); extern ULONG WINAPI D3D8CB_DestroySwapChain (IWineD3DSwapChain *pSwapChain);
extern ULONG WINAPI D3D8CB_DestroyDepthStencilSurface (IWineD3DSurface *pSurface); extern ULONG WINAPI D3D8CB_DestroyDepthStencilSurface (IWineD3DSurface *pSurface);
extern ULONG WINAPI D3D8CB_DestroyRenderTarget (IWineD3DSurface *pSurface); extern ULONG WINAPI D3D8CB_DestroyRenderTarget (IWineD3DSurface *pSurface);
extern ULONG WINAPI D3D8CB_DestroySurface(IWineD3DSurface *pSurface); extern ULONG WINAPI D3D8CB_DestroySurface(IWineD3DSurface *pSurface);
extern ULONG WINAPI D3D8CB_DestroyVolume(IWineD3DVolume *pVolume); extern ULONG WINAPI D3D8CB_DestroyVolume(IWineD3DVolume *pVolume);
#endif /* __WINE_D3DX8_PRIVATE_H */ #endif /* __WINE_D3DX8_PRIVATE_H */

View File

@@ -73,6 +73,13 @@ static HRESULT WINAPI IDirect3DDevice8Impl_QueryInterface(LPDIRECT3DDEVICE8 ifac
return S_OK; return S_OK;
} }
if (IsEqualGUID(riid, &IID_IWineD3DDeviceParent))
{
IUnknown_AddRef((IUnknown *)&This->device_parent_vtbl);
*ppobj = &This->device_parent_vtbl;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj); WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL; *ppobj = NULL;
return E_NOINTERFACE; return E_NOINTERFACE;
@@ -104,7 +111,7 @@ static ULONG WINAPI IDirect3DDevice8Impl_Release(LPDIRECT3DDEVICE8 iface) {
This->inDestruction = TRUE; This->inDestruction = TRUE;
for(i = 0; i < This->numConvertedDecls; i++) { for(i = 0; i < This->numConvertedDecls; i++) {
IWineD3DVertexDeclaration_Release(This->decls[i].decl); IDirect3DVertexDeclaration8_Release(This->decls[i].decl);
} }
HeapFree(GetProcessHeap(), 0, This->decls); HeapFree(GetProcessHeap(), 0, This->decls);
@@ -308,7 +315,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateAdditionalSwapChain(LPDIRECT3DD
localParameters.AutoRestoreDisplayMode = TRUE; localParameters.AutoRestoreDisplayMode = TRUE;
EnterCriticalSection(&d3d8_cs); EnterCriticalSection(&d3d8_cs);
hrc = IWineD3DDevice_CreateSwapChain(This->WineD3DDevice, &localParameters, &object->wineD3DSwapChain, (IUnknown*)object, D3D8CB_CreateRenderTarget, D3D8CB_CreateDepthStencilSurface, SURFACE_OPENGL); hrc = IWineD3DDevice_CreateSwapChain(This->WineD3DDevice, &localParameters,
&object->wineD3DSwapChain, (IUnknown *)object, SURFACE_OPENGL);
LeaveCriticalSection(&d3d8_cs); LeaveCriticalSection(&d3d8_cs);
pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth; pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
@@ -462,7 +470,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateTexture(LPDIRECT3DDEVICE8 iface
object->ref = 1; object->ref = 1;
EnterCriticalSection(&d3d8_cs); EnterCriticalSection(&d3d8_cs);
hrc = IWineD3DDevice_CreateTexture(This->WineD3DDevice, Width, Height, Levels, Usage & WINED3DUSAGE_MASK, hrc = IWineD3DDevice_CreateTexture(This->WineD3DDevice, Width, Height, Levels, Usage & WINED3DUSAGE_MASK,
(WINED3DFORMAT)Format, (WINED3DPOOL) Pool, &object->wineD3DTexture, NULL, (IUnknown *)object, D3D8CB_CreateSurface); Format, Pool, &object->wineD3DTexture, NULL, (IUnknown *)object);
LeaveCriticalSection(&d3d8_cs); LeaveCriticalSection(&d3d8_cs);
if (FAILED(hrc)) { if (FAILED(hrc)) {
@@ -501,9 +509,8 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(LPDIRECT3DDEVICE8
object->lpVtbl = &Direct3DVolumeTexture8_Vtbl; object->lpVtbl = &Direct3DVolumeTexture8_Vtbl;
object->ref = 1; object->ref = 1;
EnterCriticalSection(&d3d8_cs); EnterCriticalSection(&d3d8_cs);
hrc = IWineD3DDevice_CreateVolumeTexture(This->WineD3DDevice, Width, Height, Depth, Levels, Usage & WINED3DUSAGE_MASK, hrc = IWineD3DDevice_CreateVolumeTexture(This->WineD3DDevice, Width, Height, Depth, Levels,
(WINED3DFORMAT)Format, (WINED3DPOOL) Pool, &object->wineD3DVolumeTexture, NULL, Usage & WINED3DUSAGE_MASK, Format, Pool, &object->wineD3DVolumeTexture, NULL, (IUnknown *)object);
(IUnknown *)object, D3D8CB_CreateVolume);
LeaveCriticalSection(&d3d8_cs); LeaveCriticalSection(&d3d8_cs);
if (hrc != D3D_OK) { if (hrc != D3D_OK) {
@@ -543,8 +550,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(LPDIRECT3DDEVICE8 i
object->ref = 1; object->ref = 1;
EnterCriticalSection(&d3d8_cs); EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_CreateCubeTexture(This->WineD3DDevice, EdgeLength, Levels, Usage & WINED3DUSAGE_MASK, hr = IWineD3DDevice_CreateCubeTexture(This->WineD3DDevice, EdgeLength, Levels, Usage & WINED3DUSAGE_MASK,
(WINED3DFORMAT)Format, (WINED3DPOOL) Pool, &object->wineD3DCubeTexture, NULL, (IUnknown*)object, Format, Pool, &object->wineD3DCubeTexture, NULL, (IUnknown *)object);
D3D8CB_CreateSurface);
LeaveCriticalSection(&d3d8_cs); LeaveCriticalSection(&d3d8_cs);
if (hr != D3D_OK){ if (hr != D3D_OK){
@@ -632,7 +638,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateIndexBuffer(LPDIRECT3DDEVICE8 i
return hrc; return hrc;
} }
static HRESULT WINAPI IDirect3DDevice8Impl_CreateSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IDirect3DSurface8 **ppSurface,D3DRESOURCETYPE Type, UINT Usage,D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality) { static HRESULT IDirect3DDevice8Impl_CreateSurface(LPDIRECT3DDEVICE8 iface, UINT Width, UINT Height, D3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IDirect3DSurface8 **ppSurface,D3DRESOURCETYPE Type, UINT Usage,D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality) {
HRESULT hrc; HRESULT hrc;
IDirect3DSurface8Impl *object; IDirect3DSurface8Impl *object;
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
@@ -761,11 +767,11 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CopyRects(LPDIRECT3DDEVICE8 iface, ID
/* Copy rect by rect */ /* Copy rect by rect */
if (NULL != pSourceRects && NULL != pDestPoints) { if (NULL != pSourceRects && NULL != pDestPoints) {
for (i = 0; i < cRects; ++i) { for (i = 0; i < cRects; ++i) {
IWineD3DSurface_BltFast(Dest->wineD3DSurface, pDestPoints[i].x, pDestPoints[i].y, Source->wineD3DSurface, (RECT *) &pSourceRects[i], WINEDDBLTFAST_NOCOLORKEY); IWineD3DSurface_BltFast(Dest->wineD3DSurface, pDestPoints[i].x, pDestPoints[i].y, Source->wineD3DSurface, &pSourceRects[i], WINEDDBLTFAST_NOCOLORKEY);
} }
} else { } else {
for (i = 0; i < cRects; ++i) { for (i = 0; i < cRects; ++i) {
IWineD3DSurface_BltFast(Dest->wineD3DSurface, 0, 0, Source->wineD3DSurface, (RECT *) &pSourceRects[i], WINEDDBLTFAST_NOCOLORKEY); IWineD3DSurface_BltFast(Dest->wineD3DSurface, 0, 0, Source->wineD3DSurface, &pSourceRects[i], WINEDDBLTFAST_NOCOLORKEY);
} }
} }
} }
@@ -1110,7 +1116,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_EndStateBlock(LPDIRECT3DDEVICE8 iface
EnterCriticalSection(&d3d8_cs); EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_EndStateBlock(This->WineD3DDevice , &wineD3DStateBlock); hr = IWineD3DDevice_EndStateBlock(This->WineD3DDevice , &wineD3DStateBlock);
if (hr != D3D_OK) { if (hr != D3D_OK) {
FIXME("IWineD3DDevice_EndStateBlock returned an error\n"); WARN("IWineD3DDevice_EndStateBlock returned an error\n");
LeaveCriticalSection(&d3d8_cs); LeaveCriticalSection(&d3d8_cs);
return hr; return hr;
} }
@@ -1263,100 +1269,70 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetTexture(LPDIRECT3DDEVICE8 iface, D
return hr; return hr;
} }
static const struct tss_lookup
{
BOOL sampler_state;
DWORD state;
}
tss_lookup[] =
{
{FALSE, WINED3DTSS_FORCE_DWORD}, /* 0, unused */
{FALSE, WINED3DTSS_COLOROP}, /* 1, D3DTSS_COLOROP */
{FALSE, WINED3DTSS_COLORARG1}, /* 2, D3DTSS_COLORARG1 */
{FALSE, WINED3DTSS_COLORARG2}, /* 3, D3DTSS_COLORARG2 */
{FALSE, WINED3DTSS_ALPHAOP}, /* 4, D3DTSS_ALPHAOP */
{FALSE, WINED3DTSS_ALPHAARG1}, /* 5, D3DTSS_ALPHAARG1 */
{FALSE, WINED3DTSS_ALPHAARG2}, /* 6, D3DTSS_ALPHAARG2 */
{FALSE, WINED3DTSS_BUMPENVMAT00}, /* 7, D3DTSS_BUMPENVMAT00 */
{FALSE, WINED3DTSS_BUMPENVMAT01}, /* 8, D3DTSS_BUMPENVMAT01 */
{FALSE, WINED3DTSS_BUMPENVMAT10}, /* 9, D3DTSS_BUMPENVMAT10 */
{FALSE, WINED3DTSS_BUMPENVMAT11}, /* 10, D3DTSS_BUMPENVMAT11 */
{FALSE, WINED3DTSS_TEXCOORDINDEX}, /* 11, D3DTSS_TEXCOORDINDEX */
{FALSE, WINED3DTSS_FORCE_DWORD}, /* 12, unused */
{TRUE, WINED3DSAMP_ADDRESSU}, /* 13, D3DTSS_ADDRESSU */
{TRUE, WINED3DSAMP_ADDRESSV}, /* 14, D3DTSS_ADDRESSV */
{TRUE, WINED3DSAMP_BORDERCOLOR}, /* 15, D3DTSS_BORDERCOLOR */
{TRUE, WINED3DSAMP_MAGFILTER}, /* 16, D3DTSS_MAGFILTER */
{TRUE, WINED3DSAMP_MINFILTER}, /* 17, D3DTSS_MINFILTER */
{TRUE, WINED3DSAMP_MIPFILTER}, /* 18, D3DTSS_MIPFILTER */
{TRUE, WINED3DSAMP_MIPMAPLODBIAS}, /* 19, D3DTSS_MIPMAPLODBIAS */
{TRUE, WINED3DSAMP_MAXMIPLEVEL}, /* 20, D3DTSS_MAXMIPLEVEL */
{TRUE, WINED3DSAMP_MAXANISOTROPY}, /* 21, D3DTSS_MAXANISOTROPY */
{FALSE, WINED3DTSS_BUMPENVLSCALE}, /* 22, D3DTSS_BUMPENVLSCALE */
{FALSE, WINED3DTSS_BUMPENVLOFFSET}, /* 23, D3DTSS_BUMPENVLOFFSET */
{FALSE, WINED3DTSS_TEXTURETRANSFORMFLAGS}, /* 24, D3DTSS_TEXTURETRANSFORMFLAGS */
{TRUE, WINED3DSAMP_ADDRESSW}, /* 25, D3DTSS_ADDRESSW */
{FALSE, WINED3DTSS_COLORARG0}, /* 26, D3DTSS_COLORARG0 */
{FALSE, WINED3DTSS_ALPHAARG0}, /* 27, D3DTSS_ALPHAARG0 */
{FALSE, WINED3DTSS_RESULTARG}, /* 28, D3DTSS_RESULTARG */
};
static HRESULT WINAPI IDirect3DDevice8Impl_GetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue) { static HRESULT WINAPI IDirect3DDevice8Impl_GetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue) {
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
const struct tss_lookup *l = &tss_lookup[Type];
HRESULT hr; HRESULT hr;
TRACE("(%p) Relay\n" , This); TRACE("(%p) Relay\n" , This);
switch(Type) {
case D3DTSS_ADDRESSU:
Type = WINED3DSAMP_ADDRESSU;
break;
case D3DTSS_ADDRESSV:
Type = WINED3DSAMP_ADDRESSV;
break;
case D3DTSS_ADDRESSW:
Type = WINED3DSAMP_ADDRESSW;
break;
case D3DTSS_BORDERCOLOR:
Type = WINED3DSAMP_BORDERCOLOR;
break;
case D3DTSS_MAGFILTER:
Type = WINED3DSAMP_MAGFILTER;
break;
case D3DTSS_MAXANISOTROPY:
Type = WINED3DSAMP_MAXANISOTROPY;
break;
case D3DTSS_MAXMIPLEVEL:
Type = WINED3DSAMP_MAXMIPLEVEL;
break;
case D3DTSS_MINFILTER:
Type = WINED3DSAMP_MINFILTER;
break;
case D3DTSS_MIPFILTER:
Type = WINED3DSAMP_MIPFILTER;
break;
case D3DTSS_MIPMAPLODBIAS:
Type = WINED3DSAMP_MIPMAPLODBIAS;
break;
default:
EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, Type, pValue);
LeaveCriticalSection(&d3d8_cs);
return hr;
}
EnterCriticalSection(&d3d8_cs); EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_GetSamplerState(This->WineD3DDevice, Stage, Type, pValue);
if (l->sampler_state) hr = IWineD3DDevice_GetSamplerState(This->WineD3DDevice, Stage, l->state, pValue);
else hr = IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, l->state, pValue);
LeaveCriticalSection(&d3d8_cs); LeaveCriticalSection(&d3d8_cs);
return hr; return hr;
} }
static HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) { static HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) {
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
const struct tss_lookup *l = &tss_lookup[Type];
HRESULT hr; HRESULT hr;
TRACE("(%p) Relay\n" , This); TRACE("(%p) Relay\n" , This);
switch(Type) {
case D3DTSS_ADDRESSU:
Type = WINED3DSAMP_ADDRESSU;
break;
case D3DTSS_ADDRESSV:
Type = WINED3DSAMP_ADDRESSV;
break;
case D3DTSS_ADDRESSW:
Type = WINED3DSAMP_ADDRESSW;
break;
case D3DTSS_BORDERCOLOR:
Type = WINED3DSAMP_BORDERCOLOR;
break;
case D3DTSS_MAGFILTER:
Type = WINED3DSAMP_MAGFILTER;
break;
case D3DTSS_MAXANISOTROPY:
Type = WINED3DSAMP_MAXANISOTROPY;
break;
case D3DTSS_MAXMIPLEVEL:
Type = WINED3DSAMP_MAXMIPLEVEL;
break;
case D3DTSS_MINFILTER:
Type = WINED3DSAMP_MINFILTER;
break;
case D3DTSS_MIPFILTER:
Type = WINED3DSAMP_MIPFILTER;
break;
case D3DTSS_MIPMAPLODBIAS:
Type = WINED3DSAMP_MIPMAPLODBIAS;
break;
default:
EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, Type, Value);
LeaveCriticalSection(&d3d8_cs);
return hr;
}
EnterCriticalSection(&d3d8_cs); EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_SetSamplerState(This->WineD3DDevice, Stage, Type, Value);
if (l->sampler_state) hr = IWineD3DDevice_SetSamplerState(This->WineD3DDevice, Stage, l->state, Value);
else hr = IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, l->state, Value);
LeaveCriticalSection(&d3d8_cs); LeaveCriticalSection(&d3d8_cs);
return hr; return hr;
} }
@@ -1482,7 +1458,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_ProcessVertices(LPDIRECT3DDEVICE8 ifa
return hr; return hr;
} }
static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexDeclaration(IDirect3DDevice8 *iface, CONST DWORD *declaration, IDirect3DVertexDeclaration8 **decl_ptr) { static HRESULT IDirect3DDevice8Impl_CreateVertexDeclaration(IDirect3DDevice8 *iface, CONST DWORD *declaration, IDirect3DVertexDeclaration8 **decl_ptr) {
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
IDirect3DVertexDeclaration8Impl *object; IDirect3DVertexDeclaration8Impl *object;
WINED3DVERTEXELEMENT *wined3d_elements; WINED3DVERTEXELEMENT *wined3d_elements;
@@ -1537,6 +1513,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(LPDIRECT3DDEVICE8
IDirect3DVertexShader8Impl *object; IDirect3DVertexShader8Impl *object;
IWineD3DVertexDeclaration *wined3d_vertex_declaration; IWineD3DVertexDeclaration *wined3d_vertex_declaration;
const DWORD *token = pDeclaration; const DWORD *token = pDeclaration;
shader_handle *handle;
/* Test if the vertex declaration is valid */ /* Test if the vertex declaration is valid */
while (D3DVSD_END() != *token) { while (D3DVSD_END() != *token) {
@@ -1575,41 +1552,57 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateVertexShader(LPDIRECT3DDEVICE8
*ppShader = 0; *ppShader = 0;
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
} }
wined3d_vertex_declaration = ((IDirect3DVertexDeclaration8Impl *)object->vertex_declaration)->wined3d_vertex_declaration;
/* Usage is missing ... Use SetRenderState to set the sw vp render state in SetVertexShader */ handle = alloc_shader_handle(This);
hrc = IWineD3DDevice_CreateVertexShader(This->WineD3DDevice, wined3d_vertex_declaration, pFunction, &object->wineD3DVertexShader, (IUnknown *)object); if (!handle)
{
if (FAILED(hrc)) { ERR("Failed to allocate shader handle\n");
/* free up object */ LeaveCriticalSection(&d3d8_cs);
FIXME("Call to IWineD3DDevice_CreateVertexShader failed\n"); IDirect3DVertexDeclaration8_Release(object->vertex_declaration);
HeapFree(GetProcessHeap(), 0, object); HeapFree(GetProcessHeap(), 0, object);
*ppShader = 0; *ppShader = 0;
} else { return E_OUTOFMEMORY;
/* TODO: Store the VS declarations locally so that they can be dereferenced with a value higher than VS_HIGHESTFIXEDFXF */ }
shader_handle *handle = alloc_shader_handle(This); else
if (!handle) { {
ERR("Failed to allocate shader handle\n"); DWORD shader_handle = (handle - This->shader_handles) + VS_HIGHESTFIXEDFXF + 1;
IDirect3DVertexShader8_Release((IUnknown *)object); *handle = object;
hrc = E_OUTOFMEMORY; *ppShader = ((IDirect3DVertexDeclaration8Impl *)object->vertex_declaration)->shader_handle = shader_handle;
} else { }
*handle = object;
object->handle = (handle - This->shader_handles) + VS_HIGHESTFIXEDFXF + 1;
*ppShader = object->handle;
wined3d_vertex_declaration = ((IDirect3DVertexDeclaration8Impl *)object->vertex_declaration)->wined3d_vertex_declaration;
if (pFunction)
{
/* Usage is missing ... Use SetRenderState to set the sw vp render state in SetVertexShader */
hrc = IWineD3DDevice_CreateVertexShader(This->WineD3DDevice, wined3d_vertex_declaration,
pFunction, &object->wineD3DVertexShader, (IUnknown *)object);
if (FAILED(hrc))
{
/* free up object */
FIXME("Call to IWineD3DDevice_CreateVertexShader failed\n");
free_shader_handle(This, handle);
IDirect3DVertexDeclaration8_Release(object->vertex_declaration);
HeapFree(GetProcessHeap(), 0, object);
*ppShader = 0;
}
else
{
load_local_constants(pDeclaration, object->wineD3DVertexShader); load_local_constants(pDeclaration, object->wineD3DVertexShader);
TRACE("(%p) : returning %p (handle %#x)\n", This, object, *ppShader); TRACE("(%p) : returning %p (handle %#x)\n", This, object, *ppShader);
} }
} }
LeaveCriticalSection(&d3d8_cs); LeaveCriticalSection(&d3d8_cs);
return hrc; return hrc;
} }
IWineD3DVertexDeclaration *IDirect3DDevice8Impl_FindDecl(IDirect3DDevice8Impl *This, DWORD fvf) static IDirect3DVertexDeclaration8Impl *IDirect3DDevice8Impl_FindDecl(IDirect3DDevice8Impl *This, DWORD fvf)
{ {
IDirect3DVertexDeclaration8Impl *d3d8_declaration;
HRESULT hr; HRESULT hr;
IWineD3DVertexDeclaration* pDecl = NULL;
int p, low, high; /* deliberately signed */ int p, low, high; /* deliberately signed */
struct FvfToDecl *convertedDecls = This->decls; struct FvfToDecl *convertedDecls = This->decls;
@@ -1622,7 +1615,7 @@ IWineD3DVertexDeclaration *IDirect3DDevice8Impl_FindDecl(IDirect3DDevice8Impl *T
TRACE("%d ", p); TRACE("%d ", p);
if(convertedDecls[p].fvf == fvf) { if(convertedDecls[p].fvf == fvf) {
TRACE("found %p\n", convertedDecls[p].decl); TRACE("found %p\n", convertedDecls[p].decl);
return convertedDecls[p].decl; return (IDirect3DVertexDeclaration8Impl *)convertedDecls[p].decl;
} else if(convertedDecls[p].fvf < fvf) { } else if(convertedDecls[p].fvf < fvf) {
low = p + 1; low = p + 1;
} else { } else {
@@ -1631,11 +1624,27 @@ IWineD3DVertexDeclaration *IDirect3DDevice8Impl_FindDecl(IDirect3DDevice8Impl *T
} }
TRACE("not found. Creating and inserting at position %d.\n", low); TRACE("not found. Creating and inserting at position %d.\n", low);
d3d8_declaration = HeapAlloc(GetProcessHeap(), 0, sizeof(*d3d8_declaration));
if (!d3d8_declaration)
{
ERR("Memory allocation failed.\n");
return NULL;
}
d3d8_declaration->ref_count = 1;
d3d8_declaration->lpVtbl = &Direct3DVertexDeclaration8_Vtbl;
d3d8_declaration->elements = NULL;
d3d8_declaration->elements_size = 0;
d3d8_declaration->shader_handle = fvf;
hr = IWineD3DDevice_CreateVertexDeclarationFromFVF(This->WineD3DDevice, hr = IWineD3DDevice_CreateVertexDeclarationFromFVF(This->WineD3DDevice,
&pDecl, &d3d8_declaration->wined3d_vertex_declaration, (IUnknown *)d3d8_declaration, fvf);
(IUnknown *) This, if (FAILED(hr))
fvf); {
if (FAILED(hr)) return NULL; ERR("Failed to create wined3d vertex declaration.\n");
HeapFree(GetProcessHeap(), 0, d3d8_declaration);
return NULL;
}
if(This->declArraySize == This->numConvertedDecls) { if(This->declArraySize == This->numConvertedDecls) {
int grow = This->declArraySize / 2; int grow = This->declArraySize / 2;
@@ -1643,7 +1652,7 @@ IWineD3DVertexDeclaration *IDirect3DDevice8Impl_FindDecl(IDirect3DDevice8Impl *T
sizeof(convertedDecls[0]) * (This->numConvertedDecls + grow)); sizeof(convertedDecls[0]) * (This->numConvertedDecls + grow));
if(!convertedDecls) { if(!convertedDecls) {
/* This will destroy it */ /* This will destroy it */
IWineD3DVertexDeclaration_Release(pDecl); IDirect3DVertexDeclaration8_Release((IDirect3DVertexDeclaration8 *)d3d8_declaration);
return NULL; return NULL;
} }
This->decls = convertedDecls; This->decls = convertedDecls;
@@ -1651,12 +1660,12 @@ IWineD3DVertexDeclaration *IDirect3DDevice8Impl_FindDecl(IDirect3DDevice8Impl *T
} }
memmove(convertedDecls + low + 1, convertedDecls + low, sizeof(convertedDecls[0]) * (This->numConvertedDecls - low)); memmove(convertedDecls + low + 1, convertedDecls + low, sizeof(convertedDecls[0]) * (This->numConvertedDecls - low));
convertedDecls[low].decl = pDecl; convertedDecls[low].decl = (IDirect3DVertexDeclaration8 *)d3d8_declaration;
convertedDecls[low].fvf = fvf; convertedDecls[low].fvf = fvf;
This->numConvertedDecls++; This->numConvertedDecls++;
TRACE("Returning %p. %d decls in array\n", pDecl, This->numConvertedDecls); TRACE("Returning %p. %u decls in array\n", d3d8_declaration, This->numConvertedDecls);
return pDecl; return d3d8_declaration;
} }
static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) { static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(LPDIRECT3DDEVICE8 iface, DWORD pShader) {
@@ -1666,9 +1675,9 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(LPDIRECT3DDEVICE8 ifa
TRACE("(%p) : Relay\n", This); TRACE("(%p) : Relay\n", This);
EnterCriticalSection(&d3d8_cs); EnterCriticalSection(&d3d8_cs);
if (VS_HIGHESTFIXEDFXF >= pShader) { if (VS_HIGHESTFIXEDFXF >= pShader) {
TRACE("Setting FVF, %d %d\n", VS_HIGHESTFIXEDFXF, pShader); TRACE("Setting FVF, %#x\n", pShader);
IWineD3DDevice_SetFVF(This->WineD3DDevice, pShader); IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice,
IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice, IDirect3DDevice8Impl_FindDecl(This, pShader)); IDirect3DDevice8Impl_FindDecl(This, pShader)->wined3d_vertex_declaration);
IWineD3DDevice_SetVertexShader(This->WineD3DDevice, NULL); IWineD3DDevice_SetVertexShader(This->WineD3DDevice, NULL);
} else { } else {
TRACE("Setting shader\n"); TRACE("Setting shader\n");
@@ -1677,9 +1686,19 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(LPDIRECT3DDEVICE8 ifa
hrc = D3DERR_INVALIDCALL; hrc = D3DERR_INVALIDCALL;
} else { } else {
IDirect3DVertexShader8Impl *shader = This->shader_handles[pShader - (VS_HIGHESTFIXEDFXF + 1)]; IDirect3DVertexShader8Impl *shader = This->shader_handles[pShader - (VS_HIGHESTFIXEDFXF + 1)];
IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice,
shader ? ((IDirect3DVertexDeclaration8Impl *)shader->vertex_declaration)->wined3d_vertex_declaration : NULL); if (shader)
hrc = IWineD3DDevice_SetVertexShader(This->WineD3DDevice, 0 == shader ? NULL : shader->wineD3DVertexShader); {
hrc = IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice,
((IDirect3DVertexDeclaration8Impl *)shader->vertex_declaration)->wined3d_vertex_declaration);
if (SUCCEEDED(hrc))
hrc = IWineD3DDevice_SetVertexShader(This->WineD3DDevice, shader->wineD3DVertexShader);
}
else
{
hrc = IWineD3DDevice_SetVertexDeclaration(This->WineD3DDevice, NULL);
if (SUCCEEDED(hrc)) hrc = IWineD3DDevice_SetVertexShader(This->WineD3DDevice, NULL);
}
} }
} }
TRACE("(%p) : returning hr(%u)\n", This, hrc); TRACE("(%p) : returning hr(%u)\n", This, hrc);
@@ -1690,24 +1709,36 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShader(LPDIRECT3DDEVICE8 ifa
static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShader(LPDIRECT3DDEVICE8 iface, DWORD* ppShader) { static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShader(LPDIRECT3DDEVICE8 iface, DWORD* ppShader) {
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface; IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
IWineD3DVertexShader *pShader; IWineD3DVertexDeclaration *wined3d_declaration;
HRESULT hrc = D3D_OK; HRESULT hrc;
TRACE("(%p) : Relay device@%p\n", This, This->WineD3DDevice); TRACE("(%p) : Relay device@%p\n", This, This->WineD3DDevice);
EnterCriticalSection(&d3d8_cs); EnterCriticalSection(&d3d8_cs);
hrc = IWineD3DDevice_GetVertexShader(This->WineD3DDevice, &pShader);
if (D3D_OK == hrc) { hrc = IWineD3DDevice_GetVertexDeclaration(This->WineD3DDevice, &wined3d_declaration);
if(0 != pShader) { if (SUCCEEDED(hrc))
IDirect3DVertexShader8Impl *d3d8_shader; {
hrc = IWineD3DVertexShader_GetParent(pShader, (IUnknown **)&d3d8_shader); if (wined3d_declaration)
IWineD3DVertexShader_Release(pShader); {
*ppShader = d3d8_shader->handle; IDirect3DVertexDeclaration8 *d3d8_declaration;
} else { hrc = IWineD3DVertexDeclaration_GetParent(wined3d_declaration, (IUnknown **)&d3d8_declaration);
IWineD3DVertexDeclaration_Release(wined3d_declaration);
if (SUCCEEDED(hrc))
{
*ppShader = ((IDirect3DVertexDeclaration8Impl *)d3d8_declaration)->shader_handle;
IDirect3DVertexDeclaration8_Release(d3d8_declaration);
}
}
else
{
*ppShader = 0; *ppShader = 0;
hrc = D3D_OK; hrc = D3D_OK;
} }
} else { }
WARN("(%p) : Call to IWineD3DDevice_GetVertexShader failed %u (device %p)\n", This, hrc, This->WineD3DDevice); else
{
WARN("(%p) : Call to IWineD3DDevice_GetVertexDeclaration failed %#x (device %p)\n",
This, hrc, This->WineD3DDevice);
} }
TRACE("(%p) : returning %#x\n", This, *ppShader); TRACE("(%p) : returning %#x\n", This, *ppShader);
LeaveCriticalSection(&d3d8_cs); LeaveCriticalSection(&d3d8_cs);
@@ -1750,7 +1781,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetVertexShaderConstant(LPDIRECT3DDEV
TRACE("(%p) : Relay\n", This); TRACE("(%p) : Relay\n", This);
EnterCriticalSection(&d3d8_cs); EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_SetVertexShaderConstantF(This->WineD3DDevice, Register, (CONST float *)pConstantData, ConstantCount); hr = IWineD3DDevice_SetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, ConstantCount);
LeaveCriticalSection(&d3d8_cs); LeaveCriticalSection(&d3d8_cs);
return hr; return hr;
} }
@@ -1761,7 +1792,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderConstant(LPDIRECT3DDEV
TRACE("(%p) : Relay\n", This); TRACE("(%p) : Relay\n", This);
EnterCriticalSection(&d3d8_cs); EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_GetVertexShaderConstantF(This->WineD3DDevice, Register, (float *)pConstantData, ConstantCount); hr = IWineD3DDevice_GetVertexShaderConstantF(This->WineD3DDevice, Register, pConstantData, ConstantCount);
LeaveCriticalSection(&d3d8_cs); LeaveCriticalSection(&d3d8_cs);
return hr; return hr;
} }
@@ -1819,7 +1850,16 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetVertexShaderFunction(LPDIRECT3DDEV
} }
shader = This->shader_handles[pVertexShader - (VS_HIGHESTFIXEDFXF + 1)]; shader = This->shader_handles[pVertexShader - (VS_HIGHESTFIXEDFXF + 1)];
hr = IWineD3DVertexShader_GetFunction(shader->wineD3DVertexShader, pData, pSizeOfData); if (shader->wineD3DVertexShader)
{
hr = IWineD3DVertexShader_GetFunction(shader->wineD3DVertexShader, pData, pSizeOfData);
}
else
{
*pSizeOfData = 0;
hr = D3D_OK;
}
LeaveCriticalSection(&d3d8_cs); LeaveCriticalSection(&d3d8_cs);
return hr; return hr;
} }
@@ -1995,7 +2035,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_SetPixelShaderConstant(LPDIRECT3DDE
TRACE("(%p) Relay\n", This); TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs); EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_SetPixelShaderConstantF(This->WineD3DDevice, Register, (CONST float *)pConstantData, ConstantCount); hr = IWineD3DDevice_SetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, ConstantCount);
LeaveCriticalSection(&d3d8_cs); LeaveCriticalSection(&d3d8_cs);
return hr; return hr;
} }
@@ -2006,7 +2046,7 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetPixelShaderConstant(LPDIRECT3DDEVI
TRACE("(%p) Relay\n", This); TRACE("(%p) Relay\n", This);
EnterCriticalSection(&d3d8_cs); EnterCriticalSection(&d3d8_cs);
hr = IWineD3DDevice_GetPixelShaderConstantF(This->WineD3DDevice, Register, (float *)pConstantData, ConstantCount); hr = IWineD3DDevice_GetPixelShaderConstantF(This->WineD3DDevice, Register, pConstantData, ConstantCount);
LeaveCriticalSection(&d3d8_cs); LeaveCriticalSection(&d3d8_cs);
return hr; return hr;
} }
@@ -2206,34 +2246,6 @@ const IDirect3DDevice8Vtbl Direct3DDevice8_Vtbl =
IDirect3DDevice8Impl_DeletePatch IDirect3DDevice8Impl_DeletePatch
}; };
/* Internal function called back during the CreateDevice to create a render target */
HRESULT WINAPI D3D8CB_CreateSurface(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
WINED3DFORMAT Format, DWORD Usage, WINED3DPOOL Pool, UINT Level,
WINED3DCUBEMAP_FACES Face, IWineD3DSurface **ppSurface,
HANDLE *pSharedHandle) {
HRESULT res = D3D_OK;
IDirect3DSurface8Impl *d3dSurface = NULL;
BOOL Lockable = TRUE;
if((WINED3DPOOL_DEFAULT == Pool && WINED3DUSAGE_DYNAMIC != Usage))
Lockable = FALSE;
TRACE("relay\n");
res = IDirect3DDevice8Impl_CreateSurface((IDirect3DDevice8 *)device, Width, Height, (D3DFORMAT)Format, Lockable, FALSE/*Discard*/, Level, (IDirect3DSurface8 **)&d3dSurface, D3DRTYPE_SURFACE, Usage, Pool, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */);
if (SUCCEEDED(res)) {
*ppSurface = d3dSurface->wineD3DSurface;
d3dSurface->container = pSuperior;
IUnknown_Release(d3dSurface->parentDevice);
d3dSurface->parentDevice = NULL;
d3dSurface->forwardReference = pSuperior;
} else {
FIXME("(%p) IDirect3DDevice8_CreateSurface failed\n", device);
}
return res;
}
ULONG WINAPI D3D8CB_DestroySurface(IWineD3DSurface *pSurface) { ULONG WINAPI D3D8CB_DestroySurface(IWineD3DSurface *pSurface) {
IDirect3DSurface8Impl* surfaceParent; IDirect3DSurface8Impl* surfaceParent;
TRACE("(%p) call back\n", pSurface); TRACE("(%p) call back\n", pSurface);
@@ -2244,3 +2256,234 @@ ULONG WINAPI D3D8CB_DestroySurface(IWineD3DSurface *pSurface) {
surfaceParent->forwardReference = NULL; surfaceParent->forwardReference = NULL;
return IDirect3DSurface8_Release((IDirect3DSurface8*) surfaceParent); return IDirect3DSurface8_Release((IDirect3DSurface8*) surfaceParent);
} }
/* IWineD3DDeviceParent IUnknown methods */
static inline struct IDirect3DDevice8Impl *device_from_device_parent(IWineD3DDeviceParent *iface)
{
return (struct IDirect3DDevice8Impl *)((char*)iface
- FIELD_OFFSET(struct IDirect3DDevice8Impl, device_parent_vtbl));
}
HRESULT STDMETHODCALLTYPE device_parent_QueryInterface(IWineD3DDeviceParent *iface, REFIID riid, void **object)
{
struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
return IDirect3DDevice8Impl_QueryInterface((IDirect3DDevice8 *)This, riid, object);
}
ULONG STDMETHODCALLTYPE device_parent_AddRef(IWineD3DDeviceParent *iface)
{
struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
return IDirect3DDevice8Impl_AddRef((IDirect3DDevice8 *)This);
}
ULONG STDMETHODCALLTYPE device_parent_Release(IWineD3DDeviceParent *iface)
{
struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
return IDirect3DDevice8Impl_Release((IDirect3DDevice8 *)This);
}
/* IWineD3DDeviceParent methods */
static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParent *iface,
IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, DWORD usage,
WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, IWineD3DSurface **surface)
{
struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
IDirect3DSurface8Impl *d3d_surface;
BOOL lockable = TRUE;
HRESULT hr;
TRACE("iface %p, superior %p, width %u, height %u, format %#x, usage %#x,\n"
"\tpool %#x, level %u, face %u, surface %p\n",
iface, superior, width, height, format, usage, pool, level, face, surface);
if (pool == WINED3DPOOL_DEFAULT && !(usage & WINED3DUSAGE_DYNAMIC)) lockable = FALSE;
hr = IDirect3DDevice8Impl_CreateSurface((IDirect3DDevice8 *)This, width, height,
format, lockable, FALSE /* Discard */, level, (IDirect3DSurface8 **)&d3d_surface,
D3DRTYPE_SURFACE, usage, pool, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */);
if (FAILED(hr))
{
ERR("(%p) CreateSurface failed, returning %#x\n", iface, hr);
return hr;
}
*surface = d3d_surface->wineD3DSurface;
d3d_surface->container = superior;
IUnknown_Release(d3d_surface->parentDevice);
d3d_surface->parentDevice = NULL;
d3d_surface->forwardReference = superior;
return hr;
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateRenderTarget(IWineD3DDeviceParent *iface,
IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, WINED3DMULTISAMPLE_TYPE multisample_type,
DWORD multisample_quality, BOOL lockable, IWineD3DSurface **surface)
{
struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
IDirect3DSurface8Impl *d3d_surface;
HRESULT hr;
TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
"\tmultisample_quality %u, lockable %u, surface %p\n",
iface, superior, width, height, format, multisample_type, multisample_quality, lockable, surface);
hr = IDirect3DDevice8_CreateRenderTarget((IDirect3DDevice8 *)This, width, height, format,
multisample_type, lockable, (IDirect3DSurface8 **)&d3d_surface);
if (FAILED(hr))
{
ERR("(%p) CreateRenderTarget failed, returning %#x\n", iface, hr);
return hr;
}
*surface = d3d_surface->wineD3DSurface;
d3d_surface->container = (IUnknown *)This;
d3d_surface->isImplicit = TRUE;
/* Implicit surfaces are created with an refcount of 0 */
IUnknown_Release((IUnknown *)d3d_surface);
return hr;
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateDepthStencilSurface(IWineD3DDeviceParent *iface,
IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, WINED3DMULTISAMPLE_TYPE multisample_type,
DWORD multisample_quality, BOOL discard, IWineD3DSurface **surface)
{
struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
IDirect3DSurface8Impl *d3d_surface;
HRESULT hr;
TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
"\tmultisample_quality %u, discard %u, surface %p\n",
iface, superior, width, height, format, multisample_type, multisample_quality, discard, surface);
hr = IDirect3DDevice8_CreateDepthStencilSurface((IDirect3DDevice8 *)This, width, height, format,
multisample_type, (IDirect3DSurface8 **)&d3d_surface);
if (FAILED(hr))
{
ERR("(%p) CreateDepthStencilSurface failed, returning %#x\n", iface, hr);
return hr;
}
*surface = d3d_surface->wineD3DSurface;
d3d_surface->container = (IUnknown *)This;
d3d_surface->isImplicit = TRUE;
/* Implicit surfaces are created with an refcount of 0 */
IUnknown_Release((IUnknown *)d3d_surface);
return hr;
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent *iface,
IUnknown *superior, UINT width, UINT height, UINT depth, WINED3DFORMAT format,
WINED3DPOOL pool, DWORD usage, IWineD3DVolume **volume)
{
struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
IDirect3DVolume8Impl *object;
HRESULT hr;
TRACE("iface %p, superior %p, width %u, height %u, depth %u, format %#x, pool %#x, usage %#x, volume %p\n",
iface, superior, width, height, depth, format, pool, usage, volume);
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
{
FIXME("Allocation of memory failed\n");
*volume = NULL;
return D3DERR_OUTOFVIDEOMEMORY;
}
object->lpVtbl = &Direct3DVolume8_Vtbl;
object->ref = 1;
hr = IWineD3DDevice_CreateVolume(This->WineD3DDevice, width, height, depth, usage,
format, pool, &object->wineD3DVolume, NULL, (IUnknown *)object);
if (FAILED(hr))
{
ERR("(%p) CreateVolume failed, returning %#x\n", iface, hr);
HeapFree(GetProcessHeap(), 0, object);
*volume = NULL;
return hr;
}
*volume = object->wineD3DVolume;
object->container = superior;
object->forwardReference = superior;
TRACE("(%p) Created volume %p\n", iface, *volume);
return hr;
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDeviceParent *iface,
WINED3DPRESENT_PARAMETERS *present_parameters, IWineD3DSwapChain **swapchain)
{
struct IDirect3DDevice8Impl *This = device_from_device_parent(iface);
IDirect3DSwapChain8Impl *d3d_swapchain;
D3DPRESENT_PARAMETERS local_parameters;
HRESULT hr;
TRACE("iface %p, present_parameters %p, swapchain %p\n", iface, present_parameters, swapchain);
/* Copy the presentation parameters */
local_parameters.BackBufferWidth = present_parameters->BackBufferWidth;
local_parameters.BackBufferHeight = present_parameters->BackBufferHeight;
local_parameters.BackBufferFormat = present_parameters->BackBufferFormat;
local_parameters.BackBufferCount = present_parameters->BackBufferCount;
local_parameters.MultiSampleType = present_parameters->MultiSampleType;
local_parameters.SwapEffect = present_parameters->SwapEffect;
local_parameters.hDeviceWindow = present_parameters->hDeviceWindow;
local_parameters.Windowed = present_parameters->Windowed;
local_parameters.EnableAutoDepthStencil = present_parameters->EnableAutoDepthStencil;
local_parameters.AutoDepthStencilFormat = present_parameters->AutoDepthStencilFormat;
local_parameters.Flags = present_parameters->Flags;
local_parameters.FullScreen_RefreshRateInHz = present_parameters->FullScreen_RefreshRateInHz;
local_parameters.FullScreen_PresentationInterval = present_parameters->PresentationInterval;
hr = IDirect3DDevice8_CreateAdditionalSwapChain((IDirect3DDevice8 *)This,
&local_parameters, (IDirect3DSwapChain8 **)&d3d_swapchain);
if (FAILED(hr))
{
ERR("(%p) CreateAdditionalSwapChain failed, returning %#x\n", iface, hr);
*swapchain = NULL;
return hr;
}
*swapchain = d3d_swapchain->wineD3DSwapChain;
IUnknown_Release(d3d_swapchain->parentDevice);
d3d_swapchain->parentDevice = NULL;
/* Copy back the presentation parameters */
present_parameters->BackBufferWidth = local_parameters.BackBufferWidth;
present_parameters->BackBufferHeight = local_parameters.BackBufferHeight;
present_parameters->BackBufferFormat = local_parameters.BackBufferFormat;
present_parameters->BackBufferCount = local_parameters.BackBufferCount;
present_parameters->MultiSampleType = local_parameters.MultiSampleType;
present_parameters->SwapEffect = local_parameters.SwapEffect;
present_parameters->hDeviceWindow = local_parameters.hDeviceWindow;
present_parameters->Windowed = local_parameters.Windowed;
present_parameters->EnableAutoDepthStencil = local_parameters.EnableAutoDepthStencil;
present_parameters->AutoDepthStencilFormat = local_parameters.AutoDepthStencilFormat;
present_parameters->Flags = local_parameters.Flags;
present_parameters->FullScreen_RefreshRateInHz = local_parameters.FullScreen_RefreshRateInHz;
present_parameters->PresentationInterval = local_parameters.FullScreen_PresentationInterval;
return hr;
}
const IWineD3DDeviceParentVtbl d3d8_wined3d_device_parent_vtbl =
{
/* IUnknown methods */
device_parent_QueryInterface,
device_parent_AddRef,
device_parent_Release,
/* IWineD3DDeviceParent methods */
device_parent_CreateSurface,
device_parent_CreateRenderTarget,
device_parent_CreateDepthStencilSurface,
device_parent_CreateVolume,
device_parent_CreateSwapChain,
};

View File

@@ -260,31 +260,6 @@ static HMONITOR WINAPI IDirect3D8Impl_GetAdapterMonitor(LPDIRECT3D8 iface, UINT
return ret; return ret;
} }
/* Internal function called back during the CreateDevice to create a render target */
HRESULT WINAPI D3D8CB_CreateRenderTarget(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
WINED3DFORMAT Format, WINED3DMULTISAMPLE_TYPE MultiSample,
DWORD MultisampleQuality, BOOL Lockable,
IWineD3DSurface** ppSurface, HANDLE* pSharedHandle) {
HRESULT res = D3D_OK;
IDirect3DSurface8Impl *d3dSurface = NULL;
TRACE("(%p) call back\n", device);
res = IDirect3DDevice8_CreateRenderTarget((IDirect3DDevice8 *)device, Width, Height,
(D3DFORMAT)Format, MultiSample, Lockable,
(IDirect3DSurface8 **)&d3dSurface);
if (SUCCEEDED(res)) {
*ppSurface = d3dSurface->wineD3DSurface;
d3dSurface->container = device;
d3dSurface->isImplicit = TRUE;
/* Implicit surfaces are created with an refcount of 0 */
IUnknown_Release((IUnknown *)d3dSurface);
} else {
*ppSurface = NULL;
}
return res;
}
ULONG WINAPI D3D8CB_DestroyRenderTarget(IWineD3DSurface *pSurface) { ULONG WINAPI D3D8CB_DestroyRenderTarget(IWineD3DSurface *pSurface) {
IDirect3DSurface8Impl* surfaceParent; IDirect3DSurface8Impl* surfaceParent;
TRACE("(%p) call back\n", pSurface); TRACE("(%p) call back\n", pSurface);
@@ -295,58 +270,6 @@ ULONG WINAPI D3D8CB_DestroyRenderTarget(IWineD3DSurface *pSurface) {
return IDirect3DSurface8_Release((IDirect3DSurface8*) surfaceParent); return IDirect3DSurface8_Release((IDirect3DSurface8*) surfaceParent);
} }
/* Callback for creating the implicit swapchain when the device is created */
static HRESULT WINAPI D3D8CB_CreateAdditionalSwapChain(IUnknown *device,
WINED3DPRESENT_PARAMETERS* pPresentationParameters,
IWineD3DSwapChain ** ppSwapChain){
HRESULT res = D3D_OK;
IDirect3DSwapChain8Impl *d3dSwapChain = NULL;
D3DPRESENT_PARAMETERS localParameters;
TRACE("(%p) call back\n", device);
/* Copy the presentation parameters */
localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
localParameters.BackBufferFormat = pPresentationParameters->BackBufferFormat;
localParameters.BackBufferCount = pPresentationParameters->BackBufferCount;
localParameters.MultiSampleType = pPresentationParameters->MultiSampleType;
localParameters.SwapEffect = pPresentationParameters->SwapEffect;
localParameters.hDeviceWindow = pPresentationParameters->hDeviceWindow;
localParameters.Windowed = pPresentationParameters->Windowed;
localParameters.EnableAutoDepthStencil = pPresentationParameters->EnableAutoDepthStencil;
localParameters.AutoDepthStencilFormat = pPresentationParameters->AutoDepthStencilFormat;
localParameters.Flags = pPresentationParameters->Flags;
localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
localParameters.FullScreen_PresentationInterval = pPresentationParameters->PresentationInterval;
res = IDirect3DDevice8_CreateAdditionalSwapChain((IDirect3DDevice8 *)device, &localParameters, (IDirect3DSwapChain8 **)&d3dSwapChain);
/* Copy back the presentation parameters */
pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
pPresentationParameters->BackBufferFormat = localParameters.BackBufferFormat;
pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
pPresentationParameters->SwapEffect = localParameters.SwapEffect;
pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
pPresentationParameters->Windowed = localParameters.Windowed;
pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
pPresentationParameters->AutoDepthStencilFormat = localParameters.AutoDepthStencilFormat;
pPresentationParameters->Flags = localParameters.Flags;
pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
pPresentationParameters->PresentationInterval = localParameters.FullScreen_PresentationInterval;
if (SUCCEEDED(res)) {
*ppSwapChain = d3dSwapChain->wineD3DSwapChain;
IUnknown_Release(d3dSwapChain->parentDevice);
d3dSwapChain->parentDevice = NULL;
} else {
*ppSwapChain = NULL;
}
return res;
}
ULONG WINAPI D3D8CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain) { ULONG WINAPI D3D8CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain) {
IUnknown* swapChainParent; IUnknown* swapChainParent;
TRACE("(%p) call back\n", pSwapChain); TRACE("(%p) call back\n", pSwapChain);
@@ -356,27 +279,6 @@ ULONG WINAPI D3D8CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain) {
return IUnknown_Release(swapChainParent); return IUnknown_Release(swapChainParent);
} }
/* Internal function called back during the CreateDevice to create a render target */
HRESULT WINAPI D3D8CB_CreateDepthStencilSurface(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
WINED3DFORMAT Format, WINED3DMULTISAMPLE_TYPE MultiSample,
DWORD MultisampleQuality, BOOL Discard,
IWineD3DSurface** ppSurface, HANDLE* pSharedHandle) {
HRESULT res = D3D_OK;
IDirect3DSurface8Impl *d3dSurface = NULL;
TRACE("(%p) call back\n", device);
res = IDirect3DDevice8_CreateDepthStencilSurface((IDirect3DDevice8 *)device, Width, Height,
(D3DFORMAT)Format, MultiSample, (IDirect3DSurface8 **)&d3dSurface);
if (SUCCEEDED(res)) {
*ppSurface = d3dSurface->wineD3DSurface;
d3dSurface->container = device;
d3dSurface->isImplicit = TRUE;
/* Implicit surfaces are created with an refcount of 0 */
IUnknown_Release((IUnknown *)d3dSurface);
}
return res;
}
ULONG WINAPI D3D8CB_DestroyDepthStencilSurface(IWineD3DSurface *pSurface) { ULONG WINAPI D3D8CB_DestroyDepthStencilSurface(IWineD3DSurface *pSurface) {
IDirect3DSurface8Impl* surfaceParent; IDirect3DSurface8Impl* surfaceParent;
TRACE("(%p) call back\n", pSurface); TRACE("(%p) call back\n", pSurface);
@@ -412,6 +314,7 @@ static HRESULT WINAPI IDirect3D8Impl_CreateDevice(LPDIRECT3D8 iface, UINT Adapte
} }
object->lpVtbl = &Direct3DDevice8_Vtbl; object->lpVtbl = &Direct3DDevice8_Vtbl;
object->device_parent_vtbl = &d3d8_wined3d_device_parent_vtbl;
object->ref = 1; object->ref = 1;
object->shader_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, INITIAL_SHADER_HANDLE_TABLE_SIZE * sizeof(shader_handle)); object->shader_handles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, INITIAL_SHADER_HANDLE_TABLE_SIZE * sizeof(shader_handle));
object->shader_handle_table_size = INITIAL_SHADER_HANDLE_TABLE_SIZE; object->shader_handle_table_size = INITIAL_SHADER_HANDLE_TABLE_SIZE;
@@ -419,7 +322,8 @@ static HRESULT WINAPI IDirect3D8Impl_CreateDevice(LPDIRECT3D8 iface, UINT Adapte
/* Allocate an associated WineD3DDevice object */ /* Allocate an associated WineD3DDevice object */
EnterCriticalSection(&d3d8_cs); EnterCriticalSection(&d3d8_cs);
hr =IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &object->WineD3DDevice, (IUnknown *)object); hr = IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags,
(IUnknown *)object, (IWineD3DDeviceParent *)&object->device_parent_vtbl, &object->WineD3DDevice);
if (hr != D3D_OK) { if (hr != D3D_OK) {
HeapFree(GetProcessHeap(), 0, object); HeapFree(GetProcessHeap(), 0, object);
@@ -450,7 +354,7 @@ static HRESULT WINAPI IDirect3D8Impl_CreateDevice(LPDIRECT3D8 iface, UINT Adapte
IWineD3DDevice_SetMultithreaded(object->WineD3DDevice); IWineD3DDevice_SetMultithreaded(object->WineD3DDevice);
} }
hr = IWineD3DDevice_Init3D(object->WineD3DDevice, &localParameters, D3D8CB_CreateAdditionalSwapChain); hr = IWineD3DDevice_Init3D(object->WineD3DDevice, &localParameters);
LeaveCriticalSection(&d3d8_cs); LeaveCriticalSection(&d3d8_cs);
pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth; pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;

View File

@@ -62,34 +62,10 @@ static ULONG WINAPI IDirect3DPixelShader8Impl_Release(IDirect3DPixelShader8 * if
return ref; return ref;
} }
/* IDirect3DPixelShader8 Interface follow: */
static HRESULT WINAPI IDirect3DPixelShader8Impl_GetDevice(IDirect3DPixelShader8 *iface, IDirect3DDevice8 **ppDevice) {
IDirect3DPixelShader8Impl *This = (IDirect3DPixelShader8Impl *)iface;
IWineD3DDevice *myDevice = NULL;
TRACE("(%p) : Relay\n", This);
IWineD3DPixelShader_GetDevice(This->wineD3DPixelShader, &myDevice);
IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
TRACE("(%p) returning (%p)\n", This, *ppDevice);
return D3D_OK;
}
static HRESULT WINAPI IDirect3DPixelShader8Impl_GetFunction(IDirect3DPixelShader8 *iface, VOID *pData, UINT *pSizeOfData) {
IDirect3DPixelShader8Impl *This = (IDirect3DPixelShader8Impl *)iface;
TRACE("(%p) Relay\n", This);
return IWineD3DPixelShader_GetFunction(This->wineD3DPixelShader, pData, pSizeOfData);
}
const IDirect3DPixelShader8Vtbl Direct3DPixelShader8_Vtbl = const IDirect3DPixelShader8Vtbl Direct3DPixelShader8_Vtbl =
{ {
/* IUnknown */ /* IUnknown */
IDirect3DPixelShader8Impl_QueryInterface, IDirect3DPixelShader8Impl_QueryInterface,
IDirect3DPixelShader8Impl_AddRef, IDirect3DPixelShader8Impl_AddRef,
IDirect3DPixelShader8Impl_Release, IDirect3DPixelShader8Impl_Release,
/* IDirect3DPixelShader8 */
IDirect3DPixelShader8Impl_GetDevice,
IDirect3DPixelShader8Impl_GetFunction
}; };

View File

@@ -206,7 +206,11 @@ static HRESULT WINAPI IDirect3DSurface8Impl_UnlockRect(LPDIRECT3DSURFACE8 iface)
EnterCriticalSection(&d3d8_cs); EnterCriticalSection(&d3d8_cs);
hr = IWineD3DSurface_UnlockRect(This->wineD3DSurface); hr = IWineD3DSurface_UnlockRect(This->wineD3DSurface);
LeaveCriticalSection(&d3d8_cs); LeaveCriticalSection(&d3d8_cs);
return hr; switch(hr)
{
case WINEDDERR_NOTLOCKED: return D3DERR_INVALIDCALL;
default: return hr;
}
} }
const IDirect3DSurface8Vtbl Direct3DSurface8_Vtbl = const IDirect3DSurface8Vtbl Direct3DSurface8_Vtbl =

View File

@@ -57,45 +57,16 @@ static ULONG WINAPI IDirect3DVertexShader8Impl_Release(IDirect3DVertexShader8 *i
if (ref == 0) { if (ref == 0) {
IDirect3DVertexDeclaration8_Release(This->vertex_declaration); IDirect3DVertexDeclaration8_Release(This->vertex_declaration);
IWineD3DVertexShader_Release(This->wineD3DVertexShader); if (This->wineD3DVertexShader) IWineD3DVertexShader_Release(This->wineD3DVertexShader);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
return ref; return ref;
} }
/* IDirect3DVertexShader8 Interface follow: */
static HRESULT WINAPI IDirect3DVertexShader8Impl_GetDevice(IDirect3DVertexShader8 *iface, IDirect3DDevice8** ppDevice) {
IDirect3DVertexShader8Impl *This = (IDirect3DVertexShader8Impl *)iface;
IWineD3DDevice *myDevice = NULL;
HRESULT hr;
TRACE("(%p) : Relay\n", This);
hr = IWineD3DVertexShader_GetDevice(This->wineD3DVertexShader, &myDevice);
if (WINED3D_OK == hr && myDevice != NULL) {
hr = IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
IWineD3DDevice_Release(myDevice);
} else {
*ppDevice = NULL;
}
TRACE("(%p) returning (%p)\n", This, *ppDevice);
return hr;
}
static HRESULT WINAPI IDirect3DVertexShader8Impl_GetFunction(IDirect3DVertexShader8 *iface, VOID* pData, UINT* pSizeOfData) {
IDirect3DVertexShader8Impl *This = (IDirect3DVertexShader8Impl *)iface;
TRACE("(%p) : Relay\n", This);
return IWineD3DVertexShader_GetFunction(This->wineD3DVertexShader, pData, pSizeOfData);
}
const IDirect3DVertexShader8Vtbl Direct3DVertexShader8_Vtbl = const IDirect3DVertexShader8Vtbl Direct3DVertexShader8_Vtbl =
{ {
/* IUnknown */ /* IUnknown */
IDirect3DVertexShader8Impl_QueryInterface, IDirect3DVertexShader8Impl_QueryInterface,
IDirect3DVertexShader8Impl_AddRef, IDirect3DVertexShader8Impl_AddRef,
IDirect3DVertexShader8Impl_Release, IDirect3DVertexShader8Impl_Release,
/* IDirect3DVertexShader8 */
IDirect3DVertexShader8Impl_GetDevice,
IDirect3DVertexShader8Impl_GetFunction
}; };

View File

@@ -192,7 +192,7 @@ static HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(LPDIRECT3DVOLUME8 iface) {
return hr; return hr;
} }
static const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl = const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl =
{ {
/* IUnknown */ /* IUnknown */
IDirect3DVolume8Impl_QueryInterface, IDirect3DVolume8Impl_QueryInterface,
@@ -209,42 +209,6 @@ static const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl =
IDirect3DVolume8Impl_UnlockBox IDirect3DVolume8Impl_UnlockBox
}; };
/* Internal function called back during the CreateVolumeTexture */
HRESULT WINAPI D3D8CB_CreateVolume(IUnknown *pDevice, IUnknown *pSuperior, UINT Width, UINT Height, UINT Depth,
WINED3DFORMAT Format, WINED3DPOOL Pool, DWORD Usage,
IWineD3DVolume **ppVolume,
HANDLE * pSharedHandle) {
IDirect3DVolume8Impl *object;
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)pDevice;
HRESULT hrc = D3D_OK;
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolume8Impl));
if (NULL == object) {
FIXME("Allocation of memory failed\n");
*ppVolume = NULL;
return D3DERR_OUTOFVIDEOMEMORY;
}
object->lpVtbl = &Direct3DVolume8_Vtbl;
object->ref = 1;
hrc = IWineD3DDevice_CreateVolume(This->WineD3DDevice, Width, Height, Depth, Usage, Format,
Pool, &object->wineD3DVolume, pSharedHandle, (IUnknown *)object);
if (hrc != D3D_OK) {
/* free up object */
FIXME("(%p) call to IWineD3DDevice_CreateVolume failed\n", This);
HeapFree(GetProcessHeap(), 0, object);
*ppVolume = NULL;
} else {
*ppVolume = object->wineD3DVolume;
object->container = pSuperior;
object->forwardReference = pSuperior;
}
TRACE("(%p) Created volume %p\n", This, *ppVolume);
return hrc;
}
ULONG WINAPI D3D8CB_DestroyVolume(IWineD3DVolume *pVolume) { ULONG WINAPI D3D8CB_DestroyVolume(IWineD3DVolume *pVolume) {
IDirect3DVolume8Impl* volumeParent; IDirect3DVolume8Impl* volumeParent;

View File

@@ -348,21 +348,20 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateCubeTexture(LPDIRECT3DDEVICE9EX ifac
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (NULL == object) { if (NULL == object) {
FIXME("(%p) allocation of CubeTexture failed\n", This); ERR("(%p) allocation of CubeTexture failed\n", This);
return D3DERR_OUTOFVIDEOMEMORY; return D3DERR_OUTOFVIDEOMEMORY;
} }
object->lpVtbl = &Direct3DCubeTexture9_Vtbl; object->lpVtbl = &Direct3DCubeTexture9_Vtbl;
object->ref = 1; object->ref = 1;
EnterCriticalSection(&d3d9_cs); EnterCriticalSection(&d3d9_cs);
hr = IWineD3DDevice_CreateCubeTexture(This->WineD3DDevice, EdgeLength, Levels, Usage, hr = IWineD3DDevice_CreateCubeTexture(This->WineD3DDevice, EdgeLength, Levels, Usage,
(WINED3DFORMAT)Format, (WINED3DPOOL) Pool, &object->wineD3DCubeTexture, pSharedHandle, (IUnknown*)object, Format, Pool, &object->wineD3DCubeTexture, pSharedHandle, (IUnknown*)object);
D3D9CB_CreateSurface);
LeaveCriticalSection(&d3d9_cs); LeaveCriticalSection(&d3d9_cs);
if (hr != D3D_OK){ if (hr != D3D_OK){
/* free up object */ /* free up object */
FIXME("(%p) call to IWineD3DDevice_CreateCubeTexture failed\n", This); WARN("(%p) call to IWineD3DDevice_CreateCubeTexture failed\n", This);
HeapFree(GetProcessHeap(), 0, object); HeapFree(GetProcessHeap(), 0, object);
} else { } else {
IDirect3DDevice9Ex_AddRef(iface); IDirect3DDevice9Ex_AddRef(iface);

View File

@@ -35,4 +35,6 @@
<file>volume.c</file> <file>volume.c</file>
<file>volumetexture.c</file> <file>volumetexture.c</file>
<file>version.rc</file> <file>version.rc</file>
<dependency>wineheaders</dependency>
</module> </module>

View File

@@ -36,7 +36,7 @@
#include "wine/unicode.h" #include "wine/unicode.h"
#include "d3d9.h" #include "d3d9.h"
#include "wine/wined3d_interface.h" #include "wine/wined3d.h"
/* =========================================================================== /* ===========================================================================
Internal use Internal use
@@ -167,6 +167,7 @@ void filter_caps(D3DCAPS9* pCaps);
* Predeclare the interface implementation structures * Predeclare the interface implementation structures
*/ */
extern const IDirect3DDevice9ExVtbl Direct3DDevice9_Vtbl; extern const IDirect3DDevice9ExVtbl Direct3DDevice9_Vtbl;
extern const IWineD3DDeviceParentVtbl d3d9_wined3d_device_parent_vtbl;
/***************************************************************************** /*****************************************************************************
* IDirect3DDevice9 implementation structure * IDirect3DDevice9 implementation structure
@@ -175,6 +176,7 @@ typedef struct IDirect3DDevice9Impl
{ {
/* IUnknown fields */ /* IUnknown fields */
const IDirect3DDevice9ExVtbl *lpVtbl; const IDirect3DDevice9ExVtbl *lpVtbl;
const IWineD3DDeviceParentVtbl *device_parent_vtbl;
LONG ref; LONG ref;
/* IDirect3DDevice9 fields */ /* IDirect3DDevice9 fields */
@@ -191,7 +193,6 @@ typedef struct IDirect3DDevice9Impl
/* IDirect3DDevice9: */ /* IDirect3DDevice9: */
extern HRESULT WINAPI IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9EX iface, IDirect3D9** ppD3D9);
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE9EX iface, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain); extern HRESULT WINAPI IDirect3DDevice9Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE9EX iface, D3DPRESENT_PARAMETERS* pPresentationParameters, IDirect3DSwapChain9** pSwapChain);
extern HRESULT WINAPI IDirect3DDevice9Impl_GetSwapChain(LPDIRECT3DDEVICE9EX iface, UINT iSwapChain, IDirect3DSwapChain9** pSwapChain); extern HRESULT WINAPI IDirect3DDevice9Impl_GetSwapChain(LPDIRECT3DDEVICE9EX iface, UINT iSwapChain, IDirect3DSwapChain9** pSwapChain);
extern UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(LPDIRECT3DDEVICE9EX iface); extern UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(LPDIRECT3DDEVICE9EX iface);
@@ -206,8 +207,6 @@ extern HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(LPDIRECT3DDEVICE9EX i
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexDeclaration(LPDIRECT3DDEVICE9EX iface, CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl); extern HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexDeclaration(LPDIRECT3DDEVICE9EX iface, CONST D3DVERTEXELEMENT9* pVertexElements, IDirect3DVertexDeclaration9** ppDecl);
extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(LPDIRECT3DDEVICE9EX iface, IDirect3DVertexDeclaration9* pDecl); extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexDeclaration(LPDIRECT3DDEVICE9EX iface, IDirect3DVertexDeclaration9* pDecl);
extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(LPDIRECT3DDEVICE9EX iface, IDirect3DVertexDeclaration9** ppDecl); extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexDeclaration(LPDIRECT3DDEVICE9EX iface, IDirect3DVertexDeclaration9** ppDecl);
extern HRESULT WINAPI IDirect3DDevice9Impl_SetFVF(LPDIRECT3DDEVICE9EX iface, DWORD FVF);
extern HRESULT WINAPI IDirect3DDevice9Impl_GetFVF(LPDIRECT3DDEVICE9EX iface, DWORD* pFVF);
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexShader(LPDIRECT3DDEVICE9EX iface, CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader); extern HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexShader(LPDIRECT3DDEVICE9EX iface, CONST DWORD* pFunction, IDirect3DVertexShader9** ppShader);
extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(LPDIRECT3DDEVICE9EX iface, IDirect3DVertexShader9* pShader); extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShader(LPDIRECT3DDEVICE9EX iface, IDirect3DVertexShader9* pShader);
extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(LPDIRECT3DDEVICE9EX iface, IDirect3DVertexShader9** ppShader); extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(LPDIRECT3DDEVICE9EX iface, IDirect3DVertexShader9** ppShader);
@@ -217,8 +216,6 @@ extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantI(LPDIRECT3D
extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantI(LPDIRECT3DDEVICE9EX iface, UINT StartRegister, int* pConstantData, UINT Vector4iCount); extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantI(LPDIRECT3DDEVICE9EX iface, UINT StartRegister, int* pConstantData, UINT Vector4iCount);
extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount); extern HRESULT WINAPI IDirect3DDevice9Impl_SetVertexShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT StartRegister, CONST BOOL* pConstantData, UINT BoolCount);
extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT StartRegister, BOOL* pConstantData, UINT BoolCount); extern HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShaderConstantB(LPDIRECT3DDEVICE9EX iface, UINT StartRegister, BOOL* pConstantData, UINT BoolCount);
extern HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9EX iface, UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride);
extern HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSource(LPDIRECT3DDEVICE9EX iface, UINT StreamNumber, IDirect3DVertexBuffer9** ppStreamData, UINT* OffsetInBytes, UINT* pStride);
extern HRESULT WINAPI IDirect3DDevice9Impl_CreatePixelShader(LPDIRECT3DDEVICE9EX iface, CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader); extern HRESULT WINAPI IDirect3DDevice9Impl_CreatePixelShader(LPDIRECT3DDEVICE9EX iface, CONST DWORD* pFunction, IDirect3DPixelShader9** ppShader);
extern HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(LPDIRECT3DDEVICE9EX iface, IDirect3DPixelShader9* pShader); extern HRESULT WINAPI IDirect3DDevice9Impl_SetPixelShader(LPDIRECT3DDEVICE9EX iface, IDirect3DPixelShader9* pShader);
extern HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(LPDIRECT3DDEVICE9EX iface, IDirect3DPixelShader9** ppShader); extern HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(LPDIRECT3DDEVICE9EX iface, IDirect3DPixelShader9** ppShader);
@@ -238,6 +235,7 @@ extern HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(LPDIRECT3DDEVICE9EX ifa
/***************************************************************************** /*****************************************************************************
* IDirect3DVolume9 implementation structure * IDirect3DVolume9 implementation structure
*/ */
extern const IDirect3DVolume9Vtbl Direct3DVolume9_Vtbl;
typedef struct IDirect3DVolume9Impl typedef struct IDirect3DVolume9Impl
{ {
/* IUnknown fields */ /* IUnknown fields */
@@ -556,34 +554,10 @@ typedef struct IDirect3DQuery9Impl {
/* Callbacks */ /* Callbacks */
extern HRESULT WINAPI D3D9CB_CreateSurface(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
WINED3DFORMAT Format, DWORD Usage, WINED3DPOOL Pool, UINT Level,
WINED3DCUBEMAP_FACES Face, IWineD3DSurface** ppSurface,
HANDLE* pSharedHandle);
extern HRESULT WINAPI D3D9CB_CreateVolume(IUnknown *pDevice, IUnknown *pSuperior, UINT Width, UINT Height, UINT Depth,
WINED3DFORMAT Format, WINED3DPOOL Pool, DWORD Usage,
IWineD3DVolume **ppVolume,
HANDLE * pSharedHandle);
extern HRESULT WINAPI D3D9CB_CreateDepthStencilSurface(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
WINED3DFORMAT Format, WINED3DMULTISAMPLE_TYPE MultiSample,
DWORD MultisampleQuality, BOOL Discard,
IWineD3DSurface** ppSurface, HANDLE* pSharedHandle);
extern HRESULT WINAPI D3D9CB_CreateRenderTarget(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
WINED3DFORMAT Format, WINED3DMULTISAMPLE_TYPE MultiSample,
DWORD MultisampleQuality, BOOL Lockable,
IWineD3DSurface** ppSurface, HANDLE* pSharedHandle);
extern ULONG WINAPI D3D9CB_DestroySwapChain (IWineD3DSwapChain *pSwapChain); extern ULONG WINAPI D3D9CB_DestroySwapChain (IWineD3DSwapChain *pSwapChain);
extern ULONG WINAPI D3D9CB_DestroyDepthStencilSurface (IWineD3DSurface *pSurface); extern ULONG WINAPI D3D9CB_DestroyDepthStencilSurface (IWineD3DSurface *pSurface);
extern ULONG WINAPI D3D9CB_DestroyRenderTarget (IWineD3DSurface *pSurface); extern ULONG WINAPI D3D9CB_DestroyRenderTarget (IWineD3DSurface *pSurface);
extern ULONG WINAPI D3D9CB_DestroySurface(IWineD3DSurface *pSurface); extern ULONG WINAPI D3D9CB_DestroySurface(IWineD3DSurface *pSurface);
extern ULONG WINAPI D3D9CB_DestroyVolume(IWineD3DVolume *pVolume); extern ULONG WINAPI D3D9CB_DestroyVolume(IWineD3DVolume *pVolume);
#endif /* __WINE_D3D9_PRIVATE_H */ #endif /* __WINE_D3D9_PRIVATE_H */

View File

@@ -59,6 +59,13 @@ static HRESULT WINAPI IDirect3DDevice9Impl_QueryInterface(LPDIRECT3DDEVICE9EX if
} }
} }
if (IsEqualGUID(riid, &IID_IWineD3DDeviceParent))
{
IUnknown_AddRef((IUnknown *)&This->device_parent_vtbl);
*ppobj = &This->device_parent_vtbl;
return S_OK;
}
WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj); WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
*ppobj = NULL; *ppobj = NULL;
return E_NOINTERFACE; return E_NOINTERFACE;
@@ -142,7 +149,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_EvictManagedResources(LPDIRECT3DDEV
return hr; return hr;
} }
HRESULT WINAPI IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9EX iface, IDirect3D9** ppD3D9) { static HRESULT WINAPI IDirect3DDevice9Impl_GetDirect3D(LPDIRECT3DDEVICE9EX iface, IDirect3D9** ppD3D9) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hr = D3D_OK; HRESULT hr = D3D_OK;
IWineD3D* pWineD3D; IWineD3D* pWineD3D;
@@ -478,7 +485,7 @@ static void WINAPI IDirect3DDevice9Impl_GetGammaRamp(LPDIRECT3DDEVICE9EX iface,
} }
static HRESULT WINAPI IDirect3DDevice9Impl_CreateSurface(LPDIRECT3DDEVICE9EX iface, UINT Width, UINT Height, D3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IDirect3DSurface9 **ppSurface,D3DRESOURCETYPE Type, UINT Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality,HANDLE* pSharedHandle ) { static HRESULT IDirect3DDevice9Impl_CreateSurface(LPDIRECT3DDEVICE9EX iface, UINT Width, UINT Height, D3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IDirect3DSurface9 **ppSurface,D3DRESOURCETYPE Type, UINT Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality,HANDLE* pSharedHandle ) {
HRESULT hrc; HRESULT hrc;
IDirect3DSurface9Impl *object; IDirect3DSurface9Impl *object;
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
@@ -577,14 +584,6 @@ static HRESULT WINAPI IDirect3DDevice9Impl_UpdateTexture(LPDIRECT3DDEVICE9EX i
return hr; return hr;
} }
/* This isn't in MSDN!
static HRESULT WINAPI IDirect3DDevice9Impl_GetFrontBuffer(LPDIRECT3DDEVICE9EX iface, IDirect3DSurface9* pDestSurface) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
FIXME("(%p) : stub\n", This);
return D3D_OK;
}
*/
static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTargetData(LPDIRECT3DDEVICE9EX iface, IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface) { static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTargetData(LPDIRECT3DDEVICE9EX iface, IDirect3DSurface9* pRenderTarget, IDirect3DSurface9* pDestSurface) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IDirect3DSurface9Impl *renderTarget = (IDirect3DSurface9Impl *)pRenderTarget; IDirect3DSurface9Impl *renderTarget = (IDirect3DSurface9Impl *)pRenderTarget;
@@ -1016,13 +1015,50 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetTexture(LPDIRECT3DDEVICE9EX ifac
return hr; return hr;
} }
static const WINED3DTEXTURESTAGESTATETYPE tss_lookup[] =
{
WINED3DTSS_FORCE_DWORD, /* 0, unused */
WINED3DTSS_COLOROP, /* 1, D3DTSS_COLOROP */
WINED3DTSS_COLORARG1, /* 2, D3DTSS_COLORARG1 */
WINED3DTSS_COLORARG2, /* 3, D3DTSS_COLORARG2 */
WINED3DTSS_ALPHAOP, /* 4, D3DTSS_ALPHAOP */
WINED3DTSS_ALPHAARG1, /* 5, D3DTSS_ALPHAARG1 */
WINED3DTSS_ALPHAARG2, /* 6, D3DTSS_ALPHAARG2 */
WINED3DTSS_BUMPENVMAT00, /* 7, D3DTSS_BUMPENVMAT00 */
WINED3DTSS_BUMPENVMAT01, /* 8, D3DTSS_BUMPENVMAT01 */
WINED3DTSS_BUMPENVMAT10, /* 9, D3DTSS_BUMPENVMAT10 */
WINED3DTSS_BUMPENVMAT11, /* 10, D3DTSS_BUMPENVMAT11 */
WINED3DTSS_TEXCOORDINDEX, /* 11, D3DTSS_TEXCOORDINDEX */
WINED3DTSS_FORCE_DWORD, /* 12, unused */
WINED3DTSS_FORCE_DWORD, /* 13, unused */
WINED3DTSS_FORCE_DWORD, /* 14, unused */
WINED3DTSS_FORCE_DWORD, /* 15, unused */
WINED3DTSS_FORCE_DWORD, /* 16, unused */
WINED3DTSS_FORCE_DWORD, /* 17, unused */
WINED3DTSS_FORCE_DWORD, /* 18, unused */
WINED3DTSS_FORCE_DWORD, /* 19, unused */
WINED3DTSS_FORCE_DWORD, /* 20, unused */
WINED3DTSS_FORCE_DWORD, /* 21, unused */
WINED3DTSS_BUMPENVLSCALE, /* 22, D3DTSS_BUMPENVLSCALE */
WINED3DTSS_BUMPENVLOFFSET, /* 23, D3DTSS_BUMPENVLOFFSET */
WINED3DTSS_TEXTURETRANSFORMFLAGS, /* 24, D3DTSS_TEXTURETRANSFORMFLAGS */
WINED3DTSS_FORCE_DWORD, /* 25, unused */
WINED3DTSS_COLORARG0, /* 26, D3DTSS_COLORARG0 */
WINED3DTSS_ALPHAARG0, /* 27, D3DTSS_ALPHAARG0 */
WINED3DTSS_RESULTARG, /* 28, D3DTSS_RESULTARG */
WINED3DTSS_FORCE_DWORD, /* 29, unused */
WINED3DTSS_FORCE_DWORD, /* 30, unused */
WINED3DTSS_FORCE_DWORD, /* 31, unused */
WINED3DTSS_CONSTANT, /* 32, D3DTSS_CONSTANT */
};
static HRESULT WINAPI IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVICE9EX iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) { static HRESULT WINAPI IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVICE9EX iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hr; HRESULT hr;
TRACE("(%p) Relay\n" , This); TRACE("(%p) Relay\n" , This);
EnterCriticalSection(&d3d9_cs); EnterCriticalSection(&d3d9_cs);
hr = IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, Type, pValue); hr = IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, tss_lookup[Type], pValue);
LeaveCriticalSection(&d3d9_cs); LeaveCriticalSection(&d3d9_cs);
return hr; return hr;
} }
@@ -1033,7 +1069,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetTextureStageState(LPDIRECT3DDEVI
TRACE("(%p) Relay\n" , This); TRACE("(%p) Relay\n" , This);
EnterCriticalSection(&d3d9_cs); EnterCriticalSection(&d3d9_cs);
hr = IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, Type, Value); hr = IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, tss_lookup[Type], Value);
LeaveCriticalSection(&d3d9_cs); LeaveCriticalSection(&d3d9_cs);
return hr; return hr;
} }
@@ -1243,7 +1279,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_ProcessVertices(LPDIRECT3DDEVICE9EX
return hr; return hr;
} }
IDirect3DVertexDeclaration9 *getConvertedDecl(IDirect3DDevice9Impl *This, DWORD fvf) { static IDirect3DVertexDeclaration9 *getConvertedDecl(IDirect3DDevice9Impl *This, DWORD fvf) {
HRESULT hr; HRESULT hr;
D3DVERTEXELEMENT9* elements = NULL; D3DVERTEXELEMENT9* elements = NULL;
IDirect3DVertexDeclaration9* pDecl = NULL; IDirect3DVertexDeclaration9* pDecl = NULL;
@@ -1300,7 +1336,7 @@ IDirect3DVertexDeclaration9 *getConvertedDecl(IDirect3DDevice9Impl *This, DWORD
return pDecl; return pDecl;
} }
HRESULT WINAPI IDirect3DDevice9Impl_SetFVF(LPDIRECT3DDEVICE9EX iface, DWORD FVF) { static HRESULT WINAPI IDirect3DDevice9Impl_SetFVF(LPDIRECT3DDEVICE9EX iface, DWORD FVF) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hr; HRESULT hr;
TRACE("(%p) Relay\n" , This); TRACE("(%p) Relay\n" , This);
@@ -1322,24 +1358,41 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetFVF(LPDIRECT3DDEVICE9EX iface, DWORD FV
return hr; return hr;
} }
} }
hr = IWineD3DDevice_SetFVF(This->WineD3DDevice, FVF);
LeaveCriticalSection(&d3d9_cs); LeaveCriticalSection(&d3d9_cs);
return hr; return hr;
} }
HRESULT WINAPI IDirect3DDevice9Impl_GetFVF(LPDIRECT3DDEVICE9EX iface, DWORD* pFVF) { static HRESULT WINAPI IDirect3DDevice9Impl_GetFVF(LPDIRECT3DDEVICE9EX iface, DWORD* pFVF) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IDirect3DVertexDeclaration9 *decl;
HRESULT hr; HRESULT hr;
TRACE("(%p) Relay\n" , This); TRACE("(%p) Relay\n" , This);
EnterCriticalSection(&d3d9_cs); hr = IDirect3DDevice9_GetVertexDeclaration(iface, &decl);
hr = IWineD3DDevice_GetFVF(This->WineD3DDevice, pFVF); if (FAILED(hr))
LeaveCriticalSection(&d3d9_cs); {
WARN("Failed to get vertex declaration, %#x\n", hr);
*pFVF = 0;
return hr;
}
if (decl)
{
*pFVF = ((IDirect3DVertexDeclaration9Impl *)decl)->convFVF;
IDirect3DVertexDeclaration9_Release(decl);
}
else
{
*pFVF = 0;
}
TRACE("Returning FVF %#x\n", *pFVF);
return hr; return hr;
} }
HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9EX iface, UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride) { static HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9EX iface, UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hr; HRESULT hr;
TRACE("(%p) Relay\n" , This); TRACE("(%p) Relay\n" , This);
@@ -1352,7 +1405,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_SetStreamSource(LPDIRECT3DDEVICE9EX iface,
return hr; return hr;
} }
HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSource(LPDIRECT3DDEVICE9EX iface, UINT StreamNumber, IDirect3DVertexBuffer9 **pStream, UINT* OffsetInBytes, UINT* pStride) { static HRESULT WINAPI IDirect3DDevice9Impl_GetStreamSource(LPDIRECT3DDEVICE9EX iface, UINT StreamNumber, IDirect3DVertexBuffer9 **pStream, UINT* OffsetInBytes, UINT* pStride) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
IWineD3DVertexBuffer *retStream = NULL; IWineD3DVertexBuffer *retStream = NULL;
HRESULT rc = D3D_OK; HRESULT rc = D3D_OK;
@@ -1702,37 +1755,6 @@ const IDirect3DDevice9ExVtbl Direct3DDevice9_Vtbl =
IDirect3DDevice9ExImpl_GetDisplayModeEx IDirect3DDevice9ExImpl_GetDisplayModeEx
}; };
/* Internal function called back during the CreateDevice to create a render target */
HRESULT WINAPI D3D9CB_CreateSurface(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
WINED3DFORMAT Format, DWORD Usage, WINED3DPOOL Pool, UINT Level,
WINED3DCUBEMAP_FACES Face,IWineD3DSurface** ppSurface,
HANDLE* pSharedHandle) {
HRESULT res = D3D_OK;
IDirect3DSurface9Impl *d3dSurface = NULL;
BOOL Lockable = TRUE;
if((Pool == D3DPOOL_DEFAULT && Usage != D3DUSAGE_DYNAMIC))
Lockable = FALSE;
TRACE("relay\n");
res = IDirect3DDevice9Impl_CreateSurface((IDirect3DDevice9Ex *)device, Width, Height, (D3DFORMAT)Format,
Lockable, FALSE/*Discard*/, Level, (IDirect3DSurface9 **)&d3dSurface, D3DRTYPE_SURFACE,
Usage, (D3DPOOL) Pool, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */, pSharedHandle);
if (SUCCEEDED(res)) {
*ppSurface = d3dSurface->wineD3DSurface;
d3dSurface->container = pSuperior;
IDirect3DDevice9Ex_Release(d3dSurface->parentDevice);
d3dSurface->parentDevice = NULL;
d3dSurface->forwardReference = pSuperior;
} else {
FIXME("(%p) IDirect3DDevice9_CreateSurface failed\n", device);
}
return res;
}
ULONG WINAPI D3D9CB_DestroySurface(IWineD3DSurface *pSurface) { ULONG WINAPI D3D9CB_DestroySurface(IWineD3DSurface *pSurface) {
IDirect3DSurface9Impl* surfaceParent; IDirect3DSurface9Impl* surfaceParent;
TRACE("(%p) call back\n", pSurface); TRACE("(%p) call back\n", pSurface);
@@ -1743,3 +1765,236 @@ ULONG WINAPI D3D9CB_DestroySurface(IWineD3DSurface *pSurface) {
surfaceParent->forwardReference = NULL; surfaceParent->forwardReference = NULL;
return IDirect3DSurface9_Release((IDirect3DSurface9*) surfaceParent); return IDirect3DSurface9_Release((IDirect3DSurface9*) surfaceParent);
} }
/* IWineD3DDeviceParent IUnknown methods */
static inline struct IDirect3DDevice9Impl *device_from_device_parent(IWineD3DDeviceParent *iface)
{
return (struct IDirect3DDevice9Impl *)((char*)iface
- FIELD_OFFSET(struct IDirect3DDevice9Impl, device_parent_vtbl));
}
static HRESULT STDMETHODCALLTYPE device_parent_QueryInterface(IWineD3DDeviceParent *iface, REFIID riid, void **object)
{
struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
return IDirect3DDevice9Impl_QueryInterface((IDirect3DDevice9Ex *)This, riid, object);
}
static ULONG STDMETHODCALLTYPE device_parent_AddRef(IWineD3DDeviceParent *iface)
{
struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
return IDirect3DDevice9Impl_AddRef((IDirect3DDevice9Ex *)This);
}
static ULONG STDMETHODCALLTYPE device_parent_Release(IWineD3DDeviceParent *iface)
{
struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
return IDirect3DDevice9Impl_Release((IDirect3DDevice9Ex *)This);
}
/* IWineD3DDeviceParent methods */
static HRESULT STDMETHODCALLTYPE device_parent_CreateSurface(IWineD3DDeviceParent *iface,
IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, DWORD usage,
WINED3DPOOL pool, UINT level, WINED3DCUBEMAP_FACES face, IWineD3DSurface **surface)
{
struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
IDirect3DSurface9Impl *d3d_surface;
BOOL lockable = TRUE;
HRESULT hr;
TRACE("iface %p, superior %p, width %u, height %u, format %#x, usage %#x,\n"
"\tpool %#x, level %u, face %u, surface %p\n",
iface, superior, width, height, format, usage, pool, level, face, surface);
if (pool == D3DPOOL_DEFAULT && !(usage & D3DUSAGE_DYNAMIC)) lockable = FALSE;
hr = IDirect3DDevice9Impl_CreateSurface((IDirect3DDevice9Ex *)This, width, height,
format, lockable, FALSE /* Discard */, level, (IDirect3DSurface9 **)&d3d_surface,
D3DRTYPE_SURFACE, usage, pool, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */, NULL);
if (FAILED(hr))
{
ERR("(%p) CreateSurface failed, returning %#x\n", iface, hr);
return hr;
}
*surface = d3d_surface->wineD3DSurface;
d3d_surface->container = superior;
IDirect3DDevice9Ex_Release(d3d_surface->parentDevice);
d3d_surface->parentDevice = NULL;
d3d_surface->forwardReference = superior;
return hr;
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateRenderTarget(IWineD3DDeviceParent *iface,
IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, WINED3DMULTISAMPLE_TYPE multisample_type,
DWORD multisample_quality, BOOL lockable, IWineD3DSurface **surface)
{
struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
IDirect3DSurface9Impl *d3d_surface;
HRESULT hr;
TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
"\tmultisample_quality %u, lockable %u, surface %p\n",
iface, superior, width, height, format, multisample_type, multisample_quality, lockable, surface);
hr = IDirect3DDevice9Impl_CreateRenderTarget((IDirect3DDevice9Ex *)This, width, height, format,
multisample_type, multisample_quality, lockable, (IDirect3DSurface9 **)&d3d_surface, NULL);
if (FAILED(hr))
{
ERR("(%p) CreateRenderTarget failed, returning %#x\n", iface, hr);
return hr;
}
*surface = d3d_surface->wineD3DSurface;
d3d_surface->container = superior;
d3d_surface->isImplicit = TRUE;
/* Implicit surfaces are created with an refcount of 0 */
IDirect3DSurface9_Release((IDirect3DSurface9 *)d3d_surface);
return hr;
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateDepthStencilSurface(IWineD3DDeviceParent *iface,
IUnknown *superior, UINT width, UINT height, WINED3DFORMAT format, WINED3DMULTISAMPLE_TYPE multisample_type,
DWORD multisample_quality, BOOL discard, IWineD3DSurface **surface)
{
struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
IDirect3DSurface9Impl *d3d_surface;
HRESULT hr;
TRACE("iface %p, superior %p, width %u, height %u, format %#x, multisample_type %#x,\n"
"\tmultisample_quality %u, discard %u, surface %p\n",
iface, superior, width, height, format, multisample_type, multisample_quality, discard, surface);
hr = IDirect3DDevice9Impl_CreateDepthStencilSurface((IDirect3DDevice9Ex *)This, width, height, format,
multisample_type, multisample_quality, discard, (IDirect3DSurface9 **)&d3d_surface, NULL);
if (FAILED(hr))
{
ERR("(%p) CreateDepthStencilSurface failed, returning %#x\n", iface, hr);
return hr;
}
*surface = d3d_surface->wineD3DSurface;
d3d_surface->container = (IUnknown *)This;
d3d_surface->isImplicit = TRUE;
/* Implicit surfaces are created with an refcount of 0 */
IDirect3DSurface9_Release((IDirect3DSurface9 *)d3d_surface);
return hr;
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateVolume(IWineD3DDeviceParent *iface,
IUnknown *superior, UINT width, UINT height, UINT depth, WINED3DFORMAT format,
WINED3DPOOL pool, DWORD usage, IWineD3DVolume **volume)
{
struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
IDirect3DVolume9Impl *object;
HRESULT hr;
TRACE("iface %p, superior %p, width %u, height %u, depth %u, format %#x, pool %#x, usage %#x, volume %p\n",
iface, superior, width, height, depth, format, pool, usage, volume);
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
{
FIXME("Allocation of memory failed\n");
*volume = NULL;
return D3DERR_OUTOFVIDEOMEMORY;
}
object->lpVtbl = &Direct3DVolume9_Vtbl;
object->ref = 1;
hr = IWineD3DDevice_CreateVolume(This->WineD3DDevice, width, height, depth, usage & WINED3DUSAGE_MASK,
format, pool, &object->wineD3DVolume, NULL, (IUnknown *)object);
if (FAILED(hr))
{
ERR("(%p) CreateVolume failed, returning %#x\n", iface, hr);
HeapFree(GetProcessHeap(), 0, object);
*volume = NULL;
return hr;
}
*volume = object->wineD3DVolume;
object->container = superior;
object->forwardReference = superior;
TRACE("(%p) Created volume %p\n", iface, *volume);
return hr;
}
static HRESULT STDMETHODCALLTYPE device_parent_CreateSwapChain(IWineD3DDeviceParent *iface,
WINED3DPRESENT_PARAMETERS *present_parameters, IWineD3DSwapChain **swapchain)
{
struct IDirect3DDevice9Impl *This = device_from_device_parent(iface);
IDirect3DSwapChain9Impl *d3d_swapchain;
D3DPRESENT_PARAMETERS local_parameters;
HRESULT hr;
TRACE("iface %p, present_parameters %p, swapchain %p\n", iface, present_parameters, swapchain);
/* Copy the presentation parameters */
local_parameters.BackBufferWidth = present_parameters->BackBufferWidth;
local_parameters.BackBufferHeight = present_parameters->BackBufferHeight;
local_parameters.BackBufferFormat = present_parameters->BackBufferFormat;
local_parameters.BackBufferCount = present_parameters->BackBufferCount;
local_parameters.MultiSampleType = present_parameters->MultiSampleType;
local_parameters.MultiSampleQuality = present_parameters->MultiSampleQuality;
local_parameters.SwapEffect = present_parameters->SwapEffect;
local_parameters.hDeviceWindow = present_parameters->hDeviceWindow;
local_parameters.Windowed = present_parameters->Windowed;
local_parameters.EnableAutoDepthStencil = present_parameters->EnableAutoDepthStencil;
local_parameters.AutoDepthStencilFormat = present_parameters->AutoDepthStencilFormat;
local_parameters.Flags = present_parameters->Flags;
local_parameters.FullScreen_RefreshRateInHz = present_parameters->FullScreen_RefreshRateInHz;
local_parameters.PresentationInterval = present_parameters->PresentationInterval;
hr = IDirect3DDevice9Impl_CreateAdditionalSwapChain((IDirect3DDevice9Ex *)This,
&local_parameters, (IDirect3DSwapChain9 **)&d3d_swapchain);
if (FAILED(hr))
{
ERR("(%p) CreateAdditionalSwapChain failed, returning %#x\n", iface, hr);
*swapchain = NULL;
return hr;
}
*swapchain = d3d_swapchain->wineD3DSwapChain;
d3d_swapchain->isImplicit = TRUE;
/* Implicit swap chains are created with an refcount of 0 */
IDirect3DSwapChain9_Release((IDirect3DSwapChain9 *)d3d_swapchain);
/* Copy back the presentation parameters */
present_parameters->BackBufferWidth = local_parameters.BackBufferWidth;
present_parameters->BackBufferHeight = local_parameters.BackBufferHeight;
present_parameters->BackBufferFormat = local_parameters.BackBufferFormat;
present_parameters->BackBufferCount = local_parameters.BackBufferCount;
present_parameters->MultiSampleType = local_parameters.MultiSampleType;
present_parameters->MultiSampleQuality = local_parameters.MultiSampleQuality;
present_parameters->SwapEffect = local_parameters.SwapEffect;
present_parameters->hDeviceWindow = local_parameters.hDeviceWindow;
present_parameters->Windowed = local_parameters.Windowed;
present_parameters->EnableAutoDepthStencil = local_parameters.EnableAutoDepthStencil;
present_parameters->AutoDepthStencilFormat = local_parameters.AutoDepthStencilFormat;
present_parameters->Flags = local_parameters.Flags;
present_parameters->FullScreen_RefreshRateInHz = local_parameters.FullScreen_RefreshRateInHz;
present_parameters->PresentationInterval = local_parameters.PresentationInterval;
return hr;
}
const IWineD3DDeviceParentVtbl d3d9_wined3d_device_parent_vtbl =
{
/* IUnknown methods */
device_parent_QueryInterface,
device_parent_AddRef,
device_parent_Release,
/* IWineD3DDeviceParent methods */
device_parent_CreateSurface,
device_parent_CreateRenderTarget,
device_parent_CreateDepthStencilSurface,
device_parent_CreateVolume,
device_parent_CreateSwapChain,
};

View File

@@ -329,30 +329,6 @@ static HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9EX iface, UIN
return ret; return ret;
} }
/* Internal function called back during the CreateDevice to create a render target */
HRESULT WINAPI D3D9CB_CreateRenderTarget(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
WINED3DFORMAT Format, WINED3DMULTISAMPLE_TYPE MultiSample,
DWORD MultisampleQuality, BOOL Lockable,
IWineD3DSurface** ppSurface, HANDLE* pSharedHandle) {
HRESULT res = D3D_OK;
IDirect3DSurface9Impl *d3dSurface = NULL;
TRACE("(%p) call back\n", device);
res = IDirect3DDevice9_CreateRenderTarget((IDirect3DDevice9 *)device, Width, Height,
(D3DFORMAT)Format, MultiSample, MultisampleQuality, Lockable,
(IDirect3DSurface9 **)&d3dSurface, pSharedHandle);
if (SUCCEEDED(res)) {
*ppSurface = d3dSurface->wineD3DSurface;
d3dSurface->container = pSuperior;
d3dSurface->isImplicit = TRUE;
/* Implicit surfaces are created with an refcount of 0 */
IDirect3DSurface9_Release((IDirect3DSurface9 *)d3dSurface);
} else {
*ppSurface = NULL;
}
return res;
}
ULONG WINAPI D3D9CB_DestroyRenderTarget(IWineD3DSurface *pSurface) { ULONG WINAPI D3D9CB_DestroyRenderTarget(IWineD3DSurface *pSurface) {
IDirect3DSurface9Impl* surfaceParent; IDirect3DSurface9Impl* surfaceParent;
TRACE("(%p) call back\n", pSurface); TRACE("(%p) call back\n", pSurface);
@@ -363,60 +339,6 @@ ULONG WINAPI D3D9CB_DestroyRenderTarget(IWineD3DSurface *pSurface) {
return IDirect3DSurface9_Release((IDirect3DSurface9*) surfaceParent); return IDirect3DSurface9_Release((IDirect3DSurface9*) surfaceParent);
} }
static HRESULT WINAPI D3D9CB_CreateAdditionalSwapChain(IUnknown *device,
WINED3DPRESENT_PARAMETERS* pPresentationParameters,
IWineD3DSwapChain ** ppSwapChain) {
HRESULT res = D3D_OK;
IDirect3DSwapChain9Impl *d3dSwapChain = NULL;
D3DPRESENT_PARAMETERS localParameters;
TRACE("(%p) call back\n", device);
/* Copy the presentation parameters */
localParameters.BackBufferWidth = pPresentationParameters->BackBufferWidth;
localParameters.BackBufferHeight = pPresentationParameters->BackBufferHeight;
localParameters.BackBufferFormat = pPresentationParameters->BackBufferFormat;
localParameters.BackBufferCount = pPresentationParameters->BackBufferCount;
localParameters.MultiSampleType = pPresentationParameters->MultiSampleType;
localParameters.MultiSampleQuality = pPresentationParameters->MultiSampleQuality;
localParameters.SwapEffect = pPresentationParameters->SwapEffect;
localParameters.hDeviceWindow = pPresentationParameters->hDeviceWindow;
localParameters.Windowed = pPresentationParameters->Windowed;
localParameters.EnableAutoDepthStencil = pPresentationParameters->EnableAutoDepthStencil;
localParameters.AutoDepthStencilFormat = pPresentationParameters->AutoDepthStencilFormat;
localParameters.Flags = pPresentationParameters->Flags;
localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
localParameters.PresentationInterval = pPresentationParameters->PresentationInterval;
res = IDirect3DDevice9_CreateAdditionalSwapChain((IDirect3DDevice9 *)device, &localParameters, (IDirect3DSwapChain9 **)&d3dSwapChain);
if (SUCCEEDED(res)) {
*ppSwapChain = d3dSwapChain->wineD3DSwapChain;
d3dSwapChain->isImplicit = TRUE;
/* Implicit swap chains are created with an refcount of 0 */
IDirect3DSwapChain9_Release((IDirect3DSwapChain9 *)d3dSwapChain);
} else {
*ppSwapChain = NULL;
}
/* Copy back the presentation parameters */
pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;
pPresentationParameters->BackBufferFormat = localParameters.BackBufferFormat;
pPresentationParameters->BackBufferCount = localParameters.BackBufferCount;
pPresentationParameters->MultiSampleType = localParameters.MultiSampleType;
pPresentationParameters->MultiSampleQuality = localParameters.MultiSampleQuality;
pPresentationParameters->SwapEffect = localParameters.SwapEffect;
pPresentationParameters->hDeviceWindow = localParameters.hDeviceWindow;
pPresentationParameters->Windowed = localParameters.Windowed;
pPresentationParameters->EnableAutoDepthStencil = localParameters.EnableAutoDepthStencil;
pPresentationParameters->AutoDepthStencilFormat = localParameters.AutoDepthStencilFormat;
pPresentationParameters->Flags = localParameters.Flags;
pPresentationParameters->FullScreen_RefreshRateInHz = localParameters.FullScreen_RefreshRateInHz;
pPresentationParameters->PresentationInterval = localParameters.PresentationInterval;
return res;
}
ULONG WINAPI D3D9CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain) { ULONG WINAPI D3D9CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain) {
IDirect3DSwapChain9Impl* swapChainParent; IDirect3DSwapChain9Impl* swapChainParent;
TRACE("(%p) call back\n", pSwapChain); TRACE("(%p) call back\n", pSwapChain);
@@ -427,28 +349,6 @@ ULONG WINAPI D3D9CB_DestroySwapChain(IWineD3DSwapChain *pSwapChain) {
return IDirect3DSwapChain9_Release((IDirect3DSwapChain9*) swapChainParent); return IDirect3DSwapChain9_Release((IDirect3DSwapChain9*) swapChainParent);
} }
/* Internal function called back during the CreateDevice to create a render target */
HRESULT WINAPI D3D9CB_CreateDepthStencilSurface(IUnknown *device, IUnknown *pSuperior, UINT Width, UINT Height,
WINED3DFORMAT Format, WINED3DMULTISAMPLE_TYPE MultiSample,
DWORD MultisampleQuality, BOOL Discard,
IWineD3DSurface** ppSurface, HANDLE* pSharedHandle) {
HRESULT res = D3D_OK;
IDirect3DSurface9Impl *d3dSurface = NULL;
TRACE("(%p) call back\n", device);
res = IDirect3DDevice9_CreateDepthStencilSurface((IDirect3DDevice9 *)device, Width, Height,
(D3DFORMAT)Format, MultiSample, MultisampleQuality, Discard,
(IDirect3DSurface9 **)&d3dSurface, pSharedHandle);
if (SUCCEEDED(res)) {
*ppSurface = d3dSurface->wineD3DSurface;
d3dSurface->container = device;
d3dSurface->isImplicit = TRUE;
/* Implicit surfaces are created with an refcount of 0 */
IDirect3DSurface9_Release((IDirect3DSurface9 *)d3dSurface);
}
return res;
}
ULONG WINAPI D3D9CB_DestroyDepthStencilSurface(IWineD3DSurface *pSurface) { ULONG WINAPI D3D9CB_DestroyDepthStencilSurface(IWineD3DSurface *pSurface) {
IDirect3DSurface9Impl* surfaceParent; IDirect3DSurface9Impl* surfaceParent;
TRACE("(%p) call back\n", pSurface); TRACE("(%p) call back\n", pSurface);
@@ -485,13 +385,14 @@ static HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9EX iface, UINT Adap
} }
object->lpVtbl = &Direct3DDevice9_Vtbl; object->lpVtbl = &Direct3DDevice9_Vtbl;
object->device_parent_vtbl = &d3d9_wined3d_device_parent_vtbl;
object->ref = 1; object->ref = 1;
*ppReturnedDeviceInterface = (IDirect3DDevice9 *)object; *ppReturnedDeviceInterface = (IDirect3DDevice9 *)object;
/* Allocate an associated WineD3DDevice object */ /* Allocate an associated WineD3DDevice object */
EnterCriticalSection(&d3d9_cs); EnterCriticalSection(&d3d9_cs);
hr =IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags, &object->WineD3DDevice, (IUnknown *)object); hr = IWineD3D_CreateDevice(This->WineD3D, Adapter, DeviceType, hFocusWindow, BehaviourFlags,
(IUnknown *)object, (IWineD3DDeviceParent *)&object->device_parent_vtbl, &object->WineD3DDevice);
if (hr != D3D_OK) { if (hr != D3D_OK) {
HeapFree(GetProcessHeap(), 0, object); HeapFree(GetProcessHeap(), 0, object);
*ppReturnedDeviceInterface = NULL; *ppReturnedDeviceInterface = NULL;
@@ -521,7 +422,7 @@ static HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9EX iface, UINT Adap
IWineD3DDevice_SetMultithreaded(object->WineD3DDevice); IWineD3DDevice_SetMultithreaded(object->WineD3DDevice);
} }
hr = IWineD3DDevice_Init3D(object->WineD3DDevice, &localParameters, D3D9CB_CreateAdditionalSwapChain); hr = IWineD3DDevice_Init3D(object->WineD3DDevice, &localParameters);
pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth; pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;
pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight; pPresentationParameters->BackBufferHeight = localParameters.BackBufferHeight;

View File

@@ -170,11 +170,21 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetPixelShader(LPDIRECT3DDEVICE9EX iface, ID
EnterCriticalSection(&d3d9_cs); EnterCriticalSection(&d3d9_cs);
hrc = IWineD3DDevice_GetPixelShader(This->WineD3DDevice, &object); hrc = IWineD3DDevice_GetPixelShader(This->WineD3DDevice, &object);
if (hrc == D3D_OK && object != NULL) { if (SUCCEEDED(hrc))
hrc = IWineD3DPixelShader_GetParent(object, (IUnknown **)ppShader); {
IWineD3DPixelShader_Release(object); if (object)
} else { {
*ppShader = NULL; hrc = IWineD3DPixelShader_GetParent(object, (IUnknown **)ppShader);
IWineD3DPixelShader_Release(object);
}
else
{
*ppShader = NULL;
}
}
else
{
WARN("(%p) : Call to IWineD3DDevice_GetPixelShader failed %u (device %p)\n", This, hrc, This->WineD3DDevice);
} }
LeaveCriticalSection(&d3d9_cs); LeaveCriticalSection(&d3d9_cs);

View File

@@ -163,7 +163,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(LPDIRECT3DDEVICE9EX iface, D3DQU
/* Allocate the storage for the device */ /* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DQuery9Impl)); object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DQuery9Impl));
if (NULL == object) { if (NULL == object) {
FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n"); ERR("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
return D3DERR_OUTOFVIDEOMEMORY; return D3DERR_OUTOFVIDEOMEMORY;
} }
@@ -176,7 +176,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(LPDIRECT3DDEVICE9EX iface, D3DQU
if (FAILED(hr)) { if (FAILED(hr)) {
/* free up object */ /* free up object */
FIXME("(%p) call to IWineD3DDevice_CreateQuery failed\n", This); WARN("(%p) call to IWineD3DDevice_CreateQuery failed\n", This);
HeapFree(GetProcessHeap(), 0, object); HeapFree(GetProcessHeap(), 0, object);
} else { } else {
IDirect3DDevice9Ex_AddRef(iface); IDirect3DDevice9Ex_AddRef(iface);

View File

@@ -175,7 +175,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(LPDIRECT3DDEVICE9EX iface, I
hr=IWineD3DDevice_EndStateBlock(This->WineD3DDevice,&wineD3DStateBlock); hr=IWineD3DDevice_EndStateBlock(This->WineD3DDevice,&wineD3DStateBlock);
LeaveCriticalSection(&d3d9_cs); LeaveCriticalSection(&d3d9_cs);
if(hr!= D3D_OK){ if(hr!= D3D_OK){
FIXME("IWineD3DDevice_EndStateBlock returned an error\n"); WARN("IWineD3DDevice_EndStateBlock returned an error\n");
return hr; return hr;
} }
/* allocate a new IDirectD3DStateBlock */ /* allocate a new IDirectD3DStateBlock */
@@ -188,6 +188,6 @@ HRESULT WINAPI IDirect3DDevice9Impl_EndStateBlock(LPDIRECT3DDEVICE9EX iface, I
IDirect3DDevice9Ex_AddRef(iface); IDirect3DDevice9Ex_AddRef(iface);
object->parentDevice = iface; object->parentDevice = iface;
*ppSB=(IDirect3DStateBlock9*)object; *ppSB=(IDirect3DStateBlock9*)object;
TRACE("(%p)Returning %p %p\n", This, *ppSB, wineD3DStateBlock); TRACE("(%p) Returning *ppSB %p, wineD3DStateBlock %p\n", This, *ppSB, wineD3DStateBlock);
return D3D_OK; return D3D_OK;
} }

View File

@@ -241,7 +241,11 @@ static HRESULT WINAPI IDirect3DSurface9Impl_UnlockRect(LPDIRECT3DSURFACE9 iface)
EnterCriticalSection(&d3d9_cs); EnterCriticalSection(&d3d9_cs);
hr = IWineD3DSurface_UnlockRect(This->wineD3DSurface); hr = IWineD3DSurface_UnlockRect(This->wineD3DSurface);
LeaveCriticalSection(&d3d9_cs); LeaveCriticalSection(&d3d9_cs);
return hr; switch(hr)
{
case WINEDDERR_NOTLOCKED: return D3DERR_INVALIDCALL;
default: return hr;
}
} }
static HRESULT WINAPI IDirect3DSurface9Impl_GetDC(LPDIRECT3DSURFACE9 iface, HDC* phdc) { static HRESULT WINAPI IDirect3DSurface9Impl_GetDC(LPDIRECT3DSURFACE9 iface, HDC* phdc) {
@@ -263,7 +267,10 @@ static HRESULT WINAPI IDirect3DSurface9Impl_ReleaseDC(LPDIRECT3DSURFACE9 iface,
EnterCriticalSection(&d3d9_cs); EnterCriticalSection(&d3d9_cs);
hr = IWineD3DSurface_ReleaseDC(This->wineD3DSurface, hdc); hr = IWineD3DSurface_ReleaseDC(This->wineD3DSurface, hdc);
LeaveCriticalSection(&d3d9_cs); LeaveCriticalSection(&d3d9_cs);
return hr; switch(hr) {
case WINEDDERR_NODC: return WINED3DERR_INVALIDCALL;
default: return hr;
}
} }

View File

@@ -227,9 +227,11 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateAdditionalSwapChain(LPDIRECT3DDEVICE
localParameters.Flags = pPresentationParameters->Flags; localParameters.Flags = pPresentationParameters->Flags;
localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz; localParameters.FullScreen_RefreshRateInHz = pPresentationParameters->FullScreen_RefreshRateInHz;
localParameters.PresentationInterval = pPresentationParameters->PresentationInterval; localParameters.PresentationInterval = pPresentationParameters->PresentationInterval;
localParameters.AutoRestoreDisplayMode = TRUE;
EnterCriticalSection(&d3d9_cs); EnterCriticalSection(&d3d9_cs);
hrc = IWineD3DDevice_CreateSwapChain(This->WineD3DDevice, &localParameters, &object->wineD3DSwapChain, (IUnknown*)object, D3D9CB_CreateRenderTarget, D3D9CB_CreateDepthStencilSurface, SURFACE_OPENGL); hrc = IWineD3DDevice_CreateSwapChain(This->WineD3DDevice, &localParameters,
&object->wineD3DSwapChain, (IUnknown*)object, SURFACE_OPENGL);
LeaveCriticalSection(&d3d9_cs); LeaveCriticalSection(&d3d9_cs);
pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth; pPresentationParameters->BackBufferWidth = localParameters.BackBufferWidth;

View File

@@ -339,7 +339,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateTexture(LPDIRECT3DDEVICE9EX iface, U
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DTexture9Impl)); object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DTexture9Impl));
if (NULL == object) { if (NULL == object) {
FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n"); ERR("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
return D3DERR_OUTOFVIDEOMEMORY; return D3DERR_OUTOFVIDEOMEMORY;
} }
@@ -347,13 +347,12 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateTexture(LPDIRECT3DDEVICE9EX iface, U
object->ref = 1; object->ref = 1;
EnterCriticalSection(&d3d9_cs); EnterCriticalSection(&d3d9_cs);
hrc = IWineD3DDevice_CreateTexture(This->WineD3DDevice, Width, Height, Levels, Usage & WINED3DUSAGE_MASK, hrc = IWineD3DDevice_CreateTexture(This->WineD3DDevice, Width, Height, Levels, Usage & WINED3DUSAGE_MASK,
(WINED3DFORMAT)Format, (WINED3DPOOL) Pool, &object->wineD3DTexture, pSharedHandle, (IUnknown *)object, D3D9CB_CreateSurface); Format, Pool, &object->wineD3DTexture, pSharedHandle, (IUnknown *)object);
LeaveCriticalSection(&d3d9_cs); LeaveCriticalSection(&d3d9_cs);
if (FAILED(hrc)) { if (FAILED(hrc)) {
/* free up object */ /* free up object */
FIXME("(%p) call to IWineD3DDevice_CreateTexture failed\n", This); WARN("(%p) call to IWineD3DDevice_CreateTexture failed\n", This);
HeapFree(GetProcessHeap(), 0, object); HeapFree(GetProcessHeap(), 0, object);
} else { } else {
IDirect3DDevice9Ex_AddRef(iface); IDirect3DDevice9Ex_AddRef(iface);

View File

@@ -96,6 +96,10 @@ HRESULT vdecl_convert_fvf(
elements[idx].Type = D3DDECLTYPE_FLOAT4; elements[idx].Type = D3DDECLTYPE_FLOAT4;
elements[idx].Usage = D3DDECLUSAGE_POSITIONT; elements[idx].Usage = D3DDECLUSAGE_POSITIONT;
} }
else if (!has_blend && (fvf & D3DFVF_XYZW) == D3DFVF_XYZW) {
elements[idx].Type = D3DDECLTYPE_FLOAT4;
elements[idx].Usage = D3DDECLUSAGE_POSITION;
}
else { else {
elements[idx].Type = D3DDECLTYPE_FLOAT3; elements[idx].Type = D3DDECLTYPE_FLOAT3;
elements[idx].Usage = D3DDECLUSAGE_POSITION; elements[idx].Usage = D3DDECLUSAGE_POSITION;

View File

@@ -166,10 +166,20 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetVertexShader(LPDIRECT3DDEVICE9EX iface, I
TRACE("(%p) : Relay device@%p\n", This, This->WineD3DDevice); TRACE("(%p) : Relay device@%p\n", This, This->WineD3DDevice);
EnterCriticalSection(&d3d9_cs); EnterCriticalSection(&d3d9_cs);
hrc = IWineD3DDevice_GetVertexShader(This->WineD3DDevice, &pShader); hrc = IWineD3DDevice_GetVertexShader(This->WineD3DDevice, &pShader);
if(hrc == D3D_OK && pShader != NULL){ if (SUCCEEDED(hrc))
hrc = IWineD3DVertexShader_GetParent(pShader, (IUnknown **)ppShader); {
IWineD3DVertexShader_Release(pShader); if (pShader)
} else { {
hrc = IWineD3DVertexShader_GetParent(pShader, (IUnknown **)ppShader);
IWineD3DVertexShader_Release(pShader);
}
else
{
*ppShader = NULL;
}
}
else
{
WARN("(%p) : Call to IWineD3DDevice_GetVertexShader failed %u (device %p)\n", This, hrc, This->WineD3DDevice); WARN("(%p) : Call to IWineD3DDevice_GetVertexShader failed %u (device %p)\n", This, hrc, This->WineD3DDevice);
} }
LeaveCriticalSection(&d3d9_cs); LeaveCriticalSection(&d3d9_cs);

View File

@@ -160,7 +160,7 @@ static HRESULT WINAPI IDirect3DVolume9Impl_UnlockBox(LPDIRECT3DVOLUME9 iface) {
return IWineD3DVolume_UnlockBox(This->wineD3DVolume); return IWineD3DVolume_UnlockBox(This->wineD3DVolume);
} }
static const IDirect3DVolume9Vtbl Direct3DVolume9_Vtbl = const IDirect3DVolume9Vtbl Direct3DVolume9_Vtbl =
{ {
/* IUnknown */ /* IUnknown */
IDirect3DVolume9Impl_QueryInterface, IDirect3DVolume9Impl_QueryInterface,
@@ -177,42 +177,6 @@ static const IDirect3DVolume9Vtbl Direct3DVolume9_Vtbl =
IDirect3DVolume9Impl_UnlockBox IDirect3DVolume9Impl_UnlockBox
}; };
/* Internal function called back during the CreateVolumeTexture */
HRESULT WINAPI D3D9CB_CreateVolume(IUnknown *pDevice, IUnknown *pSuperior, UINT Width, UINT Height, UINT Depth,
WINED3DFORMAT Format, WINED3DPOOL Pool, DWORD Usage,
IWineD3DVolume **ppVolume,
HANDLE * pSharedHandle) {
IDirect3DVolume9Impl *object;
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)pDevice;
HRESULT hrc = D3D_OK;
/* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolume9Impl));
if (NULL == object) {
FIXME("Allocation of memory failed\n");
*ppVolume = NULL;
return D3DERR_OUTOFVIDEOMEMORY;
}
object->lpVtbl = &Direct3DVolume9_Vtbl;
object->ref = 1;
hrc = IWineD3DDevice_CreateVolume(This->WineD3DDevice, Width, Height, Depth, Usage & WINED3DUSAGE_MASK, Format,
Pool, &object->wineD3DVolume, pSharedHandle, (IUnknown *)object);
if (hrc != D3D_OK) {
/* free up object */
FIXME("(%p) call to IWineD3DDevice_CreateVolume failed\n", This);
HeapFree(GetProcessHeap(), 0, object);
*ppVolume = NULL;
} else {
*ppVolume = object->wineD3DVolume;
object->container = pSuperior;
object->forwardReference = pSuperior;
}
TRACE("(%p) Created volume %p\n", This, *ppVolume);
return hrc;
}
ULONG WINAPI D3D9CB_DestroyVolume(IWineD3DVolume *pVolume) { ULONG WINAPI D3D9CB_DestroyVolume(IWineD3DVolume *pVolume) {
IDirect3DVolume9Impl* volumeParent; IDirect3DVolume9Impl* volumeParent;

View File

@@ -252,21 +252,18 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateVolumeTexture(LPDIRECT3DDEVICE9EX if
/* Allocate the storage for the device */ /* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolumeTexture9Impl)); object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVolumeTexture9Impl));
if (NULL == object) { if (NULL == object) {
FIXME("(%p) allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n", This); ERR("(%p) allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n", This);
return D3DERR_OUTOFVIDEOMEMORY; return D3DERR_OUTOFVIDEOMEMORY;
} }
object->lpVtbl = &Direct3DVolumeTexture9_Vtbl; object->lpVtbl = &Direct3DVolumeTexture9_Vtbl;
object->ref = 1; object->ref = 1;
hrc = IWineD3DDevice_CreateVolumeTexture(This->WineD3DDevice, Width, Height, Depth, Levels, Usage & WINED3DUSAGE_MASK, hrc = IWineD3DDevice_CreateVolumeTexture(This->WineD3DDevice, Width, Height, Depth, Levels,
(WINED3DFORMAT)Format, (WINED3DPOOL) Pool, &object->wineD3DVolumeTexture, pSharedHandle, Usage & WINED3DUSAGE_MASK, Format, Pool, &object->wineD3DVolumeTexture, pSharedHandle, (IUnknown *)object);
(IUnknown *)object, D3D9CB_CreateVolume);
if (hrc != D3D_OK) { if (hrc != D3D_OK) {
/* free up object */ /* free up object */
FIXME("(%p) call to IWineD3DDevice_CreateVolumeTexture failed\n", This); WARN("(%p) call to IWineD3DDevice_CreateVolumeTexture failed\n", This);
HeapFree(GetProcessHeap(), 0, object); HeapFree(GetProcessHeap(), 0, object);
} else { } else {
IDirect3DDevice9Ex_AddRef(iface); IDirect3DDevice9Ex_AddRef(iface);

View File

@@ -7,7 +7,7 @@
<directory name="d3d8"> <directory name="d3d8">
<xi:include href="d3d8/d3d8.rbuild" /> <xi:include href="d3d8/d3d8.rbuild" />
</directory> </directory>
<directory name="d3d9"> <!-- <directory name="d3d9">
<xi:include href="d3d9/d3d9.rbuild" /> <xi:include href="d3d9/d3d9.rbuild" />
</directory> </directory> -->
</group> </group>

File diff suppressed because it is too large Load Diff

View File

@@ -26,6 +26,7 @@
#include "wined3d_private.h" #include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader); WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
WINE_DECLARE_DEBUG_CHANNEL(d3d);
/* Some private defines, Constant associations, etc. /* Some private defines, Constant associations, etc.
* Env bump matrix and per stage constant should be independent, * Env bump matrix and per stage constant should be independent,
@@ -158,8 +159,99 @@ static const char *debug_rep(GLuint rep) {
} }
} }
static const char *debug_op(GLuint op) {
switch(op) {
case GL_MOV_ATI: return "GL_MOV_ATI";
case GL_ADD_ATI: return "GL_ADD_ATI";
case GL_MUL_ATI: return "GL_MUL_ATI";
case GL_SUB_ATI: return "GL_SUB_ATI";
case GL_DOT3_ATI: return "GL_DOT3_ATI";
case GL_DOT4_ATI: return "GL_DOT4_ATI";
case GL_MAD_ATI: return "GL_MAD_ATI";
case GL_LERP_ATI: return "GL_LERP_ATI";
case GL_CND_ATI: return "GL_CND_ATI";
case GL_CND0_ATI: return "GL_CND0_ATI";
case GL_DOT2_ADD_ATI: return "GL_DOT2_ADD_ATI";
default: return "unexpected op";
}
}
static const char *debug_mask(GLuint mask) {
switch(mask) {
case GL_NONE: return "GL_NONE";
case GL_RED_BIT_ATI: return "GL_RED_BIT_ATI";
case GL_GREEN_BIT_ATI: return "GL_GREEN_BIT_ATI";
case GL_BLUE_BIT_ATI: return "GL_BLUE_BIT_ATI";
case GL_RED_BIT_ATI | GL_GREEN_BIT_ATI: return "GL_RED_BIT_ATI | GL_GREEN_BIT_ATI";
case GL_RED_BIT_ATI | GL_BLUE_BIT_ATI: return "GL_RED_BIT_ATI | GL_BLUE_BIT_ATI";
case GL_GREEN_BIT_ATI | GL_BLUE_BIT_ATI:return "GL_GREEN_BIT_ATI | GL_BLUE_BIT_ATI";
case GL_RED_BIT_ATI | GL_GREEN_BIT_ATI | GL_BLUE_BIT_ATI:return "GL_RED_BIT_ATI | GL_GREEN_BIT_ATI | GL_BLUE_BIT_ATI";
default: return "Unexpected writemask";
}
}
#define GLINFO_LOCATION (*gl_info) #define GLINFO_LOCATION (*gl_info)
static GLuint register_for_arg(DWORD arg, WineD3D_GL_Info *gl_info, unsigned int stage, GLuint *mod, GLuint *rep, GLuint tmparg) {
static void wrap_op1(const WineD3D_GL_Info *gl_info, GLuint op, GLuint dst, GLuint dstMask, GLuint dstMod,
GLuint arg1, GLuint arg1Rep, GLuint arg1Mod) {
if(dstMask == GL_ALPHA) {
TRACE("glAlphaFragmentOp1ATI(%s, %s, %s, %s, %s, %s)\n", debug_op(op), debug_register(dst), debug_dstmod(dstMod),
debug_register(arg1), debug_rep(arg1Rep), debug_argmod(arg1Mod));
GL_EXTCALL(glAlphaFragmentOp1ATI(op, dst, dstMod, arg1, arg1Rep, arg1Mod));
} else {
TRACE("glColorFragmentOp1ATI(%s, %s, %s, %s, %s, %s, %s)\n", debug_op(op), debug_register(dst),
debug_mask(dstMask), debug_dstmod(dstMod),
debug_register(arg1), debug_rep(arg1Rep), debug_argmod(arg1Mod));
GL_EXTCALL(glColorFragmentOp1ATI(op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod));
}
}
static void wrap_op2(const WineD3D_GL_Info *gl_info, GLuint op, GLuint dst, GLuint dstMask, GLuint dstMod,
GLuint arg1, GLuint arg1Rep, GLuint arg1Mod,
GLuint arg2, GLuint arg2Rep, GLuint arg2Mod) {
if(dstMask == GL_ALPHA) {
TRACE("glAlphaFragmentOp2ATI(%s, %s, %s, %s, %s, %s, %s, %s, %s)\n", debug_op(op), debug_register(dst), debug_dstmod(dstMod),
debug_register(arg1), debug_rep(arg1Rep), debug_argmod(arg1Mod),
debug_register(arg2), debug_rep(arg2Rep), debug_argmod(arg2Mod));
GL_EXTCALL(glAlphaFragmentOp2ATI(op, dst, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod));
} else {
TRACE("glColorFragmentOp2ATI(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)\n", debug_op(op), debug_register(dst),
debug_mask(dstMask), debug_dstmod(dstMod),
debug_register(arg1), debug_rep(arg1Rep), debug_argmod(arg1Mod),
debug_register(arg2), debug_rep(arg2Rep), debug_argmod(arg2Mod));
GL_EXTCALL(glColorFragmentOp2ATI(op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod));
}
}
static void wrap_op3(const WineD3D_GL_Info *gl_info, GLuint op, GLuint dst, GLuint dstMask, GLuint dstMod,
GLuint arg1, GLuint arg1Rep, GLuint arg1Mod,
GLuint arg2, GLuint arg2Rep, GLuint arg2Mod,
GLuint arg3, GLuint arg3Rep, GLuint arg3Mod) {
if(dstMask == GL_ALPHA) {
/* Leave some free space to fit "GL_NONE, " in to align most alpha and color op lines */
TRACE("glAlphaFragmentOp3ATI(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)\n", debug_op(op), debug_register(dst), debug_dstmod(dstMod),
debug_register(arg1), debug_rep(arg1Rep), debug_argmod(arg1Mod),
debug_register(arg2), debug_rep(arg2Rep), debug_argmod(arg2Mod),
debug_register(arg3), debug_rep(arg3Rep), debug_argmod(arg3Mod));
GL_EXTCALL(glAlphaFragmentOp3ATI(op, dst, dstMod,
arg1, arg1Rep, arg1Mod,
arg2, arg2Rep, arg2Mod,
arg3, arg3Rep, arg3Mod));
} else {
TRACE("glColorFragmentOp3ATI(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)\n", debug_op(op), debug_register(dst),
debug_mask(dstMask), debug_dstmod(dstMod),
debug_register(arg1), debug_rep(arg1Rep), debug_argmod(arg1Mod),
debug_register(arg2), debug_rep(arg2Rep), debug_argmod(arg2Mod),
debug_register(arg3), debug_rep(arg3Rep), debug_argmod(arg3Mod));
GL_EXTCALL(glColorFragmentOp3ATI(op, dst, dstMask, dstMod,
arg1, arg1Rep, arg1Mod,
arg2, arg2Rep, arg2Mod,
arg3, arg3Rep, arg3Mod));
}
}
static GLuint register_for_arg(DWORD arg, const WineD3D_GL_Info *gl_info,
unsigned int stage, GLuint *mod, GLuint *rep, GLuint tmparg)
{
GLenum ret; GLenum ret;
if(mod) *mod = GL_NONE; if(mod) *mod = GL_NONE;
@@ -224,7 +316,8 @@ static GLuint register_for_arg(DWORD arg, WineD3D_GL_Info *gl_info, unsigned int
return ret; return ret;
} }
static GLuint find_tmpreg(struct texture_stage_op op[MAX_TEXTURES]) { static GLuint find_tmpreg(const struct texture_stage_op op[MAX_TEXTURES])
{
int lowest_read = -1; int lowest_read = -1;
int lowest_write = -1; int lowest_write = -1;
int i; int i;
@@ -284,7 +377,8 @@ static GLuint find_tmpreg(struct texture_stage_op op[MAX_TEXTURES]) {
} }
} }
static GLuint gen_ati_shader(struct texture_stage_op op[MAX_TEXTURES], WineD3D_GL_Info *gl_info) { static GLuint gen_ati_shader(const struct texture_stage_op op[MAX_TEXTURES], const WineD3D_GL_Info *gl_info)
{
GLuint ret = GL_EXTCALL(glGenFragmentShadersATI(1)); GLuint ret = GL_EXTCALL(glGenFragmentShadersATI(1));
unsigned int stage; unsigned int stage;
GLuint arg0, arg1, arg2, extrarg; GLuint arg0, arg1, arg2, extrarg;
@@ -339,23 +433,31 @@ static GLuint gen_ati_shader(struct texture_stage_op op[MAX_TEXTURES], WineD3D_G
/* Pass 2: Generate perturbation calculations */ /* Pass 2: Generate perturbation calculations */
for(stage = 0; stage < GL_LIMITS(textures); stage++) { for(stage = 0; stage < GL_LIMITS(textures); stage++) {
GLuint argmodextra_x, argmodextra_y;
struct color_fixup_desc fixup;
if(op[stage].cop == WINED3DTOP_DISABLE) break; if(op[stage].cop == WINED3DTOP_DISABLE) break;
if(op[stage].cop != WINED3DTOP_BUMPENVMAP && if(op[stage].cop != WINED3DTOP_BUMPENVMAP &&
op[stage].cop != WINED3DTOP_BUMPENVMAPLUMINANCE) continue; op[stage].cop != WINED3DTOP_BUMPENVMAPLUMINANCE) continue;
/* Nice thing, we get the color correction for free :-) */ fixup = op[stage].color_fixup;
if(op[stage].color_correction == WINED3DFMT_V8U8) { if (fixup.x_source != CHANNEL_SOURCE_X || fixup.y_source != CHANNEL_SOURCE_Y)
argmodextra = GL_2X_BIT_ATI | GL_BIAS_BIT_ATI; {
} else { FIXME("Swizzles not implemented\n");
argmodextra = 0; argmodextra_x = GL_NONE;
argmodextra_y = GL_NONE;
}
else
{
/* Nice thing, we get the color correction for free :-) */
argmodextra_x = fixup.x_sign_fixup ? GL_2X_BIT_ATI | GL_BIAS_BIT_ATI : GL_NONE;
argmodextra_y = fixup.y_sign_fixup ? GL_2X_BIT_ATI | GL_BIAS_BIT_ATI : GL_NONE;
} }
TRACE("glColorFragmentOp3ATI(GL_DOT2_ADD_ATI, GL_REG_%d_ATI, GL_RED_BIT_ATI, GL_NONE, GL_REG_%d_ATI, GL_NONE, %s, ATI_FFP_CONST_BUMPMAT(%d), GL_NONE, GL_NONE, GL_REG_%d_ATI, GL_RED, GL_NONE)\n", wrap_op3(gl_info, GL_DOT2_ADD_ATI, GL_REG_0_ATI + stage + 1, GL_RED_BIT_ATI, GL_NONE,
stage + 1, stage, debug_argmod(argmodextra), stage, stage + 1); GL_REG_0_ATI + stage, GL_NONE, argmodextra_x,
GL_EXTCALL(glColorFragmentOp3ATI(GL_DOT2_ADD_ATI, GL_REG_0_ATI + stage + 1, GL_RED_BIT_ATI, GL_NONE, ATI_FFP_CONST_BUMPMAT(stage), GL_NONE, GL_2X_BIT_ATI | GL_BIAS_BIT_ATI,
GL_REG_0_ATI + stage, GL_NONE, argmodextra, GL_REG_0_ATI + stage + 1, GL_RED, GL_NONE);
ATI_FFP_CONST_BUMPMAT(stage), GL_NONE, GL_2X_BIT_ATI | GL_BIAS_BIT_ATI,
GL_REG_0_ATI + stage + 1, GL_RED, GL_NONE));
/* FIXME: How can I make GL_DOT2_ADD_ATI read the factors from blue and alpha? It defaults to red and green, /* FIXME: How can I make GL_DOT2_ADD_ATI read the factors from blue and alpha? It defaults to red and green,
* and it is fairly easy to make it read GL_BLUE or BL_ALPHA, but I can't get an R * B + G * A. So we're wasting * and it is fairly easy to make it read GL_BLUE or BL_ALPHA, but I can't get an R * B + G * A. So we're wasting
@@ -365,18 +467,14 @@ static GLuint gen_ati_shader(struct texture_stage_op op[MAX_TEXTURES], WineD3D_G
* NOTE: GL_BLUE | GL_ALPHA is not possible. It doesn't throw a compilation error, but an OR operation on the * NOTE: GL_BLUE | GL_ALPHA is not possible. It doesn't throw a compilation error, but an OR operation on the
* constants doesn't make sense, considering their values. * constants doesn't make sense, considering their values.
*/ */
TRACE("glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_5_ATI, GL_RED_BIT_ATI, GL_NONE, ATI_FFP_CONST_BUMPMAT(%d), GL_BLUE, GL_NONE)\n", stage); wrap_op1(gl_info, GL_MOV_ATI, GL_REG_5_ATI, GL_RED_BIT_ATI, GL_NONE,
GL_EXTCALL(glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_5_ATI, GL_RED_BIT_ATI, GL_NONE, ATI_FFP_CONST_BUMPMAT(stage), GL_BLUE, GL_NONE);
ATI_FFP_CONST_BUMPMAT(stage), GL_BLUE, GL_NONE)); wrap_op1(gl_info, GL_MOV_ATI, GL_REG_5_ATI, GL_GREEN_BIT_ATI, GL_NONE,
TRACE("glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_5_ATI, GL_GREEN_BIT_ATI, GL_NONE, ATI_FFP_CONST_BUMPMAT(%d), GL_ALPHA, GL_NONE)\n", stage); ATI_FFP_CONST_BUMPMAT(stage), GL_ALPHA, GL_NONE);
GL_EXTCALL(glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_5_ATI, GL_GREEN_BIT_ATI, GL_NONE, wrap_op3(gl_info, GL_DOT2_ADD_ATI, GL_REG_0_ATI + stage + 1, GL_GREEN_BIT_ATI, GL_NONE,
ATI_FFP_CONST_BUMPMAT(stage), GL_ALPHA, GL_NONE)); GL_REG_0_ATI + stage, GL_NONE, argmodextra_y,
TRACE("glColorFragmentOp3ATI(GL_DOT2_ADD_ATI, GL_REG_%d_ATI, GL_GREEN_BIT_ATI, GL_NONE, GL_REG_%d_ATI, GL_NONE, %s, GL_REG_5_ATI, GL_NONE, GL_NONE, GL_REG_%d_ATI, GL_GREEN, GL_NONE)\n", GL_REG_5_ATI, GL_NONE, GL_2X_BIT_ATI | GL_BIAS_BIT_ATI,
stage + 1, stage, debug_argmod(argmodextra), stage + 1); GL_REG_0_ATI + stage + 1, GL_GREEN, GL_NONE);
GL_EXTCALL(glColorFragmentOp3ATI(GL_DOT2_ADD_ATI, GL_REG_0_ATI + stage + 1, GL_GREEN_BIT_ATI, GL_NONE,
GL_REG_0_ATI + stage, GL_NONE, argmodextra,
GL_REG_5_ATI, GL_NONE, GL_2X_BIT_ATI | GL_BIAS_BIT_ATI,
GL_REG_0_ATI + stage + 1, GL_GREEN, GL_NONE));
} }
/* Pass 3: Generate sampling instructions for regular textures */ /* Pass 3: Generate sampling instructions for regular textures */
@@ -424,12 +522,10 @@ static GLuint gen_ati_shader(struct texture_stage_op op[MAX_TEXTURES], WineD3D_G
if(op[stage].cop == WINED3DTOP_DISABLE) { if(op[stage].cop == WINED3DTOP_DISABLE) {
if(stage == 0) { if(stage == 0) {
/* Handle complete texture disabling gracefully */ /* Handle complete texture disabling gracefully */
TRACE("glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, GL_PRIMARY_COLOR, GL_NONE, GL_NONE)\n"); wrap_op1(gl_info, GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
GL_EXTCALL(glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE, GL_PRIMARY_COLOR, GL_NONE, GL_NONE);
GL_PRIMARY_COLOR, GL_NONE, GL_NONE)); wrap_op1(gl_info, GL_MOV_ATI, GL_REG_0_ATI, GL_ALPHA, GL_NONE,
TRACE("glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_PRIMARY_COLOR, GL_NONE, GL_NONE)\n"); GL_PRIMARY_COLOR, GL_NONE, GL_NONE);
GL_EXTCALL(glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE,
GL_PRIMARY_COLOR, GL_NONE, GL_NONE));
} }
break; break;
} }
@@ -458,10 +554,8 @@ static GLuint gen_ati_shader(struct texture_stage_op op[MAX_TEXTURES], WineD3D_G
argmod1 = argmod2; argmod1 = argmod2;
rep1 = rep2; rep1 = rep2;
case WINED3DTOP_SELECTARG1: case WINED3DTOP_SELECTARG1:
TRACE("glColorFragmentOp1ATI(GL_MOV_ATI, %s, GL_NONE, GL_NONE, %s, %s, %s)\n", wrap_op1(gl_info, GL_MOV_ATI, dstreg, GL_NONE, GL_NONE,
debug_register(dstreg), debug_register(arg1), debug_rep(rep1), debug_argmod(argmod1)); arg1, rep1, argmod1);
GL_EXTCALL(glColorFragmentOp1ATI(GL_MOV_ATI, dstreg, GL_NONE, GL_NONE,
arg1, rep1, argmod1));
break; break;
case WINED3DTOP_MODULATE4X: case WINED3DTOP_MODULATE4X:
@@ -470,13 +564,9 @@ static GLuint gen_ati_shader(struct texture_stage_op op[MAX_TEXTURES], WineD3D_G
if(dstmod == GL_NONE) dstmod = GL_2X_BIT_ATI; if(dstmod == GL_NONE) dstmod = GL_2X_BIT_ATI;
dstmod |= GL_SATURATE_BIT_ATI; dstmod |= GL_SATURATE_BIT_ATI;
case WINED3DTOP_MODULATE: case WINED3DTOP_MODULATE:
TRACE("glColorFragmentOp2ATI(GL_MUL_ATI, %s, GL_NONE, %s, %s, %s, %s, %s, %s, %s)\n", wrap_op2(gl_info, GL_MUL_ATI, dstreg, GL_NONE, dstmod,
debug_register(dstreg), debug_dstmod(dstmod), arg1, rep1, argmod1,
debug_register(arg1), debug_rep(rep1), debug_argmod(argmod1), arg2, rep2, argmod2);
debug_register(arg2), debug_rep(rep2), debug_argmod(argmod2));
GL_EXTCALL(glColorFragmentOp2ATI(GL_MUL_ATI, dstreg, GL_NONE, dstmod,
arg1, rep1, argmod1,
arg2, rep2, argmod2));
break; break;
case WINED3DTOP_ADDSIGNED2X: case WINED3DTOP_ADDSIGNED2X:
@@ -485,40 +575,27 @@ static GLuint gen_ati_shader(struct texture_stage_op op[MAX_TEXTURES], WineD3D_G
argmodextra = GL_BIAS_BIT_ATI; argmodextra = GL_BIAS_BIT_ATI;
case WINED3DTOP_ADD: case WINED3DTOP_ADD:
dstmod |= GL_SATURATE_BIT_ATI; dstmod |= GL_SATURATE_BIT_ATI;
TRACE("glColorFragmentOp2ATI(GL_ADD_ATI, %s, GL_NONE, %s, %s, %s, %s, %s, %s, %s)\n", wrap_op2(gl_info, GL_ADD_ATI, GL_REG_0_ATI, GL_NONE, dstmod,
debug_register(dstreg), debug_dstmod(dstmod), arg1, rep1, argmod1,
debug_register(arg1), debug_rep(rep1), debug_argmod(argmod1), arg2, rep2, argmodextra | argmod2);
debug_register(arg2), debug_rep(rep2), debug_argmod(argmodextra | argmod2));
GL_EXTCALL(glColorFragmentOp2ATI(GL_ADD_ATI, GL_REG_0_ATI, GL_NONE, dstmod,
arg1, rep1, argmod1,
arg2, rep2, argmodextra | argmod2));
break; break;
case WINED3DTOP_SUBTRACT: case WINED3DTOP_SUBTRACT:
dstmod |= GL_SATURATE_BIT_ATI; dstmod |= GL_SATURATE_BIT_ATI;
TRACE("glColorFragmentOp2ATI(GL_SUB_ATI, %s, GL_NONE, %s, %s, %s, %s, %s, %s, %s)\n", wrap_op2(gl_info, GL_SUB_ATI, dstreg, GL_NONE, dstmod,
debug_register(dstreg), debug_dstmod(dstmod), arg1, rep1, argmod1,
debug_register(arg1), debug_rep(rep1), debug_argmod(argmod1), arg2, rep2, argmod2);
debug_register(arg2), debug_rep(rep2), debug_argmod(argmod2));
GL_EXTCALL(glColorFragmentOp2ATI(GL_SUB_ATI, dstreg, GL_NONE, dstmod,
arg1, rep1, argmod1,
arg2, rep2, argmod2));
break; break;
case WINED3DTOP_ADDSMOOTH: case WINED3DTOP_ADDSMOOTH:
argmodextra = argmod1 & GL_COMP_BIT_ATI ? argmod1 & ~GL_COMP_BIT_ATI : argmod1 | GL_COMP_BIT_ATI; argmodextra = argmod1 & GL_COMP_BIT_ATI ? argmod1 & ~GL_COMP_BIT_ATI : argmod1 | GL_COMP_BIT_ATI;
TRACE("glColorFragmentOp3ATI(GL_MAD_ATI, %s, GL_NONE, GL_SATURATE_BIT_ATI, %s, %s, %s, %s, %s, %s, %s, %s, %s)\n",
debug_register(dstreg),
debug_register(arg2), debug_rep(rep2), debug_argmod(argmod2),
debug_register(arg1), debug_rep(rep1), debug_argmod(argmodextra),
debug_register(arg1), debug_rep(rep1), debug_argmod(argmod1));
/* Dst = arg1 + * arg2(1 -arg 1) /* Dst = arg1 + * arg2(1 -arg 1)
* = arg2 * (1 - arg1) + arg1 * = arg2 * (1 - arg1) + arg1
*/ */
GL_EXTCALL(glColorFragmentOp3ATI(GL_MAD_ATI, dstreg, GL_NONE, GL_SATURATE_BIT_ATI, wrap_op3(gl_info, GL_MAD_ATI, dstreg, GL_NONE, GL_SATURATE_BIT_ATI,
arg2, rep2, argmod2, arg2, rep2, argmod2,
arg1, rep1, argmodextra, arg1, rep1, argmodextra,
arg1, rep1, argmod1)); arg1, rep1, argmod1);
break; break;
case WINED3DTOP_BLENDCURRENTALPHA: case WINED3DTOP_BLENDCURRENTALPHA:
@@ -529,28 +606,18 @@ static GLuint gen_ati_shader(struct texture_stage_op op[MAX_TEXTURES], WineD3D_G
if(extrarg == GL_NONE) extrarg = register_for_arg(WINED3DTA_TEXTURE, gl_info, stage, NULL, NULL, -1); if(extrarg == GL_NONE) extrarg = register_for_arg(WINED3DTA_TEXTURE, gl_info, stage, NULL, NULL, -1);
case WINED3DTOP_BLENDDIFFUSEALPHA: case WINED3DTOP_BLENDDIFFUSEALPHA:
if(extrarg == GL_NONE) extrarg = register_for_arg(WINED3DTA_DIFFUSE, gl_info, stage, NULL, NULL, -1); if(extrarg == GL_NONE) extrarg = register_for_arg(WINED3DTA_DIFFUSE, gl_info, stage, NULL, NULL, -1);
TRACE("glColorFragmentOp3ATI(GL_LERP_ATI, %s, GL_NONE, GL_NONE, %s, GL_ALPHA, GL_NONE, %s, %s, %s, %s, %s, %s)\n", wrap_op3(gl_info, GL_LERP_ATI, dstreg, GL_NONE, GL_NONE,
debug_register(dstreg), extrarg, GL_ALPHA, GL_NONE,
debug_register(extrarg), arg1, rep1, argmod1,
debug_register(arg1), debug_rep(rep1), debug_argmod(argmod1), arg2, rep2, argmod2);
debug_register(arg2), debug_rep(rep2), debug_argmod(argmod2));
GL_EXTCALL(glColorFragmentOp3ATI(GL_LERP_ATI, dstreg, GL_NONE, GL_NONE,
extrarg, GL_ALPHA, GL_NONE,
arg1, rep1, argmod1,
arg2, rep2, argmod2));
break; break;
case WINED3DTOP_BLENDTEXTUREALPHAPM: case WINED3DTOP_BLENDTEXTUREALPHAPM:
arg0 = register_for_arg(WINED3DTA_TEXTURE, gl_info, stage, NULL, NULL, -1); arg0 = register_for_arg(WINED3DTA_TEXTURE, gl_info, stage, NULL, NULL, -1);
TRACE("glColorFragmentOp3ATI(GL_MAD_ATI, %s, GL_NONE, GL_NONE, %s, %s, %s, %s, GL_ALPHA, GL_COMP_BIT_ATI, %s, %s, %s)\n", wrap_op3(gl_info, GL_MAD_ATI, dstreg, GL_NONE, GL_NONE,
debug_register(dstreg), arg2, rep2, argmod2,
debug_register(arg2), debug_rep(rep2), debug_argmod(argmod2), arg0, GL_ALPHA, GL_COMP_BIT_ATI,
debug_register(arg0), arg1, rep1, argmod1);
debug_register(arg1), debug_rep(rep1), debug_argmod(argmod1));
GL_EXTCALL(glColorFragmentOp3ATI(GL_MAD_ATI, dstreg, GL_NONE, GL_NONE,
arg2, rep2, argmod2,
arg0, GL_ALPHA, GL_COMP_BIT_ATI,
arg1, rep1, argmod1));
break; break;
/* D3DTOP_PREMODULATE ???? */ /* D3DTOP_PREMODULATE ???? */
@@ -559,63 +626,40 @@ static GLuint gen_ati_shader(struct texture_stage_op op[MAX_TEXTURES], WineD3D_G
argmodextra = argmod1 & GL_COMP_BIT_ATI ? argmod1 & ~GL_COMP_BIT_ATI : argmod1 | GL_COMP_BIT_ATI; argmodextra = argmod1 & GL_COMP_BIT_ATI ? argmod1 & ~GL_COMP_BIT_ATI : argmod1 | GL_COMP_BIT_ATI;
case WINED3DTOP_MODULATEALPHA_ADDCOLOR: case WINED3DTOP_MODULATEALPHA_ADDCOLOR:
if(!argmodextra) argmodextra = argmod1; if(!argmodextra) argmodextra = argmod1;
TRACE("glColorFragmentOp3ATI(GL_MAD_ATI, %s, GL_NONE, GL_SATURATE_BIT_ATI, %s, %s, %s, %s, GL_ALPHA, %s, %s, %s, %s)\n", wrap_op3(gl_info, GL_MAD_ATI, dstreg, GL_NONE, GL_SATURATE_BIT_ATI,
debug_register(dstreg), arg2, rep2, argmod2,
debug_register(arg2), debug_rep(rep2), debug_argmod(argmod2), arg1, GL_ALPHA, argmodextra,
debug_register(arg1), debug_argmod(argmodextra), debug_register(arg1), debug_rep(rep1), debug_argmod(arg1)); arg1, rep1, argmod1);
GL_EXTCALL(glColorFragmentOp3ATI(GL_MAD_ATI, dstreg, GL_NONE, GL_SATURATE_BIT_ATI,
arg2, rep2, argmod2,
arg1, GL_ALPHA, argmodextra,
arg1, rep1, argmod1));
break; break;
case WINED3DTOP_MODULATEINVCOLOR_ADDALPHA: case WINED3DTOP_MODULATEINVCOLOR_ADDALPHA:
argmodextra = argmod1 & GL_COMP_BIT_ATI ? argmod1 & ~GL_COMP_BIT_ATI : argmod1 | GL_COMP_BIT_ATI; argmodextra = argmod1 & GL_COMP_BIT_ATI ? argmod1 & ~GL_COMP_BIT_ATI : argmod1 | GL_COMP_BIT_ATI;
case WINED3DTOP_MODULATECOLOR_ADDALPHA: case WINED3DTOP_MODULATECOLOR_ADDALPHA:
if(!argmodextra) argmodextra = argmod1; if(!argmodextra) argmodextra = argmod1;
TRACE("glColorFragmentOp3ATI(GL_MAD_ATI, %s, GL_NONE, GL_SATURATE_BIT_ATI, %s, %s, %s, %s, %s, %s, %s, GL_ALPHA, %s)\n", wrap_op3(gl_info, GL_MAD_ATI, dstreg, GL_NONE, GL_SATURATE_BIT_ATI,
debug_register(dstreg), arg2, rep2, argmod2,
debug_register(arg2), debug_rep(rep2), debug_argmod(argmod2), arg1, rep1, argmodextra,
debug_register(arg1), debug_rep(rep1), debug_argmod(argmodextra), arg1, GL_ALPHA, argmod1);
debug_register(arg1), debug_argmod(argmod1));
GL_EXTCALL(glColorFragmentOp3ATI(GL_MAD_ATI, dstreg, GL_NONE, GL_SATURATE_BIT_ATI,
arg2, rep2, argmod2,
arg1, rep1, argmodextra,
arg1, GL_ALPHA, argmod1));
break; break;
case WINED3DTOP_DOTPRODUCT3: case WINED3DTOP_DOTPRODUCT3:
TRACE("glColorFragmentOp2ATI(GL_DOT3_ATI, %s, GL_NONE, GL_4X_BIT_ATI | GL_SATURATE_BIT_ATI, %s, %s, %s, %s, %s, %s)\n", wrap_op2(gl_info, GL_DOT3_ATI, dstreg, GL_NONE, GL_4X_BIT_ATI | GL_SATURATE_BIT_ATI,
debug_register(dstreg), arg1, rep1, argmod1 | GL_BIAS_BIT_ATI,
debug_register(arg1), debug_rep(rep1), debug_argmod(argmod1 | GL_BIAS_BIT_ATI), arg2, rep2, argmod2 | GL_BIAS_BIT_ATI);
debug_register(arg2), debug_rep(rep2), debug_argmod(argmod2 | GL_BIAS_BIT_ATI));
GL_EXTCALL(glColorFragmentOp2ATI(GL_DOT3_ATI, dstreg, GL_NONE, GL_4X_BIT_ATI | GL_SATURATE_BIT_ATI,
arg1, rep1, argmod1 | GL_BIAS_BIT_ATI,
arg2, rep2, argmod2 | GL_BIAS_BIT_ATI));
break; break;
case WINED3DTOP_MULTIPLYADD: case WINED3DTOP_MULTIPLYADD:
TRACE("glColorFragmentOp3ATI(GL_MAD_ATI, %s, GL_NONE, GL_SATURATE_BIT_ATI, %s, %s, %s, %s, %s, %s, %s, %s, %s)\n", wrap_op3(gl_info, GL_MAD_ATI, dstreg, GL_NONE, GL_SATURATE_BIT_ATI,
debug_register(dstreg), arg1, rep1, argmod1,
debug_register(arg1), debug_rep(rep1), debug_argmod(argmod1), arg2, rep2, argmod2,
debug_register(arg2), debug_rep(rep2), debug_argmod(argmod2), arg0, rep0, argmod0);
debug_register(arg0), debug_rep(rep0), debug_argmod(argmod0));
GL_EXTCALL(glColorFragmentOp3ATI(GL_MAD_ATI, dstreg, GL_NONE, GL_SATURATE_BIT_ATI,
arg1, rep1, argmod1,
arg2, rep2, argmod2,
arg0, rep0, argmod0));
break; break;
case WINED3DTOP_LERP: case WINED3DTOP_LERP:
TRACE("glColorFragmentOp3ATI(GL_LERP_ATI, %s, GL_NONE, GL_NONE, %s, %s, %s, %s, %s, %s, %s, %s, %s)\n", wrap_op3(gl_info, GL_LERP_ATI, dstreg, GL_NONE, GL_NONE,
debug_register(dstreg), arg0, rep0, argmod0,
debug_register(arg1), debug_rep(rep1), debug_argmod(argmod1), arg1, rep1, argmod1,
debug_register(arg2), debug_rep(rep2), debug_argmod(argmod2), arg2, rep2, argmod2);
debug_register(arg0), debug_rep(rep0), debug_argmod(argmod0));
GL_EXTCALL(glColorFragmentOp3ATI(GL_LERP_ATI, dstreg, GL_NONE, GL_NONE,
arg0, rep0, argmod0,
arg1, rep1, argmod1,
arg2, rep2, argmod2));
break; break;
case WINED3DTOP_BUMPENVMAP: case WINED3DTOP_BUMPENVMAP:
@@ -637,9 +681,8 @@ static GLuint gen_ati_shader(struct texture_stage_op op[MAX_TEXTURES], WineD3D_G
case WINED3DTOP_DISABLE: case WINED3DTOP_DISABLE:
/* Get the primary color to the output if on stage 0, otherwise leave register 0 untouched */ /* Get the primary color to the output if on stage 0, otherwise leave register 0 untouched */
if(stage == 0) { if(stage == 0) {
TRACE("glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_PRIMARY_COLOR, GL_NONE, GL_NONE)\n"); wrap_op1(gl_info, GL_MOV_ATI, GL_REG_0_ATI, GL_ALPHA, GL_NONE,
GL_EXTCALL(glAlphaFragmentOp1ATI(GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_PRIMARY_COLOR, GL_NONE, GL_NONE);
GL_PRIMARY_COLOR, GL_NONE, GL_NONE));
} }
break; break;
@@ -647,11 +690,8 @@ static GLuint gen_ati_shader(struct texture_stage_op op[MAX_TEXTURES], WineD3D_G
arg1 = arg2; arg1 = arg2;
argmod1 = argmod2; argmod1 = argmod2;
case WINED3DTOP_SELECTARG1: case WINED3DTOP_SELECTARG1:
TRACE("glAlphaFragmentOp1ATI(GL_MOV_ATI, %s, GL_NONE, %s, GL_NONE, %s)\n", wrap_op1(gl_info, GL_MOV_ATI, dstreg, GL_ALPHA, GL_NONE,
debug_register(dstreg), arg1, GL_NONE, argmod1);
debug_register(arg1), debug_argmod(argmod1));
GL_EXTCALL(glAlphaFragmentOp1ATI(GL_MOV_ATI, dstreg, GL_NONE,
arg1, GL_NONE, argmod1));
break; break;
case WINED3DTOP_MODULATE4X: case WINED3DTOP_MODULATE4X:
@@ -660,13 +700,9 @@ static GLuint gen_ati_shader(struct texture_stage_op op[MAX_TEXTURES], WineD3D_G
if(dstmod == GL_NONE) dstmod = GL_2X_BIT_ATI; if(dstmod == GL_NONE) dstmod = GL_2X_BIT_ATI;
dstmod |= GL_SATURATE_BIT_ATI; dstmod |= GL_SATURATE_BIT_ATI;
case WINED3DTOP_MODULATE: case WINED3DTOP_MODULATE:
TRACE("glAlphaFragmentOp2ATI(GL_MUL_ATI, %s, %s, %s, GL_NONE, %s, %s, GL_NONE, %s)\n", wrap_op2(gl_info, GL_MUL_ATI, dstreg, GL_ALPHA, dstmod,
debug_register(dstreg), debug_dstmod(dstmod), arg1, GL_NONE, argmod1,
debug_register(arg1), debug_argmod(argmod1), arg2, GL_NONE, argmod2);
debug_register(arg2), debug_argmod(argmod2));
GL_EXTCALL(glAlphaFragmentOp2ATI(GL_MUL_ATI, dstreg, dstmod,
arg1, GL_NONE, argmod1,
arg2, GL_NONE, argmod2));
break; break;
case WINED3DTOP_ADDSIGNED2X: case WINED3DTOP_ADDSIGNED2X:
@@ -675,40 +711,27 @@ static GLuint gen_ati_shader(struct texture_stage_op op[MAX_TEXTURES], WineD3D_G
argmodextra = GL_BIAS_BIT_ATI; argmodextra = GL_BIAS_BIT_ATI;
case WINED3DTOP_ADD: case WINED3DTOP_ADD:
dstmod |= GL_SATURATE_BIT_ATI; dstmod |= GL_SATURATE_BIT_ATI;
TRACE("glAlphaFragmentOp2ATI(GL_ADD_ATI, %s, %s, %s, GL_NONE, %s, %s, GL_NONE, %s)\n", wrap_op2(gl_info, GL_ADD_ATI, dstreg, GL_ALPHA, dstmod,
debug_register(dstreg), debug_dstmod(dstmod), arg1, GL_NONE, argmod1,
debug_register(arg1), debug_argmod(argmod1), arg2, GL_NONE, argmodextra | argmod2);
debug_register(arg2), debug_argmod(argmodextra | argmod2));
GL_EXTCALL(glAlphaFragmentOp2ATI(GL_ADD_ATI, dstreg, dstmod,
arg1, GL_NONE, argmod1,
arg2, GL_NONE, argmodextra | argmod2));
break; break;
case WINED3DTOP_SUBTRACT: case WINED3DTOP_SUBTRACT:
dstmod |= GL_SATURATE_BIT_ATI; dstmod |= GL_SATURATE_BIT_ATI;
TRACE("glAlphaFragmentOp2ATI(GL_SUB_ATI, %s, GL_NONE, %s, %s, GL_NONE, %s, %s, GL_NONE, %s)\n", wrap_op2(gl_info, GL_SUB_ATI, dstreg, GL_ALPHA, dstmod,
debug_register(dstreg), debug_dstmod(dstmod), arg1, GL_NONE, argmod1,
debug_register(arg1), debug_argmod(argmod1), arg2, GL_NONE, argmod2);
debug_register(arg2), debug_argmod(argmod2));
GL_EXTCALL(glAlphaFragmentOp2ATI(GL_SUB_ATI, dstreg, dstmod,
arg1, GL_NONE, argmod1,
arg2, GL_NONE, argmod2));
break; break;
case WINED3DTOP_ADDSMOOTH: case WINED3DTOP_ADDSMOOTH:
argmodextra = argmod1 & GL_COMP_BIT_ATI ? argmod1 & ~GL_COMP_BIT_ATI : argmod1 | GL_COMP_BIT_ATI; argmodextra = argmod1 & GL_COMP_BIT_ATI ? argmod1 & ~GL_COMP_BIT_ATI : argmod1 | GL_COMP_BIT_ATI;
TRACE("glAlphaFragmentOp3ATI(GL_MAD_ATI, %s, GL_SATURATE_BIT_ATI, %s, GL_NONE, %s, %s, GL_NONE, %s, %s, GL_NONE, %s)\n",
debug_register(dstreg),
debug_register(arg2), debug_argmod(argmod2),
debug_register(arg1), debug_argmod(argmodextra),
debug_register(arg1), debug_argmod(argmod1));
/* Dst = arg1 + * arg2(1 -arg 1) /* Dst = arg1 + * arg2(1 -arg 1)
* = arg2 * (1 - arg1) + arg1 * = arg2 * (1 - arg1) + arg1
*/ */
GL_EXTCALL(glAlphaFragmentOp3ATI(GL_MAD_ATI, dstreg, GL_SATURATE_BIT_ATI, wrap_op3(gl_info, GL_MAD_ATI, dstreg, GL_ALPHA, GL_SATURATE_BIT_ATI,
arg2, GL_NONE, argmod2, arg2, GL_NONE, argmod2,
arg1, GL_NONE, argmodextra, arg1, GL_NONE, argmodextra,
arg1, GL_NONE, argmod1)); arg1, GL_NONE, argmod1);
break; break;
case WINED3DTOP_BLENDCURRENTALPHA: case WINED3DTOP_BLENDCURRENTALPHA:
@@ -719,64 +742,40 @@ static GLuint gen_ati_shader(struct texture_stage_op op[MAX_TEXTURES], WineD3D_G
if(extrarg == GL_NONE) extrarg = register_for_arg(WINED3DTA_TEXTURE, gl_info, stage, NULL, NULL, -1); if(extrarg == GL_NONE) extrarg = register_for_arg(WINED3DTA_TEXTURE, gl_info, stage, NULL, NULL, -1);
case WINED3DTOP_BLENDDIFFUSEALPHA: case WINED3DTOP_BLENDDIFFUSEALPHA:
if(extrarg == GL_NONE) extrarg = register_for_arg(WINED3DTA_DIFFUSE, gl_info, stage, NULL, NULL, -1); if(extrarg == GL_NONE) extrarg = register_for_arg(WINED3DTA_DIFFUSE, gl_info, stage, NULL, NULL, -1);
TRACE("glAlphaFragmentOp3ATI(GL_LERP_ATI, %s, GL_NONE, %s, GL_ALPHA, GL_NONE, %s, GL_NONE, %s, %s, GL_NONE, %s)\n", wrap_op3(gl_info, GL_LERP_ATI, dstreg, GL_ALPHA, GL_NONE,
debug_register(dstreg), extrarg, GL_ALPHA, GL_NONE,
debug_register(extrarg), arg1, GL_NONE, argmod1,
debug_register(arg1), debug_argmod(argmod1), arg2, GL_NONE, argmod2);
debug_register(arg2), debug_argmod(argmod2));
GL_EXTCALL(glAlphaFragmentOp3ATI(GL_LERP_ATI, dstreg, GL_NONE,
extrarg, GL_ALPHA, GL_NONE,
arg1, GL_NONE, argmod1,
arg2, GL_NONE, argmod2));
break; break;
case WINED3DTOP_BLENDTEXTUREALPHAPM: case WINED3DTOP_BLENDTEXTUREALPHAPM:
arg0 = register_for_arg(WINED3DTA_TEXTURE, gl_info, stage, NULL, NULL, -1); arg0 = register_for_arg(WINED3DTA_TEXTURE, gl_info, stage, NULL, NULL, -1);
TRACE("glAlphaFragmentOp3ATI(GL_MAD_ATI, %s, GL_NONE, %s, GL_NONE, %s, %s, GL_ALPHA, GL_COMP_BIT_ATI, %s, GL_NONE, %s)\n", wrap_op3(gl_info, GL_MAD_ATI, dstreg, GL_ALPHA, GL_NONE,
debug_register(dstreg), arg2, GL_NONE, argmod2,
debug_register(arg2), debug_argmod(argmod2), arg0, GL_ALPHA, GL_COMP_BIT_ATI,
debug_register(arg0), arg1, GL_NONE, argmod1);
debug_register(arg1), debug_argmod(argmod1));
GL_EXTCALL(glAlphaFragmentOp3ATI(GL_MAD_ATI, dstreg, GL_NONE,
arg2, GL_NONE, argmod2,
arg0, GL_ALPHA, GL_COMP_BIT_ATI,
arg1, GL_NONE, argmod1));
break; break;
/* D3DTOP_PREMODULATE ???? */ /* D3DTOP_PREMODULATE ???? */
case WINED3DTOP_DOTPRODUCT3: case WINED3DTOP_DOTPRODUCT3:
TRACE("glAlphaFragmentOp2ATI(GL_DOT3_ATI, %s, GL_4X_BIT_ATI | GL_SATURATE_BIT_ATI, %s, GL_NONE, %s, %s, GL_NONE, %s)\n", wrap_op2(gl_info, GL_DOT3_ATI, dstreg, GL_ALPHA, GL_4X_BIT_ATI | GL_SATURATE_BIT_ATI,
debug_register(dstreg), arg1, GL_NONE, argmod1 | GL_BIAS_BIT_ATI,
debug_register(arg1), debug_argmod(argmod1 | GL_BIAS_BIT_ATI), arg2, GL_NONE, argmod2 | GL_BIAS_BIT_ATI);
debug_register(arg2), debug_argmod(argmod2 | GL_BIAS_BIT_ATI));
GL_EXTCALL(glAlphaFragmentOp2ATI(GL_DOT3_ATI, dstreg, GL_4X_BIT_ATI | GL_SATURATE_BIT_ATI,
arg1, GL_NONE, argmod1 | GL_BIAS_BIT_ATI,
arg2, GL_NONE, argmod2 | GL_BIAS_BIT_ATI));
break; break;
case WINED3DTOP_MULTIPLYADD: case WINED3DTOP_MULTIPLYADD:
TRACE("glAlphaFragmentOp3ATI(GL_MAD_ATI, %s, GL_SATURATE_BIT_ATI, %s, GL_NONE, %s, %s, GL_NONE, %s, %s, GL_NONE, %s)\n", wrap_op3(gl_info, GL_MAD_ATI, dstreg, GL_ALPHA, GL_SATURATE_BIT_ATI,
debug_register(dstreg), arg1, GL_NONE, argmod1,
debug_register(arg1), debug_argmod(argmod1), arg2, GL_NONE, argmod2,
debug_register(arg2), debug_argmod(argmod2), arg0, GL_NONE, argmod0);
debug_register(arg0), debug_argmod(argmod0));
GL_EXTCALL(glAlphaFragmentOp3ATI(GL_MAD_ATI, dstreg, GL_SATURATE_BIT_ATI,
arg1, GL_NONE, argmod1,
arg2, GL_NONE, argmod2,
arg0, GL_NONE, argmod0));
break; break;
case WINED3DTOP_LERP: case WINED3DTOP_LERP:
TRACE("glAlphaFragmentOp3ATI(GL_LERP_ATI, %s, GL_SATURATE_BIT_ATI, %s, GL_NONE, %s, %s, GL_NONE, %s, %s, GL_NONE, %s)\n", wrap_op3(gl_info, GL_LERP_ATI, dstreg, GL_ALPHA, GL_SATURATE_BIT_ATI,
debug_register(dstreg), arg1, GL_NONE, argmod1,
debug_register(arg1), debug_argmod(argmod1), arg2, GL_NONE, argmod2,
debug_register(arg2), debug_argmod(argmod2), arg0, GL_NONE, argmod0);
debug_register(arg0), debug_argmod(argmod0));
GL_EXTCALL(glAlphaFragmentOp3ATI(GL_LERP_ATI, dstreg, GL_SATURATE_BIT_ATI,
arg1, GL_NONE, argmod1,
arg2, GL_NONE, argmod2,
arg0, GL_NONE, argmod0));
break; break;
case WINED3DTOP_MODULATEINVALPHA_ADDCOLOR: case WINED3DTOP_MODULATEINVALPHA_ADDCOLOR:
@@ -802,30 +801,32 @@ static GLuint gen_ati_shader(struct texture_stage_op op[MAX_TEXTURES], WineD3D_G
#define GLINFO_LOCATION stateblock->wineD3DDevice->adapter->gl_info #define GLINFO_LOCATION stateblock->wineD3DDevice->adapter->gl_info
static void set_tex_op_atifs(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { static void set_tex_op_atifs(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
IWineD3DDeviceImpl *This = stateblock->wineD3DDevice; IWineD3DDeviceImpl *This = stateblock->wineD3DDevice;
struct atifs_ffp_desc *desc; const struct atifs_ffp_desc *desc;
struct ffp_frag_settings settings; struct ffp_frag_settings settings;
struct atifs_private_data *priv = (struct atifs_private_data *) This->fragment_priv; struct atifs_private_data *priv = (struct atifs_private_data *) This->fragment_priv;
DWORD mapped_stage; DWORD mapped_stage;
unsigned int i; unsigned int i;
gen_ffp_frag_op(stateblock, &settings, TRUE); gen_ffp_frag_op(stateblock, &settings, TRUE);
desc = (struct atifs_ffp_desc *) find_ffp_frag_shader(priv->fragment_shaders, &settings); desc = (const struct atifs_ffp_desc *)find_ffp_frag_shader(priv->fragment_shaders, &settings);
if(!desc) { if(!desc) {
desc = HeapAlloc(GetProcessHeap(), 0, sizeof(*desc)); struct atifs_ffp_desc *new_desc = HeapAlloc(GetProcessHeap(), 0, sizeof(*new_desc));
if(!desc) { if (!new_desc)
{
ERR("Out of memory\n"); ERR("Out of memory\n");
return; return;
} }
desc->num_textures_used = 0; new_desc->num_textures_used = 0;
for(i = 0; i < GL_LIMITS(texture_stages); i++) { for(i = 0; i < GL_LIMITS(texture_stages); i++) {
if(settings.op[i].cop == WINED3DTOP_DISABLE) break; if(settings.op[i].cop == WINED3DTOP_DISABLE) break;
desc->num_textures_used = i; new_desc->num_textures_used = i;
} }
memcpy(&desc->parent.settings, &settings, sizeof(settings)); memcpy(&new_desc->parent.settings, &settings, sizeof(settings));
desc->shader = gen_ati_shader(settings.op, &GLINFO_LOCATION); new_desc->shader = gen_ati_shader(settings.op, &GLINFO_LOCATION);
add_ffp_frag_shader(priv->fragment_shaders, &desc->parent); add_ffp_frag_shader(priv->fragment_shaders, &new_desc->parent);
TRACE("Allocated fixed function replacement shader descriptor %p\n", desc); TRACE("Allocated fixed function replacement shader descriptor %p\n", new_desc);
desc = new_desc;
} }
/* GL_ATI_fragment_shader depends on the GL_TEXTURE_xD enable settings. Update the texture stages /* GL_ATI_fragment_shader depends on the GL_TEXTURE_xD enable settings. Update the texture stages
@@ -852,7 +853,7 @@ static void state_texfactor_atifs(DWORD state, IWineD3DStateBlockImpl *statebloc
} }
static void set_bumpmat(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { static void set_bumpmat(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE; DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
float mat[2][2]; float mat[2][2];
mat[0][0] = *((float *) &stateblock->textureState[stage][WINED3DTSS_BUMPENVMAT00]); mat[0][0] = *((float *) &stateblock->textureState[stage][WINED3DTSS_BUMPENVMAT00]);
@@ -880,10 +881,41 @@ static void textransform(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3
} }
} }
static void atifs_apply_pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
IWineD3DDeviceImpl *device = stateblock->wineD3DDevice;
BOOL use_vshader = use_vs(stateblock);
/* The ATIFS code does not support pixel shaders currently, but we have to provide a state handler
* to call shader_select to select a vertex shader if one is applied because the vertex shader state
* may defer calling the shader backend if the pshader state is dirty.
*
* In theory the application should not be able to mark the pixel shader dirty because it cannot
* create a shader, and thus has no way to set the state to something != NULL. However, a different
* pipeline part may link a different state to its pixelshader handler, thus a pshader state exists
* and can be dirtified. Also the pshader is always dirtified at startup, and blitting disables all
* shaders and dirtifies all shader states. If atifs can deal with this it keeps the rest of the code
* simpler.
*/
if(!isStateDirty(context, device->StateTable[STATE_VSHADER].representative)) {
device->shader_backend->shader_select((IWineD3DDevice *)stateblock->wineD3DDevice, FALSE, use_vshader);
if (!isStateDirty(context, STATE_VERTEXSHADERCONSTANT) && use_vshader) {
device->StateTable[STATE_VERTEXSHADERCONSTANT].apply(STATE_VERTEXSHADERCONSTANT, stateblock, context);
}
}
}
#undef GLINFO_LOCATION #undef GLINFO_LOCATION
static const struct StateEntryTemplate atifs_fragmentstate_template[] = { static const struct StateEntryTemplate atifs_fragmentstate_template[] = {
{STATE_RENDER(WINED3DRS_TEXTUREFACTOR), { STATE_RENDER(WINED3DRS_TEXTUREFACTOR), state_texfactor_atifs }, 0 }, {STATE_RENDER(WINED3DRS_TEXTUREFACTOR), { STATE_RENDER(WINED3DRS_TEXTUREFACTOR), state_texfactor_atifs }, 0 },
{STATE_RENDER(WINED3DRS_FOGCOLOR), { STATE_RENDER(WINED3DRS_FOGCOLOR), state_fogcolor }, 0 },
{STATE_RENDER(WINED3DRS_FOGDENSITY), { STATE_RENDER(WINED3DRS_FOGDENSITY), state_fogdensity }, 0 },
{STATE_RENDER(WINED3DRS_FOGENABLE), { STATE_RENDER(WINED3DRS_FOGENABLE), state_fog_fragpart }, 0 },
{STATE_RENDER(WINED3DRS_FOGTABLEMODE), { STATE_RENDER(WINED3DRS_FOGENABLE), state_fog_fragpart }, 0 },
{STATE_RENDER(WINED3DRS_FOGVERTEXMODE), { STATE_RENDER(WINED3DRS_FOGENABLE), state_fog_fragpart }, 0 },
{STATE_RENDER(WINED3DRS_FOGSTART), { STATE_RENDER(WINED3DRS_FOGSTART), state_fogstartend }, 0 },
{STATE_RENDER(WINED3DRS_FOGEND), { STATE_RENDER(WINED3DRS_FOGSTART), state_fogstartend }, 0 },
{STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 }, {STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 }, {STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
{STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 }, {STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), set_tex_op_atifs }, 0 },
@@ -1004,6 +1036,7 @@ static const struct StateEntryTemplate atifs_fragmentstate_template[] = {
{STATE_TEXTURESTAGE(5,WINED3DTSS_TEXTURETRANSFORMFLAGS),{STATE_TEXTURESTAGE(5, WINED3DTSS_TEXTURETRANSFORMFLAGS), textransform }, 0 }, {STATE_TEXTURESTAGE(5,WINED3DTSS_TEXTURETRANSFORMFLAGS),{STATE_TEXTURESTAGE(5, WINED3DTSS_TEXTURETRANSFORMFLAGS), textransform }, 0 },
{STATE_TEXTURESTAGE(6,WINED3DTSS_TEXTURETRANSFORMFLAGS),{STATE_TEXTURESTAGE(6, WINED3DTSS_TEXTURETRANSFORMFLAGS), textransform }, 0 }, {STATE_TEXTURESTAGE(6,WINED3DTSS_TEXTURETRANSFORMFLAGS),{STATE_TEXTURESTAGE(6, WINED3DTSS_TEXTURETRANSFORMFLAGS), textransform }, 0 },
{STATE_TEXTURESTAGE(7,WINED3DTSS_TEXTURETRANSFORMFLAGS),{STATE_TEXTURESTAGE(7, WINED3DTSS_TEXTURETRANSFORMFLAGS), textransform }, 0 }, {STATE_TEXTURESTAGE(7,WINED3DTSS_TEXTURETRANSFORMFLAGS),{STATE_TEXTURESTAGE(7, WINED3DTSS_TEXTURETRANSFORMFLAGS), textransform }, 0 },
{STATE_PIXELSHADER, { STATE_PIXELSHADER, atifs_apply_pixelshader }, 0 },
{0 /* Terminate */, { 0, 0 }, 0 }, {0 /* Terminate */, { 0, 0 }, 0 },
}; };
@@ -1017,7 +1050,8 @@ static void atifs_enable(IWineD3DDevice *iface, BOOL enable) {
} }
} }
static void atifs_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, struct fragment_caps *caps) { static void atifs_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct fragment_caps *caps)
{
caps->TextureOpCaps = WINED3DTEXOPCAPS_DISABLE | caps->TextureOpCaps = WINED3DTEXOPCAPS_DISABLE |
WINED3DTEXOPCAPS_SELECTARG1 | WINED3DTEXOPCAPS_SELECTARG1 |
WINED3DTEXOPCAPS_SELECTARG2 | WINED3DTEXOPCAPS_SELECTARG2 |
@@ -1101,17 +1135,25 @@ static void atifs_free(IWineD3DDevice *iface) {
} }
#undef GLINFO_LOCATION #undef GLINFO_LOCATION
static BOOL atifs_conv_supported(WINED3DFORMAT fmt) { static BOOL atifs_color_fixup_supported(struct color_fixup_desc fixup)
TRACE("Checking shader format support for format %s:", debug_d3dformat(fmt)); {
switch(fmt) { if (TRACE_ON(d3d_shader) && TRACE_ON(d3d))
case WINED3DFMT_V8U8: {
case WINED3DFMT_V16U16: TRACE("Checking support for fixup:\n");
TRACE("[OK]\n"); dump_color_fixup_desc(fixup);
return TRUE;
default:
TRACE("[FAILED\n");
return FALSE;
} }
/* We only support sign fixup of the first two channels. */
if (fixup.x_source == CHANNEL_SOURCE_X && fixup.y_source == CHANNEL_SOURCE_Y
&& fixup.z_source == CHANNEL_SOURCE_Z && fixup.w_source == CHANNEL_SOURCE_W
&& !fixup.z_sign_fixup && !fixup.w_sign_fixup)
{
TRACE("[OK]\n");
return TRUE;
}
TRACE("[FAILED]\n");
return FALSE;
} }
const struct fragment_pipeline atifs_fragment_pipeline = { const struct fragment_pipeline atifs_fragment_pipeline = {
@@ -1119,7 +1161,7 @@ const struct fragment_pipeline atifs_fragment_pipeline = {
atifs_get_caps, atifs_get_caps,
atifs_alloc, atifs_alloc,
atifs_free, atifs_free,
atifs_conv_supported, atifs_color_fixup_supported,
atifs_fragmentstate_template, atifs_fragmentstate_template,
TRUE /* We can disable projected textures */ TRUE /* We can disable projected textures */
}; };

File diff suppressed because it is too large Load Diff

View File

@@ -27,46 +27,18 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture); WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info #define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
/* ******************************************* void basetexture_init(struct IWineD3DBaseTextureClass *texture, UINT levels, DWORD usage)
IWineD3DBaseTexture IUnknown parts follow
******************************************* */
HRESULT WINAPI IWineD3DBaseTextureImpl_QueryInterface(IWineD3DBaseTexture *iface, REFIID riid, LPVOID *ppobj)
{ {
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface; texture->levels = levels;
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj); texture->filterType = (usage & WINED3DUSAGE_AUTOGENMIPMAP) ? WINED3DTEXF_LINEAR : WINED3DTEXF_NONE;
if (IsEqualGUID(riid, &IID_IUnknown) texture->LOD = 0;
|| IsEqualGUID(riid, &IID_IWineD3DBase) texture->dirty = TRUE;
|| IsEqualGUID(riid, &IID_IWineD3DResource) texture->is_srgb = FALSE;
|| IsEqualGUID(riid, &IID_IWineD3DBaseTexture)) { texture->srgb_mode_change_count = 0;
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
*ppobj = NULL;
return E_NOINTERFACE;
} }
ULONG WINAPI IWineD3DBaseTextureImpl_AddRef(IWineD3DBaseTexture *iface) { void basetexture_cleanup(IWineD3DBaseTexture *iface)
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface; {
ULONG ref = InterlockedIncrement(&This->resource.ref);
TRACE("(%p) : AddRef increasing from %d\n", This,ref - 1);
return ref;
}
ULONG WINAPI IWineD3DBaseTextureImpl_Release(IWineD3DBaseTexture *iface) {
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
ULONG ref = InterlockedDecrement(&This->resource.ref);
TRACE("(%p) : Releasing from %d\n", This, ref + 1);
if (ref == 0) {
IWineD3DBaseTextureImpl_CleanUp(iface);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* class static */
void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture *iface) {
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface; IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
@@ -78,41 +50,12 @@ void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture *iface) {
glDeleteTextures(1, &This->baseTexture.textureName); glDeleteTextures(1, &This->baseTexture.textureName);
LEAVE_GL(); LEAVE_GL();
} }
IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
resource_cleanup((IWineD3DResource *)iface);
} }
/* **************************************************** void basetexture_unload(IWineD3DBaseTexture *iface)
IWineD3DBaseTexture IWineD3DResource parts follow {
**************************************************** */
HRESULT WINAPI IWineD3DBaseTextureImpl_GetDevice(IWineD3DBaseTexture *iface, IWineD3DDevice** ppDevice) {
return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
}
HRESULT WINAPI IWineD3DBaseTextureImpl_SetPrivateData(IWineD3DBaseTexture *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
}
HRESULT WINAPI IWineD3DBaseTextureImpl_GetPrivateData(IWineD3DBaseTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
}
HRESULT WINAPI IWineD3DBaseTextureImpl_FreePrivateData(IWineD3DBaseTexture *iface, REFGUID refguid) {
return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
}
DWORD WINAPI IWineD3DBaseTextureImpl_SetPriority(IWineD3DBaseTexture *iface, DWORD PriorityNew) {
return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
}
DWORD WINAPI IWineD3DBaseTextureImpl_GetPriority(IWineD3DBaseTexture *iface) {
return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
}
void WINAPI IWineD3DBaseTextureImpl_PreLoad(IWineD3DBaseTexture *iface) {
IWineD3DResourceImpl_PreLoad((IWineD3DResource *)iface);
}
void WINAPI IWineD3DBaseTextureImpl_UnLoad(IWineD3DBaseTexture *iface) {
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface; IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
@@ -126,21 +69,10 @@ void WINAPI IWineD3DBaseTextureImpl_UnLoad(IWineD3DBaseTexture *iface
This->baseTexture.dirty = TRUE; This->baseTexture.dirty = TRUE;
} }
WINED3DRESOURCETYPE WINAPI IWineD3DBaseTextureImpl_GetType(IWineD3DBaseTexture *iface) {
return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
}
HRESULT WINAPI IWineD3DBaseTextureImpl_GetParent(IWineD3DBaseTexture *iface, IUnknown **pParent) {
return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
}
/* ******************************************************
IWineD3DBaseTexture IWineD3DBaseTexture parts follow
****************************************************** */
/* There is no OpenGL equivalent of setLOD, getLOD. All they do anyway is prioritize texture loading /* There is no OpenGL equivalent of setLOD, getLOD. All they do anyway is prioritize texture loading
* so just pretend that they work unless something really needs a failure. */ * so just pretend that they work unless something really needs a failure. */
DWORD WINAPI IWineD3DBaseTextureImpl_SetLOD(IWineD3DBaseTexture *iface, DWORD LODNew) { DWORD basetexture_set_lod(IWineD3DBaseTexture *iface, DWORD LODNew)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface; IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
if (This->resource.pool != WINED3DPOOL_MANAGED) { if (This->resource.pool != WINED3DPOOL_MANAGED) {
@@ -156,7 +88,8 @@ DWORD WINAPI IWineD3DBaseTextureImpl_SetLOD(IWineD3DBaseTexture *iface, DWORD LO
return This->baseTexture.LOD; return This->baseTexture.LOD;
} }
DWORD WINAPI IWineD3DBaseTextureImpl_GetLOD(IWineD3DBaseTexture *iface) { DWORD basetexture_get_lod(IWineD3DBaseTexture *iface)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface; IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
if (This->resource.pool != WINED3DPOOL_MANAGED) { if (This->resource.pool != WINED3DPOOL_MANAGED) {
@@ -168,13 +101,15 @@ DWORD WINAPI IWineD3DBaseTextureImpl_GetLOD(IWineD3DBaseTexture *iface) {
return This->baseTexture.LOD; return This->baseTexture.LOD;
} }
DWORD WINAPI IWineD3DBaseTextureImpl_GetLevelCount(IWineD3DBaseTexture *iface) { DWORD basetexture_get_level_count(IWineD3DBaseTexture *iface)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface; IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
TRACE("(%p) : returning %d\n", This, This->baseTexture.levels); TRACE("(%p) : returning %d\n", This, This->baseTexture.levels);
return This->baseTexture.levels; return This->baseTexture.levels;
} }
HRESULT WINAPI IWineD3DBaseTextureImpl_SetAutoGenFilterType(IWineD3DBaseTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType) { HRESULT basetexture_set_autogen_filter_type(IWineD3DBaseTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface; IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
UINT textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface); UINT textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
@@ -216,7 +151,8 @@ HRESULT WINAPI IWineD3DBaseTextureImpl_SetAutoGenFilterType(IWineD3DBaseTexture
return WINED3D_OK; return WINED3D_OK;
} }
WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DBaseTextureImpl_GetAutoGenFilterType(IWineD3DBaseTexture *iface) { WINED3DTEXTUREFILTERTYPE basetexture_get_autogen_filter_type(IWineD3DBaseTexture *iface)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface; IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
FIXME("(%p) : stub\n", This); FIXME("(%p) : stub\n", This);
if (!(This->resource.usage & WINED3DUSAGE_AUTOGENMIPMAP)) { if (!(This->resource.usage & WINED3DUSAGE_AUTOGENMIPMAP)) {
@@ -225,15 +161,16 @@ WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DBaseTextureImpl_GetAutoGenFilterType(IWi
return This->baseTexture.filterType; return This->baseTexture.filterType;
} }
void WINAPI IWineD3DBaseTextureImpl_GenerateMipSubLevels(IWineD3DBaseTexture *iface) { void basetexture_generate_mipmaps(IWineD3DBaseTexture *iface)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface; IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
/* TODO: implement filters using GL_SGI_generate_mipmaps http://oss.sgi.com/projects/ogl-sample/registry/SGIS/generate_mipmap.txt */ /* TODO: implement filters using GL_SGI_generate_mipmaps http://oss.sgi.com/projects/ogl-sample/registry/SGIS/generate_mipmap.txt */
FIXME("(%p) : stub\n", This); FIXME("(%p) : stub\n", This);
return ; return ;
} }
/* Internal function, No d3d mapping */ BOOL basetexture_set_dirty(IWineD3DBaseTexture *iface, BOOL dirty)
BOOL WINAPI IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture *iface, BOOL dirty) { {
BOOL old; BOOL old;
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface; IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
old = This->baseTexture.dirty; old = This->baseTexture.dirty;
@@ -241,12 +178,14 @@ BOOL WINAPI IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture *iface, BOOL di
return old; return old;
} }
BOOL WINAPI IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture *iface) { BOOL basetexture_get_dirty(IWineD3DBaseTexture *iface)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface; IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
return This->baseTexture.dirty; return This->baseTexture.dirty;
} }
HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface) { HRESULT basetexture_bind(IWineD3DBaseTexture *iface)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface; IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
HRESULT hr = WINED3D_OK; HRESULT hr = WINED3D_OK;
UINT textureDimensions; UINT textureDimensions;
@@ -320,7 +259,6 @@ HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface) {
glTexParameteri(textureDimensions, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); glTexParameteri(textureDimensions, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
} }
} }
} else { /* this only happened if we've run out of openGL textures */ } else { /* this only happened if we've run out of openGL textures */
WARN("This texture doesn't have an openGL texture assigned to it\n"); WARN("This texture doesn't have an openGL texture assigned to it\n");
hr = WINED3DERR_INVALIDCALL; hr = WINED3DERR_INVALIDCALL;
@@ -330,32 +268,6 @@ HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface) {
return hr; return hr;
} }
UINT WINAPI IWineD3DBaseTextureImpl_GetTextureDimensions(IWineD3DBaseTexture *iface){
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
FIXME("(%p) : This shouldn't be called\n", This);
return WINED3D_OK;
}
BOOL WINAPI IWineD3DBaseTextureImpl_IsCondNP2(IWineD3DBaseTexture *iface){
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
FIXME("(%p) : This shouldn't be called\n", This);
return FALSE;
}
static inline GLenum warpLookupType(WINED3DSAMPLERSTATETYPE Type) {
switch(Type) {
case WINED3DSAMP_ADDRESSU:
return GL_TEXTURE_WRAP_S;
case WINED3DSAMP_ADDRESSV:
return GL_TEXTURE_WRAP_T;
case WINED3DSAMP_ADDRESSW:
return GL_TEXTURE_WRAP_R;
default:
FIXME("Unexpected warp type %d\n", Type);
return 0;
}
}
static inline void apply_wrap(const GLint textureDimensions, const DWORD state, const GLint type, static inline void apply_wrap(const GLint textureDimensions, const DWORD state, const GLint type,
BOOL cond_np2) { BOOL cond_np2) {
GLint wrapParm; GLint wrapParm;
@@ -381,9 +293,10 @@ static inline void apply_wrap(const GLint textureDimensions, const DWORD state,
} }
} }
void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface, void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1], const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1],
const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]) { const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1])
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface; IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
DWORD state; DWORD state;
GLint textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface); GLint textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
@@ -426,7 +339,7 @@ void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface
if (state > WINED3DTEXF_ANISOTROPIC) { if (state > WINED3DTEXF_ANISOTROPIC) {
FIXME("Unrecognized or unsupported MAGFILTER* value %d\n", state); FIXME("Unrecognized or unsupported MAGFILTER* value %d\n", state);
} else { } else {
glValue = (*This->baseTexture.magLookup)[state - WINED3DTEXF_NONE]; glValue = This->baseTexture.magLookup[state - WINED3DTEXF_NONE];
TRACE("ValueMAG=%d setting MAGFILTER to %x\n", state, glValue); TRACE("ValueMAG=%d setting MAGFILTER to %x\n", state, glValue);
glTexParameteri(textureDimensions, GL_TEXTURE_MAG_FILTER, glValue); glTexParameteri(textureDimensions, GL_TEXTURE_MAG_FILTER, glValue);
/* We need to reset the Anisotropic filtering state when we change the mag filter to WINED3DTEXF_ANISOTROPIC (this seems a bit weird, check the documentation to see how it should be switched off. */ /* We need to reset the Anisotropic filtering state when we change the mag filter to WINED3DTEXF_ANISOTROPIC (this seems a bit weird, check the documentation to see how it should be switched off. */
@@ -455,9 +368,9 @@ void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface
This->baseTexture.states[WINED3DTEXSTA_MINFILTER], This->baseTexture.states[WINED3DTEXSTA_MINFILTER],
This->baseTexture.states[WINED3DTEXSTA_MIPFILTER]); This->baseTexture.states[WINED3DTEXSTA_MIPFILTER]);
} }
glValue = (*This->baseTexture.minMipLookup) glValue = This->baseTexture.minMipLookup
[min(max(samplerStates[WINED3DSAMP_MINFILTER],WINED3DTEXF_NONE), WINED3DTEXF_ANISOTROPIC)] [min(max(samplerStates[WINED3DSAMP_MINFILTER],WINED3DTEXF_NONE), WINED3DTEXF_ANISOTROPIC)]
[min(max(samplerStates[WINED3DSAMP_MIPFILTER],WINED3DTEXF_NONE), WINED3DTEXF_LINEAR)]; .mip[min(max(samplerStates[WINED3DSAMP_MIPFILTER],WINED3DTEXF_NONE), WINED3DTEXF_LINEAR)];
TRACE("ValueMIN=%d, ValueMIP=%d, setting MINFILTER to %x\n", TRACE("ValueMIN=%d, ValueMIP=%d, setting MINFILTER to %x\n",
samplerStates[WINED3DSAMP_MINFILTER], samplerStates[WINED3DSAMP_MINFILTER],
@@ -487,38 +400,3 @@ void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface
This->baseTexture.states[WINED3DTEXSTA_MAXANISOTROPY] = samplerStates[WINED3DSAMP_MAXANISOTROPY]; This->baseTexture.states[WINED3DTEXSTA_MAXANISOTROPY] = samplerStates[WINED3DSAMP_MAXANISOTROPY];
} }
} }
static const IWineD3DBaseTextureVtbl IWineD3DBaseTexture_Vtbl =
{
/* IUnknown */
IWineD3DBaseTextureImpl_QueryInterface,
IWineD3DBaseTextureImpl_AddRef,
IWineD3DBaseTextureImpl_Release,
/* IWineD3DResource */
IWineD3DBaseTextureImpl_GetParent,
IWineD3DBaseTextureImpl_GetDevice,
IWineD3DBaseTextureImpl_SetPrivateData,
IWineD3DBaseTextureImpl_GetPrivateData,
IWineD3DBaseTextureImpl_FreePrivateData,
IWineD3DBaseTextureImpl_SetPriority,
IWineD3DBaseTextureImpl_GetPriority,
IWineD3DBaseTextureImpl_PreLoad,
IWineD3DBaseTextureImpl_UnLoad,
IWineD3DBaseTextureImpl_GetType,
/*IWineD3DBaseTexture*/
IWineD3DBaseTextureImpl_SetLOD,
IWineD3DBaseTextureImpl_GetLOD,
IWineD3DBaseTextureImpl_GetLevelCount,
IWineD3DBaseTextureImpl_SetAutoGenFilterType,
IWineD3DBaseTextureImpl_GetAutoGenFilterType,
IWineD3DBaseTextureImpl_GenerateMipSubLevels,
IWineD3DBaseTextureImpl_SetDirty,
IWineD3DBaseTextureImpl_GetDirty,
/* internal */
IWineD3DBaseTextureImpl_BindTexture,
IWineD3DBaseTextureImpl_GetTextureDimensions,
IWineD3DBaseTextureImpl_IsCondNP2,
IWineD3DBaseTextureImpl_ApplyStateChanges
};

View File

@@ -96,7 +96,8 @@ static HRESULT WINAPI IWineD3DClipperImpl_SetHwnd(IWineD3DClipper *iface, DWORD
return WINED3D_OK; return WINED3D_OK;
} }
static HRESULT WINAPI IWineD3DClipperImpl_GetClipList(IWineD3DClipper *iface, RECT *Rect, RGNDATA *ClipList, DWORD *Size) static HRESULT WINAPI IWineD3DClipperImpl_GetClipList(IWineD3DClipper *iface, const RECT *Rect,
RGNDATA *ClipList, DWORD *Size)
{ {
IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface; IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
TRACE("(%p,%p,%p,%p)\n", This, Rect, ClipList, Size); TRACE("(%p,%p,%p,%p)\n", This, Rect, ClipList, Size);
@@ -140,7 +141,7 @@ static HRESULT WINAPI IWineD3DClipperImpl_GetClipList(IWineD3DClipper *iface, RE
} }
} }
static HRESULT WINAPI IWineD3DClipperImpl_SetClipList(IWineD3DClipper *iface, RGNDATA *rgn, DWORD Flags) static HRESULT WINAPI IWineD3DClipperImpl_SetClipList(IWineD3DClipper *iface, const RGNDATA *rgn, DWORD Flags)
{ {
IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface; IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
static int warned = 0; static int warned = 0;

View File

@@ -839,12 +839,6 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
checkGLcall("glClear"); checkGLcall("glClear");
glColor3f(1.0, 1.0, 1.0);
checkGLcall("glColor3f");
glEnable(GL_LIGHTING);
checkGLcall("glEnable");
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);"); checkGLcall("glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);");
@@ -1053,7 +1047,7 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, WineD3DContext *contex
/* TODO: Use a display list */ /* TODO: Use a display list */
/* Disable shaders */ /* Disable shaders */
This->shader_backend->shader_cleanup((IWineD3DDevice *) This); This->shader_backend->shader_select((IWineD3DDevice *)This, FALSE, FALSE);
Context_MarkStateDirty(context, STATE_VSHADER, StateTable); Context_MarkStateDirty(context, STATE_VSHADER, StateTable);
Context_MarkStateDirty(context, STATE_PIXELSHADER, StateTable); Context_MarkStateDirty(context, STATE_PIXELSHADER, StateTable);
@@ -1066,42 +1060,40 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, WineD3DContext *contex
/* Disable all textures. The caller can then bind a texture it wants to blit /* Disable all textures. The caller can then bind a texture it wants to blit
* from * 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
*/ */
if (GL_SUPPORT(ARB_MULTITEXTURE)) { for(i = GL_LIMITS(textures) - 1; i > 0 ; i--) {
/* The blitting code uses (for now) the fixed function pipeline, so make sure to reset all fixed sampler = This->rev_tex_unit_map[i];
* function texture unit. No need to care for higher samplers GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i));
*/
for(i = GL_LIMITS(textures) - 1; i > 0 ; i--) {
sampler = This->rev_tex_unit_map[i];
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i));
checkGLcall("glActiveTextureARB");
if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) {
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
checkGLcall("glDisable GL_TEXTURE_CUBE_MAP_ARB");
}
glDisable(GL_TEXTURE_3D);
checkGLcall("glDisable GL_TEXTURE_3D");
if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) {
glDisable(GL_TEXTURE_RECTANGLE_ARB);
checkGLcall("glDisable GL_TEXTURE_RECTANGLE_ARB");
}
glDisable(GL_TEXTURE_2D);
checkGLcall("glDisable GL_TEXTURE_2D");
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);");
if (sampler != -1) {
if (sampler < MAX_TEXTURES) {
Context_MarkStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP), StateTable);
}
Context_MarkStateDirty(context, STATE_SAMPLER(sampler), StateTable);
}
}
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB));
checkGLcall("glActiveTextureARB"); checkGLcall("glActiveTextureARB");
if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) {
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
checkGLcall("glDisable GL_TEXTURE_CUBE_MAP_ARB");
}
glDisable(GL_TEXTURE_3D);
checkGLcall("glDisable GL_TEXTURE_3D");
if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) {
glDisable(GL_TEXTURE_RECTANGLE_ARB);
checkGLcall("glDisable GL_TEXTURE_RECTANGLE_ARB");
}
glDisable(GL_TEXTURE_2D);
checkGLcall("glDisable GL_TEXTURE_2D");
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);");
if (sampler != -1) {
if (sampler < MAX_TEXTURES) {
Context_MarkStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP), StateTable);
}
Context_MarkStateDirty(context, STATE_SAMPLER(sampler), StateTable);
}
} }
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB));
checkGLcall("glActiveTextureARB");
sampler = This->rev_tex_unit_map[0]; sampler = This->rev_tex_unit_map[0];
@@ -1150,7 +1142,7 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, WineD3DContext *contex
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
checkGLcall("glDisable GL_DEPTH_TEST"); checkGLcall("glDisable GL_DEPTH_TEST");
Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_ZENABLE), StateTable); Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_ZENABLE), StateTable);
glDisable(GL_FOG); glDisableWINE(GL_FOG);
checkGLcall("glDisable GL_FOG"); checkGLcall("glDisable GL_FOG");
Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_FOGENABLE), StateTable); Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_FOGENABLE), StateTable);
glDisable(GL_BLEND); glDisable(GL_BLEND);
@@ -1253,7 +1245,7 @@ static inline WineD3DContext *FindContext(IWineD3DDeviceImpl *This, IWineD3DSurf
* the alpha blend state changes with different render target formats * the alpha blend state changes with different render target formats
*/ */
if(oldFmt != newFmt) { if(oldFmt != newFmt) {
const GlPixelFormatDesc *glDesc; const struct GlPixelFormatDesc *glDesc;
const StaticPixelFormatDesc *old = getFormatDescEntry(oldFmt, NULL, NULL); const StaticPixelFormatDesc *old = getFormatDescEntry(oldFmt, NULL, NULL);
const StaticPixelFormatDesc *new = getFormatDescEntry(newFmt, &GLINFO_LOCATION, &glDesc); const StaticPixelFormatDesc *new = getFormatDescEntry(newFmt, &GLINFO_LOCATION, &glDesc);
@@ -1623,3 +1615,7 @@ void ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, ContextU
FIXME("Unexpected context usage requested\n"); FIXME("Unexpected context usage requested\n");
} }
} }
WineD3DContext *getActiveContext(void) {
return last_device->activeContext;
}

View File

@@ -68,27 +68,27 @@ static ULONG WINAPI IWineD3DCubeTextureImpl_Release(IWineD3DCubeTexture *iface)
IWineD3DCubeTexture IWineD3DResource parts follow IWineD3DCubeTexture IWineD3DResource parts follow
**************************************************** */ **************************************************** */
static HRESULT WINAPI IWineD3DCubeTextureImpl_GetDevice(IWineD3DCubeTexture *iface, IWineD3DDevice** ppDevice) { static HRESULT WINAPI IWineD3DCubeTextureImpl_GetDevice(IWineD3DCubeTexture *iface, IWineD3DDevice** ppDevice) {
return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice); return resource_get_device((IWineD3DResource *)iface, ppDevice);
} }
static HRESULT WINAPI IWineD3DCubeTextureImpl_SetPrivateData(IWineD3DCubeTexture *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) { static HRESULT WINAPI IWineD3DCubeTextureImpl_SetPrivateData(IWineD3DCubeTexture *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags); return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
} }
static HRESULT WINAPI IWineD3DCubeTextureImpl_GetPrivateData(IWineD3DCubeTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) { static HRESULT WINAPI IWineD3DCubeTextureImpl_GetPrivateData(IWineD3DCubeTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData); return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
} }
static HRESULT WINAPI IWineD3DCubeTextureImpl_FreePrivateData(IWineD3DCubeTexture *iface, REFGUID refguid) { static HRESULT WINAPI IWineD3DCubeTextureImpl_FreePrivateData(IWineD3DCubeTexture *iface, REFGUID refguid) {
return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid); return resource_free_private_data((IWineD3DResource *)iface, refguid);
} }
static DWORD WINAPI IWineD3DCubeTextureImpl_SetPriority(IWineD3DCubeTexture *iface, DWORD PriorityNew) { static DWORD WINAPI IWineD3DCubeTextureImpl_SetPriority(IWineD3DCubeTexture *iface, DWORD PriorityNew) {
return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew); return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
} }
static DWORD WINAPI IWineD3DCubeTextureImpl_GetPriority(IWineD3DCubeTexture *iface) { static DWORD WINAPI IWineD3DCubeTextureImpl_GetPriority(IWineD3DCubeTexture *iface) {
return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface); return resource_get_priority((IWineD3DResource *)iface);
} }
static void WINAPI IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture *iface) { static void WINAPI IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture *iface) {
@@ -136,9 +136,8 @@ static void WINAPI IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture *iface) {
} }
} }
} else if (srgb_was_toggled) { } else if (srgb_was_toggled) {
/* Loop is repeated in the else block with the extra AddDirtyRect line to avoid the alternative of /* Loop is repeated in the else block with the extra surface_add_dirty_rect() line to avoid the
* checking srgb_was_toggled in every iteration, even when the texture is just dirty * alternative of checking srgb_was_toggled in every iteration, even when the texture is just dirty */
*/
if (This->baseTexture.srgb_mode_change_count < 20) if (This->baseTexture.srgb_mode_change_count < 20)
++This->baseTexture.srgb_mode_change_count; ++This->baseTexture.srgb_mode_change_count;
else else
@@ -146,7 +145,7 @@ static void WINAPI IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture *iface) {
for (i = 0; i < This->baseTexture.levels; i++) { for (i = 0; i < This->baseTexture.levels; i++) {
for (j = WINED3DCUBEMAP_FACE_POSITIVE_X; j <= WINED3DCUBEMAP_FACE_NEGATIVE_Z ; j++) { for (j = WINED3DCUBEMAP_FACE_POSITIVE_X; j <= WINED3DCUBEMAP_FACE_NEGATIVE_Z ; j++) {
IWineD3DSurface_AddDirtyRect(This->surfaces[j][i], NULL); surface_add_dirty_rect(This->surfaces[j][i], NULL);
surface_force_reload(This->surfaces[j][i]); surface_force_reload(This->surfaces[j][i]);
IWineD3DSurface_LoadTexture(This->surfaces[j][i], srgb_mode); IWineD3DSurface_LoadTexture(This->surfaces[j][i], srgb_mode);
} }
@@ -176,52 +175,52 @@ static void WINAPI IWineD3DCubeTextureImpl_UnLoad(IWineD3DCubeTexture *iface) {
} }
} }
IWineD3DBaseTextureImpl_UnLoad((IWineD3DBaseTexture *) iface); basetexture_unload((IWineD3DBaseTexture *)iface);
} }
static WINED3DRESOURCETYPE WINAPI IWineD3DCubeTextureImpl_GetType(IWineD3DCubeTexture *iface) { static WINED3DRESOURCETYPE WINAPI IWineD3DCubeTextureImpl_GetType(IWineD3DCubeTexture *iface) {
return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface); return resource_get_type((IWineD3DResource *)iface);
} }
static HRESULT WINAPI IWineD3DCubeTextureImpl_GetParent(IWineD3DCubeTexture *iface, IUnknown **pParent) { static HRESULT WINAPI IWineD3DCubeTextureImpl_GetParent(IWineD3DCubeTexture *iface, IUnknown **pParent) {
return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent); return resource_get_parent((IWineD3DResource *)iface, pParent);
} }
/* ****************************************************** /* ******************************************************
IWineD3DCubeTexture IWineD3DBaseTexture parts follow IWineD3DCubeTexture IWineD3DBaseTexture parts follow
****************************************************** */ ****************************************************** */
static DWORD WINAPI IWineD3DCubeTextureImpl_SetLOD(IWineD3DCubeTexture *iface, DWORD LODNew) { static DWORD WINAPI IWineD3DCubeTextureImpl_SetLOD(IWineD3DCubeTexture *iface, DWORD LODNew) {
return IWineD3DBaseTextureImpl_SetLOD((IWineD3DBaseTexture *)iface, LODNew); return basetexture_set_lod((IWineD3DBaseTexture *)iface, LODNew);
} }
static DWORD WINAPI IWineD3DCubeTextureImpl_GetLOD(IWineD3DCubeTexture *iface) { static DWORD WINAPI IWineD3DCubeTextureImpl_GetLOD(IWineD3DCubeTexture *iface) {
return IWineD3DBaseTextureImpl_GetLOD((IWineD3DBaseTexture *)iface); return basetexture_get_lod((IWineD3DBaseTexture *)iface);
} }
static DWORD WINAPI IWineD3DCubeTextureImpl_GetLevelCount(IWineD3DCubeTexture *iface) { static DWORD WINAPI IWineD3DCubeTextureImpl_GetLevelCount(IWineD3DCubeTexture *iface) {
return IWineD3DBaseTextureImpl_GetLevelCount((IWineD3DBaseTexture *)iface); return basetexture_get_level_count((IWineD3DBaseTexture *)iface);
} }
static HRESULT WINAPI IWineD3DCubeTextureImpl_SetAutoGenFilterType(IWineD3DCubeTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType) { static HRESULT WINAPI IWineD3DCubeTextureImpl_SetAutoGenFilterType(IWineD3DCubeTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType) {
return IWineD3DBaseTextureImpl_SetAutoGenFilterType((IWineD3DBaseTexture *)iface, FilterType); return basetexture_set_autogen_filter_type((IWineD3DBaseTexture *)iface, FilterType);
} }
static WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DCubeTextureImpl_GetAutoGenFilterType(IWineD3DCubeTexture *iface) { static WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DCubeTextureImpl_GetAutoGenFilterType(IWineD3DCubeTexture *iface) {
return IWineD3DBaseTextureImpl_GetAutoGenFilterType((IWineD3DBaseTexture *)iface); return basetexture_get_autogen_filter_type((IWineD3DBaseTexture *)iface);
} }
static void WINAPI IWineD3DCubeTextureImpl_GenerateMipSubLevels(IWineD3DCubeTexture *iface) { static void WINAPI IWineD3DCubeTextureImpl_GenerateMipSubLevels(IWineD3DCubeTexture *iface) {
IWineD3DBaseTextureImpl_GenerateMipSubLevels((IWineD3DBaseTexture *)iface); basetexture_generate_mipmaps((IWineD3DBaseTexture *)iface);
} }
/* Internal function, No d3d mapping */ /* Internal function, No d3d mapping */
static BOOL WINAPI IWineD3DCubeTextureImpl_SetDirty(IWineD3DCubeTexture *iface, BOOL dirty) { static BOOL WINAPI IWineD3DCubeTextureImpl_SetDirty(IWineD3DCubeTexture *iface, BOOL dirty) {
return IWineD3DBaseTextureImpl_SetDirty((IWineD3DBaseTexture *)iface, dirty); return basetexture_set_dirty((IWineD3DBaseTexture *)iface, dirty);
} }
/* Internal function, No d3d mapping */ /* Internal function, No d3d mapping */
static BOOL WINAPI IWineD3DCubeTextureImpl_GetDirty(IWineD3DCubeTexture *iface) { static BOOL WINAPI IWineD3DCubeTextureImpl_GetDirty(IWineD3DCubeTexture *iface) {
return IWineD3DBaseTextureImpl_GetDirty((IWineD3DBaseTexture *)iface); return basetexture_get_dirty((IWineD3DBaseTexture *)iface);
} }
static HRESULT WINAPI IWineD3DCubeTextureImpl_BindTexture(IWineD3DCubeTexture *iface) { static HRESULT WINAPI IWineD3DCubeTextureImpl_BindTexture(IWineD3DCubeTexture *iface) {
@@ -231,7 +230,7 @@ static HRESULT WINAPI IWineD3DCubeTextureImpl_BindTexture(IWineD3DCubeTexture *i
TRACE("(%p) : relay to BaseTexture\n", This); TRACE("(%p) : relay to BaseTexture\n", This);
hr = IWineD3DBaseTextureImpl_BindTexture((IWineD3DBaseTexture *)iface); hr = basetexture_bind((IWineD3DBaseTexture *)iface);
if (set_gl_texture_desc && SUCCEEDED(hr)) { if (set_gl_texture_desc && SUCCEEDED(hr)) {
UINT i, j; UINT i, j;
for (i = 0; i < This->baseTexture.levels; ++i) { for (i = 0; i < This->baseTexture.levels; ++i) {
@@ -262,7 +261,7 @@ static void WINAPI IWineD3DCubeTextureImpl_ApplyStateChanges(IWineD3DCubeTexture
const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1], const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1],
const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]) { const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]) {
TRACE("(%p) : relay to BaseTexture\n", iface); TRACE("(%p) : relay to BaseTexture\n", iface);
IWineD3DBaseTextureImpl_ApplyStateChanges((IWineD3DBaseTexture *)iface, textureStates, samplerStates); basetexture_apply_state_changes((IWineD3DBaseTexture *)iface, textureStates, samplerStates);
} }
@@ -286,7 +285,7 @@ static void WINAPI IWineD3DCubeTextureImpl_Destroy(IWineD3DCubeTexture *iface, D
} }
} }
} }
IWineD3DBaseTextureImpl_CleanUp((IWineD3DBaseTexture *) iface); basetexture_cleanup((IWineD3DBaseTexture *)iface);
/* finally delete the object */ /* finally delete the object */
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
@@ -298,7 +297,7 @@ static HRESULT WINAPI IWineD3DCubeTextureImpl_GetLevelDesc(IWineD3DCubeTexture *
TRACE("(%p) level (%d)\n", This, Level); TRACE("(%p) level (%d)\n", This, Level);
return IWineD3DSurface_GetDesc(This->surfaces[0][Level], pDesc); return IWineD3DSurface_GetDesc(This->surfaces[0][Level], pDesc);
} }
FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels); WARN("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
@@ -360,7 +359,8 @@ static HRESULT WINAPI IWineD3DCubeTextureImpl_AddDirtyRect(IWineD3DCubeTexture
This->baseTexture.dirty = TRUE; This->baseTexture.dirty = TRUE;
TRACE("(%p) : dirtyfication of faceType(%d) Level (0)\n", This, FaceType); TRACE("(%p) : dirtyfication of faceType(%d) Level (0)\n", This, FaceType);
if (FaceType <= WINED3DCUBEMAP_FACE_NEGATIVE_Z) { if (FaceType <= WINED3DCUBEMAP_FACE_NEGATIVE_Z) {
hr = IWineD3DSurface_AddDirtyRect(This->surfaces[FaceType][0], pDirtyRect); surface_add_dirty_rect(This->surfaces[FaceType][0], pDirtyRect);
hr = WINED3D_OK;
} else { } else {
WARN("(%p) overflow FaceType(%d)\n", This, FaceType); WARN("(%p) overflow FaceType(%d)\n", This, FaceType);
} }

File diff suppressed because it is too large Load Diff

View File

@@ -82,6 +82,7 @@ static const struct {
{"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT, 0 }, {"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT, 0 },
{"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO, MAKEDWORD_VERSION(2, 0) }, {"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO, MAKEDWORD_VERSION(2, 0) },
{"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE, 0 }, {"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE, 0 },
{"GL_ARB_texture_rg", ARB_TEXTURE_RG, 0 },
{"GL_ARB_vertex_blend", ARB_VERTEX_BLEND, 0 }, {"GL_ARB_vertex_blend", ARB_VERTEX_BLEND, 0 },
{"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT, 0 }, {"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT, 0 },
{"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM, 0 }, {"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM, 0 },
@@ -109,9 +110,11 @@ static const struct {
{"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE, 0 }, {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE, 0 },
{"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3, 0 }, {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3, 0 },
{"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB, 0 }, {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB, 0 },
{"GL_EXT_texture_swizzle", EXT_TEXTURE_SWIZZLE, 0 },
{"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC, 0 }, {"GL_EXT_texture_filter_anisotropic", EXT_TEXTURE_FILTER_ANISOTROPIC, 0 },
{"GL_EXT_texture_lod", EXT_TEXTURE_LOD, 0 }, {"GL_EXT_texture_lod", EXT_TEXTURE_LOD, 0 },
{"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS, 0 }, {"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS, 0 },
{"GL_EXT_vertex_array_bgra", EXT_VERTEX_ARRAY_BGRA, 0 },
{"GL_EXT_vertex_shader", EXT_VERTEX_SHADER, 0 }, {"GL_EXT_vertex_shader", EXT_VERTEX_SHADER, 0 },
{"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS, 0 }, {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS, 0 },
@@ -154,20 +157,30 @@ static const shader_backend_t *select_shader_backend(UINT Adapter, WINED3DDEVTYP
static const struct blit_shader *select_blit_implementation(UINT Adapter, WINED3DDEVTYPE DeviceType); static const struct blit_shader *select_blit_implementation(UINT Adapter, WINED3DDEVTYPE DeviceType);
/* lookup tables */ /* lookup tables */
int minLookup[MAX_LOOKUPS]; const int minLookup[MAX_LOOKUPS] =
int maxLookup[MAX_LOOKUPS]; {
DWORD *stateLookup[MAX_LOOKUPS]; WINED3DTADDRESS_WRAP, /* WINELOOKUP_WARPPARAM */
DWORD minMipLookup[WINED3DTEXF_ANISOTROPIC + 1][WINED3DTEXF_LINEAR + 1];
DWORD minMipLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 1][WINED3DTEXF_LINEAR + 1] = {
{GL_NEAREST, GL_NEAREST, GL_NEAREST},
{GL_NEAREST, GL_NEAREST, GL_NEAREST},
{GL_NEAREST, GL_NEAREST, GL_NEAREST},
{GL_NEAREST, GL_NEAREST, GL_NEAREST},
}; };
DWORD magLookup[WINED3DTEXF_ANISOTROPIC + 1]; const int maxLookup[MAX_LOOKUPS] =
DWORD magLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 1] = { {
WINED3DTADDRESS_MIRRORONCE, /* WINELOOKUP_WARPPARAM */
};
DWORD *stateLookup[MAX_LOOKUPS];
struct min_lookup minMipLookup[WINED3DTEXF_ANISOTROPIC + 1];
const struct min_lookup minMipLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 1] =
{
{{GL_NEAREST, GL_NEAREST, GL_NEAREST}},
{{GL_NEAREST, GL_NEAREST, GL_NEAREST}},
{{GL_NEAREST, GL_NEAREST, GL_NEAREST}},
{{GL_NEAREST, GL_NEAREST, GL_NEAREST}},
};
GLenum magLookup[WINED3DTEXF_ANISOTROPIC + 1];
const GLenum magLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 1] =
{
GL_NEAREST, GL_NEAREST, GL_NEAREST, GL_NEAREST GL_NEAREST, GL_NEAREST, GL_NEAREST, GL_NEAREST
}; };
@@ -177,7 +190,6 @@ glAttribFunc diffuse_funcs[WINED3DDECLTYPE_UNUSED];
glAttribFunc specular_funcs[WINED3DDECLTYPE_UNUSED]; glAttribFunc specular_funcs[WINED3DDECLTYPE_UNUSED];
glAttribFunc normal_funcs[WINED3DDECLTYPE_UNUSED]; glAttribFunc normal_funcs[WINED3DDECLTYPE_UNUSED];
glMultiTexCoordFunc multi_texcoord_funcs[WINED3DDECLTYPE_UNUSED]; glMultiTexCoordFunc multi_texcoord_funcs[WINED3DDECLTYPE_UNUSED];
glAttribFunc texcoord_funcs[WINED3DDECLTYPE_UNUSED];
/** /**
* Note: GL seems to trap if GetDeviceCaps is called before any HWND's created, * Note: GL seems to trap if GetDeviceCaps is called before any HWND's created,
@@ -367,12 +379,8 @@ static ULONG WINAPI IWineD3DImpl_Release(IWineD3D *iface) {
/* Set the shader type for this device, depending on the given capabilities, /* Set the shader type for this device, depending on the given capabilities,
* the device type, and the user preferences in wined3d_settings */ * the device type, and the user preferences in wined3d_settings */
void select_shader_mode( static void select_shader_mode(const WineD3D_GL_Info *gl_info, WINED3DDEVTYPE DeviceType, int *ps_selected, int *vs_selected)
WineD3D_GL_Info *gl_info, {
WINED3DDEVTYPE DeviceType,
int* ps_selected,
int* vs_selected) {
if (wined3d_settings.vs_mode == VS_NONE) { if (wined3d_settings.vs_mode == VS_NONE) {
*vs_selected = SHADER_NONE; *vs_selected = SHADER_NONE;
} else if (gl_info->supported[ARB_VERTEX_SHADER] && wined3d_settings.glslRequested) { } else if (gl_info->supported[ARB_VERTEX_SHADER] && wined3d_settings.glslRequested) {
@@ -450,7 +458,8 @@ static void select_shader_max_constants(
**********************************************************/ **********************************************************/
#define GLINFO_LOCATION (*gl_info) #define GLINFO_LOCATION (*gl_info)
static inline BOOL test_arb_vs_offset_limit(WineD3D_GL_Info *gl_info) { static inline BOOL test_arb_vs_offset_limit(const WineD3D_GL_Info *gl_info)
{
GLuint prog; GLuint prog;
BOOL ret = FALSE; BOOL ret = FALSE;
const char *testcode = const char *testcode =
@@ -494,7 +503,7 @@ static DWORD ver_for_ext(GL_SupportedExt ext)
return 0; return 0;
} }
BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) { static BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
const char *GL_Extensions = NULL; const char *GL_Extensions = NULL;
const char *WGL_Extensions = NULL; const char *WGL_Extensions = NULL;
const char *gl_string = NULL; const char *gl_string = NULL;
@@ -512,8 +521,7 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
ENTER_GL(); ENTER_GL();
gl_string = (const char *) glGetString(GL_RENDERER); gl_string = (const char *) glGetString(GL_RENDERER);
if (NULL == gl_string) if (!gl_string) gl_string = "None";
gl_string = "None";
strcpy(gl_info->gl_renderer, gl_string); strcpy(gl_info->gl_renderer, gl_string);
gl_string = (const char *) glGetString(GL_VENDOR); gl_string = (const char *) glGetString(GL_VENDOR);
@@ -708,7 +716,7 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
gl_info->max_texture_stages = 1; gl_info->max_texture_stages = 1;
gl_info->max_fragment_samplers = 1; gl_info->max_fragment_samplers = 1;
gl_info->max_vertex_samplers = 0; gl_info->max_vertex_samplers = 0;
gl_info->max_combined_samplers = 0; gl_info->max_combined_samplers = gl_info->max_fragment_samplers + gl_info->max_vertex_samplers;
gl_info->max_sampler_stages = 1; gl_info->max_sampler_stages = 1;
gl_info->ps_arb_version = PS_VERSION_NOT_SUPPORTED; gl_info->ps_arb_version = PS_VERSION_NOT_SUPPORTED;
gl_info->ps_arb_max_temps = 0; gl_info->ps_arb_max_temps = 0;
@@ -736,7 +744,7 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
gl_info->max_texture_size = gl_max; gl_info->max_texture_size = gl_max;
TRACE_(d3d_caps)("Maximum texture size support - max texture size=%d\n", gl_max); TRACE_(d3d_caps)("Maximum texture size support - max texture size=%d\n", gl_max);
glGetFloatv(GL_POINT_SIZE_RANGE, gl_floatv); glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, gl_floatv);
gl_info->max_pointsizemin = gl_floatv[0]; gl_info->max_pointsizemin = gl_floatv[0];
gl_info->max_pointsize = gl_floatv[1]; gl_info->max_pointsize = gl_floatv[1];
TRACE_(d3d_caps)("Maximum point size support - max point size=%f\n", gl_floatv[1]); TRACE_(d3d_caps)("Maximum point size support - max point size=%f\n", gl_floatv[1]);
@@ -1075,8 +1083,13 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
* shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx. * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx.
*/ */
if(WINE_D3D9_CAPABLE(gl_info) && (gl_info->vs_nv_version == VS_VERSION_30)) { if(WINE_D3D9_CAPABLE(gl_info) && (gl_info->vs_nv_version == VS_VERSION_30)) {
/* Geforce GTX - highend */
if(strstr(gl_info->gl_renderer, "GTX 280")) {
gl_info->gl_card = CARD_NVIDIA_GEFORCE_GTX280;
vidmem = 1024;
}
/* Geforce9 - highend */ /* Geforce9 - highend */
if(strstr(gl_info->gl_renderer, "9800")) { else if(strstr(gl_info->gl_renderer, "9800")) {
gl_info->gl_card = CARD_NVIDIA_GEFORCE_9800GT; gl_info->gl_card = CARD_NVIDIA_GEFORCE_9800GT;
vidmem = 512; vidmem = 512;
} }
@@ -1291,7 +1304,8 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
} }
break; break;
case VENDOR_INTEL: case VENDOR_INTEL:
if (strstr(gl_info->gl_renderer, "GMA 950")) { if (strstr(gl_info->gl_renderer, "GMA 950") ||
strstr(gl_info->gl_renderer, "945GM")) {
/* MacOS calls the card GMA 950, but everywhere else the PCI ID is named 945GM */ /* MacOS calls the card GMA 950, but everywhere else the PCI ID is named 945GM */
gl_info->gl_card = CARD_INTEL_I945GM; gl_info->gl_card = CARD_INTEL_I945GM;
vidmem = 64; vidmem = 64;
@@ -1336,11 +1350,7 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
else else
gl_info->vidmem = WINE_DEFAULT_VIDMEM; gl_info->vidmem = WINE_DEFAULT_VIDMEM;
/* Load all the lookup tables /* Load all the lookup tables */
TODO: It may be a good idea to make minLookup and maxLookup const and populate them in wined3d_private.h where they are declared */
minLookup[WINELOOKUP_WARPPARAM] = WINED3DTADDRESS_WRAP;
maxLookup[WINELOOKUP_WARPPARAM] = WINED3DTADDRESS_MIRRORONCE;
for (i = 0; i < MAX_LOOKUPS; i++) { for (i = 0; i < MAX_LOOKUPS; i++) {
stateLookup[i] = HeapAlloc(GetProcessHeap(), 0, sizeof(*stateLookup[i]) * (1 + maxLookup[i] - minLookup[i]) ); stateLookup[i] = HeapAlloc(GetProcessHeap(), 0, sizeof(*stateLookup[i]) * (1 + maxLookup[i] - minLookup[i]) );
} }
@@ -1363,19 +1373,21 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR : GL_NEAREST; gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR : GL_NEAREST;
minMipLookup[WINED3DTEXF_NONE][WINED3DTEXF_NONE] = GL_LINEAR; minMipLookup[WINED3DTEXF_NONE].mip[WINED3DTEXF_NONE] = GL_LINEAR;
minMipLookup[WINED3DTEXF_NONE][WINED3DTEXF_POINT] = GL_LINEAR; minMipLookup[WINED3DTEXF_NONE].mip[WINED3DTEXF_POINT] = GL_LINEAR;
minMipLookup[WINED3DTEXF_NONE][WINED3DTEXF_LINEAR] = GL_LINEAR; minMipLookup[WINED3DTEXF_NONE].mip[WINED3DTEXF_LINEAR] = GL_LINEAR;
minMipLookup[WINED3DTEXF_POINT][WINED3DTEXF_NONE] = GL_NEAREST; minMipLookup[WINED3DTEXF_POINT].mip[WINED3DTEXF_NONE] = GL_NEAREST;
minMipLookup[WINED3DTEXF_POINT][WINED3DTEXF_POINT] = GL_NEAREST_MIPMAP_NEAREST; minMipLookup[WINED3DTEXF_POINT].mip[WINED3DTEXF_POINT] = GL_NEAREST_MIPMAP_NEAREST;
minMipLookup[WINED3DTEXF_POINT][WINED3DTEXF_LINEAR] = GL_NEAREST_MIPMAP_LINEAR; minMipLookup[WINED3DTEXF_POINT].mip[WINED3DTEXF_LINEAR] = GL_NEAREST_MIPMAP_LINEAR;
minMipLookup[WINED3DTEXF_LINEAR][WINED3DTEXF_NONE] = GL_LINEAR; minMipLookup[WINED3DTEXF_LINEAR].mip[WINED3DTEXF_NONE] = GL_LINEAR;
minMipLookup[WINED3DTEXF_LINEAR][WINED3DTEXF_POINT] = GL_LINEAR_MIPMAP_NEAREST; minMipLookup[WINED3DTEXF_LINEAR].mip[WINED3DTEXF_POINT] = GL_LINEAR_MIPMAP_NEAREST;
minMipLookup[WINED3DTEXF_LINEAR][WINED3DTEXF_LINEAR] = GL_LINEAR_MIPMAP_LINEAR; minMipLookup[WINED3DTEXF_LINEAR].mip[WINED3DTEXF_LINEAR] = GL_LINEAR_MIPMAP_LINEAR;
minMipLookup[WINED3DTEXF_ANISOTROPIC][WINED3DTEXF_NONE] = gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? minMipLookup[WINED3DTEXF_ANISOTROPIC].mip[WINED3DTEXF_NONE]
GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR; = gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR;
minMipLookup[WINED3DTEXF_ANISOTROPIC][WINED3DTEXF_POINT] = gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR; minMipLookup[WINED3DTEXF_ANISOTROPIC].mip[WINED3DTEXF_POINT]
minMipLookup[WINED3DTEXF_ANISOTROPIC][WINED3DTEXF_LINEAR] = gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR; = gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR;
minMipLookup[WINED3DTEXF_ANISOTROPIC].mip[WINED3DTEXF_LINEAR]
= gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR;
/* TODO: config lookups */ /* TODO: config lookups */
@@ -1527,7 +1539,7 @@ static HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapte
if (Adapter == 0 && !DEBUG_SINGLE_MODE) { /* Display */ if (Adapter == 0 && !DEBUG_SINGLE_MODE) { /* Display */
DEVMODEW DevModeW; DEVMODEW DevModeW;
int ModeIdx = 0; int ModeIdx = 0;
int i = 0; UINT i = 0;
int j = 0; int j = 0;
ZeroMemory(&DevModeW, sizeof(DevModeW)); ZeroMemory(&DevModeW, sizeof(DevModeW));
@@ -1665,6 +1677,18 @@ static HRESULT WINAPI IWineD3DImpl_GetAdapterIdentifier(IWineD3D *iface, UINT Ad
*(pIdentifier->Revision) = 0; *(pIdentifier->Revision) = 0;
*pIdentifier->DeviceIdentifier = IID_D3DDEVICE_D3DUID; *pIdentifier->DeviceIdentifier = IID_D3DDEVICE_D3DUID;
if(wined3d_settings.pci_device_id != PCI_DEVICE_NONE)
{
TRACE_(d3d_caps)("Overriding pci device id with: %x\n", wined3d_settings.pci_device_id);
*(pIdentifier->DeviceId) = wined3d_settings.pci_device_id;
}
if(wined3d_settings.pci_vendor_id != PCI_VENDOR_NONE)
{
TRACE_(d3d_caps)("Overriding pci vendor id with: %x\n", wined3d_settings.pci_vendor_id);
*(pIdentifier->VendorId) = wined3d_settings.pci_vendor_id;
}
if (Flags & WINED3DENUM_NO_WHQL_LEVEL) { if (Flags & WINED3DENUM_NO_WHQL_LEVEL) {
*(pIdentifier->WHQLLevel) = 0; *(pIdentifier->WHQLLevel) = 0;
} else { } else {
@@ -1755,7 +1779,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDepthStencilMatch(IWineD3D *iface, UINT
WINED3DFORMAT DepthStencilFormat) { WINED3DFORMAT DepthStencilFormat) {
IWineD3DImpl *This = (IWineD3DImpl *)iface; IWineD3DImpl *This = (IWineD3DImpl *)iface;
int nCfgs; int nCfgs;
WineD3D_PixelFormat *cfgs; const WineD3D_PixelFormat *cfgs;
int it; int it;
WARN_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%x,%s), AdptFmt:(%x,%s), RendrTgtFmt:(%x,%s), DepthStencilFmt:(%x,%s))\n", WARN_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%x,%s), AdptFmt:(%x,%s), RendrTgtFmt:(%x,%s), DepthStencilFmt:(%x,%s))\n",
@@ -1790,7 +1814,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, U
BOOL Windowed, WINED3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) { BOOL Windowed, WINED3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) {
IWineD3DImpl *This = (IWineD3DImpl *)iface; IWineD3DImpl *This = (IWineD3DImpl *)iface;
const GlPixelFormatDesc *glDesc; const struct GlPixelFormatDesc *glDesc;
const StaticPixelFormatDesc *desc; const StaticPixelFormatDesc *desc;
TRACE_(d3d_caps)("(%p)-> (Adptr:%d, DevType:(%x,%s), SurfFmt:(%x,%s), Win?%d, MultiSamp:%x, pQual:%p)\n", TRACE_(d3d_caps)("(%p)-> (Adptr:%d, DevType:(%x,%s), SurfFmt:(%x,%s), Win?%d, MultiSamp:%x, pQual:%p)\n",
@@ -1823,7 +1847,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, U
if(glDesc->Flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)) { if(glDesc->Flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)) {
int i, nCfgs; int i, nCfgs;
WineD3D_PixelFormat *cfgs; const WineD3D_PixelFormat *cfgs;
cfgs = Adapters[Adapter].cfgs; cfgs = Adapters[Adapter].cfgs;
nCfgs = Adapters[Adapter].nCfgs; nCfgs = Adapters[Adapter].nCfgs;
@@ -1844,7 +1868,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, U
else if(glDesc->Flags & WINED3DFMT_FLAG_RENDERTARGET) { else if(glDesc->Flags & WINED3DFMT_FLAG_RENDERTARGET) {
short redSize, greenSize, blueSize, alphaSize, colorBits; short redSize, greenSize, blueSize, alphaSize, colorBits;
int i, nCfgs; int i, nCfgs;
WineD3D_PixelFormat *cfgs; const WineD3D_PixelFormat *cfgs;
if(!getColorBits(SurfaceFormat, &redSize, &greenSize, &blueSize, &alphaSize, &colorBits)) { if(!getColorBits(SurfaceFormat, &redSize, &greenSize, &blueSize, &alphaSize, &colorBits)) {
ERR("Unable to color bits for format %#x, can't check multisampling capability!\n", SurfaceFormat); ERR("Unable to color bits for format %#x, can't check multisampling capability!\n", SurfaceFormat);
@@ -1965,7 +1989,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceType(IWineD3D *iface, UINT Adapter
static BOOL CheckBumpMapCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINED3DFORMAT CheckFormat) static BOOL CheckBumpMapCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINED3DFORMAT CheckFormat)
{ {
const struct fragment_pipeline *fp; const struct fragment_pipeline *fp;
const GlPixelFormatDesc *glDesc; const struct GlPixelFormatDesc *glDesc;
switch(CheckFormat) { switch(CheckFormat) {
case WINED3DFMT_V8U8: case WINED3DFMT_V8U8:
@@ -1973,24 +1997,18 @@ static BOOL CheckBumpMapCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINE
case WINED3DFMT_L6V5U5: case WINED3DFMT_L6V5U5:
case WINED3DFMT_X8L8V8U8: case WINED3DFMT_X8L8V8U8:
case WINED3DFMT_Q8W8V8U8: case WINED3DFMT_Q8W8V8U8:
/* Ask the fixed function pipeline implementation if it can deal
* with the conversion. If we've got a GL extension giving native
* support this will be an identity conversion. */
getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc); getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc);
if(glDesc->conversion_group == WINED3DFMT_UNKNOWN) {
/* We have a GL extension giving native support */
TRACE_(d3d_caps)("[OK]\n");
return TRUE;
}
/* No native support: Ask the fixed function pipeline implementation if it
* can deal with the conversion
*/
fp = select_fragment_implementation(Adapter, DeviceType); fp = select_fragment_implementation(Adapter, DeviceType);
if(fp->conv_supported(CheckFormat)) { if (fp->color_fixup_supported(glDesc->color_fixup))
{
TRACE_(d3d_caps)("[OK]\n"); TRACE_(d3d_caps)("[OK]\n");
return TRUE; return TRUE;
} else {
TRACE_(d3d_caps)("[FAILED]\n");
return FALSE;
} }
TRACE_(d3d_caps)("[FAILED]\n");
return FALSE;
default: default:
TRACE_(d3d_caps)("[FAILED]\n"); TRACE_(d3d_caps)("[FAILED]\n");
@@ -2002,7 +2020,7 @@ static BOOL CheckBumpMapCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINE
static BOOL CheckDepthStencilCapability(UINT Adapter, WINED3DFORMAT DisplayFormat, WINED3DFORMAT DepthStencilFormat) static BOOL CheckDepthStencilCapability(UINT Adapter, WINED3DFORMAT DisplayFormat, WINED3DFORMAT DepthStencilFormat)
{ {
int it=0; int it=0;
const GlPixelFormatDesc *glDesc; const struct GlPixelFormatDesc *glDesc;
const StaticPixelFormatDesc *desc = getFormatDescEntry(DepthStencilFormat, &GLINFO_LOCATION, &glDesc); const StaticPixelFormatDesc *desc = getFormatDescEntry(DepthStencilFormat, &GLINFO_LOCATION, &glDesc);
/* Fail if we weren't able to get a description of the format */ /* Fail if we weren't able to get a description of the format */
@@ -2028,7 +2046,7 @@ static BOOL CheckDepthStencilCapability(UINT Adapter, WINED3DFORMAT DisplayForma
static BOOL CheckFilterCapability(UINT Adapter, WINED3DFORMAT CheckFormat) static BOOL CheckFilterCapability(UINT Adapter, WINED3DFORMAT CheckFormat)
{ {
const GlPixelFormatDesc *glDesc; const struct GlPixelFormatDesc *glDesc;
const StaticPixelFormatDesc *desc = getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc); const StaticPixelFormatDesc *desc = getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc);
/* Fail if we weren't able to get a description of the format */ /* Fail if we weren't able to get a description of the format */
@@ -2046,7 +2064,7 @@ static BOOL CheckFilterCapability(UINT Adapter, WINED3DFORMAT CheckFormat)
static BOOL CheckRenderTargetCapability(WINED3DFORMAT AdapterFormat, WINED3DFORMAT CheckFormat) static BOOL CheckRenderTargetCapability(WINED3DFORMAT AdapterFormat, WINED3DFORMAT CheckFormat)
{ {
UINT Adapter = 0; UINT Adapter = 0;
const GlPixelFormatDesc *glDesc; const struct GlPixelFormatDesc *glDesc;
const StaticPixelFormatDesc *desc = getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc); const StaticPixelFormatDesc *desc = getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc);
/* Fail if we weren't able to get a description of the format */ /* Fail if we weren't able to get a description of the format */
@@ -2153,7 +2171,7 @@ static BOOL CheckSrgbWriteCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WI
/* Check if a format support blending in combination with pixel shaders */ /* Check if a format support blending in combination with pixel shaders */
static BOOL CheckPostPixelShaderBlendingCapability(UINT Adapter, WINED3DFORMAT CheckFormat) static BOOL CheckPostPixelShaderBlendingCapability(UINT Adapter, WINED3DFORMAT CheckFormat)
{ {
const GlPixelFormatDesc *glDesc; const struct GlPixelFormatDesc *glDesc;
const StaticPixelFormatDesc *desc = getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc); const StaticPixelFormatDesc *desc = getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc);
/* Fail if we weren't able to get a description of the format */ /* Fail if we weren't able to get a description of the format */
@@ -2185,7 +2203,7 @@ static BOOL CheckTextureCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINE
{ {
const shader_backend_t *shader_backend; const shader_backend_t *shader_backend;
const struct fragment_pipeline *fp; const struct fragment_pipeline *fp;
const GlPixelFormatDesc *glDesc; const struct GlPixelFormatDesc *glDesc;
switch (CheckFormat) { switch (CheckFormat) {
@@ -2260,25 +2278,18 @@ static BOOL CheckTextureCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINE
case WINED3DFMT_L6V5U5: case WINED3DFMT_L6V5U5:
case WINED3DFMT_Q8W8V8U8: case WINED3DFMT_Q8W8V8U8:
case WINED3DFMT_V16U16: case WINED3DFMT_V16U16:
case WINED3DFMT_W11V11U10: /* Ask the shader backend if it can deal with the conversion. If
* we've got a GL extension giving native support this will be an
* identity conversion. */
getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc); getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc);
if(glDesc->conversion_group == WINED3DFMT_UNKNOWN) {
/* We have a GL extension giving native support */
TRACE_(d3d_caps)("[OK]\n");
return TRUE;
}
/* No native support: Ask the fixed function pipeline implementation if it
* can deal with the conversion
*/
shader_backend = select_shader_backend(Adapter, DeviceType); shader_backend = select_shader_backend(Adapter, DeviceType);
if(shader_backend->shader_conv_supported(CheckFormat)) { if (shader_backend->shader_color_fixup_supported(glDesc->color_fixup))
{
TRACE_(d3d_caps)("[OK]\n"); TRACE_(d3d_caps)("[OK]\n");
return TRUE; return TRUE;
} else {
TRACE_(d3d_caps)("[FAILED]\n");
return FALSE;
} }
TRACE_(d3d_caps)("[FAILED]\n");
return FALSE;
case WINED3DFMT_DXT1: case WINED3DFMT_DXT1:
case WINED3DFMT_DXT2: case WINED3DFMT_DXT2:
@@ -2301,6 +2312,7 @@ static BOOL CheckTextureCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINE
case WINED3DFMT_INDEX32: case WINED3DFMT_INDEX32:
case WINED3DFMT_Q16W16V16U16: case WINED3DFMT_Q16W16V16U16:
case WINED3DFMT_A2W10V10U10: case WINED3DFMT_A2W10V10U10:
case WINED3DFMT_W11V11U10:
TRACE_(d3d_caps)("[FAILED]\n"); /* Enable when implemented */ TRACE_(d3d_caps)("[FAILED]\n"); /* Enable when implemented */
return FALSE; return FALSE;
@@ -2351,6 +2363,10 @@ static BOOL CheckTextureCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINE
case WINED3DFMT_G16R16F: case WINED3DFMT_G16R16F:
case WINED3DFMT_G32R32F: case WINED3DFMT_G32R32F:
if(GL_SUPPORT(ARB_TEXTURE_RG)) {
TRACE_(d3d_caps)("[OK]\n");
return TRUE;
}
TRACE_(d3d_caps)("[FAILED]\n"); TRACE_(d3d_caps)("[FAILED]\n");
return FALSE; return FALSE;
@@ -2383,10 +2399,12 @@ static BOOL CheckTextureCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINE
/* Vendor specific formats */ /* Vendor specific formats */
case WINED3DFMT_ATI2N: case WINED3DFMT_ATI2N:
if(GL_SUPPORT(ATI_TEXTURE_COMPRESSION_3DC) || GL_SUPPORT(EXT_TEXTURE_COMPRESSION_RGTC)) { if(GL_SUPPORT(ATI_TEXTURE_COMPRESSION_3DC) || GL_SUPPORT(EXT_TEXTURE_COMPRESSION_RGTC)) {
getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc);
shader_backend = select_shader_backend(Adapter, DeviceType); shader_backend = select_shader_backend(Adapter, DeviceType);
fp = select_fragment_implementation(Adapter, DeviceType); fp = select_fragment_implementation(Adapter, DeviceType);
if(shader_backend->shader_conv_supported(CheckFormat) && if (shader_backend->shader_color_fixup_supported(glDesc->color_fixup)
fp->conv_supported(CheckFormat)) { && fp->color_fixup_supported(glDesc->color_fixup))
{
TRACE_(d3d_caps)("[OK]\n"); TRACE_(d3d_caps)("[OK]\n");
return TRUE; return TRUE;
} }
@@ -2419,6 +2437,7 @@ static BOOL CheckTextureCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINE
} }
static BOOL CheckSurfaceCapability(UINT Adapter, WINED3DFORMAT AdapterFormat, WINED3DDEVTYPE DeviceType, WINED3DFORMAT CheckFormat, WINED3DSURFTYPE SurfaceType) { static BOOL CheckSurfaceCapability(UINT Adapter, WINED3DFORMAT AdapterFormat, WINED3DDEVTYPE DeviceType, WINED3DFORMAT CheckFormat, WINED3DSURFTYPE SurfaceType) {
const struct GlPixelFormatDesc *format_desc;
const struct blit_shader *blitter; const struct blit_shader *blitter;
if(SurfaceType == SURFACE_GDI) { if(SurfaceType == SURFACE_GDI) {
@@ -2455,8 +2474,10 @@ static BOOL CheckSurfaceCapability(UINT Adapter, WINED3DFORMAT AdapterFormat, WI
if(CheckDepthStencilCapability(Adapter, AdapterFormat, CheckFormat)) return TRUE; if(CheckDepthStencilCapability(Adapter, AdapterFormat, CheckFormat)) return TRUE;
/* If opengl can't process the format natively, the blitter may be able to convert it */ /* If opengl can't process the format natively, the blitter may be able to convert it */
getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &format_desc);
blitter = select_blit_implementation(Adapter, DeviceType); blitter = select_blit_implementation(Adapter, DeviceType);
if(blitter->conv_supported(CheckFormat)) { if (blitter->color_fixup_supported(format_desc->color_fixup))
{
TRACE_(d3d_caps)("[OK]\n"); TRACE_(d3d_caps)("[OK]\n");
return TRUE; return TRUE;
} }
@@ -3131,11 +3152,11 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
pCaps->RasterCaps |= WINED3DPRASTERCAPS_FOGRANGE; pCaps->RasterCaps |= WINED3DPRASTERCAPS_FOGRANGE;
} }
/* FIXME Add: /* FIXME Add:
WINED3DPRASTERCAPS_COLORPERSPECTIVE WINED3DPRASTERCAPS_COLORPERSPECTIVE
WINED3DPRASTERCAPS_STRETCHBLTMULTISAMPLE WINED3DPRASTERCAPS_STRETCHBLTMULTISAMPLE
WINED3DPRASTERCAPS_ANTIALIASEDGES WINED3DPRASTERCAPS_ANTIALIASEDGES
WINED3DPRASTERCAPS_ZBUFFERLESSHSR WINED3DPRASTERCAPS_ZBUFFERLESSHSR
WINED3DPRASTERCAPS_WBUFFER */ WINED3DPRASTERCAPS_WBUFFER */
pCaps->ZCmpCaps = WINED3DPCMPCAPS_ALWAYS | pCaps->ZCmpCaps = WINED3DPCMPCAPS_ALWAYS |
WINED3DPCMPCAPS_EQUAL | WINED3DPCMPCAPS_EQUAL |
@@ -3601,16 +3622,17 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
/* Note due to structure differences between dx8 and dx9 D3DPRESENT_PARAMETERS, /* Note due to structure differences between dx8 and dx9 D3DPRESENT_PARAMETERS,
and fields being inserted in the middle, a new structure is used in place */ and fields being inserted in the middle, a new structure is used in place */
static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, WINED3DDEVTYPE DeviceType, HWND hFocusWindow, static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter,
DWORD BehaviourFlags, IWineD3DDevice** ppReturnedDeviceInterface, WINED3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviourFlags, IUnknown *parent,
IUnknown *parent) { IWineD3DDeviceParent *device_parent, IWineD3DDevice **ppReturnedDeviceInterface)
{
IWineD3DDeviceImpl *object = NULL; IWineD3DDeviceImpl *object = NULL;
IWineD3DImpl *This = (IWineD3DImpl *)iface; IWineD3DImpl *This = (IWineD3DImpl *)iface;
WINED3DDISPLAYMODE mode; WINED3DDISPLAYMODE mode;
const struct fragment_pipeline *frag_pipeline = NULL; const struct fragment_pipeline *frag_pipeline = NULL;
int i; int i;
struct fragment_caps ffp_caps; struct fragment_caps ffp_caps;
HRESULT hr;
/* Validate the adapter number. If no adapters are available(no GL), ignore the adapter /* Validate the adapter number. If no adapters are available(no GL), ignore the adapter
* number and create a device without a 3D adapter for 2D only operation. * number and create a device without a 3D adapter for 2D only operation.
@@ -3634,6 +3656,7 @@ static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter,
object->adapter = numAdapters ? &Adapters[Adapter] : NULL; object->adapter = numAdapters ? &Adapters[Adapter] : NULL;
IWineD3D_AddRef(object->wineD3D); IWineD3D_AddRef(object->wineD3D);
object->parent = parent; object->parent = parent;
object->device_parent = device_parent;
list_init(&object->resources); list_init(&object->resources);
list_init(&object->shaders); list_init(&object->shaders);
@@ -3669,19 +3692,18 @@ static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter,
frag_pipeline->get_caps(DeviceType, &GLINFO_LOCATION, &ffp_caps); frag_pipeline->get_caps(DeviceType, &GLINFO_LOCATION, &ffp_caps);
object->max_ffp_textures = ffp_caps.MaxSimultaneousTextures; object->max_ffp_textures = ffp_caps.MaxSimultaneousTextures;
object->max_ffp_texture_stages = ffp_caps.MaxTextureBlendStages; object->max_ffp_texture_stages = ffp_caps.MaxTextureBlendStages;
compile_state_table(object->StateTable, object->multistate_funcs, &GLINFO_LOCATION, hr = compile_state_table(object->StateTable, object->multistate_funcs, &GLINFO_LOCATION,
ffp_vertexstate_template, frag_pipeline, misc_state_template); ffp_vertexstate_template, frag_pipeline, misc_state_template);
object->blitter = select_blit_implementation(Adapter, DeviceType); if (FAILED(hr)) {
IWineD3D_Release(object->wineD3D);
HeapFree(GetProcessHeap(), 0, object);
/* Prefer the vtable with functions optimized for single dirtifyable objects if the shader return hr;
* model can deal with that. It is essentially the same, just with adjusted
* Set*ShaderConstantF implementations
*/
if(object->shader_backend->shader_dirtifyable_constants((IWineD3DDevice *) object)) {
object->lpVtbl = &IWineD3DDevice_DirtyConst_Vtbl;
} }
object->blitter = select_blit_implementation(Adapter, DeviceType);
/* set the state of the device to valid */ /* set the state of the device to valid */
object->state = WINED3D_OK; object->state = WINED3D_OK;
@@ -3726,7 +3748,8 @@ ULONG WINAPI D3DCB_DefaultDestroyVolume(IWineD3DVolume *pVolume) {
return IUnknown_Release(volumeParent); return IUnknown_Release(volumeParent);
} }
static BOOL implementation_is_apple(WineD3D_GL_Info *gl_info) { static BOOL implementation_is_apple(const WineD3D_GL_Info *gl_info)
{
/* MacOS has various specialities in the extensions it advertises. Some have to be loaded from /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
* the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
* detect the Apple OpenGL implementation to apply some extension fixups afterwards. * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
@@ -3848,6 +3871,7 @@ static const struct driver_version_information driver_version_table[] = {
{VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTS, 7, 15, 11, 7341 }, {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTS, 7, 15, 11, 7341 },
{VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9600GT, 7, 15, 11, 7341 }, {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9600GT, 7, 15, 11, 7341 },
{VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9800GT, 7, 15, 11, 7341 }, {VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9800GT, 7, 15, 11, 7341 },
{VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX280, 7, 15, 11, 7341 },
/* ATI cards. The driver versions are somewhat similar, but not quite the same. Let's hardcode */ /* ATI cards. The driver versions are somewhat similar, but not quite the same. Let's hardcode */
{VENDOR_ATI, CARD_ATI_RADEON_9500, 6, 14, 10, 6764 }, {VENDOR_ATI, CARD_ATI_RADEON_9500, 6, 14, 10, 6764 },
@@ -3964,12 +3988,14 @@ static void fixup_extensions(WineD3D_GL_Info *gl_info) {
} }
} }
static void WINE_GLAPI invalid_func(void *data) { static void WINE_GLAPI invalid_func(const void *data)
{
ERR("Invalid vertex attribute function called\n"); ERR("Invalid vertex attribute function called\n");
DebugBreak(); DebugBreak();
} }
static void WINE_GLAPI invalid_texcoord_func(GLenum unit, void * data) { static void WINE_GLAPI invalid_texcoord_func(GLenum unit, const void *data)
{
ERR("Invalid texcoord function called\n"); ERR("Invalid texcoord function called\n");
DebugBreak(); DebugBreak();
} }
@@ -3979,8 +4005,9 @@ static void WINE_GLAPI invalid_texcoord_func(GLenum unit, void * data) {
/* Helper functions for providing vertex data to opengl. The arrays are initialized based on /* Helper functions for providing vertex data to opengl. The arrays are initialized based on
* the extension detection and are used in drawStridedSlow * the extension detection and are used in drawStridedSlow
*/ */
static void WINE_GLAPI position_d3dcolor(void *data) { static void WINE_GLAPI position_d3dcolor(const void *data)
DWORD pos = *((DWORD *) data); {
DWORD pos = *((const DWORD *)data);
FIXME("Add a test for fixed function position from d3dcolor type\n"); FIXME("Add a test for fixed function position from d3dcolor type\n");
glVertex4s(D3DCOLOR_B_R(pos), glVertex4s(D3DCOLOR_B_R(pos),
@@ -3988,8 +4015,10 @@ static void WINE_GLAPI position_d3dcolor(void *data) {
D3DCOLOR_B_B(pos), D3DCOLOR_B_B(pos),
D3DCOLOR_B_A(pos)); D3DCOLOR_B_A(pos));
} }
static void WINE_GLAPI position_float4(void *data) {
GLfloat *pos = (float *) data; static void WINE_GLAPI position_float4(const void *data)
{
const GLfloat *pos = data;
if (pos[3] < eps && pos[3] > -eps) if (pos[3] < eps && pos[3] > -eps)
glVertex3fv(pos); glVertex3fv(pos);
@@ -4000,8 +4029,9 @@ static void WINE_GLAPI position_float4(void *data) {
} }
} }
static void WINE_GLAPI diffuse_d3dcolor(void *data) { static void WINE_GLAPI diffuse_d3dcolor(const void *data)
DWORD diffuseColor = *((DWORD *) data); {
DWORD diffuseColor = *((const DWORD *)data);
glColor4ub(D3DCOLOR_B_R(diffuseColor), glColor4ub(D3DCOLOR_B_R(diffuseColor),
D3DCOLOR_B_G(diffuseColor), D3DCOLOR_B_G(diffuseColor),
@@ -4009,154 +4039,134 @@ static void WINE_GLAPI diffuse_d3dcolor(void *data) {
D3DCOLOR_B_A(diffuseColor)); D3DCOLOR_B_A(diffuseColor));
} }
static void WINE_GLAPI specular_d3dcolor(void *data) { static void WINE_GLAPI specular_d3dcolor(const void *data)
DWORD specularColor = *((DWORD *) data); {
DWORD specularColor = *((const DWORD *)data);
GL_EXTCALL(glSecondaryColor3ubEXT)(D3DCOLOR_B_R(specularColor), GL_EXTCALL(glSecondaryColor3ubEXT)(D3DCOLOR_B_R(specularColor),
D3DCOLOR_B_G(specularColor), D3DCOLOR_B_G(specularColor),
D3DCOLOR_B_B(specularColor)); D3DCOLOR_B_B(specularColor));
} }
static void WINE_GLAPI warn_no_specular_func(void *data) {
static void WINE_GLAPI warn_no_specular_func(const void *data)
{
WARN("GL_EXT_secondary_color not supported\n"); WARN("GL_EXT_secondary_color not supported\n");
} }
void fillGLAttribFuncs(WineD3D_GL_Info *gl_info) { static void fillGLAttribFuncs(const WineD3D_GL_Info *gl_info)
position_funcs[WINED3DDECLTYPE_FLOAT1] = (void *) invalid_func; {
position_funcs[WINED3DDECLTYPE_FLOAT2] = (void *) invalid_func; position_funcs[WINED3DDECLTYPE_FLOAT1] = invalid_func;
position_funcs[WINED3DDECLTYPE_FLOAT3] = (void *) glVertex3fv; position_funcs[WINED3DDECLTYPE_FLOAT2] = invalid_func;
position_funcs[WINED3DDECLTYPE_FLOAT4] = (void *) position_float4; position_funcs[WINED3DDECLTYPE_FLOAT3] = (glAttribFunc)glVertex3fv;
position_funcs[WINED3DDECLTYPE_D3DCOLOR] = (void *) position_d3dcolor; position_funcs[WINED3DDECLTYPE_FLOAT4] = position_float4;
position_funcs[WINED3DDECLTYPE_UBYTE4] = (void *) invalid_func; position_funcs[WINED3DDECLTYPE_D3DCOLOR] = position_d3dcolor;
position_funcs[WINED3DDECLTYPE_SHORT2] = (void *) invalid_func; position_funcs[WINED3DDECLTYPE_UBYTE4] = invalid_func;
position_funcs[WINED3DDECLTYPE_SHORT4] = (void *) glVertex2sv; position_funcs[WINED3DDECLTYPE_SHORT2] = invalid_func;
position_funcs[WINED3DDECLTYPE_UBYTE4N] = (void *) invalid_func; position_funcs[WINED3DDECLTYPE_SHORT4] = (glAttribFunc)glVertex2sv;
position_funcs[WINED3DDECLTYPE_SHORT2N] = (void *) invalid_func; position_funcs[WINED3DDECLTYPE_UBYTE4N] = invalid_func;
position_funcs[WINED3DDECLTYPE_SHORT4N] = (void *) invalid_func; position_funcs[WINED3DDECLTYPE_SHORT2N] = invalid_func;
position_funcs[WINED3DDECLTYPE_USHORT2N] = (void *) invalid_func; position_funcs[WINED3DDECLTYPE_SHORT4N] = invalid_func;
position_funcs[WINED3DDECLTYPE_USHORT4N] = (void *) invalid_func; position_funcs[WINED3DDECLTYPE_USHORT2N] = invalid_func;
position_funcs[WINED3DDECLTYPE_UDEC3] = (void *) invalid_func; position_funcs[WINED3DDECLTYPE_USHORT4N] = invalid_func;
position_funcs[WINED3DDECLTYPE_DEC3N] = (void *) invalid_func; position_funcs[WINED3DDECLTYPE_UDEC3] = invalid_func;
position_funcs[WINED3DDECLTYPE_FLOAT16_2] = (void *) invalid_func; position_funcs[WINED3DDECLTYPE_DEC3N] = invalid_func;
position_funcs[WINED3DDECLTYPE_FLOAT16_4] = (void *) invalid_func; position_funcs[WINED3DDECLTYPE_FLOAT16_2] = invalid_func;
position_funcs[WINED3DDECLTYPE_FLOAT16_4] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_FLOAT1] = (void *) invalid_func; diffuse_funcs[WINED3DDECLTYPE_FLOAT1] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_FLOAT2] = (void *) invalid_func; diffuse_funcs[WINED3DDECLTYPE_FLOAT2] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_FLOAT3] = (void *) glColor3fv; diffuse_funcs[WINED3DDECLTYPE_FLOAT3] = (glAttribFunc)glColor3fv;
diffuse_funcs[WINED3DDECLTYPE_FLOAT4] = (void *) glColor4fv; diffuse_funcs[WINED3DDECLTYPE_FLOAT4] = (glAttribFunc)glColor4fv;
diffuse_funcs[WINED3DDECLTYPE_D3DCOLOR] = (void *) diffuse_d3dcolor; diffuse_funcs[WINED3DDECLTYPE_D3DCOLOR] = diffuse_d3dcolor;
diffuse_funcs[WINED3DDECLTYPE_UBYTE4] = (void *) invalid_func; diffuse_funcs[WINED3DDECLTYPE_UBYTE4] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_SHORT2] = (void *) invalid_func; diffuse_funcs[WINED3DDECLTYPE_SHORT2] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_SHORT4] = (void *) invalid_func; diffuse_funcs[WINED3DDECLTYPE_SHORT4] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_UBYTE4N] = (void *) glColor4ubv; diffuse_funcs[WINED3DDECLTYPE_UBYTE4N] = (glAttribFunc)glColor4ubv;
diffuse_funcs[WINED3DDECLTYPE_SHORT2N] = (void *) invalid_func; diffuse_funcs[WINED3DDECLTYPE_SHORT2N] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_SHORT4N] = (void *) glColor4sv; diffuse_funcs[WINED3DDECLTYPE_SHORT4N] = (glAttribFunc)glColor4sv;
diffuse_funcs[WINED3DDECLTYPE_USHORT2N] = (void *) invalid_func; diffuse_funcs[WINED3DDECLTYPE_USHORT2N] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_USHORT4N] = (void *) glColor4usv; diffuse_funcs[WINED3DDECLTYPE_USHORT4N] = (glAttribFunc)glColor4usv;
diffuse_funcs[WINED3DDECLTYPE_UDEC3] = (void *) invalid_func; diffuse_funcs[WINED3DDECLTYPE_UDEC3] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_DEC3N] = (void *) invalid_func; diffuse_funcs[WINED3DDECLTYPE_DEC3N] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_FLOAT16_2] = (void *) invalid_func; diffuse_funcs[WINED3DDECLTYPE_FLOAT16_2] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_FLOAT16_4] = (void *) invalid_func; diffuse_funcs[WINED3DDECLTYPE_FLOAT16_4] = invalid_func;
/* No 4 component entry points here */ /* No 4 component entry points here */
specular_funcs[WINED3DDECLTYPE_FLOAT1] = (void *) invalid_func; specular_funcs[WINED3DDECLTYPE_FLOAT1] = invalid_func;
specular_funcs[WINED3DDECLTYPE_FLOAT2] = (void *) invalid_func; specular_funcs[WINED3DDECLTYPE_FLOAT2] = invalid_func;
if(GL_SUPPORT(EXT_SECONDARY_COLOR)) { if(GL_SUPPORT(EXT_SECONDARY_COLOR)) {
specular_funcs[WINED3DDECLTYPE_FLOAT3] = (void *) GL_EXTCALL(glSecondaryColor3fvEXT); specular_funcs[WINED3DDECLTYPE_FLOAT3] = (glAttribFunc)GL_EXTCALL(glSecondaryColor3fvEXT);
} else { } else {
specular_funcs[WINED3DDECLTYPE_FLOAT3] = (void *) warn_no_specular_func; specular_funcs[WINED3DDECLTYPE_FLOAT3] = warn_no_specular_func;
} }
specular_funcs[WINED3DDECLTYPE_FLOAT4] = (void *) invalid_func; specular_funcs[WINED3DDECLTYPE_FLOAT4] = invalid_func;
if(GL_SUPPORT(EXT_SECONDARY_COLOR)) { if(GL_SUPPORT(EXT_SECONDARY_COLOR)) {
specular_funcs[WINED3DDECLTYPE_D3DCOLOR] = (void *) specular_d3dcolor; specular_funcs[WINED3DDECLTYPE_D3DCOLOR] = specular_d3dcolor;
} else { } else {
specular_funcs[WINED3DDECLTYPE_D3DCOLOR] = (void *) warn_no_specular_func; specular_funcs[WINED3DDECLTYPE_D3DCOLOR] = warn_no_specular_func;
} }
specular_funcs[WINED3DDECLTYPE_UBYTE4] = (void *) invalid_func; specular_funcs[WINED3DDECLTYPE_UBYTE4] = invalid_func;
specular_funcs[WINED3DDECLTYPE_SHORT2] = (void *) invalid_func; specular_funcs[WINED3DDECLTYPE_SHORT2] = invalid_func;
specular_funcs[WINED3DDECLTYPE_SHORT4] = (void *) invalid_func; specular_funcs[WINED3DDECLTYPE_SHORT4] = invalid_func;
specular_funcs[WINED3DDECLTYPE_UBYTE4N] = (void *) invalid_func; specular_funcs[WINED3DDECLTYPE_UBYTE4N] = invalid_func;
specular_funcs[WINED3DDECLTYPE_SHORT2N] = (void *) invalid_func; specular_funcs[WINED3DDECLTYPE_SHORT2N] = invalid_func;
specular_funcs[WINED3DDECLTYPE_SHORT4N] = (void *) invalid_func; specular_funcs[WINED3DDECLTYPE_SHORT4N] = invalid_func;
specular_funcs[WINED3DDECLTYPE_USHORT2N] = (void *) invalid_func; specular_funcs[WINED3DDECLTYPE_USHORT2N] = invalid_func;
specular_funcs[WINED3DDECLTYPE_USHORT4N] = (void *) invalid_func; specular_funcs[WINED3DDECLTYPE_USHORT4N] = invalid_func;
specular_funcs[WINED3DDECLTYPE_UDEC3] = (void *) invalid_func; specular_funcs[WINED3DDECLTYPE_UDEC3] = invalid_func;
specular_funcs[WINED3DDECLTYPE_DEC3N] = (void *) invalid_func; specular_funcs[WINED3DDECLTYPE_DEC3N] = invalid_func;
specular_funcs[WINED3DDECLTYPE_FLOAT16_2] = (void *) invalid_func; specular_funcs[WINED3DDECLTYPE_FLOAT16_2] = invalid_func;
specular_funcs[WINED3DDECLTYPE_FLOAT16_4] = (void *) invalid_func; specular_funcs[WINED3DDECLTYPE_FLOAT16_4] = invalid_func;
/* Only 3 component entry points here. Test how others behave. Float4 normals are used /* Only 3 component entry points here. Test how others behave. Float4 normals are used
* by one of our tests, trying to pass it to the pixel shader, which fails on Windows. * by one of our tests, trying to pass it to the pixel shader, which fails on Windows.
*/ */
normal_funcs[WINED3DDECLTYPE_FLOAT1] = (void *) invalid_func; normal_funcs[WINED3DDECLTYPE_FLOAT1] = invalid_func;
normal_funcs[WINED3DDECLTYPE_FLOAT2] = (void *) invalid_func; normal_funcs[WINED3DDECLTYPE_FLOAT2] = invalid_func;
normal_funcs[WINED3DDECLTYPE_FLOAT3] = (void *) glNormal3fv; normal_funcs[WINED3DDECLTYPE_FLOAT3] = (glAttribFunc)glNormal3fv;
normal_funcs[WINED3DDECLTYPE_FLOAT4] = (void *) glNormal3fv; /* Just ignore the 4th value */ normal_funcs[WINED3DDECLTYPE_FLOAT4] = (glAttribFunc)glNormal3fv; /* Just ignore the 4th value */
normal_funcs[WINED3DDECLTYPE_D3DCOLOR] = (void *) invalid_func; normal_funcs[WINED3DDECLTYPE_D3DCOLOR] = invalid_func;
normal_funcs[WINED3DDECLTYPE_UBYTE4] = (void *) invalid_func; normal_funcs[WINED3DDECLTYPE_UBYTE4] = invalid_func;
normal_funcs[WINED3DDECLTYPE_SHORT2] = (void *) invalid_func; normal_funcs[WINED3DDECLTYPE_SHORT2] = invalid_func;
normal_funcs[WINED3DDECLTYPE_SHORT4] = (void *) invalid_func; normal_funcs[WINED3DDECLTYPE_SHORT4] = invalid_func;
normal_funcs[WINED3DDECLTYPE_UBYTE4N] = (void *) invalid_func; normal_funcs[WINED3DDECLTYPE_UBYTE4N] = invalid_func;
normal_funcs[WINED3DDECLTYPE_SHORT2N] = (void *) invalid_func; normal_funcs[WINED3DDECLTYPE_SHORT2N] = invalid_func;
normal_funcs[WINED3DDECLTYPE_SHORT4N] = (void *) invalid_func; normal_funcs[WINED3DDECLTYPE_SHORT4N] = invalid_func;
normal_funcs[WINED3DDECLTYPE_USHORT2N] = (void *) invalid_func; normal_funcs[WINED3DDECLTYPE_USHORT2N] = invalid_func;
normal_funcs[WINED3DDECLTYPE_USHORT4N] = (void *) invalid_func; normal_funcs[WINED3DDECLTYPE_USHORT4N] = invalid_func;
normal_funcs[WINED3DDECLTYPE_UDEC3] = (void *) invalid_func; normal_funcs[WINED3DDECLTYPE_UDEC3] = invalid_func;
normal_funcs[WINED3DDECLTYPE_DEC3N] = (void *) invalid_func; normal_funcs[WINED3DDECLTYPE_DEC3N] = invalid_func;
normal_funcs[WINED3DDECLTYPE_FLOAT16_2] = (void *) invalid_func; normal_funcs[WINED3DDECLTYPE_FLOAT16_2] = invalid_func;
normal_funcs[WINED3DDECLTYPE_FLOAT16_4] = (void *) invalid_func; normal_funcs[WINED3DDECLTYPE_FLOAT16_4] = invalid_func;
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT1] = (void *) GL_EXTCALL(glMultiTexCoord1fvARB); multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT1] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord1fvARB);
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT2] = (void *) GL_EXTCALL(glMultiTexCoord2fvARB); multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2fvARB);
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT3] = (void *) GL_EXTCALL(glMultiTexCoord3fvARB); multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT3] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord3fvARB);
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT4] = (void *) GL_EXTCALL(glMultiTexCoord4fvARB); multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4fvARB);
multi_texcoord_funcs[WINED3DDECLTYPE_D3DCOLOR] = (void *) invalid_texcoord_func; multi_texcoord_funcs[WINED3DDECLTYPE_D3DCOLOR] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_UBYTE4] = (void *) invalid_texcoord_func; multi_texcoord_funcs[WINED3DDECLTYPE_UBYTE4] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_SHORT2] = (void *) GL_EXTCALL(glMultiTexCoord2svARB); multi_texcoord_funcs[WINED3DDECLTYPE_SHORT2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2svARB);
multi_texcoord_funcs[WINED3DDECLTYPE_SHORT4] = (void *) GL_EXTCALL(glMultiTexCoord4svARB); multi_texcoord_funcs[WINED3DDECLTYPE_SHORT4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4svARB);
multi_texcoord_funcs[WINED3DDECLTYPE_UBYTE4N] = (void *) invalid_texcoord_func; multi_texcoord_funcs[WINED3DDECLTYPE_UBYTE4N] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_SHORT2N] = (void *) invalid_texcoord_func; multi_texcoord_funcs[WINED3DDECLTYPE_SHORT2N] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_SHORT4N] = (void *) invalid_texcoord_func; multi_texcoord_funcs[WINED3DDECLTYPE_SHORT4N] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_USHORT2N] = (void *) invalid_texcoord_func; multi_texcoord_funcs[WINED3DDECLTYPE_USHORT2N] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_USHORT4N] = (void *) invalid_texcoord_func; multi_texcoord_funcs[WINED3DDECLTYPE_USHORT4N] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_UDEC3] = (void *) invalid_texcoord_func; multi_texcoord_funcs[WINED3DDECLTYPE_UDEC3] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_DEC3N] = (void *) invalid_texcoord_func; multi_texcoord_funcs[WINED3DDECLTYPE_DEC3N] = invalid_texcoord_func;
if (GL_SUPPORT(NV_HALF_FLOAT)) if (GL_SUPPORT(NV_HALF_FLOAT))
{ {
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = (void *) GL_EXTCALL(glMultiTexCoord2hvNV); multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2hvNV);
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = (void *) GL_EXTCALL(glMultiTexCoord4hvNV); multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4hvNV);
} else { } else {
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = (void *) invalid_texcoord_func; multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = (void *) invalid_texcoord_func; multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = invalid_texcoord_func;
}
texcoord_funcs[WINED3DDECLTYPE_FLOAT1] = (void *) glTexCoord1fv;
texcoord_funcs[WINED3DDECLTYPE_FLOAT2] = (void *) glTexCoord2fv;
texcoord_funcs[WINED3DDECLTYPE_FLOAT3] = (void *) glTexCoord3fv;
texcoord_funcs[WINED3DDECLTYPE_FLOAT4] = (void *) glTexCoord4fv;
texcoord_funcs[WINED3DDECLTYPE_D3DCOLOR] = (void *) invalid_func;
texcoord_funcs[WINED3DDECLTYPE_UBYTE4] = (void *) invalid_func;
texcoord_funcs[WINED3DDECLTYPE_SHORT2] = (void *) glTexCoord2sv;
texcoord_funcs[WINED3DDECLTYPE_SHORT4] = (void *) glTexCoord4sv;
texcoord_funcs[WINED3DDECLTYPE_UBYTE4N] = (void *) invalid_func;
texcoord_funcs[WINED3DDECLTYPE_SHORT2N] = (void *) invalid_func;
texcoord_funcs[WINED3DDECLTYPE_SHORT4N] = (void *) invalid_func;
texcoord_funcs[WINED3DDECLTYPE_USHORT2N] = (void *) invalid_func;
texcoord_funcs[WINED3DDECLTYPE_USHORT4N] = (void *) invalid_func;
texcoord_funcs[WINED3DDECLTYPE_UDEC3] = (void *) invalid_func;
texcoord_funcs[WINED3DDECLTYPE_DEC3N] = (void *) invalid_func;
if (GL_SUPPORT(NV_HALF_FLOAT))
{
texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = (void *) GL_EXTCALL(glTexCoord2hvNV);
texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = (void *) GL_EXTCALL(glTexCoord4hvNV);
} else {
texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = (void *) invalid_func;
texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = (void *) invalid_func;
} }
} }
#define PUSH1(att) attribs[nAttribs++] = (att); #define PUSH1(att) attribs[nAttribs++] = (att);
BOOL InitAdapters(void) { BOOL InitAdapters(void) {
static HMODULE mod_gl, mod_win32gl; static HMODULE mod_gl;
BOOL ret; BOOL ret;
int ps_selected_mode, vs_selected_mode; int ps_selected_mode, vs_selected_mode;
@@ -4175,16 +4185,10 @@ BOOL InitAdapters(void) {
ERR("Can't load opengl32.dll!\n"); ERR("Can't load opengl32.dll!\n");
goto nogl_adapter; goto nogl_adapter;
} }
mod_win32gl = mod_gl;
#else #else
#define USE_GL_FUNC(pfn) pfn = (void*)pwglGetProcAddress(#pfn); #define USE_GL_FUNC(pfn) pfn = (void*)pwglGetProcAddress(#pfn);
/* To bypass the opengl32 thunks load wglGetProcAddress from gdi32 (glXGetProcAddress wrapper) instead of opengl32's */ /* To bypass the opengl32 thunks load wglGetProcAddress from gdi32 (glXGetProcAddress wrapper) instead of opengl32's */
mod_gl = GetModuleHandleA("gdi32.dll"); mod_gl = GetModuleHandleA("gdi32.dll");
mod_win32gl = LoadLibraryA("opengl32.dll");
if(!mod_win32gl) {
ERR("Can't load opengl32.dll!\n");
goto nogl_adapter;
}
#endif #endif
} }
@@ -4205,8 +4209,16 @@ BOOL InitAdapters(void) {
/* Load glFinish and glFlush from opengl32.dll even if we're not using WIN32 opengl /* Load glFinish and glFlush from opengl32.dll even if we're not using WIN32 opengl
* otherwise because we have to use winex11.drv's override * otherwise because we have to use winex11.drv's override
*/ */
glFinish = (void*)GetProcAddress(mod_win32gl, "glFinish"); #ifdef USE_WIN32_OPENGL
glFlush = (void*)GetProcAddress(mod_win32gl, "glFlush"); glFinish = (void*)GetProcAddress(mod_gl, "glFinish");
glFlush = (void*)GetProcAddress(mod_gl, "glFlush");
#else
glFinish = (void*)pwglGetProcAddress("wglFinish");
glFlush = (void*)pwglGetProcAddress("wglFlush");
#endif
glEnableWINE = glEnable;
glDisableWINE = glDisable;
/* For now only one default adapter */ /* For now only one default adapter */
{ {
@@ -4349,6 +4361,7 @@ BOOL InitAdapters(void) {
} }
fixup_extensions(&Adapters[0].gl_info); fixup_extensions(&Adapters[0].gl_info);
add_gl_compat_wrappers(&Adapters[0].gl_info);
WineD3D_ReleaseFakeGLContext(); WineD3D_ReleaseFakeGLContext();

View File

@@ -142,29 +142,30 @@ void primitiveDeclarationConvertToStridedData(
/* We need to deal with frequency data!*/ /* We need to deal with frequency data!*/
BYTE *data = NULL; const BYTE *data = NULL;
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DVertexDeclarationImpl* vertexDeclaration = (IWineD3DVertexDeclarationImpl *)This->stateBlock->vertexDecl; IWineD3DVertexDeclarationImpl* vertexDeclaration = (IWineD3DVertexDeclarationImpl *)This->stateBlock->vertexDecl;
int i; unsigned int i;
WINED3DVERTEXELEMENT *element; const WINED3DVERTEXELEMENT *element;
DWORD stride; DWORD stride;
DWORD numPreloadStreams = This->stateBlock->streamIsUP ? 0 : vertexDeclaration->num_streams; DWORD numPreloadStreams = This->stateBlock->streamIsUP ? 0 : vertexDeclaration->num_streams;
DWORD *streams = vertexDeclaration->streams; const DWORD *streams = vertexDeclaration->streams;
/* Check for transformed vertices, disable vertex shader if present */ /* Check for transformed vertices, disable vertex shader if present */
strided->u.s.position_transformed = vertexDeclaration->position_transformed; strided->position_transformed = vertexDeclaration->position_transformed;
if(vertexDeclaration->position_transformed) { if(vertexDeclaration->position_transformed) {
useVertexShaderFunction = FALSE; useVertexShaderFunction = FALSE;
} }
/* Translate the declaration into strided data */ /* Translate the declaration into strided data */
strided->swizzle_map = 0;
for (i = 0 ; i < vertexDeclaration->declarationWNumElements - 1; ++i) { for (i = 0 ; i < vertexDeclaration->declarationWNumElements - 1; ++i) {
GLint streamVBO = 0; GLint streamVBO = 0;
BOOL stride_used; BOOL stride_used;
unsigned int idx; unsigned int idx;
element = vertexDeclaration->pDeclarationWine + i; element = vertexDeclaration->pDeclarationWine + i;
TRACE("%p Element %p (%d of %d)\n", vertexDeclaration->pDeclarationWine, TRACE("%p Element %p (%u of %u)\n", vertexDeclaration->pDeclarationWine,
element, i + 1, vertexDeclaration->declarationWNumElements - 1); element, i + 1, vertexDeclaration->declarationWNumElements - 1);
if (This->stateBlock->streamSource[element->Stream] == NULL) if (This->stateBlock->streamSource[element->Stream] == NULL)
@@ -201,8 +202,8 @@ void primitiveDeclarationConvertToStridedData(
element->Usage == WINED3DDECLUSAGE_POSITIONT)) { element->Usage == WINED3DDECLUSAGE_POSITIONT)) {
static BOOL warned = FALSE; static BOOL warned = FALSE;
if(!warned) { if(!warned) {
/* This may be bad with the fixed function pipeline */ /* This may be bad with the fixed function pipeline */
FIXME("Missing vbo streams with unfixed colors or transformed position, expect problems\n"); FIXME("Missing vbo streams with unfixed colors or transformed position, expect problems\n");
warned = TRUE; warned = TRUE;
} }
} }
@@ -234,6 +235,11 @@ void primitiveDeclarationConvertToStridedData(
strided->u.input[idx].dwStride = stride; strided->u.input[idx].dwStride = stride;
strided->u.input[idx].VBO = streamVBO; strided->u.input[idx].VBO = streamVBO;
strided->u.input[idx].streamNo = element->Stream; strided->u.input[idx].streamNo = element->Stream;
if (!GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA) && element->Type == WINED3DDECLTYPE_D3DCOLOR)
{
strided->swizzle_map |= 1 << idx;
}
strided->use_map |= 1 << idx;
} }
} }
} }
@@ -253,32 +259,35 @@ void primitiveDeclarationConvertToStridedData(
} }
} }
static void drawStridedFast(IWineD3DDevice *iface,UINT numberOfVertices, GLenum glPrimitiveType, static void drawStridedFast(IWineD3DDevice *iface, GLenum primitive_type,
const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx, ULONG startVertex) { UINT min_vertex_idx, UINT max_vertex_idx, UINT count, short idx_size,
const void *idx_data, UINT start_idx)
{
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
if (idxSize != 0 /* This crashes sometimes!*/) { if (idx_size)
TRACE("(%p) : glElements(%x, %d, %d, ...)\n", This, glPrimitiveType, numberOfVertices, minIndex); {
idxData = idxData == (void *)-1 ? NULL : idxData; TRACE("(%p) : glElements(%x, %d, %d, ...)\n", This, primitive_type, count, min_vertex_idx);
#if 1
glDrawElements(glPrimitiveType, numberOfVertices, idxSize == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT,
(const char *)idxData+(idxSize * startIdx));
checkGLcall("glDrawElements");
#else /* using drawRangeElements may be faster */
glDrawRangeElements(glPrimitiveType, minIndex, minIndex + numberOfVertices - 1, numberOfVertices, #if 1
idxSize == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, glDrawElements(primitive_type, count,
(const char *)idxData+(idxSize * startIdx)); idx_size == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT,
(const char *)idx_data + (idx_size * start_idx));
checkGLcall("glDrawElements");
#else
glDrawRangeElements(primitive_type, min_vertex_idx, max_vertex_idx, count,
idx_size == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT,
(const char *)idx_data + (idx_size * start_idx));
checkGLcall("glDrawRangeElements"); checkGLcall("glDrawRangeElements");
#endif #endif
}
else
{
TRACE("(%p) : glDrawArrays(%#x, %d, %d)\n", This, primitive_type, start_idx, count);
} else { glDrawArrays(primitive_type, start_idx, count);
TRACE("(%p) : glDrawArrays(%#x, %d, %d)\n", This, glPrimitiveType, startVertex, numberOfVertices);
glDrawArrays(glPrimitiveType, startVertex, numberOfVertices);
checkGLcall("glDrawArrays"); checkGLcall("glDrawArrays");
} }
return;
} }
/* /*
@@ -286,21 +295,22 @@ static void drawStridedFast(IWineD3DDevice *iface,UINT numberOfVertices, GLenum
* Slower GL version which extracts info about each vertex in turn * Slower GL version which extracts info about each vertex in turn
*/ */
static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData *sd, static void drawStridedSlow(IWineD3DDevice *iface, const WineDirect3DVertexStridedData *sd, UINT NumVertexes,
UINT NumVertexes, GLenum glPrimType, GLenum glPrimType, const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx)
const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx, ULONG startVertex) { {
unsigned int textureNo = 0; unsigned int textureNo = 0;
const WORD *pIdxBufS = NULL; const WORD *pIdxBufS = NULL;
const DWORD *pIdxBufL = NULL; const DWORD *pIdxBufL = NULL;
LONG vx_index; ULONG vx_index;
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
UINT *streamOffset = This->stateBlock->streamOffset; const UINT *streamOffset = This->stateBlock->streamOffset;
long SkipnStrides = startVertex + This->stateBlock->loadBaseVertexIndex; long SkipnStrides = startIdx + This->stateBlock->loadBaseVertexIndex;
BOOL pixelShader = use_ps(This); BOOL pixelShader = use_ps(This->stateBlock);
BOOL specular_fog = FALSE;
BYTE *texCoords[WINED3DDP_MAXTEXCOORD]; UINT texture_stages = GL_LIMITS(texture_stages);
BYTE *diffuse = NULL, *specular = NULL, *normal = NULL, *position = NULL; const BYTE *texCoords[WINED3DDP_MAXTEXCOORD];
const BYTE *diffuse = NULL, *specular = NULL, *normal = NULL, *position = NULL;
DWORD tex_mask = 0;
TRACE("Using slow vertex array code\n"); TRACE("Using slow vertex array code\n");
@@ -321,56 +331,92 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData
return; return;
} }
/* Adding the stream offset once is cheaper than doing it every iteration. Do not modify the strided data, it is a pointer
* to the strided Data in the device and might be needed intact on the next draw
*/
for (textureNo = 0; textureNo < GL_LIMITS(texture_stages); ++textureNo) {
if(sd->u.s.texCoords[textureNo].lpData) {
texCoords[textureNo] = sd->u.s.texCoords[textureNo].lpData + streamOffset[sd->u.s.texCoords[textureNo].streamNo];
} else {
texCoords[textureNo] = NULL;
}
}
if(sd->u.s.diffuse.lpData) {
diffuse = sd->u.s.diffuse.lpData + streamOffset[sd->u.s.diffuse.streamNo];
}
if(sd->u.s.specular.lpData) {
specular = sd->u.s.specular.lpData + streamOffset[sd->u.s.specular.streamNo];
}
if(sd->u.s.normal.lpData) {
normal = sd->u.s.normal.lpData + streamOffset[sd->u.s.normal.streamNo];
}
if(sd->u.s.position.lpData) {
position = sd->u.s.position.lpData + streamOffset[sd->u.s.position.streamNo];
}
if(FIXME_ON(d3d_draw)) {
if(specular && This->stateBlock->renderState[WINED3DRS_FOGENABLE] &&
(This->stateBlock->renderState[WINED3DRS_FOGVERTEXMODE] == WINED3DFOG_NONE || sd->u.s.position_transformed )&&
This->stateBlock->renderState[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE) {
if(GL_SUPPORT(EXT_FOG_COORD) && sd->u.s.specular.dwType != WINED3DDECLTYPE_D3DCOLOR) {
FIXME("Implement fog coordinates from %s\n", debug_d3ddecltype(sd->u.s.specular.dwType));
}
}
if(This->activeContext->num_untracked_materials && sd->u.s.diffuse.dwType != WINED3DDECLTYPE_D3DCOLOR) {
FIXME("Implement diffuse color tracking from %s\n", debug_d3ddecltype(sd->u.s.diffuse.dwType));
}
}
/* Start drawing in GL */ /* Start drawing in GL */
VTRACE(("glBegin(%x)\n", glPrimType)); VTRACE(("glBegin(%x)\n", glPrimType));
glBegin(glPrimType); glBegin(glPrimType);
/* Default settings for data that is not passed */ if (sd->u.s.position.lpData) position = sd->u.s.position.lpData + streamOffset[sd->u.s.position.streamNo];
if (sd->u.s.normal.lpData == NULL) {
glNormal3f(0, 0, 0); if (sd->u.s.normal.lpData) normal = sd->u.s.normal.lpData + streamOffset[sd->u.s.normal.streamNo];
else glNormal3f(0, 0, 0);
if (sd->u.s.diffuse.lpData) diffuse = sd->u.s.diffuse.lpData + streamOffset[sd->u.s.diffuse.streamNo];
else glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
if (This->activeContext->num_untracked_materials && sd->u.s.diffuse.dwType != WINED3DDECLTYPE_D3DCOLOR)
FIXME("Implement diffuse color tracking from %s\n", debug_d3ddecltype(sd->u.s.diffuse.dwType));
if (sd->u.s.specular.lpData)
{
specular = sd->u.s.specular.lpData + streamOffset[sd->u.s.specular.streamNo];
/* special case where the fog density is stored in the specular alpha channel */
if (This->stateBlock->renderState[WINED3DRS_FOGENABLE]
&& (This->stateBlock->renderState[WINED3DRS_FOGVERTEXMODE] == WINED3DFOG_NONE
|| sd->u.s.position.dwType == WINED3DDECLTYPE_FLOAT4)
&& This->stateBlock->renderState[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE)
{
if (GL_SUPPORT(EXT_FOG_COORD))
{
if (sd->u.s.specular.dwType == WINED3DDECLTYPE_D3DCOLOR) specular_fog = TRUE;
else FIXME("Implement fog coordinates from %s\n", debug_d3ddecltype(sd->u.s.specular.dwType));
}
else
{
static BOOL warned;
if (!warned)
{
/* TODO: Use the fog table code from old ddraw */
FIXME("Implement fog for transformed vertices in software\n");
warned = TRUE;
}
}
}
} }
if(sd->u.s.diffuse.lpData == NULL) { else if (GL_SUPPORT(EXT_SECONDARY_COLOR))
glColor4f(1.0f, 1.0f, 1.0f, 1.0f); {
GL_EXTCALL(glSecondaryColor3fEXT)(0, 0, 0);
} }
if(sd->u.s.specular.lpData == NULL) {
if (GL_SUPPORT(EXT_SECONDARY_COLOR)) { for (textureNo = 0; textureNo < texture_stages; ++textureNo)
GL_EXTCALL(glSecondaryColor3fEXT)(0, 0, 0); {
int coordIdx = This->stateBlock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX];
int texture_idx = This->texUnitMap[textureNo];
if (!GL_SUPPORT(ARB_MULTITEXTURE) && textureNo > 0)
{
FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
continue;
}
if (!pixelShader && !This->stateBlock->textures[textureNo]) continue;
if (texture_idx == -1) continue;
if (coordIdx > 7)
{
TRACE("tex: %d - Skip tex coords, as being system generated\n", textureNo);
continue;
}
else if (coordIdx < 0)
{
FIXME("tex: %d - Coord index %d is less than zero, expect a crash.\n", textureNo, coordIdx);
continue;
}
if(sd->u.s.texCoords[coordIdx].lpData)
{
texCoords[coordIdx] =
sd->u.s.texCoords[coordIdx].lpData + streamOffset[sd->u.s.texCoords[coordIdx].streamNo];
tex_mask |= (1 << textureNo);
}
else
{
TRACE("tex: %d - Skipping tex coords, as no data supplied\n", textureNo);
if (GL_SUPPORT(ARB_MULTITEXTURE))
GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + texture_idx, 0, 0, 0, 1));
else
glTexCoord4f(0, 0, 0, 1);
} }
} }
@@ -380,6 +426,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData
/* For each primitive */ /* For each primitive */
for (vx_index = 0; vx_index < NumVertexes; ++vx_index) { for (vx_index = 0; vx_index < NumVertexes; ++vx_index) {
UINT texture, tmp_tex_mask;
/* Blending data and Point sizes are not supported by this function. They are not supported by the fixed /* Blending data and Point sizes are not supported by this function. They are not supported by the fixed
* function pipeline at all. A Fixme for them is printed after decoding the vertex declaration * function pipeline at all. A Fixme for them is printed after decoding the vertex declaration
*/ */
@@ -389,63 +436,37 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData
/* Indexed so work out the number of strides to skip */ /* Indexed so work out the number of strides to skip */
if (idxSize == 2) { if (idxSize == 2) {
VTRACE(("Idx for vertex %d = %d\n", vx_index, pIdxBufS[startIdx+vx_index])); VTRACE(("Idx for vertex %u = %u\n", vx_index, pIdxBufS[startIdx+vx_index]));
SkipnStrides = pIdxBufS[startIdx + vx_index] + This->stateBlock->loadBaseVertexIndex; SkipnStrides = pIdxBufS[startIdx + vx_index] + This->stateBlock->loadBaseVertexIndex;
} else { } else {
VTRACE(("Idx for vertex %d = %d\n", vx_index, pIdxBufL[startIdx+vx_index])); VTRACE(("Idx for vertex %u = %u\n", vx_index, pIdxBufL[startIdx+vx_index]));
SkipnStrides = pIdxBufL[startIdx + vx_index] + This->stateBlock->loadBaseVertexIndex; SkipnStrides = pIdxBufL[startIdx + vx_index] + This->stateBlock->loadBaseVertexIndex;
} }
} }
/* Texture coords --------------------------- */ tmp_tex_mask = tex_mask;
for (textureNo = 0; textureNo < GL_LIMITS(texture_stages); ++textureNo) { for (texture = 0; tmp_tex_mask; tmp_tex_mask >>= 1, ++texture)
{
int coord_idx;
const void *ptr;
int texture_idx;
if (!GL_SUPPORT(ARB_MULTITEXTURE) && textureNo > 0) { if (!(tmp_tex_mask & 1)) continue;
FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
continue ;
}
/* Query tex coords */ coord_idx = This->stateBlock->textureState[texture][WINED3DTSS_TEXCOORDINDEX];
if (This->stateBlock->textures[textureNo] != NULL || pixelShader) { ptr = texCoords[coord_idx] + (SkipnStrides * sd->u.s.texCoords[coord_idx].dwStride);
int coordIdx = This->stateBlock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX];
int texture_idx = This->texUnitMap[textureNo];
void *ptrToCoords;
if (coordIdx > 7) { texture_idx = This->texUnitMap[texture];
VTRACE(("tex: %d - Skip tex coords, as being system generated\n", textureNo)); multi_texcoord_funcs[sd->u.s.texCoords[coord_idx].dwType](GL_TEXTURE0_ARB + texture_idx, ptr);
continue; }
} else if (coordIdx < 0) {
FIXME("tex: %d - Coord index %d is less than zero, expect a crash.\n", textureNo, coordIdx);
continue;
}
if (texture_idx == -1) continue;
if (texCoords[coordIdx] == NULL) {
TRACE("tex: %d - Skipping tex coords, as no data supplied\n", textureNo);
if (GL_SUPPORT(ARB_MULTITEXTURE)) {
GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + texture_idx, 0, 0, 0, 1));
} else {
glTexCoord4f(0, 0, 0, 1);
}
continue;
}
ptrToCoords = texCoords[coordIdx] + (SkipnStrides * sd->u.s.texCoords[coordIdx].dwStride);
if (GL_SUPPORT(ARB_MULTITEXTURE))
multi_texcoord_funcs[sd->u.s.texCoords[coordIdx].dwType](GL_TEXTURE0_ARB + texture_idx, ptrToCoords);
else
texcoord_funcs[sd->u.s.texCoords[coordIdx].dwType](ptrToCoords);
}
} /* End of textures */
/* Diffuse -------------------------------- */ /* Diffuse -------------------------------- */
if (diffuse) { if (diffuse) {
DWORD *ptrToCoords = (DWORD *)(diffuse + (SkipnStrides * sd->u.s.diffuse.dwStride)); const void *ptrToCoords = diffuse + SkipnStrides * sd->u.s.diffuse.dwStride;
diffuse_funcs[sd->u.s.diffuse.dwType]((void *) ptrToCoords); diffuse_funcs[sd->u.s.diffuse.dwType](ptrToCoords);
if(This->activeContext->num_untracked_materials) { if(This->activeContext->num_untracked_materials) {
DWORD diffuseColor = ptrToCoords[0]; DWORD diffuseColor = ((const DWORD *)ptrToCoords)[0];
unsigned char i; unsigned char i;
float color[4]; float color[4];
@@ -462,37 +483,26 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData
/* Specular ------------------------------- */ /* Specular ------------------------------- */
if (specular) { if (specular) {
DWORD *ptrToCoords = (DWORD *)(specular + (SkipnStrides * sd->u.s.specular.dwStride)); const void *ptrToCoords = specular + SkipnStrides * sd->u.s.specular.dwStride;
/* special case where the fog density is stored in the specular alpha channel */ specular_funcs[sd->u.s.specular.dwType](ptrToCoords);
if(This->stateBlock->renderState[WINED3DRS_FOGENABLE] &&
(This->stateBlock->renderState[WINED3DRS_FOGVERTEXMODE] == WINED3DFOG_NONE || sd->u.s.position.dwType == WINED3DDECLTYPE_FLOAT4 )&& if (specular_fog)
This->stateBlock->renderState[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE) { {
if(GL_SUPPORT(EXT_FOG_COORD)) { DWORD specularColor = *(const DWORD *)ptrToCoords;
DWORD specularColor = ptrToCoords[0]; GL_EXTCALL(glFogCoordfEXT(specularColor >> 24));
GL_EXTCALL(glFogCoordfEXT(specularColor >> 24));
} else {
static BOOL warned = FALSE;
if(!warned) {
/* TODO: Use the fog table code from old ddraw */
FIXME("Implement fog for transformed vertices in software\n");
warned = TRUE;
}
}
} }
specular_funcs[sd->u.s.specular.dwType]((void *) ptrToCoords);
} }
/* Normal -------------------------------- */ /* Normal -------------------------------- */
if (normal != NULL) { if (normal != NULL) {
float *ptrToCoords = (float *)(normal + (SkipnStrides * sd->u.s.normal.dwStride)); const void *ptrToCoords = normal + SkipnStrides * sd->u.s.normal.dwStride;
normal_funcs[sd->u.s.normal.dwType](ptrToCoords); normal_funcs[sd->u.s.normal.dwType](ptrToCoords);
} }
/* Position -------------------------------- */ /* Position -------------------------------- */
if (position) { if (position) {
float *ptrToCoords = (float *)(position + (SkipnStrides * sd->u.s.position.dwStride)); const void *ptrToCoords = position + SkipnStrides * sd->u.s.position.dwStride;
position_funcs[sd->u.s.position.dwType](ptrToCoords); position_funcs[sd->u.s.position.dwType](ptrToCoords);
} }
@@ -509,16 +519,16 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData
static inline void send_attribute(IWineD3DDeviceImpl *This, const DWORD type, const UINT index, const void *ptr) { static inline void send_attribute(IWineD3DDeviceImpl *This, const DWORD type, const UINT index, const void *ptr) {
switch(type) { switch(type) {
case WINED3DDECLTYPE_FLOAT1: case WINED3DDECLTYPE_FLOAT1:
GL_EXTCALL(glVertexAttrib1fvARB(index, (float *) ptr)); GL_EXTCALL(glVertexAttrib1fvARB(index, (const float *)ptr));
break; break;
case WINED3DDECLTYPE_FLOAT2: case WINED3DDECLTYPE_FLOAT2:
GL_EXTCALL(glVertexAttrib2fvARB(index, (float *) ptr)); GL_EXTCALL(glVertexAttrib2fvARB(index, (const float *)ptr));
break; break;
case WINED3DDECLTYPE_FLOAT3: case WINED3DDECLTYPE_FLOAT3:
GL_EXTCALL(glVertexAttrib3fvARB(index, (float *) ptr)); GL_EXTCALL(glVertexAttrib3fvARB(index, (const float *)ptr));
break; break;
case WINED3DDECLTYPE_FLOAT4: case WINED3DDECLTYPE_FLOAT4:
GL_EXTCALL(glVertexAttrib4fvARB(index, (float *) ptr)); GL_EXTCALL(glVertexAttrib4fvARB(index, (const float *)ptr));
break; break;
case WINED3DDECLTYPE_UBYTE4: case WINED3DDECLTYPE_UBYTE4:
@@ -530,29 +540,29 @@ static inline void send_attribute(IWineD3DDeviceImpl *This, const DWORD type, co
break; break;
case WINED3DDECLTYPE_SHORT2: case WINED3DDECLTYPE_SHORT2:
GL_EXTCALL(glVertexAttrib4svARB(index, (GLshort *) ptr)); GL_EXTCALL(glVertexAttrib4svARB(index, (const GLshort *)ptr));
break; break;
case WINED3DDECLTYPE_SHORT4: case WINED3DDECLTYPE_SHORT4:
GL_EXTCALL(glVertexAttrib4svARB(index, (GLshort *) ptr)); GL_EXTCALL(glVertexAttrib4svARB(index, (const GLshort *)ptr));
break; break;
case WINED3DDECLTYPE_SHORT2N: case WINED3DDECLTYPE_SHORT2N:
{ {
GLshort s[4] = {((short *) ptr)[0], ((short *) ptr)[1], 0, 1}; GLshort s[4] = {((const GLshort *)ptr)[0], ((const GLshort *)ptr)[1], 0, 1};
GL_EXTCALL(glVertexAttrib4NsvARB(index, s)); GL_EXTCALL(glVertexAttrib4NsvARB(index, s));
break; break;
} }
case WINED3DDECLTYPE_USHORT2N: case WINED3DDECLTYPE_USHORT2N:
{ {
GLushort s[4] = {((unsigned short *) ptr)[0], ((unsigned short *) ptr)[1], 0, 1}; GLushort s[4] = {((const GLushort *)ptr)[0], ((const GLushort *)ptr)[1], 0, 1};
GL_EXTCALL(glVertexAttrib4NusvARB(index, s)); GL_EXTCALL(glVertexAttrib4NusvARB(index, s));
break; break;
} }
case WINED3DDECLTYPE_SHORT4N: case WINED3DDECLTYPE_SHORT4N:
GL_EXTCALL(glVertexAttrib4NsvARB(index, (GLshort *) ptr)); GL_EXTCALL(glVertexAttrib4NsvARB(index, (const GLshort *)ptr));
break; break;
case WINED3DDECLTYPE_USHORT4N: case WINED3DDECLTYPE_USHORT4N:
GL_EXTCALL(glVertexAttrib4NusvARB(index, (GLushort *) ptr)); GL_EXTCALL(glVertexAttrib4NusvARB(index, (const GLushort *)ptr));
break; break;
case WINED3DDECLTYPE_UDEC3: case WINED3DDECLTYPE_UDEC3:
@@ -569,21 +579,21 @@ static inline void send_attribute(IWineD3DDeviceImpl *This, const DWORD type, co
* byte float according to the IEEE standard * byte float according to the IEEE standard
*/ */
if (GL_SUPPORT(NV_HALF_FLOAT)) { if (GL_SUPPORT(NV_HALF_FLOAT)) {
GL_EXTCALL(glVertexAttrib2hvNV(index, (GLhalfNV *)ptr)); GL_EXTCALL(glVertexAttrib2hvNV(index, (const GLhalfNV *)ptr));
} else { } else {
float x = float_16_to_32(((unsigned short *) ptr) + 0); float x = float_16_to_32(((const unsigned short *)ptr) + 0);
float y = float_16_to_32(((unsigned short *) ptr) + 1); float y = float_16_to_32(((const unsigned short *)ptr) + 1);
GL_EXTCALL(glVertexAttrib2fARB(index, x, y)); GL_EXTCALL(glVertexAttrib2fARB(index, x, y));
} }
break; break;
case WINED3DDECLTYPE_FLOAT16_4: case WINED3DDECLTYPE_FLOAT16_4:
if (GL_SUPPORT(NV_HALF_FLOAT)) { if (GL_SUPPORT(NV_HALF_FLOAT)) {
GL_EXTCALL(glVertexAttrib4hvNV(index, (GLhalfNV *)ptr)); GL_EXTCALL(glVertexAttrib4hvNV(index, (const GLhalfNV *)ptr));
} else { } else {
float x = float_16_to_32(((unsigned short *) ptr) + 0); float x = float_16_to_32(((const unsigned short *)ptr) + 0);
float y = float_16_to_32(((unsigned short *) ptr) + 1); float y = float_16_to_32(((const unsigned short *)ptr) + 1);
float z = float_16_to_32(((unsigned short *) ptr) + 2); float z = float_16_to_32(((const unsigned short *)ptr) + 2);
float w = float_16_to_32(((unsigned short *) ptr) + 3); float w = float_16_to_32(((const unsigned short *)ptr) + 3);
GL_EXTCALL(glVertexAttrib4fARB(index, x, y, z, w)); GL_EXTCALL(glVertexAttrib4fARB(index, x, y, z, w));
} }
break; break;
@@ -595,18 +605,17 @@ static inline void send_attribute(IWineD3DDeviceImpl *This, const DWORD type, co
} }
} }
static void drawStridedSlowVs(IWineD3DDevice *iface, WineDirect3DVertexStridedData *sd, UINT numberOfVertices, static void drawStridedSlowVs(IWineD3DDevice *iface, const WineDirect3DVertexStridedData *sd, UINT numberOfVertices,
GLenum glPrimitiveType, const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx, GLenum glPrimitiveType, const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx)
ULONG startVertex) { {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
long SkipnStrides = startVertex + This->stateBlock->loadBaseVertexIndex; long SkipnStrides = startIdx + This->stateBlock->loadBaseVertexIndex;
const WORD *pIdxBufS = NULL; const WORD *pIdxBufS = NULL;
const DWORD *pIdxBufL = NULL; const DWORD *pIdxBufL = NULL;
LONG vx_index; ULONG vx_index;
int i; int i;
IWineD3DStateBlockImpl *stateblock = This->stateBlock; IWineD3DStateBlockImpl *stateblock = This->stateBlock;
BYTE *ptr; const BYTE *ptr;
if (idxSize != 0) { if (idxSize != 0) {
/* Immediate mode drawing can't make use of indices in a vbo - get the data from the index buffer. /* Immediate mode drawing can't make use of indices in a vbo - get the data from the index buffer.
@@ -656,11 +665,12 @@ static void drawStridedSlowVs(IWineD3DDevice *iface, WineDirect3DVertexStridedDa
glEnd(); glEnd();
} }
static inline void drawStridedInstanced(IWineD3DDevice *iface, WineDirect3DVertexStridedData *sd, UINT numberOfVertices, static inline void drawStridedInstanced(IWineD3DDevice *iface, const WineDirect3DVertexStridedData *sd,
GLenum glPrimitiveType, const void *idxData, short idxSize, ULONG minIndex, UINT numberOfVertices, GLenum glPrimitiveType, const void *idxData, short idxSize, ULONG minIndex,
ULONG startIdx, ULONG startVertex) { ULONG startIdx)
UINT numInstances = 0; {
int numInstancedAttribs = 0, i, j; UINT numInstances = 0, i;
int numInstancedAttribs = 0, j;
UINT instancedData[sizeof(sd->u.input) / sizeof(sd->u.input[0]) /* 16 */]; UINT instancedData[sizeof(sd->u.input) / sizeof(sd->u.input[0]) /* 16 */];
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
IWineD3DStateBlockImpl *stateblock = This->stateBlock; IWineD3DStateBlockImpl *stateblock = This->stateBlock;
@@ -677,7 +687,6 @@ static inline void drawStridedInstanced(IWineD3DDevice *iface, WineDirect3DVerte
} }
TRACE("(%p) : glElements(%x, %d, %d, ...)\n", This, glPrimitiveType, numberOfVertices, minIndex); TRACE("(%p) : glElements(%x, %d, %d, ...)\n", This, glPrimitiveType, numberOfVertices, minIndex);
idxData = idxData == (void *)-1 ? NULL : idxData;
/* First, figure out how many instances we have to draw */ /* First, figure out how many instances we have to draw */
for(i = 0; i < MAX_STREAMS; i++) { for(i = 0; i < MAX_STREAMS; i++) {
@@ -704,7 +713,7 @@ static inline void drawStridedInstanced(IWineD3DDevice *iface, WineDirect3DVerte
for(i = 0; i < numInstances; i++) { for(i = 0; i < numInstances; i++) {
/* Specify the instanced attributes using immediate mode calls */ /* Specify the instanced attributes using immediate mode calls */
for(j = 0; j < numInstancedAttribs; j++) { for(j = 0; j < numInstancedAttribs; j++) {
BYTE *ptr = sd->u.input[instancedData[j]].lpData + const BYTE *ptr = sd->u.input[instancedData[j]].lpData +
sd->u.input[instancedData[j]].dwStride * i + sd->u.input[instancedData[j]].dwStride * i +
stateblock->streamOffset[sd->u.input[instancedData[j]].streamNo]; stateblock->streamOffset[sd->u.input[instancedData[j]].streamNo];
if(sd->u.input[instancedData[j]].VBO) { if(sd->u.input[instancedData[j]].VBO) {
@@ -810,20 +819,13 @@ static inline void remove_vbos(IWineD3DDeviceImpl *This, WineDirect3DVertexStrid
} }
/* Routine common to the draw primitive and draw indexed primitive routines */ /* Routine common to the draw primitive and draw indexed primitive routines */
void drawPrimitive(IWineD3DDevice *iface, void drawPrimitive(IWineD3DDevice *iface, int PrimitiveType, long NumPrimitives,
int PrimitiveType, UINT numberOfVertices, long StartIdx, short idxSize, const void *idxData, int minIndex)
long NumPrimitives, {
/* for Indexed: */
long StartVertexIndex,
UINT numberOfVertices,
long StartIdx,
short idxSize,
const void *idxData,
int minIndex) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DSurfaceImpl *target; IWineD3DSurfaceImpl *target;
int i; unsigned int i;
if (NumPrimitives == 0) return; if (NumPrimitives == 0) return;
@@ -854,7 +856,7 @@ void drawPrimitive(IWineD3DDevice *iface,
{ {
GLenum glPrimType; GLenum glPrimType;
BOOL emulation = FALSE; BOOL emulation = FALSE;
WineDirect3DVertexStridedData *strided = &This->strided_streams; const WineDirect3DVertexStridedData *strided = &This->strided_streams;
WineDirect3DVertexStridedData stridedlcl; WineDirect3DVertexStridedData stridedlcl;
/* Ok, Work out which primitive is requested and how many vertexes that /* Ok, Work out which primitive is requested and how many vertexes that
will be */ will be */
@@ -862,13 +864,15 @@ void drawPrimitive(IWineD3DDevice *iface,
if (numberOfVertices == 0 ) if (numberOfVertices == 0 )
numberOfVertices = calculatedNumberOfindices; numberOfVertices = calculatedNumberOfindices;
if(!use_vs(This)) { if (!use_vs(This->stateBlock))
if(!This->strided_streams.u.s.position_transformed && This->activeContext->num_untracked_materials && {
This->stateBlock->renderState[WINED3DRS_LIGHTING]) { if (!This->strided_streams.position_transformed && This->activeContext->num_untracked_materials
static BOOL first = TRUE; && This->stateBlock->renderState[WINED3DRS_LIGHTING])
if(first) { {
static BOOL warned;
if (!warned) {
FIXME("Using software emulation because not all material properties could be tracked\n"); FIXME("Using software emulation because not all material properties could be tracked\n");
first = FALSE; warned = TRUE;
} else { } else {
TRACE("Using software emulation because not all material properties could be tracked\n"); TRACE("Using software emulation because not all material properties could be tracked\n");
} }
@@ -878,10 +882,10 @@ void drawPrimitive(IWineD3DDevice *iface,
/* Either write a pipeline replacement shader or convert the specular alpha from unsigned byte /* Either write a pipeline replacement shader or convert the specular alpha from unsigned byte
* to a float in the vertex buffer * to a float in the vertex buffer
*/ */
static BOOL first = TRUE; static BOOL warned;
if(first) { if (!warned) {
FIXME("Using software emulation because manual fog coordinates are provided\n"); FIXME("Using software emulation because manual fog coordinates are provided\n");
first = FALSE; warned = TRUE;
} else { } else {
TRACE("Using software emulation because manual fog coordinates are provided\n"); TRACE("Using software emulation because manual fog coordinates are provided\n");
} }
@@ -897,27 +901,28 @@ void drawPrimitive(IWineD3DDevice *iface,
if (This->useDrawStridedSlow || emulation) { if (This->useDrawStridedSlow || emulation) {
/* Immediate mode drawing */ /* Immediate mode drawing */
if(use_vs(This)) { if (use_vs(This->stateBlock))
static BOOL first = TRUE; {
if(first) { static BOOL warned;
if (!warned) {
FIXME("Using immediate mode with vertex shaders for half float emulation\n"); FIXME("Using immediate mode with vertex shaders for half float emulation\n");
first = FALSE; warned = TRUE;
} else { } else {
TRACE("Using immediate mode with vertex shaders for half float emulation\n"); TRACE("Using immediate mode with vertex shaders for half float emulation\n");
} }
drawStridedSlowVs(iface, strided, calculatedNumberOfindices, glPrimType, drawStridedSlowVs(iface, strided, calculatedNumberOfindices,
idxData, idxSize, minIndex, StartIdx, StartVertexIndex); glPrimType, idxData, idxSize, minIndex, StartIdx);
} else { } else {
drawStridedSlow(iface, strided, calculatedNumberOfindices, drawStridedSlow(iface, strided, calculatedNumberOfindices,
glPrimType, idxData, idxSize, minIndex, StartIdx, StartVertexIndex); glPrimType, idxData, idxSize, minIndex, StartIdx);
} }
} else if(This->instancedDraw) { } else if(This->instancedDraw) {
/* Instancing emulation with mixing immediate mode and arrays */ /* Instancing emulation with mixing immediate mode and arrays */
drawStridedInstanced(iface, &This->strided_streams, calculatedNumberOfindices, glPrimType, drawStridedInstanced(iface, &This->strided_streams, calculatedNumberOfindices, glPrimType,
idxData, idxSize, minIndex, StartIdx, StartVertexIndex); idxData, idxSize, minIndex, StartIdx);
} else { } else {
drawStridedFast(iface, calculatedNumberOfindices, glPrimType, drawStridedFast(iface, glPrimType, minIndex, minIndex + numberOfVertices - 1,
idxData, idxSize, minIndex, StartIdx, StartVertexIndex); calculatedNumberOfindices, idxSize, idxData, StartIdx);
} }
} }
@@ -1005,8 +1010,8 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
unsigned int i, j, num_quads, out_vertex_size, buffer_size, d3d_out_vertex_size; unsigned int i, j, num_quads, out_vertex_size, buffer_size, d3d_out_vertex_size;
float max_x = 0.0, max_y = 0.0, max_z = 0.0, neg_z = 0.0; float max_x = 0.0, max_y = 0.0, max_z = 0.0, neg_z = 0.0;
WineDirect3DVertexStridedData strided; WineDirect3DVertexStridedData strided;
BYTE *data; const BYTE *data;
WINED3DRECTPATCH_INFO *info = &patch->RectPatchInfo; const WINED3DRECTPATCH_INFO *info = &patch->RectPatchInfo;
DWORD vtxStride; DWORD vtxStride;
GLenum feedback_type; GLenum feedback_type;
GLfloat *feedbuffer; GLfloat *feedbuffer;
@@ -1028,9 +1033,8 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
vtxStride * info->StartVertexOffsetWidth; vtxStride * info->StartVertexOffsetWidth;
/* Not entirely sure about what happens with transformed vertices */ /* Not entirely sure about what happens with transformed vertices */
if(strided.u.s.position_transformed) { if (strided.position_transformed) FIXME("Transformed position in rectpatch generation\n");
FIXME("Transformed position in rectpatch generation\n");
}
if(vtxStride % sizeof(GLfloat)) { if(vtxStride % sizeof(GLfloat)) {
/* glMap2f reads vertex sizes in GLfloats, the d3d stride is in bytes. /* glMap2f reads vertex sizes in GLfloats, the d3d stride is in bytes.
* I don't see how the stride could not be a multiple of 4, but make sure * I don't see how the stride could not be a multiple of 4, but make sure
@@ -1048,7 +1052,7 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
/* First, get the boundary cube of the input data */ /* First, get the boundary cube of the input data */
for(j = 0; j < info->Height; j++) { for(j = 0; j < info->Height; j++) {
for(i = 0; i < info->Width; i++) { for(i = 0; i < info->Width; i++) {
float *v = (float *) (data + vtxStride * i + vtxStride * info->Stride * j); const float *v = (const float *)(data + vtxStride * i + vtxStride * info->Stride * j);
if(fabs(v[0]) > max_x) max_x = fabs(v[0]); if(fabs(v[0]) > max_x) max_x = fabs(v[0]);
if(fabs(v[1]) > max_y) max_y = fabs(v[1]); if(fabs(v[1]) > max_y) max_y = fabs(v[1]);
if(fabs(v[2]) > max_z) max_z = fabs(v[2]); if(fabs(v[2]) > max_z) max_z = fabs(v[2]);
@@ -1085,11 +1089,11 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)"); checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)");
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_FILLMODE)); IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_FILLMODE));
if(patch->has_normals) { if(patch->has_normals) {
float black[4] = {0, 0, 0, 0}; static const GLfloat black[] = {0, 0, 0, 0};
float red[4] = {1, 0, 0, 0}; static const GLfloat red[] = {1, 0, 0, 0};
float green[4] = {0, 1, 0, 0}; static const GLfloat green[] = {0, 1, 0, 0};
float blue[4] = {0, 0, 1, 0}; static const GLfloat blue[] = {0, 0, 1, 0};
float white[4] = {1, 1, 1, 1}; static const GLfloat white[] = {1, 1, 1, 1};
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
checkGLcall("glEnable(GL_LIGHTING)"); checkGLcall("glEnable(GL_LIGHTING)");
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, black); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, black);
@@ -1172,13 +1176,13 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
glMap2f(GL_MAP2_VERTEX_3, glMap2f(GL_MAP2_VERTEX_3,
0, 1, vtxStride / sizeof(float), info->Width, 0, 1, vtxStride / sizeof(float), info->Width,
0, 1, info->Stride * vtxStride / sizeof(float), info->Height, 0, 1, info->Stride * vtxStride / sizeof(float), info->Height,
(float *) data); (const GLfloat *)data);
checkGLcall("glMap2f"); checkGLcall("glMap2f");
if(patch->has_texcoords) { if(patch->has_texcoords) {
glMap2f(GL_MAP2_TEXTURE_COORD_4, glMap2f(GL_MAP2_TEXTURE_COORD_4,
0, 1, vtxStride / sizeof(float), info->Width, 0, 1, vtxStride / sizeof(float), info->Width,
0, 1, info->Stride * vtxStride / sizeof(float), info->Height, 0, 1, info->Stride * vtxStride / sizeof(float), info->Height,
(float *) data); (const GLfloat *)data);
checkGLcall("glMap2f"); checkGLcall("glMap2f");
} }
glMapGrid2f(ceilf(patch->numSegs[0]), 0.0, 1.0, ceilf(patch->numSegs[1]), 0.0, 1.0); glMapGrid2f(ceilf(patch->numSegs[0]), 0.0, 1.0, ceilf(patch->numSegs[1]), 0.0, 1.0);
@@ -1256,9 +1260,9 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
if(patch->has_normals) { if(patch->has_normals) {
/* Now do the same with reverse light directions */ /* Now do the same with reverse light directions */
float x[4] = {-1, 0, 0, 0}; static const GLfloat x[] = {-1, 0, 0, 0};
float y[4] = { 0, -1, 0, 0}; static const GLfloat y[] = { 0, -1, 0, 0};
float z[4] = { 0, 0, -1, 0}; static const GLfloat z[] = { 0, 0, -1, 0};
glLightfv(GL_LIGHT0, GL_POSITION, x); glLightfv(GL_LIGHT0, GL_POSITION, x);
glLightfv(GL_LIGHT1, GL_POSITION, y); glLightfv(GL_LIGHT1, GL_POSITION, y);
glLightfv(GL_LIGHT2, GL_POSITION, z); glLightfv(GL_LIGHT2, GL_POSITION, z);

View File

@@ -0,0 +1,535 @@
/*
* Compatibility functions for older GL implementations
*
* Copyright 2008 Stefan Dösinger for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <stdio.h>
#ifdef HAVE_FLOAT_H
# include <float.h>
#endif
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(gl_compat);
/* Start GL_ARB_multitexture emulation */
static void WINE_GLAPI wine_glMultiTexCoord1fARB(GLenum target, GLfloat s) {
if(target != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
glTexCoord1f(s);
}
static void WINE_GLAPI wine_glMultiTexCoord1fvARB(GLenum target, const GLfloat *v) {
if(target != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
glTexCoord1fv(v);
}
static void WINE_GLAPI wine_glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t) {
if(target != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
glTexCoord2f(s, t);
}
static void WINE_GLAPI wine_glMultiTexCoord2fvARB(GLenum target, const GLfloat *v) {
if(target != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
glTexCoord2fv(v);
}
static void WINE_GLAPI wine_glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r) {
if(target != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
glTexCoord3f(s, t, r);
}
static void WINE_GLAPI wine_glMultiTexCoord3fvARB(GLenum target, const GLfloat *v) {
if(target != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
glTexCoord3fv(v);
}
static void WINE_GLAPI wine_glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) {
if(target != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
glTexCoord4f(s, t, r, q);
}
static void WINE_GLAPI wine_glMultiTexCoord4fvARB(GLenum target, const GLfloat *v) {
if(target != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
glTexCoord4fv(v);
}
static void WINE_GLAPI wine_glMultiTexCoord2svARB(GLenum target, const GLshort *v) {
if(target != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
glTexCoord2sv(v);
}
static void WINE_GLAPI wine_glMultiTexCoord4svARB(GLenum target, const GLshort *v) {
if(target != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
glTexCoord4sv(v);
}
static void WINE_GLAPI wine_glActiveTextureARB(GLenum texture) {
if(texture != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
}
static void WINE_GLAPI wine_glClientActiveTextureARB(GLenum texture) {
if(texture != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
}
static void (WINE_GLAPI *old_multitex_glGetIntegerv) (GLenum pname, GLint* params) = NULL;
static void WINE_GLAPI wine_glGetIntegerv(GLenum pname, GLint* params) {
switch(pname) {
case GL_ACTIVE_TEXTURE: *params = 0; break;
case GL_MAX_TEXTURE_UNITS_ARB: *params = 1; break;
default: old_multitex_glGetIntegerv(pname, params);
}
}
static void (WINE_GLAPI *old_multitex_glGetFloatv) (GLenum pname, GLfloat* params) = NULL;
static void WINE_GLAPI wine_glGetFloatv(GLenum pname, GLfloat* params) {
if(pname == GL_ACTIVE_TEXTURE) *params = 0.0;
else old_multitex_glGetFloatv(pname, params);
}
static void (WINE_GLAPI *old_multitex_glGetDoublev) (GLenum pname, GLdouble* params) = NULL;
static void WINE_GLAPI wine_glGetDoublev(GLenum pname, GLdouble* params) {
if(pname == GL_ACTIVE_TEXTURE) *params = 0.0;
else old_multitex_glGetDoublev(pname, params);
}
/* Start GL_EXT_fogcoord emulation */
static void (WINE_GLAPI *old_fogcoord_glEnable) (GLenum cap) = NULL;
static void WINE_GLAPI wine_glEnable(GLenum cap) {
if(cap == GL_FOG) {
WineD3DContext *ctx = getActiveContext();
ctx->fog_enabled = 1;
if(ctx->gl_fog_source != GL_FRAGMENT_DEPTH_EXT) return;
}
old_fogcoord_glEnable(cap);
}
static void (WINE_GLAPI *old_fogcoord_glDisable) (GLenum cap) = NULL;
static void WINE_GLAPI wine_glDisable(GLenum cap) {
if(cap == GL_FOG) {
WineD3DContext *ctx = getActiveContext();
ctx->fog_enabled = 0;
if(ctx->gl_fog_source != GL_FRAGMENT_DEPTH_EXT) return;
}
old_fogcoord_glDisable(cap);
}
static void (WINE_GLAPI *old_fogcoord_glFogi) (GLenum pname, GLint param) = NULL;
static void WINE_GLAPI wine_glFogi(GLenum pname, GLint param) {
if(pname == GL_FOG_COORDINATE_SOURCE_EXT) {
WineD3DContext *ctx = getActiveContext();
ctx->gl_fog_source = param;
if(param == GL_FRAGMENT_DEPTH_EXT) {
if(ctx->fog_enabled) old_fogcoord_glEnable(GL_FOG);
} else {
WARN("Fog coords activated, but not supported. Using slow emulation\n");
old_fogcoord_glDisable(GL_FOG);
}
} else {
if(pname == GL_FOG_START) {
getActiveContext()->fogstart = param;
} else if(pname == GL_FOG_END) {
getActiveContext()->fogend = param;
}
old_fogcoord_glFogi(pname, param);
}
}
static void (WINE_GLAPI *old_fogcoord_glFogiv) (GLenum pname, const GLint *param) = NULL;
static void WINE_GLAPI wine_glFogiv(GLenum pname, const GLint *param) {
if(pname == GL_FOG_COORDINATE_SOURCE_EXT) {
WineD3DContext *ctx = getActiveContext();
ctx->gl_fog_source = *param;
if(*param == GL_FRAGMENT_DEPTH_EXT) {
if(ctx->fog_enabled) old_fogcoord_glEnable(GL_FOG);
} else {
WARN("Fog coords activated, but not supported. Using slow emulation\n");
old_fogcoord_glDisable(GL_FOG);
}
} else {
if(pname == GL_FOG_START) {
getActiveContext()->fogstart = *param;
} else if(pname == GL_FOG_END) {
getActiveContext()->fogend = *param;
}
old_fogcoord_glFogiv(pname, param);
}
}
static void (WINE_GLAPI *old_fogcoord_glFogf) (GLenum pname, GLfloat param) = NULL;
static void WINE_GLAPI wine_glFogf(GLenum pname, GLfloat param) {
if(pname == GL_FOG_COORDINATE_SOURCE_EXT) {
WineD3DContext *ctx = getActiveContext();
ctx->gl_fog_source = (GLint) param;
if(param == GL_FRAGMENT_DEPTH_EXT) {
if(ctx->fog_enabled) old_fogcoord_glEnable(GL_FOG);
} else {
WARN("Fog coords activated, but not supported. Using slow emulation\n");
old_fogcoord_glDisable(GL_FOG);
}
} else {
if(pname == GL_FOG_START) {
getActiveContext()->fogstart = param;
} else if(pname == GL_FOG_END) {
getActiveContext()->fogend = param;
}
old_fogcoord_glFogf(pname, param);
}
}
static void (WINE_GLAPI *old_fogcoord_glFogfv) (GLenum pname, const GLfloat *param) = NULL;
static void WINE_GLAPI wine_glFogfv(GLenum pname, const GLfloat *param) {
if(pname == GL_FOG_COORDINATE_SOURCE_EXT) {
WineD3DContext *ctx = getActiveContext();
ctx->gl_fog_source = (GLint) *param;
if(*param == GL_FRAGMENT_DEPTH_EXT) {
if(ctx->fog_enabled) old_fogcoord_glEnable(GL_FOG);
} else {
WARN("Fog coords activated, but not supported. Using slow emulation\n");
old_fogcoord_glDisable(GL_FOG);
}
} else {
if(pname == GL_FOG_COLOR) {
WineD3DContext *ctx = getActiveContext();
ctx->fogcolor[0] = param[0];
ctx->fogcolor[1] = param[1];
ctx->fogcolor[2] = param[2];
ctx->fogcolor[3] = param[3];
} else if(pname == GL_FOG_START) {
getActiveContext()->fogstart = *param;
} else if(pname == GL_FOG_END) {
getActiveContext()->fogend = *param;
}
old_fogcoord_glFogfv(pname, param);
}
}
static void (WINE_GLAPI *old_fogcoord_glVertex4f) (GLfloat x, GLfloat y, GLfloat z, GLfloat w) = NULL;
static void (WINE_GLAPI *old_fogcoord_glVertex4fv) (const GLfloat *pos) = NULL;
static void (WINE_GLAPI *old_fogcoord_glVertex3f) (GLfloat x, GLfloat y, GLfloat z) = NULL;
static void (WINE_GLAPI *old_fogcoord_glVertex3fv) (const GLfloat *pos) = NULL;
static void (WINE_GLAPI *old_fogcoord_glColor4f) (GLfloat r, GLfloat g, GLfloat b, GLfloat a) = NULL;
static void (WINE_GLAPI *old_fogcoord_glColor4fv) (const GLfloat *color) = NULL;
static void (WINE_GLAPI *old_fogcoord_glColor3f) (GLfloat r, GLfloat g, GLfloat b) = NULL;
static void (WINE_GLAPI *old_fogcoord_glColor3fv) (const GLfloat *color) = NULL;
static void (WINE_GLAPI *old_fogcoord_glColor4ub) (GLubyte r, GLubyte g, GLubyte b, GLubyte a) = NULL;
static void (WINE_GLAPI *old_fogcoord_glFogCoordfEXT) (GLfloat f) = NULL;
static void (WINE_GLAPI *old_fogcoord_glFogCoorddEXT) (GLdouble f) = NULL;
static void (WINE_GLAPI *old_fogcoord_glFogCoordfvEXT) (const GLfloat *f) = NULL;
static void (WINE_GLAPI *old_fogcoord_glFogCoorddvEXT) (const GLdouble *f) = NULL;
static void WINE_GLAPI wine_glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
WineD3DContext *ctx = getActiveContext();
if(ctx->gl_fog_source == GL_FOG_COORDINATE_EXT && ctx->fog_enabled) {
GLfloat c[4] = {ctx->color[0], ctx->color[1], ctx->color[2], ctx->color[3]};
GLfloat i;
i = (ctx->fogend - ctx->fog_coord_value) / (ctx->fogend - ctx->fogstart);
c[0] = i * c[0] + (1.0 - i) * ctx->fogcolor[0];
c[1] = i * c[1] + (1.0 - i) * ctx->fogcolor[1];
c[2] = i * c[2] + (1.0 - i) * ctx->fogcolor[2];
old_fogcoord_glColor4f(c[0], c[1], c[2], c[3]);
old_fogcoord_glVertex4f(x, y, z, w);
} else {
old_fogcoord_glVertex4f(x, y, z, w);
}
}
static void WINE_GLAPI wine_glVertex4fv(const GLfloat *pos) {
wine_glVertex4f(pos[0], pos[1], pos[2], pos[3]);
}
static void WINE_GLAPI wine_glVertex3f(GLfloat x, GLfloat y, GLfloat z) {
wine_glVertex4f(x, y, z, 1.0);
}
static void WINE_GLAPI wine_glVertex3fv(const GLfloat *pos) {
wine_glVertex4f(pos[0], pos[1], pos[2], 1.0);
}
static void wine_glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
WineD3DContext *ctx = getActiveContext();
ctx->color[0] = r;
ctx->color[1] = g;
ctx->color[2] = b;
ctx->color[3] = a;
old_fogcoord_glColor4f(r, g, b, a);
}
static void wine_glColor4fv(const GLfloat *c) {
wine_glColor4f(c[0], c[1], c[2], c[3]);
}
static void wine_glColor3f(GLfloat r, GLfloat g, GLfloat b) {
wine_glColor4f(r, g, b, 1.0);
}
static void wine_glColor3fv(const GLfloat *c) {
wine_glColor4f(c[0], c[1], c[2], 1.0);
}
static void wine_glColor4ub(GLubyte r, GLubyte g, GLubyte b, GLubyte a) {
wine_glColor4f(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
}
/* In D3D the fog coord is a UBYTE, so there's no problem with using the single
* precision function
*/
static void wine_glFogCoordfEXT(GLfloat f) {
WineD3DContext *ctx = getActiveContext();
ctx->fog_coord_value = f;
}
static void wine_glFogCoorddEXT(GLdouble f) {
wine_glFogCoordfEXT(f);
}
static void wine_glFogCoordfvEXT(const GLfloat *f) {
wine_glFogCoordfEXT(*f);
}
static void wine_glFogCoorddvEXT(const GLdouble *f) {
wine_glFogCoordfEXT(*f);
}
/* End GL_EXT_fog_coord emulation */
#define GLINFO_LOCATION (*gl_info)
void add_gl_compat_wrappers(WineD3D_GL_Info *gl_info) {
if(!GL_SUPPORT(ARB_MULTITEXTURE)) {
TRACE("Applying GL_ARB_multitexture emulation hooks\n");
gl_info->glActiveTextureARB = wine_glActiveTextureARB;
gl_info->glClientActiveTextureARB = wine_glClientActiveTextureARB;
gl_info->glMultiTexCoord1fARB = wine_glMultiTexCoord1fARB;
gl_info->glMultiTexCoord1fvARB = wine_glMultiTexCoord1fvARB;
gl_info->glMultiTexCoord2fARB = wine_glMultiTexCoord2fARB;
gl_info->glMultiTexCoord2fvARB = wine_glMultiTexCoord2fvARB;
gl_info->glMultiTexCoord3fARB = wine_glMultiTexCoord3fARB;
gl_info->glMultiTexCoord3fvARB = wine_glMultiTexCoord3fvARB;
gl_info->glMultiTexCoord4fARB = wine_glMultiTexCoord4fARB;
gl_info->glMultiTexCoord4fvARB = wine_glMultiTexCoord4fvARB;
gl_info->glMultiTexCoord2svARB = wine_glMultiTexCoord2svARB;
gl_info->glMultiTexCoord4svARB = wine_glMultiTexCoord4svARB;
if(old_multitex_glGetIntegerv) {
FIXME("GL_ARB_multitexture glGetIntegerv hook already applied\n");
} else {
old_multitex_glGetIntegerv = glGetIntegerv;
glGetIntegerv = wine_glGetIntegerv;
}
if(old_multitex_glGetFloatv) {
FIXME("GL_ARB_multitexture glGetGloatv hook already applied\n");
} else {
old_multitex_glGetFloatv = glGetFloatv;
glGetFloatv = wine_glGetFloatv;
}
if(old_multitex_glGetDoublev) {
FIXME("GL_ARB_multitexture glGetDoublev hook already applied\n");
} else {
old_multitex_glGetDoublev = glGetDoublev;
glGetDoublev = wine_glGetDoublev;
}
gl_info->supported[ARB_MULTITEXTURE] = TRUE;
}
if(!GL_SUPPORT(EXT_FOG_COORD)) {
/* This emulation isn't perfect. There are a number of potential problems, but they should
* not matter in practise:
*
* Fog vs fragment shader: If we are using GL_ARB_fragment_program with the fog option, the
* glDisable(GL_FOG) here won't matter. However, if we have GL_ARB_fragment_program, it is pretty
* unlikely that we don't have GL_EXT_fog_coord. Besides, we probably have GL_ARB_vertex_program
* too, which would allow fog coord emulation in a fixed function vertex pipeline replacement.
*
* Fog vs texture: We apply the fog in the vertex color. An app could set up texturing settings which
* ignore the vertex color, thus effectively disabing our fog. However, in D3D this type of fog is
* a per-vertex fog too, so the apps shouldn't do that.
*
* Fog vs lighting: The app could in theory use D3DFOG_NONE table and D3DFOG_NONE vertex fog with
* untransformed vertices. That enables lighting and fog coords at the same time, and the lighting
* calculations could affect the already blended in fog color. There's nothing we can do against that,
* but most apps using fog color do their own lighting too and often even use RHW vertices. So live
* with it.
*/
TRACE("Applying GL_ARB_fog_coord emulation hooks\n");
/* This probably means that the implementation doesn't advertise the extension, but implicitly supports
* it via the GL core version, or someone messed around in the extension table in directx.c. Add version-
* dependent loading for this extension if we ever hit this situation
*/
if(GL_SUPPORT(ARB_FRAGMENT_PROGRAM)) {
FIXME("GL implementation supports GL_ARB_fragment_program but not GL_EXT_fog_coord\n");
FIXME("The fog coord emulation will most likely fail\n");
} else if(GL_SUPPORT(ARB_FRAGMENT_SHADER)) {
FIXME("GL implementation supports GL_ARB_fragment_shader but not GL_EXT_fog_coord\n");
FIXME("The fog coord emulation will most likely fail\n");
}
if(old_fogcoord_glFogi) {
FIXME("GL_EXT_fogcoord glFogi hook already applied\n");
} else {
old_fogcoord_glFogi = glFogi;
glFogi = wine_glFogi;
}
if(old_fogcoord_glFogiv) {
FIXME("GL_EXT_fogcoord glFogiv hook already applied\n");
} else {
old_fogcoord_glFogiv = glFogiv;
glFogiv = wine_glFogiv;
}
if(old_fogcoord_glFogf) {
FIXME("GL_EXT_fogcoord glFogf hook already applied\n");
} else {
old_fogcoord_glFogf = glFogf;
glFogf = wine_glFogf;
}
if(old_fogcoord_glFogfv) {
FIXME("GL_EXT_fogcoord glFogfv hook already applied\n");
} else {
old_fogcoord_glFogfv = glFogfv;
glFogfv = wine_glFogfv;
}
if(old_fogcoord_glEnable) {
FIXME("GL_EXT_fogcoord glEnable hook already applied\n");
} else {
old_fogcoord_glEnable = glEnableWINE;
glEnableWINE = wine_glEnable;
}
if(old_fogcoord_glDisable) {
FIXME("GL_EXT_fogcoord glDisable hook already applied\n");
} else {
old_fogcoord_glDisable = glDisableWINE;
glDisableWINE = wine_glDisable;
}
if(old_fogcoord_glVertex4f) {
FIXME("GL_EXT_fogcoord glVertex4f hook already applied\n");
} else {
old_fogcoord_glVertex4f = glVertex4f;
glVertex4f = wine_glVertex4f;
}
if(old_fogcoord_glVertex4fv) {
FIXME("GL_EXT_fogcoord glVertex4fv hook already applied\n");
} else {
old_fogcoord_glVertex4fv = glVertex4fv;
glVertex4fv = wine_glVertex4fv;
}
if(old_fogcoord_glVertex3f) {
FIXME("GL_EXT_fogcoord glVertex3f hook already applied\n");
} else {
old_fogcoord_glVertex3f = glVertex3f;
glVertex3f = wine_glVertex3f;
}
if(old_fogcoord_glVertex3fv) {
FIXME("GL_EXT_fogcoord glVertex3fv hook already applied\n");
} else {
old_fogcoord_glVertex3fv = glVertex3fv;
glVertex3fv = wine_glVertex3fv;
}
if(old_fogcoord_glColor4f) {
FIXME("GL_EXT_fogcoord glColor4f hook already applied\n");
} else {
old_fogcoord_glColor4f = glColor4f;
glColor4f = wine_glColor4f;
}
if(old_fogcoord_glColor4fv) {
FIXME("GL_EXT_fogcoord glColor4fv hook already applied\n");
} else {
old_fogcoord_glColor4fv = glColor4fv;
glColor4fv = wine_glColor4fv;
}
if(old_fogcoord_glColor3f) {
FIXME("GL_EXT_fogcoord glColor3f hook already applied\n");
} else {
old_fogcoord_glColor3f = glColor3f;
glColor3f = wine_glColor3f;
}
if(old_fogcoord_glColor3fv) {
FIXME("GL_EXT_fogcoord glColor3fv hook already applied\n");
} else {
old_fogcoord_glColor3fv = glColor3fv;
glColor3fv = wine_glColor3fv;
}
if(old_fogcoord_glColor4ub) {
FIXME("GL_EXT_fogcoord glColor4ub hook already applied\n");
} else {
old_fogcoord_glColor4ub = glColor4ub;
glColor4ub = wine_glColor4ub;
}
if(old_fogcoord_glFogCoordfEXT) {
FIXME("GL_EXT_fogcoord glFogCoordfEXT hook already applied\n");
} else {
old_fogcoord_glFogCoordfEXT = gl_info->glFogCoordfEXT;
gl_info->glFogCoordfEXT = wine_glFogCoordfEXT;
}
if(old_fogcoord_glFogCoordfvEXT) {
FIXME("GL_EXT_fogcoord glFogCoordfvEXT hook already applied\n");
} else {
old_fogcoord_glFogCoordfvEXT = gl_info->glFogCoordfvEXT;
gl_info->glFogCoordfvEXT = wine_glFogCoordfvEXT;
}
if(old_fogcoord_glFogCoorddEXT) {
FIXME("GL_EXT_fogcoord glFogCoorddEXT hook already applied\n");
} else {
old_fogcoord_glFogCoorddEXT = gl_info->glFogCoorddEXT;
gl_info->glFogCoorddEXT = wine_glFogCoorddEXT;
}
if(old_fogcoord_glFogCoorddvEXT) {
FIXME("GL_EXT_fogcoord glFogCoorddvEXT hook already applied\n");
} else {
old_fogcoord_glFogCoorddvEXT = gl_info->glFogCoorddvEXT;
gl_info->glFogCoorddvEXT = wine_glFogCoorddvEXT;
}
gl_info->supported[EXT_FOG_COORD] = TRUE;
}
}
#undef GLINFO_LOCATION

File diff suppressed because it is too large Load Diff

View File

@@ -74,7 +74,7 @@ static ULONG WINAPI IWineD3DIndexBufferImpl_Release(IWineD3DIndexBuffer *iface)
LEAVE_GL(); LEAVE_GL();
} }
IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface); resource_cleanup((IWineD3DResource *)iface);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
return ref; return ref;
@@ -84,31 +84,31 @@ static ULONG WINAPI IWineD3DIndexBufferImpl_Release(IWineD3DIndexBuffer *iface)
IWineD3DIndexBuffer IWineD3DResource parts follow IWineD3DIndexBuffer IWineD3DResource parts follow
**************************************************** */ **************************************************** */
static HRESULT WINAPI IWineD3DIndexBufferImpl_GetDevice(IWineD3DIndexBuffer *iface, IWineD3DDevice** ppDevice) { static HRESULT WINAPI IWineD3DIndexBufferImpl_GetDevice(IWineD3DIndexBuffer *iface, IWineD3DDevice** ppDevice) {
return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice); return resource_get_device((IWineD3DResource *)iface, ppDevice);
} }
static HRESULT WINAPI IWineD3DIndexBufferImpl_SetPrivateData(IWineD3DIndexBuffer *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) { static HRESULT WINAPI IWineD3DIndexBufferImpl_SetPrivateData(IWineD3DIndexBuffer *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags); return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
} }
static HRESULT WINAPI IWineD3DIndexBufferImpl_GetPrivateData(IWineD3DIndexBuffer *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) { static HRESULT WINAPI IWineD3DIndexBufferImpl_GetPrivateData(IWineD3DIndexBuffer *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData); return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
} }
static HRESULT WINAPI IWineD3DIndexBufferImpl_FreePrivateData(IWineD3DIndexBuffer *iface, REFGUID refguid) { static HRESULT WINAPI IWineD3DIndexBufferImpl_FreePrivateData(IWineD3DIndexBuffer *iface, REFGUID refguid) {
return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid); return resource_free_private_data((IWineD3DResource *)iface, refguid);
} }
static DWORD WINAPI IWineD3DIndexBufferImpl_SetPriority(IWineD3DIndexBuffer *iface, DWORD PriorityNew) { static DWORD WINAPI IWineD3DIndexBufferImpl_SetPriority(IWineD3DIndexBuffer *iface, DWORD PriorityNew) {
return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew); return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
} }
static DWORD WINAPI IWineD3DIndexBufferImpl_GetPriority(IWineD3DIndexBuffer *iface) { static DWORD WINAPI IWineD3DIndexBufferImpl_GetPriority(IWineD3DIndexBuffer *iface) {
return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface); return resource_get_priority((IWineD3DResource *)iface);
} }
static void WINAPI IWineD3DIndexBufferImpl_PreLoad(IWineD3DIndexBuffer *iface) { static void WINAPI IWineD3DIndexBufferImpl_PreLoad(IWineD3DIndexBuffer *iface) {
IWineD3DResourceImpl_PreLoad((IWineD3DResource *)iface); TRACE("iface %p.\n", iface);
} }
static void WINAPI IWineD3DIndexBufferImpl_UnLoad(IWineD3DIndexBuffer *iface) { static void WINAPI IWineD3DIndexBufferImpl_UnLoad(IWineD3DIndexBuffer *iface) {
@@ -133,11 +133,11 @@ static void WINAPI IWineD3DIndexBufferImpl_UnLoad(IWineD3DIndexBuffer *iface) {
} }
static WINED3DRESOURCETYPE WINAPI IWineD3DIndexBufferImpl_GetType(IWineD3DIndexBuffer *iface) { static WINED3DRESOURCETYPE WINAPI IWineD3DIndexBufferImpl_GetType(IWineD3DIndexBuffer *iface) {
return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface); return resource_get_type((IWineD3DResource *)iface);
} }
static HRESULT WINAPI IWineD3DIndexBufferImpl_GetParent(IWineD3DIndexBuffer *iface, IUnknown **pParent) { static HRESULT WINAPI IWineD3DIndexBufferImpl_GetParent(IWineD3DIndexBuffer *iface, IUnknown **pParent) {
return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent); return resource_get_parent((IWineD3DResource *)iface, pParent);
} }
/* ****************************************************** /* ******************************************************

View File

@@ -29,7 +29,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION stateblock->wineD3DDevice->adapter->gl_info #define GLINFO_LOCATION stateblock->wineD3DDevice->adapter->gl_info
void nvts_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { static void nvts_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
BOOL bumpmap = FALSE; BOOL bumpmap = FALSE;
if(stage > 0 && (stateblock->textureState[stage - 1][WINED3DTSS_COLOROP] == WINED3DTOP_BUMPENVMAPLUMINANCE || if(stage > 0 && (stateblock->textureState[stage - 1][WINED3DTSS_COLOROP] == WINED3DTOP_BUMPENVMAPLUMINANCE ||
@@ -41,7 +41,7 @@ void nvts_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock, W
} }
if(stateblock->textures[stage]) { if(stateblock->textures[stage]) {
switch(stateblock->textureDimensions[stage]) { switch(IWineD3DBaseTexture_GetTextureDimensions(stateblock->textures[stage])) {
case GL_TEXTURE_2D: case GL_TEXTURE_2D:
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, bumpmap ? GL_OFFSET_TEXTURE_2D_NV : GL_TEXTURE_2D); glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, bumpmap ? GL_OFFSET_TEXTURE_2D_NV : GL_TEXTURE_2D);
checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, ...)"); checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, ...)");
@@ -451,32 +451,24 @@ void set_tex_op_nvrc(IWineD3DDevice *iface, BOOL is_alpha, int stage, WINED3DTEX
static void nvrc_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { static void nvrc_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE; DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage]; DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage];
BOOL tex_used = stateblock->wineD3DDevice->fixed_function_usage_map[stage]; BOOL tex_used = stateblock->wineD3DDevice->fixed_function_usage_map & (1 << stage);
TRACE("Setting color op for stage %d\n", stage); TRACE("Setting color op for stage %d\n", stage);
if (stateblock->pixelShader && stateblock->wineD3DDevice->ps_selected_mode != SHADER_NONE && /* Using a pixel shader? Don't care for anything here, the shader applying does it */
((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.function) { if (use_ps(stateblock)) return;
/* Using a pixel shader? Don't care for anything here, the shader applying does it */
return;
}
if (stage != mapped_stage) WARN("Using non 1:1 mapping: %d -> %d!\n", stage, mapped_stage); if (stage != mapped_stage) WARN("Using non 1:1 mapping: %d -> %d!\n", stage, mapped_stage);
if (mapped_stage != -1) { if (mapped_stage != -1) {
if (GL_SUPPORT(ARB_MULTITEXTURE)) { if (tex_used && mapped_stage >= GL_LIMITS(textures)) {
if (tex_used && mapped_stage >= GL_LIMITS(textures)) { FIXME("Attempt to enable unsupported stage!\n");
FIXME("Attempt to enable unsupported stage!\n");
return;
}
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
checkGLcall("glActiveTextureARB");
} else if (stage > 0) {
WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
return; return;
} }
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
checkGLcall("glActiveTextureARB");
} }
if(stateblock->lowest_disabled_stage > 0) { if(stateblock->lowest_disabled_stage > 0) {
@@ -548,7 +540,7 @@ static void nvrc_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3
} }
} }
void nvts_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { static void nvts_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
DWORD sampler = state - STATE_SAMPLER(0); DWORD sampler = state - STATE_SAMPLER(0);
DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[sampler]; DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[sampler];
@@ -564,7 +556,7 @@ void nvts_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext
} }
static void nvts_bumpenvmat(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { static void nvts_bumpenvmat(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE; DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage + 1]; DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage + 1];
float mat[2][2]; float mat[2][2];
@@ -610,7 +602,8 @@ static void nvts_enable(IWineD3DDevice *iface, BOOL enable) {
} }
} }
static void nvrc_fragment_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, struct fragment_caps *pCaps) { static void nvrc_fragment_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct fragment_caps *pCaps)
{
pCaps->TextureOpCaps = WINED3DTEXOPCAPS_ADD | pCaps->TextureOpCaps = WINED3DTEXOPCAPS_ADD |
WINED3DTEXOPCAPS_ADDSIGNED | WINED3DTEXOPCAPS_ADDSIGNED |
WINED3DTEXOPCAPS_ADDSIGNED2X | WINED3DTEXOPCAPS_ADDSIGNED2X |
@@ -672,12 +665,26 @@ static void nvrc_fragment_free(IWineD3DDevice *iface) {}
* register combiners extension(Pre-GF3). * register combiners extension(Pre-GF3).
*/ */
static BOOL nvts_conv_supported(WINED3DFORMAT fmt) { static BOOL nvts_color_fixup_supported(struct color_fixup_desc fixup)
TRACE("Checking shader format support for format %s: [FAILED]\n", debug_d3dformat(fmt)); {
if (TRACE_ON(d3d))
{
TRACE("Checking support for fixup:\n");
dump_color_fixup_desc(fixup);
}
/* We only support identity conversions. */
if (is_identity_fixup(fixup))
{
TRACE("[OK]\n");
return TRUE;
}
TRACE("[FAILED]\n");
return FALSE; return FALSE;
} }
const struct StateEntryTemplate nvrc_fragmentstate_template[] = { static const struct StateEntryTemplate nvrc_fragmentstate_template[] = {
{ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), nvrc_colorop }, 0 }, { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), nvrc_colorop }, 0 }, { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), nvrc_colorop }, 0 }, { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
@@ -785,6 +792,13 @@ const struct StateEntryTemplate nvrc_fragmentstate_template[] = {
{ STATE_PIXELSHADER, { STATE_PIXELSHADER, apply_pixelshader }, 0 }, { STATE_PIXELSHADER, { STATE_PIXELSHADER, apply_pixelshader }, 0 },
{ STATE_RENDER(WINED3DRS_SRGBWRITEENABLE), { STATE_PIXELSHADER, apply_pixelshader }, 0 }, { STATE_RENDER(WINED3DRS_SRGBWRITEENABLE), { STATE_PIXELSHADER, apply_pixelshader }, 0 },
{ STATE_RENDER(WINED3DRS_TEXTUREFACTOR), { STATE_RENDER(WINED3DRS_TEXTUREFACTOR), nvrc_texfactor }, 0 }, { STATE_RENDER(WINED3DRS_TEXTUREFACTOR), { STATE_RENDER(WINED3DRS_TEXTUREFACTOR), nvrc_texfactor }, 0 },
{ STATE_RENDER(WINED3DRS_FOGCOLOR), { STATE_RENDER(WINED3DRS_FOGCOLOR), state_fogcolor }, 0 },
{ STATE_RENDER(WINED3DRS_FOGDENSITY), { STATE_RENDER(WINED3DRS_FOGDENSITY), state_fogdensity }, 0 },
{ STATE_RENDER(WINED3DRS_FOGENABLE), { STATE_RENDER(WINED3DRS_FOGENABLE), state_fog_fragpart }, 0 },
{ STATE_RENDER(WINED3DRS_FOGTABLEMODE), { STATE_RENDER(WINED3DRS_FOGENABLE), state_fog_fragpart }, 0 },
{ STATE_RENDER(WINED3DRS_FOGVERTEXMODE), { STATE_RENDER(WINED3DRS_FOGENABLE), state_fog_fragpart }, 0 },
{ STATE_RENDER(WINED3DRS_FOGSTART), { STATE_RENDER(WINED3DRS_FOGSTART), state_fogstartend }, 0 },
{ STATE_RENDER(WINED3DRS_FOGEND), { STATE_RENDER(WINED3DRS_FOGSTART), state_fogstartend }, 0 },
{ STATE_SAMPLER(0), { STATE_SAMPLER(0), nvts_texdim }, NV_TEXTURE_SHADER2 }, { STATE_SAMPLER(0), { STATE_SAMPLER(0), nvts_texdim }, NV_TEXTURE_SHADER2 },
{ STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texdim }, 0 }, { STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texdim }, 0 },
{ STATE_SAMPLER(1), { STATE_SAMPLER(1), nvts_texdim }, NV_TEXTURE_SHADER2 }, { STATE_SAMPLER(1), { STATE_SAMPLER(1), nvts_texdim }, NV_TEXTURE_SHADER2 },
@@ -809,7 +823,7 @@ const struct fragment_pipeline nvts_fragment_pipeline = {
nvrc_fragment_get_caps, nvrc_fragment_get_caps,
nvrc_fragment_alloc, nvrc_fragment_alloc,
nvrc_fragment_free, nvrc_fragment_free,
nvts_conv_supported, nvts_color_fixup_supported,
nvrc_fragmentstate_template, nvrc_fragmentstate_template,
FALSE /* we cannot disable projected textures. The vertex pipe has to do it */ FALSE /* we cannot disable projected textures. The vertex pipe has to do it */
}; };
@@ -819,7 +833,7 @@ const struct fragment_pipeline nvrc_fragment_pipeline = {
nvrc_fragment_get_caps, nvrc_fragment_get_caps,
nvrc_fragment_alloc, nvrc_fragment_alloc,
nvrc_fragment_free, nvrc_fragment_free,
nvts_conv_supported, nvts_color_fixup_supported,
nvrc_fragmentstate_template, nvrc_fragmentstate_template,
FALSE /* we cannot disable projected textures. The vertex pipe has to do it */ FALSE /* we cannot disable projected textures. The vertex pipe has to do it */
}; };

View File

@@ -1,4 +1,4 @@
/* DirectDraw - IDirectPalette base interface /* DirectDraw - IDirectPalette base interface
* *
* Copyright 1997-2000 Marcus Meissner * Copyright 1997-2000 Marcus Meissner
* Copyright 2000-2001 TransGaming Technologies Inc. * Copyright 2000-2001 TransGaming Technologies Inc.
@@ -105,7 +105,8 @@ static HRESULT WINAPI IWineD3DPaletteImpl_GetEntries(IWineD3DPalette *iface, DW
return WINED3D_OK; return WINED3D_OK;
} }
static HRESULT WINAPI IWineD3DPaletteImpl_SetEntries(IWineD3DPalette *iface, DWORD Flags, DWORD Start, DWORD Count, PALETTEENTRY *PalEnt) static HRESULT WINAPI IWineD3DPaletteImpl_SetEntries(IWineD3DPalette *iface,
DWORD Flags, DWORD Start, DWORD Count, const PALETTEENTRY *PalEnt)
{ {
IWineD3DPaletteImpl *This = (IWineD3DPaletteImpl *)iface; IWineD3DPaletteImpl *This = (IWineD3DPaletteImpl *)iface;
IWineD3DResourceImpl *res; IWineD3DResourceImpl *res;

View File

@@ -37,15 +37,46 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
#define GLNAME_REQUIRE_GLSL ((const char *)1) #define GLNAME_REQUIRE_GLSL ((const char *)1)
static HRESULT WINAPI IWineD3DPixelShaderImpl_QueryInterface(IWineD3DPixelShader *iface, REFIID riid, LPVOID *ppobj) { static HRESULT WINAPI IWineD3DPixelShaderImpl_QueryInterface(IWineD3DPixelShader *iface, REFIID riid, LPVOID *ppobj) {
return IWineD3DBaseShaderImpl_QueryInterface((IWineD3DBaseShader *) iface, riid, ppobj); TRACE("iface %p, riid %s, ppobj %p\n", iface, debugstr_guid(riid), ppobj);
if (IsEqualGUID(riid, &IID_IWineD3DPixelShader)
|| IsEqualGUID(riid, &IID_IWineD3DBaseShader)
|| IsEqualGUID(riid, &IID_IWineD3DBase)
|| IsEqualGUID(riid, &IID_IUnknown))
{
IUnknown_AddRef(iface);
*ppobj = iface;
return S_OK;
}
WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
*ppobj = NULL;
return E_NOINTERFACE;
} }
static ULONG WINAPI IWineD3DPixelShaderImpl_AddRef(IWineD3DPixelShader *iface) { static ULONG WINAPI IWineD3DPixelShaderImpl_AddRef(IWineD3DPixelShader *iface) {
return IWineD3DBaseShaderImpl_AddRef((IWineD3DBaseShader *) iface); IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface;
ULONG refcount = InterlockedIncrement(&This->baseShader.ref);
TRACE("%p increasing refcount to %u\n", This, refcount);
return refcount;
} }
static ULONG WINAPI IWineD3DPixelShaderImpl_Release(IWineD3DPixelShader *iface) { static ULONG WINAPI IWineD3DPixelShaderImpl_Release(IWineD3DPixelShader *iface) {
return IWineD3DBaseShaderImpl_Release((IWineD3DBaseShader *) iface); IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface;
ULONG refcount = InterlockedDecrement(&This->baseShader.ref);
TRACE("%p decreasing refcount to %u\n", This, refcount);
if (!refcount)
{
shader_cleanup((IWineD3DBaseShader *)iface);
HeapFree(GetProcessHeap(), 0, This);
}
return refcount;
} }
/* ******************************************* /* *******************************************
@@ -84,111 +115,105 @@ static HRESULT WINAPI IWineD3DPixelShaderImpl_GetFunction(IWineD3DPixelShader*
* return D3DERR_MOREDATA. That's not actually true. */ * return D3DERR_MOREDATA. That's not actually true. */
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
if (NULL == This->baseShader.function) { /* no function defined */
TRACE("(%p) : GetFunction no User Function defined using NULL to %p\n", This, pData);
(*(DWORD **) pData) = NULL;
} else {
if (This->baseShader.functionLength == 0) {
} TRACE("(%p) : GetFunction copying to %p\n", This, pData);
TRACE("(%p) : GetFunction copying to %p\n", This, pData); memcpy(pData, This->baseShader.function, This->baseShader.functionLength);
memcpy(pData, This->baseShader.function, This->baseShader.functionLength);
}
return WINED3D_OK; return WINED3D_OK;
} }
CONST SHADER_OPCODE IWineD3DPixelShaderImpl_shader_ins[] = { CONST SHADER_OPCODE IWineD3DPixelShaderImpl_shader_ins[] = {
/* Arithmetic */ /* Arithmetic */
{WINED3DSIO_NOP, "nop", "NOP", 0, 0, WINED3DSIH_NOP, 0, 0 }, {WINED3DSIO_NOP, "nop", 0, 0, WINED3DSIH_NOP, 0, 0 },
{WINED3DSIO_MOV, "mov", "MOV", 1, 2, WINED3DSIH_MOV, 0, 0 }, {WINED3DSIO_MOV, "mov", 1, 2, WINED3DSIH_MOV, 0, 0 },
{WINED3DSIO_ADD, "add", "ADD", 1, 3, WINED3DSIH_ADD, 0, 0 }, {WINED3DSIO_ADD, "add", 1, 3, WINED3DSIH_ADD, 0, 0 },
{WINED3DSIO_SUB, "sub", "SUB", 1, 3, WINED3DSIH_SUB, 0, 0 }, {WINED3DSIO_SUB, "sub", 1, 3, WINED3DSIH_SUB, 0, 0 },
{WINED3DSIO_MAD, "mad", "MAD", 1, 4, WINED3DSIH_MAD, 0, 0 }, {WINED3DSIO_MAD, "mad", 1, 4, WINED3DSIH_MAD, 0, 0 },
{WINED3DSIO_MUL, "mul", "MUL", 1, 3, WINED3DSIH_MUL, 0, 0 }, {WINED3DSIO_MUL, "mul", 1, 3, WINED3DSIH_MUL, 0, 0 },
{WINED3DSIO_RCP, "rcp", "RCP", 1, 2, WINED3DSIH_RCP, 0, 0 }, {WINED3DSIO_RCP, "rcp", 1, 2, WINED3DSIH_RCP, 0, 0 },
{WINED3DSIO_RSQ, "rsq", "RSQ", 1, 2, WINED3DSIH_RSQ, 0, 0 }, {WINED3DSIO_RSQ, "rsq", 1, 2, WINED3DSIH_RSQ, 0, 0 },
{WINED3DSIO_DP3, "dp3", "DP3", 1, 3, WINED3DSIH_DP3, 0, 0 }, {WINED3DSIO_DP3, "dp3", 1, 3, WINED3DSIH_DP3, 0, 0 },
{WINED3DSIO_DP4, "dp4", "DP4", 1, 3, WINED3DSIH_DP4, 0, 0 }, {WINED3DSIO_DP4, "dp4", 1, 3, WINED3DSIH_DP4, 0, 0 },
{WINED3DSIO_MIN, "min", "MIN", 1, 3, WINED3DSIH_MIN, 0, 0 }, {WINED3DSIO_MIN, "min", 1, 3, WINED3DSIH_MIN, 0, 0 },
{WINED3DSIO_MAX, "max", "MAX", 1, 3, WINED3DSIH_MAX, 0, 0 }, {WINED3DSIO_MAX, "max", 1, 3, WINED3DSIH_MAX, 0, 0 },
{WINED3DSIO_SLT, "slt", "SLT", 1, 3, WINED3DSIH_SLT, 0, 0 }, {WINED3DSIO_SLT, "slt", 1, 3, WINED3DSIH_SLT, 0, 0 },
{WINED3DSIO_SGE, "sge", "SGE", 1, 3, WINED3DSIH_SGE, 0, 0 }, {WINED3DSIO_SGE, "sge", 1, 3, WINED3DSIH_SGE, 0, 0 },
{WINED3DSIO_ABS, "abs", "ABS", 1, 2, WINED3DSIH_ABS, 0, 0 }, {WINED3DSIO_ABS, "abs", 1, 2, WINED3DSIH_ABS, 0, 0 },
{WINED3DSIO_EXP, "exp", "EX2", 1, 2, WINED3DSIH_EXP, 0, 0 }, {WINED3DSIO_EXP, "exp", 1, 2, WINED3DSIH_EXP, 0, 0 },
{WINED3DSIO_LOG, "log", "LG2", 1, 2, WINED3DSIH_LOG, 0, 0 }, {WINED3DSIO_LOG, "log", 1, 2, WINED3DSIH_LOG, 0, 0 },
{WINED3DSIO_EXPP, "expp", "EXP", 1, 2, WINED3DSIH_EXPP, 0, 0 }, {WINED3DSIO_EXPP, "expp", 1, 2, WINED3DSIH_EXPP, 0, 0 },
{WINED3DSIO_LOGP, "logp", "LOG", 1, 2, WINED3DSIH_LOGP, 0, 0 }, {WINED3DSIO_LOGP, "logp", 1, 2, WINED3DSIH_LOGP, 0, 0 },
{WINED3DSIO_DST, "dst", "DST", 1, 3, WINED3DSIH_DST, 0, 0 }, {WINED3DSIO_DST, "dst", 1, 3, WINED3DSIH_DST, 0, 0 },
{WINED3DSIO_LRP, "lrp", "LRP", 1, 4, WINED3DSIH_LRP, 0, 0 }, {WINED3DSIO_LRP, "lrp", 1, 4, WINED3DSIH_LRP, 0, 0 },
{WINED3DSIO_FRC, "frc", "FRC", 1, 2, WINED3DSIH_FRC, 0, 0 }, {WINED3DSIO_FRC, "frc", 1, 2, WINED3DSIH_FRC, 0, 0 },
{WINED3DSIO_CND, "cnd", NULL, 1, 4, WINED3DSIH_CND, WINED3DPS_VERSION(1,0), WINED3DPS_VERSION(1,4)}, {WINED3DSIO_CND, "cnd", 1, 4, WINED3DSIH_CND, WINED3DPS_VERSION(1,0), WINED3DPS_VERSION(1,4)},
{WINED3DSIO_CMP, "cmp", NULL, 1, 4, WINED3DSIH_CMP, WINED3DPS_VERSION(1,2), WINED3DPS_VERSION(3,0)}, {WINED3DSIO_CMP, "cmp", 1, 4, WINED3DSIH_CMP, WINED3DPS_VERSION(1,2), WINED3DPS_VERSION(3,0)},
{WINED3DSIO_POW, "pow", "POW", 1, 3, WINED3DSIH_POW, 0, 0 }, {WINED3DSIO_POW, "pow", 1, 3, WINED3DSIH_POW, 0, 0 },
{WINED3DSIO_CRS, "crs", "XPD", 1, 3, WINED3DSIH_CRS, 0, 0 }, {WINED3DSIO_CRS, "crs", 1, 3, WINED3DSIH_CRS, 0, 0 },
{WINED3DSIO_NRM, "nrm", NULL, 1, 2, WINED3DSIH_NRM, 0, 0 }, {WINED3DSIO_NRM, "nrm", 1, 2, WINED3DSIH_NRM, 0, 0 },
{WINED3DSIO_SINCOS, "sincos", NULL, 1, 4, WINED3DSIH_SINCOS, WINED3DPS_VERSION(2,0), WINED3DPS_VERSION(2,1)}, {WINED3DSIO_SINCOS, "sincos", 1, 4, WINED3DSIH_SINCOS, WINED3DPS_VERSION(2,0), WINED3DPS_VERSION(2,1)},
{WINED3DSIO_SINCOS, "sincos", "SCS", 1, 2, WINED3DSIH_SINCOS, WINED3DPS_VERSION(3,0), -1 }, {WINED3DSIO_SINCOS, "sincos", 1, 2, WINED3DSIH_SINCOS, WINED3DPS_VERSION(3,0), -1 },
{WINED3DSIO_DP2ADD, "dp2add", NULL, 1, 4, WINED3DSIH_DP2ADD, WINED3DPS_VERSION(2,0), -1 }, {WINED3DSIO_DP2ADD, "dp2add", 1, 4, WINED3DSIH_DP2ADD, WINED3DPS_VERSION(2,0), -1 },
/* Matrix */ /* Matrix */
{WINED3DSIO_M4x4, "m4x4", "undefined", 1, 3, WINED3DSIH_M4x4, 0, 0 }, {WINED3DSIO_M4x4, "m4x4", 1, 3, WINED3DSIH_M4x4, 0, 0 },
{WINED3DSIO_M4x3, "m4x3", "undefined", 1, 3, WINED3DSIH_M4x3, 0, 0 }, {WINED3DSIO_M4x3, "m4x3", 1, 3, WINED3DSIH_M4x3, 0, 0 },
{WINED3DSIO_M3x4, "m3x4", "undefined", 1, 3, WINED3DSIH_M3x4, 0, 0 }, {WINED3DSIO_M3x4, "m3x4", 1, 3, WINED3DSIH_M3x4, 0, 0 },
{WINED3DSIO_M3x3, "m3x3", "undefined", 1, 3, WINED3DSIH_M3x3, 0, 0 }, {WINED3DSIO_M3x3, "m3x3", 1, 3, WINED3DSIH_M3x3, 0, 0 },
{WINED3DSIO_M3x2, "m3x2", "undefined", 1, 3, WINED3DSIH_M3x2, 0, 0 }, {WINED3DSIO_M3x2, "m3x2", 1, 3, WINED3DSIH_M3x2, 0, 0 },
/* Register declarations */ /* Register declarations */
{WINED3DSIO_DCL, "dcl", NULL, 0, 2, WINED3DSIH_DCL, 0, 0 }, {WINED3DSIO_DCL, "dcl", 0, 2, WINED3DSIH_DCL, 0, 0 },
/* Flow control - requires GLSL or software shaders */ /* Flow control - requires GLSL or software shaders */
{WINED3DSIO_REP , "rep", NULL, 0, 1, WINED3DSIH_REP, WINED3DPS_VERSION(2,1), -1 }, {WINED3DSIO_REP , "rep", 0, 1, WINED3DSIH_REP, WINED3DPS_VERSION(2,1), -1 },
{WINED3DSIO_ENDREP, "endrep", NULL, 0, 0, WINED3DSIH_ENDREP, WINED3DPS_VERSION(2,1), -1 }, {WINED3DSIO_ENDREP, "endrep", 0, 0, WINED3DSIH_ENDREP, WINED3DPS_VERSION(2,1), -1 },
{WINED3DSIO_IF, "if", NULL, 0, 1, WINED3DSIH_IF, WINED3DPS_VERSION(2,1), -1 }, {WINED3DSIO_IF, "if", 0, 1, WINED3DSIH_IF, WINED3DPS_VERSION(2,1), -1 },
{WINED3DSIO_IFC, "ifc", NULL, 0, 2, WINED3DSIH_IFC, WINED3DPS_VERSION(2,1), -1 }, {WINED3DSIO_IFC, "ifc", 0, 2, WINED3DSIH_IFC, WINED3DPS_VERSION(2,1), -1 },
{WINED3DSIO_ELSE, "else", NULL, 0, 0, WINED3DSIH_ELSE, WINED3DPS_VERSION(2,1), -1 }, {WINED3DSIO_ELSE, "else", 0, 0, WINED3DSIH_ELSE, WINED3DPS_VERSION(2,1), -1 },
{WINED3DSIO_ENDIF, "endif", NULL, 0, 0, WINED3DSIH_ENDIF, WINED3DPS_VERSION(2,1), -1 }, {WINED3DSIO_ENDIF, "endif", 0, 0, WINED3DSIH_ENDIF, WINED3DPS_VERSION(2,1), -1 },
{WINED3DSIO_BREAK, "break", NULL, 0, 0, WINED3DSIH_BREAK, WINED3DPS_VERSION(2,1), -1 }, {WINED3DSIO_BREAK, "break", 0, 0, WINED3DSIH_BREAK, WINED3DPS_VERSION(2,1), -1 },
{WINED3DSIO_BREAKC, "breakc", NULL, 0, 2, WINED3DSIH_BREAKC, WINED3DPS_VERSION(2,1), -1 }, {WINED3DSIO_BREAKC, "breakc", 0, 2, WINED3DSIH_BREAKC, WINED3DPS_VERSION(2,1), -1 },
{WINED3DSIO_BREAKP, "breakp", GLNAME_REQUIRE_GLSL, 0, 1, WINED3DSIH_BREAKP, 0, 0 }, {WINED3DSIO_BREAKP, "breakp", 0, 1, WINED3DSIH_BREAKP, 0, 0 },
{WINED3DSIO_CALL, "call", NULL, 0, 1, WINED3DSIH_CALL, WINED3DPS_VERSION(2,1), -1 }, {WINED3DSIO_CALL, "call", 0, 1, WINED3DSIH_CALL, WINED3DPS_VERSION(2,1), -1 },
{WINED3DSIO_CALLNZ, "callnz", NULL, 0, 2, WINED3DSIH_CALLNZ, WINED3DPS_VERSION(2,1), -1 }, {WINED3DSIO_CALLNZ, "callnz", 0, 2, WINED3DSIH_CALLNZ, WINED3DPS_VERSION(2,1), -1 },
{WINED3DSIO_LOOP, "loop", NULL, 0, 2, WINED3DSIH_LOOP, WINED3DPS_VERSION(3,0), -1 }, {WINED3DSIO_LOOP, "loop", 0, 2, WINED3DSIH_LOOP, WINED3DPS_VERSION(3,0), -1 },
{WINED3DSIO_RET, "ret", NULL, 0, 0, WINED3DSIH_RET, WINED3DPS_VERSION(2,1), -1 }, {WINED3DSIO_RET, "ret", 0, 0, WINED3DSIH_RET, WINED3DPS_VERSION(2,1), -1 },
{WINED3DSIO_ENDLOOP, "endloop", NULL, 0, 0, WINED3DSIH_ENDLOOP, WINED3DPS_VERSION(3,0), -1 }, {WINED3DSIO_ENDLOOP, "endloop", 0, 0, WINED3DSIH_ENDLOOP, WINED3DPS_VERSION(3,0), -1 },
{WINED3DSIO_LABEL, "label", NULL, 0, 1, WINED3DSIH_LABEL, WINED3DPS_VERSION(2,1), -1 }, {WINED3DSIO_LABEL, "label", 0, 1, WINED3DSIH_LABEL, WINED3DPS_VERSION(2,1), -1 },
/* Constant definitions */ /* Constant definitions */
{WINED3DSIO_DEF, "def", "undefined", 1, 5, WINED3DSIH_DEF, 0, 0 }, {WINED3DSIO_DEF, "def", 1, 5, WINED3DSIH_DEF, 0, 0 },
{WINED3DSIO_DEFB, "defb", GLNAME_REQUIRE_GLSL, 1, 2, WINED3DSIH_DEFB, 0, 0 }, {WINED3DSIO_DEFB, "defb", 1, 2, WINED3DSIH_DEFB, 0, 0 },
{WINED3DSIO_DEFI, "defi", GLNAME_REQUIRE_GLSL, 1, 5, WINED3DSIH_DEFI, 0, 0 }, {WINED3DSIO_DEFI, "defi", 1, 5, WINED3DSIH_DEFI, 0, 0 },
/* Texture */ /* Texture */
{WINED3DSIO_TEXCOORD, "texcoord", "undefined", 1, 1, WINED3DSIH_TEXCOORD, 0, WINED3DPS_VERSION(1,3)}, {WINED3DSIO_TEXCOORD, "texcoord", 1, 1, WINED3DSIH_TEXCOORD, 0, WINED3DPS_VERSION(1,3)},
{WINED3DSIO_TEXCOORD, "texcrd", "undefined", 1, 2, WINED3DSIH_TEXCOORD, WINED3DPS_VERSION(1,4), WINED3DPS_VERSION(1,4)}, {WINED3DSIO_TEXCOORD, "texcrd", 1, 2, WINED3DSIH_TEXCOORD, WINED3DPS_VERSION(1,4), WINED3DPS_VERSION(1,4)},
{WINED3DSIO_TEXKILL, "texkill", "KIL", 1, 1, WINED3DSIH_TEXKILL, WINED3DPS_VERSION(1,0), WINED3DPS_VERSION(3,0)}, {WINED3DSIO_TEXKILL, "texkill", 1, 1, WINED3DSIH_TEXKILL, WINED3DPS_VERSION(1,0), WINED3DPS_VERSION(3,0)},
{WINED3DSIO_TEX, "tex", "undefined", 1, 1, WINED3DSIH_TEX, 0, WINED3DPS_VERSION(1,3)}, {WINED3DSIO_TEX, "tex", 1, 1, WINED3DSIH_TEX, 0, WINED3DPS_VERSION(1,3)},
{WINED3DSIO_TEX, "texld", "undefined", 1, 2, WINED3DSIH_TEX, WINED3DPS_VERSION(1,4), WINED3DPS_VERSION(1,4)}, {WINED3DSIO_TEX, "texld", 1, 2, WINED3DSIH_TEX, WINED3DPS_VERSION(1,4), WINED3DPS_VERSION(1,4)},
{WINED3DSIO_TEX, "texld", "undefined", 1, 3, WINED3DSIH_TEX, WINED3DPS_VERSION(2,0), -1 }, {WINED3DSIO_TEX, "texld", 1, 3, WINED3DSIH_TEX, WINED3DPS_VERSION(2,0), -1 },
{WINED3DSIO_TEXBEM, "texbem", "undefined", 1, 2, WINED3DSIH_TEXBEM, 0, WINED3DPS_VERSION(1,3)}, {WINED3DSIO_TEXBEM, "texbem", 1, 2, WINED3DSIH_TEXBEM, 0, WINED3DPS_VERSION(1,3)},
{WINED3DSIO_TEXBEML, "texbeml", GLNAME_REQUIRE_GLSL, 1, 2, WINED3DSIH_TEXBEML, WINED3DPS_VERSION(1,0), WINED3DPS_VERSION(1,3)}, {WINED3DSIO_TEXBEML, "texbeml", 1, 2, WINED3DSIH_TEXBEML, WINED3DPS_VERSION(1,0), WINED3DPS_VERSION(1,3)},
{WINED3DSIO_TEXREG2AR, "texreg2ar", "undefined", 1, 2, WINED3DSIH_TEXREG2AR, WINED3DPS_VERSION(1,0), WINED3DPS_VERSION(1,3)}, {WINED3DSIO_TEXREG2AR, "texreg2ar", 1, 2, WINED3DSIH_TEXREG2AR, WINED3DPS_VERSION(1,0), WINED3DPS_VERSION(1,3)},
{WINED3DSIO_TEXREG2GB, "texreg2gb", "undefined", 1, 2, WINED3DSIH_TEXREG2GB, WINED3DPS_VERSION(1,0), WINED3DPS_VERSION(1,3)}, {WINED3DSIO_TEXREG2GB, "texreg2gb", 1, 2, WINED3DSIH_TEXREG2GB, WINED3DPS_VERSION(1,0), WINED3DPS_VERSION(1,3)},
{WINED3DSIO_TEXREG2RGB, "texreg2rgb", "undefined", 1, 2, WINED3DSIH_TEXREG2RGB, WINED3DPS_VERSION(1,2), WINED3DPS_VERSION(1,3)}, {WINED3DSIO_TEXREG2RGB, "texreg2rgb", 1, 2, WINED3DSIH_TEXREG2RGB, WINED3DPS_VERSION(1,2), WINED3DPS_VERSION(1,3)},
{WINED3DSIO_TEXM3x2PAD, "texm3x2pad", "undefined", 1, 2, WINED3DSIH_TEXM3x2PAD, WINED3DPS_VERSION(1,0), WINED3DPS_VERSION(1,3)}, {WINED3DSIO_TEXM3x2PAD, "texm3x2pad", 1, 2, WINED3DSIH_TEXM3x2PAD, WINED3DPS_VERSION(1,0), WINED3DPS_VERSION(1,3)},
{WINED3DSIO_TEXM3x2TEX, "texm3x2tex", "undefined", 1, 2, WINED3DSIH_TEXM3x2TEX, WINED3DPS_VERSION(1,0), WINED3DPS_VERSION(1,3)}, {WINED3DSIO_TEXM3x2TEX, "texm3x2tex", 1, 2, WINED3DSIH_TEXM3x2TEX, WINED3DPS_VERSION(1,0), WINED3DPS_VERSION(1,3)},
{WINED3DSIO_TEXM3x3PAD, "texm3x3pad", "undefined", 1, 2, WINED3DSIH_TEXM3x3PAD, WINED3DPS_VERSION(1,0), WINED3DPS_VERSION(1,3)}, {WINED3DSIO_TEXM3x3PAD, "texm3x3pad", 1, 2, WINED3DSIH_TEXM3x3PAD, WINED3DPS_VERSION(1,0), WINED3DPS_VERSION(1,3)},
{WINED3DSIO_TEXM3x3DIFF, "texm3x3diff", GLNAME_REQUIRE_GLSL, 1, 2, WINED3DSIH_TEXM3x3DIFF, WINED3DPS_VERSION(0,0), WINED3DPS_VERSION(0,0)}, {WINED3DSIO_TEXM3x3DIFF, "texm3x3diff", 1, 2, WINED3DSIH_TEXM3x3DIFF, WINED3DPS_VERSION(0,0), WINED3DPS_VERSION(0,0)},
{WINED3DSIO_TEXM3x3SPEC, "texm3x3spec", "undefined", 1, 3, WINED3DSIH_TEXM3x3SPEC, WINED3DPS_VERSION(1,0), WINED3DPS_VERSION(1,3)}, {WINED3DSIO_TEXM3x3SPEC, "texm3x3spec", 1, 3, WINED3DSIH_TEXM3x3SPEC, WINED3DPS_VERSION(1,0), WINED3DPS_VERSION(1,3)},
{WINED3DSIO_TEXM3x3VSPEC, "texm3x3vspec", "undefined", 1, 2, WINED3DSIH_TEXM3x3VSPEC, WINED3DPS_VERSION(1,0), WINED3DPS_VERSION(1,3)}, {WINED3DSIO_TEXM3x3VSPEC, "texm3x3vspec", 1, 2, WINED3DSIH_TEXM3x3VSPEC, WINED3DPS_VERSION(1,0), WINED3DPS_VERSION(1,3)},
{WINED3DSIO_TEXM3x3TEX, "texm3x3tex", "undefined", 1, 2, WINED3DSIH_TEXM3x3TEX, WINED3DPS_VERSION(1,0), WINED3DPS_VERSION(1,3)}, {WINED3DSIO_TEXM3x3TEX, "texm3x3tex", 1, 2, WINED3DSIH_TEXM3x3TEX, WINED3DPS_VERSION(1,0), WINED3DPS_VERSION(1,3)},
{WINED3DSIO_TEXDP3TEX, "texdp3tex", NULL, 1, 2, WINED3DSIH_TEXDP3TEX, WINED3DPS_VERSION(1,2), WINED3DPS_VERSION(1,3)}, {WINED3DSIO_TEXDP3TEX, "texdp3tex", 1, 2, WINED3DSIH_TEXDP3TEX, WINED3DPS_VERSION(1,2), WINED3DPS_VERSION(1,3)},
{WINED3DSIO_TEXM3x2DEPTH, "texm3x2depth", GLNAME_REQUIRE_GLSL, 1, 2, WINED3DSIH_TEXM3x2DEPTH, WINED3DPS_VERSION(1,3), WINED3DPS_VERSION(1,3)}, {WINED3DSIO_TEXM3x2DEPTH, "texm3x2depth", 1, 2, WINED3DSIH_TEXM3x2DEPTH, WINED3DPS_VERSION(1,3), WINED3DPS_VERSION(1,3)},
{WINED3DSIO_TEXDP3, "texdp3", NULL, 1, 2, WINED3DSIH_TEXDP3, WINED3DPS_VERSION(1,2), WINED3DPS_VERSION(1,3)}, {WINED3DSIO_TEXDP3, "texdp3", 1, 2, WINED3DSIH_TEXDP3, WINED3DPS_VERSION(1,2), WINED3DPS_VERSION(1,3)},
{WINED3DSIO_TEXM3x3, "texm3x3", NULL, 1, 2, WINED3DSIH_TEXM3x3, WINED3DPS_VERSION(1,2), WINED3DPS_VERSION(1,3)}, {WINED3DSIO_TEXM3x3, "texm3x3", 1, 2, WINED3DSIH_TEXM3x3, WINED3DPS_VERSION(1,2), WINED3DPS_VERSION(1,3)},
{WINED3DSIO_TEXDEPTH, "texdepth", NULL, 1, 1, WINED3DSIH_TEXDEPTH, WINED3DPS_VERSION(1,4), WINED3DPS_VERSION(1,4)}, {WINED3DSIO_TEXDEPTH, "texdepth", 1, 1, WINED3DSIH_TEXDEPTH, WINED3DPS_VERSION(1,4), WINED3DPS_VERSION(1,4)},
{WINED3DSIO_BEM, "bem", "undefined", 1, 3, WINED3DSIH_BEM, WINED3DPS_VERSION(1,4), WINED3DPS_VERSION(1,4)}, {WINED3DSIO_BEM, "bem", 1, 3, WINED3DSIH_BEM, WINED3DPS_VERSION(1,4), WINED3DPS_VERSION(1,4)},
{WINED3DSIO_DSX, "dsx", NULL, 1, 2, WINED3DSIH_DSX, WINED3DPS_VERSION(2,1), -1 }, {WINED3DSIO_DSX, "dsx", 1, 2, WINED3DSIH_DSX, WINED3DPS_VERSION(2,1), -1 },
{WINED3DSIO_DSY, "dsy", NULL, 1, 2, WINED3DSIH_DSY, WINED3DPS_VERSION(2,1), -1 }, {WINED3DSIO_DSY, "dsy", 1, 2, WINED3DSIH_DSY, WINED3DPS_VERSION(2,1), -1 },
{WINED3DSIO_TEXLDD, "texldd", GLNAME_REQUIRE_GLSL, 1, 5, WINED3DSIH_TEXLDD, WINED3DPS_VERSION(2,1), -1 }, {WINED3DSIO_TEXLDD, "texldd", 1, 5, WINED3DSIH_TEXLDD, WINED3DPS_VERSION(2,1), -1 },
{WINED3DSIO_SETP, "setp", GLNAME_REQUIRE_GLSL, 1, 3, WINED3DSIH_SETP, 0, 0 }, {WINED3DSIO_SETP, "setp", 1, 3, WINED3DSIH_SETP, 0, 0 },
{WINED3DSIO_TEXLDL, "texldl", NULL, 1, 3, WINED3DSIH_TEXLDL, WINED3DPS_VERSION(3,0), -1 }, {WINED3DSIO_TEXLDL, "texldl", 1, 3, WINED3DSIH_TEXLDL, WINED3DPS_VERSION(3,0), -1 },
{WINED3DSIO_PHASE, "phase", GLNAME_REQUIRE_GLSL, 0, 0, WINED3DSIH_PHASE, 0, 0 }, {WINED3DSIO_PHASE, "phase", 0, 0, WINED3DSIH_PHASE, 0, 0 },
{0, NULL, NULL, 0, 0, 0, 0, 0 } {0, NULL, 0, 0, 0, 0, 0 }
}; };
static void pshader_set_limits( static void pshader_set_limits(
@@ -198,7 +223,8 @@ static void pshader_set_limits(
This->baseShader.limits.address = 0; This->baseShader.limits.address = 0;
This->baseShader.limits.packed_output = 0; This->baseShader.limits.packed_output = 0;
switch (This->baseShader.hex_version) { switch (This->baseShader.reg_maps.shader_version)
{
case WINED3DPS_VERSION(1,0): case WINED3DPS_VERSION(1,0):
case WINED3DPS_VERSION(1,1): case WINED3DPS_VERSION(1,1):
case WINED3DPS_VERSION(1,2): case WINED3DPS_VERSION(1,2):
@@ -265,228 +291,157 @@ static void pshader_set_limits(
This->baseShader.limits.sampler = 16; This->baseShader.limits.sampler = 16;
This->baseShader.limits.packed_input = 0; This->baseShader.limits.packed_input = 0;
This->baseShader.limits.label = 0; This->baseShader.limits.label = 0;
FIXME("Unrecognized pixel shader version %#x\n", FIXME("Unrecognized pixel shader version %#x\n",
This->baseShader.hex_version); This->baseShader.reg_maps.shader_version);
} }
} }
/** Generate a pixel shader string using either GL_FRAGMENT_PROGRAM_ARB
or GLSL and send it to the card */
static inline VOID IWineD3DPixelShaderImpl_GenerateShader(
IWineD3DPixelShader *iface) {
IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface;
SHADER_BUFFER buffer;
#if 0 /* FIXME: Use the buffer that is held by the device, this is ok since fixups will be skipped for software shaders
it also requires entering a critical section but cuts down the runtime footprint of wined3d and any memory fragmentation that may occur... */
if (This->device->fixupVertexBufferSize < SHADER_PGMSIZE) {
HeapFree(GetProcessHeap(), 0, This->fixupVertexBuffer);
This->fixupVertexBuffer = HeapAlloc(GetProcessHeap() , 0, SHADER_PGMSIZE);
This->fixupVertexBufferSize = PGMSIZE;
This->fixupVertexBuffer[0] = 0;
}
buffer.buffer = This->device->fixupVertexBuffer;
#else
buffer.buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, SHADER_PGMSIZE);
#endif
buffer.bsize = 0;
buffer.lineNo = 0;
buffer.newline = TRUE;
((IWineD3DDeviceImpl *)This->baseShader.device)->shader_backend->shader_generate_pshader(iface, &buffer);
#if 1 /* if were using the data buffer of device then we don't need to free it */
HeapFree(GetProcessHeap(), 0, buffer.buffer);
#endif
}
static HRESULT WINAPI IWineD3DPixelShaderImpl_SetFunction(IWineD3DPixelShader *iface, CONST DWORD *pFunction) { static HRESULT WINAPI IWineD3DPixelShaderImpl_SetFunction(IWineD3DPixelShader *iface, CONST DWORD *pFunction) {
IWineD3DPixelShaderImpl *This =(IWineD3DPixelShaderImpl *)iface; IWineD3DPixelShaderImpl *This =(IWineD3DPixelShaderImpl *)iface;
IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *) This->baseShader.device; IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *) This->baseShader.device;
unsigned int i, highest_reg_used = 0, num_regs_used = 0;
shader_reg_maps *reg_maps = &This->baseShader.reg_maps;
HRESULT hr;
TRACE("(%p) : pFunction %p\n", iface, pFunction); TRACE("(%p) : pFunction %p\n", iface, pFunction);
/* First pass: trace shader */ /* First pass: trace shader */
shader_trace_init((IWineD3DBaseShader*) This, pFunction); if (TRACE_ON(d3d_shader)) shader_trace_init(pFunction, This->baseShader.shader_ins);
pshader_set_limits(This);
/* Initialize immediate constant lists */ /* Initialize immediate constant lists */
list_init(&This->baseShader.constantsF); list_init(&This->baseShader.constantsF);
list_init(&This->baseShader.constantsB); list_init(&This->baseShader.constantsB);
list_init(&This->baseShader.constantsI); list_init(&This->baseShader.constantsI);
if (WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) > 1) { /* Second pass: figure out which registers are used, what the semantics are, etc.. */
shader_reg_maps *reg_maps = &This->baseShader.reg_maps; memset(reg_maps, 0, sizeof(shader_reg_maps));
HRESULT hr; hr = shader_get_registers_used((IWineD3DBaseShader *)This, reg_maps, This->semantics_in, NULL, pFunction);
unsigned int i, j, highest_reg_used = 0, num_regs_used = 0; if (FAILED(hr)) return hr;
/* Second pass: figure out which registers are used, what the semantics are, etc.. */ pshader_set_limits(This);
memset(reg_maps, 0, sizeof(shader_reg_maps));
hr = shader_get_registers_used((IWineD3DBaseShader*) This, reg_maps,
This->semantics_in, NULL, pFunction, NULL);
if (FAILED(hr)) return hr;
/* FIXME: validate reg_maps against OpenGL */
for(i = 0; i < MAX_REG_INPUT; i++) { for (i = 0; i < MAX_REG_INPUT; ++i)
if(This->input_reg_used[i]) { {
num_regs_used++; if (This->input_reg_used[i])
highest_reg_used = i; {
} ++num_regs_used;
} highest_reg_used = i;
/* Don't do any register mapping magic if it is not needed, or if we can't
* achieve anything anyway
*/
if(highest_reg_used < (GL_LIMITS(glsl_varyings) / 4) ||
num_regs_used > (GL_LIMITS(glsl_varyings) / 4) ) {
if(num_regs_used > (GL_LIMITS(glsl_varyings) / 4)) {
/* This happens with relative addressing. The input mapper function
* warns about this if the higher registers are declared too, so
* don't write a FIXME here
*/
WARN("More varying registers used than supported\n");
}
for(i = 0; i < MAX_REG_INPUT; i++) {
This->input_reg_map[i] = i;
}
This->declared_in_count = highest_reg_used + 1;
} else {
j = 0;
for(i = 0; i < MAX_REG_INPUT; i++) {
if(This->input_reg_used[i]) {
This->input_reg_map[i] = j;
j++;
} else {
This->input_reg_map[i] = -1;
}
}
This->declared_in_count = j;
} }
} }
/* Don't do any register mapping magic if it is not needed, or if we can't
* achieve anything anyway */
if (highest_reg_used < (GL_LIMITS(glsl_varyings) / 4)
|| num_regs_used > (GL_LIMITS(glsl_varyings) / 4))
{
if (num_regs_used > (GL_LIMITS(glsl_varyings) / 4))
{
/* This happens with relative addressing. The input mapper function
* warns about this if the higher registers are declared too, so
* don't write a FIXME here */
WARN("More varying registers used than supported\n");
}
for (i = 0; i < MAX_REG_INPUT; ++i)
{
This->input_reg_map[i] = i;
}
This->declared_in_count = highest_reg_used + 1;
}
else
{
This->declared_in_count = 0;
for (i = 0; i < MAX_REG_INPUT; ++i)
{
if (This->input_reg_used[i]) This->input_reg_map[i] = This->declared_in_count++;
else This->input_reg_map[i] = -1;
}
}
This->baseShader.load_local_constsF = FALSE; This->baseShader.load_local_constsF = FALSE;
This->baseShader.shader_mode = deviceImpl->ps_selected_mode; This->baseShader.shader_mode = deviceImpl->ps_selected_mode;
TRACE("(%p) : Copying the function\n", This); TRACE("(%p) : Copying the function\n", This);
if (NULL != pFunction) {
void *function;
function = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->baseShader.functionLength); This->baseShader.function = HeapAlloc(GetProcessHeap(), 0, This->baseShader.functionLength);
if (!function) return E_OUTOFMEMORY; if (!This->baseShader.function) return E_OUTOFMEMORY;
memcpy(function, pFunction, This->baseShader.functionLength); memcpy(This->baseShader.function, pFunction, This->baseShader.functionLength);
This->baseShader.function = function;
} else {
This->baseShader.function = NULL;
}
return WINED3D_OK; return WINED3D_OK;
} }
static HRESULT WINAPI IWineD3DPixelShaderImpl_CompileShader(IWineD3DPixelShader *iface) { static void pixelshader_update_samplers(struct shader_reg_maps *reg_maps, IWineD3DBaseTexture * const *textures)
{
DWORD shader_version = reg_maps->shader_version;
DWORD *samplers = reg_maps->samplers;
unsigned int i;
IWineD3DPixelShaderImpl *This =(IWineD3DPixelShaderImpl *)iface; if (WINED3DSHADER_VERSION_MAJOR(shader_version) != 1) return;
IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
for (i = 0; i < max(MAX_FRAGMENT_SAMPLERS, MAX_VERTEX_SAMPLERS); ++i)
{
/* We don't sample from this sampler */
if (!samplers[i]) continue;
if (!textures[i])
{
ERR("No texture bound to sampler %u, using 2D\n", i);
samplers[i] = (0x1 << 31) | WINED3DSTT_2D;
continue;
}
switch (IWineD3DBaseTexture_GetTextureDimensions(textures[i]))
{
case GL_TEXTURE_RECTANGLE_ARB:
case GL_TEXTURE_2D:
/* We have to select between texture rectangles and 2D textures later because 2.0 and
* 3.0 shaders only have WINED3DSTT_2D as well */
samplers[i] = (1 << 31) | WINED3DSTT_2D;
break;
case GL_TEXTURE_3D:
samplers[i] = (1 << 31) | WINED3DSTT_VOLUME;
break;
case GL_TEXTURE_CUBE_MAP_ARB:
samplers[i] = (1 << 31) | WINED3DSTT_CUBE;
break;
default:
FIXME("Unrecognized texture type %#x, using 2D\n",
IWineD3DBaseTexture_GetTextureDimensions(textures[i]));
samplers[i] = (0x1 << 31) | WINED3DSTT_2D;
}
}
}
static GLuint pixelshader_compile(IWineD3DPixelShaderImpl *This, const struct ps_compile_args *args)
{
CONST DWORD *function = This->baseShader.function; CONST DWORD *function = This->baseShader.function;
UINT i, sampler; GLuint retval;
IWineD3DBaseTextureImpl *texture; SHADER_BUFFER buffer;
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device;
TRACE("(%p) : function %p\n", iface, function); TRACE("(%p) : function %p\n", This, function);
/* We're already compiled, but check if any of the hardcoded stateblock assumptions pixelshader_update_samplers(&This->baseShader.reg_maps,
* changed. ((IWineD3DDeviceImpl *)This->baseShader.device)->stateBlock->textures);
*/
if (This->baseShader.is_compiled) {
char srgbenabled = deviceImpl->stateBlock->renderState[WINED3DRS_SRGBWRITEENABLE] ? 1 : 0;
for(i = 0; i < This->baseShader.num_sampled_samplers; i++) {
sampler = This->baseShader.sampled_samplers[i];
texture = (IWineD3DBaseTextureImpl *) deviceImpl->stateBlock->textures[sampler];
if(texture && texture->baseTexture.shader_conversion_group != This->baseShader.sampled_format[sampler]) {
WARN("Recompiling shader %p due to format change on sampler %d\n", This, sampler);
WARN("Old format group %s, new is %s\n",
debug_d3dformat(This->baseShader.sampled_format[sampler]),
debug_d3dformat(texture->baseTexture.shader_conversion_group));
goto recompile;
}
}
/* TODO: Check projected textures */
/* TODO: Check texture types(2D, Cube, 3D) */
if(srgbenabled != This->srgb_enabled && This->srgb_mode_hardcoded) {
WARN("Recompiling shader because srgb correction is different and hardcoded\n");
goto recompile;
}
if(This->baseShader.reg_maps.vpos && !This->vpos_uniform) {
if(This->render_offscreen != deviceImpl->render_offscreen ||
This->height != ((IWineD3DSurfaceImpl *) deviceImpl->render_targets[0])->currentDesc.Height) {
WARN("Recompiling shader because vpos is used, hard compiled and changed\n");
goto recompile;
}
}
if(This->baseShader.reg_maps.usesdsy && !This->vpos_uniform) {
if(This->render_offscreen ? 0 : 1 != deviceImpl->render_offscreen ? 0 : 1) {
WARN("Recompiling shader because dsy is used, hard compiled and render_offscreen changed\n");
goto recompile;
}
}
if(This->baseShader.hex_version >= WINED3DPS_VERSION(3,0)) {
if(((IWineD3DDeviceImpl *) This->baseShader.device)->strided_streams.u.s.position_transformed) {
if(This->vertexprocessing != pretransformed) {
WARN("Recompiling shader because pretransformed vertices are provided, which wasn't the case before\n");
goto recompile;
}
} else if(!use_vs((IWineD3DDeviceImpl *) This->baseShader.device) &&
This->vertexprocessing != fixedfunction) {
WARN("Recompiling shader because fixed function vp is in use, which wasn't the case before\n");
goto recompile;
} else if(This->vertexprocessing != vertexshader) {
WARN("Recompiling shader because vertex shaders are in use, which wasn't the case before\n");
goto recompile;
}
}
return WINED3D_OK;
recompile:
if(This->baseShader.recompile_count > 50) {
FIXME("Shader %p recompiled more than 50 times\n", This);
} else {
This->baseShader.recompile_count++;
}
deviceImpl->shader_backend->shader_destroy((IWineD3DBaseShader *) iface);
}
/* We don't need to compile */
if (!function) {
This->baseShader.is_compiled = TRUE;
return WINED3D_OK;
}
if (WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) == 1) {
shader_reg_maps *reg_maps = &This->baseShader.reg_maps;
HRESULT hr;
/* Second pass: figure out which registers are used, what the semantics are, etc.. */
memset(reg_maps, 0, sizeof(shader_reg_maps));
hr = shader_get_registers_used((IWineD3DBaseShader*)This, reg_maps,
This->semantics_in, NULL, This->baseShader.function, deviceImpl->stateBlock);
if (FAILED(hr)) return hr;
/* FIXME: validate reg_maps against OpenGL */
}
/* Reset fields tracking stateblock values being hardcoded in the shader */ /* Reset fields tracking stateblock values being hardcoded in the shader */
This->baseShader.num_sampled_samplers = 0; This->baseShader.num_sampled_samplers = 0;
/* Generate the HW shader */ /* Generate the HW shader */
TRACE("(%p) : Generating hardware program\n", This); TRACE("(%p) : Generating hardware program\n", This);
IWineD3DPixelShaderImpl_GenerateShader(iface); shader_buffer_init(&buffer);
retval = device->shader_backend->shader_generate_pshader((IWineD3DPixelShader *)This, &buffer, args);
shader_buffer_free(&buffer);
This->baseShader.is_compiled = TRUE; This->baseShader.is_compiled = TRUE;
return WINED3D_OK; return retval;
} }
const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl = const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl =
@@ -499,8 +454,98 @@ const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl =
IWineD3DPixelShaderImpl_GetParent, IWineD3DPixelShaderImpl_GetParent,
/*** IWineD3DBaseShader methods ***/ /*** IWineD3DBaseShader methods ***/
IWineD3DPixelShaderImpl_SetFunction, IWineD3DPixelShaderImpl_SetFunction,
IWineD3DPixelShaderImpl_CompileShader,
/*** IWineD3DPixelShader methods ***/ /*** IWineD3DPixelShader methods ***/
IWineD3DPixelShaderImpl_GetDevice, IWineD3DPixelShaderImpl_GetDevice,
IWineD3DPixelShaderImpl_GetFunction IWineD3DPixelShaderImpl_GetFunction
}; };
void find_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWineD3DStateBlockImpl *stateblock, struct ps_compile_args *args) {
UINT i, sampler;
IWineD3DBaseTextureImpl *tex;
memset(args, 0, sizeof(*args)); /* FIXME: Make sure all bits are set */
args->srgb_correction = stateblock->renderState[WINED3DRS_SRGBWRITEENABLE] ? 1 : 0;
for(i = 0; i < shader->baseShader.num_sampled_samplers; i++) {
sampler = shader->baseShader.sampled_samplers[i];
tex = (IWineD3DBaseTextureImpl *) stateblock->textures[sampler];
if(!tex) {
args->color_fixup[sampler] = COLOR_FIXUP_IDENTITY;
continue;
}
args->color_fixup[sampler] = tex->baseTexture.shader_color_fixup;
}
if (shader->baseShader.reg_maps.shader_version >= WINED3DPS_VERSION(3,0))
{
if (((IWineD3DDeviceImpl *)shader->baseShader.device)->strided_streams.position_transformed)
{
args->vp_mode = pretransformed;
}
else if (use_vs(stateblock))
{
args->vp_mode = vertexshader;
} else {
args->vp_mode = fixedfunction;
}
args->fog = FOG_OFF;
} else {
args->vp_mode = vertexshader;
if(stateblock->renderState[WINED3DRS_FOGENABLE]) {
switch(stateblock->renderState[WINED3DRS_FOGTABLEMODE]) {
case WINED3DFOG_NONE:
if (((IWineD3DDeviceImpl *)shader->baseShader.device)->strided_streams.position_transformed
|| use_vs(stateblock))
{
args->fog = FOG_LINEAR;
break;
}
switch(stateblock->renderState[WINED3DRS_FOGVERTEXMODE]) {
case WINED3DFOG_NONE: /* Drop through */
case WINED3DFOG_LINEAR: args->fog = FOG_LINEAR; break;
case WINED3DFOG_EXP: args->fog = FOG_EXP; break;
case WINED3DFOG_EXP2: args->fog = FOG_EXP2; break;
}
break;
case WINED3DFOG_LINEAR: args->fog = FOG_LINEAR; break;
case WINED3DFOG_EXP: args->fog = FOG_EXP; break;
case WINED3DFOG_EXP2: args->fog = FOG_EXP2; break;
}
} else {
args->fog = FOG_OFF;
}
}
}
GLuint find_gl_pshader(IWineD3DPixelShaderImpl *shader, const struct ps_compile_args *args)
{
UINT i;
struct ps_compiled_shader *old_array;
/* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2),
* so a linear search is more performant than a hashmap
*/
for(i = 0; i < shader->num_gl_shaders; i++) {
if(memcmp(&shader->gl_shaders[i].args, args, sizeof(*args)) == 0) {
return shader->gl_shaders[i].prgId;
}
}
TRACE("No matching GL shader found, compiling a new shader\n");
old_array = shader->gl_shaders;
if(old_array) {
shader->gl_shaders = HeapReAlloc(GetProcessHeap(), 0, old_array,
(shader->num_gl_shaders + 1) * sizeof(*shader->gl_shaders));
} else {
shader->gl_shaders = HeapAlloc(GetProcessHeap(), 0, sizeof(*shader->gl_shaders));
}
if(!shader->gl_shaders) {
ERR("Out of memory\n");
return 0;
}
shader->gl_shaders[shader->num_gl_shaders].args = *args;
shader->gl_shaders[shader->num_gl_shaders].prgId = pixelshader_compile(shader, args);
return shader->gl_shaders[shader->num_gl_shaders++].prgId;
}

View File

@@ -63,8 +63,18 @@ static ULONG WINAPI IWineD3DQueryImpl_Release(IWineD3DQuery *iface) {
ref = InterlockedDecrement(&This->ref); ref = InterlockedDecrement(&This->ref);
if (ref == 0) { if (ref == 0) {
ENTER_GL(); ENTER_GL();
/* Queries are specific to the GL context that created them. Not
* deleting the query will obviously leak it, but that's still better
* than potentially deleting a different query with the same id in this
* context, and (still) leaking the actual query. */
if(This->type == WINED3DQUERYTYPE_EVENT) { if(This->type == WINED3DQUERYTYPE_EVENT) {
if(GL_SUPPORT(APPLE_FENCE)) { if (((WineQueryEventData *)This->extendedData)->ctx != This->wineD3DDevice->activeContext
|| This->wineD3DDevice->activeContext->tid != GetCurrentThreadId())
{
FIXME("Query was created in a different context, skipping deletion\n");
}
else if(GL_SUPPORT(APPLE_FENCE))
{
GL_EXTCALL(glDeleteFencesAPPLE(1, &((WineQueryEventData *)(This->extendedData))->fenceId)); GL_EXTCALL(glDeleteFencesAPPLE(1, &((WineQueryEventData *)(This->extendedData))->fenceId));
checkGLcall("glDeleteFencesAPPLE"); checkGLcall("glDeleteFencesAPPLE");
} else if(GL_SUPPORT(NV_FENCE)) { } else if(GL_SUPPORT(NV_FENCE)) {
@@ -72,8 +82,16 @@ static ULONG WINAPI IWineD3DQueryImpl_Release(IWineD3DQuery *iface) {
checkGLcall("glDeleteFencesNV"); checkGLcall("glDeleteFencesNV");
} }
} else if(This->type == WINED3DQUERYTYPE_OCCLUSION && GL_SUPPORT(ARB_OCCLUSION_QUERY)) { } else if(This->type == WINED3DQUERYTYPE_OCCLUSION && GL_SUPPORT(ARB_OCCLUSION_QUERY)) {
GL_EXTCALL(glDeleteQueriesARB(1, &((WineQueryOcclusionData *)(This->extendedData))->queryId)); if (((WineQueryOcclusionData *)This->extendedData)->ctx != This->wineD3DDevice->activeContext
checkGLcall("glDeleteQueriesARB"); || This->wineD3DDevice->activeContext->tid != GetCurrentThreadId())
{
FIXME("Query was created in a different context, skipping deletion\n");
}
else
{
GL_EXTCALL(glDeleteQueriesARB(1, &((WineQueryOcclusionData *)(This->extendedData))->queryId));
checkGLcall("glDeleteQueriesARB");
}
} }
LEAVE_GL(); LEAVE_GL();
@@ -268,48 +286,68 @@ static HRESULT WINAPI IWineD3DQueryImpl_GetData(IWineD3DQuery* iface, void* pDa
static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) { static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) {
IWineD3DQueryImpl *This = (IWineD3DQueryImpl *) iface; IWineD3DQueryImpl *This = (IWineD3DQueryImpl *) iface;
GLuint queryId = ((WineQueryOcclusionData *)This->extendedData)->queryId;
DWORD* data = pData; DWORD* data = pData;
GLuint available;
GLuint samples;
HRESULT res; HRESULT res;
TRACE("(%p) : type D3DQUERY_OCCLUSION, pData %p, dwSize %#x, dwGetDataFlags %#x\n", This, pData, dwSize, dwGetDataFlags); TRACE("(%p) : type D3DQUERY_OCCLUSION, pData %p, dwSize %#x, dwGetDataFlags %#x\n", This, pData, dwSize, dwGetDataFlags);
if(This->state == QUERY_CREATED) { if (This->state == QUERY_CREATED)
{
/* D3D allows GetData on a new query, OpenGL doesn't. So just invent the data ourselves */ /* D3D allows GetData on a new query, OpenGL doesn't. So just invent the data ourselves */
TRACE("Query wasn't yet started, returning S_OK\n"); TRACE("Query wasn't yet started, returning S_OK\n");
res = S_OK;
if(data) *data = 0; if(data) *data = 0;
} else if(This->state == QUERY_BUILDING) { return S_OK;
}
if (This->state == QUERY_BUILDING)
{
/* Msdn says this returns an error, but our tests show that S_FALSE is returned */ /* Msdn says this returns an error, but our tests show that S_FALSE is returned */
TRACE("Query is building, returning S_FALSE\n"); TRACE("Query is building, returning S_FALSE\n");
res = S_FALSE; return S_FALSE;
} else if (GL_SUPPORT(ARB_OCCLUSION_QUERY) && }
((WineQueryOcclusionData *)This->extendedData)->ctx == This->wineD3DDevice->activeContext &&
This->wineD3DDevice->activeContext->tid == GetCurrentThreadId()) {
GLuint available;
GLuint samples;
GLuint queryId = ((WineQueryOcclusionData *)This->extendedData)->queryId;
ENTER_GL(); if (!GL_SUPPORT(ARB_OCCLUSION_QUERY))
GL_EXTCALL(glGetQueryObjectuivARB(queryId, GL_QUERY_RESULT_AVAILABLE_ARB, &available)); {
checkGLcall("glGetQueryObjectuivARB(GL_QUERY_RESULT_AVAILABLE)\n"); WARN("(%p) : Occlusion queries not supported. Returning 1.\n", This);
TRACE("(%p) : available %d.\n", This, available);
if (available) {
if(data) {
GL_EXTCALL(glGetQueryObjectuivARB(queryId, GL_QUERY_RESULT_ARB, &samples));
checkGLcall("glGetQueryObjectuivARB(GL_QUERY_RESULT)\n");
TRACE("(%p) : Returning %d samples.\n", This, samples);
*data = samples;
}
res = S_OK;
} else {
res = S_FALSE;
}
LEAVE_GL();
} else {
WARN("(%p) : Occlusion queries not supported, or wrong context. Returning 1.\n", This);
*data = 1; *data = 1;
return S_OK;
}
if (((WineQueryOcclusionData *)This->extendedData)->ctx != This->wineD3DDevice->activeContext
|| This->wineD3DDevice->activeContext->tid != GetCurrentThreadId())
{
FIXME("%p Wrong context, returning 1.\n", This);
*data = 1;
return S_OK;
}
ENTER_GL();
GL_EXTCALL(glGetQueryObjectuivARB(queryId, GL_QUERY_RESULT_AVAILABLE_ARB, &available));
checkGLcall("glGetQueryObjectuivARB(GL_QUERY_RESULT_AVAILABLE)\n");
TRACE("(%p) : available %d.\n", This, available);
if (available)
{
if (data)
{
GL_EXTCALL(glGetQueryObjectuivARB(queryId, GL_QUERY_RESULT_ARB, &samples));
checkGLcall("glGetQueryObjectuivARB(GL_QUERY_RESULT)\n");
TRACE("(%p) : Returning %d samples.\n", This, samples);
*data = samples;
}
res = S_OK; res = S_OK;
} }
else
{
res = S_FALSE;
}
LEAVE_GL();
return res; return res;
} }
@@ -324,7 +362,7 @@ static HRESULT WINAPI IWineD3DEventQueryImpl_GetData(IWineD3DQuery* iface, void
return S_OK; return S_OK;
} if(ctx != This->wineD3DDevice->activeContext || ctx->tid != GetCurrentThreadId()) { } if(ctx != This->wineD3DDevice->activeContext || ctx->tid != GetCurrentThreadId()) {
/* See comment in IWineD3DQuery::Issue, event query codeblock */ /* See comment in IWineD3DQuery::Issue, event query codeblock */
WARN("Query context not active, reporting GPU idle\n"); FIXME("Query context not active, reporting GPU idle\n");
*data = TRUE; *data = TRUE;
} else if(GL_SUPPORT(APPLE_FENCE)) { } else if(GL_SUPPORT(APPLE_FENCE)) {
ENTER_GL(); ENTER_GL();
@@ -460,7 +498,7 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_Issue(IWineD3DQuery* iface, D
WineD3DContext *ctx = ((WineQueryOcclusionData *)This->extendedData)->ctx; WineD3DContext *ctx = ((WineQueryOcclusionData *)This->extendedData)->ctx;
if(ctx != This->wineD3DDevice->activeContext || ctx->tid != GetCurrentThreadId()) { if(ctx != This->wineD3DDevice->activeContext || ctx->tid != GetCurrentThreadId()) {
WARN("Not the owning context, can't start query\n"); FIXME("Not the owning context, can't start query\n");
} else { } else {
ENTER_GL(); ENTER_GL();
/* This is allowed according to msdn and our tests. Reset the query and restart */ /* This is allowed according to msdn and our tests. Reset the query and restart */

View File

@@ -27,42 +27,52 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info #define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info
/* IWineD3DResource IUnknown parts follow: */ HRESULT resource_init(struct IWineD3DResourceClass *resource, WINED3DRESOURCETYPE resource_type,
HRESULT WINAPI IWineD3DResourceImpl_QueryInterface(IWineD3DResource *iface, REFIID riid, LPVOID *ppobj) IWineD3DDeviceImpl *device, UINT size, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool, IUnknown *parent)
{ {
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface; resource->wineD3DDevice = device;
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj); resource->parent = parent;
if (IsEqualGUID(riid, &IID_IUnknown) resource->resourceType = resource_type;
|| IsEqualGUID(riid, &IID_IWineD3DBase) resource->ref = 1;
|| IsEqualGUID(riid, &IID_IWineD3DResource)) { resource->pool = pool;
IUnknown_AddRef(iface); resource->format = format;
*ppobj = This; resource->usage = usage;
return S_OK; resource->size = size;
resource->priority = 0;
list_init(&resource->privateData);
if (size)
{
resource->heapMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size + RESOURCE_ALIGNMENT);
if (!resource->heapMemory)
{
ERR("Out of memory!\n");
return WINED3DERR_OUTOFVIDEOMEMORY;
}
} }
*ppobj = NULL; else
return E_NOINTERFACE; {
} resource->heapMemory = NULL;
ULONG WINAPI IWineD3DResourceImpl_AddRef(IWineD3DResource *iface) {
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
ULONG ref = InterlockedIncrement(&This->resource.ref);
TRACE("(%p) : AddRef increasing from %d\n", This, ref - 1);
return ref;
}
ULONG WINAPI IWineD3DResourceImpl_Release(IWineD3DResource *iface) {
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
ULONG ref = InterlockedDecrement(&This->resource.ref);
TRACE("(%p) : Releasing from %d\n", This, ref + 1);
if (ref == 0) {
IWineD3DResourceImpl_CleanUp(iface);
HeapFree(GetProcessHeap(), 0, This);
} }
return ref; resource->allocatedMemory = (BYTE *)(((ULONG_PTR)resource->heapMemory + (RESOURCE_ALIGNMENT - 1)) & ~(RESOURCE_ALIGNMENT - 1));
/* Check that we have enough video ram left */
if (pool == WINED3DPOOL_DEFAULT)
{
if (size > IWineD3DDevice_GetAvailableTextureMem((IWineD3DDevice *)device))
{
ERR("Out of adapter memory\n");
HeapFree(GetProcessHeap(), 0, resource->heapMemory);
return WINED3DERR_OUTOFVIDEOMEMORY;
}
WineD3DAdapterChangeGLRam(device, size);
}
return WINED3D_OK;
} }
/* class static (not in vtable) */ void resource_cleanup(IWineD3DResource *iface)
void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface){ {
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface; IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
struct list *e1, *e2; struct list *e1, *e2;
PrivateData *data; PrivateData *data;
@@ -76,7 +86,7 @@ void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface){
LIST_FOR_EACH_SAFE(e1, e2, &This->resource.privateData) { LIST_FOR_EACH_SAFE(e1, e2, &This->resource.privateData) {
data = LIST_ENTRY(e1, PrivateData, entry); data = LIST_ENTRY(e1, PrivateData, entry);
hr = IWineD3DResourceImpl_FreePrivateData(iface, &data->tag); hr = resource_free_private_data(iface, &data->tag);
if(hr != WINED3D_OK) { if(hr != WINED3D_OK) {
ERR("Failed to free private data when destroying resource %p, hr = %08x\n", This, hr); ERR("Failed to free private data when destroying resource %p, hr = %08x\n", This, hr);
} }
@@ -92,8 +102,8 @@ void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface){
return; return;
} }
/* IWineD3DResource Interface follows: */ HRESULT resource_get_device(IWineD3DResource *iface, IWineD3DDevice** ppDevice)
HRESULT WINAPI IWineD3DResourceImpl_GetDevice(IWineD3DResource *iface, IWineD3DDevice** ppDevice) { {
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface; IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
TRACE("(%p) : returning %p\n", This, This->resource.wineD3DDevice); TRACE("(%p) : returning %p\n", This, This->resource.wineD3DDevice);
*ppDevice = (IWineD3DDevice *) This->resource.wineD3DDevice; *ppDevice = (IWineD3DDevice *) This->resource.wineD3DDevice;
@@ -101,8 +111,7 @@ HRESULT WINAPI IWineD3DResourceImpl_GetDevice(IWineD3DResource *iface, IWineD3DD
return WINED3D_OK; return WINED3D_OK;
} }
static PrivateData* IWineD3DResourceImpl_FindPrivateData(IWineD3DResourceImpl *This, static PrivateData* resource_find_private_data(IWineD3DResourceImpl *This, REFGUID tag)
REFGUID tag)
{ {
PrivateData *data; PrivateData *data;
struct list *entry; struct list *entry;
@@ -120,21 +129,21 @@ static PrivateData* IWineD3DResourceImpl_FindPrivateData(IWineD3DResourceImpl *T
return NULL; return NULL;
} }
HRESULT WINAPI IWineD3DResourceImpl_SetPrivateData(IWineD3DResource *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) { HRESULT resource_set_private_data(IWineD3DResource *iface, REFGUID refguid,
const void *pData, DWORD SizeOfData, DWORD Flags)
{
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface; IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
PrivateData *data; PrivateData *data;
TRACE("(%p) : %s %p %d %d\n", This, debugstr_guid(refguid), pData, SizeOfData, Flags); TRACE("(%p) : %s %p %d %d\n", This, debugstr_guid(refguid), pData, SizeOfData, Flags);
IWineD3DResourceImpl_FreePrivateData(iface, refguid); resource_free_private_data(iface, refguid);
data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data)); data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data));
if (NULL == data) return E_OUTOFMEMORY; if (NULL == data) return E_OUTOFMEMORY;
data->tag = *refguid; data->tag = *refguid;
data->flags = Flags; data->flags = Flags;
#if 0
(*data)->uniquenessValue = This->uniquenessValue;
#endif
if (Flags & WINED3DSPD_IUNKNOWN) { if (Flags & WINED3DSPD_IUNKNOWN) {
if(SizeOfData != sizeof(IUnknown *)) { if(SizeOfData != sizeof(IUnknown *)) {
WARN("IUnknown data with size %d, returning WINED3DERR_INVALIDCALL\n", SizeOfData); WARN("IUnknown data with size %d, returning WINED3DERR_INVALIDCALL\n", SizeOfData);
@@ -160,20 +169,15 @@ HRESULT WINAPI IWineD3DResourceImpl_SetPrivateData(IWineD3DResource *iface, REFG
return WINED3D_OK; return WINED3D_OK;
} }
HRESULT WINAPI IWineD3DResourceImpl_GetPrivateData(IWineD3DResource *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) { HRESULT resource_get_private_data(IWineD3DResource *iface, REFGUID refguid, void *pData, DWORD *pSizeOfData)
{
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface; IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
PrivateData *data; PrivateData *data;
TRACE("(%p) : %p %p %p\n", This, refguid, pData, pSizeOfData); TRACE("(%p) : %p %p %p\n", This, refguid, pData, pSizeOfData);
data = IWineD3DResourceImpl_FindPrivateData(This, refguid); data = resource_find_private_data(This, refguid);
if (data == NULL) return WINED3DERR_NOTFOUND; if (data == NULL) return WINED3DERR_NOTFOUND;
#if 0 /* This may not be right. */
if (((*data)->flags & WINED3DSPD_VOLATILE)
&& (*data)->uniquenessValue != This->uniquenessValue)
return DDERR_EXPIRED;
#endif
if (*pSizeOfData < data->size) { if (*pSizeOfData < data->size) {
*pSizeOfData = data->size; *pSizeOfData = data->size;
return WINED3DERR_MOREDATA; return WINED3DERR_MOREDATA;
@@ -195,12 +199,13 @@ HRESULT WINAPI IWineD3DResourceImpl_GetPrivateData(IWineD3DResource *iface, REFG
return WINED3D_OK; return WINED3D_OK;
} }
HRESULT WINAPI IWineD3DResourceImpl_FreePrivateData(IWineD3DResource *iface, REFGUID refguid) { HRESULT resource_free_private_data(IWineD3DResource *iface, REFGUID refguid)
{
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface; IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
PrivateData *data; PrivateData *data;
TRACE("(%p) : %s\n", This, debugstr_guid(refguid)); TRACE("(%p) : %s\n", This, debugstr_guid(refguid));
data = IWineD3DResourceImpl_FindPrivateData(This, refguid); data = resource_find_private_data(This, refguid);
if (data == NULL) return WINED3DERR_NOTFOUND; if (data == NULL) return WINED3DERR_NOTFOUND;
if (data->flags & WINED3DSPD_IUNKNOWN) if (data->flags & WINED3DSPD_IUNKNOWN)
@@ -217,7 +222,8 @@ HRESULT WINAPI IWineD3DResourceImpl_FreePrivateData(IWineD3DResource *iface, REF
return WINED3D_OK; return WINED3D_OK;
} }
DWORD WINAPI IWineD3DResourceImpl_SetPriority(IWineD3DResource *iface, DWORD PriorityNew) { DWORD resource_set_priority(IWineD3DResource *iface, DWORD PriorityNew)
{
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface; IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
DWORD PriorityOld = This->resource.priority; DWORD PriorityOld = This->resource.priority;
This->resource.priority = PriorityNew; This->resource.priority = PriorityNew;
@@ -225,30 +231,22 @@ DWORD WINAPI IWineD3DResourceImpl_SetPriority(IWineD3DResource *iface,
return PriorityOld; return PriorityOld;
} }
DWORD WINAPI IWineD3DResourceImpl_GetPriority(IWineD3DResource *iface) { DWORD resource_get_priority(IWineD3DResource *iface)
{
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface; IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
TRACE("(%p) : returning %d\n", This, This->resource.priority ); TRACE("(%p) : returning %d\n", This, This->resource.priority );
return This->resource.priority; return This->resource.priority;
} }
/* Preloading of resources is not supported yet */ WINED3DRESOURCETYPE resource_get_type(IWineD3DResource *iface)
void WINAPI IWineD3DResourceImpl_PreLoad(IWineD3DResource *iface) { {
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
FIXME("(%p) : stub\n", This);
}
void WINAPI IWineD3DResourceImpl_UnLoad(IWineD3DResource *iface) {
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
FIXME("(%p) : stub\n", This);
}
WINED3DRESOURCETYPE WINAPI IWineD3DResourceImpl_GetType(IWineD3DResource *iface) {
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface; IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
TRACE("(%p) : returning %d\n", This, This->resource.resourceType); TRACE("(%p) : returning %d\n", This, This->resource.resourceType);
return This->resource.resourceType; return This->resource.resourceType;
} }
HRESULT WINAPI IWineD3DResourceImpl_GetParent(IWineD3DResource *iface, IUnknown **pParent) { HRESULT resource_get_parent(IWineD3DResource *iface, IUnknown **pParent)
{
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface; IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
IUnknown_AddRef(This->resource.parent); IUnknown_AddRef(This->resource.parent);
*pParent = This->resource.parent; *pParent = This->resource.parent;
@@ -262,22 +260,3 @@ void dumpResources(struct list *list) {
FIXME("Leftover resource %p with type %d,%s\n", resource, IWineD3DResource_GetType((IWineD3DResource *) resource), debug_d3dresourcetype(IWineD3DResource_GetType((IWineD3DResource *) resource))); FIXME("Leftover resource %p with type %d,%s\n", resource, IWineD3DResource_GetType((IWineD3DResource *) resource), debug_d3dresourcetype(IWineD3DResource_GetType((IWineD3DResource *) resource)));
} }
} }
static const IWineD3DResourceVtbl IWineD3DResource_Vtbl =
{
/* IUnknown */
IWineD3DResourceImpl_QueryInterface,
IWineD3DResourceImpl_AddRef,
IWineD3DResourceImpl_Release,
/* IWineD3DResource */
IWineD3DResourceImpl_GetParent,
IWineD3DResourceImpl_GetDevice,
IWineD3DResourceImpl_SetPrivateData,
IWineD3DResourceImpl_GetPrivateData,
IWineD3DResourceImpl_FreePrivateData,
IWineD3DResourceImpl_SetPriority,
IWineD3DResourceImpl_GetPriority,
IWineD3DResourceImpl_PreLoad,
IWineD3DResourceImpl_UnLoad,
IWineD3DResourceImpl_GetType
};

File diff suppressed because it is too large Load Diff

View File

@@ -38,43 +38,47 @@ HRESULT allocate_shader_constants(IWineD3DStateBlockImpl* object) {
IWineD3DStateBlockImpl *This = object; IWineD3DStateBlockImpl *This = object;
#define WINED3D_MEMCHECK(_object) if (NULL == _object) { FIXME("Out of memory!\n"); return E_OUTOFMEMORY; }
/* Allocate space for floating point constants */ /* Allocate space for floating point constants */
object->pixelShaderConstantF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(float) * GL_LIMITS(pshader_constantsF) * 4); object->pixelShaderConstantF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(float) * GL_LIMITS(pshader_constantsF) * 4);
WINED3D_MEMCHECK(object->pixelShaderConstantF); if (!object->pixelShaderConstantF) goto fail;
object->changed.pixelShaderConstantsF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BOOL) * GL_LIMITS(pshader_constantsF)); object->changed.pixelShaderConstantsF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BOOL) * GL_LIMITS(pshader_constantsF));
WINED3D_MEMCHECK(object->changed.pixelShaderConstantsF); if (!object->changed.pixelShaderConstantsF) goto fail;
object->vertexShaderConstantF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(float) * GL_LIMITS(vshader_constantsF) * 4); object->vertexShaderConstantF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(float) * GL_LIMITS(vshader_constantsF) * 4);
WINED3D_MEMCHECK(object->vertexShaderConstantF); if (!object->vertexShaderConstantF) goto fail;
object->changed.vertexShaderConstantsF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BOOL) * GL_LIMITS(vshader_constantsF)); object->changed.vertexShaderConstantsF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BOOL) * GL_LIMITS(vshader_constantsF));
WINED3D_MEMCHECK(object->changed.vertexShaderConstantsF); if (!object->changed.vertexShaderConstantsF) goto fail;
object->contained_vs_consts_f = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) * GL_LIMITS(vshader_constantsF)); object->contained_vs_consts_f = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) * GL_LIMITS(vshader_constantsF));
WINED3D_MEMCHECK(object->contained_vs_consts_f); if (!object->contained_vs_consts_f) goto fail;
object->contained_ps_consts_f = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) * GL_LIMITS(pshader_constantsF)); object->contained_ps_consts_f = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) * GL_LIMITS(pshader_constantsF));
WINED3D_MEMCHECK(object->contained_ps_consts_f); if (!object->contained_ps_consts_f) goto fail;
list_init(&object->set_vconstantsF);
list_init(&object->set_pconstantsF);
#undef WINED3D_MEMCHECK
return WINED3D_OK; return WINED3D_OK;
fail:
ERR("Failed to allocate memory\n");
HeapFree(GetProcessHeap(), 0, object->pixelShaderConstantF);
HeapFree(GetProcessHeap(), 0, object->changed.pixelShaderConstantsF);
HeapFree(GetProcessHeap(), 0, object->vertexShaderConstantF);
HeapFree(GetProcessHeap(), 0, object->changed.vertexShaderConstantsF);
HeapFree(GetProcessHeap(), 0, object->contained_vs_consts_f);
HeapFree(GetProcessHeap(), 0, object->contained_ps_consts_f);
return E_OUTOFMEMORY;
} }
/** Copy all members of one stateblock to another */ /** Copy all members of one stateblock to another */
void stateblock_savedstates_copy( static void stateblock_savedstates_copy(IWineD3DStateBlock* iface, SAVEDSTATES *dest, const SAVEDSTATES *source)
IWineD3DStateBlock* iface, {
SAVEDSTATES* dest,
SAVEDSTATES* source) {
IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface; IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
unsigned bsize = sizeof(BOOL); unsigned bsize = sizeof(BOOL);
/* Single values */ /* Single values */
dest->indices = source->indices; dest->indices = source->indices;
dest->material = source->material; dest->material = source->material;
dest->fvf = source->fvf;
dest->viewport = source->viewport; dest->viewport = source->viewport;
dest->vertexDecl = source->vertexDecl; dest->vertexDecl = source->vertexDecl;
dest->pixelShader = source->pixelShader; dest->pixelShader = source->pixelShader;
@@ -82,24 +86,31 @@ void stateblock_savedstates_copy(
dest->scissorRect = dest->scissorRect; dest->scissorRect = dest->scissorRect;
/* Fixed size arrays */ /* Fixed size arrays */
memcpy(dest->streamSource, source->streamSource, bsize * MAX_STREAMS); dest->streamSource = source->streamSource;
memcpy(dest->streamFreq, source->streamFreq, bsize * MAX_STREAMS); dest->streamFreq = source->streamFreq;
memcpy(dest->textures, source->textures, bsize * MAX_COMBINED_SAMPLERS); dest->textures = source->textures;
memcpy(dest->transform, source->transform, bsize * (HIGHEST_TRANSFORMSTATE + 1)); memcpy(dest->transform, source->transform, sizeof(source->transform));
memcpy(dest->renderState, source->renderState, bsize * (WINEHIGHEST_RENDER_STATE + 1)); memcpy(dest->renderState, source->renderState, sizeof(source->renderState));
memcpy(dest->textureState, source->textureState, bsize * MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1)); memcpy(dest->textureState, source->textureState, sizeof(source->textureState));
memcpy(dest->samplerState, source->samplerState, bsize * MAX_COMBINED_SAMPLERS * (WINED3D_HIGHEST_SAMPLER_STATE + 1)); memcpy(dest->samplerState, source->samplerState, sizeof(source->samplerState));
memcpy(dest->clipplane, source->clipplane, bsize * MAX_CLIPPLANES); dest->clipplane = source->clipplane;
memcpy(dest->pixelShaderConstantsB, source->pixelShaderConstantsB, bsize * MAX_CONST_B); dest->pixelShaderConstantsB = source->pixelShaderConstantsB;
memcpy(dest->pixelShaderConstantsI, source->pixelShaderConstantsI, bsize * MAX_CONST_I); dest->pixelShaderConstantsI = source->pixelShaderConstantsI;
memcpy(dest->vertexShaderConstantsB, source->vertexShaderConstantsB, bsize * MAX_CONST_B); dest->vertexShaderConstantsB = source->vertexShaderConstantsB;
memcpy(dest->vertexShaderConstantsI, source->vertexShaderConstantsI, bsize * MAX_CONST_I); dest->vertexShaderConstantsI = source->vertexShaderConstantsI;
/* Dynamically sized arrays */ /* Dynamically sized arrays */
memcpy(dest->pixelShaderConstantsF, source->pixelShaderConstantsF, bsize * GL_LIMITS(pshader_constantsF)); memcpy(dest->pixelShaderConstantsF, source->pixelShaderConstantsF, bsize * GL_LIMITS(pshader_constantsF));
memcpy(dest->vertexShaderConstantsF, source->vertexShaderConstantsF, bsize * GL_LIMITS(vshader_constantsF)); memcpy(dest->vertexShaderConstantsF, source->vertexShaderConstantsF, bsize * GL_LIMITS(vshader_constantsF));
} }
static inline void stateblock_set_bits(DWORD *map, UINT map_size)
{
DWORD mask = (1 << (map_size & 0x1f)) - 1;
memset(map, 0xff, (map_size >> 5) * sizeof(*map));
if (mask) map[map_size >> 5] = mask;
}
/** Set all members of a stateblock savedstate to the given value */ /** Set all members of a stateblock savedstate to the given value */
void stateblock_savedstates_set( void stateblock_savedstates_set(
IWineD3DStateBlock* iface, IWineD3DStateBlock* iface,
@@ -112,7 +123,6 @@ void stateblock_savedstates_set(
/* Single values */ /* Single values */
states->indices = value; states->indices = value;
states->material = value; states->material = value;
states->fvf = value;
states->viewport = value; states->viewport = value;
states->vertexDecl = value; states->vertexDecl = value;
states->pixelShader = value; states->pixelShader = value;
@@ -120,18 +130,37 @@ void stateblock_savedstates_set(
states->scissorRect = value; states->scissorRect = value;
/* Fixed size arrays */ /* Fixed size arrays */
memset(states->streamSource, value, bsize * MAX_STREAMS); if (value)
memset(states->streamFreq, value, bsize * MAX_STREAMS); {
memset(states->textures, value, bsize * MAX_COMBINED_SAMPLERS); int i;
memset(states->transform, value, bsize * (HIGHEST_TRANSFORMSTATE + 1)); states->streamSource = 0xffff;
memset(states->renderState, value, bsize * (WINEHIGHEST_RENDER_STATE + 1)); states->streamFreq = 0xffff;
memset(states->textureState, value, bsize * MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1)); states->textures = 0xfffff;
memset(states->samplerState, value, bsize * MAX_COMBINED_SAMPLERS * (WINED3D_HIGHEST_SAMPLER_STATE + 1)); stateblock_set_bits(states->transform, HIGHEST_TRANSFORMSTATE + 1);
memset(states->clipplane, value, bsize * MAX_CLIPPLANES); stateblock_set_bits(states->renderState, WINEHIGHEST_RENDER_STATE + 1);
memset(states->pixelShaderConstantsB, value, bsize * MAX_CONST_B); for (i = 0; i < MAX_TEXTURES; ++i) states->textureState[i] = 0x3ffff;
memset(states->pixelShaderConstantsI, value, bsize * MAX_CONST_I); for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i) states->samplerState[i] = 0x3fff;
memset(states->vertexShaderConstantsB, value, bsize * MAX_CONST_B); states->clipplane = 0xffffffff;
memset(states->vertexShaderConstantsI, value, bsize * MAX_CONST_I); states->pixelShaderConstantsB = 0xffff;
states->pixelShaderConstantsI = 0xffff;
states->vertexShaderConstantsB = 0xffff;
states->vertexShaderConstantsI = 0xffff;
}
else
{
states->streamSource = 0;
states->streamFreq = 0;
states->textures = 0;
memset(states->transform, 0, sizeof(states->transform));
memset(states->renderState, 0, sizeof(states->renderState));
memset(states->textureState, 0, sizeof(states->textureState));
memset(states->samplerState, 0, sizeof(states->samplerState));
states->clipplane = 0;
states->pixelShaderConstantsB = 0;
states->pixelShaderConstantsI = 0;
states->vertexShaderConstantsB = 0;
states->vertexShaderConstantsI = 0;
}
/* Dynamically sized arrays */ /* Dynamically sized arrays */
memset(states->pixelShaderConstantsF, value, bsize * GL_LIMITS(pshader_constantsF)); memset(states->pixelShaderConstantsF, value, bsize * GL_LIMITS(pshader_constantsF));
@@ -159,7 +188,6 @@ void stateblock_copy(
stateblock_savedstates_copy(source, &Dest->changed, &This->changed); stateblock_savedstates_copy(source, &Dest->changed, &This->changed);
/* Single items */ /* Single items */
Dest->fvf = This->fvf;
Dest->vertexDecl = This->vertexDecl; Dest->vertexDecl = This->vertexDecl;
Dest->vertexShader = This->vertexShader; Dest->vertexShader = This->vertexShader;
Dest->streamIsUP = This->streamIsUP; Dest->streamIsUP = This->streamIsUP;
@@ -206,7 +234,6 @@ void stateblock_copy(
memcpy(Dest->clipplane, This->clipplane, sizeof(double) * MAX_CLIPPLANES * 4); memcpy(Dest->clipplane, This->clipplane, sizeof(double) * MAX_CLIPPLANES * 4);
memcpy(Dest->renderState, This->renderState, sizeof(DWORD) * (WINEHIGHEST_RENDER_STATE + 1)); memcpy(Dest->renderState, This->renderState, sizeof(DWORD) * (WINEHIGHEST_RENDER_STATE + 1));
memcpy(Dest->textures, This->textures, sizeof(IWineD3DBaseTexture*) * MAX_COMBINED_SAMPLERS); memcpy(Dest->textures, This->textures, sizeof(IWineD3DBaseTexture*) * MAX_COMBINED_SAMPLERS);
memcpy(Dest->textureDimensions, This->textureDimensions, sizeof(int) * MAX_COMBINED_SAMPLERS);
memcpy(Dest->textureState, This->textureState, sizeof(DWORD) * MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1)); memcpy(Dest->textureState, This->textureState, sizeof(DWORD) * MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1));
memcpy(Dest->samplerState, This->samplerState, sizeof(DWORD) * MAX_COMBINED_SAMPLERS * (WINED3D_HIGHEST_SAMPLER_STATE + 1)); memcpy(Dest->samplerState, This->samplerState, sizeof(DWORD) * MAX_COMBINED_SAMPLERS * (WINED3D_HIGHEST_SAMPLER_STATE + 1));
@@ -248,7 +275,6 @@ static ULONG WINAPI IWineD3DStateBlockImpl_Release(IWineD3DStateBlock *iface) {
TRACE("(%p) : Releasing from %d\n", This, refCount + 1); TRACE("(%p) : Releasing from %d\n", This, refCount + 1);
if (!refCount) { if (!refCount) {
constants_entry *constant, *constant2;
int counter; int counter;
/* type 0 represents the primary stateblock, so free all the resources */ /* type 0 represents the primary stateblock, so free all the resources */
@@ -290,15 +316,6 @@ static ULONG WINAPI IWineD3DStateBlockImpl_Release(IWineD3DStateBlock *iface) {
HeapFree(GetProcessHeap(), 0, This->changed.pixelShaderConstantsF); HeapFree(GetProcessHeap(), 0, This->changed.pixelShaderConstantsF);
HeapFree(GetProcessHeap(), 0, This->contained_vs_consts_f); HeapFree(GetProcessHeap(), 0, This->contained_vs_consts_f);
HeapFree(GetProcessHeap(), 0, This->contained_ps_consts_f); HeapFree(GetProcessHeap(), 0, This->contained_ps_consts_f);
LIST_FOR_EACH_ENTRY_SAFE(constant, constant2, &This->set_vconstantsF, constants_entry, entry) {
HeapFree(GetProcessHeap(), 0, constant);
}
LIST_FOR_EACH_ENTRY_SAFE(constant, constant2, &This->set_pconstantsF, constants_entry, entry) {
HeapFree(GetProcessHeap(), 0, constant);
}
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
return refCount; return refCount;
@@ -381,6 +398,7 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface; IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
IWineD3DStateBlockImpl *targetStateBlock = This->wineD3DDevice->stateBlock; IWineD3DStateBlockImpl *targetStateBlock = This->wineD3DDevice->stateBlock;
unsigned int i, j; unsigned int i, j;
DWORD map;
TRACE("(%p) : Updating state block %p ------------------v\n", targetStateBlock, This); TRACE("(%p) : Updating state block %p ------------------v\n", targetStateBlock, This);
@@ -399,11 +417,11 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
/* Vertex Shader Float Constants */ /* Vertex Shader Float Constants */
for (j = 0; j < This->num_contained_vs_consts_f; ++j) { for (j = 0; j < This->num_contained_vs_consts_f; ++j) {
i = This->contained_vs_consts_f[j]; i = This->contained_vs_consts_f[j];
TRACE("Setting %p from %p %d to { %f, %f, %f, %f }\n", This, targetStateBlock, i, TRACE("Setting %p from %p %u to {%f, %f, %f, %f}\n", This, targetStateBlock, i,
targetStateBlock->vertexShaderConstantF[i * 4], targetStateBlock->vertexShaderConstantF[i * 4],
targetStateBlock->vertexShaderConstantF[i * 4 + 1], targetStateBlock->vertexShaderConstantF[i * 4 + 1],
targetStateBlock->vertexShaderConstantF[i * 4 + 2], targetStateBlock->vertexShaderConstantF[i * 4 + 2],
targetStateBlock->vertexShaderConstantF[i * 4 + 3]); targetStateBlock->vertexShaderConstantF[i * 4 + 3]);
This->vertexShaderConstantF[i * 4] = targetStateBlock->vertexShaderConstantF[i * 4]; This->vertexShaderConstantF[i * 4] = targetStateBlock->vertexShaderConstantF[i * 4];
This->vertexShaderConstantF[i * 4 + 1] = targetStateBlock->vertexShaderConstantF[i * 4 + 1]; This->vertexShaderConstantF[i * 4 + 1] = targetStateBlock->vertexShaderConstantF[i * 4 + 1];
@@ -414,11 +432,11 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
/* Vertex Shader Integer Constants */ /* Vertex Shader Integer Constants */
for (j = 0; j < This->num_contained_vs_consts_i; ++j) { for (j = 0; j < This->num_contained_vs_consts_i; ++j) {
i = This->contained_vs_consts_i[j]; i = This->contained_vs_consts_i[j];
TRACE("Setting %p from %p %d to { %d, %d, %d, %d }\n", This, targetStateBlock, i, TRACE("Setting %p from %p %u to {%d, %d, %d, %d}\n", This, targetStateBlock, i,
targetStateBlock->vertexShaderConstantI[i * 4], targetStateBlock->vertexShaderConstantI[i * 4],
targetStateBlock->vertexShaderConstantI[i * 4 + 1], targetStateBlock->vertexShaderConstantI[i * 4 + 1],
targetStateBlock->vertexShaderConstantI[i * 4 + 2], targetStateBlock->vertexShaderConstantI[i * 4 + 2],
targetStateBlock->vertexShaderConstantI[i * 4 + 3]); targetStateBlock->vertexShaderConstantI[i * 4 + 3]);
This->vertexShaderConstantI[i * 4] = targetStateBlock->vertexShaderConstantI[i * 4]; This->vertexShaderConstantI[i * 4] = targetStateBlock->vertexShaderConstantI[i * 4];
This->vertexShaderConstantI[i * 4 + 1] = targetStateBlock->vertexShaderConstantI[i * 4 + 1]; This->vertexShaderConstantI[i * 4 + 1] = targetStateBlock->vertexShaderConstantI[i * 4 + 1];
@@ -429,8 +447,8 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
/* Vertex Shader Boolean Constants */ /* Vertex Shader Boolean Constants */
for (j = 0; j < This->num_contained_vs_consts_b; ++j) { for (j = 0; j < This->num_contained_vs_consts_b; ++j) {
i = This->contained_vs_consts_b[j]; i = This->contained_vs_consts_b[j];
TRACE("Setting %p from %p %d to %s\n", This, targetStateBlock, i, TRACE("Setting %p from %p %u to %s\n", This, targetStateBlock, i,
targetStateBlock->vertexShaderConstantB[i]? "TRUE":"FALSE"); targetStateBlock->vertexShaderConstantB[i] ? "TRUE" : "FALSE");
This->vertexShaderConstantB[i] = targetStateBlock->vertexShaderConstantB[i]; This->vertexShaderConstantB[i] = targetStateBlock->vertexShaderConstantB[i];
} }
@@ -438,11 +456,11 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
/* Pixel Shader Float Constants */ /* Pixel Shader Float Constants */
for (j = 0; j < This->num_contained_ps_consts_f; ++j) { for (j = 0; j < This->num_contained_ps_consts_f; ++j) {
i = This->contained_ps_consts_f[j]; i = This->contained_ps_consts_f[j];
TRACE("Setting %p from %p %d to { %f, %f, %f, %f }\n", This, targetStateBlock, i, TRACE("Setting %p from %p %u to {%f, %f, %f, %f}\n", This, targetStateBlock, i,
targetStateBlock->pixelShaderConstantF[i * 4], targetStateBlock->pixelShaderConstantF[i * 4],
targetStateBlock->pixelShaderConstantF[i * 4 + 1], targetStateBlock->pixelShaderConstantF[i * 4 + 1],
targetStateBlock->pixelShaderConstantF[i * 4 + 2], targetStateBlock->pixelShaderConstantF[i * 4 + 2],
targetStateBlock->pixelShaderConstantF[i * 4 + 3]); targetStateBlock->pixelShaderConstantF[i * 4 + 3]);
This->pixelShaderConstantF[i * 4] = targetStateBlock->pixelShaderConstantF[i * 4]; This->pixelShaderConstantF[i * 4] = targetStateBlock->pixelShaderConstantF[i * 4];
This->pixelShaderConstantF[i * 4 + 1] = targetStateBlock->pixelShaderConstantF[i * 4 + 1]; This->pixelShaderConstantF[i * 4 + 1] = targetStateBlock->pixelShaderConstantF[i * 4 + 1];
@@ -453,11 +471,11 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
/* Pixel Shader Integer Constants */ /* Pixel Shader Integer Constants */
for (j = 0; j < This->num_contained_ps_consts_i; ++j) { for (j = 0; j < This->num_contained_ps_consts_i; ++j) {
i = This->contained_ps_consts_i[j]; i = This->contained_ps_consts_i[j];
TRACE("Setting %p from %p %d to { %d, %d, %d, %d }\n", This, targetStateBlock, i, TRACE("Setting %p from %p %u to {%d, %d, %d, %d}\n", This, targetStateBlock, i,
targetStateBlock->pixelShaderConstantI[i * 4], targetStateBlock->pixelShaderConstantI[i * 4],
targetStateBlock->pixelShaderConstantI[i * 4 + 1], targetStateBlock->pixelShaderConstantI[i * 4 + 1],
targetStateBlock->pixelShaderConstantI[i * 4 + 2], targetStateBlock->pixelShaderConstantI[i * 4 + 2],
targetStateBlock->pixelShaderConstantI[i * 4 + 3]); targetStateBlock->pixelShaderConstantI[i * 4 + 3]);
This->pixelShaderConstantI[i * 4] = targetStateBlock->pixelShaderConstantI[i * 4]; This->pixelShaderConstantI[i * 4] = targetStateBlock->pixelShaderConstantI[i * 4];
This->pixelShaderConstantI[i * 4 + 1] = targetStateBlock->pixelShaderConstantI[i * 4 + 1]; This->pixelShaderConstantI[i * 4 + 1] = targetStateBlock->pixelShaderConstantI[i * 4 + 1];
@@ -468,23 +486,23 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
/* Pixel Shader Boolean Constants */ /* Pixel Shader Boolean Constants */
for (j = 0; j < This->num_contained_ps_consts_b; ++j) { for (j = 0; j < This->num_contained_ps_consts_b; ++j) {
i = This->contained_ps_consts_b[j]; i = This->contained_ps_consts_b[j];
TRACE("Setting %p from %p %d to %s\n", This, targetStateBlock, i, TRACE("Setting %p from %p %u to %s\n", This, targetStateBlock, i,
targetStateBlock->pixelShaderConstantB[i]? "TRUE":"FALSE"); targetStateBlock->pixelShaderConstantB[i] ? "TRUE" : "FALSE");
This->pixelShaderConstantB[i] = targetStateBlock->pixelShaderConstantB[i]; This->pixelShaderConstantB[i] = targetStateBlock->pixelShaderConstantB[i];
} }
/* Others + Render & Texture */ /* Others + Render & Texture */
for (i = 0; i < This->num_contained_transform_states; i++) { for (i = 0; i < This->num_contained_transform_states; i++) {
TRACE("Updating transform %d\n", i); TRACE("Updating transform %u\n", i);
This->transforms[This->contained_transform_states[i]] = This->transforms[This->contained_transform_states[i]] =
targetStateBlock->transforms[This->contained_transform_states[i]]; targetStateBlock->transforms[This->contained_transform_states[i]];
} }
if (This->changed.indices && ((This->pIndexData != targetStateBlock->pIndexData) if (This->changed.indices && ((This->pIndexData != targetStateBlock->pIndexData)
|| (This->baseVertexIndex != targetStateBlock->baseVertexIndex))) { || (This->baseVertexIndex != targetStateBlock->baseVertexIndex))) {
TRACE("Updating pindexData to %p, baseVertexIndex to %d\n", TRACE("Updating pIndexData to %p, baseVertexIndex to %d\n",
targetStateBlock->pIndexData, targetStateBlock->baseVertexIndex); targetStateBlock->pIndexData, targetStateBlock->baseVertexIndex);
if(targetStateBlock->pIndexData) IWineD3DIndexBuffer_AddRef(targetStateBlock->pIndexData); if(targetStateBlock->pIndexData) IWineD3DIndexBuffer_AddRef(targetStateBlock->pIndexData);
if(This->pIndexData) IWineD3DIndexBuffer_Release(This->pIndexData); if(This->pIndexData) IWineD3DIndexBuffer_Release(This->pIndexData);
This->pIndexData = targetStateBlock->pIndexData; This->pIndexData = targetStateBlock->pIndexData;
@@ -497,10 +515,6 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
This->vertexDecl = targetStateBlock->vertexDecl; This->vertexDecl = targetStateBlock->vertexDecl;
} }
if(This->changed.fvf && This->fvf != targetStateBlock->fvf){
This->fvf = targetStateBlock->fvf;
}
if (This->changed.material && memcmp(&targetStateBlock->material, if (This->changed.material && memcmp(&targetStateBlock->material,
&This->material, &This->material,
sizeof(WINED3DMATERIAL)) != 0) { sizeof(WINED3DMATERIAL)) != 0) {
@@ -523,43 +537,54 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
targetStateBlock->scissorRect = This->scissorRect; targetStateBlock->scissorRect = This->scissorRect;
} }
for (i = 0; i < MAX_STREAMS; i++) { map = This->changed.streamSource;
if (This->changed.streamSource[i] && for (i = 0; map; map >>= 1, ++i)
((This->streamStride[i] != targetStateBlock->streamStride[i]) || {
(This->streamSource[i] != targetStateBlock->streamSource[i]))) { if (!(map & 1)) continue;
TRACE("Updating stream source %d to %p, stride to %d\n", i, targetStateBlock->streamSource[i],
targetStateBlock->streamStride[i]); if (This->streamStride[i] != targetStateBlock->streamStride[i]
|| This->streamSource[i] != targetStateBlock->streamSource[i])
{
TRACE("Updating stream source %u to %p, stride to %u\n",
i, targetStateBlock->streamSource[i], targetStateBlock->streamStride[i]);
This->streamStride[i] = targetStateBlock->streamStride[i]; This->streamStride[i] = targetStateBlock->streamStride[i];
if(targetStateBlock->streamSource[i]) IWineD3DVertexBuffer_AddRef(targetStateBlock->streamSource[i]); if(targetStateBlock->streamSource[i]) IWineD3DVertexBuffer_AddRef(targetStateBlock->streamSource[i]);
if(This->streamSource[i]) IWineD3DVertexBuffer_Release(This->streamSource[i]); if(This->streamSource[i]) IWineD3DVertexBuffer_Release(This->streamSource[i]);
This->streamSource[i] = targetStateBlock->streamSource[i]; This->streamSource[i] = targetStateBlock->streamSource[i];
} }
}
if (This->changed.streamFreq[i] && map = This->changed.streamFreq;
(This->streamFreq[i] != targetStateBlock->streamFreq[i] for (i = 0; map; map >>= 1, ++i)
|| This->streamFlags[i] != targetStateBlock->streamFlags[i])){ {
TRACE("Updating stream frequency %d to %d flags to %d\n", i , targetStateBlock->streamFreq[i] , if (!(map & 1)) continue;
targetStateBlock->streamFlags[i]);
This->streamFreq[i] = targetStateBlock->streamFreq[i]; if (This->streamFreq[i] != targetStateBlock->streamFreq[i]
This->streamFlags[i] = targetStateBlock->streamFlags[i]; || This->streamFlags[i] != targetStateBlock->streamFlags[i])
{
TRACE("Updating stream frequency %u to %u flags to %#x\n",
i, targetStateBlock->streamFreq[i], targetStateBlock->streamFlags[i]);
This->streamFreq[i] = targetStateBlock->streamFreq[i];
This->streamFlags[i] = targetStateBlock->streamFlags[i];
} }
} }
for (i = 0; i < GL_LIMITS(clipplanes); i++) { map = This->changed.clipplane;
if (This->changed.clipplane[i] && memcmp(&targetStateBlock->clipplane[i], for (i = 0; map; map >>= 1, ++i)
&This->clipplane[i], {
sizeof(This->clipplane)) != 0) { if (!(map & 1)) continue;
TRACE("Updating clipplane %d\n", i); if (memcmp(targetStateBlock->clipplane[i], This->clipplane[i], sizeof(*This->clipplane)))
memcpy(&This->clipplane[i], &targetStateBlock->clipplane[i], {
sizeof(This->clipplane)); TRACE("Updating clipplane %u\n", i);
memcpy(This->clipplane[i], targetStateBlock->clipplane[i], sizeof(*This->clipplane));
} }
} }
/* Render */ /* Render */
for (i = 0; i < This->num_contained_render_states; i++) { for (i = 0; i < This->num_contained_render_states; i++) {
TRACE("Updating renderState %d to %d\n", TRACE("Updating renderState %u to %u\n", This->contained_render_states[i],
This->contained_render_states[i], targetStateBlock->renderState[This->contained_render_states[i]]); targetStateBlock->renderState[This->contained_render_states[i]]);
This->renderState[This->contained_render_states[i]] = targetStateBlock->renderState[This->contained_render_states[i]]; This->renderState[This->contained_render_states[i]] = targetStateBlock->renderState[This->contained_render_states[i]];
} }
@@ -568,26 +593,27 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
DWORD stage = This->contained_tss_states[j].stage; DWORD stage = This->contained_tss_states[j].stage;
DWORD state = This->contained_tss_states[j].state; DWORD state = This->contained_tss_states[j].state;
TRACE("Updating texturestagestate %d,%d to %d (was %d)\n", stage,state, TRACE("Updating texturestage state %u, %u to %u (was %u)\n", stage, state,
targetStateBlock->textureState[stage][state], This->textureState[stage][state]); targetStateBlock->textureState[stage][state], This->textureState[stage][state]);
This->textureState[stage][state] = targetStateBlock->textureState[stage][state]; This->textureState[stage][state] = targetStateBlock->textureState[stage][state];
} }
/* Samplers */ /* Samplers */
/* TODO: move over to using memcpy */ /* TODO: move over to using memcpy */
for (j = 0; j < MAX_COMBINED_SAMPLERS; j++) { map = This->changed.textures;
if (This->changed.textures[j]) { for (i = 0; map; map >>= 1, ++i)
TRACE("Updating texture %d to %p (was %p)\n", j, targetStateBlock->textures[j], This->textures[j]); {
This->textures[j] = targetStateBlock->textures[j]; if (!(map & 1)) continue;
}
TRACE("Updating texture %u to %p (was %p)\n", i, targetStateBlock->textures[i], This->textures[i]);
This->textures[i] = targetStateBlock->textures[i];
} }
for (j = 0; j < This->num_contained_sampler_states; j++) { for (j = 0; j < This->num_contained_sampler_states; j++) {
DWORD stage = This->contained_sampler_states[j].stage; DWORD stage = This->contained_sampler_states[j].stage;
DWORD state = This->contained_sampler_states[j].state; DWORD state = This->contained_sampler_states[j].state;
TRACE("Updating sampler state %d,%d to %d (was %d)\n", TRACE("Updating sampler state %u, %u to %u (was %u)\n", stage, state,
stage, state, targetStateBlock->samplerState[stage][state], targetStateBlock->samplerState[stage][state], This->samplerState[stage][state]);
This->samplerState[stage][state]);
This->samplerState[stage][state] = targetStateBlock->samplerState[stage][state]; This->samplerState[stage][state] = targetStateBlock->samplerState[stage][state];
} }
if(This->changed.pixelShader && This->pixelShader != targetStateBlock->pixelShader) { if(This->changed.pixelShader && This->pixelShader != targetStateBlock->pixelShader) {
@@ -618,7 +644,6 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
memcpy(This->pixelShaderConstantF, targetStateBlock->pixelShaderConstantF, sizeof(float) * GL_LIMITS(pshader_constantsF) * 4); memcpy(This->pixelShaderConstantF, targetStateBlock->pixelShaderConstantF, sizeof(float) * GL_LIMITS(pshader_constantsF) * 4);
memcpy(This->renderState, targetStateBlock->renderState, sizeof(This->renderState)); memcpy(This->renderState, targetStateBlock->renderState, sizeof(This->renderState));
memcpy(This->textures, targetStateBlock->textures, sizeof(This->textures)); memcpy(This->textures, targetStateBlock->textures, sizeof(This->textures));
memcpy(This->textureDimensions, targetStateBlock->textureDimensions, sizeof(This->textureDimensions));
memcpy(This->textureState, targetStateBlock->textureState, sizeof(This->textureState)); memcpy(This->textureState, targetStateBlock->textureState, sizeof(This->textureState));
memcpy(This->samplerState, targetStateBlock->samplerState, sizeof(This->samplerState)); memcpy(This->samplerState, targetStateBlock->samplerState, sizeof(This->samplerState));
This->scissorRect = targetStateBlock->scissorRect; This->scissorRect = targetStateBlock->scissorRect;
@@ -710,7 +735,7 @@ static inline void apply_lights(IWineD3DDevice *pDevice, IWineD3DStateBlockImpl
struct list *e; struct list *e;
LIST_FOR_EACH(e, &This->lightMap[i]) { LIST_FOR_EACH(e, &This->lightMap[i]) {
PLIGHTINFOEL *light = LIST_ENTRY(e, PLIGHTINFOEL, entry); const PLIGHTINFOEL *light = LIST_ENTRY(e, PLIGHTINFOEL, entry);
if(light->changed) { if(light->changed) {
IWineD3DDevice_SetLight(pDevice, light->OriginalIndex, &light->OriginalParms); IWineD3DDevice_SetLight(pDevice, light->OriginalIndex, &light->OriginalParms);
@@ -731,6 +756,7 @@ should really perform a delta so that only the changes get updated*/
UINT i; UINT i;
UINT j; UINT j;
DWORD map;
TRACE("(%p) : Applying state block %p ------------------v\n", This, pDevice); TRACE("(%p) : Applying state block %p ------------------v\n", This, pDevice);
@@ -783,7 +809,7 @@ should really perform a delta so that only the changes get updated*/
DWORD stage = This->contained_tss_states[i].stage; DWORD stage = This->contained_tss_states[i].stage;
DWORD state = This->contained_tss_states[i].state; DWORD state = This->contained_tss_states[i].state;
((IWineD3DDeviceImpl *)pDevice)->stateBlock->textureState[stage][state] = This->textureState[stage][state]; ((IWineD3DDeviceImpl *)pDevice)->stateBlock->textureState[stage][state] = This->textureState[stage][state];
((IWineD3DDeviceImpl *)pDevice)->stateBlock->changed.textureState[stage][state] = TRUE; ((IWineD3DDeviceImpl *)pDevice)->stateBlock->changed.textureState[stage] |= 1 << state;
/* TODO: Record a display list to apply all gl states. For now apply by brute force */ /* TODO: Record a display list to apply all gl states. For now apply by brute force */
IWineD3DDeviceImpl_MarkStateDirty((IWineD3DDeviceImpl *)pDevice, STATE_TEXTURESTAGE(stage, state)); IWineD3DDeviceImpl_MarkStateDirty((IWineD3DDeviceImpl *)pDevice, STATE_TEXTURESTAGE(stage, state));
} }
@@ -792,7 +818,7 @@ should really perform a delta so that only the changes get updated*/
DWORD stage = This->contained_sampler_states[i].stage; DWORD stage = This->contained_sampler_states[i].stage;
DWORD state = This->contained_sampler_states[i].state; DWORD state = This->contained_sampler_states[i].state;
((IWineD3DDeviceImpl *)pDevice)->stateBlock->samplerState[stage][state] = This->samplerState[stage][state]; ((IWineD3DDeviceImpl *)pDevice)->stateBlock->samplerState[stage][state] = This->samplerState[stage][state];
((IWineD3DDeviceImpl *)pDevice)->stateBlock->changed.samplerState[stage][state] = TRUE; ((IWineD3DDeviceImpl *)pDevice)->stateBlock->changed.samplerState[stage] |= 1 << state;
IWineD3DDeviceImpl_MarkStateDirty((IWineD3DDeviceImpl *)pDevice, STATE_SAMPLER(stage)); IWineD3DDeviceImpl_MarkStateDirty((IWineD3DDeviceImpl *)pDevice, STATE_SAMPLER(stage));
} }
@@ -806,10 +832,6 @@ should really perform a delta so that only the changes get updated*/
IWineD3DDevice_SetBaseVertexIndex(pDevice, This->baseVertexIndex); IWineD3DDevice_SetBaseVertexIndex(pDevice, This->baseVertexIndex);
} }
if (This->changed.fvf) {
IWineD3DDevice_SetFVF(pDevice, This->fvf);
}
if (This->changed.vertexDecl) { if (This->changed.vertexDecl) {
IWineD3DDevice_SetVertexDeclaration(pDevice, This->vertexDecl); IWineD3DDevice_SetVertexDeclaration(pDevice, This->vertexDecl);
} }
@@ -827,35 +849,41 @@ should really perform a delta so that only the changes get updated*/
} }
/* TODO: Proper implementation using SetStreamSource offset (set to 0 for the moment)\n") */ /* TODO: Proper implementation using SetStreamSource offset (set to 0 for the moment)\n") */
for (i=0; i<MAX_STREAMS; i++) { map = This->changed.streamSource;
if (This->changed.streamSource[i]) for (i = 0; map; map >>= 1, ++i)
IWineD3DDevice_SetStreamSource(pDevice, i, This->streamSource[i], 0, This->streamStride[i]); {
if (map & 1) IWineD3DDevice_SetStreamSource(pDevice, i, This->streamSource[i], 0, This->streamStride[i]);
if (This->changed.streamFreq[i])
IWineD3DDevice_SetStreamSourceFreq(pDevice, i, This->streamFreq[i] | This->streamFlags[i]);
}
for (j = 0 ; j < MAX_COMBINED_SAMPLERS; j++){
if (This->changed.textures[j]) {
if (j < MAX_FRAGMENT_SAMPLERS) {
IWineD3DDevice_SetTexture(pDevice, j, This->textures[j]);
} else {
IWineD3DDevice_SetTexture(pDevice, WINED3DVERTEXTEXTURESAMPLER0 + j - MAX_FRAGMENT_SAMPLERS, This->textures[j]);
}
}
} }
for (i = 0; i < GL_LIMITS(clipplanes); i++) { map = This->changed.streamFreq;
if (This->changed.clipplane[i]) { for (i = 0; map; map >>= 1, ++i)
float clip[4]; {
if (map & 1) IWineD3DDevice_SetStreamSourceFreq(pDevice, i, This->streamFreq[i] | This->streamFlags[i]);
clip[0] = This->clipplane[i][0];
clip[1] = This->clipplane[i][1];
clip[2] = This->clipplane[i][2];
clip[3] = This->clipplane[i][3];
IWineD3DDevice_SetClipPlane(pDevice, i, clip);
}
} }
map = This->changed.textures;
for (i = 0; map; map >>= 1, ++i)
{
if (!(map & 1)) continue;
if (i < MAX_FRAGMENT_SAMPLERS) IWineD3DDevice_SetTexture(pDevice, i, This->textures[i]);
else IWineD3DDevice_SetTexture(pDevice, WINED3DVERTEXTEXTURESAMPLER0 + i - MAX_FRAGMENT_SAMPLERS,
This->textures[i]);
}
map = This->changed.clipplane;
for (i = 0; map; map >>= 1, ++i)
{
float clip[4];
if (!(map & 1)) continue;
clip[0] = This->clipplane[i][0];
clip[1] = This->clipplane[i][1];
clip[2] = This->clipplane[i][2];
clip[3] = This->clipplane[i][3];
IWineD3DDevice_SetClipPlane(pDevice, i, clip);
}
} else if(This->blockType == WINED3DSBT_VERTEXSTATE) { } else if(This->blockType == WINED3DSBT_VERTEXSTATE) {
IWineD3DDevice_SetVertexShader(pDevice, This->vertexShader); IWineD3DDevice_SetVertexShader(pDevice, This->vertexShader);
for (i = 0; i < GL_LIMITS(vshader_constantsF); i++) { for (i = 0; i < GL_LIMITS(vshader_constantsF); i++) {
@@ -971,7 +999,8 @@ should really perform a delta so that only the changes get updated*/
IWineD3DDevice_SetRenderState(pDevice, i, This->renderState[i]); IWineD3DDevice_SetRenderState(pDevice, i, This->renderState[i]);
} }
for(j = 0; j < MAX_TEXTURES; j++) { for(j = 0; j < MAX_TEXTURES; j++) {
for(i = 1; i <= WINED3D_HIGHEST_TEXTURE_STATE; i++) { for (i = 0; i <= WINED3D_HIGHEST_TEXTURE_STATE; ++i)
{
IWineD3DDevice_SetTextureStageState(pDevice, j, i, This->textureState[j][i]); IWineD3DDevice_SetTextureStageState(pDevice, j, i, This->textureState[j][i]);
} }
} }
@@ -982,7 +1011,6 @@ should really perform a delta so that only the changes get updated*/
} }
IWineD3DDevice_SetIndices(pDevice, This->pIndexData); IWineD3DDevice_SetIndices(pDevice, This->pIndexData);
IWineD3DDevice_SetBaseVertexIndex(pDevice, This->baseVertexIndex); IWineD3DDevice_SetBaseVertexIndex(pDevice, This->baseVertexIndex);
IWineD3DDevice_SetFVF(pDevice, This->fvf);
IWineD3DDevice_SetVertexDeclaration(pDevice, This->vertexDecl); IWineD3DDevice_SetVertexDeclaration(pDevice, This->vertexDecl);
IWineD3DDevice_SetMaterial(pDevice, &This->material); IWineD3DDevice_SetMaterial(pDevice, &This->material);
IWineD3DDevice_SetViewport(pDevice, &This->viewport); IWineD3DDevice_SetViewport(pDevice, &This->viewport);
@@ -997,7 +1025,8 @@ should really perform a delta so that only the changes get updated*/
UINT sampler = j < MAX_FRAGMENT_SAMPLERS ? j : WINED3DVERTEXTEXTURESAMPLER0 + j - MAX_FRAGMENT_SAMPLERS; UINT sampler = j < MAX_FRAGMENT_SAMPLERS ? j : WINED3DVERTEXTEXTURESAMPLER0 + j - MAX_FRAGMENT_SAMPLERS;
IWineD3DDevice_SetTexture(pDevice, sampler, This->textures[j]); IWineD3DDevice_SetTexture(pDevice, sampler, This->textures[j]);
for(i = 1; i < WINED3D_HIGHEST_SAMPLER_STATE; i++) { for (i = 1; i <= WINED3D_HIGHEST_SAMPLER_STATE; ++i)
{
IWineD3DDevice_SetSamplerState(pDevice, sampler, i, This->samplerState[j][i]); IWineD3DDevice_SetSamplerState(pDevice, sampler, i, This->samplerState[j][i]);
} }
} }
@@ -1128,7 +1157,7 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStat
IWineD3DDevice_SetRenderState(device, WINED3DRS_SOFTWAREVERTEXPROCESSING, FALSE); IWineD3DDevice_SetRenderState(device, WINED3DRS_SOFTWAREVERTEXPROCESSING, FALSE);
tmpfloat.f = 1.0f; tmpfloat.f = 1.0f;
IWineD3DDevice_SetRenderState(device, WINED3DRS_POINTSIZE, tmpfloat.d); IWineD3DDevice_SetRenderState(device, WINED3DRS_POINTSIZE, tmpfloat.d);
tmpfloat.f = 1.0f; tmpfloat.f = ((IWineD3DImpl *)This->wineD3DDevice->wineD3D)->dxVersion < 9 ? 0.0f : 1.0f;
IWineD3DDevice_SetRenderState(device, WINED3DRS_POINTSIZE_MIN, tmpfloat.d); IWineD3DDevice_SetRenderState(device, WINED3DRS_POINTSIZE_MIN, tmpfloat.d);
IWineD3DDevice_SetRenderState(device, WINED3DRS_POINTSPRITEENABLE, FALSE); IWineD3DDevice_SetRenderState(device, WINED3DRS_POINTSPRITEENABLE, FALSE);
IWineD3DDevice_SetRenderState(device, WINED3DRS_POINTSCALEENABLE, FALSE); IWineD3DDevice_SetRenderState(device, WINED3DRS_POINTSCALEENABLE, FALSE);
@@ -1144,7 +1173,7 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStat
tmpfloat.f = 1.0f; tmpfloat.f = 1.0f;
IWineD3DDevice_SetRenderState(device, WINED3DRS_PATCHSEGMENTS, tmpfloat.d); IWineD3DDevice_SetRenderState(device, WINED3DRS_PATCHSEGMENTS, tmpfloat.d);
IWineD3DDevice_SetRenderState(device, WINED3DRS_DEBUGMONITORTOKEN, 0xbaadcafe); IWineD3DDevice_SetRenderState(device, WINED3DRS_DEBUGMONITORTOKEN, 0xbaadcafe);
tmpfloat.f = 64.0f; tmpfloat.f = GL_LIMITS(pointsize);
IWineD3DDevice_SetRenderState(device, WINED3DRS_POINTSIZE_MAX, tmpfloat.d); IWineD3DDevice_SetRenderState(device, WINED3DRS_POINTSIZE_MAX, tmpfloat.d);
IWineD3DDevice_SetRenderState(device, WINED3DRS_INDEXEDVERTEXBLENDENABLE, FALSE); IWineD3DDevice_SetRenderState(device, WINED3DRS_INDEXEDVERTEXBLENDENABLE, FALSE);
IWineD3DDevice_SetRenderState(device, WINED3DRS_COLORWRITEENABLE, 0x0000000F); IWineD3DDevice_SetRenderState(device, WINED3DRS_COLORWRITEENABLE, 0x0000000F);
@@ -1214,7 +1243,6 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStat
This->textureState[i][WINED3DTSS_BUMPENVLSCALE ] = 0; This->textureState[i][WINED3DTSS_BUMPENVLSCALE ] = 0;
This->textureState[i][WINED3DTSS_BUMPENVLOFFSET ] = 0; This->textureState[i][WINED3DTSS_BUMPENVLOFFSET ] = 0;
This->textureState[i][WINED3DTSS_TEXTURETRANSFORMFLAGS ] = WINED3DTTFF_DISABLE; This->textureState[i][WINED3DTSS_TEXTURETRANSFORMFLAGS ] = WINED3DTTFF_DISABLE;
This->textureState[i][WINED3DTSS_ADDRESSW ] = WINED3DTADDRESS_WRAP;
This->textureState[i][WINED3DTSS_COLORARG0 ] = WINED3DTA_CURRENT; This->textureState[i][WINED3DTSS_COLORARG0 ] = WINED3DTA_CURRENT;
This->textureState[i][WINED3DTSS_ALPHAARG0 ] = WINED3DTA_CURRENT; This->textureState[i][WINED3DTSS_ALPHAARG0 ] = WINED3DTA_CURRENT;
This->textureState[i][WINED3DTSS_RESULTARG ] = WINED3DTA_CURRENT; This->textureState[i][WINED3DTSS_RESULTARG ] = WINED3DTA_CURRENT;
@@ -1241,7 +1269,7 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStat
for(i = 0; i < GL_LIMITS(textures); i++) { for(i = 0; i < GL_LIMITS(textures); i++) {
/* Note: This avoids calling SetTexture, so pretend it has been called */ /* Note: This avoids calling SetTexture, so pretend it has been called */
This->changed.textures[i] = TRUE; This->changed.textures |= 1 << i;
This->textures[i] = NULL; This->textures[i] = NULL;
} }
@@ -1252,6 +1280,8 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStat
/* check the return values, because the GetBackBuffer call isn't valid for ddraw */ /* check the return values, because the GetBackBuffer call isn't valid for ddraw */
hr = IWineD3DDevice_GetSwapChain(device, 0, &swapchain); hr = IWineD3DDevice_GetSwapChain(device, 0, &swapchain);
if( hr == WINED3D_OK && swapchain != NULL) { if( hr == WINED3D_OK && swapchain != NULL) {
WINED3DVIEWPORT vp;
hr = IWineD3DSwapChain_GetBackBuffer(swapchain, 0, WINED3DBACKBUFFER_TYPE_MONO, &backbuffer); hr = IWineD3DSwapChain_GetBackBuffer(swapchain, 0, WINED3DBACKBUFFER_TYPE_MONO, &backbuffer);
if( hr == WINED3D_OK && backbuffer != NULL) { if( hr == WINED3D_OK && backbuffer != NULL) {
IWineD3DSurface_GetDesc(backbuffer, &desc); IWineD3DSurface_GetDesc(backbuffer, &desc);
@@ -1266,6 +1296,16 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStat
ERR("This should never happen, expect rendering issues!\n"); ERR("This should never happen, expect rendering issues!\n");
} }
} }
/* Set the default viewport */
vp.X = 0;
vp.Y = 0;
vp.Width = ((IWineD3DSwapChainImpl *)swapchain)->presentParms.BackBufferWidth;
vp.Height = ((IWineD3DSwapChainImpl *)swapchain)->presentParms.BackBufferHeight;
vp.MinZ = 0.0f;
vp.MaxZ = 1.0f;
IWineD3DDevice_SetViewport(device, &vp);
IWineD3DSwapChain_Release(swapchain); IWineD3DSwapChain_Release(swapchain);
} }

View File

@@ -31,12 +31,11 @@
#include "wined3d_private.h" #include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface); WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
WINE_DECLARE_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info #define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height, UINT outpitch, CONVERT_TYPES convert, IWineD3DSurfaceImpl *surf);
static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4], BOOL colorkey); static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4], BOOL colorkey);
static void d3dfmt_p8_upload_palette(IWineD3DSurface *iface, CONVERT_TYPES convert); static void d3dfmt_p8_upload_palette(IWineD3DSurface *iface, CONVERT_TYPES convert);
static inline void clear_unused_channels(IWineD3DSurfaceImpl *This);
static void surface_remove_pbo(IWineD3DSurfaceImpl *This); static void surface_remove_pbo(IWineD3DSurfaceImpl *This);
void surface_force_reload(IWineD3DSurface *iface) void surface_force_reload(IWineD3DSurface *iface)
@@ -100,15 +99,11 @@ static void surface_bind_and_dirtify(IWineD3DSurfaceImpl *This) {
* *
* TODO: Track the current active texture per GL context instead of using glGet * TODO: Track the current active texture per GL context instead of using glGet
*/ */
if (GL_SUPPORT(ARB_MULTITEXTURE)) { GLint active_texture;
GLint active_texture; ENTER_GL();
ENTER_GL(); glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); LEAVE_GL();
LEAVE_GL(); active_sampler = This->resource.wineD3DDevice->rev_tex_unit_map[active_texture - GL_TEXTURE0_ARB];
active_sampler = This->resource.wineD3DDevice->rev_tex_unit_map[active_texture - GL_TEXTURE0_ARB];
} else {
active_sampler = 0;
}
if (active_sampler != -1) { if (active_sampler != -1) {
IWineD3DDeviceImpl_MarkStateDirty(This->resource.wineD3DDevice, STATE_SAMPLER(active_sampler)); IWineD3DDeviceImpl_MarkStateDirty(This->resource.wineD3DDevice, STATE_SAMPLER(active_sampler));
@@ -210,8 +205,9 @@ static void surface_download_data(IWineD3DSurfaceImpl *This) {
LEAVE_GL(); LEAVE_GL();
if (This->Flags & SFLAG_NONPOW2) { if (This->Flags & SFLAG_NONPOW2) {
LPBYTE src_data, dst_data; const BYTE *src_data;
int y; BYTE *dst_data;
UINT y;
/* /*
* Some games (e.g. warhammer 40k) don't work properly with the odd pitches, preventing * Some games (e.g. warhammer 40k) don't work properly with the odd pitches, preventing
* the surface pitch from being used to box non-power2 textures. Instead we have to use a hack to * the surface pitch from being used to box non-power2 textures. Instead we have to use a hack to
@@ -346,7 +342,7 @@ static void surface_upload_data(IWineD3DSurfaceImpl *This, GLenum internal, GLsi
* activating the right context and binding the correct texture. */ * activating the right context and binding the correct texture. */
static void surface_allocate_surface(IWineD3DSurfaceImpl *This, GLenum internal, GLsizei width, GLsizei height, GLenum format, GLenum type) { static void surface_allocate_surface(IWineD3DSurfaceImpl *This, GLenum internal, GLsizei width, GLsizei height, GLenum format, GLenum type) {
BOOL enable_client_storage = FALSE; BOOL enable_client_storage = FALSE;
BYTE *mem = NULL; const BYTE *mem = NULL;
if(This->heightscale != 1.0 && This->heightscale != 0.0) height *= This->heightscale; if(This->heightscale != 1.0 && This->heightscale != 0.0) height *= This->heightscale;
@@ -443,7 +439,7 @@ void surface_set_compatible_renderbuffer(IWineD3DSurface *iface, unsigned int wi
} }
if (!renderbuffer) { if (!renderbuffer) {
const GlPixelFormatDesc *glDesc; const struct GlPixelFormatDesc *glDesc;
getFormatDescEntry(This->resource.format, &GLINFO_LOCATION, &glDesc); getFormatDescEntry(This->resource.format, &GLINFO_LOCATION, &glDesc);
GL_EXTCALL(glGenRenderbuffersEXT(1, &renderbuffer)); GL_EXTCALL(glGenRenderbuffersEXT(1, &renderbuffer));
@@ -480,7 +476,45 @@ GLenum surface_get_gl_buffer(IWineD3DSurface *iface, IWineD3DSwapChain *swapchai
return GL_BACK; return GL_BACK;
} }
ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface) { /* Slightly inefficient way to handle multiple dirty rects but it works :) */
void surface_add_dirty_rect(IWineD3DSurface *iface, const RECT *dirty_rect)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
IWineD3DBaseTexture *baseTexture = NULL;
if (!(This->Flags & SFLAG_INSYSMEM) && (This->Flags & SFLAG_INTEXTURE))
IWineD3DSurface_LoadLocation(iface, SFLAG_INSYSMEM, NULL /* no partial locking for textures yet */);
IWineD3DSurface_ModifyLocation(iface, SFLAG_INSYSMEM, TRUE);
if (dirty_rect)
{
This->dirtyRect.left = min(This->dirtyRect.left, dirty_rect->left);
This->dirtyRect.top = min(This->dirtyRect.top, dirty_rect->top);
This->dirtyRect.right = max(This->dirtyRect.right, dirty_rect->right);
This->dirtyRect.bottom = max(This->dirtyRect.bottom, dirty_rect->bottom);
}
else
{
This->dirtyRect.left = 0;
This->dirtyRect.top = 0;
This->dirtyRect.right = This->currentDesc.Width;
This->dirtyRect.bottom = This->currentDesc.Height;
}
TRACE("(%p) : Dirty: yes, Rect:(%d, %d, %d, %d)\n", This, This->dirtyRect.left,
This->dirtyRect.top, This->dirtyRect.right, This->dirtyRect.bottom);
/* if the container is a basetexture then mark it dirty. */
if (SUCCEEDED(IWineD3DSurface_GetContainer(iface, &IID_IWineD3DBaseTexture, (void **)&baseTexture)))
{
TRACE("Passing to container\n");
IWineD3DBaseTexture_SetDirty(baseTexture, TRUE);
IWineD3DBaseTexture_Release(baseTexture);
}
}
static ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
ULONG ref = InterlockedDecrement(&This->resource.ref); ULONG ref = InterlockedDecrement(&This->resource.ref);
TRACE("(%p) : Releasing from %d\n", This, ref + 1); TRACE("(%p) : Releasing from %d\n", This, ref + 1);
@@ -527,7 +561,7 @@ ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface) {
HeapFree(GetProcessHeap(), 0, This->palette9); HeapFree(GetProcessHeap(), 0, This->palette9);
IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface); resource_cleanup((IWineD3DResource *)iface);
if(This->overlay_dest) { if(This->overlay_dest) {
list_remove(&This->overlay_entry); list_remove(&This->overlay_entry);
@@ -544,7 +578,8 @@ ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface) {
IWineD3DSurface IWineD3DResource parts follow IWineD3DSurface IWineD3DResource parts follow
**************************************************** */ **************************************************** */
void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface) { static void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface)
{
/* TODO: check for locks */ /* TODO: check for locks */
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
IWineD3DBaseTexture *baseTexture = NULL; IWineD3DBaseTexture *baseTexture = NULL;
@@ -674,22 +709,13 @@ static void WINAPI IWineD3DSurfaceImpl_UnLoad(IWineD3DSurface *iface) {
IWineD3DSurface IWineD3DSurface parts follow IWineD3DSurface IWineD3DSurface parts follow
****************************************************** */ ****************************************************** */
void WINAPI IWineD3DSurfaceImpl_GetGlDesc(IWineD3DSurface *iface, glDescriptor **glDescription) { static void WINAPI IWineD3DSurfaceImpl_GetGlDesc(IWineD3DSurface *iface, glDescriptor **glDescription)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
TRACE("(%p) : returning %p\n", This, &This->glDescription); TRACE("(%p) : returning %p\n", This, &This->glDescription);
*glDescription = &This->glDescription; *glDescription = &This->glDescription;
} }
/* TODO: think about moving this down to resource? */
const void *WINAPI IWineD3DSurfaceImpl_GetData(IWineD3DSurface *iface) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
/* This should only be called for sysmem textures, it may be a good idea to extend this to all pools at some point in the future */
if (This->resource.pool != WINED3DPOOL_SYSTEMMEM) {
FIXME(" (%p)Attempting to get system memory for a non-system memory texture\n", iface);
}
return (CONST void*)(This->resource.allocatedMemory);
}
/* Read the framebuffer back into the surface */ /* Read the framebuffer back into the surface */
static void read_from_framebuffer(IWineD3DSurfaceImpl *This, CONST RECT *rect, void *dest, UINT pitch) { static void read_from_framebuffer(IWineD3DSurfaceImpl *This, CONST RECT *rect, void *dest, UINT pitch) {
IWineD3DSwapChainImpl *swapchain; IWineD3DSwapChainImpl *swapchain;
@@ -702,6 +728,9 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, CONST RECT *rect, v
BOOL bpp; BOOL bpp;
RECT local_rect; RECT local_rect;
BOOL srcIsUpsideDown; BOOL srcIsUpsideDown;
GLint rowLen = 0;
GLint skipPix = 0;
GLint skipRow = 0;
if(wined3d_settings.rendertargetlock_mode == RTL_DISABLE) { if(wined3d_settings.rendertargetlock_mode == RTL_DISABLE) {
static BOOL warned = FALSE; static BOOL warned = FALSE;
@@ -797,13 +826,41 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, CONST RECT *rect, v
if(This->Flags & SFLAG_PBO) { if(This->Flags & SFLAG_PBO) {
GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, This->pbo)); GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, This->pbo));
checkGLcall("glBindBufferARB"); checkGLcall("glBindBufferARB");
if(mem != NULL) {
ERR("mem not null for pbo -- unexpected\n");
mem = NULL;
}
} }
glReadPixels(local_rect.left, local_rect.top, /* Save old pixel store pack state */
glGetIntegerv(GL_PACK_ROW_LENGTH, &rowLen);
checkGLcall("glIntegerv");
glGetIntegerv(GL_PACK_SKIP_PIXELS, &skipPix);
checkGLcall("glIntegerv");
glGetIntegerv(GL_PACK_SKIP_ROWS, &skipRow);
checkGLcall("glIntegerv");
/* Setup pixel store pack state -- to glReadPixels into the correct place */
glPixelStorei(GL_PACK_ROW_LENGTH, This->currentDesc.Width);
checkGLcall("glPixelStorei");
glPixelStorei(GL_PACK_SKIP_PIXELS, local_rect.left);
checkGLcall("glPixelStorei");
glPixelStorei(GL_PACK_SKIP_ROWS, local_rect.top);
checkGLcall("glPixelStorei");
glReadPixels(local_rect.left, (!srcIsUpsideDown) ? (This->currentDesc.Height - local_rect.bottom) : local_rect.top ,
local_rect.right - local_rect.left, local_rect.right - local_rect.left,
local_rect.bottom - local_rect.top, local_rect.bottom - local_rect.top,
fmt, type, mem); fmt, type, mem);
vcheckGLcall("glReadPixels"); checkGLcall("glReadPixels");
/* Reset previous pixel store pack state */
glPixelStorei(GL_PACK_ROW_LENGTH, rowLen);
checkGLcall("glPixelStorei");
glPixelStorei(GL_PACK_SKIP_PIXELS, skipPix);
checkGLcall("glPixelStorei");
glPixelStorei(GL_PACK_SKIP_ROWS, skipRow);
checkGLcall("glPixelStorei");
if(This->Flags & SFLAG_PBO) { if(This->Flags & SFLAG_PBO) {
GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0)); GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0));
@@ -839,7 +896,7 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, CONST RECT *rect, v
} }
top = mem + pitch * local_rect.top; top = mem + pitch * local_rect.top;
bottom = mem + pitch * ( local_rect.bottom - local_rect.top - 1); bottom = mem + pitch * (local_rect.bottom - 1);
for(i = 0; i < (local_rect.bottom - local_rect.top) / 2; i++) { for(i = 0; i < (local_rect.bottom - local_rect.top) / 2; i++) {
memcpy(row, top + off, len); memcpy(row, top + off, len);
memcpy(top + off, bottom + off, len); memcpy(top + off, bottom + off, len);
@@ -864,7 +921,7 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, CONST RECT *rect, v
* In case of P8 render targets, the index is stored in the alpha component so no conversion is needed. * In case of P8 render targets, the index is stored in the alpha component so no conversion is needed.
*/ */
if((This->resource.format == WINED3DFMT_P8) && !primary_render_target_is_p8(myDevice)) { if((This->resource.format == WINED3DFMT_P8) && !primary_render_target_is_p8(myDevice)) {
PALETTEENTRY *pal = NULL; const PALETTEENTRY *pal = NULL;
DWORD width = pitch / 3; DWORD width = pitch / 3;
int x, y, c; int x, y, c;
@@ -879,9 +936,9 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, CONST RECT *rect, v
for(y = local_rect.top; y < local_rect.bottom; y++) { for(y = local_rect.top; y < local_rect.bottom; y++) {
for(x = local_rect.left; x < local_rect.right; x++) { for(x = local_rect.left; x < local_rect.right; x++) {
/* start lines pixels */ /* start lines pixels */
BYTE *blue = mem + y * pitch + x * (sizeof(BYTE) * 3); const BYTE *blue = mem + y * pitch + x * (sizeof(BYTE) * 3);
BYTE *green = blue + 1; const BYTE *green = blue + 1;
BYTE *red = green + 1; const BYTE *red = green + 1;
for(c = 0; c < 256; c++) { for(c = 0; c < 256; c++) {
if(*red == pal[c].peRed && if(*red == pal[c].peRed &&
@@ -943,6 +1000,7 @@ static void read_from_framebuffer_texture(IWineD3DSurfaceImpl *This)
TRACE("Locking offscreen render target\n"); TRACE("Locking offscreen render target\n");
ENTER_GL(); ENTER_GL();
glReadBuffer(device->offscreenBuffer); glReadBuffer(device->offscreenBuffer);
checkGLcall("glReadBuffer");
LEAVE_GL(); LEAVE_GL();
} }
@@ -951,8 +1009,6 @@ static void read_from_framebuffer_texture(IWineD3DSurfaceImpl *This)
This->pow2Height, format, type); This->pow2Height, format, type);
} }
clear_unused_channels(This);
ENTER_GL(); ENTER_GL();
/* If !SrcIsUpsideDown we should flip the surface. /* If !SrcIsUpsideDown we should flip the surface.
* This can be done using glCopyTexSubImage2D but this * This can be done using glCopyTexSubImage2D but this
@@ -968,7 +1024,7 @@ static void read_from_framebuffer_texture(IWineD3DSurfaceImpl *This)
checkGLcall("glCopyTexSubImage2D"); checkGLcall("glCopyTexSubImage2D");
glReadBuffer(prevRead); glReadBuffer(prevRead);
vcheckGLcall("glReadBuffer"); checkGLcall("glReadBuffer");
LEAVE_GL(); LEAVE_GL();
TRACE("Updated target %d\n", This->glDescription.target); TRACE("Updated target %d\n", This->glDescription.target);
@@ -1174,7 +1230,7 @@ lock_end:
* Dirtify on lock * Dirtify on lock
* as seen in msdn docs * as seen in msdn docs
*/ */
IWineD3DSurface_AddDirtyRect(iface, pRect); surface_add_dirty_rect(iface, pRect);
/** Dirtify Container if needed */ /** Dirtify Container if needed */
if (SUCCEEDED(IWineD3DSurface_GetContainer(iface, &IID_IWineD3DBaseTexture, (void **)&pBaseTexture))) { if (SUCCEEDED(IWineD3DSurface_GetContainer(iface, &IID_IWineD3DBaseTexture, (void **)&pBaseTexture))) {
@@ -1216,18 +1272,18 @@ static void flush_to_framebuffer_drawpixels(IWineD3DSurfaceImpl *This, GLenum fm
} }
glGetIntegerv(GL_PACK_SWAP_BYTES, &prev_store); glGetIntegerv(GL_PACK_SWAP_BYTES, &prev_store);
vcheckGLcall("glIntegerv"); checkGLcall("glIntegerv");
glGetIntegerv(GL_CURRENT_RASTER_POSITION, &prev_rasterpos[0]); glGetIntegerv(GL_CURRENT_RASTER_POSITION, &prev_rasterpos[0]);
vcheckGLcall("glIntegerv"); checkGLcall("glIntegerv");
glPixelZoom(1.0, -1.0); glPixelZoom(1.0, -1.0);
vcheckGLcall("glPixelZoom"); checkGLcall("glPixelZoom");
/* If not fullscreen, we need to skip a number of bytes to find the next row of data */ /* If not fullscreen, we need to skip a number of bytes to find the next row of data */
glGetIntegerv(GL_UNPACK_ROW_LENGTH, &skipBytes); glGetIntegerv(GL_UNPACK_ROW_LENGTH, &skipBytes);
glPixelStorei(GL_UNPACK_ROW_LENGTH, This->currentDesc.Width); glPixelStorei(GL_UNPACK_ROW_LENGTH, This->currentDesc.Width);
glRasterPos3i(This->lockedRect.left, This->lockedRect.top, 1); glRasterPos3i(This->lockedRect.left, This->lockedRect.top, 1);
vcheckGLcall("glRasterPos2f"); checkGLcall("glRasterPos2f");
/* Some drivers(radeon dri, others?) don't like exceptions during /* Some drivers(radeon dri, others?) don't like exceptions during
* glDrawPixels. If the surface is a DIB section, it might be in GDIMode * glDrawPixels. If the surface is a DIB section, it might be in GDIMode
@@ -1270,14 +1326,14 @@ static void flush_to_framebuffer_drawpixels(IWineD3DSurfaceImpl *This, GLenum fm
} }
glPixelZoom(1.0,1.0); glPixelZoom(1.0,1.0);
vcheckGLcall("glPixelZoom"); checkGLcall("glPixelZoom");
glRasterPos3iv(&prev_rasterpos[0]); glRasterPos3iv(&prev_rasterpos[0]);
vcheckGLcall("glRasterPos3iv"); checkGLcall("glRasterPos3iv");
/* Reset to previous pack row length */ /* Reset to previous pack row length */
glPixelStorei(GL_UNPACK_ROW_LENGTH, skipBytes); glPixelStorei(GL_UNPACK_ROW_LENGTH, skipBytes);
vcheckGLcall("glPixelStorei GL_UNPACK_ROW_LENGTH"); checkGLcall("glPixelStorei GL_UNPACK_ROW_LENGTH");
if(!swapchain) { if(!swapchain) {
glDrawBuffer(myDevice->offscreenBuffer); glDrawBuffer(myDevice->offscreenBuffer);
@@ -1302,7 +1358,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
if (!(This->Flags & SFLAG_LOCKED)) { if (!(This->Flags & SFLAG_LOCKED)) {
WARN("trying to Unlock an unlocked surf@%p\n", This); WARN("trying to Unlock an unlocked surf@%p\n", This);
return WINED3DERR_INVALIDCALL; return WINEDDERR_NOTLOCKED;
} }
if (This->Flags & SFLAG_PBO) { if (This->Flags & SFLAG_PBO) {
@@ -1405,7 +1461,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
return WINED3D_OK; return WINED3D_OK;
} }
HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) { static HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
WINED3DLOCKED_RECT lock; WINED3DLOCKED_RECT lock;
HRESULT hr; HRESULT hr;
@@ -1470,7 +1527,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
/* GetDC on palettized formats is unsupported in D3D9, and the method is missing in /* GetDC on palettized formats is unsupported in D3D9, and the method is missing in
D3D8, so this should only be used for DX <=7 surfaces (with non-device palettes) */ D3D8, so this should only be used for DX <=7 surfaces (with non-device palettes) */
unsigned int n; unsigned int n;
PALETTEENTRY *pal = NULL; const PALETTEENTRY *pal = NULL;
if(This->palette) { if(This->palette) {
pal = This->palette->palents; pal = This->palette->palents;
@@ -1501,17 +1558,18 @@ HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
return WINED3D_OK; return WINED3D_OK;
} }
HRESULT WINAPI IWineD3DSurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) { static HRESULT WINAPI IWineD3DSurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
TRACE("(%p)->(%p)\n",This,hDC); TRACE("(%p)->(%p)\n",This,hDC);
if (!(This->Flags & SFLAG_DCINUSE)) if (!(This->Flags & SFLAG_DCINUSE))
return WINED3DERR_INVALIDCALL; return WINEDDERR_NODC;
if (This->hDC !=hDC) { if (This->hDC !=hDC) {
WARN("Application tries to release an invalid DC(%p), surface dc is %p\n", hDC, This->hDC); WARN("Application tries to release an invalid DC(%p), surface dc is %p\n", hDC, This->hDC);
return WINED3DERR_INVALIDCALL; return WINEDDERR_NODC;
} }
if((This->Flags & SFLAG_PBO) && This->resource.allocatedMemory) { if((This->Flags & SFLAG_PBO) && This->resource.allocatedMemory) {
@@ -1533,7 +1591,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) {
HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_texturing, GLenum *format, GLenum *internal, GLenum *type, CONVERT_TYPES *convert, int *target_bpp, BOOL srgb_mode) { HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_texturing, GLenum *format, GLenum *internal, GLenum *type, CONVERT_TYPES *convert, int *target_bpp, BOOL srgb_mode) {
BOOL colorkey_active = need_alpha_ck && (This->CKeyFlags & WINEDDSD_CKSRCBLT); BOOL colorkey_active = need_alpha_ck && (This->CKeyFlags & WINEDDSD_CKSRCBLT);
const GlPixelFormatDesc *glDesc; const struct GlPixelFormatDesc *glDesc;
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
getFormatDescEntry(This->resource.format, &GLINFO_LOCATION, &glDesc); getFormatDescEntry(This->resource.format, &GLINFO_LOCATION, &glDesc);
@@ -1707,30 +1765,6 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_
*target_bpp = 2; *target_bpp = 2;
break; break;
case WINED3DFMT_R32F:
/* Can be loaded in theory with fmt=GL_RED, type=GL_FLOAT, but this fails. The reason
* is that D3D expects the undefined green, blue and alpha channels to return 1.0
* when sampling, but OpenGL sets green and blue to 0.0 instead. Thus we have to inject
* 1.0 instead.
*
* The alpha channel defaults to 1.0 in opengl, so nothing has to be done about it.
*/
*convert = CONVERT_R32F;
*format = GL_RGB;
*internal = GL_RGB32F_ARB;
*type = GL_FLOAT;
*target_bpp = 12;
break;
case WINED3DFMT_R16F:
/* Similar to R32F */
*convert = CONVERT_R16F;
*format = GL_RGB;
*internal = GL_RGB16F_ARB;
*type = GL_HALF_FLOAT_ARB;
*target_bpp = 6;
break;
case WINED3DFMT_G16R16: case WINED3DFMT_G16R16:
*convert = CONVERT_G16R16; *convert = CONVERT_G16R16;
*format = GL_RGB; *format = GL_RGB;
@@ -1746,8 +1780,11 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_
return WINED3D_OK; return WINED3D_OK;
} }
HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height, UINT outpitch, CONVERT_TYPES convert, IWineD3DSurfaceImpl *This) { static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UINT width,
BYTE *source, *dest; UINT height, UINT outpitch, CONVERT_TYPES convert, IWineD3DSurfaceImpl *This)
{
const BYTE *source;
BYTE *dest;
TRACE("(%p)->(%p),(%d,%d,%d,%d,%p)\n", src, dst, pitch, height, outpitch, convert,This); TRACE("(%p)->(%p),(%d,%d,%d,%d,%p)\n", src, dst, pitch, height, outpitch, convert,This);
switch (convert) { switch (convert) {
@@ -1798,13 +1835,13 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
on the same surface and disables color keying in such a case on the same surface and disables color keying in such a case
*/ */
unsigned int x, y; unsigned int x, y;
WORD *Source; const WORD *Source;
WORD *Dest; WORD *Dest;
TRACE("Color keyed 565\n"); TRACE("Color keyed 565\n");
for (y = 0; y < height; y++) { for (y = 0; y < height; y++) {
Source = (WORD *) (src + y * pitch); Source = (const WORD *)(src + y * pitch);
Dest = (WORD *) (dst + y * outpitch); Dest = (WORD *) (dst + y * outpitch);
for (x = 0; x < width; x++ ) { for (x = 0; x < width; x++ ) {
WORD color = *Source++; WORD color = *Source++;
@@ -1823,15 +1860,15 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
{ {
/* Converting X1R5G5B5 format to R5G5B5A1 to emulate color-keying. */ /* Converting X1R5G5B5 format to R5G5B5A1 to emulate color-keying. */
unsigned int x, y; unsigned int x, y;
WORD *Source; const WORD *Source;
WORD *Dest; WORD *Dest;
TRACE("Color keyed 5551\n"); TRACE("Color keyed 5551\n");
for (y = 0; y < height; y++) { for (y = 0; y < height; y++) {
Source = (WORD *) (src + y * pitch); Source = (const WORD *)(src + y * pitch);
Dest = (WORD *) (dst + y * outpitch); Dest = (WORD *) (dst + y * outpitch);
for (x = 0; x < width; x++ ) { for (x = 0; x < width; x++ ) {
WORD color = *Source++; WORD color = *Source++;
*Dest = color; *Dest = color;
if ((color < This->SrcBltCKey.dwColorSpaceLowValue) || if ((color < This->SrcBltCKey.dwColorSpaceLowValue) ||
(color > This->SrcBltCKey.dwColorSpaceHighValue)) { (color > This->SrcBltCKey.dwColorSpaceHighValue)) {
*Dest |= (1 << 15); *Dest |= (1 << 15);
@@ -1845,6 +1882,29 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
} }
break; break;
case CONVERT_CK_RGB24:
{
/* Converting R8G8B8 format to R8G8B8A8 with color-keying. */
unsigned int x, y;
for (y = 0; y < height; y++)
{
source = src + pitch * y;
dest = dst + outpitch * y;
for (x = 0; x < width; x++) {
DWORD color = ((DWORD)source[0] << 16) + ((DWORD)source[1] << 8) + (DWORD)source[2] ;
DWORD dstcolor = color << 8;
if ((color < This->SrcBltCKey.dwColorSpaceLowValue) ||
(color > This->SrcBltCKey.dwColorSpaceHighValue)) {
dstcolor |= 0xff;
}
*(DWORD*)dest = dstcolor;
source += 3;
dest += 4;
}
}
}
break;
case CONVERT_RGB32_888: case CONVERT_RGB32_888:
{ {
/* Converting X8R8G8B8 format to R8G8B8A8 with color-keying. */ /* Converting X8R8G8B8 format to R8G8B8A8 with color-keying. */
@@ -1854,7 +1914,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
source = src + pitch * y; source = src + pitch * y;
dest = dst + outpitch * y; dest = dst + outpitch * y;
for (x = 0; x < width; x++) { for (x = 0; x < width; x++) {
DWORD color = 0xffffff & *(DWORD*)source; DWORD color = 0xffffff & *(const DWORD*)source;
DWORD dstcolor = color << 8; DWORD dstcolor = color << 8;
if ((color < This->SrcBltCKey.dwColorSpaceLowValue) || if ((color < This->SrcBltCKey.dwColorSpaceLowValue) ||
(color > This->SrcBltCKey.dwColorSpaceHighValue)) { (color > This->SrcBltCKey.dwColorSpaceHighValue)) {
@@ -1871,10 +1931,10 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
case CONVERT_V8U8: case CONVERT_V8U8:
{ {
unsigned int x, y; unsigned int x, y;
short *Source; const short *Source;
unsigned char *Dest; unsigned char *Dest;
for(y = 0; y < height; y++) { for(y = 0; y < height; y++) {
Source = (short *) (src + y * pitch); Source = (const short *)(src + y * pitch);
Dest = dst + y * outpitch; Dest = dst + y * outpitch;
for (x = 0; x < width; x++ ) { for (x = 0; x < width; x++ ) {
long color = (*Source++); long color = (*Source++);
@@ -1890,10 +1950,10 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
case CONVERT_V16U16: case CONVERT_V16U16:
{ {
unsigned int x, y; unsigned int x, y;
DWORD *Source; const DWORD *Source;
unsigned short *Dest; unsigned short *Dest;
for(y = 0; y < height; y++) { for(y = 0; y < height; y++) {
Source = (DWORD *) (src + y * pitch); Source = (const DWORD *)(src + y * pitch);
Dest = (unsigned short *) (dst + y * outpitch); Dest = (unsigned short *) (dst + y * outpitch);
for (x = 0; x < width; x++ ) { for (x = 0; x < width; x++ ) {
DWORD color = (*Source++); DWORD color = (*Source++);
@@ -1909,10 +1969,10 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
case CONVERT_Q8W8V8U8: case CONVERT_Q8W8V8U8:
{ {
unsigned int x, y; unsigned int x, y;
DWORD *Source; const DWORD *Source;
unsigned char *Dest; unsigned char *Dest;
for(y = 0; y < height; y++) { for(y = 0; y < height; y++) {
Source = (DWORD *) (src + y * pitch); Source = (const DWORD *)(src + y * pitch);
Dest = dst + y * outpitch; Dest = dst + y * outpitch;
for (x = 0; x < width; x++ ) { for (x = 0; x < width; x++ ) {
long color = (*Source++); long color = (*Source++);
@@ -1929,7 +1989,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
case CONVERT_L6V5U5: case CONVERT_L6V5U5:
{ {
unsigned int x, y; unsigned int x, y;
WORD *Source; const WORD *Source;
unsigned char *Dest; unsigned char *Dest;
if(GL_SUPPORT(NV_TEXTURE_SHADER)) { if(GL_SUPPORT(NV_TEXTURE_SHADER)) {
@@ -1938,7 +1998,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
* loaded * loaded
*/ */
for(y = 0; y < height; y++) { for(y = 0; y < height; y++) {
Source = (WORD *) (src + y * pitch); Source = (const WORD *)(src + y * pitch);
Dest = dst + y * outpitch; Dest = dst + y * outpitch;
for (x = 0; x < width; x++ ) { for (x = 0; x < width; x++ ) {
short color = (*Source++); short color = (*Source++);
@@ -1963,7 +2023,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
} else { } else {
for(y = 0; y < height; y++) { for(y = 0; y < height; y++) {
unsigned short *Dest_s = (unsigned short *) (dst + y * outpitch); unsigned short *Dest_s = (unsigned short *) (dst + y * outpitch);
Source = (WORD *) (src + y * pitch); Source = (const WORD *)(src + y * pitch);
for (x = 0; x < width; x++ ) { for (x = 0; x < width; x++ ) {
short color = (*Source++); short color = (*Source++);
unsigned char l = ((color >> 10) & 0xfc); unsigned char l = ((color >> 10) & 0xfc);
@@ -1983,7 +2043,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
case CONVERT_X8L8V8U8: case CONVERT_X8L8V8U8:
{ {
unsigned int x, y; unsigned int x, y;
DWORD *Source; const DWORD *Source;
unsigned char *Dest; unsigned char *Dest;
if(GL_SUPPORT(NV_TEXTURE_SHADER)) { if(GL_SUPPORT(NV_TEXTURE_SHADER)) {
@@ -1991,7 +2051,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
* without further modification after converting the surface. * without further modification after converting the surface.
*/ */
for(y = 0; y < height; y++) { for(y = 0; y < height; y++) {
Source = (DWORD *) (src + y * pitch); Source = (const DWORD *)(src + y * pitch);
Dest = dst + y * outpitch; Dest = dst + y * outpitch;
for (x = 0; x < width; x++ ) { for (x = 0; x < width; x++ ) {
long color = (*Source++); long color = (*Source++);
@@ -2008,7 +2068,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
* standard fixed function pipeline anyway). * standard fixed function pipeline anyway).
*/ */
for(y = 0; y < height; y++) { for(y = 0; y < height; y++) {
Source = (DWORD *) (src + y * pitch); Source = (const DWORD *)(src + y * pitch);
Dest = dst + y * outpitch; Dest = dst + y * outpitch;
for (x = 0; x < width; x++ ) { for (x = 0; x < width; x++ ) {
long color = (*Source++); long color = (*Source++);
@@ -2025,7 +2085,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
case CONVERT_A4L4: case CONVERT_A4L4:
{ {
unsigned int x, y; unsigned int x, y;
unsigned char *Source; const unsigned char *Source;
unsigned char *Dest; unsigned char *Dest;
for(y = 0; y < height; y++) { for(y = 0; y < height; y++) {
Source = src + y * pitch; Source = src + y * pitch;
@@ -2040,53 +2100,14 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
break; break;
} }
case CONVERT_R32F:
{
unsigned int x, y;
float *Source;
float *Dest;
for(y = 0; y < height; y++) {
Source = (float *) (src + y * pitch);
Dest = (float *) (dst + y * outpitch);
for (x = 0; x < width; x++ ) {
float color = (*Source++);
Dest[0] = color;
Dest[1] = 1.0;
Dest[2] = 1.0;
Dest += 3;
}
}
break;
}
case CONVERT_R16F:
{
unsigned int x, y;
WORD *Source;
WORD *Dest;
WORD one = 0x3c00;
for(y = 0; y < height; y++) {
Source = (WORD *) (src + y * pitch);
Dest = (WORD *) (dst + y * outpitch);
for (x = 0; x < width; x++ ) {
WORD color = (*Source++);
Dest[0] = color;
Dest[1] = one;
Dest[2] = one;
Dest += 3;
}
}
break;
}
case CONVERT_G16R16: case CONVERT_G16R16:
{ {
unsigned int x, y; unsigned int x, y;
WORD *Source; const WORD *Source;
WORD *Dest; WORD *Dest;
for(y = 0; y < height; y++) { for(y = 0; y < height; y++) {
Source = (WORD *) (src + y * pitch); Source = (const WORD *)(src + y * pitch);
Dest = (WORD *) (dst + y * outpitch); Dest = (WORD *) (dst + y * outpitch);
for (x = 0; x < width; x++ ) { for (x = 0; x < width; x++ ) {
WORD green = (*Source++); WORD green = (*Source++);
@@ -2111,7 +2132,7 @@ static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4]
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
BOOL index_in_alpha = FALSE; BOOL index_in_alpha = FALSE;
int dxVersion = ( (IWineD3DImpl *) device->wineD3D)->dxVersion; int dxVersion = ( (IWineD3DImpl *) device->wineD3D)->dxVersion;
int i; unsigned int i;
/* Old games like StarCraft, C&C, Red Alert and others use P8 render targets. /* Old games like StarCraft, C&C, Red Alert and others use P8 render targets.
* Reading back the RGB output each lockrect (each frame as they lock the whole screen) * Reading back the RGB output each lockrect (each frame as they lock the whole screen)
@@ -2165,15 +2186,6 @@ static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4]
} }
} }
const char *fragment_palette_conversion =
"!!ARBfp1.0\n"
"TEMP index;\n"
"PARAM constants = { 0.996, 0.00195, 0, 0 };\n" /* { 255/256, 0.5/255*255/256, 0, 0 } */
"TEX index, fragment.texcoord[0], texture[0], 2D;\n" /* The alpha-component contains the palette index */
"MAD index.a, index.a, constants.x, constants.y;\n" /* Scale the index by 255/256 and add a bias of '0.5' in order to sample in the middle */
"TEX result.color, index.a, texture[1], 1D;\n" /* use the alpha-component as a index in the palette to get the final color */
"END";
/* This function is used in case of 8bit paletted textures to upload the palette. /* This function is used in case of 8bit paletted textures to upload the palette.
It supports GL_EXT_paletted_texture and GL_ARB_fragment_program, support for other It supports GL_EXT_paletted_texture and GL_ARB_fragment_program, support for other
extensions like ATI_fragment_shaders is possible. extensions like ATI_fragment_shaders is possible.
@@ -2200,6 +2212,19 @@ static void d3dfmt_p8_upload_palette(IWineD3DSurface *iface, CONVERT_TYPES conve
/* Create the fragment program if we don't have it */ /* Create the fragment program if we don't have it */
if(!device->paletteConversionShader) if(!device->paletteConversionShader)
{ {
const char *fragment_palette_conversion =
"!!ARBfp1.0\n"
"TEMP index;\n"
/* { 255/256, 0.5/255*255/256, 0, 0 } */
"PARAM constants = { 0.996, 0.00195, 0, 0 };\n"
/* The alpha-component contains the palette index */
"TEX index, fragment.texcoord[0], texture[0], 2D;\n"
/* Scale the index by 255/256 and add a bias of '0.5' in order to sample in the middle */
"MAD index.a, index.a, constants.x, constants.y;\n"
/* Use the alpha-component as an index in the palette to get the final color */
"TEX result.color, index.a, texture[1], 1D;\n"
"END";
glEnable(GL_FRAGMENT_PROGRAM_ARB); glEnable(GL_FRAGMENT_PROGRAM_ARB);
GL_EXTCALL(glGenProgramsARB(1, &device->paletteConversionShader)); GL_EXTCALL(glGenProgramsARB(1, &device->paletteConversionShader));
GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, device->paletteConversionShader)); GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, device->paletteConversionShader));
@@ -2247,41 +2272,6 @@ BOOL palette9_changed(IWineD3DSurfaceImpl *This) {
return TRUE; return TRUE;
} }
static inline void clear_unused_channels(IWineD3DSurfaceImpl *This) {
GLboolean oldwrite[4];
/* Some formats have only some color channels, and the others are 1.0.
* since our rendering renders to all channels, and those pixel formats
* are emulated by using a full texture with the other channels set to 1.0
* manually, clear the unused channels.
*
* This could be done with hacking colorwriteenable to mask the colors,
* but before drawing the buffer would have to be cleared too, so there's
* no gain in that
*/
switch(This->resource.format) {
case WINED3DFMT_R16F:
case WINED3DFMT_R32F:
TRACE("R16F or R32F format, clearing green, blue and alpha to 1.0\n");
/* Do not activate a context, the correct drawable is active already
* though just the read buffer is set, make sure to have the correct draw
* buffer too
*/
glDrawBuffer(This->resource.wineD3DDevice->offscreenBuffer);
glDisable(GL_SCISSOR_TEST);
glGetBooleanv(GL_COLOR_WRITEMASK, oldwrite);
glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE);
glClearColor(0.0, 1.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glColorMask(oldwrite[0], oldwrite[1], oldwrite[2], oldwrite[3]);
if(!This->resource.wineD3DDevice->render_offscreen) glDrawBuffer(GL_BACK);
checkGLcall("Unused channel clear\n");
break;
default: break;
}
}
static HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, BOOL srgb_mode) { static HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, BOOL srgb_mode) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
@@ -2407,14 +2397,14 @@ static void WINAPI IWineD3DSurfaceImpl_BindTexture(IWineD3DSurface *iface) {
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const char* filename) { static HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const char* filename)
{
FILE* f = NULL; FILE* f = NULL;
UINT i, y;
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
char *allocatedMemory; char *allocatedMemory;
char *textureRow; const char *textureRow;
IWineD3DSwapChain *swapChain = NULL; IWineD3DSwapChain *swapChain = NULL;
int width, height; int width, height, i, y;
GLuint tmpTexture = 0; GLuint tmpTexture = 0;
DWORD color; DWORD color;
/*FIXME: /*FIXME:
@@ -2458,9 +2448,9 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const ch
NULL); NULL);
glGetIntegerv(GL_READ_BUFFER, &prevRead); glGetIntegerv(GL_READ_BUFFER, &prevRead);
vcheckGLcall("glGetIntegerv"); checkGLcall("glGetIntegerv");
glReadBuffer(swapChain ? GL_BACK : This->resource.wineD3DDevice->offscreenBuffer); glReadBuffer(swapChain ? GL_BACK : This->resource.wineD3DDevice->offscreenBuffer);
vcheckGLcall("glReadBuffer"); checkGLcall("glReadBuffer");
glCopyTexImage2D(GL_TEXTURE_2D, glCopyTexImage2D(GL_TEXTURE_2D,
0, 0,
GL_RGBA, GL_RGBA,
@@ -2528,7 +2518,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const ch
textureRow = allocatedMemory; textureRow = allocatedMemory;
for (y = 0 ; y < height; y++) { for (y = 0 ; y < height; y++) {
for (i = 0; i < width; i++) { for (i = 0; i < width; i++) {
color = *((DWORD*)textureRow); color = *((const DWORD*)textureRow);
fputc((color >> 16) & 0xFF, f); /* B */ fputc((color >> 16) & 0xFF, f); /* B */
fputc((color >> 8) & 0xFF, f); /* G */ fputc((color >> 8) & 0xFF, f); /* G */
fputc((color >> 0) & 0xFF, f); /* R */ fputc((color >> 0) & 0xFF, f); /* R */
@@ -2550,43 +2540,10 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const ch
return WINED3D_OK; return WINED3D_OK;
} }
/** static HRESULT WINAPI IWineD3DSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORMAT format) {
* Slightly inefficient way to handle multiple dirty rects but it works :)
*/
HRESULT WINAPI IWineD3DSurfaceImpl_AddDirtyRect(IWineD3DSurface *iface, CONST RECT* pDirtyRect) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
IWineD3DBaseTexture *baseTexture = NULL;
if (!(This->Flags & SFLAG_INSYSMEM) && (This->Flags & SFLAG_INTEXTURE))
IWineD3DSurface_LoadLocation(iface, SFLAG_INSYSMEM, NULL /* no partial locking for textures yet */);
IWineD3DSurface_ModifyLocation(iface, SFLAG_INSYSMEM, TRUE);
if (NULL != pDirtyRect) {
This->dirtyRect.left = min(This->dirtyRect.left, pDirtyRect->left);
This->dirtyRect.top = min(This->dirtyRect.top, pDirtyRect->top);
This->dirtyRect.right = max(This->dirtyRect.right, pDirtyRect->right);
This->dirtyRect.bottom = max(This->dirtyRect.bottom, pDirtyRect->bottom);
} else {
This->dirtyRect.left = 0;
This->dirtyRect.top = 0;
This->dirtyRect.right = This->currentDesc.Width;
This->dirtyRect.bottom = This->currentDesc.Height;
}
TRACE("(%p) : Dirty: yes, Rect:(%d,%d,%d,%d)\n", This, This->dirtyRect.left,
This->dirtyRect.top, This->dirtyRect.right, This->dirtyRect.bottom);
/* if the container is a basetexture then mark it dirty. */
if (IWineD3DSurface_GetContainer(iface, &IID_IWineD3DBaseTexture, (void **)&baseTexture) == WINED3D_OK) {
TRACE("Passing to container\n");
IWineD3DBaseTexture_SetDirty(baseTexture, TRUE);
IWineD3DBaseTexture_Release(baseTexture);
}
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORMAT format) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
HRESULT hr; HRESULT hr;
const GlPixelFormatDesc *glDesc; const struct GlPixelFormatDesc *glDesc;
getFormatDescEntry(format, &GLINFO_LOCATION, &glDesc); getFormatDescEntry(format, &GLINFO_LOCATION, &glDesc);
TRACE("(%p) : Calling base function first\n", This); TRACE("(%p) : Calling base function first\n", This);
@@ -2604,7 +2561,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORM
return hr; return hr;
} }
HRESULT WINAPI IWineD3DSurfaceImpl_SetMem(IWineD3DSurface *iface, void *Mem) { static HRESULT WINAPI IWineD3DSurfaceImpl_SetMem(IWineD3DSurface *iface, void *Mem) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
if(This->Flags & (SFLAG_LOCKED | SFLAG_DCINUSE)) { if(This->Flags & (SFLAG_LOCKED | SFLAG_DCINUSE)) {
@@ -2797,7 +2754,10 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_Flip(IWineD3DSurface *iface, IWineD3DS
/* Does a direct frame buffer -> texture copy. Stretching is done /* Does a direct frame buffer -> texture copy. Stretching is done
* with single pixel copy calls * with single pixel copy calls
*/ */
static inline void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3DSurface *SrcSurface, IWineD3DSwapChainImpl *swapchain, WINED3DRECT *srect, WINED3DRECT *drect, BOOL upsidedown, WINED3DTEXTUREFILTERTYPE Filter) { static inline void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3DSurface *SrcSurface,
IWineD3DSwapChainImpl *swapchain, const WINED3DRECT *srect, const WINED3DRECT *drect,
BOOL upsidedown, WINED3DTEXTUREFILTERTYPE Filter)
{
IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice; IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
float xrel, yrel; float xrel, yrel;
UINT row; UINT row;
@@ -2875,13 +2835,16 @@ static inline void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3D
} }
} }
} }
vcheckGLcall("glCopyTexSubImage2D"); checkGLcall("glCopyTexSubImage2D");
LEAVE_GL(); LEAVE_GL();
} }
/* Uses the hardware to stretch and flip the image */ /* Uses the hardware to stretch and flip the image */
static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWineD3DSurface *SrcSurface, IWineD3DSwapChainImpl *swapchain, WINED3DRECT *srect, WINED3DRECT *drect, BOOL upsidedown, WINED3DTEXTUREFILTERTYPE Filter) { static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWineD3DSurface *SrcSurface,
IWineD3DSwapChainImpl *swapchain, const WINED3DRECT *srect, const WINED3DRECT *drect,
BOOL upsidedown, WINED3DTEXTUREFILTERTYPE Filter)
{
GLuint src, backup = 0; GLuint src, backup = 0;
IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice; IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
IWineD3DSurfaceImpl *Src = (IWineD3DSurfaceImpl *) SrcSurface; IWineD3DSurfaceImpl *Src = (IWineD3DSurfaceImpl *) SrcSurface;
@@ -2957,7 +2920,7 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
magLookup[Filter - WINED3DTEXF_NONE]); magLookup[Filter - WINED3DTEXF_NONE]);
checkGLcall("glTexParameteri"); checkGLcall("glTexParameteri");
glTexParameteri(texture_target, GL_TEXTURE_MIN_FILTER, glTexParameteri(texture_target, GL_TEXTURE_MIN_FILTER,
minMipLookup[Filter][WINED3DTEXF_NONE]); minMipLookup[Filter].mip[WINED3DTEXF_NONE]);
checkGLcall("glTexParameteri"); checkGLcall("glTexParameteri");
if(!swapchain || (IWineD3DSurface *) Src == swapchain->backBuffer[0]) { if(!swapchain || (IWineD3DSurface *) Src == swapchain->backBuffer[0]) {
@@ -3117,7 +3080,10 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
} }
/* Not called from the VTable */ /* Not called from the VTable */
static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT *DestRect, IWineD3DSurface *SrcSurface, RECT *SrcRect, DWORD Flags, WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter) { static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const RECT *DestRect,
IWineD3DSurface *SrcSurface, const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx,
WINED3DTEXTUREFILTERTYPE Filter)
{
WINED3DRECT rect; WINED3DRECT rect;
IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice; IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
IWineD3DSwapChainImpl *srcSwapchain = NULL, *dstSwapchain = NULL; IWineD3DSwapChainImpl *srcSwapchain = NULL, *dstSwapchain = NULL;
@@ -3494,7 +3460,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT *
magLookup[Filter - WINED3DTEXF_NONE]); magLookup[Filter - WINED3DTEXF_NONE]);
checkGLcall("glTexParameteri"); checkGLcall("glTexParameteri");
glTexParameteri(Src->glDescription.target, GL_TEXTURE_MIN_FILTER, glTexParameteri(Src->glDescription.target, GL_TEXTURE_MIN_FILTER,
minMipLookup[Filter][WINED3DTEXF_NONE]); minMipLookup[Filter].mip[WINED3DTEXF_NONE]);
checkGLcall("glTexParameteri"); checkGLcall("glTexParameteri");
glTexParameteri(Src->glDescription.target, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(Src->glDescription.target, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(Src->glDescription.target, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(Src->glDescription.target, GL_TEXTURE_WRAP_T, GL_CLAMP);
@@ -3648,7 +3614,8 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT *
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
static HRESULT WINAPI IWineD3DSurfaceImpl_BltZ(IWineD3DSurfaceImpl *This, RECT *DestRect, IWineD3DSurface *SrcSurface, RECT *SrcRect, DWORD Flags, WINEDDBLTFX *DDBltFx) static HRESULT IWineD3DSurfaceImpl_BltZ(IWineD3DSurfaceImpl *This, const RECT *DestRect,
IWineD3DSurface *SrcSurface, const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx)
{ {
IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice; IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
float depth; float depth;
@@ -3675,7 +3642,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_BltZ(IWineD3DSurfaceImpl *This, RECT *
return IWineD3DDevice_Clear((IWineD3DDevice *) myDevice, return IWineD3DDevice_Clear((IWineD3DDevice *) myDevice,
DestRect == NULL ? 0 : 1, DestRect == NULL ? 0 : 1,
(WINED3DRECT *) DestRect, (const WINED3DRECT *)DestRect,
WINED3DCLEAR_ZBUFFER, WINED3DCLEAR_ZBUFFER,
0x00000000, 0x00000000,
depth, depth,
@@ -3686,7 +3653,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_BltZ(IWineD3DSurfaceImpl *This, RECT *
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
static HRESULT WINAPI IWineD3DSurfaceImpl_Blt(IWineD3DSurface *iface, RECT *DestRect, IWineD3DSurface *SrcSurface, RECT *SrcRect, DWORD Flags, WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter) { static HRESULT WINAPI IWineD3DSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *DestRect, IWineD3DSurface *SrcSurface,
const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
IWineD3DSurfaceImpl *Src = (IWineD3DSurfaceImpl *) SrcSurface; IWineD3DSurfaceImpl *Src = (IWineD3DSurfaceImpl *) SrcSurface;
IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice; IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
@@ -3725,7 +3693,9 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_Blt(IWineD3DSurface *iface, RECT *Dest
return IWineD3DBaseSurfaceImpl_Blt(iface, DestRect, SrcSurface, SrcRect, Flags, DDBltFx, Filter); return IWineD3DBaseSurfaceImpl_Blt(iface, DestRect, SrcSurface, SrcRect, Flags, DDBltFx, Filter);
} }
HRESULT WINAPI IWineD3DSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, DWORD dsty, IWineD3DSurface *Source, RECT *rsrc, DWORD trans) { static HRESULT WINAPI IWineD3DSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, DWORD dsty,
IWineD3DSurface *Source, const RECT *rsrc, DWORD trans)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
IWineD3DSurfaceImpl *srcImpl = (IWineD3DSurfaceImpl *) Source; IWineD3DSurfaceImpl *srcImpl = (IWineD3DSurfaceImpl *) Source;
IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice; IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
@@ -3785,7 +3755,8 @@ HRESULT WINAPI IWineD3DSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, D
return IWineD3DBaseSurfaceImpl_BltFast(iface, dstx, dsty, Source, rsrc, trans); return IWineD3DBaseSurfaceImpl_BltFast(iface, dstx, dsty, Source, rsrc, trans);
} }
HRESULT WINAPI IWineD3DSurfaceImpl_RealizePalette(IWineD3DSurface *iface) { static HRESULT WINAPI IWineD3DSurfaceImpl_RealizePalette(IWineD3DSurface *iface)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
RGBQUAD col[256]; RGBQUAD col[256];
IWineD3DPaletteImpl *pal = This->palette; IWineD3DPaletteImpl *pal = This->palette;
@@ -3849,7 +3820,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_PrivateSetup(IWineD3DSurface *iface) {
/** Check against the maximum texture sizes supported by the video card **/ /** Check against the maximum texture sizes supported by the video card **/
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
unsigned int pow2Width, pow2Height; unsigned int pow2Width, pow2Height;
const GlPixelFormatDesc *glDesc; const struct GlPixelFormatDesc *glDesc;
getFormatDescEntry(This->resource.format, &GLINFO_LOCATION, &glDesc); getFormatDescEntry(This->resource.format, &GLINFO_LOCATION, &glDesc);
/* Setup some glformat defaults */ /* Setup some glformat defaults */
@@ -3898,7 +3869,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_PrivateSetup(IWineD3DSurface *iface) {
3: WARN and return WINED3DERR_NOTAVAILABLE; 3: WARN and return WINED3DERR_NOTAVAILABLE;
4: Create the surface, but allow it to be used only for DirectDraw Blts. Some apps(e.g. Swat 3) create textures with a Height of 16 and a Width > 3000 and blt 16x16 letter areas from them to the render target. 4: Create the surface, but allow it to be used only for DirectDraw Blts. Some apps(e.g. Swat 3) create textures with a Height of 16 and a Width > 3000 and blt 16x16 letter areas from them to the render target.
*/ */
WARN("(%p) Creating an oversized surface\n", This); WARN("(%p) Creating an oversized surface: %ux%u (texture is %ux%u)\n",
This, This->pow2Width, This->pow2Height, This->currentDesc.Width, This->currentDesc.Height);
This->Flags |= SFLAG_OVERSIZE; This->Flags |= SFLAG_OVERSIZE;
/* This will be initialized on the first blt */ /* This will be initialized on the first blt */
@@ -4674,7 +4646,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, D
return WINED3D_OK; return WINED3D_OK;
} }
HRESULT WINAPI IWineD3DSurfaceImpl_SetContainer(IWineD3DSurface *iface, IWineD3DBase *container) { static HRESULT WINAPI IWineD3DSurfaceImpl_SetContainer(IWineD3DSurface *iface, IWineD3DBase *container)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
IWineD3DSwapChain *swapchain = NULL; IWineD3DSwapChain *swapchain = NULL;
@@ -4766,13 +4739,12 @@ const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl =
IWineD3DBaseSurfaceImpl_SetClipper, IWineD3DBaseSurfaceImpl_SetClipper,
IWineD3DBaseSurfaceImpl_GetClipper, IWineD3DBaseSurfaceImpl_GetClipper,
/* Internal use: */ /* Internal use: */
IWineD3DSurfaceImpl_AddDirtyRect,
IWineD3DSurfaceImpl_LoadTexture, IWineD3DSurfaceImpl_LoadTexture,
IWineD3DSurfaceImpl_BindTexture, IWineD3DSurfaceImpl_BindTexture,
IWineD3DSurfaceImpl_SaveSnapshot, IWineD3DSurfaceImpl_SaveSnapshot,
IWineD3DSurfaceImpl_SetContainer, IWineD3DSurfaceImpl_SetContainer,
IWineD3DSurfaceImpl_GetGlDesc, IWineD3DSurfaceImpl_GetGlDesc,
IWineD3DSurfaceImpl_GetData, IWineD3DBaseSurfaceImpl_GetData,
IWineD3DSurfaceImpl_SetFormat, IWineD3DSurfaceImpl_SetFormat,
IWineD3DSurfaceImpl_PrivateSetup, IWineD3DSurfaceImpl_PrivateSetup,
IWineD3DSurfaceImpl_ModifyLocation, IWineD3DSurfaceImpl_ModifyLocation,
@@ -4806,8 +4778,22 @@ static void ffp_blit_unset(IWineD3DDevice *iface) {
} }
} }
static BOOL ffp_blit_conv_supported(WINED3DFORMAT fmt) { static BOOL ffp_blit_color_fixup_supported(struct color_fixup_desc fixup)
TRACE("Checking blit format support for format %s: [FAILED]\n", debug_d3dformat(fmt)); {
if (TRACE_ON(d3d_surface) && TRACE_ON(d3d))
{
TRACE("Checking support for fixup:\n");
dump_color_fixup_desc(fixup);
}
/* We only support identity conversions. */
if (is_identity_fixup(fixup))
{
TRACE("[OK]\n");
return TRUE;
}
TRACE("[FAILED]\n");
return FALSE; return FALSE;
} }
@@ -4816,5 +4802,5 @@ const struct blit_shader ffp_blit = {
ffp_blit_free, ffp_blit_free,
ffp_blit_set, ffp_blit_set,
ffp_blit_unset, ffp_blit_unset,
ffp_blit_conv_supported ffp_blit_color_fixup_supported
}; };

View File

@@ -29,6 +29,7 @@
#include "config.h" #include "config.h"
#include "wine/port.h" #include "wine/port.h"
#include "wined3d_private.h" #include "wined3d_private.h"
#include "float.h"
#include <assert.h> #include <assert.h>
@@ -45,7 +46,7 @@ static inline unsigned short float_32_to_16(const float *in)
/* Deal with special numbers */ /* Deal with special numbers */
if(*in == 0.0) return 0x0000; if(*in == 0.0) return 0x0000;
if(isnan(*in)) return 0x7C01; if(isnan(*in)) return 0x7C01;
if(!finite(*in)) return (*in < 0.0 ? 0xFC00 : 0x7c00); if(!_finite(*in)) return (*in < 0.0 ? 0xFC00 : 0x7c00);
if(tmp < pow(2, 10)) { if(tmp < pow(2, 10)) {
do do
@@ -119,37 +120,37 @@ ULONG WINAPI IWineD3DBaseSurfaceImpl_AddRef(IWineD3DSurface *iface) {
IWineD3DSurface IWineD3DResource parts follow IWineD3DSurface IWineD3DResource parts follow
**************************************************** */ **************************************************** */
HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetDevice(IWineD3DSurface *iface, IWineD3DDevice** ppDevice) { HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetDevice(IWineD3DSurface *iface, IWineD3DDevice** ppDevice) {
return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice); return resource_get_device((IWineD3DResource *)iface, ppDevice);
} }
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPrivateData(IWineD3DSurface *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) { HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPrivateData(IWineD3DSurface *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags); return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
} }
HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPrivateData(IWineD3DSurface *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) { HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPrivateData(IWineD3DSurface *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData); return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
} }
HRESULT WINAPI IWineD3DBaseSurfaceImpl_FreePrivateData(IWineD3DSurface *iface, REFGUID refguid) { HRESULT WINAPI IWineD3DBaseSurfaceImpl_FreePrivateData(IWineD3DSurface *iface, REFGUID refguid) {
return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid); return resource_free_private_data((IWineD3DResource *)iface, refguid);
} }
DWORD WINAPI IWineD3DBaseSurfaceImpl_SetPriority(IWineD3DSurface *iface, DWORD PriorityNew) { DWORD WINAPI IWineD3DBaseSurfaceImpl_SetPriority(IWineD3DSurface *iface, DWORD PriorityNew) {
return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew); return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
} }
DWORD WINAPI IWineD3DBaseSurfaceImpl_GetPriority(IWineD3DSurface *iface) { DWORD WINAPI IWineD3DBaseSurfaceImpl_GetPriority(IWineD3DSurface *iface) {
return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface); return resource_get_priority((IWineD3DResource *)iface);
} }
WINED3DRESOURCETYPE WINAPI IWineD3DBaseSurfaceImpl_GetType(IWineD3DSurface *iface) { WINED3DRESOURCETYPE WINAPI IWineD3DBaseSurfaceImpl_GetType(IWineD3DSurface *iface) {
TRACE("(%p) : calling resourceimpl_GetType\n", iface); TRACE("(%p) : calling resourceimpl_GetType\n", iface);
return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface); return resource_get_type((IWineD3DResource *)iface);
} }
HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetParent(IWineD3DSurface *iface, IUnknown **pParent) { HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetParent(IWineD3DSurface *iface, IUnknown **pParent) {
TRACE("(%p) : calling resourceimpl_GetParent\n", iface); TRACE("(%p) : calling resourceimpl_GetParent\n", iface);
return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent); return resource_get_parent((IWineD3DResource *)iface, pParent);
} }
/* ****************************************************** /* ******************************************************
@@ -166,11 +167,7 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetContainer(IWineD3DSurface* iface, REFI
ERR("Called without a valid ppContainer.\n"); ERR("Called without a valid ppContainer.\n");
} }
/** From MSDN: /* Standalone surfaces return the device as container. */
* If the surface is created using CreateImageSurface/CreateOffscreenPlainSurface, CreateRenderTarget,
* or CreateDepthStencilSurface, the surface is considered stand alone. In this case,
* GetContainer will return the Direct3D device used to create the surface.
*/
if (This->container) { if (This->container) {
container = This->container; container = This->container;
} else { } else {
@@ -269,7 +266,8 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD
else return WINED3D_OK; else return WINED3D_OK;
} }
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD Flags, WINEDDCOLORKEY *CKey) { HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD Flags, const WINEDDCOLORKEY *CKey)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
TRACE("(%p)->(%08x,%p)\n", This, Flags, CKey); TRACE("(%p)->(%08x,%p)\n", This, Flags, CKey);
@@ -418,7 +416,9 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlayZOrder(IWineD3DSurface *ifac
return WINED3D_OK; return WINED3D_OK;
} }
HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, RECT *SrcRect, IWineD3DSurface *DstSurface, RECT *DstRect, DWORD Flags, WINEDDOVERLAYFX *FX) { HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, const RECT *SrcRect,
IWineD3DSurface *DstSurface, const RECT *DstRect, DWORD Flags, const WINEDDOVERLAYFX *FX)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
IWineD3DSurfaceImpl *Dst = (IWineD3DSurfaceImpl *) DstSurface; IWineD3DSurfaceImpl *Dst = (IWineD3DSurfaceImpl *) DstSurface;
TRACE("(%p)->(%p, %p, %p, %08x, %p)\n", This, SrcRect, Dst, DstRect, Flags, FX); TRACE("(%p)->(%p, %p, %p, %08x, %p)\n", This, SrcRect, Dst, DstRect, Flags, FX);
@@ -682,14 +682,16 @@ HRESULT IWineD3DBaseSurfaceImpl_CreateDIBSection(IWineD3DSurface *iface) {
return WINED3D_OK; return WINED3D_OK;
} }
void convert_r32f_r16f(BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h) { static void convert_r32f_r16f(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out,
unsigned int w, unsigned int h)
{
unsigned int x, y; unsigned int x, y;
float *src_f; const float *src_f;
unsigned short *dst_s; unsigned short *dst_s;
TRACE("Converting %dx%d pixels, pitches %d %d\n", w, h, pitch_in, pitch_out); TRACE("Converting %dx%d pixels, pitches %d %d\n", w, h, pitch_in, pitch_out);
for(y = 0; y < h; y++) { for(y = 0; y < h; y++) {
src_f = (float *) (src + y * pitch_in); src_f = (const float *)(src + y * pitch_in);
dst_s = (unsigned short *) (dst + y * pitch_out); dst_s = (unsigned short *) (dst + y * pitch_out);
for(x = 0; x < w; x++) { for(x = 0; x < w; x++) {
dst_s[x] = float_32_to_16(src_f + x); dst_s[x] = float_32_to_16(src_f + x);
@@ -697,16 +699,59 @@ void convert_r32f_r16f(BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, un
} }
} }
static void convert_r5g6b5_x8r8g8b8(const BYTE *src, BYTE *dst,
DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
{
static const unsigned char convert_5to8[] =
{
0x00, 0x08, 0x10, 0x19, 0x21, 0x29, 0x31, 0x3a,
0x42, 0x4a, 0x52, 0x5a, 0x63, 0x6b, 0x73, 0x7b,
0x84, 0x8c, 0x94, 0x9c, 0xa5, 0xad, 0xb5, 0xbd,
0xc5, 0xce, 0xd6, 0xde, 0xe6, 0xef, 0xf7, 0xff,
};
static const unsigned char convert_6to8[] =
{
0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, 0x18, 0x1c,
0x20, 0x24, 0x28, 0x2d, 0x31, 0x35, 0x39, 0x3d,
0x41, 0x45, 0x49, 0x4d, 0x51, 0x55, 0x59, 0x5d,
0x61, 0x65, 0x69, 0x6d, 0x71, 0x75, 0x79, 0x7d,
0x82, 0x86, 0x8a, 0x8e, 0x92, 0x96, 0x9a, 0x9e,
0xa2, 0xa6, 0xaa, 0xae, 0xb2, 0xb6, 0xba, 0xbe,
0xc2, 0xc6, 0xca, 0xce, 0xd2, 0xd7, 0xdb, 0xdf,
0xe3, 0xe7, 0xeb, 0xef, 0xf3, 0xf7, 0xfb, 0xff,
};
unsigned int x, y;
TRACE("Converting %ux%u pixels, pitches %u %u\n", w, h, pitch_in, pitch_out);
for (y = 0; y < h; ++y)
{
const WORD *src_line = (const WORD *)(src + y * pitch_in);
DWORD *dst_line = (DWORD *)(dst + y * pitch_out);
for (x = 0; x < w; ++x)
{
WORD pixel = src_line[x];
dst_line[x] = 0xff000000
| convert_5to8[(pixel & 0xf800) >> 11] << 16
| convert_6to8[(pixel & 0x07e0) >> 5] << 8
| convert_5to8[(pixel & 0x001f)];
}
}
}
struct d3dfmt_convertor_desc { struct d3dfmt_convertor_desc {
WINED3DFORMAT from, to; WINED3DFORMAT from, to;
void (*convert)(BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h); void (*convert)(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h);
}; };
struct d3dfmt_convertor_desc convertors[] = { static const struct d3dfmt_convertor_desc convertors[] =
{
{WINED3DFMT_R32F, WINED3DFMT_R16F, convert_r32f_r16f}, {WINED3DFMT_R32F, WINED3DFMT_R16F, convert_r32f_r16f},
{WINED3DFMT_R5G6B5, WINED3DFMT_X8R8G8B8, convert_r5g6b5_x8r8g8b8},
}; };
static inline struct d3dfmt_convertor_desc *find_convertor(WINED3DFORMAT from, WINED3DFORMAT to) { static inline const struct d3dfmt_convertor_desc *find_convertor(WINED3DFORMAT from, WINED3DFORMAT to)
{
unsigned int i; unsigned int i;
for(i = 0; i < (sizeof(convertors) / sizeof(convertors[0])); i++) { for(i = 0; i < (sizeof(convertors) / sizeof(convertors[0])); i++) {
if(convertors[i].from == from && convertors[i].to == to) { if(convertors[i].from == from && convertors[i].to == to) {
@@ -727,9 +772,9 @@ static inline struct d3dfmt_convertor_desc *find_convertor(WINED3DFORMAT from, W
* fmt: Requested destination format * fmt: Requested destination format
* *
*****************************************************************************/ *****************************************************************************/
IWineD3DSurfaceImpl *surface_convert_format(IWineD3DSurfaceImpl *source, WINED3DFORMAT to_fmt) { static IWineD3DSurfaceImpl *surface_convert_format(IWineD3DSurfaceImpl *source, WINED3DFORMAT to_fmt) {
IWineD3DSurface *ret = NULL; IWineD3DSurface *ret = NULL;
struct d3dfmt_convertor_desc *conv; const struct d3dfmt_convertor_desc *conv;
WINED3DLOCKED_RECT lock_src, lock_dst; WINED3DLOCKED_RECT lock_src, lock_dst;
HRESULT hr; HRESULT hr;
@@ -862,14 +907,8 @@ static HRESULT
* SrcSurface: Source surface, can be NULL * SrcSurface: Source surface, can be NULL
* SrcRect: Source rectangle * SrcRect: Source rectangle
*****************************************************************************/ *****************************************************************************/
HRESULT WINAPI HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *DestRect, IWineD3DSurface *SrcSurface,
IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter)
RECT *DestRect,
IWineD3DSurface *SrcSurface,
RECT *SrcRect,
DWORD Flags,
WINEDDBLTFX *DDBltFx,
WINED3DTEXTUREFILTERTYPE Filter)
{ {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
IWineD3DSurfaceImpl *Src = (IWineD3DSurfaceImpl *) SrcSurface; IWineD3DSurfaceImpl *Src = (IWineD3DSurfaceImpl *) SrcSurface;
@@ -880,7 +919,8 @@ IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface,
int bpp, srcheight, srcwidth, dstheight, dstwidth, width; int bpp, srcheight, srcwidth, dstheight, dstwidth, width;
int x, y; int x, y;
const StaticPixelFormatDesc *sEntry, *dEntry; const StaticPixelFormatDesc *sEntry, *dEntry;
LPBYTE dbuf, sbuf; const BYTE *sbuf;
BYTE *dbuf;
TRACE("(%p)->(%p,%p,%p,%x,%p)\n", This, DestRect, Src, SrcRect, Flags, DDBltFx); TRACE("(%p)->(%p,%p,%p,%x,%p)\n", This, DestRect, Src, SrcRect, Flags, DDBltFx);
if (TRACE_ON(d3d_surface)) if (TRACE_ON(d3d_surface))
@@ -1171,7 +1211,7 @@ IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface,
/* Now the 'with source' blits */ /* Now the 'with source' blits */
if (Src) if (Src)
{ {
LPBYTE sbase; const BYTE *sbase;
int sx, xinc, sy, yinc; int sx, xinc, sy, yinc;
if (!dstwidth || !dstheight) /* hmm... stupid program ? */ if (!dstwidth || !dstheight) /* hmm... stupid program ? */
@@ -1250,7 +1290,8 @@ IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface,
else else
{ {
#define STRETCH_ROW(type) { \ #define STRETCH_ROW(type) { \
type *s = (type *) sbuf, *d = (type *) dbuf; \ const type *s = (const type *)sbuf; \
type *d = (type *)dbuf; \
for (x = sx = 0; x < dstwidth; x++, sx += xinc) \ for (x = sx = 0; x < dstwidth; x++, sx += xinc) \
d[x] = s[sx >> 16]; \ d[x] = s[sx >> 16]; \
break; } break; }
@@ -1262,7 +1303,8 @@ IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface,
case 4: STRETCH_ROW(DWORD) case 4: STRETCH_ROW(DWORD)
case 3: case 3:
{ {
LPBYTE s,d = dbuf; const BYTE *s;
BYTE *d = dbuf;
for (x = sx = 0; x < dstwidth; x++, sx+= xinc) for (x = sx = 0; x < dstwidth; x++, sx+= xinc)
{ {
DWORD pixel; DWORD pixel;
@@ -1416,9 +1458,10 @@ IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface,
} }
#define COPY_COLORKEY_FX(type) { \ #define COPY_COLORKEY_FX(type) { \
type *s, *d = (type *) dbuf, *dx, tmp; \ const type *s; \
type *d = (type *)dbuf, *dx, tmp; \
for (y = sy = 0; y < dstheight; y++, sy += yinc) { \ for (y = sy = 0; y < dstheight; y++, sy += yinc) { \
s = (type*)(sbase + (sy >> 16) * slock.Pitch); \ s = (const type*)(sbase + (sy >> 16) * slock.Pitch); \
dx = d; \ dx = d; \
for (x = sx = 0; x < dstwidth; x++, sx += xinc) { \ for (x = sx = 0; x < dstwidth; x++, sx += xinc) { \
tmp = s[sx >> 16]; \ tmp = s[sx >> 16]; \
@@ -1438,7 +1481,8 @@ IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface,
case 4: COPY_COLORKEY_FX(DWORD) case 4: COPY_COLORKEY_FX(DWORD)
case 3: case 3:
{ {
LPBYTE s,d = dbuf, dx; const BYTE *s;
BYTE *d = dbuf, *dx;
for (y = sy = 0; y < dstheight; y++, sy += yinc) for (y = sy = 0; y < dstheight; y++, sy += yinc)
{ {
sbuf = sbase + (sy >> 16) * slock.Pitch; sbuf = sbase + (sy >> 16) * slock.Pitch;
@@ -1504,13 +1548,8 @@ release:
* WINED3D_OK on success * WINED3D_OK on success
* *
*****************************************************************************/ *****************************************************************************/
HRESULT WINAPI HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, DWORD dsty,
IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, IWineD3DSurface *Source, const RECT *rsrc, DWORD trans)
DWORD dstx,
DWORD dsty,
IWineD3DSurface *Source,
RECT *rsrc,
DWORD trans)
{ {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
IWineD3DSurfaceImpl *Src = (IWineD3DSurfaceImpl *) Source; IWineD3DSurfaceImpl *Src = (IWineD3DSurfaceImpl *) Source;
@@ -1520,7 +1559,8 @@ IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface,
HRESULT ret = WINED3D_OK; HRESULT ret = WINED3D_OK;
RECT rsrc2; RECT rsrc2;
RECT lock_src, lock_dst, lock_union; RECT lock_src, lock_dst, lock_union;
BYTE *sbuf, *dbuf; const BYTE *sbuf;
BYTE *dbuf;
const StaticPixelFormatDesc *sEntry, *dEntry; const StaticPixelFormatDesc *sEntry, *dEntry;
if (TRACE_ON(d3d_surface)) if (TRACE_ON(d3d_surface))
@@ -1548,11 +1588,11 @@ IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface,
if (!rsrc) if (!rsrc)
{ {
WARN("rsrc is NULL!\n"); WARN("rsrc is NULL!\n");
rsrc2.left = 0;
rsrc2.top = 0;
rsrc2.right = Src->currentDesc.Width;
rsrc2.bottom = Src->currentDesc.Height;
rsrc = &rsrc2; rsrc = &rsrc2;
rsrc->left = 0;
rsrc->top = 0;
rsrc->right = Src->currentDesc.Width;
rsrc->bottom = Src->currentDesc.Height;
} }
/* Check source rect for validity. Copied from normal Blt. Fixes Baldur's Gate.*/ /* Check source rect for validity. Copied from normal Blt. Fixes Baldur's Gate.*/
@@ -1670,15 +1710,15 @@ IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface,
} }
#define COPYBOX_COLORKEY(type) { \ #define COPYBOX_COLORKEY(type) { \
type *d, *s, tmp; \ const type *s = (const type *)sbuf; \
s = (type *) sbuf; \ type *d = (type *)dbuf; \
d = (type *) dbuf; \ type tmp; \
for (y = 0; y < h; y++) { \ for (y = 0; y < h; y++) { \
for (x = 0; x < w; x++) { \ for (x = 0; x < w; x++) { \
tmp = s[x]; \ tmp = s[x]; \
if (tmp < keylow || tmp > keyhigh) d[x] = tmp; \ if (tmp < keylow || tmp > keyhigh) d[x] = tmp; \
} \ } \
s = (type *)((BYTE *)s + slock.Pitch); \ s = (const type *)((const BYTE *)s + slock.Pitch); \
d = (type *)((BYTE *)d + dlock.Pitch); \ d = (type *)((BYTE *)d + dlock.Pitch); \
} \ } \
break; \ break; \
@@ -1690,7 +1730,8 @@ IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface,
case 4: COPYBOX_COLORKEY(DWORD) case 4: COPYBOX_COLORKEY(DWORD)
case 3: case 3:
{ {
BYTE *d, *s; const BYTE *s;
BYTE *d;
DWORD tmp; DWORD tmp;
s = sbuf; s = sbuf;
d = dbuf; d = dbuf;
@@ -1826,3 +1867,17 @@ void WINAPI IWineD3DBaseSurfaceImpl_BindTexture(IWineD3DSurface *iface) {
ERR("Should not be called on base texture\n"); ERR("Should not be called on base texture\n");
return; return;
} }
/* TODO: think about moving this down to resource? */
const void *WINAPI IWineD3DBaseSurfaceImpl_GetData(IWineD3DSurface *iface)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
/* This should only be called for sysmem textures, it may be a good idea
* to extend this to all pools at some point in the future */
if (This->resource.pool != WINED3DPOOL_SYSTEMMEM)
{
FIXME("(%p) Attempting to get system memory for a non-system memory texture\n", iface);
}
return This->resource.allocatedMemory;
}

View File

@@ -42,7 +42,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
* to destroy all the GL things. * to destroy all the GL things.
* *
*****************************************************************************/ *****************************************************************************/
ULONG WINAPI IWineGDISurfaceImpl_Release(IWineD3DSurface *iface) { static ULONG WINAPI IWineGDISurfaceImpl_Release(IWineD3DSurface *iface) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
ULONG ref = InterlockedDecrement(&This->resource.ref); ULONG ref = InterlockedDecrement(&This->resource.ref);
TRACE("(%p) : Releasing from %d\n", This, ref + 1); TRACE("(%p) : Releasing from %d\n", This, ref + 1);
@@ -62,7 +62,7 @@ ULONG WINAPI IWineGDISurfaceImpl_Release(IWineD3DSurface *iface) {
HeapFree(GetProcessHeap(), 0, This->palette9); HeapFree(GetProcessHeap(), 0, This->palette9);
IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface); resource_cleanup((IWineD3DResource *)iface);
if(This->overlay_dest) { if(This->overlay_dest) {
list_remove(&This->overlay_entry); list_remove(&This->overlay_entry);
@@ -168,7 +168,7 @@ IWineGDISurfaceImpl_UnlockRect(IWineD3DSurface *iface)
if (!(This->Flags & SFLAG_LOCKED)) if (!(This->Flags & SFLAG_LOCKED))
{ {
WARN("trying to Unlock an unlocked surf@%p\n", This); WARN("trying to Unlock an unlocked surf@%p\n", This);
return WINED3DERR_INVALIDCALL; return WINEDDERR_NOTLOCKED;
} }
/* Can be useful for debugging */ /* Can be useful for debugging */
@@ -245,7 +245,7 @@ IWineGDISurfaceImpl_Flip(IWineD3DSurface *iface,
* D3DERR_INVALIDCALL * D3DERR_INVALIDCALL
* *
*****************************************************************************/ *****************************************************************************/
HRESULT WINAPI static HRESULT WINAPI
IWineGDISurfaceImpl_LoadTexture(IWineD3DSurface *iface, BOOL srgb_mode) IWineGDISurfaceImpl_LoadTexture(IWineD3DSurface *iface, BOOL srgb_mode)
{ {
ERR("Unsupported on X11 surfaces\n"); ERR("Unsupported on X11 surfaces\n");
@@ -280,7 +280,7 @@ static int get_shift(DWORD color_mask) {
} }
HRESULT WINAPI static HRESULT WINAPI
IWineGDISurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, IWineGDISurfaceImpl_SaveSnapshot(IWineD3DSurface *iface,
const char* filename) const char* filename)
{ {
@@ -288,7 +288,7 @@ const char* filename)
UINT y = 0, x = 0; UINT y = 0, x = 0;
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
static char *output = NULL; static char *output = NULL;
static int size = 0; static UINT size = 0;
const StaticPixelFormatDesc *formatEntry = getFormatDescEntry(This->resource.format, NULL, NULL); const StaticPixelFormatDesc *formatEntry = getFormatDescEntry(This->resource.format, NULL, NULL);
if (This->pow2Width > size) { if (This->pow2Width > size) {
@@ -340,8 +340,8 @@ const char* filename)
alpha_shift = get_shift(formatEntry->alphaMask); alpha_shift = get_shift(formatEntry->alphaMask);
for (y = 0; y < This->pow2Height; y++) { for (y = 0; y < This->pow2Height; y++) {
unsigned char *src = This->resource.allocatedMemory + (y * 1 * IWineD3DSurface_GetPitch(iface)); const unsigned char *src = This->resource.allocatedMemory + (y * 1 * IWineD3DSurface_GetPitch(iface));
for (x = 0; x < This->pow2Width; x++) { for (x = 0; x < This->pow2Width; x++) {
unsigned int color; unsigned int color;
unsigned int comp; unsigned int comp;
int i; int i;
@@ -366,7 +366,7 @@ const char* filename)
return WINED3D_OK; return WINED3D_OK;
} }
HRESULT WINAPI IWineGDISurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) { static HRESULT WINAPI IWineGDISurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
WINED3DLOCKED_RECT lock; WINED3DLOCKED_RECT lock;
HRESULT hr; HRESULT hr;
@@ -405,7 +405,7 @@ HRESULT WINAPI IWineGDISurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
if(This->resource.format == WINED3DFMT_P8 || if(This->resource.format == WINED3DFMT_P8 ||
This->resource.format == WINED3DFMT_A8P8) { This->resource.format == WINED3DFMT_A8P8) {
unsigned int n; unsigned int n;
PALETTEENTRY *pal = NULL; const PALETTEENTRY *pal = NULL;
if(This->palette) { if(This->palette) {
pal = This->palette->palents; pal = This->palette->palents;
@@ -436,17 +436,17 @@ HRESULT WINAPI IWineGDISurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
return WINED3D_OK; return WINED3D_OK;
} }
HRESULT WINAPI IWineGDISurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) { static HRESULT WINAPI IWineGDISurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
TRACE("(%p)->(%p)\n",This,hDC); TRACE("(%p)->(%p)\n",This,hDC);
if (!(This->Flags & SFLAG_DCINUSE)) if (!(This->Flags & SFLAG_DCINUSE))
return WINED3DERR_INVALIDCALL; return WINEDDERR_NODC;
if (This->hDC !=hDC) { if (This->hDC !=hDC) {
WARN("Application tries to release an invalid DC(%p), surface dc is %p\n", hDC, This->hDC); WARN("Application tries to release an invalid DC(%p), surface dc is %p\n", hDC, This->hDC);
return WINED3DERR_INVALIDCALL; return WINEDDERR_NODC;
} }
/* we locked first, so unlock now */ /* we locked first, so unlock now */
@@ -457,7 +457,7 @@ HRESULT WINAPI IWineGDISurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) {
return WINED3D_OK; return WINED3D_OK;
} }
HRESULT WINAPI IWineGDISurfaceImpl_RealizePalette(IWineD3DSurface *iface) { static HRESULT WINAPI IWineGDISurfaceImpl_RealizePalette(IWineD3DSurface *iface) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
RGBQUAD col[256]; RGBQUAD col[256];
IWineD3DPaletteImpl *pal = This->palette; IWineD3DPaletteImpl *pal = This->palette;
@@ -507,7 +507,7 @@ HRESULT WINAPI IWineGDISurfaceImpl_RealizePalette(IWineD3DSurface *iface) {
* The return values of called methods on failure * The return values of called methods on failure
* *
*****************************************************************************/ *****************************************************************************/
HRESULT WINAPI static HRESULT WINAPI
IWineGDISurfaceImpl_PrivateSetup(IWineD3DSurface *iface) IWineGDISurfaceImpl_PrivateSetup(IWineD3DSurface *iface)
{ {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
@@ -534,21 +534,13 @@ IWineGDISurfaceImpl_PrivateSetup(IWineD3DSurface *iface)
return WINED3D_OK; return WINED3D_OK;
} }
void WINAPI IWineGDISurfaceImpl_GetGlDesc(IWineD3DSurface *iface, glDescriptor **glDescription) { static void WINAPI IWineGDISurfaceImpl_GetGlDesc(IWineD3DSurface *iface, glDescriptor **glDescription) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
FIXME("(%p) : Should not be called on a GDI surface\n", This); FIXME("(%p) : Should not be called on a GDI surface\n", This);
*glDescription = NULL; *glDescription = NULL;
} }
HRESULT WINAPI IWineGDISurfaceImpl_AddDirtyRect(IWineD3DSurface *iface, CONST RECT* pDirtyRect) { static HRESULT WINAPI IWineGDISurfaceImpl_SetMem(IWineD3DSurface *iface, void *Mem) {
/* GDI surface data can only be in one location, the system memory dib section. So they are
* always clean by definition.
*/
TRACE("No dirtification in GDI surfaces\n");
return WINED3D_OK;
}
HRESULT WINAPI IWineGDISurfaceImpl_SetMem(IWineD3DSurface *iface, void *Mem) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface; IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
/* Render targets depend on their hdc, and we can't create an hdc on a user pointer */ /* Render targets depend on their hdc, and we can't create an hdc on a user pointer */
@@ -673,13 +665,12 @@ const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl =
IWineD3DBaseSurfaceImpl_SetClipper, IWineD3DBaseSurfaceImpl_SetClipper,
IWineD3DBaseSurfaceImpl_GetClipper, IWineD3DBaseSurfaceImpl_GetClipper,
/* Internal use: */ /* Internal use: */
IWineGDISurfaceImpl_AddDirtyRect,
IWineGDISurfaceImpl_LoadTexture, IWineGDISurfaceImpl_LoadTexture,
IWineD3DBaseSurfaceImpl_BindTexture, IWineD3DBaseSurfaceImpl_BindTexture,
IWineGDISurfaceImpl_SaveSnapshot, IWineGDISurfaceImpl_SaveSnapshot,
IWineD3DBaseSurfaceImpl_SetContainer, IWineD3DBaseSurfaceImpl_SetContainer,
IWineGDISurfaceImpl_GetGlDesc, IWineGDISurfaceImpl_GetGlDesc,
IWineD3DSurfaceImpl_GetData, IWineD3DBaseSurfaceImpl_GetData,
IWineD3DBaseSurfaceImpl_SetFormat, IWineD3DBaseSurfaceImpl_SetFormat,
IWineGDISurfaceImpl_PrivateSetup, IWineGDISurfaceImpl_PrivateSetup,
IWineGDISurfaceImpl_ModifyLocation, IWineGDISurfaceImpl_ModifyLocation,

View File

@@ -39,7 +39,7 @@ WINE_DECLARE_DEBUG_CHANNEL(fps);
static void WINAPI IWineD3DSwapChainImpl_Destroy(IWineD3DSwapChain *iface, D3DCB_DESTROYSURFACEFN D3DCB_DestroyRenderTarget) { static void WINAPI IWineD3DSwapChainImpl_Destroy(IWineD3DSwapChain *iface, D3DCB_DESTROYSURFACEFN D3DCB_DestroyRenderTarget) {
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface; IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
WINED3DDISPLAYMODE mode; WINED3DDISPLAYMODE mode;
int i; unsigned int i;
TRACE("Destroying swapchain %p\n", iface); TRACE("Destroying swapchain %p\n", iface);
@@ -54,7 +54,7 @@ static void WINAPI IWineD3DSwapChainImpl_Destroy(IWineD3DSwapChain *iface, D3DCB
} }
if(This->backBuffer) { if(This->backBuffer) {
int i; UINT i;
for(i = 0; i < This->presentParms.BackBufferCount; i++) { for(i = 0; i < This->presentParms.BackBufferCount; i++) {
IWineD3DSurface_SetContainer(This->backBuffer[i], 0); IWineD3DSurface_SetContainer(This->backBuffer[i], 0);
if(D3DCB_DestroyRenderTarget(This->backBuffer[i]) > 0) { if(D3DCB_DestroyRenderTarget(This->backBuffer[i]) > 0) {
@@ -138,7 +138,7 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO
IWineD3DSurface_BltFast(This->backBuffer[0], 0, 0, This->wineD3DDevice->logo_surface, NULL, WINEDDBLTFAST_SRCCOLORKEY); IWineD3DSurface_BltFast(This->backBuffer[0], 0, 0, This->wineD3DDevice->logo_surface, NULL, WINEDDBLTFAST_SRCCOLORKEY);
} }
if (pSourceRect || pDestRect) FIXME("Unhandled present options %p/%p\n", pSourceRect, pDestRect); if (pSourceRect || pDestRect) FIXME("Unhandled present rects %s/%s\n", wine_dbgstr_rect(pSourceRect), wine_dbgstr_rect(pDestRect));
/* TODO: If only source rect or dest rect are supplied then clip the window to match */ /* TODO: If only source rect or dest rect are supplied then clip the window to match */
TRACE("presetting HDC %p\n", This->context[0]->hdc); TRACE("presetting HDC %p\n", This->context[0]->hdc);

View File

@@ -122,13 +122,14 @@ HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetBackBuffer(IWineD3DSwapChain *iface,
HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetRasterStatus(IWineD3DSwapChain *iface, WINED3DRASTER_STATUS *pRasterStatus) { HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetRasterStatus(IWineD3DSwapChain *iface, WINED3DRASTER_STATUS *pRasterStatus) {
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface; IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
static BOOL showFixmes = TRUE; static BOOL warned;
pRasterStatus->InVBlank = TRUE; pRasterStatus->InVBlank = TRUE;
pRasterStatus->ScanLine = 0; pRasterStatus->ScanLine = 0;
/* No openGL equivalent */ /* No openGL equivalent */
if(showFixmes) { if (!warned)
{
FIXME("(%p) : stub (once)\n", This); FIXME("(%p) : stub (once)\n", This);
showFixmes = FALSE; warned = TRUE;
} }
return WINED3D_OK; return WINED3D_OK;
} }

View File

@@ -44,7 +44,7 @@ static void WINAPI IWineGDISwapChainImpl_Destroy(IWineD3DSwapChain *iface, D3DCB
} }
if(This->backBuffer) { if(This->backBuffer) {
int i; UINT i;
for(i = 0; i < This->presentParms.BackBufferCount; i++) { for(i = 0; i < This->presentParms.BackBufferCount; i++) {
IWineD3DSurface_SetContainer(This->backBuffer[i], 0); IWineD3DSurface_SetContainer(This->backBuffer[i], 0);
if(D3DCB_DestroyRenderback(This->backBuffer[i]) > 0) { if(D3DCB_DestroyRenderback(This->backBuffer[i]) > 0) {
@@ -80,7 +80,8 @@ static void WINAPI IWineGDISwapChainImpl_Destroy(IWineD3DSwapChain *iface, D3DCB
* rc: Rectangle to copy * rc: Rectangle to copy
* *
*****************************************************************************/ *****************************************************************************/
void x11_copy_to_screen(IWineD3DSwapChainImpl *This, LPRECT rc) { void x11_copy_to_screen(IWineD3DSwapChainImpl *This, const RECT *rc)
{
IWineD3DSurfaceImpl *front = (IWineD3DSurfaceImpl *) This->frontBuffer; IWineD3DSurfaceImpl *front = (IWineD3DSurfaceImpl *) This->frontBuffer;
if(front->resource.usage & WINED3DUSAGE_RENDERTARGET) { if(front->resource.usage & WINED3DUSAGE_RENDERTARGET) {
@@ -238,18 +239,6 @@ static HRESULT WINAPI IWineGDISwapChainImpl_Present(IWineD3DSwapChain *iface, CO
return WINED3D_OK; return WINED3D_OK;
} }
/* FIXME: This should not be needed, the base version is OK */
HRESULT WINAPI IWineGDIBaseSwapChainImpl_GetDisplayMode(IWineD3DSwapChain *iface, WINED3DDISPLAYMODE*pMode) {
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
IWineD3DDeviceImpl *device = This->wineD3DDevice;
pMode->Width = device->ddraw_width;
pMode->Height = device->ddraw_height;
pMode->Format = device->ddraw_format;
pMode->RefreshRate = 0;
return WINED3D_OK;
}
const IWineD3DSwapChainVtbl IWineGDISwapChain_Vtbl = const IWineD3DSwapChainVtbl IWineGDISwapChain_Vtbl =
{ {
/* IUnknown */ /* IUnknown */

View File

@@ -69,27 +69,27 @@ static ULONG WINAPI IWineD3DTextureImpl_Release(IWineD3DTexture *iface) {
IWineD3DTexture IWineD3DResource parts follow IWineD3DTexture IWineD3DResource parts follow
**************************************************** */ **************************************************** */
static HRESULT WINAPI IWineD3DTextureImpl_GetDevice(IWineD3DTexture *iface, IWineD3DDevice** ppDevice) { static HRESULT WINAPI IWineD3DTextureImpl_GetDevice(IWineD3DTexture *iface, IWineD3DDevice** ppDevice) {
return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice); return resource_get_device((IWineD3DResource *)iface, ppDevice);
} }
static HRESULT WINAPI IWineD3DTextureImpl_SetPrivateData(IWineD3DTexture *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) { static HRESULT WINAPI IWineD3DTextureImpl_SetPrivateData(IWineD3DTexture *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags); return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
} }
static HRESULT WINAPI IWineD3DTextureImpl_GetPrivateData(IWineD3DTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) { static HRESULT WINAPI IWineD3DTextureImpl_GetPrivateData(IWineD3DTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData); return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
} }
static HRESULT WINAPI IWineD3DTextureImpl_FreePrivateData(IWineD3DTexture *iface, REFGUID refguid) { static HRESULT WINAPI IWineD3DTextureImpl_FreePrivateData(IWineD3DTexture *iface, REFGUID refguid) {
return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid); return resource_free_private_data((IWineD3DResource *)iface, refguid);
} }
static DWORD WINAPI IWineD3DTextureImpl_SetPriority(IWineD3DTexture *iface, DWORD PriorityNew) { static DWORD WINAPI IWineD3DTextureImpl_SetPriority(IWineD3DTexture *iface, DWORD PriorityNew) {
return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew); return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
} }
static DWORD WINAPI IWineD3DTextureImpl_GetPriority(IWineD3DTexture *iface) { static DWORD WINAPI IWineD3DTextureImpl_GetPriority(IWineD3DTexture *iface) {
return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface); return resource_get_priority((IWineD3DResource *)iface);
} }
static void WINAPI IWineD3DTextureImpl_PreLoad(IWineD3DTexture *iface) { static void WINAPI IWineD3DTextureImpl_PreLoad(IWineD3DTexture *iface) {
@@ -137,7 +137,7 @@ static void WINAPI IWineD3DTextureImpl_PreLoad(IWineD3DTexture *iface) {
FIXME("Texture (%p) has been reloaded at least 20 times due to WINED3DSAMP_SRGBTEXTURE changes on it\'s sampler\n", This); FIXME("Texture (%p) has been reloaded at least 20 times due to WINED3DSAMP_SRGBTEXTURE changes on it\'s sampler\n", This);
for (i = 0; i < This->baseTexture.levels; i++) { for (i = 0; i < This->baseTexture.levels; i++) {
IWineD3DSurface_AddDirtyRect(This->surfaces[i], NULL); surface_add_dirty_rect(This->surfaces[i], NULL);
surface_force_reload(This->surfaces[i]); surface_force_reload(This->surfaces[i]);
IWineD3DSurface_LoadTexture(This->surfaces[i], srgb_mode); IWineD3DSurface_LoadTexture(This->surfaces[i], srgb_mode);
} }
@@ -165,51 +165,51 @@ static void WINAPI IWineD3DTextureImpl_UnLoad(IWineD3DTexture *iface) {
surface_set_texture_name(This->surfaces[i], 0); surface_set_texture_name(This->surfaces[i], 0);
} }
IWineD3DBaseTextureImpl_UnLoad((IWineD3DBaseTexture *) iface); basetexture_unload((IWineD3DBaseTexture *)iface);
} }
static WINED3DRESOURCETYPE WINAPI IWineD3DTextureImpl_GetType(IWineD3DTexture *iface) { static WINED3DRESOURCETYPE WINAPI IWineD3DTextureImpl_GetType(IWineD3DTexture *iface) {
return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface); return resource_get_type((IWineD3DResource *)iface);
} }
static HRESULT WINAPI IWineD3DTextureImpl_GetParent(IWineD3DTexture *iface, IUnknown **pParent) { static HRESULT WINAPI IWineD3DTextureImpl_GetParent(IWineD3DTexture *iface, IUnknown **pParent) {
return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent); return resource_get_parent((IWineD3DResource *)iface, pParent);
} }
/* ****************************************************** /* ******************************************************
IWineD3DTexture IWineD3DBaseTexture parts follow IWineD3DTexture IWineD3DBaseTexture parts follow
****************************************************** */ ****************************************************** */
static DWORD WINAPI IWineD3DTextureImpl_SetLOD(IWineD3DTexture *iface, DWORD LODNew) { static DWORD WINAPI IWineD3DTextureImpl_SetLOD(IWineD3DTexture *iface, DWORD LODNew) {
return IWineD3DBaseTextureImpl_SetLOD((IWineD3DBaseTexture *)iface, LODNew); return basetexture_set_lod((IWineD3DBaseTexture *)iface, LODNew);
} }
static DWORD WINAPI IWineD3DTextureImpl_GetLOD(IWineD3DTexture *iface) { static DWORD WINAPI IWineD3DTextureImpl_GetLOD(IWineD3DTexture *iface) {
return IWineD3DBaseTextureImpl_GetLOD((IWineD3DBaseTexture *)iface); return basetexture_get_lod((IWineD3DBaseTexture *)iface);
} }
static DWORD WINAPI IWineD3DTextureImpl_GetLevelCount(IWineD3DTexture *iface) { static DWORD WINAPI IWineD3DTextureImpl_GetLevelCount(IWineD3DTexture *iface) {
return IWineD3DBaseTextureImpl_GetLevelCount((IWineD3DBaseTexture *)iface); return basetexture_get_level_count((IWineD3DBaseTexture *)iface);
} }
static HRESULT WINAPI IWineD3DTextureImpl_SetAutoGenFilterType(IWineD3DTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType) { static HRESULT WINAPI IWineD3DTextureImpl_SetAutoGenFilterType(IWineD3DTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType) {
return IWineD3DBaseTextureImpl_SetAutoGenFilterType((IWineD3DBaseTexture *)iface, FilterType); return basetexture_set_autogen_filter_type((IWineD3DBaseTexture *)iface, FilterType);
} }
static WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DTextureImpl_GetAutoGenFilterType(IWineD3DTexture *iface) { static WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DTextureImpl_GetAutoGenFilterType(IWineD3DTexture *iface) {
return IWineD3DBaseTextureImpl_GetAutoGenFilterType((IWineD3DBaseTexture *)iface); return basetexture_get_autogen_filter_type((IWineD3DBaseTexture *)iface);
} }
static void WINAPI IWineD3DTextureImpl_GenerateMipSubLevels(IWineD3DTexture *iface) { static void WINAPI IWineD3DTextureImpl_GenerateMipSubLevels(IWineD3DTexture *iface) {
IWineD3DBaseTextureImpl_GenerateMipSubLevels((IWineD3DBaseTexture *)iface); basetexture_generate_mipmaps((IWineD3DBaseTexture *)iface);
} }
/* Internal function, No d3d mapping */ /* Internal function, No d3d mapping */
static BOOL WINAPI IWineD3DTextureImpl_SetDirty(IWineD3DTexture *iface, BOOL dirty) { static BOOL WINAPI IWineD3DTextureImpl_SetDirty(IWineD3DTexture *iface, BOOL dirty) {
return IWineD3DBaseTextureImpl_SetDirty((IWineD3DBaseTexture *)iface, dirty); return basetexture_set_dirty((IWineD3DBaseTexture *)iface, dirty);
} }
static BOOL WINAPI IWineD3DTextureImpl_GetDirty(IWineD3DTexture *iface) { static BOOL WINAPI IWineD3DTextureImpl_GetDirty(IWineD3DTexture *iface) {
return IWineD3DBaseTextureImpl_GetDirty((IWineD3DBaseTexture *)iface); return basetexture_get_dirty((IWineD3DBaseTexture *)iface);
} }
static HRESULT WINAPI IWineD3DTextureImpl_BindTexture(IWineD3DTexture *iface) { static HRESULT WINAPI IWineD3DTextureImpl_BindTexture(IWineD3DTexture *iface) {
@@ -219,7 +219,7 @@ static HRESULT WINAPI IWineD3DTextureImpl_BindTexture(IWineD3DTexture *iface) {
TRACE("(%p) : relay to BaseTexture\n", This); TRACE("(%p) : relay to BaseTexture\n", This);
hr = IWineD3DBaseTextureImpl_BindTexture((IWineD3DBaseTexture *)iface); hr = basetexture_bind((IWineD3DBaseTexture *)iface);
if (set_gl_texture_desc && SUCCEEDED(hr)) { if (set_gl_texture_desc && SUCCEEDED(hr)) {
UINT i; UINT i;
for (i = 0; i < This->baseTexture.levels; ++i) { for (i = 0; i < This->baseTexture.levels; ++i) {
@@ -270,7 +270,7 @@ static void WINAPI IWineD3DTextureImpl_ApplyStateChanges(IWineD3DTexture *iface,
const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1], const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1],
const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]) { const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]) {
TRACE("(%p) : relay to BaseTexture\n", iface); TRACE("(%p) : relay to BaseTexture\n", iface);
IWineD3DBaseTextureImpl_ApplyStateChanges((IWineD3DBaseTexture *)iface, textureStates, samplerStates); basetexture_apply_state_changes((IWineD3DBaseTexture *)iface, textureStates, samplerStates);
} }
/* ******************************************* /* *******************************************
@@ -291,7 +291,7 @@ static void WINAPI IWineD3DTextureImpl_Destroy(IWineD3DTexture *iface, D3DCB_DES
} }
} }
TRACE("(%p) : cleaning up base texture\n", This); TRACE("(%p) : cleaning up base texture\n", This);
IWineD3DBaseTextureImpl_CleanUp((IWineD3DBaseTexture *)iface); basetexture_cleanup((IWineD3DBaseTexture *)iface);
/* free the object */ /* free the object */
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
@@ -303,7 +303,7 @@ static HRESULT WINAPI IWineD3DTextureImpl_GetLevelDesc(IWineD3DTexture *iface, U
TRACE("(%p) Level (%d)\n", This, Level); TRACE("(%p) Level (%d)\n", This, Level);
return IWineD3DSurface_GetDesc(This->surfaces[Level], pDesc); return IWineD3DSurface_GetDesc(This->surfaces[Level], pDesc);
} }
FIXME("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels); WARN("(%p) level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
@@ -360,7 +360,9 @@ static HRESULT WINAPI IWineD3DTextureImpl_AddDirtyRect(IWineD3DTexture *iface, C
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface; IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
This->baseTexture.dirty = TRUE; This->baseTexture.dirty = TRUE;
TRACE("(%p) : dirtyfication of surface Level (0)\n", This); TRACE("(%p) : dirtyfication of surface Level (0)\n", This);
return IWineD3DSurface_AddDirtyRect(This->surfaces[0], pDirtyRect); surface_add_dirty_rect(This->surfaces[0], pDirtyRect);
return WINED3D_OK;
} }
const IWineD3DTextureVtbl IWineD3DTexture_Vtbl = const IWineD3DTextureVtbl IWineD3DTexture_Vtbl =

View File

@@ -167,7 +167,7 @@ static const GlPixelFormatDescTemplate gl_formats_template[] = {
/* IEEE formats */ /* IEEE formats */
{WINED3DFMT_R32F ,GL_RGB32F_ARB ,GL_RGB32F_ARB , 0, GL_RED ,GL_FLOAT {WINED3DFMT_R32F ,GL_RGB32F_ARB ,GL_RGB32F_ARB , 0, GL_RED ,GL_FLOAT
,WINED3DFMT_FLAG_RENDERTARGET }, ,WINED3DFMT_FLAG_RENDERTARGET },
{WINED3DFMT_G32R32F ,0 ,0 , 0, 0 ,0 {WINED3DFMT_G32R32F ,GL_RG32F ,GL_RG32F , 0, GL_RG ,GL_FLOAT
,WINED3DFMT_FLAG_RENDERTARGET }, ,WINED3DFMT_FLAG_RENDERTARGET },
{WINED3DFMT_A32B32G32R32F ,GL_RGBA32F_ARB ,GL_RGBA32F_ARB , 0, GL_RGBA ,GL_FLOAT {WINED3DFMT_A32B32G32R32F ,GL_RGBA32F_ARB ,GL_RGBA32F_ARB , 0, GL_RGBA ,GL_FLOAT
,WINED3DFMT_FLAG_RENDERTARGET }, ,WINED3DFMT_FLAG_RENDERTARGET },
@@ -177,7 +177,7 @@ static const GlPixelFormatDescTemplate gl_formats_template[] = {
/* Float */ /* Float */
{WINED3DFMT_R16F ,GL_RGB16F_ARB ,GL_RGB16F_ARB , 0, GL_RED ,GL_HALF_FLOAT_ARB {WINED3DFMT_R16F ,GL_RGB16F_ARB ,GL_RGB16F_ARB , 0, GL_RED ,GL_HALF_FLOAT_ARB
,WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET }, ,WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET },
{WINED3DFMT_G16R16F ,0 ,0 , 0, 0 ,0 {WINED3DFMT_G16R16F ,GL_RG16F ,GL_RG16F , 0, GL_RG ,GL_HALF_FLOAT_ARB
,WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET }, ,WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET },
{WINED3DFMT_A16B16G16R16F ,GL_RGBA16F_ARB ,GL_RGBA16F_ARB , 0, GL_RGBA ,GL_HALF_FLOAT_ARB {WINED3DFMT_A16B16G16R16F ,GL_RGBA16F_ARB ,GL_RGBA16F_ARB , 0, GL_RGBA ,GL_HALF_FLOAT_ARB
,WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET }, ,WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET },
@@ -318,7 +318,7 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)
gl_info->gl_formats[dst].glGammaInternal = gl_formats_template[src].glGammaInternal; gl_info->gl_formats[dst].glGammaInternal = gl_formats_template[src].glGammaInternal;
gl_info->gl_formats[dst].glFormat = gl_formats_template[src].glFormat; gl_info->gl_formats[dst].glFormat = gl_formats_template[src].glFormat;
gl_info->gl_formats[dst].glType = gl_formats_template[src].glType; gl_info->gl_formats[dst].glType = gl_formats_template[src].glType;
gl_info->gl_formats[dst].conversion_group= WINED3DFMT_UNKNOWN; gl_info->gl_formats[dst].color_fixup = COLOR_FIXUP_IDENTITY;
gl_info->gl_formats[dst].Flags = gl_formats_template[src].Flags; gl_info->gl_formats[dst].Flags = gl_formats_template[src].Flags;
gl_info->gl_formats[dst].heightscale = 1.0; gl_info->gl_formats[dst].heightscale = 1.0;
@@ -363,29 +363,64 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)
} }
} }
dst = getFmtIdx(WINED3DFMT_R16F);
gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
/* When ARB_texture_rg is supported we only require 16-bit for R16F instead of 64-bit RGBA16F */
if(GL_SUPPORT(ARB_TEXTURE_RG))
{
gl_info->gl_formats[dst].glInternal = GL_R16F;
gl_info->gl_formats[dst].glGammaInternal = GL_R16F;
}
dst = getFmtIdx(WINED3DFMT_R32F);
gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
/* When ARB_texture_rg is supported we only require 32-bit for R32F instead of 128-bit RGBA32F */
if(GL_SUPPORT(ARB_TEXTURE_RG))
{
gl_info->gl_formats[dst].glInternal = GL_R32F;
gl_info->gl_formats[dst].glGammaInternal = GL_R32F;
}
dst = getFmtIdx(WINED3DFMT_G16R16);
gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
dst = getFmtIdx(WINED3DFMT_G16R16F);
gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
dst = getFmtIdx(WINED3DFMT_G32R32F);
gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
/* V8U8 is supported natively by GL_ATI_envmap_bumpmap and GL_NV_texture_shader. /* V8U8 is supported natively by GL_ATI_envmap_bumpmap and GL_NV_texture_shader.
* V16U16 is only supported by GL_NV_texture_shader. The formats need fixup if * V16U16 is only supported by GL_NV_texture_shader. The formats need fixup if
* their extensions are not available. * their extensions are not available. GL_ATI_envmap_bumpmap is not used because
* the only driver that implements it(fglrx) has a buggy implementation.
* *
* In theory, V8U8 and V16U16 need a fixup of the undefined blue channel. OpenGL * V8U8 and V16U16 need a fixup of the undefined blue channel. OpenGL
* returns 0.0 when sampling from it, DirectX 1.0. This is disabled until we find * returns 0.0 when sampling from it, DirectX 1.0. So we always have in-shader
* an application that needs this because it causes performance problems due to * conversion for this format.
* shader recompiling in some games.
*/ */
if(!GL_SUPPORT(NV_TEXTURE_SHADER2)) { if (!GL_SUPPORT(NV_TEXTURE_SHADER))
/* signed -> unsigned fixup */ {
dst = getFmtIdx(WINED3DFMT_V8U8); dst = getFmtIdx(WINED3DFMT_V8U8);
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_V8U8; gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
dst = getFmtIdx(WINED3DFMT_V16U16); dst = getFmtIdx(WINED3DFMT_V16U16);
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_V8U8; gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
} else { 1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
/* Blue = 1.0 fixup, disabled for now */ }
if(0) { else
dst = getFmtIdx(WINED3DFMT_V8U8); {
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_V8U8; dst = getFmtIdx(WINED3DFMT_V8U8);
dst = getFmtIdx(WINED3DFMT_V16U16); gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_V8U8; 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
} dst = getFmtIdx(WINED3DFMT_V16U16);
gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
} }
if(!GL_SUPPORT(NV_TEXTURE_SHADER)) { if(!GL_SUPPORT(NV_TEXTURE_SHADER)) {
@@ -393,11 +428,14 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)
* with each other * with each other
*/ */
dst = getFmtIdx(WINED3DFMT_L6V5U5); dst = getFmtIdx(WINED3DFMT_L6V5U5);
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_L6V5U5; gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE);
dst = getFmtIdx(WINED3DFMT_X8L8V8U8); dst = getFmtIdx(WINED3DFMT_X8L8V8U8);
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_X8L8V8U8; gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_W);
dst = getFmtIdx(WINED3DFMT_Q8W8V8U8); dst = getFmtIdx(WINED3DFMT_Q8W8V8U8);
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_Q8W8V8U8; gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 1, CHANNEL_SOURCE_Z, 1, CHANNEL_SOURCE_W);
} else { } else {
/* If GL_NV_texture_shader is supported, WINED3DFMT_L6V5U5 and WINED3DFMT_X8L8V8U8 /* If GL_NV_texture_shader is supported, WINED3DFMT_L6V5U5 and WINED3DFMT_X8L8V8U8
* are converted at surface loading time, but they do not need any modification in * are converted at surface loading time, but they do not need any modification in
@@ -410,12 +448,14 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)
dst = getFmtIdx(WINED3DFMT_ATI2N); dst = getFmtIdx(WINED3DFMT_ATI2N);
gl_info->gl_formats[dst].glInternal = GL_COMPRESSED_RED_GREEN_RGTC2_EXT; gl_info->gl_formats[dst].glInternal = GL_COMPRESSED_RED_GREEN_RGTC2_EXT;
gl_info->gl_formats[dst].glGammaInternal = GL_COMPRESSED_RED_GREEN_RGTC2_EXT; gl_info->gl_formats[dst].glGammaInternal = GL_COMPRESSED_RED_GREEN_RGTC2_EXT;
gl_info->gl_formats[dst].conversion_group= WINED3DFMT_ATI2N; gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
} else if(GL_SUPPORT(ATI_TEXTURE_COMPRESSION_3DC)) { } else if(GL_SUPPORT(ATI_TEXTURE_COMPRESSION_3DC)) {
dst = getFmtIdx(WINED3DFMT_ATI2N); dst = getFmtIdx(WINED3DFMT_ATI2N);
gl_info->gl_formats[dst].glInternal = GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI; gl_info->gl_formats[dst].glInternal = GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI;
gl_info->gl_formats[dst].glGammaInternal = GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI; gl_info->gl_formats[dst].glGammaInternal = GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI;
gl_info->gl_formats[dst].conversion_group= WINED3DFMT_ATI2N; gl_info->gl_formats[dst].color_fixup= create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_W, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
} }
if(!GL_SUPPORT(APPLE_YCBCR_422)) { if(!GL_SUPPORT(APPLE_YCBCR_422)) {
@@ -424,51 +464,60 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)
gl_info->gl_formats[dst].glGammaInternal = GL_LUMINANCE_ALPHA; /* not srgb */ gl_info->gl_formats[dst].glGammaInternal = GL_LUMINANCE_ALPHA; /* not srgb */
gl_info->gl_formats[dst].glFormat = GL_LUMINANCE_ALPHA; gl_info->gl_formats[dst].glFormat = GL_LUMINANCE_ALPHA;
gl_info->gl_formats[dst].glType = GL_UNSIGNED_BYTE; gl_info->gl_formats[dst].glType = GL_UNSIGNED_BYTE;
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_YUY2; gl_info->gl_formats[dst].color_fixup = create_yuv_fixup_desc(YUV_FIXUP_YUY2);
dst = getFmtIdx(WINED3DFMT_UYVY); dst = getFmtIdx(WINED3DFMT_UYVY);
gl_info->gl_formats[dst].glInternal = GL_LUMINANCE_ALPHA; gl_info->gl_formats[dst].glInternal = GL_LUMINANCE_ALPHA;
gl_info->gl_formats[dst].glGammaInternal = GL_LUMINANCE_ALPHA; /* not srgb */ gl_info->gl_formats[dst].glGammaInternal = GL_LUMINANCE_ALPHA; /* not srgb */
gl_info->gl_formats[dst].glFormat = GL_LUMINANCE_ALPHA; gl_info->gl_formats[dst].glFormat = GL_LUMINANCE_ALPHA;
gl_info->gl_formats[dst].glType = GL_UNSIGNED_BYTE; gl_info->gl_formats[dst].glType = GL_UNSIGNED_BYTE;
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_UYVY; gl_info->gl_formats[dst].color_fixup = create_yuv_fixup_desc(YUV_FIXUP_UYVY);
} }
dst = getFmtIdx(WINED3DFMT_YV12); dst = getFmtIdx(WINED3DFMT_YV12);
gl_info->gl_formats[dst].heightscale = 1.5; gl_info->gl_formats[dst].heightscale = 1.5;
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_YV12; gl_info->gl_formats[dst].color_fixup = create_yuv_fixup_desc(YUV_FIXUP_YV12);
return TRUE; return TRUE;
} }
/* NOTE: Make sure these are in the correct numerical order. (see /include/wined3d_types.h) */ /* NOTE: Make sure these are in the correct numerical order. (see /include/wined3d_types.h) */
static WINED3DGLTYPE const glTypeLookupTemplate[WINED3DDECLTYPE_UNUSED] = { static WINED3DGLTYPE const glTypeLookupTemplate[WINED3DDECLTYPE_UNUSED] =
{WINED3DDECLTYPE_FLOAT1, 1, GL_FLOAT , GL_FALSE ,sizeof(float)}, {
{WINED3DDECLTYPE_FLOAT2, 2, GL_FLOAT , GL_FALSE ,sizeof(float)}, {WINED3DDECLTYPE_FLOAT1, 1, GL_FLOAT, 1, GL_FALSE, sizeof(float)},
{WINED3DDECLTYPE_FLOAT3, 3, GL_FLOAT , GL_FALSE ,sizeof(float)}, {WINED3DDECLTYPE_FLOAT2, 2, GL_FLOAT, 2, GL_FALSE, sizeof(float)},
{WINED3DDECLTYPE_FLOAT4, 4, GL_FLOAT , GL_FALSE ,sizeof(float)}, {WINED3DDECLTYPE_FLOAT3, 3, GL_FLOAT, 3, GL_FALSE, sizeof(float)},
{WINED3DDECLTYPE_D3DCOLOR, 4, GL_UNSIGNED_BYTE , GL_TRUE ,sizeof(BYTE)}, {WINED3DDECLTYPE_FLOAT4, 4, GL_FLOAT, 4, GL_FALSE, sizeof(float)},
{WINED3DDECLTYPE_UBYTE4, 4, GL_UNSIGNED_BYTE , GL_FALSE ,sizeof(BYTE)}, {WINED3DDECLTYPE_D3DCOLOR, 4, GL_UNSIGNED_BYTE, 4, GL_TRUE, sizeof(BYTE)},
{WINED3DDECLTYPE_SHORT2, 2, GL_SHORT , GL_FALSE ,sizeof(short int)}, {WINED3DDECLTYPE_UBYTE4, 4, GL_UNSIGNED_BYTE, 4, GL_FALSE, sizeof(BYTE)},
{WINED3DDECLTYPE_SHORT4, 4, GL_SHORT , GL_FALSE ,sizeof(short int)}, {WINED3DDECLTYPE_SHORT2, 2, GL_SHORT, 2, GL_FALSE, sizeof(short int)},
{WINED3DDECLTYPE_UBYTE4N, 4, GL_UNSIGNED_BYTE , GL_TRUE ,sizeof(BYTE)}, {WINED3DDECLTYPE_SHORT4, 4, GL_SHORT, 4, GL_FALSE, sizeof(short int)},
{WINED3DDECLTYPE_SHORT2N, 2, GL_SHORT , GL_TRUE ,sizeof(short int)}, {WINED3DDECLTYPE_UBYTE4N, 4, GL_UNSIGNED_BYTE, 4, GL_TRUE, sizeof(BYTE)},
{WINED3DDECLTYPE_SHORT4N, 4, GL_SHORT , GL_TRUE ,sizeof(short int)}, {WINED3DDECLTYPE_SHORT2N, 2, GL_SHORT, 2, GL_TRUE, sizeof(short int)},
{WINED3DDECLTYPE_USHORT2N, 2, GL_UNSIGNED_SHORT , GL_TRUE ,sizeof(short int)}, {WINED3DDECLTYPE_SHORT4N, 4, GL_SHORT, 4, GL_TRUE, sizeof(short int)},
{WINED3DDECLTYPE_USHORT4N, 4, GL_UNSIGNED_SHORT , GL_TRUE ,sizeof(short int)}, {WINED3DDECLTYPE_USHORT2N, 2, GL_UNSIGNED_SHORT, 2, GL_TRUE, sizeof(short int)},
{WINED3DDECLTYPE_UDEC3, 3, GL_UNSIGNED_SHORT , GL_FALSE ,sizeof(short int)}, {WINED3DDECLTYPE_USHORT4N, 4, GL_UNSIGNED_SHORT, 4, GL_TRUE, sizeof(short int)},
{WINED3DDECLTYPE_DEC3N, 3, GL_SHORT , GL_TRUE ,sizeof(short int)}, {WINED3DDECLTYPE_UDEC3, 3, GL_UNSIGNED_SHORT, 3, GL_FALSE, sizeof(short int)},
{WINED3DDECLTYPE_FLOAT16_2, 2, GL_HALF_FLOAT_NV , GL_FALSE ,sizeof(GLhalfNV)}, {WINED3DDECLTYPE_DEC3N, 3, GL_SHORT, 3, GL_TRUE, sizeof(short int)},
{WINED3DDECLTYPE_FLOAT16_4, 4, GL_HALF_FLOAT_NV , GL_FALSE ,sizeof(GLhalfNV)}}; {WINED3DDECLTYPE_FLOAT16_2, 2, GL_FLOAT, 2, GL_FALSE, sizeof(GLhalfNV)},
{WINED3DDECLTYPE_FLOAT16_4, 4, GL_FLOAT, 4, GL_FALSE, sizeof(GLhalfNV)}
};
void init_type_lookup(WineD3D_GL_Info *gl_info) { void init_type_lookup(WineD3D_GL_Info *gl_info) {
memcpy(gl_info->glTypeLookup, glTypeLookupTemplate, sizeof(glTypeLookupTemplate)); memcpy(gl_info->glTypeLookup, glTypeLookupTemplate, sizeof(glTypeLookupTemplate));
if(!GL_SUPPORT(NV_HALF_FLOAT)) {
if (GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA))
{
gl_info->glTypeLookup[WINED3DDECLTYPE_D3DCOLOR].format = GL_BGRA;
}
if (GL_SUPPORT(NV_HALF_FLOAT))
{
/* Do not change the size of the type, it is CPU side. We have to change the GPU-side information though. /* Do not change the size of the type, it is CPU side. We have to change the GPU-side information though.
* It is the job of the vertex buffer code to make sure that the vbos have the right format * It is the job of the vertex buffer code to make sure that the vbos have the right format
*/ */
gl_info->glTypeLookup[WINED3DDECLTYPE_FLOAT16_2].glType = GL_FLOAT; gl_info->glTypeLookup[WINED3DDECLTYPE_FLOAT16_2].glType = GL_HALF_FLOAT_NV;
gl_info->glTypeLookup[WINED3DDECLTYPE_FLOAT16_4].glType = GL_FLOAT; gl_info->glTypeLookup[WINED3DDECLTYPE_FLOAT16_4].glType = GL_HALF_FLOAT_NV;
} }
} }
@@ -476,7 +525,8 @@ void init_type_lookup(WineD3D_GL_Info *gl_info) {
#define GLINFO_LOCATION This->adapter->gl_info #define GLINFO_LOCATION This->adapter->gl_info
const StaticPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt, WineD3D_GL_Info *gl_info, const GlPixelFormatDesc **glDesc) const StaticPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt, const WineD3D_GL_Info *gl_info,
const struct GlPixelFormatDesc **glDesc)
{ {
int idx = getFmtIdx(fmt); int idx = getFmtIdx(fmt);
@@ -491,7 +541,7 @@ const StaticPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt, WineD3D_GL_In
* all gl caps check return "unsupported" than catching the lack of gl all over the code. ANSI C requires * all gl caps check return "unsupported" than catching the lack of gl all over the code. ANSI C requires
* static variables to be initialized to 0. * static variables to be initialized to 0.
*/ */
static const GlPixelFormatDesc dummyFmt; static const struct GlPixelFormatDesc dummyFmt;
*glDesc = &dummyFmt; *glDesc = &dummyFmt;
} else { } else {
*glDesc = &gl_info->gl_formats[idx]; *glDesc = &gl_info->gl_formats[idx];
@@ -713,7 +763,7 @@ const char* debug_d3ddeclusage(BYTE usage) {
const char* debug_d3dresourcetype(WINED3DRESOURCETYPE res) { const char* debug_d3dresourcetype(WINED3DRESOURCETYPE res) {
switch (res) { switch (res) {
#define RES_TO_STR(res) case res: return #res; #define RES_TO_STR(res) case res: return #res
RES_TO_STR(WINED3DRTYPE_SURFACE); RES_TO_STR(WINED3DRTYPE_SURFACE);
RES_TO_STR(WINED3DRTYPE_VOLUME); RES_TO_STR(WINED3DRTYPE_VOLUME);
RES_TO_STR(WINED3DRTYPE_TEXTURE); RES_TO_STR(WINED3DRTYPE_TEXTURE);
@@ -730,7 +780,7 @@ const char* debug_d3dresourcetype(WINED3DRESOURCETYPE res) {
const char* debug_d3dprimitivetype(WINED3DPRIMITIVETYPE PrimitiveType) { const char* debug_d3dprimitivetype(WINED3DPRIMITIVETYPE PrimitiveType) {
switch (PrimitiveType) { switch (PrimitiveType) {
#define PRIM_TO_STR(prim) case prim: return #prim; #define PRIM_TO_STR(prim) case prim: return #prim
PRIM_TO_STR(WINED3DPT_POINTLIST); PRIM_TO_STR(WINED3DPT_POINTLIST);
PRIM_TO_STR(WINED3DPT_LINELIST); PRIM_TO_STR(WINED3DPT_LINELIST);
PRIM_TO_STR(WINED3DPT_LINESTRIP); PRIM_TO_STR(WINED3DPT_LINESTRIP);
@@ -979,15 +1029,11 @@ const char* debug_d3dtexturestate(DWORD state) {
D3DSTATE_TO_STR(WINED3DTSS_BUMPENVLSCALE ); D3DSTATE_TO_STR(WINED3DTSS_BUMPENVLSCALE );
D3DSTATE_TO_STR(WINED3DTSS_BUMPENVLOFFSET ); D3DSTATE_TO_STR(WINED3DTSS_BUMPENVLOFFSET );
D3DSTATE_TO_STR(WINED3DTSS_TEXTURETRANSFORMFLAGS ); D3DSTATE_TO_STR(WINED3DTSS_TEXTURETRANSFORMFLAGS );
D3DSTATE_TO_STR(WINED3DTSS_ADDRESSW );
D3DSTATE_TO_STR(WINED3DTSS_COLORARG0 ); D3DSTATE_TO_STR(WINED3DTSS_COLORARG0 );
D3DSTATE_TO_STR(WINED3DTSS_ALPHAARG0 ); D3DSTATE_TO_STR(WINED3DTSS_ALPHAARG0 );
D3DSTATE_TO_STR(WINED3DTSS_RESULTARG ); D3DSTATE_TO_STR(WINED3DTSS_RESULTARG );
D3DSTATE_TO_STR(WINED3DTSS_CONSTANT ); D3DSTATE_TO_STR(WINED3DTSS_CONSTANT );
#undef D3DSTATE_TO_STR #undef D3DSTATE_TO_STR
case 12:
/* Note WINED3DTSS are not consecutive, so skip these */
return "unused";
default: default:
FIXME("Unrecognized %u texture state!\n", state); FIXME("Unrecognized %u texture state!\n", state);
return "unrecognized"; return "unrecognized";
@@ -1057,7 +1103,7 @@ const char* debug_d3dtstype(WINED3DTRANSFORMSTATETYPE tstype) {
const char* debug_d3dpool(WINED3DPOOL Pool) { const char* debug_d3dpool(WINED3DPOOL Pool) {
switch (Pool) { switch (Pool) {
#define POOL_TO_STR(p) case p: return #p; #define POOL_TO_STR(p) case p: return #p
POOL_TO_STR(WINED3DPOOL_DEFAULT); POOL_TO_STR(WINED3DPOOL_DEFAULT);
POOL_TO_STR(WINED3DPOOL_MANAGED); POOL_TO_STR(WINED3DPOOL_MANAGED);
POOL_TO_STR(WINED3DPOOL_SYSTEMMEM); POOL_TO_STR(WINED3DPOOL_SYSTEMMEM);
@@ -1125,6 +1171,55 @@ const char *debug_d3ddegree(WINED3DDEGREETYPE degree) {
} }
} }
const char *debug_fixup_channel_source(enum fixup_channel_source source)
{
switch(source)
{
#define WINED3D_TO_STR(x) case x: return #x
WINED3D_TO_STR(CHANNEL_SOURCE_ZERO);
WINED3D_TO_STR(CHANNEL_SOURCE_ONE);
WINED3D_TO_STR(CHANNEL_SOURCE_X);
WINED3D_TO_STR(CHANNEL_SOURCE_Y);
WINED3D_TO_STR(CHANNEL_SOURCE_Z);
WINED3D_TO_STR(CHANNEL_SOURCE_W);
WINED3D_TO_STR(CHANNEL_SOURCE_YUV0);
WINED3D_TO_STR(CHANNEL_SOURCE_YUV1);
#undef WINED3D_TO_STR
default:
FIXME("Unrecognized fixup_channel_source %#x\n", source);
return "unrecognized";
}
}
const char *debug_yuv_fixup(enum yuv_fixup yuv_fixup)
{
switch(yuv_fixup)
{
#define WINED3D_TO_STR(x) case x: return #x
WINED3D_TO_STR(YUV_FIXUP_YUY2);
WINED3D_TO_STR(YUV_FIXUP_UYVY);
WINED3D_TO_STR(YUV_FIXUP_YV12);
#undef WINED3D_TO_STR
default:
FIXME("Unrecognized YUV fixup %#x\n", yuv_fixup);
return "unrecognized";
}
}
void dump_color_fixup_desc(struct color_fixup_desc fixup)
{
if (is_yuv_fixup(fixup))
{
TRACE("\tYUV: %s\n", debug_yuv_fixup(get_yuv_fixup(fixup)));
return;
}
TRACE("\tX: %s%s\n", debug_fixup_channel_source(fixup.x_source), fixup.x_sign_fixup ? ", SIGN_FIXUP" : "");
TRACE("\tY: %s%s\n", debug_fixup_channel_source(fixup.y_source), fixup.y_sign_fixup ? ", SIGN_FIXUP" : "");
TRACE("\tZ: %s%s\n", debug_fixup_channel_source(fixup.z_source), fixup.z_sign_fixup ? ", SIGN_FIXUP" : "");
TRACE("\tW: %s%s\n", debug_fixup_channel_source(fixup.w_source), fixup.w_sign_fixup ? ", SIGN_FIXUP" : "");
}
/***************************************************************************** /*****************************************************************************
* Useful functions mapping GL <-> D3D values * Useful functions mapping GL <-> D3D values
*/ */
@@ -1422,6 +1517,7 @@ DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) {
case WINED3DFVF_XYZB3: size += 6 * sizeof(float); break; case WINED3DFVF_XYZB3: size += 6 * sizeof(float); break;
case WINED3DFVF_XYZB4: size += 7 * sizeof(float); break; case WINED3DFVF_XYZB4: size += 7 * sizeof(float); break;
case WINED3DFVF_XYZB5: size += 8 * sizeof(float); break; case WINED3DFVF_XYZB5: size += 8 * sizeof(float); break;
case WINED3DFVF_XYZW: size += 4 * sizeof(float); break;
default: ERR("Unexpected position mask\n"); default: ERR("Unexpected position mask\n");
} }
for (i = 0; i < numTextures; i++) { for (i = 0; i < numTextures; i++) {
@@ -1633,7 +1729,18 @@ void hash_table_destroy(struct hash_table_t *table, void (*free_value)(void *val
HeapFree(GetProcessHeap(), 0, table); HeapFree(GetProcessHeap(), 0, table);
} }
static inline struct hash_table_entry_t *hash_table_get_by_idx(struct hash_table_t *table, void *key, unsigned int idx) void hash_table_for_each_entry(struct hash_table_t *table, void (*callback)(void *value, void *context), void *context)
{
unsigned int i = 0;
for (i = 0; i < table->entry_count; ++i)
{
callback(table->entries[i].value, context);
}
}
static inline struct hash_table_entry_t *hash_table_get_by_idx(const struct hash_table_t *table, const void *key,
unsigned int idx)
{ {
struct hash_table_entry_t *entry; struct hash_table_entry_t *entry;
@@ -1781,7 +1888,7 @@ void hash_table_remove(struct hash_table_t *table, void *key)
hash_table_put(table, key, NULL); hash_table_put(table, key, NULL);
} }
void *hash_table_get(struct hash_table_t *table, void *key) void *hash_table_get(const struct hash_table_t *table, const void *key)
{ {
unsigned int idx; unsigned int idx;
struct hash_table_entry_t *entry; struct hash_table_entry_t *entry;
@@ -1838,7 +1945,7 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
settings->op[i].aop = WINED3DTOP_DISABLE; settings->op[i].aop = WINED3DTOP_DISABLE;
settings->op[i].carg0 = settings->op[i].carg1 = settings->op[i].carg2 = ARG_UNUSED; settings->op[i].carg0 = settings->op[i].carg1 = settings->op[i].carg2 = ARG_UNUSED;
settings->op[i].aarg0 = settings->op[i].aarg1 = settings->op[i].aarg2 = ARG_UNUSED; settings->op[i].aarg0 = settings->op[i].aarg1 = settings->op[i].aarg2 = ARG_UNUSED;
settings->op[i].color_correction = WINED3DFMT_UNKNOWN; settings->op[i].color_fixup = COLOR_FIXUP_IDENTITY;
settings->op[i].dst = resultreg; settings->op[i].dst = resultreg;
settings->op[i].tex_type = tex_1d; settings->op[i].tex_type = tex_1d;
settings->op[i].projected = proj_none; settings->op[i].projected = proj_none;
@@ -1848,11 +1955,11 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
texture = (IWineD3DBaseTextureImpl *) stateblock->textures[i]; texture = (IWineD3DBaseTextureImpl *) stateblock->textures[i];
if(texture) { if(texture) {
settings->op[i].color_correction = texture->baseTexture.shader_conversion_group; settings->op[i].color_fixup = texture->baseTexture.shader_color_fixup;
if(ignore_textype) { if(ignore_textype) {
settings->op[i].tex_type = tex_1d; settings->op[i].tex_type = tex_1d;
} else { } else {
switch(stateblock->textureDimensions[i]) { switch (IWineD3DBaseTexture_GetTextureDimensions((IWineD3DBaseTexture *)texture)) {
case GL_TEXTURE_1D: case GL_TEXTURE_1D:
settings->op[i].tex_type = tex_1d; settings->op[i].tex_type = tex_1d;
break; break;
@@ -1871,21 +1978,21 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
} }
} }
} else { } else {
settings->op[i].color_correction = WINED3DFMT_UNKNOWN; settings->op[i].color_fixup = COLOR_FIXUP_IDENTITY;
settings->op[i].tex_type = tex_1d; settings->op[i].tex_type = tex_1d;
} }
cop = stateblock->textureState[i][WINED3DTSS_COLOROP]; cop = stateblock->textureState[i][WINED3DTSS_COLOROP];
aop = stateblock->textureState[i][WINED3DTSS_ALPHAOP]; aop = stateblock->textureState[i][WINED3DTSS_ALPHAOP];
carg1 = (args[cop] & ARG1) ? stateblock->textureState[i][WINED3DTSS_COLORARG1] : 0xffffffff; carg1 = (args[cop] & ARG1) ? stateblock->textureState[i][WINED3DTSS_COLORARG1] : ARG_UNUSED;
carg2 = (args[cop] & ARG2) ? stateblock->textureState[i][WINED3DTSS_COLORARG2] : 0xffffffff; carg2 = (args[cop] & ARG2) ? stateblock->textureState[i][WINED3DTSS_COLORARG2] : ARG_UNUSED;
carg0 = (args[cop] & ARG0) ? stateblock->textureState[i][WINED3DTSS_COLORARG0] : 0xffffffff; carg0 = (args[cop] & ARG0) ? stateblock->textureState[i][WINED3DTSS_COLORARG0] : ARG_UNUSED;
if(is_invalid_op(stateblock->wineD3DDevice, i, cop, if(is_invalid_op(stateblock->wineD3DDevice, i, cop,
carg1, carg2, carg0)) { carg1, carg2, carg0)) {
carg0 = 0xffffffff; carg0 = ARG_UNUSED;
carg2 = 0xffffffff; carg2 = ARG_UNUSED;
carg1 = WINED3DTA_CURRENT; carg1 = WINED3DTA_CURRENT;
cop = WINED3DTOP_SELECTARG1; cop = WINED3DTOP_SELECTARG1;
} }
@@ -1899,45 +2006,54 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
aarg2 = carg2; aarg2 = carg2;
aarg0 = carg0; aarg0 = carg0;
} else { } else {
aarg1 = (args[aop] & ARG1) ? stateblock->textureState[i][WINED3DTSS_ALPHAARG1] : 0xffffffff; aarg1 = (args[aop] & ARG1) ? stateblock->textureState[i][WINED3DTSS_ALPHAARG1] : ARG_UNUSED;
aarg2 = (args[aop] & ARG2) ? stateblock->textureState[i][WINED3DTSS_ALPHAARG2] : 0xffffffff; aarg2 = (args[aop] & ARG2) ? stateblock->textureState[i][WINED3DTSS_ALPHAARG2] : ARG_UNUSED;
aarg0 = (args[aop] & ARG0) ? stateblock->textureState[i][WINED3DTSS_ALPHAARG0] : 0xffffffff; aarg0 = (args[aop] & ARG0) ? stateblock->textureState[i][WINED3DTSS_ALPHAARG0] : ARG_UNUSED;
} }
if(i == 0 && stateblock->textures[0] && if (i == 0 && stateblock->textures[0] && stateblock->renderState[WINED3DRS_COLORKEYENABLE])
stateblock->renderState[WINED3DRS_COLORKEYENABLE] && {
(stateblock->textureDimensions[0] == GL_TEXTURE_2D || UINT texture_dimensions = IWineD3DBaseTexture_GetTextureDimensions(stateblock->textures[0]);
stateblock->textureDimensions[0] == GL_TEXTURE_RECTANGLE_ARB)) {
IWineD3DSurfaceImpl *surf = (IWineD3DSurfaceImpl *) ((IWineD3DTextureImpl *) stateblock->textures[0])->surfaces[0];
if(surf->CKeyFlags & WINEDDSD_CKSRCBLT && if (texture_dimensions == GL_TEXTURE_2D || texture_dimensions == GL_TEXTURE_RECTANGLE_ARB)
getFormatDescEntry(surf->resource.format, NULL, NULL)->alphaMask == 0x00000000) { {
IWineD3DSurfaceImpl *surf;
surf = (IWineD3DSurfaceImpl *) ((IWineD3DTextureImpl *) stateblock->textures[0])->surfaces[0];
if(aop == WINED3DTOP_DISABLE) { if (surf->CKeyFlags & WINEDDSD_CKSRCBLT
aarg1 = WINED3DTA_TEXTURE; && getFormatDescEntry(surf->resource.format, NULL, NULL)->alphaMask == 0x00000000)
aop = WINED3DTOP_SELECTARG1; {
} if (aop == WINED3DTOP_DISABLE)
else if(aop == WINED3DTOP_SELECTARG1 && aarg1 != WINED3DTA_TEXTURE) { {
if (stateblock->renderState[WINED3DRS_ALPHABLENDENABLE]) { aarg1 = WINED3DTA_TEXTURE;
aarg2 = WINED3DTA_TEXTURE; aop = WINED3DTOP_SELECTARG1;
aop = WINED3DTOP_MODULATE;
} }
else aarg1 = WINED3DTA_TEXTURE; else if (aop == WINED3DTOP_SELECTARG1 && aarg1 != WINED3DTA_TEXTURE)
} {
else if(aop == WINED3DTOP_SELECTARG2 && aarg2 != WINED3DTA_TEXTURE) { if (stateblock->renderState[WINED3DRS_ALPHABLENDENABLE])
if (stateblock->renderState[WINED3DRS_ALPHABLENDENABLE]) { {
aarg1 = WINED3DTA_TEXTURE; aarg2 = WINED3DTA_TEXTURE;
aop = WINED3DTOP_MODULATE; aop = WINED3DTOP_MODULATE;
}
else aarg1 = WINED3DTA_TEXTURE;
}
else if (aop == WINED3DTOP_SELECTARG2 && aarg2 != WINED3DTA_TEXTURE)
{
if (stateblock->renderState[WINED3DRS_ALPHABLENDENABLE])
{
aarg1 = WINED3DTA_TEXTURE;
aop = WINED3DTOP_MODULATE;
}
else aarg2 = WINED3DTA_TEXTURE;
} }
else aarg2 = WINED3DTA_TEXTURE;
} }
} }
} }
if(is_invalid_op(stateblock->wineD3DDevice, i, aop, if(is_invalid_op(stateblock->wineD3DDevice, i, aop,
aarg1, aarg2, aarg0)) { aarg1, aarg2, aarg0)) {
aarg0 = 0xffffffff; aarg0 = ARG_UNUSED;
aarg2 = 0xffffffff; aarg2 = ARG_UNUSED;
aarg1 = WINED3DTA_CURRENT; aarg1 = WINED3DTA_CURRENT;
aop = WINED3DTOP_SELECTARG1; aop = WINED3DTOP_SELECTARG1;
} }
@@ -2013,9 +2129,11 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
} }
#undef GLINFO_LOCATION #undef GLINFO_LOCATION
struct ffp_frag_desc *find_ffp_frag_shader(struct hash_table_t *fragment_shaders, struct ffp_frag_settings *settings) const struct ffp_frag_desc *find_ffp_frag_shader(const struct hash_table_t *fragment_shaders,
const struct ffp_frag_settings *settings)
{ {
return (struct ffp_frag_desc *)hash_table_get(fragment_shaders, settings);} return (const struct ffp_frag_desc *)hash_table_get(fragment_shaders, settings);
}
void add_ffp_frag_shader(struct hash_table_t *shaders, struct ffp_frag_desc *desc) { void add_ffp_frag_shader(struct hash_table_t *shaders, struct ffp_frag_desc *desc) {
struct ffp_frag_settings *key = HeapAlloc(GetProcessHeap(), 0, sizeof(*key)); struct ffp_frag_settings *key = HeapAlloc(GetProcessHeap(), 0, sizeof(*key));
@@ -2034,7 +2152,7 @@ void add_ffp_frag_shader(struct hash_table_t *shaders, struct ffp_frag_desc *des
#define GLINFO_LOCATION stateblock->wineD3DDevice->adapter->gl_info #define GLINFO_LOCATION stateblock->wineD3DDevice->adapter->gl_info
void texture_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { void texture_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
if(stateblock->textures[stage]) { if(stateblock->textures[stage]) {
switch(stateblock->textureDimensions[stage]) { switch (IWineD3DBaseTexture_GetTextureDimensions(stateblock->textures[stage])) {
case GL_TEXTURE_2D: case GL_TEXTURE_2D:
glDisable(GL_TEXTURE_3D); glDisable(GL_TEXTURE_3D);
checkGLcall("glDisable(GL_TEXTURE_3D)"); checkGLcall("glDisable(GL_TEXTURE_3D)");
@@ -2121,10 +2239,11 @@ void sampler_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCont
} }
#undef GLINFO_LOCATION #undef GLINFO_LOCATION
unsigned int ffp_frag_program_key_hash(void *key) { unsigned int ffp_frag_program_key_hash(const void *key)
struct ffp_frag_settings *k = (struct ffp_frag_settings *)key; {
const struct ffp_frag_settings *k = (const struct ffp_frag_settings *)key;
unsigned int hash = 0, i; unsigned int hash = 0, i;
DWORD *blob; const DWORD *blob;
/* This takes the texture op settings of stage 0 and 1 into account. /* This takes the texture op settings of stage 0 and 1 into account.
* how exactly depends on the memory laybout of the compiler, but it * how exactly depends on the memory laybout of the compiler, but it
@@ -2133,7 +2252,7 @@ unsigned int ffp_frag_program_key_hash(void *key) {
* the ffp setup has distinct stage 0 and 1 settings. * the ffp setup has distinct stage 0 and 1 settings.
*/ */
for(i = 0; i < 2; i++) { for(i = 0; i < 2; i++) {
blob = (DWORD *) &k->op[i]; blob = (const DWORD *)&k->op[i];
hash ^= blob[0] ^ blob[1]; hash ^= blob[0] ^ blob[1];
} }
@@ -2147,9 +2266,36 @@ unsigned int ffp_frag_program_key_hash(void *key) {
return hash; return hash;
} }
BOOL ffp_frag_program_key_compare(void *keya, void *keyb) { BOOL ffp_frag_program_key_compare(const void *keya, const void *keyb)
struct ffp_frag_settings *ka = (struct ffp_frag_settings *)keya; {
struct ffp_frag_settings *kb = (struct ffp_frag_settings *)keyb; const struct ffp_frag_settings *ka = (const struct ffp_frag_settings *)keya;
const struct ffp_frag_settings *kb = (const struct ffp_frag_settings *)keyb;
return memcmp(ka, kb, sizeof(*ka)) == 0; return memcmp(ka, kb, sizeof(*ka)) == 0;
} }
UINT wined3d_log2i(UINT32 x)
{
static const BYTE l[] =
{
0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
};
UINT32 i;
return (i = x >> 16) ? (x = i >> 8) ? l[x] + 24 : l[i] + 16 : (i = x >> 8) ? l[i] + 8 : l[x];
}

View File

@@ -72,7 +72,7 @@ static ULONG WINAPI IWineD3DVertexBufferImpl_Release(IWineD3DVertexBuffer *iface
LEAVE_GL(); LEAVE_GL();
} }
IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface); resource_cleanup((IWineD3DResource *)iface);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
return ref; return ref;
@@ -82,27 +82,27 @@ static ULONG WINAPI IWineD3DVertexBufferImpl_Release(IWineD3DVertexBuffer *iface
IWineD3DVertexBuffer IWineD3DResource parts follow IWineD3DVertexBuffer IWineD3DResource parts follow
**************************************************** */ **************************************************** */
static HRESULT WINAPI IWineD3DVertexBufferImpl_GetDevice(IWineD3DVertexBuffer *iface, IWineD3DDevice** ppDevice) { static HRESULT WINAPI IWineD3DVertexBufferImpl_GetDevice(IWineD3DVertexBuffer *iface, IWineD3DDevice** ppDevice) {
return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice); return resource_get_device((IWineD3DResource *)iface, ppDevice);
} }
static HRESULT WINAPI IWineD3DVertexBufferImpl_SetPrivateData(IWineD3DVertexBuffer *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) { static HRESULT WINAPI IWineD3DVertexBufferImpl_SetPrivateData(IWineD3DVertexBuffer *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags); return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
} }
static HRESULT WINAPI IWineD3DVertexBufferImpl_GetPrivateData(IWineD3DVertexBuffer *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) { static HRESULT WINAPI IWineD3DVertexBufferImpl_GetPrivateData(IWineD3DVertexBuffer *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData); return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
} }
static HRESULT WINAPI IWineD3DVertexBufferImpl_FreePrivateData(IWineD3DVertexBuffer *iface, REFGUID refguid) { static HRESULT WINAPI IWineD3DVertexBufferImpl_FreePrivateData(IWineD3DVertexBuffer *iface, REFGUID refguid) {
return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid); return resource_free_private_data((IWineD3DResource *)iface, refguid);
} }
static DWORD WINAPI IWineD3DVertexBufferImpl_SetPriority(IWineD3DVertexBuffer *iface, DWORD PriorityNew) { static DWORD WINAPI IWineD3DVertexBufferImpl_SetPriority(IWineD3DVertexBuffer *iface, DWORD PriorityNew) {
return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew); return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
} }
static DWORD WINAPI IWineD3DVertexBufferImpl_GetPriority(IWineD3DVertexBuffer *iface) { static DWORD WINAPI IWineD3DVertexBufferImpl_GetPriority(IWineD3DVertexBuffer *iface) {
return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface); return resource_get_priority((IWineD3DResource *)iface);
} }
static inline void fixup_d3dcolor(DWORD *pos) { static inline void fixup_d3dcolor(DWORD *pos) {
@@ -143,7 +143,8 @@ static inline void fixup_transformed_pos(float *p) {
p[3] = w; p[3] = w;
} }
DWORD *find_conversion_shift(IWineD3DVertexBufferImpl *This, WineDirect3DVertexStridedData *strided, DWORD stride) { static DWORD *find_conversion_shift(IWineD3DVertexBufferImpl *This, const WineDirect3DVertexStridedData *strided, DWORD stride)
{
DWORD *ret, i, shift, j, type; DWORD *ret, i, shift, j, type;
DWORD orig_type_size; DWORD orig_type_size;
@@ -279,7 +280,7 @@ static inline BOOL check_attribute(IWineD3DVertexBufferImpl *This, const WineDir
return ret; return ret;
} }
inline BOOL WINAPI IWineD3DVertexBufferImpl_FindDecl(IWineD3DVertexBufferImpl *This) static inline BOOL IWineD3DVertexBufferImpl_FindDecl(IWineD3DVertexBufferImpl *This)
{ {
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
BOOL ret = FALSE; BOOL ret = FALSE;
@@ -326,8 +327,9 @@ inline BOOL WINAPI IWineD3DVertexBufferImpl_FindDecl(IWineD3DVertexBufferImpl *T
* done, or if the DIFFUSE is replaced with a D3DCOLOR BLENDWEIGHT we can happily dismiss the change. Some conversion types * done, or if the DIFFUSE is replaced with a D3DCOLOR BLENDWEIGHT we can happily dismiss the change. Some conversion types
* depend on the semantic as well, for example a FLOAT4 texcoord needs no conversion while a FLOAT4 positiont needs one * depend on the semantic as well, for example a FLOAT4 texcoord needs no conversion while a FLOAT4 positiont needs one
*/ */
if(use_vs(device)) { if (use_vs(device->stateBlock))
TRACE("vhsader\n"); {
TRACE("vshader\n");
/* If the current vertex declaration is marked for no half float conversion don't bother to /* If the current vertex declaration is marked for no half float conversion don't bother to
* analyse the strided streams in depth, just set them up for no conversion. Return decl changed * analyse the strided streams in depth, just set them up for no conversion. Return decl changed
* if we used conversion before * if we used conversion before
@@ -362,10 +364,11 @@ inline BOOL WINAPI IWineD3DVertexBufferImpl_FindDecl(IWineD3DVertexBufferImpl *T
* FLOAT16s if not supported. Also, we can't iterate over the array, so use macros to generate code for all * FLOAT16s if not supported. Also, we can't iterate over the array, so use macros to generate code for all
* the attributes that our current fixed function pipeline implementation cares for. * the attributes that our current fixed function pipeline implementation cares for.
*/ */
BOOL support_d3dcolor = GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA);
ret = check_attribute(This, &device->strided_streams.u.s.position, TRUE, TRUE, FALSE, &stride_this_run, &float16_used) || ret; ret = check_attribute(This, &device->strided_streams.u.s.position, TRUE, TRUE, FALSE, &stride_this_run, &float16_used) || ret;
ret = check_attribute(This, &device->strided_streams.u.s.normal, TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret; ret = check_attribute(This, &device->strided_streams.u.s.normal, TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
ret = check_attribute(This, &device->strided_streams.u.s.diffuse, TRUE, FALSE, TRUE, &stride_this_run, &float16_used) || ret; ret = check_attribute(This, &device->strided_streams.u.s.diffuse, !support_d3dcolor, FALSE, TRUE, &stride_this_run, &float16_used) || ret;
ret = check_attribute(This, &device->strided_streams.u.s.specular, TRUE, FALSE, TRUE, &stride_this_run, &float16_used) || ret; ret = check_attribute(This, &device->strided_streams.u.s.specular, !support_d3dcolor, FALSE, TRUE, &stride_this_run, &float16_used) || ret;
ret = check_attribute(This, &device->strided_streams.u.s.texCoords[0], TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret; ret = check_attribute(This, &device->strided_streams.u.s.texCoords[0], TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
ret = check_attribute(This, &device->strided_streams.u.s.texCoords[1], TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret; ret = check_attribute(This, &device->strided_streams.u.s.texCoords[1], TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
ret = check_attribute(This, &device->strided_streams.u.s.texCoords[2], TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret; ret = check_attribute(This, &device->strided_streams.u.s.texCoords[2], TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
@@ -622,7 +625,7 @@ static void WINAPI IWineD3DVertexBufferImpl_PreLoad(IWineD3DVertexBuffer *if
case CONV_FLOAT16_2: case CONV_FLOAT16_2:
{ {
float *out = (float *) (&data[This->conv_stride * i + j + This->conv_shift[j]]); float *out = (float *) (&data[This->conv_stride * i + j + This->conv_shift[j]]);
WORD *in = (WORD *) (&This->resource.allocatedMemory[i * This->stride + j]); const WORD *in = (WORD *) (&This->resource.allocatedMemory[i * This->stride + j]);
out[1] = float_16_to_32(in + 1); out[1] = float_16_to_32(in + 1);
out[0] = float_16_to_32(in + 0); out[0] = float_16_to_32(in + 0);
@@ -703,11 +706,11 @@ static void WINAPI IWineD3DVertexBufferImpl_UnLoad(IWineD3DVertexBuffer *iface)
} }
static WINED3DRESOURCETYPE WINAPI IWineD3DVertexBufferImpl_GetType(IWineD3DVertexBuffer *iface) { static WINED3DRESOURCETYPE WINAPI IWineD3DVertexBufferImpl_GetType(IWineD3DVertexBuffer *iface) {
return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface); return resource_get_type((IWineD3DResource *)iface);
} }
static HRESULT WINAPI IWineD3DVertexBufferImpl_GetParent(IWineD3DVertexBuffer *iface, IUnknown **pParent) { static HRESULT WINAPI IWineD3DVertexBufferImpl_GetParent(IWineD3DVertexBuffer *iface, IUnknown **pParent) {
return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent); return resource_get_parent((IWineD3DResource *)iface, pParent);
} }
/* ****************************************************** /* ******************************************************
@@ -743,7 +746,7 @@ static HRESULT WINAPI IWineD3DVertexBufferImpl_Lock(IWineD3DVertexBuffer *iface
/* TODO: check Flags compatibility with This->currentDesc.Usage (see MSDN) */ /* TODO: check Flags compatibility with This->currentDesc.Usage (see MSDN) */
return WINED3D_OK; return WINED3D_OK;
} }
HRESULT WINAPI IWineD3DVertexBufferImpl_Unlock(IWineD3DVertexBuffer *iface) { static HRESULT WINAPI IWineD3DVertexBufferImpl_Unlock(IWineD3DVertexBuffer *iface) {
IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *) iface; IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *) iface;
LONG lockcount; LONG lockcount;
TRACE("(%p)\n", This); TRACE("(%p)\n", This);
@@ -796,7 +799,8 @@ const IWineD3DVertexBufferVtbl IWineD3DVertexBuffer_Vtbl =
IWineD3DVertexBufferImpl_GetDesc IWineD3DVertexBufferImpl_GetDesc
}; };
BYTE* WINAPI IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWORD iOffset, GLint *vbo) { const BYTE* IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWORD iOffset, GLint *vbo)
{
IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *)iface; IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *)iface;
*vbo = This->vbo; *vbo = This->vbo;
@@ -806,15 +810,11 @@ BYTE* WINAPI IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWO
This->Flags &= ~VBFLAG_CREATEVBO; This->Flags &= ~VBFLAG_CREATEVBO;
if(This->vbo) { if(This->vbo) {
*vbo = This->vbo; *vbo = This->vbo;
return (BYTE *) iOffset; return (const BYTE *)iOffset;
} }
} }
return This->resource.allocatedMemory + iOffset; return This->resource.allocatedMemory + iOffset;
} else { } else {
return (BYTE *) iOffset; return (const BYTE *)iOffset;
} }
} }
HRESULT WINAPI IWineD3DVertexBufferImpl_ReleaseMemory(IWineD3DVertexBuffer* iface) {
return WINED3D_OK;
}

View File

@@ -207,7 +207,7 @@ static HRESULT WINAPI IWineD3DVertexDeclarationImpl_SetDeclaration(IWineD3DVerte
const WINED3DVERTEXELEMENT *elements, UINT element_count) { const WINED3DVERTEXELEMENT *elements, UINT element_count) {
IWineD3DVertexDeclarationImpl *This = (IWineD3DVertexDeclarationImpl *)iface; IWineD3DVertexDeclarationImpl *This = (IWineD3DVertexDeclarationImpl *)iface;
HRESULT hr = WINED3D_OK; HRESULT hr = WINED3D_OK;
int i, j; int i;
char isPreLoaded[MAX_STREAMS]; char isPreLoaded[MAX_STREAMS];
TRACE("(%p) : d3d version %d\n", This, ((IWineD3DImpl *)This->wineD3DDevice->wineD3D)->dxVersion); TRACE("(%p) : d3d version %d\n", This, ((IWineD3DImpl *)This->wineD3DDevice->wineD3D)->dxVersion);
@@ -263,39 +263,13 @@ static HRESULT WINAPI IWineD3DVertexDeclarationImpl_SetDeclaration(IWineD3DVerte
isPreLoaded[This->pDeclarationWine[i].Stream] = 1; isPreLoaded[This->pDeclarationWine[i].Stream] = 1;
} }
/* Create a sorted array containing the attribute declarations that are of type if (This->pDeclarationWine[i].Type == WINED3DDECLTYPE_FLOAT16_2
* D3DCOLOR. D3DCOLOR requires swizzling of the r and b component, and if the || This->pDeclarationWine[i].Type == WINED3DDECLTYPE_FLOAT16_4)
* declaration of one attribute changes the vertex shader needs recompilation. {
* Having a sorted array of the attributes allows efficient comparison of the if (!GL_SUPPORT(NV_HALF_FLOAT)) This->half_float_conv_needed = TRUE;
* declaration against a shader
*/
if(This->pDeclarationWine[i].Type == WINED3DDECLTYPE_D3DCOLOR) {
for(j = 0; j < This->num_swizzled_attribs; j++) {
if(This->swizzled_attribs[j].usage > This->pDeclarationWine[i].Usage ||
(This->swizzled_attribs[j].usage == This->pDeclarationWine[i].Usage &&
This->swizzled_attribs[j].idx > This->pDeclarationWine[i].UsageIndex)) {
memmove(&This->swizzled_attribs[j + 1], &This->swizzled_attribs[j],
sizeof(This->swizzled_attribs) - (sizeof(This->swizzled_attribs[0]) * (j + 1)));
break;
}
}
This->swizzled_attribs[j].usage = This->pDeclarationWine[i].Usage;
This->swizzled_attribs[j].idx = This->pDeclarationWine[i].UsageIndex;
This->num_swizzled_attribs++;
} else if(This->pDeclarationWine[i].Type == WINED3DDECLTYPE_FLOAT16_2 ||
This->pDeclarationWine[i].Type == WINED3DDECLTYPE_FLOAT16_4) {
if(!GL_SUPPORT(NV_HALF_FLOAT)) {
This->half_float_conv_needed = TRUE;
}
} }
} }
TRACE("Swizzled attributes found:\n");
for(i = 0; i < This->num_swizzled_attribs; i++) {
TRACE("%u: %s%d\n", i,
debug_d3ddeclusage(This->swizzled_attribs[i].usage), This->swizzled_attribs[i].idx);
}
TRACE("Returning\n"); TRACE("Returning\n");
return hr; return hr;
} }

View File

@@ -43,71 +43,71 @@ CONST SHADER_OPCODE IWineD3DVertexShaderImpl_shader_ins[] = {
/* This table is not order or position dependent. */ /* This table is not order or position dependent. */
/* Arithmetic */ /* Arithmetic */
{WINED3DSIO_NOP, "nop", "NOP", 0, 0, WINED3DSIH_NOP, 0, 0 }, {WINED3DSIO_NOP, "nop", 0, 0, WINED3DSIH_NOP, 0, 0 },
{WINED3DSIO_MOV, "mov", "MOV", 1, 2, WINED3DSIH_MOV, 0, 0 }, {WINED3DSIO_MOV, "mov", 1, 2, WINED3DSIH_MOV, 0, 0 },
{WINED3DSIO_MOVA, "mova", NULL, 1, 2, WINED3DSIH_MOVA, WINED3DVS_VERSION(2,0), -1 }, {WINED3DSIO_MOVA, "mova", 1, 2, WINED3DSIH_MOVA, WINED3DVS_VERSION(2,0), -1 },
{WINED3DSIO_ADD, "add", "ADD", 1, 3, WINED3DSIH_ADD, 0, 0 }, {WINED3DSIO_ADD, "add", 1, 3, WINED3DSIH_ADD, 0, 0 },
{WINED3DSIO_SUB, "sub", "SUB", 1, 3, WINED3DSIH_SUB, 0, 0 }, {WINED3DSIO_SUB, "sub", 1, 3, WINED3DSIH_SUB, 0, 0 },
{WINED3DSIO_MAD, "mad", "MAD", 1, 4, WINED3DSIH_MAD, 0, 0 }, {WINED3DSIO_MAD, "mad", 1, 4, WINED3DSIH_MAD, 0, 0 },
{WINED3DSIO_MUL, "mul", "MUL", 1, 3, WINED3DSIH_MUL, 0, 0 }, {WINED3DSIO_MUL, "mul", 1, 3, WINED3DSIH_MUL, 0, 0 },
{WINED3DSIO_RCP, "rcp", "RCP", 1, 2, WINED3DSIH_RCP, 0, 0 }, {WINED3DSIO_RCP, "rcp", 1, 2, WINED3DSIH_RCP, 0, 0 },
{WINED3DSIO_RSQ, "rsq", "RSQ", 1, 2, WINED3DSIH_RSQ, 0, 0 }, {WINED3DSIO_RSQ, "rsq", 1, 2, WINED3DSIH_RSQ, 0, 0 },
{WINED3DSIO_DP3, "dp3", "DP3", 1, 3, WINED3DSIH_DP3, 0, 0 }, {WINED3DSIO_DP3, "dp3", 1, 3, WINED3DSIH_DP3, 0, 0 },
{WINED3DSIO_DP4, "dp4", "DP4", 1, 3, WINED3DSIH_DP4, 0, 0 }, {WINED3DSIO_DP4, "dp4", 1, 3, WINED3DSIH_DP4, 0, 0 },
{WINED3DSIO_MIN, "min", "MIN", 1, 3, WINED3DSIH_MIN, 0, 0 }, {WINED3DSIO_MIN, "min", 1, 3, WINED3DSIH_MIN, 0, 0 },
{WINED3DSIO_MAX, "max", "MAX", 1, 3, WINED3DSIH_MAX, 0, 0 }, {WINED3DSIO_MAX, "max", 1, 3, WINED3DSIH_MAX, 0, 0 },
{WINED3DSIO_SLT, "slt", "SLT", 1, 3, WINED3DSIH_SLT, 0, 0 }, {WINED3DSIO_SLT, "slt", 1, 3, WINED3DSIH_SLT, 0, 0 },
{WINED3DSIO_SGE, "sge", "SGE", 1, 3, WINED3DSIH_SGE, 0, 0 }, {WINED3DSIO_SGE, "sge", 1, 3, WINED3DSIH_SGE, 0, 0 },
{WINED3DSIO_ABS, "abs", "ABS", 1, 2, WINED3DSIH_ABS, 0, 0 }, {WINED3DSIO_ABS, "abs", 1, 2, WINED3DSIH_ABS, 0, 0 },
{WINED3DSIO_EXP, "exp", "EX2", 1, 2, WINED3DSIH_EXP, 0, 0 }, {WINED3DSIO_EXP, "exp", 1, 2, WINED3DSIH_EXP, 0, 0 },
{WINED3DSIO_LOG, "log", "LG2", 1, 2, WINED3DSIH_LOG, 0, 0 }, {WINED3DSIO_LOG, "log", 1, 2, WINED3DSIH_LOG, 0, 0 },
{WINED3DSIO_EXPP, "expp", "EXP", 1, 2, WINED3DSIH_EXPP, 0, 0 }, {WINED3DSIO_EXPP, "expp", 1, 2, WINED3DSIH_EXPP, 0, 0 },
{WINED3DSIO_LOGP, "logp", "LOG", 1, 2, WINED3DSIH_LOGP, 0, 0 }, {WINED3DSIO_LOGP, "logp", 1, 2, WINED3DSIH_LOGP, 0, 0 },
{WINED3DSIO_LIT, "lit", "LIT", 1, 2, WINED3DSIH_LIT, 0, 0 }, {WINED3DSIO_LIT, "lit", 1, 2, WINED3DSIH_LIT, 0, 0 },
{WINED3DSIO_DST, "dst", "DST", 1, 3, WINED3DSIH_DST, 0, 0 }, {WINED3DSIO_DST, "dst", 1, 3, WINED3DSIH_DST, 0, 0 },
{WINED3DSIO_LRP, "lrp", "LRP", 1, 4, WINED3DSIH_LRP, 0, 0 }, {WINED3DSIO_LRP, "lrp", 1, 4, WINED3DSIH_LRP, 0, 0 },
{WINED3DSIO_FRC, "frc", "FRC", 1, 2, WINED3DSIH_FRC, 0, 0 }, {WINED3DSIO_FRC, "frc", 1, 2, WINED3DSIH_FRC, 0, 0 },
{WINED3DSIO_POW, "pow", "POW", 1, 3, WINED3DSIH_POW, 0, 0 }, {WINED3DSIO_POW, "pow", 1, 3, WINED3DSIH_POW, 0, 0 },
{WINED3DSIO_CRS, "crs", "XPD", 1, 3, WINED3DSIH_CRS, 0, 0 }, {WINED3DSIO_CRS, "crs", 1, 3, WINED3DSIH_CRS, 0, 0 },
/* TODO: sng can possibly be performed a s /* TODO: sng can possibly be performed as
RCP tmp, vec RCP tmp, vec
MUL out, tmp, vec*/ MUL out, tmp, vec*/
{WINED3DSIO_SGN, "sgn", NULL, 1, 2, WINED3DSIH_SGN, 0, 0 }, {WINED3DSIO_SGN, "sgn", 1, 2, WINED3DSIH_SGN, 0, 0 },
{WINED3DSIO_NRM, "nrm", NULL, 1, 2, WINED3DSIH_NRM, 0, 0 }, {WINED3DSIO_NRM, "nrm", 1, 2, WINED3DSIH_NRM, 0, 0 },
{WINED3DSIO_SINCOS, "sincos", NULL, 1, 4, WINED3DSIH_SINCOS, WINED3DVS_VERSION(2,0), WINED3DVS_VERSION(2,1)}, {WINED3DSIO_SINCOS, "sincos", 1, 4, WINED3DSIH_SINCOS, WINED3DVS_VERSION(2,0), WINED3DVS_VERSION(2,1)},
{WINED3DSIO_SINCOS, "sincos", "SCS", 1, 2, WINED3DSIH_SINCOS, WINED3DVS_VERSION(3,0), -1 }, {WINED3DSIO_SINCOS, "sincos", 1, 2, WINED3DSIH_SINCOS, WINED3DVS_VERSION(3,0), -1 },
/* Matrix */ /* Matrix */
{WINED3DSIO_M4x4, "m4x4", "undefined", 1, 3, WINED3DSIH_M4x4, 0, 0 }, {WINED3DSIO_M4x4, "m4x4", 1, 3, WINED3DSIH_M4x4, 0, 0 },
{WINED3DSIO_M4x3, "m4x3", "undefined", 1, 3, WINED3DSIH_M4x3, 0, 0 }, {WINED3DSIO_M4x3, "m4x3", 1, 3, WINED3DSIH_M4x3, 0, 0 },
{WINED3DSIO_M3x4, "m3x4", "undefined", 1, 3, WINED3DSIH_M3x4, 0, 0 }, {WINED3DSIO_M3x4, "m3x4", 1, 3, WINED3DSIH_M3x4, 0, 0 },
{WINED3DSIO_M3x3, "m3x3", "undefined", 1, 3, WINED3DSIH_M3x3, 0, 0 }, {WINED3DSIO_M3x3, "m3x3", 1, 3, WINED3DSIH_M3x3, 0, 0 },
{WINED3DSIO_M3x2, "m3x2", "undefined", 1, 3, WINED3DSIH_M3x2, 0, 0 }, {WINED3DSIO_M3x2, "m3x2", 1, 3, WINED3DSIH_M3x2, 0, 0 },
/* Declare registers */ /* Declare registers */
{WINED3DSIO_DCL, "dcl", NULL, 0, 2, WINED3DSIH_DCL, 0, 0 }, {WINED3DSIO_DCL, "dcl", 0, 2, WINED3DSIH_DCL, 0, 0 },
/* Constant definitions */ /* Constant definitions */
{WINED3DSIO_DEF, "def", NULL, 1, 5, WINED3DSIH_DEF, 0, 0 }, {WINED3DSIO_DEF, "def", 1, 5, WINED3DSIH_DEF, 0, 0 },
{WINED3DSIO_DEFB, "defb", GLNAME_REQUIRE_GLSL, 1, 2, WINED3DSIH_DEFB, 0, 0 }, {WINED3DSIO_DEFB, "defb", 1, 2, WINED3DSIH_DEFB, 0, 0 },
{WINED3DSIO_DEFI, "defi", GLNAME_REQUIRE_GLSL, 1, 5, WINED3DSIH_DEFI, 0, 0 }, {WINED3DSIO_DEFI, "defi", 1, 5, WINED3DSIH_DEFI, 0, 0 },
/* Flow control - requires GLSL or software shaders */ /* Flow control - requires GLSL or software shaders */
{WINED3DSIO_REP , "rep", NULL, 0, 1, WINED3DSIH_REP, WINED3DVS_VERSION(2,0), -1 }, {WINED3DSIO_REP , "rep", 0, 1, WINED3DSIH_REP, WINED3DVS_VERSION(2,0), -1 },
{WINED3DSIO_ENDREP, "endrep", NULL, 0, 0, WINED3DSIH_ENDREP, WINED3DVS_VERSION(2,0), -1 }, {WINED3DSIO_ENDREP, "endrep", 0, 0, WINED3DSIH_ENDREP, WINED3DVS_VERSION(2,0), -1 },
{WINED3DSIO_IF, "if", NULL, 0, 1, WINED3DSIH_IF, WINED3DVS_VERSION(2,0), -1 }, {WINED3DSIO_IF, "if", 0, 1, WINED3DSIH_IF, WINED3DVS_VERSION(2,0), -1 },
{WINED3DSIO_IFC, "ifc", NULL, 0, 2, WINED3DSIH_IFC, WINED3DVS_VERSION(2,1), -1 }, {WINED3DSIO_IFC, "ifc", 0, 2, WINED3DSIH_IFC, WINED3DVS_VERSION(2,1), -1 },
{WINED3DSIO_ELSE, "else", NULL, 0, 0, WINED3DSIH_ELSE, WINED3DVS_VERSION(2,0), -1 }, {WINED3DSIO_ELSE, "else", 0, 0, WINED3DSIH_ELSE, WINED3DVS_VERSION(2,0), -1 },
{WINED3DSIO_ENDIF, "endif", NULL, 0, 0, WINED3DSIH_ENDIF, WINED3DVS_VERSION(2,0), -1 }, {WINED3DSIO_ENDIF, "endif", 0, 0, WINED3DSIH_ENDIF, WINED3DVS_VERSION(2,0), -1 },
{WINED3DSIO_BREAK, "break", NULL, 0, 0, WINED3DSIH_BREAK, WINED3DVS_VERSION(2,1), -1 }, {WINED3DSIO_BREAK, "break", 0, 0, WINED3DSIH_BREAK, WINED3DVS_VERSION(2,1), -1 },
{WINED3DSIO_BREAKC, "breakc", NULL, 0, 2, WINED3DSIH_BREAKC, WINED3DVS_VERSION(2,1), -1 }, {WINED3DSIO_BREAKC, "breakc", 0, 2, WINED3DSIH_BREAKC, WINED3DVS_VERSION(2,1), -1 },
{WINED3DSIO_BREAKP, "breakp", GLNAME_REQUIRE_GLSL, 0, 1, WINED3DSIH_BREAKP, 0, 0 }, {WINED3DSIO_BREAKP, "breakp", 0, 1, WINED3DSIH_BREAKP, 0, 0 },
{WINED3DSIO_CALL, "call", NULL, 0, 1, WINED3DSIH_CALL, WINED3DVS_VERSION(2,0), -1 }, {WINED3DSIO_CALL, "call", 0, 1, WINED3DSIH_CALL, WINED3DVS_VERSION(2,0), -1 },
{WINED3DSIO_CALLNZ, "callnz", NULL, 0, 2, WINED3DSIH_CALLNZ, WINED3DVS_VERSION(2,0), -1 }, {WINED3DSIO_CALLNZ, "callnz", 0, 2, WINED3DSIH_CALLNZ, WINED3DVS_VERSION(2,0), -1 },
{WINED3DSIO_LOOP, "loop", NULL, 0, 2, WINED3DSIH_LOOP, WINED3DVS_VERSION(2,0), -1 }, {WINED3DSIO_LOOP, "loop", 0, 2, WINED3DSIH_LOOP, WINED3DVS_VERSION(2,0), -1 },
{WINED3DSIO_RET, "ret", NULL, 0, 0, WINED3DSIH_RET, WINED3DVS_VERSION(2,0), -1 }, {WINED3DSIO_RET, "ret", 0, 0, WINED3DSIH_RET, WINED3DVS_VERSION(2,0), -1 },
{WINED3DSIO_ENDLOOP, "endloop", NULL, 0, 0, WINED3DSIH_ENDLOOP, WINED3DVS_VERSION(2,0), -1 }, {WINED3DSIO_ENDLOOP, "endloop", 0, 0, WINED3DSIH_ENDLOOP, WINED3DVS_VERSION(2,0), -1 },
{WINED3DSIO_LABEL, "label", NULL, 0, 1, WINED3DSIH_LABEL, WINED3DVS_VERSION(2,0), -1 }, {WINED3DSIO_LABEL, "label", 0, 1, WINED3DSIH_LABEL, WINED3DVS_VERSION(2,0), -1 },
{WINED3DSIO_SETP, "setp", GLNAME_REQUIRE_GLSL, 1, 3, WINED3DSIH_SETP, 0, 0 }, {WINED3DSIO_SETP, "setp", 1, 3, WINED3DSIH_SETP, 0, 0 },
{WINED3DSIO_TEXLDL, "texldl", NULL, 1, 3, WINED3DSIH_TEXLDL, WINED3DVS_VERSION(3,0), -1 }, {WINED3DSIO_TEXLDL, "texldl", 1, 3, WINED3DSIH_TEXLDL, WINED3DVS_VERSION(3,0), -1 },
{0, NULL, NULL, 0, 0, 0, 0, 0 } {0, NULL, 0, 0, 0, 0, 0 }
}; };
static void vshader_set_limits( static void vshader_set_limits(
@@ -120,7 +120,8 @@ static void vshader_set_limits(
/* Must match D3DCAPS9.MaxVertexShaderConst: at least 256 for vs_2_0 */ /* Must match D3DCAPS9.MaxVertexShaderConst: at least 256 for vs_2_0 */
This->baseShader.limits.constant_float = GL_LIMITS(vshader_constantsF); This->baseShader.limits.constant_float = GL_LIMITS(vshader_constantsF);
switch (This->baseShader.hex_version) { switch (This->baseShader.reg_maps.shader_version)
{
case WINED3DVS_VERSION(1,0): case WINED3DVS_VERSION(1,0):
case WINED3DVS_VERSION(1,1): case WINED3DVS_VERSION(1,1):
This->baseShader.limits.temporary = 12; This->baseShader.limits.temporary = 12;
@@ -161,7 +162,7 @@ static void vshader_set_limits(
This->baseShader.limits.sampler = 0; This->baseShader.limits.sampler = 0;
This->baseShader.limits.label = 16; This->baseShader.limits.label = 16;
FIXME("Unrecognized vertex shader version %#x\n", FIXME("Unrecognized vertex shader version %#x\n",
This->baseShader.hex_version); This->baseShader.reg_maps.shader_version);
} }
} }
@@ -217,152 +218,65 @@ BOOL vshader_get_input(
return FALSE; return FALSE;
} }
BOOL vshader_input_is_color(
IWineD3DVertexShader* iface,
unsigned int regnum) {
IWineD3DVertexShaderImpl* This = (IWineD3DVertexShaderImpl*) iface;
DWORD usage_token = This->semantics_in[regnum].usage;
DWORD usage = (usage_token & WINED3DSP_DCL_USAGE_MASK) >> WINED3DSP_DCL_USAGE_SHIFT;
DWORD usage_idx = (usage_token & WINED3DSP_DCL_USAGEINDEX_MASK) >> WINED3DSP_DCL_USAGEINDEX_SHIFT;
int i;
for(i = 0; i < This->num_swizzled_attribs; i++) {
if(This->swizzled_attribs[i].usage == usage &&
This->swizzled_attribs[i].idx == usage_idx) {
return TRUE;
}
}
return FALSE;
}
static inline void find_swizzled_attribs(IWineD3DVertexDeclaration *declaration, IWineD3DVertexShaderImpl *This) {
UINT num = 0, i, j;
UINT numoldswizzles = This->num_swizzled_attribs;
IWineD3DVertexDeclarationImpl *decl = (IWineD3DVertexDeclarationImpl *) declaration;
DWORD usage_token, usage, usage_idx;
BOOL found;
attrib_declaration oldswizzles[sizeof(This->swizzled_attribs) / sizeof(This->swizzled_attribs[0])];
/* Back up the old swizzles to keep attributes that are undefined in the current declaration */
memcpy(oldswizzles, This->swizzled_attribs, sizeof(oldswizzles));
memset(This->swizzled_attribs, 0, sizeof(This->swizzled_attribs[0]) * MAX_ATTRIBS);
for(i = 0; i < decl->num_swizzled_attribs; i++) {
for(j = 0; j < MAX_ATTRIBS; j++) {
if(!This->baseShader.reg_maps.attributes[j]) continue;
usage_token = This->semantics_in[j].usage;
usage = (usage_token & WINED3DSP_DCL_USAGE_MASK) >> WINED3DSP_DCL_USAGE_SHIFT;
usage_idx = (usage_token & WINED3DSP_DCL_USAGEINDEX_MASK) >> WINED3DSP_DCL_USAGEINDEX_SHIFT;
if(decl->swizzled_attribs[i].usage == usage &&
decl->swizzled_attribs[i].idx == usage_idx) {
This->swizzled_attribs[num].usage = usage;
This->swizzled_attribs[num].idx = usage_idx;
num++;
}
}
}
/* Add previously converted attributes back in if they are not defined in the current declaration */
for(i = 0; i < numoldswizzles; i++) {
found = FALSE;
for(j = 0; j < decl->declarationWNumElements; j++) {
if(oldswizzles[i].usage == decl->pDeclarationWine[j].Usage &&
oldswizzles[i].idx == decl->pDeclarationWine[j].UsageIndex) {
found = TRUE;
}
}
if(found) {
/* This previously converted attribute is declared in the current declaration. Either it is
* already in the new array, or it should not be there. Skip it
*/
continue;
}
/* We have a previously swizzled attribute that is not defined by the current vertex declaration.
* Insert it into the new conversion array to keep it in the old defined state. Otherwise we end up
* recompiling if the old decl is used again because undefined attributes are reset to no swizzling.
* In the reverse way(attribute was not swizzled and is not declared in new declaration) the attrib
* stays unswizzled as well because it isn't found in the oldswizzles array
*/
for(j = 0; j < num; j++) {
if(oldswizzles[i].usage > This->swizzled_attribs[j].usage || (
oldswizzles[i].usage == This->swizzled_attribs[j].usage &&
oldswizzles[i].idx > This->swizzled_attribs[j].idx)) {
memmove(&This->swizzled_attribs[j + 1], &This->swizzled_attribs[j],
sizeof(This->swizzled_attribs) - (sizeof(This->swizzled_attribs[0]) * (j + 1)));
break;
}
}
This->swizzled_attribs[j].usage = oldswizzles[i].usage;
This->swizzled_attribs[j].idx = oldswizzles[i].idx;
num++;
}
TRACE("New swizzled attributes array\n");
for(i = 0; i < num; i++) {
TRACE("%d: %s(%d), %d\n", i, debug_d3ddeclusage(This->swizzled_attribs[i].usage),
This->swizzled_attribs[i].usage, This->swizzled_attribs[i].idx);
}
This->num_swizzled_attribs = num;
}
/** Generate a vertex shader string using either GL_VERTEX_PROGRAM_ARB /** Generate a vertex shader string using either GL_VERTEX_PROGRAM_ARB
or GLSL and send it to the card */ or GLSL and send it to the card */
static VOID IWineD3DVertexShaderImpl_GenerateShader( static void IWineD3DVertexShaderImpl_GenerateShader(IWineD3DVertexShader *iface,
IWineD3DVertexShader *iface, const struct shader_reg_maps* reg_maps, const DWORD *pFunction)
shader_reg_maps* reg_maps, {
CONST DWORD *pFunction) {
IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface; IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface;
IWineD3DVertexDeclaration *decl = ((IWineD3DDeviceImpl *) This->baseShader.device)->stateBlock->vertexDecl;
SHADER_BUFFER buffer; SHADER_BUFFER buffer;
find_swizzled_attribs(decl, This); This->swizzle_map = ((IWineD3DDeviceImpl *)This->baseShader.device)->strided_streams.swizzle_map;
#if 0 /* FIXME: Use the buffer that is held by the device, this is ok since fixups will be skipped for software shaders
it also requires entering a critical section but cuts down the runtime footprint of wined3d and any memory fragmentation that may occur... */
if (This->device->fixupVertexBufferSize < SHADER_PGMSIZE) {
HeapFree(GetProcessHeap(), 0, This->fixupVertexBuffer);
This->fixupVertexBuffer = HeapAlloc(GetProcessHeap() , 0, SHADER_PGMSIZE);
This->fixupVertexBufferSize = PGMSIZE;
This->fixupVertexBuffer[0] = 0;
}
buffer.buffer = This->device->fixupVertexBuffer;
#else
buffer.buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, SHADER_PGMSIZE);
#endif
buffer.bsize = 0;
buffer.lineNo = 0;
buffer.newline = TRUE;
shader_buffer_init(&buffer);
((IWineD3DDeviceImpl *)This->baseShader.device)->shader_backend->shader_generate_vshader(iface, &buffer); ((IWineD3DDeviceImpl *)This->baseShader.device)->shader_backend->shader_generate_vshader(iface, &buffer);
shader_buffer_free(&buffer);
#if 1 /* if were using the data buffer of device then we don't need to free it */
HeapFree(GetProcessHeap(), 0, buffer.buffer);
#endif
} }
/* ******************************************* /* *******************************************
IWineD3DVertexShader IUnknown parts follow IWineD3DVertexShader IUnknown parts follow
******************************************* */ ******************************************* */
static HRESULT WINAPI IWineD3DVertexShaderImpl_QueryInterface(IWineD3DVertexShader *iface, REFIID riid, LPVOID *ppobj) { static HRESULT WINAPI IWineD3DVertexShaderImpl_QueryInterface(IWineD3DVertexShader *iface, REFIID riid, LPVOID *ppobj) {
return IWineD3DBaseShaderImpl_QueryInterface((IWineD3DBaseShader *) iface, riid, ppobj); TRACE("iface %p, riid %s, ppobj %p\n", iface, debugstr_guid(riid), ppobj);
if (IsEqualGUID(riid, &IID_IWineD3DVertexShader)
|| IsEqualGUID(riid, &IID_IWineD3DBaseShader)
|| IsEqualGUID(riid, &IID_IWineD3DBase)
|| IsEqualGUID(riid, &IID_IUnknown))
{
IUnknown_AddRef(iface);
*ppobj = iface;
return S_OK;
}
WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
*ppobj = NULL;
return E_NOINTERFACE;
} }
static ULONG WINAPI IWineD3DVertexShaderImpl_AddRef(IWineD3DVertexShader *iface) { static ULONG WINAPI IWineD3DVertexShaderImpl_AddRef(IWineD3DVertexShader *iface) {
return IWineD3DBaseShaderImpl_AddRef((IWineD3DBaseShader *) iface); IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface;
ULONG refcount = InterlockedIncrement(&This->baseShader.ref);
TRACE("%p increasing refcount to %u\n", This, refcount);
return refcount;
} }
static ULONG WINAPI IWineD3DVertexShaderImpl_Release(IWineD3DVertexShader *iface) { static ULONG WINAPI IWineD3DVertexShaderImpl_Release(IWineD3DVertexShader *iface) {
return IWineD3DBaseShaderImpl_Release((IWineD3DBaseShader *) iface); IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface;
ULONG refcount = InterlockedDecrement(&This->baseShader.ref);
TRACE("%p decreasing refcount to %u\n", This, refcount);
if (!refcount)
{
shader_cleanup((IWineD3DBaseShader *)iface);
HeapFree(GetProcessHeap(), 0, This);
}
return refcount;
} }
/* ******************************************* /* *******************************************
@@ -400,16 +314,10 @@ static HRESULT WINAPI IWineD3DVertexShaderImpl_GetFunction(IWineD3DVertexShader*
* return D3DERR_MOREDATA. That's not actually true. */ * return D3DERR_MOREDATA. That's not actually true. */
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
if (NULL == This->baseShader.function) { /* no function defined */
TRACE("(%p) : GetFunction no User Function defined using NULL to %p\n", This, pData);
(*(DWORD **) pData) = NULL;
} else {
if(This->baseShader.functionLength == 0){
} TRACE("(%p) : GetFunction copying to %p\n", This, pData);
TRACE("(%p) : GetFunction copying to %p\n", This, pData); memcpy(pData, This->baseShader.function, This->baseShader.functionLength);
memcpy(pData, This->baseShader.function, This->baseShader.functionLength);
}
return WINED3D_OK; return WINED3D_OK;
} }
@@ -427,8 +335,7 @@ static HRESULT WINAPI IWineD3DVertexShaderImpl_SetFunction(IWineD3DVertexShader
TRACE("(%p) : pFunction %p\n", iface, pFunction); TRACE("(%p) : pFunction %p\n", iface, pFunction);
/* First pass: trace shader */ /* First pass: trace shader */
shader_trace_init((IWineD3DBaseShader*) This, pFunction); if (TRACE_ON(d3d_shader)) shader_trace_init(pFunction, This->baseShader.shader_ins);
vshader_set_limits(This);
/* Initialize immediate constant lists */ /* Initialize immediate constant lists */
list_init(&This->baseShader.constantsF); list_init(&This->baseShader.constantsF);
@@ -440,9 +347,11 @@ static HRESULT WINAPI IWineD3DVertexShaderImpl_SetFunction(IWineD3DVertexShader
This->max_rel_offset = 0; This->max_rel_offset = 0;
memset(reg_maps, 0, sizeof(shader_reg_maps)); memset(reg_maps, 0, sizeof(shader_reg_maps));
hr = shader_get_registers_used((IWineD3DBaseShader*) This, reg_maps, hr = shader_get_registers_used((IWineD3DBaseShader*) This, reg_maps,
This->semantics_in, This->semantics_out, pFunction, NULL); This->semantics_in, This->semantics_out, pFunction);
if (hr != WINED3D_OK) return hr; if (hr != WINED3D_OK) return hr;
vshader_set_limits(This);
This->baseShader.shader_mode = deviceImpl->vs_selected_mode; This->baseShader.shader_mode = deviceImpl->vs_selected_mode;
if(deviceImpl->vs_selected_mode == SHADER_ARB && if(deviceImpl->vs_selected_mode == SHADER_ARB &&
@@ -464,16 +373,9 @@ static HRESULT WINAPI IWineD3DVertexShaderImpl_SetFunction(IWineD3DVertexShader
This->baseShader.load_local_constsF = This->baseShader.reg_maps.usesrelconstF && !list_empty(&This->baseShader.constantsF); This->baseShader.load_local_constsF = This->baseShader.reg_maps.usesrelconstF && !list_empty(&This->baseShader.constantsF);
/* copy the function ... because it will certainly be released by application */ /* copy the function ... because it will certainly be released by application */
if (NULL != pFunction) { This->baseShader.function = HeapAlloc(GetProcessHeap(), 0, This->baseShader.functionLength);
void *function; if (!This->baseShader.function) return E_OUTOFMEMORY;
memcpy(This->baseShader.function, pFunction, This->baseShader.functionLength);
function = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->baseShader.functionLength);
if (!function) return E_OUTOFMEMORY;
memcpy(function, pFunction, This->baseShader.functionLength);
This->baseShader.function = function;
} else {
This->baseShader.function = NULL;
}
return WINED3D_OK; return WINED3D_OK;
} }
@@ -485,7 +387,7 @@ static void WINAPI IWineD3DVertexShaderImpl_FakeSemantics(IWineD3DVertexShader *
int i; int i;
for (i = 0; i < vdecl->declarationWNumElements - 1; ++i) { for (i = 0; i < vdecl->declarationWNumElements - 1; ++i) {
WINED3DVERTEXELEMENT* element = vdecl->pDeclarationWine + i; const WINED3DVERTEXELEMENT *element = vdecl->pDeclarationWine + i;
vshader_set_input(This, element->Reg, element->Usage, element->UsageIndex); vshader_set_input(This, element->Reg, element->Usage, element->UsageIndex);
} }
} }
@@ -516,56 +418,8 @@ static HRESULT WINAPI IWIneD3DVertexShaderImpl_SetLocalConstantsF(IWineD3DVertex
return WINED3D_OK; return WINED3D_OK;
} }
static inline BOOL swizzled_attribs_differ(IWineD3DVertexShaderImpl *This, IWineD3DVertexDeclarationImpl *vdecl) { HRESULT IWineD3DVertexShaderImpl_CompileShader(IWineD3DVertexShader *iface) {
UINT i, j, k;
BOOL found;
DWORD usage_token;
DWORD usage;
DWORD usage_idx;
for(i = 0; i < vdecl->declarationWNumElements; i++) {
/* Ignore tesselated streams and the termination entry(position0, stream 255, unused) */
if(vdecl->pDeclarationWine[i].Stream >= MAX_STREAMS ||
vdecl->pDeclarationWine[i].Type == WINED3DDECLTYPE_UNUSED) continue;
for(j = 0; j < MAX_ATTRIBS; j++) {
if(!This->baseShader.reg_maps.attributes[j]) continue;
usage_token = This->semantics_in[j].usage;
usage = (usage_token & WINED3DSP_DCL_USAGE_MASK) >> WINED3DSP_DCL_USAGE_SHIFT;
usage_idx = (usage_token & WINED3DSP_DCL_USAGEINDEX_MASK) >> WINED3DSP_DCL_USAGEINDEX_SHIFT;
if(vdecl->pDeclarationWine[i].Usage != usage ||
vdecl->pDeclarationWine[i].UsageIndex != usage_idx) {
continue;
}
found = FALSE;
for(k = 0; k < This->num_swizzled_attribs; k++) {
if(This->swizzled_attribs[k].usage == usage &&
This->swizzled_attribs[k].idx == usage_idx) {
found = TRUE;
}
}
if(!found && vdecl->pDeclarationWine[i].Type == WINED3DDECLTYPE_D3DCOLOR) {
TRACE("Attribute %s%d is D3DCOLOR now but wasn't before\n",
debug_d3ddeclusage(usage), usage_idx);
return TRUE;
}
if( found && vdecl->pDeclarationWine[i].Type != WINED3DDECLTYPE_D3DCOLOR) {
TRACE("Attribute %s%d was D3DCOLOR before but is not any more\n",
debug_d3ddeclusage(usage), usage_idx);
return TRUE;
}
}
}
return FALSE;
}
static HRESULT WINAPI IWineD3DVertexShaderImpl_CompileShader(IWineD3DVertexShader *iface) {
IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface; IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface;
IWineD3DVertexDeclarationImpl *vdecl;
CONST DWORD *function = This->baseShader.function; CONST DWORD *function = This->baseShader.function;
IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *) This->baseShader.device; IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *) This->baseShader.device;
@@ -573,20 +427,10 @@ static HRESULT WINAPI IWineD3DVertexShaderImpl_CompileShader(IWineD3DVertexShade
/* We're already compiled. */ /* We're already compiled. */
if (This->baseShader.is_compiled) { if (This->baseShader.is_compiled) {
vdecl = (IWineD3DVertexDeclarationImpl *) deviceImpl->stateBlock->vertexDecl; if ((This->swizzle_map & deviceImpl->strided_streams.use_map) != deviceImpl->strided_streams.swizzle_map)
{
if(This->num_swizzled_attribs != vdecl->num_swizzled_attribs || WARN("Recompiling vertex shader %p due to D3DCOLOR input changes\n", This);
memcmp(This->swizzled_attribs, vdecl->swizzled_attribs, sizeof(vdecl->swizzled_attribs[0]) * This->num_swizzled_attribs) != 0) { goto recompile;
/* The swizzled attributes differ between shader and declaration. This doesn't necessarily mean
* we have to recompile, but we have to take a deeper look at see if the attribs that differ
* are declared in the decl and used in the shader
*/
if(swizzled_attribs_differ(This, vdecl)) {
WARN("Recompiling vertex shader %p due to D3DCOLOR input changes\n", This);
goto recompile;
}
WARN("Swizzled attribute validation required an expensive comparison\n");
} }
return WINED3D_OK; return WINED3D_OK;
@@ -601,12 +445,6 @@ static HRESULT WINAPI IWineD3DVertexShaderImpl_CompileShader(IWineD3DVertexShade
deviceImpl->shader_backend->shader_destroy((IWineD3DBaseShader *) iface); deviceImpl->shader_backend->shader_destroy((IWineD3DBaseShader *) iface);
} }
/* We don't need to compile */
if (!function) {
This->baseShader.is_compiled = TRUE;
return WINED3D_OK;
}
/* Generate the HW shader */ /* Generate the HW shader */
TRACE("(%p) : Generating hardware program\n", This); TRACE("(%p) : Generating hardware program\n", This);
IWineD3DVertexShaderImpl_GenerateShader(iface, &This->baseShader.reg_maps, function); IWineD3DVertexShaderImpl_GenerateShader(iface, &This->baseShader.reg_maps, function);
@@ -626,7 +464,6 @@ const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl =
IWineD3DVertexShaderImpl_GetParent, IWineD3DVertexShaderImpl_GetParent,
/*** IWineD3DBaseShader methods ***/ /*** IWineD3DBaseShader methods ***/
IWineD3DVertexShaderImpl_SetFunction, IWineD3DVertexShaderImpl_SetFunction,
IWineD3DVertexShaderImpl_CompileShader,
/*** IWineD3DVertexShader methods ***/ /*** IWineD3DVertexShader methods ***/
IWineD3DVertexShaderImpl_GetDevice, IWineD3DVertexShaderImpl_GetDevice,
IWineD3DVertexShaderImpl_GetFunction, IWineD3DVertexShaderImpl_GetFunction,

View File

@@ -64,6 +64,31 @@ static void volume_bind_and_dirtify(IWineD3DVolume *iface) {
} }
} }
void volume_add_dirty_box(IWineD3DVolume *iface, const WINED3DBOX *dirty_box)
{
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
This->dirty = TRUE;
if (dirty_box)
{
This->lockedBox.Left = min(This->lockedBox.Left, dirty_box->Left);
This->lockedBox.Top = min(This->lockedBox.Top, dirty_box->Top);
This->lockedBox.Front = min(This->lockedBox.Front, dirty_box->Front);
This->lockedBox.Right = max(This->lockedBox.Right, dirty_box->Right);
This->lockedBox.Bottom = max(This->lockedBox.Bottom, dirty_box->Bottom);
This->lockedBox.Back = max(This->lockedBox.Back, dirty_box->Back);
}
else
{
This->lockedBox.Left = 0;
This->lockedBox.Top = 0;
This->lockedBox.Front = 0;
This->lockedBox.Right = This->currentDesc.Width;
This->lockedBox.Bottom = This->currentDesc.Height;
This->lockedBox.Back = This->currentDesc.Depth;
}
}
/* ******************************************* /* *******************************************
IWineD3DVolume IUnknown parts follow IWineD3DVolume IUnknown parts follow
******************************************* */ ******************************************* */
@@ -94,7 +119,7 @@ static ULONG WINAPI IWineD3DVolumeImpl_Release(IWineD3DVolume *iface) {
TRACE("(%p) : Releasing from %d\n", This, This->resource.ref); TRACE("(%p) : Releasing from %d\n", This, This->resource.ref);
ref = InterlockedDecrement(&This->resource.ref); ref = InterlockedDecrement(&This->resource.ref);
if (ref == 0) { if (ref == 0) {
IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface); resource_cleanup((IWineD3DResource *)iface);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
return ref; return ref;
@@ -104,35 +129,35 @@ static ULONG WINAPI IWineD3DVolumeImpl_Release(IWineD3DVolume *iface) {
IWineD3DVolume IWineD3DResource parts follow IWineD3DVolume IWineD3DResource parts follow
**************************************************** */ **************************************************** */
static HRESULT WINAPI IWineD3DVolumeImpl_GetParent(IWineD3DVolume *iface, IUnknown **pParent) { static HRESULT WINAPI IWineD3DVolumeImpl_GetParent(IWineD3DVolume *iface, IUnknown **pParent) {
return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent); return resource_get_parent((IWineD3DResource *)iface, pParent);
} }
static HRESULT WINAPI IWineD3DVolumeImpl_GetDevice(IWineD3DVolume *iface, IWineD3DDevice** ppDevice) { static HRESULT WINAPI IWineD3DVolumeImpl_GetDevice(IWineD3DVolume *iface, IWineD3DDevice** ppDevice) {
return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice); return resource_get_device((IWineD3DResource *)iface, ppDevice);
} }
static HRESULT WINAPI IWineD3DVolumeImpl_SetPrivateData(IWineD3DVolume *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) { static HRESULT WINAPI IWineD3DVolumeImpl_SetPrivateData(IWineD3DVolume *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags); return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
} }
static HRESULT WINAPI IWineD3DVolumeImpl_GetPrivateData(IWineD3DVolume *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) { static HRESULT WINAPI IWineD3DVolumeImpl_GetPrivateData(IWineD3DVolume *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData); return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
} }
static HRESULT WINAPI IWineD3DVolumeImpl_FreePrivateData(IWineD3DVolume *iface, REFGUID refguid) { static HRESULT WINAPI IWineD3DVolumeImpl_FreePrivateData(IWineD3DVolume *iface, REFGUID refguid) {
return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid); return resource_free_private_data((IWineD3DResource *)iface, refguid);
} }
static DWORD WINAPI IWineD3DVolumeImpl_SetPriority(IWineD3DVolume *iface, DWORD PriorityNew) { static DWORD WINAPI IWineD3DVolumeImpl_SetPriority(IWineD3DVolume *iface, DWORD PriorityNew) {
return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew); return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
} }
static DWORD WINAPI IWineD3DVolumeImpl_GetPriority(IWineD3DVolume *iface) { static DWORD WINAPI IWineD3DVolumeImpl_GetPriority(IWineD3DVolume *iface) {
return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface); return resource_get_priority((IWineD3DResource *)iface);
} }
static void WINAPI IWineD3DVolumeImpl_PreLoad(IWineD3DVolume *iface) { static void WINAPI IWineD3DVolumeImpl_PreLoad(IWineD3DVolume *iface) {
IWineD3DResourceImpl_PreLoad((IWineD3DResource *)iface); FIXME("iface %p stub!\n", iface);
} }
static void WINAPI IWineD3DVolumeImpl_UnLoad(IWineD3DVolume *iface) { static void WINAPI IWineD3DVolumeImpl_UnLoad(IWineD3DVolume *iface) {
@@ -143,7 +168,7 @@ static void WINAPI IWineD3DVolumeImpl_UnLoad(IWineD3DVolume *iface) {
} }
static WINED3DRESOURCETYPE WINAPI IWineD3DVolumeImpl_GetType(IWineD3DVolume *iface) { static WINED3DRESOURCETYPE WINAPI IWineD3DVolumeImpl_GetType(IWineD3DVolume *iface) {
return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface); return resource_get_type((IWineD3DResource *)iface);
} }
/* ******************************************* /* *******************************************
@@ -225,7 +250,7 @@ static HRESULT WINAPI IWineD3DVolumeImpl_LockBox(IWineD3DVolume *iface, WINED3DL
* Dirtify on lock * Dirtify on lock
* as seen in msdn docs * as seen in msdn docs
*/ */
IWineD3DVolume_AddDirtyBox(iface, &This->lockedBox); volume_add_dirty_box(iface, &This->lockedBox);
/** Dirtify Container if needed */ /** Dirtify Container if needed */
if (NULL != This->container) { if (NULL != This->container) {
@@ -261,39 +286,6 @@ static HRESULT WINAPI IWineD3DVolumeImpl_UnlockBox(IWineD3DVolume *iface) {
/* Internal use functions follow : */ /* Internal use functions follow : */
static HRESULT WINAPI IWineD3DVolumeImpl_CleanDirtyBox(IWineD3DVolume *iface) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
This->dirty = FALSE;
This->lockedBox.Left = This->currentDesc.Width;
This->lockedBox.Top = This->currentDesc.Height;
This->lockedBox.Front = This->currentDesc.Depth;
This->lockedBox.Right = 0;
This->lockedBox.Bottom = 0;
This->lockedBox.Back = 0;
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DVolumeImpl_AddDirtyBox(IWineD3DVolume *iface, CONST WINED3DBOX* pDirtyBox) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
This->dirty = TRUE;
if (NULL != pDirtyBox) {
This->lockedBox.Left = min(This->lockedBox.Left, pDirtyBox->Left);
This->lockedBox.Top = min(This->lockedBox.Top, pDirtyBox->Top);
This->lockedBox.Front = min(This->lockedBox.Front, pDirtyBox->Front);
This->lockedBox.Right = max(This->lockedBox.Right, pDirtyBox->Right);
This->lockedBox.Bottom = max(This->lockedBox.Bottom, pDirtyBox->Bottom);
This->lockedBox.Back = max(This->lockedBox.Back, pDirtyBox->Back);
} else {
This->lockedBox.Left = 0;
This->lockedBox.Top = 0;
This->lockedBox.Front = 0;
This->lockedBox.Right = This->currentDesc.Width;
This->lockedBox.Bottom = This->currentDesc.Height;
This->lockedBox.Back = This->currentDesc.Depth;
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DVolumeImpl_SetContainer(IWineD3DVolume *iface, IWineD3DBase* container) { static HRESULT WINAPI IWineD3DVolumeImpl_SetContainer(IWineD3DVolume *iface, IWineD3DBase* container) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface; IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
@@ -310,7 +302,7 @@ static HRESULT WINAPI IWineD3DVolumeImpl_SetContainer(IWineD3DVolume *iface, IWi
static HRESULT WINAPI IWineD3DVolumeImpl_LoadTexture(IWineD3DVolume *iface, int gl_level, BOOL srgb_mode) { static HRESULT WINAPI IWineD3DVolumeImpl_LoadTexture(IWineD3DVolume *iface, int gl_level, BOOL srgb_mode) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface; IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
WINED3DFORMAT format = This->resource.format; WINED3DFORMAT format = This->resource.format;
const GlPixelFormatDesc *glDesc; const struct GlPixelFormatDesc *glDesc;
getFormatDescEntry(format, &GLINFO_LOCATION, &glDesc); getFormatDescEntry(format, &GLINFO_LOCATION, &glDesc);
TRACE("(%p) : level %u, format %s (0x%08x)\n", This, gl_level, debug_d3dformat(format), format); TRACE("(%p) : level %u, format %s (0x%08x)\n", This, gl_level, debug_d3dformat(format), format);
@@ -374,8 +366,6 @@ const IWineD3DVolumeVtbl IWineD3DVolume_Vtbl =
IWineD3DVolumeImpl_LockBox, IWineD3DVolumeImpl_LockBox,
IWineD3DVolumeImpl_UnlockBox, IWineD3DVolumeImpl_UnlockBox,
/* Internal interface */ /* Internal interface */
IWineD3DVolumeImpl_AddDirtyBox,
IWineD3DVolumeImpl_CleanDirtyBox,
IWineD3DVolumeImpl_LoadTexture, IWineD3DVolumeImpl_LoadTexture,
IWineD3DVolumeImpl_SetContainer IWineD3DVolumeImpl_SetContainer
}; };

View File

@@ -67,27 +67,27 @@ static ULONG WINAPI IWineD3DVolumeTextureImpl_Release(IWineD3DVolumeTexture *ifa
IWineD3DVolumeTexture IWineD3DResource parts follow IWineD3DVolumeTexture IWineD3DResource parts follow
**************************************************** */ **************************************************** */
static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetDevice(IWineD3DVolumeTexture *iface, IWineD3DDevice** ppDevice) { static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetDevice(IWineD3DVolumeTexture *iface, IWineD3DDevice** ppDevice) {
return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice); return resource_get_device((IWineD3DResource *)iface, ppDevice);
} }
static HRESULT WINAPI IWineD3DVolumeTextureImpl_SetPrivateData(IWineD3DVolumeTexture *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) { static HRESULT WINAPI IWineD3DVolumeTextureImpl_SetPrivateData(IWineD3DVolumeTexture *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags); return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
} }
static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetPrivateData(IWineD3DVolumeTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) { static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetPrivateData(IWineD3DVolumeTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData); return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
} }
static HRESULT WINAPI IWineD3DVolumeTextureImpl_FreePrivateData(IWineD3DVolumeTexture *iface, REFGUID refguid) { static HRESULT WINAPI IWineD3DVolumeTextureImpl_FreePrivateData(IWineD3DVolumeTexture *iface, REFGUID refguid) {
return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid); return resource_free_private_data((IWineD3DResource *)iface, refguid);
} }
static DWORD WINAPI IWineD3DVolumeTextureImpl_SetPriority(IWineD3DVolumeTexture *iface, DWORD PriorityNew) { static DWORD WINAPI IWineD3DVolumeTextureImpl_SetPriority(IWineD3DVolumeTexture *iface, DWORD PriorityNew) {
return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew); return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
} }
static DWORD WINAPI IWineD3DVolumeTextureImpl_GetPriority(IWineD3DVolumeTexture *iface) { static DWORD WINAPI IWineD3DVolumeTextureImpl_GetPriority(IWineD3DVolumeTexture *iface) {
return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface); return resource_get_priority((IWineD3DResource *)iface);
} }
static void WINAPI IWineD3DVolumeTextureImpl_PreLoad(IWineD3DVolumeTexture *iface) { static void WINAPI IWineD3DVolumeTextureImpl_PreLoad(IWineD3DVolumeTexture *iface) {
@@ -119,7 +119,7 @@ static void WINAPI IWineD3DVolumeTextureImpl_PreLoad(IWineD3DVolumeTexture *ifac
FIXME("Volumetexture (%p) has been reloaded at least 20 times due to WINED3DSAMP_SRGBTEXTURE changes on it\'s sampler\n", This); FIXME("Volumetexture (%p) has been reloaded at least 20 times due to WINED3DSAMP_SRGBTEXTURE changes on it\'s sampler\n", This);
for (i = 0; i < This->baseTexture.levels; i++) { for (i = 0; i < This->baseTexture.levels; i++) {
IWineD3DVolume_AddDirtyBox(This->volumes[i], NULL); volume_add_dirty_box(This->volumes[i], NULL);
IWineD3DVolume_LoadTexture(This->volumes[i], i, srgb_mode); IWineD3DVolume_LoadTexture(This->volumes[i], i, srgb_mode);
} }
} else { } else {
@@ -145,57 +145,57 @@ static void WINAPI IWineD3DVolumeTextureImpl_UnLoad(IWineD3DVolumeTexture *iface
IWineD3DVolume_UnLoad(This->volumes[i]); IWineD3DVolume_UnLoad(This->volumes[i]);
} }
IWineD3DBaseTextureImpl_UnLoad((IWineD3DBaseTexture *) iface); basetexture_unload((IWineD3DBaseTexture *)iface);
} }
static WINED3DRESOURCETYPE WINAPI IWineD3DVolumeTextureImpl_GetType(IWineD3DVolumeTexture *iface) { static WINED3DRESOURCETYPE WINAPI IWineD3DVolumeTextureImpl_GetType(IWineD3DVolumeTexture *iface) {
return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface); return resource_get_type((IWineD3DResource *)iface);
} }
static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetParent(IWineD3DVolumeTexture *iface, IUnknown **pParent) { static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetParent(IWineD3DVolumeTexture *iface, IUnknown **pParent) {
return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent); return resource_get_parent((IWineD3DResource *)iface, pParent);
} }
/* ****************************************************** /* ******************************************************
IWineD3DVolumeTexture IWineD3DBaseTexture parts follow IWineD3DVolumeTexture IWineD3DBaseTexture parts follow
****************************************************** */ ****************************************************** */
static DWORD WINAPI IWineD3DVolumeTextureImpl_SetLOD(IWineD3DVolumeTexture *iface, DWORD LODNew) { static DWORD WINAPI IWineD3DVolumeTextureImpl_SetLOD(IWineD3DVolumeTexture *iface, DWORD LODNew) {
return IWineD3DBaseTextureImpl_SetLOD((IWineD3DBaseTexture *)iface, LODNew); return basetexture_set_lod((IWineD3DBaseTexture *)iface, LODNew);
} }
static DWORD WINAPI IWineD3DVolumeTextureImpl_GetLOD(IWineD3DVolumeTexture *iface) { static DWORD WINAPI IWineD3DVolumeTextureImpl_GetLOD(IWineD3DVolumeTexture *iface) {
return IWineD3DBaseTextureImpl_GetLOD((IWineD3DBaseTexture *)iface); return basetexture_get_lod((IWineD3DBaseTexture *)iface);
} }
static DWORD WINAPI IWineD3DVolumeTextureImpl_GetLevelCount(IWineD3DVolumeTexture *iface) { static DWORD WINAPI IWineD3DVolumeTextureImpl_GetLevelCount(IWineD3DVolumeTexture *iface) {
return IWineD3DBaseTextureImpl_GetLevelCount((IWineD3DBaseTexture *)iface); return basetexture_get_level_count((IWineD3DBaseTexture *)iface);
} }
static HRESULT WINAPI IWineD3DVolumeTextureImpl_SetAutoGenFilterType(IWineD3DVolumeTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType) { static HRESULT WINAPI IWineD3DVolumeTextureImpl_SetAutoGenFilterType(IWineD3DVolumeTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType) {
return IWineD3DBaseTextureImpl_SetAutoGenFilterType((IWineD3DBaseTexture *)iface, FilterType); return basetexture_set_autogen_filter_type((IWineD3DBaseTexture *)iface, FilterType);
} }
static WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DVolumeTextureImpl_GetAutoGenFilterType(IWineD3DVolumeTexture *iface) { static WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DVolumeTextureImpl_GetAutoGenFilterType(IWineD3DVolumeTexture *iface) {
return IWineD3DBaseTextureImpl_GetAutoGenFilterType((IWineD3DBaseTexture *)iface); return basetexture_get_autogen_filter_type((IWineD3DBaseTexture *)iface);
} }
static void WINAPI IWineD3DVolumeTextureImpl_GenerateMipSubLevels(IWineD3DVolumeTexture *iface) { static void WINAPI IWineD3DVolumeTextureImpl_GenerateMipSubLevels(IWineD3DVolumeTexture *iface) {
IWineD3DBaseTextureImpl_GenerateMipSubLevels((IWineD3DBaseTexture *)iface); basetexture_generate_mipmaps((IWineD3DBaseTexture *)iface);
} }
/* Internal function, No d3d mapping */ /* Internal function, No d3d mapping */
static BOOL WINAPI IWineD3DVolumeTextureImpl_SetDirty(IWineD3DVolumeTexture *iface, BOOL dirty) { static BOOL WINAPI IWineD3DVolumeTextureImpl_SetDirty(IWineD3DVolumeTexture *iface, BOOL dirty) {
return IWineD3DBaseTextureImpl_SetDirty((IWineD3DBaseTexture *)iface, dirty); return basetexture_set_dirty((IWineD3DBaseTexture *)iface, dirty);
} }
static BOOL WINAPI IWineD3DVolumeTextureImpl_GetDirty(IWineD3DVolumeTexture *iface) { static BOOL WINAPI IWineD3DVolumeTextureImpl_GetDirty(IWineD3DVolumeTexture *iface) {
return IWineD3DBaseTextureImpl_GetDirty((IWineD3DBaseTexture *)iface); return basetexture_get_dirty((IWineD3DBaseTexture *)iface);
} }
static HRESULT WINAPI IWineD3DVolumeTextureImpl_BindTexture(IWineD3DVolumeTexture *iface) { static HRESULT WINAPI IWineD3DVolumeTextureImpl_BindTexture(IWineD3DVolumeTexture *iface) {
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface; IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
TRACE("(%p) : relay to BaseTexture\n", This); TRACE("(%p) : relay to BaseTexture\n", This);
return IWineD3DBaseTextureImpl_BindTexture((IWineD3DBaseTexture *)iface); return basetexture_bind((IWineD3DBaseTexture *)iface);
} }
static UINT WINAPI IWineD3DVolumeTextureImpl_GetTextureDimensions(IWineD3DVolumeTexture *iface) { static UINT WINAPI IWineD3DVolumeTextureImpl_GetTextureDimensions(IWineD3DVolumeTexture *iface) {
@@ -216,7 +216,7 @@ static void WINAPI IWineD3DVolumeTextureImpl_ApplyStateChanges(IWineD3DVolumeTex
const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]) { const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]) {
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface; IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
TRACE("(%p) : nothing to do, passing to base texture\n", This); TRACE("(%p) : nothing to do, passing to base texture\n", This);
IWineD3DBaseTextureImpl_ApplyStateChanges((IWineD3DBaseTexture *)iface, textureStates, samplerStates); basetexture_apply_state_changes((IWineD3DBaseTexture *)iface, textureStates, samplerStates);
} }
@@ -234,7 +234,7 @@ static void WINAPI IWineD3DVolumeTextureImpl_Destroy(IWineD3DVolumeTexture *ifac
D3DCB_DestroyVolume(This->volumes[i]); D3DCB_DestroyVolume(This->volumes[i]);
} }
} }
IWineD3DBaseTextureImpl_CleanUp((IWineD3DBaseTexture *) iface); basetexture_cleanup((IWineD3DBaseTexture *)iface);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
@@ -244,7 +244,7 @@ static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetLevelDesc(IWineD3DVolumeTextu
TRACE("(%p) Level (%d)\n", This, Level); TRACE("(%p) Level (%d)\n", This, Level);
return IWineD3DVolume_GetDesc(This->volumes[Level], pDesc); return IWineD3DVolume_GetDesc(This->volumes[Level], pDesc);
} else { } else {
FIXME("(%p) Level (%d)\n", This, Level); WARN("(%p) Level (%d)\n", This, Level);
} }
return WINED3D_OK; return WINED3D_OK;
} }
@@ -255,7 +255,7 @@ static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetVolumeLevel(IWineD3DVolumeTex
IWineD3DVolume_AddRef(*ppVolumeLevel); IWineD3DVolume_AddRef(*ppVolumeLevel);
TRACE("(%p) -> level(%d) returning volume@%p\n", This, Level, *ppVolumeLevel); TRACE("(%p) -> level(%d) returning volume@%p\n", This, Level, *ppVolumeLevel);
} else { } else {
FIXME("(%p) Level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels); WARN("(%p) Level(%d) overflow Levels(%d)\n", This, Level, This->baseTexture.levels);
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
return WINED3D_OK; return WINED3D_OK;
@@ -295,7 +295,9 @@ static HRESULT WINAPI IWineD3DVolumeTextureImpl_AddDirtyBox(IWineD3DVolumeTextur
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface; IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
This->baseTexture.dirty = TRUE; This->baseTexture.dirty = TRUE;
TRACE("(%p) : dirtyfication of volume Level (0)\n", This); TRACE("(%p) : dirtyfication of volume Level (0)\n", This);
return IWineD3DVolume_AddDirtyBox(This->volumes[0], pDirtyBox); volume_add_dirty_box(This->volumes[0], pDirtyBox);
return WINED3D_OK;
} }
const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl = const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl =

View File

@@ -1,7 +1,8 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd"> <!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd">
<module name="wined3d" type="win32dll" installbase="system32" installname="wined3d.dll" allowwarnings ="true"> <module name="wined3d" type="win32dll" installbase="system32" installname="wined3d.dll" allowwarnings ="true" crt="msvcrt">
<importlibrary definition="wined3d.def" /> <importlibrary definition="wined3d.def" />
<compilerflag compiler="cc">-Wno-format</compilerflag>
<include base="wined3d">.</include> <include base="wined3d">.</include>
<include base="ReactOS">include/reactos/wine</include> <include base="ReactOS">include/reactos/wine</include>
<define name="__WINESRC__" /> <define name="__WINESRC__" />
@@ -25,6 +26,7 @@
<file>device.c</file> <file>device.c</file>
<file>directx.c</file> <file>directx.c</file>
<file>drawprim.c</file> <file>drawprim.c</file>
<file>gl_compat.c</file>
<file>glsl_shader.c</file> <file>glsl_shader.c</file>
<file>indexbuffer.c</file> <file>indexbuffer.c</file>
<file>nvidia_texture_shader.c</file> <file>nvidia_texture_shader.c</file>
@@ -49,4 +51,6 @@
<file>volumetexture.c</file> <file>volumetexture.c</file>
<file>wined3d_main.c</file> <file>wined3d_main.c</file>
<file>version.rc</file> <file>version.rc</file>
<dependency>wineheaders</dependency>
</module> </module>

View File

@@ -866,6 +866,7 @@ void (WINE_GLAPI *glDepthFunc) (GLenum func);
void (WINE_GLAPI *glDepthMask) (GLboolean flag); void (WINE_GLAPI *glDepthMask) (GLboolean flag);
void (WINE_GLAPI *glDepthRange) (GLclampd nearParam, GLclampd farParam); void (WINE_GLAPI *glDepthRange) (GLclampd nearParam, GLclampd farParam);
void (WINE_GLAPI *glDisable) (GLenum cap); void (WINE_GLAPI *glDisable) (GLenum cap);
void (WINE_GLAPI *glDisableWINE) (GLenum cap);
void (WINE_GLAPI *glDisableClientState) (GLenum array); void (WINE_GLAPI *glDisableClientState) (GLenum array);
void (WINE_GLAPI *glDrawArrays) (GLenum mode, GLint first, GLsizei count); void (WINE_GLAPI *glDrawArrays) (GLenum mode, GLint first, GLsizei count);
void (WINE_GLAPI *glDrawBuffer) (GLenum mode); void (WINE_GLAPI *glDrawBuffer) (GLenum mode);
@@ -875,6 +876,7 @@ void (WINE_GLAPI *glEdgeFlag) (GLboolean flag);
void (WINE_GLAPI *glEdgeFlagPointer) (GLsizei stride, const GLvoid* pointer); void (WINE_GLAPI *glEdgeFlagPointer) (GLsizei stride, const GLvoid* pointer);
void (WINE_GLAPI *glEdgeFlagv) (const GLboolean* flag); void (WINE_GLAPI *glEdgeFlagv) (const GLboolean* flag);
void (WINE_GLAPI *glEnable) (GLenum cap); void (WINE_GLAPI *glEnable) (GLenum cap);
void (WINE_GLAPI *glEnableWINE) (GLenum cap);
void (WINE_GLAPI *glEnableClientState) (GLenum array); void (WINE_GLAPI *glEnableClientState) (GLenum array);
void (WINE_GLAPI *glEnd) (); void (WINE_GLAPI *glEnd) ();
void (WINE_GLAPI *glEndList) (); void (WINE_GLAPI *glEndList) ();
@@ -1754,7 +1756,7 @@ typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const
#define GL_MODELVIEW30_ARB 0x873E #define GL_MODELVIEW30_ARB 0x873E
#define GL_MODELVIEW31_ARB 0x873F #define GL_MODELVIEW31_ARB 0x873F
#endif #endif
typedef void (WINE_GLAPI * PGLFNGLWEIGHTPOINTERARB) (GLint size, GLenum type, GLsizei stride, GLvoid* pointer); typedef void (WINE_GLAPI * PGLFNGLWEIGHTPOINTERARB) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
typedef void (WINE_GLAPI * PGLFNGLWEIGHTBV) (GLint size, const GLbyte *weights); typedef void (WINE_GLAPI * PGLFNGLWEIGHTBV) (GLint size, const GLbyte *weights);
typedef void (WINE_GLAPI * PGLFNGLWEIGHTSV) (GLint size, const GLshort *weights); typedef void (WINE_GLAPI * PGLFNGLWEIGHTSV) (GLint size, const GLshort *weights);
typedef void (WINE_GLAPI * PGLFNGLWEIGHTIV) (GLint size, const GLint *weights); typedef void (WINE_GLAPI * PGLFNGLWEIGHTIV) (GLint size, const GLint *weights);
@@ -2037,6 +2039,39 @@ typedef void (WINE_GLAPI * PGLFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint le
#define GL_RGBA16F_ARB 0x881A #define GL_RGBA16F_ARB 0x881A
#define GL_RGB16F_ARB 0x881B #define GL_RGB16F_ARB 0x881B
#endif #endif
/* GL_ARB_texture_rg */
#ifndef GL_ARB_texture_rg
#define GL_RG 0x8227
#define GL_RG_INTEGER 0x8228
#define GL_R8 0x8229
#define GL_R16 0x822A
#define GL_RG8 0x822B
#define GL_RG16 0x822C
#define GL_R16F 0x822D
#define GL_R32F 0x822E
#define GL_RG16F 0x822F
#define GL_RG32F 0x8230
#define GL_R8I 0x8231
#define GL_R8UI 0x8232
#define GL_R16I 0x8233
#define GL_R16UI 0x8234
#define GL_R32I 0x8235
#define GL_R32UI 0x8236
#define GL_RG8I 0x8237
#define GL_RG8UI 0x8238
#define GL_RG16I 0x8239
#define GL_RG16UI 0x823A
#define GL_RG32I 0x823B
#define GL_RG32UI 0x823C
#endif
/* GL_EXT_texture_swizzle */
#ifndef GL_EXT_texture_swizzle
#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42
#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43
#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44
#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45
#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46
#endif
/* GL_ARB_half_float_pixel */ /* GL_ARB_half_float_pixel */
#ifndef GL_ARB_half_float_pixel #ifndef GL_ARB_half_float_pixel
#define GL_ARB_half_float_pixel #define GL_ARB_half_float_pixel
@@ -2288,10 +2323,10 @@ typedef void (WINE_GLAPI * PGLFNBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, G
#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 #define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456
#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 #define GL_FOG_COORDINATE_ARRAY_EXT 0x8457
#endif /* GL_EXT_fog_coord */ #endif /* GL_EXT_fog_coord */
typedef void (WINE_GLAPI * PGLFNGLFOGCOORDFEXTPROC) (GLfloat intesity); typedef void (WINE_GLAPI * PGLFNGLFOGCOORDFEXTPROC) (GLfloat coord);
typedef void (WINE_GLAPI * PGLFNGLFOGCOORDFVEXTPROC) (GLfloat intesity); typedef void (WINE_GLAPI * PGLFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord);
typedef void (WINE_GLAPI * PGLFNGLFOGCOORDDEXTPROC) (GLfloat intesity); typedef void (WINE_GLAPI * PGLFNGLFOGCOORDDEXTPROC) (GLdouble coord);
typedef void (WINE_GLAPI * PGLFNGLFOGCOORDDVEXTPROC) (GLfloat intesity); typedef void (WINE_GLAPI * PGLFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord);
typedef void (WINE_GLAPI * PGLFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, GLvoid *data); typedef void (WINE_GLAPI * PGLFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, GLvoid *data);
/* GL_ARB_shader_objects (GLSL) */ /* GL_ARB_shader_objects (GLSL) */
#ifndef GL_ARB_shader_objects #ifndef GL_ARB_shader_objects
@@ -3254,6 +3289,7 @@ typedef enum _GL_Cards {
CARD_NVIDIA_GEFORCE_8800GTS = 0x0193, CARD_NVIDIA_GEFORCE_8800GTS = 0x0193,
CARD_NVIDIA_GEFORCE_9600GT = 0x0622, CARD_NVIDIA_GEFORCE_9600GT = 0x0622,
CARD_NVIDIA_GEFORCE_9800GT = 0x0614, CARD_NVIDIA_GEFORCE_9800GT = 0x0614,
CARD_NVIDIA_GEFORCE_GTX280 = 0x05e1,
CARD_INTEL_845G = 0x2562, CARD_INTEL_845G = 0x2562,
CARD_INTEL_I830G = 0x3577, CARD_INTEL_I830G = 0x3577,
@@ -3316,6 +3352,7 @@ typedef enum _GL_SupportedExt {
ARB_TEXTURE_MIRRORED_REPEAT, ARB_TEXTURE_MIRRORED_REPEAT,
ARB_TEXTURE_NON_POWER_OF_TWO, ARB_TEXTURE_NON_POWER_OF_TWO,
ARB_TEXTURE_RECTANGLE, ARB_TEXTURE_RECTANGLE,
ARB_TEXTURE_RG,
ARB_VERTEX_PROGRAM, ARB_VERTEX_PROGRAM,
ARB_VERTEX_BLEND, ARB_VERTEX_BLEND,
ARB_VERTEX_BUFFER_OBJECT, ARB_VERTEX_BUFFER_OBJECT,
@@ -3346,7 +3383,9 @@ typedef enum _GL_SupportedExt {
EXT_TEXTURE_ENV_COMBINE, EXT_TEXTURE_ENV_COMBINE,
EXT_TEXTURE_ENV_DOT3, EXT_TEXTURE_ENV_DOT3,
EXT_TEXTURE_SRGB, EXT_TEXTURE_SRGB,
EXT_TEXTURE_SWIZZLE,
EXT_GPU_PROGRAM_PARAMETERS, EXT_GPU_PROGRAM_PARAMETERS,
EXT_VERTEX_ARRAY_BGRA,
/* NVIDIA */ /* NVIDIA */
NV_HALF_FLOAT, NV_HALF_FLOAT,
NV_FOG_DISTANCE, NV_FOG_DISTANCE,
@@ -3470,7 +3509,7 @@ typedef enum _GL_SupportedExt {
USE_GL_FUNC(PGLFNGLFOGCOORDFEXTPROC, glFogCoordfEXT, EXT_FOG_COORD, NULL )\ USE_GL_FUNC(PGLFNGLFOGCOORDFEXTPROC, glFogCoordfEXT, EXT_FOG_COORD, NULL )\
USE_GL_FUNC(PGLFNGLFOGCOORDFVEXTPROC, glFogCoordfvEXT, EXT_FOG_COORD, NULL )\ USE_GL_FUNC(PGLFNGLFOGCOORDFVEXTPROC, glFogCoordfvEXT, EXT_FOG_COORD, NULL )\
USE_GL_FUNC(PGLFNGLFOGCOORDDEXTPROC, glFogCoorddEXT, EXT_FOG_COORD, NULL )\ USE_GL_FUNC(PGLFNGLFOGCOORDDEXTPROC, glFogCoorddEXT, EXT_FOG_COORD, NULL )\
USE_GL_FUNC(PGLFNGLFOGCOORDDVEXTPROC, glFogCoordvEXT, EXT_FOG_COORD, NULL )\ USE_GL_FUNC(PGLFNGLFOGCOORDDVEXTPROC, glFogCoorddvEXT, EXT_FOG_COORD, NULL )\
USE_GL_FUNC(PGLFNGLFOGCOORDPOINTEREXTPROC, glFogCoordPointerEXT, EXT_FOG_COORD, NULL )\ USE_GL_FUNC(PGLFNGLFOGCOORDPOINTEREXTPROC, glFogCoordPointerEXT, EXT_FOG_COORD, NULL )\
/* GL_EXT_framebuffer_object */ \ /* GL_EXT_framebuffer_object */ \
USE_GL_FUNC(PGLFNGLISRENDERBUFFEREXTPROC, glIsRenderbufferEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\ USE_GL_FUNC(PGLFNGLISRENDERBUFFEREXTPROC, glIsRenderbufferEXT, EXT_FRAMEBUFFER_OBJECT, NULL )\
@@ -3578,8 +3617,8 @@ typedef enum _GL_SupportedExt {
USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX2FVARBPROC, glUniformMatrix2fvARB, ARB_SHADER_OBJECTS, NULL )\ USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX2FVARBPROC, glUniformMatrix2fvARB, ARB_SHADER_OBJECTS, NULL )\
USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX3FVARBPROC, glUniformMatrix3fvARB, ARB_SHADER_OBJECTS, NULL )\ USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX3FVARBPROC, glUniformMatrix3fvARB, ARB_SHADER_OBJECTS, NULL )\
USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX4FVARBPROC, glUniformMatrix4fvARB, ARB_SHADER_OBJECTS, NULL )\ USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX4FVARBPROC, glUniformMatrix4fvARB, ARB_SHADER_OBJECTS, NULL )\
USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMFVARBPROC, glGetUniform4fvARB, ARB_SHADER_OBJECTS, NULL )\ USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMFVARBPROC, glGetUniformfvARB, ARB_SHADER_OBJECTS, NULL )\
USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMIVARBPROC, glGetUniform4ivARB, ARB_SHADER_OBJECTS, NULL )\ USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMIVARBPROC, glGetUniformivARB, ARB_SHADER_OBJECTS, NULL )\
USE_GL_FUNC(WINED3D_PFNGLGETINFOLOGARBPROC, glGetInfoLogARB, ARB_SHADER_OBJECTS, NULL )\ USE_GL_FUNC(WINED3D_PFNGLGETINFOLOGARBPROC, glGetInfoLogARB, ARB_SHADER_OBJECTS, NULL )\
USE_GL_FUNC(WINED3D_PFNGLUSEPROGRAMOBJECTARBPROC, glUseProgramObjectARB, ARB_SHADER_OBJECTS, NULL )\ USE_GL_FUNC(WINED3D_PFNGLUSEPROGRAMOBJECTARBPROC, glUseProgramObjectARB, ARB_SHADER_OBJECTS, NULL )\
USE_GL_FUNC(WINED3D_PFNGLCREATESHADEROBJECTARBPROC, glCreateShaderObjectARB, ARB_SHADER_OBJECTS, NULL )\ USE_GL_FUNC(WINED3D_PFNGLCREATESHADEROBJECTARBPROC, glCreateShaderObjectARB, ARB_SHADER_OBJECTS, NULL )\
@@ -3677,8 +3716,8 @@ typedef enum _GL_SupportedExt {
USE_GL_FUNC(PGLXFNGETVIDEOSYNCSGIPROC, glXGetVideoSyncSGI, SGI_VIDEO_SYNC, NULL )\ USE_GL_FUNC(PGLXFNGETVIDEOSYNCSGIPROC, glXGetVideoSyncSGI, SGI_VIDEO_SYNC, NULL )\
USE_GL_FUNC(PGLXFNWAITVIDEOSYNCSGIPROC, glXWaitVideoSyncSGI, SGI_VIDEO_SYNC, NULL )\ USE_GL_FUNC(PGLXFNWAITVIDEOSYNCSGIPROC, glXWaitVideoSyncSGI, SGI_VIDEO_SYNC, NULL )\
/* GL_APPLE_flush_render */ \ /* GL_APPLE_flush_render */ \
USE_GL_FUNC(PGLFNFLUSHRENDERAPPLEPROC, glFlushRenderApple, APPLE_FLUSH_RENDER, NULL )\ USE_GL_FUNC(PGLFNFLUSHRENDERAPPLEPROC, glFlushRenderAPPLE, APPLE_FLUSH_RENDER, NULL )\
USE_GL_FUNC(PGLFNFINISHRENDERAPPLEPROC, glFinishRenderApple, APPLE_FLUSH_RENDER, NULL )\ USE_GL_FUNC(PGLFNFINISHRENDERAPPLEPROC, glFinishRenderAPPLE, APPLE_FLUSH_RENDER, NULL )\
/* GL_EXT_gpu_program_parameters */ \ /* GL_EXT_gpu_program_parameters */ \
USE_GL_FUNC(PGLFNPROGRAMENVPARAMETERS4FVEXTPROC, glProgramEnvParameters4fvEXT, EXT_GPU_PROGRAM_PARAMETERS,NULL )\ USE_GL_FUNC(PGLFNPROGRAMENVPARAMETERS4FVEXTPROC, glProgramEnvParameters4fvEXT, EXT_GPU_PROGRAM_PARAMETERS,NULL )\
USE_GL_FUNC(PGLFNPROGRAMLOCALPARAMETERS4FVEXTPROC, glProgramLocalParameters4fvEXT, EXT_GPU_PROGRAM_PARAMETERS,NULL )\ USE_GL_FUNC(PGLFNPROGRAMLOCALPARAMETERS4FVEXTPROC, glProgramLocalParameters4fvEXT, EXT_GPU_PROGRAM_PARAMETERS,NULL )\
@@ -3812,17 +3851,11 @@ typedef BOOL (WINAPI * WINED3D_PFNWGLSETPIXELFORMATWINE) (HDC hdc, int iPixelFor
* Structures * Structures
****************************************************/ ****************************************************/
typedef struct {
GLint glInternal, glGammaInternal, rtInternal, glFormat, glType;
WINED3DFORMAT conversion_group;
unsigned int Flags;
float heightscale;
} GlPixelFormatDesc;
typedef struct _WINED3DGLTYPE { typedef struct _WINED3DGLTYPE {
int d3dType; int d3dType;
GLint size; GLint size;
GLenum glType; GLenum glType;
GLint format;
GLboolean normalized; GLboolean normalized;
int typesize; int typesize;
} WINED3DGLTYPE; } WINED3DGLTYPE;
@@ -3888,7 +3921,7 @@ typedef struct _WineD3D_GL_Info {
/** OpenGL WGL functions ptr */ /** OpenGL WGL functions ptr */
WGL_EXT_FUNCS_GEN WGL_EXT_FUNCS_GEN
GlPixelFormatDesc *gl_formats; struct GlPixelFormatDesc *gl_formats;
/* Vertex data types */ /* Vertex data types */
WINED3DGLTYPE glTypeLookup[WINED3DDECLTYPE_UNUSED]; WINED3DGLTYPE glTypeLookup[WINED3DDECLTYPE_UNUSED];

View File

@@ -29,8 +29,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DEFAULT_DEBUG_CHANNEL(d3d);
int num_lock = 0; int num_lock = 0;
void (*wine_tsx11_lock_ptr)(void) = NULL; void (*CDECL wine_tsx11_lock_ptr)(void) = NULL;
void (*wine_tsx11_unlock_ptr)(void) = NULL; void (*CDECL wine_tsx11_unlock_ptr)(void) = NULL;
/* When updating default value here, make sure to update winecfg as well, /* When updating default value here, make sure to update winecfg as well,
@@ -43,6 +43,8 @@ wined3d_settings_t wined3d_settings =
TRUE, /* Use of GLSL enabled by default */ TRUE, /* Use of GLSL enabled by default */
ORM_BACKBUFFER, /* Use the backbuffer to do offscreen rendering */ ORM_BACKBUFFER, /* Use the backbuffer to do offscreen rendering */
RTL_AUTO, /* Automatically determine best locking method */ RTL_AUTO, /* Automatically determine best locking method */
PCI_VENDOR_NONE,/* PCI Vendor ID */
PCI_DEVICE_NONE,/* PCI Device ID */
0, /* The default of memory is set in FillGLCaps */ 0, /* The default of memory is set in FillGLCaps */
NULL, /* No wine logo by default */ NULL, /* No wine logo by default */
FALSE /* Disable multisampling for now due to Nvidia driver bugs which happens for some users */ FALSE /* Disable multisampling for now due to Nvidia driver bugs which happens for some users */
@@ -77,7 +79,16 @@ static inline DWORD get_config_key(HKEY defkey, HKEY appkey, const char* name, c
return ERROR_FILE_NOT_FOUND; return ERROR_FILE_NOT_FOUND;
} }
static void wined3d_do_nothing(void) static inline DWORD get_config_key_dword(HKEY defkey, HKEY appkey, const char* name, DWORD *data)
{
DWORD type;
DWORD size = sizeof(DWORD);
if (0 != appkey && !RegQueryValueExA( appkey, name, 0, &type, (LPBYTE) data, &size ) && (type == REG_DWORD)) return 0;
if (0 != defkey && !RegQueryValueExA( defkey, name, 0, &type, (LPBYTE) data, &size ) && (type == REG_DWORD)) return 0;
return ERROR_FILE_NOT_FOUND;
}
static void CDECL wined3d_do_nothing(void)
{ {
} }
@@ -92,7 +103,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
DWORD size = sizeof(buffer); DWORD size = sizeof(buffer);
HKEY hkey = 0; HKEY hkey = 0;
HKEY appkey = 0; HKEY appkey = 0;
DWORD len; DWORD len, tmpvalue;
WNDCLASSA wc; WNDCLASSA wc;
/* We need our own window class for a fake window which we use to retrieve GL capabilities */ /* We need our own window class for a fake window which we use to retrieve GL capabilities */
@@ -238,6 +249,36 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
wined3d_settings.rendertargetlock_mode = RTL_TEXTEX; wined3d_settings.rendertargetlock_mode = RTL_TEXTEX;
} }
} }
if ( !get_config_key_dword( hkey, appkey, "VideoPciDeviceID", &tmpvalue) )
{
int pci_device_id = tmpvalue;
/* A pci device id is 16-bit */
if(pci_device_id > 0xffff)
{
ERR("Invalid value for VideoPciDeviceID. The value should be smaller or equal to 65535 or 0xffff\n");
}
else
{
TRACE("Using PCI Device ID %04x\n", pci_device_id);
wined3d_settings.pci_device_id = pci_device_id;
}
}
if ( !get_config_key_dword( hkey, appkey, "VideoPciVendorID", &tmpvalue) )
{
int pci_vendor_id = tmpvalue;
/* A pci device id is 16-bit */
if(pci_vendor_id > 0xffff)
{
ERR("Invalid value for VideoPciVendorID. The value should be smaller or equal to 65535 or 0xffff\n");
}
else
{
TRACE("Using PCI Vendor ID %04x\n", pci_vendor_id);
wined3d_settings.pci_vendor_id = pci_vendor_id;
}
}
if ( !get_config_key( hkey, appkey, "VideoMemorySize", buffer, size) ) if ( !get_config_key( hkey, appkey, "VideoMemorySize", buffer, size) )
{ {
int TmpVideoMemorySize = atoi(buffer); int TmpVideoMemorySize = atoi(buffer);

File diff suppressed because it is too large Load Diff

View File

@@ -6,9 +6,12 @@
<include base="dciman32">.</include> <include base="dciman32">.</include>
<include base="ReactOS">include/reactos/wine</include> <include base="ReactOS">include/reactos/wine</include>
<define name="__WINESRC__" /> <define name="__WINESRC__" />
<file>dciman_main.c</file>
<library>wine</library> <library>wine</library>
<library>kernel32</library> <library>kernel32</library>
<library>ntdll</library> <library>ntdll</library>
<library>gdi32</library>
<library>user32</library>
<file>dciman_main.c</file>
</module> </module>
</group> </group>

View File

@@ -1,21 +1,21 @@
@ stub DCIBeginAccess @ stdcall DCIBeginAccess(ptr long long long long)
@ stdcall DCICloseProvider(long) @ stdcall DCICloseProvider(ptr)
@ stub DCICreateOffscreen @ stdcall DCICreateOffscreen(ptr long long long long long long long long ptr)
@ stub DCICreateOverlay @ stdcall DCICreateOverlay(ptr ptr ptr)
@ stdcall DCICreatePrimary(long ptr) @ stdcall DCICreatePrimary(ptr ptr)
@ stub DCIDestroy @ stdcall DCIDestroy(ptr)
@ stub DCIDraw @ stdcall DCIDraw(ptr)
@ stub DCIEndAccess @ stdcall DCIEndAccess(ptr)
@ stub DCIEnum @ stdcall DCIEnum(ptr ptr ptr ptr ptr)
@ stdcall DCIOpenProvider() @ stdcall DCIOpenProvider()
@ stub DCISetClipList @ stdcall DCISetClipList(ptr ptr)
@ stub DCISetDestination @ stdcall DCISetDestination(ptr ptr ptr)
@ stub DCISetSrcDestClip @ stdcall DCISetSrcDestClip(ptr ptr ptr ptr)
@ stdcall -private DllEntryPoint(long long ptr) DllMain @ stdcall -private DllEntryPoint(ptr long ptr) DllMain
@ stub GetDCRegionData @ stdcall GetDCRegionData(ptr long ptr)
@ stub GetWindowRegionData @ stdcall GetWindowRegionData(ptr long ptr)
@ stub WinWatchClose @ stdcall WinWatchClose(ptr)
@ stub WinWatchDidStatusChange @ stdcall WinWatchDidStatusChange(ptr)
@ stub WinWatchGetClipList @ stdcall WinWatchGetClipList(ptr ptr long ptr)
@ stub WinWatchNotify @ stdcall WinWatchNotify(ptr ptr long)
@ stub WinWatchOpen @ stdcall WinWatchOpen(ptr)

File diff suppressed because it is too large Load Diff

View File

@@ -622,4 +622,4 @@ bInitSystemAndFontsDirectoriesW@8
bMakePathNameW@16 bMakePathNameW@16
cGetTTFFromFOT@28 cGetTTFFromFOT@28
gdiPlaySpoolStream@24 gdiPlaySpoolStream@24
GdiGetBitmapBitsSize@4 GdiGetBitmapBitsSize@4

View File

@@ -1,8 +1,11 @@
<module name="gdi32" type="win32dll" baseaddress="${BASEADDRESS_GDI32}" installbase="system32" installname="gdi32.dll" unicode="yes"> <module name="gdi32" type="win32dll" baseaddress="${BASEADDRESS_GDI32}" installbase="system32" installname="gdi32.dll" unicode="yes" crt="dll">
<importlibrary definition="gdi32.def" /> <importlibrary definition="gdi32.def" />
<include base="gdi32">include</include> <include base="gdi32">include</include>
<define name="_DISABLE_TIDENTS" /> <define name="_DISABLE_TIDENTS" />
<define name="LANGPACK" /> <define name="LANGPACK" />
<library>user32</library> <library>user32</library>
<library>kernel32</library> <library>kernel32</library>
<library>advapi32</library> <library>advapi32</library>
@@ -11,6 +14,12 @@
<library>dxguid</library> <library>dxguid</library>
<library>ntdll</library> <library>ntdll</library>
<if property="REACTX_EMU" value="1">
<library>uuid</library>
<library>wine</library>
<library>opengl32</library>
</if>
<!-- See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38269 <!-- See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38269
<directory name="include"> <directory name="include">
<pch>precomp.h</pch> <pch>precomp.h</pch>
@@ -21,7 +30,12 @@
</directory> </directory>
<directory name="misc"> <directory name="misc">
<file>heap.c</file> <file>heap.c</file>
<if property="REACTX_EMU" value="1">
<file>gdientryhelgl.c</file>
</if>
<if property="REACTX_EMU" value="0">
<file>gdientry.c</file> <file>gdientry.c</file>
</if>
<file>hacks.c</file> <file>hacks.c</file>
<file>historic.c</file> <file>historic.c</file>
<file>misc.c</file> <file>misc.c</file>

File diff suppressed because it is too large Load Diff

View File

@@ -21,6 +21,8 @@
#define UNIMPLEMENTED DbgPrint("GDI32: %s is unimplemented, please try again later.\n", __FUNCTION__); #define UNIMPLEMENTED DbgPrint("GDI32: %s is unimplemented, please try again later.\n", __FUNCTION__);
/* /*
* @unimplemented * @unimplemented
*/ */
@@ -1335,7 +1337,7 @@ int
WINAPI WINAPI
Escape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpvInData, LPVOID lpvOutData) Escape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpvInData, LPVOID lpvOutData)
{ {
int retValue = SP_ERROR; int retValue = SP_ERROR;
HGDIOBJ hObject = hdc; HGDIOBJ hObject = hdc;
UINT Type = 0; UINT Type = 0;
LPVOID pUserData = NULL; LPVOID pUserData = NULL;
@@ -1352,12 +1354,12 @@ Escape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpvInData, LPVOID lpvOutData)
{ {
switch (nEscape) switch (nEscape)
{ {
case ABORTDOC: case ABORTDOC:
/* Note Winodws check see if the handle have any user data for ABORTDOC command /* Note Winodws check see if the handle have any user data for ABORTDOC command
* ReactOS copy this behavior to be compatible with windows 2003 * ReactOS copy this behavior to be compatible with windows 2003
*/ */
if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) || if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) ||
(pUserData == NULL) ) (pUserData == NULL) )
{ {
GdiSetLastError(ERROR_INVALID_HANDLE); GdiSetLastError(ERROR_INVALID_HANDLE);
retValue = FALSE; retValue = FALSE;
@@ -1372,11 +1374,11 @@ Escape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpvInData, LPVOID lpvOutData)
case FLUSHOUTPUT: case FLUSHOUTPUT:
case SETCOLORTABLE: case SETCOLORTABLE:
/* Note 1: DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE is outdated and been replace with other api */ /* Note 1: DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE is outdated and been replace with other api */
/* Note 2: Winodws check see if the handle have any user data for DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE command /* Note 2: Winodws check see if the handle have any user data for DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE command
* ReactOS copy this behavior to be compatible with windows 2003 * ReactOS copy this behavior to be compatible with windows 2003
*/ */
if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) || if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) ||
(pUserData == NULL) ) (pUserData == NULL) )
{ {
GdiSetLastError(ERROR_INVALID_HANDLE); GdiSetLastError(ERROR_INVALID_HANDLE);
} }
@@ -1384,11 +1386,11 @@ Escape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpvInData, LPVOID lpvOutData)
break; break;
case SETABORTPROC: case SETABORTPROC:
/* Note : Winodws check see if the handle have any user data for DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE command /* Note : Winodws check see if the handle have any user data for DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE command
* ReactOS copy this behavior to be compatible with windows 2003 * ReactOS copy this behavior to be compatible with windows 2003
*/ */
if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) || if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) ||
(pUserData == NULL) ) (pUserData == NULL) )
{ {
GdiSetLastError(ERROR_INVALID_HANDLE); GdiSetLastError(ERROR_INVALID_HANDLE);
retValue = FALSE; retValue = FALSE;
@@ -1400,16 +1402,16 @@ Escape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpvInData, LPVOID lpvOutData)
retValue = GetSystemPaletteEntries(hdc, (UINT)*lpvInData, 1, (LPPALETTEENTRY)lpvOutData); retValue = GetSystemPaletteEntries(hdc, (UINT)*lpvInData, 1, (LPPALETTEENTRY)lpvOutData);
if ( !retValue ) if ( !retValue )
{ {
retValue = SP_ERROR; retValue = SP_ERROR;
} }
break; break;
case ENDDOC: case ENDDOC:
/* Note : Winodws check see if the handle have any user data for DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE command /* Note : Winodws check see if the handle have any user data for DRAFTMODE, FLUSHOUTPUT, SETCOLORTABLE command
* ReactOS copy this behavior to be compatible with windows 2003 * ReactOS copy this behavior to be compatible with windows 2003
*/ */
if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) || if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserData)) ||
(pUserData == NULL) ) (pUserData == NULL) )
{ {
GdiSetLastError(ERROR_INVALID_HANDLE); GdiSetLastError(ERROR_INVALID_HANDLE);
retValue = FALSE; retValue = FALSE;
@@ -1421,14 +1423,14 @@ Escape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpvInData, LPVOID lpvOutData)
case GETSCALINGFACTOR: case GETSCALINGFACTOR:
/* Note GETSCALINGFACTOR is outdated have been replace by GetDeviceCaps */ /* Note GETSCALINGFACTOR is outdated have been replace by GetDeviceCaps */
if ( Type == GDI_OBJECT_TYPE_DC ) if ( Type == GDI_OBJECT_TYPE_DC )
{ {
if ( lpvOutData ) if ( lpvOutData )
{ {
PPOINT ptr = (PPOINT) lpvOutData; PPOINT ptr = (PPOINT) lpvOutData;
ptr->x = 0; ptr->x = 0;
ptr->y = 0; ptr->y = 0;
} }
} }
retValue = FALSE; retValue = FALSE;
break; break;
@@ -1441,11 +1443,11 @@ Escape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpvInData, LPVOID lpvOutData)
DOCINFOA *pUserDatalpdi; DOCINFOA *pUserDatalpdi;
DOCINFOA lpdi; DOCINFOA lpdi;
/* Note : Winodws check see if the handle have any user data for STARTDOC command /* Note : Winodws check see if the handle have any user data for STARTDOC command
* ReactOS copy this behavior to be compatible with windows 2003 * ReactOS copy this behavior to be compatible with windows 2003
*/ */
if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserDatalpdi)) || if ( (!GdiGetHandleUserData(hObject, (DWORD)Type, (PVOID) &pUserDatalpdi)) ||
(pUserData == NULL) ) (pUserData == NULL) )
{ {
GdiSetLastError(ERROR_INVALID_HANDLE); GdiSetLastError(ERROR_INVALID_HANDLE);
retValue = FALSE; retValue = FALSE;
@@ -1461,13 +1463,13 @@ Escape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpvInData, LPVOID lpvOutData)
lpdi.lpszDocName = lpvInData; lpdi.lpszDocName = lpvInData;
/* NOTE : doc for StartDocA/W at msdn http://msdn2.microsoft.com/en-us/library/ms535793(VS.85).aspx */ /* NOTE : doc for StartDocA/W at msdn http://msdn2.microsoft.com/en-us/library/ms535793(VS.85).aspx */
retValue = StartDocA(hdc, &lpdi); retValue = StartDocA(hdc, &lpdi);
/* StartDocA fail */ /* StartDocA fail */
if (retValue < 0) if (retValue < 0)
{ {
/* check see if outbuffer contain any data, if it does abort */ /* check see if outbuffer contain any data, if it does abort */
if ( (pUserDatalpdi->lpszOutput != 0) && if ( (pUserDatalpdi->lpszOutput != 0) &&
( (*(WCHAR *)pUserDatalpdi->lpszOutput) != UNICODE_NULL) ) ( (*(WCHAR *)pUserDatalpdi->lpszOutput) != UNICODE_NULL) )
{ {
retValue = SP_APPABORT; retValue = SP_APPABORT;
@@ -1475,9 +1477,9 @@ Escape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpvInData, LPVOID lpvOutData)
else else
{ {
retValue = GetLastError(); retValue = GetLastError();
/* Translate StartDocA error code to STARTDOC error code /* Translate StartDocA error code to STARTDOC error code
* see msdn http://msdn2.microsoft.com/en-us/library/ms535472.aspx * see msdn http://msdn2.microsoft.com/en-us/library/ms535472.aspx
*/ */
switch(retValue) switch(retValue)
{ {
@@ -1496,21 +1498,21 @@ Escape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpvInData, LPVOID lpvOutData)
default: default:
retValue = SP_ERROR; retValue = SP_ERROR;
break; break;
} }
} }
} }
} }
break; break;
default: default:
UNIMPLEMENTED; UNIMPLEMENTED;
SetLastError(ERROR_CALL_NOT_IMPLEMENTED); SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
} }
} }
return retValue; return retValue;
} }

View File

@@ -34,6 +34,9 @@
WINE_DEFAULT_DEBUG_CHANNEL(gdiplus); WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
/******************************************************************************
* GdipCloneBrush [GDIPLUS.@]
*/
GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone) GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
{ {
TRACE("(%p, %p)\n", brush, clone); TRACE("(%p, %p)\n", brush, clone);
@@ -121,6 +124,9 @@ GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
return Ok; return Ok;
} }
/******************************************************************************
* GdipCreateLineBrush [GDIPLUS.@]
*/
GpStatus WINGDIPAPI GdipCreateLineBrush(GDIPCONST GpPointF* startpoint, GpStatus WINGDIPAPI GdipCreateLineBrush(GDIPCONST GpPointF* startpoint,
GDIPCONST GpPointF* endpoint, ARGB startcolor, ARGB endcolor, GDIPCONST GpPointF* endpoint, ARGB startcolor, ARGB endcolor,
GpWrapMode wrap, GpLineGradient **line) GpWrapMode wrap, GpLineGradient **line)
@@ -212,9 +218,13 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectI(GDIPCONST GpRect* rect,
return GdipCreateLineBrushFromRect(&rectF, startcolor, endcolor, mode, wrap, line); return GdipCreateLineBrushFromRect(&rectF, startcolor, endcolor, mode, wrap, line);
} }
/* FIXME: angle value completely ignored. Don't know how to use it since native /******************************************************************************
always set Brush rectangle to rect (independetly of this angle). * GdipCreateLineBrushFromRectWithAngle [GDIPLUS.@]
Maybe it's used only on drawing. */ *
* FIXME: angle value completely ignored. Don't know how to use it since native
* always set Brush rectangle to rect (independetly of this angle).
* Maybe it's used only on drawing.
*/
GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect, GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect,
ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap, ARGB startcolor, ARGB endcolor, REAL angle, BOOL isAngleScalable, GpWrapMode wrap,
GpLineGradient **line) GpLineGradient **line)
@@ -323,7 +333,11 @@ GpStatus WINGDIPAPI GdipCreatePathGradientI(GDIPCONST GpPoint* points,
return ret; return ret;
} }
/* FIXME: path gradient brushes not truly supported (drawn as solid brushes) */ /******************************************************************************
* GdipCreatePathGradientFromPath [GDIPLUS.@]
*
* FIXME: path gradient brushes not truly supported (drawn as solid brushes)
*/
GpStatus WINGDIPAPI GdipCreatePathGradientFromPath(GDIPCONST GpPath* path, GpStatus WINGDIPAPI GdipCreatePathGradientFromPath(GDIPCONST GpPath* path,
GpPathGradient **grad) GpPathGradient **grad)
{ {
@@ -379,6 +393,9 @@ GpStatus WINGDIPAPI GdipCreatePathGradientFromPath(GDIPCONST GpPath* path,
return Ok; return Ok;
} }
/******************************************************************************
* GdipCreateSolidFill [GDIPLUS.@]
*/
GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf) GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
{ {
COLORREF col = ARGB2COLORREF(color); COLORREF col = ARGB2COLORREF(color);
@@ -401,7 +418,7 @@ GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
return Ok; return Ok;
} }
/******************************************************************************* /******************************************************************************
* GdipCreateTexture [GDIPLUS.@] * GdipCreateTexture [GDIPLUS.@]
* *
* PARAMS * PARAMS
@@ -435,6 +452,9 @@ GpStatus WINGDIPAPI GdipCreateTexture(GpImage *image, GpWrapMode wrapmode,
texture); texture);
} }
/******************************************************************************
* GdipCreateTexture2 [GDIPLUS.@]
*/
GpStatus WINGDIPAPI GdipCreateTexture2(GpImage *image, GpWrapMode wrapmode, GpStatus WINGDIPAPI GdipCreateTexture2(GpImage *image, GpWrapMode wrapmode,
REAL x, REAL y, REAL width, REAL height, GpTexture **texture) REAL x, REAL y, REAL width, REAL height, GpTexture **texture)
{ {
@@ -448,19 +468,23 @@ GpStatus WINGDIPAPI GdipCreateTexture2(GpImage *image, GpWrapMode wrapmode,
texture); texture);
} }
/* FIXME: imageattr ignored */ /******************************************************************************
* GdipCreateTextureIA [GDIPLUS.@]
*
* FIXME: imageattr ignored
*/
GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image, GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
GDIPCONST GpImageAttributes *imageattr, REAL x, REAL y, REAL width, GDIPCONST GpImageAttributes *imageattr, REAL x, REAL y, REAL width,
REAL height, GpTexture **texture) REAL height, GpTexture **texture)
{ {
HDC hdc; HDC hdc;
OLE_HANDLE hbm; HBITMAP hbm, old = NULL;
HBITMAP old = NULL; BITMAPINFO *pbmi;
BITMAPINFO bmi;
BITMAPINFOHEADER *bmih; BITMAPINFOHEADER *bmih;
INT n_x, n_y, n_width, n_height, abs_height, stride, image_stride, i, bytespp; INT n_x, n_y, n_width, n_height, abs_height, stride, image_stride, i, bytespp;
BOOL bm_is_selected; BOOL bm_is_selected;
BYTE *dibits, *buff, *textbits; BYTE *dibits, *buff, *textbits;
GpStatus status;
TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %p)\n", image, imageattr, x, y, width, height, TRACE("(%p, %p, %.2f, %.2f, %.2f, %.2f, %p)\n", image, imageattr, x, y, width, height,
texture); texture);
@@ -482,46 +506,54 @@ GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
n_y + n_height > ((GpBitmap*)image)->height) n_y + n_height > ((GpBitmap*)image)->height)
return InvalidParameter; return InvalidParameter;
IPicture_get_Handle(image->picture, &hbm); IPicture_get_Handle(image->picture, (OLE_HANDLE*)&hbm);
if(!hbm) return GenericError; if(!hbm) return GenericError;
IPicture_get_CurDC(image->picture, &hdc); IPicture_get_CurDC(image->picture, &hdc);
bm_is_selected = (hdc != 0); bm_is_selected = (hdc != 0);
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
bmi.bmiHeader.biBitCount = 0; if (!pbmi)
return OutOfMemory;
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pbmi->bmiHeader.biBitCount = 0;
if(!bm_is_selected){ if(!bm_is_selected){
hdc = CreateCompatibleDC(0); hdc = CreateCompatibleDC(0);
old = SelectObject(hdc, (HBITMAP)hbm); old = SelectObject(hdc, hbm);
} }
/* fill out bmi */ /* fill out bmi */
GetDIBits(hdc, (HBITMAP)hbm, 0, 0, NULL, &bmi, DIB_RGB_COLORS); GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS);
bytespp = bmi.bmiHeader.biBitCount / 8; bytespp = pbmi->bmiHeader.biBitCount / 8;
abs_height = abs(bmi.bmiHeader.biHeight); abs_height = abs(pbmi->bmiHeader.biHeight);
if(n_x > bmi.bmiHeader.biWidth || n_x + n_width > bmi.bmiHeader.biWidth || if(n_x > pbmi->bmiHeader.biWidth || n_x + n_width > pbmi->bmiHeader.biWidth ||
n_y > abs_height || n_y + n_height > abs_height) n_y > abs_height || n_y + n_height > abs_height){
GdipFree(pbmi);
return InvalidParameter; return InvalidParameter;
}
dibits = GdipAlloc(bmi.bmiHeader.biSizeImage); dibits = GdipAlloc(pbmi->bmiHeader.biSizeImage);
if(dibits) /* this is not a good place to error out */ if(dibits) /* this is not a good place to error out */
GetDIBits(hdc, (HBITMAP)hbm, 0, abs_height, dibits, &bmi, DIB_RGB_COLORS); GetDIBits(hdc, hbm, 0, abs_height, dibits, pbmi, DIB_RGB_COLORS);
if(!bm_is_selected){ if(!bm_is_selected){
SelectObject(hdc, old); SelectObject(hdc, old);
DeleteDC(hdc); DeleteDC(hdc);
} }
if(!dibits) if(!dibits){
GdipFree(pbmi);
return OutOfMemory; return OutOfMemory;
}
image_stride = (bmi.bmiHeader.biWidth * bytespp + 3) & ~3; image_stride = (pbmi->bmiHeader.biWidth * bytespp + 3) & ~3;
stride = (n_width * bytespp + 3) & ~3; stride = (n_width * bytespp + 3) & ~3;
buff = GdipAlloc(sizeof(BITMAPINFOHEADER) + stride * n_height); buff = GdipAlloc(sizeof(BITMAPINFOHEADER) + stride * n_height);
if(!buff){ if(!buff){
GdipFree(pbmi);
GdipFree(dibits); GdipFree(dibits);
return OutOfMemory; return OutOfMemory;
} }
@@ -533,25 +565,38 @@ GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
bmih->biHeight = n_height; bmih->biHeight = n_height;
bmih->biCompression = BI_RGB; bmih->biCompression = BI_RGB;
bmih->biSizeImage = stride * n_height; bmih->biSizeImage = stride * n_height;
bmih->biBitCount = bmi.bmiHeader.biBitCount; bmih->biBitCount = pbmi->bmiHeader.biBitCount;
bmih->biClrUsed = 0; bmih->biClrUsed = 0;
bmih->biPlanes = 1; bmih->biPlanes = 1;
/* image is flipped */ /* image is flipped */
if(bmi.bmiHeader.biHeight > 0){ if(pbmi->bmiHeader.biHeight > 0){
dibits += bmi.bmiHeader.biSizeImage; dibits += pbmi->bmiHeader.biSizeImage;
image_stride *= -1; image_stride *= -1;
textbits += stride * (n_height - 1); textbits += stride * (n_height - 1);
stride *= -1; stride *= -1;
} }
GdipFree(pbmi);
for(i = 0; i < n_height; i++) for(i = 0; i < n_height; i++)
memcpy(&textbits[i * stride], memcpy(&textbits[i * stride],
&dibits[n_x * bytespp + (n_y + i) * image_stride], &dibits[n_x * bytespp + (n_y + i) * image_stride],
abs(stride)); abs(stride));
*texture = GdipAlloc(sizeof(GpTexture)); *texture = GdipAlloc(sizeof(GpTexture));
if (!*texture) return OutOfMemory; if (!*texture){
GdipFree(dibits);
GdipFree(buff);
return OutOfMemory;
}
if((status = GdipCreateMatrix(&(*texture)->transform)) != Ok){
GdipFree(*texture);
GdipFree(dibits);
GdipFree(buff);
return status;
}
(*texture)->brush.lb.lbStyle = BS_DIBPATTERNPT; (*texture)->brush.lb.lbStyle = BS_DIBPATTERNPT;
(*texture)->brush.lb.lbColor = DIB_RGB_COLORS; (*texture)->brush.lb.lbColor = DIB_RGB_COLORS;
@@ -559,6 +604,7 @@ GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
(*texture)->brush.gdibrush = CreateBrushIndirect(&(*texture)->brush.lb); (*texture)->brush.gdibrush = CreateBrushIndirect(&(*texture)->brush.lb);
(*texture)->brush.bt = BrushTypeTextureFill; (*texture)->brush.bt = BrushTypeTextureFill;
(*texture)->wrap = imageattr->wrap;
GdipFree(dibits); GdipFree(dibits);
GdipFree(buff); GdipFree(buff);
@@ -566,6 +612,9 @@ GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
return Ok; return Ok;
} }
/******************************************************************************
* GdipCreateTextureIAI [GDIPLUS.@]
*/
GpStatus WINGDIPAPI GdipCreateTextureIAI(GpImage *image, GDIPCONST GpImageAttributes *imageattr, GpStatus WINGDIPAPI GdipCreateTextureIAI(GpImage *image, GDIPCONST GpImageAttributes *imageattr,
INT x, INT y, INT width, INT height, GpTexture **texture) INT x, INT y, INT width, INT height, GpTexture **texture)
{ {
@@ -615,7 +664,10 @@ GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
break; break;
case BrushTypeSolidColor: case BrushTypeSolidColor:
case BrushTypeLinearGradient: case BrushTypeLinearGradient:
break;
case BrushTypeTextureFill: case BrushTypeTextureFill:
GdipDeleteMatrix(((GpTexture*)brush)->transform);
break;
default: default:
break; break;
} }
@@ -845,6 +897,77 @@ GpStatus WINGDIPAPI GdipGetSolidFillColor(GpSolidFill *sf, ARGB *argb)
return Ok; return Ok;
} }
/******************************************************************************
* GdipGetTextureTransform [GDIPLUS.@]
*/
GpStatus WINGDIPAPI GdipGetTextureTransform(GpTexture *brush, GpMatrix *matrix)
{
TRACE("(%p, %p)\n", brush, matrix);
if(!brush || !matrix)
return InvalidParameter;
memcpy(matrix, brush->transform, sizeof(GpMatrix));
return Ok;
}
/******************************************************************************
* GdipGetTextureWrapMode [GDIPLUS.@]
*/
GpStatus WINGDIPAPI GdipGetTextureWrapMode(GpTexture *brush, GpWrapMode *wrapmode)
{
TRACE("(%p, %p)\n", brush, wrapmode);
if(!brush || !wrapmode)
return InvalidParameter;
*wrapmode = brush->wrap;
return Ok;
}
/******************************************************************************
* GdipMultiplyTextureTransform [GDIPLUS.@]
*/
GpStatus WINGDIPAPI GdipMultiplyTextureTransform(GpTexture* brush,
GDIPCONST GpMatrix *matrix, GpMatrixOrder order)
{
TRACE("(%p, %p, %d)\n", brush, matrix, order);
if(!brush || !matrix)
return InvalidParameter;
return GdipMultiplyMatrix(brush->transform, matrix, order);
}
/******************************************************************************
* GdipResetTextureTransform [GDIPLUS.@]
*/
GpStatus WINGDIPAPI GdipResetTextureTransform(GpTexture* brush)
{
TRACE("(%p)\n", brush);
if(!brush)
return InvalidParameter;
return GdipSetMatrixElements(brush->transform, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
}
/******************************************************************************
* GdipScaleTextureTransform [GDIPLUS.@]
*/
GpStatus WINGDIPAPI GdipScaleTextureTransform(GpTexture* brush,
REAL sx, REAL sy, GpMatrixOrder order)
{
TRACE("(%p, %.2f, %.2f, %d)\n", brush, sx, sy, order);
if(!brush)
return InvalidParameter;
return GdipScaleMatrix(brush->transform, sx, sy, order);
}
GpStatus WINGDIPAPI GdipSetLineBlend(GpLineGradient *brush, GpStatus WINGDIPAPI GdipSetLineBlend(GpLineGradient *brush,
GDIPCONST REAL *blend, GDIPCONST REAL* positions, INT count) GDIPCONST REAL *blend, GDIPCONST REAL* positions, INT count)
{ {
@@ -899,6 +1022,17 @@ GpStatus WINGDIPAPI GdipSetLineWrapMode(GpLineGradient *line,
return Ok; return Ok;
} }
GpStatus WINGDIPAPI GdipSetPathGradientBlend(GpPathGradient *brush, GDIPCONST REAL *blend,
GDIPCONST REAL *pos, INT count)
{
static int calls;
if(!(calls++))
FIXME("not implemented\n");
return NotImplemented;
}
GpStatus WINGDIPAPI GdipSetPathGradientCenterColor(GpPathGradient *grad, GpStatus WINGDIPAPI GdipSetPathGradientCenterColor(GpPathGradient *grad,
ARGB argb) ARGB argb)
{ {
@@ -1031,16 +1165,35 @@ GpStatus WINGDIPAPI GdipSetSolidFillColor(GpSolidFill *sf, ARGB argb)
return Ok; return Ok;
} }
/******************************************************************************
* GdipSetTextureTransform [GDIPLUS.@]
*/
GpStatus WINGDIPAPI GdipSetTextureTransform(GpTexture *texture, GpStatus WINGDIPAPI GdipSetTextureTransform(GpTexture *texture,
GDIPCONST GpMatrix *matrix) GDIPCONST GpMatrix *matrix)
{ {
static int calls; TRACE("(%p, %p)\n", texture, matrix);
if(!texture || !matrix) if(!texture || !matrix)
return InvalidParameter; return InvalidParameter;
if(!(calls++)) memcpy(texture->transform, matrix, sizeof(GpMatrix));
FIXME("not implemented\n");
return Ok;
}
/******************************************************************************
* GdipSetTextureWrapMode [GDIPLUS.@]
*
* WrapMode not used, only stored
*/
GpStatus WINGDIPAPI GdipSetTextureWrapMode(GpTexture *brush, GpWrapMode wrapmode)
{
TRACE("(%p, %d)\n", brush, wrapmode);
if(!brush)
return InvalidParameter;
brush->wrap = wrapmode;
return Ok; return Ok;
} }
@@ -1072,6 +1225,20 @@ GpStatus WINGDIPAPI GdipGetLineColors(GpLineGradient *brush, ARGB *colors)
return Ok; return Ok;
} }
/******************************************************************************
* GdipRotateTextureTransform [GDIPLUS.@]
*/
GpStatus WINGDIPAPI GdipRotateTextureTransform(GpTexture* brush, REAL angle,
GpMatrixOrder order)
{
TRACE("(%p, %.2f, %d)\n", brush, angle, order);
if(!brush)
return InvalidParameter;
return GdipRotateMatrix(brush->transform, angle, order);
}
GpStatus WINGDIPAPI GdipSetLineLinearBlend(GpLineGradient *brush, REAL focus, GpStatus WINGDIPAPI GdipSetLineLinearBlend(GpLineGradient *brush, REAL focus,
REAL scale) REAL scale)
{ {
@@ -1113,6 +1280,20 @@ GpStatus WINGDIPAPI GdipTranslateLineTransform(GpLineGradient* brush,
return NotImplemented; return NotImplemented;
} }
/******************************************************************************
* GdipTranslateTextureTransform [GDIPLUS.@]
*/
GpStatus WINGDIPAPI GdipTranslateTextureTransform(GpTexture* brush, REAL dx, REAL dy,
GpMatrixOrder order)
{
TRACE("(%p, %.2f, %.2f, %d)\n", brush, dx, dy, order);
if(!brush)
return InvalidParameter;
return GdipTranslateMatrix(brush->transform, dx, dy, order);
}
GpStatus WINGDIPAPI GdipGetLineRect(GpLineGradient *brush, GpRectF *rect) GpStatus WINGDIPAPI GdipGetLineRect(GpLineGradient *brush, GpRectF *rect)
{ {
TRACE("(%p, %p)\n", brush, rect); TRACE("(%p, %p)\n", brush, rect);

View File

@@ -153,6 +153,8 @@ GpStatus WINGDIPAPI GdipCreateFont(GDIPCONST GpFontFamily *fontFamily,
(*font)->unit = unit; (*font)->unit = unit;
(*font)->emSize = emSize; (*font)->emSize = emSize;
(*font)->height = tmw->ntmSizeEM;
(*font)->line_spacing = tmw->tmAscent + tmw->tmDescent + tmw->tmExternalLeading;
return Ok; return Ok;
} }
@@ -194,6 +196,9 @@ GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc,
(*font)->lfw.lfHeight = -textmet.tmHeight; (*font)->lfw.lfHeight = -textmet.tmHeight;
(*font)->lfw.lfWeight = textmet.tmWeight; (*font)->lfw.lfWeight = textmet.tmWeight;
(*font)->height = 1; /* FIXME: need NEWTEXTMETRIC.ntmSizeEM here */
(*font)->line_spacing = textmet.tmAscent + textmet.tmDescent + textmet.tmExternalLeading;
SelectObject(hdc, oldfont); SelectObject(hdc, oldfont);
DeleteObject(hfont); DeleteObject(hfont);
@@ -251,7 +256,7 @@ GpStatus WINGDIPAPI GdipCreateFontFromDC(HDC hdc, GpFont **font)
if(!font) if(!font)
return InvalidParameter; return InvalidParameter;
hfont = (HFONT)GetCurrentObject(hdc, OBJ_FONT); hfont = GetCurrentObject(hdc, OBJ_FONT);
if(!hfont) if(!hfont)
return GenericError; return GenericError;
@@ -444,15 +449,31 @@ GpStatus WINGDIPAPI GdipGetFontHeight(GDIPCONST GpFont *font,
*/ */
GpStatus WINGDIPAPI GdipGetFontHeightGivenDPI(GDIPCONST GpFont *font, REAL dpi, REAL *height) GpStatus WINGDIPAPI GdipGetFontHeightGivenDPI(GDIPCONST GpFont *font, REAL dpi, REAL *height)
{ {
REAL font_height;
TRACE("%p (%s), %f, %p\n", font, TRACE("%p (%s), %f, %p\n", font,
debugstr_w(font->lfw.lfFaceName), dpi, height); debugstr_w(font->lfw.lfFaceName), dpi, height);
if (!(font && height)) return InvalidParameter; if (!(font && height)) return InvalidParameter;
font_height = font->line_spacing * (font->emSize / font->height);
switch (font->unit) switch (font->unit)
{ {
case UnitPixel: case UnitPixel:
*height = font->emSize; *height = font_height;
break;
case UnitPoint:
*height = font_height * dpi * inch_per_point;
break;
case UnitInch:
*height = font_height * dpi;
break;
case UnitDocument:
*height = font_height * (dpi / 300.0);
break;
case UnitMillimeter:
*height = font_height * (dpi / mm_per_inch);
break; break;
default: default:
FIXME("Unhandled unit type: %d\n", font->unit); FIXME("Unhandled unit type: %d\n", font->unit);
@@ -667,8 +688,7 @@ GpStatus WINGDIPAPI GdipGetEmHeight(GDIPCONST GpFontFamily *family, INT style, U
{ {
if (!(family && EmHeight)) return InvalidParameter; if (!(family && EmHeight)) return InvalidParameter;
TRACE("%p (%s), %d, %p, stub!\n", family, TRACE("%p (%s), %d, %p\n", family, debugstr_w(family->FamilyName), style, EmHeight);
debugstr_w(family->FamilyName), style, EmHeight);
*EmHeight = family->tmw.ntmSizeEM; *EmHeight = family->tmw.ntmSizeEM;
@@ -693,11 +713,16 @@ GpStatus WINGDIPAPI GdipGetEmHeight(GDIPCONST GpFontFamily *family, INT style, U
GpStatus WINGDIPAPI GdipGetLineSpacing(GDIPCONST GpFontFamily *family, GpStatus WINGDIPAPI GdipGetLineSpacing(GDIPCONST GpFontFamily *family,
INT style, UINT16* LineSpacing) INT style, UINT16* LineSpacing)
{ {
if (!(family && LineSpacing)) return InvalidParameter; TRACE("%p, %d, %p\n", family, style, LineSpacing);
FIXME("stub!\n"); if (!(family && LineSpacing))
return InvalidParameter;
return NotImplemented; if (style) FIXME("ignoring style\n");
*LineSpacing = family->tmw.tmAscent + family->tmw.tmDescent + family->tmw.tmExternalLeading;
return Ok;
} }
GpStatus WINGDIPAPI GdipIsStyleAvailable(GDIPCONST GpFontFamily* family, GpStatus WINGDIPAPI GdipIsStyleAvailable(GDIPCONST GpFontFamily* family,
@@ -785,12 +810,17 @@ GpStatus WINGDIPAPI GdipGetGenericFontFamilySansSerif(GpFontFamily **nativeFamil
*/ */
GpStatus WINGDIPAPI GdipNewPrivateFontCollection(GpFontCollection** fontCollection) GpStatus WINGDIPAPI GdipNewPrivateFontCollection(GpFontCollection** fontCollection)
{ {
FIXME("stub %p\n", fontCollection); TRACE("%p\n", fontCollection);
if (!fontCollection) if (!fontCollection)
return InvalidParameter; return InvalidParameter;
return NotImplemented; *fontCollection = GdipAlloc(sizeof(GpFontCollection));
if (!*fontCollection) return OutOfMemory;
(*fontCollection)->FontFamilies = NULL;
(*fontCollection)->count = 0;
return Ok;
} }
/***************************************************************************** /*****************************************************************************
@@ -798,12 +828,17 @@ GpStatus WINGDIPAPI GdipNewPrivateFontCollection(GpFontCollection** fontCollecti
*/ */
GpStatus WINGDIPAPI GdipDeletePrivateFontCollection(GpFontCollection **fontCollection) GpStatus WINGDIPAPI GdipDeletePrivateFontCollection(GpFontCollection **fontCollection)
{ {
FIXME("stub %p\n", fontCollection); INT i;
TRACE("%p\n", fontCollection);
if (!fontCollection) if (!fontCollection)
return InvalidParameter; return InvalidParameter;
return NotImplemented; for (i = 0; i < (*fontCollection)->count; i++) GdipFree((*fontCollection)->FontFamilies[i]);
GdipFree(*fontCollection);
return Ok;
} }
/***************************************************************************** /*****************************************************************************
@@ -820,18 +855,33 @@ GpStatus WINGDIPAPI GdipPrivateAddFontFile(GpFontCollection* fontCollection,
return NotImplemented; return NotImplemented;
} }
/*****************************************************************************
* GdipPrivateAddMemoryFont [GDIPLUS.@]
*/
GpStatus WINGDIPAPI GdipPrivateAddMemoryFont(GpFontCollection* fontCollection,
GDIPCONST void* memory, INT length)
{
FIXME("%p, %p, %d\n", fontCollection, memory, length);
if (!(fontCollection && memory && length))
return InvalidParameter;
return Ok;
}
/***************************************************************************** /*****************************************************************************
* GdipGetFontCollectionFamilyCount [GDIPLUS.@] * GdipGetFontCollectionFamilyCount [GDIPLUS.@]
*/ */
GpStatus WINGDIPAPI GdipGetFontCollectionFamilyCount( GpStatus WINGDIPAPI GdipGetFontCollectionFamilyCount(
GpFontCollection* fontCollection, INT* numFound) GpFontCollection* fontCollection, INT* numFound)
{ {
FIXME("stub: %p, %p\n", fontCollection, numFound); TRACE("%p, %p\n", fontCollection, numFound);
if (!(fontCollection && numFound)) if (!(fontCollection && numFound))
return InvalidParameter; return InvalidParameter;
return NotImplemented; *numFound = fontCollection->count;
return Ok;
} }
/***************************************************************************** /*****************************************************************************
@@ -841,11 +891,28 @@ GpStatus WINGDIPAPI GdipGetFontCollectionFamilyList(
GpFontCollection* fontCollection, INT numSought, GpFontCollection* fontCollection, INT numSought,
GpFontFamily* gpfamilies[], INT* numFound) GpFontFamily* gpfamilies[], INT* numFound)
{ {
FIXME("stub: %p, %d, %p, %p\n", fontCollection, numSought, gpfamilies, INT i;
numFound);
TRACE("%p, %d, %p, %p\n", fontCollection, numSought, gpfamilies, numFound);
if (!(fontCollection && gpfamilies && numFound)) if (!(fontCollection && gpfamilies && numFound))
return InvalidParameter; return InvalidParameter;
for (i = 0; i < numSought && i < fontCollection->count; i++)
{
gpfamilies[i] = fontCollection->FontFamilies[i];
}
*numFound = i;
return Ok;
}
GpStatus WINGDIPAPI GdipNewInstalledFontCollection(
GpFontCollection** fontCollection)
{
FIXME("stub: %p\n",fontCollection);
if (!fontCollection)
return InvalidParameter;
return NotImplemented; return NotImplemented;
} }

View File

@@ -93,11 +93,25 @@ Status WINAPI GdiplusStartup(ULONG_PTR *token, const struct GdiplusStartupInput
output->NotificationUnhook = NotificationUnhook; output->NotificationUnhook = NotificationUnhook;
} }
*token = 0xdeadbeef;
/* FIXME: DebugEventCallback ignored */ /* FIXME: DebugEventCallback ignored */
return Ok; return Ok;
} }
GpStatus WINAPI GdiplusNotificationHook(ULONG_PTR *token)
{
FIXME("%p\n", token);
return NotificationHook(token);
}
void WINAPI GdiplusNotificationUnhook(ULONG_PTR token)
{
FIXME("%ld\n", token);
NotificationUnhook(token);
}
/***************************************************** /*****************************************************
* GdiplusShutdown [GDIPLUS.@] * GdiplusShutdown [GDIPLUS.@]
*/ */

View File

@@ -32,7 +32,7 @@
@ stub GdipAddPathString @ stub GdipAddPathString
@ stub GdipAddPathStringI @ stub GdipAddPathStringI
@ stdcall GdipAlloc(long) @ stdcall GdipAlloc(long)
@ stub GdipBeginContainer2 @ stdcall GdipBeginContainer2(ptr ptr)
@ stub GdipBeginContainer @ stub GdipBeginContainer
@ stub GdipBeginContainerI @ stub GdipBeginContainerI
@ stub GdipBitmapApplyEffect @ stub GdipBitmapApplyEffect
@@ -81,7 +81,7 @@
@ stdcall GdipCreateBitmapFromScan0(long long long long ptr ptr) @ stdcall GdipCreateBitmapFromScan0(long long long long ptr ptr)
@ stdcall GdipCreateBitmapFromStream(ptr ptr) @ stdcall GdipCreateBitmapFromStream(ptr ptr)
@ stdcall GdipCreateBitmapFromStreamICM(ptr ptr) @ stdcall GdipCreateBitmapFromStreamICM(ptr ptr)
@ stub GdipCreateCachedBitmap @ stdcall GdipCreateCachedBitmap(ptr ptr ptr)
@ stdcall GdipCreateCustomLineCap(ptr ptr long long ptr) @ stdcall GdipCreateCustomLineCap(ptr ptr long long ptr)
@ stub GdipCreateEffect @ stub GdipCreateEffect
@ stdcall GdipCreateFont(ptr long long long ptr) @ stdcall GdipCreateFont(ptr long long long ptr)
@@ -95,7 +95,7 @@
@ stdcall GdipCreateFromHWNDICM(long ptr) @ stdcall GdipCreateFromHWNDICM(long ptr)
@ stdcall GdipCreateHBITMAPFromBitmap(ptr ptr long) @ stdcall GdipCreateHBITMAPFromBitmap(ptr ptr long)
@ stub GdipCreateHICONFromBitmap @ stub GdipCreateHICONFromBitmap
@ stub GdipCreateHalftonePalette @ stdcall GdipCreateHalftonePalette()
@ stub GdipCreateHatchBrush @ stub GdipCreateHatchBrush
@ stdcall GdipCreateImageAttributes(ptr) @ stdcall GdipCreateImageAttributes(ptr)
@ stdcall GdipCreateLineBrush(ptr ptr long long long ptr) @ stdcall GdipCreateLineBrush(ptr ptr long long long ptr)
@@ -137,7 +137,7 @@
@ stdcall GdipCreateTextureIA(ptr ptr long long long long ptr) @ stdcall GdipCreateTextureIA(ptr ptr long long long long ptr)
@ stdcall GdipCreateTextureIAI(ptr ptr long long long long ptr) @ stdcall GdipCreateTextureIAI(ptr ptr long long long long ptr)
@ stdcall GdipDeleteBrush(ptr) @ stdcall GdipDeleteBrush(ptr)
@ stub GdipDeleteCachedBitmap @ stdcall GdipDeleteCachedBitmap(ptr)
@ stdcall GdipDeleteCustomLineCap(ptr) @ stdcall GdipDeleteCustomLineCap(ptr)
@ stub GdipDeleteEffect @ stub GdipDeleteEffect
@ stdcall GdipDeleteFont(ptr) @ stdcall GdipDeleteFont(ptr)
@@ -158,7 +158,7 @@
@ stdcall GdipDrawBezierI(ptr ptr long long long long long long long long) @ stdcall GdipDrawBezierI(ptr ptr long long long long long long long long)
@ stdcall GdipDrawBeziers(ptr ptr ptr long) @ stdcall GdipDrawBeziers(ptr ptr ptr long)
@ stdcall GdipDrawBeziersI(ptr ptr ptr long) @ stdcall GdipDrawBeziersI(ptr ptr ptr long)
@ stub GdipDrawCachedBitmap @ stdcall GdipDrawCachedBitmap(ptr ptr long long)
@ stdcall GdipDrawClosedCurve2(ptr ptr ptr long long) @ stdcall GdipDrawClosedCurve2(ptr ptr ptr long long)
@ stdcall GdipDrawClosedCurve2I(ptr ptr ptr long long) @ stdcall GdipDrawClosedCurve2I(ptr ptr ptr long long)
@ stdcall GdipDrawClosedCurve(ptr ptr ptr long) @ stdcall GdipDrawClosedCurve(ptr ptr ptr long)
@@ -200,7 +200,7 @@
@ stdcall GdipDrawRectanglesI(ptr ptr ptr long) @ stdcall GdipDrawRectanglesI(ptr ptr ptr long)
@ stdcall GdipDrawString(ptr ptr long ptr ptr ptr ptr) @ stdcall GdipDrawString(ptr ptr long ptr ptr ptr ptr)
@ stub GdipEmfToWmfBits @ stub GdipEmfToWmfBits
@ stub GdipEndContainer @ stdcall GdipEndContainer(ptr ptr)
@ stub GdipEnumerateMetafileDestPoint @ stub GdipEnumerateMetafileDestPoint
@ stub GdipEnumerateMetafileDestPointI @ stub GdipEnumerateMetafileDestPointI
@ stub GdipEnumerateMetafileDestPoints @ stub GdipEnumerateMetafileDestPoints
@@ -240,7 +240,7 @@
@ stdcall GdipGetAdjustableArrowCapHeight(ptr ptr) @ stdcall GdipGetAdjustableArrowCapHeight(ptr ptr)
@ stdcall GdipGetAdjustableArrowCapMiddleInset(ptr ptr) @ stdcall GdipGetAdjustableArrowCapMiddleInset(ptr ptr)
@ stdcall GdipGetAdjustableArrowCapWidth(ptr ptr) @ stdcall GdipGetAdjustableArrowCapWidth(ptr ptr)
@ stub GdipGetAllPropertyItems @ stdcall GdipGetAllPropertyItems(ptr long long ptr)
@ stdcall GdipGetBrushType(ptr ptr) @ stdcall GdipGetBrushType(ptr ptr)
@ stdcall GdipGetCellAscent(ptr long ptr) @ stdcall GdipGetCellAscent(ptr long ptr)
@ stdcall GdipGetCellDescent(ptr long ptr) @ stdcall GdipGetCellDescent(ptr long ptr)
@@ -281,8 +281,8 @@
@ stub GdipGetHemfFromMetafile @ stub GdipGetHemfFromMetafile
@ stub GdipGetImageAttributesAdjustedPalette @ stub GdipGetImageAttributesAdjustedPalette
@ stdcall GdipGetImageBounds(ptr ptr ptr) @ stdcall GdipGetImageBounds(ptr ptr ptr)
@ stub GdipGetImageDecoders @ stdcall GdipGetImageDecoders(long long ptr)
@ stub GdipGetImageDecodersSize @ stdcall GdipGetImageDecodersSize(ptr ptr)
@ stdcall GdipGetImageDimension(ptr ptr ptr) @ stdcall GdipGetImageDimension(ptr ptr ptr)
@ stdcall GdipGetImageEncoders(long long ptr) @ stdcall GdipGetImageEncoders(long long ptr)
@ stdcall GdipGetImageEncodersSize(ptr ptr) @ stdcall GdipGetImageEncodersSize(ptr ptr)
@@ -292,7 +292,7 @@
@ stdcall GdipGetImageHorizontalResolution(ptr ptr) @ stdcall GdipGetImageHorizontalResolution(ptr ptr)
@ stub GdipGetImageItemData @ stub GdipGetImageItemData
@ stub GdipGetImagePalette @ stub GdipGetImagePalette
@ stub GdipGetImagePaletteSize @ stdcall GdipGetImagePaletteSize(ptr ptr)
@ stdcall GdipGetImagePixelFormat(ptr ptr) @ stdcall GdipGetImagePixelFormat(ptr ptr)
@ stdcall GdipGetImageRawFormat(ptr ptr) @ stdcall GdipGetImageRawFormat(ptr ptr)
@ stub GdipGetImageThumbnail @ stub GdipGetImageThumbnail
@@ -360,7 +360,7 @@
@ stdcall GdipGetPenDashOffset(ptr ptr) @ stdcall GdipGetPenDashOffset(ptr ptr)
@ stdcall GdipGetPenDashStyle(ptr ptr) @ stdcall GdipGetPenDashStyle(ptr ptr)
@ stdcall GdipGetPenEndCap(ptr ptr) @ stdcall GdipGetPenEndCap(ptr ptr)
@ stub GdipGetPenFillType @ stdcall GdipGetPenFillType(ptr ptr)
@ stdcall GdipGetPenLineJoin(ptr ptr) @ stdcall GdipGetPenLineJoin(ptr ptr)
@ stdcall GdipGetPenMiterLimit(ptr ptr) @ stdcall GdipGetPenMiterLimit(ptr ptr)
@ stdcall GdipGetPenMode(ptr ptr) @ stdcall GdipGetPenMode(ptr ptr)
@@ -370,11 +370,11 @@
@ stdcall GdipGetPenWidth(ptr ptr) @ stdcall GdipGetPenWidth(ptr ptr)
@ stdcall GdipGetPixelOffsetMode(ptr ptr) @ stdcall GdipGetPixelOffsetMode(ptr ptr)
@ stdcall GdipGetPointCount(ptr ptr) @ stdcall GdipGetPointCount(ptr ptr)
@ stub GdipGetPropertyCount @ stdcall GdipGetPropertyCount(ptr ptr)
@ stub GdipGetPropertyIdList @ stdcall GdipGetPropertyIdList(ptr long ptr)
@ stub GdipGetPropertyItem @ stdcall GdipGetPropertyItem(ptr long long ptr)
@ stdcall GdipGetPropertyItemSize(ptr long ptr) @ stdcall GdipGetPropertyItemSize(ptr long ptr)
@ stub GdipGetPropertySize @ stdcall GdipGetPropertySize(ptr ptr ptr)
@ stdcall GdipGetRegionBounds(ptr ptr ptr) @ stdcall GdipGetRegionBounds(ptr ptr ptr)
@ stdcall GdipGetRegionBoundsI(ptr ptr ptr) @ stdcall GdipGetRegionBoundsI(ptr ptr ptr)
@ stdcall GdipGetRegionData(ptr ptr long ptr) @ stdcall GdipGetRegionData(ptr ptr long ptr)
@@ -395,17 +395,17 @@
@ stdcall GdipGetStringFormatTabStopCount(ptr ptr) @ stdcall GdipGetStringFormatTabStopCount(ptr ptr)
@ stdcall GdipGetStringFormatTabStops(ptr long ptr ptr) @ stdcall GdipGetStringFormatTabStops(ptr long ptr ptr)
@ stdcall GdipGetStringFormatTrimming(ptr ptr) @ stdcall GdipGetStringFormatTrimming(ptr ptr)
@ stub GdipGetTextContrast @ stdcall GdipGetTextContrast(ptr ptr)
@ stdcall GdipGetTextRenderingHint(ptr ptr) @ stdcall GdipGetTextRenderingHint(ptr ptr)
@ stub GdipGetTextureImage @ stub GdipGetTextureImage
@ stub GdipGetTextureTransform @ stdcall GdipGetTextureTransform(ptr ptr)
@ stub GdipGetTextureWrapMode @ stdcall GdipGetTextureWrapMode(ptr ptr)
@ stub GdipGetVisibleClipBounds @ stub GdipGetVisibleClipBounds
@ stub GdipGetVisibleClipBoundsI @ stub GdipGetVisibleClipBoundsI
@ stdcall GdipGetWorldTransform(ptr ptr) @ stdcall GdipGetWorldTransform(ptr ptr)
@ stdcall GdipGraphicsClear(ptr long) @ stdcall GdipGraphicsClear(ptr long)
@ stub GdipGraphicsSetAbort @ stub GdipGraphicsSetAbort
@ stub GdipImageForceValidation @ stdcall GdipImageForceValidation(ptr)
@ stdcall GdipImageGetFrameCount(ptr ptr ptr) @ stdcall GdipImageGetFrameCount(ptr ptr ptr)
@ stdcall GdipImageGetFrameDimensionsCount(ptr ptr) @ stdcall GdipImageGetFrameDimensionsCount(ptr ptr)
@ stdcall GdipImageGetFrameDimensionsList(ptr ptr long) @ stdcall GdipImageGetFrameDimensionsList(ptr ptr long)
@@ -427,8 +427,8 @@
@ stub GdipIsVisibleClipEmpty @ stub GdipIsVisibleClipEmpty
@ stdcall GdipIsVisiblePathPoint(ptr long long ptr ptr) @ stdcall GdipIsVisiblePathPoint(ptr long long ptr ptr)
@ stdcall GdipIsVisiblePathPointI(ptr long long ptr ptr) @ stdcall GdipIsVisiblePathPointI(ptr long long ptr ptr)
@ stub GdipIsVisiblePoint @ stdcall GdipIsVisiblePoint(ptr long long ptr)
@ stub GdipIsVisiblePointI @ stdcall GdipIsVisiblePointI(ptr long long ptr)
@ stub GdipIsVisibleRect @ stub GdipIsVisibleRect
@ stub GdipIsVisibleRectI @ stub GdipIsVisibleRectI
@ stub GdipIsVisibleRegionPoint @ stub GdipIsVisibleRegionPoint
@@ -446,9 +446,9 @@
@ stdcall GdipMultiplyMatrix(ptr ptr long) @ stdcall GdipMultiplyMatrix(ptr ptr long)
@ stub GdipMultiplyPathGradientTransform @ stub GdipMultiplyPathGradientTransform
@ stub GdipMultiplyPenTransform @ stub GdipMultiplyPenTransform
@ stub GdipMultiplyTextureTransform @ stdcall GdipMultiplyTextureTransform(ptr ptr long)
@ stdcall GdipMultiplyWorldTransform(ptr ptr long) @ stdcall GdipMultiplyWorldTransform(ptr ptr long)
@ stub GdipNewInstalledFontCollection @ stdcall GdipNewInstalledFontCollection(ptr)
@ stdcall GdipNewPrivateFontCollection(ptr) @ stdcall GdipNewPrivateFontCollection(ptr)
@ stdcall GdipPathIterCopyData(ptr ptr ptr ptr long long) @ stdcall GdipPathIterCopyData(ptr ptr ptr ptr long long)
@ stdcall GdipPathIterEnumerate(ptr ptr ptr ptr long) @ stdcall GdipPathIterEnumerate(ptr ptr ptr ptr long)
@@ -465,10 +465,10 @@
@ stub GdipPlayMetafileRecord @ stub GdipPlayMetafileRecord
@ stub GdipPlayTSClientRecord @ stub GdipPlayTSClientRecord
@ stdcall GdipPrivateAddFontFile(ptr wstr) @ stdcall GdipPrivateAddFontFile(ptr wstr)
@ stub GdipPrivateAddMemoryFont @ stdcall GdipPrivateAddMemoryFont(ptr ptr long)
@ stub GdipRecordMetafile @ stub GdipRecordMetafile
@ stub GdipRecordMetafileFileName @ stdcall GdipRecordMetafileFileName(wstr long long ptr long wstr ptr)
@ stub GdipRecordMetafileFileNameI @ stdcall GdipRecordMetafileFileNameI(wstr long long ptr long wstr ptr)
@ stub GdipRecordMetafileI @ stub GdipRecordMetafileI
@ stub GdipRecordMetafileStream @ stub GdipRecordMetafileStream
@ stub GdipRecordMetafileStreamI @ stub GdipRecordMetafileStreamI
@@ -481,7 +481,7 @@
@ stdcall GdipResetPath(ptr) @ stdcall GdipResetPath(ptr)
@ stub GdipResetPathGradientTransform @ stub GdipResetPathGradientTransform
@ stub GdipResetPenTransform @ stub GdipResetPenTransform
@ stub GdipResetTextureTransform @ stdcall GdipResetTextureTransform(ptr)
@ stdcall GdipResetWorldTransform(ptr) @ stdcall GdipResetWorldTransform(ptr)
@ stdcall GdipRestoreGraphics(ptr long) @ stdcall GdipRestoreGraphics(ptr long)
@ stdcall GdipReversePath(ptr) @ stdcall GdipReversePath(ptr)
@@ -489,7 +489,7 @@
@ stdcall GdipRotateMatrix(ptr long long) @ stdcall GdipRotateMatrix(ptr long long)
@ stub GdipRotatePathGradientTransform @ stub GdipRotatePathGradientTransform
@ stub GdipRotatePenTransform @ stub GdipRotatePenTransform
@ stub GdipRotateTextureTransform @ stdcall GdipRotateTextureTransform(ptr long long)
@ stdcall GdipRotateWorldTransform(ptr long long) @ stdcall GdipRotateWorldTransform(ptr long long)
@ stub GdipSaveAdd @ stub GdipSaveAdd
@ stub GdipSaveAddImage @ stub GdipSaveAddImage
@@ -500,16 +500,16 @@
@ stdcall GdipScaleMatrix(ptr long long long) @ stdcall GdipScaleMatrix(ptr long long long)
@ stub GdipScalePathGradientTransform @ stub GdipScalePathGradientTransform
@ stub GdipScalePenTransform @ stub GdipScalePenTransform
@ stub GdipScaleTextureTransform @ stdcall GdipScaleTextureTransform(ptr long long long)
@ stdcall GdipScaleWorldTransform(ptr long long long) @ stdcall GdipScaleWorldTransform(ptr long long long)
@ stdcall GdipSetAdjustableArrowCapFillState(ptr long) @ stdcall GdipSetAdjustableArrowCapFillState(ptr long)
@ stdcall GdipSetAdjustableArrowCapHeight(ptr long) @ stdcall GdipSetAdjustableArrowCapHeight(ptr long)
@ stdcall GdipSetAdjustableArrowCapMiddleInset(ptr long) @ stdcall GdipSetAdjustableArrowCapMiddleInset(ptr long)
@ stdcall GdipSetAdjustableArrowCapWidth(ptr long) @ stdcall GdipSetAdjustableArrowCapWidth(ptr long)
@ stub GdipSetClipGraphics @ stdcall GdipSetClipGraphics(ptr ptr long)
@ stub GdipSetClipHrgn @ stub GdipSetClipHrgn
@ stub GdipSetClipPath @ stdcall GdipSetClipPath(ptr ptr long)
@ stub GdipSetClipRect @ stdcall GdipSetClipRect(ptr long long long long long)
@ stdcall GdipSetClipRectI(ptr long long long long long) @ stdcall GdipSetClipRectI(ptr long long long long long)
@ stdcall GdipSetClipRegion(ptr ptr long) @ stdcall GdipSetClipRegion(ptr ptr long)
@ stdcall GdipSetCompositingMode(ptr long) @ stdcall GdipSetCompositingMode(ptr long)
@@ -548,7 +548,7 @@
@ stdcall GdipSetPageScale(ptr long) @ stdcall GdipSetPageScale(ptr long)
@ stdcall GdipSetPageUnit(ptr long) @ stdcall GdipSetPageUnit(ptr long)
@ stdcall GdipSetPathFillMode(ptr long) @ stdcall GdipSetPathFillMode(ptr long)
@ stub GdipSetPathGradientBlend @ stdcall GdipSetPathGradientBlend(ptr ptr ptr long)
@ stdcall GdipSetPathGradientCenterColor(ptr long) @ stdcall GdipSetPathGradientCenterColor(ptr long)
@ stdcall GdipSetPathGradientCenterPoint(ptr ptr) @ stdcall GdipSetPathGradientCenterPoint(ptr ptr)
@ stdcall GdipSetPathGradientCenterPointI(ptr ptr) @ stdcall GdipSetPathGradientCenterPointI(ptr ptr)
@@ -564,7 +564,7 @@
@ stdcall GdipSetPathMarker(ptr) @ stdcall GdipSetPathMarker(ptr)
@ stdcall GdipSetPenBrushFill(ptr ptr) @ stdcall GdipSetPenBrushFill(ptr ptr)
@ stdcall GdipSetPenColor(ptr long) @ stdcall GdipSetPenColor(ptr long)
@ stub GdipSetPenCompoundArray @ stdcall GdipSetPenCompoundArray(ptr ptr long)
@ stdcall GdipSetPenCustomEndCap(ptr ptr) @ stdcall GdipSetPenCustomEndCap(ptr ptr)
@ stdcall GdipSetPenCustomStartCap(ptr ptr) @ stdcall GdipSetPenCustomStartCap(ptr ptr)
@ stdcall GdipSetPenDashArray(ptr ptr long) @ stdcall GdipSetPenDashArray(ptr ptr long)
@@ -581,7 +581,7 @@
@ stub GdipSetPenUnit @ stub GdipSetPenUnit
@ stdcall GdipSetPenWidth(ptr long) @ stdcall GdipSetPenWidth(ptr long)
@ stdcall GdipSetPixelOffsetMode(ptr long) @ stdcall GdipSetPixelOffsetMode(ptr long)
@ stub GdipSetPropertyItem @ stdcall GdipSetPropertyItem(ptr ptr)
@ stub GdipSetRenderingOrigin @ stub GdipSetRenderingOrigin
@ stdcall GdipSetSmoothingMode(ptr long) @ stdcall GdipSetSmoothingMode(ptr long)
@ stdcall GdipSetSolidFillColor(ptr ptr) @ stdcall GdipSetSolidFillColor(ptr ptr)
@@ -593,16 +593,16 @@
@ stdcall GdipSetStringFormatMeasurableCharacterRanges(ptr long ptr) @ stdcall GdipSetStringFormatMeasurableCharacterRanges(ptr long ptr)
@ stdcall GdipSetStringFormatTabStops(ptr long long ptr) @ stdcall GdipSetStringFormatTabStops(ptr long long ptr)
@ stdcall GdipSetStringFormatTrimming(ptr long) @ stdcall GdipSetStringFormatTrimming(ptr long)
@ stub GdipSetTextContrast @ stdcall GdipSetTextContrast(ptr long)
@ stdcall GdipSetTextRenderingHint(ptr long) @ stdcall GdipSetTextRenderingHint(ptr long)
@ stdcall GdipSetTextureTransform(ptr ptr) @ stdcall GdipSetTextureTransform(ptr ptr)
@ stub GdipSetTextureWrapMode @ stdcall GdipSetTextureWrapMode(ptr long)
@ stdcall GdipSetWorldTransform(ptr ptr) @ stdcall GdipSetWorldTransform(ptr ptr)
@ stdcall GdipShearMatrix(ptr long long long) @ stdcall GdipShearMatrix(ptr long long long)
@ stdcall GdipStartPathFigure(ptr) @ stdcall GdipStartPathFigure(ptr)
@ stdcall GdipStringFormatGetGenericDefault(ptr) @ stdcall GdipStringFormatGetGenericDefault(ptr)
@ stdcall GdipStringFormatGetGenericTypographic(ptr) @ stdcall GdipStringFormatGetGenericTypographic(ptr)
@ stub GdipTestControl @ stdcall GdipTestControl(long ptr)
@ stdcall GdipTransformMatrixPoints(ptr ptr long) @ stdcall GdipTransformMatrixPoints(ptr ptr long)
@ stdcall GdipTransformMatrixPointsI(ptr ptr long) @ stdcall GdipTransformMatrixPointsI(ptr ptr long)
@ stdcall GdipTransformPath(ptr ptr) @ stdcall GdipTransformPath(ptr ptr)
@@ -617,14 +617,14 @@
@ stub GdipTranslatePenTransform @ stub GdipTranslatePenTransform
@ stdcall GdipTranslateRegion(ptr long long) @ stdcall GdipTranslateRegion(ptr long long)
@ stdcall GdipTranslateRegionI(ptr long long) @ stdcall GdipTranslateRegionI(ptr long long)
@ stub GdipTranslateTextureTransform @ stdcall GdipTranslateTextureTransform(ptr long long long)
@ stdcall GdipTranslateWorldTransform(ptr long long long) @ stdcall GdipTranslateWorldTransform(ptr long long long)
@ stdcall GdipVectorTransformMatrixPoints(ptr ptr long) @ stdcall GdipVectorTransformMatrixPoints(ptr ptr long)
@ stdcall GdipVectorTransformMatrixPointsI(ptr ptr long) @ stdcall GdipVectorTransformMatrixPointsI(ptr ptr long)
@ stub GdipWarpPath @ stub GdipWarpPath
@ stub GdipWidenPath @ stub GdipWidenPath
@ stub GdipWindingModeOutline @ stub GdipWindingModeOutline
@ stub GdiplusNotificationHook @ stdcall GdiplusNotificationHook(ptr)
@ stub GdiplusNotificationUnhook @ stdcall GdiplusNotificationUnhook(ptr)
@ stdcall GdiplusShutdown(ptr) @ stdcall GdiplusShutdown(ptr)
@ stdcall GdiplusStartup(ptr ptr ptr) @ stdcall GdiplusStartup(ptr ptr ptr)

View File

@@ -54,6 +54,8 @@ extern void calc_curve_bezier_endp(REAL xend, REAL yend, REAL xadj, REAL yadj,
extern BOOL lengthen_path(GpPath *path, INT len); extern BOOL lengthen_path(GpPath *path, INT len);
extern GpStatus trace_path(GpGraphics *graphics, GpPath *path);
typedef struct region_element region_element; typedef struct region_element region_element;
extern inline void delete_element(region_element *element); extern inline void delete_element(region_element *element);
@@ -100,6 +102,7 @@ struct GpGraphics{
GpMatrix * worldtrans; /* world transform */ GpMatrix * worldtrans; /* world transform */
BOOL busy; /* hdc handle obtained by GdipGetDC */ BOOL busy; /* hdc handle obtained by GdipGetDC */
GpRegion *clip; GpRegion *clip;
UINT textcontrast; /* not used yet. get/set only */
}; };
struct GpBrush{ struct GpBrush{
@@ -138,6 +141,8 @@ struct GpLineGradient{
struct GpTexture{ struct GpTexture{
GpBrush brush; GpBrush brush;
GpMatrix *transform;
WrapMode wrap; /* not used yet */
}; };
struct GpPath{ struct GpPath{
@@ -193,6 +198,10 @@ struct GpBitmap{
BYTE *bitmapbits; /* pointer to the buffer we passed in BitmapLockBits */ BYTE *bitmapbits; /* pointer to the buffer we passed in BitmapLockBits */
}; };
struct GpCachedBitmap{
GpImage *image;
};
struct GpImageAttributes{ struct GpImageAttributes{
WrapMode wrap; WrapMode wrap;
}; };
@@ -200,6 +209,8 @@ struct GpImageAttributes{
struct GpFont{ struct GpFont{
LOGFONTW lfw; LOGFONTW lfw;
REAL emSize; REAL emSize;
UINT height;
LONG line_spacing;
Unit unit; Unit unit;
}; };
@@ -218,7 +229,8 @@ struct GpStringFormat{
}; };
struct GpFontCollection{ struct GpFontCollection{
GpFontFamily* FontFamilies; GpFontFamily **FontFamilies;
INT count;
}; };
struct GpFontFamily{ struct GpFontFamily{

View File

@@ -715,6 +715,17 @@ end:
return status; return status;
} }
GpStatus trace_path(GpGraphics *graphics, GpPath *path)
{
GpStatus result;
BeginPath(graphics->hdc);
result = draw_poly(graphics, NULL, path->pathdata.Points,
path->pathdata.Types, path->pathdata.Count, FALSE);
EndPath(graphics->hdc);
return result;
}
GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics) GpStatus WINGDIPAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics)
{ {
TRACE("(%p, %p)\n", hdc, graphics); TRACE("(%p, %p)\n", hdc, graphics);
@@ -763,6 +774,7 @@ GpStatus WINGDIPAPI GdipCreateFromHDC2(HDC hdc, HANDLE hDevice, GpGraphics **gra
(*graphics)->unit = UnitDisplay; (*graphics)->unit = UnitDisplay;
(*graphics)->scale = 1.0; (*graphics)->scale = 1.0;
(*graphics)->busy = FALSE; (*graphics)->busy = FALSE;
(*graphics)->textcontrast = 4;
return Ok; return Ok;
} }
@@ -2507,6 +2519,18 @@ GpStatus WINGDIPAPI GdipGetSmoothingMode(GpGraphics *graphics, SmoothingMode *mo
return Ok; return Ok;
} }
GpStatus WINGDIPAPI GdipGetTextContrast(GpGraphics *graphics, UINT *contrast)
{
TRACE("(%p, %p)\n", graphics, contrast);
if(!graphics || !contrast)
return InvalidParameter;
*contrast = graphics->textcontrast;
return Ok;
}
/* FIXME: Text rendering hint is not used anywhere except the getter/setter. */ /* FIXME: Text rendering hint is not used anywhere except the getter/setter. */
GpStatus WINGDIPAPI GdipGetTextRenderingHint(GpGraphics *graphics, GpStatus WINGDIPAPI GdipGetTextRenderingHint(GpGraphics *graphics,
TextRenderingHint *hint) TextRenderingHint *hint)
@@ -2583,6 +2607,32 @@ GpStatus WINGDIPAPI GdipIsClipEmpty(GpGraphics *graphics, BOOL *res)
return GdipIsEmptyRegion(graphics->clip, graphics, res); return GdipIsEmptyRegion(graphics->clip, graphics, res);
} }
GpStatus WINGDIPAPI GdipIsVisiblePoint(GpGraphics *graphics, REAL x, REAL y, BOOL *result)
{
FIXME("(%p, %.2f, %.2f, %p) stub\n", graphics, x, y, result);
if(!graphics || !result)
return InvalidParameter;
if(graphics->busy)
return ObjectBusy;
return NotImplemented;
}
GpStatus WINGDIPAPI GdipIsVisiblePointI(GpGraphics *graphics, INT x, INT y, BOOL *result)
{
FIXME("(%p, %d, %d, %p) stub\n", graphics, x, y, result);
if(!graphics || !result)
return InvalidParameter;
if(graphics->busy)
return ObjectBusy;
return NotImplemented;
}
GpStatus WINGDIPAPI GdipMeasureCharacterRanges(GpGraphics* graphics, GpStatus WINGDIPAPI GdipMeasureCharacterRanges(GpGraphics* graphics,
GDIPCONST WCHAR* string, INT length, GDIPCONST GpFont* font, GDIPCONST WCHAR* string, INT length, GDIPCONST GpFont* font,
GDIPCONST RectF* layoutRect, GDIPCONST GpStringFormat *stringFormat, GDIPCONST RectF* layoutRect, GDIPCONST GpStringFormat *stringFormat,
@@ -2615,17 +2665,15 @@ GpStatus WINGDIPAPI GdipMeasureString(GpGraphics *graphics,
if(!graphics || !string || !font || !rect) if(!graphics || !string || !font || !rect)
return InvalidParameter; return InvalidParameter;
if(codepointsfitted || linesfilled){ if(linesfilled) *linesfilled = 0;
FIXME("not implemented for given parameters\n"); if(codepointsfitted) *codepointsfitted = 0;
return NotImplemented;
}
if(format) if(format)
TRACE("may be ignoring some format flags: attr %x\n", format->attr); TRACE("may be ignoring some format flags: attr %x\n", format->attr);
if(length == -1) length = lstrlenW(string); if(length == -1) length = lstrlenW(string);
stringdup = GdipAlloc(length * sizeof(WCHAR)); stringdup = GdipAlloc((length + 1) * sizeof(WCHAR));
if(!stringdup) return OutOfMemory; if(!stringdup) return OutOfMemory;
oldfont = SelectObject(graphics->hdc, CreateFontIndirectW(&font->lfw)); oldfont = SelectObject(graphics->hdc, CreateFontIndirectW(&font->lfw));
@@ -2683,7 +2731,10 @@ GpStatus WINGDIPAPI GdipMeasureString(GpGraphics *graphics,
nwidth, &j, NULL, &size); nwidth, &j, NULL, &size);
sum += fit + (lret < fitcpy ? 1 : 0); sum += fit + (lret < fitcpy ? 1 : 0);
if(codepointsfitted) *codepointsfitted = sum;
height += size.cy; height += size.cy;
if(linesfilled) *linesfilled += size.cy;
max_width = max(max_width, size.cx); max_width = max(max_width, size.cx);
if(height > nheight) if(height > nheight)
@@ -2748,7 +2799,7 @@ GpStatus WINGDIPAPI GdipRestoreGraphics(GpGraphics *graphics, GraphicsState stat
if(!(calls++)) if(!(calls++))
FIXME("graphics state not implemented\n"); FIXME("graphics state not implemented\n");
return NotImplemented; return Ok;
} }
GpStatus WINGDIPAPI GdipRotateWorldTransform(GpGraphics *graphics, REAL angle, GpStatus WINGDIPAPI GdipRotateWorldTransform(GpGraphics *graphics, REAL angle,
@@ -2775,7 +2826,29 @@ GpStatus WINGDIPAPI GdipSaveGraphics(GpGraphics *graphics, GraphicsState *state)
if(!(calls++)) if(!(calls++))
FIXME("graphics state not implemented\n"); FIXME("graphics state not implemented\n");
return NotImplemented; *state = 0xdeadbeef;
return Ok;
}
GpStatus WINGDIPAPI GdipBeginContainer2(GpGraphics *graphics, GraphicsContainer *state)
{
FIXME("(%p, %p)\n", graphics, state);
if(!graphics || !state)
return InvalidParameter;
*state = 0xdeadbeef;
return Ok;
}
GpStatus WINGDIPAPI GdipEndContainer(GpGraphics *graphics, GraphicsState state)
{
FIXME("(%p, 0x%x)\n", graphics, state);
if(!graphics || !state)
return InvalidParameter;
return Ok;
} }
GpStatus WINGDIPAPI GdipScaleWorldTransform(GpGraphics *graphics, REAL sx, GpStatus WINGDIPAPI GdipScaleWorldTransform(GpGraphics *graphics, REAL sx,
@@ -2792,6 +2865,17 @@ GpStatus WINGDIPAPI GdipScaleWorldTransform(GpGraphics *graphics, REAL sx,
return GdipScaleMatrix(graphics->worldtrans, sx, sy, order); return GdipScaleMatrix(graphics->worldtrans, sx, sy, order);
} }
GpStatus WINGDIPAPI GdipSetClipGraphics(GpGraphics *graphics, GpGraphics *srcgraphics,
CombineMode mode)
{
TRACE("(%p, %p, %d)\n", graphics, srcgraphics, mode);
if(!graphics || !srcgraphics)
return InvalidParameter;
return GdipCombineRegionRegion(graphics->clip, srcgraphics->clip, mode);
}
GpStatus WINGDIPAPI GdipSetCompositingMode(GpGraphics *graphics, GpStatus WINGDIPAPI GdipSetCompositingMode(GpGraphics *graphics,
CompositingMode mode) CompositingMode mode)
{ {
@@ -2904,6 +2988,18 @@ GpStatus WINGDIPAPI GdipSetSmoothingMode(GpGraphics *graphics, SmoothingMode mod
return Ok; return Ok;
} }
GpStatus WINGDIPAPI GdipSetTextContrast(GpGraphics *graphics, UINT contrast)
{
TRACE("(%p, %d)\n", graphics, contrast);
if(!graphics)
return InvalidParameter;
graphics->textcontrast = contrast;
return Ok;
}
GpStatus WINGDIPAPI GdipSetTextRenderingHint(GpGraphics *graphics, GpStatus WINGDIPAPI GdipSetTextRenderingHint(GpGraphics *graphics,
TextRenderingHint hint) TextRenderingHint hint)
{ {
@@ -2948,11 +3044,9 @@ GpStatus WINGDIPAPI GdipTranslateWorldTransform(GpGraphics *graphics, REAL dx,
return GdipTranslateMatrix(graphics->worldtrans, dx, dy, order); return GdipTranslateMatrix(graphics->worldtrans, dx, dy, order);
} }
GpStatus WINGDIPAPI GdipSetClipRectI(GpGraphics *graphics, INT x, INT y, GpStatus WINGDIPAPI GdipSetClipPath(GpGraphics *graphics, GpPath *path, CombineMode mode)
INT width, INT height,
CombineMode combineMode)
{ {
static int calls; TRACE("(%p, %p, %d)\n", graphics, path, mode);
if(!graphics) if(!graphics)
return InvalidParameter; return InvalidParameter;
@@ -2960,10 +3054,44 @@ GpStatus WINGDIPAPI GdipSetClipRectI(GpGraphics *graphics, INT x, INT y,
if(graphics->busy) if(graphics->busy)
return ObjectBusy; return ObjectBusy;
if(!(calls++)) return GdipCombineRegionPath(graphics->clip, path, mode);
FIXME("not implemented\n"); }
return NotImplemented; GpStatus WINGDIPAPI GdipSetClipRect(GpGraphics *graphics, REAL x, REAL y,
REAL width, REAL height,
CombineMode mode)
{
GpRectF rect;
TRACE("(%p, %.2f, %.2f, %.2f, %.2f, %d)\n", graphics, x, y, width, height, mode);
if(!graphics)
return InvalidParameter;
if(graphics->busy)
return ObjectBusy;
rect.X = x;
rect.Y = y;
rect.Width = width;
rect.Height = height;
return GdipCombineRegionRect(graphics->clip, &rect, mode);
}
GpStatus WINGDIPAPI GdipSetClipRectI(GpGraphics *graphics, INT x, INT y,
INT width, INT height,
CombineMode mode)
{
TRACE("(%p, %d, %d, %d, %d, %d)\n", graphics, x, y, width, height, mode);
if(!graphics)
return InvalidParameter;
if(graphics->busy)
return ObjectBusy;
return GdipSetClipRect(graphics, (REAL)x, (REAL)y, (REAL)width, (REAL)height, mode);
} }
GpStatus WINGDIPAPI GdipSetClipRegion(GpGraphics *graphics, GpRegion *region, GpStatus WINGDIPAPI GdipSetClipRegion(GpGraphics *graphics, GpRegion *region,
@@ -3170,3 +3298,10 @@ GpStatus WINGDIPAPI GdipTransformPointsI(GpGraphics *graphics, GpCoordinateSpace
return NotImplemented; return NotImplemented;
} }
HPALETTE WINGDIPAPI GdipCreateHalftonePalette(void)
{
FIXME("\n");
return NULL;
}

View File

@@ -984,17 +984,17 @@ GpStatus WINGDIPAPI GdipFlattenPath(GpPath *path, GpMatrix* matrix, REAL flatnes
/* always add line points and start points */ /* always add line points and start points */
if((type == PathPointTypeStart) || (type == PathPointTypeLine)){ if((type == PathPointTypeStart) || (type == PathPointTypeLine)){
type = (path->pathdata.Types[i] & ~PathPointTypeBezier) | PathPointTypeLine; if(!add_path_list_node(node, pt.X, pt.Y, path->pathdata.Types[i]))
if(!add_path_list_node(node, pt.X, pt.Y, type))
goto memout; goto memout;
node = node->next; node = node->next;
++i;
continue; continue;
} }
/* Bezier curve always stored as 4 points */ /* Bezier curve always stored as 4 points */
if((path->pathdata.Types[i-1] & PathPointTypePathTypeMask) != PathPointTypeStart){ if((path->pathdata.Types[i-1] & PathPointTypePathTypeMask) != PathPointTypeStart){
type = (path->pathdata.Types[i] & ~PathPointTypeBezier) | PathPointTypeLine; type = (path->pathdata.Types[i] & ~PathPointTypePathTypeMask) | PathPointTypeLine;
if(!add_path_list_node(node, pt.X, pt.Y, type)) if(!add_path_list_node(node, pt.X, pt.Y, type))
goto memout; goto memout;
@@ -1014,7 +1014,7 @@ GpStatus WINGDIPAPI GdipFlattenPath(GpPath *path, GpMatrix* matrix, REAL flatnes
start = node; start = node;
/* add Bezier end point */ /* add Bezier end point */
type = (path->pathdata.Types[i] & ~PathPointTypeBezier) | PathPointTypeLine; type = (path->pathdata.Types[i] & ~PathPointTypePathTypeMask) | PathPointTypeLine;
if(!add_path_list_node(node, pt.X, pt.Y, type)) if(!add_path_list_node(node, pt.X, pt.Y, type))
goto memout; goto memout;
node = node->next; node = node->next;

View File

@@ -28,6 +28,7 @@
#include "olectl.h" #include "olectl.h"
#include "ole2.h" #include "ole2.h"
#include "initguid.h"
#include "gdiplus.h" #include "gdiplus.h"
#include "gdiplus_private.h" #include "gdiplus_private.h"
#include "wine/debug.h" #include "wine/debug.h"
@@ -95,10 +96,9 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect,
{ {
BOOL bm_is_selected; BOOL bm_is_selected;
INT stride, bitspp = PIXELFORMATBPP(format); INT stride, bitspp = PIXELFORMATBPP(format);
OLE_HANDLE hbm;
HDC hdc; HDC hdc;
HBITMAP old = NULL; HBITMAP hbm, old = NULL;
BITMAPINFO bmi; BITMAPINFO *pbmi;
BYTE *buff = NULL; BYTE *buff = NULL;
UINT abs_height; UINT abs_height;
GpRect act_rect; /* actual rect to be used */ GpRect act_rect; /* actual rect to be used */
@@ -127,46 +127,51 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect,
if(bitmap->lockmode) if(bitmap->lockmode)
return WrongState; return WrongState;
IPicture_get_Handle(bitmap->image.picture, &hbm); IPicture_get_Handle(bitmap->image.picture, (OLE_HANDLE*)&hbm);
IPicture_get_CurDC(bitmap->image.picture, &hdc); IPicture_get_CurDC(bitmap->image.picture, &hdc);
bm_is_selected = (hdc != 0); bm_is_selected = (hdc != 0);
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
bmi.bmiHeader.biBitCount = 0; if (!pbmi)
return OutOfMemory;
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pbmi->bmiHeader.biBitCount = 0;
if(!bm_is_selected){ if(!bm_is_selected){
hdc = CreateCompatibleDC(0); hdc = CreateCompatibleDC(0);
old = SelectObject(hdc, (HBITMAP)hbm); old = SelectObject(hdc, hbm);
} }
/* fill out bmi */ /* fill out bmi */
GetDIBits(hdc, (HBITMAP)hbm, 0, 0, NULL, &bmi, DIB_RGB_COLORS); GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS);
abs_height = abs(bmi.bmiHeader.biHeight); abs_height = abs(pbmi->bmiHeader.biHeight);
stride = bmi.bmiHeader.biWidth * bitspp / 8; stride = pbmi->bmiHeader.biWidth * bitspp / 8;
stride = (stride + 3) & ~3; stride = (stride + 3) & ~3;
buff = GdipAlloc(stride * abs_height); buff = GdipAlloc(stride * abs_height);
bmi.bmiHeader.biBitCount = bitspp; pbmi->bmiHeader.biBitCount = bitspp;
if(buff) if(buff)
GetDIBits(hdc, (HBITMAP)hbm, 0, abs_height, buff, &bmi, DIB_RGB_COLORS); GetDIBits(hdc, hbm, 0, abs_height, buff, pbmi, DIB_RGB_COLORS);
if(!bm_is_selected){ if(!bm_is_selected){
SelectObject(hdc, old); SelectObject(hdc, old);
DeleteDC(hdc); DeleteDC(hdc);
} }
if(!buff) if(!buff){
GdipFree(pbmi);
return OutOfMemory; return OutOfMemory;
}
lockeddata->Width = act_rect.Width; lockeddata->Width = act_rect.Width;
lockeddata->Height = act_rect.Height; lockeddata->Height = act_rect.Height;
lockeddata->PixelFormat = format; lockeddata->PixelFormat = format;
lockeddata->Reserved = flags; lockeddata->Reserved = flags;
if(bmi.bmiHeader.biHeight > 0){ if(pbmi->bmiHeader.biHeight > 0){
lockeddata->Stride = -stride; lockeddata->Stride = -stride;
lockeddata->Scan0 = buff + (bitspp / 8) * act_rect.X + lockeddata->Scan0 = buff + (bitspp / 8) * act_rect.X +
stride * (abs_height - 1 - act_rect.Y); stride * (abs_height - 1 - act_rect.Y);
@@ -181,17 +186,17 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect,
bitmap->bitmapbits = buff; bitmap->bitmapbits = buff;
GdipFree(pbmi);
return Ok; return Ok;
} }
GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap, GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap,
BitmapData* lockeddata) BitmapData* lockeddata)
{ {
OLE_HANDLE hbm;
HDC hdc; HDC hdc;
HBITMAP old = NULL; HBITMAP hbm, old = NULL;
BOOL bm_is_selected; BOOL bm_is_selected;
BITMAPINFO bmi; BITMAPINFO *pbmi;
if(!bitmap || !lockeddata) if(!bitmap || !lockeddata)
return InvalidParameter; return InvalidParameter;
@@ -211,28 +216,30 @@ GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap,
return Ok; return Ok;
} }
IPicture_get_Handle(bitmap->image.picture, &hbm); IPicture_get_Handle(bitmap->image.picture, (OLE_HANDLE*)&hbm);
IPicture_get_CurDC(bitmap->image.picture, &hdc); IPicture_get_CurDC(bitmap->image.picture, &hdc);
bm_is_selected = (hdc != 0); bm_is_selected = (hdc != 0);
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
bmi.bmiHeader.biBitCount = 0; pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pbmi->bmiHeader.biBitCount = 0;
if(!bm_is_selected){ if(!bm_is_selected){
hdc = CreateCompatibleDC(0); hdc = CreateCompatibleDC(0);
old = SelectObject(hdc, (HBITMAP)hbm); old = SelectObject(hdc, hbm);
} }
GetDIBits(hdc, (HBITMAP)hbm, 0, 0, NULL, &bmi, DIB_RGB_COLORS); GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS);
bmi.bmiHeader.biBitCount = PIXELFORMATBPP(lockeddata->PixelFormat); pbmi->bmiHeader.biBitCount = PIXELFORMATBPP(lockeddata->PixelFormat);
SetDIBits(hdc, (HBITMAP)hbm, 0, abs(bmi.bmiHeader.biHeight), SetDIBits(hdc, hbm, 0, abs(pbmi->bmiHeader.biHeight),
bitmap->bitmapbits, &bmi, DIB_RGB_COLORS); bitmap->bitmapbits, pbmi, DIB_RGB_COLORS);
if(!bm_is_selected){ if(!bm_is_selected){
SelectObject(hdc, old); SelectObject(hdc, old);
DeleteDC(hdc); DeleteDC(hdc);
} }
GdipFree(pbmi);
GdipFree(bitmap->bitmapbits); GdipFree(bitmap->bitmapbits);
bitmap->bitmapbits = NULL; bitmap->bitmapbits = NULL;
bitmap->lockmode = 0; bitmap->lockmode = 0;
@@ -245,6 +252,8 @@ GpStatus WINGDIPAPI GdipCloneImage(GpImage *image, GpImage **cloneImage)
IStream* stream; IStream* stream;
HRESULT hr; HRESULT hr;
INT size; INT size;
LARGE_INTEGER move;
GpStatus stat = GenericError;
TRACE("%p, %p\n", image, cloneImage); TRACE("%p, %p\n", image, cloneImage);
@@ -255,15 +264,6 @@ GpStatus WINGDIPAPI GdipCloneImage(GpImage *image, GpImage **cloneImage)
if (FAILED(hr)) if (FAILED(hr))
return GenericError; return GenericError;
*cloneImage = GdipAlloc(sizeof(GpImage));
if (!*cloneImage)
{
IStream_Release(stream);
return OutOfMemory;
}
(*cloneImage)->type = image->type;
(*cloneImage)->flags = image->flags;
hr = IPicture_SaveAsFile(image->picture, stream, FALSE, &size); hr = IPicture_SaveAsFile(image->picture, stream, FALSE, &size);
if(FAILED(hr)) if(FAILED(hr))
{ {
@@ -271,21 +271,18 @@ GpStatus WINGDIPAPI GdipCloneImage(GpImage *image, GpImage **cloneImage)
goto out; goto out;
} }
hr = OleLoadPicture(stream, size, FALSE, &IID_IPicture, /* Set seek pointer back to the beginning of the picture */
(LPVOID*) &(*cloneImage)->picture); move.QuadPart = 0;
hr = IStream_Seek(stream, move, STREAM_SEEK_SET, NULL);
if (FAILED(hr)) if (FAILED(hr))
{
WARN("Failed to load image from stream\n");
goto out; goto out;
}
IStream_Release(stream); stat = GdipLoadImageFromStream(stream, cloneImage);
return Ok; if (stat != Ok) WARN("Failed to load image from stream\n");
out: out:
IStream_Release(stream); IStream_Release(stream);
GdipFree(*cloneImage); return stat;
*cloneImage = NULL;
return GenericError;
} }
GpStatus WINGDIPAPI GdipCreateBitmapFromFile(GDIPCONST WCHAR* filename, GpStatus WINGDIPAPI GdipCreateBitmapFromFile(GDIPCONST WCHAR* filename,
@@ -294,6 +291,8 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromFile(GDIPCONST WCHAR* filename,
GpStatus stat; GpStatus stat;
IStream *stream; IStream *stream;
TRACE("(%s) %p\n", debugstr_w(filename), bitmap);
if(!filename || !bitmap) if(!filename || !bitmap)
return InvalidParameter; return InvalidParameter;
@@ -354,6 +353,8 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromGdiDib(GDIPCONST BITMAPINFO* info,
GpStatus WINGDIPAPI GdipCreateBitmapFromFileICM(GDIPCONST WCHAR* filename, GpStatus WINGDIPAPI GdipCreateBitmapFromFileICM(GDIPCONST WCHAR* filename,
GpBitmap **bitmap) GpBitmap **bitmap)
{ {
TRACE("(%s) %p\n", debugstr_w(filename), bitmap);
return GdipCreateBitmapFromFile(filename, bitmap); return GdipCreateBitmapFromFile(filename, bitmap);
} }
@@ -363,11 +364,14 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromResource(HINSTANCE hInstance,
HBITMAP hbm; HBITMAP hbm;
GpStatus stat = InvalidParameter; GpStatus stat = InvalidParameter;
TRACE("%p (%s) %p\n", hInstance, debugstr_w(lpBitmapName), bitmap);
if(!lpBitmapName || !bitmap) if(!lpBitmapName || !bitmap)
return InvalidParameter; return InvalidParameter;
/* load DIB */ /* load DIB */
hbm = (HBITMAP)LoadImageW(hInstance,lpBitmapName,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION); hbm = LoadImageW(hInstance, lpBitmapName, IMAGE_BITMAP, 0, 0,
LR_CREATEDIBSECTION);
if(hbm){ if(hbm){
stat = GdipCreateBitmapFromHBITMAP(hbm, NULL, bitmap); stat = GdipCreateBitmapFromHBITMAP(hbm, NULL, bitmap);
@@ -436,7 +440,9 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
TRACE("%d %d %d %d %p %p\n", width, height, stride, format, scan0, bitmap); TRACE("%d %d %d %d %p %p\n", width, height, stride, format, scan0, bitmap);
if(!bitmap || width <= 0 || height <= 0 || (scan0 && (stride % 4))){ if (!bitmap) return InvalidParameter;
if(width <= 0 || height <= 0 || (scan0 && (stride % 4))){
*bitmap = NULL; *bitmap = NULL;
return InvalidParameter; return InvalidParameter;
} }
@@ -516,6 +522,8 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromStream(IStream* stream,
{ {
GpStatus stat; GpStatus stat;
TRACE("%p %p\n", stream, bitmap);
stat = GdipLoadImageFromStream(stream, (GpImage**) bitmap); stat = GdipLoadImageFromStream(stream, (GpImage**) bitmap);
if(stat != Ok) if(stat != Ok)
@@ -534,13 +542,64 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromStream(IStream* stream,
GpStatus WINGDIPAPI GdipCreateBitmapFromStreamICM(IStream* stream, GpStatus WINGDIPAPI GdipCreateBitmapFromStreamICM(IStream* stream,
GpBitmap **bitmap) GpBitmap **bitmap)
{ {
TRACE("%p %p\n", stream, bitmap);
return GdipCreateBitmapFromStream(stream, bitmap); return GdipCreateBitmapFromStream(stream, bitmap);
} }
GpStatus WINGDIPAPI GdipCreateCachedBitmap(GpBitmap *bitmap, GpGraphics *graphics,
GpCachedBitmap **cachedbmp)
{
GpStatus stat;
TRACE("%p %p %p\n", bitmap, graphics, cachedbmp);
if(!bitmap || !graphics || !cachedbmp)
return InvalidParameter;
*cachedbmp = GdipAlloc(sizeof(GpCachedBitmap));
if(!*cachedbmp)
return OutOfMemory;
stat = GdipCloneImage(&(bitmap->image), &(*cachedbmp)->image);
if(stat != Ok){
GdipFree(*cachedbmp);
return stat;
}
return Ok;
}
GpStatus WINGDIPAPI GdipDeleteCachedBitmap(GpCachedBitmap *cachedbmp)
{
TRACE("%p\n", cachedbmp);
if(!cachedbmp)
return InvalidParameter;
GdipDisposeImage(cachedbmp->image);
GdipFree(cachedbmp);
return Ok;
}
GpStatus WINGDIPAPI GdipDrawCachedBitmap(GpGraphics *graphics,
GpCachedBitmap *cachedbmp, INT x, INT y)
{
TRACE("%p %p %d %d\n", graphics, cachedbmp, x, y);
if(!graphics || !cachedbmp)
return InvalidParameter;
return GdipDrawImage(graphics, cachedbmp->image, (REAL)x, (REAL)y);
}
GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image) GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
{ {
HDC hdc; HDC hdc;
TRACE("%p\n", image);
if(!image) if(!image)
return InvalidParameter; return InvalidParameter;
@@ -565,6 +624,8 @@ GpStatus WINGDIPAPI GdipFindFirstImageItem(GpImage *image, ImageItemData* item)
GpStatus WINGDIPAPI GdipGetImageBounds(GpImage *image, GpRectF *srcRect, GpStatus WINGDIPAPI GdipGetImageBounds(GpImage *image, GpRectF *srcRect,
GpUnit *srcUnit) GpUnit *srcUnit)
{ {
TRACE("%p %p %p\n", image, srcRect, srcUnit);
if(!image || !srcRect || !srcUnit) if(!image || !srcRect || !srcUnit)
return InvalidParameter; return InvalidParameter;
if(image->type == ImageTypeMetafile){ if(image->type == ImageTypeMetafile){
@@ -593,6 +654,8 @@ GpStatus WINGDIPAPI GdipGetImageBounds(GpImage *image, GpRectF *srcRect,
GpStatus WINGDIPAPI GdipGetImageDimension(GpImage *image, REAL *width, GpStatus WINGDIPAPI GdipGetImageDimension(GpImage *image, REAL *width,
REAL *height) REAL *height)
{ {
TRACE("%p %p %p\n", image, width, height);
if(!image || !height || !width) if(!image || !height || !width)
return InvalidParameter; return InvalidParameter;
@@ -626,6 +689,8 @@ GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image,
{ {
HDC hdc; HDC hdc;
TRACE("%p %p\n", image, graphics);
if(!image || !graphics) if(!image || !graphics)
return InvalidParameter; return InvalidParameter;
@@ -646,6 +711,8 @@ GpStatus WINGDIPAPI GdipGetImageGraphicsContext(GpImage *image,
GpStatus WINGDIPAPI GdipGetImageHeight(GpImage *image, UINT *height) GpStatus WINGDIPAPI GdipGetImageHeight(GpImage *image, UINT *height)
{ {
TRACE("%p %p\n", image, height);
if(!image || !height) if(!image || !height)
return InvalidParameter; return InvalidParameter;
@@ -680,9 +747,21 @@ GpStatus WINGDIPAPI GdipGetImageHorizontalResolution(GpImage *image, REAL *res)
return NotImplemented; return NotImplemented;
} }
GpStatus WINGDIPAPI GdipGetImagePaletteSize(GpImage *image, INT *size)
{
FIXME("%p %p\n", image, size);
if(!image || !size)
return InvalidParameter;
return NotImplemented;
}
/* FIXME: test this function for non-bitmap types */ /* FIXME: test this function for non-bitmap types */
GpStatus WINGDIPAPI GdipGetImagePixelFormat(GpImage *image, PixelFormat *format) GpStatus WINGDIPAPI GdipGetImagePixelFormat(GpImage *image, PixelFormat *format)
{ {
TRACE("%p %p\n", image, format);
if(!image || !format) if(!image || !format)
return InvalidParameter; return InvalidParameter;
@@ -702,13 +781,24 @@ GpStatus WINGDIPAPI GdipGetImageRawFormat(GpImage *image, GUID *format)
return InvalidParameter; return InvalidParameter;
if(!(calls++)) if(!(calls++))
FIXME("not implemented\n"); FIXME("stub\n");
return NotImplemented; /* FIXME: should be detected from embedded picture or stored separately */
switch (image->type)
{
case ImageTypeBitmap: *format = ImageFormatBMP; break;
case ImageTypeMetafile: *format = ImageFormatEMF; break;
default:
WARN("unknown type %u\n", image->type);
*format = ImageFormatUndefined;
}
return Ok;
} }
GpStatus WINGDIPAPI GdipGetImageType(GpImage *image, ImageType *type) GpStatus WINGDIPAPI GdipGetImageType(GpImage *image, ImageType *type)
{ {
TRACE("%p %p\n", image, type);
if(!image || !type) if(!image || !type)
return InvalidParameter; return InvalidParameter;
@@ -732,6 +822,8 @@ GpStatus WINGDIPAPI GdipGetImageVerticalResolution(GpImage *image, REAL *res)
GpStatus WINGDIPAPI GdipGetImageWidth(GpImage *image, UINT *width) GpStatus WINGDIPAPI GdipGetImageWidth(GpImage *image, UINT *width)
{ {
TRACE("%p %p\n", image, width);
if(!image || !width) if(!image || !width)
return InvalidParameter; return InvalidParameter;
@@ -767,6 +859,48 @@ GpStatus WINGDIPAPI GdipGetMetafileHeaderFromMetafile(GpMetafile * metafile,
return Ok; return Ok;
} }
GpStatus WINGDIPAPI GdipGetAllPropertyItems(GpImage *image, UINT size,
UINT num, PropertyItem* items)
{
static int calls;
if(!(calls++))
FIXME("not implemented\n");
return InvalidParameter;
}
GpStatus WINGDIPAPI GdipGetPropertyCount(GpImage *image, UINT* num)
{
static int calls;
if(!(calls++))
FIXME("not implemented\n");
return InvalidParameter;
}
GpStatus WINGDIPAPI GdipGetPropertyIdList(GpImage *image, UINT num, PROPID* list)
{
static int calls;
if(!(calls++))
FIXME("not implemented\n");
return InvalidParameter;
}
GpStatus WINGDIPAPI GdipGetPropertyItem(GpImage *image, PROPID id, UINT size,
PropertyItem* buffer)
{
static int calls;
if(!(calls++))
FIXME("not implemented\n");
return InvalidParameter;
}
GpStatus WINGDIPAPI GdipGetPropertyItemSize(GpImage *image, PROPID pid, GpStatus WINGDIPAPI GdipGetPropertyItemSize(GpImage *image, PROPID pid,
UINT* size) UINT* size)
{ {
@@ -783,6 +917,16 @@ GpStatus WINGDIPAPI GdipGetPropertyItemSize(GpImage *image, PROPID pid,
return NotImplemented; return NotImplemented;
} }
GpStatus WINGDIPAPI GdipGetPropertySize(GpImage *image, UINT* size, UINT* num)
{
static int calls;
if(!(calls++))
FIXME("not implemented\n");
return InvalidParameter;
}
GpStatus WINGDIPAPI GdipImageGetFrameCount(GpImage *image, GpStatus WINGDIPAPI GdipImageGetFrameCount(GpImage *image,
GDIPCONST GUID* dimensionID, UINT* count) GDIPCONST GUID* dimensionID, UINT* count)
{ {
@@ -844,6 +988,8 @@ GpStatus WINGDIPAPI GdipLoadImageFromFile(GDIPCONST WCHAR* filename,
GpStatus stat; GpStatus stat;
IStream *stream; IStream *stream;
TRACE("(%s) %p\n", debugstr_w(filename), image);
if (!filename || !image) if (!filename || !image)
return InvalidParameter; return InvalidParameter;
@@ -862,6 +1008,8 @@ GpStatus WINGDIPAPI GdipLoadImageFromFile(GDIPCONST WCHAR* filename,
/* FIXME: no icm handling */ /* FIXME: no icm handling */
GpStatus WINGDIPAPI GdipLoadImageFromFileICM(GDIPCONST WCHAR* filename,GpImage **image) GpStatus WINGDIPAPI GdipLoadImageFromFileICM(GDIPCONST WCHAR* filename,GpImage **image)
{ {
TRACE("(%s) %p\n", debugstr_w(filename), image);
return GdipLoadImageFromFile(filename, image); return GdipLoadImageFromFile(filename, image);
} }
@@ -870,6 +1018,8 @@ GpStatus WINGDIPAPI GdipLoadImageFromStream(IStream* stream, GpImage **image)
IPicture *pic; IPicture *pic;
short type; short type;
TRACE("%p %p\n", stream, image);
if(!stream || !image) if(!stream || !image)
return InvalidParameter; return InvalidParameter;
@@ -882,38 +1032,44 @@ GpStatus WINGDIPAPI GdipLoadImageFromStream(IStream* stream, GpImage **image)
IPicture_get_Type(pic, &type); IPicture_get_Type(pic, &type);
if(type == PICTYPE_BITMAP){ if(type == PICTYPE_BITMAP){
BITMAPINFO bmi; BITMAPINFO *pbmi;
BITMAPCOREHEADER* bmch; BITMAPCOREHEADER* bmch;
OLE_HANDLE hbm; HBITMAP hbm;
HDC hdc; HDC hdc;
pbmi = GdipAlloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
if (!pbmi)
return OutOfMemory;
*image = GdipAlloc(sizeof(GpBitmap)); *image = GdipAlloc(sizeof(GpBitmap));
if(!*image) return OutOfMemory; if(!*image){
GdipFree(pbmi);
return OutOfMemory;
}
(*image)->type = ImageTypeBitmap; (*image)->type = ImageTypeBitmap;
(*((GpBitmap**) image))->width = ipicture_pixel_width(pic); (*((GpBitmap**) image))->width = ipicture_pixel_width(pic);
(*((GpBitmap**) image))->height = ipicture_pixel_height(pic); (*((GpBitmap**) image))->height = ipicture_pixel_height(pic);
/* get the pixel format */ /* get the pixel format */
IPicture_get_Handle(pic, &hbm); IPicture_get_Handle(pic, (OLE_HANDLE*)&hbm);
IPicture_get_CurDC(pic, &hdc); IPicture_get_CurDC(pic, &hdc);
ZeroMemory(&bmi, sizeof(bmi)); bmch = (BITMAPCOREHEADER*) (&pbmi->bmiHeader);
bmch = (BITMAPCOREHEADER*) (&bmi.bmiHeader);
bmch->bcSize = sizeof(BITMAPCOREHEADER); bmch->bcSize = sizeof(BITMAPCOREHEADER);
if(!hdc){ if(!hdc){
HBITMAP old; HBITMAP old;
hdc = CreateCompatibleDC(0); hdc = CreateCompatibleDC(0);
old = SelectObject(hdc, (HBITMAP)hbm); old = SelectObject(hdc, hbm);
GetDIBits(hdc, (HBITMAP)hbm, 0, 0, NULL, &bmi, DIB_RGB_COLORS); GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS);
SelectObject(hdc, old); SelectObject(hdc, old);
DeleteDC(hdc); DeleteDC(hdc);
} }
else else
GetDIBits(hdc, (HBITMAP)hbm, 0, 0, NULL, &bmi, DIB_RGB_COLORS); GetDIBits(hdc, hbm, 0, 0, NULL, pbmi, DIB_RGB_COLORS);
(*((GpBitmap**) image))->format = (bmch->bcBitCount << 8) | PixelFormatGDI; (*((GpBitmap**) image))->format = (bmch->bcBitCount << 8) | PixelFormatGDI;
GdipFree(pbmi);
} }
else if(type == PICTYPE_METAFILE || type == PICTYPE_ENHMETAFILE){ else if(type == PICTYPE_METAFILE || type == PICTYPE_ENHMETAFILE){
/* FIXME: missing initialization code */ /* FIXME: missing initialization code */
@@ -936,6 +1092,8 @@ GpStatus WINGDIPAPI GdipLoadImageFromStream(IStream* stream, GpImage **image)
/* FIXME: no ICM */ /* FIXME: no ICM */
GpStatus WINGDIPAPI GdipLoadImageFromStreamICM(IStream* stream, GpImage **image) GpStatus WINGDIPAPI GdipLoadImageFromStreamICM(IStream* stream, GpImage **image)
{ {
TRACE("%p %p\n", stream, image);
return GdipLoadImageFromStream(stream, image); return GdipLoadImageFromStream(stream, image);
} }
@@ -952,6 +1110,16 @@ GpStatus WINGDIPAPI GdipRemovePropertyItem(GpImage *image, PROPID propId)
return NotImplemented; return NotImplemented;
} }
GpStatus WINGDIPAPI GdipSetPropertyItem(GpImage *image, GDIPCONST PropertyItem* item)
{
static int calls;
if(!(calls++))
FIXME("not implemented\n");
return NotImplemented;
}
GpStatus WINGDIPAPI GdipSaveImageToFile(GpImage *image, GDIPCONST WCHAR* filename, GpStatus WINGDIPAPI GdipSaveImageToFile(GpImage *image, GDIPCONST WCHAR* filename,
GDIPCONST CLSID *clsidEncoder, GDIPCONST CLSID *clsidEncoder,
GDIPCONST EncoderParameters *encoderParams) GDIPCONST EncoderParameters *encoderParams)
@@ -959,6 +1127,8 @@ GpStatus WINGDIPAPI GdipSaveImageToFile(GpImage *image, GDIPCONST WCHAR* filenam
GpStatus stat; GpStatus stat;
IStream *stream; IStream *stream;
TRACE("%p (%s) %p %p\n", image, debugstr_w(filename), clsidEncoder, encoderParams);
if (!image || !filename|| !clsidEncoder) if (!image || !filename|| !clsidEncoder)
return InvalidParameter; return InvalidParameter;
@@ -1067,6 +1237,8 @@ GpStatus WINGDIPAPI GdipSaveImageToStream(GpImage *image, IStream* stream,
output = NULL; output = NULL;
output_size = 0; output_size = 0;
TRACE("%p %p %p %p\n", image, stream, clsid, params);
if(!image || !stream) if(!image || !stream)
return InvalidParameter; return InvalidParameter;
@@ -1176,11 +1348,42 @@ static const ImageCodecInfo codecs[NUM_ENCODERS_SUPPORTED] =
}, },
}; };
/*****************************************************************************
* GdipGetImageDecodersSize [GDIPLUS.@]
*/
GpStatus WINGDIPAPI GdipGetImageDecodersSize(UINT *numDecoders, UINT *size)
{
FIXME("%p %p stub!\n", numDecoders, size);
if (!numDecoders || !size)
return InvalidParameter;
*numDecoders = 0;
*size = 0;
return Ok;
}
/*****************************************************************************
* GdipGetImageDecoders [GDIPLUS.@]
*/
GpStatus WINGDIPAPI GdipGetImageDecoders(UINT numDecoders, UINT size, ImageCodecInfo *decoders)
{
FIXME("%u %u %p stub!\n", numDecoders, size, decoders);
if (!decoders)
return GenericError;
return NotImplemented;
}
/***************************************************************************** /*****************************************************************************
* GdipGetImageEncodersSize [GDIPLUS.@] * GdipGetImageEncodersSize [GDIPLUS.@]
*/ */
GpStatus WINGDIPAPI GdipGetImageEncodersSize(UINT *numEncoders, UINT *size) GpStatus WINGDIPAPI GdipGetImageEncodersSize(UINT *numEncoders, UINT *size)
{ {
TRACE("%p %p\n", numEncoders, size);
if (!numEncoders || !size) if (!numEncoders || !size)
return InvalidParameter; return InvalidParameter;
@@ -1195,6 +1398,8 @@ GpStatus WINGDIPAPI GdipGetImageEncodersSize(UINT *numEncoders, UINT *size)
*/ */
GpStatus WINGDIPAPI GdipGetImageEncoders(UINT numEncoders, UINT size, ImageCodecInfo *encoders) GpStatus WINGDIPAPI GdipGetImageEncoders(UINT numEncoders, UINT size, ImageCodecInfo *encoders)
{ {
TRACE("%u %u %p\n", numEncoders, size, encoders);
if (!encoders || if (!encoders ||
(numEncoders != NUM_ENCODERS_SUPPORTED) || (numEncoders != NUM_ENCODERS_SUPPORTED) ||
(size != sizeof (codecs))) (size != sizeof (codecs)))
@@ -1214,6 +1419,8 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
GpStatus retval; GpStatus retval;
PixelFormat format; PixelFormat format;
TRACE("%p %p %p\n", hbm, hpal, bitmap);
if(!hbm || !bitmap) if(!hbm || !bitmap)
return InvalidParameter; return InvalidParameter;
@@ -1240,6 +1447,9 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
case 24: case 24:
format = PixelFormat24bppRGB; format = PixelFormat24bppRGB;
break; break;
case 32:
format = PixelFormat32bppRGB;
break;
case 48: case 48:
format = PixelFormat48bppRGB; format = PixelFormat48bppRGB;
break; break;
@@ -1273,6 +1483,8 @@ GpStatus WINGDIPAPI GdipSetEffectParameters(CGpEffect *effect,
*/ */
GpStatus WINGDIPAPI GdipGetImageFlags(GpImage *image, UINT *flags) GpStatus WINGDIPAPI GdipGetImageFlags(GpImage *image, UINT *flags)
{ {
TRACE("%p %p\n", image, flags);
if(!image || !flags) if(!image || !flags)
return InvalidParameter; return InvalidParameter;
@@ -1280,3 +1492,52 @@ GpStatus WINGDIPAPI GdipGetImageFlags(GpImage *image, UINT *flags)
return Ok; return Ok;
} }
GpStatus WINGDIPAPI GdipTestControl(GpTestControlEnum control, void *param)
{
TRACE("(%d, %p)\n", control, param);
switch(control){
case TestControlForceBilinear:
if(param)
FIXME("TestControlForceBilinear not handled\n");
break;
case TestControlNoICM:
if(param)
FIXME("TestControlNoICM not handled\n");
break;
case TestControlGetBuildNumber:
*((DWORD*)param) = 3102;
break;
}
return Ok;
}
GpStatus WINGDIPAPI GdipRecordMetafileFileName(GDIPCONST WCHAR* fileName,
HDC hdc, EmfType type, GDIPCONST GpRectF *pFrameRect,
MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc,
GpMetafile **metafile)
{
FIXME("%s %p %d %p %d %s %p stub!\n", debugstr_w(fileName), hdc, type, pFrameRect,
frameUnit, debugstr_w(desc), metafile);
return NotImplemented;
}
GpStatus WINGDIPAPI GdipRecordMetafileFileNameI(GDIPCONST WCHAR* fileName, HDC hdc, EmfType type,
GDIPCONST GpRect *pFrameRect, MetafileFrameUnit frameUnit,
GDIPCONST WCHAR *desc, GpMetafile **metafile)
{
FIXME("%s %p %d %p %d %s %p stub!\n", debugstr_w(fileName), hdc, type, pFrameRect,
frameUnit, debugstr_w(desc), metafile);
return NotImplemented;
}
GpStatus WINGDIPAPI GdipImageForceValidation(GpImage *image)
{
FIXME("%p\n", image);
return Ok;
}

Some files were not shown because too many files have changed in this diff Show More