Commit 1f1a833d by Nicolas Capens Committed by Shannon Woods

Implemented integer sampler HLSL translation.

TRAC #23359 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods Author: Nicolas Capens
parent 344e7142
...@@ -675,6 +675,11 @@ void OutputHLSL::header() ...@@ -675,6 +675,11 @@ void OutputHLSL::header()
"{\n" "{\n"
" return t.Sample(s, uv);\n" " return t.Sample(s, uv);\n"
"}\n" "}\n"
"\n"
"int4 gl_texture2D(Texture2D<int4> t, SamplerState s, float2 uv)\n"
"{\n"
" return t.Sample(s, uv);\n"
"}\n"
"\n"; "\n";
} }
else UNREACHABLE(); else UNREACHABLE();
...@@ -696,6 +701,11 @@ void OutputHLSL::header() ...@@ -696,6 +701,11 @@ void OutputHLSL::header()
"{\n" "{\n"
" return t.SampleBias(s, uv, bias);\n" " return t.SampleBias(s, uv, bias);\n"
"}\n" "}\n"
"\n"
"int4 gl_texture2D(Texture2D<int4> t, SamplerState s, float2 uv, float bias)\n"
"{\n"
" return t.SampleBias(s, uv, bias);\n"
"}\n"
"\n"; "\n";
} }
else UNREACHABLE(); else UNREACHABLE();
...@@ -727,6 +737,16 @@ void OutputHLSL::header() ...@@ -727,6 +737,16 @@ void OutputHLSL::header()
"{\n" "{\n"
" return t.Sample(s, float2(uvw.x / uvw.w, uvw.y / uvw.w));\n" " return t.Sample(s, float2(uvw.x / uvw.w, uvw.y / uvw.w));\n"
"}\n" "}\n"
"\n"
"int4 gl_texture2DProj(Texture2D<int4> t, SamplerState s, float3 uvw)\n"
"{\n"
" return t.Sample(s, float2(uvw.x / uvw.z, uvw.y / uvw.z));\n"
"}\n"
"\n"
"int4 gl_texture2DProj(Texture2D<int4> t, SamplerState s, float4 uvw)\n"
"{\n"
" return t.Sample(s, float2(uvw.x / uvw.w, uvw.y / uvw.w));\n"
"}\n"
"\n"; "\n";
} }
else UNREACHABLE(); else UNREACHABLE();
...@@ -758,6 +778,16 @@ void OutputHLSL::header() ...@@ -758,6 +778,16 @@ void OutputHLSL::header()
"{\n" "{\n"
" return t.SampleBias(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), bias);\n" " return t.SampleBias(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), bias);\n"
"}\n" "}\n"
"\n"
"int4 gl_texture2DProj(Texture2D<int4> t, SamplerState s, float3 uvw, float bias)\n"
"{\n"
" return t.SampleBias(s, float2(uvw.x / uvw.z, uvw.y / uvw.z), bias);\n"
"}\n"
"\n"
"int4 gl_texture2DProj(Texture2D<int4> t, SamplerState s, float4 uvw, float bias)\n"
"{\n"
" return t.SampleBias(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), bias);\n"
"}\n"
"\n"; "\n";
} }
else UNREACHABLE(); else UNREACHABLE();
...@@ -779,6 +809,11 @@ void OutputHLSL::header() ...@@ -779,6 +809,11 @@ void OutputHLSL::header()
"{\n" "{\n"
" return t.Sample(s, uvw);\n" " return t.Sample(s, uvw);\n"
"}\n" "}\n"
"\n"
"int4 gl_textureCube(TextureCube<int4> t, SamplerState s, float3 uvw)\n"
"{\n"
" return t.Sample(s, uvw);\n"
"}\n"
"\n"; "\n";
} }
else UNREACHABLE(); else UNREACHABLE();
...@@ -800,6 +835,11 @@ void OutputHLSL::header() ...@@ -800,6 +835,11 @@ void OutputHLSL::header()
"{\n" "{\n"
" return t.SampleBias(s, uvw, bias);\n" " return t.SampleBias(s, uvw, bias);\n"
"}\n" "}\n"
"\n"
"int4 gl_textureCube(TextureCube<int4> t, SamplerState s, float3 uvw, float bias)\n"
"{\n"
" return t.SampleBias(s, uvw, bias);\n"
"}\n"
"\n"; "\n";
} }
else UNREACHABLE(); else UNREACHABLE();
...@@ -823,6 +863,11 @@ void OutputHLSL::header() ...@@ -823,6 +863,11 @@ void OutputHLSL::header()
"{\n" "{\n"
" return t.SampleLevel(s, uv, 0);\n" " return t.SampleLevel(s, uv, 0);\n"
"}\n" "}\n"
"\n"
"int4 gl_texture2DLod0(Texture2D<int4> t, SamplerState s, float2 uv)\n"
"{\n"
" return t.SampleLevel(s, uv, 0);\n"
"}\n"
"\n"; "\n";
} }
else UNREACHABLE(); else UNREACHABLE();
...@@ -844,6 +889,11 @@ void OutputHLSL::header() ...@@ -844,6 +889,11 @@ void OutputHLSL::header()
"{\n" "{\n"
" return t.SampleLevel(s, uv, 0);\n" " return t.SampleLevel(s, uv, 0);\n"
"}\n" "}\n"
"\n"
"int4 gl_texture2DLod0(Texture2D<int4> t, SamplerState s, float2 uv, float bias)\n"
"{\n"
" return t.SampleLevel(s, uv, 0);\n"
"}\n"
"\n"; "\n";
} }
else UNREACHABLE(); else UNREACHABLE();
...@@ -875,6 +925,16 @@ void OutputHLSL::header() ...@@ -875,6 +925,16 @@ void OutputHLSL::header()
"{\n" "{\n"
" return t.SampleLevel(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), 0);\n" " return t.SampleLevel(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), 0);\n"
"}\n" "}\n"
"\n"
"int4 gl_texture2DProjLod0(Texture2D<int4> t, SamplerState s, float3 uvw)\n"
"{\n"
" return t.SampleLevel(s, float2(uvw.x / uvw.z, uvw.y / uvw.z), 0);\n"
"}\n"
"\n"
"int4 gl_texture2DProjLod0(Texture2D<int4> t, SamplerState s, float4 uvw)\n"
"{\n"
" return t.SampleLevel(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), 0);\n"
"}\n"
"\n"; "\n";
} }
else UNREACHABLE(); else UNREACHABLE();
...@@ -906,6 +966,16 @@ void OutputHLSL::header() ...@@ -906,6 +966,16 @@ void OutputHLSL::header()
"{\n" "{\n"
" return t.SampleLevel(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), 0);\n" " return t.SampleLevel(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), 0);\n"
"}\n" "}\n"
"\n"
"int4 gl_texture2DProjLod_bias(Texture2D<int4> t, SamplerState s, float3 uvw, float bias)\n"
"{\n"
" return t.SampleLevel(s, float2(uvw.x / uvw.z, uvw.y / uvw.z), 0);\n"
"}\n"
"\n"
"int4 gl_texture2DProjLod_bias(Texture2D<int4> t, SamplerState s, float4 uvw, float bias)\n"
"{\n"
" return t.SampleLevel(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), 0);\n"
"}\n"
"\n"; "\n";
} }
else UNREACHABLE(); else UNREACHABLE();
...@@ -927,6 +997,11 @@ void OutputHLSL::header() ...@@ -927,6 +997,11 @@ void OutputHLSL::header()
"{\n" "{\n"
" return t.SampleLevel(s, uvw, 0);\n" " return t.SampleLevel(s, uvw, 0);\n"
"}\n" "}\n"
"\n"
"int4 gl_textureCubeLod0(TextureCube<int4> t, SamplerState s, float3 uvw)\n"
"{\n"
" return t.SampleLevel(s, uvw, 0);\n"
"}\n"
"\n"; "\n";
} }
else UNREACHABLE(); else UNREACHABLE();
...@@ -948,6 +1023,11 @@ void OutputHLSL::header() ...@@ -948,6 +1023,11 @@ void OutputHLSL::header()
"{\n" "{\n"
" return t.SampleLevel(s, uvw, 0);\n" " return t.SampleLevel(s, uvw, 0);\n"
"}\n" "}\n"
"\n"
"int4 gl_textureCubeLod0(TextureCube<int4> t, SamplerState s, float3 uvw, float bias)\n"
"{\n"
" return t.SampleLevel(s, uvw, 0);\n"
"}\n"
"\n"; "\n";
} }
else UNREACHABLE(); else UNREACHABLE();
...@@ -1049,6 +1129,11 @@ void OutputHLSL::header() ...@@ -1049,6 +1129,11 @@ void OutputHLSL::header()
"{\n" "{\n"
" return t.SampleLevel(s, uv, 0);\n" " return t.SampleLevel(s, uv, 0);\n"
"}\n" "}\n"
"\n"
"int4 gl_texture2D(Texture2D<int> t, SamplerState s, float2 uv)\n"
"{\n"
" return t.SampleLevel(s, uv, 0);\n"
"}\n"
"\n"; "\n";
} }
else UNREACHABLE(); else UNREACHABLE();
...@@ -1070,6 +1155,11 @@ void OutputHLSL::header() ...@@ -1070,6 +1155,11 @@ void OutputHLSL::header()
"{\n" "{\n"
" return t.SampleLevel(s, uv, lod);\n" " return t.SampleLevel(s, uv, lod);\n"
"}\n" "}\n"
"\n"
"int4 gl_texture2DLod(Texture2D<int> t, SamplerState s, float2 uv, float lod)\n"
"{\n"
" return t.SampleLevel(s, uv, lod);\n"
"}\n"
"\n"; "\n";
} }
else UNREACHABLE(); else UNREACHABLE();
...@@ -1101,6 +1191,16 @@ void OutputHLSL::header() ...@@ -1101,6 +1191,16 @@ void OutputHLSL::header()
"{\n" "{\n"
" return t.SampleLevel(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), 0);\n" " return t.SampleLevel(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), 0);\n"
"}\n" "}\n"
"\n"
"int4 gl_texture2DProj(Texture2D<int4> t, SamplerState s, float3 uvw)\n"
"{\n"
" return t.SampleLevel(s, float2(uvw.x / uvw.z, uvw.y / uvw.z), 0);\n"
"}\n"
"\n"
"int4 gl_texture2DProj(Texture2D<int4> t, SamplerState s, float4 uvw)\n"
"{\n"
" return t.SampleLevel(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), 0);\n"
"}\n"
"\n"; "\n";
} }
else UNREACHABLE(); else UNREACHABLE();
...@@ -1132,6 +1232,16 @@ void OutputHLSL::header() ...@@ -1132,6 +1232,16 @@ void OutputHLSL::header()
"{\n" "{\n"
" return t.SampleLevel(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), lod);\n" " return t.SampleLevel(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), lod);\n"
"}\n" "}\n"
"\n"
"int4 gl_texture2DProj(Texture2D<int4> t, SamplerState s, float3 uvw, float lod)\n"
"{\n"
" return t.SampleLevel(s, float2(uvw.x / uvw.z, uvw.y / uvw.z), lod);\n"
"}\n"
"\n"
"int4 gl_texture2DProj(Texture2D<int4> t, SamplerState s, float4 uvw)\n"
"{\n"
" return t.SampleLevel(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), lod);\n"
"}\n"
"\n"; "\n";
} }
else UNREACHABLE(); else UNREACHABLE();
...@@ -1153,6 +1263,11 @@ void OutputHLSL::header() ...@@ -1153,6 +1263,11 @@ void OutputHLSL::header()
"{\n" "{\n"
" return t.SampleLevel(s, uvw, 0);\n" " return t.SampleLevel(s, uvw, 0);\n"
"}\n" "}\n"
"\n"
"int4 gl_textureCube(TextureCube<int4> t, SamplerState s, float3 uvw)\n"
"{\n"
" return t.SampleLevel(s, uvw, 0);\n"
"}\n"
"\n"; "\n";
} }
else UNREACHABLE(); else UNREACHABLE();
...@@ -1174,6 +1289,11 @@ void OutputHLSL::header() ...@@ -1174,6 +1289,11 @@ void OutputHLSL::header()
"{\n" "{\n"
" return t.SampleLevel(s, uvw, lod);\n" " return t.SampleLevel(s, uvw, lod);\n"
"}\n" "}\n"
"\n"
"int4 gl_textureCubeLod(TextureCube<int4> t, SamplerState s, float3 uvw, float lod)\n"
"{\n"
" return t.SampleLevel(s, uvw, lod);\n"
"}\n"
"\n"; "\n";
} }
else UNREACHABLE(); else UNREACHABLE();
...@@ -2244,7 +2364,8 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -2244,7 +2364,8 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
{ {
TBasicType samplerType = arguments[0]->getAsTyped()->getType().getBasicType(); TBasicType samplerType = arguments[0]->getAsTyped()->getType().getBasicType();
if (name == "texture2D" || (name == "texture" && samplerType == EbtSampler2D)) if (name == "texture2D" ||
(name == "texture" && (samplerType == EbtSampler2D || samplerType == EbtISampler2D)))
{ {
if (!lod0) if (!lod0)
{ {
...@@ -2275,7 +2396,8 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -2275,7 +2396,8 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
out << "gl_texture2DLod0("; out << "gl_texture2DLod0(";
} }
} }
else if (name == "texture2DProj" || (name == "textureProj" && samplerType == EbtSampler2D)) else if (name == "texture2DProj" ||
(name == "textureProj" && (samplerType == EbtSampler2D || samplerType == EbtISampler2D)))
{ {
if (!lod0) if (!lod0)
{ {
...@@ -2306,7 +2428,8 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -2306,7 +2428,8 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
out << "gl_texture2DProjLod0("; out << "gl_texture2DProjLod0(";
} }
} }
else if (name == "textureCube" || (name == "texture" && samplerType == EbtSamplerCube)) else if (name == "textureCube" ||
(name == "texture" && (samplerType == EbtSamplerCube || samplerType == EbtISamplerCube)))
{ {
if (!lod0) if (!lod0)
{ {
...@@ -2337,7 +2460,8 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -2337,7 +2460,8 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
out << "gl_textureCubeLod0("; out << "gl_textureCubeLod0(";
} }
} }
else if (name == "texture2DLod" || (name == "textureLod" && samplerType == EbtSampler2D)) else if (name == "texture2DLod" ||
(name == "textureLod" && (samplerType == EbtSampler2D || samplerType == EbtISampler2D)))
{ {
if (arguments.size() == 3) if (arguments.size() == 3)
{ {
...@@ -2347,7 +2471,8 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -2347,7 +2471,8 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
out << "gl_texture2DLod("; out << "gl_texture2DLod(";
} }
else if (name == "texture2DProjLod" || (name == "textureProjLod" && samplerType == EbtSampler2D)) else if (name == "texture2DProjLod" ||
(name == "textureProjLod" && (samplerType == EbtSampler2D || samplerType == EbtISampler2D)))
{ {
if (arguments.size() == 3) if (arguments.size() == 3)
{ {
...@@ -2357,7 +2482,8 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -2357,7 +2482,8 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
out << "gl_texture2DProjLod("; out << "gl_texture2DProjLod(";
} }
else if (name == "textureCubeLod" || (name == "textureLod" && samplerType == EbtSamplerCube)) else if (name == "textureCubeLod" ||
(name == "textureLod" && (samplerType == EbtSamplerCube || samplerType == EbtISamplerCube)))
{ {
if (arguments.size() == 3) if (arguments.size() == 3)
{ {
...@@ -3117,8 +3243,10 @@ TString OutputHLSL::typeString(const TType &type) ...@@ -3117,8 +3243,10 @@ TString OutputHLSL::typeString(const TType &type)
case EbtVoid: case EbtVoid:
return "void"; return "void";
case EbtSampler2D: case EbtSampler2D:
case EbtISampler2D:
return "sampler2D"; return "sampler2D";
case EbtSamplerCube: case EbtSamplerCube:
case EbtISamplerCube:
return "samplerCUBE"; return "samplerCUBE";
case EbtSamplerExternalOES: case EbtSamplerExternalOES:
return "sampler2D"; return "sampler2D";
...@@ -3141,6 +3269,10 @@ TString OutputHLSL::textureString(const TType &type) ...@@ -3141,6 +3269,10 @@ TString OutputHLSL::textureString(const TType &type)
return "TextureCube"; return "TextureCube";
case EbtSamplerExternalOES: case EbtSamplerExternalOES:
return "Texture2D"; return "Texture2D";
case EbtISampler2D:
return "Texture2D<int4>";
case EbtISamplerCube:
return "TextureCube<int4>";
default: default:
break; break;
} }
...@@ -3756,6 +3888,14 @@ GLenum OutputHLSL::glVariableType(const TType &type) ...@@ -3756,6 +3888,14 @@ GLenum OutputHLSL::glVariableType(const TType &type)
{ {
return GL_SAMPLER_CUBE; return GL_SAMPLER_CUBE;
} }
else if (type.getBasicType() == EbtISampler2D)
{
return GL_INT_SAMPLER_2D;
}
else if (type.getBasicType() == EbtISamplerCube)
{
return GL_INT_SAMPLER_CUBE;
}
else UNREACHABLE(); else UNREACHABLE();
return GL_NONE; return GL_NONE;
......
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