Use DX12 by default on Windows
This commit is contained in:
parent
ba4d15886f
commit
6be0616d1e
5 changed files with 33 additions and 5 deletions
|
@ -29,4 +29,12 @@ macro(set_engine_properties target)
|
|||
if(ENABLE_METAL)
|
||||
target_compile_definitions(${target} PUBLIC ENABLE_METAL)
|
||||
endif()
|
||||
|
||||
if(ENABLE_WEBGPU)
|
||||
target_compile_definitions(${target} PUBLIC ENABLE_WEBGPU)
|
||||
endif()
|
||||
|
||||
if(ENABLE_DX12)
|
||||
target_compile_definitions(${target} PUBLIC ENABLE_DX12)
|
||||
endif()
|
||||
endmacro()
|
||||
|
|
|
@ -4,7 +4,10 @@
|
|||
|
||||
class gfx_dx12 : public GFX {
|
||||
public:
|
||||
bool initialize() override;
|
||||
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* getName() override;
|
||||
const char* get_name() override;
|
||||
};
|
||||
|
|
|
@ -10,10 +10,10 @@ using namespace Microsoft::WRL;
|
|||
|
||||
ComPtr<ID3D12Device> g_Device;
|
||||
|
||||
bool gfx_dx12::initialize() {
|
||||
bool gfx_dx12::initialize(const GFXCreateInfo& info) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* gfx_dx12::getName() {
|
||||
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})
|
||||
endif()
|
||||
|
||||
if(ENABLE_DX12)
|
||||
set(EXTRA_LIBRARIES GFXDX12 ${EXTRA_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(TARGET SDL2::SDL2)
|
||||
set(EXTRA_LIBRARIES SDL2::SDL2 ${EXTRA_LIBRARIES})
|
||||
endif()
|
||||
|
|
|
@ -8,6 +8,10 @@
|
|||
#include <SDL.h>
|
||||
#include <SDL_vulkan.h>
|
||||
|
||||
#ifdef ENABLE_DX12
|
||||
#include "gfx_dx12.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VULKAN
|
||||
#include "gfx_vulkan.hpp"
|
||||
#endif
|
||||
|
@ -319,6 +323,11 @@ void platform::end_text_input() {
|
|||
}
|
||||
|
||||
bool platform::supports_context(GFXContext context) {
|
||||
#ifdef ENABLE_DX12
|
||||
if(context == GFXContext::DirectX)
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VULKAN
|
||||
if(context == GFXContext::Vulkan)
|
||||
return true;
|
||||
|
@ -397,7 +406,7 @@ template<class GFXBackend>
|
|||
void try_initialize() {
|
||||
if(gfx_interface == nullptr) {
|
||||
auto backend = new GFXBackend();
|
||||
const bool supported = backend->is_supported();
|
||||
const bool supported = backend->is_supported() && platform::supports_context(backend->required_context());
|
||||
if(!supported) {
|
||||
prism::log("Failed to initialize GFX backend... trying next...");
|
||||
} else {
|
||||
|
@ -411,6 +420,10 @@ int main(int argc, char* argv[]) {
|
|||
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
|
||||
|
||||
// determine gfx context at the beginning
|
||||
#ifdef ENABLE_DX12
|
||||
try_initialize<gfx_dx12>();
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_METAL
|
||||
try_initialize<GFXMetal>();
|
||||
#endif
|
||||
|
|
Reference in a new issue