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

Update Effekseer #100

Merged
merged 5 commits into from
Aug 2, 2023
Merged
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
13 changes: 4 additions & 9 deletions Dev/Cpp/android/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ LOCAL_SRC_FILES := \
$(LOCAL_PATH)/../common/EffekseerPlugin.cpp \
$(LOCAL_PATH)/../common/MemoryFile.cpp \
$(LOCAL_PATH)/../renderer/EffekseerRendererImplemented.cpp \
$(LOCAL_PATH)/../renderer/EffekseerRendererIndexBuffer.cpp \
$(LOCAL_PATH)/../renderer/EffekseerRendererModelLoader.cpp \
$(LOCAL_PATH)/../renderer/EffekseerRendererMaterialLoader.cpp \
$(LOCAL_PATH)/../renderer/EffekseerRendererRenderState.cpp \
$(LOCAL_PATH)/../renderer/EffekseerRendererShader.cpp \
$(LOCAL_PATH)/../renderer/EffekseerRendererTextureLoader.cpp \
$(LOCAL_PATH)/../renderer/EffekseerRendererVertexBuffer.cpp \
$(LOCAL_PATH)/../graphicsAPI/EffekseerPluginGraphics.cpp \
$(LOCAL_PATH)/../graphicsAPI/EffekseerPluginGraphicsUnity.cpp \
$(LOCAL_PATH)/../graphicsAPI/EffekseerPluginGraphicsGL.cpp
Expand Down Expand Up @@ -97,9 +95,10 @@ LOCAL_SRC_FILES += \

LIB_SRC_PATH := $(LOCAL_PATH)/../../Effekseer/Dev/Cpp/EffekseerRendererCommon
LOCAL_SRC_FILES += \
$(LIB_SRC_PATH)/GraphicsDeviceCPU.cpp \
$(LIB_SRC_PATH)/TextureLoader.cpp \
$(LIB_SRC_PATH)/ModelLoader.cpp \
$(LIB_SRC_PATH)/EffekseerRenderer.IndexBufferBase.cpp \
$(LIB_SRC_PATH)/VertexBuffer.cpp \
$(LIB_SRC_PATH)/EffekseerRenderer.ModelRendererBase.cpp \
$(LIB_SRC_PATH)/EffekseerRenderer.Renderer.cpp \
$(LIB_SRC_PATH)/EffekseerRenderer.Renderer_Impl.cpp \
Expand All @@ -108,7 +107,6 @@ LOCAL_SRC_FILES += \
$(LIB_SRC_PATH)/EffekseerRenderer.RingRendererBase.cpp \
$(LIB_SRC_PATH)/EffekseerRenderer.SpriteRendererBase.cpp \
$(LIB_SRC_PATH)/EffekseerRenderer.TrackRendererBase.cpp \
$(LIB_SRC_PATH)/EffekseerRenderer.VertexBufferBase.cpp \
$(LIB_SRC_PATH)/EffekseerRenderer.CommonUtils.cpp \
$(LIB_SRC_PATH)/EffekseerRenderer.DDSTextureLoader.cpp \
$(LIB_SRC_PATH)/EffekseerRenderer.PngTextureLoader.cpp \
Expand All @@ -118,15 +116,12 @@ LIB_SRC_PATH := $(LOCAL_PATH)/../../Effekseer/Dev/Cpp/EffekseerRendererGL/Effeks
LOCAL_SRC_FILES += \
$(LIB_SRC_PATH)/EffekseerRendererGL.DeviceObject.cpp \
$(LIB_SRC_PATH)/EffekseerRendererGL.GLExtension.cpp \
$(LIB_SRC_PATH)/EffekseerRendererGL.IndexBuffer.cpp \
$(LIB_SRC_PATH)/EffekseerRendererGL.ModelRenderer.cpp \
$(LIB_SRC_PATH)/EffekseerRendererGL.GPUTimer.cpp \
$(LIB_SRC_PATH)/EffekseerRendererGL.MaterialLoader.cpp \
$(LIB_SRC_PATH)/EffekseerRendererGL.ModelRenderer.cpp \
$(LIB_SRC_PATH)/EffekseerRendererGL.Renderer.cpp \
$(LIB_SRC_PATH)/EffekseerRendererGL.RenderState.cpp \
$(LIB_SRC_PATH)/EffekseerRendererGL.Shader.cpp \
$(LIB_SRC_PATH)/EffekseerRendererGL.VertexArray.cpp \
$(LIB_SRC_PATH)/EffekseerRendererGL.VertexBuffer.cpp \
$(LIB_SRC_PATH)/EffekseerRendererGL.GPUTimer.cpp \
$(LIB_SRC_PATH)/GraphicsDevice.cpp

include $(BUILD_SHARED_LIBRARY)
56 changes: 39 additions & 17 deletions Dev/Cpp/renderer/EffekseerRendererImplemented.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "EffekseerRendererImplemented.h"
#include "EffekseerRendererIndexBuffer.h"
#include "EffekseerRendererRenderState.h"
#include "EffekseerRendererShader.h"
#include "EffekseerRendererTextureLoader.h"
#include "EffekseerRendererVertexBuffer.h"

