BlamKiwi / angleproject

Automatically exported from code.google.com/p/angleproject
Other
0 stars 0 forks source link

Streamline and optimize index validation #956

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Index validation and caching in ANGLE is implemented in a very complex way, and 
there are a lot of slow operations involved, like std::map lookups and frequent 
integer division. Both the readability and the performance of the code could be 
improved.

Some suggestions:

1. Replace usage of division with bitshifts where possible
2. Replace usage of % with & where possible
3. Replace usage of std::map lookups from static structures with switch 
statements or simpler lookups where possible.
3. Remove streamOffset from the index range cache, and always compute it 
dynamically instead. This will simplify maintaining the cache - adding items to 
the cache doesn't need to be deferred until the streamOffset is known. This 
will not cost too much performance, since with above optimizations computing 
streamOffset should be fast.

Similar optimizations could also be performed in other areas of the code.

Original issue reported on code.google.com by oetu...@nvidia.com on 24 Mar 2015 at 3:38

GoogleCodeExporter commented 9 years ago
Project: angle/angle
Branch : master
Author : Olli Etuaho <oetuaho@nvidia.com>
Commit : 31f8f4f5ee027dc5ce2ddba011308a397730aeaf

Code-Review  0 : Nicolas Capens, Olli Etuaho
Code-Review  +1: Geoff Lang
Code-Review  +2: Jamie Madill
Verified     0 : Geoff Lang, Jamie Madill, Nicolas Capens
Verified     +1: Olli Etuaho
Commit Queue   : Chumped
Change-Id      : I628db95febab309e241be216e2998305525da76e
Reviewed-at    : https://chromium-review.googlesource.com/262421

Use switch/case in GetTypeInfo instead of a map lookup

This should be faster, and also matches the C++ style rules better: static
variables should not have complex class types.

BUG=angleproject:956
TEST=angle_end2end_tests, WebGL conformance tests

src/libANGLE/formatutils.cpp

Original comment by bugdroid1@chromium.org on 27 Mar 2015 at 7:50

GoogleCodeExporter commented 9 years ago
Project: angle/angle
Branch : master
Author : Olli Etuaho <oetuaho@nvidia.com>
Commit : 11ffe1b8796b95bd27b579c2477c73dd98e70d6b

Code-Review  0 : Geoff Lang, Jamie Madill, Olli Etuaho, Shannon Woods
Code-Review  +2: Nicolas Capens
Verified     0 : Geoff Lang, Nicolas Capens, Shannon Woods
Verified     +1: Jamie Madill, Olli Etuaho
Commit Queue   : Chumped
Change-Id      : I57ab540d447c03dae5a96bafb4975fc37e310261
Reviewed-at    : https://chromium-review.googlesource.com/262181

Micro-optimize math in IndexDataManager

Use bitwise operations instead of division, which is expensive on multiple CPU
architectures.

BUG=angleproject:956
TEST=angle_end2end_tests

src/libANGLE/formatutils.cpp
src/libANGLE/formatutils.h
src/libANGLE/renderer/d3d/IndexDataManager.cpp

Original comment by bugdroid1@chromium.org on 30 Mar 2015 at 9:24

GoogleCodeExporter commented 9 years ago
Project: angle/angle
Branch : master
Author : Olli Etuaho <oetuaho@nvidia.com>
Commit : 3d5f2687791e08e46c857c1aeeafb915269cb1ef

Code-Review  0 : Jamie Madill, Olli Etuaho
Code-Review  +1: Nicolas Capens
Code-Review  +2: Geoff Lang
Verified     0 : Geoff Lang, Nicolas Capens
Verified     +1: Jamie Madill, Olli Etuaho
Commit Queue   : Chumped
Change-Id      : If4b6c8bcbebf24fbf84723fe081fd058916cc504
Reviewed-at    : https://chromium-review.googlesource.com/262423

Remove unused streamOffset from IndexRangeCache

This value is now redundant - it is always the same as regular offset.

TEST=angle_end2end_tests
BUG=angleproject:956

src/libANGLE/renderer/IndexRangeCache.cpp
src/libANGLE/renderer/IndexRangeCache.h
src/libANGLE/renderer/gl/VertexArrayGL.cpp
src/libANGLE/validationES.cpp

Original comment by bugdroid1@chromium.org on 31 Mar 2015 at 8:59

