summaryrefslogtreecommitdiff
path: root/video/archive/pixlib/pixel.cpp
blob: a1599e63bf08a4cb2c9afde2d99f1f34dbf1b603 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
/*==========================================================================;
 *
 *  Copyright (C) 1999-2002 Microsoft Corporation.  All Rights Reserved.
 *
 *  File:       pixel.cpp
 *  Content:    Utility class for working with pixel formats
 *
 *
 ***************************************************************************/

#include "strsafe.h"
#include "pixel.hpp"

#ifndef DXPIXELVER
#define DXPIXELVER 100
#endif

IHVFormatInfo *CPixel::m_pFormatList = 0;

#undef DPF_MODNAME
#define DPF_MODNAME "CPixel::Cleanup"
void CPixel::Cleanup()
{
    while(m_pFormatList != 0)
    {
        IHVFormatInfo *t = m_pFormatList->m_pNext;
        delete m_pFormatList;
        m_pFormatList = t;
    }
}

#undef DPF_MODNAME
#define DPF_MODNAME "CPixel::BytesPerPixel"

UINT CPixel::BytesPerPixel(D3DFORMAT Format)
{
    switch (DWORD(Format))
    {
    case D3DFMT_DXT1:
        // Size is negative to indicate DXT; and indicates
        // the size of the block
        return (UINT)(-8);
    case D3DFMT_DXT2:
    case D3DFMT_DXT3:
    case D3DFMT_DXT4:
    case D3DFMT_DXT5:
        // Size is negative to indicate DXT; and indicates
        // the size of the block
        return (UINT)(-16);


#if (DXPIXELVER > 8)
    case D3DFMT_A32B32G32R32F:
        return 16;

    case D3DFMT_A16B16G16R16:
    case D3DFMT_Q16W16V16U16:
    case D3DFMT_A16B16G16R16F:
    case D3DFMT_G32R32F:
    case D3DFMT_MULTI2_ARGB8:
        return 8;
#endif

    case D3DFMT_A8R8G8B8:
    case D3DFMT_X8R8G8B8:
    case D3DFMT_D32:
    case D3DFMT_D24S8:
    case D3DFMT_S8D24:
    case D3DFMT_X8L8V8U8:
    case D3DFMT_X4S4D24:
    case D3DFMT_D24X4S4:
    case D3DFMT_Q8W8V8U8:
    case D3DFMT_V16U16:
    case D3DFMT_A2W10V10U10:
    case D3DFMT_A2B10G10R10:
    case D3DFMT_A8B8G8R8:
    case D3DFMT_X8B8G8R8:
    case D3DFMT_G16R16:
    case D3DFMT_D24X8:
    case D3DFMT_X8D24:
    case D3DFMT_W11V11U10:
#if (DXPIXELVER > 8)
    case D3DFMT_A2R10G10B10:
    case D3DFMT_G16R16F:
    case D3DFMT_R32F:
    case D3DFMT_D32F_LOCKABLE:
    case D3DFMT_D24FS8:
    case D3DFMT_D32_LOCKABLE:
#endif
        return 4;

    case D3DFMT_R8G8B8:
        return 3;

    case D3DFMT_R5G6B5:
    case D3DFMT_X1R5G5B5:
    case D3DFMT_A1R5G5B5:
    case D3DFMT_A4R4G4B4:
    case D3DFMT_A8L8:
    case D3DFMT_V8U8:
    case D3DFMT_L6V5U5:
    case D3DFMT_D16:
    case D3DFMT_D16_LOCKABLE:
    case D3DFMT_D15S1:
    case D3DFMT_S1D15:
    case D3DFMT_A8P8:
    case D3DFMT_A8R3G3B2:
    case D3DFMT_UYVY:
    case D3DFMT_YUY2:
    case D3DFMT_X4R4G4B4:
#if (DXPIXELVER > 8)
    case D3DFMT_CxV8U8:
    case D3DFMT_L16:
    case D3DFMT_R16F:
    case D3DFMT_R8G8_B8G8:
    case D3DFMT_G8R8_G8B8:
#endif
        return 2;

    case D3DFMT_P8:
    case D3DFMT_L8:
    case D3DFMT_R3G3B2:
    case D3DFMT_A4L4:
    case D3DFMT_A8:
#if (DXPIXELVER > 8)
    case D3DFMT_A1:
    case D3DFMT_S8_LOCKABLE:
#endif
        return 1;

    default:
        return 0;
    };
}; // BytesPerPixel

#undef DPF_MODNAME
#define DPF_MODNAME "CPixel::ComputePixelStride"

UINT CPixel::ComputePixelStride(D3DFORMAT Format)
{
    UINT BPP = BytesPerPixel(Format);
    if (BPP == 0)
    {
        for(IHVFormatInfo *p = m_pFormatList; p != 0; p = p->m_pNext)
        {
            if (p->m_Format == Format)
            {
                return p->m_BPP >> 3;
            }
        }
    }
    return BPP;
}; // ComputePixelStride

#undef DPF_MODNAME
#define DPF_MODNAME "CPixel::ComputeSurfaceStride"

// Figure out a stride for a particular surface based on format and width
inline UINT CPixel::ComputeSurfaceStride(UINT cpWidth, UINT cbPixel)
{
    UINT uStride = 0;
    ComputeSurfaceStrideChecked(cpWidth, cbPixel, &uStride);
    return uStride;
}; // ComputeSurfaceStride

#undef DPF_MODNAME
#define DPF_MODNAME "CPixel::ComputeSurfaceStrideChecked"

// Figure out a stride for a particular surface based on format and width
inline BOOL CPixel::ComputeSurfaceStrideChecked(UINT cpWidth, UINT cbPixel, UINT *pStride)
{
    // Figure out basic (linear) stride;
    UINT64 u64Stride = (UINT64)cpWidth * (UINT64)cbPixel;

    // Round up to multiple of 4 (for NT; but makes sense to maximize
    // cache hits and reduce unaligned accesses)
    //
    // NOTE:  Also necessary for UYVY and YUY2 formats that this round
    // up by at least a multiple of 4.
    u64Stride = (u64Stride + 3) & ~3;    //safe since cbPixel cannot be 4G

    if (u64Stride <= MAXALLOCSIZE)
    {
        *pStride = (UINT)u64Stride;
        return TRUE;
    }
    return FALSE;
}; // ComputeSurfaceStride



#undef DPF_MODNAME
#define DPF_MODNAME "CPixel::ComputeSurfaceSize"

UINT CPixel::ComputeSurfaceSize(UINT            cpWidth,
                                UINT            cpHeight,
                                UINT            cbPixel)
{
    UINT uSize;
    ComputeSurfaceSizeChecked(cpWidth, cpHeight, cbPixel, &uSize);
    return uSize;
} // ComputeSurfaceSize

#undef DPF_MODNAME
#define DPF_MODNAME "CPixel::ComputeSurfaceSizeChecked"

BOOL CPixel::ComputeSurfaceSizeChecked(UINT            cpWidth,
                                       UINT            cpHeight,
                                       UINT            cbPixel,
                                       UINT           *pSize)

{
    UINT uStride;
    UINT64 uSize64;
    if (ComputeSurfaceStrideChecked(cpWidth, cbPixel, &uStride))
    {
        uSize64 = (UINT64)cpHeight * (UINT64)uStride;
        if (uSize64 <= MAXALLOCSIZE)
        {
            *pSize = (UINT)uSize64;
            return TRUE;
        }
    }

    *pSize = 0U;
    return FALSE;
} // ComputeSurfaceSize


#undef DPF_MODNAME
#define DPF_MODNAME "CPixel::ComputeMipMapSize"

UINT CPixel::ComputeMipMapSize(UINT             cpWidth,
                               UINT             cpHeight,
                               UINT             cLevels,
                               D3DFORMAT       Format)
{
    UINT uSize = 0; // initialize to zero to keep prefix happy win7: 185027
    ComputeMipMapSizeChecked(cpWidth, cpHeight, cLevels, Format, &uSize);
    return uSize;
} // ComputeMipMapSize

