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
9fe6f984
Commit
9fe6f984
authored
Jun 24, 2013
by
Nicolas Capens
Committed by
Shannon Woods
Jul 19, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented 3D sampler HLSL translation.
TRAC #23365 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods Author: Nicolas Capens
parent
da07535f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
381 additions
and
0 deletions
+381
-0
OutputHLSL.cpp
src/compiler/OutputHLSL.cpp
+371
-0
OutputHLSL.h
src/compiler/OutputHLSL.h
+10
-0
No files found.
src/compiler/OutputHLSL.cpp
View file @
9fe6f984
...
...
@@ -41,6 +41,12 @@ OutputHLSL::OutputHLSL(TParseContext &context, const ShBuiltInResources& resourc
mUsesTexture2DProj_bias
=
false
;
mUsesTexture2DProjLod
=
false
;
mUsesTexture2DLod
=
false
;
mUsesTexture3D
=
false
;
mUsesTexture3D_bias
=
false
;
mUsesTexture3DProj
=
false
;
mUsesTexture3DProj_bias
=
false
;
mUsesTexture3DProjLod
=
false
;
mUsesTexture3DLod
=
false
;
mUsesTextureCube
=
false
;
mUsesTextureCube_bias
=
false
;
mUsesTextureCubeLod
=
false
;
...
...
@@ -48,6 +54,10 @@ OutputHLSL::OutputHLSL(TParseContext &context, const ShBuiltInResources& resourc
mUsesTexture2DLod0_bias
=
false
;
mUsesTexture2DProjLod0
=
false
;
mUsesTexture2DProjLod0_bias
=
false
;
mUsesTexture3DLod0
=
false
;
mUsesTexture3DLod0_bias
=
false
;
mUsesTexture3DProjLod0
=
false
;
mUsesTexture3DProjLod0_bias
=
false
;
mUsesTextureCubeLod0
=
false
;
mUsesTextureCubeLod0_bias
=
false
;
mUsesFragColor
=
false
;
...
...
@@ -823,6 +833,98 @@ void OutputHLSL::header()
else
UNREACHABLE
();
}
if
(
mUsesTexture3D
)
{
if
(
mOutputType
==
SH_HLSL11_OUTPUT
)
{
out
<<
"float4 gl_texture3D(Texture3D t, SamplerState s, float3 uvw)
\n
"
"{
\n
"
" return t.Sample(s, uvw);
\n
"
"}
\n
"
"
\n
"
"int4 gl_texture3D(Texture3D<int4> t, SamplerState s, float3 uvw)
\n
"
"{
\n
"
" return t.Sample(s, uvw);
\n
"
"}
\n
"
"
\n
"
"uint4 gl_texture3D(Texture3D<uint4> t, SamplerState s, float3 uvw)
\n
"
"{
\n
"
" return t.Sample(s, uvw);
\n
"
"}
\n
"
"
\n
"
;
}
else
UNREACHABLE
();
}
if
(
mUsesTexture3D_bias
)
{
if
(
mOutputType
==
SH_HLSL11_OUTPUT
)
{
out
<<
"float4 gl_texture3D(Texture3D t, SamplerState s, float3 uvw, float bias)
\n
"
"{
\n
"
" return t.SampleBias(s, uvw, bias);
\n
"
"}
\n
"
"
\n
"
"int4 gl_texture3D(Texture3D<int4> t, SamplerState s, float3 uvw, float bias)
\n
"
"{
\n
"
" return t.SampleBias(s, uvw, bias);
\n
"
"}
\n
"
"
\n
"
"uint4 gl_texture3D(Texture3D<uint4> t, SamplerState s, float3 uvw, float bias)
\n
"
"{
\n
"
" return t.SampleBias(s, uvw, bias);
\n
"
"}
\n
"
"
\n
"
;
}
else
UNREACHABLE
();
}
if
(
mUsesTexture3DProj
)
{
if
(
mOutputType
==
SH_HLSL11_OUTPUT
)
{
out
<<
"float4 gl_texture3DProj(Texture3D t, SamplerState s, float4 uvw)
\n
"
"{
\n
"
" return t.Sample(s, float3(uvw.x / uvw.w, uvw.y / uvw.w, uvw.z / uvw.w));
\n
"
"}
\n
"
"
\n
"
"int4 gl_texture3DProj(Texture3D<int4> t, SamplerState s, float4 uvw)
\n
"
"{
\n
"
" return t.Sample(s, float3(uvw.x / uvw.w, uvw.y / uvw.w, uvw.z / uvw.w));
\n
"
"}
\n
"
"
\n
"
"uint4 gl_texture3DProj(Texture3D<uint4> t, SamplerState s, float4 uvw)
\n
"
"{
\n
"
" return t.Sample(s, float3(uvw.x / uvw.w, uvw.y / uvw.w, uvw.z / uvw.w));
\n
"
"}
\n
"
"
\n
"
;
}
else
UNREACHABLE
();
}
if
(
mUsesTexture3DProj_bias
)
{
if
(
mOutputType
==
SH_HLSL11_OUTPUT
)
{
out
<<
"float4 gl_texture3DProj(Texture3D t, SamplerState s, float4 uvw, float bias)
\n
"
"{
\n
"
" return t.SampleBias(s, float3(uvw.x / uvw.w, uvw.y / uvw.w, uvw.z / uvw.w), bias);
\n
"
"}
\n
"
"
\n
"
"int4 gl_texture3DProj(Texture3D<int4> t, SamplerState s, float4 uvw, float bias)
\n
"
"{
\n
"
" return t.SampleBias(s, float3(uvw.x / uvw.w, uvw.y / uvw.w, uvw.z / uvw.w), bias);
\n
"
"}
\n
"
"
\n
"
"uint4 gl_texture3DProj(Texture3D<uint4> t, SamplerState s, float4 uvw, float bias)
\n
"
"{
\n
"
" return t.SampleBias(s, float3(uvw.x / uvw.w, uvw.y / uvw.w, uvw.z / uvw.w), bias);
\n
"
"}
\n
"
"
\n
"
;
}
else
UNREACHABLE
();
}
if
(
mUsesTextureCube
)
{
if
(
mOutputType
==
SH_HLSL9_OUTPUT
)
...
...
@@ -1051,6 +1153,99 @@ void OutputHLSL::header()
else
UNREACHABLE
();
}
if
(
mUsesTexture3DLod0
)
{
if
(
mOutputType
==
SH_HLSL11_OUTPUT
)
{
out
<<
"float4 gl_texture3DLod0(Texture3D t, SamplerState s, float3 uvw)
\n
"
"{
\n
"
" return t.SampleLevel(s, uvw, 0);
\n
"
"}
\n
"
"
\n
"
"int4 gl_texture3DLod0(Texture3D<int4> t, SamplerState s, float3 uvw)
\n
"
"{
\n
"
" return t.SampleLevel(s, uvw, 0);
\n
"
"}
\n
"
"
\n
"
"uint4 gl_texture3DLod0(Texture3D<uint4> t, SamplerState s, float3 uvw)
\n
"
"{
\n
"
" return t.SampleLevel(s, uvw, 0);
\n
"
"}
\n
"
"
\n
"
;
}
else
UNREACHABLE
();
}
if
(
mUsesTexture3DLod0_bias
)
{
if
(
mOutputType
==
SH_HLSL11_OUTPUT
)
{
out
<<
"float4 gl_texture3DLod0(Texture3D t, SamplerState s, float3 uvw, float bias)
\n
"
"{
\n
"
" return t.SampleLevel(s, uvw, 0);
\n
"
"}
\n
"
"
\n
"
"int4 gl_texture3DLod0(Texture3D<int4> t, SamplerState s, float3 uvw, float bias)
\n
"
"{
\n
"
" return t.SampleLevel(s, uvw, 0);
\n
"
"}
\n
"
"
\n
"
"uint4 gl_texture3DLod0(Texture3D<uint4> t, SamplerState s, float3 uvw, float bias)
\n
"
"{
\n
"
" return t.SampleLevel(s, uvw, 0);
\n
"
"}
\n
"
"
\n
"
;
}
else
UNREACHABLE
();
}
if
(
mUsesTexture3DProjLod0
)
{
if
(
mOutputType
==
SH_HLSL11_OUTPUT
)
{
out
<<
"float4 gl_texture3DProjLod0(Texture3D t, SamplerState s, float4 uvw)
\n
"
"{
\n
"
" return t.SampleLevel(s, float3(uvw.x / uvw.w, uvw.y / uvw.w, uvw.z / uvw.w), 0);
\n
"
"}
\n
"
"
\n
"
"int4 gl_texture3DProjLod0(Texture3D<int4> t, SamplerState s, float4 uvw)
\n
"
"{
\n
"
" return t.SampleLevel(s, float3(uvw.x / uvw.w, uvw.y / uvw.w, uvw.z / uvw.w), 0);
\n
"
"}
\n
"
"
\n
"
"uint4 gl_texture3DProjLod0(Texture3D<uint4> t, SamplerState s, float4 uvw)
\n
"
"{
\n
"
" return t.SampleLevel(s, float3(uvw.x / uvw.w, uvw.y / uvw.w, uvw.z / uvw.w), 0);
\n
"
"}
\n
"
"
\n
"
;
}
else
UNREACHABLE
();
}
if
(
mUsesTexture3DProjLod0_bias
)
{
if
(
mOutputType
==
SH_HLSL11_OUTPUT
)
{
out
<<
"float4 gl_texture3DProjLod_bias(Texture3D t, SamplerState s, float4 uvw, float bias)
\n
"
"{
\n
"
" return t.SampleLevel(s, float3(uvw.x / uvw.w, uvw.y / uvw.w, uvw.z / uvw.w), 0);
\n
"
"}
\n
"
"
\n
"
"int4 gl_texture3DProjLod_bias(Texture3D<int4> t, SamplerState s, float4 uvw, float bias)
\n
"
"{
\n
"
" return t.SampleLevel(s, float3(uvw.x / uvw.w, uvw.y / uvw.w, uvw.z / uvw.w), 0);
\n
"
"}
\n
"
"
\n
"
"
\n
"
"uint4 gl_texture3DProjLod_bias(Texture3D<uint4> t, SamplerState s, float4 uvw, float bias)
\n
"
"{
\n
"
" return t.SampleLevel(s, float3(uvw.x / uvw.w, uvw.y / uvw.w, uvw.z / uvw.w), 0);
\n
"
"}
\n
"
"
\n
"
;
}
else
UNREACHABLE
();
}
if
(
mUsesTextureCubeLod0
)
{
if
(
mOutputType
==
SH_HLSL9_OUTPUT
)
...
...
@@ -1357,6 +1552,88 @@ void OutputHLSL::header()
else
UNREACHABLE
();
}
if
(
mUsesTexture3D
)
{
if
(
mOutputType
==
SH_HLSL11_OUTPUT
)
{
out
<<
"float4 gl_texture3D(Texture3D t, SamplerState s, float3 uvw)
\n
"
"{
\n
"
" return t.SampleLevel(s, uvw, 0);
\n
"
"}
\n
"
"
\n
"
"int4 gl_texture3D(Texture3D<int> t, SamplerState s, float3 uvw)
\n
"
"{
\n
"
" return t.SampleLevel(s, uvw, 0);
\n
"
"}
\n
"
"
\n
"
;
}
else
UNREACHABLE
();
}
if
(
mUsesTexture3DLod
)
{
if
(
mOutputType
==
SH_HLSL11_OUTPUT
)
{
out
<<
"float4 gl_texture3DLod(Texture3D t, SamplerState s, float3 uvw, float lod)
\n
"
"{
\n
"
" return t.SampleLevel(s, uvw, lod);
\n
"
"}
\n
"
"
\n
"
"int4 gl_texture3DLod(Texture3D<int> t, SamplerState s, float3 uvw, float lod)
\n
"
"{
\n
"
" return t.SampleLevel(s, uvw, lod);
\n
"
"}
\n
"
"
\n
"
;
}
else
UNREACHABLE
();
}
if
(
mUsesTexture3DProj
)
{
if
(
mOutputType
==
SH_HLSL11_OUTPUT
)
{
out
<<
"float4 gl_texture3DProj(Texture3D t, SamplerState s, float4 uvw)
\n
"
"{
\n
"
" return t.SampleLevel(s, float3(uvw.x / uvw.w, uvw.y / uvw.w, uvw.z / uvw.w), 0);
\n
"
"}
\n
"
"
\n
"
"int4 gl_texture3DProj(Texture3D<int4> t, SamplerState s, float4 uvw)
\n
"
"{
\n
"
" return t.SampleLevel(s, float3(uvw.x / uvw.w, uvw.y / uvw.w, uvw.z / uvw.w), 0);
\n
"
"}
\n
"
"
\n
"
"uint4 gl_texture3DProj(Texture3D<uint4> t, SamplerState s, float4 uvw)
\n
"
"{
\n
"
" return t.SampleLevel(s, float3(uvw.x / uvw.w, uvw.y / uvw.w, uvw.z / uvw.w), 0);
\n
"
"}
\n
"
"
\n
"
;
}
else
UNREACHABLE
();
}
if
(
mUsesTexture3DProjLod
)
{
if
(
mOutputType
==
SH_HLSL11_OUTPUT
)
{
out
<<
"float4 gl_texture3DProj(Texture3D t, SamplerState s, float4 uvw, float lod)
\n
"
"{
\n
"
" return t.SampleLevel(s, float3(uvw.x / uvw.w, uvw.y / uvw.w, uvw.z / uvw.w), lod);
\n
"
"}
\n
"
"
\n
"
"int4 gl_texture3DProj(Texture3D<int4> t, SamplerState s, float4 uvw, float lod)
\n
"
"{
\n
"
" return t.SampleLevel(s, float3(uvw.x / uvw.w, uvw.y / uvw.w, uvw.z / uvw.w), lod);
\n
"
"}
\n
"
"
\n
"
"uint4 gl_texture3DProj(Texture3D<uint4> t, SamplerState s, float4 uvw, float lod)
\n
"
"{
\n
"
" return t.SampleLevel(s, float3(uvw.x / uvw.w, uvw.y / uvw.w, uvw.z / uvw.w), lod);
\n
"
"}
\n
"
"
\n
"
;
}
else
UNREACHABLE
();
}
if
(
mUsesTextureCube
)
{
if
(
mOutputType
==
SH_HLSL9_OUTPUT
)
...
...
@@ -2548,6 +2825,68 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
out
<<
"gl_texture2DProjLod0("
;
}
}
else
if
(
name
==
"texture"
&&
(
samplerType
==
EbtSampler3D
||
samplerType
==
EbtISampler3D
||
samplerType
==
EbtUSampler3D
))
{
if
(
!
lod0
)
{
if
(
arguments
.
size
()
==
2
)
{
mUsesTexture3D
=
true
;
}
else
if
(
arguments
.
size
()
==
3
)
{
mUsesTexture3D_bias
=
true
;
}
else
UNREACHABLE
();
out
<<
"gl_texture3D("
;
}
else
{
if
(
arguments
.
size
()
==
2
)
{
mUsesTexture3DLod0
=
true
;
}
else
if
(
arguments
.
size
()
==
3
)
{
mUsesTexture3DLod0_bias
=
true
;
}
else
UNREACHABLE
();
out
<<
"gl_texture3DLod0("
;
}
}
else
if
(
name
==
"textureProj"
&&
(
samplerType
==
EbtSampler3D
||
samplerType
==
EbtISampler3D
||
samplerType
==
EbtUSampler3D
))
{
if
(
!
lod0
)
{
if
(
arguments
.
size
()
==
2
)
{
mUsesTexture3DProj
=
true
;
}
else
if
(
arguments
.
size
()
==
3
)
{
mUsesTexture3DProj_bias
=
true
;
}
else
UNREACHABLE
();
out
<<
"gl_texture3DProj("
;
}
else
{
if
(
arguments
.
size
()
==
2
)
{
mUsesTexture3DProjLod0
=
true
;
}
else
if
(
arguments
.
size
()
==
3
)
{
mUsesTexture3DProjLod0_bias
=
true
;
}
else
UNREACHABLE
();
out
<<
"gl_texture3DProjLod0("
;
}
}
else
if
(
name
==
"textureCube"
||
(
name
==
"texture"
&&
(
samplerType
==
EbtSamplerCube
||
samplerType
==
EbtISamplerCube
||
samplerType
==
EbtUSamplerCube
)))
{
...
...
@@ -2602,6 +2941,26 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
out
<<
"gl_texture2DProjLod("
;
}
else
if
(
name
==
"textureLod"
&&
(
samplerType
==
EbtSampler3D
||
samplerType
==
EbtISampler3D
||
samplerType
==
EbtUSampler3D
))
{
if
(
arguments
.
size
()
==
3
)
{
mUsesTexture3DLod
=
true
;
}
else
UNREACHABLE
();
out
<<
"gl_texture3DLod("
;
}
else
if
(
name
==
"textureProjLod"
&&
(
samplerType
==
EbtSampler3D
||
samplerType
==
EbtISampler3D
||
samplerType
==
EbtUSampler3D
))
{
if
(
arguments
.
size
()
==
3
)
{
mUsesTexture3DProjLod
=
true
;
}
else
UNREACHABLE
();
out
<<
"gl_texture3DProjLod("
;
}
else
if
(
name
==
"textureCubeLod"
||
(
name
==
"textureLod"
&&
(
samplerType
==
EbtSamplerCube
||
samplerType
==
EbtISamplerCube
||
samplerType
==
EbtUSamplerCube
)))
{
...
...
@@ -4010,6 +4369,10 @@ GLenum OutputHLSL::glVariableType(const TType &type)
{
return
GL_SAMPLER_2D
;
}
else
if
(
type
.
getBasicType
()
==
EbtSampler3D
)
{
return
GL_SAMPLER_3D
;
}
else
if
(
type
.
getBasicType
()
==
EbtSamplerCube
)
{
return
GL_SAMPLER_CUBE
;
...
...
@@ -4018,6 +4381,10 @@ GLenum OutputHLSL::glVariableType(const TType &type)
{
return
GL_INT_SAMPLER_2D
;
}
else
if
(
type
.
getBasicType
()
==
EbtISampler3D
)
{
return
GL_INT_SAMPLER_3D
;
}
else
if
(
type
.
getBasicType
()
==
EbtISamplerCube
)
{
return
GL_INT_SAMPLER_CUBE
;
...
...
@@ -4026,6 +4393,10 @@ GLenum OutputHLSL::glVariableType(const TType &type)
{
return
GL_UNSIGNED_INT_SAMPLER_2D
;
}
else
if
(
type
.
getBasicType
()
==
EbtUSampler3D
)
{
return
GL_UNSIGNED_INT_SAMPLER_3D
;
}
else
if
(
type
.
getBasicType
()
==
EbtUSamplerCube
)
{
return
GL_UNSIGNED_INT_SAMPLER_CUBE
;
...
...
src/compiler/OutputHLSL.h
View file @
9fe6f984
...
...
@@ -101,6 +101,12 @@ class OutputHLSL : public TIntermTraverser
bool
mUsesTexture2DProj
;
bool
mUsesTexture2DProj_bias
;
bool
mUsesTexture2DProjLod
;
bool
mUsesTexture3D
;
bool
mUsesTexture3D_bias
;
bool
mUsesTexture3DLod
;
bool
mUsesTexture3DProj
;
bool
mUsesTexture3DProj_bias
;
bool
mUsesTexture3DProjLod
;
bool
mUsesTextureCube
;
bool
mUsesTextureCube_bias
;
bool
mUsesTextureCubeLod
;
...
...
@@ -108,6 +114,10 @@ class OutputHLSL : public TIntermTraverser
bool
mUsesTexture2DLod0_bias
;
bool
mUsesTexture2DProjLod0
;
bool
mUsesTexture2DProjLod0_bias
;
bool
mUsesTexture3DLod0
;
bool
mUsesTexture3DLod0_bias
;
bool
mUsesTexture3DProjLod0
;
bool
mUsesTexture3DProjLod0_bias
;
bool
mUsesTextureCubeLod0
;
bool
mUsesTextureCubeLod0_bias
;
bool
mUsesFragColor
;
...
...
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