mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
fix the device crach appeared when the device fallback is performed (#11818)
* fix the device crach appeared when the device fallback is performed * Fix crash on SM-9005 (#2) Co-authored-by: James Chen <dumganhar@gmail.com>
This commit is contained in:
@@ -23,11 +23,11 @@
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include <boost/align/align_up.hpp>
|
||||
#include <cstring>
|
||||
#include "base/Log.h"
|
||||
#include "base/threading/MessageQueue.h"
|
||||
#include "base/threading/ThreadSafeLinearAllocator.h"
|
||||
#include <boost/align/align_up.hpp>
|
||||
|
||||
#include "BufferAgent.h"
|
||||
#include "CommandBufferAgent.h"
|
||||
@@ -92,12 +92,16 @@ bool DeviceAgent::doInit(const DeviceInfo &info) {
|
||||
}
|
||||
|
||||
void DeviceAgent::doDestroy() {
|
||||
ENQUEUE_MESSAGE_1(
|
||||
_mainMessageQueue, DeviceDestroy,
|
||||
actor, _actor,
|
||||
{
|
||||
actor->destroy();
|
||||
});
|
||||
if (!_mainMessageQueue) {
|
||||
_actor->destroy();
|
||||
} else {
|
||||
ENQUEUE_MESSAGE_1(
|
||||
_mainMessageQueue, DeviceDestroy,
|
||||
actor, _actor,
|
||||
{
|
||||
actor->destroy();
|
||||
});
|
||||
}
|
||||
|
||||
if (_cmdBuff) {
|
||||
static_cast<CommandBufferAgent *>(_cmdBuff)->destroyAgent();
|
||||
@@ -118,7 +122,7 @@ void DeviceAgent::doDestroy() {
|
||||
|
||||
if (_mainMessageQueue) {
|
||||
_mainMessageQueue->terminateConsumerThread();
|
||||
|
||||
|
||||
// NOTE: C++17 required when enable alignment
|
||||
// TODO(PatriceJiang): replace with: CC_SAFE_DELETE(_mainMessageQueue);
|
||||
_mainMessageQueue->~MessageQueue();
|
||||
@@ -287,10 +291,10 @@ void doBufferTextureCopy(const uint8_t *const *buffers, Texture *texture, const
|
||||
for (uint32_t i = 0U; i < count; i++) {
|
||||
bufferCount += regions[i].texSubres.layerCount;
|
||||
}
|
||||
|
||||
|
||||
Format format = texture->getFormat();
|
||||
constexpr uint32_t alignment = 16;
|
||||
|
||||
|
||||
size_t totalSize = boost::alignment::align_up(sizeof(BufferTextureCopy) * count + sizeof(uint8_t *) * bufferCount, alignment);
|
||||
for (uint32_t i = 0U; i < count; i++) {
|
||||
const BufferTextureCopy ®ion = regions[i];
|
||||
|
||||
@@ -62,9 +62,9 @@ bool Device::initialize(const DeviceInfo &info) {
|
||||
#endif
|
||||
|
||||
bool result = doInit(info);
|
||||
_cmdBuff->addRef();
|
||||
_queue->addRef();
|
||||
|
||||
CC_SAFE_ADD_REF(_cmdBuff);
|
||||
CC_SAFE_ADD_REF(_queue);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user