early-access version 3605

This commit is contained in:
pineappleEA 2023-05-23 02:50:14 +02:00
parent b6b3e678ad
commit 1537f02c4c
14 changed files with 61 additions and 50 deletions

View File

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

View File

@ -154,6 +154,11 @@ void AudioRenderer::ThreadFunc() {
return;
case RenderMessage::AudioRenderer_Render: {
if (system.IsShuttingDown()) [[unlikely]] {
std::this_thread::sleep_for(std::chrono::milliseconds(5));
mailbox->ADSPSendMessage(RenderMessage::AudioRenderer_RenderResponse);
continue;
}
std::array<bool, MaxRendererSessions> buffers_reset{};
std::array<u64, MaxRendererSessions> render_times_taken{};
const auto start_time{system.CoreTiming().GetClockTicks()};

View File

@ -27,7 +27,7 @@ bool SystemManager::InitializeUnsafe() {
if (!active) {
if (adsp.Start()) {
active = true;
thread = std::jthread([this](std::stop_token stop_token) { ThreadFunc(); });
thread = std::jthread([this](std::stop_token stop_token) { ThreadFunc(stop_token); });
}
}
@ -39,8 +39,7 @@ void SystemManager::Stop() {
return;
}
active = false;
update.store(true);
update.notify_all();
thread.request_stop();
thread.join();
adsp.Stop();
}
@ -85,12 +84,12 @@ bool SystemManager::Remove(System& system_) {
return true;
}
void SystemManager::ThreadFunc() {
void SystemManager::ThreadFunc(std::stop_token stop_token) {
static constexpr char name[]{"AudioRenderSystemManager"};
MicroProfileOnThreadCreate(name);
Common::SetCurrentThreadName(name);
Common::SetCurrentThreadPriority(Common::ThreadPriority::High);
while (active) {
while (active && !stop_token.stop_requested()) {
{
std::scoped_lock l{mutex1};

View File

@ -66,13 +66,7 @@ private:
/**
* Main thread responsible for command generation.
*/
void ThreadFunc();
enum class StreamState {
Filling,
Steady,
Draining,
};
void ThreadFunc(std::stop_token stop_token);
/// Core system
Core::System& core;
@ -90,8 +84,6 @@ private:
ADSP::ADSP& adsp;
/// AudioRenderer mailbox for communication
ADSP::AudioRenderer_Mailbox* mailbox{};
/// Atomic for main thread to wait on
std::atomic<bool> update{};
};
} // namespace AudioCore::AudioRenderer

View File

@ -270,8 +270,8 @@ u64 SinkStream::GetExpectedPlayedSampleCount() {
void SinkStream::WaitFreeSpace() {
std::unique_lock lk{release_mutex};
release_cv.wait(
lk, [this]() { return queued_buffers < max_queue_size || system.IsShuttingDown(); });
release_cv.wait_for(lk, std::chrono::milliseconds(5),
[this]() { return queued_buffers < max_queue_size; });
}
} // namespace AudioCore::Sink

View File

@ -144,7 +144,7 @@ public:
return state_tracker;
}
void CheckFeedbackLoop(ImageView& image_view) const noexcept {
void BarrierFeedbackLoop() const noexcept {
// OpenGL does not require a barrier for attachment feedback loops.
}

View File

@ -175,7 +175,6 @@ public:
std::array<f32, 4> words{};
};
template <bool CheckFeedbackLoop = false>
inline void PushImageDescriptors(TextureCache& texture_cache,
GuestDescriptorQueue& guest_descriptor_queue,
const Shader::Info& info, RescalingPushConstant& rescaling,
@ -193,9 +192,6 @@ inline void PushImageDescriptors(TextureCache& texture_cache,
const VkImageView vk_image_view{image_view.Handle(desc.type)};
guest_descriptor_queue.AddSampledImage(vk_image_view, sampler);
rescaling.PushTexture(texture_cache.IsRescaling(image_view));
if constexpr (CheckFeedbackLoop) {
texture_cache.CheckFeedbackLoop(image_view);
}
}
}
for (const auto& desc : info.image_descriptors) {
@ -207,9 +203,6 @@ inline void PushImageDescriptors(TextureCache& texture_cache,
const VkImageView vk_image_view{image_view.StorageView(desc.type, desc.format)};
guest_descriptor_queue.AddImage(vk_image_view);
rescaling.PushImage(texture_cache.IsRescaling(image_view));
if constexpr (CheckFeedbackLoop) {
texture_cache.CheckFeedbackLoop(image_view);
}
}
}
}

View File

@ -457,8 +457,8 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
const VideoCommon::ImageViewInOut* views_it{views.data()};
const auto prepare_stage{[&](size_t stage) LAMBDA_FORCEINLINE {
buffer_cache.BindHostStageBuffers(stage);
PushImageDescriptors<true>(texture_cache, guest_descriptor_queue, stage_infos[stage],
rescaling, samplers_it, views_it);
PushImageDescriptors(texture_cache, guest_descriptor_queue, stage_infos[stage], rescaling,
samplers_it, views_it);
const auto& info{stage_infos[0]};
if (info.uses_render_area) {
render_area.uses_render_area = true;
@ -481,12 +481,13 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
if constexpr (Spec::enabled_stages[4]) {
prepare_stage(4);
}
texture_cache.UpdateRenderTargets(false);
texture_cache.CheckFeedbackLoop(views);
ConfigureDraw(rescaling, render_area);
}
void GraphicsPipeline::ConfigureDraw(const RescalingPushConstant& rescaling,
const RenderAreaPushConstant& render_area) {
texture_cache.UpdateRenderTargets(false);
scheduler.RequestRenderpass(texture_cache.GetFramebuffer());
if (!is_built.load(std::memory_order::relaxed)) {

View File

@ -106,15 +106,6 @@ public:
return *master_semaphore;
}
[[nodiscard]] bool IsRenderpassImage(VkImage image) const noexcept {
for (u32 i = 0; i < num_renderpass_images; i++) {
if (image == renderpass_images[i]) {
return true;
}
}
return false;
}
std::mutex submit_mutex;
private:

View File

@ -861,10 +861,8 @@ VkBuffer TextureCacheRuntime::GetTemporaryBuffer(size_t needed_size) {
return *buffers[level];
}
void TextureCacheRuntime::CheckFeedbackLoop(ImageView& image_view) {
if (scheduler.IsRenderpassImage(image_view.ImageHandle())) {
scheduler.RequestOutsideRenderPassOperationContext();
}
void TextureCacheRuntime::BarrierFeedbackLoop() {
scheduler.RequestOutsideRenderPassOperationContext();
}
void TextureCacheRuntime::ReinterpretImage(Image& dst, Image& src,

View File

@ -103,7 +103,7 @@ public:
[[nodiscard]] VkBuffer GetTemporaryBuffer(size_t needed_size);
void CheckFeedbackLoop(ImageView& image_view);
void BarrierFeedbackLoop();
const Device& device;
Scheduler& scheduler;

View File

@ -182,6 +182,42 @@ void TextureCache<P>::FillComputeImageViews(std::span<ImageViewInOut> views) {
views);
}
template <class P>
void TextureCache<P>::CheckFeedbackLoop(std::span<const ImageViewInOut> views) {
const bool requires_barrier = [&] {
for (const auto& view : views) {
if (!view.id) {
continue;
}
auto& image_view = slot_image_views[view.id];
// Check color targets
for (const auto& ct_view_id : render_targets.color_buffer_ids) {
if (ct_view_id) {
auto& ct_view = slot_image_views[ct_view_id];
if (image_view.image_id == ct_view.image_id) {
return true;
}
}
}
// Check zeta target
if (render_targets.depth_buffer_id) {
auto& zt_view = slot_image_views[render_targets.depth_buffer_id];
if (image_view.image_id == zt_view.image_id) {
return true;
}
}
}
return false;
}();
if (requires_barrier) {
runtime.BarrierFeedbackLoop();
}
}
template <class P>
typename P::Sampler* TextureCache<P>::GetGraphicsSampler(u32 index) {
if (index > channel_state->graphics_sampler_table.Limit()) {
@ -2374,11 +2410,6 @@ bool TextureCache<P>::IsFullClear(ImageViewId id) {
scissor.max_y >= size.height;
}
template <class P>
void TextureCache<P>::CheckFeedbackLoop(ImageView& image_view) {
runtime.CheckFeedbackLoop(image_view);
}
template <class P>
void TextureCache<P>::CreateChannel(struct Tegra::Control::ChannelState& channel) {
VideoCommon::ChannelSetupCaches<TextureCacheChannelInfo>::CreateChannel(channel);

View File

@ -148,6 +148,9 @@ public:
/// Fill image_view_ids with the compute images in indices
void FillComputeImageViews(std::span<ImageViewInOut> views);
/// Handle feedback loops during draws.
void CheckFeedbackLoop(std::span<const ImageViewInOut> views);
/// Get the sampler from the graphics descriptor table in the specified index
Sampler* GetGraphicsSampler(u32 index);
@ -224,9 +227,6 @@ public:
[[nodiscard]] bool IsRescaling(const ImageViewBase& image_view) const noexcept;
/// Handle feedback loops during draws.
void CheckFeedbackLoop(ImageView& image_view);
/// Create channel state.
void CreateChannel(Tegra::Control::ChannelState& channel) final override;

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include <stb_dxt.h>
#include <string.h>
#include "common/alignment.h"
#include "video_core/textures/bcn.h"