performance test works

This commit is contained in:
Yun Hsiao Wu
2021-01-04 18:06:30 +08:00
parent be4dd54d86
commit fc034ea606
45 changed files with 633 additions and 313 deletions
+68 -7
View File
@@ -50,7 +50,7 @@ endif()
# set c++ standard
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
@@ -320,6 +320,18 @@ cocos_source_files(
cocos/base/memory/NedPooling.h
cocos/base/memory/StdAlloc.h
cocos/base/memory/StlAlloc.h
cocos/base/threading/ConditionVariable.h
cocos/base/threading/ConditionVariable.cpp
cocos/base/threading/Event.h
cocos/base/threading/MessageQueue.h
cocos/base/threading/MessageQueue.cpp
cocos/base/threading/Semaphore.h
cocos/base/threading/Semaphore.cpp
cocos/base/threading/ThreadPool.h
cocos/base/threading/ThreadPool.cpp
cocos/base/threading/ThreadSafeCounter.h
cocos/base/threading/ThreadSafeLinearAllocator.h
cocos/base/threading/ThreadSafeLinearAllocator.cpp
cocos/base/Object.h
cocos/base/TypeDef.h
cocos/base/uthash.h
@@ -332,6 +344,21 @@ cocos_source_files(
cocos/base/ZipUtils.h
)
##### job system
cocos_source_files(
cocos/base/job-system/JobSystem.h
cocos/base/job-system/job-system-taskflow/TFJobGraph.h
cocos/base/job-system/job-system-taskflow/TFJobGraph.cpp
cocos/base/job-system/job-system-taskflow/TFJobSystem.h
cocos/base/job-system/job-system-taskflow/TFJobSystem.cpp
cocos/base/job-system/job-system-tbb/TBBJobGraph.h
cocos/base/job-system/job-system-tbb/TBBJobGraph.cpp
cocos/base/job-system/job-system-tbb/TBBJobSystem.h
cocos/base/job-system/job-system-tbb/TBBJobSystem.cpp
)
##### math
cocos_source_files(
cocos/math/Geometry.cpp
@@ -567,6 +594,36 @@ cocos_source_files(
cocos/renderer/core/gfx/GFXTexture.h
cocos/renderer/core/gfx/GFXFence.h
cocos/renderer/core/gfx/GFXFence.cpp
cocos/renderer/core/gfx-agent/GFXAgent.h
cocos/renderer/core/gfx-agent/GFXBufferAgent.h
cocos/renderer/core/gfx-agent/GFXBufferAgent.cpp
cocos/renderer/core/gfx-agent/GFXCommandBufferAgent.h
cocos/renderer/core/gfx-agent/GFXCommandBufferAgent.cpp
cocos/renderer/core/gfx-agent/GFXDescriptorSetAgent.h
cocos/renderer/core/gfx-agent/GFXDescriptorSetAgent.cpp
cocos/renderer/core/gfx-agent/GFXDescriptorSetLayoutAgent.h
cocos/renderer/core/gfx-agent/GFXDescriptorSetLayoutAgent.cpp
cocos/renderer/core/gfx-agent/GFXDeviceAgent.h
cocos/renderer/core/gfx-agent/GFXDeviceAgent.cpp
cocos/renderer/core/gfx-agent/GFXFramebufferAgent.h
cocos/renderer/core/gfx-agent/GFXFramebufferAgent.cpp
cocos/renderer/core/gfx-agent/GFXInputAssemblerAgent.h
cocos/renderer/core/gfx-agent/GFXInputAssemblerAgent.cpp
cocos/renderer/core/gfx-agent/GFXLinearAllocatorPool.h
cocos/renderer/core/gfx-agent/GFXPipelineLayoutAgent.h
cocos/renderer/core/gfx-agent/GFXPipelineLayoutAgent.cpp
cocos/renderer/core/gfx-agent/GFXPipelineStateAgent.h
cocos/renderer/core/gfx-agent/GFXPipelineStateAgent.cpp
cocos/renderer/core/gfx-agent/GFXQueueAgent.h
cocos/renderer/core/gfx-agent/GFXQueueAgent.cpp
cocos/renderer/core/gfx-agent/GFXRenderPassAgent.h
cocos/renderer/core/gfx-agent/GFXRenderPassAgent.cpp
cocos/renderer/core/gfx-agent/GFXSamplerAgent.h
cocos/renderer/core/gfx-agent/GFXSamplerAgent.cpp
cocos/renderer/core/gfx-agent/GFXShaderAgent.h
cocos/renderer/core/gfx-agent/GFXShaderAgent.cpp
cocos/renderer/core/gfx-agent/GFXTextureAgent.h
cocos/renderer/core/gfx-agent/GFXTextureAgent.cpp
cocos/renderer/pipeline/BatchedBuffer.cpp
cocos/renderer/pipeline/BatchedBuffer.h
cocos/renderer/pipeline/Define.h
@@ -1099,19 +1156,19 @@ if(USE_MIDDLEWARE)
cocos/editor-support/dragonbones/core/BaseObject.cpp
cocos/editor-support/dragonbones/core/BaseObject.h
cocos/editor-support/dragonbones/core/DragonBones.cpp
cocos/editor-support/dragonbones/core/DragonBones.h
cocos/editor-support/dragonbones/core/DragonBones.h
cocos/editor-support/dragonbones/event/EventObject.cpp
cocos/editor-support/dragonbones/event/EventObject.h
cocos/editor-support/dragonbones/event/IEventDispatcher.h
cocos/editor-support/dragonbones/event/IEventDispatcher.h
cocos/editor-support/dragonbones/factory/BaseFactory.cpp
cocos/editor-support/dragonbones/factory/BaseFactory.h
cocos/editor-support/dragonbones/factory/BaseFactory.h
cocos/editor-support/dragonbones/geom/ColorTransform.h
cocos/editor-support/dragonbones/geom/Matrix.h
cocos/editor-support/dragonbones/geom/Point.cpp
cocos/editor-support/dragonbones/geom/Point.h
cocos/editor-support/dragonbones/geom/Rectangle.h
cocos/editor-support/dragonbones/geom/Transform.cpp
cocos/editor-support/dragonbones/geom/Transform.h
cocos/editor-support/dragonbones/geom/Transform.h
cocos/editor-support/dragonbones/model/AnimationConfig.cpp
cocos/editor-support/dragonbones/model/AnimationConfig.h
cocos/editor-support/dragonbones/model/AnimationData.cpp
@@ -1139,7 +1196,7 @@ if(USE_MIDDLEWARE)
cocos/editor-support/dragonbones/parser/DataParser.cpp
cocos/editor-support/dragonbones/parser/DataParser.h
cocos/editor-support/dragonbones/parser/JSONDataParser.cpp
cocos/editor-support/dragonbones/parser/JSONDataParser.h
cocos/editor-support/dragonbones/parser/JSONDataParser.h
cocos/editor-support/dragonbones-creator-support/ArmatureCache.cpp
cocos/editor-support/dragonbones-creator-support/ArmatureCache.h
cocos/editor-support/dragonbones-creator-support/ArmatureCacheMgr.cpp
@@ -1504,6 +1561,11 @@ target_include_directories(cocos2d
${CC_EXTERNAL_PRIVATE_INCLUDES}
)
target_compile_definitions(cocos2d
PRIVATE
${CC_EXTERNAL_PRIVATE_DEFINITIONS}
)
if(WIN32)
target_link_libraries(cocos2d PUBLIC
ws2_32 userenv psapi winmm Version Iphlpapi opengl32
@@ -1523,7 +1585,6 @@ if(WIN32)
_USRLIBSIMSTATIC
SE_ENABLE_INSPECTOR
)
endif()
if(ANDROID)
+1 -1
View File
@@ -1,7 +1,7 @@
#pragma once
#include "Event.h"
#include "concurrentqueue.h"
#include "concurrentqueue/concurrentqueue.h"
#include <cstdint>
namespace cc {
+2 -2
View File
@@ -1,8 +1,8 @@
#pragma once
#include <cassert>
#include "concurrentqueue.h"
#include "lightweightsemaphore.h"
#include "concurrentqueue/concurrentqueue.h"
#include "concurrentqueue/lightweightsemaphore.h"
namespace cc {
+1 -1
View File
@@ -8,7 +8,7 @@
#include <queue>
#include <cassert>
#include <cstdint>
#include "concurrentqueue.h"
#include "concurrentqueue/concurrentqueue.h"
#include "Event.h"
namespace cc {
File diff suppressed because it is too large Load Diff
@@ -46,6 +46,7 @@ static bool js_gles2_GLES2Device_getThreadID(se::State& s)
unsigned int result = cobj->getThreadID();
ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/);
SE_PRECONDITION2(ok, false, "js_gles2_GLES2Device_getThreadID : Error processing arguments");
SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval());
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
@@ -46,6 +46,7 @@ static bool js_gles3_GLES3Device_getThreadID(se::State& s)
unsigned int result = cobj->getThreadID();
ok &= nativevalue_to_se(result, s.rval(), nullptr /*ctx*/);
SE_PRECONDITION2(ok, false, "js_gles3_GLES3Device_getThreadID : Error processing arguments");
SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval());
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
@@ -13,6 +13,21 @@
se::Object* __jsb_cc_gfx_CCMTLDevice_proto = nullptr;
se::Class* __jsb_cc_gfx_CCMTLDevice_class = nullptr;
static bool js_mtl_CCMTLDevice_ensureAutoreleasePool(se::State& s)
{
cc::gfx::CCMTLDevice* cobj = SE_THIS_OBJECT<cc::gfx::CCMTLDevice>(s);
SE_PRECONDITION2(cobj, false, "js_mtl_CCMTLDevice_ensureAutoreleasePool : Invalid Native Object");
const auto& args = s.args();
size_t argc = args.size();
if (argc == 0) {
cobj->ensureAutoreleasePool();
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0);
return false;
}
SE_BIND_FUNC(js_mtl_CCMTLDevice_ensureAutoreleasePool)
SE_DECLARE_FINALIZE_FUNC(js_cc_gfx_CCMTLDevice_finalize)
static bool js_mtl_CCMTLDevice_constructor(se::State& s) // constructor.c
@@ -45,6 +60,7 @@ bool js_register_mtl_CCMTLDevice(se::Object* obj)
{
auto cls = se::Class::create("CCMTLDevice", obj, __jsb_cc_gfx_Device_proto, _SE(js_mtl_CCMTLDevice_constructor));
cls->defineFunction("ensureAutoreleasePool", _SE(js_mtl_CCMTLDevice_ensureAutoreleasePool));
cls->defineFinalizeFunction(_SE(js_cc_gfx_CCMTLDevice_finalize));
cls->install();
JSBClassType::registerClass<cc::gfx::CCMTLDevice>(cls);
@@ -12,5 +12,6 @@ bool js_register_cc_gfx_CCMTLDevice(se::Object* obj);
bool register_all_mtl(se::Object* obj);
JSB_REGISTER_OBJECT_TYPE(cc::gfx::CCMTLDevice);
SE_DECLARE_FUNC(js_mtl_CCMTLDevice_ensureAutoreleasePool);
SE_DECLARE_FUNC(js_mtl_CCMTLDevice_CCMTLDevice);
-2
View File
@@ -51,8 +51,6 @@ THE SOFTWARE.
#include "base/Macros.h"
#include "base/UTF8.h"
#include "base/Utils.h"
#include "base/job-system/JobSystem.h"
// math
#include "math/Geometry.h"
-15
View File
@@ -46,18 +46,3 @@ THE SOFTWARE.
#include "gfx/GFXSampler.h"
#include "gfx/GFXShader.h"
#include "gfx/GFXTexture.h"
#include "threading/MessageQueue.h"
#include "threading/ThreadPool.h"
#include "gfx-agent/GFXBufferAgent.h"
#include "gfx-agent/GFXCommandBufferAgent.h"
#include "gfx-agent/GFXDescriptorSetAgent.h"
#include "gfx-agent/GFXDeviceAgent.h"
#include "gfx-agent/GFXFramebufferAgent.h"
#include "gfx-agent/GFXInputAssemblerAgent.h"
#include "gfx-agent/GFXPipelineStateAgent.h"
#include "gfx-agent/GFXQueueAgent.h"
#include "gfx-agent/GFXRenderPassAgent.h"
#include "gfx-agent/GFXShaderAgent.h"
#include "gfx-agent/GFXTextureAgent.h"
@@ -10,10 +10,10 @@ class CC_DLL Agent : public Actor {
public:
Agent() noexcept = delete;
explicit Agent(Actor *const actor, Device *const device) noexcept
Agent(Actor *const actor, Device *const device) noexcept
: Actor(device), _actor(actor) {}
virtual ~Agent() {}
~Agent() override {}
Agent(Agent const &) = delete;
@@ -26,7 +26,7 @@ public:
inline Actor *getActor() const noexcept { return _actor; }
protected:
Actor * _actor{nullptr};
Actor *_actor{nullptr};
};
} // namespace gfx
@@ -1,6 +1,6 @@
#include "CoreStd.h"
#include "threading/MessageQueue.h"
#include "base/threading/MessageQueue.h"
#include "GFXBufferAgent.h"
#include "GFXDeviceAgent.h"
#include "GFXLinearAllocatorPool.h"
@@ -8,6 +8,16 @@
namespace cc {
namespace gfx {
BufferAgent::~BufferAgent() {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
BufferDestruct,
actor, _actor,
{
CC_DELETE(actor);
});
}
bool BufferAgent::initialize(const BufferInfo &info) {
_usage = info.usage;
_memUsage = info.memUsage;
@@ -52,17 +62,13 @@ bool BufferAgent::initialize(const BufferViewInfo &info) {
}
void BufferAgent::destroy() {
if (_actor) {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
BufferDestroy,
actor, getActor(),
{
CC_DESTROY(actor);
});
_actor = nullptr;
}
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
BufferDestroy,
actor, getActor(),
{
actor->destroy();
});
}
void BufferAgent::update(void *buffer, uint size) {
@@ -10,12 +10,13 @@ class CC_DLL BufferAgent final : public Agent<Buffer> {
public:
using Agent::Agent;
BufferAgent(Device *device) = delete;
~BufferAgent() override;
virtual bool initialize(const BufferInfo &info) override;
virtual bool initialize(const BufferViewInfo &info) override;
virtual void destroy() override;
virtual void resize(uint size) override;
virtual void update(void *buffer, uint size) override;
bool initialize(const BufferInfo &info) override;
bool initialize(const BufferViewInfo &info) override;
void destroy() override;
void resize(uint size) override;
void update(void *buffer, uint size) override;
};
} // namespace gfx
@@ -1,7 +1,7 @@
#include "CoreStd.h"
#include "job-system/JobSystem.h"
#include "threading/MessageQueue.h"
#include "base/job-system/JobSystem.h"
#include "base/threading/MessageQueue.h"
#include "GFXBufferAgent.h"
#include "GFXCommandBufferAgent.h"
#include "GFXDescriptorSetAgent.h"
@@ -37,6 +37,16 @@ void CommandBufferAgent::flushCommands(CommandBufferAgent *const *cmdBuffs, uint
}
}
CommandBufferAgent::~CommandBufferAgent() {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
CommandBufferDestruct,
actor, _actor,
{
CC_DELETE(actor);
});
}
void CommandBufferAgent::initMessageQueue() {
_allocatorPools.resize(MAX_CPU_FRAME_AHEAD + 1);
for (uint i = 0u; i < MAX_CPU_FRAME_AHEAD + 1; ++i) {
@@ -86,17 +96,14 @@ bool CommandBufferAgent::initialize(const CommandBufferInfo &info) {
void CommandBufferAgent::destroy() {
destroyMessageQueue();
if (_actor) {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
CommandBufferDestroy,
actor, getActor(),
{
CC_DESTROY(actor);
});
_actor = nullptr;
}
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
CommandBufferDestroy,
actor, getActor(),
{
actor->destroy();
});
}
void CommandBufferAgent::begin(RenderPass *renderPass, uint subpass, Framebuffer *frameBuffer, int submitIndex) {
@@ -171,18 +178,23 @@ void CommandBufferAgent::endRenderPass() {
void CommandBufferAgent::execute(const CommandBuffer *const *cmdBuffs, uint32_t count) {
if (!count) return;
const CommandBuffer **actorCmdBuffs = _messageQueue->allocate<const CommandBuffer *>(count);
const CommandBuffer **actorCmdBuffs = getAllocator()->allocate<const CommandBuffer *>(count);
for (uint i = 0; i < count; ++i) {
actorCmdBuffs[i] = ((CommandBufferAgent *)cmdBuffs[i])->getActor();
}
const CommandBufferAgent **agentCmdBuffs = getAllocator()->allocate<const CommandBufferAgent *>(count);
for (uint i = 0; i < count; ++i) {
agentCmdBuffs[i] = (CommandBufferAgent *)cmdBuffs[i];
}
bool multiThreaded = _device->hasFeature(Feature::MULTITHREADED_SUBMISSION);
ENQUEUE_MESSAGE_5(
_messageQueue,
CommandBufferExecute,
actor, getActor(),
cmdBuffs, (CommandBufferAgent *const *)cmdBuffs,
cmdBuffs, (CommandBufferAgent *const *)agentCmdBuffs,
actorCmdBuffs, actorCmdBuffs,
count, count,
multiThreaded, multiThreaded,
@@ -15,34 +15,35 @@ class CC_DLL CommandBufferAgent final : public Agent<CommandBuffer> {
public:
using Agent::Agent;
CommandBufferAgent(Device *device) = delete;
~CommandBufferAgent() override;
static void flushCommands(CommandBufferAgent *const *cmdBuffs, uint count, bool multiThreaded);
virtual bool initialize(const CommandBufferInfo &info) override;
virtual void destroy() override;
virtual void begin(RenderPass *renderPass, uint subpass, Framebuffer *frameBuffer, int submitIndex) override;
virtual void end() override;
virtual void beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const Color *colors, float depth, int stencil, uint32_t secondaryCBCount, const CommandBuffer *const *secondaryCBs) override;
virtual void endRenderPass() override;
virtual void bindPipelineState(PipelineState *pso) override;
virtual void bindDescriptorSet(uint set, DescriptorSet *descriptorSet, uint dynamicOffsetCount, const uint *dynamicOffsets) override;
virtual void bindInputAssembler(InputAssembler *ia) override;
virtual void setViewport(const Viewport &vp) override;
virtual void setScissor(const Rect &rect) override;
virtual void setLineWidth(const float width) override;
virtual void setDepthBias(float constant, float clamp, float slope) override;
virtual void setBlendConstants(const Color &constants) override;
virtual void setDepthBound(float minBounds, float maxBounds) override;
virtual void setStencilWriteMask(StencilFace face, uint mask) override;
virtual void setStencilCompareMask(StencilFace face, int ref, uint mask) override;
virtual void draw(InputAssembler *ia) override;
virtual void updateBuffer(Buffer *buff, const void *data, uint size) override;
virtual void copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint count) override;
virtual void execute(const CommandBuffer *const *cmdBuffs, uint32_t count) override;
bool initialize(const CommandBufferInfo &info) override;
void destroy() override;
void begin(RenderPass *renderPass, uint subpass, Framebuffer *frameBuffer, int submitIndex) override;
void end() override;
void beginRenderPass(RenderPass *renderPass, Framebuffer *fbo, const Rect &renderArea, const Color *colors, float depth, int stencil, uint32_t secondaryCBCount, const CommandBuffer *const *secondaryCBs) override;
void endRenderPass() override;
void bindPipelineState(PipelineState *pso) override;
void bindDescriptorSet(uint set, DescriptorSet *descriptorSet, uint dynamicOffsetCount, const uint *dynamicOffsets) override;
void bindInputAssembler(InputAssembler *ia) override;
void setViewport(const Viewport &vp) override;
void setScissor(const Rect &rect) override;
void setLineWidth(const float width) override;
void setDepthBias(float constant, float clamp, float slope) override;
void setBlendConstants(const Color &constants) override;
void setDepthBound(float minBounds, float maxBounds) override;
void setStencilWriteMask(StencilFace face, uint mask) override;
void setStencilCompareMask(StencilFace face, int ref, uint mask) override;
void draw(InputAssembler *ia) override;
void updateBuffer(Buffer *buff, const void *data, uint size) override;
void copyBuffersToTexture(const uint8_t *const *buffers, Texture *texture, const BufferTextureCopy *regions, uint count) override;
void execute(const CommandBuffer *const *cmdBuffs, uint32_t count) override;
virtual uint getNumDrawCalls() const override { return _actor->getNumDrawCalls(); }
virtual uint getNumInstances() const override { return _actor->getNumInstances(); }
virtual uint getNumTris() const override { return _actor->getNumTris(); }
uint getNumDrawCalls() const override { return _actor->getNumDrawCalls(); }
uint getNumInstances() const override { return _actor->getNumInstances(); }
uint getNumTris() const override { return _actor->getNumTris(); }
CC_INLINE MessageQueue *getMessageQueue() { return _messageQueue; }
LinearAllocatorPool *getAllocator();
@@ -6,11 +6,21 @@
#include "GFXDeviceAgent.h"
#include "GFXSamplerAgent.h"
#include "GFXTextureAgent.h"
#include "threading/MessageQueue.h"
#include "base/threading/MessageQueue.h"
namespace cc {
namespace gfx {
DescriptorSetAgent::~DescriptorSetAgent() {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
DescriptorSetDestruct,
actor, _actor,
{
CC_DELETE(actor);
});
}
bool DescriptorSetAgent::initialize(const DescriptorSetInfo &info) {
_layout = info.layout;
uint descriptorCount = _layout->getDescriptorCount();
@@ -39,17 +49,13 @@ void DescriptorSetAgent::destroy() {
_textures.clear();
_samplers.clear();
if (_actor) {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
DescriptorSetDestroy,
actor, getActor(),
{
CC_DESTROY(actor);
});
_actor = nullptr;
}
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
DescriptorSetDestroy,
actor, getActor(),
{
actor->destroy();
});
}
void DescriptorSetAgent::update() {
@@ -10,14 +10,15 @@ class CC_DLL DescriptorSetAgent final : public Agent<DescriptorSet> {
public:
using Agent::Agent;
DescriptorSetAgent(Device *device) = delete;
~DescriptorSetAgent() override;
virtual bool initialize(const DescriptorSetInfo &info) override;
virtual void destroy() override;
virtual void update() override;
bool initialize(const DescriptorSetInfo &info) override;
void destroy() override;
void update() override;
virtual void bindBuffer(uint binding, Buffer *buffer, uint index) override;
virtual void bindTexture(uint binding, Texture *texture, uint index) override;
virtual void bindSampler(uint binding, Sampler *sampler, uint index) override;
void bindBuffer(uint binding, Buffer *buffer, uint index) override;
void bindTexture(uint binding, Texture *texture, uint index) override;
void bindSampler(uint binding, Sampler *sampler, uint index) override;
};
} // namespace gfx
@@ -1,12 +1,22 @@
#include "CoreStd.h"
#include "threading/MessageQueue.h"
#include "base/threading/MessageQueue.h"
#include "GFXDeviceAgent.h"
#include "GFXDescriptorSetLayoutAgent.h"
namespace cc {
namespace gfx {
DescriptorSetLayoutAgent::~DescriptorSetLayoutAgent() {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
DescriptorSetLayoutDestruct,
actor, _actor,
{
CC_DELETE(actor);
});
}
bool DescriptorSetLayoutAgent::initialize(const DescriptorSetLayoutInfo &info) {
_bindings = info.bindings;
@@ -45,17 +55,13 @@ bool DescriptorSetLayoutAgent::initialize(const DescriptorSetLayoutInfo &info) {
}
void DescriptorSetLayoutAgent::destroy() {
if (_actor) {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
DescriptorSetLayoutDestroy,
actor, getActor(),
{
CC_DESTROY(actor);
});
_actor = nullptr;
}
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
DescriptorSetLayoutDestroy,
actor, getActor(),
{
actor->destroy();
});
}
} // namespace gfx
@@ -10,9 +10,10 @@ class CC_DLL DescriptorSetLayoutAgent final : public Agent<DescriptorSetLayout>
public:
using Agent::Agent;
DescriptorSetLayoutAgent(Device *device) = delete;
~DescriptorSetLayoutAgent() override;
virtual bool initialize(const DescriptorSetLayoutInfo &info) override;
virtual void destroy() override;
bool initialize(const DescriptorSetLayoutInfo &info) override;
void destroy() override;
};
} // namespace gfx
@@ -1,10 +1,9 @@
#include "CoreStd.h"
#include "threading/MessageQueue.h"
#include "GFXBufferAgent.h"
#include "GFXCommandBufferAgent.h"
#include "GFXDescriptorSetLayoutAgent.h"
#include "GFXDescriptorSetAgent.h"
#include "GFXDescriptorSetLayoutAgent.h"
#include "GFXDeviceAgent.h"
#include "GFXFramebufferAgent.h"
#include "GFXInputAssemblerAgent.h"
@@ -16,10 +15,15 @@
#include "GFXSamplerAgent.h"
#include "GFXShaderAgent.h"
#include "GFXTextureAgent.h"
#include "base/threading/MessageQueue.h"
namespace cc {
namespace gfx {
DeviceAgent::~DeviceAgent() {
CC_SAFE_DELETE(_actor);
}
bool DeviceAgent::initialize(const DeviceInfo &info) {
_clipSpaceMinZ = _actor->getClipSpaceMinZ();
_screenSpaceSignY = _actor->getScreenSpaceSignY();
@@ -79,17 +83,13 @@ bool DeviceAgent::initialize(const DeviceInfo &info) {
}
void DeviceAgent::destroy() {
if (_actor) {
ENQUEUE_MESSAGE_1(
getMessageQueue(),
DeviceDestroy,
actor, getActor(),
{
CC_DESTROY(actor);
});
_actor = nullptr;
}
ENQUEUE_MESSAGE_1(
getMessageQueue(),
DeviceDestroy,
actor, getActor(),
{
actor->destroy();
});
((CommandBufferAgent *)_cmdBuff)->destroyMessageQueue();
CC_SAFE_DELETE(_cmdBuff);
@@ -146,7 +146,7 @@ void DeviceAgent::present() {
_frameBoundarySemaphore.Wait();
getMainAllocator()->reset();
for (LinearAllocatorPool **allocatorPools: _allocatorPoolRefs) {
for (LinearAllocatorPool **allocatorPools : _allocatorPoolRefs) {
allocatorPools[_currentIndex]->reset();
}
}
@@ -1,7 +1,7 @@
#pragma once
#include "../gfx/GFXDevice.h"
#include "threading/Semaphore.h"
#include "base/threading/Semaphore.h"
#include "GFXAgent.h"
namespace cc {
@@ -23,40 +23,40 @@ struct SubmitContext final {
class CC_DLL DeviceAgent final : public Agent<Device> {
public:
using Agent::Agent;
~DeviceAgent() override;
virtual bool initialize(const DeviceInfo &info) override;
virtual void destroy() override;
virtual void resize(uint width, uint height) override;
virtual void acquire() override;
virtual void present() override;
bool initialize(const DeviceInfo &info) override;
void destroy() override;
void resize(uint width, uint height) override;
void acquire() override;
void present() override;
virtual CommandBuffer *doCreateCommandBuffer(const CommandBufferInfo &info, bool hasAgent) override;
virtual Fence *createFence() override;
virtual Queue *createQueue() override;
virtual Buffer *createBuffer() override;
virtual Texture *createTexture() override;
virtual Sampler *createSampler() override;
virtual Shader *createShader() override;
virtual InputAssembler *createInputAssembler() override;
virtual RenderPass *createRenderPass() override;
virtual Framebuffer *createFramebuffer() override;
virtual DescriptorSet *createDescriptorSet() override;
virtual DescriptorSetLayout *createDescriptorSetLayout() override;
virtual PipelineLayout *createPipelineLayout() override;
virtual PipelineState *createPipelineState() override;
virtual void copyBuffersToTexture(const uint8_t *const *buffers, Texture *dst, const BufferTextureCopy *regions, uint count) override;
CommandBuffer *doCreateCommandBuffer(const CommandBufferInfo &info, bool hasAgent) override;
Fence *createFence() override;
Queue *createQueue() override;
Buffer *createBuffer() override;
Texture *createTexture() override;
Sampler *createSampler() override;
Shader *createShader() override;
InputAssembler *createInputAssembler() override;
RenderPass *createRenderPass() override;
Framebuffer *createFramebuffer() override;
DescriptorSet *createDescriptorSet() override;
DescriptorSetLayout *createDescriptorSetLayout() override;
PipelineLayout *createPipelineLayout() override;
PipelineState *createPipelineState() override;
void copyBuffersToTexture(const uint8_t *const *buffers, Texture *dst, const BufferTextureCopy *regions, uint count) override;
virtual void setMultithreaded(bool multithreaded) override;
virtual SurfaceTransform getSurfaceTransform() const override { return _actor->getSurfaceTransform(); }
virtual uint getWidth() const override { return _actor->getWidth(); }
virtual uint getHeight() const override { return _actor->getHeight(); }
virtual uint getNativeWidth() const override { return _actor->getNativeWidth(); }
virtual uint getNativeHeight() const override { return _actor->getNativeHeight(); }
virtual MemoryStatus &getMemoryStatus() override { return _actor->getMemoryStatus(); }
virtual uint getNumDrawCalls() const override { return _actor->getNumDrawCalls(); }
virtual uint getNumInstances() const override { return _actor->getNumInstances(); }
virtual uint getNumTris() const override { return _actor->getNumTris(); }
void setMultithreaded(bool multithreaded) override;
SurfaceTransform getSurfaceTransform() const override { return _actor->getSurfaceTransform(); }
uint getWidth() const override { return _actor->getWidth(); }
uint getHeight() const override { return _actor->getHeight(); }
uint getNativeWidth() const override { return _actor->getNativeWidth(); }
uint getNativeHeight() const override { return _actor->getNativeHeight(); }
MemoryStatus &getMemoryStatus() override { return _actor->getMemoryStatus(); }
uint getNumDrawCalls() const override { return _actor->getNumDrawCalls(); }
uint getNumInstances() const override { return _actor->getNumInstances(); }
uint getNumTris() const override { return _actor->getNumTris(); }
MessageQueue *getMessageQueue() const { return _mainEncoder; }
LinearAllocatorPool *getMainAllocator() const { return _allocatorPools[_currentIndex]; }
@@ -1,6 +1,6 @@
#include "CoreStd.h"
#include "threading/MessageQueue.h"
#include "base/threading/MessageQueue.h"
#include "GFXDeviceAgent.h"
#include "GFXFramebufferAgent.h"
#include "GFXRenderPassAgent.h"
@@ -9,6 +9,16 @@
namespace cc {
namespace gfx {
FramebufferAgent::~FramebufferAgent() {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
FramebufferDestruct,
actor, _actor,
{
CC_DELETE(actor);
});
}
bool FramebufferAgent::initialize(const FramebufferInfo &info) {
_renderPass = info.renderPass;
_colorTextures = info.colorTextures;
@@ -38,17 +48,13 @@ bool FramebufferAgent::initialize(const FramebufferInfo &info) {
}
void FramebufferAgent::destroy() {
if (_actor) {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
FramebufferDestroy,
actor, getActor(),
{
CC_DESTROY(actor);
});
_actor = nullptr;
}
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
FramebufferDestroy,
actor, getActor(),
{
actor->destroy();
});
}
} // namespace gfx
@@ -10,9 +10,10 @@ class CC_DLL FramebufferAgent final : public Agent<Framebuffer> {
public:
using Agent::Agent;
FramebufferAgent(Device *device) = delete;
~FramebufferAgent() override;
virtual bool initialize(const FramebufferInfo &info) override;
virtual void destroy() override;
bool initialize(const FramebufferInfo &info) override;
void destroy() override;
};
} // namespace gfx
@@ -1,6 +1,6 @@
#include "CoreStd.h"
#include "threading/MessageQueue.h"
#include "base/threading/MessageQueue.h"
#include "GFXBufferAgent.h"
#include "GFXDeviceAgent.h"
#include "GFXInputAssemblerAgent.h"
@@ -8,6 +8,16 @@
namespace cc {
namespace gfx {
InputAssemblerAgent::~InputAssemblerAgent() {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
InputAssemblerDestruct,
actor, _actor,
{
CC_DELETE(actor);
});
}
bool InputAssemblerAgent::initialize(const InputAssemblerInfo &info) {
_attributes = info.attributes;
_vertexBuffers = info.vertexBuffers;
@@ -48,17 +58,13 @@ bool InputAssemblerAgent::initialize(const InputAssemblerInfo &info) {
}
void InputAssemblerAgent::destroy() {
if (_actor) {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
InputAssemblerDestroy,
actor, getActor(),
{
CC_DESTROY(actor);
});
_actor = nullptr;
}
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
InputAssemblerDestroy,
actor, getActor(),
{
actor->destroy();
});
}
} // namespace gfx
@@ -10,17 +10,18 @@ class CC_DLL InputAssemblerAgent final : public Agent<InputAssembler> {
public:
using Agent::Agent;
InputAssemblerAgent(Device *device) = delete;
~InputAssemblerAgent() override;
virtual bool initialize(const InputAssemblerInfo &info) override;
virtual void destroy() override;
bool initialize(const InputAssemblerInfo &info) override;
void destroy() override;
virtual void setVertexCount(uint count) override { _vertexCount = count; _actor->setVertexCount(count); }
virtual void setFirstVertex(uint first) override { _firstVertex = first; _actor->setFirstVertex(first); }
virtual void setIndexCount(uint count) override { _indexCount = count; _actor->setIndexCount(count); }
virtual void setFirstIndex(uint first) override { _firstIndex = first; _actor->setFirstIndex(first); }
virtual void setVertexOffset(uint offset) override { _vertexOffset = offset; _actor->setVertexOffset(offset); }
virtual void setInstanceCount(uint count) override { _instanceCount = count; _actor->setInstanceCount(count); }
virtual void setFirstInstance(uint first) override { _firstInstance = first; _actor->setFirstInstance(first); }
void setVertexCount(uint count) override { _vertexCount = count; _actor->setVertexCount(count); }
void setFirstVertex(uint first) override { _firstVertex = first; _actor->setFirstVertex(first); }
void setIndexCount(uint count) override { _indexCount = count; _actor->setIndexCount(count); }
void setFirstIndex(uint first) override { _firstIndex = first; _actor->setFirstIndex(first); }
void setVertexOffset(uint offset) override { _vertexOffset = offset; _actor->setVertexOffset(offset); }
void setInstanceCount(uint count) override { _instanceCount = count; _actor->setInstanceCount(count); }
void setFirstInstance(uint first) override { _firstInstance = first; _actor->setFirstInstance(first); }
};
} // namespace gfx
@@ -2,7 +2,7 @@
#include <vector>
#include <algorithm>
#include "threading/ThreadSafeLinearAllocator.h"
#include "base/threading/ThreadSafeLinearAllocator.h"
namespace cc {
namespace gfx {
@@ -26,7 +26,7 @@ public:
LinearAllocatorPool(size_t defaultBlockSize = DEFAULT_BLOCK_SIZE): _defaultBlockSize(defaultBlockSize) {
_allocators.emplace_back(CC_NEW(ThreadSafeLinearAllocator(_defaultBlockSize)));
}
~LinearAllocatorPool() {
for (ThreadSafeLinearAllocator *allocator : _allocators) {
CC_SAFE_DELETE(allocator);
@@ -36,13 +36,15 @@ public:
template<typename T>
T* allocate(const uint count, uint alignment = 64u) noexcept {
if (!count) return nullptr;
T* res = nullptr;
size_t size = count * sizeof(T);
for (ThreadSafeLinearAllocator *allocator : _allocators) {
res = reinterpret_cast<T*>(allocator->Allocate(size, alignment));
if (res) return res;
}
size_t capacity = nextPowerOf2(std::max(DEFAULT_BLOCK_SIZE, size));
size_t capacity = nextPowerOf2(std::max(DEFAULT_BLOCK_SIZE, size + alignment)); // reserve enough padding space for alignment
_allocators.emplace_back(CC_NEW(ThreadSafeLinearAllocator(capacity)));
return reinterpret_cast<T*>(_allocators.back()->Allocate(size, alignment));
}
@@ -1,6 +1,6 @@
#include "CoreStd.h"
#include "threading/MessageQueue.h"
#include "base/threading/MessageQueue.h"
#include "GFXDescriptorSetLayoutAgent.h"
#include "GFXDeviceAgent.h"
#include "GFXPipelineLayoutAgent.h"
@@ -8,6 +8,16 @@
namespace cc {
namespace gfx {
PipelineLayoutAgent::~PipelineLayoutAgent() {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
PipelineLayoutDestruct,
actor, _actor,
{
CC_DELETE(actor);
});
}
bool PipelineLayoutAgent::initialize(const PipelineLayoutInfo &info) {
_setLayouts = info.setLayouts;
@@ -31,17 +41,13 @@ bool PipelineLayoutAgent::initialize(const PipelineLayoutInfo &info) {
}
void PipelineLayoutAgent::destroy() {
if (_actor) {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
PipelineLayoutDestroy,
actor, getActor(),
{
CC_DESTROY(actor);
});
_actor = nullptr;
}
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
PipelineLayoutDestroy,
actor, getActor(),
{
actor->destroy();
});
}
} // namespace gfx
@@ -10,9 +10,10 @@ class CC_DLL PipelineLayoutAgent final : public Agent<PipelineLayout> {
public:
using Agent::Agent;
PipelineLayoutAgent(Device *device) = delete;
~PipelineLayoutAgent() override;
virtual bool initialize(const PipelineLayoutInfo &info) override;
virtual void destroy() override;
bool initialize(const PipelineLayoutInfo &info) override;
void destroy() override;
};
} // namespace gfx
@@ -1,6 +1,6 @@
#include "CoreStd.h"
#include "threading/MessageQueue.h"
#include "base/threading/MessageQueue.h"
#include "GFXDeviceAgent.h"
#include "GFXPipelineLayoutAgent.h"
#include "GFXPipelineStateAgent.h"
@@ -10,6 +10,16 @@
namespace cc {
namespace gfx {
PipelineStateAgent::~PipelineStateAgent() {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
PipelineStateDestruct,
actor, _actor,
{
CC_DELETE(actor);
});
}
bool PipelineStateAgent::initialize(const PipelineStateInfo &info) {
_primitive = info.primitive;
_shader = info.shader;
@@ -39,17 +49,13 @@ bool PipelineStateAgent::initialize(const PipelineStateInfo &info) {
}
void PipelineStateAgent::destroy() {
if (_actor) {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
PipelineStateDestroy,
actor, getActor(),
{
CC_DESTROY(actor);
});
_actor = nullptr;
}
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
PipelineStateDestroy,
actor, getActor(),
{
actor->destroy();
});
}
} // namespace gfx
@@ -10,9 +10,10 @@ class CC_DLL PipelineStateAgent final : public Agent<PipelineState> {
public:
using Agent::Agent;
PipelineStateAgent(Device *device) = delete;
~PipelineStateAgent() override;
virtual bool initialize(const PipelineStateInfo &info) override;
virtual void destroy() override;
bool initialize(const PipelineStateInfo &info) override;
void destroy() override;
};
} // namespace gfx
@@ -4,12 +4,22 @@
#include "GFXDeviceAgent.h"
#include "GFXLinearAllocatorPool.h"
#include "GFXQueueAgent.h"
#include "job-system/JobSystem.h"
#include "threading/MessageQueue.h"
#include "base/job-system/JobSystem.h"
#include "base/threading/MessageQueue.h"
namespace cc {
namespace gfx {
QueueAgent::~QueueAgent() {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
QueueDestruct,
actor, _actor,
{
CC_DELETE(actor);
});
}
bool QueueAgent::initialize(const QueueInfo &info) {
_type = info.type;
@@ -26,17 +36,13 @@ bool QueueAgent::initialize(const QueueInfo &info) {
}
void QueueAgent::destroy() {
if (_actor) {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
QueueDestroy,
actor, getActor(),
{
CC_DESTROY(actor);
});
_actor = nullptr;
}
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
QueueDestroy,
actor, getActor(),
{
actor->destroy();
});
}
void QueueAgent::submit(const CommandBuffer *const *cmdBuffs, uint count, Fence *fence) {
@@ -48,6 +54,11 @@ void QueueAgent::submit(const CommandBuffer *const *cmdBuffs, uint count, Fence
actorCmdBuffs[i] = ((CommandBufferAgent *)cmdBuffs[i])->getActor();
}
const CommandBufferAgent **agentCmdBuffs = allocator->allocate<const CommandBufferAgent *>(count);
for (uint i = 0; i < count; ++i) {
agentCmdBuffs[i] = (CommandBufferAgent *)cmdBuffs[i];
}
bool multiThreaded = _device->hasFeature(Feature::MULTITHREADED_SUBMISSION);
ENQUEUE_MESSAGE_6(
@@ -55,7 +66,7 @@ void QueueAgent::submit(const CommandBuffer *const *cmdBuffs, uint count, Fence
QueueSubmit,
actor, getActor(),
multiThreaded, multiThreaded,
cmdBuffs, (CommandBufferAgent *const *)cmdBuffs,
cmdBuffs, (CommandBufferAgent *const *)agentCmdBuffs,
actorCmdBuffs, actorCmdBuffs,
count, count,
fence, fence,
@@ -12,11 +12,12 @@ public:
using Queue::submit;
QueueAgent(Device *device) = delete;
~QueueAgent() override;
virtual bool initialize(const QueueInfo &info) override;
virtual void destroy() override;
bool initialize(const QueueInfo &info) override;
void destroy() override;
virtual void submit(const CommandBuffer *const *cmdBuffs, uint count, Fence *fence) override;
void submit(const CommandBuffer *const *cmdBuffs, uint count, Fence *fence) override;
};
} // namespace gfx
@@ -1,12 +1,22 @@
#include "CoreStd.h"
#include "threading/MessageQueue.h"
#include "base/threading/MessageQueue.h"
#include "GFXDeviceAgent.h"
#include "GFXRenderPassAgent.h"
namespace cc {
namespace gfx {
RenderPassAgent::~RenderPassAgent(){
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
RenderPassDestruct,
actor, _actor,
{
CC_DELETE(actor);
});
}
bool RenderPassAgent::initialize(const RenderPassInfo &info) {
_colorAttachments = info.colorAttachments;
@@ -27,17 +37,13 @@ bool RenderPassAgent::initialize(const RenderPassInfo &info) {
}
void RenderPassAgent::destroy() {
if (_actor) {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
RenderPassDestroy,
actor, getActor(),
{
CC_DESTROY(actor);
});
_actor = nullptr;
}
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
RenderPassDestroy,
actor, getActor(),
{
actor->destroy();
});
}
} // namespace gfx
@@ -10,9 +10,10 @@ class CC_DLL RenderPassAgent final : public Agent<RenderPass> {
public:
using Agent::Agent;
RenderPassAgent(Device *device) = delete;
~RenderPassAgent() override;
virtual bool initialize(const RenderPassInfo &info) override;
virtual void destroy() override;
bool initialize(const RenderPassInfo &info) override;
void destroy() override;
};
} // namespace gfx
@@ -1,6 +1,6 @@
#include "CoreStd.h"
#include "threading/MessageQueue.h"
#include "base/threading/MessageQueue.h"
#include "GFXDescriptorSetLayoutAgent.h"
#include "GFXDeviceAgent.h"
#include "GFXSamplerAgent.h"
@@ -8,6 +8,16 @@
namespace cc {
namespace gfx {
SamplerAgent::~SamplerAgent() {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
SamplerDestruct,
actor, _actor,
{
CC_DELETE(actor);
});
}
bool SamplerAgent::initialize(const SamplerInfo &info) {
_minFilter = info.minFilter;
@@ -36,17 +46,13 @@ bool SamplerAgent::initialize(const SamplerInfo &info) {
}
void SamplerAgent::destroy() {
if (_actor) {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
SamplerDestroy,
actor, getActor(),
{
CC_DESTROY(actor);
});
_actor = nullptr;
}
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
SamplerDestroy,
actor, getActor(),
{
actor->destroy();
});
}
} // namespace gfx
@@ -10,9 +10,10 @@ class CC_DLL SamplerAgent final : public Agent<Sampler> {
public:
using Agent::Agent;
SamplerAgent(Device *device) = delete;
~SamplerAgent() override;
virtual bool initialize(const SamplerInfo &info) override;
virtual void destroy() override;
bool initialize(const SamplerInfo &info) override;
void destroy() override;
};
} // namespace gfx
@@ -1,12 +1,22 @@
#include "CoreStd.h"
#include "threading/MessageQueue.h"
#include "base/threading/MessageQueue.h"
#include "GFXDeviceAgent.h"
#include "GFXShaderAgent.h"
namespace cc {
namespace gfx {
ShaderAgent::~ShaderAgent() {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
ShaderDestruct,
actor, _actor,
{
CC_DELETE(actor);
});
}
bool ShaderAgent::initialize(const ShaderInfo &info) {
_name = info.name;
_stages = info.stages;
@@ -27,17 +37,13 @@ bool ShaderAgent::initialize(const ShaderInfo &info) {
}
void ShaderAgent::destroy() {
if (_actor) {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
ShaderDestroy,
actor, getActor(),
{
CC_DESTROY(actor);
});
_actor = nullptr;
}
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
ShaderDestroy,
actor, getActor(),
{
actor->destroy();
});
}
} // namespace gfx
@@ -10,9 +10,10 @@ class CC_DLL ShaderAgent final : public Agent<Shader> {
public:
using Agent::Agent;
ShaderAgent(Device *device) = delete;
~ShaderAgent() override;
virtual bool initialize(const ShaderInfo &info) override;
virtual void destroy() override;
bool initialize(const ShaderInfo &info) override;
void destroy() override;
};
} // namespace gfx
@@ -1,12 +1,22 @@
#include "CoreStd.h"
#include "threading/MessageQueue.h"
#include "base/threading/MessageQueue.h"
#include "GFXTextureAgent.h"
#include "GFXDeviceAgent.h"
namespace cc {
namespace gfx {
TextureAgent::~TextureAgent() {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
TextureDestruct,
actor, _actor,
{
CC_DELETE(actor);
});
}
bool TextureAgent::initialize(const TextureInfo &info) {
_type = info.type;
_usage = info.usage;
@@ -66,17 +76,13 @@ bool TextureAgent::initialize(const TextureViewInfo &info) {
}
void TextureAgent::destroy() {
if (_actor) {
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
TextureDestroy,
actor, getActor(),
{
CC_DESTROY(actor);
});
_actor = nullptr;
}
ENQUEUE_MESSAGE_1(
((DeviceAgent *)_device)->getMessageQueue(),
TextureDestroy,
actor, getActor(),
{
actor->destroy();
});
}
void TextureAgent::resize(uint width, uint height) {
@@ -10,11 +10,12 @@ class CC_DLL TextureAgent final : public Agent<Texture> {
public:
using Agent::Agent;
TextureAgent(Device *device) = delete;
~TextureAgent() override;
virtual bool initialize(const TextureInfo &info) override;
virtual bool initialize(const TextureViewInfo &info) override;
virtual void destroy() override;
virtual void resize(uint width, uint height) override;
bool initialize(const TextureInfo &info) override;
bool initialize(const TextureViewInfo &info) override;
void destroy() override;
void resize(uint width, uint height) override;
};
} // namespace gfx
+1 -1
View File
@@ -51,7 +51,7 @@ public:
CC_INLINE PipelineLayout *createPipelineLayout(const PipelineLayoutInfo &info) { PipelineLayout *res = createPipelineLayout(); res->initialize(info); return res; }
CC_INLINE PipelineState *createPipelineState(const PipelineStateInfo &info) { PipelineState *res = createPipelineState(); res->initialize(info); return res; }
CC_INLINE void copyBuffersToTexture(const BufferDataList &buffers, Texture *dst, const BufferTextureCopyList &regions) {
copyBuffersToTexture(buffers.data(), dst, regions.data(), static_cast<uint>(regions.size()) );
copyBuffersToTexture(buffers.data(), dst, regions.data(), static_cast<uint>(regions.size()));
}
virtual void setMultithreaded(bool multithreaded) {}
@@ -69,7 +69,6 @@ public:
CC_INLINE bool isIndirectDrawSupported() const { return _indirectDrawSupported; }
CC_INLINE CCMTLGPUStagingBufferPool *gpuStagingBufferPool() const { return _gpuStagingBufferPools[_currentFrameIndex]; }
CC_INLINE bool isSamplerDescriptorCompareFunctionSupported() const { return _isSamplerDescriptorCompareFunctionSupported; }
CC_INLINE void *getDSSTexture() const { return _dssTex; }
virtual void ensureAutoreleasePool();
@@ -313,10 +313,10 @@ public:
CCVKGPUSwapchain *swapchain = nullptr; // reference
/* *
/* */
using CommandBufferPools = tbb::concurrent_unordered_map<
std::thread::id, CCVKGPUCommandBufferPool *, std::hash<std::thread::id>>;
/* */
/* *
using CommandBufferPools = unordered_map<std::thread::id, CCVKGPUCommandBufferPool *>;
std::mutex mutex;
/* */
+1 -1
View File
@@ -16,7 +16,7 @@ android_flags = -target armv7-none-linux-androideabi -D_LIBCPP_DISABLE_VISIBILIT
clang_headers =
clang_flags = -nostdinc -x c++ -std=c++11 -fsigned-char -U__SSE__
cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/renderer -I%(cocosdir)s/cocos/renderer/core-I%(cocosdir)s/cocos/math -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external/source
cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/renderer -I%(cocosdir)s/cocos/renderer/core-I%(cocosdir)s/cocos/math -I%(cocosdir)s/cocos/platform/android -I%(cocosdir)s/external/sources
cocos_flags = -DANDROID -DCC_PLATFORM=3 -DCC_PLATFORM_MAC_IOS=1 -DCC_PLATFORM_MAC_OSX=4 -DCC_PLATFORM_WINDOWS=2 -DCC_PLATFORM_ANDROID=3