diff options
author | pineappleEA <pineaea@gmail.com> | 2024-02-16 03:52:15 +0100 |
---|---|---|
committer | pineappleEA <pineaea@gmail.com> | 2024-02-16 03:52:15 +0100 |
commit | 7a77957f8bdad7e8bef66ac7d9891db6cfd97665 (patch) | |
tree | 89b38cd52c8ba283b9f10b3e4d018242f6c4b548 | |
parent | 40d2b57dc0e363a5b8614353b8057c94b4e2678b (diff) |
early-access version 4142EA-4142
-rwxr-xr-x | README.md | 2 | ||||
-rwxr-xr-x | src/shader_recompiler/backend/spirv/emit_spirv_image.cpp | 47 | ||||
-rwxr-xr-x | src/shader_recompiler/backend/spirv/emit_spirv_instructions.h | 4 | ||||
-rwxr-xr-x | src/video_core/buffer_cache/buffer_cache.h | 2 | ||||
-rwxr-xr-x | src/video_core/surface.cpp | 14 | ||||
-rwxr-xr-x | src/video_core/surface.h | 2 | ||||
-rwxr-xr-x | src/video_core/texture_cache/texture_cache.h | 6 | ||||
-rwxr-xr-x | src/video_core/vulkan_common/vulkan_device.cpp | 5 |
8 files changed, 67 insertions, 15 deletions
@@ -1,7 +1,7 @@ | |||
1 | yuzu emulator early access | 1 | yuzu emulator early access |
2 | ============= | 2 | ============= |
3 | 3 | ||
4 | This is the source code for early-access 4141. | 4 | This is the source code for early-access 4142. |
5 | 5 | ||
6 | ## Legal Notice | 6 | ## Legal Notice |
7 | 7 | ||
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp index ad33210f2..b53e1f446 100755 --- a/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_image.cpp | |||
@@ -60,11 +60,10 @@ public: | |||
60 | Add(spv::ImageOperandsMask::ConstOffsets, offsets); | 60 | Add(spv::ImageOperandsMask::ConstOffsets, offsets); |
61 | } | 61 | } |
62 | 62 | ||
63 | explicit ImageOperands(EmitContext& ctx, const IR::Value& offset, Id lod, Id ms) { | 63 | explicit ImageOperands(Id lod, Id ms) { |
64 | if (Sirit::ValidId(lod)) { | 64 | if (Sirit::ValidId(lod)) { |
65 | Add(spv::ImageOperandsMask::Lod, lod); | 65 | Add(spv::ImageOperandsMask::Lod, lod); |
66 | } | 66 | } |
67 | AddOffset(ctx, offset, ImageFetchOffsetAllowed); | ||
68 | if (Sirit::ValidId(ms)) { | 67 | if (Sirit::ValidId(ms)) { |
69 | Add(spv::ImageOperandsMask::Sample, ms); | 68 | Add(spv::ImageOperandsMask::Sample, ms); |
70 | } | 69 | } |
@@ -312,6 +311,43 @@ Id ImageGatherSubpixelOffset(EmitContext& ctx, const IR::TextureInstInfo& info, | |||
312 | return coords; | 311 | return coords; |
313 | } | 312 | } |
314 | } | 313 | } |
314 | |||
315 | void AddOffsetToCoordinates(EmitContext& ctx, const IR::TextureInstInfo& info, Id& coords, | ||
316 | Id offset) { | ||
317 | if (!Sirit::ValidId(offset)) { | ||
318 | return; | ||
319 | } | ||
320 | |||
321 | Id result_type{}; | ||
322 | switch (info.type) { | ||
323 | case TextureType::Buffer: | ||
324 | case TextureType::Color1D: { | ||
325 | result_type = ctx.U32[1]; | ||
326 | break; | ||
327 | } | ||
328 | case TextureType::ColorArray1D: | ||
329 | offset = ctx.OpCompositeConstruct(ctx.U32[2], offset, ctx.u32_zero_value); | ||
330 | [[fallthrough]]; | ||
331 | case TextureType::Color2D: | ||
332 | case TextureType::Color2DRect: { | ||
333 | result_type = ctx.U32[2]; | ||
334 | break; | ||
335 | } | ||
336 | case TextureType::ColorArray2D: | ||
337 | offset = ctx.OpCompositeConstruct(ctx.U32[3], ctx.OpCompositeExtract(ctx.U32[1], coords, 0), | ||
338 | ctx.OpCompositeExtract(ctx.U32[1], coords, 1), | ||
339 | ctx.u32_zero_value); | ||
340 | [[fallthrough]]; | ||
341 | case TextureType::Color3D: { | ||
342 | result_type = ctx.U32[3]; | ||
343 | break; | ||
344 | } | ||
345 | case TextureType::ColorCube: | ||
346 | case TextureType::ColorArrayCube: | ||
347 | return; | ||
348 | } | ||
349 | coords = ctx.OpIAdd(result_type, coords, offset); | ||
350 | } | ||
315 | } // Anonymous namespace | 351 | } // Anonymous namespace |
316 | 352 | ||
317 | Id EmitBindlessImageSampleImplicitLod(EmitContext&) { | 353 | Id EmitBindlessImageSampleImplicitLod(EmitContext&) { |
@@ -494,9 +530,10 @@ Id EmitImageGatherDref(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, | |||
494 | operands.Span()); | 530 | operands.Span()); |
495 | } | 531 | } |
496 | 532 | ||
497 | Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, | 533 | Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id offset, |
498 | const IR::Value& offset, Id lod, Id ms) { | 534 | Id lod, Id ms) { |
499 | const auto info{inst->Flags<IR::TextureInstInfo>()}; | 535 | const auto info{inst->Flags<IR::TextureInstInfo>()}; |
536 | AddOffsetToCoordinates(ctx, info, coords, offset); | ||
500 | if (info.type == TextureType::Buffer) { | 537 | if (info.type == TextureType::Buffer) { |
501 | lod = Id{}; | 538 | lod = Id{}; |
502 | } | 539 | } |
@@ -504,7 +541,7 @@ Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id c | |||
504 | // This image is multisampled, lod must be implicit | 541 | // This image is multisampled, lod must be implicit |
505 | lod = Id{}; | 542 | lod = Id{}; |
506 | } | 543 | } |
507 | const ImageOperands operands(ctx, offset, lod, ms); | 544 | const ImageOperands operands(lod, ms); |
508 | return Emit(&EmitContext::OpImageSparseFetch, &EmitContext::OpImageFetch, ctx, inst, ctx.F32[4], | 545 | return Emit(&EmitContext::OpImageSparseFetch, &EmitContext::OpImageFetch, ctx, inst, ctx.F32[4], |
509 | TextureImage(ctx, info, index), coords, operands.MaskOptional(), operands.Span()); | 546 | TextureImage(ctx, info, index), coords, operands.MaskOptional(), operands.Span()); |
510 | } | 547 | } |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h index 9465b0f32..7a3300b33 100755 --- a/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h +++ b/src/shader_recompiler/backend/spirv/emit_spirv_instructions.h | |||
@@ -537,8 +537,8 @@ Id EmitImageGather(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id | |||
537 | const IR::Value& offset, const IR::Value& offset2); | 537 | const IR::Value& offset, const IR::Value& offset2); |
538 | Id EmitImageGatherDref(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, | 538 | Id EmitImageGatherDref(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, |
539 | const IR::Value& offset, const IR::Value& offset2, Id dref); | 539 | const IR::Value& offset, const IR::Value& offset2, Id dref); |
540 | Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, | 540 | Id EmitImageFetch(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords, Id offset, |
541 | const IR::Value& offset, Id lod, Id ms); | 541 | Id lod, Id ms); |
542 | Id EmitImageQueryDimensions(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id lod, | 542 | Id EmitImageQueryDimensions(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id lod, |
543 | const IR::Value& skip_mips); | 543 | const IR::Value& skip_mips); |
544 | Id EmitImageQueryLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords); | 544 | Id EmitImageQueryLod(EmitContext& ctx, IR::Inst* inst, const IR::Value& index, Id coords); |
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index 1f33301b7..1d6c117b1 100755 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h | |||
@@ -35,7 +35,7 @@ BufferCache<P>::BufferCache(Tegra::MaxwellDeviceMemoryManager& device_memory_, R | |||
35 | const s64 min_spacing_critical = device_local_memory - 512_MiB; | 35 | const s64 min_spacing_critical = device_local_memory - 512_MiB; |
36 | const s64 mem_threshold = std::min(device_local_memory, TARGET_THRESHOLD); | 36 | const s64 mem_threshold = std::min(device_local_memory, TARGET_THRESHOLD); |
37 | const s64 min_vacancy_expected = (6 * mem_threshold) / 10; | 37 | const s64 min_vacancy_expected = (6 * mem_threshold) / 10; |
38 | const s64 min_vacancy_critical = (3 * mem_threshold) / 10; | 38 | const s64 min_vacancy_critical = (2 * mem_threshold) / 10; |
39 | minimum_memory = static_cast<u64>( | 39 | minimum_memory = static_cast<u64>( |
40 | std::max(std::min(device_local_memory - min_vacancy_expected, min_spacing_expected), | 40 | std::max(std::min(device_local_memory - min_vacancy_expected, min_spacing_expected), |
41 | DEFAULT_EXPECTED_MEMORY)); | 41 | DEFAULT_EXPECTED_MEMORY)); |
diff --git a/src/video_core/surface.cpp b/src/video_core/surface.cpp index c48e19ffa..a94d2371a 100755 --- a/src/video_core/surface.cpp +++ b/src/video_core/surface.cpp | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #include "common/common_types.h" | 4 | #include "common/common_types.h" |
5 | #include "common/math_util.h" | 5 | #include "common/math_util.h" |
6 | #include "common/settings.h" | ||
6 | #include "video_core/surface.h" | 7 | #include "video_core/surface.h" |
7 | 8 | ||
8 | namespace VideoCore::Surface { | 9 | namespace VideoCore::Surface { |
@@ -400,11 +401,20 @@ std::pair<u32, u32> GetASTCBlockSize(PixelFormat format) { | |||
400 | return {DefaultBlockWidth(format), DefaultBlockHeight(format)}; | 401 | return {DefaultBlockWidth(format), DefaultBlockHeight(format)}; |
401 | } | 402 | } |
402 | 403 | ||
403 | u64 EstimatedDecompressedSize(u64 base_size, PixelFormat format) { | 404 | u64 TranscodedAstcSize(u64 base_size, PixelFormat format) { |
404 | constexpr u64 RGBA8_PIXEL_SIZE = 4; | 405 | constexpr u64 RGBA8_PIXEL_SIZE = 4; |
405 | const u64 base_block_size = static_cast<u64>(DefaultBlockWidth(format)) * | 406 | const u64 base_block_size = static_cast<u64>(DefaultBlockWidth(format)) * |
406 | static_cast<u64>(DefaultBlockHeight(format)) * RGBA8_PIXEL_SIZE; | 407 | static_cast<u64>(DefaultBlockHeight(format)) * RGBA8_PIXEL_SIZE; |
407 | return (base_size * base_block_size) / BytesPerBlock(format); | 408 | const u64 uncompressed_size = (base_size * base_block_size) / BytesPerBlock(format); |
409 | |||
410 | switch (Settings::values.astc_recompression.GetValue()) { | ||
411 | case Settings::AstcRecompression::Bc1: | ||
412 | return uncompressed_size / 8; | ||
413 | case Settings::AstcRecompression::Bc3: | ||
414 | return uncompressed_size / 4; | ||
415 | default: | ||
416 | return uncompressed_size; | ||
417 | } | ||
408 | } | 418 | } |
409 | 419 | ||
410 | } // namespace VideoCore::Surface | 420 | } // namespace VideoCore::Surface |
diff --git a/src/video_core/surface.h b/src/video_core/surface.h index 9ac9b6343..2c212a6b1 100755 --- a/src/video_core/surface.h +++ b/src/video_core/surface.h | |||
@@ -517,6 +517,6 @@ size_t PixelComponentSizeBitsInteger(PixelFormat format); | |||
517 | 517 | ||
518 | std::pair<u32, u32> GetASTCBlockSize(PixelFormat format); | 518 | std::pair<u32, u32> GetASTCBlockSize(PixelFormat format); |
519 | 519 | ||
520 | u64 EstimatedDecompressedSize(u64 base_size, PixelFormat format); | 520 | u64 TranscodedAstcSize(u64 base_size, PixelFormat format); |
521 | 521 | ||
522 | } // namespace VideoCore::Surface | 522 | } // namespace VideoCore::Surface |
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 47ea0bd96..f790897ef 100755 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
@@ -55,7 +55,7 @@ TextureCache<P>::TextureCache(Runtime& runtime_, Tegra::MaxwellDeviceMemoryManag | |||
55 | const s64 min_spacing_critical = device_local_memory - 512_MiB; | 55 | const s64 min_spacing_critical = device_local_memory - 512_MiB; |
56 | const s64 mem_threshold = std::min(device_local_memory, TARGET_THRESHOLD); | 56 | const s64 mem_threshold = std::min(device_local_memory, TARGET_THRESHOLD); |
57 | const s64 min_vacancy_expected = (6 * mem_threshold) / 10; | 57 | const s64 min_vacancy_expected = (6 * mem_threshold) / 10; |
58 | const s64 min_vacancy_critical = (3 * mem_threshold) / 10; | 58 | const s64 min_vacancy_critical = (2 * mem_threshold) / 10; |
59 | expected_memory = static_cast<u64>( | 59 | expected_memory = static_cast<u64>( |
60 | std::max(std::min(device_local_memory - min_vacancy_expected, min_spacing_expected), | 60 | std::max(std::min(device_local_memory - min_vacancy_expected, min_spacing_expected), |
61 | DEFAULT_EXPECTED_MEMORY)); | 61 | DEFAULT_EXPECTED_MEMORY)); |
@@ -1979,7 +1979,7 @@ void TextureCache<P>::RegisterImage(ImageId image_id) { | |||
1979 | if ((IsPixelFormatASTC(image.info.format) && | 1979 | if ((IsPixelFormatASTC(image.info.format) && |
1980 | True(image.flags & ImageFlagBits::AcceleratedUpload)) || | 1980 | True(image.flags & ImageFlagBits::AcceleratedUpload)) || |
1981 | True(image.flags & ImageFlagBits::Converted)) { | 1981 | True(image.flags & ImageFlagBits::Converted)) { |
1982 | tentative_size = EstimatedDecompressedSize(tentative_size, image.info.format); | 1982 | tentative_size = TranscodedAstcSize(tentative_size, image.info.format); |
1983 | } | 1983 | } |
1984 | total_used_memory += Common::AlignUp(tentative_size, 1024); | 1984 | total_used_memory += Common::AlignUp(tentative_size, 1024); |
1985 | image.lru_index = lru_cache.Insert(image_id, frame_tick); | 1985 | image.lru_index = lru_cache.Insert(image_id, frame_tick); |
@@ -2149,7 +2149,7 @@ void TextureCache<P>::DeleteImage(ImageId image_id, bool immediate_delete) { | |||
2149 | if ((IsPixelFormatASTC(image.info.format) && | 2149 | if ((IsPixelFormatASTC(image.info.format) && |
2150 | True(image.flags & ImageFlagBits::AcceleratedUpload)) || | 2150 | True(image.flags & ImageFlagBits::AcceleratedUpload)) || |
2151 | True(image.flags & ImageFlagBits::Converted)) { | 2151 | True(image.flags & ImageFlagBits::Converted)) { |
2152 | tentative_size = EstimatedDecompressedSize(tentative_size, image.info.format); | 2152 | tentative_size = TranscodedAstcSize(tentative_size, image.info.format); |
2153 | } | 2153 | } |
2154 | total_used_memory -= Common::AlignUp(tentative_size, 1024); | 2154 | total_used_memory -= Common::AlignUp(tentative_size, 1024); |
2155 | const GPUVAddr gpu_addr = image.gpu_addr; | 2155 | const GPUVAddr gpu_addr = image.gpu_addr; |
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index 940cc0a54..bd77057b0 100755 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp | |||
@@ -1290,6 +1290,10 @@ u64 Device::GetDeviceMemoryUsage() const { | |||
1290 | } | 1290 | } |
1291 | 1291 | ||
1292 | void Device::CollectPhysicalMemoryInfo() { | 1292 | void Device::CollectPhysicalMemoryInfo() { |
1293 | // Account for resolution scaling in memory limits | ||
1294 | const size_t normal_memory = 6_GiB; | ||
1295 | const size_t scaler_memory = 1_GiB * Settings::values.resolution_info.ScaleUp(1); | ||
1296 | |||
1293 | // Calculate limits using memory budget | 1297 | // Calculate limits using memory budget |
1294 | VkPhysicalDeviceMemoryBudgetPropertiesEXT budget{}; | 1298 | VkPhysicalDeviceMemoryBudgetPropertiesEXT budget{}; |
1295 | budget.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT; | 1299 | budget.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT; |
@@ -1320,6 +1324,7 @@ void Device::CollectPhysicalMemoryInfo() { | |||
1320 | if (!is_integrated) { | 1324 | if (!is_integrated) { |
1321 | const u64 reserve_memory = std::min<u64>(device_access_memory / 8, 1_GiB); | 1325 | const u64 reserve_memory = std::min<u64>(device_access_memory / 8, 1_GiB); |
1322 | device_access_memory -= reserve_memory; | 1326 | device_access_memory -= reserve_memory; |
1327 | device_access_memory = std::min<u64>(device_access_memory, normal_memory + scaler_memory); | ||
1323 | return; | 1328 | return; |
1324 | } | 1329 | } |
1325 | const s64 available_memory = static_cast<s64>(device_access_memory - device_initial_usage); | 1330 | const s64 available_memory = static_cast<s64>(device_access_memory - device_initial_usage); |