Merge pull request #1 from citra-emu/master

2017/10/29 23:16
This commit is contained in:
raven3 2017-10-29 23:17:17 +09:00 committed by GitHub
commit 257b5c93ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 170 additions and 68 deletions

View File

@ -30,9 +30,9 @@ void EmuThread::run() {
stop_run = false;
// holds whether the cpu was running during the last iteration,
// Holds whether the cpu was running during the last iteration,
// so that the DebugModeLeft signal can be emitted before the
// next execution step
// next execution step.
bool was_active = false;
while (!stop_run) {
if (running) {

View File

@ -174,7 +174,7 @@ void GameList::onTextChanged(const QString& newText) {
child_file->data(GameListItemPath::ProgramIdRole).toString().toLower();
// Only items which filename in combination with its title contains all words
// that are in the searchfiel will be visible in the gamelist
// that are in the searchfield will be visible in the gamelist
// The search is case insensitive because of toLower()
// I decided not to use Qt::CaseInsensitive in containsAllWords to prevent
// multiple conversions of edit_filter_text for each game in the gamelist

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <algorithm>
#include <cinttypes>
#include <memory>
#include <vector>
#include "common/common_types.h"

View File

@ -24,6 +24,9 @@
namespace Service {
namespace AM {
constexpr u32 TID_HIGH_UPDATE = 0x0004000E;
constexpr u32 TID_HIGH_DLC = 0x0004008C;
static bool lists_initialized = false;
static std::array<std::vector<u64_le>, 3> am_title_list;
@ -182,7 +185,7 @@ void GetNumPrograms(Service::Interface* self) {
}
void FindContentInfos(Service::Interface* self) {
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1002, 4, 2); // 0x10020104
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1002, 4, 4); // 0x10020104
auto media_type = static_cast<Service::FS::MediaType>(rp.Pop<u8>());
u64 title_id = rp.Pop<u64>();
@ -225,7 +228,7 @@ void FindContentInfos(Service::Interface* self) {
}
void ListContentInfos(Service::Interface* self) {
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1003, 5, 1); // 0x10030142
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1003, 5, 2); // 0x10030142
u32 content_count = rp.Pop<u32>();
auto media_type = static_cast<Service::FS::MediaType>(rp.Pop<u8>());
u64 title_id = rp.Pop<u64>();
@ -264,7 +267,7 @@ void ListContentInfos(Service::Interface* self) {
}
void DeleteContents(Service::Interface* self) {
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1004, 4, 1); // 0x10040102
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1004, 4, 2); // 0x10040102
u8 media_type = rp.Pop<u8>();
u64 title_id = rp.Pop<u64>();
u32 content_count = rp.Pop<u32>();
@ -278,7 +281,7 @@ void DeleteContents(Service::Interface* self) {
}
void GetProgramList(Service::Interface* self) {
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 2, 2, 1); // 0x00020082
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 2, 2, 2); // 0x00020082
u32 count = rp.Pop<u32>();
u8 media_type = rp.Pop<u8>();
@ -302,18 +305,9 @@ void GetProgramList(Service::Interface* self) {
rb.Push(copied);
}
void GetProgramInfos(Service::Interface* self) {
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 3, 2, 2); // 0x00030084
auto media_type = static_cast<Service::FS::MediaType>(rp.Pop<u8>());
u32 title_count = rp.Pop<u32>();
VAddr title_id_list_pointer = rp.PopMappedBuffer();
VAddr title_info_out = rp.PopMappedBuffer();
std::vector<u64> title_id_list(title_count);
Memory::ReadBlock(title_id_list_pointer, title_id_list.data(), title_count * sizeof(u64));
for (u32 i = 0; i < title_count; i++) {
ResultCode GetTitleInfoFromList(const std::vector<u64>& title_id_list,
Service::FS::MediaType media_type, VAddr title_info_out) {
for (u32 i = 0; i < title_id_list.size(); i++) {
std::string tmd_path = GetTitleMetadataPath(media_type, title_id_list[i]);
TitleInfo title_info = {};
@ -326,23 +320,113 @@ void GetProgramInfos(Service::Interface* self) {
title_info.size = tmd.GetContentSizeByIndex(FileSys::TMDContentIndex::Main);
title_info.version = tmd.GetTitleVersion();
title_info.type = tmd.GetTitleType();
} else {
return ResultCode(ErrorDescription::NotFound, ErrorModule::AM,
ErrorSummary::InvalidState, ErrorLevel::Permanent);
}
Memory::WriteBlock(title_info_out, &title_info, sizeof(TitleInfo));
title_info_out += sizeof(TitleInfo);
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS);
return RESULT_SUCCESS;
}
void GetDataTitleInfos(Service::Interface* self) {
GetProgramInfos(self);
void GetProgramInfos(Service::Interface* self) {
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 3, 2, 4); // 0x00030084
LOG_WARNING(Service_AM, "(STUBBED) called");
auto media_type = static_cast<Service::FS::MediaType>(rp.Pop<u8>());
u32 title_count = rp.Pop<u32>();
size_t title_id_list_size, title_info_size;
IPC::MappedBufferPermissions title_id_list_perms, title_info_perms;
VAddr title_id_list_pointer = rp.PopMappedBuffer(&title_id_list_size, &title_id_list_perms);
VAddr title_info_out = rp.PopMappedBuffer(&title_info_size, &title_info_perms);
std::vector<u64> title_id_list(title_count);
Memory::ReadBlock(title_id_list_pointer, title_id_list.data(), title_count * sizeof(u64));
ResultCode result = GetTitleInfoFromList(title_id_list, media_type, title_info_out);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
rb.Push(result);
rb.PushMappedBuffer(title_id_list_pointer, title_id_list_size, title_id_list_perms);
rb.PushMappedBuffer(title_info_out, title_info_size, title_info_perms);
}
void GetDLCTitleInfos(Service::Interface* self) {
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1005, 2, 4); // 0x10050084
auto media_type = static_cast<Service::FS::MediaType>(rp.Pop<u8>());
u32 title_count = rp.Pop<u32>();
size_t title_id_list_size, title_info_size;
IPC::MappedBufferPermissions title_id_list_perms, title_info_perms;
VAddr title_id_list_pointer = rp.PopMappedBuffer(&title_id_list_size, &title_id_list_perms);
VAddr title_info_out = rp.PopMappedBuffer(&title_info_size, &title_info_perms);
std::vector<u64> title_id_list(title_count);
Memory::ReadBlock(title_id_list_pointer, title_id_list.data(), title_count * sizeof(u64));
ResultCode result = RESULT_SUCCESS;
// Validate that DLC TIDs were passed in
for (u32 i = 0; i < title_count; i++) {
u32 tid_high = static_cast<u32>(title_id_list[i] >> 32);
if (tid_high != TID_HIGH_DLC) {
result = ResultCode(ErrCodes::InvalidTIDInList, ErrorModule::AM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
break;
}
}
if (result.IsSuccess()) {
result = GetTitleInfoFromList(title_id_list, media_type, title_info_out);
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
rb.Push(result);
rb.PushMappedBuffer(title_id_list_pointer, title_id_list_size, title_id_list_perms);
rb.PushMappedBuffer(title_info_out, title_info_size, title_info_perms);
}
void GetPatchTitleInfos(Service::Interface* self) {
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x100D, 2, 4); // 0x100D0084
auto media_type = static_cast<Service::FS::MediaType>(rp.Pop<u8>());
u32 title_count = rp.Pop<u32>();
size_t title_id_list_size, title_info_size;
IPC::MappedBufferPermissions title_id_list_perms, title_info_perms;
VAddr title_id_list_pointer = rp.PopMappedBuffer(&title_id_list_size, &title_id_list_perms);
VAddr title_info_out = rp.PopMappedBuffer(&title_info_size, &title_info_perms);
std::vector<u64> title_id_list(title_count);
Memory::ReadBlock(title_id_list_pointer, title_id_list.data(), title_count * sizeof(u64));
ResultCode result = RESULT_SUCCESS;
// Validate that update TIDs were passed in
for (u32 i = 0; i < title_count; i++) {
u32 tid_high = static_cast<u32>(title_id_list[i] >> 32);
if (tid_high != TID_HIGH_UPDATE) {
result = ResultCode(ErrCodes::InvalidTIDInList, ErrorModule::AM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
break;
}
}
if (result.IsSuccess()) {
result = GetTitleInfoFromList(title_id_list, media_type, title_info_out);
}
IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
rb.Push(result);
rb.PushMappedBuffer(title_id_list_pointer, title_id_list_size, title_id_list_perms);
rb.PushMappedBuffer(title_info_out, title_info_size, title_info_perms);
}
void ListDataTitleTicketInfos(Service::Interface* self) {
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1007, 4, 1); // 0x10070102
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1007, 4, 4); // 0x10070102
u32 ticket_count = rp.Pop<u32>();
u64 title_id = rp.Pop<u64>();
u32 start_index = rp.Pop<u32>();
@ -408,7 +492,7 @@ void GetNumTickets(Service::Interface* self) {
}
void GetTicketList(Service::Interface* self) {
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 9, 2, 1); // 0x00090082
IPC::RequestParser rp(Kernel::GetCommandBuffer(), 9, 2, 2); // 0x00090082
u32 ticket_list_count = rp.Pop<u32>();
u32 ticket_index = rp.Pop<u32>();
VAddr ticket_tids_out = rp.PopMappedBuffer();

View File

@ -19,6 +19,12 @@ class Interface;
namespace AM {
namespace ErrCodes {
enum {
InvalidTIDInList = 60,
};
} // namespace ErrCodes
/**
* Get the .tmd path for a title
* @param media_type the media the title exists on
@ -139,8 +145,8 @@ void GetProgramList(Service::Interface* self);
void GetProgramInfos(Service::Interface* self);
/**
* AM::GetDataTitleInfos service function
* Wrapper for AM::GetProgramInfos
* AM::GetDLCTitleInfos service function
* Wrapper for AM::GetProgramInfos, explicitly checks that TID high value is 0004008C.
* Inputs:
* 1 : u8 Mediatype
* 2 : Total titles
@ -149,7 +155,22 @@ void GetProgramInfos(Service::Interface* self);
* Outputs:
* 1 : Result, 0 on success, otherwise error code
*/
void GetDataTitleInfos(Service::Interface* self);
void GetDLCTitleInfos(Service::Interface* self);
/**
* AM::GetPatchTitleInfos service function
* Wrapper for AM::GetProgramInfos, explicitly checks that TID high value is 0004000E.
* Inputs:
* 1 : u8 Mediatype
* 2 : Total titles
* 4 : TitleIDList input pointer
* 6 : TitleList output pointer
* Outputs:
* 1 : Result, 0 on success, otherwise error code
* 2 : TitleIDList input pointer
* 4 : TitleList output pointer
*/
void GetPatchTitleInfos(Service::Interface* self);
/**
* AM::ListDataTitleTicketInfos service function

View File

@ -13,7 +13,7 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x10020104, FindContentInfos, "FindContentInfos"},
{0x10030142, ListContentInfos, "ListContentInfos"},
{0x10040102, DeleteContents, "DeleteContents"},
{0x10050084, GetDataTitleInfos, "GetDataTitleInfos"},
{0x10050084, GetDLCTitleInfos, "GetDLCTitleInfos"},
{0x10060080, nullptr, "GetNumDataTitleTickets"},
{0x10070102, ListDataTitleTicketInfos, "ListDataTitleTicketInfos"},
{0x100801C2, nullptr, "GetItemRights"},
@ -21,7 +21,7 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x100A0000, nullptr, "IsExternalTitleDatabaseInitialized"},
{0x100B00C0, nullptr, "GetNumExistingContentInfos"},
{0x100C0142, nullptr, "ListExistingContentInfos"},
{0x100D0084, nullptr, "GetPatchTitleInfos"},
{0x100D0084, GetPatchTitleInfos, "GetPatchTitleInfos"},
};
AM_APP_Interface::AM_APP_Interface() {

View File

@ -58,7 +58,7 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x10020104, FindContentInfos, "FindContentInfos"},
{0x10030142, ListContentInfos, "ListContentInfos"},
{0x10040102, DeleteContents, "DeleteContents"},
{0x10050084, GetDataTitleInfos, "GetDataTitleInfos"},
{0x10050084, GetDLCTitleInfos, "GetDLCTitleInfos"},
{0x10060080, nullptr, "GetNumDataTitleTickets"},
{0x10070102, ListDataTitleTicketInfos, "ListDataTitleTicketInfos"},
{0x100801C2, nullptr, "GetItemRights"},
@ -66,7 +66,7 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x100A0000, nullptr, "IsExternalTitleDatabaseInitialized"},
{0x100B00C0, nullptr, "GetNumExistingContentInfos"},
{0x100C0142, nullptr, "ListExistingContentInfos"},
{0x100D0084, nullptr, "GetPatchTitleInfos"},
{0x100D0084, GetPatchTitleInfos, "GetPatchTitleInfos"},
};
AM_SYS_Interface::AM_SYS_Interface() {

View File

@ -393,7 +393,7 @@ void RasterizerMarkRegionCached(PAddr start, u32 size, int count_delta) {
case PageType::RasterizerCachedMemory: {
u8* pointer = GetPointerFromVMA(vaddr & ~PAGE_MASK);
if (pointer == nullptr) {
// It's possible that this function has called been while updating the pagetable
// It's possible that this function has been called while updating the pagetable
// after unmapping a VMA. In that case the underlying VMA will no longer exist,
// and we should just leave the pagetable entry blank.
page_type = PageType::Unmapped;

View File

@ -20,7 +20,6 @@
using Pica::Rasterizer::Vertex;
namespace Pica {
namespace Clipper {
struct ClippingEdge {
@ -192,6 +191,5 @@ void ProcessTriangle(const OutputVertex& v0, const OutputVertex& v1, const Outpu
}
}
} // namespace
} // namespace
} // namespace Clipper
} // namespace Pica

View File

@ -5,7 +5,6 @@
#pragma once
namespace Pica {
namespace Shader {
struct OutputVertex;
}
@ -16,6 +15,5 @@ using Shader::OutputVertex;
void ProcessTriangle(const OutputVertex& v0, const OutputVertex& v1, const OutputVertex& v2);
} // namespace
} // namespace
} // namespace Clipper
} // namespace Pica

View File

@ -376,8 +376,9 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve
if (use_border_s || use_border_t) {
auto border_color = texture.config.border_color;
texture_color[i] = {border_color.r, border_color.g, border_color.b,
border_color.a};
texture_color[i] = Math::MakeVec(border_color.r.Value(), border_color.g.Value(),
border_color.b.Value(), border_color.a.Value())
.Cast<u8>();
} else {
// Textures are laid out from bottom to top, hence we invert the t coordinate.
// NOTE: This may not be the right place for the inversion.
@ -414,12 +415,12 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve
// analogously.
Math::Vec4<u8> combiner_output;
Math::Vec4<u8> combiner_buffer = {0, 0, 0, 0};
Math::Vec4<u8> next_combiner_buffer = {
regs.texturing.tev_combiner_buffer_color.r,
regs.texturing.tev_combiner_buffer_color.g,
regs.texturing.tev_combiner_buffer_color.b,
regs.texturing.tev_combiner_buffer_color.a,
};
Math::Vec4<u8> next_combiner_buffer =
Math::MakeVec(regs.texturing.tev_combiner_buffer_color.r.Value(),
regs.texturing.tev_combiner_buffer_color.g.Value(),
regs.texturing.tev_combiner_buffer_color.b.Value(),
regs.texturing.tev_combiner_buffer_color.a.Value())
.Cast<u8>();
Math::Vec4<u8> primary_fragment_color = {0, 0, 0, 0};
Math::Vec4<u8> secondary_fragment_color = {0, 0, 0, 0};
@ -473,8 +474,9 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve
return combiner_buffer;
case Source::Constant:
return {tev_stage.const_r, tev_stage.const_g, tev_stage.const_b,
tev_stage.const_a};
return Math::MakeVec(tev_stage.const_r.Value(), tev_stage.const_g.Value(),
tev_stage.const_b.Value(), tev_stage.const_a.Value())
.Cast<u8>();
case Source::Previous:
return combiner_output;
@ -587,11 +589,10 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve
// store the depth etc. Using float for now until we know more
// about Pica datatypes
if (regs.texturing.fog_mode == TexturingRegs::FogMode::Fog) {
const Math::Vec3<u8> fog_color = {
static_cast<u8>(regs.texturing.fog_color.r.Value()),
static_cast<u8>(regs.texturing.fog_color.g.Value()),
static_cast<u8>(regs.texturing.fog_color.b.Value()),
};
const Math::Vec3<u8> fog_color = Math::MakeVec(regs.texturing.fog_color.r.Value(),
regs.texturing.fog_color.g.Value(),
regs.texturing.fog_color.b.Value())
.Cast<u8>();
// Get index into fog LUT
float fog_index;
@ -743,12 +744,12 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve
FramebufferRegs::BlendFactor factor) -> u8 {
DEBUG_ASSERT(channel < 4);
const Math::Vec4<u8> blend_const = {
static_cast<u8>(output_merger.blend_const.r),
static_cast<u8>(output_merger.blend_const.g),
static_cast<u8>(output_merger.blend_const.b),
static_cast<u8>(output_merger.blend_const.a),
};
const Math::Vec4<u8> blend_const =
Math::MakeVec(output_merger.blend_const.r.Value(),
output_merger.blend_const.g.Value(),
output_merger.blend_const.b.Value(),
output_merger.blend_const.a.Value())
.Cast<u8>();
switch (factor) {
case FramebufferRegs::BlendFactor::Zero:
@ -849,5 +850,4 @@ void ProcessTriangle(const Vertex& v0, const Vertex& v1, const Vertex& v2) {
}
} // namespace Rasterizer
} // namespace Pica

View File

@ -7,7 +7,6 @@
#include "video_core/shader/shader.h"
namespace Pica {
namespace Rasterizer {
struct Vertex : Shader::OutputVertex {
@ -44,5 +43,4 @@ struct Vertex : Shader::OutputVertex {
void ProcessTriangle(const Vertex& v0, const Vertex& v1, const Vertex& v2);
} // namespace Rasterizer
} // namespace Pica

View File

@ -12,4 +12,5 @@ void SWRasterizer::AddTriangle(const Pica::Shader::OutputVertex& v0,
const Pica::Shader::OutputVertex& v2) {
Pica::Clipper::ProcessTriangle(v0, v1, v2);
}
}
} // namespace VideoCore

View File

@ -24,4 +24,5 @@ class SWRasterizer : public RasterizerInterface {
void FlushRegion(PAddr addr, u32 size) override {}
void FlushAndInvalidateRegion(PAddr addr, u32 size) override {}
};
}
} // namespace VideoCore