Hash :
c1fd7376
Author :
Date :
2018-10-26T22:48:39
Move index range calculations into VertexArray. This is in preparation for removing the entire DrawCallParams struct. This struct was big enough to cause a performance hit on draw call perf tests just by virtue of initializing the fields. Also dereferencing the struct members is slower than reading function parameters since it adds an indirection. Also includes some error refactoring to enable moving code to a shared location. In total this patch series reduces overhead by up to 5%. Bug: angleproject:2933 Change-Id: Ib663f2538c14ac30d4c31fd10d6350be469626e2 Reviewed-on: https://chromium-review.googlesource.com/c/1298380 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
//
// Copyright 2017 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// params:
// Parameter wrapper structs for OpenGL ES. These helpers cache re-used values
// in entry point routines.
#include "libANGLE/params.h"
#include "common/utilities.h"
#include "libANGLE/Context.h"
#include "libANGLE/VertexArray.h"
namespace gl
{
// static
constexpr ParamTypeInfo ParamsBase::TypeInfo;
constexpr ParamTypeInfo DrawCallParams::TypeInfo;
// Called by DrawArraysIndirect.
DrawCallParams::DrawCallParams(PrimitiveMode mode, const void *indirect)
: mMode(mode),
mFirstVertex(0),
mVertexCount(0),
mIndexCount(0),
mBaseVertex(0),
mType(GL_NONE),
mIndices(nullptr),
mInstances(0),
mIndirect(indirect)
{
}
// Called by DrawElementsIndirect.
DrawCallParams::DrawCallParams(PrimitiveMode mode, GLenum type, const void *indirect)
: mMode(mode),
mFirstVertex(0),
mVertexCount(0),
mIndexCount(0),
mBaseVertex(0),
mType(type),
mIndices(nullptr),
mInstances(0),
mIndirect(indirect)
{
}
GLsizei DrawCallParams::indexCount() const
{
ASSERT(isDrawElements());
return mIndexCount;
}
GLint DrawCallParams::baseVertex() const
{
return mBaseVertex;
}
GLenum DrawCallParams::type() const
{
ASSERT(isDrawElements());
return mType;
}
const void *DrawCallParams::indices() const
{
return mIndices;
}
GLsizei DrawCallParams::instances() const
{
return mInstances;
}
const void *DrawCallParams::indirect() const
{
return mIndirect;
}
bool DrawCallParams::isDrawIndirect() const
{
// This is a bit of a hack - it's quite possible for a direct call to have a zero count, but we
// assume these calls are filtered out before they make it to this code.
return (mIndexCount == 0 && mVertexCount == 0);
}
} // namespace gl