Merge remote-tracking branch 'origin/master' into dev

This commit is contained in:
Flyinghead 2023-09-25 22:17:29 +02:00
commit a915f185f8
14 changed files with 1996 additions and 360 deletions

View File

@ -1386,7 +1386,7 @@ if(WIN32 AND USE_DX11)
core/rend/dx11/oit/dx11_oitshaders.h)
target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_D3D11)
target_link_libraries(${PROJECT_NAME} PRIVATE d3d11 d3dcompiler)
target_link_libraries(${PROJECT_NAME} PRIVATE d3d11 d3dcompiler dxgi)
endif()
if(ENABLE_GDB_SERVER)

View File

@ -296,7 +296,11 @@ bool GamepadDevice::gamepad_axis_input(u32 code, int value)
{
//printf("B-AXIS %d Mapped to %d -> %d\n", key, value, v);
// TODO hysteresis?
if (std::abs(v) < 16384)
int threshold = 16384;
if ( code == leftTrigger || code == rightTrigger )
threshold = 100;
if (std::abs(v) < threshold)
kcode[port] |= key; // button released
else
kcode[port] &= ~key; // button pressed

View File

@ -110,6 +110,8 @@ protected:
std::shared_ptr<InputMapping> input_mapper;
bool rumbleEnabled = false;
int rumblePower = 100;
u32 leftTrigger = ~0;
u32 rightTrigger = ~0;
private:
bool handleButtonInput(int port, DreamcastKey key, bool pressed);

View File

@ -50,8 +50,8 @@ button_list[] =
{ EMU_BTN_FFORWARD, "emulator", "btn_fforward" },
{ DC_AXIS_LT, "compat", "btn_trigger_left" },
{ DC_AXIS_RT, "compat", "btn_trigger_right" },
{ DC_AXIS_LT2, "compat", "btn_trigger_left2" },
{ DC_AXIS_RT2, "compat", "btn_trigger_right2" },
{ DC_AXIS_LT2, "compat", "btn_trigger2_left" },
{ DC_AXIS_RT2, "compat", "btn_trigger2_right" },
{ DC_AXIS_UP, "compat", "btn_analog_up" },
{ DC_AXIS_DOWN, "compat", "btn_analog_down" },
{ DC_AXIS_LEFT, "compat", "btn_analog_left" },
@ -87,8 +87,8 @@ axis_list[] =
{ DC_AXIS3_DOWN, "", "axis3_down", "", "" },
{ DC_AXIS_LT, "dreamcast", "axis_trigger_left", "compat", "axis_trigger_left_inverted" },
{ DC_AXIS_RT, "dreamcast", "axis_trigger_right", "compat", "axis_trigger_right_inverted" },
{ DC_AXIS_LT2, "dreamcast", "axis_trigger_left2", "compat", "axis_trigger_left2_inverted" },
{ DC_AXIS_RT2, "dreamcast", "axis_trigger_right2", "compat", "axis_trigger_right2_inverted" },
{ DC_AXIS_LT2, "dreamcast", "axis_trigger2_left", "compat", "axis_trigger2_left_inverted" },
{ DC_AXIS_RT2, "dreamcast", "axis_trigger2_right", "compat", "axis_trigger2_right_inverted" },
// legacy (v2)
{ DC_AXIS_RIGHT, "dreamcast", "axis_x", "compat", "axis_x_inverted" },

View File

@ -48,7 +48,7 @@ public:
D3D11_RASTERIZER_DESC desc{};
desc.FillMode = D3D11_FILL_SOLID;
desc.CullMode = D3D11_CULL_NONE;
desc.ScissorEnable = true;
desc.ScissorEnable = false;
desc.DepthClipEnable = true;
device->CreateRasterizerState(&desc, &rasterizerState.get());
}
@ -109,10 +109,10 @@ public:
deviceContext->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
deviceContext->VSSetShader(rotate ? rotateVertexShader : vertexShader, nullptr, 0);
deviceContext->PSSetShader(pixelShader, nullptr, 0);
// TODO Scissor?
//const D3D11_RECT r = { (LONG)(pcmd->ClipRect.x - clip_off.x), (LONG)(pcmd->ClipRect.y - clip_off.y), (LONG)(pcmd->ClipRect.z - clip_off.x), (LONG)(pcmd->ClipRect.w - clip_off.y) };
//deviceContext->RSSetScissorRects(1, &r);
deviceContext->GSSetShader(nullptr, nullptr, 0);
deviceContext->HSSetShader(nullptr, nullptr, 0);
deviceContext->DSSetShader(nullptr, nullptr, 0);
deviceContext->CSSetShader(nullptr, nullptr, 0);
static const float white[] = { 1.f, 1.f, 1.f, 1.f };
if (color == nullptr)

View File

@ -26,6 +26,8 @@
#include "emulator.h"
#include "dx11_driver.h"
#include "imgui/backends/imgui_impl_dx11.h"
#include <dxgi.h>
#include <dxgi1_6.h>
#ifdef TARGET_UWP
#include <windows.h>
#include <gamingdeviceinformation.h>
@ -57,6 +59,23 @@ bool DX11Context::init(bool keepCurrentWindow)
}
#endif
// Use high performance GPU on Windows 10 (1803 or later)
ComPtr<IDXGIFactory1> dxgiFactory;
ComPtr<IDXGIFactory6> dxgiFactory6;
ComPtr<IDXGIAdapter> dxgiAdapter;
HRESULT hr;
hr = CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void **)&dxgiFactory.get());
if (SUCCEEDED(hr))
{
dxgiFactory.as(dxgiFactory6);
if (dxgiFactory6)
{
dxgiFactory6->EnumAdapterByGpuPreference(0, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE, __uuidof(IDXGIAdapter), (void **)&dxgiAdapter.get());
dxgiFactory6.reset();
}
}
dxgiFactory.reset();
D3D_FEATURE_LEVEL featureLevels[] =
{
D3D_FEATURE_LEVEL_11_1,
@ -64,10 +83,9 @@ bool DX11Context::init(bool keepCurrentWindow)
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
};
HRESULT hr;
hr = D3D11CreateDevice(
nullptr, // Specify nullptr to use the default adapter.
D3D_DRIVER_TYPE_HARDWARE,
dxgiAdapter.get(), // High performance GPU, or fallback to use the default adapter.
dxgiAdapter.get() == nullptr ? D3D_DRIVER_TYPE_HARDWARE : D3D_DRIVER_TYPE_UNKNOWN, // D3D_DRIVER_TYPE_UNKNOWN is required when providing an adapter.
nullptr,
D3D11_CREATE_DEVICE_BGRA_SUPPORT, // | D3D11_CREATE_DEVICE_DEBUG,
featureLevels,
@ -84,7 +102,7 @@ bool DX11Context::init(bool keepCurrentWindow)
ComPtr<IDXGIDevice2> dxgiDevice;
pDevice.as(dxgiDevice);
ComPtr<IDXGIAdapter> dxgiAdapter;
dxgiAdapter.reset();
dxgiDevice->GetAdapter(&dxgiAdapter.get());
DXGI_ADAPTER_DESC desc;
dxgiAdapter->GetDesc(&desc);
@ -94,7 +112,6 @@ bool DX11Context::init(bool keepCurrentWindow)
adapterVersion = std::to_string(desc.Revision);
vendorId = desc.VendorId;
ComPtr<IDXGIFactory1> dxgiFactory;
dxgiAdapter->GetParent(__uuidof(IDXGIFactory1), (void **)&dxgiFactory.get());
ComPtr<IDXGIFactory2> dxgiFactory2;

View File

@ -409,6 +409,7 @@ private:
hash |= (pp->isp.ZWriteDis << 20) | (pp->isp.CullMode << 21) | ((autosort ? 6 : pp->isp.DepthMode) << 23);
hash |= ((u32)gpuPalette << 26) | ((u32)pass << 27) | ((u32)pp->isNaomi2() << 29);
hash |= (u32)(!settings.platform.isNaomi2() && config::NativeDepthInterpolation) << 30;
hash |= (u32)(pp->tcw.PixelFmt == PixelBumpMap) << 31;
return hash;
}

View File

@ -272,7 +272,8 @@ private:
hash |= (pp->isp.ZWriteDis << 20) | (pp->isp.CullMode << 21) | (pp->isp.DepthMode << 23);
hash |= ((u32)sortTriangles << 26) | ((u32)gpuPalette << 27) | ((u32)pp->isNaomi2() << 28);
hash |= (u32)(!settings.platform.isNaomi2() && config::NativeDepthInterpolation) << 29;
hash |= (u32)dithering << 30;
hash |= (u32)(pp->tcw.PixelFmt == PixelBumpMap) << 30;
hash |= (u32)dithering << 31;
return hash;
}

View File

@ -254,6 +254,28 @@ void input_sdl_handle()
checkRawInput();
if (event.key.repeat == 0)
{
auto is_key_mapped = [](u32 code) -> bool {
#if defined(_WIN32) && !defined(TARGET_UWP)
if (config::UseRawInput)
{
for (int i = 0; i < GamepadDevice::GetGamepadCount(); i++)
{
auto gamepad = GamepadDevice::GetGamepad(i);
if (dynamic_cast<rawinput::RawKeyboard*>(gamepad.get()) != nullptr)
{
bool mapped = (gamepad->get_input_mapping()->get_button_id(0, code) != EMU_BTN_NONE);
if (mapped) return true;
}
}
return false;
}
else
#endif
{
return (sdl_keyboard->get_input_mapping()->get_button_id(0, code) != EMU_BTN_NONE);
}
};
if (event.type == SDL_KEYDOWN
&& ((event.key.keysym.sym == SDLK_RETURN && (event.key.keysym.mod & KMOD_ALT))
|| (event.key.keysym.sym == SDLK_F11 && (event.key.keysym.mod & (KMOD_ALT | KMOD_CTRL | KMOD_SHIFT | KMOD_GUI)) == 0)))
@ -272,7 +294,7 @@ void input_sdl_handle()
}
window_fullscreen = !window_fullscreen;
}
else if (event.type == SDL_KEYDOWN && (event.key.keysym.mod & KMOD_LALT) && (event.key.keysym.mod & KMOD_LCTRL))
else if (event.type == SDL_KEYDOWN && (event.key.keysym.mod & KMOD_LALT) && (event.key.keysym.mod & KMOD_LCTRL) && !(is_key_mapped(SDL_SCANCODE_LALT) || is_key_mapped(SDL_SCANCODE_LCTRL)) )
{
captureMouse(!mouseCaptured);
}

View File

@ -413,8 +413,6 @@ private:
float vib_inclination = 0;
double vib_stop_time = 0;
SDL_GameController *sdl_controller = nullptr;
u32 leftTrigger = ~0;
u32 rightTrigger = ~0;
static std::map<SDL_JoystickID, std::shared_ptr<SDLGamepad>> sdl_gamepads;
};

View File

@ -72,7 +72,7 @@ template<bool Arcade = false, bool Gamepad = false>
class DefaultInputMapping : public InputMapping
{
public:
DefaultInputMapping(const AndroidGamepadDevice& gamepad);
DefaultInputMapping(AndroidGamepadDevice& gamepad);
};
class ShieldRemoteInputMapping : public InputMapping
@ -216,6 +216,12 @@ public:
}
}
void set_trigger_axes(u32 left_axis_code, u32 right_axis_code)
{
leftTrigger = left_axis_code;
rightTrigger = right_axis_code;
}
static std::shared_ptr<AndroidGamepadDevice> GetAndroidGamepad(int id)
{
auto it = android_gamepads.find(id);
@ -338,7 +344,7 @@ private:
std::map<int, std::shared_ptr<AndroidGamepadDevice>> AndroidGamepadDevice::android_gamepads;
template<bool Arcade, bool Gamepad>
inline DefaultInputMapping<Arcade, Gamepad>::DefaultInputMapping(const AndroidGamepadDevice& gamepad)
inline DefaultInputMapping<Arcade, Gamepad>::DefaultInputMapping(AndroidGamepadDevice& gamepad)
{
name = Arcade ? Gamepad ? "Arcade Gamepad" : "Arcade Hitbox" : "Default";
int ltAxis = AXIS_LTRIGGER;
@ -454,6 +460,8 @@ inline DefaultInputMapping<Arcade, Gamepad>::DefaultInputMapping(const AndroidGa
set_axis(DC_AXIS_UP, AXIS_Y, false);
set_axis(DC_AXIS_DOWN, AXIS_Y, true);
gamepad.set_trigger_axes(ltAxis, rtAxis);
dirty = false;
}

View File

@ -354,6 +354,8 @@ void retro_init()
#if defined(__APPLE__) || (defined(__GNUC__) && defined(__linux__) && !defined(__ANDROID__))
if (!emuInited)
#else
(void)emuInited;
#endif
emu.init();
emuInited = true;
@ -1801,18 +1803,19 @@ static bool set_opengl_hw_render(u32 preferred)
preferred = RETRO_HW_CONTEXT_OPENGL_CORE;
#endif
#ifdef HAVE_OIT
if (config::RendererType == RenderType::OpenGL_OIT)
if (config::RendererType == RenderType::OpenGL_OIT || config::RendererType == RenderType::DirectX11_OIT || config::RendererType == RenderType::Vulkan_OIT)
{
params.context_type = (retro_hw_context_type)preferred;
config::RendererType = RenderType::OpenGL_OIT;
params.context_type = (retro_hw_context_type)preferred;
if (preferred == RETRO_HW_CONTEXT_OPENGL)
{
// There are some weirdness with RA's gl context's versioning :
// - any value above 3.0 won't provide a valid context, while the GLSM_CTL_STATE_CONTEXT_INIT call returns true...
// - the only way to overwrite previously set version with zero values is to set them directly in hw_render, otherwise they are ignored (see glsm_state_ctx_init logic)
// FIXME what's the point of this?
retro_hw_render_callback hw_render;
hw_render.version_major = 3;
hw_render.version_minor = 0;
//retro_hw_render_callback hw_render;
//hw_render.version_major = 3;
//hw_render.version_minor = 0;
}
else
{

View File

@ -732,6 +732,26 @@ struct retro_core_option_v2_definition option_defs_us[] = {
{ "280", "280 MHz" },
{ "290", "290 MHz" },
{ "300", "300 MHz" },
{ "310", "310 MHz" },
{ "320", "320 MHz" },
{ "330", "330 MHz" },
{ "340", "340 MHz" },
{ "350", "350 MHz" },
{ "360", "360 MHz" },
{ "370", "370 MHz" },
{ "380", "380 MHz" },
{ "390", "390 MHz" },
{ "400", "400 MHz" },
{ "410", "410 MHz" },
{ "420", "420 MHz" },
{ "430", "430 MHz" },
{ "440", "440 MHz" },
{ "450", "450 MHz" },
{ "460", "460 MHz" },
{ "470", "470 MHz" },
{ "480", "480 MHz" },
{ "490", "490 MHz" },
{ "500", "500 MHz" },
{ NULL, NULL },
},
"200",

File diff suppressed because it is too large Load Diff