Commit 93e50deb by Nicolas Capens Committed by Shannon Woods

Implement array sampler support.

TRAC #23472 Signed-off-by: Geoff Lang Signed-off-by: Shannon Woods Author: Nicolas Capens
parent 67a819f3
...@@ -206,6 +206,33 @@ inline bool IsSampler3D(TBasicType type) ...@@ -206,6 +206,33 @@ inline bool IsSampler3D(TBasicType type)
return false; return false;
} }
inline bool IsSamplerArray(TBasicType type)
{
switch (type)
{
case EbtSampler2DArray:
case EbtISampler2DArray:
case EbtUSampler2DArray:
return true;
case EbtSampler2D:
case EbtISampler2D:
case EbtUSampler2D:
case EbtSampler2DRect:
case EbtSamplerExternalOES:
case EbtSampler3D:
case EbtISampler3D:
case EbtUSampler3D:
case EbtISamplerCube:
case EbtUSamplerCube:
case EbtSamplerCube:
return false;
default:
assert(!IsSampler(type));
}
return false;
}
// //
// Qualifiers and built-ins. These are mainly used to see what can be read // Qualifiers and built-ins. These are mainly used to see what can be read
// or written, and by the machine dependent translator to know which registers // or written, and by the machine dependent translator to know which registers
......
...@@ -931,15 +931,15 @@ void OutputHLSL::header() ...@@ -931,15 +931,15 @@ void OutputHLSL::header()
case EbtSampler2D: out << "Texture2D x, SamplerState s"; hlslCoords = 2; break; case EbtSampler2D: out << "Texture2D x, SamplerState s"; hlslCoords = 2; break;
case EbtSampler3D: out << "Texture3D x, SamplerState s"; hlslCoords = 3; break; case EbtSampler3D: out << "Texture3D x, SamplerState s"; hlslCoords = 3; break;
case EbtSamplerCube: out << "TextureCube x, SamplerState s"; hlslCoords = 3; break; case EbtSamplerCube: out << "TextureCube x, SamplerState s"; hlslCoords = 3; break;
case EbtSampler2DArray: out << "Texture2DArray x, SamplerState s"; hlslCoords = 2; break; case EbtSampler2DArray: out << "Texture2DArray x, SamplerState s"; hlslCoords = 3; break;
case EbtISampler2D: out << "Texture2D<int4> x, SamplerState s"; hlslCoords = 2; break; case EbtISampler2D: out << "Texture2D<int4> x, SamplerState s"; hlslCoords = 2; break;
case EbtISampler3D: out << "Texture3D<int4> x, SamplerState s"; hlslCoords = 3; break; case EbtISampler3D: out << "Texture3D<int4> x, SamplerState s"; hlslCoords = 3; break;
case EbtISamplerCube: out << "TextureCube<int4> x, SamplerState s"; hlslCoords = 3; break; case EbtISamplerCube: out << "TextureCube<int4> x, SamplerState s"; hlslCoords = 3; break;
case EbtISampler2DArray: out << "Texture2DArray<int4> x, SamplerState s"; hlslCoords = 2; break; case EbtISampler2DArray: out << "Texture2DArray<int4> x, SamplerState s"; hlslCoords = 3; break;
case EbtUSampler2D: out << "Texture2D<uint4> x, SamplerState s"; hlslCoords = 2; break; case EbtUSampler2D: out << "Texture2D<uint4> x, SamplerState s"; hlslCoords = 2; break;
case EbtUSampler3D: out << "Texture3D<uint4> x, SamplerState s"; hlslCoords = 3; break; case EbtUSampler3D: out << "Texture3D<uint4> x, SamplerState s"; hlslCoords = 3; break;
case EbtUSamplerCube: out << "TextureCube<uint4> x, SamplerState s"; hlslCoords = 3; break; case EbtUSamplerCube: out << "TextureCube<uint4> x, SamplerState s"; hlslCoords = 3; break;
case EbtUSampler2DArray: out << "Texture2DArray<uint4> x, SamplerState s"; hlslCoords = 2; break; case EbtUSampler2DArray: out << "Texture2DArray<uint4> x, SamplerState s"; hlslCoords = 3; break;
default: UNREACHABLE(); default: UNREACHABLE();
} }
} }
...@@ -985,8 +985,16 @@ void OutputHLSL::header() ...@@ -985,8 +985,16 @@ void OutputHLSL::header()
{ {
if (IsSampler2D(textureFunction->sampler)) if (IsSampler2D(textureFunction->sampler))
{ {
out << " uint width; uint height; uint numberOfLevels;\n" if (IsSamplerArray(textureFunction->sampler))
" x.GetDimensions(0, width, height, numberOfLevels);\n"; {
out << " uint width; uint height; uint layers; uint numberOfLevels;\n"
" x.GetDimensions(0, width, height, layers, numberOfLevels);\n";
}
else
{
out << " uint width; uint height; uint numberOfLevels;\n"
" x.GetDimensions(0, width, height, numberOfLevels);\n";
}
} }
else if (IsSampler3D(textureFunction->sampler)) else if (IsSampler3D(textureFunction->sampler))
{ {
...@@ -1052,10 +1060,19 @@ void OutputHLSL::header() ...@@ -1052,10 +1060,19 @@ void OutputHLSL::header()
default: UNREACHABLE(); default: UNREACHABLE();
} }
addressx = "int(floor(float(width) * frac("; addressx = "int(floor(float(width) * frac((";
addressy = "int(floor(float(height) * frac("; addressy = "int(floor(float(height) * frac((";
addressz = "int(floor(float(depth) * frac(";
close = ")))"; if (IsSamplerArray(textureFunction->sampler))
{
addressz = "int(max(0, min(layers - 1, floor(0.5 + ";
}
else
{
addressz = "int(floor(float(depth) * frac((";
}
close = "))))";
} }
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment