Compare commits

..

5 Commits

Author SHA1 Message Date
1b89bd2c0d Android #160 2023-12-14 00:57:11 +00:00
65b3ca6143 Merge PR 12349 2023-12-14 00:57:11 +00:00
aec017b8cf Merge PR 12345 2023-12-14 00:57:11 +00:00
d7d7a439ca Merge PR 12335 2023-12-14 00:57:11 +00:00
1882fcb5d9 Merge PR 12237 2023-12-14 00:57:10 +00:00
8 changed files with 56 additions and 22 deletions

View File

@ -2,6 +2,8 @@
|----|----|----|----|----| |----|----|----|----|----|
| [12237](https://github.com/yuzu-emu/yuzu//pull/12237) | [`a05c24242`](https://github.com/yuzu-emu/yuzu//pull/12237/files) | nce: implement instruction emulation for misaligned memory accesses | [liamwhite](https://github.com/liamwhite/) | Yes | | [12237](https://github.com/yuzu-emu/yuzu//pull/12237) | [`a05c24242`](https://github.com/yuzu-emu/yuzu//pull/12237/files) | nce: implement instruction emulation for misaligned memory accesses | [liamwhite](https://github.com/liamwhite/) | Yes |
| [12335](https://github.com/yuzu-emu/yuzu//pull/12335) | [`86d26914a`](https://github.com/yuzu-emu/yuzu//pull/12335/files) | android: Game Properties | [t895](https://github.com/t895/) | Yes | | [12335](https://github.com/yuzu-emu/yuzu//pull/12335) | [`86d26914a`](https://github.com/yuzu-emu/yuzu//pull/12335/files) | android: Game Properties | [t895](https://github.com/t895/) | Yes |
| [12345](https://github.com/yuzu-emu/yuzu//pull/12345) | [`24a0bde93`](https://github.com/yuzu-emu/yuzu//pull/12345/files) | renderer_vulkan: cap async presentation frame count | [liamwhite](https://github.com/liamwhite/) | Yes |
| [12349](https://github.com/yuzu-emu/yuzu//pull/12349) | [`8abdfcf8d`](https://github.com/yuzu-emu/yuzu//pull/12349/files) | Have GetActiveChannelCount return the system channels instead of host device channels | [Kelebek1](https://github.com/Kelebek1/) | Yes |
End of merge log. You can find the original README.md below the break. End of merge log. You can find the original README.md below the break.

View File

@ -253,8 +253,9 @@ CubebSink::~CubebSink() {
#endif #endif
} }
SinkStream* CubebSink::AcquireSinkStream(Core::System& system, u32 system_channels, SinkStream* CubebSink::AcquireSinkStream(Core::System& system, u32 system_channels_,
const std::string& name, StreamType type) { const std::string& name, StreamType type) {
system_channels = system_channels_;
SinkStreamPtr& stream = sink_streams.emplace_back(std::make_unique<CubebSinkStream>( SinkStreamPtr& stream = sink_streams.emplace_back(std::make_unique<CubebSinkStream>(
ctx, device_channels, system_channels, output_device, input_device, name, type, system)); ctx, device_channels, system_channels, output_device, input_device, name, type, system));

View File

@ -168,8 +168,9 @@ SDLSink::SDLSink(std::string_view target_device_name) {
SDLSink::~SDLSink() = default; SDLSink::~SDLSink() = default;
SinkStream* SDLSink::AcquireSinkStream(Core::System& system, u32 system_channels, SinkStream* SDLSink::AcquireSinkStream(Core::System& system, u32 system_channels_,
const std::string&, StreamType type) { const std::string&, StreamType type) {
system_channels = system_channels_;
SinkStreamPtr& stream = sink_streams.emplace_back(std::make_unique<SDLSinkStream>( SinkStreamPtr& stream = sink_streams.emplace_back(std::make_unique<SDLSinkStream>(
device_channels, system_channels, output_device, input_device, type, system)); device_channels, system_channels, output_device, input_device, type, system));
return stream.get(); return stream.get();

View File

@ -85,9 +85,21 @@ public:
*/ */
virtual void SetSystemVolume(f32 volume) = 0; virtual void SetSystemVolume(f32 volume) = 0;
/**
* Get the number of channels the game has set, can be different to the host hardware's support.
* Either 2 or 6.
*
* @return Number of device channels.
*/
u32 GetSystemChannels() const {
return system_channels;
}
protected: protected:
/// Number of device channels supported by the hardware /// Number of device channels supported by the hardware
u32 device_channels{2}; u32 device_channels{2};
/// Number of channels the game is sending
u32 system_channels{2};
}; };
using SinkPtr = std::unique_ptr<Sink>; using SinkPtr = std::unique_ptr<Sink>;

View File

@ -40,29 +40,38 @@ void SinkStream::AppendBuffer(SinkBuffer& buffer, std::span<s16> samples) {
if (system_channels == 6 && device_channels == 2) { if (system_channels == 6 && device_channels == 2) {
// We're given 6 channels, but our device only outputs 2, so downmix. // We're given 6 channels, but our device only outputs 2, so downmix.
static constexpr std::array<f32, 4> down_mix_coeff{1.0f, 0.707f, 0.251f, 0.707f}; // Front = 1.0
// Center = 0.596
// Back = 0.707
// LFE = 0.354
// 1.0 + 0.596 + 0.707 + 0.354 = 2.657, 1/2.657 = 0.37636f downscale coefficient
static constexpr std::array<f32, 4> down_mix_coeff{0.37636f, 0.22431056f, 0.13323144f,
0.26608652f};
for (u32 read_index = 0, write_index = 0; read_index < samples.size(); for (u32 read_index = 0, write_index = 0; read_index < samples.size();
read_index += system_channels, write_index += device_channels) { read_index += system_channels, write_index += device_channels) {
const auto fl =
static_cast<f32>(samples[read_index + static_cast<u32>(Channels::FrontLeft)]);
const auto fr =
static_cast<f32>(samples[read_index + static_cast<u32>(Channels::FrontRight)]);
const auto c =
static_cast<f32>(samples[read_index + static_cast<u32>(Channels::Center)]);
const auto lfe =
static_cast<f32>(samples[read_index + static_cast<u32>(Channels::LFE)]);
const auto bl =
static_cast<f32>(samples[read_index + static_cast<u32>(Channels::BackLeft)]);
const auto br =
static_cast<f32>(samples[read_index + static_cast<u32>(Channels::BackRight)]);
const auto left_sample{ const auto left_sample{
((Common::FixedPoint<49, 15>( static_cast<s32>((fl * down_mix_coeff[0] + c * down_mix_coeff[1] +
samples[read_index + static_cast<u32>(Channels::FrontLeft)]) * lfe * down_mix_coeff[2] + bl * down_mix_coeff[3]) *
down_mix_coeff[0] + volume)};
samples[read_index + static_cast<u32>(Channels::Center)] * down_mix_coeff[1] +
samples[read_index + static_cast<u32>(Channels::LFE)] * down_mix_coeff[2] +
samples[read_index + static_cast<u32>(Channels::BackLeft)] * down_mix_coeff[3]) *
volume)
.to_int()};
const auto right_sample{ const auto right_sample{
((Common::FixedPoint<49, 15>( static_cast<s32>((fr * down_mix_coeff[0] + c * down_mix_coeff[1] +
samples[read_index + static_cast<u32>(Channels::FrontRight)]) * lfe * down_mix_coeff[2] + br * down_mix_coeff[3]) *
down_mix_coeff[0] + volume)};
samples[read_index + static_cast<u32>(Channels::Center)] * down_mix_coeff[1] +
samples[read_index + static_cast<u32>(Channels::LFE)] * down_mix_coeff[2] +
samples[read_index + static_cast<u32>(Channels::BackRight)] * down_mix_coeff[3]) *
volume)
.to_int()};
samples[write_index + static_cast<u32>(Channels::FrontLeft)] = samples[write_index + static_cast<u32>(Channels::FrontLeft)] =
static_cast<s16>(std::clamp(left_sample, min, max)); static_cast<s16>(std::clamp(left_sample, min, max));

View File

@ -359,7 +359,7 @@ private:
void GetActiveChannelCount(HLERequestContext& ctx) { void GetActiveChannelCount(HLERequestContext& ctx) {
const auto& sink{system.AudioCore().GetOutputSink()}; const auto& sink{system.AudioCore().GetOutputSink()};
u32 channel_count{sink.GetDeviceChannels()}; u32 channel_count{sink.GetSystemChannels()};
LOG_DEBUG(Service_Audio, "(STUBBED) called. Channels={}", channel_count); LOG_DEBUG(Service_Audio, "(STUBBED) called. Channels={}", channel_count);

View File

@ -102,8 +102,8 @@ PresentManager::PresentManager(const vk::Instance& instance_,
memory_allocator{memory_allocator_}, scheduler{scheduler_}, swapchain{swapchain_}, memory_allocator{memory_allocator_}, scheduler{scheduler_}, swapchain{swapchain_},
surface{surface_}, blit_supported{CanBlitToSwapchain(device.GetPhysical(), surface{surface_}, blit_supported{CanBlitToSwapchain(device.GetPhysical(),
swapchain.GetImageViewFormat())}, swapchain.GetImageViewFormat())},
use_present_thread{Settings::values.async_presentation.GetValue()}, use_present_thread{Settings::values.async_presentation.GetValue()} {
image_count{swapchain.GetImageCount()} { SetImageCount();
auto& dld = device.GetLogical(); auto& dld = device.GetLogical();
cmdpool = dld.CreateCommandPool({ cmdpool = dld.CreateCommandPool({
@ -292,6 +292,13 @@ void PresentManager::RecreateSwapchain(Frame* frame) {
image_count = swapchain.GetImageCount(); image_count = swapchain.GetImageCount();
} }
void PresentManager::SetImageCount() {
// We cannot have more than 5 images in flight at any given time.
// FRAMES_IN_FLIGHT is 7, and the cache TICKS_TO_DESTROY is 6.
// Mali drivers will give us 6.
image_count = std::min<size_t>(swapchain.GetImageCount(), 5);
}
void PresentManager::CopyToSwapchain(Frame* frame) { void PresentManager::CopyToSwapchain(Frame* frame) {
bool requires_recreation = false; bool requires_recreation = false;

View File

@ -62,6 +62,8 @@ private:
void RecreateSwapchain(Frame* frame); void RecreateSwapchain(Frame* frame);
void SetImageCount();
private: private:
const vk::Instance& instance; const vk::Instance& instance;
Core::Frontend::EmuWindow& render_window; Core::Frontend::EmuWindow& render_window;