Pass through the PSIZE semantic all the way to the fragment shader in D3D11, fixing a register error.

In some cases when the app would draw triangles, and writes to gl_PointSize, the vertex shader would
output PSIZE and the pixel shader would not read it as an input.

TRAC #22561

Signed-off-by: Geoff Lang
Signed-off-by: Shannon Woods
Author: Jamie Madill

git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1933 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/ProgramBinary.cpp b/src/libGLESv2/ProgramBinary.cpp
index c2247a1..3cf1b6d 100644
--- a/src/libGLESv2/ProgramBinary.cpp
+++ b/src/libGLESv2/ProgramBinary.cpp
@@ -1424,6 +1424,13 @@
     {
         pixelHLSL += "    float4 gl_FragCoord : " + fragCoordSemantic + ";\n";
         
+        // Must consume the PSIZE element if the geometry shader is not active
+        // We won't know if we use a GS until we draw
+        if (vertexShader->mUsesPointSize && shaderModel >= 4)
+        {
+            pixelHLSL += "    float gl_PointSize : PSIZE;\n";
+        }
+
         if (shaderModel >= 4)
         {
             pixelHLSL += "    float4 dx_VPos : SV_Position;\n";
@@ -2163,10 +2170,10 @@
 
     geomHLSL += "    float gl_PointSize : PSIZE;\n"
                 "    float4 gl_Position : SV_Position;\n"
-                  "};\n"
-                  "\n"
-                  "struct GS_OUTPUT\n"
-                  "{\n";
+                "};\n"
+                "\n"
+                "struct GS_OUTPUT\n"
+                "{\n";
 
     for (int r = 0; r < registers; r++)
     {
@@ -2185,7 +2192,8 @@
         geomHLSL += "    float2 gl_PointCoord : " + pointCoordSemantic + ";\n";
     }
 
-    geomHLSL +=   "    float4 gl_Position : SV_Position;\n"
+    geomHLSL +=   "    float gl_PointSize : PSIZE;\n"
+                  "    float4 gl_Position : SV_Position;\n"
                   "};\n"
                   "\n"
                   "static float2 pointSpriteCorners[] = \n"
@@ -2210,7 +2218,8 @@
                   "[maxvertexcount(4)]\n"
                   "void main(point GS_INPUT input[1], inout TriangleStream<GS_OUTPUT> outStream)\n"
                   "{\n"
-                  "    GS_OUTPUT output = (GS_OUTPUT)0;\n";
+                  "    GS_OUTPUT output = (GS_OUTPUT)0;\n"
+                  "    output.gl_PointSize = input[0].gl_PointSize;\n";
 
     for (int r = 0; r < registers; r++)
     {