mirror of
https://github.com/yuzu-emu/yuzu-mainline.git
synced 2025-08-31 19:21:02 +00:00
Compare commits
3 commits
master
...
mainline-0
Author | SHA1 | Date | |
---|---|---|---|
|
d6150e55b1 | ||
|
42fb4bae67 | ||
|
6be2b0e1a7 |
|
@ -57,7 +57,7 @@ Result NpadAbstractSixAxisHandler::UpdateSixAxisState() {
|
||||||
Core::HID::NpadIdType npad_id = properties_handler->GetNpadId();
|
Core::HID::NpadIdType npad_id = properties_handler->GetNpadId();
|
||||||
for (std::size_t i = 0; i < AruidIndexMax; i++) {
|
for (std::size_t i = 0; i < AruidIndexMax; i++) {
|
||||||
auto* data = applet_resource_holder->applet_resource->GetAruidDataByIndex(i);
|
auto* data = applet_resource_holder->applet_resource->GetAruidDataByIndex(i);
|
||||||
if (data->flag.is_assigned) {
|
if (data == nullptr || !data->flag.is_assigned) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto& npad_entry = data->shared_memory_format->npad.npad_entry[NpadIdTypeToIndex(npad_id)];
|
auto& npad_entry = data->shared_memory_format->npad.npad_entry[NpadIdTypeToIndex(npad_id)];
|
||||||
|
|
|
@ -131,7 +131,7 @@ void NPad::ControllerUpdate(Core::HID::ControllerTriggerType type, std::size_t c
|
||||||
|
|
||||||
auto* data = applet_resource_holder.applet_resource->GetAruidDataByIndex(aruid_index);
|
auto* data = applet_resource_holder.applet_resource->GetAruidDataByIndex(aruid_index);
|
||||||
|
|
||||||
if (!data->flag.is_assigned) {
|
if (data == nullptr || !data->flag.is_assigned) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,13 +463,13 @@ void NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||||
std::scoped_lock lock{*applet_resource_holder.shared_mutex};
|
std::scoped_lock lock{*applet_resource_holder.shared_mutex};
|
||||||
for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; ++aruid_index) {
|
for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; ++aruid_index) {
|
||||||
const auto* data = applet_resource_holder.applet_resource->GetAruidDataByIndex(aruid_index);
|
const auto* data = applet_resource_holder.applet_resource->GetAruidDataByIndex(aruid_index);
|
||||||
const auto aruid = data->aruid;
|
|
||||||
|
|
||||||
if (!data->flag.is_assigned) {
|
if (data == nullptr || !data->flag.is_assigned) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_set{};
|
bool is_set{};
|
||||||
|
const auto aruid = data->aruid;
|
||||||
npad_resource.IsSupportedNpadStyleSet(is_set, aruid);
|
npad_resource.IsSupportedNpadStyleSet(is_set, aruid);
|
||||||
// Wait until style is defined
|
// Wait until style is defined
|
||||||
if (!is_set) {
|
if (!is_set) {
|
||||||
|
|
|
@ -28,142 +28,148 @@ void SixAxis::OnRelease() {}
|
||||||
|
|
||||||
void SixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
void SixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||||
std::scoped_lock shared_lock{*shared_mutex};
|
std::scoped_lock shared_lock{*shared_mutex};
|
||||||
const u64 aruid = applet_resource->GetActiveAruid();
|
|
||||||
auto* data = applet_resource->GetAruidData(aruid);
|
|
||||||
|
|
||||||
if (data == nullptr || !data->flag.is_assigned) {
|
for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; ++aruid_index) {
|
||||||
return;
|
const auto* data = applet_resource->GetAruidDataByIndex(aruid_index);
|
||||||
}
|
|
||||||
|
|
||||||
if (!IsControllerActivated()) {
|
if (data == nullptr || !data->flag.is_assigned) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (std::size_t i = 0; i < controller_data.size(); ++i) {
|
|
||||||
NpadSharedMemoryEntry& shared_memory = data->shared_memory_format->npad.npad_entry[i];
|
|
||||||
auto& controller = controller_data[i];
|
|
||||||
const auto& controller_type = controller.device->GetNpadStyleIndex();
|
|
||||||
|
|
||||||
if (controller_type == Core::HID::NpadStyleIndex::None ||
|
|
||||||
!controller.device->IsConnected()) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& motion_state = controller.device->GetMotions();
|
if (!IsControllerActivated()) {
|
||||||
auto& sixaxis_fullkey_state = controller.sixaxis_fullkey_state;
|
return;
|
||||||
auto& sixaxis_handheld_state = controller.sixaxis_handheld_state;
|
|
||||||
auto& sixaxis_dual_left_state = controller.sixaxis_dual_left_state;
|
|
||||||
auto& sixaxis_dual_right_state = controller.sixaxis_dual_right_state;
|
|
||||||
auto& sixaxis_left_lifo_state = controller.sixaxis_left_lifo_state;
|
|
||||||
auto& sixaxis_right_lifo_state = controller.sixaxis_right_lifo_state;
|
|
||||||
|
|
||||||
auto& sixaxis_fullkey_lifo = shared_memory.internal_state.sixaxis_fullkey_lifo;
|
|
||||||
auto& sixaxis_handheld_lifo = shared_memory.internal_state.sixaxis_handheld_lifo;
|
|
||||||
auto& sixaxis_dual_left_lifo = shared_memory.internal_state.sixaxis_dual_left_lifo;
|
|
||||||
auto& sixaxis_dual_right_lifo = shared_memory.internal_state.sixaxis_dual_right_lifo;
|
|
||||||
auto& sixaxis_left_lifo = shared_memory.internal_state.sixaxis_left_lifo;
|
|
||||||
auto& sixaxis_right_lifo = shared_memory.internal_state.sixaxis_right_lifo;
|
|
||||||
|
|
||||||
// Clear previous state
|
|
||||||
sixaxis_fullkey_state = {};
|
|
||||||
sixaxis_handheld_state = {};
|
|
||||||
sixaxis_dual_left_state = {};
|
|
||||||
sixaxis_dual_right_state = {};
|
|
||||||
sixaxis_left_lifo_state = {};
|
|
||||||
sixaxis_right_lifo_state = {};
|
|
||||||
|
|
||||||
if (controller.sixaxis_sensor_enabled && Settings::values.motion_enabled.GetValue()) {
|
|
||||||
controller.sixaxis_at_rest = true;
|
|
||||||
for (std::size_t e = 0; e < motion_state.size(); ++e) {
|
|
||||||
controller.sixaxis_at_rest =
|
|
||||||
controller.sixaxis_at_rest && motion_state[e].is_at_rest;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto set_motion_state = [&](Core::HID::SixAxisSensorState& state,
|
for (std::size_t i = 0; i < controller_data.size(); ++i) {
|
||||||
const Core::HID::ControllerMotion& hid_state) {
|
NpadSharedMemoryEntry& shared_memory = data->shared_memory_format->npad.npad_entry[i];
|
||||||
using namespace std::literals::chrono_literals;
|
auto& controller = controller_data[i];
|
||||||
static constexpr Core::HID::SixAxisSensorState default_motion_state = {
|
const auto& controller_type = controller.device->GetNpadStyleIndex();
|
||||||
.delta_time = std::chrono::nanoseconds(5ms).count(),
|
|
||||||
.accel = {0, 0, -1.0f},
|
if (!data->flag.enable_six_axis_sensor) {
|
||||||
.orientation =
|
continue;
|
||||||
{
|
}
|
||||||
Common::Vec3f{1.0f, 0, 0},
|
|
||||||
Common::Vec3f{0, 1.0f, 0},
|
if (controller_type == Core::HID::NpadStyleIndex::None ||
|
||||||
Common::Vec3f{0, 0, 1.0f},
|
!controller.device->IsConnected()) {
|
||||||
},
|
continue;
|
||||||
.attribute = {1},
|
}
|
||||||
|
|
||||||
|
const auto& motion_state = controller.device->GetMotions();
|
||||||
|
auto& sixaxis_fullkey_state = controller.sixaxis_fullkey_state;
|
||||||
|
auto& sixaxis_handheld_state = controller.sixaxis_handheld_state;
|
||||||
|
auto& sixaxis_dual_left_state = controller.sixaxis_dual_left_state;
|
||||||
|
auto& sixaxis_dual_right_state = controller.sixaxis_dual_right_state;
|
||||||
|
auto& sixaxis_left_lifo_state = controller.sixaxis_left_lifo_state;
|
||||||
|
auto& sixaxis_right_lifo_state = controller.sixaxis_right_lifo_state;
|
||||||
|
|
||||||
|
auto& sixaxis_fullkey_lifo = shared_memory.internal_state.sixaxis_fullkey_lifo;
|
||||||
|
auto& sixaxis_handheld_lifo = shared_memory.internal_state.sixaxis_handheld_lifo;
|
||||||
|
auto& sixaxis_dual_left_lifo = shared_memory.internal_state.sixaxis_dual_left_lifo;
|
||||||
|
auto& sixaxis_dual_right_lifo = shared_memory.internal_state.sixaxis_dual_right_lifo;
|
||||||
|
auto& sixaxis_left_lifo = shared_memory.internal_state.sixaxis_left_lifo;
|
||||||
|
auto& sixaxis_right_lifo = shared_memory.internal_state.sixaxis_right_lifo;
|
||||||
|
|
||||||
|
// Clear previous state
|
||||||
|
sixaxis_fullkey_state = {};
|
||||||
|
sixaxis_handheld_state = {};
|
||||||
|
sixaxis_dual_left_state = {};
|
||||||
|
sixaxis_dual_right_state = {};
|
||||||
|
sixaxis_left_lifo_state = {};
|
||||||
|
sixaxis_right_lifo_state = {};
|
||||||
|
|
||||||
|
if (controller.sixaxis_sensor_enabled && Settings::values.motion_enabled.GetValue()) {
|
||||||
|
controller.sixaxis_at_rest = true;
|
||||||
|
for (std::size_t e = 0; e < motion_state.size(); ++e) {
|
||||||
|
controller.sixaxis_at_rest =
|
||||||
|
controller.sixaxis_at_rest && motion_state[e].is_at_rest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto set_motion_state = [&](Core::HID::SixAxisSensorState& state,
|
||||||
|
const Core::HID::ControllerMotion& hid_state) {
|
||||||
|
using namespace std::literals::chrono_literals;
|
||||||
|
static constexpr Core::HID::SixAxisSensorState default_motion_state = {
|
||||||
|
.delta_time = std::chrono::nanoseconds(5ms).count(),
|
||||||
|
.accel = {0, 0, -1.0f},
|
||||||
|
.orientation =
|
||||||
|
{
|
||||||
|
Common::Vec3f{1.0f, 0, 0},
|
||||||
|
Common::Vec3f{0, 1.0f, 0},
|
||||||
|
Common::Vec3f{0, 0, 1.0f},
|
||||||
|
},
|
||||||
|
.attribute = {1},
|
||||||
|
};
|
||||||
|
if (!controller.sixaxis_sensor_enabled) {
|
||||||
|
state = default_motion_state;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!Settings::values.motion_enabled.GetValue()) {
|
||||||
|
state = default_motion_state;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
state.attribute.is_connected.Assign(1);
|
||||||
|
state.delta_time = std::chrono::nanoseconds(5ms).count();
|
||||||
|
state.accel = hid_state.accel;
|
||||||
|
state.gyro = hid_state.gyro;
|
||||||
|
state.rotation = hid_state.rotation;
|
||||||
|
state.orientation = hid_state.orientation;
|
||||||
};
|
};
|
||||||
if (!controller.sixaxis_sensor_enabled) {
|
|
||||||
state = default_motion_state;
|
switch (controller_type) {
|
||||||
return;
|
case Core::HID::NpadStyleIndex::None:
|
||||||
|
ASSERT(false);
|
||||||
|
break;
|
||||||
|
case Core::HID::NpadStyleIndex::Fullkey:
|
||||||
|
set_motion_state(sixaxis_fullkey_state, motion_state[0]);
|
||||||
|
break;
|
||||||
|
case Core::HID::NpadStyleIndex::Handheld:
|
||||||
|
set_motion_state(sixaxis_handheld_state, motion_state[0]);
|
||||||
|
break;
|
||||||
|
case Core::HID::NpadStyleIndex::JoyconDual:
|
||||||
|
set_motion_state(sixaxis_dual_left_state, motion_state[0]);
|
||||||
|
set_motion_state(sixaxis_dual_right_state, motion_state[1]);
|
||||||
|
break;
|
||||||
|
case Core::HID::NpadStyleIndex::JoyconLeft:
|
||||||
|
set_motion_state(sixaxis_left_lifo_state, motion_state[0]);
|
||||||
|
break;
|
||||||
|
case Core::HID::NpadStyleIndex::JoyconRight:
|
||||||
|
set_motion_state(sixaxis_right_lifo_state, motion_state[1]);
|
||||||
|
break;
|
||||||
|
case Core::HID::NpadStyleIndex::Pokeball:
|
||||||
|
using namespace std::literals::chrono_literals;
|
||||||
|
set_motion_state(sixaxis_fullkey_state, motion_state[0]);
|
||||||
|
sixaxis_fullkey_state.delta_time = std::chrono::nanoseconds(15ms).count();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (!Settings::values.motion_enabled.GetValue()) {
|
|
||||||
state = default_motion_state;
|
sixaxis_fullkey_state.sampling_number =
|
||||||
return;
|
sixaxis_fullkey_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1;
|
||||||
|
sixaxis_handheld_state.sampling_number =
|
||||||
|
sixaxis_handheld_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1;
|
||||||
|
sixaxis_dual_left_state.sampling_number =
|
||||||
|
sixaxis_dual_left_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1;
|
||||||
|
sixaxis_dual_right_state.sampling_number =
|
||||||
|
sixaxis_dual_right_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1;
|
||||||
|
sixaxis_left_lifo_state.sampling_number =
|
||||||
|
sixaxis_left_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1;
|
||||||
|
sixaxis_right_lifo_state.sampling_number =
|
||||||
|
sixaxis_right_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1;
|
||||||
|
|
||||||
|
if (IndexToNpadIdType(i) == Core::HID::NpadIdType::Handheld) {
|
||||||
|
// This buffer only is updated on handheld on HW
|
||||||
|
sixaxis_handheld_lifo.lifo.WriteNextEntry(sixaxis_handheld_state);
|
||||||
|
} else {
|
||||||
|
// Handheld doesn't update this buffer on HW
|
||||||
|
sixaxis_fullkey_lifo.lifo.WriteNextEntry(sixaxis_fullkey_state);
|
||||||
}
|
}
|
||||||
state.attribute.is_connected.Assign(1);
|
|
||||||
state.delta_time = std::chrono::nanoseconds(5ms).count();
|
|
||||||
state.accel = hid_state.accel;
|
|
||||||
state.gyro = hid_state.gyro;
|
|
||||||
state.rotation = hid_state.rotation;
|
|
||||||
state.orientation = hid_state.orientation;
|
|
||||||
};
|
|
||||||
|
|
||||||
switch (controller_type) {
|
sixaxis_dual_left_lifo.lifo.WriteNextEntry(sixaxis_dual_left_state);
|
||||||
case Core::HID::NpadStyleIndex::None:
|
sixaxis_dual_right_lifo.lifo.WriteNextEntry(sixaxis_dual_right_state);
|
||||||
ASSERT(false);
|
sixaxis_left_lifo.lifo.WriteNextEntry(sixaxis_left_lifo_state);
|
||||||
break;
|
sixaxis_right_lifo.lifo.WriteNextEntry(sixaxis_right_lifo_state);
|
||||||
case Core::HID::NpadStyleIndex::Fullkey:
|
|
||||||
set_motion_state(sixaxis_fullkey_state, motion_state[0]);
|
|
||||||
break;
|
|
||||||
case Core::HID::NpadStyleIndex::Handheld:
|
|
||||||
set_motion_state(sixaxis_handheld_state, motion_state[0]);
|
|
||||||
break;
|
|
||||||
case Core::HID::NpadStyleIndex::JoyconDual:
|
|
||||||
set_motion_state(sixaxis_dual_left_state, motion_state[0]);
|
|
||||||
set_motion_state(sixaxis_dual_right_state, motion_state[1]);
|
|
||||||
break;
|
|
||||||
case Core::HID::NpadStyleIndex::JoyconLeft:
|
|
||||||
set_motion_state(sixaxis_left_lifo_state, motion_state[0]);
|
|
||||||
break;
|
|
||||||
case Core::HID::NpadStyleIndex::JoyconRight:
|
|
||||||
set_motion_state(sixaxis_right_lifo_state, motion_state[1]);
|
|
||||||
break;
|
|
||||||
case Core::HID::NpadStyleIndex::Pokeball:
|
|
||||||
using namespace std::literals::chrono_literals;
|
|
||||||
set_motion_state(sixaxis_fullkey_state, motion_state[0]);
|
|
||||||
sixaxis_fullkey_state.delta_time = std::chrono::nanoseconds(15ms).count();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sixaxis_fullkey_state.sampling_number =
|
|
||||||
sixaxis_fullkey_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1;
|
|
||||||
sixaxis_handheld_state.sampling_number =
|
|
||||||
sixaxis_handheld_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1;
|
|
||||||
sixaxis_dual_left_state.sampling_number =
|
|
||||||
sixaxis_dual_left_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1;
|
|
||||||
sixaxis_dual_right_state.sampling_number =
|
|
||||||
sixaxis_dual_right_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1;
|
|
||||||
sixaxis_left_lifo_state.sampling_number =
|
|
||||||
sixaxis_left_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1;
|
|
||||||
sixaxis_right_lifo_state.sampling_number =
|
|
||||||
sixaxis_right_lifo.lifo.ReadCurrentEntry().state.sampling_number + 1;
|
|
||||||
|
|
||||||
if (IndexToNpadIdType(i) == Core::HID::NpadIdType::Handheld) {
|
|
||||||
// This buffer only is updated on handheld on HW
|
|
||||||
sixaxis_handheld_lifo.lifo.WriteNextEntry(sixaxis_handheld_state);
|
|
||||||
} else {
|
|
||||||
// Handheld doesn't update this buffer on HW
|
|
||||||
sixaxis_fullkey_lifo.lifo.WriteNextEntry(sixaxis_fullkey_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
sixaxis_dual_left_lifo.lifo.WriteNextEntry(sixaxis_dual_left_state);
|
|
||||||
sixaxis_dual_right_lifo.lifo.WriteNextEntry(sixaxis_dual_right_state);
|
|
||||||
sixaxis_left_lifo.lifo.WriteNextEntry(sixaxis_left_lifo_state);
|
|
||||||
sixaxis_right_lifo.lifo.WriteNextEntry(sixaxis_right_lifo_state);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ Result TouchResource::ActivateTouch(u64 aruid) {
|
||||||
auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index);
|
auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index);
|
||||||
TouchAruidData& touch_data = aruid_data[aruid_index];
|
TouchAruidData& touch_data = aruid_data[aruid_index];
|
||||||
|
|
||||||
if (!applet_data->flag.is_assigned) {
|
if (applet_data == nullptr || !applet_data->flag.is_assigned) {
|
||||||
touch_data = {};
|
touch_data = {};
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ Result TouchResource::ActivateGesture(u64 aruid, u32 basic_gesture_id) {
|
||||||
auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index);
|
auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index);
|
||||||
TouchAruidData& touch_data = aruid_data[aruid_index];
|
TouchAruidData& touch_data = aruid_data[aruid_index];
|
||||||
|
|
||||||
if (!applet_data->flag.is_assigned) {
|
if (applet_data == nullptr || !applet_data->flag.is_assigned) {
|
||||||
touch_data = {};
|
touch_data = {};
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ Result TouchResource::SetTouchScreenConfiguration(
|
||||||
const auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index);
|
const auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index);
|
||||||
TouchAruidData& data = aruid_data[aruid_index];
|
TouchAruidData& data = aruid_data[aruid_index];
|
||||||
|
|
||||||
if (!applet_data->flag.is_assigned) {
|
if (applet_data == nullptr || !applet_data->flag.is_assigned) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (aruid != data.aruid) {
|
if (aruid != data.aruid) {
|
||||||
|
@ -344,7 +344,7 @@ Result TouchResource::GetTouchScreenConfiguration(
|
||||||
const auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index);
|
const auto* applet_data = applet_resource->GetAruidDataByIndex(aruid_index);
|
||||||
const TouchAruidData& data = aruid_data[aruid_index];
|
const TouchAruidData& data = aruid_data[aruid_index];
|
||||||
|
|
||||||
if (!applet_data->flag.is_assigned) {
|
if (applet_data == nullptr || !applet_data->flag.is_assigned) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (aruid != data.aruid) {
|
if (aruid != data.aruid) {
|
||||||
|
|
|
@ -1546,7 +1546,10 @@ void BufferCache<P>::ImmediateUploadMemory([[maybe_unused]] Buffer& buffer,
|
||||||
std::span<const u8> upload_span;
|
std::span<const u8> upload_span;
|
||||||
const DAddr device_addr = buffer.CpuAddr() + copy.dst_offset;
|
const DAddr device_addr = buffer.CpuAddr() + copy.dst_offset;
|
||||||
if (IsRangeGranular(device_addr, copy.size)) {
|
if (IsRangeGranular(device_addr, copy.size)) {
|
||||||
upload_span = std::span(device_memory.GetPointer<u8>(device_addr), copy.size);
|
auto* const ptr = device_memory.GetPointer<u8>(device_addr);
|
||||||
|
if (ptr != nullptr) {
|
||||||
|
upload_span = std::span(ptr, copy.size);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (immediate_buffer.empty()) {
|
if (immediate_buffer.empty()) {
|
||||||
immediate_buffer = ImmediateBuffer(largest_copy);
|
immediate_buffer = ImmediateBuffer(largest_copy);
|
||||||
|
|
|
@ -1064,8 +1064,6 @@ public:
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
auto* ptr = device_memory.GetPointer<u8>(new_query->dependant_address);
|
|
||||||
ASSERT(ptr != nullptr);
|
|
||||||
|
|
||||||
new_query->dependant_manage = must_manage_dependance;
|
new_query->dependant_manage = must_manage_dependance;
|
||||||
pending_flush_queries.push_back(index);
|
pending_flush_queries.push_back(index);
|
||||||
|
@ -1104,9 +1102,11 @@ public:
|
||||||
tfb_streamer.Free(query->dependant_index);
|
tfb_streamer.Free(query->dependant_index);
|
||||||
} else {
|
} else {
|
||||||
u8* pointer = device_memory.GetPointer<u8>(query->dependant_address);
|
u8* pointer = device_memory.GetPointer<u8>(query->dependant_address);
|
||||||
u32 result;
|
if (pointer != nullptr) {
|
||||||
std::memcpy(&result, pointer, sizeof(u32));
|
u32 result;
|
||||||
num_vertices = static_cast<u64>(result) / query->stride;
|
std::memcpy(&result, pointer, sizeof(u32));
|
||||||
|
num_vertices = static_cast<u64>(result) / query->stride;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
query->value = [&]() -> u64 {
|
query->value = [&]() -> u64 {
|
||||||
switch (query->topology) {
|
switch (query->topology) {
|
||||||
|
@ -1360,7 +1360,9 @@ bool QueryCacheRuntime::HostConditionalRenderingCompareValues(VideoCommon::Looku
|
||||||
const auto check_value = [&](DAddr address) {
|
const auto check_value = [&](DAddr address) {
|
||||||
u8* ptr = impl->device_memory.GetPointer<u8>(address);
|
u8* ptr = impl->device_memory.GetPointer<u8>(address);
|
||||||
u64 value{};
|
u64 value{};
|
||||||
std::memcpy(&value, ptr, sizeof(value));
|
if (ptr != nullptr) {
|
||||||
|
std::memcpy(&value, ptr, sizeof(value));
|
||||||
|
}
|
||||||
return value == 0;
|
return value == 0;
|
||||||
};
|
};
|
||||||
std::array<VideoCommon::LookupData*, 2> objects{&object_1, &object_2};
|
std::array<VideoCommon::LookupData*, 2> objects{&object_1, &object_2};
|
||||||
|
|
|
@ -1050,37 +1050,16 @@ void RasterizerVulkan::UpdateDepthBias(Tegra::Engines::Maxwell3D::Regs& regs) {
|
||||||
regs.zeta.format == Tegra::DepthFormat::X8Z24_UNORM ||
|
regs.zeta.format == Tegra::DepthFormat::X8Z24_UNORM ||
|
||||||
regs.zeta.format == Tegra::DepthFormat::S8Z24_UNORM ||
|
regs.zeta.format == Tegra::DepthFormat::S8Z24_UNORM ||
|
||||||
regs.zeta.format == Tegra::DepthFormat::V8Z24_UNORM;
|
regs.zeta.format == Tegra::DepthFormat::V8Z24_UNORM;
|
||||||
bool force_unorm = ([&] {
|
if (is_d24 && !device.SupportsD24DepthBuffer() &&
|
||||||
if (!is_d24 || device.SupportsD24DepthBuffer()) {
|
Settings::values.renderer_amdvlk_depth_bias_workaround) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (device.IsExtDepthBiasControlSupported()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!Settings::values.renderer_amdvlk_depth_bias_workaround) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// the base formulas can be obtained from here:
|
// the base formulas can be obtained from here:
|
||||||
// https://docs.microsoft.com/en-us/windows/win32/direct3d11/d3d10-graphics-programming-guide-output-merger-stage-depth-bias
|
// https://docs.microsoft.com/en-us/windows/win32/direct3d11/d3d10-graphics-programming-guide-output-merger-stage-depth-bias
|
||||||
const double rescale_factor =
|
const double rescale_factor =
|
||||||
static_cast<double>(1ULL << (32 - 24)) / (static_cast<double>(0x1.ep+127));
|
static_cast<double>(1ULL << (32 - 24)) / (static_cast<double>(0x1.ep+127));
|
||||||
units = static_cast<float>(static_cast<double>(units) * rescale_factor);
|
units = static_cast<float>(static_cast<double>(units) * rescale_factor);
|
||||||
return false;
|
}
|
||||||
})();
|
|
||||||
scheduler.Record([constant = units, clamp = regs.depth_bias_clamp,
|
scheduler.Record([constant = units, clamp = regs.depth_bias_clamp,
|
||||||
factor = regs.slope_scale_depth_bias, force_unorm,
|
factor = regs.slope_scale_depth_bias](vk::CommandBuffer cmdbuf) {
|
||||||
precise = device.HasExactDepthBiasControl()](vk::CommandBuffer cmdbuf) {
|
|
||||||
if (force_unorm) {
|
|
||||||
VkDepthBiasRepresentationInfoEXT info{
|
|
||||||
.sType = VK_STRUCTURE_TYPE_DEPTH_BIAS_REPRESENTATION_INFO_EXT,
|
|
||||||
.pNext = nullptr,
|
|
||||||
.depthBiasRepresentation =
|
|
||||||
VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORCE_UNORM_EXT,
|
|
||||||
.depthBiasExact = precise ? VK_TRUE : VK_FALSE,
|
|
||||||
};
|
|
||||||
cmdbuf.SetDepthBias(constant, clamp, factor, &info);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cmdbuf.SetDepthBias(constant, clamp, factor);
|
cmdbuf.SetDepthBias(constant, clamp, factor);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1137,13 +1137,6 @@ void Device::RemoveUnsuitableExtensions() {
|
||||||
RemoveExtensionFeatureIfUnsuitable(extensions.custom_border_color, features.custom_border_color,
|
RemoveExtensionFeatureIfUnsuitable(extensions.custom_border_color, features.custom_border_color,
|
||||||
VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
|
VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
|
||||||
|
|
||||||
// VK_EXT_depth_bias_control
|
|
||||||
extensions.depth_bias_control =
|
|
||||||
features.depth_bias_control.depthBiasControl &&
|
|
||||||
features.depth_bias_control.leastRepresentableValueForceUnormRepresentation;
|
|
||||||
RemoveExtensionFeatureIfUnsuitable(extensions.depth_bias_control, features.depth_bias_control,
|
|
||||||
VK_EXT_DEPTH_BIAS_CONTROL_EXTENSION_NAME);
|
|
||||||
|
|
||||||
// VK_EXT_depth_clip_control
|
// VK_EXT_depth_clip_control
|
||||||
extensions.depth_clip_control = features.depth_clip_control.depthClipControl;
|
extensions.depth_clip_control = features.depth_clip_control.depthClipControl;
|
||||||
RemoveExtensionFeatureIfUnsuitable(extensions.depth_clip_control, features.depth_clip_control,
|
RemoveExtensionFeatureIfUnsuitable(extensions.depth_clip_control, features.depth_clip_control,
|
||||||
|
|
|
@ -41,7 +41,6 @@ VK_DEFINE_HANDLE(VmaAllocator)
|
||||||
// Define all features which may be used by the implementation and require an extension here.
|
// Define all features which may be used by the implementation and require an extension here.
|
||||||
#define FOR_EACH_VK_FEATURE_EXT(FEATURE) \
|
#define FOR_EACH_VK_FEATURE_EXT(FEATURE) \
|
||||||
FEATURE(EXT, CustomBorderColor, CUSTOM_BORDER_COLOR, custom_border_color) \
|
FEATURE(EXT, CustomBorderColor, CUSTOM_BORDER_COLOR, custom_border_color) \
|
||||||
FEATURE(EXT, DepthBiasControl, DEPTH_BIAS_CONTROL, depth_bias_control) \
|
|
||||||
FEATURE(EXT, DepthClipControl, DEPTH_CLIP_CONTROL, depth_clip_control) \
|
FEATURE(EXT, DepthClipControl, DEPTH_CLIP_CONTROL, depth_clip_control) \
|
||||||
FEATURE(EXT, ExtendedDynamicState, EXTENDED_DYNAMIC_STATE, extended_dynamic_state) \
|
FEATURE(EXT, ExtendedDynamicState, EXTENDED_DYNAMIC_STATE, extended_dynamic_state) \
|
||||||
FEATURE(EXT, ExtendedDynamicState2, EXTENDED_DYNAMIC_STATE_2, extended_dynamic_state2) \
|
FEATURE(EXT, ExtendedDynamicState2, EXTENDED_DYNAMIC_STATE_2, extended_dynamic_state2) \
|
||||||
|
@ -97,7 +96,6 @@ VK_DEFINE_HANDLE(VmaAllocator)
|
||||||
#define FOR_EACH_VK_RECOMMENDED_EXTENSION(EXTENSION_NAME) \
|
#define FOR_EACH_VK_RECOMMENDED_EXTENSION(EXTENSION_NAME) \
|
||||||
EXTENSION_NAME(VK_EXT_CONDITIONAL_RENDERING_EXTENSION_NAME) \
|
EXTENSION_NAME(VK_EXT_CONDITIONAL_RENDERING_EXTENSION_NAME) \
|
||||||
EXTENSION_NAME(VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME) \
|
EXTENSION_NAME(VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME) \
|
||||||
EXTENSION_NAME(VK_EXT_DEPTH_BIAS_CONTROL_EXTENSION_NAME) \
|
|
||||||
EXTENSION_NAME(VK_EXT_DEPTH_RANGE_UNRESTRICTED_EXTENSION_NAME) \
|
EXTENSION_NAME(VK_EXT_DEPTH_RANGE_UNRESTRICTED_EXTENSION_NAME) \
|
||||||
EXTENSION_NAME(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME) \
|
EXTENSION_NAME(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME) \
|
||||||
EXTENSION_NAME(VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME) \
|
EXTENSION_NAME(VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME) \
|
||||||
|
@ -150,9 +148,6 @@ VK_DEFINE_HANDLE(VmaAllocator)
|
||||||
// Define features where the absence of the feature may result in a degraded experience.
|
// Define features where the absence of the feature may result in a degraded experience.
|
||||||
#define FOR_EACH_VK_RECOMMENDED_FEATURE(FEATURE_NAME) \
|
#define FOR_EACH_VK_RECOMMENDED_FEATURE(FEATURE_NAME) \
|
||||||
FEATURE_NAME(custom_border_color, customBorderColors) \
|
FEATURE_NAME(custom_border_color, customBorderColors) \
|
||||||
FEATURE_NAME(depth_bias_control, depthBiasControl) \
|
|
||||||
FEATURE_NAME(depth_bias_control, leastRepresentableValueForceUnormRepresentation) \
|
|
||||||
FEATURE_NAME(depth_bias_control, depthBiasExact) \
|
|
||||||
FEATURE_NAME(extended_dynamic_state, extendedDynamicState) \
|
FEATURE_NAME(extended_dynamic_state, extendedDynamicState) \
|
||||||
FEATURE_NAME(format_a4b4g4r4, formatA4B4G4R4) \
|
FEATURE_NAME(format_a4b4g4r4, formatA4B4G4R4) \
|
||||||
FEATURE_NAME(index_type_uint8, indexTypeUint8) \
|
FEATURE_NAME(index_type_uint8, indexTypeUint8) \
|
||||||
|
@ -479,11 +474,6 @@ public:
|
||||||
return extensions.depth_clip_control;
|
return extensions.depth_clip_control;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if the device supports VK_EXT_depth_bias_control.
|
|
||||||
bool IsExtDepthBiasControlSupported() const {
|
|
||||||
return extensions.depth_bias_control;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns true if the device supports VK_EXT_shader_viewport_index_layer.
|
/// Returns true if the device supports VK_EXT_shader_viewport_index_layer.
|
||||||
bool IsExtShaderViewportIndexLayerSupported() const {
|
bool IsExtShaderViewportIndexLayerSupported() const {
|
||||||
return extensions.shader_viewport_index_layer;
|
return extensions.shader_viewport_index_layer;
|
||||||
|
@ -649,10 +639,6 @@ public:
|
||||||
return features.robustness2.nullDescriptor;
|
return features.robustness2.nullDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasExactDepthBiasControl() const {
|
|
||||||
return features.depth_bias_control.depthBiasExact;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 GetMaxVertexInputAttributes() const {
|
u32 GetMaxVertexInputAttributes() const {
|
||||||
return properties.properties.limits.maxVertexInputAttributes;
|
return properties.properties.limits.maxVertexInputAttributes;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue