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
75fb4752
Commit
75fb4752
authored
Jul 10, 2013
by
Nicolas Capens
Committed by
Shannon Woods
Jul 19, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement textureSize.
TRAC #23485 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods Author: Nicolas Capens
parent
c98406ab
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
121 additions
and
38 deletions
+121
-38
Initialize.cpp
src/compiler/Initialize.cpp
+14
-0
OutputHLSL.cpp
src/compiler/OutputHLSL.cpp
+102
-34
OutputHLSL.h
src/compiler/OutputHLSL.h
+5
-4
No files found.
src/compiler/Initialize.cpp
View file @
75fb4752
...
...
@@ -22,6 +22,7 @@ void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltI
TType
*
float3
=
new
TType
(
EbtFloat
,
EbpUndefined
,
EvqGlobal
,
3
);
TType
*
float4
=
new
TType
(
EbtFloat
,
EbpUndefined
,
EvqGlobal
,
4
);
TType
*
int1
=
new
TType
(
EbtInt
,
EbpUndefined
,
EvqGlobal
,
1
);
TType
*
int2
=
new
TType
(
EbtInt
,
EbpUndefined
,
EvqGlobal
,
2
);
TType
*
int3
=
new
TType
(
EbtInt
,
EbpUndefined
,
EvqGlobal
,
3
);
TType
*
int4
=
new
TType
(
EbtInt
,
EbpUndefined
,
EvqGlobal
,
4
);
...
...
@@ -459,6 +460,19 @@ void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltI
symbolTable
.
insertBuiltIn
(
ESSL3_BUILTINS
,
uint4
,
"textureProj"
,
usampler3D
,
"sampler"
,
float4
,
"coord"
,
float1
,
"bias"
);
}
symbolTable
.
insertBuiltIn
(
ESSL3_BUILTINS
,
int2
,
"textureSize"
,
sampler2D
,
"sampler"
,
int1
,
"lod"
);
symbolTable
.
insertBuiltIn
(
ESSL3_BUILTINS
,
int2
,
"textureSize"
,
isampler2D
,
"sampler"
,
int1
,
"lod"
);
symbolTable
.
insertBuiltIn
(
ESSL3_BUILTINS
,
int2
,
"textureSize"
,
usampler2D
,
"sampler"
,
int1
,
"lod"
);
symbolTable
.
insertBuiltIn
(
ESSL3_BUILTINS
,
int3
,
"textureSize"
,
sampler3D
,
"sampler"
,
int1
,
"lod"
);
symbolTable
.
insertBuiltIn
(
ESSL3_BUILTINS
,
int3
,
"textureSize"
,
isampler3D
,
"sampler"
,
int1
,
"lod"
);
symbolTable
.
insertBuiltIn
(
ESSL3_BUILTINS
,
int3
,
"textureSize"
,
usampler3D
,
"sampler"
,
int1
,
"lod"
);
symbolTable
.
insertBuiltIn
(
ESSL3_BUILTINS
,
int2
,
"textureSize"
,
samplerCube
,
"sampler"
,
int1
,
"lod"
);
symbolTable
.
insertBuiltIn
(
ESSL3_BUILTINS
,
int2
,
"textureSize"
,
isamplerCube
,
"sampler"
,
int1
,
"lod"
);
symbolTable
.
insertBuiltIn
(
ESSL3_BUILTINS
,
int2
,
"textureSize"
,
usamplerCube
,
"sampler"
,
int1
,
"lod"
);
symbolTable
.
insertBuiltIn
(
ESSL3_BUILTINS
,
int3
,
"textureSize"
,
sampler2DArray
,
"sampler"
,
int1
,
"lod"
);
symbolTable
.
insertBuiltIn
(
ESSL3_BUILTINS
,
int3
,
"textureSize"
,
isampler2DArray
,
"sampler"
,
int1
,
"lod"
);
symbolTable
.
insertBuiltIn
(
ESSL3_BUILTINS
,
int3
,
"textureSize"
,
usampler2DArray
,
"sampler"
,
int1
,
"lod"
);
if
(
type
==
SH_FRAGMENT_SHADER
)
{
symbolTable
.
insertBuiltIn
(
ESSL3_BUILTINS
,
float1
,
"dFdx"
,
float1
,
"p"
);
...
...
src/compiler/OutputHLSL.cpp
View file @
75fb4752
...
...
@@ -53,12 +53,13 @@ TString OutputHLSL::TextureFunction::name() const
name
+=
"Proj"
;
}
switch
(
m
ipmap
)
switch
(
m
ethod
)
{
case
IMPLICIT
:
break
;
case
BIAS
:
break
;
case
LOD
:
name
+=
"Lod"
;
break
;
case
LOD0
:
name
+=
"Lod0"
;
break
;
case
SIZE
:
name
+=
"Size"
;
break
;
default
:
UNREACHABLE
();
}
...
...
@@ -70,7 +71,7 @@ bool OutputHLSL::TextureFunction::operator<(const TextureFunction &rhs) const
if
(
sampler
<
rhs
.
sampler
)
return
true
;
if
(
coords
<
rhs
.
coords
)
return
true
;
if
(
!
proj
&&
rhs
.
proj
)
return
true
;
if
(
m
ipmap
<
rhs
.
mipmap
)
return
true
;
if
(
m
ethod
<
rhs
.
method
)
return
true
;
return
false
;
}
...
...
@@ -883,21 +884,43 @@ void OutputHLSL::header()
for
(
TextureFunctionSet
::
const_iterator
textureFunction
=
mUsesTexture
.
begin
();
textureFunction
!=
mUsesTexture
.
end
();
textureFunction
++
)
{
// Return type
switch
(
textureFunction
->
sampler
)
{
case
EbtSampler2D
:
out
<<
"float4 "
;
break
;
case
EbtSampler3D
:
out
<<
"float4 "
;
break
;
case
EbtSamplerCube
:
out
<<
"float4 "
;
break
;
case
EbtSampler2DArray
:
out
<<
"float4 "
;
break
;
case
EbtISampler2D
:
out
<<
"int4 "
;
break
;
case
EbtISampler3D
:
out
<<
"int4 "
;
break
;
case
EbtISamplerCube
:
out
<<
"int4 "
;
break
;
case
EbtISampler2DArray
:
out
<<
"int4 "
;
break
;
case
EbtUSampler2D
:
out
<<
"uint4 "
;
break
;
case
EbtUSampler3D
:
out
<<
"uint4 "
;
break
;
case
EbtUSamplerCube
:
out
<<
"uint4 "
;
break
;
case
EbtUSampler2DArray
:
out
<<
"uint4 "
;
break
;
default
:
UNREACHABLE
();
if
(
textureFunction
->
method
==
TextureFunction
::
SIZE
)
{
switch
(
textureFunction
->
sampler
)
{
case
EbtSampler2D
:
out
<<
"int2 "
;
break
;
case
EbtSampler3D
:
out
<<
"int3 "
;
break
;
case
EbtSamplerCube
:
out
<<
"int2 "
;
break
;
case
EbtSampler2DArray
:
out
<<
"int3 "
;
break
;
case
EbtISampler2D
:
out
<<
"int2 "
;
break
;
case
EbtISampler3D
:
out
<<
"int3 "
;
break
;
case
EbtISamplerCube
:
out
<<
"int2 "
;
break
;
case
EbtISampler2DArray
:
out
<<
"int3 "
;
break
;
case
EbtUSampler2D
:
out
<<
"int2 "
;
break
;
case
EbtUSampler3D
:
out
<<
"int3 "
;
break
;
case
EbtUSamplerCube
:
out
<<
"int2 "
;
break
;
case
EbtUSampler2DArray
:
out
<<
"int3 "
;
break
;
default
:
UNREACHABLE
();
}
}
else
// Sampling function
{
switch
(
textureFunction
->
sampler
)
{
case
EbtSampler2D
:
out
<<
"float4 "
;
break
;
case
EbtSampler3D
:
out
<<
"float4 "
;
break
;
case
EbtSamplerCube
:
out
<<
"float4 "
;
break
;
case
EbtSampler2DArray
:
out
<<
"float4 "
;
break
;
case
EbtISampler2D
:
out
<<
"int4 "
;
break
;
case
EbtISampler3D
:
out
<<
"int4 "
;
break
;
case
EbtISamplerCube
:
out
<<
"int4 "
;
break
;
case
EbtISampler2DArray
:
out
<<
"int4 "
;
break
;
case
EbtUSampler2D
:
out
<<
"uint4 "
;
break
;
case
EbtUSampler3D
:
out
<<
"uint4 "
;
break
;
case
EbtUSamplerCube
:
out
<<
"uint4 "
;
break
;
case
EbtUSampler2DArray
:
out
<<
"uint4 "
;
break
;
default
:
UNREACHABLE
();
}
}
// Function name
...
...
@@ -915,7 +938,7 @@ void OutputHLSL::header()
default
:
UNREACHABLE
();
}
switch
(
textureFunction
->
m
ipmap
)
switch
(
textureFunction
->
m
ethod
)
{
case
TextureFunction
:
:
IMPLICIT
:
break
;
case
TextureFunction
:
:
BIAS
:
hlslCoords
=
4
;
break
;
...
...
@@ -947,25 +970,66 @@ void OutputHLSL::header()
switch
(
textureFunction
->
coords
)
{
case
1
:
out
<<
", int lod"
;
break
;
case
2
:
out
<<
", float2 t"
;
break
;
case
3
:
out
<<
", float3 t"
;
break
;
case
4
:
out
<<
", float4 t"
;
break
;
default
:
UNREACHABLE
();
}
switch
(
textureFunction
->
m
ipmap
)
switch
(
textureFunction
->
m
ethod
)
{
case
TextureFunction
:
:
IMPLICIT
:
break
;
case
TextureFunction
:
:
BIAS
:
out
<<
", float bias"
;
break
;
case
TextureFunction
:
:
LOD
:
out
<<
", float lod"
;
break
;
case
TextureFunction
:
:
LOD0
:
break
;
case
TextureFunction
:
:
SIZE
:
break
;
default
:
UNREACHABLE
();
}
out
<<
")
\n
"
"{
\n
"
;
if
(
IsIntegerSampler
(
textureFunction
->
sampler
)
&&
IsSamplerCube
(
textureFunction
->
sampler
))
if
(
textureFunction
->
method
==
TextureFunction
::
SIZE
)
{
if
(
IsSampler2D
(
textureFunction
->
sampler
)
||
IsSamplerCube
(
textureFunction
->
sampler
))
{
if
(
IsSamplerArray
(
textureFunction
->
sampler
))
{
out
<<
" uint width; uint height; uint layers; uint numberOfLevels;
\n
"
" x.GetDimensions(lod, width, height, layers, numberOfLevels);
\n
"
;
}
else
{
out
<<
" uint width; uint height; uint numberOfLevels;
\n
"
" x.GetDimensions(lod, width, height, numberOfLevels);
\n
"
;
}
}
else
if
(
IsSampler3D
(
textureFunction
->
sampler
))
{
out
<<
" uint width; uint height; uint depth; uint numberOfLevels;
\n
"
" x.GetDimensions(lod, width, height, depth, numberOfLevels);
\n
"
;
}
else
UNREACHABLE
();
switch
(
textureFunction
->
sampler
)
{
case
EbtSampler2D
:
out
<<
" return int2(width, height);"
;
break
;
case
EbtSampler3D
:
out
<<
" return int3(width, height, depth);"
;
break
;
case
EbtSamplerCube
:
out
<<
" return int2(width, height);"
;
break
;
case
EbtSampler2DArray
:
out
<<
" return int3(width, height, layers);"
;
break
;
case
EbtISampler2D
:
out
<<
" return int2(width, height);"
;
break
;
case
EbtISampler3D
:
out
<<
" return int3(width, height, depth);"
;
break
;
case
EbtISamplerCube
:
out
<<
" return int2(width, height);"
;
break
;
case
EbtISampler2DArray
:
out
<<
" return int3(width, height, layers);"
;
break
;
case
EbtUSampler2D
:
out
<<
" return int2(width, height);"
;
break
;
case
EbtUSampler3D
:
out
<<
" return int3(width, height, depth);"
;
break
;
case
EbtUSamplerCube
:
out
<<
" return int2(width, height);"
;
break
;
case
EbtUSampler2DArray
:
out
<<
" return int3(width, height, layers);"
;
break
;
default
:
UNREACHABLE
();
}
}
else
if
(
IsIntegerSampler
(
textureFunction
->
sampler
)
&&
IsSamplerCube
(
textureFunction
->
sampler
))
{
// Currently unsupported because TextureCube does not support Load
// This will require emulation using a Texture2DArray with 6 faces
...
...
@@ -1016,7 +1080,7 @@ void OutputHLSL::header()
default
:
UNREACHABLE
();
}
switch
(
textureFunction
->
m
ipmap
)
switch
(
textureFunction
->
m
ethod
)
{
case
TextureFunction
:
:
IMPLICIT
:
out
<<
"(s, "
;
break
;
case
TextureFunction
:
:
BIAS
:
out
<<
"bias(s, "
;
break
;
...
...
@@ -1033,7 +1097,7 @@ void OutputHLSL::header()
}
else
{
switch
(
textureFunction
->
m
ipmap
)
switch
(
textureFunction
->
m
ethod
)
{
case
TextureFunction
:
:
IMPLICIT
:
out
<<
"x.Sample(s, "
;
break
;
case
TextureFunction
:
:
BIAS
:
out
<<
"x.SampleBias(s, "
;
break
;
...
...
@@ -1115,7 +1179,7 @@ void OutputHLSL::header()
if
(
hlslCoords
==
4
)
{
switch
(
textureFunction
->
m
ipmap
)
switch
(
textureFunction
->
m
ethod
)
{
case
TextureFunction
:
:
BIAS
:
out
<<
", bias"
;
break
;
case
TextureFunction
:
:
LOD
:
out
<<
", lod"
;
break
;
...
...
@@ -1135,7 +1199,7 @@ void OutputHLSL::header()
if
(
!
IsIntegerSampler
(
textureFunction
->
sampler
))
{
switch
(
textureFunction
->
m
ipmap
)
switch
(
textureFunction
->
m
ethod
)
{
case
TextureFunction
:
:
IMPLICIT
:
out
<<
"));"
;
break
;
case
TextureFunction
:
:
BIAS
:
out
<<
"), bias);"
;
break
;
...
...
@@ -2264,39 +2328,43 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
TextureFunction
textureFunction
;
textureFunction
.
sampler
=
samplerType
;
textureFunction
.
coords
=
arguments
[
1
]
->
getAsTyped
()
->
getNominalSize
();
textureFunction
.
mipmap
=
TextureFunction
::
IMPLICIT
;
textureFunction
.
method
=
TextureFunction
::
IMPLICIT
;
textureFunction
.
proj
=
false
;
if
(
name
==
"texture2D"
||
name
==
"textureCube"
||
name
==
"texture"
)
{
textureFunction
.
mipmap
=
TextureFunction
::
IMPLICIT
;
textureFunction
.
proj
=
false
;
textureFunction
.
method
=
TextureFunction
::
IMPLICIT
;
}
else
if
(
name
==
"texture2DProj"
||
name
==
"textureProj"
)
{
textureFunction
.
m
ipmap
=
TextureFunction
::
IMPLICIT
;
textureFunction
.
m
ethod
=
TextureFunction
::
IMPLICIT
;
textureFunction
.
proj
=
true
;
}
else
if
(
name
==
"texture2DLod"
||
name
==
"textureCubeLod"
||
name
==
"textureLod"
)
{
textureFunction
.
mipmap
=
TextureFunction
::
LOD
;
textureFunction
.
proj
=
false
;
textureFunction
.
method
=
TextureFunction
::
LOD
;
}
else
if
(
name
==
"texture2DProjLod"
||
name
==
"textureProjLod"
)
{
textureFunction
.
m
ipmap
=
TextureFunction
::
LOD
;
textureFunction
.
m
ethod
=
TextureFunction
::
LOD
;
textureFunction
.
proj
=
true
;
}
else
if
(
name
==
"textureSize"
)
{
textureFunction
.
method
=
TextureFunction
::
SIZE
;
}
else
UNREACHABLE
();
if
(
textureFunction
.
mipmap
!=
TextureFunction
::
LOD
)
if
(
textureFunction
.
method
!=
TextureFunction
::
LOD
&&
textureFunction
.
method
!=
TextureFunction
::
SIZE
)
{
if
(
lod0
||
mContext
.
shaderType
==
SH_VERTEX_SHADER
)
{
textureFunction
.
m
ipmap
=
TextureFunction
::
LOD0
;
textureFunction
.
m
ethod
=
TextureFunction
::
LOD0
;
}
else
if
(
arguments
.
size
()
==
3
)
{
textureFunction
.
m
ipmap
=
TextureFunction
::
BIAS
;
textureFunction
.
m
ethod
=
TextureFunction
::
BIAS
;
}
}
...
...
src/compiler/OutputHLSL.h
View file @
75fb4752
...
...
@@ -96,18 +96,19 @@ class OutputHLSL : public TIntermTraverser
struct
TextureFunction
{
enum
M
ipmap
enum
M
ethod
{
IMPLICIT
,
IMPLICIT
,
// Mipmap LOD determined implicitly (standard lookup)
BIAS
,
LOD
,
LOD0
LOD0
,
SIZE
// textureSize()
};
TBasicType
sampler
;
int
coords
;
bool
proj
;
M
ipmap
mipmap
;
M
ethod
method
;
TString
name
()
const
;
...
...
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