texture2DMS-to-texture2D-noms.txt 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. "Texture2D < float4 > PassSrg_m_texture0ms : register ( t0 , space0 ) ;"
  2. "Texture2D < float4 > PassSrg_m_texture1 : register ( t1 , space0 ) ;"
  3. "Texture2D < float4 > PassSrg_m_texture2ms : register ( t2 , space0 ) ;"
  4. "Texture2DArray < float4 > PassSrg_m_textureArray0ms : register ( t3 , space0 ) ;"
  5. "Texture2DArray < float4 > PassSrg_m_textureArray1 : register ( t4 , space0 ) ;"
  6. "float4 PassSrg_Load ( int2 texelLoc , int2 texelLocDelta , int element , int sampleIndex )"
  7. "{"
  8. "float4 color = float4 ( 0 , 0 , 0 , 0 ) ;"
  9. "color += :: PassSrg_m_texture0ms . Load ( int3 ( texelLoc , 0 ) ) ;"
  10. "color -= :: PassSrg_m_texture0ms . Load ( int3 ( texelLoc + texelLocDelta , 0 ) ) ;"
  11. "color += :: PassSrg_m_texture0ms . Load ( int3 ( texelLoc + texelLocDelta , 0 ) , int2 ( 0 , 2 ) ) ;"
  12. "color -= :: PassSrg_m_texture1 . Load ( int3 ( texelLoc , 0 ) ) ;"
  13. "color += :: PassSrg_m_texture1 . Load ( int3 ( texelLoc , 1 ) ) ;"
  14. "color -= :: PassSrg_m_texture2ms . Load ( int3 ( texelLoc - 2 . 0 * texelLocDelta , 0 ) , int2 ( 1 , 1 ) ) ;"
  15. "color += :: PassSrg_m_textureArray0ms . Load ( int4 ( int3 ( texelLoc , element ) , 0 ) ) - :: PassSrg_m_textureArray1 . Load ( int4 ( texelLoc , element , 3 ) ) ;"
  16. "return color ;"
  17. "}"
  18. "float2 PassSrg_GetSamplePosition ( int sampleIndex )"
  19. "{"
  20. "return float2 ( 0 , 0 ) + float2 ( 0 , 0 ) + float2 ( 0 , 0 ) ;"
  21. "}"
  22. "void PassSrg_GetDimensions ( out uint width , out uint height , out uint elements , out uint numSamples )"
  23. "{"
  24. "uint tmpWidth ;"
  25. "uint tmpHeight ;"
  26. "uint tmpElements ;"
  27. "uint tmpNumSamples ;"
  28. "width = 0 ;"
  29. "height = 0 ;"
  30. "elements = 0 ;"
  31. "numSamples = 0 ;"
  32. ":: PassSrg_m_texture0ms . GetDimensions ( tmpWidth , tmpHeight ) ; tmpNumSamples = 1 ;"
  33. "width += tmpWidth ;"
  34. "height += tmpHeight ;"
  35. "numSamples += tmpNumSamples ;"
  36. ":: PassSrg_m_texture1 . GetDimensions ( tmpWidth , tmpHeight ) ;"
  37. "width += tmpWidth ;"
  38. "height += tmpHeight ;"
  39. ":: PassSrg_m_texture2ms . GetDimensions ( tmpWidth , tmpHeight ) ; tmpNumSamples = 1 ;"
  40. "width += tmpWidth ;"
  41. "height += tmpHeight ;"
  42. "numSamples += tmpNumSamples ;"
  43. ":: PassSrg_m_textureArray0ms . GetDimensions ( tmpWidth , tmpHeight , tmpElements ) ; tmpNumSamples = 1 ;"
  44. "width += tmpWidth ;"
  45. "height += tmpHeight ;"
  46. "elements += tmpElements ;"
  47. "numSamples += tmpNumSamples ;"
  48. ":: PassSrg_m_textureArray1 . GetDimensions ( tmpWidth , tmpHeight , tmpElements ) ;"
  49. "width += tmpWidth ;"
  50. "height += tmpHeight ;"
  51. "elements += tmpElements ;"
  52. "width /= 5 ;"
  53. "height /= 5 ;"
  54. "elements /= 2 ;"
  55. "numSamples /= 3 ;"
  56. "}"
  57. "float4 Load ( int2 texelLoc , int2 texelLocDelta , int element , int sampleIndex , Texture2D < float4 > tex0ms , Texture2D < float4 > tex1 , Texture2D < float4 > tex2ms , Texture2DArray < float4 > texArray0ms , Texture2DArray < float4 > texArray1 )"
  58. "{"
  59. "float4 color = float4 ( 0 , 0 , 0 , 0 ) ;"
  60. "color += tex0ms . Load ( int3 ( texelLoc , 0 ) ) ;"
  61. "color -= tex0ms . Load ( int3 ( texelLoc + texelLocDelta , 0 ) ) ;"
  62. "color += tex0ms . Load ( int3 ( texelLoc + texelLocDelta , 0 ) , int2 ( 0 , 2 ) ) ;"
  63. "color -= tex1 . Load ( int3 ( texelLoc , 0 ) ) ;"
  64. "color += tex1 . Load ( int3 ( texelLoc , 1 ) ) ;"
  65. "color -= tex2ms . Load ( int3 ( texelLoc - 2 . 0 * texelLocDelta , 0 ) , int2 ( 1 , 1 ) ) ;"
  66. "color += texArray0ms . Load ( int4 ( int3 ( texelLoc , element ) , 0 ) ) - texArray1 . Load ( int4 ( texelLoc , element , 3 ) ) ;"
  67. "return color ;"
  68. "}"
  69. "struct VSOutput"
  70. "{"
  71. "float4 m_position : SV_Position ;"
  72. "float2 m_texCoord : TEXCOORD0 ;"
  73. "} ;"
  74. "struct PSOutput"
  75. "{"
  76. "float4 m_color : SV_Target0 ;"
  77. "} ;"
  78. ":: PSOutput PSMain ( :: VSOutput IN )"
  79. "{"
  80. "uint sampleIndex = ( uint ) 0 ;"
  81. "PSOutput OUT ;"
  82. "int2 texelCoord = int2 ( IN . m_position . xy ) ;"
  83. "float4 color1 = :: PassSrg_Load ( texelCoord , int2 ( 0 , 0 ) , 1 , sampleIndex ) ;"
  84. "float4 color2 = Load ( texelCoord , int2 ( 0 , 0 ) , 1 , sampleIndex , :: PassSrg_m_texture0ms , :: PassSrg_m_texture1 , :: PassSrg_m_texture2ms , :: PassSrg_m_textureArray0ms , :: PassSrg_m_textureArray1 ) ;"
  85. "float2 samplePos = :: PassSrg_GetSamplePosition ( sampleIndex ) ;"
  86. "uint width ;"
  87. "uint height ;"
  88. "uint elements ;"
  89. "uint numSamples ;"
  90. ":: PassSrg_GetDimensions ( width , height , elements , numSamples ) ;"
  91. "if ( ( samplePos . x == samplePos . y ) && ( width == height ) && ( elements != numSamples ) ) {"
  92. "OUT . m_color = color1 ;"
  93. "} else {"
  94. "OUT . m_color = color2 ;"
  95. "} return OUT ;"
  96. "}"
  97. ":: PSOutput PSMainCoverage ( :: VSOutput IN )"
  98. "{"
  99. "uint coverage = ( uint ) -1 ;"
  100. "PSOutput OUT ;"
  101. "int2 texelCoord = int2 ( IN . m_position . xy ) ;"
  102. "uint width ;"
  103. "uint height ;"
  104. "uint elements ;"
  105. "uint numSamples ;"
  106. ":: PassSrg_GetDimensions ( width , height , elements , numSamples ) ;"
  107. "for ( uint sampleIndex = 0 ;"
  108. "sampleIndex < numSamples ;"
  109. "++ sampleIndex ) {"
  110. "if ( ! ( coverage & ( 1 < < sampleIndex ) ) ) {"
  111. "continue ;"
  112. "} float4 color1 = :: PassSrg_Load ( texelCoord , int2 ( 0 , 0 ) , 1 , sampleIndex ) ;"
  113. "float4 color2 = Load ( texelCoord , int2 ( 0 , 0 ) , 1 , sampleIndex , :: PassSrg_m_texture0ms , :: PassSrg_m_texture1 , :: PassSrg_m_texture2ms , :: PassSrg_m_textureArray0ms , :: PassSrg_m_textureArray1 ) ;"
  114. "float2 samplePos = :: PassSrg_GetSamplePosition ( sampleIndex ) ;"
  115. "if ( ( samplePos . x == samplePos . y ) && ( width == height ) && ( elements != numSamples ) ) {"
  116. "OUT . m_color += color1 ;"
  117. "coverage &= ~ ( 1 < < sampleIndex ) ;"
  118. "} else {"
  119. "OUT . m_color -= color2 ;"
  120. "} } return OUT ;"
  121. "}"
  122. "struct VSOutputWithSampleIndex"
  123. "{"
  124. "float4 m_position : SV_Position ;"
  125. "float2 m_texCoord : TEXCOORD0 ;"
  126. "static const uint m_sampleIndex = ( uint ) 0 ;"
  127. ";"
  128. "} ;"
  129. ":: PSOutput PSMain2 ( :: VSOutputWithSampleIndex IN )"
  130. "{"
  131. "PSOutput OUT ;"
  132. "int2 texelCoord = int2 ( IN . m_position . xy ) ;"
  133. "float4 color1 = :: PassSrg_Load ( texelCoord , int2 ( 0 , 0 ) , 1 , IN . m_sampleIndex ) ;"
  134. "float4 color2 = Load ( texelCoord , int2 ( 0 , 0 ) , 1 , IN . m_sampleIndex , :: PassSrg_m_texture0ms , :: PassSrg_m_texture1 , :: PassSrg_m_texture2ms , :: PassSrg_m_textureArray0ms , :: PassSrg_m_textureArray1 ) ;"
  135. "float2 samplePos = :: PassSrg_GetSamplePosition ( IN . m_sampleIndex ) ;"
  136. "uint width ;"
  137. "uint height ;"
  138. "uint elements ;"
  139. "uint numSamples ;"
  140. ":: PassSrg_GetDimensions ( width , height , elements , numSamples ) ;"
  141. "if ( ( samplePos . x == samplePos . y ) && ( width == height ) && ( elements != numSamples ) ) {"
  142. "OUT . m_color = color1 ;"
  143. "} else {"
  144. "OUT . m_color = color2 ;"
  145. "} return OUT ;"
  146. "}"