GoogleCodeExporter commented 9 years ago
Project: angle/angle
Branch : master
Author : Olli Etuaho <oetuaho@nvidia.com>
Commit : ff5e7374aecf72c2e98f66f86ecc0dcf95608b62

Code-Review  0 : Jamie Madill, Olli Etuaho
Code-Review  +1: Nicolas Capens
Code-Review  +2: Geoff Lang
Verified     0 : Geoff Lang, Nicolas Capens
Verified     +1: Jamie Madill, Olli Etuaho
Commit Queue   : Chumped
Change-Id      : Icb9cc4e4ffd685a78b7f8a45958992a471ebb0f5
Reviewed-at    : https://chromium-review.googlesource.com/262422

Recompute stream offset instead of fetching a cached value

Recomputing the stream offset is relatively cheap now after recent changes.
Remove caching it to make the code less complex.

TEST=angle_end2end_tests
BUG=angleproject:956

src/libANGLE/renderer/d3d/IndexBuffer.cpp
src/libANGLE/renderer/d3d/IndexBuffer.h
src/libANGLE/renderer/d3d/IndexDataManager.cpp
src/libANGLE/validationES.cpp

Original comment by bugdroid1@chromium.org on 31 Mar 2015 at 8:59

GoogleCodeExporter commented 9 years ago

Original comment by oetu...@nvidia.com on 31 Mar 2015 at 9:14

GoogleCodeExporter commented 9 years ago
Project: angle/angle
Branch : master
Author : Jamie Madill <jmadill@chromium.org>
Commit : 3ad467df2817df60ae90a84aae68dc37b46b2b34

Code-Review  0 : Jamie Madill, Olli Etuaho
Code-Review  +1: Geoff Lang
Code-Review  +2: Brandon Jones
Verified     0 : Brandon Jones, Geoff Lang, Olli Etuaho
Verified     +1: Jamie Madill
Commit Queue   : Chumped
Change-Id      : Ibc80997eec184d0d5aa9c6c076c9d4507fbf8caa
Reviewed-at    : https://chromium-review.googlesource.com/262776

Remove shared_utils.h, use angle_common instead.

This saves us from needing to replicate the same code in two places.

BUG=angleproject:956

samples/samples.gyp
src/tests/end2end_tests/ANGLETest.h
src/tests/perf_tests/ANGLEPerfTest.h
util/EGLWindow.h
util/shared_utils.h
util/util.gyp

Original comment by bugdroid1@chromium.org on 31 Mar 2015 at 3:17

GoogleCodeExporter commented 9 years ago
Project: angle/angle
Branch : master
Author : Jamie Madill <jmadill@chromium.org>
Commit : 9bd4dbef19f44e9d5a9535140299921cdd86ceb8

Code-Review  0 : Brandon Jones, Jamie Madill
Code-Review  +1: Olli Etuaho
Code-Review  +2: Geoff Lang
Verified     0 : Brandon Jones, Geoff Lang, Olli Etuaho
Verified     +1: Jamie Madill
Commit Queue   : Chumped
Change-Id      : Iade393facc30c8d7288b1b94a159ce3afe993021
Reviewed-at    : https://chromium-review.googlesource.com/262775

Split ANGLEPerfTest into a Render and basic test.

The basic test we can use for perf testing internal classes with
mocks. The render tests are more specific to doing draw calls.

BUG=angleproject:956

src/tests/perf_tests/ANGLEPerfTest.cpp
src/tests/perf_tests/ANGLEPerfTest.h
src/tests/perf_tests/BufferSubData.cpp
src/tests/perf_tests/PointSprites.cpp
src/tests/perf_tests/TexSubImage.cpp

Original comment by bugdroid1@chromium.org on 31 Mar 2015 at 3:17

GoogleCodeExporter commented 9 years ago
Project: angle/angle
Branch : master
Author : Jamie Madill <jmadill@chromium.org>
Commit : fd1bf4e6fc3218aeeb23b5675eba7b3dc623b0c8

Code-Review  0 : Brandon Jones, Jamie Madill
Code-Review  +1: Olli Etuaho
Code-Review  +2: Geoff Lang
Verified     0 : Brandon Jones, Geoff Lang, Olli Etuaho
Verified     +1: Jamie Madill
Commit Queue   : Chumped
Change-Id      : Id8b1220a763873ee871ce92365bbee03633789c7
Reviewed-at    : https://chromium-review.googlesource.com/262774

Add an BufferFactoryD3D class to help mocking.

