Commit 978911ca by Al Patrick Committed by Shannon Woods

InputLayoutCache only hashes input layout keys up to last used element.

R=geofflang@chromium.org Review URL: https://codereview.appspot.com/12676043 Conflicts: src/common/version.h src/libGLESv2/libGLESv2.vcxproj src/libGLESv2/renderer/InputLayoutCache.cpp
parent 3841b8e0
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat> <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalDependencies>d3d9.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>d3d9.lib;%(AdditionalDependencies)</AdditionalDependencies>
...@@ -124,7 +124,7 @@ copy "$(OutDir)libEGL.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" ...@@ -124,7 +124,7 @@ copy "$(OutDir)libEGL.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalDependencies>d3d9.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>d3d9.lib;%(AdditionalDependencies)</AdditionalDependencies>
...@@ -161,7 +161,7 @@ copy "$(OutDir)libEGL.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" ...@@ -161,7 +161,7 @@ copy "$(OutDir)libEGL.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<PrecompiledHeader> <PrecompiledHeader>
</PrecompiledHeader> </PrecompiledHeader>
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
</ClCompile> </ClCompile>
...@@ -197,7 +197,7 @@ copy "$(OutDir)libEGL.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" ...@@ -197,7 +197,7 @@ copy "$(OutDir)libEGL.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<PrecompiledHeader> <PrecompiledHeader>
</PrecompiledHeader> </PrecompiledHeader>
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
</ClCompile> </ClCompile>
......
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat> <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile> <PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile>
<AdditionalOptions>$(ExternalCompilerOptions) %(AdditionalOptions)</AdditionalOptions> <AdditionalOptions>$(ExternalCompilerOptions) %(AdditionalOptions)</AdditionalOptions>
</ClCompile> </ClCompile>
...@@ -126,7 +126,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" ...@@ -126,7 +126,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;4718;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;4718;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile> <PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile>
<AdditionalOptions>$(ExternalCompilerOptions) %(AdditionalOptions)</AdditionalOptions> <AdditionalOptions>$(ExternalCompilerOptions) %(AdditionalOptions)</AdditionalOptions>
</ClCompile> </ClCompile>
...@@ -164,7 +164,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" ...@@ -164,7 +164,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>Use</PrecompiledHeader> <PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;4718;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;4718;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
<PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile> <PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile>
...@@ -200,7 +200,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" ...@@ -200,7 +200,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>Use</PrecompiledHeader> <PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;4718;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;4718;4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
<PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile> <PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile>
...@@ -492,4 +492,4 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" ...@@ -492,4 +492,4 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>
</Project> </Project>
\ No newline at end of file
...@@ -106,15 +106,15 @@ GLenum InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::M ...@@ -106,15 +106,15 @@ GLenum InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::M
// Record the type of the associated vertex shader vector in our key // Record the type of the associated vertex shader vector in our key
// This will prevent mismatched vertex shaders from using the same input layout // This will prevent mismatched vertex shaders from using the same input layout
GLint attributeSize; GLint attributeSize;
programBinary->getActiveAttribute(ilKey.elementCount, 0, NULL, &attributeSize, &ilKey.glslElementType[ilKey.elementCount], NULL); programBinary->getActiveAttribute(ilKey.elementCount, 0, NULL, &attributeSize, &ilKey.elements[ilKey.elementCount].glslElementType, NULL);
ilKey.elements[ilKey.elementCount].SemanticName = semanticName; ilKey.elements[ilKey.elementCount].desc.SemanticName = semanticName;
ilKey.elements[ilKey.elementCount].SemanticIndex = sortedSemanticIndices[i]; ilKey.elements[ilKey.elementCount].desc.SemanticIndex = sortedSemanticIndices[i];
ilKey.elements[ilKey.elementCount].Format = dxgiFormat; ilKey.elements[ilKey.elementCount].desc.Format = dxgiFormat;
ilKey.elements[ilKey.elementCount].InputSlot = i; ilKey.elements[ilKey.elementCount].desc.InputSlot = i;
ilKey.elements[ilKey.elementCount].AlignedByteOffset = 0; ilKey.elements[ilKey.elementCount].desc.AlignedByteOffset = 0;
ilKey.elements[ilKey.elementCount].InputSlotClass = inputClass; ilKey.elements[ilKey.elementCount].desc.InputSlotClass = inputClass;
ilKey.elements[ilKey.elementCount].InstanceDataStepRate = attributes[i].divisor; ilKey.elements[ilKey.elementCount].desc.InstanceDataStepRate = attributes[i].divisor;
ilKey.elementCount++; ilKey.elementCount++;
vertexBuffers[i] = bufferStorage ? bufferStorage->getBuffer(GL_ARRAY_BUFFER) : vertexBuffer->getBuffer(); vertexBuffers[i] = bufferStorage ? bufferStorage->getBuffer(GL_ARRAY_BUFFER) : vertexBuffer->getBuffer();
...@@ -136,7 +136,13 @@ GLenum InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::M ...@@ -136,7 +136,13 @@ GLenum InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::M
{ {
ShaderExecutable11 *shader = ShaderExecutable11::makeShaderExecutable11(programBinary->getVertexExecutable()); ShaderExecutable11 *shader = ShaderExecutable11::makeShaderExecutable11(programBinary->getVertexExecutable());
HRESULT result = mDevice->CreateInputLayout(ilKey.elements, ilKey.elementCount, shader->getFunction(), shader->getLength(), &inputLayout); D3D11_INPUT_ELEMENT_DESC descs[gl::MAX_VERTEX_ATTRIBS];
for (unsigned int j = 0; j < ilKey.elementCount; ++j)
{
descs[j] = ilKey.elements[j].desc;
}
HRESULT result = mDevice->CreateInputLayout(descs, ilKey.elementCount, shader->getFunction(), shader->getLength(), &inputLayout);
if (FAILED(result)) if (FAILED(result))
{ {
ERR("Failed to crate input layout, result: 0x%08x", result); ERR("Failed to crate input layout, result: 0x%08x", result);
...@@ -193,13 +199,18 @@ std::size_t InputLayoutCache::hashInputLayout(const InputLayoutKey &inputLayout) ...@@ -193,13 +199,18 @@ std::size_t InputLayoutCache::hashInputLayout(const InputLayoutKey &inputLayout)
static const unsigned int seed = 0xDEADBEEF; static const unsigned int seed = 0xDEADBEEF;
std::size_t hash = 0; std::size_t hash = 0;
MurmurHash3_x86_32(&inputLayout, sizeof(InputLayoutKey), seed, &hash); MurmurHash3_x86_32(inputLayout.begin(), inputLayout.end() - inputLayout.begin(), seed, &hash);
return hash; return hash;
} }
bool InputLayoutCache::compareInputLayouts(const InputLayoutKey &a, const InputLayoutKey &b) bool InputLayoutCache::compareInputLayouts(const InputLayoutKey &a, const InputLayoutKey &b)
{ {
return memcmp(&a, &b, sizeof(InputLayoutKey)) == 0; if (a.elementCount != b.elementCount)
{
return false;
}
return std::equal(a.begin(), a.end(), b.begin());
} }
} }
...@@ -38,11 +38,26 @@ class InputLayoutCache ...@@ -38,11 +38,26 @@ class InputLayoutCache
private: private:
DISALLOW_COPY_AND_ASSIGN(InputLayoutCache); DISALLOW_COPY_AND_ASSIGN(InputLayoutCache);
struct InputLayoutElement
{
D3D11_INPUT_ELEMENT_DESC desc;
GLenum glslElementType;
};
struct InputLayoutKey struct InputLayoutKey
{ {
unsigned int elementCount; unsigned int elementCount;
D3D11_INPUT_ELEMENT_DESC elements[gl::MAX_VERTEX_ATTRIBS]; InputLayoutElement elements[gl::MAX_VERTEX_ATTRIBS];
GLenum glslElementType[gl::MAX_VERTEX_ATTRIBS];
const char *begin() const
{
return reinterpret_cast<const char*>(&elementCount);
}
const char *end() const
{
return reinterpret_cast<const char*>(&elements[elementCount]);
}
}; };
struct InputLayoutCounterPair struct InputLayoutCounterPair
......
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