Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
3.3 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Copyright (C) Microsoft Corporation, 1998.
  3. //
  4. // PixRef.cpp
  5. //
  6. // Direct3D Reference Rasterizer - Pixel Buffer Referencing
  7. //
  8. ///////////////////////////////////////////////////////////////////////////////
  9. #include "pch.cpp"
  10. #pragma hdrstop
  11. extern int g_DXTBlkSize[];
  12. //-----------------------------------------------------------------------------
  13. //
  14. // PixelAddress - Form character address of locations within buffers using base
  15. // pointer, pitch and type.
  16. //
  17. //-----------------------------------------------------------------------------
  18. char*
  19. PixelAddress( int iX, int iY, char* pBits, int iYPitch, RRSurfaceType SType )
  20. {
  21. // initialize return value to start of scan line (pitch is always in bytes)
  22. char* pPixAddr = pBits + iY*iYPitch;
  23. // bump along scan line depending on surface type to point to pixel data
  24. switch ( SType )
  25. {
  26. default:
  27. _ASSERTa(0, "Unknown RRSurfaceType value", return NULL;);
  28. case RR_STYPE_NULL:
  29. break;
  30. case RR_STYPE_B8G8R8A8:
  31. case RR_STYPE_B8G8R8X8:
  32. case RR_STYPE_Z24S8:
  33. case RR_STYPE_S8Z24:
  34. case RR_STYPE_Z24S4:
  35. case RR_STYPE_S4Z24:
  36. case RR_STYPE_Z32S0:
  37. pPixAddr += iX*4;
  38. break;
  39. case RR_STYPE_B5G6R5:
  40. case RR_STYPE_B5G5R5:
  41. case RR_STYPE_B5G5R5A1:
  42. case RR_STYPE_L8A8:
  43. case RR_STYPE_U8V8:
  44. case RR_STYPE_U5V5L6:
  45. case RR_STYPE_Z16S0:
  46. case RR_STYPE_Z15S1:
  47. case RR_STYPE_S1Z15:
  48. case RR_STYPE_B4G4R4A4:
  49. case RR_STYPE_YUY2:
  50. case RR_STYPE_UYVY:
  51. case RR_STYPE_B2G3R3A8:
  52. pPixAddr += iX*2;
  53. break;
  54. case RR_STYPE_B8G8R8:
  55. case RR_STYPE_U8V8L8:
  56. pPixAddr += iX*3;
  57. break;
  58. case RR_STYPE_PALETTE8:
  59. case RR_STYPE_L8:
  60. case RR_STYPE_B2G3R3:
  61. case RR_STYPE_L4A4:
  62. pPixAddr += iX;
  63. break;
  64. case RR_STYPE_PALETTE4:
  65. pPixAddr += (iX>>1);
  66. break;
  67. // For the DXT texture formats, obtain the address of the
  68. // block from whih to decompress the texel from
  69. case RR_STYPE_DXT1:
  70. case RR_STYPE_DXT2:
  71. case RR_STYPE_DXT3:
  72. case RR_STYPE_DXT4:
  73. case RR_STYPE_DXT5:
  74. pPixAddr = pBits + (iY >> 2)*iYPitch + (iX>>2) *
  75. g_DXTBlkSize[(int)SType - (int)RR_STYPE_DXT1];
  76. break;
  77. }
  78. return pPixAddr;
  79. }
  80. //-----------------------------------------------------------------------------
  81. //
  82. // WritePixel - Writes pixel and (maybe) depth to current render target.
  83. //
  84. // called by ReferenceRasterizer::DoPixel
  85. // and ReferenceRasterizer::DoBufferResolve
  86. //
  87. //-----------------------------------------------------------------------------
  88. void
  89. ReferenceRasterizer::WritePixel(
  90. INT32 iX, INT32 iY,
  91. const RRColor& Color, const RRDepth& Depth)
  92. {
  93. m_pRenderTarget->WritePixelColor( iX, iY, Color,
  94. m_dwRenderState[D3DRENDERSTATE_DITHERENABLE]);
  95. // don't write if Z buffering disabled or Z write disabled
  96. if ( !( m_dwRenderState[D3DRENDERSTATE_ZENABLE ] ) ||
  97. !( m_dwRenderState[D3DRENDERSTATE_ZWRITEENABLE] ) ) { return; }
  98. m_pRenderTarget->WritePixelDepth( iX, iY, Depth );
  99. }
  100. ///////////////////////////////////////////////////////////////////////////////
  101. // end