Bug 589395. d3d9: adjust vertex locations in the vertex shader. r=bas,a=blocking

Previously we adjusted the vertex locations directly, now
they have an implicit adjustment that happens in the vertex shader.
This should let us ignore the pixel center differences between
opengl/d3d9/d3d10.
This commit is contained in:
Jeff Muizelaar 2010-09-01 17:10:51 -04:00
parent 46319343f4
commit 8854ffd842
6 changed files with 41 additions and 27 deletions

View File

@ -218,13 +218,13 @@ CanvasLayerD3D9::RenderLayer()
quadTransform[0][0] = (float)mBounds.width;
if (mNeedsYFlip) {
quadTransform[1][1] = (float)-mBounds.height;
quadTransform[3][1] = (float)mBounds.height - 0.5f;
quadTransform[3][1] = (float)mBounds.height;
} else {
quadTransform[1][1] = (float)mBounds.height;
quadTransform[3][1] = -0.5f;
quadTransform[3][1] = 0.0f;
}
quadTransform[2][2] = 1.0f;
quadTransform[3][0] = -0.5f;
quadTransform[3][0] = 0.0f;
quadTransform[3][3] = 1.0f;
device()->SetVertexShaderConstantF(0, &quadTransform[0][0], 4);

View File

@ -239,8 +239,8 @@ ContainerLayerD3D9::RenderLayer()
quadTransform[0][0] = (float)visibleRect.width;
quadTransform[1][1] = (float)visibleRect.height;
quadTransform[2][2] = 1.0f;
quadTransform[3][0] = (float)visibleRect.x - 0.5f;
quadTransform[3][1] = (float)visibleRect.y - 0.5f;
quadTransform[3][0] = (float)visibleRect.x;
quadTransform[3][1] = (float)visibleRect.y;
quadTransform[3][3] = 1.0f;
device()->SetVertexShaderConstantF(0, &quadTransform[0][0], 4);

View File

@ -172,8 +172,8 @@ ImageLayerD3D9::RenderLayer()
* beyond all edges.
*/
memset(&quadTransform, 0, sizeof(quadTransform));
quadTransform[0][0] = (float)yuvImage->mSize.width + 0.5f;
quadTransform[1][1] = (float)yuvImage->mSize.height + 0.5f;
quadTransform[0][0] = (float)yuvImage->mSize.width;
quadTransform[1][1] = (float)yuvImage->mSize.height;
quadTransform[2][2] = 1.0f;
quadTransform[3][3] = 1.0f;
@ -226,8 +226,8 @@ ImageLayerD3D9::RenderLayer()
* beyond all edges.
*/
memset(&quadTransform, 0, sizeof(quadTransform));
quadTransform[0][0] = (float)cairoImage->mSize.width + 0.5f;
quadTransform[1][1] = (float)cairoImage->mSize.height + 0.5f;
quadTransform[0][0] = (float)cairoImage->mSize.width;
quadTransform[1][1] = (float)cairoImage->mSize.height;
quadTransform[2][2] = 1.0f;
quadTransform[3][3] = 1.0f;

View File

@ -25,6 +25,7 @@
//
vs_2_0
def c13, -0.5, 0, 0, 0
dcl_position v0
mul r0, v0.y, c1
mad r0, c0, v0.x, r0
@ -35,13 +36,14 @@
mad r1, c6, r0.z, r1
mad r0, c7, r0.w, r1
add r0, r0, -c12
add r0.xy, r0, c13.x
mul r1, r0.y, c9
mad r1, c8, r0.x, r1
mad r1, c10, r0.z, r1
mad oPos, c11, r0.w, r1
mov oT0.xy, v0
// approximately 14 instruction slots used
// approximately 15 instruction slots used
#endif
const BYTE LayerQuadVS[] =
@ -92,6 +94,10 @@ const BYTE LayerQuadVS[] =
108, 101, 114, 32, 57, 46,
50, 57, 46, 57, 53, 50,
46, 51, 49, 49, 49, 0,
81, 0, 0, 5, 13, 0,
15, 160, 0, 0, 0, 191,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
31, 0, 0, 2, 0, 0,
0, 128, 0, 0, 15, 144,
5, 0, 0, 3, 0, 0,
@ -122,22 +128,24 @@ const BYTE LayerQuadVS[] =
228, 128, 2, 0, 0, 3,
0, 0, 15, 128, 0, 0,
228, 128, 12, 0, 228, 161,
5, 0, 0, 3, 1, 0,
15, 128, 0, 0, 85, 128,
9, 0, 228, 160, 4, 0,
2, 0, 0, 3, 0, 0,
3, 128, 0, 0, 228, 128,
13, 0, 0, 160, 5, 0,
0, 3, 1, 0, 15, 128,
0, 0, 85, 128, 9, 0,
228, 160, 4, 0, 0, 4,
1, 0, 15, 128, 8, 0,
228, 160, 0, 0, 0, 128,
1, 0, 228, 128, 4, 0,
0, 4, 1, 0, 15, 128,
8, 0, 228, 160, 0, 0,
0, 128, 1, 0, 228, 128,
4, 0, 0, 4, 1, 0,
15, 128, 10, 0, 228, 160,
0, 0, 170, 128, 1, 0,
228, 128, 4, 0, 0, 4,
0, 0, 15, 192, 11, 0,
228, 160, 0, 0, 255, 128,
1, 0, 228, 128, 1, 0,
0, 2, 0, 0, 3, 224,
0, 0, 228, 144, 255, 255,
0, 0
10, 0, 228, 160, 0, 0,
170, 128, 1, 0, 228, 128,
4, 0, 0, 4, 0, 0,
15, 192, 11, 0, 228, 160,
0, 0, 255, 128, 1, 0,
228, 128, 1, 0, 0, 2,
0, 0, 3, 224, 0, 0,
228, 144, 255, 255, 0, 0
};
#if 0
//

View File

@ -28,7 +28,13 @@ VS_OUTPUT LayerQuadVS(const VS_INPUT aVertex)
outp.vPosition = mul(mLayerQuadTransform, outp.vPosition);
outp.vPosition = mul(mLayerTransform, outp.vPosition);
outp.vPosition = outp.vPosition - vRenderTargetOffset;
// adjust our vertices to match d3d9's pixel coordinate system
// which has pixel centers at integer locations
outp.vPosition.xy -= 0.5;
outp.vPosition = mul(mProjection, outp.vPosition);
outp.vTexCoords = aVertex.vPosition.xy;
return outp;
}

View File

@ -239,8 +239,8 @@ ThebesLayerD3D9::RenderLayer()
quadTransform[0][0] = (float)visibleRect.width;
quadTransform[1][1] = (float)visibleRect.height;
quadTransform[2][2] = 1.0f;
quadTransform[3][0] = (float)visibleRect.x - 0.5f;
quadTransform[3][1] = (float)visibleRect.y - 0.5f;
quadTransform[3][0] = (float)visibleRect.x;
quadTransform[3][1] = (float)visibleRect.y;
quadTransform[3][3] = 1.0f;
device()->SetVertexShaderConstantF(0, &quadTransform[0][0], 4);