#undef DPF_MODNAME
#define DPF_MODNAME "CPixel::ComputeMipMapSizeChecked"

BOOL CPixel::ComputeMipMapSizeChecked(UINT             cpWidth,
                                      UINT             cpHeight,
                                      UINT             cLevels,
                                      D3DFORMAT        Format,
                                      UINT            *pSize)
{
    UINT cbPixel = ComputePixelStride(Format);

    // Adjust pixel->block if necessary
    BOOL isDXT = IsDXT(cbPixel);
    if (isDXT)
        cbPixel *= (UINT)-1;

    UINT64 cbSize = 0;
    if (cpWidth > MAXALLOCSIZE-3 || cpHeight > MAXALLOCSIZE-3)
        return FALSE;

    for (UINT i = 0; i < cLevels; i++)
    {
        UINT cbMipSize;
        // Figure out the size for
        // each level of the mip-map
        if (isDXT)
        {
            if (!ComputeSurfaceSizeChecked((cpWidth+3)/4, (cpHeight+3)/4, cbPixel, &cbMipSize))
                return FALSE;
        }
        else
        {
            if (!ComputeSurfaceSizeChecked(cpWidth, cpHeight, cbPixel, &cbMipSize))
                return FALSE;
        }
        cbSize += cbMipSize;
        // Shrink width and height by half; clamp to 1 pixel
        if (cpWidth > 1)
            cpWidth >>= 1;
        if (cpHeight > 1)
            cpHeight >>= 1;
    }
    if (cbSize <= MAXALLOCSIZE)
    {
        *pSize = (UINT)cbSize;
        return TRUE;
    }
    return FALSE;

} // ComputeMipMapSize

#undef DPF_MODNAME
#define DPF_MODNAME "CPixel::ComputeMipVolumeSize"

UINT CPixel::ComputeMipVolumeSize(UINT          cpWidth,
                                  UINT          cpHeight,
                                  UINT          cpDepth,
                                  UINT          cLevels,
                                  D3DFORMAT    Format)
{
    UINT uSize = 0; // To keep prefix happy win7: 185029
    ComputeMipVolumeSizeChecked(cpWidth, cpHeight, cpDepth, cLevels, Format, &uSize);
    return uSize;
} // ComputeMipVolumeSize

#undef DPF_MODNAME
#define DPF_MODNAME "CPixel::ComputeMipVolumeSizeChecked"

BOOL CPixel::ComputeMipVolumeSizeChecked(UINT          cpWidth,
                                         UINT          cpHeight,
                                         UINT          cpDepth,
                                         UINT          cLevels,
                                         D3DFORMAT     Format,
                                         UINT         *pSize)
{
    UINT cbPixel = ComputePixelStride(Format);

    // Adjust pixel->block if necessary
    BOOL isDXT       = IsDXT(cbPixel);

    if (isDXT)
        cbPixel *= (UINT)-1;

    UINT64 cbSize = 0;

    if (cpWidth > MAXALLOCSIZE-3 || cpHeight > MAXALLOCSIZE-3 || cpDepth > MAXALLOCSIZE-3)
        return FALSE;

    for (UINT i = 0; i < cLevels; i++)
    {
        // Figure out the size for
        // each level of the mip-volume
        UINT    Depth = cpDepth;
        UINT64  cbLevelSize;
        UINT    cbSliceSize;
        if (isDXT)
        {
            if (!ComputeSurfaceSizeChecked((cpWidth+3)/4, (cpHeight+3)/4, cbPixel, &cbSliceSize))
                return FALSE;
        }
        else
        {
            if (!ComputeSurfaceSizeChecked(cpWidth, cpHeight, cbPixel, &cbSliceSize))
                return FALSE;
        }
        cbLevelSize = (UINT64)Depth * (UINT64)cbSliceSize;
        if (cbLevelSize > MAXALLOCSIZE)
            return FALSE;
        cbSize += cbLevelSize;

        // Shrink width and height by half; clamp to 1 pixel
        if (cpWidth > 1)
            cpWidth >>= 1;
        if (cpHeight > 1)
            cpHeight >>= 1;
        if (cpDepth > 1)
            cpDepth >>= 1;
    }

    if (cbSize <= MAXALLOCSIZE)
    {
        *pSize = (UINT)cbSize;
        return TRUE;
    }
    return FALSE;

} // ComputeMipVolumeSize

