⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 d3dnthal.h

📁 本源码是vc环境下的usb程序
💻 H
📖 第 1 页 / 共 5 页
字号:
{
    DWORD   dwHandle;               // Shader function handle
    DWORD   dwNumVertexElements;    // Number of vertex elements
                                    // D3DVERTEXELEMENT9 VertexElements[] that follow
} D3DNTHAL_DP2CREATEVERTEXSHADERDECL ;
typedef D3DNTHAL_DP2CREATEVERTEXSHADERDECL  *LPD3DNTHAL_DP2CREATEVERTEXSHADERDECL;

typedef struct _D3DNTHAL_DP2CREATEVERTEXSHADERFUNC
{
    DWORD   dwHandle;       // Shader function handle
    DWORD   dwSize;         // Shader function size in bytes
    // Shader declaration follows
} D3DNTHAL_DP2CREATEVERTEXSHADERFUNC ;
typedef D3DNTHAL_DP2CREATEVERTEXSHADERFUNC  *LPD3DNTHAL_DP2CREATEVERTEXSHADERFUNC;

typedef struct _D3DNTHAL_DP2SETSTREAMSOURCE2
{
    DWORD   dwStream;       // Stream index, starting from zero
    DWORD   dwVBHandle;     // Vertex buffer handle
    DWORD   dwOffset;       // Offset of the first vertex size in bytes
    DWORD   dwStride;       // Vertex size in bytes
} D3DNTHAL_DP2SETSTREAMSOURCE2;
typedef D3DNTHAL_DP2SETSTREAMSOURCE2  *LPD3DNTHAL_DP2SETSTREAMSOURCE2;

typedef struct _D3DNTHAL_DP2SETSTREAMSOURCEFREQ
{
    DWORD dwStream;     // Stream index, starting from zero
    DWORD dwDivider;    // Stream source divider
} D3DNTHAL_DP2SETSTREAMSOURCEFREQ;
typedef D3DNTHAL_DP2SETSTREAMSOURCEFREQ *LPD3DNTHAL_DP2SETSTREAMSOURCEFREQ;

typedef RECT D3DNTHAL_DP2SETSCISSORRECT;
typedef D3DNTHAL_DP2SETSCISSORRECT *LPD3DNTHAL_DP2SETSCISSORRECT;

typedef struct _D3DNTHAL_DP2BLT
{
    DWORD   dwSource;         // Source surface
    RECTL   rSource;          // Source rectangle
    DWORD   dwSourceMipLevel; // Miplevel of lightweight surface
    DWORD   dwDest;           // Dest surface
    RECTL   rDest;            // Dest rectangle
    DWORD   dwDestMipLevel;   // Miplevel of lightweight surface
    DWORD   Flags;            // Can be DP2BLT_POINT, DP2BLT_LINEAR
} D3DNTHAL_DP2BLT;
typedef D3DNTHAL_DP2BLT  *LPD3DNTHAL_DP2BLT;

#define DP2BLT_POINT    0x00000001L
#define DP2BLT_LINEAR   0x00000002L

typedef struct _D3DNTHAL_DP2COLORFILL
{
    DWORD       dwSurface;  // Surface getting filled
    RECTL       rRect;      // Surface dimensions to fill
    D3DCOLOR    Color;      // A8R8G8B8 fill color
} D3DNTHAL_DP2COLORFILL;
typedef D3DNTHAL_DP2COLORFILL  *LPD3DNTHAL_DP2COLORFILL;

typedef struct _D3DNTHAL_DP2SURFACEBLT
{
    DWORD   dwSource;         // Source surface
    RECTL   rSource;          // Source rectangle
    DWORD   dwSourceMipLevel; // Miplevel of lightweight surface
    DWORD   dwDest;           // Dest surface
    RECTL   rDest;            // Dest rectangle
    DWORD   dwDestMipLevel;   // Miplevel of lightweight surface
    DWORD   Flags;            // No flags currently defined
} D3DNTHAL_DP2SURFACEBLT;
typedef D3DNTHAL_DP2SURFACEBLT  *LPD3DNTHAL_DP2SURFACEBLT;

typedef D3DNTHAL_DP2SETVERTEXSHADERCONST D3DNTHAL_DP2SETVERTEXSHADERCONSTB;
typedef D3DNTHAL_DP2SETVERTEXSHADERCONSTB  *LPD3DNTHAL_DP2SETVERTEXSHADERCONSTB; 
typedef D3DNTHAL_DP2SETVERTEXSHADERCONST D3DNTHAL_DP2SETVERTEXSHADERCONSTI;
typedef D3DNTHAL_DP2SETVERTEXSHADERCONSTI  *LPD3DNTHAL_DP2SETVERTEXSHADERCONSTI; 

