Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polished BatchRenderer #5852

Merged
merged 1 commit into from Jun 30, 2019
Merged

Polished BatchRenderer #5852

merged 1 commit into from Jun 30, 2019

Conversation

ShukantPal
Copy link
Member

@ShukantPal ShukantPal commented Jun 30, 2019

(PLEASE JUST READ THE NEW BatchRenderer CLASS, since the changes reordered a lot
of things and you might not be able to locate the additions/deletions pairs.

I have edited the BatchRenderer class. The following major changes were
made:

  1. Changed old vertexCount to _flushId. This is because the name
    itself was misleading. It signified the number of flushes in the
    current frame.

  2. Renamed vaos and vaosMax to _packedGeometries and
    _packedGeometryPoolSize. They were not VAOs in the sense
    that they binded all the buffers automatically to the WebGL
    context. Instead, they were just reusable BatchGeometry objects.

  3. Renamed groups to _drawCalls. That is what they are, and it
    makes more sense, especially after documenting it.

  4. Renamed all private variables by adding a _ prefix.

  5. Added documentation to all private/public properties and methods.

  6. Fixed destroy(). It was nullifying non-existent variables. They
    were probably from when this class was being built/tested. I've fixed
    it so that it nullifies the correct resources.

  7. contextChange signal is now hooked in BatchRenderer rather than
    the BatchPluginFactory#create. This makes sense since the former
    is the one implementing the contextChange signal.

  8. SIDE EFFECT: Graphics used the shader property of BatchRenderer,
    and since that was deemed a private properties, it broke. It fixed that
    by making Graphics use _shader.

  9. I reordered the way in which properties are initialized in the
    constructor. The most important/public ones are on the top. They are
    ordered in a way that makes a new-comer sense.

  10. Reordered methods. The first methods are related to rendering and
    are lifecycle-type methods: contextChange, render, flush, and destroy. Then
    the start and stop methods. Then the private methods getAttributeBuffer,
    getIndexBuffer, and packInterleavedGeometry.

  11. Renamed packGeometry to packInterleavedGeometry; this is because
    the method doesn't take any geometry to put into. Rather it takes
    the interleaved buffers.

  12. Documented literally anything else.

Description of change
Pre-Merge Checklist
  • Tests and/or benchmarks are included
  • Documentation is changed or added
  • Lint process passed (npm run lint)
  • Tests passed (npm run test)

I have edited the BatchRenderer class. The following major changes were
made:

1. Changed old `vertexCount` to `_flushId`. This is because the name
itself was misleading. It signified the number of flushes in the
current frame.

2. Renamed `vaos` and `vaosMax` to `_packedGeometries` and
`_packedGeometryPoolSize`. They _were not_ VAOs in the sense
that they binded all the buffers automatically to the WebGL
context. Instead, they were just reusable `BatchGeometry` objects.

3. Renamed `groups` to `_drawCalls`. That is what they are, and it
makes more sense, especially after documenting it.

4. Renamed all private variables by adding a _ prefix.

5. Added documentation to all private/public properties and methods.

6. Fixed destroy(). It was nullifying non-existent variables. They
were probably from when this class was being built/tested. I've fixed
it so that it nullifies the correct resources.

7. contextChange signal is now hooked in `BatchRenderer` rather than
the `BatchPluginFactory#create`. This makes sense since the former
is the one implementing the `contextChange` signal.

8. SIDE EFFECT: Graphics used the `shader` property of `BatchRenderer`,
and since that was deemed a private properties, it broke. It fixed that
by making Graphics use `_shader`.

9. I reordered the way in which properties are initialized in the
constructor. The most important/public ones are on the top. They are
ordered in a way that makes a new-comer sense.

10. Reordered methods. The first methods are related to rendering and
are lifecycle-type methods: contextChange, render, flush, and destroy. Then
the start and stop methods. Then the private methods getAttributeBuffer,
getIndexBuffer, and packInterleavedGeometry.

11. Renamed packGeometry to packInterleavedGeometry; this is because
the method doesn't take any geometry to put into. Rather it takes
the interleaved buffers.

12. Documented literally anything else.
@codecov-io
Copy link

Codecov Report

Merging #5852 into dev will decrease coverage by <.01%.
The diff coverage is 39.09%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #5852      +/-   ##
==========================================
- Coverage   70.53%   70.52%   -0.01%     
==========================================
  Files         205      205              
  Lines       10406    10403       -3     
==========================================
- Hits         7340     7337       -3     
  Misses       3066     3066
Impacted Files Coverage Δ
packages/core/src/batch/BatchPluginFactory.js 84.61% <ø> (-1.1%) ⬇️
packages/graphics/src/Graphics.js 68.26% <100%> (ø) ⬆️
packages/core/src/batch/BatchRenderer.js 30.72% <38.53%> (-0.22%) ⬇️
packages/ticker/src/Ticker.js 87.9% <0%> (-0.81%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c165232...261dc92. Read the comment docs.

Copy link
Member

@englercj englercj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a great clean up pass to me! Thanks so much for this @SukantPal

@bigtimebuddy bigtimebuddy added this to the v5.1.0 milestone Jun 30, 2019
@bigtimebuddy bigtimebuddy merged commit e5f6b36 into pixijs:dev Jun 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants