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 ...@@ -191,8 +191,6 @@ template_entry_point_def = """{return_type}GL_APIENTRY {name}{explicit_context_s
Context *context = {context_getter}; Context *context = {context_getter};
if (context) if (context)
{{{assert_explicit_context}{packed_gl_enum_conversions} {{{assert_explicit_context}{packed_gl_enum_conversions}
context->gatherParams<EntryPoint::{name}>({internal_params});
if (context->skipValidation() || Validate{name}({validate_params})) if (context->skipValidation() || Validate{name}({validate_params}))
{{ {{
{return_if_needed}context->{name_lower_no_suffix}({internal_params}); {return_if_needed}context->{name_lower_no_suffix}({internal_params});
...@@ -679,6 +677,7 @@ template_sources_includes = """#include "libGLESv2/entry_points_gles_{}_autogen. ...@@ -679,6 +677,7 @@ template_sources_includes = """#include "libGLESv2/entry_points_gles_{}_autogen.
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
#include "libANGLE/validationES{}{}.h" #include "libANGLE/validationES{}{}.h"
#include "libGLESv2/entry_points_utils.h"
#include "libGLESv2/global_state.h" #include "libGLESv2/global_state.h"
""" """
...@@ -904,7 +903,7 @@ entry_points_enum = template_entry_points_enum_header.format( ...@@ -904,7 +903,7 @@ entry_points_enum = template_entry_points_enum_header.format(
year = date.today().year, year = date.today().year,
entry_points_list = ",\n".join([" " + cmd for cmd in sorted_cmd_names])) 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: with open(entry_points_enum_header_path, "w") as out:
out.write(entry_points_enum) out.write(entry_points_enum)
out.close() out.close()
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
"GL entry point:scripts/entry_point_packed_gl_enums.json": "GL entry point:scripts/entry_point_packed_gl_enums.json":
"cc1985ce86341a3ff0f5a278eae0fa8f", "cc1985ce86341a3ff0f5a278eae0fa8f",
"GL entry point:scripts/generate_entry_points.py": "GL entry point:scripts/generate_entry_points.py":
"9f2dda92feb508e98c62931a0466f5cd", "24661bb77e40e05ae8de8459e350d373",
"GL entry point:scripts/gl.xml": "GL entry point:scripts/gl.xml":
"b470cb06b06cbbe7adb2c8129ec85708", "b470cb06b06cbbe7adb2c8129ec85708",
"GL format map:src/libANGLE/es3_format_type_combinations.json": "GL format map:src/libANGLE/es3_format_type_combinations.json":
......
...@@ -336,7 +336,6 @@ Context::Context(rx::EGLImplFactory *implFactory, ...@@ -336,7 +336,6 @@ Context::Context(rx::EGLImplFactory *implFactory,
mLimitations), mLimitations),
mSkipValidation(GetNoError(attribs)), mSkipValidation(GetNoError(attribs)),
mDisplayTextureShareGroup(shareTextures != nullptr), mDisplayTextureShareGroup(shareTextures != nullptr),
mSavedArgsType(nullptr),
mImplementation(implFactory->createContext(mState, config, shareContext, attribs)), mImplementation(implFactory->createContext(mState, config, shareContext, attribs)),
mLabel(nullptr), mLabel(nullptr),
mCompiler(), mCompiler(),
...@@ -368,10 +367,6 @@ Context::Context(rx::EGLImplFactory *implFactory, ...@@ -368,10 +367,6 @@ Context::Context(rx::EGLImplFactory *implFactory,
mZeroFilledBuffer(1000u), mZeroFilledBuffer(1000u),
mThreadPool(nullptr) mThreadPool(nullptr)
{ {
// Needed to solve a Clang warning of unused variables.
ANGLE_UNUSED_VARIABLE(mSavedArgsType);
ANGLE_UNUSED_VARIABLE(mParamsBuffer);
for (angle::SubjectIndex uboIndex = kUniformBuffer0SubjectIndex; for (angle::SubjectIndex uboIndex = kUniformBuffer0SubjectIndex;
uboIndex < kUniformBufferMaxSubjectIndex; ++uboIndex) uboIndex < kUniformBufferMaxSubjectIndex; ++uboIndex)
{ {
......
...@@ -1622,9 +1622,6 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl ...@@ -1622,9 +1622,6 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
MemoryProgramCache *getMemoryProgramCache() const { return mMemoryProgramCache; } MemoryProgramCache *getMemoryProgramCache() const { return mMemoryProgramCache; }
template <EntryPoint EP, typename... ParamsT>
void gatherParams(ParamsT &&... params);
// Notification for a state change in a Texture. // Notification for a state change in a Texture.
void onTextureChange(const Texture *texture); void onTextureChange(const Texture *texture);
...@@ -1693,9 +1690,6 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl ...@@ -1693,9 +1690,6 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
bool isWebGL() const { return mState.isWebGL(); } bool isWebGL() const { return mState.isWebGL(); }
bool isWebGL1() const { return mState.isWebGL1(); } bool isWebGL1() const { return mState.isWebGL1(); }
template <typename T>
const T &getParams() const;
bool isValidBufferBinding(BufferBinding binding) const { return mValidBufferBindings[binding]; } bool isValidBufferBinding(BufferBinding binding) const { return mValidBufferBindings[binding]; }
// GLES1 emulation: Renderer level (for validation) // GLES1 emulation: Renderer level (for validation)
...@@ -1766,11 +1760,6 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl ...@@ -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. // Stores for each buffer binding type whether is it allowed to be used in this context.
angle::PackedEnumBitSet<BufferBinding> mValidBufferBindings; 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; std::unique_ptr<rx::ContextImpl> mImplementation;
EGLLabelKHR mLabel; EGLLabelKHR mLabel;
...@@ -1868,34 +1857,6 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl ...@@ -1868,34 +1857,6 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
std::shared_ptr<angle::WorkerThreadPool> mThreadPool; 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 } // namespace gl
#endif // LIBANGLE_CONTEXT_H_ #endif // LIBANGLE_CONTEXT_H_
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "libANGLE/State.h" #include "libANGLE/State.h"
#include "libANGLE/Version.h" #include "libANGLE/Version.h"
#include "libANGLE/WorkerThread.h" #include "libANGLE/WorkerThread.h"
#include "libANGLE/params.h"
namespace gl namespace gl
{ {
......
...@@ -990,12 +990,10 @@ GLenum Framebuffer::checkStatusImpl(const Context *context) ...@@ -990,12 +990,10 @@ GLenum Framebuffer::checkStatusImpl(const Context *context)
if (mCachedStatus.value() == GL_FRAMEBUFFER_COMPLETE) if (mCachedStatus.value() == GL_FRAMEBUFFER_COMPLETE)
{ {
Error err = syncState(context); angle::Result err = syncState(context);
if (err.isError()) if (err != angle::Result::Continue())
{ {
// TODO(jmadill): Remove when refactor complete. http://anglebug.com/2491 return 0;
const_cast<Context *>(context)->handleError(err);
return GetDefaultReturnValue<EntryPoint::CheckFramebufferStatus, GLenum>();
} }
if (!mImpl->checkStatus(context)) if (!mImpl->checkStatus(context))
{ {
......
...@@ -458,7 +458,6 @@ void GLES1Renderer::drawTexture(Context *context, ...@@ -458,7 +458,6 @@ void GLES1Renderer::drawTexture(Context *context,
setAttributesEnabled(context, glState, AttributesMask()); setAttributesEnabled(context, glState, AttributesMask());
context->gatherParams<EntryPoint::DrawArrays>(PrimitiveMode::Triangles, 0, 6);
context->drawArrays(PrimitiveMode::Triangles, 0, 6); context->drawArrays(PrimitiveMode::Triangles, 0, 6);
setAttributesEnabled(context, glState, prevAttributesMask); setAttributesEnabled(context, glState, prevAttributesMask);
......
...@@ -238,7 +238,7 @@ class VertexArray final : public angle::ObserverInterface, ...@@ -238,7 +238,7 @@ class VertexArray final : public angle::ObserverInterface,
DIRTY_BINDING_MAX = DIRTY_BINDING_UNKNOWN, DIRTY_BINDING_MAX = DIRTY_BINDING_UNKNOWN,
}; };
using DirtyBits = angle::BitSet<DIRTY_BIT_MAX>; using DirtyBits = angle::BitSet<DIRTY_BIT_MAX>;
using DirtyAttribBits = angle::BitSet<DIRTY_ATTRIB_MAX>; using DirtyAttribBits = angle::BitSet<DIRTY_ATTRIB_MAX>;
using DirtyBindingBits = angle::BitSet<DIRTY_BINDING_MAX>; using DirtyBindingBits = angle::BitSet<DIRTY_BINDING_MAX>;
using DirtyAttribBitsArray = std::array<DirtyAttribBits, gl::MAX_VERTEX_ATTRIBS>; using DirtyAttribBitsArray = std::array<DirtyAttribBits, gl::MAX_VERTEX_ATTRIBS>;
...@@ -343,4 +343,4 @@ class VertexArray final : public angle::ObserverInterface, ...@@ -343,4 +343,4 @@ class VertexArray final : public angle::ObserverInterface,
} // namespace gl } // namespace gl
#endif // LIBANGLE_VERTEXARRAY_H_ #endif // LIBANGLE_VERTEXARRAY_H_
//
// 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
...@@ -205,7 +205,7 @@ angle::Result InputLayoutCache::createInputLayout( ...@@ -205,7 +205,7 @@ angle::Result InputLayoutCache::createInputLayout(
GLsizei instances, GLsizei instances,
d3d11::InputLayout *inputLayoutOut) d3d11::InputLayout *inputLayoutOut)
{ {
Renderer11 *renderer = context11->getRenderer(); Renderer11 *renderer = context11->getRenderer();
ProgramD3D *programD3D = renderer->getStateManager()->getProgramD3D(); ProgramD3D *programD3D = renderer->getStateManager()->getProgramD3D();
D3D_FEATURE_LEVEL featureLevel = renderer->getRenderer11DeviceCaps().featureLevel; D3D_FEATURE_LEVEL featureLevel = renderer->getRenderer11DeviceCaps().featureLevel;
......
...@@ -120,4 +120,4 @@ class InputLayoutCache : angle::NonCopyable ...@@ -120,4 +120,4 @@ class InputLayoutCache : angle::NonCopyable
} // namespace rx } // namespace rx
#endif // LIBANGLE_RENDERER_D3D_D3D11_INPUTLAYOUTCACHE_H_ #endif // LIBANGLE_RENDERER_D3D_D3D11_INPUTLAYOUTCACHE_H_
...@@ -3100,7 +3100,7 @@ angle::Result Renderer11::readFromAttachment(const gl::Context *context, ...@@ -3100,7 +3100,7 @@ angle::Result Renderer11::readFromAttachment(const gl::Context *context,
bool reverseRowOrder = pack.reverseRowOrder; bool reverseRowOrder = pack.reverseRowOrder;
if (invertTexture) if (invertTexture)
{ {
actualArea.y = texSize.height - actualArea.y - actualArea.height; actualArea.y = texSize.height - actualArea.y - actualArea.height;
reverseRowOrder = !reverseRowOrder; reverseRowOrder = !reverseRowOrder;
} }
......
...@@ -48,16 +48,16 @@ struct Renderer11DeviceCaps ...@@ -48,16 +48,16 @@ struct Renderer11DeviceCaps
Renderer11DeviceCaps(); Renderer11DeviceCaps();
D3D_FEATURE_LEVEL featureLevel; D3D_FEATURE_LEVEL featureLevel;
bool supportsDXGI1_2; // Support for DXGI 1.2 bool supportsDXGI1_2; // Support for DXGI 1.2
bool supportsClearView; // Support for ID3D11DeviceContext1::ClearView bool supportsClearView; // Support for ID3D11DeviceContext1::ClearView
bool supportsConstantBufferOffsets; // Support for Constant buffer offset bool supportsConstantBufferOffsets; // Support for Constant buffer offset
bool supportsVpRtIndexWriteFromVertexShader; // VP/RT can be selected in the Vertex Shader bool supportsVpRtIndexWriteFromVertexShader; // VP/RT can be selected in the Vertex Shader
// stage. // stage.
bool supportsMultisampledDepthStencilSRVs; // D3D feature level 10.0 no longer allows creation bool supportsMultisampledDepthStencilSRVs; // D3D feature level 10.0 no longer allows creation
// of textures with both the bind SRV and DSV flags // of textures with both the bind SRV and DSV flags
// when multisampled. Textures will need to be // when multisampled. Textures will need to be
// resolved before reading. crbug.com/656989 // resolved before reading. crbug.com/656989
UINT B5G6R5support; // Bitfield of D3D11_FORMAT_SUPPORT values for DXGI_FORMAT_B5G6R5_UNORM UINT B5G6R5support; // Bitfield of D3D11_FORMAT_SUPPORT values for DXGI_FORMAT_B5G6R5_UNORM
UINT B5G6R5maxSamples; // Maximum number of samples supported by DXGI_FORMAT_B5G6R5_UNORM UINT B5G6R5maxSamples; // Maximum number of samples supported by DXGI_FORMAT_B5G6R5_UNORM
UINT B4G4R4A4support; // Bitfield of D3D11_FORMAT_SUPPORT values for DXGI_FORMAT_B4G4R4A4_UNORM UINT B4G4R4A4support; // Bitfield of D3D11_FORMAT_SUPPORT values for DXGI_FORMAT_B4G4R4A4_UNORM
UINT B4G4R4A4maxSamples; // Maximum number of samples supported by DXGI_FORMAT_B4G4R4A4_UNORM UINT B4G4R4A4maxSamples; // Maximum number of samples supported by DXGI_FORMAT_B4G4R4A4_UNORM
......
...@@ -105,4 +105,4 @@ class VertexArray11 : public VertexArrayImpl ...@@ -105,4 +105,4 @@ class VertexArray11 : public VertexArrayImpl
} // namespace rx } // namespace rx
#endif // LIBANGLE_RENDERER_D3D_D3D11_VERTEXARRAY11_H_ #endif // LIBANGLE_RENDERER_D3D_D3D11_VERTEXARRAY11_H_
...@@ -34,7 +34,7 @@ class Renderer11; ...@@ -34,7 +34,7 @@ class Renderer11;
class RenderTarget11; class RenderTarget11;
struct Renderer11DeviceCaps; struct Renderer11DeviceCaps;
using RTVArray = std::array<ID3D11RenderTargetView *, gl::IMPLEMENTATION_MAX_DRAW_BUFFERS>; using RTVArray = std::array<ID3D11RenderTargetView *, gl::IMPLEMENTATION_MAX_DRAW_BUFFERS>;
namespace gl_d3d11 namespace gl_d3d11
{ {
...@@ -50,7 +50,10 @@ D3D11_DEPTH_WRITE_MASK ConvertDepthMask(bool depthWriteEnabled); ...@@ -50,7 +50,10 @@ D3D11_DEPTH_WRITE_MASK ConvertDepthMask(bool depthWriteEnabled);
UINT8 ConvertStencilMask(GLuint stencilmask); UINT8 ConvertStencilMask(GLuint stencilmask);
D3D11_STENCIL_OP ConvertStencilOp(GLenum stencilOp); 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); D3D11_TEXTURE_ADDRESS_MODE ConvertTextureWrap(GLenum wrap);
UINT ConvertMaxAnisotropy(float maxAnisotropy, D3D_FEATURE_LEVEL featureLevel); UINT ConvertMaxAnisotropy(float maxAnisotropy, D3D_FEATURE_LEVEL featureLevel);
...@@ -96,7 +99,11 @@ enum ANGLED3D11DeviceType ...@@ -96,7 +99,11 @@ enum ANGLED3D11DeviceType
ANGLED3D11DeviceType GetDeviceType(ID3D11Device *device); 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( angle::Result GenerateInitialTextureData(
const gl::Context *context, const gl::Context *context,
...@@ -115,7 +122,7 @@ struct PositionTexCoordVertex ...@@ -115,7 +122,7 @@ struct PositionTexCoordVertex
float x, y; float x, y;
float u, v; 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 struct PositionLayerTexCoord3DVertex
{ {
...@@ -123,8 +130,13 @@ struct PositionLayerTexCoord3DVertex ...@@ -123,8 +130,13 @@ struct PositionLayerTexCoord3DVertex
unsigned int l; unsigned int l;
float u, v, s; float u, v, s;
}; };
void SetPositionLayerTexCoord3DVertex(PositionLayerTexCoord3DVertex* vertex, float x, float y, void SetPositionLayerTexCoord3DVertex(PositionLayerTexCoord3DVertex *vertex,
unsigned int layer, float u, float v, float s); float x,
float y,
unsigned int layer,
float u,
float v,
float s);
struct PositionVertex struct PositionVertex
{ {
...@@ -162,10 +174,11 @@ bool operator==(const RasterizerStateKey &a, const RasterizerStateKey &b); ...@@ -162,10 +174,11 @@ bool operator==(const RasterizerStateKey &a, const RasterizerStateKey &b);
bool operator!=(const RasterizerStateKey &a, const RasterizerStateKey &b); bool operator!=(const RasterizerStateKey &a, const RasterizerStateKey &b);
template <typename outType> template <typename outType>
outType* DynamicCastComObject(IUnknown* object) outType *DynamicCastComObject(IUnknown *object)
{ {
outType *outObject = nullptr; 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)) if (SUCCEEDED(result))
{ {
return outObject; return outObject;
...@@ -181,14 +194,14 @@ inline bool isDeviceLostError(HRESULT errorCode) ...@@ -181,14 +194,14 @@ inline bool isDeviceLostError(HRESULT errorCode)
{ {
switch (errorCode) switch (errorCode)
{ {
case DXGI_ERROR_DEVICE_HUNG: case DXGI_ERROR_DEVICE_HUNG:
case DXGI_ERROR_DEVICE_REMOVED: case DXGI_ERROR_DEVICE_REMOVED:
case DXGI_ERROR_DEVICE_RESET: case DXGI_ERROR_DEVICE_RESET:
case DXGI_ERROR_DRIVER_INTERNAL_ERROR: case DXGI_ERROR_DRIVER_INTERNAL_ERROR:
case DXGI_ERROR_NOT_CURRENTLY_AVAILABLE: case DXGI_ERROR_NOT_CURRENTLY_AVAILABLE:
return true; return true;
default: default:
return false; return false;
} }
} }
...@@ -438,4 +451,4 @@ IndexStorageType ClassifyIndexStorage(const gl::State &glState, ...@@ -438,4 +451,4 @@ IndexStorageType ClassifyIndexStorage(const gl::State &glState,
} // namespace rx } // namespace rx
#endif // LIBANGLE_RENDERER_D3D_D3D11_RENDERER11_UTILS_H_ #endif // LIBANGLE_RENDERER_D3D_D3D11_RENDERER11_UTILS_H_
...@@ -983,7 +983,7 @@ angle::Result Renderer9::setTexture(const gl::Context *context, ...@@ -983,7 +983,7 @@ angle::Result Renderer9::setTexture(const gl::Context *context,
gl::Texture *texture) gl::Texture *texture)
{ {
int d3dSamplerOffset = (type == gl::ShaderType::Fragment) ? 0 : D3DVERTEXTEXTURESAMPLER0; int d3dSamplerOffset = (type == gl::ShaderType::Fragment) ? 0 : D3DVERTEXTEXTURESAMPLER0;
int d3dSampler = index + d3dSamplerOffset; int d3dSampler = index + d3dSamplerOffset;
IDirect3DBaseTexture9 *d3dTexture = nullptr; IDirect3DBaseTexture9 *d3dTexture = nullptr;
bool forceSetTexture = false; bool forceSetTexture = false;
...@@ -1302,8 +1302,8 @@ angle::Result Renderer9::applyIndexBuffer(const gl::Context *context, ...@@ -1302,8 +1302,8 @@ angle::Result Renderer9::applyIndexBuffer(const gl::Context *context,
GLenum type, GLenum type,
TranslatedIndexData *indexInfo) TranslatedIndexData *indexInfo)
{ {
gl::VertexArray *vao = context->getGLState().getVertexArray(); gl::VertexArray *vao = context->getGLState().getVertexArray();
gl::Buffer *elementArrayBuffer = vao->getElementArrayBuffer(); gl::Buffer *elementArrayBuffer = vao->getElementArrayBuffer();
GLenum dstType = GL_NONE; GLenum dstType = GL_NONE;
ANGLE_TRY(GetIndexTranslationDestType(context, count, type, indices, false, &dstType)); ANGLE_TRY(GetIndexTranslationDestType(context, count, type, indices, false, &dstType));
...@@ -1676,7 +1676,7 @@ angle::Result Renderer9::getCountingIB(const gl::Context *context, ...@@ -1676,7 +1676,7 @@ angle::Result Renderer9::getCountingIB(const gl::Context *context,
angle::Result Renderer9::applyShaders(const gl::Context *context, gl::PrimitiveMode drawMode) angle::Result Renderer9::applyShaders(const gl::Context *context, gl::PrimitiveMode drawMode)
{ {
const gl::State &state = context->getContextState().getState(); const gl::State &state = context->getContextState().getState();
d3d::Context *contextD3D = GetImplAs<ContextD3D>(context); d3d::Context *contextD3D = GetImplAs<ContextD3D>(context);
// This method is called single-threaded. // This method is called single-threaded.
......
...@@ -1170,20 +1170,20 @@ angle::Result ContextVk::handleDirtyDriverUniforms(const gl::Context *context, ...@@ -1170,20 +1170,20 @@ angle::Result ContextVk::handleDirtyDriverUniforms(const gl::Context *context,
// Update the driver uniform descriptor set. // Update the driver uniform descriptor set.
VkDescriptorBufferInfo bufferInfo = {}; VkDescriptorBufferInfo bufferInfo = {};
bufferInfo.buffer = buffer; bufferInfo.buffer = buffer;
bufferInfo.offset = offset; bufferInfo.offset = offset;
bufferInfo.range = sizeof(DriverUniforms); bufferInfo.range = sizeof(DriverUniforms);
VkWriteDescriptorSet writeInfo = {}; VkWriteDescriptorSet writeInfo = {};
writeInfo.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; writeInfo.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
writeInfo.dstSet = mDriverUniformsDescriptorSet; writeInfo.dstSet = mDriverUniformsDescriptorSet;
writeInfo.dstBinding = 0; writeInfo.dstBinding = 0;
writeInfo.dstArrayElement = 0; writeInfo.dstArrayElement = 0;
writeInfo.descriptorCount = 1; writeInfo.descriptorCount = 1;
writeInfo.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; writeInfo.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
writeInfo.pImageInfo = nullptr; writeInfo.pImageInfo = nullptr;
writeInfo.pTexelBufferView = nullptr; writeInfo.pTexelBufferView = nullptr;
writeInfo.pBufferInfo = &bufferInfo; writeInfo.pBufferInfo = &bufferInfo;
vkUpdateDescriptorSets(getDevice(), 1, &writeInfo, 0, nullptr); vkUpdateDescriptorSets(getDevice(), 1, &writeInfo, 0, nullptr);
......
...@@ -236,10 +236,8 @@ class ContextVk : public ContextImpl, public vk::Context ...@@ -236,10 +236,8 @@ class ContextVk : public ContextImpl, public vk::Context
angle::Result handleDirtyDefaultAttribs(const gl::Context *context, angle::Result handleDirtyDefaultAttribs(const gl::Context *context,
vk::CommandBuffer *commandBuffer); vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyPipeline(const gl::Context *context, angle::Result handleDirtyPipeline(const gl::Context *context, vk::CommandBuffer *commandBuffer);
vk::CommandBuffer *commandBuffer); angle::Result handleDirtyTextures(const gl::Context *context, vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyTextures(const gl::Context *context,
vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyVertexBuffers(const gl::Context *context, angle::Result handleDirtyVertexBuffers(const gl::Context *context,
vk::CommandBuffer *commandBuffer); vk::CommandBuffer *commandBuffer);
angle::Result handleDirtyIndexBuffer(const gl::Context *context, angle::Result handleDirtyIndexBuffer(const gl::Context *context,
......
...@@ -364,7 +364,7 @@ angle::Result ProgramVk::initDefaultUniformBlocks(const gl::Context *glContext) ...@@ -364,7 +364,7 @@ angle::Result ProgramVk::initDefaultUniformBlocks(const gl::Context *glContext)
for (vk::ShaderType shaderType : vk::AllShaderTypes()) for (vk::ShaderType shaderType : vk::AllShaderTypes())
{ {
gl::ShaderType glShaderType = static_cast<gl::ShaderType>(shaderType); gl::ShaderType glShaderType = static_cast<gl::ShaderType>(shaderType);
gl::Shader *shader = mState.getAttachedShader(glShaderType); gl::Shader *shader = mState.getAttachedShader(glShaderType);
const std::vector<sh::Uniform> &uniforms = shader->getUniforms(); const std::vector<sh::Uniform> &uniforms = shader->getUniforms();
InitDefaultUniformBlock(uniforms, shader, &layoutMap[shaderType], InitDefaultUniformBlock(uniforms, shader, &layoutMap[shaderType],
...@@ -372,7 +372,7 @@ angle::Result ProgramVk::initDefaultUniformBlocks(const gl::Context *glContext) ...@@ -372,7 +372,7 @@ angle::Result ProgramVk::initDefaultUniformBlocks(const gl::Context *glContext)
} }
// Init the default block layout info. // Init the default block layout info.
const auto &uniforms = mState.getUniforms(); const auto &uniforms = mState.getUniforms();
for (const gl::VariableLocation &location : mState.getUniformLocations()) for (const gl::VariableLocation &location : mState.getUniformLocations())
{ {
vk::ShaderMap<sh::BlockMemberInfo> layoutInfo; vk::ShaderMap<sh::BlockMemberInfo> layoutInfo;
......
...@@ -105,8 +105,7 @@ class ProgramVk : public ProgramImpl ...@@ -105,8 +105,7 @@ class ProgramVk : public ProgramImpl
angle::Result updateUniforms(ContextVk *contextVk); angle::Result updateUniforms(ContextVk *contextVk);
angle::Result updateTexturesDescriptorSet(ContextVk *contextVk); angle::Result updateTexturesDescriptorSet(ContextVk *contextVk);
angle::Result updateDescriptorSets(ContextVk *contextVk, angle::Result updateDescriptorSets(ContextVk *contextVk, vk::CommandBuffer *commandBuffer);
vk::CommandBuffer *commandBuffer);
// For testing only. // For testing only.
void setDefaultUniformBlocksMinSizeForTesting(size_t minSize); void setDefaultUniformBlocksMinSizeForTesting(size_t minSize);
......
...@@ -23,8 +23,8 @@ namespace rx ...@@ -23,8 +23,8 @@ namespace rx
{ {
namespace namespace
{ {
constexpr size_t kDynamicVertexDataSize = 1024 * 1024; constexpr size_t kDynamicVertexDataSize = 1024 * 1024;
constexpr size_t kDynamicIndexDataSize = 1024 * 8; constexpr size_t kDynamicIndexDataSize = 1024 * 8;
constexpr size_t kMaxVertexFormatAlignment = 4; constexpr size_t kMaxVertexFormatAlignment = 4;
bool BindingIsAligned(const gl::VertexBinding &binding, unsigned componentSize) bool BindingIsAligned(const gl::VertexBinding &binding, unsigned componentSize)
...@@ -182,7 +182,7 @@ angle::Result VertexArrayVk::convertVertexBuffer(ContextVk *contextVk, ...@@ -182,7 +182,7 @@ angle::Result VertexArrayVk::convertVertexBuffer(ContextVk *contextVk,
if (bytes > 0) if (bytes > 0)
numVertices += static_cast<size_t>(bytes) / binding.getStride(); numVertices += static_cast<size_t>(bytes) / binding.getStride();
void *src = nullptr; void *src = nullptr;
ANGLE_TRY(srcBuffer->mapImpl(contextVk, &src)); ANGLE_TRY(srcBuffer->mapImpl(contextVk, &src));
const uint8_t *srcBytes = reinterpret_cast<const uint8_t *>(src); const uint8_t *srcBytes = reinterpret_cast<const uint8_t *>(src);
srcBytes += binding.getOffset(); srcBytes += binding.getOffset();
...@@ -335,8 +335,8 @@ angle::Result VertexArrayVk::syncDirtyAttrib(ContextVk *contextVk, ...@@ -335,8 +335,8 @@ angle::Result VertexArrayVk::syncDirtyAttrib(ContextVk *contextVk,
mCurrentArrayBufferResources[attribIndex] = &bufferVk->getBuffer(); mCurrentArrayBufferResources[attribIndex] = &bufferVk->getBuffer();
mCurrentArrayBufferHandles[attribIndex] = mCurrentArrayBufferHandles[attribIndex] =
bufferVk->getBuffer().getBuffer().getHandle(); bufferVk->getBuffer().getBuffer().getHandle();
mCurrentArrayBufferOffsets[attribIndex] = binding.getOffset(); mCurrentArrayBufferOffsets[attribIndex] = binding.getOffset();
mCurrentArrayBufferStrides[attribIndex] = binding.getStride(); mCurrentArrayBufferStrides[attribIndex] = binding.getStride();
} }
} }
else else
...@@ -436,7 +436,7 @@ angle::Result VertexArrayVk::updateClientAttribs(const gl::Context *context, ...@@ -436,7 +436,7 @@ angle::Result VertexArrayVk::updateClientAttribs(const gl::Context *context,
GLenum indexTypeOrNone, GLenum indexTypeOrNone,
const void *indices) const void *indices)
{ {
ContextVk *contextVk = vk::GetImpl(context); ContextVk *contextVk = vk::GetImpl(context);
const gl::AttributesMask &clientAttribs = context->getStateCache().getActiveClientAttribsMask(); const gl::AttributesMask &clientAttribs = context->getStateCache().getActiveClientAttribsMask();
ASSERT(clientAttribs.any()); ASSERT(clientAttribs.any());
......
...@@ -180,10 +180,10 @@ angle::Result DynamicBuffer::flush(Context *context) ...@@ -180,10 +180,10 @@ angle::Result DynamicBuffer::flush(Context *context)
if (!mHostCoherent && (mNextAllocationOffset > mLastFlushOrInvalidateOffset)) if (!mHostCoherent && (mNextAllocationOffset > mLastFlushOrInvalidateOffset))
{ {
VkMappedMemoryRange range = {}; VkMappedMemoryRange range = {};
range.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE; range.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
range.memory = mMemory.getHandle(); range.memory = mMemory.getHandle();
range.offset = mLastFlushOrInvalidateOffset; range.offset = mLastFlushOrInvalidateOffset;
range.size = mNextAllocationOffset - mLastFlushOrInvalidateOffset; range.size = mNextAllocationOffset - mLastFlushOrInvalidateOffset;
ANGLE_VK_TRY(context, vkFlushMappedMemoryRanges(context->getDevice(), 1, &range)); ANGLE_VK_TRY(context, vkFlushMappedMemoryRanges(context->getDevice(), 1, &range));
mLastFlushOrInvalidateOffset = mNextAllocationOffset; mLastFlushOrInvalidateOffset = mNextAllocationOffset;
...@@ -196,10 +196,10 @@ angle::Result DynamicBuffer::invalidate(Context *context) ...@@ -196,10 +196,10 @@ angle::Result DynamicBuffer::invalidate(Context *context)
if (!mHostCoherent && (mNextAllocationOffset > mLastFlushOrInvalidateOffset)) if (!mHostCoherent && (mNextAllocationOffset > mLastFlushOrInvalidateOffset))
{ {
VkMappedMemoryRange range = {}; VkMappedMemoryRange range = {};
range.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE; range.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
range.memory = mMemory.getHandle(); range.memory = mMemory.getHandle();
range.offset = mLastFlushOrInvalidateOffset; range.offset = mLastFlushOrInvalidateOffset;
range.size = mNextAllocationOffset - mLastFlushOrInvalidateOffset; range.size = mNextAllocationOffset - mLastFlushOrInvalidateOffset;
ANGLE_VK_TRY(context, vkInvalidateMappedMemoryRanges(context->getDevice(), 1, &range)); ANGLE_VK_TRY(context, vkInvalidateMappedMemoryRanges(context->getDevice(), 1, &range));
mLastFlushOrInvalidateOffset = mNextAllocationOffset; mLastFlushOrInvalidateOffset = mNextAllocationOffset;
...@@ -790,7 +790,7 @@ angle::Result LineLoopHelper::getIndexBufferForElementArrayBuffer(ContextVk *con ...@@ -790,7 +790,7 @@ angle::Result LineLoopHelper::getIndexBufferForElementArrayBuffer(ContextVk *con
VkIndexType indexType = gl_vk::GetIndexType(glIndexType); VkIndexType indexType = gl_vk::GetIndexType(glIndexType);
ASSERT(indexType == VK_INDEX_TYPE_UINT16 || indexType == VK_INDEX_TYPE_UINT32); ASSERT(indexType == VK_INDEX_TYPE_UINT16 || indexType == VK_INDEX_TYPE_UINT32);
uint32_t *indices = nullptr; uint32_t *indices = nullptr;
auto unitSize = (indexType == VK_INDEX_TYPE_UINT16 ? sizeof(uint16_t) : sizeof(uint32_t)); auto unitSize = (indexType == VK_INDEX_TYPE_UINT16 ? sizeof(uint16_t) : sizeof(uint32_t));
size_t allocateBytes = unitSize * (indexCount + 1) + 1; size_t allocateBytes = unitSize * (indexCount + 1) + 1;
...@@ -800,8 +800,8 @@ angle::Result LineLoopHelper::getIndexBufferForElementArrayBuffer(ContextVk *con ...@@ -800,8 +800,8 @@ angle::Result LineLoopHelper::getIndexBufferForElementArrayBuffer(ContextVk *con
reinterpret_cast<uint8_t **>(&indices), bufferHandleOut, reinterpret_cast<uint8_t **>(&indices), bufferHandleOut,
bufferOffsetOut, nullptr)); bufferOffsetOut, nullptr));
VkDeviceSize sourceOffset = static_cast<VkDeviceSize>(elementArrayOffset); VkDeviceSize sourceOffset = static_cast<VkDeviceSize>(elementArrayOffset);
uint64_t unitCount = static_cast<VkDeviceSize>(indexCount); uint64_t unitCount = static_cast<VkDeviceSize>(indexCount);
angle::FixedVector<VkBufferCopy, 3> copies = { angle::FixedVector<VkBufferCopy, 3> copies = {
{sourceOffset, *bufferOffsetOut, unitCount * unitSize}, {sourceOffset, *bufferOffsetOut, unitCount * unitSize},
{sourceOffset, *bufferOffsetOut + unitCount * unitSize, unitSize}, {sourceOffset, *bufferOffsetOut + unitCount * unitSize, unitSize},
...@@ -836,7 +836,7 @@ angle::Result LineLoopHelper::streamIndices(ContextVk *contextVk, ...@@ -836,7 +836,7 @@ angle::Result LineLoopHelper::streamIndices(ContextVk *contextVk,
{ {
// Vulkan doesn't support uint8 index types, so we need to emulate it. // Vulkan doesn't support uint8 index types, so we need to emulate it.
ASSERT(indexType == VK_INDEX_TYPE_UINT16); ASSERT(indexType == VK_INDEX_TYPE_UINT16);
uint16_t *indicesDst = reinterpret_cast<uint16_t *>(indices); uint16_t *indicesDst = reinterpret_cast<uint16_t *>(indices);
for (int i = 0; i < indexCount; i++) for (int i = 0; i < indexCount; i++)
{ {
indicesDst[i] = srcPtr[i]; indicesDst[i] = srcPtr[i];
...@@ -999,11 +999,11 @@ angle::Result ImageHelper::initLayerImageView(Context *context, ...@@ -999,11 +999,11 @@ angle::Result ImageHelper::initLayerImageView(Context *context,
uint32_t layerCount) uint32_t layerCount)
{ {
VkImageViewCreateInfo viewInfo = {}; VkImageViewCreateInfo viewInfo = {};
viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
viewInfo.flags = 0; viewInfo.flags = 0;
viewInfo.image = mImage.getHandle(); viewInfo.image = mImage.getHandle();
viewInfo.viewType = gl_vk::GetImageViewType(textureType); viewInfo.viewType = gl_vk::GetImageViewType(textureType);
viewInfo.format = mFormat->vkTextureFormat; viewInfo.format = mFormat->vkTextureFormat;
if (swizzleMap.swizzleRequired()) if (swizzleMap.swizzleRequired())
{ {
viewInfo.components.r = gl_vk::GetSwizzle(swizzleMap.swizzleRed); viewInfo.components.r = gl_vk::GetSwizzle(swizzleMap.swizzleRed);
...@@ -1144,14 +1144,14 @@ void ImageHelper::changeLayoutWithStages(VkImageAspectFlags aspectMask, ...@@ -1144,14 +1144,14 @@ void ImageHelper::changeLayoutWithStages(VkImageAspectFlags aspectMask,
CommandBuffer *commandBuffer) CommandBuffer *commandBuffer)
{ {
VkImageMemoryBarrier imageMemoryBarrier = {}; VkImageMemoryBarrier imageMemoryBarrier = {};
imageMemoryBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; imageMemoryBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
imageMemoryBarrier.srcAccessMask = 0; imageMemoryBarrier.srcAccessMask = 0;
imageMemoryBarrier.dstAccessMask = 0; imageMemoryBarrier.dstAccessMask = 0;
imageMemoryBarrier.oldLayout = mCurrentLayout; imageMemoryBarrier.oldLayout = mCurrentLayout;
imageMemoryBarrier.newLayout = newLayout; imageMemoryBarrier.newLayout = newLayout;
imageMemoryBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; imageMemoryBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
imageMemoryBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; imageMemoryBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
imageMemoryBarrier.image = mImage.getHandle(); imageMemoryBarrier.image = mImage.getHandle();
// TODO(jmadill): Is this needed for mipped/layer images? // TODO(jmadill): Is this needed for mipped/layer images?
imageMemoryBarrier.subresourceRange.aspectMask = aspectMask; imageMemoryBarrier.subresourceRange.aspectMask = aspectMask;
...@@ -1211,11 +1211,11 @@ void ImageHelper::clearColorLayer(const VkClearColorValue &color, ...@@ -1211,11 +1211,11 @@ void ImageHelper::clearColorLayer(const VkClearColorValue &color,
commandBuffer); commandBuffer);
VkImageSubresourceRange range = {}; VkImageSubresourceRange range = {};
range.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; range.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
range.baseMipLevel = baseMipLevel; range.baseMipLevel = baseMipLevel;
range.levelCount = levelCount; range.levelCount = levelCount;
range.baseArrayLayer = baseArrayLayer; range.baseArrayLayer = baseArrayLayer;
range.layerCount = layerCount; range.layerCount = layerCount;
commandBuffer->clearColorImage(mImage, mCurrentLayout, color, 1, &range); commandBuffer->clearColorImage(mImage, mCurrentLayout, color, 1, &range);
} }
......
...@@ -222,15 +222,12 @@ libangle_sources = [ ...@@ -222,15 +222,12 @@ libangle_sources = [
"src/libANGLE/angletypes.cpp", "src/libANGLE/angletypes.cpp",
"src/libANGLE/angletypes.h", "src/libANGLE/angletypes.h",
"src/libANGLE/angletypes.inl", "src/libANGLE/angletypes.inl",
"src/libANGLE/entry_points_enum_autogen.h",
"src/libANGLE/es3_copy_conversion_table_autogen.cpp", "src/libANGLE/es3_copy_conversion_table_autogen.cpp",
"src/libANGLE/features.h", "src/libANGLE/features.h",
"src/libANGLE/format_map_autogen.cpp", "src/libANGLE/format_map_autogen.cpp",
"src/libANGLE/formatutils.cpp", "src/libANGLE/formatutils.cpp",
"src/libANGLE/formatutils.h", "src/libANGLE/formatutils.h",
"src/libANGLE/histogram_macros.h", "src/libANGLE/histogram_macros.h",
"src/libANGLE/params.cpp",
"src/libANGLE/params.h",
"src/libANGLE/queryconversions.cpp", "src/libANGLE/queryconversions.cpp",
"src/libANGLE/queryconversions.h", "src/libANGLE/queryconversions.h",
"src/libANGLE/queryutils.cpp", "src/libANGLE/queryutils.cpp",
...@@ -867,6 +864,7 @@ libglesv2_sources = [ ...@@ -867,6 +864,7 @@ libglesv2_sources = [
"src/libGLESv2/entry_points_egl.h", "src/libGLESv2/entry_points_egl.h",
"src/libGLESv2/entry_points_egl_ext.cpp", "src/libGLESv2/entry_points_egl_ext.cpp",
"src/libGLESv2/entry_points_egl_ext.h", "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.cpp",
"src/libGLESv2/entry_points_gles_1_0_autogen.h", "src/libGLESv2/entry_points_gles_1_0_autogen.h",
"src/libGLESv2/entry_points_gles_2_0_autogen.cpp", "src/libGLESv2/entry_points_gles_2_0_autogen.cpp",
...@@ -877,6 +875,7 @@ libglesv2_sources = [ ...@@ -877,6 +875,7 @@ libglesv2_sources = [
"src/libGLESv2/entry_points_gles_3_1_autogen.h", "src/libGLESv2/entry_points_gles_3_1_autogen.h",
"src/libGLESv2/entry_points_gles_ext_autogen.cpp", "src/libGLESv2/entry_points_gles_ext_autogen.cpp",
"src/libGLESv2/entry_points_gles_ext_autogen.h", "src/libGLESv2/entry_points_gles_ext_autogen.h",
"src/libGLESv2/entry_points_utils.h",
"src/libGLESv2/global_state.cpp", "src/libGLESv2/global_state.cpp",
"src/libGLESv2/global_state.h", "src/libGLESv2/global_state.h",
"src/libGLESv2/libGLESv2_autogen.cpp", "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 // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// params: // entry_point_utils:
// Parameter wrapper structs for OpenGL ES. These helpers cache re-used values // These helpers are used in GLES entry point routines.
// in entry point routines.
#ifndef LIBANGLE_PARAMS_H_ #ifndef LIBGLESV2_ENTRY_POINT_UTILS_H_
#define LIBANGLE_PARAMS_H_ #define LIBGLESV2_ENTRY_POINT_UTILS_H_
#include "angle_gl.h" #include "angle_gl.h"
#include "common/Optional.h" #include "common/Optional.h"
#include "common/PackedEnums.h" #include "common/PackedEnums.h"
#include "common/angleutils.h" #include "common/angleutils.h"
#include "common/mathutil.h" #include "common/mathutil.h"
#include "libANGLE/Error.h" #include "libGLESv2/entry_points_enum_autogen.h"
#include "libANGLE/entry_points_enum_autogen.h"
namespace gl 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. // A template struct for determining the default value to return for each entry point.
template <EntryPoint EP, typename ReturnType> template <EntryPoint EP, typename ReturnType>
struct DefaultReturnValue; struct DefaultReturnValue;
...@@ -152,7 +81,6 @@ constexpr ANGLE_INLINE ReturnType GetDefaultReturnValue() ...@@ -152,7 +81,6 @@ constexpr ANGLE_INLINE ReturnType GetDefaultReturnValue()
{ {
return DefaultReturnValue<EP, ReturnType>::kValue; return DefaultReturnValue<EP, ReturnType>::kValue;
} }
} // namespace gl } // 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