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
a5a1dfc6
Commit
a5a1dfc6
authored
Sep 23, 2013
by
Zhenyao Mo
Committed by
Jamie Madill
Sep 24, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support precision for sampler types.
BUG= R=alokp@chromium.org Review URL:
https://codereview.appspot.com/12833045
parent
bc3f1ac6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
10 deletions
+24
-10
Compiler.cpp
src/compiler/Compiler.cpp
+12
-0
SymbolTable.h
src/compiler/SymbolTable.h
+12
-10
No files found.
src/compiler/Compiler.cpp
View file @
a5a1dfc6
...
@@ -241,6 +241,11 @@ bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources)
...
@@ -241,6 +241,11 @@ bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources)
floatingPoint
.
secondarySize
=
1
;
floatingPoint
.
secondarySize
=
1
;
floatingPoint
.
array
=
false
;
floatingPoint
.
array
=
false
;
TPublicType
sampler
;
sampler
.
primarySize
=
1
;
sampler
.
secondarySize
=
1
;
sampler
.
array
=
false
;
switch
(
shaderType
)
switch
(
shaderType
)
{
{
case
SH_FRAGMENT_SHADER
:
case
SH_FRAGMENT_SHADER
:
...
@@ -252,6 +257,13 @@ bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources)
...
@@ -252,6 +257,13 @@ bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources)
break
;
break
;
default
:
assert
(
false
&&
"Language not supported"
);
default
:
assert
(
false
&&
"Language not supported"
);
}
}
// We set defaults for all the sampler types, even those that are
// only available if an extension exists.
for
(
int
samplerType
=
EbtGuardSamplerBegin
+
1
;
samplerType
<
EbtGuardSamplerEnd
;
++
samplerType
)
{
sampler
.
type
=
static_cast
<
TBasicType
>
(
samplerType
);
symbolTable
.
setDefaultPrecision
(
sampler
,
EbpLow
);
}
InsertBuiltInFunctions
(
shaderType
,
shaderSpec
,
resources
,
symbolTable
);
InsertBuiltInFunctions
(
shaderType
,
shaderSpec
,
resources
,
symbolTable
);
...
...
src/compiler/SymbolTable.h
View file @
a5a1dfc6
...
@@ -332,10 +332,8 @@ public:
...
@@ -332,10 +332,8 @@ public:
void
dump
(
TInfoSink
&
infoSink
)
const
;
void
dump
(
TInfoSink
&
infoSink
)
const
;
bool
setDefaultPrecision
(
const
TPublicType
&
type
,
TPrecision
prec
)
{
bool
setDefaultPrecision
(
const
TPublicType
&
type
,
TPrecision
prec
)
{
if
(
IsSampler
(
type
.
type
))
if
(
!
supportsPrecision
(
type
.
type
))
return
true
;
// Skip sampler types for the time being
return
false
;
if
(
type
.
type
!=
EbtFloat
&&
type
.
type
!=
EbtInt
)
return
false
;
// Only set default precision for int/float
if
(
type
.
isAggregate
())
if
(
type
.
isAggregate
())
return
false
;
// Not allowed to set for aggregate types
return
false
;
// Not allowed to set for aggregate types
int
indexOfLastElement
=
static_cast
<
int
>
(
precisionStack
.
size
())
-
1
;
int
indexOfLastElement
=
static_cast
<
int
>
(
precisionStack
.
size
())
-
1
;
...
@@ -346,19 +344,18 @@ public:
...
@@ -346,19 +344,18 @@ public:
// Searches down the precisionStack for a precision qualifier for the specified TBasicType
// Searches down the precisionStack for a precision qualifier for the specified TBasicType
TPrecision
getDefaultPrecision
(
TBasicType
type
){
TPrecision
getDefaultPrecision
(
TBasicType
type
){
// unsigned integers use the same precision as signed
if
(
!
supportsPrecision
(
type
))
if
(
type
==
EbtUInt
)
type
=
EbtInt
;
if
(
type
!=
EbtFloat
&&
type
!=
EbtInt
)
return
EbpUndefined
;
return
EbpUndefined
;
// unsigned integers use the same precision as signed
TBasicType
baseType
=
(
type
==
EbtUInt
)
?
EbtInt
:
type
;
int
level
=
static_cast
<
int
>
(
precisionStack
.
size
())
-
1
;
int
level
=
static_cast
<
int
>
(
precisionStack
.
size
())
-
1
;
assert
(
level
>=
0
);
// Just to be safe. Should not happen.
assert
(
level
>=
0
);
// Just to be safe. Should not happen.
PrecisionStackLevel
::
iterator
it
;
PrecisionStackLevel
::
iterator
it
;
TPrecision
prec
=
EbpUndefined
;
// If we dont find anything we return this. Should we error check this?
TPrecision
prec
=
EbpUndefined
;
// If we dont find anything we return this. Should we error check this?
while
(
level
>=
0
)
{
while
(
level
>=
0
)
{
it
=
precisionStack
[
level
]
->
find
(
t
ype
);
it
=
precisionStack
[
level
]
->
find
(
baseT
ype
);
if
(
it
!=
precisionStack
[
level
]
->
end
())
{
if
(
it
!=
precisionStack
[
level
]
->
end
())
{
prec
=
(
*
it
).
second
;
prec
=
(
*
it
).
second
;
break
;
break
;
...
@@ -371,6 +368,11 @@ public:
...
@@ -371,6 +368,11 @@ public:
private
:
private
:
ESymbolLevel
currentLevel
()
const
{
return
static_cast
<
ESymbolLevel
>
(
table
.
size
()
-
1
);
}
ESymbolLevel
currentLevel
()
const
{
return
static_cast
<
ESymbolLevel
>
(
table
.
size
()
-
1
);
}
bool
supportsPrecision
(
TBasicType
type
)
{
// Only supports precision for int, float, and sampler types.
return
type
==
EbtFloat
||
type
==
EbtInt
||
type
==
EbtUInt
||
IsSampler
(
type
);
}
std
::
vector
<
TSymbolTableLevel
*>
table
;
std
::
vector
<
TSymbolTableLevel
*>
table
;
typedef
TMap
<
TBasicType
,
TPrecision
>
PrecisionStackLevel
;
typedef
TMap
<
TBasicType
,
TPrecision
>
PrecisionStackLevel
;
std
::
vector
<
PrecisionStackLevel
*>
precisionStack
;
std
::
vector
<
PrecisionStackLevel
*>
precisionStack
;
...
...
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