Compare commits

..

1 Commits

Author SHA1 Message Date
Liam
6072b22a0b core: add option to break on unmapped access 2022-12-02 08:25:45 -05:00
141 changed files with 283 additions and 1646 deletions

2
.gitmodules vendored
View File

@@ -27,7 +27,7 @@
url = https://github.com/KhronosGroup/Vulkan-Headers.git
[submodule "sirit"]
path = externals/sirit
url = https://github.com/yuzu-emu/sirit
url = https://github.com/ReinUsesLisp/sirit
[submodule "mbedtls"]
path = externals/mbedtls
url = https://github.com/yuzu-emu/mbedtls

View File

@@ -3,10 +3,6 @@
cmake_minimum_required(VERSION 3.22)
# Dynarmic has cmake_minimum_required(3.12) and we may want to override
# some of its variables, which is only possible in 3.13+
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/find-modules")
@@ -47,8 +43,6 @@ option(YUZU_USE_BUNDLED_OPUS "Compile bundled opus" ON)
option(YUZU_TESTS "Compile tests" ON)
option(YUZU_USE_PRECOMPILED_HEADERS "Use precompiled headers" ON)
CMAKE_DEPENDENT_OPTION(YUZU_CRASH_DUMPS "Compile Windows crash dump (Minidump) support" OFF "WIN32" OFF)
option(YUZU_USE_BUNDLED_VCPKG "Use vcpkg for yuzu dependencies" "${MSVC}")
@@ -70,21 +64,6 @@ elseif(NOT "$ENV{VCPKG_TOOLCHAIN_FILE}" STREQUAL "")
include("$ENV{VCPKG_TOOLCHAIN_FILE}")
endif()
if (YUZU_USE_PRECOMPILED_HEADERS)
if (MSVC AND CCACHE)
# buildcache does not properly cache PCH files, leading to compilation errors.
# See https://github.com/mbitsnbites/buildcache/discussions/230
message(WARNING "buildcache does not properly support Precompiled Headers. Disabling PCH")
set(DYNARMIC_USE_PRECOMPILED_HEADERS OFF CACHE BOOL "" FORCE)
set(YUZU_USE_PRECOMPILED_HEADERS OFF CACHE BOOL "" FORCE)
endif()
endif()
if (YUZU_USE_PRECOMPILED_HEADERS)
message(STATUS "Using Precompiled Headers.")
set(CMAKE_PCH_INSTANTIATE_TEMPLATES ON)
endif()
# Default to a Release build
get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if (NOT IS_MULTI_CONFIG AND NOT CMAKE_BUILD_TYPE)
@@ -449,7 +428,7 @@ if (TARGET Boost::boost)
endif()
# Ensure libusb is properly configured (based on dolphin libusb include)
if(NOT YUZU_USE_BUNDLED_LIBUSB)
if(NOT APPLE AND NOT YUZU_USE_BUNDLED_LIBUSB)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND AND NOT CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD")
pkg_check_modules(LIBUSB QUIET libusb-1.0>=1.0.24)
@@ -459,8 +438,7 @@ if(NOT YUZU_USE_BUNDLED_LIBUSB)
if (LIBUSB_FOUND)
add_library(usb INTERFACE)
target_include_directories(usb INTERFACE "${LIBUSB_INCLUDEDIR}" "${LIBUSB_INCLUDE_DIRS}")
target_link_directories(usb INTERFACE "${LIBUSB_LIBRARY_DIRS}")
target_include_directories(usb INTERFACE "${LIBUSB_INCLUDE_DIRS}")
target_link_libraries(usb INTERFACE "${LIBUSB_LIBRARIES}")
else()
message(WARNING "libusb not found, falling back to externals")

View File

@@ -12,6 +12,9 @@ endif()
# Dynarmic
if (ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64)
if (ARCHITECTURE_arm64)
set(DYNARMIC_FRONTENDS "A32")
endif()
set(DYNARMIC_NO_BUNDLED_FMT ON)
set(DYNARMIC_IGNORE_ASSERTS ON CACHE BOOL "" FORCE)
add_subdirectory(dynarmic)
@@ -64,12 +67,8 @@ if (YUZU_USE_EXTERNAL_SDL2)
endif()
set(SDL_STATIC ON)
set(SDL_SHARED OFF)
if (APPLE)
set(SDL_FILE ON)
endif()
add_subdirectory(SDL EXCLUDE_FROM_ALL)
target_link_directories(SDL2-static INTERFACE "${SDL2_BINARY_DIR}")
endif()
# ENet

2
externals/SDL vendored

View File

@@ -82,9 +82,8 @@ if (MSVC)
/wd4324 # 'struct_name': structure was padded due to __declspec(align())
)
if (USE_CCACHE OR YUZU_USE_PRECOMPILED_HEADERS)
if (USE_CCACHE)
# when caching, we need to use /Z7 to downgrade debug info to use an older but more cachable format
# Precompiled headers are deleted if not using /Z7. See https://github.com/nanoant/CMakePCHCompiler/issues/21
add_compile_options(/Z7)
else()
add_compile_options(/Zi)
@@ -113,8 +112,6 @@ else()
$<$<CXX_COMPILER_ID:Clang>:-Wno-braced-scalar-init>
$<$<CXX_COMPILER_ID:Clang>:-Wno-unused-private-field>
$<$<CXX_COMPILER_ID:AppleClang>:-Wno-braced-scalar-init>
$<$<CXX_COMPILER_ID:AppleClang>:-Wno-unused-private-field>
)
if (ARCHITECTURE_x86_64)

View File

@@ -31,7 +31,6 @@ add_library(audio_core STATIC
out/audio_out.h
out/audio_out_system.cpp
out/audio_out_system.h
precompiled_headers.h
renderer/adsp/adsp.cpp
renderer/adsp/adsp.h
renderer/adsp/audio_renderer.cpp
@@ -234,7 +233,3 @@ if(ENABLE_SDL2)
endif()
target_compile_definitions(audio_core PRIVATE HAVE_SDL2)
endif()
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(audio_core PRIVATE precompiled_headers.h)
endif()

View File

@@ -3,7 +3,6 @@
#include "audio_core/audio_event.h"
#include "common/assert.h"
#include "common/polyfill_ranges.h"
namespace AudioCore {

View File

@@ -9,8 +9,6 @@
#include <mutex>
#include <thread>
#include "common/polyfill_thread.h"
#include "audio_core/audio_event.h"
union Result;

View File

@@ -7,8 +7,6 @@
#include <memory>
#include <mutex>
#include "common/polyfill_thread.h"
#include "audio_core/common/common.h"
#include "audio_core/renderer/system_manager.h"
#include "core/hle/service/audio/errors.h"

View File

@@ -10,7 +10,6 @@
#include "common/assert.h"
#include "common/common_funcs.h"
#include "common/common_types.h"
#include "common/polyfill_ranges.h"
namespace AudioCore {
constexpr u32 CurrentRevision = 11;

View File

@@ -1,6 +0,0 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_precompiled_headers.h"

View File

@@ -5,7 +5,6 @@
#include "audio_core/renderer/adsp/command_list_processor.h"
#include "audio_core/renderer/command/effect/i3dl2_reverb.h"
#include "common/polyfill_ranges.h"
namespace AudioCore::AudioRenderer {

View File

@@ -6,7 +6,6 @@
#include "audio_core/renderer/adsp/command_list_processor.h"
#include "audio_core/renderer/command/effect/reverb.h"
#include "common/polyfill_ranges.h"
namespace AudioCore::AudioRenderer {

View File

@@ -5,7 +5,6 @@
#include "audio_core/renderer/mix/mix_context.h"
#include "audio_core/renderer/splitter/splitter_context.h"
#include "common/polyfill_ranges.h"
namespace AudioCore::AudioRenderer {

View File

@@ -4,7 +4,6 @@
#include <ranges>
#include "audio_core/renderer/voice/voice_context.h"
#include "common/polyfill_ranges.h"
namespace AudioCore::AudioRenderer {

View File

@@ -170,8 +170,8 @@ void SinkStream::ProcessAudioIn(std::span<const s16> input_buffer, std::size_t n
// Get the minimum frames available between the currently playing buffer, and the
// amount we have left to fill
size_t frames_available{std::min<u64>(playing_buffer.frames - playing_buffer.frames_played,
num_frames - frames_written)};
size_t frames_available{std::min(playing_buffer.frames - playing_buffer.frames_played,
num_frames - frames_written)};
samples_buffer.Push(&input_buffer[frames_written * frame_size],
frames_available * frame_size);
@@ -241,8 +241,8 @@ void SinkStream::ProcessAudioOutAndRender(std::span<s16> output_buffer, std::siz
// Get the minimum frames available between the currently playing buffer, and the
// amount we have left to fill
size_t frames_available{std::min<u64>(playing_buffer.frames - playing_buffer.frames_played,
num_frames - frames_written)};
size_t frames_available{std::min(playing_buffer.frames - playing_buffer.frames_played,
num_frames - frames_written)};
samples_buffer.Pop(&output_buffer[frames_written * frame_size],
frames_available * frame_size);

View File

@@ -37,7 +37,6 @@ add_library(common STATIC
cache_management.cpp
cache_management.h
common_funcs.h
common_precompiled_headers.h
common_types.h
concepts.h
div_ceil.h
@@ -96,7 +95,6 @@ add_library(common STATIC
param_package.h
parent_of_member.h
point.h
precompiled_headers.h
quaternion.h
reader_writer_queue.h
ring_buffer.h
@@ -185,7 +183,3 @@ else()
target_link_libraries(common PRIVATE
$<IF:$<TARGET_EXISTS:zstd::libzstd_shared>,zstd::libzstd_shared,zstd::libzstd_static>)
endif()
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(common PRIVATE precompiled_headers.h)
endif()

View File

@@ -1,14 +0,0 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <algorithm>
#include <array>
#include <chrono>
#include <memory>
#include <fmt/format.h>
#include "common/assert.h"
#include "common/common_types.h"

View File

@@ -1,8 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <vector>
#include "common/fs/file.h"
#include "common/fs/fs.h"
#include "common/logging/log.h"

View File

@@ -4,7 +4,6 @@
#include <algorithm>
#include "common/fs/fs_util.h"
#include "common/polyfill_ranges.h"
namespace Common::FS {

View File

@@ -2,7 +2,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include <algorithm>
#include <sstream>
#include <unordered_map>
#include "common/fs/fs.h"

View File

@@ -8,7 +8,6 @@
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#include "common/logging/log.h"
#include "common/param_package.h"
#include "common/uuid.h"

View File

@@ -4,6 +4,7 @@
#include <atomic>
#include <chrono>
#include <climits>
#include <stop_token>
#include <thread>
#include <fmt/format.h>
@@ -17,7 +18,6 @@
#include "common/fs/fs_paths.h"
#include "common/fs/path_util.h"
#include "common/literals.h"
#include "common/polyfill_thread.h"
#include "common/thread.h"
#include "common/logging/backend.h"

View File

@@ -1,530 +0,0 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
//
// TODO: remove this file when ranges are supported by all compilation targets
//
#pragma once
#include <algorithm>
#include <utility>
#include <version>
#ifndef __cpp_lib_ranges
namespace std {
namespace ranges {
template <typename T>
concept range = requires(T& t) {
begin(t);
end(t);
};
template <typename T>
concept input_range = range<T>;
template <typename T>
concept output_range = range<T>;
template <range R>
using range_difference_t = ptrdiff_t;
//
// find, find_if, find_if_not
//
struct find_fn {
template <typename Iterator, typename T, typename Proj = std::identity>
constexpr Iterator operator()(Iterator first, Iterator last, const T& value,
Proj proj = {}) const {
for (; first != last; ++first) {
if (std::invoke(proj, *first) == value) {
return first;
}
}
return first;
}
template <ranges::input_range R, typename T, typename Proj = std::identity>
constexpr ranges::iterator_t<R> operator()(R&& r, const T& value, Proj proj = {}) const {
return operator()(ranges::begin(r), ranges::end(r), value, std::ref(proj));
}
};
struct find_if_fn {
template <typename Iterator, typename Proj = std::identity, typename Pred>
constexpr Iterator operator()(Iterator first, Iterator last, Pred pred, Proj proj = {}) const {
for (; first != last; ++first) {
if (std::invoke(pred, std::invoke(proj, *first))) {
return first;
}
}
return first;
}
template <ranges::input_range R, typename Proj = std::identity, typename Pred>
constexpr ranges::iterator_t<R> operator()(R&& r, Pred pred, Proj proj = {}) const {
return operator()(ranges::begin(r), ranges::end(r), std::ref(pred), std::ref(proj));
}
};
struct find_if_not_fn {
template <typename Iterator, typename Proj = std::identity, typename Pred>
constexpr Iterator operator()(Iterator first, Iterator last, Pred pred, Proj proj = {}) const {
for (; first != last; ++first) {
if (!std::invoke(pred, std::invoke(proj, *first))) {
return first;
}
}
return first;
}
template <ranges::input_range R, typename Proj = std::identity, typename Pred>
constexpr ranges::iterator_t<R> operator()(R&& r, Pred pred, Proj proj = {}) const {
return operator()(ranges::begin(r), ranges::end(r), std::ref(pred), std::ref(proj));
}
};
inline constexpr find_fn find;
inline constexpr find_if_fn find_if;
inline constexpr find_if_not_fn find_if_not;
//
// any_of, all_of, none_of
//
struct all_of_fn {
template <typename Iterator, typename Proj = std::identity, typename Pred>
constexpr bool operator()(Iterator first, Iterator last, Pred pred, Proj proj = {}) const {
return ranges::find_if_not(first, last, std::ref(pred), std::ref(proj)) == last;
}
template <ranges::input_range R, typename Proj = std::identity, typename Pred>
constexpr bool operator()(R&& r, Pred pred, Proj proj = {}) const {
return operator()(ranges::begin(r), ranges::end(r), std::ref(pred), std::ref(proj));
}
};
struct any_of_fn {
template <typename Iterator, typename Proj = std::identity, typename Pred>
constexpr bool operator()(Iterator first, Iterator last, Pred pred, Proj proj = {}) const {
return ranges::find_if(first, last, std::ref(pred), std::ref(proj)) != last;
}
template <ranges::input_range R, typename Proj = std::identity, typename Pred>
constexpr bool operator()(R&& r, Pred pred, Proj proj = {}) const {
return operator()(ranges::begin(r), ranges::end(r), std::ref(pred), std::ref(proj));
}
};
struct none_of_fn {
template <typename Iterator, typename Proj = std::identity, typename Pred>
constexpr bool operator()(Iterator first, Iterator last, Pred pred, Proj proj = {}) const {
return ranges::find_if(first, last, std::ref(pred), std::ref(proj)) == last;
}
template <ranges::input_range R, typename Proj = std::identity, typename Pred>
constexpr bool operator()(R&& r, Pred pred, Proj proj = {}) const {
return operator()(ranges::begin(r), ranges::end(r), std::ref(pred), std::ref(proj));
}
};
inline constexpr any_of_fn any_of;
inline constexpr all_of_fn all_of;
inline constexpr none_of_fn none_of;
//
// count, count_if
//
struct count_fn {
template <typename Iterator, typename T, typename Proj = std::identity>
constexpr ptrdiff_t operator()(Iterator first, Iterator last, const T& value,
Proj proj = {}) const {
ptrdiff_t counter = 0;
for (; first != last; ++first)
if (std::invoke(proj, *first) == value)
++counter;
return counter;
}
template <ranges::input_range R, typename T, typename Proj = std::identity>
constexpr ptrdiff_t operator()(R&& r, const T& value, Proj proj = {}) const {
return operator()(ranges::begin(r), ranges::end(r), value, std::ref(proj));
}
};
struct count_if_fn {
template <typename Iterator, typename Proj = std::identity, typename Pred>
constexpr ptrdiff_t operator()(Iterator first, Iterator last, Pred pred, Proj proj = {}) const {
ptrdiff_t counter = 0;
for (; first != last; ++first)
if (std::invoke(pred, std::invoke(proj, *first)))
++counter;
return counter;
}
template <ranges::input_range R, typename Proj = std::identity, typename Pred>
constexpr ptrdiff_t operator()(R&& r, Pred pred, Proj proj = {}) const {
return operator()(ranges::begin(r), ranges::end(r), std::ref(pred), std::ref(proj));
}
};
inline constexpr count_fn count;
inline constexpr count_if_fn count_if;
//
// transform
//
struct transform_fn {
template <typename InputIterator, typename OutputIterator, typename F,
typename Proj = std::identity>
constexpr void operator()(InputIterator first1, InputIterator last1, OutputIterator result,
F op, Proj proj = {}) const {
for (; first1 != last1; ++first1, (void)++result) {
*result = std::invoke(op, std::invoke(proj, *first1));
}
}
template <ranges::input_range R, typename OutputIterator, typename F,
typename Proj = std::identity>
constexpr void operator()(R&& r, OutputIterator result, F op, Proj proj = {}) const {
return operator()(ranges::begin(r), ranges::end(r), result, std::ref(op), std::ref(proj));
}
};
inline constexpr transform_fn transform;
//
// sort
//
struct sort_fn {
template <typename Iterator, typename Comp = ranges::less, typename Proj = std::identity>
constexpr void operator()(Iterator first, Iterator last, Comp comp = {}, Proj proj = {}) const {
if (first == last)
return;
Iterator last_iter = ranges::next(first, last);
std::sort(first, last_iter,
[&](auto& lhs, auto& rhs) { return comp(proj(lhs), proj(rhs)); });
}
template <ranges::input_range R, typename Comp = ranges::less, typename Proj = std::identity>
constexpr void operator()(R&& r, Comp comp = {}, Proj proj = {}) const {
return operator()(ranges::begin(r), ranges::end(r), std::move(comp), std::move(proj));
}
};
inline constexpr sort_fn sort;
//
// fill
//
struct fill_fn {
template <typename T, typename OutputIterator>
constexpr OutputIterator operator()(OutputIterator first, OutputIterator last,
const T& value) const {
while (first != last) {
*first++ = value;
}
return first;
}
template <typename T, ranges::output_range R>
constexpr ranges::iterator_t<R> operator()(R&& r, const T& value) const {
return operator()(ranges::begin(r), ranges::end(r), value);
}
};
inline constexpr fill_fn fill;
//
// for_each
//
struct for_each_fn {
template <typename Iterator, typename Proj = std::identity, typename Fun>
constexpr void operator()(Iterator first, Iterator last, Fun f, Proj proj = {}) const {
for (; first != last; ++first) {
std::invoke(f, std::invoke(proj, *first));
}
}
template <ranges::input_range R, typename Proj = std::identity, typename Fun>
constexpr void operator()(R&& r, Fun f, Proj proj = {}) const {
return operator()(ranges::begin(r), ranges::end(r), std::move(f), std::ref(proj));
}
};
inline constexpr for_each_fn for_each;
//
// min_element, max_element
//
struct min_element_fn {
template <typename Iterator, typename Proj = std::identity, typename Comp = ranges::less>
constexpr Iterator operator()(Iterator first, Iterator last, Comp comp = {},
Proj proj = {}) const {
if (first == last) {
return last;
}
auto smallest = first;
++first;
for (; first != last; ++first) {
if (!std::invoke(comp, std::invoke(proj, *smallest), std::invoke(proj, *first))) {
smallest = first;
}
}
return smallest;
}
template <ranges::input_range R, typename Proj = std::identity, typename Comp = ranges::less>
constexpr ranges::iterator_t<R> operator()(R&& r, Comp comp = {}, Proj proj = {}) const {
return operator()(ranges::begin(r), ranges::end(r), std::ref(comp), std::ref(proj));
}
};
struct max_element_fn {
template <typename Iterator, typename Proj = std::identity, typename Comp = ranges::less>
constexpr Iterator operator()(Iterator first, Iterator last, Comp comp = {},
Proj proj = {}) const {
if (first == last) {
return last;
}
auto largest = first;
++first;
for (; first != last; ++first) {
if (std::invoke(comp, std::invoke(proj, *largest), std::invoke(proj, *first))) {
largest = first;
}
}
return largest;
}
template <ranges::input_range R, typename Proj = std::identity, typename Comp = ranges::less>
constexpr ranges::iterator_t<R> operator()(R&& r, Comp comp = {}, Proj proj = {}) const {
return operator()(ranges::begin(r), ranges::end(r), std::ref(comp), std::ref(proj));
}
};
inline constexpr min_element_fn min_element;
inline constexpr max_element_fn max_element;
//
// replace, replace_if
//
struct replace_fn {
template <typename Iterator, typename T1, typename T2, typename Proj = std::identity>
constexpr Iterator operator()(Iterator first, Iterator last, const T1& old_value,
const T2& new_value, Proj proj = {}) const {
for (; first != last; ++first) {
if (old_value == std::invoke(proj, *first)) {
*first = new_value;
}
}
return first;
}
template <ranges::input_range R, typename T1, typename T2, typename Proj = std::identity>
constexpr ranges::iterator_t<R> operator()(R&& r, const T1& old_value, const T2& new_value,
Proj proj = {}) const {
return operator()(ranges::begin(r), ranges::end(r), old_value, new_value, std::move(proj));
}
};
struct replace_if_fn {
template <typename Iterator, typename T, typename Proj = std::identity, typename Pred>
constexpr Iterator operator()(Iterator first, Iterator last, Pred pred, const T& new_value,
Proj proj = {}) const {
for (; first != last; ++first) {
if (!!std::invoke(pred, std::invoke(proj, *first))) {
*first = new_value;
}
}
return std::move(first);
}
template <ranges::input_range R, typename T, typename Proj = std::identity, typename Pred>
constexpr ranges::iterator_t<R> operator()(R&& r, Pred pred, const T& new_value,
Proj proj = {}) const {
return operator()(ranges::begin(r), ranges::end(r), std::move(pred), new_value,
std::move(proj));
}
};
inline constexpr replace_fn replace;
inline constexpr replace_if_fn replace_if;
//
// copy, copy_if
//
struct copy_fn {
template <typename InputIterator, typename OutputIterator>
constexpr void operator()(InputIterator first, InputIterator last,
OutputIterator result) const {
for (; first != last; ++first, (void)++result) {
*result = *first;
}
}
template <ranges::input_range R, typename OutputIterator>
constexpr void operator()(R&& r, OutputIterator result) const {
return operator()(ranges::begin(r), ranges::end(r), std::move(result));
}
};
struct copy_if_fn {
template <typename InputIterator, typename OutputIterator, typename Proj = std::identity,
typename Pred>
constexpr void operator()(InputIterator first, InputIterator last, OutputIterator result,
Pred pred, Proj proj = {}) const {
for (; first != last; ++first) {
if (std::invoke(pred, std::invoke(proj, *first))) {
*result = *first;
++result;
}
}
}
template <ranges::input_range R, typename OutputIterator, typename Proj = std::identity,
typename Pred>
constexpr void operator()(R&& r, OutputIterator result, Pred pred, Proj proj = {}) const {
return operator()(ranges::begin(r), ranges::end(r), std::move(result), std::ref(pred),
std::ref(proj));
}
};
inline constexpr copy_fn copy;
inline constexpr copy_if_fn copy_if;
//
// generate
//
struct generate_fn {
template <typename Iterator, typename F>
constexpr Iterator operator()(Iterator first, Iterator last, F gen) const {
for (; first != last; *first = std::invoke(gen), ++first)
;
return first;
}
template <typename R, std::copy_constructible F>
requires std::invocable<F&> && ranges::output_range<R>
constexpr ranges::iterator_t<R> operator()(R&& r, F gen) const {
return operator()(ranges::begin(r), ranges::end(r), std::move(gen));
}
};
inline constexpr generate_fn generate;
//
// lower_bound, upper_bound
//
struct lower_bound_fn {
template <typename Iterator, typename T, typename Proj = std::identity,
typename Comp = ranges::less>
constexpr Iterator operator()(Iterator first, Iterator last, const T& value, Comp comp = {},
Proj proj = {}) const {
Iterator it;
std::ptrdiff_t _count, _step;
_count = std::distance(first, last);
while (_count > 0) {
it = first;
_step = _count / 2;
ranges::advance(it, _step, last);
if (comp(std::invoke(proj, *it), value)) {
first = ++it;
_count -= _step + 1;
} else {
_count = _step;
}
}
return first;
}
template <ranges::input_range R, typename T, typename Proj = std::identity,
typename Comp = ranges::less>
constexpr ranges::iterator_t<R> operator()(R&& r, const T& value, Comp comp = {},
Proj proj = {}) const {
return operator()(ranges::begin(r), ranges::end(r), value, std::ref(comp), std::ref(proj));
}
};
struct upper_bound_fn {
template <typename Iterator, typename T, typename Proj = std::identity,
typename Comp = ranges::less>
constexpr Iterator operator()(Iterator first, Iterator last, const T& value, Comp comp = {},
Proj proj = {}) const {
Iterator it;
std::ptrdiff_t _count, _step;
_count = std::distance(first, last);
while (_count > 0) {
it = first;
_step = _count / 2;
ranges::advance(it, _step, last);
if (!comp(value, std::invoke(proj, *it))) {
first = ++it;
_count -= _step + 1;
} else {
_count = _step;
}
}
return first;
}
template <ranges::input_range R, typename T, typename Proj = std::identity,
typename Comp = ranges::less>
constexpr ranges::iterator_t<R> operator()(R&& r, const T& value, Comp comp = {},
Proj proj = {}) const {
return operator()(ranges::begin(r), ranges::end(r), value, std::ref(comp), std::ref(proj));
}
};
inline constexpr lower_bound_fn lower_bound;
inline constexpr upper_bound_fn upper_bound;
//
// adjacent_find
//
struct adjacent_find_fn {
template <typename Iterator, typename Proj = std::identity, typename Pred = ranges::equal_to>
constexpr Iterator operator()(Iterator first, Iterator last, Pred pred = {},
Proj proj = {}) const {
if (first == last)
return first;
auto _next = ranges::next(first);
for (; _next != last; ++_next, ++first)
if (std::invoke(pred, std::invoke(proj, *first), std::invoke(proj, *_next)))
return first;
return _next;
}
template <ranges::input_range R, typename Proj = std::identity,
typename Pred = ranges::equal_to>
constexpr ranges::iterator_t<R> operator()(R&& r, Pred pred = {}, Proj proj = {}) const {
return operator()(ranges::begin(r), ranges::end(r), std::ref(pred), std::ref(proj));
}
};
inline constexpr adjacent_find_fn adjacent_find;
} // namespace ranges
} // namespace std
#endif

View File

@@ -1,323 +0,0 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
//
// TODO: remove this file when jthread is supported by all compilation targets
//
#pragma once
#include <version>
#ifdef __cpp_lib_jthread
#include <stop_token>
#include <thread>
namespace Common {
template <typename Condvar, typename Lock, typename Pred>
void CondvarWait(Condvar& cv, Lock& lock, std::stop_token token, Pred&& pred) {
cv.wait(lock, token, std::move(pred));
}
} // namespace Common
#else
#include <atomic>
#include <functional>
#include <list>
#include <memory>
#include <mutex>
#include <optional>
#include <thread>
#include <type_traits>
namespace std {
namespace polyfill {
using stop_state_callbacks = list<function<void()>>;
class stop_state {
public:
stop_state() = default;
~stop_state() = default;
bool request_stop() {
stop_state_callbacks callbacks;
{
scoped_lock lk{m_lock};
if (m_stop_requested.load()) {
// Already set, nothing to do
return false;
}
// Set as requested
m_stop_requested = true;
// Copy callback list
callbacks = m_callbacks;
}
for (auto callback : callbacks) {
callback();
}
return true;
}
bool stop_requested() const {
return m_stop_requested.load();
}
stop_state_callbacks::const_iterator insert_callback(function<void()> f) {
stop_state_callbacks::const_iterator ret{};
bool should_run{};
{
scoped_lock lk{m_lock};
should_run = m_stop_requested.load();
m_callbacks.push_front(f);
ret = m_callbacks.begin();
}
if (should_run) {
f();
}
return ret;
}
void remove_callback(stop_state_callbacks::const_iterator it) {
scoped_lock lk{m_lock};
m_callbacks.erase(it);
}
private:
mutex m_lock;
atomic<bool> m_stop_requested;
stop_state_callbacks m_callbacks;
};
} // namespace polyfill
class stop_token;
class stop_source;
struct nostopstate_t {
explicit nostopstate_t() = default;
};
inline constexpr nostopstate_t nostopstate{};
template <class Callback>
class stop_callback;
class stop_token {
public:
stop_token() noexcept = default;
stop_token(const stop_token&) noexcept = default;
stop_token(stop_token&&) noexcept = default;
stop_token& operator=(const stop_token&) noexcept = default;
stop_token& operator=(stop_token&&) noexcept = default;
~stop_token() = default;
void swap(stop_token& other) noexcept {
m_stop_state.swap(other.m_stop_state);
}
[[nodiscard]] bool stop_requested() const noexcept {
return m_stop_state && m_stop_state->stop_requested();
}
[[nodiscard]] bool stop_possible() const noexcept {
return m_stop_state != nullptr;
}
private:
friend class stop_source;
template <typename Callback>
friend class stop_callback;
stop_token(shared_ptr<polyfill::stop_state> stop_state) : m_stop_state(move(stop_state)) {}
private:
shared_ptr<polyfill::stop_state> m_stop_state;
};
class stop_source {
public:
stop_source() : m_stop_state(make_shared<polyfill::stop_state>()) {}
explicit stop_source(nostopstate_t) noexcept {}
stop_source(const stop_source&) noexcept = default;
stop_source(stop_source&&) noexcept = default;
stop_source& operator=(const stop_source&) noexcept = default;
stop_source& operator=(stop_source&&) noexcept = default;
~stop_source() = default;
void swap(stop_source& other) noexcept {
m_stop_state.swap(other.m_stop_state);
}
[[nodiscard]] stop_token get_token() const noexcept {
return stop_token(m_stop_state);
}
[[nodiscard]] bool stop_possible() const noexcept {
return m_stop_state != nullptr;
}
[[nodiscard]] bool stop_requested() const noexcept {
return m_stop_state && m_stop_state->stop_requested();
}
bool request_stop() noexcept {
return m_stop_state && m_stop_state->request_stop();
}
private:
friend class jthread;
explicit stop_source(shared_ptr<polyfill::stop_state> stop_state)
: m_stop_state(move(stop_state)) {}
private:
shared_ptr<polyfill::stop_state> m_stop_state;
};
template <typename Callback>
class stop_callback {
static_assert(is_nothrow_destructible_v<Callback>);
static_assert(is_invocable_v<Callback>);
public:
using callback_type = Callback;
template <typename C>
requires constructible_from<Callback, C>
explicit stop_callback(const stop_token& st,
C&& cb) noexcept(is_nothrow_constructible_v<Callback, C>)
: m_stop_state(st.m_stop_state) {
if (m_stop_state) {
m_callback = m_stop_state->insert_callback(move(cb));
}
}
template <typename C>
requires constructible_from<Callback, C>
explicit stop_callback(stop_token&& st,
C&& cb) noexcept(is_nothrow_constructible_v<Callback, C>)
: m_stop_state(move(st.m_stop_state)) {
if (m_stop_state) {
m_callback = m_stop_state->insert_callback(move(cb));
}
}
~stop_callback() {
if (m_stop_state && m_callback) {
m_stop_state->remove_callback(*m_callback);
}
}
stop_callback(const stop_callback&) = delete;
stop_callback(stop_callback&&) = delete;
stop_callback& operator=(const stop_callback&) = delete;
stop_callback& operator=(stop_callback&&) = delete;
private:
shared_ptr<polyfill::stop_state> m_stop_state;
optional<polyfill::stop_state_callbacks::const_iterator> m_callback;
};
template <typename Callback>
stop_callback(stop_token, Callback) -> stop_callback<Callback>;
class jthread {
public:
using id = thread::id;
using native_handle_type = thread::native_handle_type;
jthread() noexcept = default;
template <typename F, typename... Args,
typename = enable_if_t<!is_same_v<remove_cvref_t<F>, jthread>>>
explicit jthread(F&& f, Args&&... args)
: m_stop_state(make_shared<polyfill::stop_state>()),
m_thread(make_thread(move(f), move(args)...)) {}
~jthread() {
if (joinable()) {
request_stop();
join();
}
}
jthread(const jthread&) = delete;
jthread(jthread&&) noexcept = default;
jthread& operator=(const jthread&) = delete;
jthread& operator=(jthread&& other) noexcept {
m_thread.swap(other.m_thread);
m_stop_state.swap(other.m_stop_state);
return *this;
}
void swap(jthread& other) noexcept {
m_thread.swap(other.m_thread);
m_stop_state.swap(other.m_stop_state);
}
[[nodiscard]] bool joinable() const noexcept {
return m_thread.joinable();
}
void join() {
m_thread.join();
}
void detach() {
m_thread.detach();
m_stop_state.reset();
}
[[nodiscard]] id get_id() const noexcept {
return m_thread.get_id();
}
[[nodiscard]] native_handle_type native_handle() {
return m_thread.native_handle();
}
[[nodiscard]] stop_source get_stop_source() noexcept {
return stop_source(m_stop_state);
}
[[nodiscard]] stop_token get_stop_token() const noexcept {
return stop_source(m_stop_state).get_token();
}
bool request_stop() noexcept {
return get_stop_source().request_stop();
}
[[nodiscard]] static unsigned int hardware_concurrency() noexcept {
return thread::hardware_concurrency();
}
private:
template <typename F, typename... Args>
thread make_thread(F&& f, Args&&... args) {
if constexpr (is_invocable_v<decay_t<F>, stop_token, decay_t<Args>...>) {
return thread(move(f), get_stop_token(), move(args)...);
} else {
return thread(move(f), move(args)...);
}
}
shared_ptr<polyfill::stop_state> m_stop_state;
thread m_thread;
};
} // namespace std
namespace Common {
template <typename Condvar, typename Lock, typename Pred>
void CondvarWait(Condvar& cv, Lock& lock, std::stop_token token, Pred pred) {
if (token.stop_requested()) {
return;
}
std::stop_callback callback(token, [&] { cv.notify_all(); });
cv.wait(lock, [&] { return pred() || token.stop_requested(); });
}
} // namespace Common
#endif

View File

@@ -1,6 +0,0 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_precompiled_headers.h"

View File

@@ -399,6 +399,7 @@ struct Values {
Setting<bool> cpuopt_fastmem{true, "cpuopt_fastmem"};
Setting<bool> cpuopt_fastmem_exclusives{true, "cpuopt_fastmem_exclusives"};
Setting<bool> cpuopt_recompile_exclusives{true, "cpuopt_recompile_exclusives"};
Setting<bool> cpuopt_ignore_memory_aborts{true, "cpuopt_ignore_memory_aborts"};
SwitchableSetting<bool> cpuopt_unsafe_unfuse_fma{true, "cpuopt_unsafe_unfuse_fma"};
SwitchableSetting<bool> cpuopt_unsafe_reduce_fp_error{true, "cpuopt_unsafe_reduce_fp_error"};

View File

@@ -141,7 +141,7 @@ static std::wstring CPToUTF16(u32 code_page, const std::string& input) {
MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), nullptr, 0);
if (size == 0) {
return {};
return L"";
}
std::wstring output(size, L'\0');
@@ -158,7 +158,7 @@ std::string UTF16ToUTF8(const std::wstring& input) {
const auto size = WideCharToMultiByte(CP_UTF8, 0, input.data(), static_cast<int>(input.size()),
nullptr, 0, nullptr, nullptr);
if (size == 0) {
return {};
return "";
}
std::string output(size, '\0');

View File

@@ -7,13 +7,13 @@
#include <condition_variable>
#include <functional>
#include <mutex>
#include <stop_token>
#include <string>
#include <thread>
#include <type_traits>
#include <vector>
#include <queue>
#include "common/polyfill_thread.h"
#include "common/thread.h"
#include "common/unique_function.h"
@@ -47,8 +47,7 @@ public:
if (requests.empty()) {
wait_condition.notify_all();
}
Common::CondvarWait(condition, lock, stop_token,
[this] { return !requests.empty(); });
condition.wait(lock, stop_token, [this] { return !requests.empty(); });
if (stop_token.stop_requested()) {
break;
}

View File

@@ -12,8 +12,6 @@
#include <mutex>
#include <utility>
#include "common/polyfill_thread.h"
namespace Common {
template <typename T, bool with_stop_token = false>
class SPSCQueue {
@@ -99,7 +97,7 @@ public:
T PopWait(std::stop_token stop_token) {
if (Empty()) {
std::unique_lock lock{cv_mutex};
Common::CondvarWait(cv, lock, stop_token, [this] { return !Empty(); });
cv.wait(lock, stop_token, [this] { return !Empty(); });
}
if (stop_token.stop_requested()) {
return T{};

View File

@@ -771,7 +771,6 @@ add_library(core STATIC
memory.h
perf_stats.cpp
perf_stats.h
precompiled_headers.h
reporter.cpp
reporter.h
telemetry_session.cpp
@@ -826,7 +825,3 @@ if (ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64)
)
target_link_libraries(core PRIVATE dynarmic)
endif()
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(core PRIVATE precompiled_headers.h)
endif()

View File

@@ -145,11 +145,15 @@ void ARM_Interface::Run() {
// Notify the debugger and go to sleep if a breakpoint was hit,
// or if the thread is unable to continue for any reason.
if (Has(hr, breakpoint) || Has(hr, no_execute)) {
RewindBreakpointInstruction();
if (!Has(hr, no_execute)) {
RewindBreakpointInstruction();
}
if (system.DebuggerEnabled()) {
system.GetDebugger().NotifyThreadStopped(current_thread);
} else {
LogBacktrace();
}
current_thread->RequestSuspend(Kernel::SuspendType::Debug);
current_thread->RequestSuspend(SuspendType::Debug);
break;
}

View File

@@ -29,7 +29,9 @@ class DynarmicCallbacks32 : public Dynarmic::A32::UserCallbacks {
public:
explicit DynarmicCallbacks32(ARM_Dynarmic_32& parent_)
: parent{parent_},
memory(parent.system.Memory()), debugger_enabled{parent.system.DebuggerEnabled()} {}
memory(parent.system.Memory()), debugger_enabled{parent.system.DebuggerEnabled()},
check_memory_access{debugger_enabled ||
!Settings::values.cpuopt_ignore_memory_aborts.GetValue()} {}
u8 MemoryRead8(u32 vaddr) override {
CheckMemoryAccess(vaddr, 1, Kernel::DebugWatchpointType::Read);
@@ -154,6 +156,17 @@ public:
}
bool CheckMemoryAccess(VAddr addr, u64 size, Kernel::DebugWatchpointType type) {
if (!check_memory_access) {
return true;
}
if (!memory.IsValidVirtualAddressRange(addr, size)) {
LOG_CRITICAL(Core_ARM, "Stopping execution due to unmapped memory access at {:#x}",
addr);
parent.jit.load()->HaltExecution(ARM_Interface::no_execute);
return false;
}
if (!debugger_enabled) {
return true;
}
@@ -181,7 +194,8 @@ public:
ARM_Dynarmic_32& parent;
Core::Memory::Memory& memory;
std::size_t num_interpreted_instructions{};
bool debugger_enabled{};
const bool debugger_enabled{};
const bool check_memory_access{};
static constexpr u64 minimum_run_cycles = 10000U;
};
@@ -264,6 +278,9 @@ std::shared_ptr<Dynarmic::A32::Jit> ARM_Dynarmic_32::MakeJit(Common::PageTable*
if (!Settings::values.cpuopt_recompile_exclusives) {
config.recompile_on_exclusive_fastmem_failure = false;
}
if (!Settings::values.cpuopt_ignore_memory_aborts) {
config.check_halt_on_memory_access = true;
}
} else {
// Unsafe optimizations
if (Settings::values.cpu_accuracy.GetValue() == Settings::CPUAccuracy::Unsafe) {

View File

@@ -29,7 +29,9 @@ class DynarmicCallbacks64 : public Dynarmic::A64::UserCallbacks {
public:
explicit DynarmicCallbacks64(ARM_Dynarmic_64& parent_)
: parent{parent_},
memory(parent.system.Memory()), debugger_enabled{parent.system.DebuggerEnabled()} {}
memory(parent.system.Memory()), debugger_enabled{parent.system.DebuggerEnabled()},
check_memory_access{debugger_enabled ||
!Settings::values.cpuopt_ignore_memory_aborts.GetValue()} {}
u8 MemoryRead8(u64 vaddr) override {
CheckMemoryAccess(vaddr, 1, Kernel::DebugWatchpointType::Read);
@@ -198,6 +200,17 @@ public:
}
bool CheckMemoryAccess(VAddr addr, u64 size, Kernel::DebugWatchpointType type) {
if (!check_memory_access) {
return true;
}
if (!memory.IsValidVirtualAddressRange(addr, size)) {
LOG_CRITICAL(Core_ARM, "Stopping execution due to unmapped memory access at {:#x}",
addr);
parent.jit.load()->HaltExecution(ARM_Interface::no_execute);
return false;
}
if (!debugger_enabled) {
return true;
}
@@ -226,7 +239,8 @@ public:
Core::Memory::Memory& memory;
u64 tpidrro_el0 = 0;
u64 tpidr_el0 = 0;
bool debugger_enabled{};
const bool debugger_enabled{};
const bool check_memory_access{};
static constexpr u64 minimum_run_cycles = 10000U;
};
@@ -323,6 +337,9 @@ std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic_64::MakeJit(Common::PageTable*
if (!Settings::values.cpuopt_recompile_exclusives) {
config.recompile_on_exclusive_fastmem_failure = false;
}
if (!Settings::values.cpuopt_ignore_memory_aborts) {
config.check_halt_on_memory_access = true;
}
} else {
// Unsafe optimizations
if (Settings::values.cpu_accuracy.GetValue() == Settings::CPUAccuracy::Unsafe) {

View File

@@ -10,7 +10,6 @@
#include <thread>
#include "common/fiber.h"
#include "common/polyfill_thread.h"
#include "common/thread.h"
#include "core/hardware_properties.h"

View File

@@ -9,7 +9,6 @@
#include <boost/process/async_pipe.hpp>
#include "common/logging/log.h"
#include "common/polyfill_thread.h"
#include "common/thread.h"
#include "core/core.h"
#include "core/debugger/debugger.h"

View File

@@ -7,7 +7,6 @@
#include <utility>
#include "common/logging/log.h"
#include "common/polyfill_ranges.h"
#include "core/crypto/aes_util.h"
#include "core/crypto/ctr_encryption_layer.h"
#include "core/crypto/key_manager.h"

View File

@@ -4,7 +4,6 @@
#pragma once
#include <functional>
#include <vector>
#include "common/common_types.h"

View File

@@ -17,8 +17,6 @@ enum class WindowSystemType {
Windows,
X11,
Wayland,
Cocoa,
Android,
};
/**

View File

@@ -3,7 +3,6 @@
#include <algorithm>
#include "common/polyfill_ranges.h"
#include "common/thread.h"
#include "core/hid/emulated_controller.h"
#include "core/hid/input_converter.h"

View File

@@ -8,7 +8,6 @@
#include <memory>
#include <mutex>
#include <unordered_map>
#include <vector>
#include "common/common_types.h"
#include "common/input.h"

View File

@@ -8,7 +8,6 @@
#include <memory>
#include <mutex>
#include <unordered_map>
#include <vector>
#include "common/common_types.h"
#include "common/input.h"

View File

@@ -225,8 +225,8 @@ Result KMemoryManager::AllocatePageGroupImpl(KPageGroup* out, size_t num_pages,
ON_RESULT_FAILURE {
for (const auto& it : out->Nodes()) {
auto& manager = this->GetManager(it.GetAddress());
const size_t node_num_pages = std::min<u64>(
it.GetNumPages(), (manager.GetEndAddress() - it.GetAddress()) / PageSize);
const size_t node_num_pages =
std::min(it.GetNumPages(), (manager.GetEndAddress() - it.GetAddress()) / PageSize);
manager.Free(it.GetAddress(), node_num_pages);
}
out->Finalize();

View File

@@ -6,7 +6,6 @@
#include <atomic>
#include "common/assert.h"
#include "common/atomic_ops.h"
#include "common/common_funcs.h"
#include "common/common_types.h"
#include "common/spin_lock.h"
@@ -83,13 +82,16 @@ private:
private:
void UpdatePeakImpl(uintptr_t obj) {
static_assert(std::atomic_ref<uintptr_t>::is_always_lock_free);
std::atomic_ref<uintptr_t> peak_ref(m_peak);
const uintptr_t alloc_peak = obj + this->GetObjectSize();
uintptr_t cur_peak = m_peak;
do {
if (alloc_peak <= cur_peak) {
break;
}
} while (!Common::AtomicCompareAndSwap(&m_peak, alloc_peak, cur_peak, cur_peak));
} while (!peak_ref.compare_exchange_strong(cur_peak, alloc_peak));
}
public:

View File

@@ -10,7 +10,6 @@
#include "common/assert.h"
#include "common/common_types.h"
#include "common/intrusive_red_black_tree.h"
#include "common/polyfill_ranges.h"
#include "core/hle/kernel/memory_types.h"
#include "core/hle/kernel/slab_helpers.h"
#include "core/hle/result.h"

View File

@@ -7,7 +7,6 @@
#include <thread>
#include <vector>
#include "common/polyfill_thread.h"
#include "common/scope_exit.h"
#include "common/thread.h"
#include "core/hle/ipc_helpers.h"

View File

@@ -82,7 +82,7 @@ void SvcWrap64(Core::System& system) {
}
// Used by ControlCodeMemory
template <Result func(Core::System&, Handle, u32, VAddr, size_t, Svc::MemoryPermission)>
template <Result func(Core::System&, Handle, u32, u64, u64, Svc::MemoryPermission)>
void SvcWrap64(Core::System& system) {
FuncReturn(system, func(system, static_cast<Handle>(Param(system, 0)),
static_cast<u32>(Param(system, 1)), Param(system, 2), Param(system, 3),
@@ -327,7 +327,7 @@ void SvcWrap64(Core::System& system) {
}
// Used by CreateCodeMemory
template <Result func(Core::System&, Handle*, VAddr, size_t)>
template <Result func(Core::System&, Handle*, u64, u64)>
void SvcWrap64(Core::System& system) {
u32 param_1 = 0;
const u32 retval = func(system, &param_1, Param(system, 1), Param(system, 2)).raw;

View File

@@ -7,7 +7,6 @@
#include "common/fs/file.h"
#include "common/fs/path_util.h"
#include "common/logging/log.h"
#include "common/polyfill_ranges.h"
#include "common/string_util.h"
#include "common/swap.h"
#include "core/constants.h"

View File

@@ -9,7 +9,6 @@
#include "common/fs/file.h"
#include "common/fs/fs.h"
#include "common/fs/path_util.h"
#include "common/polyfill_ranges.h"
#include "common/settings.h"
#include "core/hle/service/acc/profile_manager.h"

View File

@@ -1125,7 +1125,7 @@ void IStorageAccessor::Write(Kernel::HLERequestContext& ctx) {
const u64 offset{rp.Pop<u64>()};
const std::vector<u8> data{ctx.ReadBuffer()};
const std::size_t size{std::min<u64>(data.size(), backing.GetSize() - offset)};
const std::size_t size{std::min(data.size(), backing.GetSize() - offset)};
LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, size);
@@ -1149,7 +1149,7 @@ void IStorageAccessor::Read(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const u64 offset{rp.Pop<u64>()};
const std::size_t size{std::min<u64>(ctx.GetWriteBufferSize(), backing.GetSize() - offset)};
const std::size_t size{std::min(ctx.GetWriteBufferSize(), backing.GetSize() - offset)};
LOG_DEBUG(Service_AM, "called, offset={}, size={}", offset, size);

View File

@@ -14,7 +14,6 @@
#include "common/bit_util.h"
#include "common/common_funcs.h"
#include "common/logging/log.h"
#include "common/polyfill_ranges.h"
#include "common/string_util.h"
#include "core/core.h"
#include "core/hle/ipc_helpers.h"

View File

@@ -129,9 +129,6 @@ static_assert(sizeof(NifmNetworkProfileData) == 0x18E,
"NifmNetworkProfileData has incorrect size.");
#pragma pack(pop)
constexpr Result ResultPendingConnection{ErrorModule::NIFM, 111};
constexpr Result ResultNetworkCommunicationDisabled{ErrorModule::NIFM, 1111};
class IScanRequest final : public ServiceFramework<IScanRequest> {
public:
explicit IScanRequest(Core::System& system_) : ServiceFramework{system_, "IScanRequest"} {
@@ -195,10 +192,6 @@ private:
void Submit(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_NIFM, "(STUBBED) called");
if (state == RequestState::NotSubmitted) {
UpdateState(RequestState::Pending);
}
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
@@ -208,32 +201,19 @@ private:
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.PushEnum(state);
if (Network::GetHostIPv4Address().has_value()) {
rb.PushEnum(RequestState::Connected);
} else {
rb.PushEnum(RequestState::NotSubmitted);
}
}
void GetResult(Kernel::HLERequestContext& ctx) {
LOG_WARNING(Service_NIFM, "(STUBBED) called");
const auto result = [this] {
const auto has_connection = Network::GetHostIPv4Address().has_value();
switch (state) {
case RequestState::NotSubmitted:
return has_connection ? ResultSuccess : ResultNetworkCommunicationDisabled;
case RequestState::Pending:
if (has_connection) {
UpdateState(RequestState::Connected);
} else {
UpdateState(RequestState::Error);
}
return ResultPendingConnection;
case RequestState::Connected:
default:
return ResultSuccess;
}
}();
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(result);
rb.Push(ResultSuccess);
}
void GetSystemEventReadableHandles(Kernel::HLERequestContext& ctx) {
@@ -272,15 +252,8 @@ private:
rb.Push<u32>(0);
}
void UpdateState(RequestState new_state) {
state = new_state;
event1->Signal();
}
KernelHelpers::ServiceContext service_context;
RequestState state;
Kernel::KEvent* event1;
Kernel::KEvent* event2;
};

View File

@@ -11,7 +11,6 @@
#include <vector>
#include "common/common_types.h"
#include "common/polyfill_thread.h"
#include "core/hle/result.h"
#include "core/hle/service/kernel_helpers.h"

View File

@@ -9,7 +9,6 @@
#include "common/bit_cast.h"
#include "common/common_types.h"
#include "common/logging/log.h"
#include "common/polyfill_ranges.h"
#include "common/settings.h"
#include "common/string_util.h"
#include "core/internal_network/network_interface.h"

View File

@@ -1,11 +0,0 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <boost/container/flat_map.hpp> // used by service.h which is heavily included
#include <boost/intrusive/rbtree.hpp> // used by k_auto_object.h which is heavily included
#include "common/common_precompiled_headers.h"
#include "core/hle/kernel/k_process.h"

View File

@@ -4,7 +4,6 @@
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules)
add_executable(yuzu-room
precompiled_headers.h
yuzu_room.cpp
yuzu_room.rc
)
@@ -26,7 +25,3 @@ target_link_libraries(yuzu-room PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads)
if(UNIX AND NOT APPLE)
install(TARGETS yuzu-room)
endif()
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(yuzu-room PRIVATE precompiled_headers.h)
endif()

View File

@@ -1,6 +0,0 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_precompiled_headers.h"

View File

@@ -34,7 +34,6 @@ add_library(input_common STATIC
input_poller.h
main.cpp
main.h
precompiled_headers.h
)
if (MSVC)
@@ -68,7 +67,3 @@ target_link_libraries(input_common PRIVATE usb)
create_target_directory_groups(input_common)
target_link_libraries(input_common PUBLIC core PRIVATE common Boost::boost)
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(input_common PRIVATE precompiled_headers.h)
endif()

View File

@@ -5,10 +5,10 @@
#include <array>
#include <memory>
#include <stop_token>
#include <string>
#include <thread>
#include "common/polyfill_thread.h"
#include "input_common/input_engine.h"
struct libusb_context;

View File

@@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <stop_token>
#include <thread>
#include <fmt/format.h>

View File

@@ -3,9 +3,9 @@
#pragma once
#include <stop_token>
#include <thread>
#include "common/polyfill_thread.h"
#include "common/vector_math.h"
#include "input_common/input_engine.h"

View File

@@ -2,7 +2,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include <cstring>
#include <sstream>
#include <fmt/format.h>
#include "common/fs/file.h"

View File

@@ -1,6 +0,0 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_precompiled_headers.h"

View File

@@ -8,7 +8,6 @@ add_library(network STATIC
network.h
packet.cpp
packet.h
precompiled_headers.h
room.cpp
room.h
room_member.cpp
@@ -24,7 +23,3 @@ if (ENABLE_WEB_SERVICE)
target_compile_definitions(network PRIVATE -DENABLE_WEB_SERVICE)
target_link_libraries(network PRIVATE web_service)
endif()
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(network PRIVATE precompiled_headers.h)
endif()

View File

@@ -1,6 +0,0 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_precompiled_headers.h"

View File

@@ -221,7 +221,6 @@ add_library(shader_recompiler STATIC
ir_opt/dual_vertex_pass.cpp
ir_opt/global_memory_to_storage_buffer_pass.cpp
ir_opt/identity_removal_pass.cpp
ir_opt/layer_pass.cpp
ir_opt/lower_fp16_to_fp32.cpp
ir_opt/lower_int64_to_int32.cpp
ir_opt/passes.h
@@ -231,7 +230,6 @@ add_library(shader_recompiler STATIC
ir_opt/texture_pass.cpp
ir_opt/verification_pass.cpp
object_pool.h
precompiled_headers.h
profile.h
program_header.h
runtime_info.h
@@ -256,12 +254,7 @@ else()
# Bracket depth determines maximum size of a fold expression in Clang since 9c9974c3ccb6.
# And this in turns limits the size of a std::array.
$<$<CXX_COMPILER_ID:Clang>:-fbracket-depth=1024>
$<$<CXX_COMPILER_ID:AppleClang>:-fbracket-depth=1024>
)
endif()
create_target_directory_groups(shader_recompiler)
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(shader_recompiler PRIVATE precompiled_headers.h)
endif()

View File

@@ -402,10 +402,8 @@ void SetupCapabilities(const Profile& profile, const Info& info, EmitContext& ct
ctx.AddCapability(spv::Capability::SparseResidency);
}
if (info.uses_demote_to_helper_invocation && profile.support_demote_to_helper_invocation) {
if (profile.supported_spirv < 0x00010600) {
ctx.AddExtension("SPV_EXT_demote_to_helper_invocation");
}
ctx.AddCapability(spv::Capability::DemoteToHelperInvocation);
ctx.AddExtension("SPV_EXT_demote_to_helper_invocation");
ctx.AddCapability(spv::Capability::DemoteToHelperInvocationEXT);
}
if (info.stores[IR::Attribute::ViewportIndex]) {
ctx.AddCapability(spv::Capability::MultiViewport);
@@ -428,11 +426,12 @@ void SetupCapabilities(const Profile& profile, const Info& info, EmitContext& ct
if ((info.uses_subgroup_vote || info.uses_subgroup_invocation_id ||
info.uses_subgroup_shuffles) &&
profile.support_vote) {
ctx.AddCapability(spv::Capability::GroupNonUniformBallot);
ctx.AddCapability(spv::Capability::GroupNonUniformShuffle);
ctx.AddExtension("SPV_KHR_shader_ballot");
ctx.AddCapability(spv::Capability::SubgroupBallotKHR);
if (!profile.warp_size_potentially_larger_than_guest) {
// vote ops are only used when not taking the long path
ctx.AddCapability(spv::Capability::GroupNonUniformVote);
ctx.AddExtension("SPV_KHR_subgroup_vote");
ctx.AddCapability(spv::Capability::SubgroupVoteKHR);
}
}
if (info.uses_int64_bit_atomics && profile.support_int64_atomics) {

View File

@@ -12,7 +12,7 @@ void EmitJoin(EmitContext&) {
void EmitDemoteToHelperInvocation(EmitContext& ctx) {
if (ctx.profile.support_demote_to_helper_invocation) {
ctx.OpDemoteToHelperInvocation();
ctx.OpDemoteToHelperInvocationEXT();
} else {
const Id kill_label{ctx.OpLabel()};
const Id impossible_label{ctx.OpLabel()};

View File

@@ -6,10 +6,6 @@
namespace Shader::Backend::SPIRV {
namespace {
Id SubgroupScope(EmitContext& ctx) {
return ctx.Const(static_cast<u32>(spv::Scope::Subgroup));
}
Id GetThreadId(EmitContext& ctx) {
return ctx.OpLoad(ctx.U32[1], ctx.subgroup_local_invocation_id);
}
@@ -53,9 +49,8 @@ Id GetMaxThreadId(EmitContext& ctx, Id thread_id, Id clamp, Id segmentation_mask
}
Id SelectValue(EmitContext& ctx, Id in_range, Id value, Id src_thread_id) {
return ctx.OpSelect(
ctx.U32[1], in_range,
ctx.OpGroupNonUniformShuffle(ctx.U32[1], SubgroupScope(ctx), value, src_thread_id), value);
return ctx.OpSelect(ctx.U32[1], in_range,
ctx.OpSubgroupReadInvocationKHR(ctx.U32[1], value, src_thread_id), value);
}
Id GetUpperClamp(EmitContext& ctx, Id invocation_id, Id clamp) {
@@ -76,46 +71,40 @@ Id EmitLaneId(EmitContext& ctx) {
Id EmitVoteAll(EmitContext& ctx, Id pred) {
if (!ctx.profile.warp_size_potentially_larger_than_guest) {
return ctx.OpGroupNonUniformAll(ctx.U1, SubgroupScope(ctx), pred);
return ctx.OpSubgroupAllKHR(ctx.U1, pred);
}
const Id mask_ballot{
ctx.OpGroupNonUniformBallot(ctx.U32[4], SubgroupScope(ctx), ctx.true_value)};
const Id mask_ballot{ctx.OpSubgroupBallotKHR(ctx.U32[4], ctx.true_value)};
const Id active_mask{WarpExtract(ctx, mask_ballot)};
const Id ballot{
WarpExtract(ctx, ctx.OpGroupNonUniformBallot(ctx.U32[4], SubgroupScope(ctx), pred))};
const Id ballot{WarpExtract(ctx, ctx.OpSubgroupBallotKHR(ctx.U32[4], pred))};
const Id lhs{ctx.OpBitwiseAnd(ctx.U32[1], ballot, active_mask)};
return ctx.OpIEqual(ctx.U1, lhs, active_mask);
}
Id EmitVoteAny(EmitContext& ctx, Id pred) {
if (!ctx.profile.warp_size_potentially_larger_than_guest) {
return ctx.OpGroupNonUniformAny(ctx.U1, SubgroupScope(ctx), pred);
return ctx.OpSubgroupAnyKHR(ctx.U1, pred);
}
const Id mask_ballot{
ctx.OpGroupNonUniformBallot(ctx.U32[4], SubgroupScope(ctx), ctx.true_value)};
const Id mask_ballot{ctx.OpSubgroupBallotKHR(ctx.U32[4], ctx.true_value)};
const Id active_mask{WarpExtract(ctx, mask_ballot)};
const Id ballot{
WarpExtract(ctx, ctx.OpGroupNonUniformBallot(ctx.U32[4], SubgroupScope(ctx), pred))};
const Id ballot{WarpExtract(ctx, ctx.OpSubgroupBallotKHR(ctx.U32[4], pred))};
const Id lhs{ctx.OpBitwiseAnd(ctx.U32[1], ballot, active_mask)};
return ctx.OpINotEqual(ctx.U1, lhs, ctx.u32_zero_value);
}
Id EmitVoteEqual(EmitContext& ctx, Id pred) {
if (!ctx.profile.warp_size_potentially_larger_than_guest) {
return ctx.OpGroupNonUniformAllEqual(ctx.U1, SubgroupScope(ctx), pred);
return ctx.OpSubgroupAllEqualKHR(ctx.U1, pred);
}
const Id mask_ballot{
ctx.OpGroupNonUniformBallot(ctx.U32[4], SubgroupScope(ctx), ctx.true_value)};
const Id mask_ballot{ctx.OpSubgroupBallotKHR(ctx.U32[4], ctx.true_value)};
const Id active_mask{WarpExtract(ctx, mask_ballot)};
const Id ballot{
WarpExtract(ctx, ctx.OpGroupNonUniformBallot(ctx.U32[4], SubgroupScope(ctx), pred))};
const Id ballot{WarpExtract(ctx, ctx.OpSubgroupBallotKHR(ctx.U32[4], pred))};
const Id lhs{ctx.OpBitwiseXor(ctx.U32[1], ballot, active_mask)};
return ctx.OpLogicalOr(ctx.U1, ctx.OpIEqual(ctx.U1, lhs, ctx.u32_zero_value),
ctx.OpIEqual(ctx.U1, lhs, active_mask));
}
Id EmitSubgroupBallot(EmitContext& ctx, Id pred) {
const Id ballot{ctx.OpGroupNonUniformBallot(ctx.U32[4], SubgroupScope(ctx), pred)};
const Id ballot{ctx.OpSubgroupBallotKHR(ctx.U32[4], pred)};
if (!ctx.profile.warp_size_potentially_larger_than_guest) {
return ctx.OpCompositeExtract(ctx.U32[1], ballot, 0U);
}

View File

@@ -8,7 +8,6 @@
#include <fmt/format.h>
#include "common/polyfill_ranges.h"
#include "shader_recompiler/frontend/ir/type.h"
namespace Shader::IR {

View File

@@ -23,6 +23,7 @@
#include "shader_recompiler/frontend/ir/pred.h"
#include "shader_recompiler/frontend/ir/reg.h"
#include "shader_recompiler/frontend/ir/type.h"
#include "shader_recompiler/frontend/ir/value.h"
namespace Shader::IR {

View File

@@ -9,7 +9,6 @@
#include <fmt/format.h>
#include "common/polyfill_ranges.h"
#include "shader_recompiler/exception.h"
#include "shader_recompiler/frontend/maxwell/control_flow.h"
#include "shader_recompiler/frontend/maxwell/decode.h"

View File

@@ -7,7 +7,6 @@
#include <memory>
#include "common/common_types.h"
#include "common/polyfill_ranges.h"
#include "shader_recompiler/exception.h"
#include "shader_recompiler/frontend/maxwell/decode.h"
#include "shader_recompiler/frontend/maxwell/opcodes.h"

View File

@@ -12,7 +12,6 @@
#include <boost/intrusive/list.hpp>
#include "common/polyfill_ranges.h"
#include "shader_recompiler/environment.h"
#include "shader_recompiler/frontend/ir/basic_block.h"
#include "shader_recompiler/frontend/ir/ir_emitter.h"

View File

@@ -176,13 +176,12 @@ void TranslateF2I(TranslatorVisitor& v, u64 insn, const IR::F16F32F64& src_a) {
(f2i.src_format == SrcFormat::F64) != (f2i.dest_format == DestFormat::I64);
if (special_nan_cases) {
if (f2i.dest_format == DestFormat::I32) {
constexpr u32 nan_value = 0x8000'0000U;
handled_special_case = true;
result = IR::U32{v.ir.Select(v.ir.FPIsNan(op_a), v.ir.Imm32(nan_value), result)};
result = IR::U32{v.ir.Select(v.ir.FPIsNan(op_a), v.ir.Imm32(0x8000'0000U), result)};
} else if (f2i.dest_format == DestFormat::I64) {
constexpr u64 nan_value = 0x8000'0000'0000'0000ULL;
handled_special_case = true;
result = IR::U64{v.ir.Select(v.ir.FPIsNan(op_a), v.ir.Imm64(nan_value), result)};
result = IR::U64{
v.ir.Select(v.ir.FPIsNan(op_a), v.ir.Imm64(0x8000'0000'0000'0000UL), result)};
}
}
if (!handled_special_case && is_signed) {

View File

@@ -9,7 +9,6 @@
#include "common/settings.h"
#include "shader_recompiler/exception.h"
#include "shader_recompiler/frontend/ir/basic_block.h"
#include "shader_recompiler/frontend/ir/ir_emitter.h"
#include "shader_recompiler/frontend/ir/post_order.h"
#include "shader_recompiler/frontend/maxwell/structured_control_flow.h"
#include "shader_recompiler/frontend/maxwell/translate/translate.h"
@@ -234,8 +233,6 @@ IR::Program TranslateProgram(ObjectPool<IR::Inst>& inst_pool, ObjectPool<IR::Blo
Optimization::VerificationPass(program);
}
Optimization::CollectShaderInfoPass(env, program);
Optimization::LayerPass(program, host_info);
CollectInterpolationInfo(env, program);
AddNVNStorageBuffers(program);
return program;
@@ -334,82 +331,4 @@ void ConvertLegacyToGeneric(IR::Program& program, const Shader::RuntimeInfo& run
}
}
IR::Program GenerateGeometryPassthrough(ObjectPool<IR::Inst>& inst_pool,
ObjectPool<IR::Block>& block_pool,
const HostTranslateInfo& host_info,
IR::Program& source_program,
Shader::OutputTopology output_topology) {
IR::Program program;
program.stage = Stage::Geometry;
program.output_topology = output_topology;
switch (output_topology) {
case OutputTopology::PointList:
program.output_vertices = 1;
break;
case OutputTopology::LineStrip:
program.output_vertices = 2;
break;
default:
program.output_vertices = 3;
break;
}
program.is_geometry_passthrough = false;
program.info.loads.mask = source_program.info.stores.mask;
program.info.stores.mask = source_program.info.stores.mask;
program.info.stores.Set(IR::Attribute::Layer, true);
program.info.stores.Set(source_program.info.emulated_layer, false);
IR::Block* current_block = block_pool.Create(inst_pool);
auto& node{program.syntax_list.emplace_back()};
node.type = IR::AbstractSyntaxNode::Type::Block;
node.data.block = current_block;
IR::IREmitter ir{*current_block};
for (u32 i = 0; i < program.output_vertices; i++) {
// Assign generics from input
for (u32 j = 0; j < 32; j++) {
if (!program.info.stores.Generic(j)) {
continue;
}
const IR::Attribute attr = IR::Attribute::Generic0X + (j * 4);
ir.SetAttribute(attr + 0, ir.GetAttribute(attr + 0, ir.Imm32(i)), ir.Imm32(0));
ir.SetAttribute(attr + 1, ir.GetAttribute(attr + 1, ir.Imm32(i)), ir.Imm32(0));
ir.SetAttribute(attr + 2, ir.GetAttribute(attr + 2, ir.Imm32(i)), ir.Imm32(0));
ir.SetAttribute(attr + 3, ir.GetAttribute(attr + 3, ir.Imm32(i)), ir.Imm32(0));
}
// Assign position from input
const IR::Attribute attr = IR::Attribute::PositionX;
ir.SetAttribute(attr + 0, ir.GetAttribute(attr + 0, ir.Imm32(i)), ir.Imm32(0));
ir.SetAttribute(attr + 1, ir.GetAttribute(attr + 1, ir.Imm32(i)), ir.Imm32(0));
ir.SetAttribute(attr + 2, ir.GetAttribute(attr + 2, ir.Imm32(i)), ir.Imm32(0));
ir.SetAttribute(attr + 3, ir.GetAttribute(attr + 3, ir.Imm32(i)), ir.Imm32(0));
// Assign layer
ir.SetAttribute(IR::Attribute::Layer, ir.GetAttribute(source_program.info.emulated_layer),
ir.Imm32(0));
// Emit vertex
ir.EmitVertex(ir.Imm32(0));
}
ir.EndPrimitive(ir.Imm32(0));
IR::Block* return_block{block_pool.Create(inst_pool)};
IR::IREmitter{*return_block}.Epilogue();
current_block->AddBranch(return_block);
auto& merge{program.syntax_list.emplace_back()};
merge.type = IR::AbstractSyntaxNode::Type::Block;
merge.data.block = return_block;
program.syntax_list.emplace_back().type = IR::AbstractSyntaxNode::Type::Return;
program.blocks = GenerateBlocks(program.syntax_list);
program.post_order_blocks = PostOrder(program.syntax_list.front());
Optimization::SsaRewritePass(program);
return program;
}
} // namespace Shader::Maxwell

View File

@@ -25,13 +25,4 @@ namespace Shader::Maxwell {
void ConvertLegacyToGeneric(IR::Program& program, const RuntimeInfo& runtime_info);
// Maxwell v1 and older Nvidia cards don't support setting gl_Layer from non-geometry stages.
// This creates a workaround by setting the layer as a generic output and creating a
// passthrough geometry shader that reads the generic and sets the layer.
[[nodiscard]] IR::Program GenerateGeometryPassthrough(ObjectPool<IR::Inst>& inst_pool,
ObjectPool<IR::Block>& block_pool,
const HostTranslateInfo& host_info,
IR::Program& source_program,
Shader::OutputTopology output_topology);
} // namespace Shader::Maxwell

View File

@@ -13,8 +13,7 @@ struct HostTranslateInfo {
bool support_float16{}; ///< True when the device supports 16-bit floats
bool support_int64{}; ///< True when the device supports 64-bit integers
bool needs_demote_reorder{}; ///< True when the device needs DemoteToHelperInvocation reordered
bool support_snorm_render_buffer{}; ///< True when the device supports SNORM render buffers
bool support_viewport_index_layer{}; ///< True when the device supports gl_Layer in VS
bool support_snorm_render_buffer{}; ///< True when the device supports SNORM render buffers
};
} // namespace Shader

View File

@@ -1,68 +0,0 @@
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <algorithm>
#include <bit>
#include <optional>
#include <boost/container/small_vector.hpp>
#include "shader_recompiler/environment.h"
#include "shader_recompiler/frontend/ir/basic_block.h"
#include "shader_recompiler/frontend/ir/breadth_first_search.h"
#include "shader_recompiler/frontend/ir/ir_emitter.h"
#include "shader_recompiler/host_translate_info.h"
#include "shader_recompiler/ir_opt/passes.h"
#include "shader_recompiler/shader_info.h"
namespace Shader::Optimization {
static IR::Attribute EmulatedLayerAttribute(VaryingState& stores) {
for (u32 i = 0; i < 32; i++) {
if (!stores.Generic(i)) {
return IR::Attribute::Generic0X + (i * 4);
}
}
return IR::Attribute::Layer;
}
static bool PermittedProgramStage(Stage stage) {
switch (stage) {
case Stage::VertexA:
case Stage::VertexB:
case Stage::TessellationControl:
case Stage::TessellationEval:
return true;
default:
return false;
}
}
void LayerPass(IR::Program& program, const HostTranslateInfo& host_info) {
if (host_info.support_viewport_index_layer || !PermittedProgramStage(program.stage)) {
return;
}
const auto end{program.post_order_blocks.end()};
const auto layer_attribute = EmulatedLayerAttribute(program.info.stores);
bool requires_layer_emulation = false;
for (auto block = program.post_order_blocks.begin(); block != end; ++block) {
for (IR::Inst& inst : (*block)->Instructions()) {
if (inst.GetOpcode() == IR::Opcode::SetAttribute &&
inst.Arg(0).Attribute() == IR::Attribute::Layer) {
requires_layer_emulation = true;
inst.SetArg(0, IR::Value{layer_attribute});
}
}
}
if (requires_layer_emulation) {
program.info.requires_layer_emulation = true;
program.info.emulated_layer = layer_attribute;
program.info.stores.Set(IR::Attribute::Layer, false);
program.info.stores.Set(layer_attribute, true);
}
}
} // namespace Shader::Optimization

View File

@@ -23,7 +23,6 @@ void RescalingPass(IR::Program& program);
void SsaRewritePass(IR::Program& program);
void PositionPass(Environment& env, IR::Program& program);
void TexturePass(Environment& env, IR::Program& program, const HostTranslateInfo& host_info);
void LayerPass(IR::Program& program, const HostTranslateInfo& host_info);
void VerificationPass(const IR::Program& program);
// Dual Vertex

View File

@@ -1,7 +0,0 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_precompiled_headers.h"
#include "frontend/maxwell/translate/impl/impl.h"

View File

@@ -204,9 +204,6 @@ struct Info {
u32 nvn_buffer_base{};
std::bitset<16> nvn_buffer_used{};
bool requires_layer_emulation{};
IR::Attribute emulated_layer{};
boost::container::static_vector<ConstantBufferDescriptor, MAX_CBUFS>
constant_buffer_descriptors;
boost::container::static_vector<StorageBufferDescriptor, MAX_SSBOS> storage_buffers_descriptors;

View File

@@ -11,7 +11,6 @@ add_executable(tests
common/unique_function.cpp
core/core_timing.cpp
core/internal_network/network.cpp
precompiled_headers.h
tests.cpp
video_core/buffer_base.cpp
input_common/calibration_configuration_job.cpp
@@ -23,7 +22,3 @@ target_link_libraries(tests PRIVATE common core input_common)
target_link_libraries(tests PRIVATE ${PLATFORM_LIBRARIES} Catch2::Catch2 Threads::Threads)
add_test(NAME tests COMMAND tests)
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(tests PRIVATE precompiled_headers.h)
endif()

View File

@@ -1,6 +0,0 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_precompiled_headers.h"

View File

@@ -84,7 +84,6 @@ add_library(video_core STATIC
gpu_thread.h
memory_manager.cpp
memory_manager.h
precompiled_headers.h
pte_kind.h
query_cache.h
rasterizer_accelerated.cpp
@@ -280,15 +279,9 @@ if (MSVC)
/we4244 # 'conversion': conversion from 'type1' to 'type2', possible loss of data
)
else()
if (APPLE)
# error: declaration shadows a typedef in 'interval_base_set<SubType, DomainT, Compare, Interval, Alloc>'
# error: implicit conversion loses integer precision: 'int' to 'boost::icl::bound_type' (aka 'unsigned char')
target_compile_options(video_core PRIVATE -Wno-shadow -Wno-unused-local-typedef)
else()
target_compile_options(video_core PRIVATE -Werror=conversion)
endif()
target_compile_options(video_core PRIVATE
-Werror=conversion
-Wno-sign-conversion
)
@@ -307,7 +300,3 @@ endif()
if (ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64)
target_link_libraries(video_core PRIVATE dynarmic)
endif()
if (YUZU_USE_PRECOMPILED_HEADERS)
target_precompile_headers(video_core PRIVATE precompiled_headers.h)
endif()

View File

@@ -535,7 +535,7 @@ private:
const u64* const state_words = Array<type>();
const u64 num_query_words = size / BYTES_PER_WORD + 1;
const u64 word_begin = offset / BYTES_PER_WORD;
const u64 word_end = std::min<u64>(word_begin + num_query_words, NumWords());
const u64 word_end = std::min(word_begin + num_query_words, NumWords());
const u64 page_limit = Common::DivCeil(offset + size, BYTES_PER_PAGE);
u64 page_index = (offset / BYTES_PER_PAGE) % PAGES_PER_WORD;
for (u64 word_index = word_begin; word_index < word_end; ++word_index, page_index = 0) {

View File

@@ -19,7 +19,6 @@
#include "common/literals.h"
#include "common/lru_cache.h"
#include "common/microprofile.h"
#include "common/polyfill_ranges.h"
#include "common/settings.h"
#include "core/memory.h"
#include "video_core/buffer_cache/buffer_base.h"

View File

@@ -35,6 +35,8 @@ public:
explicit ChannelInfo(Tegra::Control::ChannelState& state);
ChannelInfo(const ChannelInfo& state) = delete;
ChannelInfo& operator=(const ChannelInfo&) = delete;
ChannelInfo(ChannelInfo&& other) = default;
ChannelInfo& operator=(ChannelInfo&& other) = default;
Tegra::Engines::Maxwell3D& maxwell3d;
Tegra::Engines::KeplerCompute& kepler_compute;

View File

@@ -126,6 +126,7 @@ void Maxwell3D::InitializeRegisterDefaults() {
draw_command[MAXWELL3D_REG_INDEX(draw_inline_index)] = true;
draw_command[MAXWELL3D_REG_INDEX(inline_index_2x16.even)] = true;
draw_command[MAXWELL3D_REG_INDEX(inline_index_4x8.index0)] = true;
draw_command[MAXWELL3D_REG_INDEX(draw.instance_id)] = true;
}
void Maxwell3D::ProcessMacro(u32 method, const u32* base_start, u32 amount, bool is_last_call) {
@@ -217,19 +218,16 @@ void Maxwell3D::ProcessMethodCall(u32 method, u32 argument, u32 nonshadow_argume
regs.index_buffer.count = regs.index_buffer32_first.count;
regs.index_buffer.first = regs.index_buffer32_first.first;
dirty.flags[VideoCommon::Dirty::IndexBuffer] = true;
draw_indexed = true;
return ProcessDraw();
case MAXWELL3D_REG_INDEX(index_buffer16_first):
regs.index_buffer.count = regs.index_buffer16_first.count;
regs.index_buffer.first = regs.index_buffer16_first.first;
dirty.flags[VideoCommon::Dirty::IndexBuffer] = true;
draw_indexed = true;
return ProcessDraw();
case MAXWELL3D_REG_INDEX(index_buffer8_first):
regs.index_buffer.count = regs.index_buffer8_first.count;
regs.index_buffer.first = regs.index_buffer8_first.first;
dirty.flags[VideoCommon::Dirty::IndexBuffer] = true;
draw_indexed = true;
return ProcessDraw();
case MAXWELL3D_REG_INDEX(topology_override):
use_topology_override = true;
@@ -302,33 +300,21 @@ void Maxwell3D::CallMethod(u32 method, u32 method_argument, bool is_last_call) {
draw_mode = DrawMode::InlineIndex;
};
switch (method) {
case MAXWELL3D_REG_INDEX(draw.begin): {
draw_mode =
(regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::Subsequent) ||
(regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::Unchanged)
? DrawMode::Instance
: DrawMode::General;
break;
}
case MAXWELL3D_REG_INDEX(draw.end):
switch (draw_mode) {
case DrawMode::General:
ProcessDraw();
ProcessDraw(1);
break;
case DrawMode::InlineIndex:
regs.index_buffer.count = static_cast<u32>(inline_index_draw_indexes.size() / 4);
regs.index_buffer.format = Regs::IndexFormat::UnsignedInt;
draw_indexed = true;
ProcessDraw();
ProcessDraw(1);
inline_index_draw_indexes.clear();
break;
case DrawMode::Instance:
break;
}
break;
case MAXWELL3D_REG_INDEX(index_buffer.count):
draw_indexed = true;
break;
case MAXWELL3D_REG_INDEX(draw_inline_index):
update_inline_index(method_argument);
break;
@@ -342,6 +328,13 @@ void Maxwell3D::CallMethod(u32 method, u32 method_argument, bool is_last_call) {
update_inline_index(regs.inline_index_4x8.index2);
update_inline_index(regs.inline_index_4x8.index3);
break;
case MAXWELL3D_REG_INDEX(draw.instance_id):
draw_mode =
(regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::Subsequent) ||
(regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::Unchanged)
? DrawMode::Instance
: DrawMode::General;
break;
}
} else {
ProcessDeferredDraw();
@@ -631,16 +624,27 @@ void Maxwell3D::ProcessClearBuffers(u32 layer_count) {
void Maxwell3D::ProcessDraw(u32 instance_count) {
LOG_TRACE(HW_GPU, "called, topology={}, count={}", regs.draw.topology.Value(),
draw_indexed ? regs.index_buffer.count : regs.vertex_buffer.count);
regs.vertex_buffer.count);
ASSERT_MSG(!(regs.index_buffer.count && regs.vertex_buffer.count), "Both indexed and direct?");
// Both instance configuration registers can not be set at the same time.
ASSERT_MSG(regs.draw.instance_id == Maxwell3D::Regs::Draw::InstanceId::First ||
regs.draw.instance_id != Maxwell3D::Regs::Draw::InstanceId::Unchanged,
"Illegal combination of instancing parameters");
ProcessTopologyOverride();
const bool is_indexed = regs.index_buffer.count && !regs.vertex_buffer.count;
if (ShouldExecute()) {
rasterizer->Draw(draw_indexed, instance_count);
rasterizer->Draw(is_indexed, instance_count);
}
draw_indexed = false;
deferred_draw_method.clear();
if (is_indexed) {
regs.index_buffer.count = 0;
} else {
regs.vertex_buffer.count = 0;
}
}
void Maxwell3D::ProcessDeferredDraw() {
@@ -663,6 +667,8 @@ void Maxwell3D::ProcessDeferredDraw() {
ASSERT_MSG(!(vertex_buffer_count && index_buffer_count), "Instance both indexed and direct?");
ProcessDraw(instance_count);
deferred_draw_method.clear();
}
} // namespace Tegra::Engines

View File

@@ -3159,7 +3159,6 @@ private:
std::vector<u32> deferred_draw_method;
enum class DrawMode : u32 { General = 0, Instance, InlineIndex };
DrawMode draw_mode{DrawMode::General};
bool draw_indexed{};
};
#define ASSERT_REG_POSITION(field_name, position) \

View File

@@ -2,12 +2,12 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#include <array>
#include <bit>
#include <cmath>
#include <span>
#include <unordered_map>
#include "common/assert.h"
#include "common/bit_cast.h"
#include "video_core/engines/sw_blitter/converter.h"
#include "video_core/surface.h"
#include "video_core/textures/decoders.h"
@@ -693,21 +693,21 @@ private:
return shifted_value >> shift_amount;
};
const auto force_to_fp16 = [](f32 base_value) {
u32 tmp = Common::BitCast<u32>(base_value);
u32 tmp = std::bit_cast<u32>(base_value);
constexpr size_t fp32_mantissa_bits = 23;
constexpr size_t fp16_mantissa_bits = 10;
constexpr size_t mantissa_mask =
~((1ULL << (fp32_mantissa_bits - fp16_mantissa_bits)) - 1ULL);
tmp = tmp & static_cast<u32>(mantissa_mask);
// TODO: force the exponent within the range of half float. Not needed in UNORM / SNORM
return Common::BitCast<f32>(tmp);
return std::bit_cast<f32>(tmp);
};
const auto from_fp_n = [&sign_extend](u32 base_value, size_t bits, size_t mantissa) {
constexpr size_t fp32_mantissa_bits = 23;
size_t shift_towards = fp32_mantissa_bits - mantissa;
const u32 new_value =
static_cast<u32>(sign_extend(base_value, bits) << shift_towards) & (~(1U << 31));
return Common::BitCast<f32>(new_value);
return std::bit_cast<f32>(new_value);
};
const auto calculate_snorm = [&]() {
return static_cast<f32>(
@@ -737,13 +737,13 @@ private:
out_component = force_to_fp16(out_component);
} else if constexpr (component_types[which_component] == ComponentType::FLOAT) {
if constexpr (component_sizes[which_component] == 32) {
out_component = Common::BitCast<f32>(value);
out_component = std::bit_cast<f32>(value);
} else if constexpr (component_sizes[which_component] == 16) {
static constexpr u32 sign_mask = 0x8000;
static constexpr u32 mantissa_mask = 0x8000;
out_component = Common::BitCast<f32>(((value & sign_mask) << 16) |
(((value & 0x7c00) + 0x1C000) << 13) |
((value & mantissa_mask) << 13));
out_component = std::bit_cast<f32>(((value & sign_mask) << 16) |
(((value & 0x7c00) + 0x1C000) << 13) |
((value & mantissa_mask) << 13));
} else {
out_component = from_fp_n(value, component_sizes[which_component],
component_sizes[which_component] - 5);
@@ -771,7 +771,7 @@ private:
};
const auto to_fp_n = [](f32 base_value, size_t bits, size_t mantissa) {
constexpr size_t fp32_mantissa_bits = 23;
u32 tmp_value = Common::BitCast<u32>(std::max(base_value, 0.0f));
u32 tmp_value = std::bit_cast<u32>(std::max(base_value, 0.0f));
size_t shift_towards = fp32_mantissa_bits - mantissa;
return tmp_value >> shift_towards;
};
@@ -799,13 +799,13 @@ private:
insert_to_word(tmp_word);
} else if constexpr (component_types[which_component] == ComponentType::FLOAT) {
if constexpr (component_sizes[which_component] == 32) {
u32 tmp_word = Common::BitCast<u32>(in_component);
u32 tmp_word = std::bit_cast<u32>(in_component);
insert_to_word(tmp_word);
} else if constexpr (component_sizes[which_component] == 16) {
static constexpr u32 sign_mask = 0x8000;
static constexpr u32 mantissa_mask = 0x03ff;
static constexpr u32 exponent_mask = 0x7c00;
const u32 tmp_word = Common::BitCast<u32>(in_component);
const u32 tmp_word = std::bit_cast<u32>(in_component);
const u32 half = ((tmp_word >> 16) & sign_mask) |
((((tmp_word & 0x7f800000) - 0x38000000) >> 13) & exponent_mask) |
((tmp_word >> 13) & mantissa_mask);

View File

@@ -125,7 +125,7 @@ u64 ThreadManager::PushCommand(CommandData&& command_data, bool block) {
state.queue.Push(CommandDataContainer(std::move(command_data), fence, block));
if (block) {
Common::CondvarWait(state.cv, lk, thread.get_stop_token(), [this, fence] {
state.cv.wait(lk, thread.get_stop_token(), [this, fence] {
return fence <= state.signaled_fence.load(std::memory_order_relaxed);
});
}

View File

@@ -10,7 +10,6 @@
#include <thread>
#include <variant>
#include "common/polyfill_thread.h"
#include "common/threadsafe_queue.h"
#include "video_core/framebuffer_config.h"

View File

@@ -1,6 +0,0 @@
// SPDX-FileCopyrightText: 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "common/common_precompiled_headers.h"

View File

@@ -6,8 +6,8 @@
#include <functional>
#include <optional>
#include <span>
#include <stop_token>
#include "common/common_types.h"
#include "common/polyfill_thread.h"
#include "video_core/engines/fermi_2d.h"
#include "video_core/gpu.h"

View File

@@ -14,7 +14,6 @@
#include "common/literals.h"
#include "common/logging/log.h"
#include "common/polyfill_ranges.h"
#include "common/settings.h"
#include "shader_recompiler/stage.h"
#include "video_core/renderer_opengl/gl_device.h"

View File

@@ -39,7 +39,6 @@ using Shader::Backend::GLASM::EmitGLASM;
using Shader::Backend::GLSL::EmitGLSL;
using Shader::Backend::SPIRV::EmitSPIRV;
using Shader::Maxwell::ConvertLegacyToGeneric;
using Shader::Maxwell::GenerateGeometryPassthrough;
using Shader::Maxwell::MergeDualVertexPrograms;
using Shader::Maxwell::TranslateProgram;
using VideoCommon::ComputeEnvironment;
@@ -57,17 +56,6 @@ auto MakeSpan(Container& container) {
return std::span(container.data(), container.size());
}
Shader::OutputTopology MaxwellToOutputTopology(Maxwell::PrimitiveTopology topology) {
switch (topology) {
case Maxwell::PrimitiveTopology::Points:
return Shader::OutputTopology::PointList;
case Maxwell::PrimitiveTopology::LineStrip:
return Shader::OutputTopology::LineStrip;
default:
return Shader::OutputTopology::TriangleStrip;
}
}
Shader::RuntimeInfo MakeRuntimeInfo(const GraphicsPipelineKey& key,
const Shader::IR::Program& program,
const Shader::IR::Program* previous_program,
@@ -232,7 +220,6 @@ ShaderCache::ShaderCache(RasterizerOpenGL& rasterizer_, Core::Frontend::EmuWindo
.support_int64 = device.HasShaderInt64(),
.needs_demote_reorder = device.IsAmd(),
.support_snorm_render_buffer = false,
.support_viewport_index_layer = device.HasVertexViewportLayer(),
} {
if (use_asynchronous_shaders) {
workers = CreateWorkers();
@@ -327,7 +314,9 @@ GraphicsPipeline* ShaderCache::CurrentGraphicsPipeline() {
const auto& regs{maxwell3d->regs};
graphics_key.raw = 0;
graphics_key.early_z.Assign(regs.mandated_early_z != 0 ? 1 : 0);
graphics_key.gs_input_topology.Assign(regs.draw.topology.Value());
graphics_key.gs_input_topology.Assign(graphics_key.unique_hashes[4] != 0
? regs.draw.topology.Value()
: Maxwell::PrimitiveTopology{});
graphics_key.tessellation_primitive.Assign(regs.tessellation.params.domain_type.Value());
graphics_key.tessellation_spacing.Assign(regs.tessellation.params.spacing.Value());
graphics_key.tessellation_clockwise.Assign(
@@ -426,19 +415,7 @@ std::unique_ptr<GraphicsPipeline> ShaderCache::CreateGraphicsPipeline(
std::array<Shader::IR::Program, Maxwell::MaxShaderProgram> programs;
const bool uses_vertex_a{key.unique_hashes[0] != 0};
const bool uses_vertex_b{key.unique_hashes[1] != 0};
// Layer passthrough generation for devices without GL_ARB_shader_viewport_layer_array
Shader::IR::Program* layer_source_program{};
for (size_t index = 0; index < Maxwell::MaxShaderProgram; ++index) {
const bool is_emulated_stage = layer_source_program != nullptr &&
index == static_cast<u32>(Maxwell::ShaderType::Geometry);
if (key.unique_hashes[index] == 0 && is_emulated_stage) {
auto topology = MaxwellToOutputTopology(key.gs_input_topology);
programs[index] = GenerateGeometryPassthrough(pools.inst, pools.block, host_info,
*layer_source_program, topology);
continue;
}
if (key.unique_hashes[index] == 0) {
continue;
}
@@ -466,10 +443,6 @@ std::unique_ptr<GraphicsPipeline> ShaderCache::CreateGraphicsPipeline(
Shader::NumDescriptors(program_vb.info.storage_buffers_descriptors);
programs[index] = MergeDualVertexPrograms(program_va, program_vb, env);
}
if (programs[index].info.requires_layer_emulation) {
layer_source_program = &programs[index];
}
}
const u32 glasm_storage_buffer_limit{device.GetMaxGLASMStorageBufferBlocks()};
const bool glasm_use_storage_buffers{total_storage_buffers <= glasm_storage_buffer_limit};
@@ -483,9 +456,7 @@ std::unique_ptr<GraphicsPipeline> ShaderCache::CreateGraphicsPipeline(
const bool use_glasm{device.UseAssemblyShaders()};
const size_t first_index = uses_vertex_a && uses_vertex_b ? 1 : 0;
for (size_t index = first_index; index < Maxwell::MaxShaderProgram; ++index) {
const bool is_emulated_stage = layer_source_program != nullptr &&
index == static_cast<u32>(Maxwell::ShaderType::Geometry);
if (key.unique_hashes[index] == 0 && !is_emulated_stage) {
if (key.unique_hashes[index] == 0) {
continue;
}
UNIMPLEMENTED_IF(index == 0);

View File

@@ -4,6 +4,7 @@
#pragma once
#include <filesystem>
#include <stop_token>
#include <unordered_map>
#include "common/common_types.h"

Some files were not shown because too many files have changed in this diff Show More