Bug 1323791 - Part 3: Add dynamic vertex shaders r=bas
authorMiko Mynttinen <mikokm@gmail.com>
Thu, 09 Feb 2017 21:41:16 +0100
changeset 346081 63608bcf9f431378aec0a0e9cd7000d50ced5071
parent 346080 619f4bab301a038b047cd3e4f1fede8575ba26d8
child 346082 88dd8c893e26601e45bc0da7bb88cc9ab596d483
push id31459
push usercbook@mozilla.com
push dateTue, 07 Mar 2017 14:05:14 +0000
treeherdermozilla-central@1fb56ba248d5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbas
bugs1323791
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1323791 - Part 3: Add dynamic vertex shaders r=bas MozReview-Commit-ID: H92wpa7QKMY
gfx/layers/d3d11/CompositorD3D11.hlsl
gfx/layers/d3d11/genshaders.sh
--- a/gfx/layers/d3d11/CompositorD3D11.hlsl
+++ b/gfx/layers/d3d11/CompositorD3D11.hlsl
@@ -38,16 +38,21 @@ Texture2D tCr : register(ps, t3);
 Texture2D tRGBWhite : register(ps, t4);
 Texture2D tMask : register(ps, t5);
 Texture2D tBackdrop : register(ps, t6);
 
 struct VS_INPUT {
   float2 vPosition : POSITION;
 };
 
+struct VS_TEX_INPUT {
+  float2 vPosition : POSITION;
+  float2 vTexCoords : TEXCOORD0;
+};
+
 struct VS_OUTPUT {
   float4 vPosition : SV_Position;
   float2 vTexCoords : TEXCOORD0;
 };
 
 struct VS_MASK_OUTPUT {
   float4 vPosition : SV_Position;
   float2 vTexCoords : TEXCOORD0;
@@ -160,16 +165,48 @@ VS_MASK_OUTPUT LayerQuadMaskVS(const VS_
   outp.vMaskCoords.z = 1;
   outp.vMaskCoords *= position.w;
 
   outp.vTexCoords = TexCoords(aVertex.vPosition.xy);
 
   return outp;
 }
 
+VS_OUTPUT LayerDynamicVS(const VS_TEX_INPUT aVertex)
+{
+  VS_OUTPUT outp;
+
+  float4 position = float4(aVertex.vPosition, 0, 1);
+  position = mul(mLayerTransform, position);
+  outp.vPosition = VertexPosition(position);
+
+  outp.vTexCoords = aVertex.vTexCoords;
+
+  return outp;
+}
+
+VS_MASK_OUTPUT LayerDynamicMaskVS(const VS_TEX_INPUT aVertex)
+{
+  VS_MASK_OUTPUT outp;
+
+  float4 position = float4(aVertex.vPosition, 0, 1);
+  position = mul(mLayerTransform, position);
+  outp.vPosition = VertexPosition(position);
+
+  // calculate the position on the mask texture
+  outp.vMaskCoords.x = (position.x - vMaskQuad.x) / vMaskQuad.z;
+  outp.vMaskCoords.y = (position.y - vMaskQuad.y) / vMaskQuad.w;
+  outp.vMaskCoords.z = 1;
+  outp.vMaskCoords *= position.w;
+
+  outp.vTexCoords = aVertex.vTexCoords;
+
+  return outp;
+}
+
 float4 RGBAShaderMask(const VS_MASK_OUTPUT aVertex) : SV_Target
 {
   float2 maskCoords = aVertex.vMaskCoords.xy / aVertex.vMaskCoords.z;
   float mask = tMask.Sample(sSampler, maskCoords).r;
   return tRGB.Sample(sSampler, aVertex.vTexCoords) * fLayerOpacity * mask;
 }
 
 float4 RGBShaderMask(const VS_MASK_OUTPUT aVertex) : SV_Target
@@ -308,16 +345,40 @@ VS_BLEND_OUTPUT LayerQuadBlendMaskVS(con
   VS_BLEND_OUTPUT o;
   o.vPosition = v.vPosition;
   o.vTexCoords = v.vTexCoords;
   o.vMaskCoords = v.vMaskCoords;
   o.vBackdropCoords = BackdropPosition(v.vPosition);
   return o;
 }
 
+VS_BLEND_OUTPUT LayerDynamicBlendVS(const VS_TEX_INPUT aVertex)
+{
+  VS_OUTPUT v = LayerDynamicVS(aVertex);
+
+  VS_BLEND_OUTPUT o;
+  o.vPosition = v.vPosition;
+  o.vTexCoords = v.vTexCoords;
+  o.vMaskCoords = float3(0, 0, 0);
+  o.vBackdropCoords = BackdropPosition(v.vPosition);
+  return o;
+}
+
+VS_BLEND_OUTPUT LayerDynamicBlendMaskVS(const VS_TEX_INPUT aVertex)
+{
+  VS_MASK_OUTPUT v = LayerDynamicMaskVS(aVertex);
+
+  VS_BLEND_OUTPUT o;
+  o.vPosition = v.vPosition;
+  o.vTexCoords = v.vTexCoords;
+  o.vMaskCoords = v.vMaskCoords;
+  o.vBackdropCoords = BackdropPosition(v.vPosition);
+  return o;
+}
+
 // The layer type and mask type are specified as constants. We use these to
 // call the correct pixel shader to determine the source color for blending.
 // Unfortunately this also requires some boilerplate to convert VS_BLEND_OUTPUT
 // to a compatible pixel shader input.
 float4 ComputeBlendSourceColor(const VS_BLEND_OUTPUT aVertex)
 {
   if (iBlendConfig.y == PS_MASK_NONE) {
     VS_OUTPUT tmp;
--- a/gfx/layers/d3d11/genshaders.sh
+++ b/gfx/layers/d3d11/genshaders.sh
@@ -25,26 +25,30 @@ makeShaderPS() {
 }
 
 SRC=CompositorD3D11.hlsl
 DEST=CompositorD3D11Shaders.h
 
 rm -f $DEST
 echo "struct ShaderBytes { const void* mData; size_t mLength; };" >> $DEST;
 makeShaderVS LayerQuadVS
+makeShaderVS LayerDynamicVS
 makeShaderPS SolidColorShader
 makeShaderPS RGBShader
 makeShaderPS RGBAShader
 makeShaderPS ComponentAlphaShader
 makeShaderPS YCbCrShader
 makeShaderVS LayerQuadMaskVS
+makeShaderVS LayerDynamicMaskVS
 makeShaderPS SolidColorShaderMask
 makeShaderPS RGBShaderMask
 makeShaderPS RGBAShaderMask
 makeShaderPS YCbCrShaderMask
 makeShaderPS ComponentAlphaShaderMask
 
 # Mix-blend shaders
 makeShaderVS LayerQuadBlendVS
 makeShaderVS LayerQuadBlendMaskVS
+makeShaderVS LayerDynamicBlendVS
+makeShaderVS LayerDynamicBlendMaskVS
 makeShaderPS BlendShader
 
 rm $tempfile