// Given a surface desc, a level, and pointer to
// bits (pBits in the LockedRectData) and a sub-rect,
// this will fill in the pLockedRectData structure
void CPixel::ComputeMipMapOffset(const D3DSURFACE_DESC *pDescTopLevel,
                                 UINT                   iLevel,
                                 BYTE                  *pBits,
                                 CONST RECT            *pRect,
                                 D3DLOCKED_RECT        *pLockedRectData)
{
    DXGASSERT(pBits != NULL);
    DXGASSERT(pLockedRectData != NULL);
    DXGASSERT(iLevel < 32);
    DXGASSERT(pDescTopLevel != NULL);
    DXGASSERT(0 != ComputePixelStride(pDescTopLevel->Format));
    DXGASSERT(pDescTopLevel->Width > 0);
    DXGASSERT(pDescTopLevel->Height > 0);

    // CONSIDER: This is slow; and we can do a much better
    // job for the non-compressed/wacky cases.
    UINT       cbOffset = 0;
    UINT       cbPixel  = ComputePixelStride(pDescTopLevel->Format);
    UINT       cpWidth  = pDescTopLevel->Width;
    UINT       cpHeight = pDescTopLevel->Height;

    // Adjust pixel->block if necessary
    BOOL isDXT = IsDXT(cbPixel);
    if (isDXT)
        cbPixel *= (UINT)-1;
    BOOL OneBitPerPixelFormat = FALSE;
#if (DXPIXELVER > 8)
    OneBitPerPixelFormat = pDescTopLevel->Format == D3DFMT_A1;
    if (OneBitPerPixelFormat)
    {
        cbPixel = 1;
    }
#endif
    for (UINT i = 0; i < iLevel; i++)
    {
        if (isDXT)
            cbOffset += ComputeSurfaceSize((cpWidth+3)/4, (cpHeight+3)/4, cbPixel);
        else
        if (OneBitPerPixelFormat)
            cbOffset += ComputeSurfaceSize((cpWidth + 7) >> 3, cpHeight, cbPixel);
        else
            cbOffset += ComputeSurfaceSize(cpWidth, cpHeight, cbPixel);

        // Shrink width and height by half; clamp to 1 pixel
        if (cpWidth > 1)
            cpWidth >>= 1;
        if (cpHeight > 1)
            cpHeight >>= 1;
    }
    if (isDXT)
        cpWidth = (cpWidth+3)/4;
    else
    if (OneBitPerPixelFormat)
        cpWidth = (cpWidth+7)/8;


    // For DXTs, the pitch is the number of bytes
    // for a single row of blocks; which is the same
    // thing as the normal routine
    pLockedRectData->Pitch = ComputeSurfaceStride(cpWidth,
                                                  cbPixel);
    DXGASSERT(pLockedRectData->Pitch != 0);

    // Don't adjust for Rect for DXT formats
    if (pRect)
    {
        if (isDXT)
        {
            DXGASSERT((pRect->top  & 3) == 0);
            DXGASSERT((pRect->left & 3) == 0);
            cbOffset += (pRect->top  / 4) * pLockedRectData->Pitch +
                        (pRect->left / 4) * cbPixel;
        }
        else
        if (OneBitPerPixelFormat)
        {
            // Assume that left is always 8 pixels aligned
            cbOffset += pRect->top  * pLockedRectData->Pitch +
                        (pRect->left >> 3);
        }
        else
        {
            cbOffset += pRect->top  * pLockedRectData->Pitch +
                        pRect->left * cbPixel;
        }
    }

    pLockedRectData->pBits = pBits + cbOffset;

} // ComputeMipMapOffset

#undef DPF_MODNAME
#define DPF_MODNAME "CPixel::ComputeMipVolumeOffset"

// MipVolume version of ComputeMipMapOffset
void CPixel::ComputeMipVolumeOffset(const D3DVOLUME_DESC  *pDescTopLevel,
                                    UINT                    iLevel,
                                    BYTE                    *pBits,
                                    CONST D3DBOX            *pBox,
                                    D3DLOCKED_BOX          *pLockedBoxData)
{
    DXGASSERT(pBits != NULL);
    DXGASSERT(pLockedBoxData != NULL);
    DXGASSERT(iLevel < 32);
    DXGASSERT(pDescTopLevel != NULL);
    DXGASSERT(0 != ComputePixelStride(pDescTopLevel->Format));
    DXGASSERT(pDescTopLevel->Width > 0);
    DXGASSERT(pDescTopLevel->Height > 0);
    DXGASSERT(pDescTopLevel->Depth > 0);

    UINT       cbOffset = 0;
    UINT       cbPixel  = ComputePixelStride(pDescTopLevel->Format);
    UINT       cpWidth  = pDescTopLevel->Width;
    UINT       cpHeight = pDescTopLevel->Height;
    UINT       cpDepth  = pDescTopLevel->Depth;

    // Adjust pixel->block if necessary
    BOOL isDXT       = IsDXT(cbPixel);

    if (isDXT)
        cbPixel *= (UINT)-1;

    for (UINT i = 0; i < iLevel; i++)
    {
        UINT    Depth = cpDepth;
        if (isDXT)
            cbOffset += Depth * ComputeSurfaceSize((cpWidth+3)/4, (cpHeight+3)/4, cbPixel);
        else
            cbOffset += Depth * ComputeSurfaceSize(cpWidth, cpHeight, cbPixel);

        // Shrink width and height by half; clamp to 1 pixel
        if (cpWidth > 1)
            cpWidth >>= 1;
        if (cpHeight > 1)
            cpHeight >>= 1;
        if (cpDepth > 1)
            cpDepth >>= 1;
    }

    if (isDXT)
    {
        cpWidth = (cpWidth+3)/4;
        cpHeight = (cpHeight+3)/4;
    }

    // For DXTs, the row pitch is the number of bytes
    // for a single row of blocks; which is the same
    // thing as the normal routine
    pLockedBoxData->RowPitch = ComputeSurfaceStride(cpWidth,
                                                    cbPixel);
    DXGASSERT(pLockedBoxData->RowPitch != 0);

    // For DXVs the slice pitch is the number of bytes
    // for a single plane of blocks; which is the same thing
    // as the normal routine
    pLockedBoxData->SlicePitch = ComputeSurfaceSize(cpWidth,
                                                    cpHeight,
                                                    cbPixel);
    DXGASSERT(pLockedBoxData->SlicePitch != 0);

    // Adjust for Box
    if (pBox)
    {
        UINT iStride = pLockedBoxData->RowPitch;
        UINT iSlice  = pLockedBoxData->SlicePitch;
        if (isDXT)
        {
                cbOffset += (pBox->Front) * iSlice;

            DXGASSERT((pBox->Top  & 3) == 0);
            DXGASSERT((pBox->Left & 3) == 0);
            cbOffset += (pBox->Top  / 4) * iStride +
                        (pBox->Left / 4) * cbPixel;
        }
        else
        {
            cbOffset += pBox->Front * iSlice  +
                        pBox->Top   * iStride +
                        pBox->Left  * cbPixel;
        }
    }

    pLockedBoxData->pBits = pBits + cbOffset;

} // ComputeMipVolumeOffset


#undef DPF_MODNAME
#define DPF_MODNAME "CPixel::Register"

HRESULT CPixel::Register(D3DFORMAT Format, DWORD BPP)
{
    DXGASSERT(BPP != 0);

    // Do not register duplicates
    IHVFormatInfo *p;
    for(p = m_pFormatList; p != 0; p = p->m_pNext)
    {
        if (p->m_Format == Format)
        {
            return S_OK;
        }
    }

    // Not found, add to registry.
    // This allocation will be leaked, but since
    // we don't expect to have a large number of
    // IHV formats, the leak is not a big deal.
    // Also, the leak will be immediately recovered
    // upon process exit.
    IHVFormatInfo *p2 = new IHVFormatInfo;
    if (p2 == 0)
    {
        return E_OUTOFMEMORY;
    }
    p2->m_Format = Format;
    p2->m_BPP = BPP;
    p2->m_pNext = m_pFormatList;
    m_pFormatList = p2;

    return S_OK;
}


extern "C" UINT CPixel__ComputeSurfaceSize(UINT            cpWidth,
                                           UINT            cpHeight,
                                           D3DFORMAT       Format)
{
    return CPixel::ComputeSurfaceSize(cpWidth, cpHeight, Format);
}

extern "C" UINT CPixel__ComputeVolumeSize(UINT             cpWidth,
                                          UINT             cpHeight,
                                          UINT             cpDepth,
                                          D3DFORMAT        Format)
{
    return CPixel::ComputeVolumeSize(cpWidth, cpHeight, cpDepth, Format);
}

extern "C" UINT CPixel__ComputeMipMapSize(UINT             cpWidth,
                                          UINT             cpHeight,
                                          UINT             cLevels,
                                          D3DFORMAT        Format)
{
    return CPixel::ComputeMipMapSize(cpWidth, cpHeight, cLevels, Format);
}

extern "C" UINT CPixel__ComputeMipVolumeSize(UINT          cpWidth,
                                             UINT          cpHeight,
                                             UINT          cpDepth,
                                             UINT          cLevels,
                                             D3DFORMAT     Format)
{
    return CPixel::ComputeMipVolumeSize(cpWidth, cpHeight, cpDepth, cLevels, Format);
}

extern "C" void CPixel__ComputeMipMapOffset(const D3DSURFACE_DESC  *pDescTopLevel,
                                            UINT                    iLevel,
                                            BYTE                   *pBits,
                                            CONST RECT             *pRect,
                                            D3DLOCKED_RECT         *pLockedRectData)
{
    CPixel::ComputeMipMapOffset(pDescTopLevel, iLevel, pBits, pRect, pLockedRectData);
}

extern "C" void CPixel__ComputeMipVolumeOffset(const D3DVOLUME_DESC  *pDescTopLevel,
                                               UINT                   iLevel,
                                               BYTE                  *pBits,
                                               CONST D3DBOX          *pBox,
                                               D3DLOCKED_BOX         *pLockedBoxData)
{
    CPixel::ComputeMipVolumeOffset(pDescTopLevel, iLevel, pBits, pBox, pLockedBoxData);
}

extern "C" void CPixel__ComputeSurfaceOffset(const D3DSURFACE_DESC  *pDesc,
                                             BYTE                   *pBits,
                                             CONST RECT             *pRect,
                                             D3DLOCKED_RECT         *pLockedRectData)
{
    CPixel::ComputeSurfaceOffset(pDesc, pBits, pRect, pLockedRectData);
}

extern "C" UINT CPixel__ComputePixelStride(D3DFORMAT Format)
{
    return CPixel::ComputePixelStride(Format);
}

extern "C" void CPixel__AdjustForDXT(UINT *pcpWidth,
                                     UINT *pcpHeight,
                                     UINT *pcbPixel)
{
    CPixel::AdjustForDXT(pcpWidth, pcpHeight, pcbPixel);
}

extern "C" BOOL CPixel__IsDXT(D3DFORMAT Format)
{
    return CPixel::IsDXT(Format);
}

extern "C" UINT CPixel__BytesPerPixel(D3DFORMAT Format)
{
    return CPixel::BytesPerPixel(Format);
}

extern "C" HRESULT CPixel__Register(D3DFORMAT Format, DWORD BPP)
{
    return CPixel::Register(Format, BPP);
}

extern "C" void CPixel__Cleanup()
{
    CPixel::Cleanup();
}

extern "C" UINT CPixel__ComputeSurfaceStride(UINT cpWidth, UINT cbPixel)
{
    return CPixel::ComputeSurfaceStride(cpWidth, cbPixel);
}


// End of file : pixel.cpp