Commit d15250e6 by Jamie Madill

Move shader variables into the base impl.

These variable types apply across shader types. Either we'll want a way to cache them after we query them, or we'll do a pre-parse pass similar to our current Chromium GLSL to GLSL pre-pass where we store the variables in ANGLE. In either case, they're shared across GL implementations so make sense as queries from gl::Shader. BUG=angle:731 Change-Id: I23f5541423abb4af87a2bc2fc1e9f4047fd2ff90 Reviewed-on: https://chromium-review.googlesource.com/214870Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent ab56c6ae
...@@ -1060,11 +1060,8 @@ bool ProgramBinary::applyUniformBuffers(const std::vector<gl::Buffer*> boundBuff ...@@ -1060,11 +1060,8 @@ bool ProgramBinary::applyUniformBuffers(const std::vector<gl::Buffer*> boundBuff
bool ProgramBinary::linkVaryings(InfoLog &infoLog, Shader *fragmentShader, Shader *vertexShader) bool ProgramBinary::linkVaryings(InfoLog &infoLog, Shader *fragmentShader, Shader *vertexShader)
{ {
rx::VertexShaderD3D *vertexShaderD3D = rx::VertexShaderD3D::makeVertexShaderD3D(vertexShader->getImplementation()); std::vector<PackedVarying> &fragmentVaryings = fragmentShader->getVaryings();
rx::FragmentShaderD3D *fragmentShaderD3D = rx::FragmentShaderD3D::makeFragmentShaderD3D(fragmentShader->getImplementation()); std::vector<PackedVarying> &vertexVaryings = vertexShader->getVaryings();
std::vector<PackedVarying> &fragmentVaryings = fragmentShaderD3D->getVaryings();
std::vector<PackedVarying> &vertexVaryings = vertexShaderD3D->getVaryings();
for (size_t fragVaryingIndex = 0; fragVaryingIndex < fragmentVaryings.size(); fragVaryingIndex++) for (size_t fragVaryingIndex = 0; fragVaryingIndex < fragmentVaryings.size(); fragVaryingIndex++)
{ {
...@@ -1654,7 +1651,7 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin ...@@ -1654,7 +1651,7 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin
bool success = true; bool success = true;
if (!linkAttributes(infoLog, attributeBindings, fragmentShader, vertexShader)) if (!linkAttributes(infoLog, attributeBindings, vertexShader))
{ {
success = false; success = false;
} }
...@@ -1688,7 +1685,7 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin ...@@ -1688,7 +1685,7 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin
if (success) if (success)
{ {
VertexFormat defaultInputLayout[MAX_VERTEX_ATTRIBS]; VertexFormat defaultInputLayout[MAX_VERTEX_ATTRIBS];
GetInputLayoutFromShader(vertexShaderD3D->getActiveAttributes(), defaultInputLayout); GetInputLayoutFromShader(vertexShader->getActiveAttributes(), defaultInputLayout);
rx::ShaderExecutable *defaultVertexExecutable = getVertexExecutableForInputLayout(defaultInputLayout); rx::ShaderExecutable *defaultVertexExecutable = getVertexExecutableForInputLayout(defaultInputLayout);
std::vector<GLenum> defaultPixelOutput(IMPLEMENTATION_MAX_DRAW_BUFFERS); std::vector<GLenum> defaultPixelOutput(IMPLEMENTATION_MAX_DRAW_BUFFERS);
...@@ -1719,12 +1716,12 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin ...@@ -1719,12 +1716,12 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin
} }
// Determines the mapping between GL attributes and Direct3D 9 vertex stream usage indices // Determines the mapping between GL attributes and Direct3D 9 vertex stream usage indices
bool ProgramBinary::linkAttributes(InfoLog &infoLog, const AttributeBindings &attributeBindings, Shader *fragmentShader, Shader *vertexShader) bool ProgramBinary::linkAttributes(InfoLog &infoLog, const AttributeBindings &attributeBindings, const Shader *vertexShader)
{ {
rx::VertexShaderD3D *vertexShaderD3D = rx::VertexShaderD3D::makeVertexShaderD3D(vertexShader->getImplementation()); const rx::VertexShaderD3D *vertexShaderD3D = rx::VertexShaderD3D::makeVertexShaderD3D(vertexShader->getImplementation());
unsigned int usedLocations = 0; unsigned int usedLocations = 0;
const std::vector<sh::Attribute> &activeAttributes = vertexShaderD3D->getActiveAttributes(); const std::vector<sh::Attribute> &activeAttributes = vertexShader->getActiveAttributes();
// Link attributes that have a binding location // Link attributes that have a binding location
for (unsigned int attributeIndex = 0; attributeIndex < activeAttributes.size(); attributeIndex++) for (unsigned int attributeIndex = 0; attributeIndex < activeAttributes.size(); attributeIndex++)
...@@ -1902,8 +1899,8 @@ bool ProgramBinary::linkUniforms(InfoLog &infoLog, const Shader &vertexShader, c ...@@ -1902,8 +1899,8 @@ bool ProgramBinary::linkUniforms(InfoLog &infoLog, const Shader &vertexShader, c
const rx::VertexShaderD3D *vertexShaderD3D = rx::VertexShaderD3D::makeVertexShaderD3D(vertexShader.getImplementation()); const rx::VertexShaderD3D *vertexShaderD3D = rx::VertexShaderD3D::makeVertexShaderD3D(vertexShader.getImplementation());
const rx::FragmentShaderD3D *fragmentShaderD3D = rx::FragmentShaderD3D::makeFragmentShaderD3D(fragmentShader.getImplementation()); const rx::FragmentShaderD3D *fragmentShaderD3D = rx::FragmentShaderD3D::makeFragmentShaderD3D(fragmentShader.getImplementation());
const std::vector<sh::Uniform> &vertexUniforms = vertexShaderD3D->getUniforms(); const std::vector<sh::Uniform> &vertexUniforms = vertexShader.getUniforms();
const std::vector<sh::Uniform> &fragmentUniforms = fragmentShaderD3D->getUniforms(); const std::vector<sh::Uniform> &fragmentUniforms = fragmentShader.getUniforms();
// Check that uniforms defined in the vertex and fragment shaders are identical // Check that uniforms defined in the vertex and fragment shaders are identical
typedef std::map<std::string, const sh::Uniform*> UniformMap; typedef std::map<std::string, const sh::Uniform*> UniformMap;
...@@ -2171,11 +2168,8 @@ bool ProgramBinary::areMatchingInterfaceBlocks(InfoLog &infoLog, const sh::Inter ...@@ -2171,11 +2168,8 @@ bool ProgramBinary::areMatchingInterfaceBlocks(InfoLog &infoLog, const sh::Inter
bool ProgramBinary::linkUniformBlocks(InfoLog &infoLog, const Shader &vertexShader, const Shader &fragmentShader, const Caps &caps) bool ProgramBinary::linkUniformBlocks(InfoLog &infoLog, const Shader &vertexShader, const Shader &fragmentShader, const Caps &caps)
{ {
const rx::VertexShaderD3D *vertexShaderD3D = rx::VertexShaderD3D::makeVertexShaderD3D(vertexShader.getImplementation()); const std::vector<sh::InterfaceBlock> &vertexInterfaceBlocks = vertexShader.getInterfaceBlocks();
const rx::FragmentShaderD3D *fragmentShaderD3D = rx::FragmentShaderD3D::makeFragmentShaderD3D(fragmentShader.getImplementation()); const std::vector<sh::InterfaceBlock> &fragmentInterfaceBlocks = fragmentShader.getInterfaceBlocks();
const std::vector<sh::InterfaceBlock> &vertexInterfaceBlocks = vertexShaderD3D->getInterfaceBlocks();
const std::vector<sh::InterfaceBlock> &fragmentInterfaceBlocks = fragmentShaderD3D->getInterfaceBlocks();
// Check that interface blocks defined in the vertex and fragment shaders are identical // Check that interface blocks defined in the vertex and fragment shaders are identical
typedef std::map<std::string, const sh::InterfaceBlock*> UniformBlockMap; typedef std::map<std::string, const sh::InterfaceBlock*> UniformBlockMap;
......
...@@ -202,7 +202,7 @@ class ProgramBinary : public RefCountObject ...@@ -202,7 +202,7 @@ class ProgramBinary : public RefCountObject
void reset(); void reset();
bool linkVaryings(InfoLog &infoLog, Shader *fragmentShader, Shader *vertexShader); bool linkVaryings(InfoLog &infoLog, Shader *fragmentShader, Shader *vertexShader);
bool linkAttributes(InfoLog &infoLog, const AttributeBindings &attributeBindings, Shader *fragmentShader, Shader *vertexShader); bool linkAttributes(InfoLog &infoLog, const AttributeBindings &attributeBindings, const Shader *vertexShader);
bool linkValidateVariablesBase(InfoLog &infoLog, bool linkValidateVariablesBase(InfoLog &infoLog,
const std::string &variableName, const std::string &variableName,
......
...@@ -32,6 +32,7 @@ Shader::Shader(ResourceManager *manager, rx::ShaderImpl *impl, GLenum type, GLui ...@@ -32,6 +32,7 @@ Shader::Shader(ResourceManager *manager, rx::ShaderImpl *impl, GLenum type, GLui
mDeleteStatus(false), mDeleteStatus(false),
mCompiled(false) mCompiled(false)
{ {
ASSERT(impl);
} }
Shader::~Shader() Shader::~Shader()
...@@ -151,4 +152,54 @@ void Shader::flagForDeletion() ...@@ -151,4 +152,54 @@ void Shader::flagForDeletion()
mDeleteStatus = true; mDeleteStatus = true;
} }
const std::vector<gl::PackedVarying> &Shader::getVaryings() const
{
return mShader->getVaryings();
}
const std::vector<sh::Uniform> &Shader::getUniforms() const
{
return mShader->getUniforms();
}
const std::vector<sh::InterfaceBlock> &Shader::getInterfaceBlocks() const
{
return mShader->getInterfaceBlocks();
}
const std::vector<sh::Attribute> &Shader::getActiveAttributes() const
{
return mShader->getActiveAttributes();
}
const std::vector<sh::Attribute> &Shader::getActiveOutputVariables() const
{
return mShader->getActiveOutputVariables();
}
std::vector<gl::PackedVarying> &Shader::getVaryings()
{
return mShader->getVaryings();
}
std::vector<sh::Uniform> &Shader::getUniforms()
{
return mShader->getUniforms();
}
std::vector<sh::InterfaceBlock> &Shader::getInterfaceBlocks()
{
return mShader->getInterfaceBlocks();
}
std::vector<sh::Attribute> &Shader::getActiveAttributes()
{
return mShader->getActiveAttributes();
}
std::vector<sh::Attribute> &Shader::getActiveOutputVariables()
{
return mShader->getActiveOutputVariables();
}
} }
...@@ -80,6 +80,18 @@ class Shader ...@@ -80,6 +80,18 @@ class Shader
bool isFlaggedForDeletion() const; bool isFlaggedForDeletion() const;
void flagForDeletion(); void flagForDeletion();
const std::vector<gl::PackedVarying> &getVaryings() const;
const std::vector<sh::Uniform> &getUniforms() const;
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const;
const std::vector<sh::Attribute> &getActiveAttributes() const;
const std::vector<sh::Attribute> &getActiveOutputVariables() const;
std::vector<gl::PackedVarying> &getVaryings();
std::vector<sh::Uniform> &getUniforms();
std::vector<sh::InterfaceBlock> &getInterfaceBlocks();
std::vector<sh::Attribute> &getActiveAttributes();
std::vector<sh::Attribute> &getActiveOutputVariables();
private: private:
DISALLOW_COPY_AND_ASSIGN(Shader); DISALLOW_COPY_AND_ASSIGN(Shader);
......
...@@ -9,7 +9,10 @@ ...@@ -9,7 +9,10 @@
#ifndef LIBGLESV2_RENDERER_SHADERIMPL_H_ #ifndef LIBGLESV2_RENDERER_SHADERIMPL_H_
#define LIBGLESV2_RENDERER_SHADERIMPL_H_ #define LIBGLESV2_RENDERER_SHADERIMPL_H_
#include <vector>
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libGLESv2/Shader.h"
namespace rx namespace rx
{ {
...@@ -22,6 +25,25 @@ class ShaderImpl ...@@ -22,6 +25,25 @@ class ShaderImpl
virtual bool compile(const std::string &source) = 0; virtual bool compile(const std::string &source) = 0;
virtual const std::string &getInfoLog() const = 0; virtual const std::string &getInfoLog() const = 0;
virtual const std::string &getTranslatedSource() const = 0; virtual const std::string &getTranslatedSource() const = 0;
const std::vector<gl::PackedVarying> &getVaryings() const { return mVaryings; }
const std::vector<sh::Uniform> &getUniforms() const { return mUniforms; }
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return mInterfaceBlocks; }
const std::vector<sh::Attribute> &getActiveAttributes() const { return mActiveAttributes; }
const std::vector<sh::Attribute> &getActiveOutputVariables() const { return mActiveOutputVariables; }
std::vector<gl::PackedVarying> &getVaryings() { return mVaryings; }
std::vector<sh::Uniform> &getUniforms() { return mUniforms; }
std::vector<sh::InterfaceBlock> &getInterfaceBlocks() { return mInterfaceBlocks; }
std::vector<sh::Attribute> &getActiveAttributes() { return mActiveAttributes; }
std::vector<sh::Attribute> &getActiveOutputVariables() { return mActiveOutputVariables; }
protected:
std::vector<gl::PackedVarying> mVaryings;
std::vector<sh::Uniform> mUniforms;
std::vector<sh::InterfaceBlock> mInterfaceBlocks;
std::vector<sh::Attribute> mActiveAttributes;
std::vector<sh::Attribute> mActiveOutputVariables;
}; };
} }
......
...@@ -218,9 +218,11 @@ int DynamicHLSL::packVaryings(InfoLog &infoLog, VaryingPacking packing, rx::Frag ...@@ -218,9 +218,11 @@ int DynamicHLSL::packVaryings(InfoLog &infoLog, VaryingPacking packing, rx::Frag
std::set<std::string> packedVaryings; std::set<std::string> packedVaryings;
for (unsigned int varyingIndex = 0; varyingIndex < fragmentShader->mVaryings.size(); varyingIndex++) std::vector<gl::PackedVarying> &fragmentVaryings = fragmentShader->getVaryings();
std::vector<gl::PackedVarying> &vertexVaryings = vertexShader->getVaryings();
for (unsigned int varyingIndex = 0; varyingIndex < fragmentVaryings.size(); varyingIndex++)
{ {
PackedVarying *varying = &fragmentShader->mVaryings[varyingIndex]; PackedVarying *varying = &fragmentVaryings[varyingIndex];
if (packVarying(varying, maxVaryingVectors, packing)) if (packVarying(varying, maxVaryingVectors, packing))
{ {
packedVaryings.insert(varying->name); packedVaryings.insert(varying->name);
...@@ -238,9 +240,9 @@ int DynamicHLSL::packVaryings(InfoLog &infoLog, VaryingPacking packing, rx::Frag ...@@ -238,9 +240,9 @@ int DynamicHLSL::packVaryings(InfoLog &infoLog, VaryingPacking packing, rx::Frag
if (packedVaryings.find(transformFeedbackVarying) == packedVaryings.end()) if (packedVaryings.find(transformFeedbackVarying) == packedVaryings.end())
{ {
bool found = false; bool found = false;
for (unsigned int varyingIndex = 0; varyingIndex < vertexShader->mVaryings.size(); varyingIndex++) for (unsigned int varyingIndex = 0; varyingIndex < vertexVaryings.size(); varyingIndex++)
{ {
PackedVarying *varying = &vertexShader->mVaryings[varyingIndex]; PackedVarying *varying = &vertexVaryings[varyingIndex];
if (transformFeedbackVarying == varying->name) if (transformFeedbackVarying == varying->name)
{ {
if (!packVarying(varying, maxVaryingVectors, packing)) if (!packVarying(varying, maxVaryingVectors, packing))
...@@ -281,9 +283,10 @@ std::string DynamicHLSL::generateVaryingHLSL(rx::VertexShaderD3D *shader) const ...@@ -281,9 +283,10 @@ std::string DynamicHLSL::generateVaryingHLSL(rx::VertexShaderD3D *shader) const
std::string varyingSemantic = getVaryingSemantic(shader->mUsesPointSize); std::string varyingSemantic = getVaryingSemantic(shader->mUsesPointSize);
std::string varyingHLSL; std::string varyingHLSL;
for (unsigned int varyingIndex = 0; varyingIndex < shader->mVaryings.size(); varyingIndex++) std::vector<gl::PackedVarying> &varyings = shader->getVaryings();
for (unsigned int varyingIndex = 0; varyingIndex < varyings.size(); varyingIndex++)
{ {
const PackedVarying &varying = shader->mVaryings[varyingIndex]; const PackedVarying &varying = varyings[varyingIndex];
if (varying.registerAssigned()) if (varying.registerAssigned())
{ {
GLenum transposedType = TransposeMatrixType(varying.type); GLenum transposedType = TransposeMatrixType(varying.type);
...@@ -608,7 +611,7 @@ void DynamicHLSL::storeUserLinkedVaryings(const rx::VertexShaderD3D *vertexShade ...@@ -608,7 +611,7 @@ void DynamicHLSL::storeUserLinkedVaryings(const rx::VertexShaderD3D *vertexShade
std::vector<LinkedVarying> *linkedVaryings) const std::vector<LinkedVarying> *linkedVaryings) const
{ {
const std::string &varyingSemantic = getVaryingSemantic(vertexShader->mUsesPointSize); const std::string &varyingSemantic = getVaryingSemantic(vertexShader->mUsesPointSize);
const std::vector<PackedVarying> &varyings = vertexShader->mVaryings; const std::vector<PackedVarying> &varyings = vertexShader->getVaryings();
for (unsigned int varyingIndex = 0; varyingIndex < varyings.size(); varyingIndex++) for (unsigned int varyingIndex = 0; varyingIndex < varyings.size(); varyingIndex++)
{ {
...@@ -723,9 +726,10 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const ...@@ -723,9 +726,10 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const
vertexHLSL += " output.gl_FragCoord = gl_Position;\n"; vertexHLSL += " output.gl_FragCoord = gl_Position;\n";
} }
for (unsigned int vertVaryingIndex = 0; vertVaryingIndex < vertexShader->mVaryings.size(); vertVaryingIndex++) const std::vector<PackedVarying> &vertexVaryings = vertexShader->getVaryings();
for (unsigned int vertVaryingIndex = 0; vertVaryingIndex < vertexVaryings.size(); vertVaryingIndex++)
{ {
const PackedVarying &varying = vertexShader->mVaryings[vertVaryingIndex]; const PackedVarying &varying = vertexVaryings[vertVaryingIndex];
if (varying.registerAssigned()) if (varying.registerAssigned())
{ {
for (unsigned int elementIndex = 0; elementIndex < varying.elementCount(); elementIndex++) for (unsigned int elementIndex = 0; elementIndex < varying.elementCount(); elementIndex++)
...@@ -813,7 +817,7 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const ...@@ -813,7 +817,7 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const
{ {
defineOutputVariables(fragmentShader, programOutputVars); defineOutputVariables(fragmentShader, programOutputVars);
const std::vector<sh::Attribute> &shaderOutputVars = fragmentShader->getOutputVariables(); const std::vector<sh::Attribute> &shaderOutputVars = fragmentShader->getActiveOutputVariables();
for (auto locationIt = programOutputVars->begin(); locationIt != programOutputVars->end(); locationIt++) for (auto locationIt = programOutputVars->begin(); locationIt != programOutputVars->end(); locationIt++)
{ {
const VariableLocation &outputLocation = locationIt->second; const VariableLocation &outputLocation = locationIt->second;
...@@ -897,9 +901,10 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const ...@@ -897,9 +901,10 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const
} }
} }
for (unsigned int varyingIndex = 0; varyingIndex < fragmentShader->mVaryings.size(); varyingIndex++) const std::vector<PackedVarying> &fragmentVaryings = fragmentShader->getVaryings();
for (unsigned int varyingIndex = 0; varyingIndex < fragmentVaryings.size(); varyingIndex++)
{ {
const PackedVarying &varying = fragmentShader->mVaryings[varyingIndex]; const PackedVarying &varying = fragmentVaryings[varyingIndex];
if (varying.registerAssigned()) if (varying.registerAssigned())
{ {
for (unsigned int elementIndex = 0; elementIndex < varying.elementCount(); elementIndex++) for (unsigned int elementIndex = 0; elementIndex < varying.elementCount(); elementIndex++)
...@@ -953,7 +958,7 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const ...@@ -953,7 +958,7 @@ bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const
void DynamicHLSL::defineOutputVariables(rx::FragmentShaderD3D *fragmentShader, std::map<int, VariableLocation> *programOutputVars) const void DynamicHLSL::defineOutputVariables(rx::FragmentShaderD3D *fragmentShader, std::map<int, VariableLocation> *programOutputVars) const
{ {
const std::vector<sh::Attribute> &shaderOutputVars = fragmentShader->getOutputVariables(); const std::vector<sh::Attribute> &shaderOutputVars = fragmentShader->getActiveOutputVariables();
for (unsigned int outputVariableIndex = 0; outputVariableIndex < shaderOutputVars.size(); outputVariableIndex++) for (unsigned int outputVariableIndex = 0; outputVariableIndex < shaderOutputVars.size(); outputVariableIndex++)
{ {
......
...@@ -135,7 +135,7 @@ void ShaderD3D::parseVaryings(void *compiler) ...@@ -135,7 +135,7 @@ void ShaderD3D::parseVaryings(void *compiler)
void ShaderD3D::resetVaryingsRegisterAssignment() void ShaderD3D::resetVaryingsRegisterAssignment()
{ {
for (unsigned int varyingIndex = 0; varyingIndex < mVaryings.size(); varyingIndex++) for (size_t varyingIndex = 0; varyingIndex < mVaryings.size(); varyingIndex++)
{ {
mVaryings[varyingIndex].resetRegisterAssignment(); mVaryings[varyingIndex].resetRegisterAssignment();
} }
...@@ -148,9 +148,6 @@ void ShaderD3D::uncompile() ...@@ -148,9 +148,6 @@ void ShaderD3D::uncompile()
mHlsl.clear(); mHlsl.clear();
mInfoLog.clear(); mInfoLog.clear();
// set by parseVaryings
mVaryings.clear();
mUsesMultipleRenderTargets = false; mUsesMultipleRenderTargets = false;
mUsesFragColor = false; mUsesFragColor = false;
mUsesFragData = false; mUsesFragData = false;
...@@ -164,8 +161,11 @@ void ShaderD3D::uncompile() ...@@ -164,8 +161,11 @@ void ShaderD3D::uncompile()
mUsesDiscardRewriting = false; mUsesDiscardRewriting = false;
mUsesNestedBreak = false; mUsesNestedBreak = false;
mActiveUniforms.clear(); mVaryings.clear();
mActiveInterfaceBlocks.clear(); mUniforms.clear();
mInterfaceBlocks.clear();
mActiveAttributes.clear();
mActiveOutputVariables.clear();
} }
void ShaderD3D::compileToHLSL(void *compiler, const std::string &source) void ShaderD3D::compileToHLSL(void *compiler, const std::string &source)
...@@ -245,11 +245,11 @@ void ShaderD3D::compileToHLSL(void *compiler, const std::string &source) ...@@ -245,11 +245,11 @@ void ShaderD3D::compileToHLSL(void *compiler, const std::string &source)
SafeDeleteArray(outputHLSL); SafeDeleteArray(outputHLSL);
mActiveUniforms = *GetShaderVariables(ShGetUniforms(compiler)); mUniforms = *GetShaderVariables(ShGetUniforms(compiler));
for (size_t uniformIndex = 0; uniformIndex < mActiveUniforms.size(); uniformIndex++) for (size_t uniformIndex = 0; uniformIndex < mUniforms.size(); uniformIndex++)
{ {
const sh::Uniform &uniform = mActiveUniforms[uniformIndex]; const sh::Uniform &uniform = mUniforms[uniformIndex];
unsigned int index = -1; unsigned int index = -1;
bool result = ShGetUniformRegister(compiler, uniform.name.c_str(), &index); bool result = ShGetUniformRegister(compiler, uniform.name.c_str(), &index);
...@@ -259,11 +259,11 @@ void ShaderD3D::compileToHLSL(void *compiler, const std::string &source) ...@@ -259,11 +259,11 @@ void ShaderD3D::compileToHLSL(void *compiler, const std::string &source)
mUniformRegisterMap[uniform.name] = index; mUniformRegisterMap[uniform.name] = index;
} }
mActiveInterfaceBlocks = *GetShaderVariables(ShGetInterfaceBlocks(compiler)); mInterfaceBlocks = *GetShaderVariables(ShGetInterfaceBlocks(compiler));
for (size_t blockIndex = 0; blockIndex < mActiveInterfaceBlocks.size(); blockIndex++) for (size_t blockIndex = 0; blockIndex < mInterfaceBlocks.size(); blockIndex++)
{ {
const sh::InterfaceBlock &interfaceBlock = mActiveInterfaceBlocks[blockIndex]; const sh::InterfaceBlock &interfaceBlock = mInterfaceBlocks[blockIndex];
unsigned int index = -1; unsigned int index = -1;
bool result = ShGetInterfaceBlockRegister(compiler, interfaceBlock.name.c_str(), &index); bool result = ShGetInterfaceBlockRegister(compiler, interfaceBlock.name.c_str(), &index);
...@@ -388,14 +388,6 @@ bool VertexShaderD3D::compile(const std::string &source) ...@@ -388,14 +388,6 @@ bool VertexShaderD3D::compile(const std::string &source)
return !getTranslatedSource().empty(); return !getTranslatedSource().empty();
} }
void VertexShaderD3D::uncompile()
{
ShaderD3D::uncompile();
// set by ParseAttributes
mActiveAttributes.clear();
}
void VertexShaderD3D::parseAttributes() void VertexShaderD3D::parseAttributes()
{ {
const std::string &hlsl = getTranslatedSource(); const std::string &hlsl = getTranslatedSource();
...@@ -405,12 +397,12 @@ void VertexShaderD3D::parseAttributes() ...@@ -405,12 +397,12 @@ void VertexShaderD3D::parseAttributes()
} }
} }
int VertexShaderD3D::getSemanticIndex(const std::string &attributeName) int VertexShaderD3D::getSemanticIndex(const std::string &attributeName) const
{ {
if (!attributeName.empty()) if (!attributeName.empty())
{ {
int semanticIndex = 0; int semanticIndex = 0;
for (unsigned int attributeIndex = 0; attributeIndex < mActiveAttributes.size(); attributeIndex++) for (size_t attributeIndex = 0; attributeIndex < mActiveAttributes.size(); attributeIndex++)
{ {
const sh::ShaderVariable &attribute = mActiveAttributes[attributeIndex]; const sh::ShaderVariable &attribute = mActiveAttributes[attributeIndex];
...@@ -452,6 +444,7 @@ bool FragmentShaderD3D::compile(const std::string &source) ...@@ -452,6 +444,7 @@ bool FragmentShaderD3D::compile(const std::string &source)
compileToHLSL(mFragmentCompiler, source); compileToHLSL(mFragmentCompiler, source);
parseVaryings(mFragmentCompiler); parseVaryings(mFragmentCompiler);
std::sort(mVaryings.begin(), mVaryings.end(), compareVarying); std::sort(mVaryings.begin(), mVaryings.end(), compareVarying);
const std::string &hlsl = getTranslatedSource(); const std::string &hlsl = getTranslatedSource();
...@@ -463,11 +456,4 @@ bool FragmentShaderD3D::compile(const std::string &source) ...@@ -463,11 +456,4 @@ bool FragmentShaderD3D::compile(const std::string &source)
return false; return false;
} }
void FragmentShaderD3D::uncompile()
{
ShaderD3D::uncompile();
mActiveOutputVariables.clear();
}
} }
...@@ -43,9 +43,6 @@ class ShaderD3D : public ShaderImpl ...@@ -43,9 +43,6 @@ class ShaderD3D : public ShaderImpl
int getShaderVersion() const { return mShaderVersion; } int getShaderVersion() const { return mShaderVersion; }
bool usesDepthRange() const { return mUsesDepthRange; } bool usesDepthRange() const { return mUsesDepthRange; }
bool usesPointSize() const { return mUsesPointSize; } bool usesPointSize() const { return mUsesPointSize; }
std::vector<gl::PackedVarying> &getVaryings() { return mVaryings; }
const std::vector<sh::Uniform> &getUniforms() const { return mActiveUniforms; }
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return mActiveInterfaceBlocks; }
static void releaseCompiler(); static void releaseCompiler();
static ShShaderOutput getCompilerOutputType(GLenum shader); static ShShaderOutput getCompilerOutputType(GLenum shader);
...@@ -61,8 +58,6 @@ class ShaderD3D : public ShaderImpl ...@@ -61,8 +58,6 @@ class ShaderD3D : public ShaderImpl
rx::Renderer *mRenderer; rx::Renderer *mRenderer;
std::vector<gl::PackedVarying> mVaryings;
int mShaderVersion; int mShaderVersion;
bool mUsesMultipleRenderTargets; bool mUsesMultipleRenderTargets;
...@@ -84,8 +79,6 @@ class ShaderD3D : public ShaderImpl ...@@ -84,8 +79,6 @@ class ShaderD3D : public ShaderImpl
std::string mHlsl; std::string mHlsl;
std::string mInfoLog; std::string mInfoLog;
std::vector<sh::Uniform> mActiveUniforms;
std::vector<sh::InterfaceBlock> mActiveInterfaceBlocks;
std::map<std::string, unsigned int> mUniformRegisterMap; std::map<std::string, unsigned int> mUniformRegisterMap;
std::map<std::string, unsigned int> mInterfaceBlockRegisterMap; std::map<std::string, unsigned int> mInterfaceBlockRegisterMap;
}; };
...@@ -102,17 +95,13 @@ class VertexShaderD3D : public ShaderD3D ...@@ -102,17 +95,13 @@ class VertexShaderD3D : public ShaderD3D
static const VertexShaderD3D *makeVertexShaderD3D(const ShaderImpl *impl); static const VertexShaderD3D *makeVertexShaderD3D(const ShaderImpl *impl);
virtual bool compile(const std::string &source); virtual bool compile(const std::string &source);
virtual void uncompile();
int getSemanticIndex(const std::string &attributeName); int getSemanticIndex(const std::string &attributeName) const;
virtual const std::vector<sh::Attribute> &getActiveAttributes() const { return mActiveAttributes; }
private: private:
DISALLOW_COPY_AND_ASSIGN(VertexShaderD3D); DISALLOW_COPY_AND_ASSIGN(VertexShaderD3D);
void parseAttributes(); void parseAttributes();
std::vector<sh::Attribute> mActiveAttributes;
}; };
class FragmentShaderD3D : public ShaderD3D class FragmentShaderD3D : public ShaderD3D
...@@ -127,14 +116,9 @@ class FragmentShaderD3D : public ShaderD3D ...@@ -127,14 +116,9 @@ class FragmentShaderD3D : public ShaderD3D
static const FragmentShaderD3D *makeFragmentShaderD3D(const ShaderImpl *impl); static const FragmentShaderD3D *makeFragmentShaderD3D(const ShaderImpl *impl);
virtual bool compile(const std::string &source); virtual bool compile(const std::string &source);
virtual void uncompile();
virtual const std::vector<sh::Attribute> &getOutputVariables() const { return mActiveOutputVariables; }
private: private:
DISALLOW_COPY_AND_ASSIGN(FragmentShaderD3D); DISALLOW_COPY_AND_ASSIGN(FragmentShaderD3D);
std::vector<sh::Attribute> mActiveOutputVariables;
}; };
} }
......
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