typedef D3DNTHAL_DP2SETPIXELSHADERCONST D3DNTHAL_DP2SETPIXELSHADERCONSTB;
typedef D3DNTHAL_DP2SETPIXELSHADERCONSTB  *LPD3DNTHAL_DP2SETPIXELSHADERCONSTB; 
typedef D3DNTHAL_DP2SETPIXELSHADERCONST D3DNTHAL_DP2SETPIXELSHADERCONSTI;
typedef D3DNTHAL_DP2SETPIXELSHADERCONSTI  *LPD3DNTHAL_DP2SETPIXELSHADERCONSTI; 

typedef struct _D3DNTHAL_DP2CREATEQUERY
{
    DWORD           dwQueryID;
    D3DQUERYTYPE    QueryType;
} D3DNTHAL_DP2CREATEQUERY;
typedef D3DNTHAL_DP2CREATEQUERY  *LPD3DNTHAL_DP2CREATEQUERY;

typedef struct _D3DNTHAL_DP2DELETEQUERY
{
    DWORD   dwQueryID;
} D3DNTHAL_DP2DELETEQUERY;
typedef D3DNTHAL_DP2DELETEQUERY  *LPD3DNTHAL_DP2DELETEQUERY;

typedef struct _D3DNTHAL_DP2ISSUEQUERY
{
    DWORD   dwQueryID;
    DWORD   dwFlags;
} D3DNTHAL_DP2ISSUEQUERY;
typedef D3DNTHAL_DP2ISSUEQUERY  *LPD3DNTHAL_DP2ISSUEQUERY;

typedef struct _D3DNTHAL_DP2SETRENDERTARGET2
{
    DWORD   RTIndex;
    DWORD   hRenderTarget;
} D3DNTHAL_DP2SETRENDERTARGET2;
typedef D3DNTHAL_DP2SETRENDERTARGET2  *LPD3DNTHAL_DP2SETRENDERTARGET2;

typedef struct _D3DNTHAL_DP2SETDEPTHSTENCIL
{
    DWORD   hZBuffer;
} D3DNTHAL_DP2SETDEPTHSTENCIL;
typedef D3DNTHAL_DP2SETDEPTHSTENCIL  *LPD3DNTHAL_DP2SETDEPTHSTENCIL;

typedef struct _D3DNTHAL_DP2GENERATEMIPSUBLEVELS
{
    DWORD                   hSurface;
    D3DTEXTUREFILTERTYPE    Filter;
} D3DNTHAL_DP2GENERATEMIPSUBLEVELS;
typedef D3DNTHAL_DP2GENERATEMIPSUBLEVELS *LPD3DNTHAL_DP2GENERATEMIPSUBLEVELS;

#define DDBLT_EXTENDED_PRESENTATION_STRETCHFACTOR   0x00000010l /* old DDBLT_ALPHAEDGEBLEND */
//
// Command structure for driver responses:
//

typedef struct _D3DNTHAL_DP2RESPONSE
{
    BYTE    bCommand;       // response/ command id
    BYTE    bReserved;
    WORD    wStateCount;    // count of responses to follow
    DWORD   dwTotalSize;    // total size of response (including the DP2REPONSE struct) to enable skipping over.
} D3DNTHAL_DP2RESPONSE, *LPD3DNTHAL_DP2RESPONSE;

// Begin Responses
typedef struct _D3DNTHAL_DP2RESPONSEQUERY
{
    DWORD   dwQueryID;
    DWORD   dwSize;
} D3DNTHAL_DP2RESPONSEQUERY;
typedef D3DNTHAL_DP2RESPONSEQUERY  *LPD3DNTHAL_DP2RESPONSEQUERY;
// End Responses

#endif // (DIRECT3D_VERSION >= 0x0900 )


// Macros to access shader binary code

#define _NT_D3DSI_GETREGNUM(token)      (token & D3DSP_REGNUM_MASK)
#define _NT_D3DSI_GETOPCODE(command)    (command & D3DSI_OPCODE_MASK)
#define _NT_D3DSI_GETWRITEMASK(token)   (token & D3DSP_WRITEMASK_ALL)
#define _NT_D3DVS_GETSWIZZLECOMP(source, component) \
                                        (source >> ((component << 1) + 16) & 0x3)