This D3D-only class has one method, used to generate the D3D
IndexBuffer/VertexBuffer. This can help us mock up
IndexDataManager.

At a later point we can refactor the VertexFormat queries
from Renderer into a Caps struct that mirrors our Texure
Caps.

BUG=angleproject:956

src/libANGLE/renderer/d3d/BufferD3D.cpp
src/libANGLE/renderer/d3d/BufferD3D.h
src/libANGLE/renderer/d3d/IndexBuffer.cpp
src/libANGLE/renderer/d3d/IndexBuffer.h
src/libANGLE/renderer/d3d/IndexDataManager.cpp
src/libANGLE/renderer/d3d/IndexDataManager.h
src/libANGLE/renderer/d3d/RendererD3D.h
src/libANGLE/renderer/d3d/VertexBuffer.cpp
src/libANGLE/renderer/d3d/VertexBuffer.h
src/libANGLE/renderer/d3d/VertexDataManager.cpp
src/libANGLE/renderer/d3d/VertexDataManager.h
src/libANGLE/renderer/d3d/d3d11/Buffer11.cpp
src/libANGLE/renderer/d3d/d3d11/Buffer11.h
src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp
src/libANGLE/renderer/d3d/d3d9/Buffer9.cpp
src/libANGLE/renderer/d3d/d3d9/Buffer9.h
src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp

Original comment by bugdroid1@chromium.org on 31 Mar 2015 at 3:17

GoogleCodeExporter commented 9 years ago
Project: angle/angle
Branch : master
Author : Jamie Madill <jmadill@chromium.org>
Commit : a79fac985fe0f73a443635f44e1a0bd12c35602c

Code-Review  0 : Jamie Madill
Code-Review  +1: Olli Etuaho
Code-Review  +2: Brandon Jones
Verified     0 : Brandon Jones, Olli Etuaho
Verified     +1: Jamie Madill
Commit Queue   : Chumped
Change-Id      : I853f3cf3171b85143e490ef9678aae7d38de0b1f
Reviewed-at    : https://chromium-review.googlesource.com/262778

Fix uninitialized member in BufferD3D.

BUG=angleproject:956

src/libANGLE/renderer/d3d/BufferD3D.cpp

Original comment by bugdroid1@chromium.org on 1 Apr 2015 at 1:39

GoogleCodeExporter commented 9 years ago
Project: angle/angle
Branch : master
Author : Jamie Madill <jmadill@chromium.org>
Commit : 514df7f7044ef78542ef7fb435b49471ac1ca918

Code-Review  0 : Jamie Madill, Olli Etuaho
Code-Review  +2: Brandon Jones
Verified     0 : Brandon Jones, Olli Etuaho
Verified     +1: Jamie Madill
Commit Queue   : Chumped
Change-Id      : I5be28590f494719b8cc995739dde26726283fced
Reviewed-at    : https://chromium-review.googlesource.com/262777

Remove uses of std::unique_ptr in perftests.

This is disallowed in Chromium because it isn't currently portable.
We can put it back later if the rules change.

BUG=angleproject:956

src/tests/perf_tests/ANGLEPerfTest.cpp
src/tests/perf_tests/ANGLEPerfTest.h

Original comment by bugdroid1@chromium.org on 1 Apr 2015 at 1:39

GoogleCodeExporter commented 9 years ago
Project: angle/angle
Branch : master
Author : Jamie Madill <jmadill@chromium.org>
Commit : f0d10f89674f004ea3a7eab1ecb6f342f3fb369d

Code-Review  0 : Jamie Madill, Olli Etuaho
Code-Review  +1: Geoff Lang
Code-Review  +2: Brandon Jones
Verified     0 : Brandon Jones, Geoff Lang, Olli Etuaho
Verified     +1: Jamie Madill
Commit Queue   : Chumped
Change-Id      : If0dc72aa3f63fbc7b8fa34907418821c64c39e2f
Reviewed-at    : https://chromium-review.googlesource.com/263257

Replace non-copyable macro with a helper class.

This class provides a simpler scheme for blocking default copy
and assignment operators. It also reduces the amount of code
needed since it's inherited to child classes. This also fixes
the conflict between our macro and the same-named macro in
Chromium code.

BUG=angleproject:956

