early-access version 3730
This commit is contained in:
parent
c30c5be9f1
commit
a324a138b2
22 changed files with 173 additions and 134 deletions
|
@ -1,7 +1,7 @@
|
||||||
yuzu emulator early access
|
yuzu emulator early access
|
||||||
=============
|
=============
|
||||||
|
|
||||||
This is the source code for early-access 3729.
|
This is the source code for early-access 3730.
|
||||||
|
|
||||||
## Legal Notice
|
## Legal Notice
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ public:
|
||||||
return push_count;
|
return push_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t Push(const std::span<T> input) {
|
std::size_t Push(std::span<const T> input) {
|
||||||
return Push(input.data(), input.size());
|
return Push(input.data(), input.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
#include "common/concepts.h"
|
|
||||||
#include "common/make_unique_for_overwrite.h"
|
#include "common/make_unique_for_overwrite.h"
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
@ -19,15 +18,22 @@ namespace Common {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class ScratchBuffer {
|
class ScratchBuffer {
|
||||||
public:
|
public:
|
||||||
using iterator = T*;
|
|
||||||
using const_iterator = const T*;
|
|
||||||
using value_type = T;
|
|
||||||
using element_type = T;
|
using element_type = T;
|
||||||
using iterator_category = std::contiguous_iterator_tag;
|
using value_type = T;
|
||||||
|
using size_type = size_t;
|
||||||
|
using difference_type = std::ptrdiff_t;
|
||||||
|
using pointer = T*;
|
||||||
|
using const_pointer = const T*;
|
||||||
|
using reference = T&;
|
||||||
|
using const_reference = const T&;
|
||||||
|
using iterator = pointer;
|
||||||
|
using const_iterator = const_pointer;
|
||||||
|
using iterator_category = std::random_access_iterator_tag;
|
||||||
|
using iterator_concept = std::contiguous_iterator_tag;
|
||||||
|
|
||||||
ScratchBuffer() = default;
|
ScratchBuffer() = default;
|
||||||
|
|
||||||
explicit ScratchBuffer(size_t initial_capacity)
|
explicit ScratchBuffer(size_type initial_capacity)
|
||||||
: last_requested_size{initial_capacity}, buffer_capacity{initial_capacity},
|
: last_requested_size{initial_capacity}, buffer_capacity{initial_capacity},
|
||||||
buffer{Common::make_unique_for_overwrite<T[]>(initial_capacity)} {}
|
buffer{Common::make_unique_for_overwrite<T[]>(initial_capacity)} {}
|
||||||
|
|
||||||
|
@ -39,7 +45,7 @@ public:
|
||||||
|
|
||||||
/// This will only grow the buffer's capacity if size is greater than the current capacity.
|
/// This will only grow the buffer's capacity if size is greater than the current capacity.
|
||||||
/// The previously held data will remain intact.
|
/// The previously held data will remain intact.
|
||||||
void resize(size_t size) {
|
void resize(size_type size) {
|
||||||
if (size > buffer_capacity) {
|
if (size > buffer_capacity) {
|
||||||
auto new_buffer = Common::make_unique_for_overwrite<T[]>(size);
|
auto new_buffer = Common::make_unique_for_overwrite<T[]>(size);
|
||||||
std::move(buffer.get(), buffer.get() + buffer_capacity, new_buffer.get());
|
std::move(buffer.get(), buffer.get() + buffer_capacity, new_buffer.get());
|
||||||
|
@ -51,7 +57,7 @@ public:
|
||||||
|
|
||||||
/// This will only grow the buffer's capacity if size is greater than the current capacity.
|
/// This will only grow the buffer's capacity if size is greater than the current capacity.
|
||||||
/// The previously held data will be destroyed if a reallocation occurs.
|
/// The previously held data will be destroyed if a reallocation occurs.
|
||||||
void resize_destructive(size_t size) {
|
void resize_destructive(size_type size) {
|
||||||
if (size > buffer_capacity) {
|
if (size > buffer_capacity) {
|
||||||
buffer_capacity = size;
|
buffer_capacity = size;
|
||||||
buffer = Common::make_unique_for_overwrite<T[]>(buffer_capacity);
|
buffer = Common::make_unique_for_overwrite<T[]>(buffer_capacity);
|
||||||
|
@ -59,43 +65,43 @@ public:
|
||||||
last_requested_size = size;
|
last_requested_size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] T* data() noexcept {
|
[[nodiscard]] pointer data() noexcept {
|
||||||
return buffer.get();
|
return buffer.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] const T* data() const noexcept {
|
[[nodiscard]] const_pointer data() const noexcept {
|
||||||
return buffer.get();
|
return buffer.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] T* begin() noexcept {
|
[[nodiscard]] iterator begin() noexcept {
|
||||||
return data();
|
return data();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] const T* begin() const noexcept {
|
[[nodiscard]] const_iterator begin() const noexcept {
|
||||||
return data();
|
return data();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] T* end() noexcept {
|
[[nodiscard]] iterator end() noexcept {
|
||||||
return data() + last_requested_size;
|
return data() + last_requested_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] const T* end() const noexcept {
|
[[nodiscard]] const_iterator end() const noexcept {
|
||||||
return data() + last_requested_size;
|
return data() + last_requested_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] T& operator[](size_t i) {
|
[[nodiscard]] reference operator[](size_type i) {
|
||||||
return buffer[i];
|
return buffer[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] const T& operator[](size_t i) const {
|
[[nodiscard]] const_reference operator[](size_type i) const {
|
||||||
return buffer[i];
|
return buffer[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] size_t size() const noexcept {
|
[[nodiscard]] size_type size() const noexcept {
|
||||||
return last_requested_size;
|
return last_requested_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] size_t capacity() const noexcept {
|
[[nodiscard]] size_type capacity() const noexcept {
|
||||||
return buffer_capacity;
|
return buffer_capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,8 +112,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t last_requested_size{};
|
size_type last_requested_size{};
|
||||||
size_t buffer_capacity{};
|
size_type buffer_capacity{};
|
||||||
std::unique_ptr<T[]> buffer{};
|
std::unique_ptr<T[]> buffer{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -338,6 +338,14 @@ public:
|
||||||
return m_parent != nullptr;
|
return m_parent != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::span<KSynchronizationObject*> GetSynchronizationObjectBuffer() {
|
||||||
|
return m_sync_object_buffer.sync_objects;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::span<Handle> GetHandleBuffer() {
|
||||||
|
return m_sync_object_buffer.handles;
|
||||||
|
}
|
||||||
|
|
||||||
u16 GetUserDisableCount() const;
|
u16 GetUserDisableCount() const;
|
||||||
void SetInterruptFlag();
|
void SetInterruptFlag();
|
||||||
void ClearInterruptFlag();
|
void ClearInterruptFlag();
|
||||||
|
@ -855,6 +863,7 @@ private:
|
||||||
u32* m_light_ipc_data{};
|
u32* m_light_ipc_data{};
|
||||||
KProcessAddress m_tls_address{};
|
KProcessAddress m_tls_address{};
|
||||||
KLightLock m_activity_pause_lock;
|
KLightLock m_activity_pause_lock;
|
||||||
|
SyncObjectBuffer m_sync_object_buffer{};
|
||||||
s64 m_schedule_count{};
|
s64 m_schedule_count{};
|
||||||
s64 m_last_scheduled_tick{};
|
s64 m_last_scheduled_tick{};
|
||||||
std::array<QueueEntry, Core::Hardware::NUM_CPU_CORES> m_per_core_priority_queue_entry{};
|
std::array<QueueEntry, Core::Hardware::NUM_CPU_CORES> m_per_core_priority_queue_entry{};
|
||||||
|
|
|
@ -38,22 +38,31 @@ Result SendAsyncRequestWithUserBuffer(Core::System& system, Handle* out_event_ha
|
||||||
|
|
||||||
Result ReplyAndReceive(Core::System& system, s32* out_index, uint64_t handles_addr, s32 num_handles,
|
Result ReplyAndReceive(Core::System& system, s32* out_index, uint64_t handles_addr, s32 num_handles,
|
||||||
Handle reply_target, s64 timeout_ns) {
|
Handle reply_target, s64 timeout_ns) {
|
||||||
|
// Ensure number of handles is valid.
|
||||||
|
R_UNLESS(0 <= num_handles && num_handles <= ArgumentHandleCountMax, ResultOutOfRange);
|
||||||
|
|
||||||
|
// Get the synchronization context.
|
||||||
auto& kernel = system.Kernel();
|
auto& kernel = system.Kernel();
|
||||||
auto& handle_table = GetCurrentProcess(kernel).GetHandleTable();
|
auto& handle_table = GetCurrentProcess(kernel).GetHandleTable();
|
||||||
|
auto objs = GetCurrentThread(kernel).GetSynchronizationObjectBuffer();
|
||||||
|
auto handles = GetCurrentThread(kernel).GetHandleBuffer();
|
||||||
|
|
||||||
R_UNLESS(0 <= num_handles && num_handles <= ArgumentHandleCountMax, ResultOutOfRange);
|
// Copy user handles.
|
||||||
R_UNLESS(GetCurrentMemory(kernel).IsValidVirtualAddressRange(
|
if (num_handles > 0) {
|
||||||
handles_addr, static_cast<u64>(sizeof(Handle) * num_handles)),
|
// Ensure we can try to get the handles.
|
||||||
ResultInvalidPointer);
|
R_UNLESS(GetCurrentMemory(kernel).IsValidVirtualAddressRange(
|
||||||
|
handles_addr, static_cast<u64>(sizeof(Handle) * num_handles)),
|
||||||
|
ResultInvalidPointer);
|
||||||
|
|
||||||
std::array<Handle, Svc::ArgumentHandleCountMax> handles;
|
// Get the handles.
|
||||||
GetCurrentMemory(kernel).ReadBlock(handles_addr, handles.data(), sizeof(Handle) * num_handles);
|
GetCurrentMemory(kernel).ReadBlock(handles_addr, handles.data(),
|
||||||
|
sizeof(Handle) * num_handles);
|
||||||
|
|
||||||
// Convert handle list to object table.
|
// Convert the handles to objects.
|
||||||
std::array<KSynchronizationObject*, Svc::ArgumentHandleCountMax> objs;
|
R_UNLESS(handle_table.GetMultipleObjects<KSynchronizationObject>(
|
||||||
R_UNLESS(handle_table.GetMultipleObjects<KSynchronizationObject>(objs.data(), handles.data(),
|
objs.data(), handles.data(), num_handles),
|
||||||
num_handles),
|
ResultInvalidHandle);
|
||||||
ResultInvalidHandle);
|
}
|
||||||
|
|
||||||
// Ensure handles are closed when we're done.
|
// Ensure handles are closed when we're done.
|
||||||
SCOPE_EXIT({
|
SCOPE_EXIT({
|
||||||
|
|
|
@ -47,21 +47,35 @@ Result ResetSignal(Core::System& system, Handle handle) {
|
||||||
R_THROW(ResultInvalidHandle);
|
R_THROW(ResultInvalidHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Result WaitSynchronization(Core::System& system, int32_t* out_index, const Handle* handles,
|
/// Wait for the given handles to synchronize, timeout after the specified nanoseconds
|
||||||
int32_t num_handles, int64_t timeout_ns) {
|
Result WaitSynchronization(Core::System& system, int32_t* out_index, u64 user_handles,
|
||||||
|
int32_t num_handles, int64_t timeout_ns) {
|
||||||
|
LOG_TRACE(Kernel_SVC, "called user_handles={:#x}, num_handles={}, timeout_ns={}", user_handles,
|
||||||
|
num_handles, timeout_ns);
|
||||||
|
|
||||||
// Ensure number of handles is valid.
|
// Ensure number of handles is valid.
|
||||||
R_UNLESS(0 <= num_handles && num_handles <= Svc::ArgumentHandleCountMax, ResultOutOfRange);
|
R_UNLESS(0 <= num_handles && num_handles <= Svc::ArgumentHandleCountMax, ResultOutOfRange);
|
||||||
|
|
||||||
// Get the synchronization context.
|
// Get the synchronization context.
|
||||||
auto& kernel = system.Kernel();
|
auto& kernel = system.Kernel();
|
||||||
auto& handle_table = GetCurrentProcess(kernel).GetHandleTable();
|
auto& handle_table = GetCurrentProcess(kernel).GetHandleTable();
|
||||||
std::array<KSynchronizationObject*, Svc::ArgumentHandleCountMax> objs;
|
auto objs = GetCurrentThread(kernel).GetSynchronizationObjectBuffer();
|
||||||
|
auto handles = GetCurrentThread(kernel).GetHandleBuffer();
|
||||||
|
|
||||||
// Copy user handles.
|
// Copy user handles.
|
||||||
if (num_handles > 0) {
|
if (num_handles > 0) {
|
||||||
|
// Ensure we can try to get the handles.
|
||||||
|
R_UNLESS(GetCurrentMemory(kernel).IsValidVirtualAddressRange(
|
||||||
|
user_handles, static_cast<u64>(sizeof(Handle) * num_handles)),
|
||||||
|
ResultInvalidPointer);
|
||||||
|
|
||||||
|
// Get the handles.
|
||||||
|
GetCurrentMemory(kernel).ReadBlock(user_handles, handles.data(),
|
||||||
|
sizeof(Handle) * num_handles);
|
||||||
|
|
||||||
// Convert the handles to objects.
|
// Convert the handles to objects.
|
||||||
R_UNLESS(handle_table.GetMultipleObjects<KSynchronizationObject>(objs.data(), handles,
|
R_UNLESS(handle_table.GetMultipleObjects<KSynchronizationObject>(
|
||||||
num_handles),
|
objs.data(), handles.data(), num_handles),
|
||||||
ResultInvalidHandle);
|
ResultInvalidHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,23 +94,6 @@ static Result WaitSynchronization(Core::System& system, int32_t* out_index, cons
|
||||||
R_RETURN(res);
|
R_RETURN(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wait for the given handles to synchronize, timeout after the specified nanoseconds
|
|
||||||
Result WaitSynchronization(Core::System& system, int32_t* out_index, u64 user_handles,
|
|
||||||
int32_t num_handles, int64_t timeout_ns) {
|
|
||||||
LOG_TRACE(Kernel_SVC, "called user_handles={:#x}, num_handles={}, timeout_ns={}", user_handles,
|
|
||||||
num_handles, timeout_ns);
|
|
||||||
|
|
||||||
// Ensure number of handles is valid.
|
|
||||||
R_UNLESS(0 <= num_handles && num_handles <= Svc::ArgumentHandleCountMax, ResultOutOfRange);
|
|
||||||
std::array<Handle, Svc::ArgumentHandleCountMax> handles;
|
|
||||||
if (num_handles > 0) {
|
|
||||||
GetCurrentMemory(system.Kernel())
|
|
||||||
.ReadBlock(user_handles, handles.data(), num_handles * sizeof(Handle));
|
|
||||||
}
|
|
||||||
|
|
||||||
R_RETURN(WaitSynchronization(system, out_index, handles.data(), num_handles, timeout_ns));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Resumes a thread waiting on WaitSynchronization
|
/// Resumes a thread waiting on WaitSynchronization
|
||||||
Result CancelSynchronization(Core::System& system, Handle handle) {
|
Result CancelSynchronization(Core::System& system, Handle handle) {
|
||||||
LOG_TRACE(Kernel_SVC, "called handle=0x{:X}", handle);
|
LOG_TRACE(Kernel_SVC, "called handle=0x{:X}", handle);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "audio_core/renderer/audio_device.h"
|
#include "audio_core/renderer/audio_device.h"
|
||||||
#include "common/common_funcs.h"
|
#include "common/common_funcs.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/settings.h"
|
#include "common/scratch_buffer.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/hle/kernel/k_event.h"
|
#include "core/hle/kernel/k_event.h"
|
||||||
|
@ -124,12 +124,15 @@ private:
|
||||||
|
|
||||||
void GetReleasedAudioInBuffer(HLERequestContext& ctx) {
|
void GetReleasedAudioInBuffer(HLERequestContext& ctx) {
|
||||||
const auto write_buffer_size = ctx.GetWriteBufferNumElements<u64>();
|
const auto write_buffer_size = ctx.GetWriteBufferNumElements<u64>();
|
||||||
tmp_buffer.resize_destructive(write_buffer_size);
|
released_buffer.resize_destructive(write_buffer_size);
|
||||||
tmp_buffer[0] = 0;
|
released_buffer[0] = 0;
|
||||||
|
|
||||||
const auto count = impl->GetReleasedBuffers(tmp_buffer);
|
const auto count = impl->GetReleasedBuffers(released_buffer);
|
||||||
|
|
||||||
ctx.WriteBuffer(tmp_buffer);
|
LOG_TRACE(Service_Audio, "called. Session {} released {} buffers",
|
||||||
|
impl->GetSystem().GetSessionId(), count);
|
||||||
|
|
||||||
|
ctx.WriteBuffer(released_buffer);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
|
@ -155,7 +158,6 @@ private:
|
||||||
LOG_DEBUG(Service_Audio, "called. Buffer count={}", buffer_count);
|
LOG_DEBUG(Service_Audio, "called. Buffer count={}", buffer_count);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
rb.Push(buffer_count);
|
rb.Push(buffer_count);
|
||||||
}
|
}
|
||||||
|
@ -195,7 +197,7 @@ private:
|
||||||
KernelHelpers::ServiceContext service_context;
|
KernelHelpers::ServiceContext service_context;
|
||||||
Kernel::KEvent* event;
|
Kernel::KEvent* event;
|
||||||
std::shared_ptr<AudioCore::AudioIn::In> impl;
|
std::shared_ptr<AudioCore::AudioIn::In> impl;
|
||||||
Common::ScratchBuffer<u64> tmp_buffer;
|
Common::ScratchBuffer<u64> released_buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
AudInU::AudInU(Core::System& system_)
|
AudInU::AudInU(Core::System& system_)
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "audio_core/renderer/audio_device.h"
|
#include "audio_core/renderer/audio_device.h"
|
||||||
#include "common/common_funcs.h"
|
#include "common/common_funcs.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
#include "common/scratch_buffer.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
#include "common/swap.h"
|
#include "common/swap.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
|
@ -102,8 +103,8 @@ private:
|
||||||
AudioOutBuffer buffer{};
|
AudioOutBuffer buffer{};
|
||||||
std::memcpy(&buffer, in_buffer.data(), sizeof(AudioOutBuffer));
|
std::memcpy(&buffer, in_buffer.data(), sizeof(AudioOutBuffer));
|
||||||
|
|
||||||
[[maybe_unused]] auto sessionid{impl->GetSystem().GetSessionId()};
|
LOG_TRACE(Service_Audio, "called. Session {} Appending buffer {:08X}",
|
||||||
LOG_TRACE(Service_Audio, "called. Session {} Appending buffer {:08X}", sessionid, tag);
|
impl->GetSystem().GetSessionId(), tag);
|
||||||
|
|
||||||
auto result = impl->AppendBuffer(buffer, tag);
|
auto result = impl->AppendBuffer(buffer, tag);
|
||||||
|
|
||||||
|
@ -123,12 +124,15 @@ private:
|
||||||
|
|
||||||
void GetReleasedAudioOutBuffers(HLERequestContext& ctx) {
|
void GetReleasedAudioOutBuffers(HLERequestContext& ctx) {
|
||||||
const auto write_buffer_size = ctx.GetWriteBufferNumElements<u64>();
|
const auto write_buffer_size = ctx.GetWriteBufferNumElements<u64>();
|
||||||
tmp_buffer.resize_destructive(write_buffer_size);
|
released_buffer.resize_destructive(write_buffer_size);
|
||||||
tmp_buffer[0] = 0;
|
released_buffer[0] = 0;
|
||||||
|
|
||||||
const auto count = impl->GetReleasedBuffers(tmp_buffer);
|
const auto count = impl->GetReleasedBuffers(released_buffer);
|
||||||
|
|
||||||
ctx.WriteBuffer(tmp_buffer);
|
ctx.WriteBuffer(released_buffer);
|
||||||
|
|
||||||
|
LOG_TRACE(Service_Audio, "called. Session {} released {} buffers",
|
||||||
|
impl->GetSystem().GetSessionId(), count);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
|
@ -154,7 +158,6 @@ private:
|
||||||
LOG_DEBUG(Service_Audio, "called. Buffer count={}", buffer_count);
|
LOG_DEBUG(Service_Audio, "called. Buffer count={}", buffer_count);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
rb.Push(buffer_count);
|
rb.Push(buffer_count);
|
||||||
}
|
}
|
||||||
|
@ -165,7 +168,6 @@ private:
|
||||||
LOG_DEBUG(Service_Audio, "called. Played samples={}", samples_played);
|
LOG_DEBUG(Service_Audio, "called. Played samples={}", samples_played);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 4};
|
IPC::ResponseBuilder rb{ctx, 4};
|
||||||
|
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
rb.Push(samples_played);
|
rb.Push(samples_played);
|
||||||
}
|
}
|
||||||
|
@ -205,7 +207,7 @@ private:
|
||||||
KernelHelpers::ServiceContext service_context;
|
KernelHelpers::ServiceContext service_context;
|
||||||
Kernel::KEvent* event;
|
Kernel::KEvent* event;
|
||||||
std::shared_ptr<AudioCore::AudioOut::Out> impl;
|
std::shared_ptr<AudioCore::AudioOut::Out> impl;
|
||||||
Common::ScratchBuffer<u64> tmp_buffer;
|
Common::ScratchBuffer<u64> released_buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
AudOutU::AudOutU(Core::System& system_)
|
AudOutU::AudOutU(Core::System& system_)
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "common/common_funcs.h"
|
#include "common/common_funcs.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/polyfill_ranges.h"
|
#include "common/polyfill_ranges.h"
|
||||||
|
#include "common/scratch_buffer.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/hle/kernel/k_event.h"
|
#include "core/hle/kernel/k_event.h"
|
||||||
|
@ -119,23 +120,23 @@ private:
|
||||||
auto is_buffer_b{ctx.BufferDescriptorB()[0].Size() != 0};
|
auto is_buffer_b{ctx.BufferDescriptorB()[0].Size() != 0};
|
||||||
if (is_buffer_b) {
|
if (is_buffer_b) {
|
||||||
const auto buffersB{ctx.BufferDescriptorB()};
|
const auto buffersB{ctx.BufferDescriptorB()};
|
||||||
tmp_output.resize_destructive(buffersB[0].Size());
|
output_buffer.resize_destructive(buffersB[0].Size());
|
||||||
tmp_performance.resize_destructive(buffersB[1].Size());
|
performance_buffer.resize_destructive(buffersB[1].Size());
|
||||||
} else {
|
} else {
|
||||||
const auto buffersC{ctx.BufferDescriptorC()};
|
const auto buffersC{ctx.BufferDescriptorC()};
|
||||||
tmp_output.resize_destructive(buffersC[0].Size());
|
output_buffer.resize_destructive(buffersC[0].Size());
|
||||||
tmp_performance.resize_destructive(buffersC[1].Size());
|
performance_buffer.resize_destructive(buffersC[1].Size());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto result = impl->RequestUpdate(input, tmp_performance, tmp_output);
|
auto result = impl->RequestUpdate(input, performance_buffer, output_buffer);
|
||||||
|
|
||||||
if (result.IsSuccess()) {
|
if (result.IsSuccess()) {
|
||||||
if (is_buffer_b) {
|
if (is_buffer_b) {
|
||||||
ctx.WriteBufferB(tmp_output.data(), tmp_output.size(), 0);
|
ctx.WriteBufferB(output_buffer.data(), output_buffer.size(), 0);
|
||||||
ctx.WriteBufferB(tmp_performance.data(), tmp_performance.size(), 1);
|
ctx.WriteBufferB(performance_buffer.data(), performance_buffer.size(), 1);
|
||||||
} else {
|
} else {
|
||||||
ctx.WriteBufferC(tmp_output.data(), tmp_output.size(), 0);
|
ctx.WriteBufferC(output_buffer.data(), output_buffer.size(), 0);
|
||||||
ctx.WriteBufferC(tmp_performance.data(), tmp_performance.size(), 1);
|
ctx.WriteBufferC(performance_buffer.data(), performance_buffer.size(), 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR(Service_Audio, "RequestUpdate failed error 0x{:02X}!", result.description);
|
LOG_ERROR(Service_Audio, "RequestUpdate failed error 0x{:02X}!", result.description);
|
||||||
|
@ -233,8 +234,8 @@ private:
|
||||||
Kernel::KEvent* rendered_event;
|
Kernel::KEvent* rendered_event;
|
||||||
Manager& manager;
|
Manager& manager;
|
||||||
std::unique_ptr<Renderer> impl;
|
std::unique_ptr<Renderer> impl;
|
||||||
Common::ScratchBuffer<u8> tmp_output;
|
Common::ScratchBuffer<u8> output_buffer;
|
||||||
Common::ScratchBuffer<u8> tmp_performance;
|
Common::ScratchBuffer<u8> performance_buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IAudioDevice final : public ServiceFramework<IAudioDevice> {
|
class IAudioDevice final : public ServiceFramework<IAudioDevice> {
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
#include "common/scratch_buffer.h"
|
||||||
#include "core/hle/service/audio/hwopus.h"
|
#include "core/hle/service/audio/hwopus.h"
|
||||||
#include "core/hle/service/ipc_helpers.h"
|
#include "core/hle/service/ipc_helpers.h"
|
||||||
|
|
||||||
|
@ -68,13 +69,13 @@ private:
|
||||||
ExtraBehavior extra_behavior) {
|
ExtraBehavior extra_behavior) {
|
||||||
u32 consumed = 0;
|
u32 consumed = 0;
|
||||||
u32 sample_count = 0;
|
u32 sample_count = 0;
|
||||||
tmp_samples.resize_destructive(ctx.GetWriteBufferNumElements<opus_int16>());
|
samples.resize_destructive(ctx.GetWriteBufferNumElements<opus_int16>());
|
||||||
|
|
||||||
if (extra_behavior == ExtraBehavior::ResetContext) {
|
if (extra_behavior == ExtraBehavior::ResetContext) {
|
||||||
ResetDecoderContext();
|
ResetDecoderContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DecodeOpusData(consumed, sample_count, ctx.ReadBuffer(), tmp_samples, performance)) {
|
if (!DecodeOpusData(consumed, sample_count, ctx.ReadBuffer(), samples, performance)) {
|
||||||
LOG_ERROR(Audio, "Failed to decode opus data");
|
LOG_ERROR(Audio, "Failed to decode opus data");
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
// TODO(ogniK): Use correct error code
|
// TODO(ogniK): Use correct error code
|
||||||
|
@ -90,7 +91,7 @@ private:
|
||||||
if (performance) {
|
if (performance) {
|
||||||
rb.Push<u64>(*performance);
|
rb.Push<u64>(*performance);
|
||||||
}
|
}
|
||||||
ctx.WriteBuffer(tmp_samples);
|
ctx.WriteBuffer(samples);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DecodeOpusData(u32& consumed, u32& sample_count, std::span<const u8> input,
|
bool DecodeOpusData(u32& consumed, u32& sample_count, std::span<const u8> input,
|
||||||
|
@ -154,7 +155,7 @@ private:
|
||||||
OpusDecoderPtr decoder;
|
OpusDecoderPtr decoder;
|
||||||
u32 sample_rate;
|
u32 sample_rate;
|
||||||
u32 channel_count;
|
u32 channel_count;
|
||||||
Common::ScratchBuffer<opus_int16> tmp_samples;
|
Common::ScratchBuffer<opus_int16> samples;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IHardwareOpusDecoderManager final : public ServiceFramework<IHardwareOpusDecoderManager> {
|
class IHardwareOpusDecoderManager final : public ServiceFramework<IHardwareOpusDecoderManager> {
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Skyline Team and Contributors
|
// SPDX-FileCopyrightText: 2021 Skyline Team and Contributors
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
#include <cinttypes>
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/hle/kernel/k_event.h"
|
#include "core/hle/kernel/k_event.h"
|
||||||
|
@ -63,12 +62,12 @@ void NVDRV::Ioctl1(HLERequestContext& ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check device
|
// Check device
|
||||||
tmp_output.resize_destructive(ctx.GetWriteBufferSize(0));
|
output_buffer.resize_destructive(ctx.GetWriteBufferSize(0));
|
||||||
const auto input_buffer = ctx.ReadBuffer(0);
|
const auto input_buffer = ctx.ReadBuffer(0);
|
||||||
|
|
||||||
const auto nv_result = nvdrv->Ioctl1(fd, command, input_buffer, tmp_output);
|
const auto nv_result = nvdrv->Ioctl1(fd, command, input_buffer, output_buffer);
|
||||||
if (command.is_out != 0) {
|
if (command.is_out != 0) {
|
||||||
ctx.WriteBuffer(tmp_output);
|
ctx.WriteBuffer(output_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
@ -90,12 +89,12 @@ void NVDRV::Ioctl2(HLERequestContext& ctx) {
|
||||||
|
|
||||||
const auto input_buffer = ctx.ReadBuffer(0);
|
const auto input_buffer = ctx.ReadBuffer(0);
|
||||||
const auto input_inlined_buffer = ctx.ReadBuffer(1);
|
const auto input_inlined_buffer = ctx.ReadBuffer(1);
|
||||||
tmp_output.resize_destructive(ctx.GetWriteBufferSize(0));
|
output_buffer.resize_destructive(ctx.GetWriteBufferSize(0));
|
||||||
|
|
||||||
const auto nv_result =
|
const auto nv_result =
|
||||||
nvdrv->Ioctl2(fd, command, input_buffer, input_inlined_buffer, tmp_output);
|
nvdrv->Ioctl2(fd, command, input_buffer, input_inlined_buffer, output_buffer);
|
||||||
if (command.is_out != 0) {
|
if (command.is_out != 0) {
|
||||||
ctx.WriteBuffer(tmp_output);
|
ctx.WriteBuffer(output_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
@ -116,12 +115,14 @@ void NVDRV::Ioctl3(HLERequestContext& ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto input_buffer = ctx.ReadBuffer(0);
|
const auto input_buffer = ctx.ReadBuffer(0);
|
||||||
tmp_output.resize_destructive(ctx.GetWriteBufferSize(0));
|
output_buffer.resize_destructive(ctx.GetWriteBufferSize(0));
|
||||||
tmp_output_inline.resize_destructive(ctx.GetWriteBufferSize(1));
|
inline_output_buffer.resize_destructive(ctx.GetWriteBufferSize(1));
|
||||||
const auto nv_result = nvdrv->Ioctl3(fd, command, input_buffer, tmp_output, tmp_output_inline);
|
|
||||||
|
const auto nv_result =
|
||||||
|
nvdrv->Ioctl3(fd, command, input_buffer, output_buffer, inline_output_buffer);
|
||||||
if (command.is_out != 0) {
|
if (command.is_out != 0) {
|
||||||
ctx.WriteBuffer(tmp_output, 0);
|
ctx.WriteBuffer(output_buffer, 0);
|
||||||
ctx.WriteBuffer(tmp_output_inline, 1);
|
ctx.WriteBuffer(inline_output_buffer, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "common/scratch_buffer.h"
|
#include "common/scratch_buffer.h"
|
||||||
#include "core/hle/service/nvdrv/nvdrv.h"
|
#include "core/hle/service/nvdrv/nvdrv.h"
|
||||||
#include "core/hle/service/service.h"
|
#include "core/hle/service/service.h"
|
||||||
|
@ -34,8 +35,8 @@ private:
|
||||||
|
|
||||||
u64 pid{};
|
u64 pid{};
|
||||||
bool is_initialized{};
|
bool is_initialized{};
|
||||||
Common::ScratchBuffer<u8> tmp_output;
|
Common::ScratchBuffer<u8> output_buffer;
|
||||||
Common::ScratchBuffer<u8> tmp_output_inline;
|
Common::ScratchBuffer<u8> inline_output_buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::Nvidia
|
} // namespace Service::Nvidia
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <span>
|
#include <span>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <boost/container/small_vector.hpp>
|
#include <boost/container/small_vector.hpp>
|
||||||
|
|
||||||
#include "common/alignment.h"
|
#include "common/alignment.h"
|
||||||
|
@ -148,9 +149,9 @@ public:
|
||||||
this->WriteImpl(0U, m_object_buffer);
|
this->WriteImpl(0U, m_object_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<u8> Serialize() const {
|
std::span<u8> Serialize() {
|
||||||
std::vector<u8> output_buffer(sizeof(ParcelHeader) + m_data_buffer.size() +
|
m_output_buffer.resize(sizeof(ParcelHeader) + m_data_buffer.size() +
|
||||||
m_object_buffer.size());
|
m_object_buffer.size());
|
||||||
|
|
||||||
ParcelHeader header{};
|
ParcelHeader header{};
|
||||||
header.data_size = static_cast<u32>(m_data_buffer.size());
|
header.data_size = static_cast<u32>(m_data_buffer.size());
|
||||||
|
@ -158,17 +159,17 @@ public:
|
||||||
header.objects_size = static_cast<u32>(m_object_buffer.size());
|
header.objects_size = static_cast<u32>(m_object_buffer.size());
|
||||||
header.objects_offset = header.data_offset + header.data_size;
|
header.objects_offset = header.data_offset + header.data_size;
|
||||||
|
|
||||||
std::memcpy(output_buffer.data(), &header, sizeof(header));
|
std::memcpy(m_output_buffer.data(), &header, sizeof(ParcelHeader));
|
||||||
std::ranges::copy(m_data_buffer, output_buffer.data() + header.data_offset);
|
std::ranges::copy(m_data_buffer, m_output_buffer.data() + header.data_offset);
|
||||||
std::ranges::copy(m_object_buffer, output_buffer.data() + header.objects_offset);
|
std::ranges::copy(m_object_buffer, m_output_buffer.data() + header.objects_offset);
|
||||||
|
|
||||||
return output_buffer;
|
return m_output_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename T>
|
template <typename T, size_t BufferSize>
|
||||||
requires(std::is_trivially_copyable_v<T>)
|
requires(std::is_trivially_copyable_v<T>)
|
||||||
void WriteImpl(const T& val, boost::container::small_vector<u8, 0x200>& buffer) {
|
void WriteImpl(const T& val, boost::container::small_vector<u8, BufferSize>& buffer) {
|
||||||
const size_t aligned_size = Common::AlignUp(sizeof(T), 4);
|
const size_t aligned_size = Common::AlignUp(sizeof(T), 4);
|
||||||
const size_t old_size = buffer.size();
|
const size_t old_size = buffer.size();
|
||||||
buffer.resize(old_size + aligned_size);
|
buffer.resize(old_size + aligned_size);
|
||||||
|
@ -177,8 +178,9 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
boost::container::small_vector<u8, 0x200> m_data_buffer;
|
boost::container::small_vector<u8, 0x1B0> m_data_buffer;
|
||||||
boost::container::small_vector<u8, 0x200> m_object_buffer;
|
boost::container::small_vector<u8, 0x40> m_object_buffer;
|
||||||
|
boost::container::small_vector<u8, 0x200> m_output_buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::android
|
} // namespace Service::android
|
||||||
|
|
|
@ -174,8 +174,7 @@ void MaxwellDMA::CopyBlockLinearToPitch() {
|
||||||
src_operand.address = regs.offset_in;
|
src_operand.address = regs.offset_in;
|
||||||
|
|
||||||
DMA::BufferOperand dst_operand;
|
DMA::BufferOperand dst_operand;
|
||||||
u32 abs_pitch_out = std::abs(static_cast<s32>(regs.pitch_out));
|
dst_operand.pitch = static_cast<u32>(std::abs(regs.pitch_out));
|
||||||
dst_operand.pitch = abs_pitch_out;
|
|
||||||
dst_operand.width = regs.line_length_in;
|
dst_operand.width = regs.line_length_in;
|
||||||
dst_operand.height = regs.line_count;
|
dst_operand.height = regs.line_count;
|
||||||
dst_operand.address = regs.offset_out;
|
dst_operand.address = regs.offset_out;
|
||||||
|
@ -222,7 +221,7 @@ void MaxwellDMA::CopyBlockLinearToPitch() {
|
||||||
const size_t src_size =
|
const size_t src_size =
|
||||||
CalculateSize(true, bytes_per_pixel, width, height, depth, block_height, block_depth);
|
CalculateSize(true, bytes_per_pixel, width, height, depth, block_height, block_depth);
|
||||||
|
|
||||||
const size_t dst_size = static_cast<size_t>(abs_pitch_out) * regs.line_count;
|
const size_t dst_size = dst_operand.pitch * regs.line_count;
|
||||||
read_buffer.resize_destructive(src_size);
|
read_buffer.resize_destructive(src_size);
|
||||||
write_buffer.resize_destructive(dst_size);
|
write_buffer.resize_destructive(dst_size);
|
||||||
|
|
||||||
|
@ -231,7 +230,7 @@ void MaxwellDMA::CopyBlockLinearToPitch() {
|
||||||
|
|
||||||
UnswizzleSubrect(write_buffer, read_buffer, bytes_per_pixel, width, height, depth, x_offset,
|
UnswizzleSubrect(write_buffer, read_buffer, bytes_per_pixel, width, height, depth, x_offset,
|
||||||
src_params.origin.y, x_elements, regs.line_count, block_height, block_depth,
|
src_params.origin.y, x_elements, regs.line_count, block_height, block_depth,
|
||||||
abs_pitch_out);
|
dst_operand.pitch);
|
||||||
|
|
||||||
memory_manager.WriteBlockCached(regs.offset_out, write_buffer.data(), dst_size);
|
memory_manager.WriteBlockCached(regs.offset_out, write_buffer.data(), dst_size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -290,7 +290,7 @@ void Codec::Decode() {
|
||||||
return vp9_decoder->GetFrameBytes();
|
return vp9_decoder->GetFrameBytes();
|
||||||
default:
|
default:
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
return std::vector<u8>{};
|
return std::span<const u8>{};
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
AVPacketPtr packet{av_packet_alloc(), AVPacketDeleter};
|
AVPacketPtr packet{av_packet_alloc(), AVPacketDeleter};
|
||||||
|
|
|
@ -29,15 +29,15 @@ H264::H264(Host1x::Host1x& host1x_) : host1x{host1x_} {}
|
||||||
|
|
||||||
H264::~H264() = default;
|
H264::~H264() = default;
|
||||||
|
|
||||||
const std::vector<u8>& H264::ComposeFrame(const Host1x::NvdecCommon::NvdecRegisters& state,
|
std::span<const u8> H264::ComposeFrame(const Host1x::NvdecCommon::NvdecRegisters& state,
|
||||||
bool is_first_frame) {
|
bool is_first_frame) {
|
||||||
H264DecoderContext context;
|
H264DecoderContext context;
|
||||||
host1x.MemoryManager().ReadBlock(state.picture_info_offset, &context,
|
host1x.MemoryManager().ReadBlock(state.picture_info_offset, &context,
|
||||||
sizeof(H264DecoderContext));
|
sizeof(H264DecoderContext));
|
||||||
|
|
||||||
const s64 frame_number = context.h264_parameter_set.frame_number.Value();
|
const s64 frame_number = context.h264_parameter_set.frame_number.Value();
|
||||||
if (!is_first_frame && frame_number != 0) {
|
if (!is_first_frame && frame_number != 0) {
|
||||||
frame.resize(context.stream_len);
|
frame.resize_destructive(context.stream_len);
|
||||||
host1x.MemoryManager().ReadBlock(state.frame_bitstream_offset, frame.data(), frame.size());
|
host1x.MemoryManager().ReadBlock(state.frame_bitstream_offset, frame.data(), frame.size());
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
@ -135,14 +135,14 @@ const std::vector<u8>& H264::ComposeFrame(const Host1x::NvdecCommon::NvdecRegist
|
||||||
for (s32 index = 0; index < 6; index++) {
|
for (s32 index = 0; index < 6; index++) {
|
||||||
writer.WriteBit(true);
|
writer.WriteBit(true);
|
||||||
std::span<const u8> matrix{context.weight_scale};
|
std::span<const u8> matrix{context.weight_scale};
|
||||||
writer.WriteScalingList(matrix, index * 16, 16);
|
writer.WriteScalingList(scan, matrix, index * 16, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.h264_parameter_set.transform_8x8_mode_flag) {
|
if (context.h264_parameter_set.transform_8x8_mode_flag) {
|
||||||
for (s32 index = 0; index < 2; index++) {
|
for (s32 index = 0; index < 2; index++) {
|
||||||
writer.WriteBit(true);
|
writer.WriteBit(true);
|
||||||
std::span<const u8> matrix{context.weight_scale_8x8};
|
std::span<const u8> matrix{context.weight_scale_8x8};
|
||||||
writer.WriteScalingList(matrix, index * 64, 64);
|
writer.WriteScalingList(scan, matrix, index * 64, 64);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,8 +188,8 @@ void H264BitWriter::WriteBit(bool state) {
|
||||||
WriteBits(state ? 1 : 0, 1);
|
WriteBits(state ? 1 : 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void H264BitWriter::WriteScalingList(std::span<const u8> list, s32 start, s32 count) {
|
void H264BitWriter::WriteScalingList(Common::ScratchBuffer<u8>& scan, std::span<const u8> list,
|
||||||
static Common::ScratchBuffer<u8> scan{};
|
s32 start, s32 count) {
|
||||||
scan.resize_destructive(count);
|
scan.resize_destructive(count);
|
||||||
if (count == 16) {
|
if (count == 16) {
|
||||||
std::memcpy(scan.data(), zig_zag_scan.data(), scan.size());
|
std::memcpy(scan.data(), zig_zag_scan.data(), scan.size());
|
||||||
|
|
|
@ -5,9 +5,11 @@
|
||||||
|
|
||||||
#include <span>
|
#include <span>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common/bit_field.h"
|
#include "common/bit_field.h"
|
||||||
#include "common/common_funcs.h"
|
#include "common/common_funcs.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "common/scratch_buffer.h"
|
||||||
#include "video_core/host1x/nvdec_common.h"
|
#include "video_core/host1x/nvdec_common.h"
|
||||||
|
|
||||||
namespace Tegra {
|
namespace Tegra {
|
||||||
|
@ -37,7 +39,8 @@ public:
|
||||||
|
|
||||||
/// Based on section 7.3.2.1.1.1 and Table 7-4 in the H.264 specification
|
/// Based on section 7.3.2.1.1.1 and Table 7-4 in the H.264 specification
|
||||||
/// Writes the scaling matrices of the sream
|
/// Writes the scaling matrices of the sream
|
||||||
void WriteScalingList(std::span<const u8> list, s32 start, s32 count);
|
void WriteScalingList(Common::ScratchBuffer<u8>& scan, std::span<const u8> list, s32 start,
|
||||||
|
s32 count);
|
||||||
|
|
||||||
/// Return the bitstream as a vector.
|
/// Return the bitstream as a vector.
|
||||||
[[nodiscard]] std::vector<u8>& GetByteArray();
|
[[nodiscard]] std::vector<u8>& GetByteArray();
|
||||||
|
@ -63,11 +66,12 @@ public:
|
||||||
~H264();
|
~H264();
|
||||||
|
|
||||||
/// Compose the H264 frame for FFmpeg decoding
|
/// Compose the H264 frame for FFmpeg decoding
|
||||||
[[nodiscard]] const std::vector<u8>& ComposeFrame(
|
[[nodiscard]] std::span<const u8> ComposeFrame(const Host1x::NvdecCommon::NvdecRegisters& state,
|
||||||
const Host1x::NvdecCommon::NvdecRegisters& state, bool is_first_frame = false);
|
bool is_first_frame = false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<u8> frame;
|
Common::ScratchBuffer<u8> frame;
|
||||||
|
Common::ScratchBuffer<u8> scan;
|
||||||
Host1x::Host1x& host1x;
|
Host1x::Host1x& host1x;
|
||||||
|
|
||||||
struct H264ParameterSet {
|
struct H264ParameterSet {
|
||||||
|
|
|
@ -12,7 +12,7 @@ VP8::VP8(Host1x::Host1x& host1x_) : host1x{host1x_} {}
|
||||||
|
|
||||||
VP8::~VP8() = default;
|
VP8::~VP8() = default;
|
||||||
|
|
||||||
const std::vector<u8>& VP8::ComposeFrame(const Host1x::NvdecCommon::NvdecRegisters& state) {
|
std::span<const u8> VP8::ComposeFrame(const Host1x::NvdecCommon::NvdecRegisters& state) {
|
||||||
VP8PictureInfo info;
|
VP8PictureInfo info;
|
||||||
host1x.MemoryManager().ReadBlock(state.picture_info_offset, &info, sizeof(VP8PictureInfo));
|
host1x.MemoryManager().ReadBlock(state.picture_info_offset, &info, sizeof(VP8PictureInfo));
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <vector>
|
#include <span>
|
||||||
|
|
||||||
#include "common/common_funcs.h"
|
#include "common/common_funcs.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "common/scratch_buffer.h"
|
||||||
#include "video_core/host1x/nvdec_common.h"
|
#include "video_core/host1x/nvdec_common.h"
|
||||||
|
|
||||||
namespace Tegra {
|
namespace Tegra {
|
||||||
|
@ -24,11 +25,11 @@ public:
|
||||||
~VP8();
|
~VP8();
|
||||||
|
|
||||||
/// Compose the VP8 frame for FFmpeg decoding
|
/// Compose the VP8 frame for FFmpeg decoding
|
||||||
[[nodiscard]] const std::vector<u8>& ComposeFrame(
|
[[nodiscard]] std::span<const u8> ComposeFrame(
|
||||||
const Host1x::NvdecCommon::NvdecRegisters& state);
|
const Host1x::NvdecCommon::NvdecRegisters& state);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<u8> frame;
|
Common::ScratchBuffer<u8> frame;
|
||||||
Host1x::Host1x& host1x;
|
Host1x::Host1x& host1x;
|
||||||
|
|
||||||
struct VP8PictureInfo {
|
struct VP8PictureInfo {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <algorithm> // for std::copy
|
#include <algorithm> // for std::copy
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "video_core/host1x/codecs/vp9.h"
|
#include "video_core/host1x/codecs/vp9.h"
|
||||||
#include "video_core/host1x/host1x.h"
|
#include "video_core/host1x/host1x.h"
|
||||||
|
|
|
@ -4,9 +4,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <span>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "common/scratch_buffer.h"
|
||||||
#include "common/stream.h"
|
#include "common/stream.h"
|
||||||
#include "video_core/host1x/codecs/vp9_types.h"
|
#include "video_core/host1x/codecs/vp9_types.h"
|
||||||
#include "video_core/host1x/nvdec_common.h"
|
#include "video_core/host1x/nvdec_common.h"
|
||||||
|
@ -128,8 +130,8 @@ public:
|
||||||
return !current_frame_info.show_frame;
|
return !current_frame_info.show_frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a const reference to the composed frame data.
|
/// Returns a const span to the composed frame data.
|
||||||
[[nodiscard]] const std::vector<u8>& GetFrameBytes() const {
|
[[nodiscard]] std::span<const u8> GetFrameBytes() const {
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +183,7 @@ private:
|
||||||
[[nodiscard]] VpxBitStreamWriter ComposeUncompressedHeader();
|
[[nodiscard]] VpxBitStreamWriter ComposeUncompressedHeader();
|
||||||
|
|
||||||
Host1x::Host1x& host1x;
|
Host1x::Host1x& host1x;
|
||||||
std::vector<u8> frame;
|
Common::ScratchBuffer<u8> frame;
|
||||||
|
|
||||||
std::array<s8, 4> loop_filter_ref_deltas{};
|
std::array<s8, 4> loop_filter_ref_deltas{};
|
||||||
std::array<s8, 2> loop_filter_mode_deltas{};
|
std::array<s8, 2> loop_filter_mode_deltas{};
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common/common_funcs.h"
|
#include "common/common_funcs.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue