Team Fortress 2 Source Code as on 22/4/2020
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.

109 lines
4.1 KiB

  1. //========= Copyright 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. int16 m_nZOffset; // What z-slice of the volume texture are we loading?
  59. #if defined( _X360 )
  60. bool m_bSrcIsTiled; // format may not be, but data could be
  61. bool m_bCanConvertFormat; // allow format conversion
  62. #else
  63. bool m_bTextureIsLockable;
  64. #endif
  65. ImageFormat m_SrcFormat;
  66. unsigned char *m_pSrcData;
  67. };
  68. //-----------------------------------------------------------------------------
  69. // Texture image upload
  70. //-----------------------------------------------------------------------------
  71. void LoadTexture( TextureLoadInfo_t &info );
  72. void LoadTextureFromVTF( TextureLoadInfo_t &info, IVTFTexture* pVTF, int iVTFFrame );
  73. void LoadCubeTextureFromVTF( TextureLoadInfo_t &info, IVTFTexture* pVTF, int iVTFFrame );
  74. void LoadVolumeTextureFromVTF( TextureLoadInfo_t &info, IVTFTexture* pVTF, int iVTFFrame );
  75. //-----------------------------------------------------------------------------
  76. // Upload to a sub-piece of a texture
  77. //-----------------------------------------------------------------------------
  78. void LoadSubTexture( TextureLoadInfo_t &info, int xOffset, int yOffset, int srcStride );
  79. //-----------------------------------------------------------------------------
  80. // Lock, unlock a texture...
  81. //-----------------------------------------------------------------------------
  82. bool LockTexture( ShaderAPITextureHandle_t textureHandle, int copy, IDirect3DBaseTexture* pTexture, int level,
  83. D3DCUBEMAP_FACES cubeFaceID, int xOffset, int yOffset, int width, int height, bool bDiscard,
  84. CPixelWriter& writer );
  85. void UnlockTexture( ShaderAPITextureHandle_t textureHandle, int copy, IDirect3DBaseTexture* pTexture, int level,
  86. D3DCUBEMAP_FACES cubeFaceID );
  87. #endif // TEXTUREDX8_H