#include "compiler/translator/SearchSymbol.h"
#include "compiler/translator/UnfoldShortCircuit.h"
#include "compiler/translator/NodeSearch.h"
+#include "compiler/translator/RewriteElseBlocks.h"
#include <algorithm>
#include <cfloat>
namespace sh
{
-// Integer to TString conversion
-TString str(int i)
-{
- char buffer[20];
- snprintf(buffer, sizeof(buffer), "%d", i);
- return buffer;
-}
OutputHLSL::OutputHLSL(TParseContext &context, const ShBuiltInResources& resources, ShShaderOutput outputType)
: TIntermTraverser(true, true, true), mContext(context), mOutputType(outputType)
{
mContainsLoopDiscontinuity = mContext.shaderType == SH_FRAGMENT_SHADER && containsLoopDiscontinuity(mContext.treeRoot);
+ // Work around D3D9 bug that would manifest in vertex shaders with selection blocks which
+ // use a vertex attribute as a condition, and some related computation in the else block.
+ if (mOutputType == SH_HLSL9_OUTPUT && mContext.shaderType == SH_VERTEX_SHADER)
+ {
+ RewriteElseBlocks(mContext.treeRoot);
+ }
+
mContext.treeRoot->traverse(this); // Output the body first to determine what has to go in the header
header();
}
else if (mOutputType == SH_HLSL11_OUTPUT)
{
- out << "float4 gl_texture2DProj(Texture2D t, SamplerState s, float3 uvw, float lod)\n"
+ out << "float4 gl_texture2DProjLod(Texture2D 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"
- "float4 gl_texture2DProj(Texture2D t, SamplerState s, float4 uvw)\n"
+ "float4 gl_texture2DProjLod(Texture2D t, SamplerState s, float4 uvw, float lod)\n"
"{\n"
" return t.SampleLevel(s, float2(uvw.x / uvw.w, uvw.y / uvw.w), lod);\n"
"}\n"
mReferencedVaryings[name] = node;
out << decorate(name);
}
+ else if (qualifier == EvqInternal)
+ {
+ out << name;
+ }
else
{
out << decorate(name);