Counter Strike : Global Offensive Source Code
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.

106 lines
3.8 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #ifndef TEXTUREDX8_H
  9. #define TEXTUREDX8_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "togl/rendermechanism.h"
  14. #include "bitmap/imageformat.h"
  15. #include "locald3dtypes.h"
  16. #include "shaderapi/ishaderapi.h"
  17. //-----------------------------------------------------------------------------
  18. // Forward declarations
  19. //-----------------------------------------------------------------------------
  20. class CPixelWriter;
  21. //-----------------------------------------------------------------------------
  22. // Returns the size of texture memory
  23. //-----------------------------------------------------------------------------
  24. int ComputeTextureMemorySize( const GUID &nDeviceId, D3DDEVTYPE deviceType );
  25. //-----------------------------------------------------------------------------
  26. // Texture creation
  27. //-----------------------------------------------------------------------------
  28. IDirect3DBaseTexture *CreateD3DTexture( int width, int height, int depth,
  29. ImageFormat dstFormat, int numLevels, int creationFlags, char *debugLabel=NULL ); // OK to not-supply the last param
  30. //-----------------------------------------------------------------------------
  31. // Texture destruction
  32. //-----------------------------------------------------------------------------
  33. void DestroyD3DTexture( IDirect3DBaseTexture *pTex );
  34. int GetD3DTextureRefCount( IDirect3DBaseTexture *pTex );
  35. //-----------------------------------------------------------------------------
  36. // Texture heap methods
  37. //-----------------------------------------------------------------------------
  38. #if defined( _X360 )
  39. void SetD3DTextureImmobile( IDirect3DBaseTexture *pTex, bool bImmobile );
  40. void CompactTextureHeap();
  41. #endif
  42. //-----------------------------------------------------------------------------
  43. // Stats...
  44. //-----------------------------------------------------------------------------
  45. int TextureCount();
  46. //-----------------------------------------------------------------------------
  47. // Info for texture loading
  48. //-----------------------------------------------------------------------------
  49. struct TextureLoadInfo_t
  50. {
  51. ShaderAPITextureHandle_t m_TextureHandle;
  52. int m_nCopy;
  53. IDirect3DBaseTexture *m_pTexture;
  54. int m_nLevel;
  55. D3DCUBEMAP_FACES m_CubeFaceID;
  56. int m_nWidth;
  57. int m_nHeight;
  58. int m_nZOffset; // What z-slice of the volume texture are we loading?
  59. ImageFormat m_SrcFormat;
  60. unsigned char *m_pSrcData;
  61. #if defined( _X360 )
  62. bool m_bSrcIsTiled; // format may not be, but data could be
  63. bool m_bCanConvertFormat; // allow format conversion
  64. #endif
  65. };
  66. //-----------------------------------------------------------------------------
  67. // Texture image upload
  68. //-----------------------------------------------------------------------------
  69. void LoadTexture( TextureLoadInfo_t &info );
  70. //-----------------------------------------------------------------------------
  71. // Upload to a sub-piece of a texture
  72. //-----------------------------------------------------------------------------
  73. void LoadSubTexture( TextureLoadInfo_t &info, int xOffset, int yOffset, int srcStride );
  74. //-----------------------------------------------------------------------------
  75. // Lock, unlock a texture...
  76. //-----------------------------------------------------------------------------
  77. bool LockTexture( ShaderAPITextureHandle_t textureHandle, int copy, IDirect3DBaseTexture* pTexture, int level,
  78. D3DCUBEMAP_FACES cubeFaceID, int xOffset, int yOffset, int width, int height, bool bDiscard,
  79. CPixelWriter& writer );
  80. void UnlockTexture( ShaderAPITextureHandle_t textureHandle, int copy, IDirect3DBaseTexture* pTexture, int level,
  81. D3DCUBEMAP_FACES cubeFaceID );
  82. #endif // TEXTUREDX8_H