mirror of https://github.com/auygun/kaliber.git
Add separate gn configs for renderer, audio and platform
This commit is contained in:
parent
5e80aa1a04
commit
d779d17b3d
|
@ -14,15 +14,6 @@ source_set("engine") {
|
|||
"asset/shader_source.h",
|
||||
"asset/sound.cc",
|
||||
"asset/sound.h",
|
||||
"audio/audio_bus.cc",
|
||||
"audio/audio_bus.h",
|
||||
"audio/audio_mixer.cc",
|
||||
"audio/audio_mixer.h",
|
||||
"audio/audio_sink.h",
|
||||
"audio/mixer_input.cc",
|
||||
"audio/mixer_input.h",
|
||||
"audio/sinc_resampler.cc",
|
||||
"audio/sinc_resampler.h",
|
||||
"drawable.cc",
|
||||
"drawable.h",
|
||||
"engine.cc",
|
||||
|
@ -34,111 +25,21 @@ source_set("engine") {
|
|||
"input_event.h",
|
||||
"persistent_data.cc",
|
||||
"persistent_data.h",
|
||||
"platform/asset_file.cc",
|
||||
"platform/asset_file.h",
|
||||
"platform/platform.h",
|
||||
"platform/platform_observer.h",
|
||||
"renderer/geometry.cc",
|
||||
"renderer/geometry.h",
|
||||
"renderer/opengl/opengl.h",
|
||||
"renderer/opengl/renderer_opengl.cc",
|
||||
"renderer/opengl/renderer_opengl.h",
|
||||
"renderer/render_resource.h",
|
||||
"renderer/renderer.h",
|
||||
"renderer/renderer_types.cc",
|
||||
"renderer/renderer_types.h",
|
||||
"renderer/shader.cc",
|
||||
"renderer/shader.h",
|
||||
"renderer/texture.cc",
|
||||
"renderer/texture.h",
|
||||
"renderer/vulkan/renderer_vulkan.cc",
|
||||
"renderer/vulkan/vulkan_context.cc",
|
||||
"solid_quad.cc",
|
||||
"solid_quad.h",
|
||||
"sound_player.cc",
|
||||
"sound_player.h",
|
||||
]
|
||||
|
||||
libs = []
|
||||
|
||||
if (target_os == "linux" || target_os == "win") {
|
||||
sources += [ "platform/asset_file_generic.cc" ]
|
||||
}
|
||||
|
||||
if (target_os == "linux") {
|
||||
sources += [
|
||||
"audio/audio_sink_alsa.cc",
|
||||
"audio/audio_sink_alsa.h",
|
||||
"platform/platform_linux.cc",
|
||||
"renderer/opengl/renderer_opengl_linux.cc",
|
||||
"renderer/vulkan/renderer_vulkan_linux.cc",
|
||||
"renderer/vulkan/vulkan_context_linux.cc",
|
||||
]
|
||||
|
||||
libs += [
|
||||
"X11",
|
||||
"GL",
|
||||
"asound",
|
||||
]
|
||||
}
|
||||
|
||||
if (target_os == "win") {
|
||||
sources += [
|
||||
"audio/audio_sink_null.h",
|
||||
"platform/platform_win.cc",
|
||||
"renderer/opengl/renderer_opengl_win.cc",
|
||||
"renderer/vulkan/renderer_vulkan_win.cc",
|
||||
"renderer/vulkan/vulkan_context_win.cc",
|
||||
]
|
||||
|
||||
libs = [
|
||||
"gdi32.lib", # Graphics
|
||||
"user32.lib", # Win32 API core functionality.
|
||||
"opengl32.lib",
|
||||
]
|
||||
}
|
||||
|
||||
if (target_os == "android") {
|
||||
sources += [
|
||||
"audio/audio_sink_oboe.cc",
|
||||
"audio/audio_sink_oboe.h",
|
||||
"platform/asset_file_android.cc",
|
||||
"platform/platform_android.cc",
|
||||
"renderer/opengl/renderer_opengl_android.cc",
|
||||
"renderer/vulkan/renderer_vulkan_android.cc",
|
||||
"renderer/vulkan/vulkan_context_android.cc",
|
||||
]
|
||||
|
||||
libs += [
|
||||
"android",
|
||||
"EGL",
|
||||
"GLESv2",
|
||||
"log",
|
||||
"z",
|
||||
]
|
||||
}
|
||||
|
||||
deps = [
|
||||
"//assets/engine",
|
||||
"//src/base",
|
||||
"//src/third_party/glslang",
|
||||
"//src/engine/audio",
|
||||
"//src/engine/platform",
|
||||
"//src/engine/renderer",
|
||||
"//src/third_party/jsoncpp",
|
||||
"//src/third_party/minimp3",
|
||||
"//src/third_party/spirv-reflect",
|
||||
"//src/third_party/stb",
|
||||
"//src/third_party/texture_compressor",
|
||||
"//src/third_party/vma",
|
||||
"//src/third_party/vulkan",
|
||||
"//src/third_party/volk",
|
||||
]
|
||||
|
||||
if (target_os == "android") {
|
||||
deps += [
|
||||
"//src/third_party/android",
|
||||
"//src/third_party/oboe",
|
||||
"//src/third_party/minizip",
|
||||
]
|
||||
} else {
|
||||
deps += [ "//src/third_party/glew" ]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
source_set("audio") {
|
||||
sources = [
|
||||
"audio_bus.cc",
|
||||
"audio_bus.h",
|
||||
"audio_mixer.cc",
|
||||
"audio_mixer.h",
|
||||
"audio_sink.h",
|
||||
"mixer_input.cc",
|
||||
"mixer_input.h",
|
||||
"sinc_resampler.cc",
|
||||
"sinc_resampler.h",
|
||||
]
|
||||
|
||||
libs = []
|
||||
deps = [ "//src/base" ]
|
||||
|
||||
if (target_os == "linux") {
|
||||
sources += [
|
||||
"audio_sink_alsa.cc",
|
||||
"audio_sink_alsa.h",
|
||||
]
|
||||
libs += [ "asound" ]
|
||||
} else if (target_os == "win") {
|
||||
sources += [ "audio_sink_null.h" ]
|
||||
} else if (target_os == "android") {
|
||||
sources += [
|
||||
"audio_sink_oboe.cc",
|
||||
"audio_sink_oboe.h",
|
||||
]
|
||||
deps += [ "//src/third_party/oboe" ]
|
||||
}
|
||||
}
|
|
@ -17,11 +17,9 @@
|
|||
#include "engine/input_event.h"
|
||||
#include "engine/platform/platform.h"
|
||||
#include "engine/renderer/geometry.h"
|
||||
#include "engine/renderer/opengl/renderer_opengl.h"
|
||||
#include "engine/renderer/renderer.h"
|
||||
#include "engine/renderer/shader.h"
|
||||
#include "engine/renderer/texture.h"
|
||||
#include "engine/renderer/vulkan/renderer_vulkan.h"
|
||||
#include "third_party/texture_compressor/texture_compressor.h"
|
||||
|
||||
using namespace base;
|
||||
|
@ -554,22 +552,10 @@ void Engine::AddInputEvent(std::unique_ptr<InputEvent> event) {
|
|||
}
|
||||
|
||||
void Engine::CreateRendererInternal(RendererType type) {
|
||||
if ((dynamic_cast<RendererVulkan*>(renderer_.get()) &&
|
||||
type == RendererType::kVulkan) ||
|
||||
(dynamic_cast<RendererOpenGL*>(renderer_.get()) &&
|
||||
type == RendererType::kOpenGL))
|
||||
if (renderer_ && renderer_->GetRendererType() == type)
|
||||
return;
|
||||
|
||||
if (type == RendererType::kVulkan) {
|
||||
renderer_ =
|
||||
std::make_unique<RendererVulkan>(std::bind(&Engine::ContextLost, this));
|
||||
} else if (type == RendererType::kOpenGL) {
|
||||
renderer_ =
|
||||
std::make_unique<RendererOpenGL>(std::bind(&Engine::ContextLost, this));
|
||||
} else {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
renderer_ = Renderer::Create(type, std::bind(&Engine::ContextLost, this));
|
||||
bool result = renderer_->Initialize(platform_);
|
||||
if (!result && type == RendererType::kVulkan) {
|
||||
LOG(0) << "Failed to initialize " << renderer_->GetDebugName()
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
source_set("platform") {
|
||||
sources = [
|
||||
"asset_file.cc",
|
||||
"asset_file.h",
|
||||
"platform.h",
|
||||
"platform_observer.h",
|
||||
]
|
||||
|
||||
libs = []
|
||||
deps = [ "//src/base" ]
|
||||
|
||||
if (target_os == "linux" || target_os == "win") {
|
||||
sources += [ "asset_file_generic.cc" ]
|
||||
}
|
||||
|
||||
if (target_os == "linux") {
|
||||
sources += [ "platform_linux.cc" ]
|
||||
libs += [
|
||||
"X11",
|
||||
"GL",
|
||||
]
|
||||
} else if (target_os == "win") {
|
||||
sources += [ "platform_win.cc" ]
|
||||
libs = [
|
||||
"gdi32.lib", # Graphics
|
||||
"user32.lib", # Win32 API core functionality.
|
||||
"opengl32.lib",
|
||||
]
|
||||
} else if (target_os == "android") {
|
||||
sources += [
|
||||
"asset_file_android.cc",
|
||||
"platform_android.cc",
|
||||
]
|
||||
libs += [
|
||||
"android",
|
||||
"EGL",
|
||||
"GLESv3",
|
||||
"log",
|
||||
"z",
|
||||
]
|
||||
deps += [
|
||||
"//src/third_party/android",
|
||||
"//src/third_party/minizip",
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
source_set("renderer") {
|
||||
sources = [
|
||||
"geometry.cc",
|
||||
"geometry.h",
|
||||
"opengl/opengl.h",
|
||||
"opengl/renderer_opengl.cc",
|
||||
"opengl/renderer_opengl.h",
|
||||
"render_resource.h",
|
||||
"renderer.cc",
|
||||
"renderer.h",
|
||||
"renderer_types.cc",
|
||||
"renderer_types.h",
|
||||
"shader.cc",
|
||||
"shader.h",
|
||||
"texture.cc",
|
||||
"texture.h",
|
||||
"vulkan/renderer_vulkan.cc",
|
||||
"vulkan/vulkan_context.cc",
|
||||
]
|
||||
|
||||
if (target_os == "linux") {
|
||||
sources += [
|
||||
"opengl/renderer_opengl_linux.cc",
|
||||
"vulkan/renderer_vulkan_linux.cc",
|
||||
"vulkan/vulkan_context_linux.cc",
|
||||
]
|
||||
} else if (target_os == "win") {
|
||||
sources += [
|
||||
"opengl/renderer_opengl_win.cc",
|
||||
"vulkan/renderer_vulkan_win.cc",
|
||||
"vulkan/vulkan_context_win.cc",
|
||||
]
|
||||
} else if (target_os == "android") {
|
||||
sources += [
|
||||
"opengl/renderer_opengl_android.cc",
|
||||
"vulkan/renderer_vulkan_android.cc",
|
||||
"vulkan/vulkan_context_android.cc",
|
||||
]
|
||||
}
|
||||
|
||||
deps = [
|
||||
"//src/base",
|
||||
"//src/third_party/glslang",
|
||||
"//src/third_party/spirv-reflect",
|
||||
"//src/third_party/vma",
|
||||
"//src/third_party/volk",
|
||||
"//src/third_party/vulkan",
|
||||
]
|
||||
|
||||
if (target_os == "android") {
|
||||
deps += [ "//src/third_party/android" ]
|
||||
} else {
|
||||
deps += [ "//src/third_party/glew" ]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
#include "engine/renderer/renderer.h"
|
||||
|
||||
#include "base/log.h"
|
||||
#include "engine/renderer/opengl/renderer_opengl.h"
|
||||
#include "engine/renderer/vulkan/renderer_vulkan.h"
|
||||
|
||||
namespace eng {
|
||||
|
||||
// static
|
||||
std::unique_ptr<Renderer> Renderer::Create(RendererType type,
|
||||
base::Closure context_lost_cb) {
|
||||
std::unique_ptr<Renderer> renderer;
|
||||
if (type == RendererType::kVulkan) {
|
||||
renderer = std::make_unique<RendererVulkan>(std::move(context_lost_cb));
|
||||
} else if (type == RendererType::kOpenGL) {
|
||||
renderer = std::make_unique<RendererOpenGL>(std::move(context_lost_cb));
|
||||
} else {
|
||||
NOTREACHED();
|
||||
}
|
||||
return renderer;
|
||||
}
|
||||
|
||||
} // namespace eng
|
|
@ -21,6 +21,9 @@ class Renderer {
|
|||
public:
|
||||
const unsigned kInvalidId = 0;
|
||||
|
||||
static std::unique_ptr<Renderer> Create(RendererType type,
|
||||
base::Closure context_lost_cb);
|
||||
|
||||
Renderer(base::Closure context_lost_cb)
|
||||
: context_lost_cb_{std::move(context_lost_cb)} {}
|
||||
virtual ~Renderer() = default;
|
||||
|
|
Loading…
Reference in New Issue