Expand GL sampler arguments to a texture and sampler argument for D3D11.

TRAC #22593 Signed-off-by: Shannon Woods Signed-off-by: Geoff Lang Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1919 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 96c21eea
...@@ -1735,158 +1735,163 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -1735,158 +1735,163 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
break; break;
case EOpFunctionCall: case EOpFunctionCall:
{ {
if (visit == PreVisit) TString name = TFunction::unmangleName(node->getName());
{ bool lod0 = mInsideDiscontinuousLoop || mOutputLod0Function;
TString name = TFunction::unmangleName(node->getName());
bool lod0 = mInsideDiscontinuousLoop || mOutputLod0Function;
if (node->isUserDefined()) if (node->isUserDefined())
{ {
out << decorate(name) << (lod0 ? "Lod0(" : "("); out << decorate(name) << (lod0 ? "Lod0(" : "(");
} }
else else
{
if (name == "texture2D")
{ {
if (name == "texture2D") if (!lod0)
{ {
if (!lod0) if (node->getSequence().size() == 2)
{ {
if (node->getSequence().size() == 2) mUsesTexture2D = true;
{
mUsesTexture2D = true;
}
else if (node->getSequence().size() == 3)
{
mUsesTexture2D_bias = true;
}
else UNREACHABLE();
out << "gl_texture2D(";
} }
else else if (node->getSequence().size() == 3)
{ {
if (node->getSequence().size() == 2) mUsesTexture2D_bias = true;
{
mUsesTexture2DLod0 = true;
}
else if (node->getSequence().size() == 3)
{
mUsesTexture2DLod0_bias = true;
}
else UNREACHABLE();
out << "gl_texture2DLod0(";
} }
else UNREACHABLE();
out << "gl_texture2D(";
} }
else if (name == "texture2DProj") else
{ {
if (!lod0) if (node->getSequence().size() == 2)
{ {
if (node->getSequence().size() == 2) mUsesTexture2DLod0 = true;
{
mUsesTexture2DProj = true;
}
else if (node->getSequence().size() == 3)
{
mUsesTexture2DProj_bias = true;
}
else UNREACHABLE();
out << "gl_texture2DProj(";
} }
else else if (node->getSequence().size() == 3)
{ {
if (node->getSequence().size() == 2) mUsesTexture2DLod0_bias = true;
{
mUsesTexture2DProjLod0 = true;
}
else if (node->getSequence().size() == 3)
{
mUsesTexture2DProjLod0_bias = true;
}
else UNREACHABLE();
out << "gl_texture2DProjLod0(";
} }
else UNREACHABLE();
out << "gl_texture2DLod0(";
} }
else if (name == "textureCube") }
else if (name == "texture2DProj")
{
if (!lod0)
{ {
if (!lod0) if (node->getSequence().size() == 2)
{ {
if (node->getSequence().size() == 2) mUsesTexture2DProj = true;
{
mUsesTextureCube = true;
}
else if (node->getSequence().size() == 3)
{
mUsesTextureCube_bias = true;
}
else UNREACHABLE();
out << "gl_textureCube(";
} }
else else if (node->getSequence().size() == 3)
{ {
if (node->getSequence().size() == 2) mUsesTexture2DProj_bias = true;
{
mUsesTextureCubeLod0 = true;
}
else if (node->getSequence().size() == 3)
{
mUsesTextureCubeLod0_bias = true;
}
else UNREACHABLE();
out << "gl_textureCubeLod0(";
} }
else UNREACHABLE();
out << "gl_texture2DProj(";
} }
else if (name == "texture2DLod") else
{ {
if (node->getSequence().size() == 3) if (node->getSequence().size() == 2)
{
mUsesTexture2DProjLod0 = true;
}
else if (node->getSequence().size() == 3)
{ {
mUsesTexture2DLod = true; mUsesTexture2DProjLod0_bias = true;
} }
else UNREACHABLE(); else UNREACHABLE();
out << "gl_texture2DLod("; out << "gl_texture2DProjLod0(";
} }
else if (name == "texture2DProjLod") }
else if (name == "textureCube")
{
if (!lod0)
{ {
if (node->getSequence().size() == 3) if (node->getSequence().size() == 2)
{
mUsesTextureCube = true;
}
else if (node->getSequence().size() == 3)
{ {
mUsesTexture2DProjLod = true; mUsesTextureCube_bias = true;
} }
else UNREACHABLE(); else UNREACHABLE();
out << "gl_texture2DProjLod("; out << "gl_textureCube(";
} }
else if (name == "textureCubeLod") else
{ {
if (node->getSequence().size() == 3) if (node->getSequence().size() == 2)
{ {
mUsesTextureCubeLod = true; mUsesTextureCubeLod0 = true;
}
else if (node->getSequence().size() == 3)
{
mUsesTextureCubeLod0_bias = true;
} }
else UNREACHABLE(); else UNREACHABLE();
out << "gl_textureCubeLod("; out << "gl_textureCubeLod0(";
}
}
else if (name == "texture2DLod")
{
if (node->getSequence().size() == 3)
{
mUsesTexture2DLod = true;
}
else UNREACHABLE();
out << "gl_texture2DLod(";
}
else if (name == "texture2DProjLod")
{
if (node->getSequence().size() == 3)
{
mUsesTexture2DProjLod = true;
} }
else UNREACHABLE(); else UNREACHABLE();
if (mOutputType == SH_HLSL11_OUTPUT) out << "gl_texture2DProjLod(";
}
else if (name == "textureCubeLod")
{
if (node->getSequence().size() == 3)
{ {
out << "texture_"; mUsesTextureCubeLod = true;
node->getSequence()[0]->traverse(this);
out << ", sampler_";
} }
else UNREACHABLE();
out << "gl_textureCubeLod(";
} }
else UNREACHABLE();
} }
else if (visit == InVisit)
{ TIntermSequence &arguments = node->getSequence();
out << ", ";
} for (TIntermSequence::iterator arg = arguments.begin(); arg != arguments.end(); arg++)
else
{ {
out << ")"; if (mOutputType == SH_HLSL11_OUTPUT && IsSampler((*arg)->getAsTyped()->getBasicType()))
{
out << "texture_";
(*arg)->traverse(this);
out << ", sampler_";
}
(*arg)->traverse(this);
if (arg < arguments.end() - 1)
{
out << ", ";
}
} }
out << ")";
return false;
} }
break; break;
case EOpParameters: outputTriplet(visit, "(", ", ", ")\n{\n"); break; case EOpParameters: outputTriplet(visit, "(", ", ", ")\n{\n"); break;
...@@ -2493,6 +2498,12 @@ TString OutputHLSL::argumentString(const TIntermSymbol *symbol) ...@@ -2493,6 +2498,12 @@ TString OutputHLSL::argumentString(const TIntermSymbol *symbol)
name = decorate(name); name = decorate(name);
} }
if (mOutputType == SH_HLSL11_OUTPUT && IsSampler(type.getBasicType()))
{
return qualifierString(qualifier) + " " + textureString(type) + " texture_" + name + arrayString(type) + ", " +
qualifierString(qualifier) + " SamplerState sampler_" + name + arrayString(type);
}
return qualifierString(qualifier) + " " + typeString(type) + " " + name + arrayString(type); return qualifierString(qualifier) + " " + typeString(type) + " " + name + arrayString(type);
} }
......
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