ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

d3d.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:        See COPYING in the top level directory
00003  * PROJECT:          ReactOS kernel
00004  * PURPOSE:          Native DirectDraw implementation
00005  * FILE:             subsystems/win32/win32k/ntddraw/d3d.c
00006  * PROGRAMER:        Magnus olsen (magnus@greatlord.com)
00007  * REVISION HISTORY:
00008  *       19/1-2006   Magnus Olsen
00009  */
00010 
00011 /* Comment 
00012  *   NtGdiDdLock and NtGdiDdLockD3D ultimately call the same function in dxg.sys 
00013  *   NtGdiDdUnlock and NtGdiDdUnlockD3D ultimately call the same function in dxg.sys 
00014  */
00015 
00016 #include <win32k.h>
00017 #include <debug.h>
00018 
00019 
00020 /*++
00021 * @name NtGdiDdCanCreateD3DBuffer
00022 * @implemented
00023 *
00024 * The function NtGdiDdCanCreateD3DBuffer checks if you can create a 
00025 * surface for DirectX. it redirects to dxg.sys in windows XP/2003, 
00026 * dxkrnl.sys in vista and is fully implemented in win32k.sys in windows 2000 and below
00027 *
00028 * @param HANDLE hDirectDraw
00029 * The handle we got from NtGdiDdCreateDirectDrawObject
00030 *
00031 * @param PDD_CANCREATESURFACEDATA puCanCreateSurfaceData
00032 * This contains information to check if the driver can create the buffers,
00033 * surfaces, textures and vertexes, and how many of each the driver can create.
00034 
00035 *
00036 * @return 
00037 * Depending on if the driver supports this function or not, DDHAL_DRIVER_HANDLED 
00038 * or DDHAL_DRIVER_NOTHANDLED is returned.
00039 * To check if the function has been successful, do a full check. 
00040 * A full check is done by checking if the return value is DDHAL_DRIVER_HANDLED 
00041 * and puCanCreateSurfaceData->ddRVal is set to DD_OK.
00042 *
00043 * @remarks.
00044 * dxg.sys NtGdiDdCanCreateD3DBuffer and NtGdiDdCanCreateSurface calls are redirected to dxg.sys.
00045 * Inside the dxg.sys they are redirected to the same function. Examine the memory addresses on the driver list functions
00046 * table and you will see they are pointed to the same memory address.
00047 *
00048 * Before calling this function please set the puCanCreateSurfaceData->ddRVal to an error value such as DDERR_NOTUSPORTED,
00049 * for the ddRVal will otherwise be unchanged even if an error occurs inside the driver. 
00050 * puCanCreateSurfaceData->lpDD  is a pointer to DDRAWI_DIRECTDRAW_GBL, not PDD_DIRECTDRAW_GLOBAL as MSDN claims.
00051 * puCanCreateSurfaceData->lpDD->hDD also needs be filled in with the handle we got from NtGdiDdCreateDirectDrawObject.
00052 * puCreateSurfaceData->CanCreateSurface is a pointer to the real functions in the HAL or HEL, that you need fill in.
00053 * Do not forget PDD_CANCREATESURFACEDATA is typecast of LPDDHAL_CANCREATESURFACEDATA and thuse two struct are different size,
00054 * the correct struct is LPDDHAL_CANCREATESURFACEDATA.
00055 *
00056 *--*/
00057 
00058 DWORD
00059 APIENTRY
00060 NtGdiDdCanCreateD3DBuffer(HANDLE hDirectDraw,
00061                           PDD_CANCREATESURFACEDATA puCanCreateSurfaceData)
00062 {
00063     PGD_DDCANCREATED3DBUFFER pfnDdCanCreateD3DBuffer = (PGD_DDCANCREATED3DBUFFER)gpDxFuncs[DXG_INDEX_DxDdCanCreateD3DBuffer].pfn;
00064 
00065     if (pfnDdCanCreateD3DBuffer == NULL)
00066     {
00067         DPRINT1("Warring no pfnDdCanCreateD3DBuffer");
00068         return DDHAL_DRIVER_NOTHANDLED;
00069     }
00070 
00071     DPRINT1("Calling on dxg.sys DdCanCreateD3DBuffer");
00072     return pfnDdCanCreateD3DBuffer(hDirectDraw,puCanCreateSurfaceData);
00073 }
00074 
00075 /*++
00076 * @name NtGdiD3dContextCreate
00077 * @implemented
00078 *
00079 * The Function NtGdiD3dContextCreate checks if you can create a 
00080 * context for Directx. It redirects to dxg.sys in windows XP/2003, 
00081 * dxkrnl.sys in vista and is fully implemented in win32k.sys in windows 2000 and below
00082 *
00083 * @param HANDLE hDirectDrawLocal
00084 * The handle we got from NtGdiDdCreateDirectDrawObject
00085 *
00086 * @param HANDLE hSurfColor
00087 * Handle to DD_SURFACE_LOCAL to be used for the rendering target
00088 *
00089 * @param HANDLE hSurfZ
00090 * Handle to a DD_SURFACE_LOCAL. It is the Z deep buffer. According MSDN if it is set to NULL nothing should happen.
00091 *
00092 * @param LPD3DNTHAL_CONTEXTCREATEDATA pdcci
00093 * The buffer to create the context data
00094 *
00095 * @return 
00096 * DDHAL_DRIVER_HANDLED or DDHAL_DRIVER_NOTHANDLED if the driver supports this function.
00097 * A full check is done by checking if the return value is DDHAL_DRIVER_HANDLED 
00098 * and pdcci->ddRVal is set to DD_OK.
00099 *
00100 *
00101 * @remarks.
00102 * dxg.sys NtGdiD3dContextCreate calls are redirected to the same function in the dxg.sys. As such they all work the same way.
00103 *
00104 * Before calling this function please set the pdcci->ddRVal to an error value such as DDERR_NOTSUPORTED,
00105 * for the ddRVal will otherwise be unchanged even if an error occurs inside the driver. 
00106 *
00107 * pdcci->lpDDLcl is a pointer to DDRAWI_DIRECTDRAW_LCL, not DD_DIRECTDRAW_LOCAL  as MSDN claims.
00108 * pdcci->lpDDSLcl is a pointer to DDRAWI_DDRAWSURFACE_LCL, not DD_DDDRAWSURFACE_LOCAL as MSDN claims.
00109 * pdcci->lpDDSZLcl is a pointer to DDRAWI_DDRAWSURFACE_LCL, not DD_DDRAWSURFACE_LOCAL as MSDN claims.
00110 * pdcci->dwhContext also needs be filled in with the handle we receive from NtGdiDdCreateDirectDrawObject.
00111 * pdcci->dwPID the processid it belong to, that you need to fill in.
00112 * Do not forget LPD3DNTHAL_CONTEXTCREATEDATA is typecast of LPD3DHAL_CONTEXTCREATEDATA and thuse two struct are different size,
00113 * the correct struct is LPD3DHAL_CONTEXTCREATEDATA.
00114 *--*/
00115 BOOL 
00116 APIENTRY
00117 NtGdiD3dContextCreate(HANDLE hDirectDrawLocal,
00118                       HANDLE hSurfColor,
00119                       HANDLE hSurfZ,
00120                       LPD3DNTHAL_CONTEXTCREATEDATA pdcci)
00121 {
00122     PGD_D3DCONTEXTCREATE pfnD3dContextCreate = (PGD_D3DCONTEXTCREATE)gpDxFuncs[DXG_INDEX_DxD3dContextCreate].pfn;
00123 
00124     if (pfnD3dContextCreate == NULL)
00125     {
00126         DPRINT1("Warning: no pfnD3dContextCreate");
00127         return FALSE;
00128     }
00129 
00130     DPRINT1("Calling dxg.sys D3dContextCreate");
00131     return pfnD3dContextCreate(hDirectDrawLocal, hSurfColor, hSurfZ, pdcci);
00132 }
00133 
00134 /*++
00135 * @name NtGdiD3dContextDestroy
00136 * @implemented
00137 *
00138 * The Function NtGdiD3dContextDestroy destorys the context data we got from NtGdiD3dContextCreate
00139 * It redirects to dxg.sys in windows XP/2003,  dxkrnl.sys in vista and is fully implemented 
00140 * in win32k.sys in windows 2000 and below
00141 *
00142 * @param LPD3DNTHAL_CONTEXTDESTROYDATA pContextDestroyData
00143 * The context data we want to destroy
00144 *
00145 * @remarks.
00146 * dxg.sys NtGdiD3dContextDestroy calls are redirected to the same functions in the dxg.sys. As such they all work the same way.
00147 *
00148 * Before calling this function please set the pContextDestroyData->ddRVal to an error value such DDERR_NOTUSPORTED,
00149 * for the ddRVal will otherwise be unchanged even if an error occurs inside the driver. 
00150 * pContextDestroyData->dwhContext also needs to be filled in with the handle we got from NtGdiDdCreateDirectDrawObject
00151 *
00152 *--*/
00153 DWORD
00154 APIENTRY
00155 NtGdiD3dContextDestroy(LPD3DNTHAL_CONTEXTDESTROYDATA pContextDestroyData)
00156 {
00157     PGD_D3DCONTEXTDESTROY pfnD3dContextDestroy = (PGD_D3DCONTEXTDESTROY)gpDxFuncs[DXG_INDEX_DxD3dContextDestroy].pfn;
00158 
00159     if ( pfnD3dContextDestroy == NULL)
00160     {
00161         DPRINT1("Warning: no pfnD3dContextDestroy");
00162         return DDHAL_DRIVER_NOTHANDLED;
00163     }
00164 
00165     DPRINT1("Calling dxg.sys D3dContextDestroy");
00166     return pfnD3dContextDestroy(pContextDestroyData);
00167 }
00168 
00169 /*++
00170 * @name NtGdiD3dContextDestroyAll
00171 * @implemented
00172 *
00173 * The Function NtGdiD3dContextDestroyAll destroys all the context data in a process
00174 * The data having been allocated with NtGdiD3dContextCreate
00175 * It redirects to dxg.sys in windows XP/2003,  dxkrnl.sys in vista and is fully implemented 
00176 * in win32k.sys in windows 2000 and below
00177 *
00178 * @param LPD3DNTHAL_CONTEXTDESTROYALLDATA pdcad
00179 * The context data we want to destory
00180 *
00181 * @remarks.
00182 * dxg.sys NtGdiD3dContextDestroy calls are redirected to the same function in the dxg.sys. As such they all work the same way.
00183 *
00184 * Before calling this function please set the pdcad->ddRVal to an error value such as DDERR_NOTUSPORTED,
00185 * for the ddRVal will otherwise be unchanged even if an error occurs inside the driver. 
00186 * pdcad->dwPID also needs to be filled in with the ID of the process that needs its context data destroyed.
00187 *
00188 * Warning: MSDN is wrong about this function. It claims the function queries free memory and does not accept
00189 * any parameters. Last time MSDN checked: 19/10-2007
00190 *--*/
00191 DWORD
00192 APIENTRY
00193 NtGdiD3dContextDestroyAll(LPD3DNTHAL_CONTEXTDESTROYALLDATA pdcad)
00194 {
00195     PGD_D3DCONTEXTDESTROYALL pfnD3dContextDestroyAll = (PGD_D3DCONTEXTDESTROYALL)gpDxFuncs[DXG_INDEX_DxD3dContextDestroyAll].pfn;
00196 
00197     if (pfnD3dContextDestroyAll == NULL)
00198     {
00199         DPRINT1("Warning: no pfnD3dContextDestroyAll");
00200         return DDHAL_DRIVER_NOTHANDLED;
00201     }
00202 
00203     DPRINT1("Calling dxg.sys D3dContextDestroyAll");
00204     return pfnD3dContextDestroyAll(pdcad);
00205 }
00206 
00207 /*++
00208 * @name NtGdiDdCreateD3DBuffer
00209 * @implemented
00210 *
00211 * The function NtGdiDdCreateD3DBuffer creates a surface for DirectX. 
00212 * It redirects to dxg.sys in windows XP/2003,  dxkrnl.sys in vista and is fully implemented 
00213 * in win32k.sys in windows 2000 and below
00214 *
00215 * @param HANDLE hDirectDraw
00216 * The handle we got from NtGdiDdCreateDirectDrawObject
00217 *
00218 * @param  HANDLE *hSurface
00219 * <FILLMEIN>
00220 *
00221 * @param DDSURFACEDESC puSurfaceDescription
00222 * Surface description: what kind of surface it should be. Examples: RGB, compress, deep, and etc
00223 * See DDSURFACEDESC for more information
00224 *
00225 * @param DD_SURFACE_GLOBAL *puSurfaceGlobalData
00226 * <FILLMEIN>
00227 *
00228 * @param DD_SURFACE_LOCAL *puSurfaceLocalData
00229 * <FILLMEIN>
00230 *
00231 * @param DD_SURFACE_MORE *puSurfaceMoreData
00232 * <FILLMEIN>
00233 *
00234 * @param PDD_CREATESURFACEDATA puCreateSurfaceData
00235 * <FILLMEIN>
00236 *
00237 * @param HANDLE *puhSurface
00238 * <FILLMEIN>
00239 *
00240 * @return 
00241 * Depending on if the driver supports this function or not, DDHAL_DRIVER_HANDLED 
00242 * or DDHAL_DRIVER_NOTHANDLED is returned.
00243 * To check if the function was successful, do a full check. 
00244 * A full check is done by checking if the return value is DDHAL_DRIVER_HANDLED 
00245 * and puCanCreateSurfaceData->ddRVal is set to DD_OK.
00246 *
00247 * @remarks.
00248 * dxg.sys NtGdiDdCreateD3DBuffer and NtGdiDdCreateSurface calls are redirected to dxg.sys.
00249 * Inside the dxg.sys they are redirected to the same function. Examine the memory addresses on the driver list functions
00250 * table and you will see they are pointed to the same memory address.
00251 *
00252 * Before calling this function please set the puCreateSurfaceData->ddRVal to an error value such as DDERR_NOTUSPORTED,
00253 * for the ddRVal will otherwise be unchanged even if an error occurs inside the driver. 
00254 * puCreateSurfaceData->lpDD  is a pointer to DDRAWI_DIRECTDRAW_GBL. MSDN claims it is PDD_DIRECTDRAW_GLOBAL but it is not.
00255 * puCreateSurfaceData->lpDD->hDD also needs to be filled in with the handle we got from NtGdiDdCreateDirectDrawObject
00256 * puCreateSurfaceData->CreateSurface is a pointer to the real functions in the HAL or HEL, that you need fill in
00257 *
00258 *--*/
00259 DWORD
00260 APIENTRY
00261 NtGdiDdCreateD3DBuffer(HANDLE hDirectDraw,
00262                        HANDLE *hSurface,
00263                        DDSURFACEDESC *puSurfaceDescription,
00264                        DD_SURFACE_GLOBAL *puSurfaceGlobalData,
00265                        DD_SURFACE_LOCAL *puSurfaceLocalData,
00266                        DD_SURFACE_MORE *puSurfaceMoreData,
00267                        PDD_CREATESURFACEDATA puCreateSurfaceData,
00268                        HANDLE *puhSurface)
00269 {
00270     PGD_DDCREATED3DBUFFER pfnDdCreateD3DBuffer = (PGD_DDCREATED3DBUFFER)gpDxFuncs[DXG_INDEX_DxDdCreateD3DBuffer].pfn;
00271 
00272     if (pfnDdCreateD3DBuffer == NULL)
00273     {
00274         DPRINT1("Warning: no pfnDdCreateD3DBuffer");
00275         return DDHAL_DRIVER_NOTHANDLED;
00276     }
00277 
00278     DPRINT1("Calling dxg.sys DdCreateD3DBuffer");
00279     return pfnDdCreateD3DBuffer(hDirectDraw, hSurface,
00280                                 puSurfaceDescription, puSurfaceGlobalData,
00281                                 puSurfaceLocalData, puSurfaceMoreData,
00282                                 puCreateSurfaceData, puhSurface);
00283 }
00284 
00285 /************************************************************************/
00286 /* NtGdiDdDestroyD3DBuffer                                              */
00287 /************************************************************************/
00288 DWORD
00289 APIENTRY
00290 NtGdiDdDestroyD3DBuffer(HANDLE hSurface)
00291 {
00292     PGD_DXDDDESTROYD3DBUFFER pfnDdDestroyD3DBuffer = (PGD_DXDDDESTROYD3DBUFFER)gpDxFuncs[DXG_INDEX_DxDdDestroyD3DBuffer].pfn;  
00293     
00294     if (pfnDdDestroyD3DBuffer == NULL)
00295     {
00296         DPRINT1("Warning: no pfnDdDestroyD3DBuffer");
00297         return DDHAL_DRIVER_NOTHANDLED;
00298     }
00299 
00300     DPRINT1("Calling dxg.sys pfnDdDestroyD3DBuffer");
00301     return pfnDdDestroyD3DBuffer(hSurface);
00302 }
00303 
00304 /************************************************************************/
00305 /* NtGdiD3dDrawPrimitives2                                              */
00306 /************************************************************************/
00307 DWORD
00308 APIENTRY
00309 NtGdiD3dDrawPrimitives2(HANDLE hCmdBuf,
00310                         HANDLE hVBuf,
00311                         LPD3DNTHAL_DRAWPRIMITIVES2DATA pded,
00312                         FLATPTR *pfpVidMemCmd,
00313                         DWORD *pdwSizeCmd,
00314                         FLATPTR *pfpVidMemVtx,
00315                         DWORD *pdwSizeVtx)
00316 {
00317     PGD_D3DDRAWPRIMITIVES2 pfnD3dDrawPrimitives2  = (PGD_D3DDRAWPRIMITIVES2)gpDxFuncs[DXG_INDEX_DxD3dDrawPrimitives2].pfn;  
00318     
00319     if (pfnD3dDrawPrimitives2 == NULL)
00320     {
00321         DPRINT1("Warning: no pfnD3dDrawPrimitives2");
00322         return DDHAL_DRIVER_NOTHANDLED;
00323     }
00324 
00325     DPRINT1("Calling dxg.sys D3dDrawPrimitives2");
00326     return pfnD3dDrawPrimitives2(hCmdBuf,hVBuf,pded,pfpVidMemCmd,pdwSizeCmd,pfpVidMemVtx,pdwSizeVtx);
00327 }
00328 
00329 
00330 /************************************************************************/
00331 /* NtGdiD3dValidateTextureStageState                                    */
00332 /************************************************************************/
00333 DWORD
00334 APIENTRY
00335 NtGdiDdLockD3D(HANDLE hSurface,
00336                PDD_LOCKDATA puLockData)
00337 {
00338     PGD_DXDDLOCKD3D pfnDdLockD3D  = (PGD_DXDDLOCKD3D)gpDxFuncs[DXG_INDEX_DxDdLockD3D].pfn;  
00339     
00340     if (pfnDdLockD3D == NULL)
00341     {
00342         DPRINT1("Warning: no pfnDdLockD3D");
00343         return DDHAL_DRIVER_NOTHANDLED;
00344     }
00345 
00346     DPRINT1("Calling dxg.sys pfnDdLockD3D");
00347     return pfnDdLockD3D(hSurface, puLockData);
00348 }
00349 
00350 /************************************************************************/
00351 /* NtGdiD3dValidateTextureStageState                                    */
00352 /************************************************************************/
00353 DWORD
00354 APIENTRY
00355 NtGdiD3dValidateTextureStageState(LPD3DNTHAL_VALIDATETEXTURESTAGESTATEDATA pData)
00356 {
00357     PGD_D3DVALIDATETEXTURESTAGESTATE pfnD3dValidateTextureStageState = (PGD_D3DVALIDATETEXTURESTAGESTATE)gpDxFuncs[DXG_INDEX_DxD3dValidateTextureStageState].pfn;  
00358    
00359     if (pfnD3dValidateTextureStageState == NULL)
00360     {
00361         DPRINT1("Warning: no pfnD3dValidateTextureStageState");
00362         return DDHAL_DRIVER_NOTHANDLED;
00363     }
00364 
00365     DPRINT1("Calling dxg.sys D3dValidateTextureStageState");
00366     return pfnD3dValidateTextureStageState(pData);
00367 }
00368 
00369 /************************************************************************/
00370 /* NtGdiDdUnlockD3D                                                     */
00371 /************************************************************************/
00372 DWORD
00373 APIENTRY
00374 NtGdiDdUnlockD3D(HANDLE hSurface,
00375                  PDD_UNLOCKDATA puUnlockData)
00376 {
00377     PGD_DXDDUNLOCKD3D pfnDdUnlockD3D = (PGD_DXDDUNLOCKD3D)gpDxFuncs[DXG_INDEX_DxDdUnlockD3D].pfn;
00378    
00379     if (pfnDdUnlockD3D == NULL)
00380     {
00381         DPRINT1("Warning: no pfnDdUnlockD3D");
00382         return DDHAL_DRIVER_NOTHANDLED;
00383     }
00384 
00385     DPRINT1("Calling dxg.sys pfnDdUnlockD3D");
00386     return pfnDdUnlockD3D(hSurface, puUnlockData);
00387 
00388 }
00389 
00390 
00391 
00392 

Generated on Sun May 27 2012 04:38:29 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.