Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
angle
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
angle
Commits
9b5f5443
Commit
9b5f5443
authored
Mar 16, 2010
by
daniel@transgaming.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Compiler - implement gl_FragCoord
TRAC #11381 Signed-off-by: Daniel Koch git-svn-id:
https://angleproject.googlecode.com/svn/trunk@21
736b8ea6-26fd-11df-bfd4-992fa37f6226
parent
998dd9ff
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
9 deletions
+35
-9
OutputHLSL.cpp
Compiler/OutputHLSL.cpp
+20
-8
OutputHLSL.h
Compiler/OutputHLSL.h
+5
-0
Context.cpp
libGLESv2/Context.cpp
+8
-0
Shader.cpp
libGLESv2/Shader.cpp
+2
-1
No files found.
Compiler/OutputHLSL.cpp
View file @
9b5f5443
...
@@ -56,12 +56,16 @@ void OutputHLSL::header()
...
@@ -56,12 +56,16 @@ void OutputHLSL::header()
}
}
}
}
out
<<
"uniform float4 gl_Window;
\n
"
"uniform float2 gl_Depth;
\n
"
"
\n
"
;
out
<<
uniforms
;
out
<<
uniforms
;
out
<<
"
\n
"
out
<<
"
\n
"
"struct PS_INPUT
\n
"
// FIXME: Prevent name clashes
"struct PS_INPUT
\n
"
// FIXME: Prevent name clashes
"{
\n
"
;
"{
\n
"
;
out
<<
varyingInput
;
out
<<
varyingInput
;
out
<<
"};
\n
"
out
<<
" float4 gl_FragCoord : TEXCOORD"
<<
HLSL_FRAG_COORD_SEMANTIC
<<
";
\n
"
"};
\n
"
"
\n
"
;
"
\n
"
;
out
<<
varyingGlobals
;
out
<<
varyingGlobals
;
out
<<
"
\n
"
out
<<
"
\n
"
...
@@ -71,6 +75,7 @@ void OutputHLSL::header()
...
@@ -71,6 +75,7 @@ void OutputHLSL::header()
"};
\n
"
"};
\n
"
"
\n
"
"
\n
"
"static float4 gl_Color[1] = {float4(0, 0, 0, 0)};
\n
"
"static float4 gl_Color[1] = {float4(0, 0, 0, 0)};
\n
"
"static float4 gl_FragCoord = float4(0, 0, 0, 0);
\n
"
"
\n
"
"
\n
"
"float4 gl_texture2D(sampler2D s, float2 t)
\n
"
"float4 gl_texture2D(sampler2D s, float2 t)
\n
"
"{
\n
"
"{
\n
"
...
@@ -141,13 +146,13 @@ void OutputHLSL::header()
...
@@ -141,13 +146,13 @@ void OutputHLSL::header()
}
}
}
}
out
<<
"uniform float2 gl_HalfPixelSize;
\n
"
;
out
<<
"uniform float2 gl_HalfPixelSize;
\n
"
out
<<
"
\n
"
;
"
\n
"
;
out
<<
uniforms
;
out
<<
uniforms
;
out
<<
"
\n
"
;
out
<<
"
\n
"
;
out
<<
globals
;
out
<<
globals
;
out
<<
"
\n
"
;
out
<<
"
\n
"
out
<<
"struct VS_INPUT
\n
"
// FIXME: Prevent name clashes
"struct VS_INPUT
\n
"
// FIXME: Prevent name clashes
"{
\n
"
;
"{
\n
"
;
out
<<
attributeInput
;
out
<<
attributeInput
;
out
<<
"};
\n
"
out
<<
"};
\n
"
...
@@ -157,7 +162,8 @@ void OutputHLSL::header()
...
@@ -157,7 +162,8 @@ void OutputHLSL::header()
"struct VS_OUTPUT
\n
"
// FIXME: Prevent name clashes
"struct VS_OUTPUT
\n
"
// FIXME: Prevent name clashes
"{
\n
"
"{
\n
"
" float4 gl_Position : POSITION;
\n
"
" float4 gl_Position : POSITION;
\n
"
" float gl_PointSize : PSIZE;
\n
"
;
" float gl_PointSize : PSIZE;
\n
"
" float4 gl_FragCoord : TEXCOORD"
<<
HLSL_FRAG_COORD_SEMANTIC
<<
";
\n
"
;
out
<<
varyingOutput
;
out
<<
varyingOutput
;
out
<<
"};
\n
"
out
<<
"};
\n
"
"
\n
"
"
\n
"
...
@@ -624,7 +630,12 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
...
@@ -624,7 +630,12 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
if
(
language
==
EShLangFragment
)
if
(
language
==
EShLangFragment
)
{
{
out
<<
"PS_OUTPUT main(PS_INPUT input)
\n
"
// FIXME: Prevent name clashes
out
<<
"PS_OUTPUT main(PS_INPUT input)
\n
"
// FIXME: Prevent name clashes
"{
\n
"
;
"{
\n
"
" float rhw = 1.0 / input.gl_FragCoord.w;
\n
"
" 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
"
;
for
(
TSymbolTableLevel
::
const_iterator
namedSymbol
=
symbols
->
begin
();
namedSymbol
!=
symbols
->
end
();
namedSymbol
++
)
for
(
TSymbolTableLevel
::
const_iterator
namedSymbol
=
symbols
->
begin
();
namedSymbol
!=
symbols
->
end
();
namedSymbol
++
)
{
{
...
@@ -728,7 +739,8 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
...
@@ -728,7 +739,8 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
" output.gl_Position.y = -(gl_Position.y - gl_HalfPixelSize.y * gl_Position.w);
\n
"
" output.gl_Position.y = -(gl_Position.y - gl_HalfPixelSize.y * gl_Position.w);
\n
"
" output.gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;
\n
"
" output.gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;
\n
"
" output.gl_Position.w = gl_Position.w;
\n
"
" output.gl_Position.w = gl_Position.w;
\n
"
" output.gl_PointSize = gl_PointSize;
\n
"
;
" output.gl_PointSize = gl_PointSize;
\n
"
" output.gl_FragCoord = gl_Position;
\n
"
;
TSymbolTableLevel
*
symbols
=
context
.
symbolTable
.
getGlobalLevel
();
TSymbolTableLevel
*
symbols
=
context
.
symbolTable
.
getGlobalLevel
();
...
...
Compiler/OutputHLSL.h
View file @
9b5f5443
...
@@ -12,6 +12,11 @@
...
@@ -12,6 +12,11 @@
namespace
sh
namespace
sh
{
{
enum
{
HLSL_FRAG_COORD_SEMANTIC
=
15
// Semantic index assigned to the gl_FragCoord varying
};
class
OutputHLSL
:
public
TIntermTraverser
class
OutputHLSL
:
public
TIntermTraverser
{
{
public
:
public
:
...
...
libGLESv2/Context.cpp
View file @
9b5f5443
...
@@ -796,6 +796,14 @@ bool Context::applyRenderTarget(bool ignoreViewport)
...
@@ -796,6 +796,14 @@ bool Context::applyRenderTarget(bool ignoreViewport)
GLfloat
xy
[
2
]
=
{
1.0
f
/
description
.
Width
,
1.0
f
/
description
.
Height
};
GLfloat
xy
[
2
]
=
{
1.0
f
/
description
.
Width
,
1.0
f
/
description
.
Height
};
programObject
->
setUniform2fv
(
halfPixelSize
,
1
,
(
GLfloat
*
)
&
xy
);
programObject
->
setUniform2fv
(
halfPixelSize
,
1
,
(
GLfloat
*
)
&
xy
);
GLuint
window
=
programObject
->
getUniformLocation
(
"gl_Window"
);
GLfloat
whxy
[
4
]
=
{
viewportWidth
/
2.0
f
,
viewportHeight
/
2.0
f
,
(
float
)
viewportX
+
viewportWidth
/
2.0
f
,
(
float
)
viewportY
+
viewportHeight
/
2.0
f
};
programObject
->
setUniform4fv
(
window
,
1
,
(
GLfloat
*
)
&
whxy
);
GLuint
depth
=
programObject
->
getUniformLocation
(
"gl_Depth"
);
GLfloat
dz
[
2
]
=
{(
zFar
-
zNear
)
/
2.0
f
,
(
zNear
+
zFar
)
/
2.0
f
};
programObject
->
setUniform2fv
(
depth
,
1
,
(
GLfloat
*
)
&
dz
);
GLuint
near
=
programObject
->
getUniformLocation
(
"gl_DepthRange.near"
);
GLuint
near
=
programObject
->
getUniformLocation
(
"gl_DepthRange.near"
);
programObject
->
setUniform1fv
(
near
,
1
,
&
zNear
);
programObject
->
setUniform1fv
(
near
,
1
,
&
zNear
);
...
...
libGLESv2/Shader.cpp
View file @
9b5f5443
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
#include "main.h"
#include "main.h"
#include "Shaderlang.h"
#include "Shaderlang.h"
#include "OutputHLSL.h"
#include "debug.h"
#include "debug.h"
namespace
gl
namespace
gl
...
@@ -236,7 +237,7 @@ const char *VertexShader::linkHLSL(const char *pixelHLSL)
...
@@ -236,7 +237,7 @@ const char *VertexShader::linkHLSL(const char *pixelHLSL)
unsigned
int
semanticIndex
;
unsigned
int
semanticIndex
;
int
matches
=
sscanf
(
input
,
"%s : TEXCOORD%d;"
,
varyingName
,
&
semanticIndex
);
int
matches
=
sscanf
(
input
,
"%s : TEXCOORD%d;"
,
varyingName
,
&
semanticIndex
);
if
(
matches
==
2
)
if
(
matches
==
2
&&
semanticIndex
!=
sh
::
HLSL_FRAG_COORD_SEMANTIC
)
{
{
ASSERT
(
semanticIndex
<
MAX_VARYING_VECTORS
);
ASSERT
(
semanticIndex
<
MAX_VARYING_VECTORS
);
char
*
varying
=
strstr
(
output
,
varyingName
);
char
*
varying
=
strstr
(
output
,
varyingName
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment