Use wgpu instance extras to select the backend
This commit is contained in:
parent
fffd2c70e6
commit
cae25f4719
2 changed files with 22 additions and 6 deletions
|
|
@ -81,11 +81,7 @@ namespace psemek::sdl2
|
||||||
|
|
||||||
wgpu::adapter::request_options adapter_request_options;
|
wgpu::adapter::request_options adapter_request_options;
|
||||||
adapter_request_options.compatible_surface = wgpu_surface_;
|
adapter_request_options.compatible_surface = wgpu_surface_;
|
||||||
#if defined(_WIN32)
|
adapter_request_options.backend_type = wgpu::backend_type::undefined;
|
||||||
adapter_request_options.backend_type = wgpu::backend_type::d3d12;
|
|
||||||
#else
|
|
||||||
adapter_request_options.backend_type = wgpu::backend_type::vulkan;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
instance.request_adapter(adapter_request_options, [this](wgpu::adapter::request_status status, wgpu::adapter adapter_in, std::string const & message)
|
instance.request_adapter(adapter_request_options, [this](wgpu::adapter::request_status status, wgpu::adapter adapter_in, std::string const & message)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,33 @@
|
||||||
#include <psemek/wgpu/instance.hpp>
|
#include <psemek/wgpu/instance.hpp>
|
||||||
#include <psemek/wgpu/external/webgpu.h>
|
#include <psemek/wgpu/external/webgpu.h>
|
||||||
|
#include <psemek/wgpu/external/wgpu.h>
|
||||||
|
|
||||||
namespace psemek::wgpu
|
namespace psemek::wgpu
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
struct extras
|
||||||
|
{};
|
||||||
|
|
||||||
|
detail::chained_struct_ptr to_chained_struct(extras const &)
|
||||||
|
{
|
||||||
|
WGPUInstanceExtras chained = {};
|
||||||
|
chained.chain.sType = (WGPUSType)WGPUSType_InstanceExtras;
|
||||||
|
chained.backends = WGPUInstanceBackend_Primary;
|
||||||
|
return detail::make_chained_struct(chained);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
instance instance::create(descriptor const & desc)
|
instance instance::create(descriptor const & desc)
|
||||||
{
|
{
|
||||||
|
std::vector<chained_struct> chain = desc.chain;
|
||||||
|
chain.push_back(extras{});
|
||||||
|
|
||||||
WGPUInstanceDescriptor descriptor = {};
|
WGPUInstanceDescriptor descriptor = {};
|
||||||
descriptor.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(desc.chain);
|
descriptor.nextInChain = (WGPUChainedStruct const *)detail::fill_chain(chain);
|
||||||
return instance(wgpuCreateInstance(&descriptor));
|
return instance(wgpuCreateInstance(&descriptor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue