Commit 437d2662 by Jamie Madill

Move some D3D-specific stuff into ProgramD3D.

BUG=angle:773 Change-Id: I48b42e7a3e82a43d3dde16a8d1016d28280eae39 Reviewed-on: https://chromium-review.googlesource.com/232968Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 8e7c8a13
...@@ -8,13 +8,12 @@ ...@@ -8,13 +8,12 @@
// and related functionality. [OpenGL ES 2.0.24] section 2.10.3 page 28. // and related functionality. [OpenGL ES 2.0.24] section 2.10.3 page 28.
#include "libANGLE/Program.h" #include "libANGLE/Program.h"
#include "libANGLE/ResourceManager.h"
#include "libANGLE/Data.h" #include "libANGLE/Data.h"
#include "libANGLE/ResourceManager.h"
#include "libANGLE/features.h" #include "libANGLE/features.h"
#include "libANGLE/renderer/Renderer.h" #include "libANGLE/renderer/Renderer.h"
#include "libANGLE/renderer/ProgramImpl.h" #include "libANGLE/renderer/ProgramImpl.h"
#include "libANGLE/renderer/d3d/ShaderD3D.h"
#include "libANGLE/renderer/d3d/VertexDataManager.h"
#include "common/debug.h" #include "common/debug.h"
#include "common/version.h" #include "common/version.h"
...@@ -322,6 +321,11 @@ Error Program::link(const Data &data) ...@@ -322,6 +321,11 @@ Error Program::link(const Data &data)
} }
ASSERT(mVertexShader->getType() == GL_VERTEX_SHADER); ASSERT(mVertexShader->getType() == GL_VERTEX_SHADER);
if (!linkAttributes(mInfoLog, mAttributeBindings, mVertexShader))
{
return Error(GL_NO_ERROR);
}
int registers; int registers;
std::vector<LinkedVarying> linkedVaryings; std::vector<LinkedVarying> linkedVaryings;
rx::LinkResult result = mProgram->link(data, mInfoLog, mFragmentShader, mVertexShader, mTransformFeedbackVaryings, mTransformFeedbackBufferMode, rx::LinkResult result = mProgram->link(data, mInfoLog, mFragmentShader, mVertexShader, mTransformFeedbackVaryings, mTransformFeedbackBufferMode,
...@@ -331,11 +335,6 @@ Error Program::link(const Data &data) ...@@ -331,11 +335,6 @@ Error Program::link(const Data &data)
return result.error; return result.error;
} }
if (!linkAttributes(mInfoLog, mAttributeBindings, mVertexShader))
{
return Error(GL_NO_ERROR);
}
if (!mProgram->linkUniforms(mInfoLog, *mVertexShader, *mFragmentShader, *data.caps)) if (!mProgram->linkUniforms(mInfoLog, *mVertexShader, *mFragmentShader, *data.caps))
{ {
return Error(GL_NO_ERROR); return Error(GL_NO_ERROR);
...@@ -398,8 +397,6 @@ void Program::unlink(bool destroy) ...@@ -398,8 +397,6 @@ void Program::unlink(bool destroy)
} }
std::fill(mLinkedAttribute, mLinkedAttribute + ArraySize(mLinkedAttribute), sh::Attribute()); std::fill(mLinkedAttribute, mLinkedAttribute + ArraySize(mLinkedAttribute), sh::Attribute());
std::fill(mSemanticIndex, mSemanticIndex + ArraySize(mSemanticIndex), -1);
std::fill(mAttributesByLayout, mAttributesByLayout + ArraySize(mAttributesByLayout), -1);
mOutputVariables.clear(); mOutputVariables.clear();
mProgram->reset(); mProgram->reset();
...@@ -454,11 +451,9 @@ Error Program::loadBinary(GLenum binaryFormat, const void *binary, GLsizei lengt ...@@ -454,11 +451,9 @@ Error Program::loadBinary(GLenum binaryFormat, const void *binary, GLsizei lengt
stream.readString(&mLinkedAttribute[i].name); stream.readString(&mLinkedAttribute[i].name);
stream.readInt(&mProgram->getShaderAttributes()[i].type); stream.readInt(&mProgram->getShaderAttributes()[i].type);
stream.readString(&mProgram->getShaderAttributes()[i].name); stream.readString(&mProgram->getShaderAttributes()[i].name);
stream.readInt(&mSemanticIndex[i]); stream.readInt(&mProgram->getSemanticIndexes()[i]);
} }
initAttributesByLayout();
rx::LinkResult result = mProgram->load(mInfoLog, &stream); rx::LinkResult result = mProgram->load(mInfoLog, &stream);
if (result.error.isError() || !result.linkSuccess) if (result.error.isError() || !result.linkSuccess)
{ {
...@@ -490,7 +485,7 @@ Error Program::saveBinary(GLenum *binaryFormat, void *binary, GLsizei bufSize, G ...@@ -490,7 +485,7 @@ Error Program::saveBinary(GLenum *binaryFormat, void *binary, GLsizei bufSize, G
stream.writeString(mLinkedAttribute[i].name); stream.writeString(mLinkedAttribute[i].name);
stream.writeInt(mProgram->getShaderAttributes()[i].type); stream.writeInt(mProgram->getShaderAttributes()[i].type);
stream.writeString(mProgram->getShaderAttributes()[i].name); stream.writeString(mProgram->getShaderAttributes()[i].name);
stream.writeInt(mSemanticIndex[i]); stream.writeInt(mProgram->getSemanticIndexes()[i]);
} }
gl::Error error = mProgram->save(&stream); gl::Error error = mProgram->save(&stream);
...@@ -622,7 +617,7 @@ int Program::getSemanticIndex(int attributeIndex) ...@@ -622,7 +617,7 @@ int Program::getSemanticIndex(int attributeIndex)
{ {
ASSERT(attributeIndex >= 0 && attributeIndex < MAX_VERTEX_ATTRIBS); ASSERT(attributeIndex >= 0 && attributeIndex < MAX_VERTEX_ATTRIBS);
return mSemanticIndex[attributeIndex]; return mProgram->getSemanticIndexes()[attributeIndex];
} }
void Program::getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) void Program::getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
...@@ -1238,50 +1233,6 @@ GLenum Program::getTransformFeedbackBufferMode() const ...@@ -1238,50 +1233,6 @@ GLenum Program::getTransformFeedbackBufferMode() const
return mTransformFeedbackBufferMode; return mTransformFeedbackBufferMode;
} }
struct AttributeSorter
{
AttributeSorter(const int(&semanticIndices)[MAX_VERTEX_ATTRIBS])
: originalIndices(semanticIndices)
{
}
bool operator()(int a, int b)
{
if (originalIndices[a] == -1) return false;
if (originalIndices[b] == -1) return true;
return (originalIndices[a] < originalIndices[b]);
}
const int(&originalIndices)[MAX_VERTEX_ATTRIBS];
};
void Program::initAttributesByLayout()
{
for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++)
{
mAttributesByLayout[i] = i;
}
std::sort(&mAttributesByLayout[0], &mAttributesByLayout[MAX_VERTEX_ATTRIBS], AttributeSorter(mSemanticIndex));
}
void Program::sortAttributesByLayout(rx::TranslatedAttribute attributes[MAX_VERTEX_ATTRIBS], int sortedSemanticIndices[MAX_VERTEX_ATTRIBS]) const
{
rx::TranslatedAttribute oldTranslatedAttributes[MAX_VERTEX_ATTRIBS];
for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++)
{
oldTranslatedAttributes[i] = attributes[i];
}
for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++)
{
int oldIndex = mAttributesByLayout[i];
sortedSemanticIndices[i] = mSemanticIndex[oldIndex];
attributes[i] = oldTranslatedAttributes[oldIndex];
}
}
bool Program::linkVaryings(InfoLog &infoLog, Shader *fragmentShader, Shader *vertexShader) bool Program::linkVaryings(InfoLog &infoLog, Shader *fragmentShader, Shader *vertexShader)
{ {
std::vector<PackedVarying> &fragmentVaryings = fragmentShader->getVaryings(); std::vector<PackedVarying> &fragmentVaryings = fragmentShader->getVaryings();
...@@ -1346,8 +1297,6 @@ bool Program::linkValidateInterfaceBlockFields(InfoLog &infoLog, const std::stri ...@@ -1346,8 +1297,6 @@ bool Program::linkValidateInterfaceBlockFields(InfoLog &infoLog, const std::stri
// 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 Program::linkAttributes(InfoLog &infoLog, const AttributeBindings &attributeBindings, const Shader *vertexShader) bool Program::linkAttributes(InfoLog &infoLog, const AttributeBindings &attributeBindings, const Shader *vertexShader)
{ {
const rx::ShaderD3D *vertexShaderD3D = rx::ShaderD3D::makeShaderD3D(vertexShader->getImplementation());
unsigned int usedLocations = 0; unsigned int usedLocations = 0;
const std::vector<sh::Attribute> &shaderAttributes = vertexShader->getActiveAttributes(); const std::vector<sh::Attribute> &shaderAttributes = vertexShader->getActiveAttributes();
...@@ -1422,17 +1371,15 @@ bool Program::linkAttributes(InfoLog &infoLog, const AttributeBindings &attribut ...@@ -1422,17 +1371,15 @@ bool Program::linkAttributes(InfoLog &infoLog, const AttributeBindings &attribut
for (int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; ) for (int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; )
{ {
int index = vertexShaderD3D->getSemanticIndex(mLinkedAttribute[attributeIndex].name); int index = vertexShader->getSemanticIndex(mLinkedAttribute[attributeIndex].name);
int rows = VariableRegisterCount(mLinkedAttribute[attributeIndex].type); int rows = VariableRegisterCount(mLinkedAttribute[attributeIndex].type);
for (int r = 0; r < rows; r++) for (int r = 0; r < rows; r++)
{ {
mSemanticIndex[attributeIndex++] = index++; mProgram->getSemanticIndexes()[attributeIndex++] = index++;
} }
} }
initAttributesByLayout();
return true; return true;
} }
......
...@@ -204,9 +204,6 @@ class Program ...@@ -204,9 +204,6 @@ class Program
GLsizei getTransformFeedbackVaryingMaxLength() const; GLsizei getTransformFeedbackVaryingMaxLength() const;
GLenum getTransformFeedbackBufferMode() const; GLenum getTransformFeedbackBufferMode() const;
void initAttributesByLayout();
void sortAttributesByLayout(rx::TranslatedAttribute attributes[MAX_VERTEX_ATTRIBS], int sortedSemanticIndices[MAX_VERTEX_ATTRIBS]) const;
static bool linkVaryings(InfoLog &infoLog, Shader *fragmentShader, Shader *vertexShader); static bool linkVaryings(InfoLog &infoLog, Shader *fragmentShader, Shader *vertexShader);
static bool linkValidateUniforms(InfoLog &infoLog, const std::string &uniformName, const sh::Uniform &vertexUniform, const sh::Uniform &fragmentUniform); static bool linkValidateUniforms(InfoLog &infoLog, const std::string &uniformName, const sh::Uniform &vertexUniform, const sh::Uniform &fragmentUniform);
static bool linkValidateInterfaceBlockFields(InfoLog &infoLog, const std::string &uniformName, const sh::InterfaceBlockField &vertexUniform, const sh::InterfaceBlockField &fragmentUniform); static bool linkValidateInterfaceBlockFields(InfoLog &infoLog, const std::string &uniformName, const sh::InterfaceBlockField &vertexUniform, const sh::InterfaceBlockField &fragmentUniform);
...@@ -251,8 +248,6 @@ class Program ...@@ -251,8 +248,6 @@ class Program
rx::ProgramImpl *mProgram; rx::ProgramImpl *mProgram;
sh::Attribute mLinkedAttribute[MAX_VERTEX_ATTRIBS]; sh::Attribute mLinkedAttribute[MAX_VERTEX_ATTRIBS];
int mSemanticIndex[MAX_VERTEX_ATTRIBS];
int mAttributesByLayout[MAX_VERTEX_ATTRIBS];
std::map<int, VariableLocation> mOutputVariables; std::map<int, VariableLocation> mOutputVariables;
......
...@@ -216,4 +216,28 @@ std::vector<sh::Attribute> &Shader::getActiveOutputVariables() ...@@ -216,4 +216,28 @@ std::vector<sh::Attribute> &Shader::getActiveOutputVariables()
return mShader->getActiveOutputVariables(); return mShader->getActiveOutputVariables();
} }
int Shader::getSemanticIndex(const std::string &attributeName) const
{
if (!attributeName.empty())
{
const auto &activeAttributes = mShader->getActiveAttributes();
int semanticIndex = 0;
for (size_t attributeIndex = 0; attributeIndex < activeAttributes.size(); attributeIndex++)
{
const sh::ShaderVariable &attribute = activeAttributes[attributeIndex];
if (attribute.name == attributeName)
{
return semanticIndex;
}
semanticIndex += gl::VariableRegisterCount(attribute.type);
}
}
return -1;
}
} }
...@@ -96,6 +96,8 @@ class Shader ...@@ -96,6 +96,8 @@ class Shader
std::vector<sh::Attribute> &getActiveAttributes(); std::vector<sh::Attribute> &getActiveAttributes();
std::vector<sh::Attribute> &getActiveOutputVariables(); std::vector<sh::Attribute> &getActiveOutputVariables();
int getSemanticIndex(const std::string &attributeName) const;
private: private:
DISALLOW_COPY_AND_ASSIGN(Shader); DISALLOW_COPY_AND_ASSIGN(Shader);
......
...@@ -142,6 +142,7 @@ GLuint ProgramImpl::getUniformBlockIndex(std::string name) const ...@@ -142,6 +142,7 @@ GLuint ProgramImpl::getUniformBlockIndex(std::string name) const
void ProgramImpl::reset() void ProgramImpl::reset()
{ {
std::fill(mSemanticIndex, mSemanticIndex + ArraySize(mSemanticIndex), -1);
SafeDeleteContainer(mUniforms); SafeDeleteContainer(mUniforms);
mUniformIndex.clear(); mUniformIndex.clear();
SafeDeleteContainer(mUniformBlocks); SafeDeleteContainer(mUniformBlocks);
......
...@@ -31,6 +31,8 @@ struct LinkResult ...@@ -31,6 +31,8 @@ struct LinkResult
class ProgramImpl class ProgramImpl
{ {
public: public:
typedef int SemanticIndexArray[gl::MAX_VERTEX_ATTRIBS];
ProgramImpl() { } ProgramImpl() { }
virtual ~ProgramImpl(); virtual ~ProgramImpl();
...@@ -39,12 +41,14 @@ class ProgramImpl ...@@ -39,12 +41,14 @@ class ProgramImpl
const std::vector<gl::UniformBlock*> &getUniformBlocks() const { return mUniformBlocks; } const std::vector<gl::UniformBlock*> &getUniformBlocks() const { return mUniformBlocks; }
const std::vector<gl::LinkedVarying> &getTransformFeedbackLinkedVaryings() const { return mTransformFeedbackLinkedVaryings; } const std::vector<gl::LinkedVarying> &getTransformFeedbackLinkedVaryings() const { return mTransformFeedbackLinkedVaryings; }
const sh::Attribute *getShaderAttributes() const { return mShaderAttributes; } const sh::Attribute *getShaderAttributes() const { return mShaderAttributes; }
const SemanticIndexArray &getSemanticIndexes() const { return mSemanticIndex; }
std::vector<gl::LinkedUniform*> &getUniforms() { return mUniforms; } std::vector<gl::LinkedUniform*> &getUniforms() { return mUniforms; }
std::vector<gl::VariableLocation> &getUniformIndices() { return mUniformIndex; } std::vector<gl::VariableLocation> &getUniformIndices() { return mUniformIndex; }
std::vector<gl::UniformBlock*> &getUniformBlocks() { return mUniformBlocks; } std::vector<gl::UniformBlock*> &getUniformBlocks() { return mUniformBlocks; }
std::vector<gl::LinkedVarying> &getTransformFeedbackLinkedVaryings() { return mTransformFeedbackLinkedVaryings; } std::vector<gl::LinkedVarying> &getTransformFeedbackLinkedVaryings() { return mTransformFeedbackLinkedVaryings; }
sh::Attribute *getShaderAttributes() { return mShaderAttributes; } sh::Attribute *getShaderAttributes() { return mShaderAttributes; }
SemanticIndexArray &getSemanticIndexes() { return mSemanticIndex; }
gl::LinkedUniform *getUniformByLocation(GLint location) const; gl::LinkedUniform *getUniformByLocation(GLint location) const;
gl::LinkedUniform *getUniformByName(const std::string &name) const; gl::LinkedUniform *getUniformByName(const std::string &name) const;
...@@ -126,6 +130,7 @@ class ProgramImpl ...@@ -126,6 +130,7 @@ class ProgramImpl
std::vector<gl::UniformBlock*> mUniformBlocks; std::vector<gl::UniformBlock*> mUniformBlocks;
std::vector<gl::LinkedVarying> mTransformFeedbackLinkedVaryings; std::vector<gl::LinkedVarying> mTransformFeedbackLinkedVaryings;
SemanticIndexArray mSemanticIndex;
sh::Attribute mShaderAttributes[gl::MAX_VERTEX_ATTRIBS]; sh::Attribute mShaderAttributes[gl::MAX_VERTEX_ATTRIBS];
}; };
......
...@@ -7,16 +7,17 @@ ...@@ -7,16 +7,17 @@
// ProgramD3D.cpp: Defines the rx::ProgramD3D class which implements rx::ProgramImpl. // ProgramD3D.cpp: Defines the rx::ProgramD3D class which implements rx::ProgramImpl.
#include "libANGLE/renderer/d3d/ProgramD3D.h" #include "libANGLE/renderer/d3d/ProgramD3D.h"
#include "libANGLE/features.h"
#include "common/utilities.h"
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/Program.h" #include "libANGLE/Program.h"
#include "libANGLE/features.h"
#include "libANGLE/renderer/ShaderExecutable.h" #include "libANGLE/renderer/ShaderExecutable.h"
#include "libANGLE/renderer/d3d/DynamicHLSL.h" #include "libANGLE/renderer/d3d/DynamicHLSL.h"
#include "libANGLE/renderer/d3d/RendererD3D.h" #include "libANGLE/renderer/d3d/RendererD3D.h"
#include "libANGLE/renderer/d3d/ShaderD3D.h" #include "libANGLE/renderer/d3d/ShaderD3D.h"
#include "libANGLE/renderer/d3d/VertexDataManager.h"
#include "common/utilities.h"
namespace rx namespace rx
{ {
...@@ -100,6 +101,23 @@ bool IsRowMajorLayout(const sh::ShaderVariable &var) ...@@ -100,6 +101,23 @@ bool IsRowMajorLayout(const sh::ShaderVariable &var)
return false; return false;
} }
struct AttributeSorter
{
AttributeSorter(const ProgramImpl::SemanticIndexArray &semanticIndices)
: originalIndices(semanticIndices)
{
}
bool operator()(int a, int b)
{
if (originalIndices[a] == -1) return false;
if (originalIndices[b] == -1) return true;
return (originalIndices[a] < originalIndices[b]);
}
const ProgramImpl::SemanticIndexArray &originalIndices;
};
} }
ProgramD3D::VertexExecutable::VertexExecutable(const gl::VertexFormat inputLayout[], ProgramD3D::VertexExecutable::VertexExecutable(const gl::VertexFormat inputLayout[],
...@@ -655,6 +673,7 @@ LinkResult ProgramD3D::load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) ...@@ -655,6 +673,7 @@ LinkResult ProgramD3D::load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream)
} }
initializeUniformStorage(); initializeUniformStorage();
initAttributesByLayout();
return LinkResult(true, gl::Error(GL_NO_ERROR)); return LinkResult(true, gl::Error(GL_NO_ERROR));
} }
...@@ -1035,6 +1054,8 @@ LinkResult ProgramD3D::link(const gl::Data &data, gl::InfoLog &infoLog, ...@@ -1035,6 +1054,8 @@ LinkResult ProgramD3D::link(const gl::Data &data, gl::InfoLog &infoLog,
mUsesPointSize = vertexShaderD3D->usesPointSize(); mUsesPointSize = vertexShaderD3D->usesPointSize();
initAttributesByLayout();
return LinkResult(true, gl::Error(GL_NO_ERROR)); return LinkResult(true, gl::Error(GL_NO_ERROR));
} }
...@@ -1930,6 +1951,8 @@ void ProgramD3D::reset() ...@@ -1930,6 +1951,8 @@ void ProgramD3D::reset()
mUsedVertexSamplerRange = 0; mUsedVertexSamplerRange = 0;
mUsedPixelSamplerRange = 0; mUsedPixelSamplerRange = 0;
mDirtySamplerMapping = true; mDirtySamplerMapping = true;
std::fill(mAttributesByLayout, mAttributesByLayout + ArraySize(mAttributesByLayout), -1);
} }
unsigned int ProgramD3D::getSerial() const unsigned int ProgramD3D::getSerial() const
...@@ -1942,4 +1965,32 @@ unsigned int ProgramD3D::issueSerial() ...@@ -1942,4 +1965,32 @@ unsigned int ProgramD3D::issueSerial()
return mCurrentSerial++; return mCurrentSerial++;
} }
void ProgramD3D::initAttributesByLayout()
{
for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
{
mAttributesByLayout[i] = i;
}
std::sort(&mAttributesByLayout[0], &mAttributesByLayout[gl::MAX_VERTEX_ATTRIBS], AttributeSorter(mSemanticIndex));
}
void ProgramD3D::sortAttributesByLayout(rx::TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS],
int sortedSemanticIndices[gl::MAX_VERTEX_ATTRIBS]) const
{
rx::TranslatedAttribute oldTranslatedAttributes[gl::MAX_VERTEX_ATTRIBS];
for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
{
oldTranslatedAttributes[i] = attributes[i];
}
for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
{
int oldIndex = mAttributesByLayout[i];
sortedSemanticIndices[i] = mSemanticIndex[oldIndex];
attributes[i] = oldTranslatedAttributes[oldIndex];
}
}
} }
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#ifndef LIBANGLE_RENDERER_D3D_PROGRAMD3D_H_ #ifndef LIBANGLE_RENDERER_D3D_PROGRAMD3D_H_
#define LIBANGLE_RENDERER_D3D_PROGRAMD3D_H_ #define LIBANGLE_RENDERER_D3D_PROGRAMD3D_H_
#include "libANGLE/Constants.h"
#include "libANGLE/renderer/ProgramImpl.h" #include "libANGLE/renderer/ProgramImpl.h"
#include "libANGLE/renderer/Workarounds.h" #include "libANGLE/renderer/Workarounds.h"
#include "libANGLE/renderer/d3d/DynamicHLSL.h" #include "libANGLE/renderer/d3d/DynamicHLSL.h"
...@@ -123,6 +124,10 @@ class ProgramD3D : public ProgramImpl ...@@ -123,6 +124,10 @@ class ProgramD3D : public ProgramImpl
unsigned int getSerial() const; unsigned int getSerial() const;
void initAttributesByLayout();
void sortAttributesByLayout(rx::TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS],
int sortedSemanticIndices[gl::MAX_VERTEX_ATTRIBS]) const;
private: private:
DISALLOW_COPY_AND_ASSIGN(ProgramD3D); DISALLOW_COPY_AND_ASSIGN(ProgramD3D);
...@@ -223,6 +228,8 @@ class ProgramD3D : public ProgramImpl ...@@ -223,6 +228,8 @@ class ProgramD3D : public ProgramImpl
int mShaderVersion; int mShaderVersion;
int mAttributesByLayout[gl::MAX_VERTEX_ATTRIBS];
unsigned int mSerial; unsigned int mSerial;
static unsigned int issueSerial(); static unsigned int issueSerial();
......
...@@ -459,25 +459,4 @@ void ShaderD3D::parseAttributes(void *compiler) ...@@ -459,25 +459,4 @@ void ShaderD3D::parseAttributes(void *compiler)
} }
} }
int ShaderD3D::getSemanticIndex(const std::string &attributeName) const
{
if (!attributeName.empty())
{
int semanticIndex = 0;
for (size_t attributeIndex = 0; attributeIndex < mActiveAttributes.size(); attributeIndex++)
{
const sh::ShaderVariable &attribute = mActiveAttributes[attributeIndex];
if (attribute.name == attributeName)
{
return semanticIndex;
}
semanticIndex += gl::VariableRegisterCount(attribute.type);
}
}
return -1;
}
} }
...@@ -41,7 +41,6 @@ class ShaderD3D : public ShaderImpl ...@@ -41,7 +41,6 @@ class ShaderD3D : public ShaderImpl
void resetVaryingsRegisterAssignment(); void resetVaryingsRegisterAssignment();
unsigned int getUniformRegister(const std::string &uniformName) const; unsigned int getUniformRegister(const std::string &uniformName) const;
unsigned int getInterfaceBlockRegister(const std::string &blockName) const; unsigned int getInterfaceBlockRegister(const std::string &blockName) const;
int getSemanticIndex(const std::string &attributeName) const;
void appendDebugInfo(const std::string &info) { mDebugInfo += info; } void appendDebugInfo(const std::string &info) { mDebugInfo += info; }
D3DWorkaroundType getD3DWorkarounds() const; D3DWorkaroundType getD3DWorkarounds() const;
......
...@@ -89,8 +89,10 @@ void InputLayoutCache::markDirty() ...@@ -89,8 +89,10 @@ void InputLayoutCache::markDirty()
gl::Error InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS], gl::Error InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS],
gl::Program *program) gl::Program *program)
{ {
ProgramD3D *programD3D = ProgramD3D::makeProgramD3D(program->getImplementation());
int sortedSemanticIndices[gl::MAX_VERTEX_ATTRIBS]; int sortedSemanticIndices[gl::MAX_VERTEX_ATTRIBS];
program->sortAttributesByLayout(attributes, sortedSemanticIndices); programD3D->sortAttributesByLayout(attributes, sortedSemanticIndices);
if (!mDevice || !mDeviceContext) if (!mDevice || !mDeviceContext)
{ {
......
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