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);
......
......@@ -238,7 +238,7 @@ class VertexArray final : public angle::ObserverInterface,
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 DirtyBindingBits = angle::BitSet<DIRTY_BINDING_MAX>;
using DirtyAttribBitsArray = std::array<DirtyAttribBits, gl::MAX_VERTEX_ATTRIBS>;
......@@ -343,4 +343,4 @@ class VertexArray final : public angle::ObserverInterface,
} // 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(
GLsizei instances,
d3d11::InputLayout *inputLayoutOut)
{
Renderer11 *renderer = context11->getRenderer();
Renderer11 *renderer = context11->getRenderer();
ProgramD3D *programD3D = renderer->getStateManager()->getProgramD3D();
D3D_FEATURE_LEVEL featureLevel = renderer->getRenderer11DeviceCaps().featureLevel;
......
......@@ -120,4 +120,4 @@ class InputLayoutCache : angle::NonCopyable
} // 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,
bool reverseRowOrder = pack.reverseRowOrder;
if (invertTexture)
{
actualArea.y = texSize.height - actualArea.y - actualArea.height;
actualArea.y = texSize.height - actualArea.y - actualArea.height;
reverseRowOrder = !reverseRowOrder;
}
......
......@@ -48,16 +48,16 @@ struct Renderer11DeviceCaps
Renderer11DeviceCaps();
D3D_FEATURE_LEVEL featureLevel;
bool supportsDXGI1_2; // Support for DXGI 1.2
bool supportsClearView; // Support for ID3D11DeviceContext1::ClearView
bool supportsConstantBufferOffsets; // Support for Constant buffer offset
bool supportsDXGI1_2; // Support for DXGI 1.2
bool supportsClearView; // Support for ID3D11DeviceContext1::ClearView
bool supportsConstantBufferOffsets; // Support for Constant buffer offset
bool supportsVpRtIndexWriteFromVertexShader; // VP/RT can be selected in the Vertex Shader
// stage.
bool supportsMultisampledDepthStencilSRVs; // D3D feature level 10.0 no longer allows creation
// of textures with both the bind SRV and DSV flags
// when multisampled. Textures will need to be
// 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 B4G4R4A4support; // Bitfield of D3D11_FORMAT_SUPPORT values for DXGI_FORMAT_B4G4R4A4_UNORM
UINT B4G4R4A4maxSamples; // Maximum number of samples supported by DXGI_FORMAT_B4G4R4A4_UNORM
......
......@@ -105,4 +105,4 @@ class VertexArray11 : public VertexArrayImpl
} // namespace rx
#endif // LIBANGLE_RENDERER_D3D_D3D11_VERTEXARRAY11_H_
#endif // LIBANGLE_RENDERER_D3D_D3D11_VERTEXARRAY11_H_
......@@ -34,7 +34,7 @@ class Renderer11;
class RenderTarget11;
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
{
......@@ -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;
......@@ -181,14 +194,14 @@ inline bool isDeviceLostError(HRESULT errorCode)
{
switch (errorCode)
{
case DXGI_ERROR_DEVICE_HUNG:
case DXGI_ERROR_DEVICE_REMOVED:
case DXGI_ERROR_DEVICE_RESET:
case DXGI_ERROR_DRIVER_INTERNAL_ERROR:
case DXGI_ERROR_NOT_CURRENTLY_AVAILABLE:
return true;
default:
return false;
case DXGI_ERROR_DEVICE_HUNG:
case DXGI_ERROR_DEVICE_REMOVED:
case DXGI_ERROR_DEVICE_RESET:
case DXGI_ERROR_DRIVER_INTERNAL_ERROR:
case DXGI_ERROR_NOT_CURRENTLY_AVAILABLE:
return true;
default:
return false;
}
}
......@@ -438,4 +451,4 @@ IndexStorageType ClassifyIndexStorage(const gl::State &glState,
} // 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,
gl::Texture *texture)
{
int d3dSamplerOffset = (type == gl::ShaderType::Fragment) ? 0 : D3DVERTEXTEXTURESAMPLER0;
int d3dSampler = index + d3dSamplerOffset;
int d3dSampler = index + d3dSamplerOffset;
IDirect3DBaseTexture9 *d3dTexture = nullptr;
bool forceSetTexture = false;
......@@ -1302,8 +1302,8 @@ angle::Result Renderer9::applyIndexBuffer(const gl::Context *context,
GLenum type,
TranslatedIndexData *indexInfo)
{
gl::VertexArray *vao = context->getGLState().getVertexArray();
gl::Buffer *elementArrayBuffer = vao->getElementArrayBuffer();
gl::VertexArray *vao = context->getGLState().getVertexArray();
gl::Buffer *elementArrayBuffer = vao->getElementArrayBuffer();
GLenum dstType = GL_NONE;
ANGLE_TRY(GetIndexTranslationDestType(context, count, type, indices, false, &dstType));
......@@ -1676,7 +1676,7 @@ angle::Result Renderer9::getCountingIB(const gl::Context *context,
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);
// This method is called single-threaded.
......
......@@ -1170,20 +1170,20 @@ angle::Result ContextVk::handleDirtyDriverUniforms(const gl::Context *context,
// Update the driver uniform descriptor set.
VkDescriptorBufferInfo bufferInfo = {};
bufferInfo.buffer = buffer;
bufferInfo.offset = offset;
bufferInfo.range = sizeof(DriverUniforms);
bufferInfo.buffer = buffer;
bufferInfo.offset = offset;
bufferInfo.range = sizeof(DriverUniforms);
VkWriteDescriptorSet writeInfo = {};
writeInfo.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
writeInfo.dstSet = mDriverUniformsDescriptorSet;
writeInfo.dstBinding = 0;
writeInfo.dstArrayElement = 0;
writeInfo.descriptorCount = 1;
writeInfo.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
writeInfo.pImageInfo = nullptr;
writeInfo.pTexelBufferView = nullptr;
writeInfo.pBufferInfo = &bufferInfo;
writeInfo.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
writeInfo.dstSet = mDriverUniformsDescriptorSet;
writeInfo.dstBinding = 0;
writeInfo.dstArrayElement = 0;
writeInfo.descriptorCount = 1;
writeInfo.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
writeInfo.pImageInfo = nullptr;
writeInfo.pTexelBufferView = nullptr;
writeInfo.pBufferInfo = &bufferInfo;
vkUpdateDescriptorSets(getDevice(), 1, &writeInfo, 0, nullptr);
......
......@@ -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,
......
......@@ -364,7 +364,7 @@ angle::Result ProgramVk::initDefaultUniformBlocks(const gl::Context *glContext)
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);
const std::vector<sh::Uniform> &uniforms = shader->getUniforms();
InitDefaultUniformBlock(uniforms, shader, &layoutMap[shaderType],
......@@ -372,7 +372,7 @@ angle::Result ProgramVk::initDefaultUniformBlocks(const gl::Context *glContext)
}
// Init the default block layout info.
const auto &uniforms = mState.getUniforms();
const auto &uniforms = mState.getUniforms();
for (const gl::VariableLocation &location : mState.getUniformLocations())
{
vk::ShaderMap<sh::BlockMemberInfo> layoutInfo;
......
......@@ -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);
......
......@@ -23,8 +23,8 @@ namespace rx
{
namespace
{
constexpr size_t kDynamicVertexDataSize = 1024 * 1024;
constexpr size_t kDynamicIndexDataSize = 1024 * 8;
constexpr size_t kDynamicVertexDataSize = 1024 * 1024;
constexpr size_t kDynamicIndexDataSize = 1024 * 8;
constexpr size_t kMaxVertexFormatAlignment = 4;
bool BindingIsAligned(const gl::VertexBinding &binding, unsigned componentSize)
......@@ -182,7 +182,7 @@ angle::Result VertexArrayVk::convertVertexBuffer(ContextVk *contextVk,
if (bytes > 0)
numVertices += static_cast<size_t>(bytes) / binding.getStride();
void *src = nullptr;
void *src = nullptr;
ANGLE_TRY(srcBuffer->mapImpl(contextVk, &src));
const uint8_t *srcBytes = reinterpret_cast<const uint8_t *>(src);
srcBytes += binding.getOffset();
......@@ -335,8 +335,8 @@ angle::Result VertexArrayVk::syncDirtyAttrib(ContextVk *contextVk,
mCurrentArrayBufferResources[attribIndex] = &bufferVk->getBuffer();
mCurrentArrayBufferHandles[attribIndex] =
bufferVk->getBuffer().getBuffer().getHandle();
mCurrentArrayBufferOffsets[attribIndex] = binding.getOffset();
mCurrentArrayBufferStrides[attribIndex] = binding.getStride();
mCurrentArrayBufferOffsets[attribIndex] = binding.getOffset();
mCurrentArrayBufferStrides[attribIndex] = binding.getStride();
}
}
else
......@@ -436,7 +436,7 @@ angle::Result VertexArrayVk::updateClientAttribs(const gl::Context *context,
GLenum indexTypeOrNone,
const void *indices)
{
ContextVk *contextVk = vk::GetImpl(context);
ContextVk *contextVk = vk::GetImpl(context);
const gl::AttributesMask &clientAttribs = context->getStateCache().getActiveClientAttribsMask();
ASSERT(clientAttribs.any());
......
......@@ -180,10 +180,10 @@ angle::Result DynamicBuffer::flush(Context *context)
if (!mHostCoherent && (mNextAllocationOffset > mLastFlushOrInvalidateOffset))
{
VkMappedMemoryRange range = {};
range.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
range.memory = mMemory.getHandle();
range.offset = mLastFlushOrInvalidateOffset;
range.size = mNextAllocationOffset - mLastFlushOrInvalidateOffset;
range.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
range.memory = mMemory.getHandle();
range.offset = mLastFlushOrInvalidateOffset;
range.size = mNextAllocationOffset - mLastFlushOrInvalidateOffset;
ANGLE_VK_TRY(context, vkFlushMappedMemoryRanges(context->getDevice(), 1, &range));
mLastFlushOrInvalidateOffset = mNextAllocationOffset;
......@@ -196,10 +196,10 @@ angle::Result DynamicBuffer::invalidate(Context *context)
if (!mHostCoherent && (mNextAllocationOffset > mLastFlushOrInvalidateOffset))
{
VkMappedMemoryRange range = {};
range.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
range.memory = mMemory.getHandle();
range.offset = mLastFlushOrInvalidateOffset;
range.size = mNextAllocationOffset - mLastFlushOrInvalidateOffset;
range.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
range.memory = mMemory.getHandle();
range.offset = mLastFlushOrInvalidateOffset;
range.size = mNextAllocationOffset - mLastFlushOrInvalidateOffset;
ANGLE_VK_TRY(context, vkInvalidateMappedMemoryRanges(context->getDevice(), 1, &range));
mLastFlushOrInvalidateOffset = mNextAllocationOffset;
......@@ -790,7 +790,7 @@ angle::Result LineLoopHelper::getIndexBufferForElementArrayBuffer(ContextVk *con
VkIndexType indexType = gl_vk::GetIndexType(glIndexType);
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));
size_t allocateBytes = unitSize * (indexCount + 1) + 1;
......@@ -800,8 +800,8 @@ angle::Result LineLoopHelper::getIndexBufferForElementArrayBuffer(ContextVk *con
reinterpret_cast<uint8_t **>(&indices), bufferHandleOut,
bufferOffsetOut, nullptr));
VkDeviceSize sourceOffset = static_cast<VkDeviceSize>(elementArrayOffset);
uint64_t unitCount = static_cast<VkDeviceSize>(indexCount);
VkDeviceSize sourceOffset = static_cast<VkDeviceSize>(elementArrayOffset);
uint64_t unitCount = static_cast<VkDeviceSize>(indexCount);
angle::FixedVector<VkBufferCopy, 3> copies = {
{sourceOffset, *bufferOffsetOut, unitCount * unitSize},
{sourceOffset, *bufferOffsetOut + unitCount * unitSize, unitSize},
......@@ -836,7 +836,7 @@ angle::Result LineLoopHelper::streamIndices(ContextVk *contextVk,
{
// Vulkan doesn't support uint8 index types, so we need to emulate it.
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++)
{
indicesDst[i] = srcPtr[i];
......@@ -999,11 +999,11 @@ angle::Result ImageHelper::initLayerImageView(Context *context,
uint32_t layerCount)
{
VkImageViewCreateInfo viewInfo = {};
viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
viewInfo.flags = 0;
viewInfo.image = mImage.getHandle();
viewInfo.viewType = gl_vk::GetImageViewType(textureType);
viewInfo.format = mFormat->vkTextureFormat;
viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
viewInfo.flags = 0;
viewInfo.image = mImage.getHandle();
viewInfo.viewType = gl_vk::GetImageViewType(textureType);
viewInfo.format = mFormat->vkTextureFormat;
if (swizzleMap.swizzleRequired())
{
viewInfo.components.r = gl_vk::GetSwizzle(swizzleMap.swizzleRed);
......@@ -1144,14 +1144,14 @@ void ImageHelper::changeLayoutWithStages(VkImageAspectFlags aspectMask,
CommandBuffer *commandBuffer)
{
VkImageMemoryBarrier imageMemoryBarrier = {};
imageMemoryBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
imageMemoryBarrier.srcAccessMask = 0;
imageMemoryBarrier.dstAccessMask = 0;
imageMemoryBarrier.oldLayout = mCurrentLayout;
imageMemoryBarrier.newLayout = newLayout;
imageMemoryBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
imageMemoryBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
imageMemoryBarrier.image = mImage.getHandle();
imageMemoryBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
imageMemoryBarrier.srcAccessMask = 0;
imageMemoryBarrier.dstAccessMask = 0;
imageMemoryBarrier.oldLayout = mCurrentLayout;
imageMemoryBarrier.newLayout = newLayout;
imageMemoryBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
imageMemoryBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
imageMemoryBarrier.image = mImage.getHandle();
// TODO(jmadill): Is this needed for mipped/layer images?
imageMemoryBarrier.subresourceRange.aspectMask = aspectMask;
......@@ -1211,11 +1211,11 @@ void ImageHelper::clearColorLayer(const VkClearColorValue &color,
commandBuffer);
VkImageSubresourceRange range = {};
range.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
range.baseMipLevel = baseMipLevel;
range.levelCount = levelCount;
range.baseArrayLayer = baseArrayLayer;
range.layerCount = layerCount;
range.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
range.baseMipLevel = baseMipLevel;
range.levelCount = levelCount;
range.baseArrayLayer = baseArrayLayer;
range.layerCount = layerCount;
commandBuffer->clearColorImage(mImage, mCurrentLayout, color, 1, &range);
}
......
......@@ -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