early-access version 2914

This commit is contained in:
pineappleEA
2022-08-21 22:11:13 +02:00
parent d4d68be38e
commit c141471dce
31 changed files with 193 additions and 249 deletions

View File

@@ -9,7 +9,7 @@
#include "core/memory.h"
#include "video_core/host1x/host1x.h"
using Core::Memory::PAGE_SIZE;
using Core::Memory::YUZU_PAGESIZE;
namespace Service::Nvidia::NvCore {
NvMap::Handle::Handle(u64 size_, Id id_)
@@ -27,7 +27,7 @@ NvResult NvMap::Handle::Alloc(Flags pFlags, u32 pAlign, u8 pKind, u64 pAddress)
flags = pFlags;
kind = pKind;
align = pAlign < PAGE_SIZE ? PAGE_SIZE : pAlign;
align = pAlign < YUZU_PAGESIZE ? YUZU_PAGESIZE : pAlign;
// This flag is only applicable for handles with an address passed
if (pAddress) {
@@ -37,7 +37,7 @@ NvResult NvMap::Handle::Alloc(Flags pFlags, u32 pAlign, u8 pKind, u64 pAddress)
"Mapping nvmap handles without a CPU side address is unimplemented!");
}
size = Common::AlignUp(size, PAGE_SIZE);
size = Common::AlignUp(size, YUZU_PAGESIZE);
aligned_size = Common::AlignUp(size, align);
address = pAddress;
allocated = true;

View File

@@ -153,7 +153,7 @@ NvResult nvhost_as_gpu::AllocateSpace(const std::vector<u8>& input, std::vector<
return NvResult::BadValue;
}
if (params.page_size != VM::PAGE_SIZE && params.page_size != vm.big_page_size) {
if (params.page_size != VM::YUZU_PAGESIZE && params.page_size != vm.big_page_size) {
return NvResult::BadValue;
}
@@ -163,11 +163,11 @@ NvResult nvhost_as_gpu::AllocateSpace(const std::vector<u8>& input, std::vector<
return NvResult::NotImplemented;
}
const u32 page_size_bits{params.page_size == VM::PAGE_SIZE ? VM::PAGE_SIZE_BITS
: vm.big_page_size_bits};
const u32 page_size_bits{params.page_size == VM::YUZU_PAGESIZE ? VM::PAGE_SIZE_BITS
: vm.big_page_size_bits};
auto& allocator{params.page_size == VM::PAGE_SIZE ? *vm.small_page_allocator
: *vm.big_page_allocator};
auto& allocator{params.page_size == VM::YUZU_PAGESIZE ? *vm.small_page_allocator
: *vm.big_page_allocator};
if ((params.flags & MappingFlags::Fixed) != MappingFlags::None) {
allocator.AllocateFixed(static_cast<u32>(params.offset >> page_size_bits), params.pages);
@@ -190,7 +190,7 @@ NvResult nvhost_as_gpu::AllocateSpace(const std::vector<u8>& input, std::vector<
.mappings{},
.page_size = params.page_size,
.sparse = (params.flags & MappingFlags::Sparse) != MappingFlags::None,
.big_pages = params.page_size != VM::PAGE_SIZE,
.big_pages = params.page_size != VM::YUZU_PAGESIZE,
};
std::memcpy(output.data(), &params, output.size());
@@ -248,10 +248,10 @@ NvResult nvhost_as_gpu::FreeSpace(const std::vector<u8>& input, std::vector<u8>&
gmmu->Unmap(params.offset, allocation.size);
}
auto& allocator{params.page_size == VM::PAGE_SIZE ? *vm.small_page_allocator
: *vm.big_page_allocator};
u32 page_size_bits{params.page_size == VM::PAGE_SIZE ? VM::PAGE_SIZE_BITS
: vm.big_page_size_bits};
auto& allocator{params.page_size == VM::YUZU_PAGESIZE ? *vm.small_page_allocator
: *vm.big_page_allocator};
u32 page_size_bits{params.page_size == VM::YUZU_PAGESIZE ? VM::PAGE_SIZE_BITS
: vm.big_page_size_bits};
allocator.Free(static_cast<u32>(params.offset >> page_size_bits),
static_cast<u32>(allocation.size >> page_size_bits));
@@ -369,7 +369,7 @@ NvResult nvhost_as_gpu::MapBufferEx(const std::vector<u8>& input, std::vector<u8
bool big_page{[&]() {
if (Common::IsAligned(handle->align, vm.big_page_size))
return true;
else if (Common::IsAligned(handle->align, VM::PAGE_SIZE))
else if (Common::IsAligned(handle->align, VM::YUZU_PAGESIZE))
return false;
else {
ASSERT(false);
@@ -396,7 +396,7 @@ NvResult nvhost_as_gpu::MapBufferEx(const std::vector<u8>& input, std::vector<u8
} else {
auto& allocator{big_page ? *vm.big_page_allocator : *vm.small_page_allocator};
u32 page_size{big_page ? vm.big_page_size : VM::PAGE_SIZE};
u32 page_size{big_page ? vm.big_page_size : VM::YUZU_PAGESIZE};
u32 page_size_bits{big_page ? vm.big_page_size_bits : VM::PAGE_SIZE_BITS};
params.offset = static_cast<u64>(allocator.Allocate(
@@ -473,7 +473,7 @@ void nvhost_as_gpu::GetVARegionsImpl(IoctlGetVaRegions& params) {
params.regions = std::array<VaRegion, 2>{
VaRegion{
.offset = vm.small_page_allocator->GetVAStart() << VM::PAGE_SIZE_BITS,
.page_size = VM::PAGE_SIZE,
.page_size = VM::YUZU_PAGESIZE,
._pad0_{},
.pages = vm.small_page_allocator->GetVALimit() - vm.small_page_allocator->GetVAStart(),
},

View File

@@ -188,8 +188,8 @@ private:
std::mutex mutex; //!< Locks all AS operations
struct VM {
static constexpr u32 PAGE_SIZE{0x1000};
static constexpr u32 PAGE_SIZE_BITS{std::countr_zero(PAGE_SIZE)};
static constexpr u32 YUZU_PAGESIZE{0x1000};
static constexpr u32 PAGE_SIZE_BITS{std::countr_zero(YUZU_PAGESIZE)};
static constexpr u32 SUPPORTED_BIG_PAGE_SIZES{0x30000};
static constexpr u32 DEFAULT_BIG_PAGE_SIZE{0x20000};

View File

@@ -16,7 +16,7 @@
#include "core/hle/service/nvdrv/devices/nvmap.h"
#include "core/memory.h"
using Core::Memory::PAGE_SIZE;
using Core::Memory::YUZU_PAGESIZE;
namespace Service::Nvidia::Devices {
@@ -75,7 +75,8 @@ NvResult nvmap::IocCreate(const std::vector<u8>& input, std::vector<u8>& output)
LOG_DEBUG(Service_NVDRV, "called, size=0x{:08X}", params.size);
std::shared_ptr<NvCore::NvMap::Handle> handle_description{};
auto result = file.CreateHandle(Common::AlignUp(params.size, PAGE_SIZE), handle_description);
auto result =
file.CreateHandle(Common::AlignUp(params.size, YUZU_PAGESIZE), handle_description);
if (result != NvResult::Success) {
LOG_CRITICAL(Service_NVDRV, "Failed to create Object");
return result;
@@ -104,8 +105,8 @@ NvResult nvmap::IocAlloc(const std::vector<u8>& input, std::vector<u8>& output)
}
// Force page size alignment at a minimum
if (params.align < PAGE_SIZE) {
params.align = PAGE_SIZE;
if (params.align < YUZU_PAGESIZE) {
params.align = YUZU_PAGESIZE;
}
auto handle_description{file.GetHandle(params.handle)};