Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactors and fix potential memory leak #58

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Effect/CubismPose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ CubismPose::PartData::~PartData()
CubismPose::PartData::PartData(const PartData& v)
: ParameterIndex(0)
, PartIndex(0)
, PartId(v.PartId)
{
PartId = v.PartId;

for (csmVector<PartData>::const_iterator ite = v.Link.Begin(); ite != v.Link.End(); ++ite)
{
Link.PushBack(*ite);
Expand Down
5 changes: 2 additions & 3 deletions src/Id/CubismId.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ CubismId::CubismId(const CubismId& c)
{ }

CubismId::CubismId(const csmChar* id)
{
_id = id;
}
: _id(id)
{ }

CubismId::~CubismId()
{ }
Expand Down
5 changes: 2 additions & 3 deletions src/Math/CubismModelMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ CubismModelMatrix::CubismModelMatrix()
{ }

CubismModelMatrix::CubismModelMatrix(csmFloat32 w, csmFloat32 h)
: _width(w)
, _height(h)
{
_width = w;
_height = h;

SetHeight(2.0f);
}

Expand Down
3 changes: 0 additions & 3 deletions src/Motion/CubismExpressionMotionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,6 @@ csmBool CubismExpressionMotionManager::UpdateMotion(CubismModel* model, csmFloat
// ----- 最新のExpressionのフェードが完了していればそれ以前を削除する ------
if (motions->GetSize() > 1)
{
CubismExpressionMotion* expressionMotion =
(CubismExpressionMotion*)(motions->At(motions->GetSize() - 1))->GetCubismMotion();

csmFloat32 latestFadeWeight = _fadeWeights[_fadeWeights.GetSize() - 1];
if (latestFadeWeight >= 1.0f)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Motion/CubismMotionQueueManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ csmBool CubismMotionQueueManager::IsFinished(CubismMotionQueueEntryHandle motion
{
// 既にモーションがあれば終了フラグを立てる

for (csmVector<CubismMotionQueueEntry*>::iterator ite = _motions.Begin(); ite != _motions.End(); ite++)
for (csmVector<CubismMotionQueueEntry*>::iterator ite = _motions.Begin(); ite != _motions.End(); ++ite)
{
CubismMotionQueueEntry* motionQueueEntry = *ite;

Expand Down
2 changes: 1 addition & 1 deletion src/Physics/CubismPhysics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,13 +442,13 @@ void UpdateOutputParameterValue(csmFloat32* parameterValue, csmFloat32 parameter

CubismPhysics::CubismPhysics()
: _physicsRig(NULL)
, _currentRemainTime(0.0f)
{
// set default options.
_options.Gravity.Y = -1.0f;
_options.Gravity.X = 0;
_options.Wind.X = 0;
_options.Wind.Y = 0;
_currentRemainTime = 0.0f;
}

CubismPhysics::~CubismPhysics()
Expand Down
21 changes: 7 additions & 14 deletions src/Rendering/CubismRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,13 @@ csmBool CubismRenderer::IsUsingHighPrecisionMask()
* CubismClippingContext
********************************************************************************************************************/
CubismClippingContext::CubismClippingContext(const csmInt32* clippingDrawableIndices, csmInt32 clipCount)
{
// クリップしている(=マスク用の)Drawableのインデックスリスト
_clippingIdList = clippingDrawableIndices;

// マスクの数
_clippingIdCount = clipCount;

_layoutChannelIndex = 0;

_allClippedDrawRect = CSM_NEW csmRectF();
_layoutBounds = CSM_NEW csmRectF();

_clippedDrawableIndexList = CSM_NEW csmVector<csmInt32>();
}
: _clippingIdList(clippingDrawableIndices)
, _clippingIdCount(clipCount)
, _layoutChannelIndex(0)
, _allClippedDrawRect(CSM_NEW csmRectF())
, _layoutBounds(CSM_NEW csmRectF())
, _clippedDrawableIndexList(CSM_NEW csmVector<csmInt32>())
{ }

CubismClippingContext::~CubismClippingContext()
{
Expand Down
5 changes: 2 additions & 3 deletions src/Rendering/D3D11/CubismRenderer_D3D11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,9 @@ CubismRenderer_D3D11::CubismRenderer_D3D11()
, _clippingManager(NULL)
, _clippingContextBufferForMask(NULL)
, _clippingContextBufferForDraw(NULL)
, _commandBufferNum(0)
, _commandBufferCurrent(0)
{
_commandBufferNum = 0;
_commandBufferCurrent = 0;

// テクスチャ対応マップの容量を確保しておく.
_textures.PrepareCapacity(32, true);
}
Expand Down
5 changes: 2 additions & 3 deletions src/Rendering/D3D9/CubismRenderer_D3D9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,9 @@ CubismRenderer_D3D9::CubismRenderer_D3D9()
, _clippingManager(NULL)
, _clippingContextBufferForMask(NULL)
, _clippingContextBufferForDraw(NULL)
, _commandBufferNum(0)
, _commandBufferCurrent(0)
{
_commandBufferNum = 0;
_commandBufferCurrent = 0;

// テクスチャ対応マップの容量を確保しておく.
_textures.PrepareCapacity(32, true);
}
Expand Down
1 change: 0 additions & 1 deletion src/Rendering/Vulkan/CubismClass_Vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ void CubismImageVulkan::SetImageLayout(VkCommandBuffer commandBuffer, VkImageLay

case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
destinationStage = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
destinationStage = VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR;
break;

Expand Down
4 changes: 4 additions & 0 deletions src/Rendering/Vulkan/CubismOffscreenSurface_Vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ void CubismOffscreenSurface_Vulkan::CreateOffscreenSurface(
csmUint32 displayBufferWidth, csmUint32 displayBufferHeight,
VkFormat surfaceFormat, VkFormat depthFormat)
{
if (_colorImage != nullptr) {
vkFreeMemory(device, _colorImage, nullptr);
}

_colorImage = new CubismImageVulkan;
_colorImage->CreateImage(device, physicalDevice, displayBufferWidth, displayBufferHeight,
1, surfaceFormat, VK_IMAGE_TILING_OPTIMAL,
Expand Down
2 changes: 1 addition & 1 deletion src/Rendering/Vulkan/CubismRenderer_Vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ VkShaderModule CubismPipeline_Vulkan::PipelineResource::CreateShaderModule(VkDev
return shaderModule;
}

void CubismPipeline_Vulkan::PipelineResource::CreateGraphicsPipeline(std::string vertFileName, std::string fragFileName,
void CubismPipeline_Vulkan::PipelineResource::CreateGraphicsPipeline(const std::string vertFileName, const std::string fragFileName,
VkDescriptorSetLayout descriptorSetLayout)
{
VkShaderModule vertShaderModule = CreateShaderModule(s_device, vertFileName);
Expand Down