зеркало из https://github.com/AvaloniaUI/angle.git
Compiler - implement gl_FrontFacing
TRAC #11368 Signed-off-by: Andrew Lewycky Signed-off-by: Daniel Koch From: Nicolas Capens <nicolas@transgaming.com> git-svn-id: https://angleproject.googlecode.com/svn/trunk@22 736b8ea6-26fd-11df-bfd4-992fa37f6226
This commit is contained in:
Родитель
9b5f5443d6
Коммит
79b820b73a
|
@ -58,13 +58,15 @@ void OutputHLSL::header()
|
|||
|
||||
out << "uniform float4 gl_Window;\n"
|
||||
"uniform float2 gl_Depth;\n"
|
||||
"uniform bool __frontCCW;\n"
|
||||
"\n";
|
||||
out << uniforms;
|
||||
out << "\n"
|
||||
"struct PS_INPUT\n" // FIXME: Prevent name clashes
|
||||
"{\n";
|
||||
out << varyingInput;
|
||||
out << " float4 gl_FragCoord : TEXCOORD" << HLSL_FRAG_COORD_SEMANTIC << ";\n"
|
||||
out << " float4 gl_FragCoord : TEXCOORD" << HLSL_FRAG_COORD_SEMANTIC << ";\n";
|
||||
out << " float __vFace : VFACE;\n"
|
||||
"};\n"
|
||||
"\n";
|
||||
out << varyingGlobals;
|
||||
|
@ -76,6 +78,7 @@ void OutputHLSL::header()
|
|||
"\n"
|
||||
"static float4 gl_Color[1] = {float4(0, 0, 0, 0)};\n"
|
||||
"static float4 gl_FragCoord = float4(0, 0, 0, 0);\n"
|
||||
"static bool gl_FrontFacing = false;\n"
|
||||
"\n"
|
||||
"float4 gl_texture2D(sampler2D s, float2 t)\n"
|
||||
"{\n"
|
||||
|
@ -635,7 +638,8 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
|
|||
" gl_FragCoord.x = (input.gl_FragCoord.x * rhw) * gl_Window.x + gl_Window.z;\n"
|
||||
" gl_FragCoord.y = (input.gl_FragCoord.y * rhw) * gl_Window.y + gl_Window.w;\n"
|
||||
" gl_FragCoord.z = (input.gl_FragCoord.z * rhw) * gl_Depth.x + gl_Depth.y;\n"
|
||||
" gl_FragCoord.w = rhw;\n";
|
||||
" gl_FragCoord.w = rhw;\n"
|
||||
" gl_FrontFacing = __frontCCW ? (input.__vFace >= 0.0) : (input.__vFace <= 0.0);\n";
|
||||
|
||||
for (TSymbolTableLevel::const_iterator namedSymbol = symbols->begin(); namedSymbol != symbols->end(); namedSymbol++)
|
||||
{
|
||||
|
|
|
@ -792,25 +792,25 @@ bool Context::applyRenderTarget(bool ignoreViewport)
|
|||
renderTarget->GetDesc(&description);
|
||||
Program *programObject = getCurrentProgram();
|
||||
|
||||
GLuint halfPixelSize = programObject->getUniformLocation("gl_HalfPixelSize");
|
||||
GLint halfPixelSize = programObject->getUniformLocation("gl_HalfPixelSize");
|
||||
GLfloat xy[2] = {1.0f / description.Width, 1.0f / description.Height};
|
||||
programObject->setUniform2fv(halfPixelSize, 1, (GLfloat*)&xy);
|
||||
|
||||
GLuint window = programObject->getUniformLocation("gl_Window");
|
||||
GLint window = programObject->getUniformLocation("gl_Window");
|
||||
GLfloat whxy[4] = {viewportWidth / 2.0f, viewportHeight / 2.0f, (float)viewportX + viewportWidth / 2.0f, (float)viewportY + viewportHeight / 2.0f};
|
||||
programObject->setUniform4fv(window, 1, (GLfloat*)&whxy);
|
||||
|
||||
GLuint depth = programObject->getUniformLocation("gl_Depth");
|
||||
GLint depth = programObject->getUniformLocation("gl_Depth");
|
||||
GLfloat dz[2] = {(zFar - zNear) / 2.0f, (zNear + zFar) / 2.0f};
|
||||
programObject->setUniform2fv(depth, 1, (GLfloat*)&dz);
|
||||
|
||||
GLuint near = programObject->getUniformLocation("gl_DepthRange.near");
|
||||
GLint near = programObject->getUniformLocation("gl_DepthRange.near");
|
||||
programObject->setUniform1fv(near, 1, &zNear);
|
||||
|
||||
GLuint far = programObject->getUniformLocation("gl_DepthRange.far");
|
||||
GLint far = programObject->getUniformLocation("gl_DepthRange.far");
|
||||
programObject->setUniform1fv(far, 1, &zFar);
|
||||
|
||||
GLuint diff = programObject->getUniformLocation("gl_DepthRange.diff");
|
||||
GLint diff = programObject->getUniformLocation("gl_DepthRange.diff");
|
||||
GLfloat zDiff = zFar - zNear;
|
||||
programObject->setUniform1fv(diff, 1, &zDiff);
|
||||
}
|
||||
|
@ -822,6 +822,11 @@ bool Context::applyRenderTarget(bool ignoreViewport)
|
|||
void Context::applyState()
|
||||
{
|
||||
IDirect3DDevice9 *device = getDevice();
|
||||
Program *programObject = getCurrentProgram();
|
||||
|
||||
GLint frontCCW = programObject->getUniformLocation("__frontCCW");
|
||||
GLint ccw = (frontFace == GL_CCW);
|
||||
programObject->setUniform1iv(frontCCW, 1, &ccw);
|
||||
|
||||
if (cullFace)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче