forked from etc/pineapple-src
early-access version 1890
This commit is contained in:
parent
8cde2bad21
commit
0a6abc3bd0
9 changed files with 57 additions and 81 deletions
|
@ -1,7 +1,7 @@
|
|||
yuzu emulator early access
|
||||
=============
|
||||
|
||||
This is the source code for early-access 1888.
|
||||
This is the source code for early-access 1890.
|
||||
|
||||
## Legal Notice
|
||||
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
# Add a custom command to generate a new shader_cache_version hash when any of the following files change
|
||||
# NOTE: This is an approximation of what files affect shader generation, its possible something else
|
||||
# could affect the result, but much more unlikely than the following files. Keeping a list of files
|
||||
# like this allows for much better caching since it doesn't force the user to recompile binary shaders every update
|
||||
set(VIDEO_CORE "${CMAKE_SOURCE_DIR}/src/video_core")
|
||||
if (DEFINED ENV{AZURECIREPO})
|
||||
set(BUILD_REPOSITORY $ENV{AZURECIREPO})
|
||||
endif()
|
||||
|
@ -30,10 +25,7 @@ add_custom_command(OUTPUT scm_rev.cpp
|
|||
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
|
||||
-P ${CMAKE_SOURCE_DIR}/CMakeModules/GenerateSCMRev.cmake
|
||||
DEPENDS
|
||||
# WARNING! It was too much work to try and make a common location for this list,
|
||||
# so if you need to change it, please update CMakeModules/GenerateSCMRev.cmake as well
|
||||
# ...
|
||||
# and also check that the scm_rev files haven't changed
|
||||
# Check that the scm_rev files haven't changed
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp.in"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.h"
|
||||
# technically we should regenerate if the git version changed, but its not worth the effort imo
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#define BUILD_ID "@BUILD_ID@"
|
||||
#define TITLE_BAR_FORMAT_IDLE "@TITLE_BAR_FORMAT_IDLE@"
|
||||
#define TITLE_BAR_FORMAT_RUNNING "@TITLE_BAR_FORMAT_RUNNING@"
|
||||
#define SHADER_CACHE_VERSION "@SHADER_CACHE_VERSION@"
|
||||
|
||||
namespace Common {
|
||||
|
||||
|
@ -28,7 +27,6 @@ const char g_build_version[] = BUILD_VERSION;
|
|||
const char g_build_id[] = BUILD_ID;
|
||||
const char g_title_bar_format_idle[] = TITLE_BAR_FORMAT_IDLE;
|
||||
const char g_title_bar_format_running[] = TITLE_BAR_FORMAT_RUNNING;
|
||||
const char g_shader_cache_version[] = SHADER_CACHE_VERSION;
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -62,7 +62,6 @@ json GetYuzuVersionData() {
|
|||
{"build_date", std::string(Common::g_build_date)},
|
||||
{"build_fullname", std::string(Common::g_build_fullname)},
|
||||
{"build_version", std::string(Common::g_build_version)},
|
||||
{"shader_cache_version", std::string(Common::g_shader_cache_version)},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -48,9 +48,12 @@ using VideoCommon::ComputeEnvironment;
|
|||
using VideoCommon::FileEnvironment;
|
||||
using VideoCommon::GenericEnvironment;
|
||||
using VideoCommon::GraphicsEnvironment;
|
||||
using VideoCommon::LoadPipelines;
|
||||
using VideoCommon::SerializePipeline;
|
||||
using Context = ShaderContext::Context;
|
||||
|
||||
constexpr u32 CACHE_VERSION = 5;
|
||||
|
||||
template <typename Container>
|
||||
auto MakeSpan(Container& container) {
|
||||
return std::span(container.data(), container.size());
|
||||
|
@ -287,7 +290,7 @@ void ShaderCache::LoadDiskResources(u64 title_id, std::stop_token stop_loading,
|
|||
});
|
||||
++state.total;
|
||||
}};
|
||||
VideoCommon::LoadPipelines(stop_loading, shader_cache_filename, load_compute, load_graphics);
|
||||
LoadPipelines(stop_loading, shader_cache_filename, CACHE_VERSION, load_compute, load_graphics);
|
||||
|
||||
std::unique_lock lock{state.mutex};
|
||||
callback(VideoCore::LoadCallbackStage::Build, 0, state.total);
|
||||
|
@ -394,7 +397,7 @@ std::unique_ptr<GraphicsPipeline> ShaderCache::CreateGraphicsPipeline() {
|
|||
env_ptrs.push_back(&environments.envs[index]);
|
||||
}
|
||||
}
|
||||
SerializePipeline(graphics_key, env_ptrs, shader_cache_filename);
|
||||
SerializePipeline(graphics_key, env_ptrs, shader_cache_filename, CACHE_VERSION);
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
|
@ -492,7 +495,8 @@ std::unique_ptr<ComputePipeline> ShaderCache::CreateComputePipeline(
|
|||
if (!pipeline || shader_cache_filename.empty()) {
|
||||
return pipeline;
|
||||
}
|
||||
SerializePipeline(key, std::array<const GenericEnvironment*, 1>{&env}, shader_cache_filename);
|
||||
SerializePipeline(key, std::array<const GenericEnvironment*, 1>{&env}, shader_cache_filename,
|
||||
CACHE_VERSION);
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,8 @@ using VideoCommon::FileEnvironment;
|
|||
using VideoCommon::GenericEnvironment;
|
||||
using VideoCommon::GraphicsEnvironment;
|
||||
|
||||
constexpr u32 CACHE_VERSION = 5;
|
||||
|
||||
template <typename Container>
|
||||
auto MakeSpan(Container& container) {
|
||||
return std::span(container.data(), container.size());
|
||||
|
@ -434,7 +436,8 @@ void PipelineCache::LoadDiskResources(u64 title_id, std::stop_token stop_loading
|
|||
});
|
||||
++state.total;
|
||||
}};
|
||||
VideoCommon::LoadPipelines(stop_loading, pipeline_cache_filename, load_compute, load_graphics);
|
||||
VideoCommon::LoadPipelines(stop_loading, pipeline_cache_filename, CACHE_VERSION, load_compute,
|
||||
load_graphics);
|
||||
|
||||
std::unique_lock lock{state.mutex};
|
||||
callback(VideoCore::LoadCallbackStage::Build, 0, state.total);
|
||||
|
@ -562,7 +565,7 @@ std::unique_ptr<GraphicsPipeline> PipelineCache::CreateGraphicsPipeline() {
|
|||
env_ptrs.push_back(&envs[index]);
|
||||
}
|
||||
}
|
||||
SerializePipeline(key, env_ptrs, pipeline_cache_filename);
|
||||
SerializePipeline(key, env_ptrs, pipeline_cache_filename, CACHE_VERSION);
|
||||
});
|
||||
return pipeline;
|
||||
}
|
||||
|
@ -581,7 +584,7 @@ std::unique_ptr<ComputePipeline> PipelineCache::CreateComputePipeline(
|
|||
}
|
||||
serialization_thread.QueueWork([this, key, env = std::move(env)] {
|
||||
SerializePipeline(key, std::array<const GenericEnvironment*, 1>{&env},
|
||||
pipeline_cache_filename);
|
||||
pipeline_cache_filename, CACHE_VERSION);
|
||||
});
|
||||
return pipeline;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
namespace VideoCommon {
|
||||
|
||||
constexpr std::array<char, 8> MAGIC_NUMBER{'y', 'u', 'z', 'u', 'c', 'a', 'c', 'h'};
|
||||
constexpr u32 CACHE_VERSION = 5;
|
||||
|
||||
constexpr size_t INST_SIZE = sizeof(u64);
|
||||
|
||||
|
@ -370,7 +369,7 @@ std::array<u32, 3> FileEnvironment::WorkgroupSize() const {
|
|||
}
|
||||
|
||||
void SerializePipeline(std::span<const char> key, std::span<const GenericEnvironment* const> envs,
|
||||
const std::filesystem::path& filename) try {
|
||||
const std::filesystem::path& filename, u32 cache_version) try {
|
||||
std::ofstream file(filename, std::ios::binary | std::ios::ate | std::ios::app);
|
||||
file.exceptions(std::ifstream::failbit);
|
||||
if (!file.is_open()) {
|
||||
|
@ -381,7 +380,7 @@ void SerializePipeline(std::span<const char> key, std::span<const GenericEnviron
|
|||
if (file.tellp() == 0) {
|
||||
// Write header
|
||||
file.write(MAGIC_NUMBER.data(), MAGIC_NUMBER.size())
|
||||
.write(reinterpret_cast<const char*>(&CACHE_VERSION), sizeof(CACHE_VERSION));
|
||||
.write(reinterpret_cast<const char*>(&cache_version), sizeof(cache_version));
|
||||
}
|
||||
if (!std::ranges::all_of(envs, &GenericEnvironment::CanBeSerialized)) {
|
||||
return;
|
||||
|
@ -402,7 +401,7 @@ void SerializePipeline(std::span<const char> key, std::span<const GenericEnviron
|
|||
}
|
||||
|
||||
void LoadPipelines(
|
||||
std::stop_token stop_loading, const std::filesystem::path& filename,
|
||||
std::stop_token stop_loading, const std::filesystem::path& filename, u32 expected_cache_version,
|
||||
Common::UniqueFunction<void, std::ifstream&, FileEnvironment> load_compute,
|
||||
Common::UniqueFunction<void, std::ifstream&, std::vector<FileEnvironment>> load_graphics) try {
|
||||
std::ifstream file(filename, std::ios::binary | std::ios::ate);
|
||||
|
@ -417,13 +416,13 @@ void LoadPipelines(
|
|||
u32 cache_version;
|
||||
file.read(magic_number.data(), magic_number.size())
|
||||
.read(reinterpret_cast<char*>(&cache_version), sizeof(cache_version));
|
||||
if (magic_number != MAGIC_NUMBER || cache_version != CACHE_VERSION) {
|
||||
if (magic_number != MAGIC_NUMBER || cache_version != expected_cache_version) {
|
||||
file.close();
|
||||
if (Common::FS::RemoveFile(filename)) {
|
||||
if (magic_number != MAGIC_NUMBER) {
|
||||
LOG_ERROR(Common_Filesystem, "Invalid pipeline cache file");
|
||||
}
|
||||
if (cache_version != CACHE_VERSION) {
|
||||
if (cache_version != expected_cache_version) {
|
||||
LOG_INFO(Common_Filesystem, "Deleting old pipeline cache");
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -164,18 +164,19 @@ private:
|
|||
};
|
||||
|
||||
void SerializePipeline(std::span<const char> key, std::span<const GenericEnvironment* const> envs,
|
||||
const std::filesystem::path& filename);
|
||||
const std::filesystem::path& filename, u32 cache_version);
|
||||
|
||||
template <typename Key, typename Envs>
|
||||
void SerializePipeline(const Key& key, const Envs& envs, const std::filesystem::path& filename) {
|
||||
void SerializePipeline(const Key& key, const Envs& envs, const std::filesystem::path& filename,
|
||||
u32 cache_version) {
|
||||
static_assert(std::is_trivially_copyable_v<Key>);
|
||||
static_assert(std::has_unique_object_representations_v<Key>);
|
||||
SerializePipeline(std::span(reinterpret_cast<const char*>(&key), sizeof(key)),
|
||||
std::span(envs.data(), envs.size()), filename);
|
||||
std::span(envs.data(), envs.size()), filename, cache_version);
|
||||
}
|
||||
|
||||
void LoadPipelines(
|
||||
std::stop_token stop_loading, const std::filesystem::path& filename,
|
||||
std::stop_token stop_loading, const std::filesystem::path& filename, u32 expected_cache_version,
|
||||
Common::UniqueFunction<void, std::ifstream&, FileEnvironment> load_compute,
|
||||
Common::UniqueFunction<void, std::ifstream&, std::vector<FileEnvironment>> load_graphics);
|
||||
|
||||
|
|
|
@ -169,23 +169,6 @@ template <u32 GOB_EXTENT>
|
|||
return Common::DivCeil(AdjustMipSize(size, level), block_size);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr std::pair<int, int> Samples(int num_samples) {
|
||||
switch (num_samples) {
|
||||
case 1:
|
||||
return {1, 1};
|
||||
case 2:
|
||||
return {2, 1};
|
||||
case 4:
|
||||
return {2, 2};
|
||||
case 8:
|
||||
return {4, 2};
|
||||
case 16:
|
||||
return {4, 4};
|
||||
}
|
||||
UNREACHABLE_MSG("Invalid number of samples={}", num_samples);
|
||||
return {1, 1};
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr Extent2D DefaultBlockSize(PixelFormat format) {
|
||||
return {DefaultBlockWidth(format), DefaultBlockHeight(format)};
|
||||
}
|
||||
|
@ -283,14 +266,13 @@ template <u32 GOB_EXTENT>
|
|||
}
|
||||
|
||||
[[nodiscard]] constexpr LevelInfo MakeLevelInfo(PixelFormat format, Extent3D size, Extent3D block,
|
||||
u32 num_samples, u32 tile_width_spacing) {
|
||||
const auto [samples_x, samples_y] = Samples(num_samples);
|
||||
u32 tile_width_spacing) {
|
||||
const u32 bytes_per_block = BytesPerBlock(format);
|
||||
return {
|
||||
.size =
|
||||
{
|
||||
.width = size.width * samples_x,
|
||||
.height = size.height * samples_y,
|
||||
.width = size.width,
|
||||
.height = size.height,
|
||||
.depth = size.depth,
|
||||
},
|
||||
.block = block,
|
||||
|
@ -301,14 +283,12 @@ template <u32 GOB_EXTENT>
|
|||
}
|
||||
|
||||
[[nodiscard]] constexpr LevelInfo MakeLevelInfo(const ImageInfo& info) {
|
||||
return MakeLevelInfo(info.format, info.size, info.block, info.num_samples,
|
||||
info.tile_width_spacing);
|
||||
return MakeLevelInfo(info.format, info.size, info.block, info.tile_width_spacing);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr u32 CalculateLevelOffset(PixelFormat format, Extent3D size, Extent3D block,
|
||||
u32 num_samples, u32 tile_width_spacing,
|
||||
u32 level) {
|
||||
const LevelInfo info = MakeLevelInfo(format, size, block, num_samples, tile_width_spacing);
|
||||
u32 tile_width_spacing, u32 level) {
|
||||
const LevelInfo info = MakeLevelInfo(format, size, block, tile_width_spacing);
|
||||
u32 offset = 0;
|
||||
for (u32 current_level = 0; current_level < level; ++current_level) {
|
||||
offset += CalculateLevelSize(info, current_level);
|
||||
|
@ -645,8 +625,8 @@ u32 CalculateLayerStride(const ImageInfo& info) noexcept {
|
|||
|
||||
u32 CalculateLayerSize(const ImageInfo& info) noexcept {
|
||||
ASSERT(info.type != ImageType::Linear);
|
||||
return CalculateLevelOffset(info.format, info.size, info.block, info.num_samples,
|
||||
info.tile_width_spacing, info.resources.levels);
|
||||
return CalculateLevelOffset(info.format, info.size, info.block, info.tile_width_spacing,
|
||||
info.resources.levels);
|
||||
}
|
||||
|
||||
LevelArray CalculateMipLevelOffsets(const ImageInfo& info) noexcept {
|
||||
|
@ -1195,37 +1175,37 @@ static_assert(CalculateLevelSize(LevelInfo{{1920, 1080, 1}, {0, 2, 0}, {1, 1}, 2
|
|||
0x7f8000);
|
||||
static_assert(CalculateLevelSize(LevelInfo{{32, 32, 1}, {0, 0, 4}, {1, 1}, 4, 0}, 0) == 0x4000);
|
||||
|
||||
static_assert(CalculateLevelOffset(PixelFormat::R8_SINT, {1920, 1080, 1}, {0, 2, 0}, 1, 0, 7) ==
|
||||
static_assert(CalculateLevelOffset(PixelFormat::R8_SINT, {1920, 1080, 1}, {0, 2, 0}, 0, 7) ==
|
||||
0x2afc00);
|
||||
static_assert(CalculateLevelOffset(PixelFormat::ASTC_2D_12X12_UNORM, {8192, 4096, 1}, {0, 2, 0}, 1,
|
||||
0, 12) == 0x50d200);
|
||||
static_assert(CalculateLevelOffset(PixelFormat::ASTC_2D_12X12_UNORM, {8192, 4096, 1}, {0, 2, 0}, 0,
|
||||
12) == 0x50d200);
|
||||
|
||||
static_assert(CalculateLevelOffset(PixelFormat::A8B8G8R8_UNORM, {1024, 1024, 1}, {0, 4, 0}, 1, 0,
|
||||
0) == 0);
|
||||
static_assert(CalculateLevelOffset(PixelFormat::A8B8G8R8_UNORM, {1024, 1024, 1}, {0, 4, 0}, 1, 0,
|
||||
1) == 0x400000);
|
||||
static_assert(CalculateLevelOffset(PixelFormat::A8B8G8R8_UNORM, {1024, 1024, 1}, {0, 4, 0}, 1, 0,
|
||||
2) == 0x500000);
|
||||
static_assert(CalculateLevelOffset(PixelFormat::A8B8G8R8_UNORM, {1024, 1024, 1}, {0, 4, 0}, 1, 0,
|
||||
3) == 0x540000);
|
||||
static_assert(CalculateLevelOffset(PixelFormat::A8B8G8R8_UNORM, {1024, 1024, 1}, {0, 4, 0}, 1, 0,
|
||||
4) == 0x550000);
|
||||
static_assert(CalculateLevelOffset(PixelFormat::A8B8G8R8_UNORM, {1024, 1024, 1}, {0, 4, 0}, 1, 0,
|
||||
5) == 0x554000);
|
||||
static_assert(CalculateLevelOffset(PixelFormat::A8B8G8R8_UNORM, {1024, 1024, 1}, {0, 4, 0}, 1, 0,
|
||||
6) == 0x555000);
|
||||
static_assert(CalculateLevelOffset(PixelFormat::A8B8G8R8_UNORM, {1024, 1024, 1}, {0, 4, 0}, 1, 0,
|
||||
7) == 0x555400);
|
||||
static_assert(CalculateLevelOffset(PixelFormat::A8B8G8R8_UNORM, {1024, 1024, 1}, {0, 4, 0}, 1, 0,
|
||||
8) == 0x555600);
|
||||
static_assert(CalculateLevelOffset(PixelFormat::A8B8G8R8_UNORM, {1024, 1024, 1}, {0, 4, 0}, 1, 0,
|
||||
9) == 0x555800);
|
||||
static_assert(CalculateLevelOffset(PixelFormat::A8B8G8R8_UNORM, {1024, 1024, 1}, {0, 4, 0}, 0, 0) ==
|
||||
0);
|
||||
static_assert(CalculateLevelOffset(PixelFormat::A8B8G8R8_UNORM, {1024, 1024, 1}, {0, 4, 0}, 0, 1) ==
|
||||
0x400000);
|
||||
static_assert(CalculateLevelOffset(PixelFormat::A8B8G8R8_UNORM, {1024, 1024, 1}, {0, 4, 0}, 0, 2) ==
|
||||
0x500000);
|
||||
static_assert(CalculateLevelOffset(PixelFormat::A8B8G8R8_UNORM, {1024, 1024, 1}, {0, 4, 0}, 0, 3) ==
|
||||
0x540000);
|
||||
static_assert(CalculateLevelOffset(PixelFormat::A8B8G8R8_UNORM, {1024, 1024, 1}, {0, 4, 0}, 0, 4) ==
|
||||
0x550000);
|
||||
static_assert(CalculateLevelOffset(PixelFormat::A8B8G8R8_UNORM, {1024, 1024, 1}, {0, 4, 0}, 0, 5) ==
|
||||
0x554000);
|
||||
static_assert(CalculateLevelOffset(PixelFormat::A8B8G8R8_UNORM, {1024, 1024, 1}, {0, 4, 0}, 0, 6) ==
|
||||
0x555000);
|
||||
static_assert(CalculateLevelOffset(PixelFormat::A8B8G8R8_UNORM, {1024, 1024, 1}, {0, 4, 0}, 0, 7) ==
|
||||
0x555400);
|
||||
static_assert(CalculateLevelOffset(PixelFormat::A8B8G8R8_UNORM, {1024, 1024, 1}, {0, 4, 0}, 0, 8) ==
|
||||
0x555600);
|
||||
static_assert(CalculateLevelOffset(PixelFormat::A8B8G8R8_UNORM, {1024, 1024, 1}, {0, 4, 0}, 0, 9) ==
|
||||
0x555800);
|
||||
|
||||
constexpr u32 ValidateLayerSize(PixelFormat format, u32 width, u32 height, u32 block_height,
|
||||
u32 tile_width_spacing, u32 level) {
|
||||
const Extent3D size{width, height, 1};
|
||||
const Extent3D block{0, block_height, 0};
|
||||
const u32 offset = CalculateLevelOffset(format, size, block, 1, tile_width_spacing, level);
|
||||
const u32 offset = CalculateLevelOffset(format, size, block, tile_width_spacing, level);
|
||||
return AlignLayerSize(offset, size, block, DefaultBlockHeight(format), tile_width_spacing);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue