Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
5c8b690d66
11 changed files with 64 additions and 82 deletions
|
@ -76,6 +76,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||||
|
|
||||||
set(ENABLE_WINDOWS TRUE)
|
set(ENABLE_WINDOWS TRUE)
|
||||||
set(ENABLE_VULKAN TRUE)
|
set(ENABLE_VULKAN TRUE)
|
||||||
|
set(ENABLE_DX12 TRUE)
|
||||||
|
|
||||||
set(NEEDS_HOSTED_SHADER_COMPILER FALSE)
|
set(NEEDS_HOSTED_SHADER_COMPILER FALSE)
|
||||||
set(REQUIRED_SHADER_LANGUAGE "spirv")
|
set(REQUIRED_SHADER_LANGUAGE "spirv")
|
||||||
|
|
|
@ -29,4 +29,12 @@ macro(set_engine_properties target)
|
||||||
if(ENABLE_METAL)
|
if(ENABLE_METAL)
|
||||||
target_compile_definitions(${target} PUBLIC ENABLE_METAL)
|
target_compile_definitions(${target} PUBLIC ENABLE_METAL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_WEBGPU)
|
||||||
|
target_compile_definitions(${target} PUBLIC ENABLE_WEBGPU)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_DX12)
|
||||||
|
target_compile_definitions(${target} PUBLIC ENABLE_DX12)
|
||||||
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
|
@ -234,7 +234,7 @@ void imgui_backend::begin_frame(const float delta_time) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for(const auto& dir_ent : std::filesystem::directory_iterator(data.current_path)) {
|
for(const auto& dir_ent : std::filesystem::directory_iterator(data.current_path)) {
|
||||||
if(ImGui::Selectable(dir_ent.path().c_str(), data.selected_path == dir_ent.path(), ImGuiSelectableFlags_DontClosePopups)) {
|
if(ImGui::Selectable(dir_ent.path().string().c_str(), data.selected_path == dir_ent.path(), ImGuiSelectableFlags_DontClosePopups)) {
|
||||||
if(dir_ent.is_directory())
|
if(dir_ent.is_directory())
|
||||||
data.current_path = dir_ent.path();
|
data.current_path = dir_ent.path();
|
||||||
else
|
else
|
||||||
|
|
|
@ -33,4 +33,4 @@ endif()
|
||||||
|
|
||||||
if(ENABLE_WEBGPU)
|
if(ENABLE_WEBGPU)
|
||||||
add_subdirectory(webgpu)
|
add_subdirectory(webgpu)
|
||||||
endif()
|
endif()
|
|
@ -1,3 +1,3 @@
|
||||||
add_library(GFXDX12 STATIC src/gfx_dummy.cpp)
|
add_library(GFXDX12 STATIC src/gfx_dx12.cpp)
|
||||||
target_include_directories(GFXDX12 PUBLIC include)
|
target_include_directories(GFXDX12 PUBLIC include)
|
||||||
target_link_libraries(GFXDX12 PUBLIC GFX)
|
target_link_libraries(GFXDX12 PUBLIC GFX)
|
|
@ -1,30 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "gfx.hpp"
|
|
||||||
|
|
||||||
class GFXDummy : public GFX {
|
|
||||||
public:
|
|
||||||
bool initialize() override;
|
|
||||||
void initializeView(void* native_handle, uint32_t width, uint32_t height) override;
|
|
||||||
|
|
||||||
// buffer operations
|
|
||||||
GFXBuffer* createBuffer(void* data, GFXSize size, GFXBufferUsage usage) override;
|
|
||||||
void copyBuffer(GFXBuffer* buffer, void* data, GFXSize offset, GFXSize size) override;
|
|
||||||
|
|
||||||
// texture operations
|
|
||||||
GFXTexture* createTexture(uint32_t width, uint32_t height, GFXPixelFormat format, GFXStorageMode storageMode, GFXTextureUsage usage) override;
|
|
||||||
void copyTexture(GFXTexture* texture, void* data, GFXSize size) override;
|
|
||||||
|
|
||||||
// framebuffer operations
|
|
||||||
GFXFramebuffer* createFramebuffer(GFXFramebufferCreateInfo& info) override;
|
|
||||||
|
|
||||||
// render pass operations
|
|
||||||
GFXRenderPass* createRenderPass(GFXRenderPassCreateInfo& info) override;
|
|
||||||
|
|
||||||
// pipeline operations
|
|
||||||
GFXPipeline* createPipeline(GFXPipelineCreateInfo& info) override;
|
|
||||||
|
|
||||||
void render(GFXCommandBuffer* command_buffer) override;
|
|
||||||
|
|
||||||
const char* getName() override;
|
|
||||||
};
|
|
13
engine/gfx/dx12/include/gfx_dx12.hpp
Executable file
13
engine/gfx/dx12/include/gfx_dx12.hpp
Executable file
|
@ -0,0 +1,13 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "gfx.hpp"
|
||||||
|
|
||||||
|
class gfx_dx12 : public GFX {
|
||||||
|
public:
|
||||||
|
bool is_supported() override { return true; }
|
||||||
|
ShaderLanguage accepted_shader_language() override { return ShaderLanguage::HLSL; }
|
||||||
|
GFXContext required_context() override { return GFXContext::DirectX; }
|
||||||
|
bool initialize(const GFXCreateInfo& info) override;
|
||||||
|
|
||||||
|
const char* get_name() override;
|
||||||
|
};
|
|
@ -1,46 +0,0 @@
|
||||||
#include "gfx_dummy.hpp"
|
|
||||||
|
|
||||||
bool GFXDummy::initialize() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GFXDummy::initializeView(void* native_handle, uint32_t width, uint32_t height) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GFXBuffer* GFXDummy::createBuffer(void* data, GFXSize size, GFXBufferUsage usage) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GFXDummy::copyBuffer(GFXBuffer* buffer, void* data, GFXSize offset, GFXSize size) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GFXTexture* GFXDummy::createTexture(uint32_t width, uint32_t height, GFXPixelFormat format, GFXStorageMode storageMode, GFXTextureUsage usage) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GFXDummy::copyTexture(GFXTexture* texture, void* data, GFXSize size) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
GFXFramebuffer* GFXDummy::createFramebuffer(GFXFramebufferCreateInfo& info) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
GFXRenderPass* GFXDummy::createRenderPass(GFXRenderPassCreateInfo& info) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
GFXPipeline* GFXDummy::createPipeline(GFXPipelineCreateInfo& info) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GFXDummy::render(GFXCommandBuffer* command_buffer) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* GFXDummy::getName() {
|
|
||||||
return "None";
|
|
||||||
}
|
|
19
engine/gfx/dx12/src/gfx_dx12.cpp
Executable file
19
engine/gfx/dx12/src/gfx_dx12.cpp
Executable file
|
@ -0,0 +1,19 @@
|
||||||
|
#include "gfx_dx12.hpp"
|
||||||
|
|
||||||
|
#include <d3d12.h>
|
||||||
|
#include <dxgi1_6.h>
|
||||||
|
#include <d3dcompiler.h>
|
||||||
|
|
||||||
|
#include <wrl.h>
|
||||||
|
|
||||||
|
using namespace Microsoft::WRL;
|
||||||
|
|
||||||
|
ComPtr<ID3D12Device> g_Device;
|
||||||
|
|
||||||
|
bool gfx_dx12::initialize(const GFXCreateInfo& info) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* gfx_dx12::get_name() {
|
||||||
|
return "DX12";
|
||||||
|
}
|
|
@ -12,6 +12,10 @@ if(ENABLE_VULKAN)
|
||||||
set(EXTRA_SRC ${CMAKE_CURRENT_SOURCE_DIR}/sdl_vulkan.cpp ${EXTRA_SRC})
|
set(EXTRA_SRC ${CMAKE_CURRENT_SOURCE_DIR}/sdl_vulkan.cpp ${EXTRA_SRC})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_DX12)
|
||||||
|
set(EXTRA_LIBRARIES GFXDX12 ${EXTRA_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
||||||
if(TARGET SDL2::SDL2)
|
if(TARGET SDL2::SDL2)
|
||||||
set(EXTRA_LIBRARIES SDL2::SDL2 ${EXTRA_LIBRARIES})
|
set(EXTRA_LIBRARIES SDL2::SDL2 ${EXTRA_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -8,6 +8,10 @@
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_vulkan.h>
|
#include <SDL_vulkan.h>
|
||||||
|
|
||||||
|
#ifdef ENABLE_DX12
|
||||||
|
#include "gfx_dx12.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_VULKAN
|
#ifdef ENABLE_VULKAN
|
||||||
#include "gfx_vulkan.hpp"
|
#include "gfx_vulkan.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
@ -18,7 +22,7 @@
|
||||||
|
|
||||||
#include "gfx_dummy.hpp"
|
#include "gfx_dummy.hpp"
|
||||||
|
|
||||||
#ifdef PLATFORM_WINDOWS
|
#if defined(PLATFORM_WINDOWS) && !defined(__MINGW32__)
|
||||||
#include <winrt/Windows.UI.ViewManagement.h>
|
#include <winrt/Windows.UI.ViewManagement.h>
|
||||||
#pragma comment(lib, "windowsapp")
|
#pragma comment(lib, "windowsapp")
|
||||||
#endif
|
#endif
|
||||||
|
@ -319,6 +323,11 @@ void platform::end_text_input() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool platform::supports_context(GFXContext context) {
|
bool platform::supports_context(GFXContext context) {
|
||||||
|
#ifdef ENABLE_DX12
|
||||||
|
if(context == GFXContext::DirectX)
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_VULKAN
|
#ifdef ENABLE_VULKAN
|
||||||
if(context == GFXContext::Vulkan)
|
if(context == GFXContext::Vulkan)
|
||||||
return true;
|
return true;
|
||||||
|
@ -397,7 +406,7 @@ template<class GFXBackend>
|
||||||
void try_initialize() {
|
void try_initialize() {
|
||||||
if(gfx_interface == nullptr) {
|
if(gfx_interface == nullptr) {
|
||||||
auto backend = new GFXBackend();
|
auto backend = new GFXBackend();
|
||||||
const bool supported = backend->is_supported();
|
const bool supported = backend->is_supported() && platform::supports_context(backend->required_context());
|
||||||
if(!supported) {
|
if(!supported) {
|
||||||
prism::log("Failed to initialize GFX backend... trying next...");
|
prism::log("Failed to initialize GFX backend... trying next...");
|
||||||
} else {
|
} else {
|
||||||
|
@ -422,6 +431,10 @@ int main(int argc, char* argv[]) {
|
||||||
engine = new prism::engine(argc, argv);
|
engine = new prism::engine(argc, argv);
|
||||||
|
|
||||||
// determine gfx context at the beginning
|
// determine gfx context at the beginning
|
||||||
|
#ifdef ENABLE_DX12
|
||||||
|
try_initialize<gfx_dx12>();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_METAL
|
#ifdef ENABLE_METAL
|
||||||
gfx_backend_order.emplace_back(gfx_backend_initializer{"metal", []{
|
gfx_backend_order.emplace_back(gfx_backend_initializer{"metal", []{
|
||||||
try_initialize<GFXMetal>();
|
try_initialize<GFXMetal>();
|
||||||
|
@ -541,7 +554,7 @@ int main(int argc, char* argv[]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PLATFORM_WINDOWS
|
#if defined(PLATFORM_WINDOWS) && !defined(__MINGW32__)
|
||||||
PlatformTheme platform::get_theme() {
|
PlatformTheme platform::get_theme() {
|
||||||
using namespace winrt::Windows::UI::ViewManagement;
|
using namespace winrt::Windows::UI::ViewManagement;
|
||||||
|
|
||||||
|
|
Reference in a new issue