Commit 5093ba67 by Michael Spang Committed by Commit Bot

Implement resource management for GL_EXT_semaphore

This implements glGenSemaphoresEXT, glDeleteSemaphoresEXT, and glIsSemaphoreEXT. It's not possible to do anything useful with them yet. Bug: angleproject:3289 Change-Id: I20ad90dbcd3fc573a4650c8531d6e1b8ccf7ca9b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1623811 Commit-Queue: Michael Spang <spang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 215b2191
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "libANGLE/Renderbuffer.h" #include "libANGLE/Renderbuffer.h"
#include "libANGLE/ResourceManager.h" #include "libANGLE/ResourceManager.h"
#include "libANGLE/Sampler.h" #include "libANGLE/Sampler.h"
#include "libANGLE/Semaphore.h"
#include "libANGLE/Surface.h" #include "libANGLE/Surface.h"
#include "libANGLE/Texture.h" #include "libANGLE/Texture.h"
#include "libANGLE/TransformFeedback.h" #include "libANGLE/TransformFeedback.h"
...@@ -558,6 +559,7 @@ egl::Error Context::onDestroy(const egl::Display *display) ...@@ -558,6 +559,7 @@ egl::Error Context::onDestroy(const egl::Display *display)
mState.mFramebufferManager->release(this); mState.mFramebufferManager->release(this);
mState.mProgramPipelineManager->release(this); mState.mProgramPipelineManager->release(this);
mState.mMemoryObjectManager->release(this); mState.mMemoryObjectManager->release(this);
mState.mSemaphoreManager->release(this);
mThreadPool.reset(); mThreadPool.reset();
...@@ -699,6 +701,11 @@ GLuint Context::createMemoryObject() ...@@ -699,6 +701,11 @@ GLuint Context::createMemoryObject()
return mState.mMemoryObjectManager->createMemoryObject(mImplementation.get()); return mState.mMemoryObjectManager->createMemoryObject(mImplementation.get());
} }
GLuint Context::createSemaphore()
{
return mState.mSemaphoreManager->createSemaphore(mImplementation.get());
}
void Context::deleteBuffer(GLuint bufferName) void Context::deleteBuffer(GLuint bufferName)
{ {
Buffer *buffer = mState.mBufferManager->getBuffer(bufferName); Buffer *buffer = mState.mBufferManager->getBuffer(bufferName);
...@@ -764,6 +771,11 @@ void Context::deleteMemoryObject(GLuint memoryObject) ...@@ -764,6 +771,11 @@ void Context::deleteMemoryObject(GLuint memoryObject)
mState.mMemoryObjectManager->deleteMemoryObject(this, memoryObject); mState.mMemoryObjectManager->deleteMemoryObject(this, memoryObject);
} }
void Context::deleteSemaphore(GLuint semaphore)
{
mState.mSemaphoreManager->deleteSemaphore(this, semaphore);
}
void Context::deletePaths(GLuint first, GLsizei range) void Context::deletePaths(GLuint first, GLsizei range)
{ {
mState.mPathManager->deletePaths(first, range); mState.mPathManager->deletePaths(first, range);
...@@ -5670,6 +5682,11 @@ MemoryObject *Context::getMemoryObject(GLuint handle) const ...@@ -5670,6 +5682,11 @@ MemoryObject *Context::getMemoryObject(GLuint handle) const
return mState.mMemoryObjectManager->getMemoryObject(handle); return mState.mMemoryObjectManager->getMemoryObject(handle);
} }
Semaphore *Context::getSemaphore(GLuint handle) const
{
return mState.mSemaphoreManager->getSemaphore(handle);
}
void Context::getProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei *length, GLchar *infolog) void Context::getProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei *length, GLchar *infolog)
{ {
Program *programObject = getProgramResolveLink(program); Program *programObject = getProgramResolveLink(program);
...@@ -7192,18 +7209,28 @@ void Context::importMemoryFd(GLuint memory, GLuint64 size, HandleType handleType ...@@ -7192,18 +7209,28 @@ void Context::importMemoryFd(GLuint memory, GLuint64 size, HandleType handleType
void Context::genSemaphores(GLsizei n, GLuint *semaphores) void Context::genSemaphores(GLsizei n, GLuint *semaphores)
{ {
UNIMPLEMENTED(); for (int i = 0; i < n; i++)
{
semaphores[i] = createSemaphore();
}
} }
void Context::deleteSemaphores(GLsizei n, const GLuint *semaphores) void Context::deleteSemaphores(GLsizei n, const GLuint *semaphores)
{ {
UNIMPLEMENTED(); for (int i = 0; i < n; i++)
{
deleteSemaphore(semaphores[i]);
}
} }
GLboolean Context::isSemaphore(GLuint semaphore) GLboolean Context::isSemaphore(GLuint semaphore)
{ {
UNIMPLEMENTED(); if (semaphore == 0)
return GL_FALSE; {
return GL_FALSE;
}
return ConvertToGLBoolean(getSemaphore(semaphore));
} }
void Context::semaphoreParameterui64v(GLuint semaphore, GLenum pname, const GLuint64 *params) void Context::semaphoreParameterui64v(GLuint semaphore, GLenum pname, const GLuint64 *params)
......
...@@ -59,6 +59,7 @@ class ProgramPipeline; ...@@ -59,6 +59,7 @@ class ProgramPipeline;
class Query; class Query;
class Renderbuffer; class Renderbuffer;
class Sampler; class Sampler;
class Semaphore;
class Shader; class Shader;
class Sync; class Sync;
class Texture; class Texture;
...@@ -316,6 +317,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl ...@@ -316,6 +317,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
GLuint createProgramPipeline(); GLuint createProgramPipeline();
GLuint createShaderProgramv(ShaderType type, GLsizei count, const GLchar *const *strings); GLuint createShaderProgramv(ShaderType type, GLsizei count, const GLchar *const *strings);
GLuint createMemoryObject(); GLuint createMemoryObject();
GLuint createSemaphore();
void deleteBuffer(GLuint buffer); void deleteBuffer(GLuint buffer);
void deleteShader(GLuint shader); void deleteShader(GLuint shader);
...@@ -325,6 +327,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl ...@@ -325,6 +327,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
void deletePaths(GLuint first, GLsizei range); void deletePaths(GLuint first, GLsizei range);
void deleteProgramPipeline(GLuint pipeline); void deleteProgramPipeline(GLuint pipeline);
void deleteMemoryObject(GLuint memoryObject); void deleteMemoryObject(GLuint memoryObject);
void deleteSemaphore(GLuint semaphore);
// CHROMIUM_path_rendering // CHROMIUM_path_rendering
bool isPath(GLuint path) const; bool isPath(GLuint path) const;
...@@ -664,6 +667,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl ...@@ -664,6 +667,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
TransformFeedback *getTransformFeedback(GLuint handle) const; TransformFeedback *getTransformFeedback(GLuint handle) const;
ProgramPipeline *getProgramPipeline(GLuint handle) const; ProgramPipeline *getProgramPipeline(GLuint handle) const;
MemoryObject *getMemoryObject(GLuint handle) const; MemoryObject *getMemoryObject(GLuint handle) const;
Semaphore *getSemaphore(GLuint handle) const;
void objectLabel(GLenum identifier, GLuint name, GLsizei length, const GLchar *label); void objectLabel(GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
void objectPtrLabel(const void *ptr, GLsizei length, const GLchar *label); void objectPtrLabel(const void *ptr, GLsizei length, const GLchar *label);
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "libANGLE/ProgramPipeline.h" #include "libANGLE/ProgramPipeline.h"
#include "libANGLE/Renderbuffer.h" #include "libANGLE/Renderbuffer.h"
#include "libANGLE/Sampler.h" #include "libANGLE/Sampler.h"
#include "libANGLE/Semaphore.h"
#include "libANGLE/Shader.h" #include "libANGLE/Shader.h"
#include "libANGLE/Texture.h" #include "libANGLE/Texture.h"
#include "libANGLE/renderer/ContextImpl.h" #include "libANGLE/renderer/ContextImpl.h"
...@@ -526,4 +527,53 @@ MemoryObject *MemoryObjectManager::getMemoryObject(GLuint handle) const ...@@ -526,4 +527,53 @@ MemoryObject *MemoryObjectManager::getMemoryObject(GLuint handle) const
return mMemoryObjects.query(handle); return mMemoryObjects.query(handle);
} }
// SemaphoreManager Implementation.
SemaphoreManager::SemaphoreManager() {}
SemaphoreManager::~SemaphoreManager()
{
ASSERT(mSemaphores.empty());
}
void SemaphoreManager::reset(const Context *context)
{
while (!mSemaphores.empty())
{
deleteSemaphore(context, mSemaphores.begin()->first);
}
mSemaphores.clear();
}
GLuint SemaphoreManager::createSemaphore(rx::GLImplFactory *factory)
{
GLuint handle = mHandleAllocator.allocate();
Semaphore *semaphore = new Semaphore(factory, handle);
semaphore->addRef();
mSemaphores.assign(handle, semaphore);
return handle;
}
void SemaphoreManager::deleteSemaphore(const Context *context, GLuint handle)
{
Semaphore *semaphore = nullptr;
if (!mSemaphores.erase(handle, &semaphore))
{
return;
}
// Requires an explicit this-> because of C++ template rules.
this->mHandleAllocator.release(handle);
if (semaphore)
{
semaphore->release(context);
}
}
Semaphore *SemaphoreManager::getSemaphore(GLuint handle) const
{
return mSemaphores.query(handle);
}
} // namespace gl } // namespace gl
...@@ -37,6 +37,7 @@ class ProgramPipeline; ...@@ -37,6 +37,7 @@ class ProgramPipeline;
class Renderbuffer; class Renderbuffer;
class Sampler; class Sampler;
class Shader; class Shader;
class Semaphore;
class Texture; class Texture;
template <typename HandleAllocatorType> template <typename HandleAllocatorType>
...@@ -323,6 +324,24 @@ class MemoryObjectManager : public ResourceManagerBase<HandleAllocator> ...@@ -323,6 +324,24 @@ class MemoryObjectManager : public ResourceManagerBase<HandleAllocator>
ResourceMap<MemoryObject> mMemoryObjects; ResourceMap<MemoryObject> mMemoryObjects;
}; };
class SemaphoreManager : public ResourceManagerBase<HandleAllocator>
{
public:
SemaphoreManager();
GLuint createSemaphore(rx::GLImplFactory *factory);
void deleteSemaphore(const Context *context, GLuint handle);
Semaphore *getSemaphore(GLuint handle) const;
protected:
~SemaphoreManager() override;
private:
void reset(const Context *context) override;
ResourceMap<Semaphore> mSemaphores;
};
} // namespace gl } // namespace gl
#endif // LIBANGLE_RESOURCEMANAGER_H_ #endif // LIBANGLE_RESOURCEMANAGER_H_
//
// Copyright 2019 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.
//
// Semaphore.h: Implements the gl::Semaphore class [EXT_external_objects]
#include "libANGLE/Semaphore.h"
#include "common/angleutils.h"
#include "libANGLE/renderer/GLImplFactory.h"
#include "libANGLE/renderer/SemaphoreImpl.h"
namespace gl
{
Semaphore::Semaphore(rx::GLImplFactory *factory, GLuint id)
: RefCountObject(id), mImplementation(factory->createSemaphore())
{}
Semaphore::~Semaphore() {}
void Semaphore::onDestroy(const Context *context)
{
mImplementation->onDestroy(context);
}
} // namespace gl
//
// Copyright 2019 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.
//
// Semaphore.h: Defines the gl::Semaphore class [EXT_external_objects]
#ifndef LIBANGLE_SEMAPHORE_H_
#define LIBANGLE_SEMAPHORE_H_
#include <memory>
#include "angle_gl.h"
#include "common/angleutils.h"
#include "libANGLE/RefCountObject.h"
namespace rx
{
class GLImplFactory;
class SemaphoreImpl;
} // namespace rx
namespace gl
{
class Context;
class Semaphore final : public RefCountObject
{
public:
Semaphore(rx::GLImplFactory *factory, GLuint id);
~Semaphore() override;
void onDestroy(const Context *context) override;
rx::SemaphoreImpl *getImplementation() const { return mImplementation.get(); }
private:
std::unique_ptr<rx::SemaphoreImpl> mImplementation;
};
} // namespace gl
#endif // LIBANGLE_SEMAPHORE_H_
...@@ -258,6 +258,8 @@ State::State(ContextID contextIn, ...@@ -258,6 +258,8 @@ State::State(ContextID contextIn,
mProgramPipelineManager(new ProgramPipelineManager()), mProgramPipelineManager(new ProgramPipelineManager()),
mMemoryObjectManager( mMemoryObjectManager(
AllocateOrGetSharedResourceManager(shareContextState, &State::mMemoryObjectManager)), AllocateOrGetSharedResourceManager(shareContextState, &State::mMemoryObjectManager)),
mSemaphoreManager(
AllocateOrGetSharedResourceManager(shareContextState, &State::mSemaphoreManager)),
mMaxDrawBuffers(0), mMaxDrawBuffers(0),
mMaxCombinedTextureImageUnits(0), mMaxCombinedTextureImageUnits(0),
mDepthClearValue(0), mDepthClearValue(0),
......
...@@ -40,6 +40,7 @@ class ProgramPipelineManager; ...@@ -40,6 +40,7 @@ class ProgramPipelineManager;
class Query; class Query;
class RenderbufferManager; class RenderbufferManager;
class SamplerManager; class SamplerManager;
class SemaphoreManager;
class ShaderProgramManager; class ShaderProgramManager;
class SyncManager; class SyncManager;
class TextureManager; class TextureManager;
...@@ -731,6 +732,7 @@ class State : angle::NonCopyable ...@@ -731,6 +732,7 @@ class State : angle::NonCopyable
FramebufferManager *mFramebufferManager; FramebufferManager *mFramebufferManager;
ProgramPipelineManager *mProgramPipelineManager; ProgramPipelineManager *mProgramPipelineManager;
MemoryObjectManager *mMemoryObjectManager; MemoryObjectManager *mMemoryObjectManager;
SemaphoreManager *mSemaphoreManager;
// Cached values from Context's caps // Cached values from Context's caps
GLuint mMaxDrawBuffers; GLuint mMaxDrawBuffers;
......
...@@ -42,6 +42,7 @@ class ProgramPipelineImpl; ...@@ -42,6 +42,7 @@ class ProgramPipelineImpl;
class QueryImpl; class QueryImpl;
class RenderbufferImpl; class RenderbufferImpl;
class SamplerImpl; class SamplerImpl;
class SemaphoreImpl;
class ShaderImpl; class ShaderImpl;
class TextureImpl; class TextureImpl;
class TransformFeedbackImpl; class TransformFeedbackImpl;
...@@ -92,6 +93,9 @@ class GLImplFactory : angle::NonCopyable ...@@ -92,6 +93,9 @@ class GLImplFactory : angle::NonCopyable
// Memory object creation // Memory object creation
virtual MemoryObjectImpl *createMemoryObject() = 0; virtual MemoryObjectImpl *createMemoryObject() = 0;
// Semaphore creation
virtual SemaphoreImpl *createSemaphore() = 0;
}; };
} // namespace rx } // namespace rx
......
//
// Copyright 2019 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.
//
// SemaphoreImpl.h: Implements the rx::SemaphoreImpl class [EXT_external_objects]
#ifndef LIBANGLE_RENDERER_SEMAPHOREIMPL_H_
#define LIBANGLE_RENDERER_SEMAPHOREIMPL_H_
#include "angle_gl.h"
#include "common/PackedEnums.h"
#include "common/angleutils.h"
#include "libANGLE/Error.h"
namespace gl
{
class Context;
class Semaphore;
} // namespace gl
namespace rx
{
class SemaphoreImpl : angle::NonCopyable
{
public:
virtual ~SemaphoreImpl() {}
virtual void onDestroy(const gl::Context *context) = 0;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_SEMAPHOREIMPL_H_
...@@ -237,6 +237,12 @@ MemoryObjectImpl *Context11::createMemoryObject() ...@@ -237,6 +237,12 @@ MemoryObjectImpl *Context11::createMemoryObject()
return nullptr; return nullptr;
} }
SemaphoreImpl *Context11::createSemaphore()
{
UNREACHABLE();
return nullptr;
}
angle::Result Context11::flush(const gl::Context *context) angle::Result Context11::flush(const gl::Context *context)
{ {
return mRenderer->flush(this); return mRenderer->flush(this);
......
...@@ -68,6 +68,9 @@ class Context11 : public ContextD3D, public MultisampleTextureInitializer ...@@ -68,6 +68,9 @@ class Context11 : public ContextD3D, public MultisampleTextureInitializer
// Memory object creation. // Memory object creation.
MemoryObjectImpl *createMemoryObject() override; MemoryObjectImpl *createMemoryObject() override;
// Semaphore creation.
SemaphoreImpl *createSemaphore() override;
// Flush and finish. // Flush and finish.
angle::Result flush(const gl::Context *context) override; angle::Result flush(const gl::Context *context) override;
angle::Result finish(const gl::Context *context) override; angle::Result finish(const gl::Context *context) override;
......
...@@ -139,6 +139,12 @@ MemoryObjectImpl *Context9::createMemoryObject() ...@@ -139,6 +139,12 @@ MemoryObjectImpl *Context9::createMemoryObject()
return nullptr; return nullptr;
} }
SemaphoreImpl *Context9::createSemaphore()
{
UNREACHABLE();
return nullptr;
}
angle::Result Context9::flush(const gl::Context *context) angle::Result Context9::flush(const gl::Context *context)
{ {
return mRenderer->flush(context); return mRenderer->flush(context);
......
...@@ -67,6 +67,9 @@ class Context9 : public ContextD3D ...@@ -67,6 +67,9 @@ class Context9 : public ContextD3D
// Memory object creation. // Memory object creation.
MemoryObjectImpl *createMemoryObject() override; MemoryObjectImpl *createMemoryObject() override;
// Semaphore creation.
SemaphoreImpl *createSemaphore() override;
// Flush and finish. // Flush and finish.
angle::Result flush(const gl::Context *context) override; angle::Result flush(const gl::Context *context) override;
angle::Result finish(const gl::Context *context) override; angle::Result finish(const gl::Context *context) override;
......
...@@ -174,6 +174,12 @@ MemoryObjectImpl *ContextGL::createMemoryObject() ...@@ -174,6 +174,12 @@ MemoryObjectImpl *ContextGL::createMemoryObject()
return nullptr; return nullptr;
} }
SemaphoreImpl *ContextGL::createSemaphore()
{
UNREACHABLE();
return nullptr;
}
angle::Result ContextGL::flush(const gl::Context *context) angle::Result ContextGL::flush(const gl::Context *context)
{ {
return mRenderer->flush(); return mRenderer->flush();
......
...@@ -78,6 +78,9 @@ class ContextGL : public ContextImpl ...@@ -78,6 +78,9 @@ class ContextGL : public ContextImpl
// Memory object creation. // Memory object creation.
MemoryObjectImpl *createMemoryObject() override; MemoryObjectImpl *createMemoryObject() override;
// Semaphore creation.
SemaphoreImpl *createSemaphore() override;
// Flush and finish. // Flush and finish.
angle::Result flush(const gl::Context *context) override; angle::Result flush(const gl::Context *context) override;
angle::Result finish(const gl::Context *context) override; angle::Result finish(const gl::Context *context) override;
......
...@@ -398,6 +398,12 @@ MemoryObjectImpl *ContextNULL::createMemoryObject() ...@@ -398,6 +398,12 @@ MemoryObjectImpl *ContextNULL::createMemoryObject()
return nullptr; return nullptr;
} }
SemaphoreImpl *ContextNULL::createSemaphore()
{
UNREACHABLE();
return nullptr;
}
angle::Result ContextNULL::dispatchCompute(const gl::Context *context, angle::Result ContextNULL::dispatchCompute(const gl::Context *context,
GLuint numGroupsX, GLuint numGroupsX,
GLuint numGroupsY, GLuint numGroupsY,
......
...@@ -201,6 +201,9 @@ class ContextNULL : public ContextImpl ...@@ -201,6 +201,9 @@ class ContextNULL : public ContextImpl
// Memory object creation. // Memory object creation.
MemoryObjectImpl *createMemoryObject() override; MemoryObjectImpl *createMemoryObject() override;
// Semaphore creation.
SemaphoreImpl *createSemaphore() override;
angle::Result dispatchCompute(const gl::Context *context, angle::Result dispatchCompute(const gl::Context *context,
GLuint numGroupsX, GLuint numGroupsX,
GLuint numGroupsY, GLuint numGroupsY,
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "libANGLE/renderer/vulkan/RenderbufferVk.h" #include "libANGLE/renderer/vulkan/RenderbufferVk.h"
#include "libANGLE/renderer/vulkan/RendererVk.h" #include "libANGLE/renderer/vulkan/RendererVk.h"
#include "libANGLE/renderer/vulkan/SamplerVk.h" #include "libANGLE/renderer/vulkan/SamplerVk.h"
#include "libANGLE/renderer/vulkan/SemaphoreVk.h"
#include "libANGLE/renderer/vulkan/ShaderVk.h" #include "libANGLE/renderer/vulkan/ShaderVk.h"
#include "libANGLE/renderer/vulkan/SurfaceVk.h" #include "libANGLE/renderer/vulkan/SurfaceVk.h"
#include "libANGLE/renderer/vulkan/SyncVk.h" #include "libANGLE/renderer/vulkan/SyncVk.h"
...@@ -1224,6 +1225,11 @@ MemoryObjectImpl *ContextVk::createMemoryObject() ...@@ -1224,6 +1225,11 @@ MemoryObjectImpl *ContextVk::createMemoryObject()
return new MemoryObjectVk(); return new MemoryObjectVk();
} }
SemaphoreImpl *ContextVk::createSemaphore()
{
return new SemaphoreVk();
}
void ContextVk::invalidateCurrentTextures() void ContextVk::invalidateCurrentTextures()
{ {
ASSERT(mProgram); ASSERT(mProgram);
......
...@@ -159,6 +159,9 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::CommandBuff ...@@ -159,6 +159,9 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::CommandBuff
// Memory object creation. // Memory object creation.
MemoryObjectImpl *createMemoryObject() override; MemoryObjectImpl *createMemoryObject() override;
// Semaphore creation.
SemaphoreImpl *createSemaphore() override;
angle::Result dispatchCompute(const gl::Context *context, angle::Result dispatchCompute(const gl::Context *context,
GLuint numGroupsX, GLuint numGroupsX,
GLuint numGroupsY, GLuint numGroupsY,
......
// Copyright 2019 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.
//
// SemaphoreVk.cpp: Defines the class interface for SemaphoreVk, implementing
// SemaphoreImpl.
#include "libANGLE/renderer/vulkan/SemaphoreVk.h"
#include "common/debug.h"
#include "libANGLE/Context.h"
namespace rx
{
SemaphoreVk::SemaphoreVk() = default;
SemaphoreVk::~SemaphoreVk() = default;
void SemaphoreVk::onDestroy(const gl::Context *context) {}
} // namespace rx
// Copyright 2019 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.
//
// SemaphoreVk.h: Defines the class interface for SemaphoreVk,
// implementing SemaphoreImpl.
#ifndef LIBANGLE_RENDERER_VULKAN_SEMAPHOREVK_H_
#define LIBANGLE_RENDERER_VULKAN_SEMAPHOREVK_H_
#include "libANGLE/renderer/SemaphoreImpl.h"
#include "libANGLE/renderer/vulkan/vk_helpers.h"
#include "libANGLE/renderer/vulkan/vk_wrapper.h"
namespace rx
{
class SemaphoreVk : public SemaphoreImpl
{
public:
SemaphoreVk();
~SemaphoreVk() override;
void onDestroy(const gl::Context *context) override;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_VULKAN_SEMAPHOREVK_H_
...@@ -3272,8 +3272,7 @@ bool ValidateDeleteSemaphoresEXT(Context *context, GLsizei n, const GLuint *sema ...@@ -3272,8 +3272,7 @@ bool ValidateDeleteSemaphoresEXT(Context *context, GLsizei n, const GLuint *sema
return false; return false;
} }
UNIMPLEMENTED(); return ValidateGenOrDelete(context, n);
return false;
} }
bool ValidateGenSemaphoresEXT(Context *context, GLsizei n, GLuint *semaphores) bool ValidateGenSemaphoresEXT(Context *context, GLsizei n, GLuint *semaphores)
...@@ -3284,8 +3283,7 @@ bool ValidateGenSemaphoresEXT(Context *context, GLsizei n, GLuint *semaphores) ...@@ -3284,8 +3283,7 @@ bool ValidateGenSemaphoresEXT(Context *context, GLsizei n, GLuint *semaphores)
return false; return false;
} }
UNIMPLEMENTED(); return ValidateGenOrDelete(context, n);
return false;
} }
bool ValidateGetSemaphoreParameterui64vEXT(Context *context, bool ValidateGetSemaphoreParameterui64vEXT(Context *context,
...@@ -3311,8 +3309,7 @@ bool ValidateIsSemaphoreEXT(Context *context, GLuint semaphore) ...@@ -3311,8 +3309,7 @@ bool ValidateIsSemaphoreEXT(Context *context, GLuint semaphore)
return false; return false;
} }
UNIMPLEMENTED(); return true;
return false;
} }
bool ValidateSemaphoreParameterui64vEXT(Context *context, bool ValidateSemaphoreParameterui64vEXT(Context *context,
......
...@@ -240,6 +240,8 @@ libangle_sources = [ ...@@ -240,6 +240,8 @@ libangle_sources = [
"src/libANGLE/ResourceMap.h", "src/libANGLE/ResourceMap.h",
"src/libANGLE/Sampler.cpp", "src/libANGLE/Sampler.cpp",
"src/libANGLE/Sampler.h", "src/libANGLE/Sampler.h",
"src/libANGLE/Semaphore.cpp",
"src/libANGLE/Semaphore.h",
"src/libANGLE/Shader.cpp", "src/libANGLE/Shader.cpp",
"src/libANGLE/Shader.h", "src/libANGLE/Shader.h",
"src/libANGLE/SizedMRUCache.h", "src/libANGLE/SizedMRUCache.h",
...@@ -803,6 +805,8 @@ libangle_vulkan_sources = [ ...@@ -803,6 +805,8 @@ libangle_vulkan_sources = [
"src/libANGLE/renderer/vulkan/SamplerVk.h", "src/libANGLE/renderer/vulkan/SamplerVk.h",
"src/libANGLE/renderer/vulkan/SecondaryCommandBuffer.cpp", "src/libANGLE/renderer/vulkan/SecondaryCommandBuffer.cpp",
"src/libANGLE/renderer/vulkan/SecondaryCommandBuffer.h", "src/libANGLE/renderer/vulkan/SecondaryCommandBuffer.h",
"src/libANGLE/renderer/vulkan/SemaphoreVk.cpp",
"src/libANGLE/renderer/vulkan/SemaphoreVk.h",
"src/libANGLE/renderer/vulkan/ShaderVk.cpp", "src/libANGLE/renderer/vulkan/ShaderVk.cpp",
"src/libANGLE/renderer/vulkan/ShaderVk.h", "src/libANGLE/renderer/vulkan/ShaderVk.h",
"src/libANGLE/renderer/vulkan/SurfaceVk.cpp", "src/libANGLE/renderer/vulkan/SurfaceVk.cpp",
......
...@@ -105,6 +105,7 @@ angle_end2end_tests_sources = [ ...@@ -105,6 +105,7 @@ angle_end2end_tests_sources = [
"gl_tests/RobustClientMemoryTest.cpp", "gl_tests/RobustClientMemoryTest.cpp",
"gl_tests/RobustResourceInitTest.cpp", "gl_tests/RobustResourceInitTest.cpp",
"gl_tests/SamplersTest.cpp", "gl_tests/SamplersTest.cpp",
"gl_tests/SemaphoreTest.cpp",
"gl_tests/ShaderStorageBufferTest.cpp", "gl_tests/ShaderStorageBufferTest.cpp",
"gl_tests/SimpleOperationTest.cpp", "gl_tests/SimpleOperationTest.cpp",
"gl_tests/SixteenBppTextureTest.cpp", "gl_tests/SixteenBppTextureTest.cpp",
......
...@@ -100,6 +100,7 @@ class MockGLFactory : public GLImplFactory ...@@ -100,6 +100,7 @@ class MockGLFactory : public GLImplFactory
TransformFeedbackImpl *(const gl::TransformFeedbackState &)); TransformFeedbackImpl *(const gl::TransformFeedbackState &));
MOCK_METHOD1(createSampler, SamplerImpl *(const gl::SamplerState &)); MOCK_METHOD1(createSampler, SamplerImpl *(const gl::SamplerState &));
MOCK_METHOD1(createPaths, std::vector<PathImpl *>(GLsizei)); MOCK_METHOD1(createPaths, std::vector<PathImpl *>(GLsizei));
MOCK_METHOD0(createSemaphore, SemaphoreImpl *());
}; };
class MockEGLFactory : public EGLImplFactory class MockEGLFactory : public EGLImplFactory
......
//
// Copyright 2019 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.
//
// SemaphoreTest.cpp : Tests of the GL_EXT_semaphore extension.
#include "test_utils/ANGLETest.h"
#include "test_utils/gl_raii.h"
namespace angle
{
class SemaphoreTest : public ANGLETest
{
protected:
SemaphoreTest()
{
setWindowWidth(1);
setWindowHeight(1);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
}
};
// glIsSemaphoreEXT must identify semaphores.
TEST_P(SemaphoreTest, SemaphoreShouldBeSemaphore)
{
ANGLE_SKIP_TEST_IF(!EnsureGLExtensionEnabled("GL_EXT_semaphore"));
constexpr GLsizei kSemaphoreCount = 2;
GLuint semaphores[kSemaphoreCount];
glGenSemaphoresEXT(kSemaphoreCount, semaphores);
EXPECT_FALSE(glIsSemaphoreEXT(0));
for (GLsizei i = 0; i < kSemaphoreCount; ++i)
{
EXPECT_TRUE(glIsSemaphoreEXT(semaphores[i]));
}
glDeleteSemaphoresEXT(kSemaphoreCount, semaphores);
EXPECT_GL_NO_ERROR();
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these
// tests should be run against.
ANGLE_INSTANTIATE_TEST(SemaphoreTest,
ES2_D3D9(),
ES2_D3D11(),
ES3_D3D11(),
ES2_OPENGL(),
ES3_OPENGL(),
ES2_OPENGLES(),
ES3_OPENGLES(),
ES2_VULKAN());
} // namespace angle
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