src/common/MemoryBuffer.h
src/common/angleutils.h
src/common/debug.h
src/compiler/translator/Diagnostics.h
src/compiler/translator/DirectiveHandler.h
src/compiler/translator/EmulatePrecision.h
src/compiler/translator/IntermNode.h
src/compiler/translator/StructureHLSL.h
src/compiler/translator/SymbolTable.h
src/compiler/translator/Types.h
src/compiler/translator/UnfoldShortCircuitAST.h
src/compiler/translator/UniformHLSL.h
src/compiler/translator/VariableInfo.cpp
src/compiler/translator/VariableInfo.h
src/compiler/translator/depgraph/DependencyGraph.h
src/compiler/translator/depgraph/DependencyGraphBuilder.h
src/compiler/translator/depgraph/DependencyGraphOutput.h
src/compiler/translator/timing/RestrictFragmentShaderTiming.h
src/compiler/translator/util.h
src/libANGLE/BinaryStream.h
src/libANGLE/Buffer.h
src/libANGLE/Context.h
src/libANGLE/Display.h
src/libANGLE/Fence.h
src/libANGLE/Framebuffer.h
src/libANGLE/FramebufferAttachment.h
src/libANGLE/HandleAllocator.h
src/libANGLE/Program.h
src/libANGLE/Query.h
src/libANGLE/RefCountObject.h
src/libANGLE/Renderbuffer.h
src/libANGLE/ResourceManager.h
src/libANGLE/Shader.h
src/libANGLE/State.h
src/libANGLE/Surface.h
src/libANGLE/Texture.h
src/libANGLE/TransformFeedback.h
src/libANGLE/Uniform.h
src/libANGLE/renderer/BufferImpl.h
src/libANGLE/renderer/CompilerImpl.h
src/libANGLE/renderer/DefaultAttachmentImpl.h
src/libANGLE/renderer/DisplayImpl.h
src/libANGLE/renderer/FenceNVImpl.h
src/libANGLE/renderer/FenceSyncImpl.h
src/libANGLE/renderer/FramebufferImpl.h
src/libANGLE/renderer/ImplFactory.h
src/libANGLE/renderer/ProgramImpl.h
src/libANGLE/renderer/QueryImpl.h
src/libANGLE/renderer/RenderbufferImpl.h
src/libANGLE/renderer/Renderer.h
... and 83 more file(s) modified...

Original comment by bugdroid1@chromium.org on 1 Apr 2015 at 1:39

GoogleCodeExporter commented 9 years ago
Project: angle/angle
Branch : master
Author : Jamie Madill <jmadill@chromium.org>
Commit : 2d1eea098ff00084be4287fdceed60cc9dfb2b42

Code-Review  0 : Jamie Madill, Olli Etuaho
Code-Review  +1: Geoff Lang
Code-Review  +2: Brandon Jones
Verified     0 : Brandon Jones, Geoff Lang, Olli Etuaho
Verified     +1: Jamie Madill
Commit Queue   : Chumped
Change-Id      : I68dffee715df03bd25685e3ed5c0506ffc41c3b9
Reviewed-at    : https://chromium-review.googlesource.com/263258

Remove shared_utils.h, use angle_common instead.

*re-land with fix for Chromium compile*

This saves us from needing to replicate the same code in two places.

BUG=angleproject:956

samples/samples.gyp
src/tests/end2end_tests/ANGLETest.h
src/tests/perf_tests/ANGLEPerfTest.h
src/tests/perf_tests/BufferSubData.cpp
src/tests/perf_tests/PointSprites.cpp
src/tests/perf_tests/TexSubImage.cpp
util/EGLWindow.h
util/shared_utils.h
util/util.gyp

Original comment by bugdroid1@chromium.org on 1 Apr 2015 at 1:39

GoogleCodeExporter commented 9 years ago
Project: angle/angle
Branch : master
Author : Jamie Madill <jmadill@chromium.org>
Commit : ed58f066b66804ac51ef4c0d52fd5a3ee091d35d

Code-Review  0 : Jamie Madill
Code-Review  +1: Brandon Jones
Code-Review  +2: Geoff Lang
Verified     0 : Brandon Jones, Geoff Lang
Verified     +1: Jamie Madill
Commit Queue   : Chumped
Change-Id      : I439c4d55612059d6a16ae6351c54c3817be017cf
Reviewed-at    : https://chromium-review.googlesource.com/263480

Fix the renderer generation script.

We no longer use the DISALLOW_COPY_AND_ASSIGN macro.

BUG=angleproject:956

src/libANGLE/renderer/generate_new_renderer.py

Original comment by bugdroid1@chromium.org on 1 Apr 2015 at 7:10