Hash :
b4d84458
Author :
Date :
2025-05-23T18:08:19
Move Buffer from VertexBinding to VertexArray In later CL we will not taking shared context lock for certain VertexArray API calls. VertexArray itself is per context, so this sounds reasonable to do. The main challenge here is a lot of VertexArray function end up accessing gl::Buffer object, which could be modified by other shared contexts. In order to safely not taking the shared context lock, we need to separate out Buffer object out of VertexArray itself so that these lockless APIs will take VertexArray that does not have access to buffer. In this CL, VertexArray is split into two classes: VertexArrayPrivate is everything in VertexArray except buffers. VertexArray is a subclass of VertexArrayPrivate and owns all the buffers. Buffer is removed from gl::VertexBinding class. In order to let back end access to buffers, VertexArrayImpl holds a weak reference to VertexArray::mVertexArrayBuffers (which is a vector of buffers). Further, VertexArrayBufferBindingMask mBufferBindingMask is moved from VertexArrayState into VertexArray class well, since it tracks which index has a non-null buffer. The bulk of change are due to the VertexARrayImpl constructor change, since it now takes vertexArrayBuffers argument. Other bulk of changes are due to VertexBinding no long has the buffer, but you need to get it directly from VertexArray or VertexArrayImpl. This CL also reverts some of the change in crrev.com/c/6758215 that mVertexBindings no longer contains kElementArrayBufferIndex. BYPASS_LARGE_CHANGE_WARNING Bug: b/433331119 Change-Id: I15f4576f7c5c8d8f4d9c9c07d38a60ce539bfeea Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6774702 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Charlie Lao <cclao@google.com>
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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
//
// Copyright 2015 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.
//
// angle_unittests_utils.h:
// Helpers for mocking and unit testing.
#ifndef TESTS_ANGLE_UNITTESTS_UTILS_H_
#define TESTS_ANGLE_UNITTESTS_UTILS_H_
#include "libANGLE/Surface.h"
#include "libANGLE/renderer/ContextImpl.h"
#include "libANGLE/renderer/EGLImplFactory.h"
#include "libANGLE/renderer/GLImplFactory.h"
namespace rx
{
// Useful when mocking a part of the GLImplFactory class
class NullFactory : public GLImplFactory
{
public:
NullFactory() {}
// Shader creation
CompilerImpl *createCompiler() override { return nullptr; }
ShaderImpl *createShader(const gl::ShaderState &data) override { return nullptr; }
ProgramImpl *createProgram(const gl::ProgramState &data) override { return nullptr; }
ProgramExecutableImpl *createProgramExecutable(const gl::ProgramExecutable *executable) override
{
return nullptr;
}
// Framebuffer creation
FramebufferImpl *createFramebuffer(const gl::FramebufferState &data) override
{
return nullptr;
}
// Texture creation
TextureImpl *createTexture(const gl::TextureState &data) override { return nullptr; }
// Renderbuffer creation
RenderbufferImpl *createRenderbuffer(const gl::RenderbufferState &state) override
{
return nullptr;
}
// Buffer creation
BufferImpl *createBuffer(const gl::BufferState &state) override { return nullptr; }
// Vertex Array creation
VertexArrayImpl *createVertexArray(const gl::VertexArrayState &data,
const gl::VertexArrayBuffers &vertexArrayBuffers) override
{
return nullptr;
}
// Query and Fence creation
QueryImpl *createQuery(gl::QueryType type) override { return nullptr; }
FenceNVImpl *createFenceNV() override { return nullptr; }
SyncImpl *createSync() override { return nullptr; }
// Transform Feedback creation
TransformFeedbackImpl *createTransformFeedback(const gl::TransformFeedbackState &state) override
{
return nullptr;
}
// Sampler object creation
SamplerImpl *createSampler(const gl::SamplerState &state) override { return nullptr; }
// Program Pipeline creation
ProgramPipelineImpl *createProgramPipeline(const gl::ProgramPipelineState &data) override
{
return nullptr;
}
SemaphoreImpl *createSemaphore() override { return nullptr; }
OverlayImpl *createOverlay(const gl::OverlayState &state) override { return nullptr; }
};
// A class with all the factory methods mocked.
class MockGLFactory : public GLImplFactory
{
public:
MOCK_METHOD1(createContext, ContextImpl *(const gl::State &));
MOCK_METHOD0(createCompiler, CompilerImpl *());
MOCK_METHOD1(createShader, ShaderImpl *(const gl::ShaderState &));
MOCK_METHOD1(createProgram, ProgramImpl *(const gl::ProgramState &));
MOCK_METHOD1(createProgramExecutable, ProgramExecutableImpl *(const gl::ProgramExecutable *));
MOCK_METHOD1(createProgramPipeline, ProgramPipelineImpl *(const gl::ProgramPipelineState &));
MOCK_METHOD1(createFramebuffer, FramebufferImpl *(const gl::FramebufferState &));
MOCK_METHOD0(createMemoryObject, MemoryObjectImpl *());
MOCK_METHOD1(createTexture, TextureImpl *(const gl::TextureState &));
MOCK_METHOD1(createRenderbuffer, RenderbufferImpl *(const gl::RenderbufferState &));
MOCK_METHOD1(createBuffer, BufferImpl *(const gl::BufferState &));
MOCK_METHOD2(createVertexArray,
VertexArrayImpl *(const gl::VertexArrayState &, const gl::VertexArrayBuffers &));
MOCK_METHOD1(createQuery, QueryImpl *(gl::QueryType type));
MOCK_METHOD0(createFenceNV, FenceNVImpl *());
MOCK_METHOD0(createSync, SyncImpl *());
MOCK_METHOD1(createTransformFeedback,
TransformFeedbackImpl *(const gl::TransformFeedbackState &));
MOCK_METHOD1(createSampler, SamplerImpl *(const gl::SamplerState &));
MOCK_METHOD0(createSemaphore, SemaphoreImpl *());
MOCK_METHOD1(createOverlay, OverlayImpl *(const gl::OverlayState &));
};
class MockEGLFactory : public EGLImplFactory
{
public:
MOCK_METHOD3(createWindowSurface,
SurfaceImpl *(const egl::SurfaceState &,
EGLNativeWindowType,
const egl::AttributeMap &));
MOCK_METHOD2(createPbufferSurface,
SurfaceImpl *(const egl::SurfaceState &, const egl::AttributeMap &));
MOCK_METHOD4(createPbufferFromClientBuffer,
SurfaceImpl *(const egl::SurfaceState &,
EGLenum,
EGLClientBuffer,
const egl::AttributeMap &));
MOCK_METHOD3(createPixmapSurface,
SurfaceImpl *(const egl::SurfaceState &,
NativePixmapType,
const egl::AttributeMap &));
MOCK_METHOD4(createImage,
ImageImpl *(const egl::ImageState &,
const gl::Context *,
EGLenum,
const egl::AttributeMap &));
MOCK_METHOD5(createContext,
ContextImpl *(const gl::State &,
gl::ErrorSet *,
const egl::Config *,
const gl::Context *,
const egl::AttributeMap &));
MOCK_METHOD2(createStreamProducerD3DTexture,
StreamProducerImpl *(egl::Stream::ConsumerType, const egl::AttributeMap &));
MOCK_METHOD1(createShareGroup, ShareGroupImpl *(const egl::ShareGroupState &));
};
} // namespace rx
#endif // TESTS_ANGLE_UNITTESTS_UTILS_H_