Commit 9616e583 by apatrick@chromium.org

Merge no-flip-rows r1142 to trunk.

Review URL: https://codereview.appspot.com/6304052 git-svn-id: https://angleproject.googlecode.com/svn/trunk@1162 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent e6357c0e
#define MAJOR_VERSION 1
#define MINOR_VERSION 0
#define BUILD_VERSION 0
#define BUILD_REVISION 1156
#define BUILD_REVISION 1162
#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
......
......@@ -219,25 +219,11 @@ void OutputHLSL::header()
out << uniforms;
out << "\n";
// The texture fetch functions "flip" the Y coordinate in one way or another. This is because textures are stored
// according to the OpenGL convention, i.e. (0, 0) is "bottom left", rather than the D3D convention where (0, 0)
// is "top left". Since the HLSL texture fetch functions expect textures to be stored according to the D3D
// convention, the Y coordinate passed to these functions is adjusted to compensate.
//
// The simplest case is texture2D where the mapping is Y -> 1-Y, which maps [0, 1] -> [1, 0].
//
// The texture2DProj functions are more complicated because the projection divides by either Z or W. For the vec3
// case, the mapping is Y -> Z-Y or Y/Z -> 1-Y/Z, which again maps [0, 1] -> [1, 0].
//
// For cube textures the mapping is Y -> -Y, which maps [-1, 1] -> [1, -1]. This is not sufficient on its own for the
// +Y and -Y faces, which are now on the "wrong sides" of the cube. This is compensated for by exchanging the
// +Y and -Y faces everywhere else throughout the code.
if (mUsesTexture2D)
{
out << "float4 gl_texture2D(sampler2D s, float2 t)\n"
"{\n"
" return tex2D(s, float2(t.x, 1 - t.y));\n"
" return tex2D(s, t);\n"
"}\n"
"\n";
}
......@@ -246,7 +232,7 @@ void OutputHLSL::header()
{
out << "float4 gl_texture2D(sampler2D s, float2 t, float bias)\n"
"{\n"
" return tex2Dbias(s, float4(t.x, 1 - t.y, 0, bias));\n"
" return tex2Dbias(s, float4(t.x, t.y, 0, bias));\n"
"}\n"
"\n";
}
......@@ -255,12 +241,12 @@ void OutputHLSL::header()
{
out << "float4 gl_texture2DProj(sampler2D s, float3 t)\n"
"{\n"
" return tex2Dproj(s, float4(t.x, t.z - t.y, 0, t.z));\n"
" return tex2Dproj(s, float4(t.x, t.y, 0, t.z));\n"
"}\n"
"\n"
"float4 gl_texture2DProj(sampler2D s, float4 t)\n"
"{\n"
" return tex2Dproj(s, float4(t.x, t.w - t.y, t.z, t.w));\n"
" return tex2Dproj(s, t);\n"
"}\n"
"\n";
}
......@@ -269,12 +255,12 @@ void OutputHLSL::header()
{
out << "float4 gl_texture2DProj(sampler2D s, float3 t, float bias)\n"
"{\n"
" return tex2Dbias(s, float4(t.x / t.z, 1 - (t.y / t.z), 0, bias));\n"
" return tex2Dbias(s, float4(t.x / t.z, t.y / t.z, 0, bias));\n"
"}\n"
"\n"
"float4 gl_texture2DProj(sampler2D s, float4 t, float bias)\n"
"{\n"
" return tex2Dbias(s, float4(t.x / t.w, 1 - (t.y / t.w), 0, bias));\n"
" return tex2Dbias(s, float4(t.x / t.w, t.y / t.w, 0, bias));\n"
"}\n"
"\n";
}
......@@ -283,7 +269,7 @@ void OutputHLSL::header()
{
out << "float4 gl_textureCube(samplerCUBE s, float3 t)\n"
"{\n"
" return texCUBE(s, float3(t.x, -t.y, t.z));\n"
" return texCUBE(s, t);\n"
"}\n"
"\n";
}
......@@ -292,7 +278,7 @@ void OutputHLSL::header()
{
out << "float4 gl_textureCube(samplerCUBE s, float3 t, float bias)\n"
"{\n"
" return texCUBEbias(s, float4(t.x, -t.y, t.z, bias));\n"
" return texCUBEbias(s, float4(t.x, t.y, t.z, bias));\n"
"}\n"
"\n";
}
......@@ -303,7 +289,7 @@ void OutputHLSL::header()
{
out << "float4 gl_texture2DLod0(sampler2D s, float2 t)\n"
"{\n"
" return tex2Dlod(s, float4(t.x, 1 - t.y, 0, 0));\n"
" return tex2Dlod(s, float4(t.x, t.y, 0, 0));\n"
"}\n"
"\n";
}
......@@ -312,7 +298,7 @@ void OutputHLSL::header()
{
out << "float4 gl_texture2DLod0(sampler2D s, float2 t, float bias)\n"
"{\n"
" return tex2Dlod(s, float4(t.x, 1 - t.y, 0, 0));\n"
" return tex2Dlod(s, float4(t.x, t.y, 0, 0));\n"
"}\n"
"\n";
}
......@@ -321,12 +307,12 @@ void OutputHLSL::header()
{
out << "float4 gl_texture2DProjLod0(sampler2D s, float3 t)\n"
"{\n"
" return tex2Dlod(s, float4(t.x / t.z, 1 - t.y / t.z, 0, 0));\n"
" return tex2Dlod(s, float4(t.x / t.z, t.y / t.z, 0, 0));\n"
"}\n"
"\n"
"float4 gl_texture2DProjLod(sampler2D s, float4 t)\n"
"{\n"
" return tex2Dlod(s, float4(t.x / t.w, 1 - t.y / t.w, 0, 0));\n"
" return tex2Dlod(s, float4(t.x / t.w, t.y / t.w, 0, 0));\n"
"}\n"
"\n";
}
......@@ -335,12 +321,12 @@ void OutputHLSL::header()
{
out << "float4 gl_texture2DProjLod0_bias(sampler2D s, float3 t, float bias)\n"
"{\n"
" return tex2Dlod(s, float4(t.x / t.z, 1 - t.y / t.z, 0, 0));\n"
" return tex2Dlod(s, float4(t.x / t.z, t.y / t.z, 0, 0));\n"
"}\n"
"\n"
"float4 gl_texture2DProjLod_bias(sampler2D s, float4 t, float bias)\n"
"{\n"
" return tex2Dlod(s, float4(t.x / t.w, 1 - t.y / t.w, 0, 0));\n"
" return tex2Dlod(s, float4(t.x / t.w, t.y / t.w, 0, 0));\n"
"}\n"
"\n";
}
......@@ -349,7 +335,7 @@ void OutputHLSL::header()
{
out << "float4 gl_textureCubeLod0(samplerCUBE s, float3 t)\n"
"{\n"
" return texCUBElod(s, float4(t.x, -t.y, t.z, 0));\n"
" return texCUBElod(s, float4(t.x, t.y, t.z, 0));\n"
"}\n"
"\n";
}
......@@ -358,7 +344,7 @@ void OutputHLSL::header()
{
out << "float4 gl_textureCubeLod0(samplerCUBE s, float3 t, float bias)\n"
"{\n"
" return texCUBElod(s, float4(t.x, -t.y, t.z, 0));\n"
" return texCUBElod(s, float4(t.x, t.y, t.z, 0));\n"
"}\n"
"\n";
}
......@@ -1232,7 +1218,7 @@ bool OutputHLSL::visitUnary(Visit visit, TIntermUnary *node)
}
else
{
outputTriplet(visit, "(-ddy(", "", "))");
outputTriplet(visit, "ddy(", "", ")");
}
break;
case EOpFwidth:
......
......@@ -69,6 +69,7 @@ private:
Display *const mDisplay;
IDirect3DSwapChain9 *mSwapChain;
IDirect3DSurface9 *mBackBuffer;
IDirect3DSurface9 *mDepthStencil;
IDirect3DSurface9* mRenderTarget;
IDirect3DTexture9* mOffscreenTexture;
......@@ -78,6 +79,7 @@ private:
void subclassWindow();
void unsubclassWindow();
bool resetSwapChain(int backbufferWidth, int backbufferHeight);
bool swapRect(EGLint x, EGLint y, EGLint width, EGLint height);
static DWORD convertInterval(EGLint interval);
const HWND mWindow; // Window that the surface is created for.
......
......@@ -1108,6 +1108,11 @@ EGLBoolean __stdcall eglPostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLi
try
{
if (x < 0 || y < 0 || width < 0 || height < 0)
{
return error(EGL_BAD_PARAMETER, EGL_FALSE);
}
egl::Display *display = static_cast<egl::Display*>(dpy);
egl::Surface *eglSurface = static_cast<egl::Surface*>(surface);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -281,7 +281,7 @@ class Context
void makeCurrent(egl::Display *display, egl::Surface *surface);
void markAllStateDirty();
virtual void markAllStateDirty();
void markDxUniformsDirty();
virtual void markContextLost();
......
......@@ -1391,7 +1391,7 @@ bool ProgramBinary::linkVaryings(std::string& pixelHLSL, std::string& vertexHLSL
"\n"
" VS_OUTPUT output;\n"
" output.gl_Position.x = gl_Position.x - dx_HalfPixelSize.x * gl_Position.w;\n"
" output.gl_Position.y = gl_Position.y - dx_HalfPixelSize.y * gl_Position.w;\n"
" output.gl_Position.y = -(gl_Position.y + dx_HalfPixelSize.y * gl_Position.w);\n"
" output.gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n"
" output.gl_Position.w = gl_Position.w;\n";
......@@ -1524,15 +1524,14 @@ bool ProgramBinary::linkVaryings(std::string& pixelHLSL, std::string& vertexHLSL
if (sm3)
{
// dx_Coord.y contains the render target height. See Context::applyRenderTarget()
pixelHLSL += " gl_FragCoord.x = input.dx_VPos.x + 0.5;\n"
" gl_FragCoord.y = dx_Coord.y - input.dx_VPos.y - 0.5;\n";
" gl_FragCoord.y = input.dx_VPos.y + 0.5;\n";
}
else
{
// dx_Coord contains the viewport width/2, height/2, center.x and center.y. See Context::applyRenderTarget()
pixelHLSL += " gl_FragCoord.x = (input.gl_FragCoord.x * rhw) * dx_Coord.x + dx_Coord.z;\n"
" gl_FragCoord.y = -(input.gl_FragCoord.y * rhw) * dx_Coord.y + dx_Coord.w;\n";
" gl_FragCoord.y = (input.gl_FragCoord.y * rhw) * dx_Coord.y + dx_Coord.w;\n";
}
pixelHLSL += " gl_FragCoord.z = (input.gl_FragCoord.z * rhw) * dx_Depth.x + dx_Depth.y;\n"
......@@ -1541,7 +1540,8 @@ bool ProgramBinary::linkVaryings(std::string& pixelHLSL, std::string& vertexHLSL
if (fragmentShader->mUsesPointCoord && sm3)
{
pixelHLSL += " gl_PointCoord = input.gl_PointCoord;\n";
pixelHLSL += " gl_PointCoord.x = input.gl_PointCoord.x;\n";
pixelHLSL += " gl_PointCoord.y = 1.0 - input.gl_PointCoord.y;\n";
}
if (fragmentShader->mUsesFrontFacing)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -70,26 +70,6 @@ inline unsigned int unorm(float x)
}
}
inline RECT transformPixelRect(GLint x, GLint y, GLint w, GLint h, GLint surfaceHeight)
{
RECT rect = {x,
surfaceHeight - y - h,
x + w,
surfaceHeight - y};
return rect;
}
inline int transformPixelYOffset(GLint yoffset, GLint h, GLint surfaceHeight)
{
return surfaceHeight - yoffset - h;
}
inline GLenum adjustWinding(GLenum winding)
{
ASSERT(winding == GL_CW || winding == GL_CCW);
return winding == GL_CW ? GL_CCW : GL_CW;
}
inline bool supportsSSE2()
{
static bool checked = false;
......
......@@ -612,9 +612,6 @@ D3DCUBEMAP_FACES ConvertCubeFace(GLenum cubeFace)
{
D3DCUBEMAP_FACES face = D3DCUBEMAP_FACE_POSITIVE_X;
// Map a cube map texture target to the corresponding D3D surface index. Note that the
// Y faces are swapped because the Y coordinate to the texture lookup intrinsic functions
// are negated in the pixel shader.
switch (cubeFace)
{
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
......@@ -624,10 +621,10 @@ D3DCUBEMAP_FACES ConvertCubeFace(GLenum cubeFace)
face = D3DCUBEMAP_FACE_NEGATIVE_X;
break;
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
face = D3DCUBEMAP_FACE_NEGATIVE_Y;
face = D3DCUBEMAP_FACE_POSITIVE_Y;
break;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
face = D3DCUBEMAP_FACE_POSITIVE_Y;
face = D3DCUBEMAP_FACE_NEGATIVE_Y;
break;
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
face = D3DCUBEMAP_FACE_POSITIVE_Z;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment