Compare commits

...

5 Commits

Author SHA1 Message Date
nmzik fc91fd2b1a libs: simplify ABI registration facades 2026-09-02 02:06:14 +04:00
nmzik a06a005124 controller: simplify input facade API 2026-09-02 02:06:14 +04:00
nmzik e9425e101d shader: add missing RDNA2 ALU opcodes
Add missing scalar and vector opcodes with compute tests.

Original work by @Pouare514 in #176.

Co-authored-by: Pouare514 <julienaulycee@gmail.com>
2026-09-02 01:56:55 +04:00
CheesyPoofs3460 04b404f3c9 controller: enable the DualSense HIDAPI driver, light bar and adaptive triggers (#437)
* controller: enable the DualSense HIDAPI driver, light bar and adaptive triggers

Three additions. SDL was opening a DualSense through the generic gamepad path, so SDL_GameControllerHasLED and SDL_GameControllerGetNumTouchpads both reported nothing and no touchpad events ever arrived - enabling the PS5 HIDAPI driver before SDL_InitSubSystem is what makes the light bar and the existing touchpad support reachable. PadSetLightBar validated its arguments and returned OK without touching the pad; it now drives the LED. PadSetTriggerEffect did the same; it now translates the mode and parameters into a DualSense trigger block and sends it.

* controller: fix DualSense effects

---------

Co-authored-by: nmzik <Nmzik@mail.ru>
2026-09-02 00:53:19 +04:00
nmzik 80225015c5 renderer: enable storage for color images 2026-09-01 23:54:17 +04:00
25 changed files with 498 additions and 188 deletions
@@ -59,16 +59,8 @@ namespace {
if (HasFormatFeature(properties, vk::FormatFeatureFlagBits::eColorAttachment)) {
usage |= vk::ImageUsageFlagBits::eColorAttachment;
}
if (info.samples == 1 &&
HasFormatFeature(properties, vk::FormatFeatureFlagBits::eStorageImage)) {
if (info.samples == 1) {
usage |= vk::ImageUsageFlagBits::eStorage;
} else if (info.samples == 1) {
const auto compatible = SrgbStorageViewFormat(info.pixel_format);
if (compatible != vk::Format::eUndefined &&
HasFormatFeature(graphics.GetFormatProperties(compatible),
vk::FormatFeatureFlagBits::eStorageImage)) {
usage |= vk::ImageUsageFlagBits::eStorage;
}
}
return usage;
}
+2 -2
View File
@@ -209,7 +209,7 @@ void RefreshVisibility() {
}
const bool was_controller = std::exchange(g_controller_captured, capture_controller);
if (capture_controller || was_controller) {
Controller::ControllerResetInputState();
Controller::ResetInputState();
}
g_active = visible;
@@ -404,7 +404,7 @@ void ShutdownImeInput() {
g_input_lifecycle_active = false;
g_active = false;
if (std::exchange(g_controller_captured, false)) {
Controller::ControllerResetInputState();
Controller::ResetInputState();
}
g_visibility_event.store(static_cast<Uint32>(-1), std::memory_order_release);
}
+10 -10
View File
@@ -194,18 +194,18 @@ const InputMap& GetInputMap() {
void SetButton(uint32_t button, bool down) {
if (button == Controller::PAD_BUTTON_L2) {
Controller::ControllerAxis(Controller::HOST_INPUT_CONTROLLER_ID,
Controller::Axis::TriggerLeft, down ? 255 : 0);
Controller::SetAxis(Controller::HOST_INPUT_CONTROLLER_ID, Controller::Axis::TriggerLeft,
down ? 255 : 0);
} else if (button == Controller::PAD_BUTTON_R2) {
Controller::ControllerAxis(Controller::HOST_INPUT_CONTROLLER_ID,
Controller::Axis::TriggerRight, down ? 255 : 0);
Controller::SetAxis(Controller::HOST_INPUT_CONTROLLER_ID, Controller::Axis::TriggerRight,
down ? 255 : 0);
} else if (button != 0) {
Controller::ControllerButton(Controller::HOST_INPUT_CONTROLLER_ID, button, down);
Controller::SetButton(Controller::HOST_INPUT_CONTROLLER_ID, button, down);
}
}
void SetTouchPad(float x, bool down) {
Controller::ControllerTouchPad(Controller::HOST_INPUT_CONTROLLER_ID, 0, down, x, 0.5f);
Controller::SetTouchPad(Controller::HOST_INPUT_CONTROLLER_ID, 0, down, x, 0.5f);
}
uint32_t DefaultKeyboardButton(int key_code) {
@@ -242,7 +242,7 @@ void SetStickAxis(Controller::Axis axis, bool negative, bool positive) {
} else if (positive && !negative) {
value = 255;
}
Controller::ControllerAxis(Controller::HOST_INPUT_CONTROLLER_ID, axis, value);
Controller::SetAxis(Controller::HOST_INPUT_CONTROLLER_ID, axis, value);
}
void SetControl(std::size_t control, bool down) {
@@ -326,15 +326,15 @@ void MouseToJoystick(int delta_x, int delta_y) {
const auto map_axis = [scale](int delta) {
return std::clamp(128 + static_cast<int>(std::lround(delta * scale)), 0, 255);
};
Controller::ControllerRightStick(Controller::HOST_INPUT_CONTROLLER_ID, map_axis(delta_x),
map_axis(delta_y));
Controller::SetRightStick(Controller::HOST_INPUT_CONTROLLER_ID, map_axis(delta_x),
map_axis(delta_y));
}
void CenterMouseStick() {
if (!g_mouse.output) {
return;
}
Controller::ControllerRightStick(Controller::HOST_INPUT_CONTROLLER_ID, 128, 128);
Controller::SetRightStick(Controller::HOST_INPUT_CONTROLLER_ID, 128, 128);
g_mouse.output = false;
}
+9 -8
View File
@@ -351,26 +351,26 @@ static void GameEventController([[maybe_unused]] const EventController& f) {
auto* pad = SDL_GameControllerOpen(f.id);
EXIT_NOT_IMPLEMENTED(pad == nullptr);
int id = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(pad));
Controller::ControllerConnect(id);
Controller::Connect(id);
}
if (f.removed) {
Controller::ControllerDisconnect(f.id);
Controller::Disconnect(f.id);
SDL_GameControllerClose(SDL_GameControllerFromInstanceID(f.id));
}
if (f.down || f.up) {
const auto button = ControllerButtonToPadButton(f.button);
if (button != 0) {
Controller::ControllerButton(f.id, button, f.down);
Controller::SetButton(f.id, button, f.down);
}
}
if (f.axis) {
const auto axis = ControllerAxisFromSdl(f.axis_id);
if (axis != Controller::Axis::AxisMax) {
Controller::ControllerAxis(f.id, axis,
ControllerAxisValueFromSdl(f.axis_id, f.axis_value));
Controller::SetAxis(f.id, axis,
ControllerAxisValueFromSdl(f.axis_id, f.axis_value));
}
}
}
@@ -708,9 +708,9 @@ void WindowContext::ProcessEvent(double time_s) {
case SDL_CONTROLLERTOUCHPADMOTION:
case SDL_CONTROLLERTOUCHPADUP:
if (event->ctouchpad.touchpad == 0) {
Controller::ControllerTouchPad(event->ctouchpad.which, event->ctouchpad.finger,
event->ctouchpad.type != SDL_CONTROLLERTOUCHPADUP,
event->ctouchpad.x, event->ctouchpad.y);
Controller::SetTouchPad(event->ctouchpad.which, event->ctouchpad.finger,
event->ctouchpad.type != SDL_CONTROLLERTOUCHPADUP,
event->ctouchpad.x, event->ctouchpad.y);
}
break;
@@ -814,6 +814,7 @@ static void WindowCreate(WindowContext& context) {
int width = static_cast<int>(context.graphic_ctx.screen_width);
int height = static_cast<int>(context.graphic_ctx.screen_height);
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1");
#if KYTY_PLATFORM == KYTY_PLATFORM_WINDOWS
SDL_SetHint(SDL_HINT_WINDOWS_DPI_SCALING, "0");
#endif
@@ -27,7 +27,8 @@ constexpr OpcodeMap SOP2_OPCODE_LIST[] = {
{0x22u, Opcode::S_ASHR_I32}, {0x24u, Opcode::S_BFM_B32},
{0x25u, Opcode::S_BFM_B64}, {0x26u, Opcode::S_MUL_I32},
{0x27u, Opcode::S_BFE_U32}, {0x28u, Opcode::S_BFE_I32},
{0x29u, Opcode::S_BFE_U64}, {0x2eu, Opcode::S_LSHL1_ADD_U32},
{0x29u, Opcode::S_BFE_U64}, {0x2cu, Opcode::S_ABSDIFF_I32},
{0x2eu, Opcode::S_LSHL1_ADD_U32},
{0x2fu, Opcode::S_LSHL2_ADD_U32}, {0x30u, Opcode::S_LSHL3_ADD_U32},
{0x31u, Opcode::S_LSHL4_ADD_U32}, {0x32u, Opcode::S_PACK_LL_B32_B16},
{0x33u, Opcode::S_PACK_LH_B32_B16}, {0x34u, Opcode::S_PACK_HH_B32_B16},
@@ -48,7 +49,9 @@ constexpr OpcodeMap SOP1_OPCODE_LIST[] = {
{0x15u, Opcode::S_FLBIT_I32_B32},
{0x16u, Opcode::S_FLBIT_I32_B64},
{0x1bu, Opcode::S_BITSET0_B32},
{0x1cu, Opcode::S_BITSET0_B64},
{0x1du, Opcode::S_BITSET1_B32},
{0x1eu, Opcode::S_BITSET1_B64},
{0x1fu, Opcode::S_GETPC_B64},
{0x20u, Opcode::S_SETPC_B64},
{0x24u, Opcode::S_AND_SAVEEXEC_B64},
@@ -93,6 +96,7 @@ constexpr OpcodeMap SOPP_OPCODE_LIST[] = {
{0x0au, Opcode::S_BARRIER},
{0x0cu, Opcode::S_WAITCNT},
{0x0eu, Opcode::S_SLEEP},
{0x0fu, Opcode::S_SETPRIO},
{0x10u, Opcode::S_SENDMSG},
{0x12u, Opcode::S_TRAP},
{0x16u, Opcode::S_TTRACEDATA},
@@ -276,6 +280,7 @@ void DecodeSopp(uint32_t pc, std::span<const uint32_t> code, uint32_t word_index
: static_cast<int32_t>(static_cast<int16_t>(simm));
inst.src_count = (inst.opcode == Opcode::S_NOP || inst.opcode == Opcode::S_WAITCNT ||
inst.opcode == Opcode::S_WAITCNT_DEPCTR || inst.opcode == Opcode::S_SLEEP ||
inst.opcode == Opcode::S_SETPRIO ||
inst.opcode == Opcode::S_SENDMSG || inst.opcode == Opcode::S_TRAP ||
inst.opcode == Opcode::S_TTRACEDATA || inst.opcode == Opcode::S_INST_PREFETCH)
? 1
@@ -479,6 +479,8 @@ std::string InstructionToString(const Instruction& inst) {
case Opcode::S_FLBIT_I32_B32:
case Opcode::S_FF1_I32_B32:
case Opcode::S_FF1_I32_B64:
case Opcode::S_BITSET0_B64:
case Opcode::S_BITSET1_B64:
case Opcode::S_NOT_B64:
case Opcode::S_WQM_B64:
case Opcode::S_QUADMASK_B64:
@@ -505,6 +507,7 @@ std::string InstructionToString(const Instruction& inst) {
case Opcode::S_WAITCNT:
case Opcode::S_WAITCNT_DEPCTR:
case Opcode::S_SLEEP:
case Opcode::S_SETPRIO:
case Opcode::S_TRAP:
case Opcode::S_SENDMSG:
case Opcode::S_TTRACEDATA:
@@ -40,6 +40,7 @@ enum class Opcode {
S_MOV_B64,
S_MOVK_I32,
S_ABS_I32,
S_ABSDIFF_I32,
S_BREV_B32,
S_BCNT1_I32_B32,
S_BCNT1_I32_B64,
@@ -69,6 +70,8 @@ enum class Opcode {
S_BITCMP1_B32,
S_BITSET0_B32,
S_BITSET1_B32,
S_BITSET0_B64,
S_BITSET1_B64,
S_MIN_I32,
S_MAX_I32,
S_MIN_U32,
@@ -108,6 +111,7 @@ enum class Opcode {
S_BFM_B64,
S_CSELECT_B32,
S_CSELECT_B64,
S_SETPRIO,
S_PACK_LL_B32_B16,
S_PACK_LH_B32_B16,
S_PACK_HH_B32_B16,
@@ -282,6 +286,7 @@ enum class Opcode {
V_MAD_MIXHI_F16,
V_ADD_NC_U32,
V_ADDC_U32,
V_SUB_CO_CI_U32,
V_SUBREV_CO_CI_U32,
V_SUB_NC_U32,
V_SUBREV_NC_U32,
@@ -61,6 +61,7 @@ constexpr Vop2OpcodeInfo VOP2_OPCODE_LIST[] = {
{0x24u, Opcode::V_MBCNT_HI_U32_B32},
{0x25u, Opcode::V_ADD_NC_U32, Vop2SdwaProfile::IntegerPartialDestination},
{0x28u, Opcode::V_ADDC_U32, Vop2SdwaProfile::IntegerFullDestination},
{0x29u, Opcode::V_SUB_CO_CI_U32},
{0x2au, Opcode::V_SUBREV_CO_CI_U32},
{0x26u, Opcode::V_SUB_NC_U32, Vop2SdwaProfile::IntegerPartialDestination},
{0x27u, Opcode::V_SUBREV_NC_U32, Vop2SdwaProfile::IntegerFullDestination},
@@ -1033,6 +1034,7 @@ void FinalizeVop2Instruction(std::span<const uint32_t> code, uint32_t word_index
inst.src_count = 3;
break;
case Opcode::V_ADDC_U32:
case Opcode::V_SUB_CO_CI_U32:
case Opcode::V_SUBREV_CO_CI_U32:
inst.dst2.kind = OperandKind::VccLo;
inst.src2.kind = OperandKind::VccLo;
@@ -1643,6 +1645,7 @@ void DecodeVop3(uint32_t pc, std::span<const uint32_t> code, uint32_t word_index
SetRawWords(inst, code, word_index, 2);
const bool carry_in_out = (inst.opcode == Opcode::V_ADDC_U32 && opcode == 0x128u) ||
(inst.opcode == Opcode::V_SUB_CO_CI_U32 && opcode == 0x129u) ||
(inst.opcode == Opcode::V_SUBREV_CO_CI_U32 && opcode == 0x12au);
const bool vop3b_carry_out = IsVop3BCarryOutOpcode(inst.opcode);
const bool vop3b_mad_u64 = IsVop3BMadU64Opcode(inst.opcode);
@@ -76,9 +76,9 @@ void Translator::SUB_U32(const Decoder::Instruction& inst, bool vector, bool rev
}
}
void Translator::SUBB_U32(const Decoder::Instruction& inst, bool vector) {
const auto lhs = ReadU32(vector ? inst.src1 : inst.src0);
const auto rhs = ReadU32(vector ? inst.src0 : inst.src1);
void Translator::SUBB_U32(const Decoder::Instruction& inst, bool vector, bool reverse) {
const auto lhs = ReadU32(reverse ? inst.src1 : inst.src0);
const auto rhs = ReadU32(reverse ? inst.src0 : inst.src1);
const auto borrow_in = vector ? ConditionBit(inst.src2)
: ConditionBit(ConditionOperand(Decoder::OperandKind::Scc));
const auto partial = ir.ISub(lhs, rhs);
@@ -94,6 +94,13 @@ void Translator::SUBB_U32(const Decoder::Instruction& inst, bool vector) {
}
}
void Translator::S_ABSDIFF_I32(const Decoder::Instruction& inst) {
const auto difference = ir.ISub(ReadU32(inst.src0), ReadU32(inst.src1));
const auto result = IR::U32(ir.Emit(IR::ValueOpcode::IAbs32, {difference}));
WriteOperand(DestinationOperand(inst), result);
ir.SetScc(ir.INotEqual(result, IR::U32(IR::Value(0u))));
}
void Translator::S_ADD_SUB_I32(const Decoder::Instruction& inst, bool subtract) {
const auto lhs = ReadU32(inst.src0);
const auto rhs = ReadU32(inst.src1);
@@ -312,6 +312,22 @@ bool Translator::S_BITSET_B32(const Decoder::Instruction& inst, bool set) {
return true;
}
bool Translator::S_BITSET_B64(const Decoder::Instruction& inst, bool set) {
const auto offset = ir.BitwiseAnd(ReadU32(inst.src0), IR::U32(IR::Value(63u)));
const auto word_bit = ir.BitwiseAnd(offset, IR::U32(IR::Value(31u)));
const auto bit = ir.ShiftLeftLogical(IR::U32(IR::Value(1u)), word_bit);
const auto old = ReadU32Pair(inst.dst);
const auto low_value = set ? ir.BitwiseOr(old[0], bit)
: ir.BitwiseAnd(old[0], ir.BitwiseNot(bit));
const auto high_value = set ? ir.BitwiseOr(old[1], bit)
: ir.BitwiseAnd(old[1], ir.BitwiseNot(bit));
const auto high = IR::U1(ir.Emit(IR::ValueOpcode::UGreaterThanEqual32,
{offset, IR::Value(32u)}));
WriteU32Pair(inst.dst,
{ir.Select(high, old[0], low_value), ir.Select(high, high_value, old[1])});
return true;
}
bool Translator::V_BCNT_U32_B32(const Decoder::Instruction& inst) {
const auto count = IR::U32(ir.Emit(IR::ValueOpcode::BitCount32, {ReadU32(inst.src0)}));
WriteOperand(DestinationOperand(inst), ir.IAdd(count, ReadU32(inst.src1)));
@@ -34,7 +34,8 @@ bool Translator::EmitScalar(const Decoder::Instruction& inst) {
case O::S_ADD_U32: ADD_U32(inst, false, false); return true;
case O::S_ADDC_U32: ADD_U32(inst, false, true); return true;
case O::S_SUB_U32: SUB_U32(inst, false, false); return true;
case O::S_SUBB_U32: SUBB_U32(inst, false); return true;
case O::S_SUBB_U32: SUBB_U32(inst, false, false); return true;
case O::S_ABSDIFF_I32: S_ABSDIFF_I32(inst); return true;
case O::S_ADD_I32: S_ADD_SUB_I32(inst, false); return true;
case O::S_SUB_I32: S_ADD_SUB_I32(inst, true); return true;
case O::S_LSHL1_ADD_U32: S_LSHL_ADD_U32(inst, 1u); return true;
@@ -186,6 +187,8 @@ bool Translator::EmitScalar(const Decoder::Instruction& inst) {
case O::S_BITSET0_B32: return S_BITSET_B32(inst, false);
case O::S_BITSET1_B32: return S_BITSET_B32(inst, true);
case O::S_BITSET0_B64: return S_BITSET_B64(inst, false);
case O::S_BITSET1_B64: return S_BITSET_B64(inst, true);
case O::S_BITREPLICATE_B64_B32: return S_BITREPLICATE_B64_B32(inst);
case O::S_QUADMASK_B64: return S_QUADMASK_B64(inst);
case O::S_BFM_B32: return BFM_B32(inst);
@@ -201,6 +204,7 @@ bool Translator::EmitScalar(const Decoder::Instruction& inst) {
case O::S_NOP:
case O::S_SLEEP:
case O::S_SETPRIO:
case O::S_TRAP: EmitControlNop(); return true;
case O::S_WAITCNT_DEPCTR: EmitWaitcnt(); return true;
case O::S_BARRIER: S_BARRIER(); return true;
@@ -192,6 +192,7 @@ private:
bool V_SAD_U32(const Decoder::Instruction& inst);
bool V_ADD3_U32(const Decoder::Instruction& inst);
bool S_BITSET_B32(const Decoder::Instruction& inst, bool set);
bool S_BITSET_B64(const Decoder::Instruction& inst, bool set);
bool V_BCNT_U32_B32(const Decoder::Instruction& inst);
bool V_MBCNT_U32_B32(const Decoder::Instruction& inst, bool low);
bool S_BITREPLICATE_B64_B32(const Decoder::Instruction& inst);
@@ -218,7 +219,8 @@ private:
bool negate_source, bool write_64);
void ADD_U32(const Decoder::Instruction& inst, bool vector, bool use_carry_in);
void SUB_U32(const Decoder::Instruction& inst, bool vector, bool reverse);
void SUBB_U32(const Decoder::Instruction& inst, bool vector);
void SUBB_U32(const Decoder::Instruction& inst, bool vector, bool reverse);
void S_ABSDIFF_I32(const Decoder::Instruction& inst);
void S_ADD_SUB_I32(const Decoder::Instruction& inst, bool subtract);
void S_LSHL_ADD_U32(const Decoder::Instruction& inst, uint32_t shift_amount);
void ScalarMinMax32(const Decoder::Instruction& inst, IR::ValueOpcode value_opcode,
@@ -10,7 +10,8 @@ bool Translator::EmitVector(const Decoder::Instruction& inst) {
case O::V_ADDC_U32: ADD_U32(inst, true, true); return true;
case O::V_SUB_I32: SUB_U32(inst, true, false); return true;
case O::V_SUBREV_I32: SUB_U32(inst, true, true); return true;
case O::V_SUBREV_CO_CI_U32: SUBB_U32(inst, true); return true;
case O::V_SUB_CO_CI_U32: SUBB_U32(inst, true, false); return true;
case O::V_SUBREV_CO_CI_U32: SUBB_U32(inst, true, true); return true;
case O::V_MOV_B32: MOV_B32(inst, true); return true;
case O::V_MOVRELS_B32: V_MOVRELS_B32(inst); return true;
+179 -27
View File
@@ -39,11 +39,42 @@ struct PadControllerInformation {
uint8_t reserve[8];
};
struct PadLightBarParam {
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t reserve;
};
struct PadVibrationParam {
uint8_t large_motor;
uint8_t small_motor;
};
struct PadTriggerEffectCommand {
uint32_t mode;
uint8_t reserve[4];
uint8_t data[48];
};
struct PadTriggerEffectParam {
uint8_t trigger_mask;
uint8_t reserve[7];
PadTriggerEffectCommand command[2];
};
static_assert(sizeof(PadTriggerEffectCommand) == 56);
static_assert(sizeof(PadTriggerEffectParam) == 120);
struct DualSenseEffects {
uint8_t enable_bits;
uint8_t reserve[9];
uint8_t right_trigger[11];
uint8_t left_trigger[11];
};
static_assert(sizeof(DualSenseEffects) == 32);
struct ControllerState {
struct Touch {
uint8_t id = 0;
@@ -73,6 +104,8 @@ public:
void ResetInputState();
void GetConnectionInfo(bool* flag, int* count);
void SetVibration(uint8_t large_motor, uint8_t small_motor);
void SetLightBar(uint8_t r, uint8_t g, uint8_t b);
bool SetTriggerEffect(const PadTriggerEffectParam& param);
void ReadState(ControllerState* state, bool* flag, int* count);
int ReadStates(ControllerState* states, int states_num, bool* flag, int* count);
@@ -125,6 +158,92 @@ static void pad_fill_data(PadData* data, const ControllerState& state, bool conn
data->device_unique_data_len = 0;
}
static bool trigger_effect_zones(uint8_t* effect, const uint8_t* strengths, uint8_t type,
uint8_t frequency = 0) {
uint16_t active = 0;
uint32_t packed = 0;
for (int i = 0; i < 10; i++) {
if (strengths[i] > 8) {
return false;
}
if (strengths[i] != 0) {
active |= static_cast<uint16_t>(1u << i);
packed |= static_cast<uint32_t>(strengths[i] - 1u) << (3 * i);
}
}
effect[0] = active != 0 && (type != 0x26 || frequency != 0) ? type : 0x05;
effect[1] = static_cast<uint8_t>(active);
effect[2] = static_cast<uint8_t>(active >> 8u);
effect[3] = static_cast<uint8_t>(packed);
effect[4] = static_cast<uint8_t>(packed >> 8u);
effect[5] = static_cast<uint8_t>(packed >> 16u);
effect[6] = static_cast<uint8_t>(packed >> 24u);
effect[9] = frequency;
return true;
}
static bool trigger_effect_to_dualsense(const PadTriggerEffectCommand& command, uint8_t* effect) {
std::memset(effect, 0, 11);
effect[0] = 0x05;
uint8_t strengths[10] = {};
switch (command.mode) {
case 0: return true;
case 1:
if (command.data[0] > 9 || command.data[1] > 8) {
return false;
}
std::fill(strengths + command.data[0], strengths + 10, command.data[1]);
return trigger_effect_zones(effect, strengths, 0x21);
case 2: {
const auto start = command.data[0];
const auto end = command.data[1];
const auto strength = command.data[2];
if (start < 2 || start > 7 || end <= start || end > 8 || strength > 8) {
return false;
}
if (strength == 0) {
return true;
}
const uint16_t zones = static_cast<uint16_t>((1u << start) | (1u << end));
effect[0] = 0x25;
effect[1] = static_cast<uint8_t>(zones);
effect[2] = static_cast<uint8_t>(zones >> 8u);
effect[3] = strength - 1u;
return true;
}
case 3:
if (command.data[0] > 9 || command.data[1] > 8) {
return false;
}
std::fill(strengths + command.data[0], strengths + 10, command.data[1]);
return trigger_effect_zones(effect, strengths, 0x26, command.data[2]);
case 4: return trigger_effect_zones(effect, command.data, 0x21);
case 5: {
const int start = command.data[0];
const int end = command.data[1];
const int start_strength = command.data[2];
const int end_strength = command.data[3];
if (start > 8 || end <= start || end > 9 || start_strength < 1 || start_strength > 8 ||
end_strength < 1 || end_strength > 8) {
return false;
}
for (int i = start; i < 10; i++) {
const int delta = (end_strength - start_strength) * (i - start);
const int length = end - start;
strengths[i] = static_cast<uint8_t>(
i >= end ? end_strength
: start_strength +
(delta + (delta < 0 ? -length / 2 : length / 2)) / length);
}
return trigger_effect_zones(effect, strengths, 0x21);
}
case 6: return trigger_effect_zones(effect, command.data + 1, 0x26, command.data[0]);
default: return false;
}
}
void Initialize() {
EXIT_IF(g_controller != nullptr);
@@ -304,6 +423,44 @@ void GameController::SetVibration(uint8_t large_motor, uint8_t small_motor) {
}
}
void GameController::SetLightBar(uint8_t r, uint8_t g, uint8_t b) {
Common::LockGuard lock(m_mutex);
if (auto* pad = SDL_GameControllerFromInstanceID(static_cast<SDL_JoystickID>(m_active_id));
pad != nullptr) {
(void)SDL_GameControllerSetLED(pad, r, g, b);
}
}
bool GameController::SetTriggerEffect(const PadTriggerEffectParam& param) {
if ((param.trigger_mask & ~0x03u) != 0) {
return false;
}
DualSenseEffects effect {};
if ((param.trigger_mask & 0x01u) != 0) {
effect.enable_bits |= 0x08;
if (!trigger_effect_to_dualsense(param.command[0], effect.left_trigger)) {
return false;
}
}
if ((param.trigger_mask & 0x02u) != 0) {
effect.enable_bits |= 0x04;
if (!trigger_effect_to_dualsense(param.command[1], effect.right_trigger)) {
return false;
}
}
if (effect.enable_bits == 0) {
return true;
}
Common::LockGuard lock(m_mutex);
auto* pad = SDL_GameControllerFromInstanceID(static_cast<SDL_JoystickID>(m_active_id));
if (pad != nullptr && SDL_GameControllerGetType(pad) == SDL_CONTROLLER_TYPE_PS5) {
(void)SDL_GameControllerSendEffect(pad, &effect, sizeof(effect));
}
return true;
}
void GameController::GetConnectionInfo(bool* flag, int* count) {
EXIT_IF(flag == nullptr);
EXIT_IF(count == nullptr);
@@ -358,44 +515,31 @@ int GameController::ReadStates(ControllerState* states, int states_num, bool* fl
return ret_num;
}
void ControllerConnect(int id) {
EXIT_IF(g_controller == nullptr);
void Connect(int id) {
g_controller->Connect(id);
}
void ControllerDisconnect(int id) {
EXIT_IF(g_controller == nullptr);
void Disconnect(int id) {
g_controller->Disconnect(id);
}
void ControllerButton(int id, uint32_t button, bool down) {
EXIT_IF(g_controller == nullptr);
void SetButton(int id, uint32_t button, bool down) {
g_controller->Button(id, button, down);
}
void ControllerAxis(int id, Axis axis, int value) {
EXIT_IF(g_controller == nullptr);
void SetAxis(int id, Axis axis, int value) {
g_controller->Axis(id, axis, value);
}
void ControllerRightStick(int id, int x, int y) {
EXIT_IF(g_controller == nullptr);
void SetRightStick(int id, int x, int y) {
g_controller->RightStick(id, x, y);
}
void ControllerTouchPad(int id, int finger, bool down, float x, float y) {
EXIT_IF(g_controller == nullptr);
void SetTouchPad(int id, int finger, bool down, float x, float y) {
g_controller->TouchPad(id, finger, down, x, y);
}
void ControllerResetInputState() {
EXIT_IF(g_controller == nullptr);
void ResetInputState() {
g_controller->ResetInputState();
}
@@ -490,8 +634,6 @@ int KYTY_SYSV_ABI PadResetOrientation(int handle) {
int KYTY_SYSV_ABI PadGetControllerInformation(int handle, PadControllerInformation* info) {
PRINT_NAME();
EXIT_IF(g_controller == nullptr);
int connected_count = 0;
bool connected = false;
@@ -529,8 +671,6 @@ int KYTY_SYSV_ABI PadReadState(int handle, PadData* data) {
return PAD_ERROR_INVALID_ARG;
}
EXIT_IF(g_controller == nullptr);
int connected_count = 0;
bool connected = false;
ControllerState state;
@@ -555,8 +695,6 @@ int KYTY_SYSV_ABI PadRead(int handle, PadData* data, int num) {
std::memset(data, 0, sizeof(PadData) * static_cast<size_t>(num));
EXIT_IF(g_controller == nullptr);
int connected_count = 0;
bool connected = false;
ControllerState states[64] = {};
@@ -591,7 +729,6 @@ int KYTY_SYSV_ABI PadSetVibration(int handle, const PadVibrationParam* param) {
"\t small_motor = %d\n",
static_cast<int>(param->large_motor), static_cast<int>(param->small_motor));
EXIT_IF(g_controller == nullptr);
g_controller->SetVibration(param->large_motor, param->small_motor);
return OK;
@@ -617,7 +754,22 @@ int KYTY_SYSV_ABI PadSetLightBar(int handle, const PadLightBarParam* param) {
return PAD_ERROR_INVALID_ARG;
}
g_controller->SetLightBar(param->r, param->g, param->b);
return OK;
}
int KYTY_SYSV_ABI PadSetTriggerEffect(int handle, const PadTriggerEffectParam* param) {
PRINT_NAME();
if (handle != 1) {
return PAD_ERROR_INVALID_HANDLE;
}
if (param == nullptr) {
return PAD_ERROR_INVALID_ARG;
}
return g_controller->SetTriggerEffect(*param) ? OK : PAD_ERROR_INVALID_ARG;
}
} // namespace Libs::Controller
+9 -7
View File
@@ -48,6 +48,7 @@ struct PadControllerInformation;
struct PadData;
struct PadVibrationParam;
struct PadLightBarParam;
struct PadTriggerEffectParam;
inline int controller_get_axis(int min, int max, int value) {
int v = (255 * (value - min)) / (max - min);
@@ -60,13 +61,13 @@ inline int controller_get_axis(int min, int max, int value) {
return v;
}
void ControllerConnect(int id);
void ControllerDisconnect(int id);
void ControllerButton(int id, uint32_t button, bool down);
void ControllerAxis(int id, Axis axis, int value);
void ControllerRightStick(int id, int x, int y);
void ControllerTouchPad(int id, int finger, bool down, float x, float y);
void ControllerResetInputState();
void Connect(int id);
void Disconnect(int id);
void SetButton(int id, uint32_t button, bool down);
void SetAxis(int id, Axis axis, int value);
void SetRightStick(int id, int x, int y);
void SetTouchPad(int id, int finger, bool down, float x, float y);
void ResetInputState();
int KYTY_SYSV_ABI PadInit();
int KYTY_SYSV_ABI PadOpen(int user_id, int type, int index, const void* param);
@@ -78,6 +79,7 @@ int KYTY_SYSV_ABI PadGetControllerInformation(int handle, PadControllerInformati
int KYTY_SYSV_ABI PadReadState(int handle, PadData* data);
int KYTY_SYSV_ABI PadRead(int handle, PadData* data, int num);
int KYTY_SYSV_ABI PadSetVibration(int handle, const PadVibrationParam* param);
int KYTY_SYSV_ABI PadSetTriggerEffect(int handle, const PadTriggerEffectParam* param);
int KYTY_SYSV_ABI PadResetLightBar(int handle);
int KYTY_SYSV_ABI PadSetLightBar(int handle, const PadLightBarParam* param);
+1 -5
View File
@@ -2644,7 +2644,7 @@ static int KYTY_SYSV_ABI AmmWaitCommandBufferCompletion(uint32_t submission_id)
} // namespace Ampr
LIB_DEFINE(InitAmpr_1_Ampr) {
LIB_DEFINE(InitAmpr_1) {
LIB_FUNC("8aI7R7WaOlc", Ampr::CommandBufferConstructor);
LIB_FUNC("a8uLzYY--tM", Ampr::AprCommandBufferConstructor);
LIB_FUNC("Qs1xtplKo0U", Ampr::AprCommandBufferDestructor);
@@ -2742,8 +2742,4 @@ LIB_DEFINE(InitAmpr_1_Ampr) {
} // namespace LibAmpr
LIB_DEFINE(InitAmpr_1) {
LibAmpr::InitAmpr_1_Ampr(s);
}
} // namespace Libs
+3 -1
View File
@@ -808,7 +808,7 @@ LIB_DEFINE(InitLibcInternal_1) {
} // namespace LibcInternal
LIB_USING(LibC);
namespace LibC {
LIB_DEFINE(InitLibC_1) {
LibcInternal::InitLibcInternal_1(s);
@@ -835,4 +835,6 @@ LIB_DEFINE(InitLibC_1) {
LIB_FUNC("DiGVep5yB5w", LibC::std_execute_once);
}
} // namespace LibC
} // namespace Libs
+1 -5
View File
@@ -16,14 +16,10 @@ static KYTY_SYSV_ABI uint32_t RazorCpuIsCapturing() {
return 0;
}
LIB_DEFINE(InitLibRazorCpu_1) {
LIB_DEFINE(InitRazorCpu_1) {
LIB_FUNC("EboejOQvLL4", LibRazorCpu::RazorCpuIsCapturing);
}
} // namespace LibRazorCpu
LIB_DEFINE(InitDebug_1) {
LibRazorCpu::InitLibRazorCpu_1(s);
}
} // namespace Libs
+15 -19
View File
@@ -512,10 +512,6 @@ bool KernelIsDispatchingSignalOnCurrentThread() {
return g_dispatching_signal_handler;
}
static void QueuePendingSignal(Pthread thread, int signum) {
PthreadQueuePendingSignal(thread, signum);
}
#if KYTY_PLATFORM != KYTY_PLATFORM_WINDOWS
static void WaitForSignalDispatch(Pthread thread, int signum) {
constexpr auto DISPATCH_WAIT_STEP = std::chrono::microseconds(1000);
@@ -529,10 +525,6 @@ static void WaitForSignalDispatch(Pthread thread, int signum) {
}
#endif
static bool TakePendingSignal(Pthread thread, int signum) {
return PthreadTakePendingSignal(thread, signum);
}
struct SignalMcontext {
uint64_t mc_onstack;
uint64_t mc_rdi;
@@ -985,7 +977,7 @@ static void HostSignalDispatchHandler(int /*host_signal*/, siginfo_t* /*info*/,
auto* host_ctx = static_cast<ucontext_t*>(native_context);
for (int signum = 0; signum < static_cast<int>(std::size(g_exception_handlers)); signum++) {
if (!TakePendingSignal(current, signum)) {
if (!PthreadTakePendingSignal(current, signum)) {
continue;
}
@@ -1046,7 +1038,7 @@ static NtQueueApcThreadExFunc GetNtQueueApcThreadEx() {
static void SignalApcHandler(void* arg1, void* arg2, void* /*arg3*/, PCONTEXT context) {
auto* thread = static_cast<Pthread>(arg1);
const auto signum = static_cast<int>(reinterpret_cast<intptr_t>(arg2));
if (!TakePendingSignal(thread, signum)) {
if (!PthreadTakePendingSignal(thread, signum)) {
return;
}
@@ -1081,7 +1073,7 @@ void KernelDispatchPendingSignalForCurrentThread() {
}
for (int signum = 0; signum < static_cast<int>(std::size(g_exception_handlers)); signum++) {
if (!TakePendingSignal(current, signum)) {
if (!PthreadTakePendingSignal(current, signum)) {
continue;
}
@@ -1159,7 +1151,7 @@ static int KYTY_SYSV_ABI KernelRaiseException(Pthread thread, int signum) {
return KERNEL_ERROR_EINVAL;
}
QueuePendingSignal(thread, signum);
PthreadQueuePendingSignal(thread, signum);
KytyUserApcOption option {};
option.UserApcFlags = KytyQueueUserApcFlagsSpecialUserApc;
@@ -1168,7 +1160,7 @@ static int KYTY_SYSV_ABI KernelRaiseException(Pthread thread, int signum) {
reinterpret_cast<void*>(static_cast<intptr_t>(signum)), nullptr);
if (status != 0) {
TakePendingSignal(thread, signum);
PthreadTakePendingSignal(thread, signum);
CloseHandle(target_thread);
LOGF("\t NtQueueApcThreadEx failed: target_os_thread=%" PRIu64 ", status=0x%016" PRIx64
"\n",
@@ -1194,9 +1186,9 @@ static int KYTY_SYSV_ABI KernelRaiseException(Pthread thread, int signum) {
return KERNEL_ERROR_EINVAL;
}
QueuePendingSignal(thread, signum);
PthreadQueuePendingSignal(thread, signum);
if (!PthreadKillHost(thread, SignalDispatchHostSignal())) {
TakePendingSignal(thread, signum);
PthreadTakePendingSignal(thread, signum);
LOGF("\t pthread_kill failed for target thread\n");
return KERNEL_ERROR_EINVAL;
}
@@ -3028,9 +3020,9 @@ namespace EventQueue = LibKernel::EventQueue;
namespace EventFlag = LibKernel::EventFlag;
namespace Semaphore = LibKernel::Semaphore;
LIB_DEFINE(InitFiber_1) {
LIB_USING(Fiber);
namespace Fiber {
LIB_DEFINE(InitFiber_1) {
LIB_FUNC("hVYD7Ou2pCQ", Fiber::FiberInitialize);
LIB_FUNC("7+OJIpko9RY", Fiber::FiberInitializeInternal);
LIB_FUNC("asjUJJ+aa8s", Fiber::FiberOptParamInitialize);
@@ -3048,13 +3040,17 @@ LIB_DEFINE(InitFiber_1) {
LIB_FUNC("0dy4JtMUcMQ", Fiber::FiberGetThreadFramePointerAddress);
}
LIB_DEFINE(InitCoredump_1) {
LIB_USING(Coredump);
} // namespace Fiber
namespace Coredump {
LIB_DEFINE(InitCoredump_1) {
LIB_FUNC("8zLSfEfW5AU", Coredump::sceCoredumpRegisterCoredumpHandler);
LIB_FUNC("fFkhOgztiCA", Coredump::sceCoredumpUnregisterCoredumpHandler);
}
} // namespace Coredump
LIB_DEFINE(InitLibKernel_1_FS) {
LIB_FUNC("1G3lF1Gg1k8", FileSystem::KernelOpen);
LIB_FUNC("UK2Tl2DWUns", FileSystem::KernelClose);
+1 -18
View File
@@ -42,23 +42,6 @@ static int KYTY_SYSV_ABI PadGetTriggerEffectState(int
return 0;
}
static int KYTY_SYSV_ABI PadSetTriggerEffect(int handle, const void* param) {
PRINT_NAME();
LOGF("\t handle = %d\n"
"\t param = 0x%016" PRIx64 "\n",
handle, reinterpret_cast<uint64_t>(param));
if (handle != 1) {
return -2137915389; /* 0x80920003 */
}
if (param == nullptr) {
return -2137915391; /* 0x80920001 */
}
return OK;
}
static int KYTY_SYSV_ABI PadSetVibrationTriggerEffectWeakWhileEmbeddedMicInUse(bool enabled) {
PRINT_NAME();
@@ -198,7 +181,7 @@ LIB_DEFINE(InitPad_1) {
LIB_FUNC("rIZnR6eSpvk", Controller::PadResetOrientation);
LIB_FUNC("vDLMoJLde8I", PadSetTiltCorrectionState);
LIB_FUNC("gjP9-KQzoUk", Controller::PadGetControllerInformation);
LIB_FUNC("2JgFB2n9oUM", PadSetTriggerEffect);
LIB_FUNC("2JgFB2n9oUM", Controller::PadSetTriggerEffect);
LIB_FUNC("YndgXqQVV7c", Controller::PadReadState);
LIB_FUNC("q1cHNfGycLI", Controller::PadRead);
LIB_FUNC("yFVnOdGxvZY", Controller::PadSetVibration);
+6 -10
View File
@@ -78,7 +78,7 @@ static int KYTY_SYSV_ABI RtcCheckValid(const RtcDateTime* time) {
return OK;
}
static int RtcGetDaysInMonth(int year, int month) {
static int GetDaysInMonth(int year, int month) {
if (year <= 0 || year > 9999) {
return RTC_ERROR_INVALID_YEAR;
}
@@ -106,7 +106,7 @@ static int KYTY_SYSV_ABI RtcIsLeapYear(int year) {
static int KYTY_SYSV_ABI RtcGetDayOfWeek(int year, int month, int day) {
PRINT_NAME();
const auto days = RtcGetDaysInMonth(year, month);
const auto days = GetDaysInMonth(year, month);
if (days < 0) {
return days;
}
@@ -118,10 +118,10 @@ static int KYTY_SYSV_ABI RtcGetDayOfWeek(int year, int month, int day) {
return (dow == 7 ? 0 : dow);
}
static int KYTY_SYSV_ABI RtcGetDaysInMonthExport(int year, int month) {
static int KYTY_SYSV_ABI RtcGetDaysInMonth(int year, int month) {
PRINT_NAME();
return RtcGetDaysInMonth(year, month);
return GetDaysInMonth(year, month);
}
static int KYTY_SYSV_ABI RtcGetTickResolution() {
@@ -549,7 +549,7 @@ static int KYTY_SYSV_ABI RtcTickAddWeeks(RtcTick* dst, const RtcTick* src, int32
} // namespace Rtc
LIB_DEFINE(InitRtc_1_Rtc) {
LIB_DEFINE(InitRtc_1) {
LIB_FUNC("lPEBYdVX0XQ", Rtc::RtcCheckValid);
LIB_FUNC("8Yr143yEnRo", Rtc::RtcConvertLocalTimeToUtc);
LIB_FUNC("M1TvFst-jrM", Rtc::RtcConvertUtcToLocalTime);
@@ -560,7 +560,7 @@ LIB_DEFINE(InitRtc_1_Rtc) {
LIB_FUNC("zO9UL3qIINQ", Rtc::RtcGetCurrentNetworkTick);
LIB_FUNC("CyIK-i4XdgQ", Rtc::RtcGetDayOfWeek);
LIB_FUNC("Ug8pCwQvh0c", Rtc::RtcIsLeapYear);
LIB_FUNC("3O7Ln8AqJ1o", Rtc::RtcGetDaysInMonthExport);
LIB_FUNC("3O7Ln8AqJ1o", Rtc::RtcGetDaysInMonth);
LIB_FUNC("8w-H19ip48I", Rtc::RtcGetTick);
LIB_FUNC("jMNwqYr4R-k", Rtc::RtcGetTickResolution);
LIB_FUNC("BtqmpTRXHgk", Rtc::RtcGetTime_t);
@@ -580,8 +580,4 @@ LIB_DEFINE(InitRtc_1_Rtc) {
} // namespace LibRtc
LIB_DEFINE(InitRtc_1) {
LibRtc::InitRtc_1_Rtc(s);
}
} // namespace Libs
-4
View File
@@ -47,8 +47,4 @@ LIB_DEFINE(InitVideoOut_1) {
} // namespace LibGen5
LIB_DEFINE(InitVideoOut_1) {
LibGen5::InitVideoOut_1(s);
}
} // namespace Libs
+64 -47
View File
@@ -6,10 +6,6 @@
namespace Libs {
namespace LibcInternal {
LIB_DEFINE(InitLibcInternal_1);
} // namespace LibcInternal
namespace LibContentDelete {
LIB_DEFINE(InitContentDelete_1);
} // namespace LibContentDelete
@@ -46,15 +42,38 @@ namespace LibPsml {
LIB_DEFINE(InitPsml_1);
} // namespace LibPsml
namespace LibC {
LIB_DEFINE(InitLibC_1);
LIB_DEFINE(InitAppContent_1);
} // namespace LibC
namespace LibAmpr {
LIB_DEFINE(InitAmpr_1);
LIB_DEFINE(InitAudio_1);
} // namespace LibAmpr
namespace Coredump {
LIB_DEFINE(InitCoredump_1);
LIB_DEFINE(InitDbgAddressSanitizer_1);
LIB_DEFINE(InitDebug_1);
LIB_DEFINE(InitDialog_1);
} // namespace Coredump
namespace LibRazorCpu {
LIB_DEFINE(InitRazorCpu_1);
} // namespace LibRazorCpu
namespace Fiber {
LIB_DEFINE(InitFiber_1);
} // namespace Fiber
namespace LibRtc {
LIB_DEFINE(InitRtc_1);
} // namespace LibRtc
namespace LibGen5 {
LIB_DEFINE(InitVideoOut_1);
} // namespace LibGen5
LIB_DEFINE(InitAppContent_1);
LIB_DEFINE(InitAudio_1);
LIB_DEFINE(InitDbgAddressSanitizer_1);
LIB_DEFINE(InitDialog_1);
LIB_DEFINE(InitFont_1);
LIB_DEFINE(InitFontFt_1);
LIB_DEFINE(InitAgcDriver_1);
@@ -65,52 +84,50 @@ LIB_DEFINE(InitPlayGo_1);
LIB_DEFINE(InitPngDec_1);
LIB_DEFINE(InitPlatform_1);
LIB_DEFINE(InitRudp_1);
LIB_DEFINE(InitRtc_1);
LIB_DEFINE(InitSaveData_1);
LIB_DEFINE(InitShare_1);
LIB_DEFINE(InitSysmodule_1);
LIB_DEFINE(InitSystemService_1);
LIB_DEFINE(InitTextToSpeech2_1);
LIB_DEFINE(InitUserService_1);
LIB_DEFINE(InitVideoOut_1);
void InitAll(Loader::SymbolDatabase* s) {
LIB_LOAD(InitAudio_1);
LIB_LOAD(InitAmpr_1);
LIB_LOAD(InitAppContent_1);
LIB_LOAD(InitCoredump_1);
LIB_LOAD(LibContentDelete::InitContentDelete_1);
LIB_LOAD(LibContentExport::InitContentExport_1);
LIB_LOAD(LibContentSearch::InitContentSearch_1);
LIB_LOAD(InitLibC_1);
LIB_LOAD(InitDbgAddressSanitizer_1);
LIB_LOAD(InitDebug_1);
LIB_LOAD(InitDialog_1);
LIB_LOAD(InitFiber_1);
LIB_LOAD(InitFont_1);
LIB_LOAD(InitFontFt_1);
LIB_LOAD(InitAgcDriver_1);
LIB_LOAD(InitLibKernel_1);
LIB_LOAD(LibMouse::InitMouse_1);
LIB_LOAD(LibKeyboard::InitKeyboard_1);
LIB_LOAD(Ime::InitPlatform_1_Ime);
LIB_LOAD(InitNet_1);
LIB_LOAD(InitPad_1);
LIB_LOAD(InitPlayGo_1);
LIB_LOAD(LibPsml::InitPsml_1);
LIB_LOAD(InitPngDec_1);
LIB_LOAD(InitPlatform_1);
LIB_LOAD(InitRudp_1);
LIB_LOAD(InitRtc_1);
LIB_LOAD(InitSaveData_1);
LIB_LOAD(InitShare_1);
LIB_LOAD(InitSysmodule_1);
LIB_LOAD(InitSystemService_1);
LIB_LOAD(InitTextToSpeech2_1);
LIB_LOAD(LibUlt::InitUlt_1);
LIB_LOAD(InitUserService_1);
LIB_LOAD(VideoDec2::InitVideoDec2_1);
LIB_LOAD(InitVideoOut_1);
InitAudio_1(s);
LibAmpr::InitAmpr_1(s);
InitAppContent_1(s);
Coredump::InitCoredump_1(s);
LibContentDelete::InitContentDelete_1(s);
LibContentExport::InitContentExport_1(s);
LibContentSearch::InitContentSearch_1(s);
LibC::InitLibC_1(s);
InitDbgAddressSanitizer_1(s);
LibRazorCpu::InitRazorCpu_1(s);
InitDialog_1(s);
Fiber::InitFiber_1(s);
InitFont_1(s);
InitFontFt_1(s);
InitAgcDriver_1(s);
InitLibKernel_1(s);
LibMouse::InitMouse_1(s);
LibKeyboard::InitKeyboard_1(s);
Ime::InitPlatform_1_Ime(s);
InitNet_1(s);
InitPad_1(s);
InitPlayGo_1(s);
LibPsml::InitPsml_1(s);
InitPngDec_1(s);
InitPlatform_1(s);
InitRudp_1(s);
LibRtc::InitRtc_1(s);
InitSaveData_1(s);
InitShare_1(s);
InitSysmodule_1(s);
InitSystemService_1(s);
InitTextToSpeech2_1(s);
LibUlt::InitUlt_1(s);
InitUserService_1(s);
VideoDec2::InitVideoDec2_1(s);
LibGen5::InitVideoOut_1(s);
}
namespace LibContentExport {
-9
View File
@@ -27,15 +27,6 @@
static constexpr int g_module_version_major = mv1; \
static constexpr int g_module_version_minor = mv2;
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define LIB_USING(n) \
using n::g_library; \
using n::g_library_version; \
using n::g_module; \
using n::g_module_version_major; \
using n::g_module_version_minor;
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define LIB_LOAD(name) name(s)
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define LIB_ADD(n, f, t) \
{ \
Loader::SymbolResolve sr {}; \
+144
View File
@@ -2950,6 +2950,28 @@ public:
"dynamic view identity omitted mapping, format, mip, layer, type, "
"or storage usage");
auto video_out_info = color_info;
video_out_info.pixel_format = vk::Format::eA2R10G10B10UnormPack32;
video_out_info.guest_format = Prospero::BufferFormat::k10_10_10_2UNorm;
Libs::Graphics::Image video_out(m_runtime_context, scheduler,
video_out_info);
auto video_out_view_info = sampled;
video_out_view_info.format = video_out_info.pixel_format;
video_out_view_info.usage = vk::ImageUsageFlagBits::eTransferSrc;
const auto video_out_view = video_out.FindView(video_out_view_info);
auto storage_alias_info = video_out_view_info;
storage_alias_info.format = vk::Format::eA2B10G10R10UnormPack32;
storage_alias_info.usage = vk::ImageUsageFlagBits::eStorage;
const auto storage_alias_view = video_out.FindView(storage_alias_info);
Require(
name, "video-out storage alias usage",
ImageViewOps::FormatsCompatible(video_out_info.pixel_format,
storage_alias_info.format) &&
static_cast<bool>(video_out.backing.usage &
vk::ImageUsageFlagBits::eStorage) &&
video_out_view != nullptr && storage_alias_view != nullptr,
"compatible video-out backing was created without storage usage");
ImageInfo depth_info{};
depth_info.pixel_format = vk::Format::eD32Sfloat;
depth_info.guest_format = Prospero::BufferFormat::k32Float;
@@ -12655,6 +12677,76 @@ TestCase ScalarAbsI32UpdatesScc() {
O::V_MOV_B32, O::BUFFER_STORE_DWORD, O::S_ENDPGM}};
}
TestCase ScalarAbsdiffBitset64AndSetprio() {
using O = ShaderOpcode;
std::vector<u32> code;
auto capture_scc = [&](u32 dst_sgpr) {
code.push_back(
EncodeSop2(0x0a, dst_sgpr, InlineU32(1), InlineU32(0)));
};
code.push_back(EncodeSMovB32(0, InlineU32(2)));
code.push_back(EncodeSMovB32(1, InlineU32(5)));
code.push_back(EncodeSop2(0x2c, 10, 0, 1));
capture_scc(20);
AppendSMovLiteral(&code, 0, 0xffffffffu);
code.push_back(EncodeSMovB32(1, InlineU32(0)));
code.push_back(EncodeSop2(0x2c, 11, 0, 1));
capture_scc(21);
AppendSMovLiteral(&code, 0, 0x80000000u);
code.push_back(EncodeSop2(0x2c, 12, 0, 1));
capture_scc(22);
code.push_back(EncodeSMovB32(1, InlineU32(1)));
code.push_back(EncodeSop2(0x2c, 13, 0, 1));
capture_scc(23);
code.push_back(EncodeSop2(0x2c, 14, 0, 0));
capture_scc(24);
AppendSMovLiteral(&code, 2, 65u);
AppendSMovLiteral(&code, 3, 101u);
code.push_back(EncodeSMovB32(4, InlineU32(0)));
code.push_back(EncodeSMovB32(5, InlineU32(0)));
code.push_back(EncodeSop1(0x1e, 4, 2));
AppendStoreSgprPair(&code, 4, 10);
code.push_back(EncodeSop1(0x1e, 4, 3));
AppendStoreSgprPair(&code, 4, 12);
code.push_back(EncodeSop1(0x1c, 4, 2));
AppendStoreSgprPair(&code, 4, 14);
code.push_back(EncodeSop1(0x1c, 4, 3));
AppendStoreSgprPair(&code, 4, 16);
code.push_back(EncodeSopp(0x0f, 3));
AppendStoreSgpr(&code, 10, 0);
AppendStoreSgpr(&code, 11, 1);
AppendStoreSgpr(&code, 12, 2);
AppendStoreSgpr(&code, 13, 3);
AppendStoreSgpr(&code, 14, 4);
AppendStoreSgpr(&code, 20, 5);
AppendStoreSgpr(&code, 21, 6);
AppendStoreSgpr(&code, 22, 7);
AppendStoreSgpr(&code, 23, 8);
AppendStoreSgpr(&code, 24, 9);
AppendEnd(&code);
TestCase test;
test.name = "ScalarAbsdiffBitset64AndSetprio";
test.code = std::move(code);
test.expected = {3u, 1u, 0x80000000u, 0x7fffffffu, 0u,
1u, 1u, 1u, 1u, 0u,
2u, 0u, 2u, 32u, 0u,
32u, 0u, 0u};
test.opcodes = {O::S_MOV_B32, O::S_ABSDIFF_I32, O::S_CSELECT_B32,
O::S_BITSET1_B64, O::S_BITSET0_B64, O::S_SETPRIO,
O::V_MOV_B32,
O::BUFFER_STORE_DWORD, O::S_ENDPGM};
test.decoded_counts = {{"S_ABSDIFF_I32", 5},
{"S_BITSET1_B64", 2},
{"S_BITSET0_B64", 2},
{"S_SETPRIO 0x00000003", 1}};
return test;
}
TestCase ScalarShiftLeftAddSccCarryEdges() {
using O = ShaderOpcode;
@@ -14155,6 +14247,55 @@ TestCase VectorAddcWritesPerLaneCarryOut() {
return test;
}
TestCase VectorSubCoCiU32CompactAndVop3() {
using O = ShaderOpcode;
std::vector<u32> code;
code.push_back(EncodeVop2(0x1a, 4, InlineU32(2), 0));
AppendBufferLoadDword(&code, 1, 4);
code.push_back(EncodeVop2(0x25, 5, InlineU32(16), 4));
AppendBufferLoadDword(&code, 2, 5);
code.push_back(EncodeVop2(0x1b, 3, InlineU32(1), 0));
code.push_back(EncodeVopc(0xc5, InlineU32(0), 3));
code.push_back(EncodeSop1(0x04, 20, 106));
code.push_back(EncodeVop2(0x29, 10, Vgpr(1), 2));
AppendVMovU32(&code, 6, 1);
code.push_back(EncodeVop2(0x01, 11, InlineU32(0), 6));
AppendStoreVgprAtLaneDwordOffset(&code, 10, 0, 0);
AppendStoreVgprAtLaneDwordOffset(&code, 11, 0, 4);
code.push_back(EncodeVopc(0xc2, InlineU32(0), 6));
AppendVop3B(&code, 0x129u, 12, 22, Vgpr(1), Vgpr(2), 20);
AppendVop3(&code, 0x101u, 13, InlineU32(0), Vgpr(6), 22);
code.push_back(EncodeVop2(0x01, 14, InlineU32(0), 6));
AppendStoreVgprAtLaneDwordOffset(&code, 12, 0, 8);
AppendStoreVgprAtLaneDwordOffset(&code, 13, 0, 12);
AppendStoreVgprAtLaneDwordOffset(&code, 14, 0, 16);
AppendEnd(&code);
TestCase test;
test.name = "VectorSubCoCiU32CompactAndVop3";
test.code = std::move(code);
test.initial = {5u, 5u, 3u, 3u, 3u, 3u, 5u, 3u, 0u, 0u,
0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u};
test.expected = {2u, 1u, 0xfffffffeu, 0xffffffffu, 0u, 0u, 1u,
1u, 2u, 1u, 0xfffffffeu, 0xffffffffu, 0u, 0u,
1u, 1u, 0u, 0u, 0u, 0u};
test.opcodes = {O::V_MOV_B32, O::V_LSHLREV_B32, O::V_ADD_NC_U32,
O::V_AND_B32, O::V_CMP_NE_U32, O::V_CMP_EQ_U32,
O::V_SUB_CO_CI_U32, O::V_CNDMASK_B32, O::S_MOV_B64,
O::BUFFER_LOAD_DWORD, O::BUFFER_STORE_DWORD, O::S_ENDPGM};
test.decoded_counts = {{"V_SUB_CO_CI_U32", 2}};
test.required_spirv = {"OpISub", "OpUGreaterThan", "OpLogicalOr"};
test.compute_info.threads_num[0] = 4;
test.compute_info.threads_num[1] = 1;
test.compute_info.threads_num[2] = 1;
test.compute_info.thread_ids_num = 1;
test.compute_info.wave_size = 32;
test.has_compute_info = true;
return test;
}
TestCase VectorSubrevCoCiU32ExactRawOnGpu() {
using O = ShaderOpcode;
@@ -21146,6 +21287,7 @@ std::vector<TestCase> MakeCases() {
AddCase(ScalarArithmeticSccCarryBorrowOverflow);
AddCase(ScalarMinMaxSccComparisonEdges);
AddCase(ScalarAbsI32UpdatesScc);
AddCase(ScalarAbsdiffBitset64AndSetprio);
AddCase(ScalarShiftLeftAddSccCarryEdges);
AddCase(ScalarCompareOps);
AddCase(ScalarShiftAddAndMaskOps);
@@ -21191,6 +21333,7 @@ std::vector<TestCase> MakeCases() {
AddCase(VectorMbcntUsesThreadMask);
AddCase(VectorAddcWritesPerLaneCarryOut);
AddCase(VectorAddcUsesPerLaneCarryIn);
AddCase(VectorSubCoCiU32CompactAndVop3);
AddCase(VectorSubrevCoCiU32ExactRawOnGpu);
AddCase(VectorVop3BSubrevCoCiUsesEncodedMasks);
AddCase(VectorVop3BCarryOutWritesSgprMask);
@@ -23439,6 +23582,7 @@ void CheckStorageTextureDepthTileUploadLayout() {
"1x1 R8_UINT depth tile lost its 64 KiB source footprint");
std::printf("[host] %-32s ok\n", "StorageTextureDepthTileUpload");
}
void CheckImageSamplerSpecialization() {
ShaderSamplerResource filtered_sampler{};
filtered_sampler.fields[2] =