Commit 3fe8c3a3 by Geoff Lang

Refactor the wait/signalSemaphore entry points to be on the Semaphore object

Convert the texture ID parameters into optimized vectors of Texture objects. BUG=angleproject:3656 Change-Id: Iffe824ade2a919c9771642ae501ff04712ca43ce Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1688505Reviewed-by: 's avatarMichael Spang <spang@chromium.org>
parent 7964101c
......@@ -7319,8 +7319,20 @@ void Context::waitSemaphore(GLuint semaphoreHandle,
Semaphore *semaphore = getSemaphore(semaphoreHandle);
ASSERT(semaphore);
ANGLE_CONTEXT_TRY(mImplementation->waitSemaphore(this, semaphore, numBufferBarriers, buffers,
numTextureBarriers, textures, srcLayouts));
BufferBarrierVector bufferBarriers(numBufferBarriers);
for (GLuint bufferBarrierIdx = 0; bufferBarrierIdx < numBufferBarriers; bufferBarrierIdx++)
{
bufferBarriers[bufferBarrierIdx] = getBuffer(buffers[bufferBarrierIdx]);
}
TextureBarrierVector textureBarriers(numTextureBarriers);
for (GLuint textureBarrierIdx = 0; textureBarrierIdx < numTextureBarriers; textureBarrierIdx++)
{
textureBarriers[textureBarrierIdx].texture = getTexture(textures[textureBarrierIdx]);
textureBarriers[textureBarrierIdx].layout = srcLayouts[textureBarrierIdx];
}
ANGLE_CONTEXT_TRY(semaphore->wait(this, bufferBarriers, textureBarriers));
}
void Context::signalSemaphore(GLuint semaphoreHandle,
......@@ -7333,8 +7345,20 @@ void Context::signalSemaphore(GLuint semaphoreHandle,
Semaphore *semaphore = getSemaphore(semaphoreHandle);
ASSERT(semaphore);
ANGLE_CONTEXT_TRY(mImplementation->signalSemaphore(this, semaphore, numBufferBarriers, buffers,
numTextureBarriers, textures, dstLayouts));
BufferBarrierVector bufferBarriers(numBufferBarriers);
for (GLuint bufferBarrierIdx = 0; bufferBarrierIdx < numBufferBarriers; bufferBarrierIdx++)
{
bufferBarriers[bufferBarrierIdx] = getBuffer(buffers[bufferBarrierIdx]);
}
TextureBarrierVector textureBarriers(numTextureBarriers);
for (GLuint textureBarrierIdx = 0; textureBarrierIdx < numTextureBarriers; textureBarrierIdx++)
{
textureBarriers[textureBarrierIdx].texture = getTexture(textures[textureBarrierIdx]);
textureBarriers[textureBarrierIdx].layout = dstLayouts[textureBarrierIdx];
}
ANGLE_CONTEXT_TRY(semaphore->signal(this, bufferBarriers, textureBarriers));
}
void Context::importSemaphoreFd(GLuint semaphore, HandleType handleType, GLint fd)
......
......@@ -30,4 +30,18 @@ angle::Result Semaphore::importFd(Context *context, HandleType handleType, GLint
return mImplementation->importFd(context, handleType, fd);
}
angle::Result Semaphore::wait(Context *context,
const BufferBarrierVector &bufferBarriers,
const TextureBarrierVector &textureBarriers)
{
return mImplementation->wait(context, bufferBarriers, textureBarriers);
}
angle::Result Semaphore::signal(Context *context,
const BufferBarrierVector &bufferBarriers,
const TextureBarrierVector &textureBarriers)
{
return mImplementation->signal(context, bufferBarriers, textureBarriers);
}
} // namespace gl
......@@ -15,6 +15,7 @@
#include "common/angleutils.h"
#include "libANGLE/Error.h"
#include "libANGLE/RefCountObject.h"
#include "libANGLE/angletypes.h"
namespace rx
{
......@@ -38,6 +39,14 @@ class Semaphore final : public RefCountObject
angle::Result importFd(Context *context, HandleType handleType, GLint fd);
angle::Result wait(Context *context,
const BufferBarrierVector &bufferBarriers,
const TextureBarrierVector &textureBarriers);
angle::Result signal(Context *context,
const BufferBarrierVector &bufferBarriers,
const TextureBarrierVector &textureBarriers);
private:
std::unique_ptr<rx::SemaphoreImpl> mImplementation;
};
......
......@@ -477,6 +477,16 @@ template <typename T>
using TransformFeedbackBuffersArray =
std::array<T, gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS>;
constexpr size_t kBarrierVectorDefaultSize = 16;
using BufferBarrierVector = angle::FastVector<Buffer *, kBarrierVectorDefaultSize>;
struct TextureBarrier
{
Texture *texture;
GLenum layout;
};
using TextureBarrierVector = angle::FastVector<TextureBarrier, kBarrierVectorDefaultSize>;
// OffsetBindingPointer.getSize() returns the size specified by the user, which may be larger than
// the size of the bound buffer. This function reduces the returned size to fit the bound buffer if
// necessary. Returns 0 if no buffer is bound or if integer overflow occurs.
......
......@@ -41,22 +41,6 @@ class ContextImpl : public GLImplFactory
virtual angle::Result flush(const gl::Context *context) = 0;
virtual angle::Result finish(const gl::Context *context) = 0;
// Semaphore operations.
virtual angle::Result waitSemaphore(const gl::Context *context,
const gl::Semaphore *semaphore,
GLuint numBufferBarriers,
const GLuint *buffers,
GLuint numTextureBarriers,
const GLuint *textures,
const GLenum *srcLayouts) = 0;
virtual angle::Result signalSemaphore(const gl::Context *context,
const gl::Semaphore *semaphore,
GLuint numBufferBarriers,
const GLuint *buffers,
GLuint numTextureBarriers,
const GLuint *textures,
const GLenum *dstLayouts) = 0;
// Drawing methods.
virtual angle::Result drawArrays(const gl::Context *context,
gl::PrimitiveMode mode,
......
......@@ -12,6 +12,7 @@
#include "common/PackedEnums.h"
#include "common/angleutils.h"
#include "libANGLE/Error.h"
#include "libANGLE/angletypes.h"
namespace gl
{
......@@ -30,6 +31,14 @@ class SemaphoreImpl : angle::NonCopyable
virtual void onDestroy(const gl::Context *context) = 0;
virtual angle::Result importFd(gl::Context *context, gl::HandleType handleType, GLint fd) = 0;
virtual angle::Result wait(gl::Context *context,
const gl::BufferBarrierVector &bufferBarriers,
const gl::TextureBarrierVector &textureBarriers) = 0;
virtual angle::Result signal(gl::Context *context,
const gl::BufferBarrierVector &bufferBarriers,
const gl::TextureBarrierVector &textureBarriers) = 0;
};
} // namespace rx
......
......@@ -253,30 +253,6 @@ angle::Result Context11::finish(const gl::Context *context)
return mRenderer->finish(this);
}
angle::Result Context11::waitSemaphore(const gl::Context *context,
const gl::Semaphore *semaphore,
GLuint numBufferBarriers,
const GLuint *buffers,
GLuint numTextureBarriers,
const GLuint *textures,
const GLenum *srcLayouts)
{
ANGLE_GL_UNREACHABLE(this);
return angle::Result::Stop;
}
angle::Result Context11::signalSemaphore(const gl::Context *context,
const gl::Semaphore *semaphore,
GLuint numBufferBarriers,
const GLuint *buffers,
GLuint numTextureBarriers,
const GLuint *textures,
const GLenum *dstLayouts)
{
ANGLE_GL_UNREACHABLE(this);
return angle::Result::Stop;
}
angle::Result Context11::drawArrays(const gl::Context *context,
gl::PrimitiveMode mode,
GLint first,
......
......@@ -75,22 +75,6 @@ class Context11 : public ContextD3D, public MultisampleTextureInitializer
angle::Result flush(const gl::Context *context) override;
angle::Result finish(const gl::Context *context) override;
// Semaphore operations.
angle::Result waitSemaphore(const gl::Context *context,
const gl::Semaphore *semaphore,
GLuint numBufferBarriers,
const GLuint *buffers,
GLuint numTextureBarriers,
const GLuint *textures,
const GLenum *srcLayouts) override;
angle::Result signalSemaphore(const gl::Context *context,
const gl::Semaphore *semaphore,
GLuint numBufferBarriers,
const GLuint *buffers,
GLuint numTextureBarriers,
const GLuint *textures,
const GLenum *dstLayouts) override;
// Drawing methods.
angle::Result drawArrays(const gl::Context *context,
gl::PrimitiveMode mode,
......
......@@ -155,30 +155,6 @@ angle::Result Context9::finish(const gl::Context *context)
return mRenderer->finish(context);
}
angle::Result Context9::waitSemaphore(const gl::Context *context,
const gl::Semaphore *semaphore,
GLuint numBufferBarriers,
const GLuint *buffers,
GLuint numTextureBarriers,
const GLuint *textures,
const GLenum *srcLayouts)
{
ANGLE_GL_UNREACHABLE(this);
return angle::Result::Stop;
}
angle::Result Context9::signalSemaphore(const gl::Context *context,
const gl::Semaphore *semaphore,
GLuint numBufferBarriers,
const GLuint *buffers,
GLuint numTextureBarriers,
const GLuint *textures,
const GLenum *dstLayouts)
{
ANGLE_GL_UNREACHABLE(this);
return angle::Result::Stop;
}
angle::Result Context9::drawArrays(const gl::Context *context,
gl::PrimitiveMode mode,
GLint first,
......
......@@ -74,22 +74,6 @@ class Context9 : public ContextD3D
angle::Result flush(const gl::Context *context) override;
angle::Result finish(const gl::Context *context) override;
// Semaphore operations.
angle::Result waitSemaphore(const gl::Context *context,
const gl::Semaphore *semaphore,
GLuint numBufferBarriers,
const GLuint *buffers,
GLuint numTextureBarriers,
const GLuint *textures,
const GLenum *srcLayouts) override;
angle::Result signalSemaphore(const gl::Context *context,
const gl::Semaphore *semaphore,
GLuint numBufferBarriers,
const GLuint *buffers,
GLuint numTextureBarriers,
const GLuint *textures,
const GLenum *dstLayouts) override;
// Drawing methods.
angle::Result drawArrays(const gl::Context *context,
gl::PrimitiveMode mode,
......
......@@ -190,30 +190,6 @@ angle::Result ContextGL::finish(const gl::Context *context)
return mRenderer->finish();
}
angle::Result ContextGL::waitSemaphore(const gl::Context *context,
const gl::Semaphore *semaphore,
GLuint numBufferBarriers,
const GLuint *buffers,
GLuint numTextureBarriers,
const GLuint *textures,
const GLenum *srcLayouts)
{
ANGLE_GL_UNREACHABLE(this);
return angle::Result::Stop;
}
angle::Result ContextGL::signalSemaphore(const gl::Context *context,
const gl::Semaphore *semaphore,
GLuint numBufferBarriers,
const GLuint *buffers,
GLuint numTextureBarriers,
const GLuint *textures,
const GLenum *dstLayouts)
{
ANGLE_GL_UNREACHABLE(this);
return angle::Result::Stop;
}
ANGLE_INLINE angle::Result ContextGL::setDrawArraysState(const gl::Context *context,
GLint first,
GLsizei count,
......
......@@ -89,22 +89,6 @@ class ContextGL : public ContextImpl
angle::Result flush(const gl::Context *context) override;
angle::Result finish(const gl::Context *context) override;
// Semaphore operations.
angle::Result waitSemaphore(const gl::Context *context,
const gl::Semaphore *semaphore,
GLuint numBufferBarriers,
const GLuint *buffers,
GLuint numTextureBarriers,
const GLuint *textures,
const GLenum *srcLayouts) override;
angle::Result signalSemaphore(const gl::Context *context,
const gl::Semaphore *semaphore,
GLuint numBufferBarriers,
const GLuint *buffers,
GLuint numTextureBarriers,
const GLuint *textures,
const GLenum *dstLayouts) override;
// Drawing methods.
angle::Result drawArrays(const gl::Context *context,
gl::PrimitiveMode mode,
......
......@@ -121,30 +121,6 @@ angle::Result ContextNULL::finish(const gl::Context *context)
return angle::Result::Continue;
}
angle::Result ContextNULL::waitSemaphore(const gl::Context *context,
const gl::Semaphore *semaphore,
GLuint numBufferBarriers,
const GLuint *buffers,
GLuint numTextureBarriers,
const GLuint *textures,
const GLenum *srcLayouts
)
{
return angle::Result::Continue;
}
angle::Result ContextNULL::signalSemaphore(const gl::Context *context,
const gl::Semaphore *semaphore,
GLuint numBufferBarriers,
const GLuint *buffers,
GLuint numTextureBarriers,
const GLuint *textures,
const GLenum *dstLayouts)
{
return angle::Result::Continue;
}
angle::Result ContextNULL::drawArrays(const gl::Context *context,
gl::PrimitiveMode mode,
GLint first,
......
......@@ -44,22 +44,6 @@ class ContextNULL : public ContextImpl
angle::Result flush(const gl::Context *context) override;
angle::Result finish(const gl::Context *context) override;
// Semaphore operations.
angle::Result waitSemaphore(const gl::Context *context,
const gl::Semaphore *semaphore,
GLuint numBufferBarriers,
const GLuint *buffers,
GLuint numTextureBarriers,
const GLuint *textures,
const GLenum *srcLayouts) override;
angle::Result signalSemaphore(const gl::Context *context,
const gl::Semaphore *semaphore,
GLuint numBufferBarriers,
const GLuint *buffers,
GLuint numTextureBarriers,
const GLuint *textures,
const GLenum *dstLayouts) override;
// Drawing methods.
angle::Result drawArrays(const gl::Context *context,
gl::PrimitiveMode mode,
......
......@@ -356,54 +356,6 @@ angle::Result ContextVk::finish(const gl::Context *context)
return finishImpl();
}
angle::Result ContextVk::waitSemaphore(const gl::Context *context,
const gl::Semaphore *semaphore,
GLuint numBufferBarriers,
const GLuint *buffers,
GLuint numTextureBarriers,
const GLuint *textures,
const GLenum *srcLayouts)
{
addWaitSemaphore(vk::GetImpl(semaphore)->getHandle());
if (numBufferBarriers != 0)
{
// Buffers in external memory are not implemented yet.
UNIMPLEMENTED();
}
if (numTextureBarriers != 0)
{
// Texture barriers are not implemented yet.
UNIMPLEMENTED();
}
return angle::Result::Continue;
}
angle::Result ContextVk::signalSemaphore(const gl::Context *context,
const gl::Semaphore *semaphore,
GLuint numBufferBarriers,
const GLuint *buffers,
GLuint numTextureBarriers,
const GLuint *textures,
const GLenum *dstLayouts)
{
if (numBufferBarriers != 0)
{
// Buffers in external memory are not implemented yet.
UNIMPLEMENTED();
}
if (numTextureBarriers != 0)
{
// Texture barriers are not implemented yet.
UNIMPLEMENTED();
}
return flushImpl(vk::GetImpl(semaphore)->ptr());
}
angle::Result ContextVk::setupDraw(const gl::Context *context,
gl::PrimitiveMode mode,
GLint firstVertex,
......@@ -2133,6 +2085,12 @@ const gl::ActiveTextureArray<TextureVk *> &ContextVk::getActiveTextures() const
return mActiveTextures;
}
void ContextVk::insertWaitSemaphore(const vk::Semaphore *waitSemaphore)
{
ASSERT(waitSemaphore);
mWaitSemaphores.push_back(waitSemaphore->getHandle());
}
angle::Result ContextVk::flushImpl(const vk::Semaphore *signalSemaphore)
{
if (mCommandGraph.empty() && !signalSemaphore && mWaitSemaphores.empty())
......
......@@ -41,22 +41,6 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::CommandBuff
angle::Result flush(const gl::Context *context) override;
angle::Result finish(const gl::Context *context) override;
// Semaphore operations.
angle::Result waitSemaphore(const gl::Context *context,
const gl::Semaphore *semaphore,
GLuint numBufferBarriers,
const GLuint *buffers,
GLuint numTextureBarriers,
const GLuint *textures,
const GLenum *srcLayouts) override;
angle::Result signalSemaphore(const gl::Context *context,
const gl::Semaphore *semaphore,
GLuint numBufferBarriers,
const GLuint *buffers,
GLuint numTextureBarriers,
const GLuint *textures,
const GLenum *dstLayouts) override;
// Drawing methods.
angle::Result drawArrays(const gl::Context *context,
gl::PrimitiveMode mode,
......@@ -241,6 +225,8 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::CommandBuff
mLastIndexBufferOffset = reinterpret_cast<const void *>(angle::DirtyPointer);
}
void insertWaitSemaphore(const vk::Semaphore *waitSemaphore);
angle::Result flushImpl(const vk::Semaphore *semaphore);
angle::Result finishImpl();
......
......@@ -38,6 +38,49 @@ angle::Result SemaphoreVk::importFd(gl::Context *context, gl::HandleType handleT
}
}
angle::Result SemaphoreVk::wait(gl::Context *context,
const gl::BufferBarrierVector &bufferBarriers,
const gl::TextureBarrierVector &textureBarriers)
{
ContextVk *contextVk = vk::GetImpl(context);
if (!bufferBarriers.empty())
{
// Buffers in external memory are not implemented yet.
UNIMPLEMENTED();
}
if (!textureBarriers.empty())
{
// Texture barriers are not implemented yet.
UNIMPLEMENTED();
}
contextVk->insertWaitSemaphore(&mSemaphore);
return angle::Result::Continue;
}
angle::Result SemaphoreVk::signal(gl::Context *context,
const gl::BufferBarrierVector &bufferBarriers,
const gl::TextureBarrierVector &textureBarriers)
{
ContextVk *contextVk = vk::GetImpl(context);
if (!bufferBarriers.empty())
{
// Buffers in external memory are not implemented yet.
UNIMPLEMENTED();
}
if (!textureBarriers.empty())
{
// Texture barriers are not implemented yet.
UNIMPLEMENTED();
}
return contextVk->flushImpl(&mSemaphore);
}
angle::Result SemaphoreVk::importOpaqueFd(gl::Context *context, GLint fd)
{
ContextVk *contextVk = vk::GetImpl(context);
......
......@@ -25,9 +25,13 @@ class SemaphoreVk : public SemaphoreImpl
angle::Result importFd(gl::Context *context, gl::HandleType handleType, GLint fd) override;
VkSemaphore getHandle() const { return mSemaphore.getHandle(); }
angle::Result wait(gl::Context *context,
const gl::BufferBarrierVector &bufferBarriers,
const gl::TextureBarrierVector &textureBarriers) override;
const vk::Semaphore *ptr() const { return &mSemaphore; }
angle::Result signal(gl::Context *context,
const gl::BufferBarrierVector &bufferBarriers,
const gl::TextureBarrierVector &textureBarriers) override;
private:
angle::Result importOpaqueFd(gl::Context *context, GLint fd);
......
......@@ -325,6 +325,7 @@ libangle_sources = [
"src/libANGLE/renderer/RenderbufferImpl.h",
"src/libANGLE/renderer/RenderTargetCache.h",
"src/libANGLE/renderer/SamplerImpl.h",
"src/libANGLE/renderer/SemaphoreImpl.h",
"src/libANGLE/renderer/ShaderImpl.cpp",
"src/libANGLE/renderer/ShaderImpl.h",
"src/libANGLE/renderer/StreamProducerImpl.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