Source code of Windows XP (NT5)
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.

157 lines
6.1 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Copyright (C) Microsoft Corporation, 2000.
  3. //
  4. // pshdrval.hpp
  5. //
  6. // Direct3D Reference Device - PixelShader validation
  7. //
  8. ///////////////////////////////////////////////////////////////////////////////
  9. #ifndef __PSHDRVAL_HPP__
  10. #define __PSHDRVAL_HPP__
  11. #define PS_INST_TOKEN_RESERVED_MASK 0xbfff0000 // bits 16-23, 24-29, 31 must be 0
  12. #define PS_DSTPARAM_TOKEN_RESERVED_MASK 0x4000e000 // bits 13-15, 30 must be 0
  13. #define PS_SRCPARAM_TOKEN_RESERVED_MASK 0x4000e000 // bits 13-15, 30 must be 0
  14. //-----------------------------------------------------------------------------
  15. // CPSInstruction
  16. //-----------------------------------------------------------------------------
  17. class CPSInstruction : public CBaseInstruction
  18. {
  19. public:
  20. CPSInstruction(CPSInstruction* pPrevInst) : CBaseInstruction(pPrevInst)
  21. {
  22. m_bTexOp = FALSE;
  23. m_bTexMOp = FALSE;
  24. m_bTexOpThatReadsTexture = FALSE;
  25. m_bCoIssue = FALSE;
  26. m_CycleNum = (UINT)-1;
  27. };
  28. void CalculateComponentReadMasks(DWORD dwVersion);
  29. BOOL m_bTexOp;
  30. BOOL m_bTexMOp;
  31. BOOL m_bTexOpThatReadsTexture;
  32. BOOL m_bCoIssue;
  33. UINT m_CycleNum; // identical for co-issued instructions
  34. };
  35. //-----------------------------------------------------------------------------
  36. // CBasePShaderValidator
  37. //-----------------------------------------------------------------------------
  38. class CBasePShaderValidator : public CBaseShaderValidator
  39. {
  40. protected:
  41. UINT m_CycleNum;
  42. UINT m_TexOpCount;
  43. UINT m_BlendOpCount;
  44. UINT m_TotalOpCount; // not necessarily the sum of TexOpCount and BlendOpCount....
  45. CRegisterFile* m_pTempRegFile;
  46. CRegisterFile* m_pInputRegFile;
  47. CRegisterFile* m_pConstRegFile;
  48. CRegisterFile* m_pTextureRegFile;
  49. CBaseInstruction* AllocateNewInstruction(CBaseInstruction*pPrevInst);
  50. BOOL DecodeNextInstruction();
  51. virtual BOOL InitValidation() = 0;
  52. virtual BOOL ApplyPerInstructionRules() = 0;
  53. virtual void ApplyPostInstructionsRules() = 0;
  54. virtual void IsCurrInstTexOp() = 0;
  55. public:
  56. CBasePShaderValidator( const DWORD* pCode, const D3DCAPS8* pCaps, DWORD Flags );
  57. ~CBasePShaderValidator();
  58. };
  59. //-----------------------------------------------------------------------------
  60. // CPShaderValidator10
  61. //-----------------------------------------------------------------------------
  62. class CPShaderValidator10 : public CBasePShaderValidator
  63. {
  64. private:
  65. UINT m_TexOpCount;
  66. UINT m_BlendOpCount;
  67. UINT m_TotalOpCount; // not necessarily the sum of TexOpCount and BlendOpCount....
  68. UINT m_TexMBaseDstReg;
  69. BOOL ApplyPerInstructionRules();
  70. void ApplyPostInstructionsRules();
  71. void IsCurrInstTexOp();
  72. BOOL InitValidation();
  73. BOOL Rule_InstructionRecognized();
  74. BOOL Rule_InstructionSupportedByVersion();
  75. BOOL Rule_ValidParamCount();
  76. BOOL Rule_ValidSrcParams();
  77. BOOL Rule_NegateAfterSat();
  78. BOOL Rule_SatBeforeBiasOrComplement();
  79. BOOL Rule_MultipleDependentTextureReads();
  80. BOOL Rule_SrcNoLongerAvailable();
  81. BOOL Rule_SrcInitialized();
  82. BOOL Rule_ValidDstParam();
  83. BOOL Rule_ValidRegisterPortUsage();
  84. BOOL Rule_TexRegsDeclaredInOrder();
  85. BOOL Rule_TexOpAfterNonTexOp();
  86. BOOL Rule_ValidTEXM3xSequence(); // Call per instruction AND after all instructions seen
  87. BOOL Rule_ValidTEXM3xRegisterNumbers();
  88. BOOL Rule_ValidCNDInstruction();
  89. BOOL Rule_ValidCMPInstruction();
  90. BOOL Rule_ValidLRPInstruction();
  91. BOOL Rule_ValidDEFInstruction();
  92. BOOL Rule_ValidDP3Instruction();
  93. BOOL Rule_ValidDP4Instruction();
  94. BOOL Rule_ValidInstructionPairing();
  95. BOOL Rule_ValidInstructionCount(); // Call per instruction AND after all instructions seen
  96. BOOL Rule_R0Written(); // Call after all instructions seen.
  97. public:
  98. CPShaderValidator10( const DWORD* pCode, const D3DCAPS8* pCaps, DWORD Flags );
  99. };
  100. //-----------------------------------------------------------------------------
  101. // CPShaderValidator14
  102. //-----------------------------------------------------------------------------
  103. class CPShaderValidator14 : public CBasePShaderValidator
  104. {
  105. private:
  106. UINT m_BlendOpCount;
  107. int m_Phase; // 1 == dependent read setup block, 2 == second pass
  108. BOOL m_bPhaseMarkerInShader; // shader is preprocessed to set this bool
  109. CPSInstruction* m_pPhaseMarkerInst; // only set at the moment marker is encountered in shader
  110. DWORD m_TempRegsWithZappedAlpha; // bitmask of temp regs for which alpha was zapped
  111. // (initialized->uninitialized) after the phase marker
  112. DWORD m_TempRegsWithZappedBlue; // bitmask of temp regs for which blue was zapped
  113. // (initialized->uninitialized) due to texcrd with .rg writemask
  114. BOOL ApplyPerInstructionRules();
  115. void ApplyPostInstructionsRules();
  116. void IsCurrInstTexOp();
  117. BOOL InitValidation();
  118. BOOL Rule_InstructionRecognized();
  119. BOOL Rule_InstructionSupportedByVersion();
  120. BOOL Rule_ValidParamCount();
  121. BOOL Rule_ValidSrcParams();
  122. BOOL Rule_LimitedUseOfProjModifier();
  123. BOOL Rule_MultipleDependentTextureReads();
  124. BOOL Rule_SrcInitialized();
  125. BOOL Rule_ValidMarker();
  126. BOOL Rule_ValidDstParam();
  127. BOOL Rule_ValidRegisterPortUsage();
  128. BOOL Rule_ValidTexOpStageAndRegisterUsage();
  129. BOOL Rule_TexOpAfterArithmeticOp();
  130. BOOL Rule_ValidTEXDEPTHInstruction();
  131. BOOL Rule_ValidTEXKILLInstruction();
  132. BOOL Rule_ValidBEMInstruction();
  133. BOOL Rule_ValidDEFInstruction();
  134. BOOL Rule_ValidInstructionPairing();
  135. BOOL Rule_ValidInstructionCount(); // Call per instruction AND after all instructions seen
  136. BOOL Rule_R0Written(); // Call after all instructions seen.
  137. public:
  138. CPShaderValidator14( const DWORD* pCode, const D3DCAPS8* pCaps, DWORD Flags );
  139. };
  140. #endif __PSHDRVAL_HPP__