#include "GraphicsDeviceCPU.h"

namespace EffekseerPlugin
{
Expand Down Expand Up @@ -387,14 +387,25 @@ RendererImplemented::~RendererImplemented()
{
ES_SAFE_DELETE(m_renderState);
ES_SAFE_DELETE(m_standardRenderer);
ES_SAFE_DELETE(m_vertexBuffer);
// ES_SAFE_DELETE(m_vertexBuffer);
}

bool RendererImplemented::Initialize(int32_t squareMaxCount)
{
m_squareMaxCount = squareMaxCount;
m_renderState = new RenderState();
m_vertexBuffer = new VertexBuffer(EffekseerRenderer::GetMaximumVertexSizeInAllTypes() * m_squareMaxCount * 4, true);
graphicsDevice_ = Effekseer::MakeRefPtr<EffekseerRendererCPU::Backend::GraphicsDevice>();

// generate a vertex buffer
{
GetImpl()->InternalVertexBuffer = std::make_shared<EffekseerRenderer::VertexBufferRing>(
graphicsDevice_, EffekseerRenderer::GetMaximumVertexSizeInAllTypes() * m_squareMaxCount * 4, 1);
if (!GetImpl()->InternalVertexBuffer->GetIsValid())
{
GetImpl()->InternalVertexBuffer = nullptr;
return false;
}
}

unlitShader_ = std::unique_ptr<Shader>(new Shader(EffekseerRenderer::RendererShaderType::Unlit));
backDistortedShader_ = std::unique_ptr<Shader>(new Shader(EffekseerRenderer::RendererShaderType::BackDistortion));
Expand Down Expand Up @@ -500,17 +511,16 @@ ::EffekseerRenderer::DistortingCallback* RendererImplemented::GetDistortingCallb

void RendererImplemented::SetDistortingCallback(::EffekseerRenderer::DistortingCallback* callback) {}

VertexBuffer* RendererImplemented::GetVertexBuffer() { return m_vertexBuffer; }

IndexBuffer* RendererImplemented::GetIndexBuffer() { return nullptr; }

EffekseerRenderer::StandardRenderer<RendererImplemented, Shader>* RendererImplemented::GetStandardRenderer() { return m_standardRenderer; }

::EffekseerRenderer::RenderStateBase* RendererImplemented::GetRenderState() { return m_renderState; }

void RendererImplemented::SetVertexBuffer(VertexBuffer* vertexBuffer, int32_t size) {}
void RendererImplemented::SetVertexBuffer(const Effekseer::Backend::VertexBufferRef& vertexBuffer, int32_t size)
{
vertexBuffer_ = vertexBuffer;
}

void RendererImplemented::SetIndexBuffer(IndexBuffer* indexBuffer) {}
void RendererImplemented::SetIndexBuffer(const Effekseer::Backend::IndexBufferRef& indexBuffer) {}

void RendererImplemented::SetLayout(Shader* shader) {}

Expand Down Expand Up @@ -621,7 +631,7 @@ void RendererImplemented::DrawSprites(int32_t spriteCount, int32_t vertexOffset)
const auto& nativeMaterial = m_currentShader->GetMaterial();
assert(!nativeMaterial->GetIsSimpleVertex());

auto* origin = (uint8_t*)m_vertexBuffer->GetResource();
auto origin = const_cast<uint8_t*>(vertexBuffer_.DownCast<EffekseerRendererCPU::Backend::VertexBuffer>()->GetBuffer().data());

int32_t customDataStride = (nativeMaterial->GetCustomData1Count() + nativeMaterial->GetCustomData2Count()) * sizeof(float);

Expand Down Expand Up @@ -721,7 +731,9 @@ void RendererImplemented::DrawSprites(int32_t spriteCount, int32_t vertexOffset)

if (m_currentShader->GetType() == EffekseerRenderer::RendererShaderType::BackDistortion)
{
auto vs = (DynamicVertex*)m_vertexBuffer->GetResource();
auto vs = reinterpret_cast<DynamicVertex*>(
const_cast<uint8_t*>(vertexBuffer_.DownCast<EffekseerRendererCPU::Backend::VertexBuffer>()->GetBuffer().data()));

for (int32_t vi = vertexOffset; vi < vertexOffset + spriteCount * 4; vi++)
{
auto& v = vs[vi];
Expand All @@ -730,7 +742,9 @@ void RendererImplemented::DrawSprites(int32_t spriteCount, int32_t vertexOffset)
}
else
{
auto vs = (EffekseerRenderer::AdvancedLightingVertex*)m_vertexBuffer->GetResource();
auto vs = reinterpret_cast<EffekseerRenderer::AdvancedLightingVertex*>(
const_cast<uint8_t*>(vertexBuffer_.DownCast<EffekseerRendererCPU::Backend::VertexBuffer>()->GetBuffer().data()));

for (int32_t vi = vertexOffset; vi < vertexOffset + spriteCount * 4; vi++)
{
auto& v = vs[vi];
Expand Down Expand Up @@ -767,7 +781,9 @@ void RendererImplemented::DrawSprites(int32_t spriteCount, int32_t vertexOffset)

if (m_currentShader->GetType() == EffekseerRenderer::RendererShaderType::Lit)
{
auto vs = (DynamicVertex*)m_vertexBuffer->GetResource();
auto vs = reinterpret_cast<DynamicVertex*>(
const_cast<uint8_t*>(vertexBuffer_.DownCast<EffekseerRendererCPU::Backend::VertexBuffer>()->GetBuffer().data()));

for (int32_t vi = vertexOffset; vi < vertexOffset + spriteCount * 4; vi++)
{
auto& v = vs[vi];
Expand All @@ -776,7 +792,9 @@ void RendererImplemented::DrawSprites(int32_t spriteCount, int32_t vertexOffset)
}
else
{
auto vs = (EffekseerRenderer::AdvancedLightingVertex*)m_vertexBuffer->GetResource();
auto vs = reinterpret_cast<EffekseerRenderer::AdvancedLightingVertex*>(
const_cast<uint8_t*>(vertexBuffer_.DownCast<EffekseerRendererCPU::Backend::VertexBuffer>()->GetBuffer().data()));

for (int32_t vi = vertexOffset; vi < vertexOffset + spriteCount * 4; vi++)
{
auto& v = vs[vi];
Expand Down Expand Up @@ -811,7 +829,9 @@ void RendererImplemented::DrawSprites(int32_t spriteCount, int32_t vertexOffset)

if (m_currentShader->GetType() == EffekseerRenderer::RendererShaderType::Unlit)
{
auto vs = (Vertex*)m_vertexBuffer->GetResource();
auto vs = reinterpret_cast<Vertex*>(
const_cast<uint8_t*>(vertexBuffer_.DownCast<EffekseerRendererCPU::Backend::VertexBuffer>()->GetBuffer().data()));

for (int32_t vi = vertexOffset; vi < vertexOffset + spriteCount * 4; vi++)
{
const auto& v = vs[vi];
Expand All @@ -820,7 +840,9 @@ void RendererImplemented::DrawSprites(int32_t spriteCount, int32_t vertexOffset)
}
else
{
auto vs = (EffekseerRenderer::AdvancedSimpleVertex*)m_vertexBuffer->GetResource();
auto vs = reinterpret_cast<EffekseerRenderer::AdvancedSimpleVertex*>(
const_cast<uint8_t*>(vertexBuffer_.DownCast<EffekseerRendererCPU::Backend::VertexBuffer>()->GetBuffer().data()));

for (int32_t vi = vertexOffset; vi < vertexOffset + spriteCount * 4; vi++)
{
const auto& v = vs[vi];
Expand Down
12 changes: 5 additions & 7 deletions Dev/Cpp/renderer/EffekseerRendererImplemented.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ class RendererImplemented : public ::EffekseerRenderer::Renderer, public ::Effek

protected:
int32_t m_squareMaxCount = 0;

VertexBuffer* m_vertexBuffer = nullptr;
Effekseer::Backend::GraphicsDeviceRef graphicsDevice_ = nullptr;
Effekseer::Backend::VertexBufferRef vertexBuffer_ = nullptr;

std::unique_ptr<Shader> unlitShader_;
std::unique_ptr<Shader> backDistortedShader_;
Expand Down Expand Up @@ -398,16 +398,14 @@ class RendererImplemented : public ::EffekseerRenderer::Renderer, public ::Effek
*/
void SetDistortingCallback(::EffekseerRenderer::DistortingCallback* callback) override;

VertexBuffer* GetVertexBuffer();

IndexBuffer* GetIndexBuffer();
Effekseer::Backend::IndexBufferRef GetIndexBuffer() { return nullptr; }

EffekseerRenderer::StandardRenderer<RendererImplemented, Shader>* GetStandardRenderer();

::EffekseerRenderer::RenderStateBase* GetRenderState();

void SetVertexBuffer(VertexBuffer* vertexBuffer, int32_t size);
void SetIndexBuffer(IndexBuffer* indexBuffer);
void SetVertexBuffer(const Effekseer::Backend::VertexBufferRef& vertexBuffer, int32_t size);
void SetIndexBuffer(const Effekseer::Backend::IndexBufferRef& indexBuffer);

void SetLayout(Shader* shader);
void DrawSprites(int32_t spriteCount, int32_t vertexOffset);
Expand Down
2 changes: 0 additions & 2 deletions Dev/Cpp/renderer/EffekseerRendererIndexBuffer.cpp

This file was deleted.

17 changes: 0 additions & 17 deletions Dev/Cpp/renderer/EffekseerRendererIndexBuffer.h

This file was deleted.

75 changes: 0 additions & 75 deletions Dev/Cpp/renderer/EffekseerRendererVertexBuffer.cpp

This file was deleted.

31 changes: 0 additions & 31 deletions Dev/Cpp/renderer/EffekseerRendererVertexBuffer.h

This file was deleted.

2 changes: 1 addition & 1 deletion Dev/Effekseer
Submodule Effekseer updated 319 files
Loading