Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(25)

Delta Between Two Patch Sets: src/compiler/OutputHLSL.cpp

Issue 3265041: All surfaces follow D3D Y convention (Closed) Base URL: http://angleproject.googlecode.com/svn/trunk/
Left Patch Set: '' Created 14 years, 3 months ago
Right Patch Set: '' Created 14 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/libEGL/Surface.h » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // 1 //
2 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. 2 // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be 3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file. 4 // found in the LICENSE file.
5 // 5 //
6 6
7 #include "compiler/OutputHLSL.h" 7 #include "compiler/OutputHLSL.h"
8 8
9 #include "compiler/debug.h" 9 #include "compiler/debug.h"
10 #include "compiler/InfoSink.h" 10 #include "compiler/InfoSink.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 188
189 if (mUsesFrontFacing) 189 if (mUsesFrontFacing)
190 { 190 {
191 out << "uniform bool dx_PointsOrLines;\n" 191 out << "uniform bool dx_PointsOrLines;\n"
192 "uniform bool dx_FrontCCW;\n"; 192 "uniform bool dx_FrontCCW;\n";
193 } 193 }
194 ········ 194 ········
195 out << "\n"; 195 out << "\n";
196 out << uniforms; 196 out << uniforms;
197 out << "\n"; 197 out << "\n";
198 198
dgkoch 2010/12/23 20:19:23 It would be worth including a comment here explain
apatrick1 2011/01/07 23:40:22 Done.
199 // The texture fetch functions "flip" the Y coordinate in one way or ano ther. This is because textures are stored
200 // according to the OpenGL convention, i.e. (0, 0) is "bottom left", rat her than the D3D convention where (0, 0)
201 // is "top left". Since the HLSL texture fetch functions expect textures to be stored according to the D3D
202 // convention, the Y coordinate passed to these functions is adjusted to compensate.
203 //
204 // The simplest case is texture2D where the mapping is Y -> 1-Y, which m aps [0, 1] -> [1, 0].
205 //
206 // The texture2DProj functions are more complicated because the projecti on divides by either Z or W. For the vec3
207 // case, the mapping is Y -> Z-Y or Y/Z -> 1-Y/Z, which again maps [0, 1 ] -> [1, 0].
208 //
209 // For cube textures the mapping is Y -> -Y, which maps [-1, 1] -> [1, - 1]. This is not sufficient on its own for the
210 // +Y and -Y faces, which are now on the "wrong sides" of the cube. This is compensated for by exchanging the
211 // +Y and -Y faces everywhere else throughout the code.
212 ········
199 if (mUsesTexture2D) 213 if (mUsesTexture2D)
200 { 214 {
201 out << "float4 gl_texture2D(sampler2D s, float2 t)\n" 215 out << "float4 gl_texture2D(sampler2D s, float2 t)\n"
202 "{\n" 216 "{\n"
203 " return tex2D(s, float2(t.x, 1 - t.y));\n" 217 " return tex2D(s, float2(t.x, 1 - t.y));\n"
204 "}\n" 218 "}\n"
205 "\n"; 219 "\n";
206 } 220 }
207 221
208 if (mUsesTexture2D_bias) 222 if (mUsesTexture2D_bias)
(...skipping 1976 matching lines...) Expand 10 before | Expand all | Expand 10 after
2185 if (string.substr(0, 3) != "gl_" && string.substr(0, 3) != "dx_") 2199 if (string.substr(0, 3) != "gl_" && string.substr(0, 3) != "dx_")
2186 { 2200 {
2187 return "_" + string; 2201 return "_" + string;
2188 } 2202 }
2189 else 2203 else
2190 { 2204 {
2191 return string; 2205 return string;
2192 } 2206 }
2193 } 2207 }
2194 } 2208 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b