diff options
Diffstat (limited to 'src/libGLESv2/ProgramBinary.cpp')
-rw-r--r-- | src/libGLESv2/ProgramBinary.cpp | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/src/libGLESv2/ProgramBinary.cpp b/src/libGLESv2/ProgramBinary.cpp index 135facd8..ee0ec8e0 100644 --- a/src/libGLESv2/ProgramBinary.cpp +++ b/src/libGLESv2/ProgramBinary.cpp @@ -34,6 +34,11 @@ std::string str(int i) return buffer; } +static rx::D3DWorkaroundType DiscardWorkaround(bool usesDiscard) +{ + return (usesDiscard ? rx::ANGLE_D3D_WORKAROUND_SM3_OPTIMIZER : rx::ANGLE_D3D_WORKAROUND_NONE); +} + UniformLocation::UniformLocation(const std::string &name, unsigned int element, unsigned int index) : name(name), element(element), index(index) { @@ -1647,6 +1652,8 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length) stream.read(&mSemanticIndex[i]); } + initAttributesByLayout(); + for (unsigned int i = 0; i < MAX_TEXTURE_IMAGE_UNITS; ++i) { stream.read(&mSamplersPS[i].active); @@ -1960,13 +1967,13 @@ bool ProgramBinary::link(InfoLog &infoLog, const AttributeBindings &attributeBin if (success) { - mVertexExecutable = mRenderer->compileToExecutable(infoLog, vertexHLSL.c_str(), rx::SHADER_VERTEX); - mPixelExecutable = mRenderer->compileToExecutable(infoLog, pixelHLSL.c_str(), rx::SHADER_PIXEL); + mVertexExecutable = mRenderer->compileToExecutable(infoLog, vertexHLSL.c_str(), rx::SHADER_VERTEX, DiscardWorkaround(vertexShader->mUsesDiscardRewriting)); + mPixelExecutable = mRenderer->compileToExecutable(infoLog, pixelHLSL.c_str(), rx::SHADER_PIXEL, DiscardWorkaround(fragmentShader->mUsesDiscardRewriting)); if (usesGeometryShader()) { std::string geometryHLSL = generateGeometryShaderHLSL(registers, packing, fragmentShader, vertexShader); - mGeometryExecutable = mRenderer->compileToExecutable(infoLog, geometryHLSL.c_str(), rx::SHADER_GEOMETRY); + mGeometryExecutable = mRenderer->compileToExecutable(infoLog, geometryHLSL.c_str(), rx::SHADER_GEOMETRY, rx::ANGLE_D3D_WORKAROUND_NONE); } if (!mVertexExecutable || !mPixelExecutable || (usesGeometryShader() && !mGeometryExecutable)) @@ -2053,6 +2060,8 @@ bool ProgramBinary::linkAttributes(InfoLog &infoLog, const AttributeBindings &at } } + initAttributesByLayout(); + return true; } @@ -2579,12 +2588,6 @@ struct AttributeSorter AttributeSorter(const int (&semanticIndices)[MAX_VERTEX_ATTRIBS]) : originalIndices(semanticIndices) { - for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++) - { - indices[i] = i; - } - - std::sort(&indices[0], &indices[MAX_VERTEX_ATTRIBS], *this); } bool operator()(int a, int b) @@ -2592,27 +2595,32 @@ struct AttributeSorter return originalIndices[a] == -1 ? false : originalIndices[a] < originalIndices[b]; } - int indices[MAX_VERTEX_ATTRIBS]; const int (&originalIndices)[MAX_VERTEX_ATTRIBS]; }; -void ProgramBinary::sortAttributesByLayout(rx::TranslatedAttribute attributes[MAX_VERTEX_ATTRIBS], int sortedSemanticIndices[MAX_VERTEX_ATTRIBS]) const +void ProgramBinary::initAttributesByLayout() { - AttributeSorter sorter(mSemanticIndex); + for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++) + { + mAttributesByLayout[i] = i; + } - int oldIndices[MAX_VERTEX_ATTRIBS]; + std::sort(&mAttributesByLayout[0], &mAttributesByLayout[MAX_VERTEX_ATTRIBS], AttributeSorter(mSemanticIndex)); +} + +void ProgramBinary::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++) { - oldIndices[i] = mSemanticIndex[i]; oldTranslatedAttributes[i] = attributes[i]; } for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++) { - int oldIndex = sorter.indices[i]; - sortedSemanticIndices[i] = oldIndices[oldIndex]; + int oldIndex = mAttributesByLayout[i]; + sortedSemanticIndices[i] = mSemanticIndex[oldIndex]; attributes[i] = oldTranslatedAttributes[oldIndex]; } } |