Commit 77abad8d by Jamie Madill Committed by Commit Bot

Remove Context::gatherParams.

This won't be used in the future. It saves a few instructions on each entry point. Also refactors a bit of touched code. Also adds in a missed entry point: "glTexStorage2DMultisampleANGLE". Removes related code and moves remaining helper code in params.h into a new file entry_point_utils.h. In total this patch series reduces overhead by up to 5%. Bug: angleproject:2933 Change-Id: Ifb49564597cde6ba82dfc3e185227619fdc62612 Reviewed-on: https://chromium-review.googlesource.com/c/1299478Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 1f056bec
......@@ -191,8 +191,6 @@ template_entry_point_def = """{return_type}GL_APIENTRY {name}{explicit_context_s
Context *context = {context_getter};
if (context)
{{{assert_explicit_context}{packed_gl_enum_conversions}
context->gatherParams<EntryPoint::{name}>({internal_params});
if (context->skipValidation() || Validate{name}({validate_params}))
{{
{return_if_needed}context->{name_lower_no_suffix}({internal_params});
......@@ -679,6 +677,7 @@ template_sources_includes = """#include "libGLESv2/entry_points_gles_{}_autogen.
#include "libANGLE/Context.h"
#include "libANGLE/validationES{}{}.h"
#include "libGLESv2/entry_points_utils.h"
#include "libGLESv2/global_state.h"
"""
......@@ -904,7 +903,7 @@ entry_points_enum = template_entry_points_enum_header.format(
year = date.today().year,
entry_points_list = ",\n".join([" " + cmd for cmd in sorted_cmd_names]))
entry_points_enum_header_path = path_to("libANGLE", "entry_points_enum_autogen.h")
entry_points_enum_header_path = path_to("libGLESv2", "entry_points_enum_autogen.h")
with open(entry_points_enum_header_path, "w") as out:
out.write(entry_points_enum)
out.close()
......
......@@ -50,7 +50,7 @@
"GL entry point:scripts/entry_point_packed_gl_enums.json":
"cc1985ce86341a3ff0f5a278eae0fa8f",
"GL entry point:scripts/generate_entry_points.py":
"9f2dda92feb508e98c62931a0466f5cd",
"24661bb77e40e05ae8de8459e350d373",
"GL entry point:scripts/gl.xml":
"b470cb06b06cbbe7adb2c8129ec85708",
"GL format map:src/libANGLE/es3_format_type_combinations.json":
......
......@@ -336,7 +336,6 @@ Context::Context(rx::EGLImplFactory *implFactory,
mLimitations),
mSkipValidation(GetNoError(attribs)),
mDisplayTextureShareGroup(shareTextures != nullptr),
mSavedArgsType(nullptr),
mImplementation(implFactory->createContext(mState, config, shareContext, attribs)),
mLabel(nullptr),
mCompiler(),
......@@ -368,10 +367,6 @@ Context::Context(rx::EGLImplFactory *implFactory,
mZeroFilledBuffer(1000u),
mThreadPool(nullptr)
{
// Needed to solve a Clang warning of unused variables.
ANGLE_UNUSED_VARIABLE(mSavedArgsType);
ANGLE_UNUSED_VARIABLE(mParamsBuffer);
for (angle::SubjectIndex uboIndex = kUniformBuffer0SubjectIndex;
uboIndex < kUniformBufferMaxSubjectIndex; ++uboIndex)
{
......
......@@ -1622,9 +1622,6 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
MemoryProgramCache *getMemoryProgramCache() const { return mMemoryProgramCache; }
template <EntryPoint EP, typename... ParamsT>
void gatherParams(ParamsT &&... params);
// Notification for a state change in a Texture.
void onTextureChange(const Texture *texture);
......@@ -1693,9 +1690,6 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
bool isWebGL() const { return mState.isWebGL(); }
bool isWebGL1() const { return mState.isWebGL1(); }
template <typename T>
const T &getParams() const;
bool isValidBufferBinding(BufferBinding binding) const { return mValidBufferBindings[binding]; }
// GLES1 emulation: Renderer level (for validation)
......@@ -1766,11 +1760,6 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
// Stores for each buffer binding type whether is it allowed to be used in this context.
angle::PackedEnumBitSet<BufferBinding> mValidBufferBindings;
// Caches entry point parameters and values re-used between layers.
mutable const ParamTypeInfo *mSavedArgsType;
static constexpr size_t kParamsBufferSize = 128u;
mutable std::array<uint8_t, kParamsBufferSize> mParamsBuffer;
std::unique_ptr<rx::ContextImpl> mImplementation;
EGLLabelKHR mLabel;
......@@ -1868,34 +1857,6 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
std::shared_ptr<angle::WorkerThreadPool> mThreadPool;
};
template <typename T>
const T &Context::getParams() const
{
const T *params = reinterpret_cast<T *>(mParamsBuffer.data());
ASSERT(mSavedArgsType->hasDynamicType(T::TypeInfo));
return *params;
}
template <EntryPoint EP, typename... ArgsT>
ANGLE_INLINE void Context::gatherParams(ArgsT &&... args)
{
static_assert(sizeof(EntryPointParamType<EP>) <= kParamsBufferSize,
"Params struct too large, please increase kParamsBufferSize.");
mSavedArgsType = &EntryPointParamType<EP>::TypeInfo;
// Skip doing any work for ParamsBase/Invalid type.
if (!EntryPointParamType<EP>::TypeInfo.isValid())
{
return;
}
EntryPointParamType<EP> *objBuffer =
reinterpret_cast<EntryPointParamType<EP> *>(mParamsBuffer.data());
EntryPointParamType<EP>::template Factory<EP>(objBuffer, this, std::forward<ArgsT>(args)...);
}
} // namespace gl
#endif // LIBANGLE_CONTEXT_H_
......@@ -14,7 +14,6 @@
#include "libANGLE/State.h"
#include "libANGLE/Version.h"
#include "libANGLE/WorkerThread.h"
#include "libANGLE/params.h"
namespace gl
{
......
......@@ -990,12 +990,10 @@ GLenum Framebuffer::checkStatusImpl(const Context *context)
if (mCachedStatus.value() == GL_FRAMEBUFFER_COMPLETE)
{
Error err = syncState(context);
if (err.isError())
angle::Result err = syncState(context);
if (err != angle::Result::Continue())
{
// TODO(jmadill): Remove when refactor complete. http://anglebug.com/2491
const_cast<Context *>(context)->handleError(err);
return GetDefaultReturnValue<EntryPoint::CheckFramebufferStatus, GLenum>();
return 0;
}
if (!mImpl->checkStatus(context))
{
......
......@@ -458,7 +458,6 @@ void GLES1Renderer::drawTexture(Context *context,
setAttributesEnabled(context, glState, AttributesMask());
context->gatherParams<EntryPoint::DrawArrays>(PrimitiveMode::Triangles, 0, 6);
context->drawArrays(PrimitiveMode::Triangles, 0, 6);
setAttributesEnabled(context, glState, prevAttributesMask);
......
//
// 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;
} // namespace gl
......@@ -1399,8 +1399,8 @@ void GenerateCaps(ID3D11Device *device,
// No specific limits on render target size, maximum 2D texture size is equivalent
caps->maxRenderbufferSize = caps->max2DTextureSize;
// Maximum draw buffers and color attachments are the same, max color attachments could eventually be
// increased to 16
// Maximum draw buffers and color attachments are the same, max color attachments could
// eventually be increased to 16
caps->maxDrawBuffers = static_cast<GLuint>(GetMaximumSimultaneousRenderTargets(featureLevel));
caps->maxColorAttachments =
static_cast<GLuint>(GetMaximumSimultaneousRenderTargets(featureLevel));
......@@ -1502,7 +1502,8 @@ void GenerateCaps(ID3D11Device *device,
// TODO(oetuaho): Get a more accurate limit. For now using the minimum requirement for GLES 3.1.
caps->maxUniformLocations = 1024;
// With DirectX 11.1, constant buffer offset and size must be a multiple of 16 constants of 16 bytes each.
// With DirectX 11.1, constant buffer offset and size must be a multiple of 16 constants of 16
// bytes each.
// https://msdn.microsoft.com/en-us/library/windows/desktop/hh404649%28v=vs.85%29.aspx
// With DirectX 11.0, we emulate UBO offsets using copies of ranges of the UBO however
// we still keep the same alignment as 11.1 for consistency.
......@@ -1623,11 +1624,14 @@ void GenerateCaps(ID3D11Device *device,
extensions->textureBorderClamp = true;
// D3D11 Feature Level 10_0+ uses SV_IsFrontFace in HLSL to emulate gl_FrontFacing.
// D3D11 Feature Level 9_3 doesn't support SV_IsFrontFace, and has no equivalent, so can't support gl_FrontFacing.
limitations->noFrontFacingSupport = (renderer11DeviceCaps.featureLevel <= D3D_FEATURE_LEVEL_9_3);
// D3D11 Feature Level 9_3 doesn't support SV_IsFrontFace, and has no equivalent, so can't
// support gl_FrontFacing.
limitations->noFrontFacingSupport =
(renderer11DeviceCaps.featureLevel <= D3D_FEATURE_LEVEL_9_3);
// D3D11 Feature Level 9_3 doesn't support alpha-to-coverage
limitations->noSampleAlphaToCoverageSupport = (renderer11DeviceCaps.featureLevel <= D3D_FEATURE_LEVEL_9_3);
limitations->noSampleAlphaToCoverageSupport =
(renderer11DeviceCaps.featureLevel <= D3D_FEATURE_LEVEL_9_3);
// D3D11 Feature Levels 9_3 and below do not support non-constant loop indexing and require
// additional
......@@ -1643,9 +1647,10 @@ void GenerateCaps(ID3D11Device *device,
limitations->noSimultaneousConstantColorAndAlphaBlendFunc = true;
#ifdef ANGLE_ENABLE_WINDOWS_STORE
// Setting a non-zero divisor on attribute zero doesn't work on certain Windows Phone 8-era devices.
// We should prevent developers from doing this on ALL Windows Store devices. This will maintain consistency across all Windows devices.
// We allow non-zero divisors on attribute zero if the Client Version >= 3, since devices affected by this issue don't support ES3+.
// Setting a non-zero divisor on attribute zero doesn't work on certain Windows Phone 8-era
// devices. We should prevent developers from doing this on ALL Windows Store devices. This will
// maintain consistency across all Windows devices. We allow non-zero divisors on attribute zero
// if the Client Version >= 3, since devices affected by this issue don't support ES3+.
limitations->attributeZeroRequiresZeroDivisorInEXT = true;
#endif
}
......@@ -2070,7 +2075,11 @@ ANGLED3D11DeviceType GetDeviceType(ID3D11Device *device)
return retDeviceType;
}
void MakeValidSize(bool isImage, DXGI_FORMAT format, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset)
void MakeValidSize(bool isImage,
DXGI_FORMAT format,
GLsizei *requestWidth,
GLsizei *requestHeight,
int *levelOffset)
{
const DXGIFormatSize &dxgiFormatInfo = d3d11::GetDXGIFormatSizeInfo(format);
......@@ -2079,7 +2088,8 @@ void MakeValidSize(bool isImage, DXGI_FORMAT format, GLsizei *requestWidth, GLsi
if (isImage || *requestWidth < static_cast<GLsizei>(dxgiFormatInfo.blockWidth) ||
*requestHeight < static_cast<GLsizei>(dxgiFormatInfo.blockHeight))
{
while (*requestWidth % dxgiFormatInfo.blockWidth != 0 || *requestHeight % dxgiFormatInfo.blockHeight != 0)
while (*requestWidth % dxgiFormatInfo.blockWidth != 0 ||
*requestHeight % dxgiFormatInfo.blockHeight != 0)
{
*requestWidth <<= 1;
*requestHeight <<= 1;
......@@ -2140,7 +2150,7 @@ UINT GetPrimitiveRestartIndex()
return std::numeric_limits<UINT>::max();
}
void SetPositionTexCoordVertex(PositionTexCoordVertex* vertex, float x, float y, float u, float v)
void SetPositionTexCoordVertex(PositionTexCoordVertex *vertex, float x, float y, float u, float v)
{
vertex->x = x;
vertex->y = y;
......@@ -2148,8 +2158,13 @@ void SetPositionTexCoordVertex(PositionTexCoordVertex* vertex, float x, float y,
vertex->v = v;
}
void SetPositionLayerTexCoord3DVertex(PositionLayerTexCoord3DVertex* vertex, float x, float y,
unsigned int layer, float u, float v, float s)
void SetPositionLayerTexCoord3DVertex(PositionLayerTexCoord3DVertex *vertex,
float x,
float y,
unsigned int layer,
float u,
float v,
float s)
{
vertex->x = x;
vertex->y = y;
......
......@@ -50,7 +50,10 @@ D3D11_DEPTH_WRITE_MASK ConvertDepthMask(bool depthWriteEnabled);
UINT8 ConvertStencilMask(GLuint stencilmask);
D3D11_STENCIL_OP ConvertStencilOp(GLenum stencilOp);
D3D11_FILTER ConvertFilter(GLenum minFilter, GLenum magFilter, float maxAnisotropy, GLenum comparisonMode);
D3D11_FILTER ConvertFilter(GLenum minFilter,
GLenum magFilter,
float maxAnisotropy,
GLenum comparisonMode);
D3D11_TEXTURE_ADDRESS_MODE ConvertTextureWrap(GLenum wrap);
UINT ConvertMaxAnisotropy(float maxAnisotropy, D3D_FEATURE_LEVEL featureLevel);
......@@ -96,7 +99,11 @@ enum ANGLED3D11DeviceType
ANGLED3D11DeviceType GetDeviceType(ID3D11Device *device);
void MakeValidSize(bool isImage, DXGI_FORMAT format, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset);
void MakeValidSize(bool isImage,
DXGI_FORMAT format,
GLsizei *requestWidth,
GLsizei *requestHeight,
int *levelOffset);
angle::Result GenerateInitialTextureData(
const gl::Context *context,
......@@ -115,7 +122,7 @@ struct PositionTexCoordVertex
float x, y;
float u, v;
};
void SetPositionTexCoordVertex(PositionTexCoordVertex* vertex, float x, float y, float u, float v);
void SetPositionTexCoordVertex(PositionTexCoordVertex *vertex, float x, float y, float u, float v);
struct PositionLayerTexCoord3DVertex
{
......@@ -123,8 +130,13 @@ struct PositionLayerTexCoord3DVertex
unsigned int l;
float u, v, s;
};
void SetPositionLayerTexCoord3DVertex(PositionLayerTexCoord3DVertex* vertex, float x, float y,
unsigned int layer, float u, float v, float s);
void SetPositionLayerTexCoord3DVertex(PositionLayerTexCoord3DVertex *vertex,
float x,
float y,
unsigned int layer,
float u,
float v,
float s);
struct PositionVertex
{
......@@ -162,10 +174,11 @@ bool operator==(const RasterizerStateKey &a, const RasterizerStateKey &b);
bool operator!=(const RasterizerStateKey &a, const RasterizerStateKey &b);
template <typename outType>
outType* DynamicCastComObject(IUnknown* object)
outType *DynamicCastComObject(IUnknown *object)
{
outType *outObject = nullptr;
HRESULT result = object->QueryInterface(__uuidof(outType), reinterpret_cast<void**>(&outObject));
HRESULT result =
object->QueryInterface(__uuidof(outType), reinterpret_cast<void **>(&outObject));
if (SUCCEEDED(result))
{
return outObject;
......
......@@ -236,10 +236,8 @@ class ContextVk : public ContextImpl, public vk::Context
angle::Result handleDirtyDefaultAttribs(const gl::Context *context,
vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyPipeline(const gl::Context *context,
vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyTextures(const gl::Context *context,
vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyPipeline(const gl::Context *context, vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyTextures(const gl::Context *context, vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyVertexBuffers(const gl::Context *context,
vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyIndexBuffer(const gl::Context *context,
......
......@@ -105,8 +105,7 @@ class ProgramVk : public ProgramImpl
angle::Result updateUniforms(ContextVk *contextVk);
angle::Result updateTexturesDescriptorSet(ContextVk *contextVk);
angle::Result updateDescriptorSets(ContextVk *contextVk,
vk::CommandBuffer *commandBuffer);
angle::Result updateDescriptorSets(ContextVk *contextVk, vk::CommandBuffer *commandBuffer);
// For testing only.
void setDefaultUniformBlocksMinSizeForTesting(size_t minSize);
......
......@@ -222,15 +222,12 @@ libangle_sources = [
"src/libANGLE/angletypes.cpp",
"src/libANGLE/angletypes.h",
"src/libANGLE/angletypes.inl",
"src/libANGLE/entry_points_enum_autogen.h",
"src/libANGLE/es3_copy_conversion_table_autogen.cpp",
"src/libANGLE/features.h",
"src/libANGLE/format_map_autogen.cpp",
"src/libANGLE/formatutils.cpp",
"src/libANGLE/formatutils.h",
"src/libANGLE/histogram_macros.h",
"src/libANGLE/params.cpp",
"src/libANGLE/params.h",
"src/libANGLE/queryconversions.cpp",
"src/libANGLE/queryconversions.h",
"src/libANGLE/queryutils.cpp",
......@@ -867,6 +864,7 @@ libglesv2_sources = [
"src/libGLESv2/entry_points_egl.h",
"src/libGLESv2/entry_points_egl_ext.cpp",
"src/libGLESv2/entry_points_egl_ext.h",
"src/libGLESv2/entry_points_enum_autogen.h",
"src/libGLESv2/entry_points_gles_1_0_autogen.cpp",
"src/libGLESv2/entry_points_gles_1_0_autogen.h",
"src/libGLESv2/entry_points_gles_2_0_autogen.cpp",
......@@ -877,6 +875,7 @@ libglesv2_sources = [
"src/libGLESv2/entry_points_gles_3_1_autogen.h",
"src/libGLESv2/entry_points_gles_ext_autogen.cpp",
"src/libGLESv2/entry_points_gles_ext_autogen.h",
"src/libGLESv2/entry_points_utils.h",
"src/libGLESv2/global_state.cpp",
"src/libGLESv2/global_state.h",
"src/libGLESv2/libGLESv2_autogen.cpp",
......
This source diff could not be displayed because it is too large. You can view the blob instead.
//
// Copyright 2017 The ANGLE Project Authors. All rights reserved.
// Copyright 2018 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.
// entry_point_utils:
// These helpers are used in GLES entry point routines.
#ifndef LIBANGLE_PARAMS_H_
#define LIBANGLE_PARAMS_H_
#ifndef LIBGLESV2_ENTRY_POINT_UTILS_H_
#define LIBGLESV2_ENTRY_POINT_UTILS_H_
#include "angle_gl.h"
#include "common/Optional.h"
#include "common/PackedEnums.h"
#include "common/angleutils.h"
#include "common/mathutil.h"
#include "libANGLE/Error.h"
#include "libANGLE/entry_points_enum_autogen.h"
#include "libGLESv2/entry_points_enum_autogen.h"
namespace gl
{
class Context;
template <EntryPoint EP>
struct EntryPointParam;
template <EntryPoint EP>
using EntryPointParamType = typename EntryPointParam<EP>::Type;
class ParamTypeInfo
{
public:
constexpr ParamTypeInfo(const char *selfClass, const ParamTypeInfo *parentType)
: mSelfClass(selfClass), mParentTypeInfo(parentType)
{
}
constexpr bool hasDynamicType(const ParamTypeInfo &typeInfo) const
{
return mSelfClass == typeInfo.mSelfClass ||
(mParentTypeInfo && mParentTypeInfo->hasDynamicType(typeInfo));
}
constexpr bool isValid() const { return mSelfClass != nullptr; }
private:
const char *mSelfClass;
const ParamTypeInfo *mParentTypeInfo;
};
#define ANGLE_PARAM_TYPE_INFO(NAME, BASENAME) \
static constexpr ParamTypeInfo TypeInfo = {#NAME, &BASENAME::TypeInfo}
class ParamsBase : angle::NonCopyable
{
public:
ParamsBase(Context *context, ...){};
template <EntryPoint EP, typename... ArgsT>
static void Factory(EntryPointParamType<EP> *objBuffer, ArgsT... args);
static constexpr ParamTypeInfo TypeInfo = {nullptr, nullptr};
};
// static
template <EntryPoint EP, typename... ArgsT>
ANGLE_INLINE void ParamsBase::Factory(EntryPointParamType<EP> *objBuffer, ArgsT... args)
{
new (objBuffer) EntryPointParamType<EP>(args...);
}
// Entry point funcs essentially re-map different entry point parameter arrays into
// the format the parameter type class expects.
#define ANGLE_ENTRY_POINT_FUNC(NAME, CLASS, ...) \
\
template<> struct EntryPointParam<EntryPoint::NAME> \
{ \
using Type = CLASS; \
}; \
\
template<> inline void CLASS::Factory<EntryPoint::NAME>(__VA_ARGS__)
#undef ANGLE_ENTRY_POINT_FUNC
template <EntryPoint EP>
struct EntryPointParam
{
using Type = ParamsBase;
};
// A template struct for determining the default value to return for each entry point.
template <EntryPoint EP, typename ReturnType>
struct DefaultReturnValue;
......@@ -152,7 +81,6 @@ constexpr ANGLE_INLINE ReturnType GetDefaultReturnValue()
{
return DefaultReturnValue<EP, ReturnType>::kValue;
}
} // namespace gl
#endif // LIBANGLE_PARAMS_H_
#endif // LIBGLESV2_ENTRY_POINT_UTILS_H_
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