early-access version 2956

This commit is contained in:
pineappleEA 2022-09-16 18:23:25 +02:00
parent 9a930c7082
commit c7c964fa7d
8 changed files with 73 additions and 46 deletions

View file

@ -1,7 +1,7 @@
yuzu emulator early access yuzu emulator early access
============= =============
This is the source code for early-access 2955. This is the source code for early-access 2956.
## Legal Notice ## Legal Notice

View file

@ -82,7 +82,7 @@ u32 Manager::GetDeviceNames(std::vector<AudioRenderer::AudioDevice::AudioDeviceN
auto input_devices{Sink::GetDeviceListForSink(Settings::values.sink_id.GetValue(), true)}; auto input_devices{Sink::GetDeviceListForSink(Settings::values.sink_id.GetValue(), true)};
if (input_devices.size() > 1) { if (input_devices.size() > 1) {
names.push_back(AudioRenderer::AudioDevice::AudioDeviceName("Uac")); names.emplace_back("Uac");
return 1; return 1;
} }
return 0; return 0;

View file

@ -74,7 +74,7 @@ void Manager::BufferReleaseAndRegister() {
u32 Manager::GetAudioOutDeviceNames( u32 Manager::GetAudioOutDeviceNames(
std::vector<AudioRenderer::AudioDevice::AudioDeviceName>& names) const { std::vector<AudioRenderer::AudioDevice::AudioDeviceName>& names) const {
names.push_back({"DeviceOut"}); names.emplace_back("DeviceOut");
return 1; return 1;
} }

View file

@ -1,6 +1,9 @@
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include <array>
#include <span>
#include "audio_core/audio_core.h" #include "audio_core/audio_core.h"
#include "audio_core/common/feature_support.h" #include "audio_core/common/feature_support.h"
#include "audio_core/renderer/audio_device.h" #include "audio_core/renderer/audio_device.h"
@ -9,14 +12,33 @@
namespace AudioCore::AudioRenderer { namespace AudioCore::AudioRenderer {
constexpr std::array usb_device_names{
AudioDevice::AudioDeviceName{"AudioStereoJackOutput"},
AudioDevice::AudioDeviceName{"AudioBuiltInSpeakerOutput"},
AudioDevice::AudioDeviceName{"AudioTvOutput"},
AudioDevice::AudioDeviceName{"AudioUsbDeviceOutput"},
};
constexpr std::array device_names{
AudioDevice::AudioDeviceName{"AudioStereoJackOutput"},
AudioDevice::AudioDeviceName{"AudioBuiltInSpeakerOutput"},
AudioDevice::AudioDeviceName{"AudioTvOutput"},
};
constexpr std::array output_device_names{
AudioDevice::AudioDeviceName{"AudioBuiltInSpeakerOutput"},
AudioDevice::AudioDeviceName{"AudioTvOutput"},
AudioDevice::AudioDeviceName{"AudioExternalOutput"},
};
AudioDevice::AudioDevice(Core::System& system, const u64 applet_resource_user_id_, AudioDevice::AudioDevice(Core::System& system, const u64 applet_resource_user_id_,
const u32 revision) const u32 revision)
: output_sink{system.AudioCore().GetOutputSink()}, : output_sink{system.AudioCore().GetOutputSink()},
applet_resource_user_id{applet_resource_user_id_}, user_revision{revision} {} applet_resource_user_id{applet_resource_user_id_}, user_revision{revision} {}
u32 AudioDevice::ListAudioDeviceName(std::vector<AudioDeviceName>& out_buffer, u32 AudioDevice::ListAudioDeviceName(std::vector<AudioDeviceName>& out_buffer,
const size_t max_count) { const size_t max_count) const {
std::span<AudioDeviceName> names{}; std::span<const AudioDeviceName> names{};
if (CheckFeatureSupported(SupportTags::AudioUsbDeviceOutput, user_revision)) { if (CheckFeatureSupported(SupportTags::AudioUsbDeviceOutput, user_revision)) {
names = usb_device_names; names = usb_device_names;
@ -24,7 +46,7 @@ u32 AudioDevice::ListAudioDeviceName(std::vector<AudioDeviceName>& out_buffer,
names = device_names; names = device_names;
} }
u32 out_count{static_cast<u32>(std::min(max_count, names.size()))}; const u32 out_count{static_cast<u32>(std::min(max_count, names.size()))};
for (u32 i = 0; i < out_count; i++) { for (u32 i = 0; i < out_count; i++) {
out_buffer.push_back(names[i]); out_buffer.push_back(names[i]);
} }
@ -32,8 +54,8 @@ u32 AudioDevice::ListAudioDeviceName(std::vector<AudioDeviceName>& out_buffer,
} }
u32 AudioDevice::ListAudioOutputDeviceName(std::vector<AudioDeviceName>& out_buffer, u32 AudioDevice::ListAudioOutputDeviceName(std::vector<AudioDeviceName>& out_buffer,
const size_t max_count) { const size_t max_count) const {
u32 out_count{static_cast<u32>(std::min(max_count, output_device_names.size()))}; const u32 out_count{static_cast<u32>(std::min(max_count, output_device_names.size()))};
for (u32 i = 0; i < out_count; i++) { for (u32 i = 0; i < out_count; i++) {
out_buffer.push_back(output_device_names[i]); out_buffer.push_back(output_device_names[i]);
@ -45,7 +67,7 @@ void AudioDevice::SetDeviceVolumes(const f32 volume) {
output_sink.SetDeviceVolume(volume); output_sink.SetDeviceVolume(volume);
} }
f32 AudioDevice::GetDeviceVolume([[maybe_unused]] std::string_view name) { f32 AudioDevice::GetDeviceVolume([[maybe_unused]] std::string_view name) const {
return output_sink.GetDeviceVolume(); return output_sink.GetDeviceVolume();
} }

View file

@ -3,7 +3,7 @@
#pragma once #pragma once
#include <span> #include <string_view>
#include "audio_core/audio_render_manager.h" #include "audio_core/audio_render_manager.h"
@ -23,21 +23,13 @@ namespace AudioRenderer {
class AudioDevice { class AudioDevice {
public: public:
struct AudioDeviceName { struct AudioDeviceName {
std::array<char, 0x100> name; std::array<char, 0x100> name{};
AudioDeviceName(const char* name_) { constexpr AudioDeviceName(std::string_view name_) {
std::strncpy(name.data(), name_, name.size()); name_.copy(name.data(), name.size() - 1);
} }
}; };
std::array<AudioDeviceName, 4> usb_device_names{"AudioStereoJackOutput",
"AudioBuiltInSpeakerOutput", "AudioTvOutput",
"AudioUsbDeviceOutput"};
std::array<AudioDeviceName, 3> device_names{"AudioStereoJackOutput",
"AudioBuiltInSpeakerOutput", "AudioTvOutput"};
std::array<AudioDeviceName, 3> output_device_names{"AudioBuiltInSpeakerOutput", "AudioTvOutput",
"AudioExternalOutput"};
explicit AudioDevice(Core::System& system, u64 applet_resource_user_id, u32 revision); explicit AudioDevice(Core::System& system, u64 applet_resource_user_id, u32 revision);
/** /**
@ -47,7 +39,7 @@ public:
* @param max_count - Maximum number of devices to write (count of out_buffer). * @param max_count - Maximum number of devices to write (count of out_buffer).
* @return Number of device names written. * @return Number of device names written.
*/ */
u32 ListAudioDeviceName(std::vector<AudioDeviceName>& out_buffer, size_t max_count); u32 ListAudioDeviceName(std::vector<AudioDeviceName>& out_buffer, size_t max_count) const;
/** /**
* Get a list of the available output devices. * Get a list of the available output devices.
@ -57,7 +49,7 @@ public:
* @param max_count - Maximum number of devices to write (count of out_buffer). * @param max_count - Maximum number of devices to write (count of out_buffer).
* @return Number of device names written. * @return Number of device names written.
*/ */
u32 ListAudioOutputDeviceName(std::vector<AudioDeviceName>& out_buffer, size_t max_count); u32 ListAudioOutputDeviceName(std::vector<AudioDeviceName>& out_buffer, size_t max_count) const;
/** /**
* Set the volume of all streams in the backend sink. * Set the volume of all streams in the backend sink.
@ -73,7 +65,7 @@ public:
* @param name - Name of the device to check. Unused. * @param name - Name of the device to check. Unused.
* @return Volume of the device. * @return Volume of the device.
*/ */
f32 GetDeviceVolume(std::string_view name); f32 GetDeviceVolume(std::string_view name) const;
private: private:
/// Backend output sink for the device /// Backend output sink for the device

View file

@ -246,9 +246,8 @@ void AudOutU::ListAudioOuts(Kernel::HLERequestContext& ctx) {
const auto write_count = const auto write_count =
static_cast<u32>(ctx.GetWriteBufferSize() / sizeof(AudioDevice::AudioDeviceName)); static_cast<u32>(ctx.GetWriteBufferSize() / sizeof(AudioDevice::AudioDeviceName));
std::vector<AudioDevice::AudioDeviceName> device_names{}; std::vector<AudioDevice::AudioDeviceName> device_names{};
std::string print_names{};
if (write_count > 0) { if (write_count > 0) {
device_names.push_back(AudioDevice::AudioDeviceName("DeviceOut")); device_names.emplace_back("DeviceOut");
LOG_DEBUG(Service_Audio, "called. \nName=DeviceOut"); LOG_DEBUG(Service_Audio, "called. \nName=DeviceOut");
} else { } else {
LOG_DEBUG(Service_Audio, "called. Empty buffer passed in."); LOG_DEBUG(Service_Audio, "called. Empty buffer passed in.");

View file

@ -252,7 +252,7 @@ private:
std::vector<AudioDevice::AudioDeviceName> out_names{}; std::vector<AudioDevice::AudioDeviceName> out_names{};
u32 out_count = impl->ListAudioDeviceName(out_names, in_count); const u32 out_count = impl->ListAudioDeviceName(out_names, in_count);
std::string out{}; std::string out{};
for (u32 i = 0; i < out_count; i++) { for (u32 i = 0; i < out_count; i++) {
@ -365,7 +365,7 @@ private:
std::vector<AudioDevice::AudioDeviceName> out_names{}; std::vector<AudioDevice::AudioDeviceName> out_names{};
u32 out_count = impl->ListAudioOutputDeviceName(out_names, in_count); const u32 out_count = impl->ListAudioOutputDeviceName(out_names, in_count);
std::string out{}; std::string out{};
for (u32 i = 0; i < out_count; i++) { for (u32 i = 0; i < out_count; i++) {

View file

@ -13,7 +13,9 @@
#include <boost/container/static_vector.hpp> #include <boost/container/static_vector.hpp>
#include "common/alignment.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "common/thread_worker.h"
#include "video_core/textures/astc.h" #include "video_core/textures/astc.h"
class InputBitStream { class InputBitStream {
@ -1650,29 +1652,41 @@ static void DecompressBlock(std::span<const u8, 16> inBuf, const u32 blockWidth,
void Decompress(std::span<const uint8_t> data, uint32_t width, uint32_t height, uint32_t depth, void Decompress(std::span<const uint8_t> data, uint32_t width, uint32_t height, uint32_t depth,
uint32_t block_width, uint32_t block_height, std::span<uint8_t> output) { uint32_t block_width, uint32_t block_height, std::span<uint8_t> output) {
u32 block_index = 0; const u32 rows = Common::DivideUp(height, block_height);
std::size_t depth_offset = 0; const u32 cols = Common::DivideUp(width, block_width);
for (u32 z = 0; z < depth; z++) {
for (u32 y = 0; y < height; y += block_height) {
for (u32 x = 0; x < width; x += block_width) {
const std::span<const u8, 16> blockPtr{data.subspan(block_index * 16, 16)};
// Blocks can be at most 12x12 Common::ThreadWorker workers{std::max(std::thread::hardware_concurrency(), 2U) / 2,
std::array<u32, 12 * 12> uncompData; "yuzu:ASTCDecompress"};
DecompressBlock(blockPtr, block_width, block_height, uncompData);
u32 decompWidth = std::min(block_width, width - x); for (u32 z = 0; z < depth; ++z) {
u32 decompHeight = std::min(block_height, height - y); const u32 depth_offset = z * height * width * 4;
for (u32 y_index = 0; y_index < rows; ++y_index) {
auto decompress_stride = [data, width, height, depth, block_width, block_height, output,
rows, cols, z, depth_offset, y_index] {
const u32 y = y_index * block_height;
for (u32 x_index = 0; x_index < cols; ++x_index) {
const u32 block_index = (z * rows * cols) + (y_index * cols) + x_index;
const u32 x = x_index * block_width;
const std::span<u8> outRow = output.subspan(depth_offset + (y * width + x) * 4); const std::span<const u8, 16> blockPtr{data.subspan(block_index * 16, 16)};
for (u32 jj = 0; jj < decompHeight; jj++) {
std::memcpy(outRow.data() + jj * width * 4, // Blocks can be at most 12x12
uncompData.data() + jj * block_width, decompWidth * 4); std::array<u32, 12 * 12> uncompData;
DecompressBlock(blockPtr, block_width, block_height, uncompData);
u32 decompWidth = std::min(block_width, width - x);
u32 decompHeight = std::min(block_height, height - y);
const std::span<u8> outRow = output.subspan(depth_offset + (y * width + x) * 4);
for (u32 h = 0; h < decompHeight; ++h) {
std::memcpy(outRow.data() + h * width * 4,
uncompData.data() + h * block_width, decompWidth * 4);
}
} }
++block_index; };
} workers.QueueWork(std::move(decompress_stride));
} }
depth_offset += height * width * 4; workers.WaitForRequests();
} }
} }