aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoff Lang <geofflang@chromium.org>2014-05-28 15:34:31 -0400
committerGeoff Lang <geofflang@chromium.org>2014-06-03 13:39:54 +0000
commitd3d870647655ea8292cee9a1b65820547b13ac0c (patch)
tree4512cad857f551c1f0d7b8433032bb5d350d5c25
parent01b4c0a0ff283e543b7fd2ec9bb3d3dd88d14566 (diff)
downloadangle-d3d870647655ea8292cee9a1b65820547b13ac0c.tar.gz
Only add the structure padding when compiling D3D11 shaders.
BUG=359225 Change-Id: Idc4e2c8631925324a5e7e2a591bd6aa75169817a Reviewed-on: https://chromium-review.googlesource.com/201890 Tested-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Nicolas Capens <nicolascapens@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/202355
-rw-r--r--src/compiler/translator/OutputHLSL.cpp20
-rw-r--r--src/compiler/translator/OutputHLSL.h2
2 files changed, 11 insertions, 11 deletions
diff --git a/src/compiler/translator/OutputHLSL.cpp b/src/compiler/translator/OutputHLSL.cpp
index d6aa5d55..498ba081 100644
--- a/src/compiler/translator/OutputHLSL.cpp
+++ b/src/compiler/translator/OutputHLSL.cpp
@@ -190,7 +190,7 @@ void OutputHLSL::header()
const TString &name = varying->second->getSymbol();
// Program linking depends on this exact format
- varyings += "static " + typeString(type) + " " + decorate(name) + arrayString(type) + " = " + initializer(type) + ";\n";
+ varyings += "static " + typeString(type) + " " + decorate(name) + arrayString(type) + " = " + initializer(type, mOutputType) + ";\n";
}
for (ReferencedSymbols::const_iterator attribute = mReferencedAttributes.begin(); attribute != mReferencedAttributes.end(); attribute++)
@@ -198,7 +198,7 @@ void OutputHLSL::header()
const TType &type = attribute->second->getType();
const TString &name = attribute->second->getSymbol();
- attributes += "static " + typeString(type) + " " + decorate(name) + arrayString(type) + " = " + initializer(type) + ";\n";
+ attributes += "static " + typeString(type) + " " + decorate(name) + arrayString(type) + " = " + initializer(type, mOutputType) + ";\n";
}
if (mUsesDiscardRewriting)
@@ -1531,7 +1531,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
{
symbol->traverse(this);
out << arrayString(symbol->getType());
- out << " = " + initializer(symbol->getType());
+ out << " = " + initializer(symbol->getType(), mOutputType);
}
else
{
@@ -2604,7 +2604,7 @@ TString OutputHLSL::arrayString(const TType &type)
return "[" + str(type.getArraySize()) + "]";
}
-static size_t getTypeComponentCount(const TType &type)
+static size_t getTypeComponentCount(const TType &type, ShShaderOutput outputType)
{
if (type.getStruct())
{
@@ -2616,8 +2616,8 @@ static size_t getTypeComponentCount(const TType &type)
const TField *field = fields[i];
const TType *fieldType = field->type();
- compCount += getTypeComponentCount(*fieldType);
- if (!fieldType->getStruct())
+ compCount += getTypeComponentCount(*fieldType, outputType);
+ if (!fieldType->getStruct() && outputType == SH_HLSL11_OUTPUT)
{
// Add padding size
compCount += 4 - fieldType->getNominalSize();
@@ -2637,11 +2637,11 @@ static size_t getTypeComponentCount(const TType &type)
}
}
-TString OutputHLSL::initializer(const TType &type)
+TString OutputHLSL::initializer(const TType &type, ShShaderOutput outputType)
{
TString string;
- size_t size = getTypeComponentCount(type);
+ size_t size = getTypeComponentCount(type, outputType);
for (size_t component = 0; component < size; component++)
{
string += "0";
@@ -2695,7 +2695,7 @@ void OutputHLSL::addConstructor(const TType &type, const TString &name, const TI
structure += " " + typeString(*field->type()) + " " + decorateField(field->name(), type) + arrayString(*field->type()) + ";\n";
- if (!field->type()->getStruct())
+ if (!field->type()->getStruct() && mOutputType == SH_HLSL11_OUTPUT)
{
// Add padding to prevent tight packing (crbug.com/359225)
unsigned int padRequired = 4 - field->type()->getNominalSize();
@@ -2827,7 +2827,7 @@ void OutputHLSL::addConstructor(const TType &type, const TString &name, const TI
constructor += "x" + str(parameterIndex);
- if (!field->type()->getStruct())
+ if (!field->type()->getStruct() && mOutputType == SH_HLSL11_OUTPUT)
{
unsigned int padRequired = 4 - field->type()->getNominalSize();
switch (padRequired)
diff --git a/src/compiler/translator/OutputHLSL.h b/src/compiler/translator/OutputHLSL.h
index 2478c9e9..77646e43 100644
--- a/src/compiler/translator/OutputHLSL.h
+++ b/src/compiler/translator/OutputHLSL.h
@@ -37,7 +37,7 @@ class OutputHLSL : public TIntermTraverser
TString textureString(const TType &type);
static TString qualifierString(TQualifier qualifier);
static TString arrayString(const TType &type);
- static TString initializer(const TType &type);
+ static TString initializer(const TType &type, ShShaderOutput outputType);
static TString decorate(const TString &string); // Prepends an underscore to avoid naming clashes
static TString decorateUniform(const TString &string, const TType &type);
static TString decorateField(const TString &string, const TType &structure);