#define _NT_D3DVS_GETSWIZZLE(token)     (token & D3DVS_SWIZZLE_MASK)
#define _NT_D3DVS_GETSRCMODIFIER(token) (token & D3DSP_SRCMOD_MASK)
#define _NT_D3DVS_GETADDRESSMODE(token) (token & D3DVS_ADDRESSMODE_MASK)

#if(DIRECT3D_VERSION < 0x0900)

#define _NT_D3DSI_GETREGTYPE(token)     ((D3DSHADER_PARAM_REGISTER_TYPE)(token & D3DSP_REGTYPE_MASK))

#else

#define _NT_D3DSI_GETREGTYPE(token)     ((D3DSHADER_PARAM_REGISTER_TYPE)(((token & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT) | \
                                                                         ((token & D3DSP_REGTYPE_MASK2) >> D3DSP_REGTYPE_SHIFT2)))
#define _NT_D3DSI_GETUSAGE(token) ((token & D3DSP_DCL_USAGE_MASK) >> D3DSP_DCL_USAGE_SHIFT)
#define _NT_D3DSI_GETUSAGEINDEX(token) ((token & D3DSP_DCL_USAGEINDEX_MASK) >> D3DSP_DCL_USAGEINDEX_SHIFT)
#define _NT_D3DSI_GETINSTLENGTH(token)  ((token & D3DSI_INSTLENGTH_MASK) >> D3DSI_INSTLENGTH_SHIFT)
#define _NT_D3DSI_GETCOMPARISON(token)  ((D3DSHADER_COMPARISON)((token & D3DSHADER_COMPARISON_MASK) >> D3DSHADER_COMPARISON_SHIFT))
#define _NT_D3DSI_GETREGISTERPROPERTIES(token) (token & D3DSP_REGISTERPROPERTIES_MASK)
#define _NT_D3DSI_GETTEXTURETYPE(token) (token & D3DSP_TEXTURETYPE_MASK)
#define _NT_D3DSI_GETDSTMODIFIER(token) (token & D3DSP_DSTMOD_MASK))
#define _NT_D3DSI_GETSWIZZLECOMP(source, component)  (source >> ((component << 1) + 16) & 0x3)
#define _NT_D3DSI_GETSWIZZLE(token)  (token & D3DVS_SWIZZLE_MASK)
#define _NT_D3DSI_GETSRCMODIFIER(token) (token & D3DSP_SRCMOD_MASK)
#define _NT_D3DSI_GETADDRESSMODE(token) (token & D3DVS_ADDRESSMODE_MASK)

#ifdef __cplusplus
// This gets regtype, and also maps D3DSPR_CONSTn to D3DSPR_CONST (for easier parsing)
inline 
D3DSHADER_PARAM_REGISTER_TYPE 
_NT_D3DSI_GETREGTYPE_RESOLVING_CONSTANTS(
    DWORD   token) 
{
    D3DSHADER_PARAM_REGISTER_TYPE RegType = _NT_D3DSI_GETREGTYPE(token);
    switch (RegType)
    {
        case D3DSPR_CONST4:
        case D3DSPR_CONST3:
        case D3DSPR_CONST2:
            return D3DSPR_CONST;
        default:
            return RegType;
    }
}

// The inline function below retrieves register number for an opcode, 
// taking into account that: if the type is a 
// D3DSPR_CONSTn, the register number needs to be remapped.
//
//           D3DSPR_CONST  is for c0-c2047
//           D3DSPR_CONST2 is for c2048-c4095
//           D3DSPR_CONST3 is for c4096-c6143
//           D3DSPR_CONST4 is for c6144-c8191
//
// For example if the instruction token specifies type D3DSPR_CONST4, reg# 3,
// the register number retrieved is 6147.
// For other register types, the register number is just returned unchanged.
inline 
UINT 
_NT_D3DSI_GETREGNUM_RESOLVING_CONSTANTS(
    DWORD   token) 
{
    D3DSHADER_PARAM_REGISTER_TYPE RegType = _NT_D3DSI_GETREGTYPE(token);
    UINT RegNum = _NT_D3DSI_GETREGNUM(token);

    switch(RegType)
    {
        case D3DSPR_CONST4:
            return RegNum + 6144;
        case D3DSPR_CONST3:
            return RegNum + 4096;
        case D3DSPR_CONST2:
            return RegNum + 2048;
        default:
            return RegNum;
    }
}
#endif // __cplusplus

#endif

//-----------------------------------------------------------------------------
//
// DirectX 8.0's new driver info querying mechanism.
//
// How to handle the new driver info query mechanism.
//
// DirectX 8.0 utilizes an extension to GetDriverInfo() to query for
// additional information from the driver. Currently this mechanism is only
// used for querying for DX8 style D3D caps but it may be used for other
// information over time.
//
// This extension to GetDriverInfo takes the form of a GetDriverInfo call
// with the GUID GUID_GetDriverInfo2. When a GetDriverInfo call with this
// GUID is received by the driver the driver must check the data passed
// in the lpvData field of the DD_GETDRIVERINFODATA data structure to see
// what information is being requested.
//
// It is important to note that the GUID GUID_GetDriverInfo2 is, in fact,
// the same as the GUID_DDStereoMode. If you driver doesn't handle
// GUID_DDStereoMode this is not an issue. However, if you wish your driver
// to handle GUID_DDStereoMode as well as GUID_GetDriverInfo2 special action
// must be taken. When a call tp GetDriverInfo with the GUID
// GUID_GetDriverInfo2/GUID_DDStereoMode is made the runtime sets the
// dwHeight field of the DD_STEREOMODE structure to the special value
// D3DGDI2_MAGIC. In this way you can determine when the request is a
// stereo mode call or a GetDriverInfo2 call. The dwHeight field of
// DD_STEREOMODE corresponds to the dwMagic field of the
// DD_GETDRIVERINFO2DATA structure.
//
// The dwExpectedSize field of the DD_GETDRIVERINFODATA structure is not
// used by when a GetDriverInfo2 request is being made and should be
// ignored. The actual expected size of the data is found in the
// dwExpectedSize of the DD_GETDRIVERINFO2DATA structure.
//
// Once the driver has determined that this is a call to
// GetDriverInfo2 it must then determine the type of information being
// requested by the runtime. This type is contained in the dwType field
// of the DD_GETDRIVERINFO2DATA data structure.
//
// Finally, once the driver knows this is a GetDriverInfo2 request of a
// particular type it can copy the requested data into the data buffer.
// It is important to note that the lpvData field of the DD_GETDRIVERINFODATA
// data structure points to data buffer in which to copy your data. lpvData
// also points to the DD_GETDRIVERINFO2DATA structure. This means that the
// data returned by the driver will overwrite the DD_GETDRIVERINFO2DATA
// structure and, hence, the DD_GETDRIVERINFO2DATA structure occupies the
// first few DWORDs of the buffer.
//
// The following code fragment demonstrates how to handle GetDriverInfo2.
//
// D3DCAPS8 myD3DCaps8;
//
// DWORD CALLBACK
// DdGetDriverInfo(LPDDHAL_GETDRIVERINFODATA lpData)
// {
//     if (MATCH_GUID((lpData->guidInfo), GUID_GetDriverInfo2) )
//     {
//         ASSERT(NULL != lpData);
//         ASSERT(NULL != lpData->lpvData);
//
//         // Is this a call to GetDriverInfo2 or DDStereoMode?
//         if (((DD_GETDRIVERINFO2DATA*)(lpData->lpvData))->dwMagic == D3DGDI2_MAGIC)
//         {
//             // Yes, its a call to GetDriverInfo2, fetch the
//             // DD_GETDRIVERINFO2DATA data structure.
//             DD_GETDRIVERINFO2DATA* pgdi2 = lpData->lpvData;
//             ASSERT(NULL != pgdi2);
//
//             // What type of request is this?
//             switch (pgdi2->dwType)
//             {
//             case D3DGDI2_TYPE_GETD3DCAPS8:
//                 {
//                     // The runtime is requesting the DX8 D3D caps so
//                     // copy them over now.
//
//                     // It should be noted that the dwExpectedSize field
//                     // of DD_GETDRIVERINFODATA is not used for
//                     // GetDriverInfo2 calls and should be ignored.
//                     size_t copySize = min(sizeof(myD3DCaps8), pgdi2->dwExpectedSize);
//                     memcpy(lpData->lpvData, &myD3DCaps8, copySize);
//                     lpData->dwActualSize = copySize;
//                     lpData->ddRVal       = DD_OK;
//                     return DDHAL_DRIVER_HANDLED;
//                 }
//             default:
//                 // For any other GetDriverInfo2 types not handled
//                 // or understood by the driver set an ddRVal of
//                 // DDERR_CURRENTLYNOTAVAIL and return
//                 // DDHAL_DRIVER_HANDLED.
//                 lpData->dwActualSize = 0;
//                 lpData->ddRVal       = DDERR_CURRENTLYNOTAVAIL;
//                 return DDHAL_DRIVER_HANDLED;
//             }
//         }
//         else
//         {
//             // It must be

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -