aurora: the boring C++ version

This commit is contained in:
Luke Street 2022-02-16 00:21:24 -05:00
parent aa13632704
commit 7b9f893a49
78 changed files with 1071 additions and 404 deletions

3
.gitmodules vendored
View File

@ -60,3 +60,6 @@
[submodule "extern/SDL"] [submodule "extern/SDL"]
path = extern/SDL path = extern/SDL
url = https://github.com/libsdl-org/SDL.git url = https://github.com/libsdl-org/SDL.git
[submodule "extern/dawn"]
path = extern/dawn
url = https://github.com/encounter/dawn-cmake.git

View File

@ -485,7 +485,9 @@ target_link_libraries(hecl-full PRIVATE zeus nod)
target_link_libraries(hecl-light PRIVATE zeus nod) target_link_libraries(hecl-light PRIVATE zeus nod)
add_subdirectory(extern/SDL EXCLUDE_FROM_ALL) add_subdirectory(extern/SDL EXCLUDE_FROM_ALL)
target_compile_options(SDL2-static PRIVATE -Wno-implicit-fallthrough) if (NOT MSVC)
target_compile_options(SDL2-static PRIVATE -Wno-implicit-fallthrough)
endif ()
if(NOT TARGET atdna) if(NOT TARGET atdna)
# Import native atdna if cross-compiling # Import native atdna if cross-compiling
@ -507,7 +509,7 @@ add_subdirectory(extern/jbus EXCLUDE_FROM_ALL)
set(JBUS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/jbus/include) set(JBUS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/jbus/include)
add_subdirectory(NESEmulator EXCLUDE_FROM_ALL) add_subdirectory(NESEmulator EXCLUDE_FROM_ALL)
add_subdirectory(Graphics) add_subdirectory(aurora)
add_subdirectory(Runtime) add_subdirectory(Runtime)
add_subdirectory(mpcksum EXCLUDE_FROM_ALL) add_subdirectory(mpcksum EXCLUDE_FROM_ALL)
add_subdirectory(gbalink EXCLUDE_FROM_ALL) add_subdirectory(gbalink EXCLUDE_FROM_ALL)

View File

@ -4,6 +4,7 @@
#include "DeafBabe.hpp" #include "DeafBabe.hpp"
#include "zeus/CAABox.hpp" #include "zeus/CAABox.hpp"
#include "CMDL.hpp" #include "CMDL.hpp"
#include "IOStreams.hpp"
#include <set> #include <set>
namespace DataSpec { namespace DataSpec {

View File

@ -9,6 +9,7 @@
#include "DataSpec/DNAMP2/CSKR.hpp" #include "DataSpec/DNAMP2/CSKR.hpp"
#include "DataSpec/DNAMP3/CMDLMaterials.hpp" #include "DataSpec/DNAMP3/CMDLMaterials.hpp"
#include "DataSpec/DNAMP3/CSKR.hpp" #include "DataSpec/DNAMP3/CSKR.hpp"
#include "IOStreams.hpp"
#include <fmt/format.h> #include <fmt/format.h>
#include <hecl/Blender/Connection.hpp> #include <hecl/Blender/Connection.hpp>

View File

@ -321,10 +321,10 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat
metaforce::SObjectTag tag = g_curSpec->buildTagFromPath(path.first); metaforce::SObjectTag tag = g_curSpec->buildTagFromPath(path.first);
if (tag.id.IsValid()) { if (tag.id.IsValid()) {
if (path.second) if (path.second)
areaOut.lazyDeps.emplace_back(tag.id.Value(), tag.type); areaOut.lazyDeps.emplace_back(tag.id.Value(), tag.type.toUint32());
else else
areaOut.lazyDeps.emplace_back(0, FOURCC('NONE')); areaOut.lazyDeps.emplace_back(0, FOURCC('NONE'));
areaOut.deps.emplace_back(tag.id.Value(), tag.type); areaOut.deps.emplace_back(tag.id.Value(), tag.type.toUint32());
} }
} }
} }
@ -350,17 +350,17 @@ bool MLVL::Cook(const hecl::ProjectPath& outPath, const hecl::ProjectPath& inPat
metaforce::SObjectTag tag = g_curSpec->buildTagFromPath(path.first); metaforce::SObjectTag tag = g_curSpec->buildTagFromPath(path.first);
if (tag.id.IsValid()) { if (tag.id.IsValid()) {
if (path.second) if (path.second)
areaOut.lazyDeps.emplace_back(tag.id.Value(), tag.type); areaOut.lazyDeps.emplace_back(tag.id.Value(), tag.type.toUint32());
else else
areaOut.lazyDeps.emplace_back(0, FOURCC('NONE')); areaOut.lazyDeps.emplace_back(0, FOURCC('NONE'));
areaOut.deps.emplace_back(tag.id.Value(), tag.type); areaOut.deps.emplace_back(tag.id.Value(), tag.type.toUint32());
} }
} }
hecl::ProjectPath pathPath = GetPathBeginsWith(areaDEnum, area.path, "!path"); hecl::ProjectPath pathPath = GetPathBeginsWith(areaDEnum, area.path, "!path");
metaforce::SObjectTag pathTag = g_curSpec->buildTagFromPath(pathPath); metaforce::SObjectTag pathTag = g_curSpec->buildTagFromPath(pathPath);
if (pathTag.id.IsValid()) { if (pathTag.id.IsValid()) {
areaOut.deps.emplace_back(pathTag.id.Value(), pathTag.type); areaOut.deps.emplace_back(pathTag.id.Value(), pathTag.type.toUint32());
areaOut.lazyDeps.emplace_back(0, FOURCC('NONE')); areaOut.lazyDeps.emplace_back(0, FOURCC('NONE'));
} }
} }

View File

@ -482,7 +482,7 @@ void SpecBase::copyBuildListData(std::vector<std::tuple<size_t, size_t, bool>>&
auto& [positionOut, sizeOut, compressedOut] = fileIndex.emplace_back(); auto& [positionOut, sizeOut, compressedOut] = fileIndex.emplace_back();
if (tag.type == FOURCC('MLVL')) { if (tag.type.toUint32() == FOURCC('MLVL')) {
auto search = mlvlData.find(tag.id); auto search = mlvlData.find(tag.id);
if (search == mlvlData.end()) if (search == mlvlData.end())
Log.report(logvisor::Fatal, FMT_STRING("Unable to find MLVL {}"), tag.id); Log.report(logvisor::Fatal, FMT_STRING("Unable to find MLVL {}"), tag.id);
@ -635,7 +635,7 @@ void SpecBase::doPackage(const hecl::ProjectPath& path, const hecl::Database::Da
std::unordered_set<metaforce::SObjectTag> addedTags; std::unordered_set<metaforce::SObjectTag> addedTags;
addedTags.reserve(buildList.size()); addedTags.reserve(buildList.size());
for (auto& tag : buildList) { for (auto& tag : buildList) {
if ((i == 0 && tag.type == FOURCC('CMDL')) || (i == 1 && tag.type != FOURCC('CMDL'))) { if ((i == 0 && tag.type.toUint32() == FOURCC('CMDL')) || (i == 1 && tag.type.toUint32() != FOURCC('CMDL'))) {
if (addedTags.find(tag) != addedTags.end()) if (addedTags.find(tag) != addedTags.end())
continue; continue;
addedTags.insert(tag); addedTags.insert(tag);
@ -820,7 +820,7 @@ FourCC SpecBase::getResourceTypeById(metaforce::CAssetId id) const {
return {}; return {};
std::unique_lock lk(m_backgroundIndexMutex); std::unique_lock lk(m_backgroundIndexMutex);
metaforce::SObjectTag searchTag = {FourCC(), id}; metaforce::SObjectTag searchTag = {metaforce::FourCC(), id};
auto search = m_tagToPath.find(searchTag); auto search = m_tagToPath.find(searchTag);
if (search == m_tagToPath.end()) { if (search == m_tagToPath.end()) {
if (m_backgroundRunning) { if (m_backgroundRunning) {
@ -838,7 +838,7 @@ FourCC SpecBase::getResourceTypeById(metaforce::CAssetId id) const {
return {}; return {};
} }
return search->first.type; return search->first.type.toUint32();
} }
void SpecBase::enumerateResources(const std::function<bool(const metaforce::SObjectTag&)>& lambda) const { void SpecBase::enumerateResources(const std::function<bool(const metaforce::SObjectTag&)>& lambda) const {
@ -1121,7 +1121,7 @@ void SpecBase::backgroundIndexProc() {
const athena::io::YAMLNode& node = *child.second; const athena::io::YAMLNode& node = *child.second;
if (node.m_seqChildren.size() >= 2) { if (node.m_seqChildren.size() >= 2) {
unsigned long id = strtoul(child.first.c_str(), nullptr, 16); unsigned long id = strtoul(child.first.c_str(), nullptr, 16);
hecl::FourCC type(node.m_seqChildren[0]->m_scalarString.c_str()); metaforce::FourCC type(node.m_seqChildren[0]->m_scalarString.c_str());
metaforce::SObjectTag pathTag(type, id); metaforce::SObjectTag pathTag(type, id);
for (auto I = node.m_seqChildren.begin() + 1, E = node.m_seqChildren.end(); I != E; ++I) { for (auto I = node.m_seqChildren.begin() + 1, E = node.m_seqChildren.end(); I != E; ++I) {
hecl::ProjectPath path(m_project.getProjectWorkingPath(), (*I)->m_scalarString); hecl::ProjectPath path(m_project.getProjectWorkingPath(), (*I)->m_scalarString);
@ -1150,7 +1150,7 @@ void SpecBase::backgroundIndexProc() {
m_catalogTagToNames.reserve(nameReader.getRootNode()->m_mapChildren.size()); m_catalogTagToNames.reserve(nameReader.getRootNode()->m_mapChildren.size());
for (const auto& child : nameReader.getRootNode()->m_mapChildren) { for (const auto& child : nameReader.getRootNode()->m_mapChildren) {
unsigned long id = strtoul(child.second->m_scalarString.c_str(), nullptr, 16); unsigned long id = strtoul(child.second->m_scalarString.c_str(), nullptr, 16);
auto search = m_tagToPath.find(metaforce::SObjectTag(FourCC(), uint32_t(id))); auto search = m_tagToPath.find(metaforce::SObjectTag(metaforce::FourCC(), uint32_t(id)));
if (search != m_tagToPath.cend()) { if (search != m_tagToPath.cend()) {
std::string chLower = child.first; std::string chLower = child.first;
std::transform(chLower.cbegin(), chLower.cend(), chLower.begin(), tolower); std::transform(chLower.cbegin(), chLower.cend(), chLower.begin(), tolower);

View File

@ -1016,7 +1016,7 @@ struct SpecMP1 : SpecBase {
w.writeUint32Big(1); w.writeUint32Big(1);
DNAMP1::PAK::NameEntry nameEnt; DNAMP1::PAK::NameEntry nameEnt;
hecl::ProjectPath parentDir = worldPath.getParentPath(); hecl::ProjectPath parentDir = worldPath.getParentPath();
nameEnt.type = worldTag.type; nameEnt.type = worldTag.type.toUint32();
nameEnt.id = worldTag.id.Value(); nameEnt.id = worldTag.id.Value();
nameEnt.nameLen = atUint32(parentDir.getLastComponent().size()); nameEnt.nameLen = atUint32(parentDir.getLastComponent().size());
nameEnt.name = parentDir.getLastComponent(); nameEnt.name = parentDir.getLastComponent();
@ -1024,19 +1024,19 @@ struct SpecMP1 : SpecBase {
std::unordered_set<metaforce::CAssetId> addedTags; std::unordered_set<metaforce::CAssetId> addedTags;
for (auto& area : mlvl.areas) { for (auto& area : mlvl.areas) {
metaforce::SObjectTag areaTag(FOURCC('MREA'), area.areaMREAId.toUint64()); metaforce::SObjectTag areaTag(metaforce::FOURCC('MREA'), area.areaMREAId.toUint64());
bool dupeRes = false; bool dupeRes = false;
if (hecl::ProjectPath areaDir = pathFromTag(areaTag).getParentPath()) if (hecl::ProjectPath areaDir = pathFromTag(areaTag).getParentPath())
dupeRes = hecl::ProjectPath(areaDir, "!duperes").isFile(); dupeRes = hecl::ProjectPath(areaDir, "!duperes").isFile();
metaforce::SObjectTag nameTag(FOURCC('STRG'), area.areaNameId.toUint64()); metaforce::SObjectTag nameTag(metaforce::FOURCC('STRG'), area.areaNameId.toUint64());
if (nameTag) if (nameTag)
listOut.push_back(nameTag); listOut.push_back(nameTag);
for (const auto& dep : area.deps) { for (const auto& dep : area.deps) {
metaforce::CAssetId newId = dep.id.toUint64(); metaforce::CAssetId newId = dep.id.toUint64();
if (dupeRes || addedTags.find(newId) == addedTags.end()) { if (dupeRes || addedTags.find(newId) == addedTags.end()) {
listOut.emplace_back(dep.type, newId); listOut.emplace_back(dep.type.toUint32(), newId);
addedTags.insert(newId); addedTags.insert(newId);
} }
} }
@ -1069,18 +1069,18 @@ struct SpecMP1 : SpecBase {
area.depLayers = std::move(strippedDepLayers); area.depLayers = std::move(strippedDepLayers);
} }
metaforce::SObjectTag nameTag(FOURCC('STRG'), mlvl.worldNameId.toUint64()); metaforce::SObjectTag nameTag(metaforce::FOURCC('STRG'), mlvl.worldNameId.toUint64());
if (nameTag) if (nameTag)
listOut.push_back(nameTag); listOut.push_back(nameTag);
metaforce::SObjectTag savwTag(FOURCC('SAVW'), mlvl.saveWorldId.toUint64()); metaforce::SObjectTag savwTag(metaforce::FOURCC('SAVW'), mlvl.saveWorldId.toUint64());
if (savwTag) { if (savwTag) {
if (hecl::ProjectPath savwPath = pathFromTag(savwTag)) if (hecl::ProjectPath savwPath = pathFromTag(savwTag))
m_project.cookPath(savwPath, {}, false, true); m_project.cookPath(savwPath, {}, false, true);
listOut.push_back(savwTag); listOut.push_back(savwTag);
} }
metaforce::SObjectTag mapTag(FOURCC('MAPW'), mlvl.worldMap.toUint64()); metaforce::SObjectTag mapTag(metaforce::FOURCC('MAPW'), mlvl.worldMap.toUint64());
if (mapTag) { if (mapTag) {
if (hecl::ProjectPath mapPath = pathFromTag(mapTag)) { if (hecl::ProjectPath mapPath = pathFromTag(mapTag)) {
m_project.cookPath(mapPath, {}, false, true); m_project.cookPath(mapPath, {}, false, true);
@ -1096,14 +1096,14 @@ struct SpecMP1 : SpecBase {
for (atUint32 i = 0; i < mapaCount; ++i) { for (atUint32 i = 0; i < mapaCount; ++i) {
UniqueID32 id; UniqueID32 id;
id.read(r); id.read(r);
listOut.emplace_back(FOURCC('MAPA'), id.toUint64()); listOut.emplace_back(metaforce::FOURCC('MAPA'), id.toUint64());
} }
} }
} }
listOut.push_back(mapTag); listOut.push_back(mapTag);
} }
metaforce::SObjectTag skyboxTag(FOURCC('CMDL'), mlvl.worldSkyboxId.toUint64()); metaforce::SObjectTag skyboxTag(metaforce::FOURCC('CMDL'), mlvl.worldSkyboxId.toUint64());
if (skyboxTag) { if (skyboxTag) {
listOut.push_back(skyboxTag); listOut.push_back(skyboxTag);
hecl::ProjectPath skyboxPath = pathFromTag(skyboxTag); hecl::ProjectPath skyboxPath = pathFromTag(skyboxTag);
@ -1126,7 +1126,7 @@ struct SpecMP1 : SpecBase {
for (const auto& item : listOut) { for (const auto& item : listOut) {
DNAMP1::PAK::Entry ent; DNAMP1::PAK::Entry ent;
ent.compressed = 0; ent.compressed = 0;
ent.type = item.type; ent.type = item.type.toUint32();
ent.id = item.id.Value(); ent.id = item.id.Value();
ent.size = 0; ent.size = 0;
ent.offset = 0; ent.offset = 0;
@ -1153,7 +1153,7 @@ struct SpecMP1 : SpecBase {
w.writeUint32Big(atUint32(nameList.size())); w.writeUint32Big(atUint32(nameList.size()));
for (const auto& item : nameList) { for (const auto& item : nameList) {
DNAMP1::PAK::NameEntry nameEnt; DNAMP1::PAK::NameEntry nameEnt;
nameEnt.type = item.first.type; nameEnt.type = item.first.type.toUint32();
nameEnt.id = item.first.id.Value(); nameEnt.id = item.first.id.Value();
nameEnt.nameLen = atUint32(item.second.size()); nameEnt.nameLen = atUint32(item.second.size());
nameEnt.name = item.second; nameEnt.name = item.second;
@ -1165,7 +1165,7 @@ struct SpecMP1 : SpecBase {
for (const auto& item : list) { for (const auto& item : list) {
DNAMP1::PAK::Entry ent; DNAMP1::PAK::Entry ent;
ent.compressed = 0; ent.compressed = 0;
ent.type = item.type; ent.type = item.type.toUint32();
ent.id = item.id.Value(); ent.id = item.id.Value();
ent.size = 0; ent.size = 0;
ent.offset = 0; ent.offset = 0;
@ -1182,7 +1182,7 @@ struct SpecMP1 : SpecBase {
const metaforce::SObjectTag& tag = *it++; const metaforce::SObjectTag& tag = *it++;
DNAMP1::PAK::Entry ent; DNAMP1::PAK::Entry ent;
ent.compressed = atUint32(std::get<2>(item)); ent.compressed = atUint32(std::get<2>(item));
ent.type = tag.type; ent.type = tag.type.toUint32();
ent.id = tag.id.Value(); ent.id = tag.id.Value();
ent.size = atUint32(std::get<1>(item)); ent.size = atUint32(std::get<1>(item));
ent.offset = atUint32(std::get<0>(item)); ent.offset = atUint32(std::get<0>(item));

View File

@ -35,7 +35,7 @@ private:
zeus::CColor m_color; zeus::CColor m_color;
}; };
std::shared_ptr<aurora::TextureHandle> m_texture; std::shared_ptr<aurora::gfx::TextureHandle> m_texture;
// boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf; // boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
// boo::ObjToken<boo::IGraphicsBufferS> m_vbo; // boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
// boo::ObjToken<boo::IShaderDataBinding> m_shadBind; // boo::ObjToken<boo::IShaderDataBinding> m_shadBind;

View File

@ -8,7 +8,7 @@ amuse::AudioGroupData CAudioGroupSet::LoadData() {
const auto readU32 = [](const u8* ptr) { const auto readU32 = [](const u8* ptr) {
uint32_t value; uint32_t value;
std::memcpy(&value, ptr, sizeof(value)); std::memcpy(&value, ptr, sizeof(value));
return hecl::SBig(value); return SBig(value);
}; };
athena::io::MemoryReader r(m_buffer.get(), INT32_MAX); athena::io::MemoryReader r(m_buffer.get(), INT32_MAX);

View File

@ -810,12 +810,12 @@ std::array<CDSPStreamManager, 4> CDSPStreamManager::g_Streams{};
SDSPStreamInfo::SDSPStreamInfo(const CDSPStreamManager& stream) { SDSPStreamInfo::SDSPStreamInfo(const CDSPStreamManager& stream) {
x0_fileName = stream.x60_fileName.c_str(); x0_fileName = stream.x60_fileName.c_str();
x4_sampleRate = hecl::SBig(stream.x0_header.x8_sample_rate); x4_sampleRate = SBig(stream.x0_header.x8_sample_rate);
xc_adpcmBytes = (hecl::SBig(stream.x0_header.x4_num_nibbles) / 2) & 0x7FFFFFE0; xc_adpcmBytes = (SBig(stream.x0_header.x4_num_nibbles) / 2) & 0x7FFFFFE0;
if (stream.x0_header.xc_loop_flag) { if (stream.x0_header.xc_loop_flag) {
u32 loopStartNibble = hecl::SBig(stream.x0_header.x10_loop_start_nibble); u32 loopStartNibble = SBig(stream.x0_header.x10_loop_start_nibble);
u32 loopEndNibble = hecl::SBig(stream.x0_header.x14_loop_end_nibble); u32 loopEndNibble = SBig(stream.x0_header.x14_loop_end_nibble);
x10_loopFlag = true; x10_loopFlag = true;
x14_loopStartByte = (loopStartNibble / 2) & 0x7FFFFFE0; x14_loopStartByte = (loopStartNibble / 2) & 0x7FFFFFE0;
x18_loopEndByte = std::min((loopEndNibble / 2) & 0x7FFFFFE0, xc_adpcmBytes); x18_loopEndByte = std::min((loopEndNibble / 2) & 0x7FFFFFE0, xc_adpcmBytes);
@ -826,8 +826,8 @@ SDSPStreamInfo::SDSPStreamInfo(const CDSPStreamManager& stream) {
} }
for (int i = 0; i < 8; ++i) { for (int i = 0; i < 8; ++i) {
x1c_coef[i][0] = hecl::SBig(stream.x0_header.x1c_coef[i][0]); x1c_coef[i][0] = SBig(stream.x0_header.x1c_coef[i][0]);
x1c_coef[i][1] = hecl::SBig(stream.x0_header.x1c_coef[i][1]); x1c_coef[i][1] = SBig(stream.x0_header.x1c_coef[i][1]);
} }
} }

View File

@ -3,7 +3,8 @@
#include <map> #include <map>
#include <vector> #include <vector>
#include "Runtime/RetroTypes.hpp" #include "RetroTypes.hpp"
#include "IOStreams.hpp"
namespace metaforce { namespace metaforce {
class CWorldSaveGameInfo; class CWorldSaveGameInfo;

View File

@ -63,7 +63,7 @@ private:
CMapSurfaceShader m_surface; CMapSurfaceShader m_surface;
CLineRenderer m_outline; CLineRenderer m_outline;
explicit DoorSurface() explicit DoorSurface()
: m_surface(aurora::ArrayRef{skDoorVerts}, aurora::ArrayRef{skDoorIndices}) : m_surface(skDoorVerts, skDoorIndices)
, m_outline(CLineRenderer::EPrimitiveMode::LineLoop, 5, nullptr, false, false, true) {} , m_outline(CLineRenderer::EPrimitiveMode::LineLoop, 5, nullptr, false, false, true) {}
}; };
std::optional<DoorSurface> m_doorSurface; std::optional<DoorSurface> m_doorSurface;

View File

@ -19,9 +19,7 @@
* (used by MSVC to definitively link DataSpecs) */ * (used by MSVC to definitively link DataSpecs) */
#include "DataSpecRegistry.hpp" #include "DataSpecRegistry.hpp"
#include "Graphics/include/aurora.hpp" #include <aurora/aurora.hpp>
#include "aurora.h"
#include "aurora_shaders.h"
using namespace std::literals; using namespace std::literals;
@ -521,6 +519,14 @@ public:
} }
} }
void onImGuiInit(float scale) noexcept override {
ImGuiEngine_Initialize(scale);
}
void onImGuiAddTextures() noexcept override {
ImGuiEngine_AddTextures();
}
[[nodiscard]] std::string getGraphicsApi() const { return m_cvarCommons.getGraphicsApi(); } [[nodiscard]] std::string getGraphicsApi() const { return m_cvarCommons.getGraphicsApi(); }
[[nodiscard]] uint32_t getSamples() const { return m_cvarCommons.getSamples(); } [[nodiscard]] uint32_t getSamples() const { return m_cvarCommons.getSamples(); }
@ -577,8 +583,6 @@ static bool IsClientLoggingEnabled(int argc, char** argv) {
} }
#if !WINDOWS_STORE #if !WINDOWS_STORE
extern "C" void cxxbridge1$rust_vec$u8$set_len(rust::Vec<u8>* ptr, std::size_t len) noexcept;
int main(int argc, char** argv) { int main(int argc, char** argv) {
//TODO: This seems to fix a lot of weird issues with rounding //TODO: This seems to fix a lot of weird issues with rounding
// but breaks animations, need to research why this is the case // but breaks animations, need to research why this is the case
@ -622,17 +626,13 @@ int main(int argc, char** argv) {
hecl::SetCpuCountOverride(argc, argv); hecl::SetCpuCountOverride(argc, argv);
auto app = std::make_unique<metaforce::Application>(fileMgr, cvarMgr, cvarCmns); auto app = std::make_unique<metaforce::Application>(fileMgr, cvarMgr, cvarCmns);
auto data = aurora::Icon{};
{
auto icon = metaforce::GetIcon(); auto icon = metaforce::GetIcon();
data.data.reserve(icon.size); auto data = aurora::Icon{
std::memcpy(data.data.data(), icon.data.get(), icon.size); .data = std::move(icon.data),
// terrible hack: https://github.com/dtolnay/cxx/issues/990 .width = icon.width,
cxxbridge1$rust_vec$u8$set_len(&data.data, icon.size); .height = icon.height,
data.width = icon.width; };
data.height = icon.height; aurora::app_run(std::move(app), std::move(data));
}
aurora::app_run(std::move(app), data);
return 0; return 0;
} }
#endif #endif

View File

@ -1,6 +1,10 @@
#pragma once #pragma once
#include "Runtime/RetroTypes.hpp" #include "Runtime/RetroTypes.hpp"
#include "Runtime/Graphics/CTexture.hpp" #include "Runtime/Graphics/CTexture.hpp"
#include <map>
namespace metaforce { namespace metaforce {
class CPaletteInfo { class CPaletteInfo {
u32 m_format; u32 m_format;

View File

@ -1,6 +1,7 @@
#include "Runtime/Collision/CAreaOctTree.hpp" #include "Runtime/Collision/CAreaOctTree.hpp"
#include "Runtime/Collision/CMaterialFilter.hpp" #include "Runtime/Collision/CMaterialFilter.hpp"
#include "IOStreams.hpp"
#include <array> #include <array>
#include <cfloat> #include <cfloat>

View File

@ -16,8 +16,8 @@ public:
[[nodiscard]] constexpr u16 GetVertIndex2() const noexcept { return x2_index2; } [[nodiscard]] constexpr u16 GetVertIndex2() const noexcept { return x2_index2; }
constexpr void swapBig() noexcept { constexpr void swapBig() noexcept {
x0_index1 = hecl::SBig(x0_index1); x0_index1 = SBig(x0_index1);
x2_index2 = hecl::SBig(x2_index2); x2_index2 = SBig(x2_index2);
} }
}; };
} // namespace metaforce } // namespace metaforce

View File

@ -436,9 +436,9 @@ void CBooRenderer::RenderFogVolumeModel(const zeus::CAABox& aabb, const CModel*
for (size_t i = 0; i < planes.size(); ++i) { for (size_t i = 0; i < planes.size(); ++i) {
DrawFogSlices(planes.data(), planes.size(), i, xfAABB.center(), longestAxis, fvs); DrawFogSlices(planes.data(), planes.size(), i, xfAABB.center(), longestAxis, fvs);
} }
aurora::shaders::queue_fog_volume_plane(fvs.m_verts, 0); aurora::gfx::queue_fog_volume_plane(fvs.m_verts, 0);
} else { } else {
aurora::shaders::queue_fog_volume_plane({}, pass); aurora::gfx::queue_fog_volume_plane({}, pass);
} }
} else { } else {
CModelFlags flags; CModelFlags flags;
@ -568,9 +568,9 @@ void CBooRenderer::ReallyRenderFogVolume(const zeus::CColor& color, const zeus::
CGraphics::ResolveSpareDepth(rect, 1); CGraphics::ResolveSpareDepth(rect, 1);
aurora::shaders::queue_fog_volume_filter(color, true); aurora::gfx::queue_fog_volume_filter(color, true);
if (camInModel) if (camInModel)
aurora::shaders::queue_fog_volume_filter(color, false); aurora::gfx::queue_fog_volume_filter(color, false);
// CGraphics::SetScissor(g_Viewport.x0_left, g_Viewport.x4_top, g_Viewport.x8_width, g_Viewport.xc_height); // CGraphics::SetScissor(g_Viewport.x0_left, g_Viewport.x4_top, g_Viewport.x8_width, g_Viewport.xc_height);
} }
@ -589,7 +589,7 @@ void CBooRenderer::ReallyRenderFogVolume(const zeus::CColor& color, const zeus::
// } // }
// } // }
// x1b8_fogVolumeRamp = // x1b8_fogVolumeRamp =
// aurora::new_static_texture_2d(FOGVOL_RAMP_RES, FOGVOL_RAMP_RES, 1, aurora::shaders::TextureFormat::R32Float, // aurora::new_static_texture_2d(FOGVOL_RAMP_RES, FOGVOL_RAMP_RES, 1, aurora::gfx::TextureFormat::R32Float,
// {data[0].data(), FOGVOL_RAMP_RES * FOGVOL_RAMP_RES * 2}); // {data[0].data(), FOGVOL_RAMP_RES * FOGVOL_RAMP_RES * 2});
//} //}
// //
@ -603,7 +603,7 @@ void CBooRenderer::ReallyRenderFogVolume(const zeus::CColor& color, const zeus::
// } // }
// } // }
// x220_sphereRamp = // x220_sphereRamp =
// aurora::new_static_texture_2d(SPHERE_RAMP_RES, SPHERE_RAMP_RES, 1, aurora::shaders::TextureFormat::R8, // aurora::new_static_texture_2d(SPHERE_RAMP_RES, SPHERE_RAMP_RES, 1, aurora::gfx::TextureFormat::R8,
// {data[0].data(), SPHERE_RAMP_RES * SPHERE_RAMP_RES}); // {data[0].data(), SPHERE_RAMP_RES * SPHERE_RAMP_RES});
//} //}
// //
@ -644,7 +644,7 @@ void CBooRenderer::ReallyRenderFogVolume(const zeus::CColor& color, const zeus::
// m_scanLinesOddVBO = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), sizeof(zeus::CVector3f), verts.size()); // m_scanLinesOddVBO = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), sizeof(zeus::CVector3f), verts.size());
//} //}
std::shared_ptr<aurora::TextureHandle> CBooRenderer::GetColorTexture(const zeus::CColor& color) { std::shared_ptr<aurora::gfx::TextureHandle> CBooRenderer::GetColorTexture(const zeus::CColor& color) {
const auto search = m_colorTextures.find(color); const auto search = m_colorTextures.find(color);
if (search != m_colorTextures.end()) { if (search != m_colorTextures.end()) {
return search->second; return search->second;
@ -652,8 +652,7 @@ std::shared_ptr<aurora::TextureHandle> CBooRenderer::GetColorTexture(const zeus:
std::array<u8, 4> pixel{}; std::array<u8, 4> pixel{};
color.toRGBA8(pixel[0], pixel[1], pixel[2], pixel[3]); color.toRGBA8(pixel[0], pixel[1], pixel[2], pixel[3]);
auto tex = aurora::new_static_texture_2d(1, 1, 1, aurora::shaders::TextureFormat::RGBA8, {pixel.data(), pixel.size()}, auto tex = aurora::gfx::new_static_texture_2d(1, 1, 1, aurora::gfx::TextureFormat::RGBA8, pixel, "Color Texture"sv);
"Color Texture"sv);
m_colorTextures.emplace(color, tex); m_colorTextures.emplace(color, tex);
return tex; return tex;
} }
@ -681,20 +680,20 @@ CBooRenderer::CBooRenderer(IObjectStore& store, IFactory& resFac)
m_staticEntropy = store.GetObj("RandomStaticEntropy"); m_staticEntropy = store.GetObj("RandomStaticEntropy");
constexpr std::array<u8, 4> clearPixel{0, 0, 0, 0}; constexpr std::array<u8, 4> clearPixel{0, 0, 0, 0};
m_clearTexture = aurora::new_static_texture_2d(1, 1, 1, aurora::shaders::TextureFormat::RGBA8, m_clearTexture =
{clearPixel.data(), clearPixel.size()}, "Clear Texture"sv); aurora::gfx::new_static_texture_2d(1, 1, 1, aurora::gfx::TextureFormat::RGBA8, clearPixel, "Clear Texture"sv);
constexpr std::array<u8, 4> blackPixel{0, 0, 0, 255}; constexpr std::array<u8, 4> blackPixel{0, 0, 0, 255};
m_blackTexture = aurora::new_static_texture_2d(1, 1, 1, aurora::shaders::TextureFormat::RGBA8, m_blackTexture =
{blackPixel.data(), blackPixel.size()}, "Black Texture"sv); aurora::gfx::new_static_texture_2d(1, 1, 1, aurora::gfx::TextureFormat::RGBA8, blackPixel, "Black Texture"sv);
constexpr std::array<u8, 4> whitePixel{255, 255, 255, 255}; constexpr std::array<u8, 4> whitePixel{255, 255, 255, 255};
m_whiteTexture = aurora::new_static_texture_2d(1, 1, 1, aurora::shaders::TextureFormat::RGBA8, m_whiteTexture =
{whitePixel.data(), whitePixel.size()}, "White Texture"sv); aurora::gfx::new_static_texture_2d(1, 1, 1, aurora::gfx::TextureFormat::RGBA8, whitePixel, "White Texture"sv);
// GenerateFogVolumeRampTex(); // GenerateFogVolumeRampTex();
// GenerateSphereRampTex(); // GenerateSphereRampTex();
m_ballShadowId = aurora::new_render_texture(m_ballShadowIdW, m_ballShadowIdH, 1, 0, "Ball Shadow"); m_ballShadowId = aurora::gfx::new_render_texture(m_ballShadowIdW, m_ballShadowIdH, 1, 0, "Ball Shadow");
// m_ballShadowId = ctx.newRenderTexture(m_ballShadowIdW, m_ballShadowIdH, boo::TextureClampMode::Repeat, 1, 0); // m_ballShadowId = ctx.newRenderTexture(m_ballShadowIdW, m_ballShadowIdH, boo::TextureClampMode::Repeat, 1, 0);
x14c_reflectionTex = aurora::new_render_texture(256, 256, 1, 0, "Reflection"); x14c_reflectionTex = aurora::gfx::new_render_texture(256, 256, 1, 0, "Reflection");
// x14c_reflectionTex = ctx.newRenderTexture(256, 256, boo::TextureClampMode::ClampToBlack, 1, 0); // x14c_reflectionTex = ctx.newRenderTexture(256, 256, boo::TextureClampMode::ClampToBlack, 1, 0);
// GenerateScanLinesVBO(); // GenerateScanLinesVBO();
// LoadThermoPalette(); // LoadThermoPalette();

View File

@ -101,20 +101,20 @@ class CBooRenderer final : public IRenderer {
// boo::ITextureS* xe4_blackTex = nullptr; // boo::ITextureS* xe4_blackTex = nullptr;
bool xee_24_ : 1 = true; bool xee_24_ : 1 = true;
std::shared_ptr<aurora::TextureHandle> m_clearTexture; std::shared_ptr<aurora::gfx::TextureHandle> m_clearTexture;
std::shared_ptr<aurora::TextureHandle> m_blackTexture; std::shared_ptr<aurora::gfx::TextureHandle> m_blackTexture;
std::shared_ptr<aurora::TextureHandle> m_whiteTexture; std::shared_ptr<aurora::gfx::TextureHandle> m_whiteTexture;
std::unordered_map<zeus::CColor, std::shared_ptr<aurora::TextureHandle>> m_colorTextures; std::unordered_map<zeus::CColor, std::shared_ptr<aurora::gfx::TextureHandle>> m_colorTextures;
std::shared_ptr<aurora::TextureHandle> x14c_reflectionTex; std::shared_ptr<aurora::gfx::TextureHandle> x14c_reflectionTex;
// boo::ITextureS* x150_mirrorRamp = nullptr; // boo::ITextureS* x150_mirrorRamp = nullptr;
// std::shared_ptr<aurora::TextureHandle> x1b8_fogVolumeRamp; // std::shared_ptr<aurora::gfx::TextureHandle> x1b8_fogVolumeRamp;
std::shared_ptr<aurora::TextureHandle> x220_sphereRamp; std::shared_ptr<aurora::gfx::TextureHandle> x220_sphereRamp;
// TLockedToken<CTexture> m_thermoPaletteTex; // TLockedToken<CTexture> m_thermoPaletteTex;
// std::shared_ptr<aurora::TextureHandle> x288_thermoPalette; // std::shared_ptr<aurora::gfx::TextureHandle> x288_thermoPalette;
// TLockedToken<CTexture> m_ballFadeTex; // TLockedToken<CTexture> m_ballFadeTex;
std::shared_ptr<aurora::TextureHandle> m_ballFade; std::shared_ptr<aurora::gfx::TextureHandle> m_ballFade;
std::shared_ptr<aurora::TextureHandle> m_ballShadowId; std::shared_ptr<aurora::gfx::TextureHandle> m_ballShadowId;
// boo::ObjToken<boo::IGraphicsBufferS> m_scanLinesEvenVBO; // boo::ObjToken<boo::IGraphicsBufferS> m_scanLinesEvenVBO;
// boo::ObjToken<boo::IGraphicsBufferS> m_scanLinesOddVBO; // boo::ObjToken<boo::IGraphicsBufferS> m_scanLinesOddVBO;
int m_ballShadowIdW = 64; int m_ballShadowIdW = 64;
@ -269,11 +269,11 @@ public:
// const boo::ObjToken<boo::IGraphicsBufferS>& GetScanLinesEvenVBO() const { return m_scanLinesEvenVBO; } // const boo::ObjToken<boo::IGraphicsBufferS>& GetScanLinesEvenVBO() const { return m_scanLinesEvenVBO; }
// const boo::ObjToken<boo::IGraphicsBufferS>& GetScanLinesOddVBO() const { return m_scanLinesOddVBO; } // const boo::ObjToken<boo::IGraphicsBufferS>& GetScanLinesOddVBO() const { return m_scanLinesOddVBO; }
const std::shared_ptr<aurora::TextureHandle>& GetClearTexture() const { return m_clearTexture; } const std::shared_ptr<aurora::gfx::TextureHandle>& GetClearTexture() const { return m_clearTexture; }
const std::shared_ptr<aurora::TextureHandle>& GetBlackTexture() const { return m_blackTexture; } const std::shared_ptr<aurora::gfx::TextureHandle>& GetBlackTexture() const { return m_blackTexture; }
const std::shared_ptr<aurora::TextureHandle>& GetWhiteTexture() const { return m_whiteTexture; } const std::shared_ptr<aurora::gfx::TextureHandle>& GetWhiteTexture() const { return m_whiteTexture; }
std::shared_ptr<aurora::TextureHandle> GetColorTexture(const zeus::CColor& color); std::shared_ptr<aurora::gfx::TextureHandle> GetColorTexture(const zeus::CColor& color);
static void BindMainDrawTarget() { static void BindMainDrawTarget() {
// CGraphics::g_BooMainCommandQueue->setRenderTarget(CGraphics::g_SpareTexture); // CGraphics::g_BooMainCommandQueue->setRenderTarget(CGraphics::g_SpareTexture);

View File

@ -17,7 +17,7 @@ static u8* MemoryFromPartData(u8*& dataCur, const u32*& secSizeCur) {
if (*secSizeCur != 0) { if (*secSizeCur != 0) {
ret = dataCur; ret = dataCur;
} }
dataCur += hecl::SBig(*secSizeCur); dataCur += SBig(*secSizeCur);
++secSizeCur; ++secSizeCur;
return ret; return ret;
} }
@ -28,17 +28,17 @@ CModel::CModel(std::unique_ptr<u8[]> in, u32 dataLen, IObjectStore* store)
, x34_next(sThisFrameList) , x34_next(sThisFrameList)
, x38_lastFrame(CGraphics::GetFrameCounter() - 2) { , x38_lastFrame(CGraphics::GetFrameCounter() - 2) {
u8* data = x0_data.get(); u8* data = x0_data.get();
u32 flags = hecl::SBig(*reinterpret_cast<u32*>(data + 8)); u32 flags = SBig(*reinterpret_cast<u32*>(data + 8));
u32 sectionSizeStart = 0x2c; u32 sectionSizeStart = 0x2c;
if (hecl::SBig(*reinterpret_cast<u32*>(data + 4)) == 1) { if (SBig(*reinterpret_cast<u32*>(data + 4)) == 1) {
sectionSizeStart = 0x28; sectionSizeStart = 0x28;
} }
const u32* secSizeCur = reinterpret_cast<u32*>(data + sectionSizeStart); const u32* secSizeCur = reinterpret_cast<u32*>(data + sectionSizeStart);
s32 numMatSets = 1; s32 numMatSets = 1;
if (hecl::SBig(*reinterpret_cast<u32*>(data + 4)) > 1) { if (SBig(*reinterpret_cast<u32*>(data + 4)) > 1) {
numMatSets = hecl::SBig(*reinterpret_cast<s32*>(data + 0x28)); numMatSets = SBig(*reinterpret_cast<s32*>(data + 0x28));
} }
u8* dataCur = data + ROUND_UP_32(sectionSizeStart + hecl::SBig(*reinterpret_cast<s32*>(data + 0x24)) * 4); u8* dataCur = data + ROUND_UP_32(sectionSizeStart + SBig(*reinterpret_cast<s32*>(data + 0x24)) * 4);
x18_matSets.reserve(numMatSets); x18_matSets.reserve(numMatSets);
for (s32 i = 0; i < numMatSets; ++i) { for (s32 i = 0; i < numMatSets; ++i) {
x18_matSets.emplace_back(static_cast<u8*>(MemoryFromPartData(dataCur, secSizeCur))); x18_matSets.emplace_back(static_cast<u8*>(MemoryFromPartData(dataCur, secSizeCur)));
@ -48,54 +48,54 @@ CModel::CModel(std::unique_ptr<u8[]> in, u32 dataLen, IObjectStore* store)
} }
/* Metaforce note: Due to padding in zeus types we need to convert these and store locally */ /* Metaforce note: Due to padding in zeus types we need to convert these and store locally */
u32 numVertices = hecl::SBig(*secSizeCur) / (sizeof(float) * 3); u32 numVertices = SBig(*secSizeCur) / (sizeof(float) * 3);
const u8* positions = MemoryFromPartData(dataCur, secSizeCur); const u8* positions = MemoryFromPartData(dataCur, secSizeCur);
for (u32 i = 0; i < numVertices; ++i) { for (u32 i = 0; i < numVertices; ++i) {
const auto* pos = reinterpret_cast<const float*>(positions + (i * (sizeof(float) * 3))); const auto* pos = reinterpret_cast<const float*>(positions + (i * (sizeof(float) * 3)));
m_positions.emplace_back(hecl::SBig(pos[0]), hecl::SBig(pos[1]), hecl::SBig(pos[2])); m_positions.emplace_back(SBig(pos[0]), SBig(pos[1]), SBig(pos[2]));
} }
u32 numNormals = hecl::SBig(*secSizeCur); u32 numNormals = SBig(*secSizeCur);
numNormals /= ((flags & 2) == 0 ? sizeof(float) : sizeof(s16)) * 3; numNormals /= ((flags & 2) == 0 ? sizeof(float) : sizeof(s16)) * 3;
const u8* normals = MemoryFromPartData(dataCur, secSizeCur); const u8* normals = MemoryFromPartData(dataCur, secSizeCur);
for (u32 i = 0; i < numNormals; ++i) { for (u32 i = 0; i < numNormals; ++i) {
if ((flags & 2) == 0) { if ((flags & 2) == 0) {
const auto* norm = reinterpret_cast<const float*>(normals + (i * (sizeof(float) * 3))); const auto* norm = reinterpret_cast<const float*>(normals + (i * (sizeof(float) * 3)));
m_normals.emplace_back(hecl::SBig(norm[0]), hecl::SBig(norm[1]), hecl::SBig(norm[2])); m_normals.emplace_back(SBig(norm[0]), SBig(norm[1]), SBig(norm[2]));
} else { } else {
const auto* norm = reinterpret_cast<const s16*>(normals + (i * (sizeof(s16) * 3))); const auto* norm = reinterpret_cast<const s16*>(normals + (i * (sizeof(s16) * 3)));
m_normals.emplace_back(hecl::SBig(norm[0]) / 32767.f, hecl::SBig(norm[1]) / 32767.f, m_normals.emplace_back(SBig(norm[0]) / 32767.f, SBig(norm[1]) / 32767.f,
hecl::SBig(norm[2]) / 32767.f); SBig(norm[2]) / 32767.f);
} }
} }
u32 numColors = hecl::SBig(*secSizeCur) / (sizeof(int)); u32 numColors = SBig(*secSizeCur) / (sizeof(int));
const u8* vtxColors = MemoryFromPartData(dataCur, secSizeCur); const u8* vtxColors = MemoryFromPartData(dataCur, secSizeCur);
for (u32 i = 0; i < numColors; ++i) { for (u32 i = 0; i < numColors; ++i) {
const u32 col = hecl::SBig(*reinterpret_cast<const u32*>(vtxColors + (i * (sizeof(u32))))); const u32 col = SBig(*reinterpret_cast<const u32*>(vtxColors + (i * (sizeof(u32)))));
m_colors.emplace_back(zeus::CColor(zeus::Comp32(col))); m_colors.emplace_back(zeus::CColor(zeus::Comp32(col)));
} }
u32 numFloatUVs = hecl::SBig(*reinterpret_cast<const u32*>(secSizeCur)) / (sizeof(float) * 2); u32 numFloatUVs = SBig(*reinterpret_cast<const u32*>(secSizeCur)) / (sizeof(float) * 2);
const u8* floatUVs = MemoryFromPartData(dataCur, secSizeCur); const u8* floatUVs = MemoryFromPartData(dataCur, secSizeCur);
for (u32 i = 0; i < numFloatUVs; ++i) { for (u32 i = 0; i < numFloatUVs; ++i) {
const auto* norm = reinterpret_cast<const float*>(floatUVs + (i * (sizeof(float) * 2))); const auto* norm = reinterpret_cast<const float*>(floatUVs + (i * (sizeof(float) * 2)));
m_floatUVs.emplace_back(hecl::SBig(norm[0]), hecl::SBig(norm[1])); m_floatUVs.emplace_back(SBig(norm[0]), SBig(norm[1]));
} }
if ((flags & 4) != 0) { if ((flags & 4) != 0) {
u32 numShortUVs = hecl::SBig(*reinterpret_cast<const u32*>(secSizeCur)) / (sizeof(s16) * 2); u32 numShortUVs = SBig(*reinterpret_cast<const u32*>(secSizeCur)) / (sizeof(s16) * 2);
const u8* shortUVs = MemoryFromPartData(dataCur, secSizeCur); const u8* shortUVs = MemoryFromPartData(dataCur, secSizeCur);
for (u32 i = 0; i < numShortUVs; ++i) { for (u32 i = 0; i < numShortUVs; ++i) {
const auto* norm = reinterpret_cast<const s16*>(shortUVs + (i * (sizeof(s16) * 2))); const auto* norm = reinterpret_cast<const s16*>(shortUVs + (i * (sizeof(s16) * 2)));
m_shortUVs.emplace_back(std::array{hecl::SBig(norm[0]), hecl::SBig(norm[1])}); m_shortUVs.emplace_back(std::array{SBig(norm[0]), SBig(norm[1])});
} }
} }
const u8* surfaceInfo = MemoryFromPartData(dataCur, secSizeCur); const u8* surfaceInfo = MemoryFromPartData(dataCur, secSizeCur);
u32 surfaceCount = hecl::SBig(*reinterpret_cast<const u32*>(surfaceInfo)); u32 surfaceCount = SBig(*reinterpret_cast<const u32*>(surfaceInfo));
x8_surfaces.reserve(surfaceCount); x8_surfaces.reserve(surfaceCount);
for (u32 i = 0; i < surfaceCount; ++i) { for (u32 i = 0; i < surfaceCount; ++i) {
@ -108,8 +108,8 @@ CModel::CModel(std::unique_ptr<u8[]> in, u32 dataLen, IObjectStore* store)
const float* bounds = reinterpret_cast<float*>(data + 12); const float* bounds = reinterpret_cast<float*>(data + 12);
zeus::CAABox aabox = zeus::skNullBox; zeus::CAABox aabox = zeus::skNullBox;
aabox.min = {hecl::SBig(bounds[0]), hecl::SBig(bounds[1]), hecl::SBig(bounds[2])}; aabox.min = {SBig(bounds[0]), SBig(bounds[1]), SBig(bounds[2])};
aabox.max = {hecl::SBig(bounds[3]), hecl::SBig(bounds[4]), hecl::SBig(bounds[5])}; aabox.max = {SBig(bounds[3]), SBig(bounds[4]), SBig(bounds[5])};
/* This constructor has been changed from the original to take into account platform differences */ /* This constructor has been changed from the original to take into account platform differences */
x28_modelInst = x28_modelInst =
@ -222,10 +222,10 @@ CCubeMaterial CCubeModel::GetMaterialByIndex(u32 idx) {
const u8* matData = x0_modelInstance.GetMaterialPointer(); const u8* matData = x0_modelInstance.GetMaterialPointer();
matData += (x1c_textures->size() + 1) * 4; matData += (x1c_textures->size() + 1) * 4;
if (idx != 0) { if (idx != 0) {
materialOffset = hecl::SBig(*reinterpret_cast<const u32*>(matData + (idx * 4))); materialOffset = SBig(*reinterpret_cast<const u32*>(matData + (idx * 4)));
} }
u32 materialCount = hecl::SBig(*reinterpret_cast<const u32*>(matData)); u32 materialCount = SBig(*reinterpret_cast<const u32*>(matData));
return CCubeMaterial(matData + materialOffset + (materialCount * 4) + 4); return CCubeMaterial(matData + materialOffset + (materialCount * 4) + 4);
} }
@ -238,10 +238,10 @@ void CCubeModel::UnlockTextures() {
void CCubeModel::MakeTexturesFromMats(const u8* ptr, std::vector<TCachedToken<CTexture>>& textures, IObjectStore* store, void CCubeModel::MakeTexturesFromMats(const u8* ptr, std::vector<TCachedToken<CTexture>>& textures, IObjectStore* store,
bool b1) { bool b1) {
const u32* curId = reinterpret_cast<const u32*>(ptr + 4); const u32* curId = reinterpret_cast<const u32*>(ptr + 4);
u32 textureCount = hecl::SBig(*reinterpret_cast<const u32*>(ptr)); u32 textureCount = SBig(*reinterpret_cast<const u32*>(ptr));
textures.reserve(textureCount); textures.reserve(textureCount);
for (u32 i = 0; i < textureCount; ++i) { for (u32 i = 0; i < textureCount; ++i) {
textures.emplace_back(store->GetObj({FOURCC('TXTR'), hecl::SBig(curId[i])})); textures.emplace_back(store->GetObj({FOURCC('TXTR'), SBig(curId[i])}));
if (!b1 && textures.back().IsNull()) { if (!b1 && textures.back().IsNull()) {
textures.back().GetObj(); textures.back().GetObj();

View File

@ -186,16 +186,16 @@ public:
[[nodiscard]] u32 GetCompressedBlend() { [[nodiscard]] u32 GetCompressedBlend() {
const u32* ptr = reinterpret_cast<const u32*>(x0_data[(GetTextureCount() * 4) + 16]); const u32* ptr = reinterpret_cast<const u32*>(x0_data[(GetTextureCount() * 4) + 16]);
if (IsFlagSet(EStateFlags::KonstEnabled)) { if (IsFlagSet(EStateFlags::KonstEnabled)) {
ptr += hecl::SBig(*ptr) + 1; ptr += SBig(*ptr) + 1;
} }
return hecl::SBig(*ptr); return SBig(*ptr);
} }
[[nodiscard]] EStateFlags GetFlags() const { return EStateFlags(hecl::SBig(*reinterpret_cast<const u32*>(x0_data))); } [[nodiscard]] EStateFlags GetFlags() const { return EStateFlags(SBig(*reinterpret_cast<const u32*>(x0_data))); }
[[nodiscard]] bool IsFlagSet(EStateFlags flag) const { return True(GetFlags() & flag); } [[nodiscard]] bool IsFlagSet(EStateFlags flag) const { return True(GetFlags() & flag); }
[[nodiscard]] u32 GetUsedTextureSlots() const { return static_cast<u32>(GetFlags()) >> 16; } [[nodiscard]] u32 GetUsedTextureSlots() const { return static_cast<u32>(GetFlags()) >> 16; }
[[nodiscard]] u32 GetTextureCount() const { return hecl::SBig(*reinterpret_cast<const u32*>(&x0_data[4])); } [[nodiscard]] u32 GetTextureCount() const { return SBig(*reinterpret_cast<const u32*>(&x0_data[4])); }
[[nodiscard]] u32 GetVertexDesc() const { return hecl::SBig(*reinterpret_cast<const u32*>(&x0_data[(GetTextureCount() * 4) + 8])); } [[nodiscard]] u32 GetVertexDesc() const { return SBig(*reinterpret_cast<const u32*>(&x0_data[(GetTextureCount() * 4) + 8])); }
}; };
#pragma endregion #pragma endregion

View File

@ -11,7 +11,7 @@
namespace metaforce { namespace metaforce {
CGraphics::CProjectionState CGraphics::g_Proj; CGraphics::CProjectionState CGraphics::g_Proj;
CGraphics::CFogState CGraphics::g_Fog; CFogState CGraphics::g_Fog;
std::array<zeus::CColor, 3> CGraphics::g_ColorRegs{}; std::array<zeus::CColor, 3> CGraphics::g_ColorRegs{};
float CGraphics::g_ProjAspect = 1.f; float CGraphics::g_ProjAspect = 1.f;
u32 CGraphics::g_NumLightsActive = 0; u32 CGraphics::g_NumLightsActive = 0;
@ -156,7 +156,7 @@ void CGraphics::SetViewMatrix() {
g_GXModelViewInvXpose.origin.zeroOut(); g_GXModelViewInvXpose.origin.zeroOut();
g_GXModelViewInvXpose.basis.transpose(); g_GXModelViewInvXpose.basis.transpose();
/* Load normal matrix */ /* Load normal matrix */
aurora::shaders::update_model_view(g_GXModelView.toMatrix4f(), g_GXModelViewInvXpose.toMatrix4f()); aurora::gfx::update_model_view(g_GXModelView.toMatrix4f(), g_GXModelViewInvXpose.toMatrix4f());
} }
void CGraphics::SetModelMatrix(const zeus::CTransform& xf) { void CGraphics::SetModelMatrix(const zeus::CTransform& xf) {
@ -323,7 +323,7 @@ void CGraphics::FlushProjection() {
} else { } else {
// Convert and load ortho // Convert and load ortho
} }
aurora::shaders::update_projection(GetPerspectiveProjectionMatrix(true)); aurora::gfx::update_projection(GetPerspectiveProjectionMatrix(true));
} }
zeus::CVector2i CGraphics::ProjectPoint(const zeus::CVector3f& point) { zeus::CVector2i CGraphics::ProjectPoint(const zeus::CVector3f& point) {
@ -423,17 +423,17 @@ void CGraphics::SetViewport(int leftOff, int bottomOff, int width, int height) {
CachedVP.position[1] = bottomOff; CachedVP.position[1] = bottomOff;
CachedVP.size[0] = width; CachedVP.size[0] = width;
CachedVP.size[1] = height; CachedVP.size[1] = height;
aurora::shaders::set_viewport(CachedVP, g_CachedDepthRange[0], g_CachedDepthRange[1]); aurora::gfx::set_viewport(CachedVP, g_CachedDepthRange[0], g_CachedDepthRange[1]);
} }
void CGraphics::SetScissor(int leftOff, int bottomOff, int width, int height) { void CGraphics::SetScissor(int leftOff, int bottomOff, int width, int height) {
aurora::shaders::set_scissor(leftOff, bottomOff, width, height); aurora::gfx::set_scissor(leftOff, bottomOff, width, height);
} }
void CGraphics::SetDepthRange(float znear, float zfar) { void CGraphics::SetDepthRange(float znear, float zfar) {
g_CachedDepthRange[0] = znear; g_CachedDepthRange[0] = znear;
g_CachedDepthRange[1] = zfar; g_CachedDepthRange[1] = zfar;
aurora::shaders::set_viewport(CachedVP, g_CachedDepthRange[0], g_CachedDepthRange[1]); aurora::gfx::set_viewport(CachedVP, g_CachedDepthRange[0], g_CachedDepthRange[1]);
} }
CTimeProvider* CGraphics::g_ExternalTimeProvider = nullptr; CTimeProvider* CGraphics::g_ExternalTimeProvider = nullptr;

View File

@ -20,77 +20,10 @@
#include <zeus/CVector2i.hpp> #include <zeus/CVector2i.hpp>
#include <zeus/CVector2f.hpp> #include <zeus/CVector2f.hpp>
#include "aurora.h" #include <aurora/gfx.hpp>
#include "aurora_shaders.h"
using frame_clock = std::chrono::high_resolution_clock; using frame_clock = std::chrono::high_resolution_clock;
namespace aurora {
using TextureRef = aurora::shaders::TextureRef;
template <typename T>
struct RustDrop {};
template <>
struct RustDrop<TextureRef> {
TextureRef ref;
explicit RustDrop(TextureRef ref) : ref(ref) {}
~RustDrop() { aurora::shaders::drop_texture(ref); }
RustDrop(const RustDrop&) = delete;
RustDrop& operator=(const RustDrop&) = delete;
};
using TextureHandle = RustDrop<TextureRef>;
inline std::shared_ptr<TextureHandle> new_static_texture_2d(uint32_t width, uint32_t height, uint32_t mips,
aurora::shaders::TextureFormat format,
rust::Slice<const uint8_t> data,
std::string_view label) {
rust::Str rlabel{label.data(), label.size()};
auto ref = aurora::shaders::create_static_texture_2d(width, height, mips, format, data, rlabel);
return std::make_shared<TextureHandle>(ref);
}
inline std::shared_ptr<TextureHandle> new_dynamic_texture_2d(uint32_t width, uint32_t height, uint32_t mips,
aurora::shaders::TextureFormat format,
std::string_view label) {
rust::Str rlabel{label.data(), label.size()};
auto ref = aurora::shaders::create_dynamic_texture_2d(width, height, mips, format, rlabel);
return std::make_shared<TextureHandle>(ref);
}
inline std::shared_ptr<TextureHandle> new_render_texture(uint32_t width, uint32_t height,
uint32_t color_bind_count, uint32_t depth_bind_count,
std::string_view label) {
rust::Str rlabel{label.data(), label.size()};
auto ref = aurora::shaders::create_render_texture(width, height, color_bind_count, depth_bind_count, rlabel);
return std::make_shared<TextureHandle>(ref);
}
template <typename T>
class ArrayRef {
public:
using value_type = std::remove_cvref_t<T>;
using pointer = value_type*;
using const_pointer = const value_type*;
using reference = value_type&;
using const_reference = const value_type&;
using iterator = const_pointer;
using const_iterator = const_pointer;
using size_type = std::size_t;
using difference_type = std::ptrdiff_t;
ArrayRef() = default;
explicit ArrayRef(T& one) : data(&one), length(1) {}
ArrayRef(T* data, size_t length) : data(data), length(length) {}
ArrayRef(T* begin, T* end) : data(begin), length(end - begin) {}
template <size_t N>
constexpr explicit ArrayRef(T (&arr)[N]) : data(arr), length(N) {}
template <size_t N>
constexpr explicit ArrayRef(std::array<T, N> arr) : data(arr.data()), length(arr.size()) {}
explicit ArrayRef(std::vector<T> vec) : data(vec.data()), length(vec.size()) {}
private:
T* data = nullptr;
size_t length = 0;
};
} // namespace aurora
namespace metaforce { namespace metaforce {
extern hecl::CVar* g_disableLighting; extern hecl::CVar* g_disableLighting;
class CLight; class CLight;
@ -160,8 +93,6 @@ enum class ERglAlphaFunc {
enum class ERglAlphaOp { And = 0, Or = 1, Xor = 2, XNor = 3 }; enum class ERglAlphaOp { And = 0, Or = 1, Xor = 2, XNor = 3 };
using ERglFogMode = aurora::shaders::FogMode;
struct SViewport { struct SViewport {
u32 x0_left; u32 x0_left;
u32 x4_top; u32 x4_top;
@ -200,7 +131,7 @@ struct SClipScreenRect {
, x20_uvYMin(uvYMin) , x20_uvYMin(uvYMin)
, x24_uvYMax(uvYMax) {} , x24_uvYMax(uvYMax) {}
SClipScreenRect(const aurora::shaders::ClipRect& rect) { SClipScreenRect(const aurora::gfx::ClipRect& rect) {
x4_left = rect.x; x4_left = rect.x;
x8_top = rect.y; x8_top = rect.y;
xc_width = rect.width; xc_width = rect.width;
@ -298,15 +229,6 @@ public:
float x18_far; float x18_far;
}; };
using CFogState = aurora::shaders::FogState;
// struct CFogState {
// zeus::CColor m_color;
// float m_A = 0.f;
// float m_B = 0.5f;
// float m_C = 0.f;
// ERglFogMode m_mode;
// };
static CProjectionState g_Proj; static CProjectionState g_Proj;
static zeus::CVector2f g_CachedDepthRange; static zeus::CVector2f g_CachedDepthRange;
static CFogState g_Fog; static CFogState g_Fog;
@ -435,12 +357,12 @@ public:
// g_BooMainCommandQueue->setShaderDataBinding(binding); // g_BooMainCommandQueue->setShaderDataBinding(binding);
// } // }
static void ResolveSpareTexture(const SClipScreenRect& rect, int bindIdx = 0, bool clearDepth = false) { static void ResolveSpareTexture(const SClipScreenRect& rect, int bindIdx = 0, bool clearDepth = false) {
aurora::shaders::resolve_color({rect.x4_left, rect.x8_top, rect.xc_width, rect.x10_height}, bindIdx, clearDepth); aurora::gfx::resolve_color({rect.x4_left, rect.x8_top, rect.xc_width, rect.x10_height}, bindIdx, clearDepth);
// boo::SWindowRect wrect = {rect.x4_left, rect.x8_top, rect.xc_width, rect.x10_height}; // boo::SWindowRect wrect = {rect.x4_left, rect.x8_top, rect.xc_width, rect.x10_height};
// g_BooMainCommandQueue->resolveBindTexture(g_SpareTexture, wrect, true, bindIdx, true, false, clearDepth); // g_BooMainCommandQueue->resolveBindTexture(g_SpareTexture, wrect, true, bindIdx, true, false, clearDepth);
} }
static void ResolveSpareDepth(const SClipScreenRect& rect, int bindIdx = 0) { static void ResolveSpareDepth(const SClipScreenRect& rect, int bindIdx = 0) {
aurora::shaders::resolve_depth({rect.x4_left, rect.x8_top, rect.xc_width, rect.x10_height}, bindIdx); aurora::gfx::resolve_depth({rect.x4_left, rect.x8_top, rect.xc_width, rect.x10_height}, bindIdx);
// boo::SWindowRect wrect = {rect.x4_left, rect.x8_top, rect.xc_width, rect.x10_height}; // boo::SWindowRect wrect = {rect.x4_left, rect.x8_top, rect.xc_width, rect.x10_height};
// g_BooMainCommandQueue->resolveBindTexture(g_SpareTexture, wrect, true, bindIdx, false, true); // g_BooMainCommandQueue->resolveBindTexture(g_SpareTexture, wrect, true, bindIdx, false, true);
} }

View File

@ -20,7 +20,7 @@ void CLineRenderer::Shutdown() {
//hecl::VertexBufferPool<CLineRenderer::SDrawVertNoTex> CLineRenderer::s_vertPoolNoTex = {}; //hecl::VertexBufferPool<CLineRenderer::SDrawVertNoTex> CLineRenderer::s_vertPoolNoTex = {};
//hecl::UniformBufferPool<CLineRenderer::SDrawUniform> CLineRenderer::s_uniformPool = {}; //hecl::UniformBufferPool<CLineRenderer::SDrawUniform> CLineRenderer::s_uniformPool = {};
CLineRenderer::CLineRenderer(EPrimitiveMode mode, u32 maxVerts, const std::shared_ptr<aurora::TextureHandle>& texture, CLineRenderer::CLineRenderer(EPrimitiveMode mode, u32 maxVerts, const std::shared_ptr<aurora::gfx::TextureHandle>& texture,
bool additive, bool zTest, bool zGEqual) bool additive, bool zTest, bool zGEqual)
: m_mode(mode), m_maxVerts(maxVerts) { : m_mode(mode), m_maxVerts(maxVerts) {
OPTICK_EVENT(); OPTICK_EVENT();

View File

@ -35,7 +35,7 @@ public:
struct SDrawUniform { struct SDrawUniform {
zeus::CColor moduColor; zeus::CColor moduColor;
CGraphics::CFogState fog; CFogState fog;
}; };
private: private:
@ -72,7 +72,7 @@ public:
// hecl::UniformBufferPool<SDrawUniform>::Token m_uniformBuf; // hecl::UniformBufferPool<SDrawUniform>::Token m_uniformBuf;
// std::array<boo::ObjToken<boo::IShaderDataBinding>, 2> m_shaderBind; // std::array<boo::ObjToken<boo::IShaderDataBinding>, 2> m_shaderBind;
CLineRenderer(EPrimitiveMode mode, u32 maxVerts, const std::shared_ptr<aurora::TextureHandle>& texture, bool additive, CLineRenderer(EPrimitiveMode mode, u32 maxVerts, const std::shared_ptr<aurora::gfx::TextureHandle>& texture, bool additive,
bool zTest = false, bool zGEqual = false); bool zTest = false, bool zGEqual = false);
CLineRenderer(CLineRenderer&&) = default; CLineRenderer(CLineRenderer&&) = default;

View File

@ -239,16 +239,16 @@ public:
static void EnsureViewDepStateCached(const CBooModel& model, const CBooSurface* surf, zeus::CMatrix4f* mtxsOut, static void EnsureViewDepStateCached(const CBooModel& model, const CBooSurface* surf, zeus::CMatrix4f* mtxsOut,
float& alphaOut); float& alphaOut);
static inline std::shared_ptr<aurora::TextureHandle> g_shadowMap; static inline std::shared_ptr<aurora::gfx::TextureHandle> g_shadowMap;
static inline zeus::CTransform g_shadowTexXf; static inline zeus::CTransform g_shadowTexXf;
static void EnableShadowMaps(const std::shared_ptr<aurora::TextureHandle>& map, const zeus::CTransform& texXf); static void EnableShadowMaps(const std::shared_ptr<aurora::gfx::TextureHandle>& map, const zeus::CTransform& texXf);
static void DisableShadowMaps(); static void DisableShadowMaps();
static inline std::shared_ptr<aurora::TextureHandle> g_disintegrateTexture; static inline std::shared_ptr<aurora::gfx::TextureHandle> g_disintegrateTexture;
static void SetDisintegrateTexture(const std::shared_ptr<aurora::TextureHandle>& map) { g_disintegrateTexture = map; } static void SetDisintegrateTexture(const std::shared_ptr<aurora::gfx::TextureHandle>& map) { g_disintegrateTexture = map; }
static inline std::shared_ptr<aurora::TextureHandle> g_reflectionCube; static inline std::shared_ptr<aurora::gfx::TextureHandle> g_reflectionCube;
static void SetReflectionCube(const std::shared_ptr<aurora::TextureHandle>& map) { g_reflectionCube = map; } static void SetReflectionCube(const std::shared_ptr<aurora::gfx::TextureHandle>& map) { g_reflectionCube = map; }
static void SetDummyTextures(bool b) { g_DummyTextures = b; } static void SetDummyTextures(bool b) { g_DummyTextures = b; }
static void SetRenderModelBlack(bool b) { g_RenderModelBlack = b; } static void SetRenderModelBlack(bool b) { g_RenderModelBlack = b; }

View File

@ -135,7 +135,7 @@ void CBooModel::EnsureViewDepStateCached(const CBooModel& model, const CBooSurfa
} }
} }
void CBooModel::EnableShadowMaps(const std::shared_ptr<aurora::TextureHandle>& map, const zeus::CTransform& texXf) { void CBooModel::EnableShadowMaps(const std::shared_ptr<aurora::gfx::TextureHandle>& map, const zeus::CTransform& texXf) {
g_shadowMap = map; g_shadowMap = map;
g_shadowTexXf = texXf; g_shadowTexXf = texXf;
} }

View File

@ -44,50 +44,50 @@ void CMoviePlayer::Initialize() { TjHandle = tjInitDecompress(); }
void CMoviePlayer::Shutdown() { tjDestroy(TjHandle); } void CMoviePlayer::Shutdown() { tjDestroy(TjHandle); }
void CMoviePlayer::THPHeader::swapBig() { void CMoviePlayer::THPHeader::swapBig() {
magic = hecl::SBig(magic); magic = SBig(magic);
version = hecl::SBig(version); version = SBig(version);
maxBufferSize = hecl::SBig(maxBufferSize); maxBufferSize = SBig(maxBufferSize);
maxAudioSamples = hecl::SBig(maxAudioSamples); maxAudioSamples = SBig(maxAudioSamples);
fps = hecl::SBig(fps); fps = SBig(fps);
numFrames = hecl::SBig(numFrames); numFrames = SBig(numFrames);
firstFrameSize = hecl::SBig(firstFrameSize); firstFrameSize = SBig(firstFrameSize);
dataSize = hecl::SBig(dataSize); dataSize = SBig(dataSize);
componentDataOffset = hecl::SBig(componentDataOffset); componentDataOffset = SBig(componentDataOffset);
offsetsDataOffset = hecl::SBig(offsetsDataOffset); offsetsDataOffset = SBig(offsetsDataOffset);
firstFrameOffset = hecl::SBig(firstFrameOffset); firstFrameOffset = SBig(firstFrameOffset);
lastFrameOffset = hecl::SBig(lastFrameOffset); lastFrameOffset = SBig(lastFrameOffset);
} }
void CMoviePlayer::THPComponents::swapBig() { numComponents = hecl::SBig(numComponents); } void CMoviePlayer::THPComponents::swapBig() { numComponents = SBig(numComponents); }
void CMoviePlayer::THPVideoInfo::swapBig() { void CMoviePlayer::THPVideoInfo::swapBig() {
width = hecl::SBig(width); width = SBig(width);
height = hecl::SBig(height); height = SBig(height);
} }
void CMoviePlayer::THPAudioInfo::swapBig() { void CMoviePlayer::THPAudioInfo::swapBig() {
numChannels = hecl::SBig(numChannels); numChannels = SBig(numChannels);
sampleRate = hecl::SBig(sampleRate); sampleRate = SBig(sampleRate);
numSamples = hecl::SBig(numSamples); numSamples = SBig(numSamples);
} }
void CMoviePlayer::THPFrameHeader::swapBig() { void CMoviePlayer::THPFrameHeader::swapBig() {
nextSize = hecl::SBig(nextSize); nextSize = SBig(nextSize);
prevSize = hecl::SBig(prevSize); prevSize = SBig(prevSize);
imageSize = hecl::SBig(imageSize); imageSize = SBig(imageSize);
audioSize = hecl::SBig(audioSize); audioSize = SBig(audioSize);
} }
void CMoviePlayer::THPAudioFrameHeader::swapBig() { void CMoviePlayer::THPAudioFrameHeader::swapBig() {
channelSize = hecl::SBig(channelSize); channelSize = SBig(channelSize);
numSamples = hecl::SBig(numSamples); numSamples = SBig(numSamples);
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 8; ++j) { for (int j = 0; j < 8; ++j) {
channelCoefs[i][j][0] = hecl::SBig(channelCoefs[i][j][0]); channelCoefs[i][j][0] = SBig(channelCoefs[i][j][0]);
channelCoefs[i][j][1] = hecl::SBig(channelCoefs[i][j][1]); channelCoefs[i][j][1] = SBig(channelCoefs[i][j][1]);
} }
channelPrevs[i][0] = hecl::SBig(channelPrevs[i][0]); channelPrevs[i][0] = SBig(channelPrevs[i][0]);
channelPrevs[i][1] = hecl::SBig(channelPrevs[i][1]); channelPrevs[i][1] = SBig(channelPrevs[i][1]);
} }
} }
@ -187,28 +187,28 @@ CMoviePlayer::CMoviePlayer(const char* path, float preLoadSeconds, bool loop, bo
CTHPTextureSet& set = x80_textures.emplace_back(); CTHPTextureSet& set = x80_textures.emplace_back();
if (deinterlace) { if (deinterlace) {
/* metaforce addition: this way interlaced THPs don't look horrible */ /* metaforce addition: this way interlaced THPs don't look horrible */
set.Y[0] = aurora::new_dynamic_texture_2d(x6c_videoInfo.width, x6c_videoInfo.height / 2, 1, set.Y[0] = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width, x6c_videoInfo.height / 2, 1,
aurora::shaders::TextureFormat::R8, aurora::gfx::TextureFormat::R8,
fmt::format(FMT_STRING("Movie {} Texture Set {} Y[0]"), path, i)); fmt::format(FMT_STRING("Movie {} Texture Set {} Y[0]"), path, i));
set.Y[1] = aurora::new_dynamic_texture_2d(x6c_videoInfo.width, x6c_videoInfo.height / 2, 1, set.Y[1] = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width, x6c_videoInfo.height / 2, 1,
aurora::shaders::TextureFormat::R8, aurora::gfx::TextureFormat::R8,
fmt::format(FMT_STRING("Movie {} Texture Set {} Y[1]"), path, i)); fmt::format(FMT_STRING("Movie {} Texture Set {} Y[1]"), path, i));
set.U = aurora::new_dynamic_texture_2d(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, 1, set.U = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, 1,
aurora::shaders::TextureFormat::R8, aurora::gfx::TextureFormat::R8,
fmt::format(FMT_STRING("Movie {} Texture Set {} U"), path, i)); fmt::format(FMT_STRING("Movie {} Texture Set {} U"), path, i));
set.V = aurora::new_dynamic_texture_2d(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, 1, set.V = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, 1,
aurora::shaders::TextureFormat::R8, aurora::gfx::TextureFormat::R8,
fmt::format(FMT_STRING("Movie {} Texture Set {} V"), path, i)); fmt::format(FMT_STRING("Movie {} Texture Set {} V"), path, i));
} else { } else {
/* normal progressive presentation */ /* normal progressive presentation */
set.Y[0] = aurora::new_dynamic_texture_2d(x6c_videoInfo.width, x6c_videoInfo.height, 1, set.Y[0] = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width, x6c_videoInfo.height, 1,
aurora::shaders::TextureFormat::R8, aurora::gfx::TextureFormat::R8,
fmt::format(FMT_STRING("Movie {} Texture Set {} Y"), path, i)); fmt::format(FMT_STRING("Movie {} Texture Set {} Y"), path, i));
set.U = aurora::new_dynamic_texture_2d(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, 1, set.U = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, 1,
aurora::shaders::TextureFormat::R8, aurora::gfx::TextureFormat::R8,
fmt::format(FMT_STRING("Movie {} Texture Set {} U"), path, i)); fmt::format(FMT_STRING("Movie {} Texture Set {} U"), path, i));
set.V = aurora::new_dynamic_texture_2d(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, 1, set.V = aurora::gfx::new_dynamic_texture_2d(x6c_videoInfo.width / 2, x6c_videoInfo.height / 2, 1,
aurora::shaders::TextureFormat::R8, aurora::gfx::TextureFormat::R8,
fmt::format(FMT_STRING("Movie {} Texture Set {} V"), path, i)); fmt::format(FMT_STRING("Movie {} Texture Set {} V"), path, i));
} }
if (xf4_25_hasAudio) if (xf4_25_hasAudio)
@ -373,7 +373,7 @@ void CMoviePlayer::DrawFrame() {
/* draw appropriate field */ /* draw appropriate field */
CTHPTextureSet& tex = x80_textures[xd0_drawTexSlot]; CTHPTextureSet& tex = x80_textures[xd0_drawTexSlot];
aurora::shaders::queue_movie_player(tex.Y[m_deinterlace ? (xfc_fieldIndex != 0) : 0]->ref, tex.U->ref, tex.V->ref, aurora::gfx::queue_movie_player(tex.Y[m_deinterlace ? (xfc_fieldIndex != 0) : 0]->ref, tex.U->ref, tex.V->ref,
zeus::skWhite, m_hpad, m_vpad); zeus::skWhite, m_hpad, m_vpad);
/* ensure second field is being displayed by VI to signal advance /* ensure second field is being displayed by VI to signal advance
@ -495,18 +495,18 @@ void CMoviePlayer::DecodeFromRead(const void* data) {
memcpy(buffer.get() + x6c_videoInfo.width * y, m_yuvBuf.get() + x6c_videoInfo.width * (y * 2), memcpy(buffer.get() + x6c_videoInfo.width * y, m_yuvBuf.get() + x6c_videoInfo.width * (y * 2),
x6c_videoInfo.width); x6c_videoInfo.width);
} }
aurora::shaders::write_texture(tex.Y[0]->ref, {buffer.get(), planeSizeHalf}); aurora::gfx::write_texture(tex.Y[0]->ref, {buffer.get(), planeSizeHalf});
for (unsigned y = 0; y < x6c_videoInfo.height / 2; ++y) { for (unsigned y = 0; y < x6c_videoInfo.height / 2; ++y) {
memcpy(buffer.get() + x6c_videoInfo.width * y, m_yuvBuf.get() + x6c_videoInfo.width * (y * 2 + 1), memcpy(buffer.get() + x6c_videoInfo.width * y, m_yuvBuf.get() + x6c_videoInfo.width * (y * 2 + 1),
x6c_videoInfo.width); x6c_videoInfo.width);
} }
aurora::shaders::write_texture(tex.Y[1]->ref, {buffer.get(), planeSizeHalf}); aurora::gfx::write_texture(tex.Y[1]->ref, {buffer.get(), planeSizeHalf});
} else { } else {
/* Direct planar load */ /* Direct planar load */
aurora::shaders::write_texture(tex.Y[0]->ref, {m_yuvBuf.get(), planeSize}); aurora::gfx::write_texture(tex.Y[0]->ref, {m_yuvBuf.get(), planeSize});
} }
aurora::shaders::write_texture(tex.U->ref, {m_yuvBuf.get() + planeSize, planeSizeQuarter}); aurora::gfx::write_texture(tex.U->ref, {m_yuvBuf.get() + planeSize, planeSizeQuarter});
aurora::shaders::write_texture(tex.V->ref, {m_yuvBuf.get() + planeSize + planeSizeQuarter, planeSizeQuarter}); aurora::gfx::write_texture(tex.V->ref, {m_yuvBuf.get() + planeSize + planeSizeQuarter, planeSizeQuarter});
break; break;
} }
@ -538,7 +538,7 @@ void CMoviePlayer::ReadCompleted() {
/* store params of next read operation */ /* store params of next read operation */
xb4_nextReadOff += xb0_nextReadSize; xb4_nextReadOff += xb0_nextReadSize;
xb0_nextReadSize = hecl::SBig(frameHeader->nextSize); xb0_nextReadSize = SBig(frameHeader->nextSize);
++xc0_curLoadFrame; ++xc0_curLoadFrame;
if (xc0_curLoadFrame == xf0_preLoadFrames) { if (xc0_curLoadFrame == xf0_preLoadFrames) {

View File

@ -69,9 +69,9 @@ private:
}; };
struct CTHPTextureSet { struct CTHPTextureSet {
std::shared_ptr<aurora::TextureHandle> Y[2]; std::shared_ptr<aurora::gfx::TextureHandle> Y[2];
std::shared_ptr<aurora::TextureHandle> U; std::shared_ptr<aurora::gfx::TextureHandle> U;
std::shared_ptr<aurora::TextureHandle> V; std::shared_ptr<aurora::gfx::TextureHandle> V;
u32 playedSamples = 0; u32 playedSamples = 0;
u32 audioSamples = 0; u32 audioSamples = 0;
std::unique_ptr<s16[]> audioBuf; std::unique_ptr<s16[]> audioBuf;

View File

@ -1,4 +1,5 @@
#include "Runtime/Graphics/CPVSAreaSet.hpp" #include "Runtime/Graphics/CPVSAreaSet.hpp"
#include "IOStreams.hpp"
namespace metaforce { namespace metaforce {

View File

@ -1,4 +1,5 @@
#include "Runtime/Graphics/CPVSVisOctree.hpp" #include "Runtime/Graphics/CPVSVisOctree.hpp"
#include "IOStreams.hpp"
#include <array> #include <array>

View File

@ -54,7 +54,7 @@ void CPVSVisSet::SetTestPoint(const CPVSVisOctree& octree, const zeus::CVector3f
if (nextNodeRel) { if (nextNodeRel) {
/* Skip node data */ /* Skip node data */
if (!(curNode & 0x60)) { if (!(curNode & 0x60)) {
octCur += hecl::SBig(reinterpret_cast<const u16*>(octCur)[nextNodeRel - 1]); octCur += SBig(reinterpret_cast<const u16*>(octCur)[nextNodeRel - 1]);
} else if (curNode & 0x20) { } else if (curNode & 0x20) {
octCur += *(octCur + nextNodeRel - 1); octCur += *(octCur + nextNodeRel - 1);
} else { } else {

View File

@ -33,8 +33,8 @@ private:
u16 x6_h; u16 x6_h;
u32 x8_mips; u32 x8_mips;
// boo::ObjToken<boo::ITexture> m_booTex; // boo::ObjToken<boo::ITexture> m_booTex;
std::shared_ptr<aurora::TextureHandle> m_tex; std::shared_ptr<aurora::gfx::TextureHandle> m_tex;
std::shared_ptr<aurora::TextureHandle> m_paletteTex; std::shared_ptr<aurora::gfx::TextureHandle> m_paletteTex;
std::unique_ptr<u8[]> m_otex; std::unique_ptr<u8[]> m_otex;
EFontType m_ftype = EFontType::None; EFontType m_ftype = EFontType::None;
const CTextureInfo* m_textureInfo; const CTextureInfo* m_textureInfo;
@ -70,11 +70,11 @@ public:
u16 GetHeight() const { return x6_h; } u16 GetHeight() const { return x6_h; }
u32 GetNumMips() const { return x8_mips; } u32 GetNumMips() const { return x8_mips; }
void Load(int slot, EClampMode clamp) const; void Load(int slot, EClampMode clamp) const;
const std::shared_ptr<aurora::TextureHandle>& GetTexture() const { return m_tex; } const std::shared_ptr<aurora::gfx::TextureHandle>& GetTexture() const { return m_tex; }
// const boo::ObjToken<boo::ITexture>& GetBooTexture() const { return m_booTex; } // const boo::ObjToken<boo::ITexture>& GetBooTexture() const { return m_booTex; }
const std::shared_ptr<aurora::TextureHandle>& GetPaletteTexture() const { return m_paletteTex; } const std::shared_ptr<aurora::gfx::TextureHandle>& GetPaletteTexture() const { return m_paletteTex; }
std::unique_ptr<u8[]> BuildMemoryCardTex(u32& sizeOut, ETexelFormat& fmtOut, std::unique_ptr<u8[]>& paletteOut) const; std::unique_ptr<u8[]> BuildMemoryCardTex(u32& sizeOut, ETexelFormat& fmtOut, std::unique_ptr<u8[]>& paletteOut) const;
const std::shared_ptr<aurora::TextureHandle>& GetFontTexture(EFontType tp); const std::shared_ptr<aurora::gfx::TextureHandle>& GetFontTexture(EFontType tp);
const CTextureInfo* GetTextureInfo() const { return m_textureInfo; } const CTextureInfo* GetTextureInfo() const { return m_textureInfo; }
}; };

View File

@ -111,7 +111,7 @@ void CTexture::BuildI4FromGCN(CInputStream& in, std::string_view label) {
} }
} }
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::RGBA8, m_tex = aurora::gfx::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::gfx::TextureFormat::RGBA8,
{reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label); {reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label);
} }
@ -151,7 +151,7 @@ void CTexture::BuildI8FromGCN(CInputStream& in, std::string_view label) {
} }
} }
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::RGBA8, m_tex = aurora::gfx::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::gfx::TextureFormat::RGBA8,
{reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label); {reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label);
} }
@ -192,7 +192,7 @@ void CTexture::BuildIA4FromGCN(CInputStream& in, std::string_view label) {
} }
} }
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::RGBA8, m_tex = aurora::gfx::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::gfx::TextureFormat::RGBA8,
{reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label); {reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label);
} }
@ -233,7 +233,7 @@ void CTexture::BuildIA8FromGCN(CInputStream& in, std::string_view label) {
} }
} }
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::RGBA8, m_tex = aurora::gfx::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::gfx::TextureFormat::RGBA8,
{reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label); {reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label);
} }
@ -312,7 +312,7 @@ void CTexture::BuildC4FromGCN(CInputStream& in, std::string_view label) {
} }
} }
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::RGBA8, m_tex = aurora::gfx::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::gfx::TextureFormat::RGBA8,
{reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label); {reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label);
} }
@ -350,7 +350,7 @@ void CTexture::BuildC8FromGCN(CInputStream& in, std::string_view label) {
} }
} }
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::RGBA8, m_tex = aurora::gfx::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::gfx::TextureFormat::RGBA8,
{reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label); {reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label);
} }
@ -393,7 +393,7 @@ void CTexture::BuildRGB565FromGCN(CInputStream& in, std::string_view label) {
} }
} }
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::RGBA8, m_tex = aurora::gfx::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::gfx::TextureFormat::RGBA8,
{reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label); {reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label);
} }
@ -439,7 +439,7 @@ void CTexture::BuildRGB5A3FromGCN(CInputStream& in, std::string_view label) {
} }
} }
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::RGBA8, m_tex = aurora::gfx::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::gfx::TextureFormat::RGBA8,
{reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label); {reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label);
} }
@ -484,7 +484,7 @@ void CTexture::BuildRGBA8FromGCN(CInputStream& in, std::string_view label) {
} }
} }
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::RGBA8, m_tex = aurora::gfx::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::gfx::TextureFormat::RGBA8,
{reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label); {reinterpret_cast<const uint8_t*>(buf.get()), texelCount * 4}, label);
} }
@ -532,7 +532,7 @@ void CTexture::BuildDXT1FromGCN(CInputStream& in, std::string_view label) {
} }
} }
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::DXT1, m_tex = aurora::gfx::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::gfx::TextureFormat::DXT1,
{reinterpret_cast<const uint8_t*>(buf.get()), blockCount * 8}, label); {reinterpret_cast<const uint8_t*>(buf.get()), blockCount * 8}, label);
} }
@ -542,7 +542,7 @@ void CTexture::BuildRGBA8(const void* data, size_t length, std::string_view labe
if (expectedSize > length) if (expectedSize > length)
Log.report(logvisor::Fatal, FMT_STRING("insufficient TXTR length ({}/{})"), length, expectedSize); Log.report(logvisor::Fatal, FMT_STRING("insufficient TXTR length ({}/{})"), length, expectedSize);
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::RGBA8, m_tex = aurora::gfx::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::gfx::TextureFormat::RGBA8,
{reinterpret_cast<const uint8_t*>(data), expectedSize}, label); {reinterpret_cast<const uint8_t*>(data), expectedSize}, label);
} }
@ -554,9 +554,9 @@ void CTexture::BuildC8(const void* data, size_t length, std::string_view label)
uint32_t nentries = hecl::SBig(*reinterpret_cast<const uint32_t*>(data)); uint32_t nentries = hecl::SBig(*reinterpret_cast<const uint32_t*>(data));
const u8* paletteTexels = reinterpret_cast<const u8*>(data) + 4; const u8* paletteTexels = reinterpret_cast<const u8*>(data) + 4;
const u8* texels = reinterpret_cast<const u8*>(data) + 4 + nentries * 4; const u8* texels = reinterpret_cast<const u8*>(data) + 4 + nentries * 4;
m_paletteTex = aurora::new_static_texture_2d(nentries, 1, 1, aurora::shaders::TextureFormat::RGBA8, m_paletteTex = aurora::gfx::new_static_texture_2d(nentries, 1, 1, aurora::gfx::TextureFormat::RGBA8,
{paletteTexels, nentries * 4}, label); {paletteTexels, nentries * 4}, label);
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::R8, {texels, texelCount}, m_tex = aurora::gfx::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::gfx::TextureFormat::R8, {texels, texelCount},
label); label);
} }
@ -660,12 +660,12 @@ void CTexture::BuildC8Font(const void* data, EFontType ftype, std::string_view l
} }
void CTexture::BuildDXT1(const void* data, size_t length, std::string_view label) { void CTexture::BuildDXT1(const void* data, size_t length, std::string_view label) {
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::DXT1, m_tex = aurora::gfx::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::gfx::TextureFormat::DXT1,
{reinterpret_cast<const uint8_t*>(data), length}, label); {reinterpret_cast<const uint8_t*>(data), length}, label);
} }
void CTexture::BuildDXT3(const void* data, size_t length, std::string_view label) { void CTexture::BuildDXT3(const void* data, size_t length, std::string_view label) {
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::DXT3, m_tex = aurora::gfx::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::gfx::TextureFormat::DXT3,
{reinterpret_cast<const uint8_t*>(data), length}, label); {reinterpret_cast<const uint8_t*>(data), length}, label);
} }
@ -754,14 +754,14 @@ CTexture::CTexture(std::unique_ptr<u8[]>&& in, u32 length, bool otex, const CTex
BuildRGBA8FromGCN(r, label); BuildRGBA8FromGCN(r, label);
break; break;
case ETexelFormat::CMPR: case ETexelFormat::CMPR:
if (aurora::get_dxt_compression_supported()) { if (aurora::gfx::get_dxt_compression_supported()) {
BuildDXT1FromGCN(r, label); BuildDXT1FromGCN(r, label);
} else { } else {
Log.report(logvisor::Error, FMT_STRING("BC/DXT1 compression is not supported on your GPU, unable to load {}"), Log.report(logvisor::Error, FMT_STRING("BC/DXT1 compression is not supported on your GPU, unable to load {}"),
label); label);
x0_fmt = ETexelFormat::RGBA8PC; x0_fmt = ETexelFormat::RGBA8PC;
x8_mips = 1; x8_mips = 1;
std::unique_ptr<u8[]> data= std::make_unique<u8[]>(x4_w * x6_h * 4); std::unique_ptr<u8[]> data = std::make_unique<u8[]>(x4_w * x6_h * 4);
/* Build a fake texture to use */ /* Build a fake texture to use */
for (u32 i = 0; i < (x4_w * x6_h) * 4; i += 4) { for (u32 i = 0; i < (x4_w * x6_h) * 4; i += 4) {
data[i + 0] = 0xFF; data[i + 0] = 0xFF;
@ -769,8 +769,9 @@ CTexture::CTexture(std::unique_ptr<u8[]>&& in, u32 length, bool otex, const CTex
data[i + 2] = 0xFF; data[i + 2] = 0xFF;
data[i + 3] = 0xFF; data[i + 3] = 0xFF;
} }
m_tex = aurora::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::shaders::TextureFormat::RGBA8, m_tex = aurora::gfx::new_static_texture_2d(x4_w, x6_h, x8_mips, aurora::gfx::TextureFormat::RGBA8,
{reinterpret_cast<const uint8_t*>(data.get()), (x4_w * x6_h * 4ul)}, label); {reinterpret_cast<const uint8_t*>(data.get()), (x4_w * x6_h * 4ul)},
label);
} }
break; break;
case ETexelFormat::RGBA8PC: case ETexelFormat::RGBA8PC:
@ -880,7 +881,7 @@ std::unique_ptr<u8[]> CTexture::BuildMemoryCardTex(u32& sizeOut, ETexelFormat& f
return ret; return ret;
} }
const std::shared_ptr<aurora::TextureHandle>& CTexture::GetFontTexture(EFontType tp) { const std::shared_ptr<aurora::gfx::TextureHandle>& CTexture::GetFontTexture(EFontType tp) {
if (m_ftype != tp && x0_fmt == ETexelFormat::C8PC) { if (m_ftype != tp && x0_fmt == ETexelFormat::C8PC) {
m_ftype = tp; m_ftype = tp;
BuildC8Font(m_otex.get() + 12, m_ftype, "Font (TODO)"sv); BuildC8Font(m_otex.get() + 12, m_ftype, "Font (TODO)"sv);

View File

@ -61,7 +61,7 @@ void CColoredStripShader::Shutdown() {
// stages.data(), nullptr, nullptr, texs.size(), texs.data(), nullptr, nullptr); // stages.data(), nullptr, nullptr, texs.size(), texs.data(), nullptr, nullptr);
//} //}
CColoredStripShader::CColoredStripShader(size_t maxVerts, Mode mode, std::shared_ptr<aurora::TextureHandle> tex) { CColoredStripShader::CColoredStripShader(size_t maxVerts, Mode mode, std::shared_ptr<aurora::gfx::TextureHandle> tex) {
// CGraphics::CommitResources([this, maxVerts, mode, tex](boo::IGraphicsDataFactory::Context& ctx) { // CGraphics::CommitResources([this, maxVerts, mode, tex](boo::IGraphicsDataFactory::Context& ctx) {
// BuildResources(ctx, maxVerts, mode, tex); // BuildResources(ctx, maxVerts, mode, tex);
// return true; // return true;

View File

@ -32,7 +32,7 @@ public:
}; };
static void Initialize(); static void Initialize();
static void Shutdown(); static void Shutdown();
CColoredStripShader(size_t maxVerts, Mode mode, std::shared_ptr<aurora::TextureHandle> tex); CColoredStripShader(size_t maxVerts, Mode mode, std::shared_ptr<aurora::gfx::TextureHandle> tex);
void draw(const zeus::CColor& color, size_t numVerts, const Vert* verts); void draw(const zeus::CColor& color, size_t numVerts, const Vert* verts);
}; };

View File

@ -198,7 +198,7 @@ CFluidPlaneShader::CFluidPlaneShader(EFluidType type, const TLockedToken<CTextur
const TLockedToken<CTexture>& patternTex2, const TLockedToken<CTexture>& colorTex, const TLockedToken<CTexture>& patternTex2, const TLockedToken<CTexture>& colorTex,
const TLockedToken<CTexture>& bumpMap, const TLockedToken<CTexture>& envMap, const TLockedToken<CTexture>& bumpMap, const TLockedToken<CTexture>& envMap,
const TLockedToken<CTexture>& envBumpMap, const TLockedToken<CTexture>& lightmap, const TLockedToken<CTexture>& envBumpMap, const TLockedToken<CTexture>& lightmap,
const std::shared_ptr<aurora::TextureHandle>& rippleMap, bool doubleLightmapBlend, const std::shared_ptr<aurora::gfx::TextureHandle>& rippleMap, bool doubleLightmapBlend,
bool additive, u32 maxVertCount) bool additive, u32 maxVertCount)
: m_patternTex1(patternTex1) : m_patternTex1(patternTex1)
, m_patternTex2(patternTex2) , m_patternTex2(patternTex2)

View File

@ -106,7 +106,7 @@ private:
TLockedToken<CTexture> m_envMap; TLockedToken<CTexture> m_envMap;
TLockedToken<CTexture> m_envBumpMap; TLockedToken<CTexture> m_envBumpMap;
TLockedToken<CTexture> m_lightmap; TLockedToken<CTexture> m_lightmap;
std::shared_ptr<aurora::TextureHandle> m_rippleMap; std::shared_ptr<aurora::gfx::TextureHandle> m_rippleMap;
// boo::ObjToken<boo::IGraphicsBufferD> m_vbo; // boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
// boo::ObjToken<boo::IGraphicsBufferD> m_pvbo; // boo::ObjToken<boo::IGraphicsBufferD> m_pvbo;
// boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf; // boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
@ -145,7 +145,7 @@ public:
const TLockedToken<CTexture>& patternTex2, const TLockedToken<CTexture>& colorTex, const TLockedToken<CTexture>& patternTex2, const TLockedToken<CTexture>& colorTex,
const TLockedToken<CTexture>& bumpMap, const TLockedToken<CTexture>& envMap, const TLockedToken<CTexture>& bumpMap, const TLockedToken<CTexture>& envMap,
const TLockedToken<CTexture>& envBumpMap, const TLockedToken<CTexture>& lightmap, const TLockedToken<CTexture>& envBumpMap, const TLockedToken<CTexture>& lightmap,
const std::shared_ptr<aurora::TextureHandle>& rippleMap, bool doubleLightmapBlend, bool additive, const std::shared_ptr<aurora::gfx::TextureHandle>& rippleMap, bool doubleLightmapBlend, bool additive,
u32 maxVertCount); u32 maxVertCount);
CFluidPlaneShader(const TLockedToken<CTexture>& patternTex1, const TLockedToken<CTexture>& patternTex2, CFluidPlaneShader(const TLockedToken<CTexture>& patternTex1, const TLockedToken<CTexture>& patternTex2,
const TLockedToken<CTexture>& colorTex, u32 maxVertCount); const TLockedToken<CTexture>& colorTex, u32 maxVertCount);

View File

@ -54,7 +54,7 @@ void CLineRendererShaders::Shutdown() {
} }
void CLineRendererShaders::BuildShaderDataBinding(CLineRenderer& renderer, void CLineRendererShaders::BuildShaderDataBinding(CLineRenderer& renderer,
const std::shared_ptr<aurora::TextureHandle>& texture, bool additive, const std::shared_ptr<aurora::gfx::TextureHandle>& texture, bool additive,
bool zTest, bool zGEqual) { bool zTest, bool zGEqual) {
// std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* pipeline = nullptr; // std::array<boo::ObjToken<boo::IShaderPipeline>, 2>* pipeline = nullptr;
// //

View File

@ -26,7 +26,7 @@ public:
static void Initialize(); static void Initialize();
static void Shutdown(); static void Shutdown();
static void BuildShaderDataBinding(CLineRenderer& renderer, static void BuildShaderDataBinding(CLineRenderer& renderer,
const std::shared_ptr<aurora::TextureHandle>& texture, bool additive, bool zTest, const std::shared_ptr<aurora::gfx::TextureHandle>& texture, bool additive, bool zTest,
bool zGEqual); bool zGEqual);
}; };

View File

@ -73,7 +73,7 @@ public:
std::array<zeus::CColor, 3> colorRegs; std::array<zeus::CColor, 3> colorRegs;
zeus::CColor mulColor; zeus::CColor mulColor;
zeus::CColor addColor; zeus::CColor addColor;
CGraphics::CFogState fog; CFogState fog;
void ActivateLights(const std::vector<CLight>& lts); void ActivateLights(const std::vector<CLight>& lts);
}; };
@ -94,7 +94,7 @@ public:
struct OneTextureUniform { struct OneTextureUniform {
zeus::CColor addColor; zeus::CColor addColor;
CGraphics::CFogState fog; CFogState fog;
}; };
static void Initialize(); static void Initialize();

View File

@ -35,8 +35,8 @@ void CSpaceWarpFilter::GenerateWarpRampTex() {
data[y][x][0] = data[y][x][1] = data[y][x][2]; data[y][x][0] = data[y][x][1] = data[y][x][2];
} }
} }
m_warpTex = aurora::new_static_texture_2d( m_warpTex = aurora::gfx::new_static_texture_2d(
WARP_RAMP_RES + 1, WARP_RAMP_RES + 1, 1, aurora::shaders::TextureFormat::R8, WARP_RAMP_RES + 1, WARP_RAMP_RES + 1, 1, aurora::gfx::TextureFormat::R8,
{reinterpret_cast<const uint8_t*>(data.data()), (WARP_RAMP_RES + 1) * (WARP_RAMP_RES + 1) * 4}, "Warp Ramp"); {reinterpret_cast<const uint8_t*>(data.data()), (WARP_RAMP_RES + 1) * (WARP_RAMP_RES + 1) * 4}, "Warp Ramp");
} }

View File

@ -17,7 +17,7 @@ class CSpaceWarpFilter {
zeus::CVector3f m_strength; zeus::CVector3f m_strength;
}; };
std::array<std::array<std::array<u8, 4>, 8>, 4> m_shiftTexture{}; std::array<std::array<std::array<u8, 4>, 8>, 4> m_shiftTexture{};
std::shared_ptr<aurora::TextureHandle> m_warpTex; std::shared_ptr<aurora::gfx::TextureHandle> m_warpTex;
// boo::ObjToken<boo::IGraphicsBufferS> m_vbo; // boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
// boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf; // boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
// boo::ObjToken<boo::IShaderDataBinding> m_dataBind; // boo::ObjToken<boo::IShaderDataBinding> m_dataBind;

View File

@ -178,11 +178,11 @@ void CTexturedQuadFilterAlpha::Shutdown() {
// } // }
//} //}
CTexturedQuadFilter::CTexturedQuadFilter(const std::shared_ptr<aurora::TextureHandle>& tex) : m_booTex(tex) { CTexturedQuadFilter::CTexturedQuadFilter(const std::shared_ptr<aurora::gfx::TextureHandle>& tex) : m_booTex(tex) {
m_flipRect = true; // TODO? m_flipRect = true; // TODO?
} }
CTexturedQuadFilter::CTexturedQuadFilter(EFilterType type, const std::shared_ptr<aurora::TextureHandle>& tex, ERglEnum ztest) CTexturedQuadFilter::CTexturedQuadFilter(EFilterType type, const std::shared_ptr<aurora::gfx::TextureHandle>& tex, ERglEnum ztest)
: m_booTex(tex), m_zTest(ztest) { : m_booTex(tex), m_zTest(ztest) {
m_flipRect = true; // TODO? m_flipRect = true; // TODO?
// tex->setClampMode(boo::TextureClampMode::ClampToEdge); // tex->setClampMode(boo::TextureClampMode::ClampToEdge);
@ -322,7 +322,7 @@ void CTexturedQuadFilter::DrawFilter(EFilterShape shape, const zeus::CColor& col
} }
} }
CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(EFilterType type, const std::shared_ptr<aurora::TextureHandle>& tex) CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(EFilterType type, const std::shared_ptr<aurora::gfx::TextureHandle>& tex)
: CTexturedQuadFilter(tex) { : CTexturedQuadFilter(tex) {
// CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) { // CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) {
// m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 32, 4); // m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 32, 4);

View File

@ -26,7 +26,7 @@ protected:
float m_lod = 0.f; float m_lod = 0.f;
}; };
TLockedToken<CTexture> m_tex; TLockedToken<CTexture> m_tex;
std::shared_ptr<aurora::TextureHandle> m_booTex; std::shared_ptr<aurora::gfx::TextureHandle> m_booTex;
// boo::ObjToken<boo::IGraphicsBufferD> m_vbo; // boo::ObjToken<boo::IGraphicsBufferD> m_vbo;
// boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf; // boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
// boo::ObjToken<boo::IShaderDataBinding> m_dataBind; // boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
@ -34,7 +34,7 @@ protected:
ERglEnum m_zTest; ERglEnum m_zTest;
bool m_flipRect = false; bool m_flipRect = false;
explicit CTexturedQuadFilter(const std::shared_ptr<aurora::TextureHandle>& tex); explicit CTexturedQuadFilter(const std::shared_ptr<aurora::gfx::TextureHandle>& tex);
public: public:
struct Vert { struct Vert {
@ -45,7 +45,7 @@ public:
static void Shutdown(); static void Shutdown();
static constexpr zeus::CRectangle DefaultRect{0.f, 0.f, 1.f, 1.f}; static constexpr zeus::CRectangle DefaultRect{0.f, 0.f, 1.f, 1.f};
explicit CTexturedQuadFilter(EFilterType type, TLockedToken<CTexture> tex, ERglEnum zTest = ERglEnum::Never); explicit CTexturedQuadFilter(EFilterType type, TLockedToken<CTexture> tex, ERglEnum zTest = ERglEnum::Never);
explicit CTexturedQuadFilter(EFilterType type, const std::shared_ptr<aurora::TextureHandle>& tex, explicit CTexturedQuadFilter(EFilterType type, const std::shared_ptr<aurora::gfx::TextureHandle>& tex,
ERglEnum zTest = ERglEnum::Never); ERglEnum zTest = ERglEnum::Never);
CTexturedQuadFilter(const CTexturedQuadFilter&) = delete; CTexturedQuadFilter(const CTexturedQuadFilter&) = delete;
CTexturedQuadFilter& operator=(const CTexturedQuadFilter&) = delete; CTexturedQuadFilter& operator=(const CTexturedQuadFilter&) = delete;
@ -56,7 +56,7 @@ public:
void drawVerts(const zeus::CColor& color, std::array<Vert, 4> verts, float lod = 0.f); void drawVerts(const zeus::CColor& color, std::array<Vert, 4> verts, float lod = 0.f);
void DrawFilter(EFilterShape shape, const zeus::CColor& color, float t); void DrawFilter(EFilterShape shape, const zeus::CColor& color, float t);
const TLockedToken<CTexture>& GetTex() const { return m_tex; } const TLockedToken<CTexture>& GetTex() const { return m_tex; }
const std::shared_ptr<aurora::TextureHandle>& GetBooTex() const { return m_booTex; } const std::shared_ptr<aurora::gfx::TextureHandle>& GetBooTex() const { return m_booTex; }
}; };
class CTexturedQuadFilterAlpha : public CTexturedQuadFilter { class CTexturedQuadFilterAlpha : public CTexturedQuadFilter {
@ -64,7 +64,7 @@ public:
static void Initialize(); static void Initialize();
static void Shutdown(); static void Shutdown();
explicit CTexturedQuadFilterAlpha(EFilterType type, TLockedToken<CTexture> tex); explicit CTexturedQuadFilterAlpha(EFilterType type, TLockedToken<CTexture> tex);
explicit CTexturedQuadFilterAlpha(EFilterType type, const std::shared_ptr<aurora::TextureHandle>& tex); explicit CTexturedQuadFilterAlpha(EFilterType type, const std::shared_ptr<aurora::gfx::TextureHandle>& tex);
}; };
} // namespace metaforce } // namespace metaforce

View File

@ -13,7 +13,7 @@
namespace metaforce { namespace metaforce {
class CWorldShadowShader { class CWorldShadowShader {
std::shared_ptr<aurora::TextureHandle> m_tex; std::shared_ptr<aurora::gfx::TextureHandle> m_tex;
std::optional<CTexturedQuadFilter> m_prevQuad; std::optional<CTexturedQuadFilter> m_prevQuad;
u32 m_w, m_h; u32 m_w, m_h;
@ -40,7 +40,7 @@ public:
u32 GetWidth() const { return m_w; } u32 GetWidth() const { return m_w; }
u32 GetHeight() const { return m_h; } u32 GetHeight() const { return m_h; }
const std::shared_ptr<aurora::TextureHandle>& GetTexture() const { return m_tex; } const std::shared_ptr<aurora::gfx::TextureHandle>& GetTexture() const { return m_tex; }
}; };
} // namespace metaforce } // namespace metaforce

View File

@ -15,7 +15,7 @@ class CXRayBlurFilter {
std::array<zeus::CMatrix4f, 8> m_uv; std::array<zeus::CMatrix4f, 8> m_uv;
}; };
TLockedToken<CTexture> m_paletteTex; TLockedToken<CTexture> m_paletteTex;
std::shared_ptr<aurora::TextureHandle> m_booTex; std::shared_ptr<aurora::gfx::TextureHandle> m_booTex;
// boo::ObjToken<boo::IGraphicsBufferS> m_vbo; // boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
// boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf; // boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
// boo::ObjToken<boo::IShaderDataBinding> m_dataBind; // boo::ObjToken<boo::IShaderDataBinding> m_dataBind;

View File

@ -83,21 +83,18 @@ void CAuiImagePane::DoDrawImagePane(const zeus::CColor& color, const CTexture& t
bool zTest = xac_drawFlags == EGuiModelDrawFlags::Shadeless || xac_drawFlags == EGuiModelDrawFlags::Opaque; bool zTest = xac_drawFlags == EGuiModelDrawFlags::Shadeless || xac_drawFlags == EGuiModelDrawFlags::Opaque;
if (noBlur) { if (noBlur) {
aurora::shaders::queue_textured_quad_verts( aurora::gfx::queue_textured_quad_verts(aurora::gfx::CameraFilterType(filter), tex.GetTexture()->ref,
aurora::shaders::CameraFilterType(filter), tex.GetTexture()->ref, aurora::shaders::ZTest::LEqual, zTest, useColor, aurora::gfx::ZTest::LEqual, zTest, useColor, xe0_coords, realUseUvs, 0);
{xe0_coords.data(), xe0_coords.size()}, {realUseUvs.data(), xe0_coords.size()}, 0);
// quad.drawVerts(useColor, verts); // quad.drawVerts(useColor, verts);
} else if ((x14c_deResFactor == 0.f && alpha == 1.f) || tex.GetNumMips() == 1) { } else if ((x14c_deResFactor == 0.f && alpha == 1.f) || tex.GetNumMips() == 1) {
aurora::shaders::queue_textured_quad_verts( aurora::gfx::queue_textured_quad_verts(aurora::gfx::CameraFilterType(filter), tex.GetTexture()->ref,
aurora::shaders::CameraFilterType(filter), tex.GetTexture()->ref, aurora::shaders::ZTest::LEqual, zTest, aurora::gfx::ZTest::LEqual, zTest, useColor, xe0_coords, realUseUvs, 0);
useColor, {xe0_coords.data(), xe0_coords.size()}, {realUseUvs.data(), xe0_coords.size()}, 0);
} else { } else {
const float tmp = (1.f - x14c_deResFactor) * alpha; const float tmp = (1.f - x14c_deResFactor) * alpha;
const float tmp3 = 1.f - tmp * tmp * tmp; const float tmp3 = 1.f - tmp * tmp * tmp;
const float mip = tmp3 * static_cast<float>(tex.GetNumMips() - 1); const float mip = tmp3 * static_cast<float>(tex.GetNumMips() - 1);
aurora::shaders::queue_textured_quad_verts( aurora::gfx::queue_textured_quad_verts(aurora::gfx::CameraFilterType(filter), tex.GetTexture()->ref,
aurora::shaders::CameraFilterType(filter), tex.GetTexture()->ref, aurora::shaders::ZTest::LEqual, zTest, aurora::gfx::ZTest::LEqual, zTest, useColor, xe0_coords, realUseUvs, mip);
useColor, {xe0_coords.data(), xe0_coords.size()}, {realUseUvs.data(), xe0_coords.size()}, mip);
} }
} }

View File

@ -169,9 +169,8 @@ void CGuiFrame::LoadWidgetsInGame(CInputStream& in, CSimplePool* sp) {
for (u32 i = 0; i < count; ++i) { for (u32 i = 0; i < count; ++i) {
DataSpec::DNAFourCC type; DataSpec::DNAFourCC type;
type.read(in); type.read(in);
std::shared_ptr<CGuiWidget> widget = CGuiSys::CreateWidgetInGame(type, in, this, sp); std::shared_ptr<CGuiWidget> widget = CGuiSys::CreateWidgetInGame(type.toUint32(), in, this, sp);
type = widget->GetWidgetTypeID(); switch (widget->GetWidgetTypeID().toUint32()) {
switch (type.toUint32()) {
case SBIG('CAMR'): case SBIG('CAMR'):
case SBIG('LITE'): case SBIG('LITE'):
case SBIG('BGND'): case SBIG('BGND'):

View File

@ -3,8 +3,6 @@
#include "Runtime/Graphics/CGraphics.hpp" #include "Runtime/Graphics/CGraphics.hpp"
#include <aurora_shaders.h>
namespace metaforce { namespace metaforce {
CGuiPane::CGuiPane(const CGuiWidgetParms& parms, const zeus::CVector2f& dim, const zeus::CVector3f& scaleCenter) CGuiPane::CGuiPane(const CGuiWidgetParms& parms, const zeus::CVector2f& dim, const zeus::CVector3f& scaleCenter)
@ -18,8 +16,8 @@ void CGuiPane::Draw(const CGuiWidgetDrawParms& parms) {
auto col = xa8_color2; auto col = xa8_color2;
col.a() = parms.x0_alphaMod * xa8_color2.a(); col.a() = parms.x0_alphaMod * xa8_color2.a();
aurora::shaders::queue_colored_quad_verts(aurora::shaders::CameraFilterType::Blend, aurora::shaders::ZTest::Always, aurora::gfx::queue_colored_quad_verts(aurora::gfx::CameraFilterType::Blend, aurora::gfx::ZTest::Always, false, col,
false, col, {xc0_verts.data(), xc0_verts.size()}); xc0_verts);
} }
CGuiWidget::Draw(parms); CGuiWidget::Draw(parms);
} }
@ -50,7 +48,6 @@ void CGuiPane::InitializeBuffers() {
xc0_verts[1].assign(-xb8_dim.x() * 0.5f, 0.f, -xb8_dim.y() * 0.5f); xc0_verts[1].assign(-xb8_dim.x() * 0.5f, 0.f, -xb8_dim.y() * 0.5f);
xc0_verts[2].assign(xb8_dim.x() * 0.5f, 0.f, xb8_dim.y() * 0.5f); xc0_verts[2].assign(xb8_dim.x() * 0.5f, 0.f, xb8_dim.y() * 0.5f);
xc0_verts[3].assign(xb8_dim.x() * 0.5f, 0.f, -xb8_dim.y() * 0.5f); xc0_verts[3].assign(xb8_dim.x() * 0.5f, 0.f, -xb8_dim.y() * 0.5f);
} }
void CGuiPane::WriteData(COutputStream& out, bool flag) const {} void CGuiPane::WriteData(COutputStream& out, bool flag) const {}

View File

@ -2,9 +2,6 @@
#include "Runtime/GuiSys/CGuiWidget.hpp" #include "Runtime/GuiSys/CGuiWidget.hpp"
#include "Runtime/GuiSys/CGuiFrame.hpp" #include "Runtime/GuiSys/CGuiFrame.hpp"
#include <aurora.h>
#include <aurora_shaders.h>
#include <logvisor/logvisor.hpp> #include <logvisor/logvisor.hpp>
namespace metaforce { namespace metaforce {

View File

@ -148,7 +148,7 @@ public:
const char16_t* str, int len) const; const char16_t* str, int len) const;
const CGlyph* GetGlyph(char16_t chr) const { return InternalGetGlyph(chr); } const CGlyph* GetGlyph(char16_t chr) const { return InternalGetGlyph(chr); }
void GetSize(const CDrawStringOptions& opts, int& width, int& height, const char16_t* str, int len) const; void GetSize(const CDrawStringOptions& opts, int& width, int& height, const char16_t* str, int len) const;
const std::shared_ptr<aurora::TextureHandle>& GetTexture() { return x80_texture->GetFontTexture(x2c_mode); } const std::shared_ptr<aurora::gfx::TextureHandle>& GetTexture() { return x80_texture->GetFontTexture(x2c_mode); }
bool IsFinishedLoading() const; bool IsFinishedLoading() const;
}; };

View File

@ -73,10 +73,10 @@ void CSplashScreen::Draw() {
rect.position.x() = 0.5f - rect.size.x() / 2.f; rect.position.x() = 0.5f - rect.size.x() / 2.f;
rect.position.y() = 0.5f - rect.size.y() / 2.f; rect.position.y() = 0.5f - rect.size.y() / 2.f;
aurora::shaders::queue_textured_quad( aurora::gfx::queue_textured_quad(
aurora::shaders::CameraFilterType::Blend, aurora::gfx::CameraFilterType::Blend,
m_texture->GetTexture()->ref, m_texture->GetTexture()->ref,
aurora::shaders::ZTest::Always, aurora::gfx::ZTest::Always,
false, false,
color, color,
1.f, 1.f,

View File

@ -54,11 +54,11 @@ void CStringTable::LoadStringTable(CInputStream& in) {
u32* off = reinterpret_cast<u32*>(x4_data.get()); u32* off = reinterpret_cast<u32*>(x4_data.get());
for (u32 i = 0; i < x0_stringCount; ++i, ++off) for (u32 i = 0; i < x0_stringCount; ++i, ++off)
*off = hecl::SBig(*off); *off = SBig(*off);
for (u32 i = x0_stringCount * 4; i < dataLen; i += 2) { for (u32 i = x0_stringCount * 4; i < dataLen; i += 2) {
u16* chr = reinterpret_cast<u16*>(x4_data.get() + i); u16* chr = reinterpret_cast<u16*>(x4_data.get() + i);
*chr = hecl::SBig(*chr); *chr = SBig(*chr);
} }
} }

View File

@ -5,10 +5,6 @@
#include "Runtime/Input/CKeyboardMouseController.hpp" #include "Runtime/Input/CKeyboardMouseController.hpp"
#include "Runtime/RetroTypes.hpp" #include "Runtime/RetroTypes.hpp"
#include "aurora.h"
//#include <boo/inputdev/DolphinSmashAdapter.hpp>
namespace metaforce { namespace metaforce {
struct SAuroraControllerState { struct SAuroraControllerState {

View File

@ -1,8 +1,9 @@
#pragma once #pragma once
#include <array> #include <array>
#include <aurora/aurora.hpp>
#include <boo/IWindow.hpp> #include <boo/IWindow.hpp>
#include "aurora.h"
namespace metaforce { namespace metaforce {

View File

@ -2045,8 +2045,8 @@ void CFrontEndUI::Draw() {
x38_pressStart->GetHeight() / 480.f * vPad); x38_pressStart->GetHeight() / 480.f * vPad);
zeus::CColor color = zeus::skWhite; zeus::CColor color = zeus::skWhite;
color.a() = x64_pressStartAlpha; color.a() = x64_pressStartAlpha;
aurora::shaders::queue_textured_quad(aurora::shaders::CameraFilterType::Add, x38_pressStart->GetTexture()->ref, aurora::gfx::queue_textured_quad(aurora::gfx::CameraFilterType::Add, x38_pressStart->GetTexture()->ref,
aurora::shaders::ZTest::Always, false, color, 1.f, rect, 0.f); aurora::gfx::ZTest::Always, false, color, 1.f, rect, 0.f);
} }
if (xc0_attractCount > 0) { if (xc0_attractCount > 0) {
@ -2058,8 +2058,8 @@ void CFrontEndUI::Draw() {
zeus::CColor color = zeus::skBlack; zeus::CColor color = zeus::skBlack;
color.a() = 1.f - x58_fadeBlackTimer; color.a() = 1.f - x58_fadeBlackTimer;
zeus::CRectangle rect(0, 0, 1, 1); zeus::CRectangle rect(0, 0, 1, 1);
aurora::shaders::queue_colored_quad(aurora::shaders::CameraFilterType::Blend, aurora::shaders::ZTest::Always, aurora::gfx::queue_colored_quad(aurora::gfx::CameraFilterType::Blend, aurora::gfx::ZTest::Always, false, color,
false, color, rect, 0.f); rect, 0.f);
} }
} }
@ -2070,15 +2070,15 @@ void CFrontEndUI::Draw() {
zeus::CColor color = zeus::skBlack; zeus::CColor color = zeus::skBlack;
color.a() = zeus::clamp(0.f, 1.f - x58_fadeBlackTimer, 1.f); color.a() = zeus::clamp(0.f, 1.f - x58_fadeBlackTimer, 1.f);
zeus::CRectangle rect(0, 0, 1, 1); zeus::CRectangle rect(0, 0, 1, 1);
aurora::shaders::queue_colored_quad(aurora::shaders::CameraFilterType::Blend, aurora::shaders::ZTest::Always, aurora::gfx::queue_colored_quad(aurora::gfx::CameraFilterType::Blend, aurora::gfx::ZTest::Always, false, color,
false, color, rect, 0.f); rect, 0.f);
} else if (x50_curScreen == EScreen::Title && x54_nextScreen == EScreen::Title) { } else if (x50_curScreen == EScreen::Title && x54_nextScreen == EScreen::Title) {
/* From black with 30-sec skip to title */ /* From black with 30-sec skip to title */
zeus::CColor color = zeus::skBlack; zeus::CColor color = zeus::skBlack;
color.a() = 1.f - zeus::clamp(0.f, 30.f - x58_fadeBlackTimer, 1.f); color.a() = 1.f - zeus::clamp(0.f, 30.f - x58_fadeBlackTimer, 1.f);
zeus::CRectangle rect(0, 0, 1, 1); zeus::CRectangle rect(0, 0, 1, 1);
aurora::shaders::queue_colored_quad(aurora::shaders::CameraFilterType::Blend, aurora::shaders::ZTest::Always, aurora::gfx::queue_colored_quad(aurora::gfx::CameraFilterType::Blend, aurora::gfx::ZTest::Always, false, color,
false, color, rect, 0.f); rect, 0.f);
} }
} }

View File

@ -209,7 +209,7 @@ CElementGen::CElementGen(TToken<CGenDescription> gen, EModelOrientationType orie
if (x26c_31_LINE) { if (x26c_31_LINE) {
CUVElement* texr = desc->x54_x40_TEXR.get(); CUVElement* texr = desc->x54_x40_TEXR.get();
std::shared_ptr<aurora::TextureHandle> tex; std::shared_ptr<aurora::gfx::TextureHandle> tex;
if (texr) if (texr)
tex = texr->GetValueTexture(0).GetObj()->GetTexture(); tex = texr->GetValueTexture(0).GetObj()->GetTexture();
int maxVerts = x90_MAXP; int maxVerts = x90_MAXP;

View File

@ -6,11 +6,9 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "Runtime/GCNTypes.hpp" #include "GCNTypes.hpp"
#include "Runtime/IOStreams.hpp" #include "rstl.hpp"
#include "Runtime/rstl.hpp"
#include <hecl/hecl.hpp>
#include <zeus/CMatrix3f.hpp> #include <zeus/CMatrix3f.hpp>
#include <zeus/CMatrix4f.hpp> #include <zeus/CMatrix4f.hpp>
#include <zeus/CTransform.hpp> #include <zeus/CTransform.hpp>
@ -21,6 +19,12 @@
#undef max #undef max
using namespace std::literals; using namespace std::literals;
namespace athena::io {
class IStreamReader;
class IStreamWriter;
} // namespace athena::io
namespace metaforce { namespace metaforce {
using kUniqueIdType = u16; using kUniqueIdType = u16;
static constexpr int kMaxEntities = 1024; static constexpr int kMaxEntities = 1024;
@ -33,7 +37,165 @@ constexpr kUniqueIdType kUniqueIdValueMask = kMaxEntities - 1;
constexpr kUniqueIdType kUniqueIdValueBits = 10; constexpr kUniqueIdType kUniqueIdValueBits = 10;
constexpr kUniqueIdType kUniqueIdVersionBits = 6; constexpr kUniqueIdType kUniqueIdVersionBits = 6;
using FourCC = hecl::FourCC; #undef bswap16
#undef bswap32
#undef bswap64
/* Type-sensitive byte swappers */
template <typename T>
constexpr T bswap16(T val) noexcept {
#if __GNUC__
return __builtin_bswap16(val);
#elif _WIN32
return _byteswap_ushort(val);
#else
return (val = (val << 8) | ((val >> 8) & 0xFF));
#endif
}
template <typename T>
constexpr T bswap32(T val) noexcept {
#if __GNUC__
return __builtin_bswap32(val);
#elif _WIN32
return _byteswap_ulong(val);
#else
val = (val & 0x0000FFFF) << 16 | (val & 0xFFFF0000) >> 16;
val = (val & 0x00FF00FF) << 8 | (val & 0xFF00FF00) >> 8;
return val;
#endif
}
template <typename T>
constexpr T bswap64(T val) noexcept {
#if __GNUC__
return __builtin_bswap64(val);
#elif _WIN32
return _byteswap_uint64(val);
#else
return ((val & 0xFF00000000000000ULL) >> 56) | ((val & 0x00FF000000000000ULL) >> 40) |
((val & 0x0000FF0000000000ULL) >> 24) | ((val & 0x000000FF00000000ULL) >> 8) |
((val & 0x00000000FF000000ULL) << 8) | ((val & 0x0000000000FF0000ULL) << 24) |
((val & 0x000000000000FF00ULL) << 40) | ((val & 0x00000000000000FFULL) << 56);
#endif
}
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
constexpr int16_t SBig(int16_t val) noexcept { return bswap16(val); }
constexpr uint16_t SBig(uint16_t val) noexcept { return bswap16(val); }
constexpr int32_t SBig(int32_t val) noexcept { return bswap32(val); }
constexpr uint32_t SBig(uint32_t val) noexcept { return bswap32(val); }
constexpr int64_t SBig(int64_t val) noexcept { return bswap64(val); }
constexpr uint64_t SBig(uint64_t val) noexcept { return bswap64(val); }
constexpr float SBig(float val) noexcept {
union {
float f;
atInt32 i;
} uval1 = {val};
union {
atInt32 i;
float f;
} uval2 = {bswap32(uval1.i)};
return uval2.f;
}
constexpr double SBig(double val) noexcept {
union {
double f;
atInt64 i;
} uval1 = {val};
union {
atInt64 i;
double f;
} uval2 = {bswap64(uval1.i)};
return uval2.f;
}
#ifndef SBIG
#define SBIG(q) (((q)&0x000000FF) << 24 | ((q)&0x0000FF00) << 8 | ((q)&0x00FF0000) >> 8 | ((q)&0xFF000000) >> 24)
#endif
constexpr int16_t SLittle(int16_t val) noexcept { return val; }
constexpr uint16_t SLittle(uint16_t val) noexcept { return val; }
constexpr int32_t SLittle(int32_t val) noexcept { return val; }
constexpr uint32_t SLittle(uint32_t val) noexcept { return val; }
constexpr int64_t SLittle(int64_t val) noexcept { return val; }
constexpr uint64_t SLittle(uint64_t val) noexcept { return val; }
constexpr float SLittle(float val) noexcept { return val; }
constexpr double SLittle(double val) noexcept { return val; }
#ifndef SLITTLE
#define SLITTLE(q) (q)
#endif
#else
constexpr int16_t SLittle(int16_t val) noexcept { return bswap16(val); }
constexpr uint16_t SLittle(uint16_t val) noexcept { return bswap16(val); }
constexpr int32_t SLittle(int32_t val) noexcept { return bswap32(val); }
constexpr uint32_t SLittle(uint32_t val) noexcept { return bswap32(val); }
constexpr int64_t SLittle(int64_t val) noexcept { return bswap64(val); }
constexpr uint64_t SLittle(uint64_t val) noexcept { return bswap64(val); }
constexpr float SLittle(float val) noexcept {
int32_t ival = bswap32(*((int32_t*)(&val)));
return *((float*)(&ival));
}
constexpr double SLittle(double val) noexcept {
int64_t ival = bswap64(*((int64_t*)(&val)));
return *((double*)(&ival));
}
#ifndef SLITTLE
#define SLITTLE(q) (((q)&0x000000FF) << 24 | ((q)&0x0000FF00) << 8 | ((q)&0x00FF0000) >> 8 | ((q)&0xFF000000) >> 24)
#endif
constexpr int16_t SBig(int16_t val) noexcept { return val; }
constexpr uint16_t SBig(uint16_t val) noexcept { return val; }
constexpr int32_t SBig(int32_t val) noexcept { return val; }
constexpr uint32_t SBig(uint32_t val) noexcept { return val; }
constexpr int64_t SBig(int64_t val) noexcept { return val; }
constexpr uint64_t SBig(uint64_t val) noexcept { return val; }
constexpr float SBig(float val) noexcept { return val; }
constexpr double SBig(double val) noexcept { return val; }
#ifndef SBIG
#define SBIG(q) (q)
#endif
#endif
class FourCC {
protected:
union {
char fcc[4];
uint32_t num = 0;
};
public:
// Sentinel FourCC
constexpr FourCC() noexcept = default;
constexpr FourCC(const FourCC& other) noexcept = default;
constexpr FourCC(FourCC&& other) noexcept = default;
constexpr FourCC(const char* name) noexcept : fcc{name[0], name[1], name[2], name[3]} {}
constexpr FourCC(uint32_t n) noexcept : num(n) {}
constexpr FourCC& operator=(const FourCC&) noexcept = default;
constexpr FourCC& operator=(FourCC&&) noexcept = default;
constexpr bool operator==(const FourCC& other) const noexcept { return num == other.num; }
constexpr bool operator!=(const FourCC& other) const noexcept { return !operator==(other); }
constexpr bool operator==(const char* other) const noexcept {
return other[0] == fcc[0] && other[1] == fcc[1] && other[2] == fcc[2] && other[3] == fcc[3];
}
constexpr bool operator!=(const char* other) const noexcept { return !operator==(other); }
constexpr bool operator==(int32_t other) const noexcept { return num == uint32_t(other); }
constexpr bool operator!=(int32_t other) const noexcept { return !operator==(other); }
constexpr bool operator==(uint32_t other) const noexcept { return num == other; }
constexpr bool operator!=(uint32_t other) const noexcept { return !operator==(other); }
std::string toString() const { return std::string(std::begin(fcc), std::end(fcc)); }
constexpr std::string_view toStringView() const { return std::string_view(fcc, std::size(fcc)); }
constexpr uint32_t toUint32() const noexcept { return num; }
constexpr const char* getChars() const noexcept { return fcc; }
constexpr char* getChars() noexcept { return fcc; }
constexpr bool IsValid() const noexcept { return num != 0; }
};
#define FOURCC(chars) FourCC(SBIG(chars))
using CInputStream = athena::io::IStreamReader;
using COutputStream = athena::io::IStreamWriter;
class CAssetId { class CAssetId {
u64 id = UINT64_MAX; u64 id = UINT64_MAX;
@ -184,6 +346,11 @@ public:
} // namespace metaforce } // namespace metaforce
namespace std { namespace std {
template <>
struct hash<metaforce::FourCC> {
size_t operator()(const metaforce::FourCC& val) const noexcept { return val.toUint32(); }
};
template <> template <>
struct hash<metaforce::SObjectTag> { struct hash<metaforce::SObjectTag> {
size_t operator()(const metaforce::SObjectTag& tag) const noexcept { return tag.id.Value(); } size_t operator()(const metaforce::SObjectTag& tag) const noexcept { return tag.id.Value(); }
@ -200,6 +367,8 @@ FMT_CUSTOM_FORMATTER(metaforce::TEditorId, "{:08X}", obj.id)
static_assert(sizeof(metaforce::kUniqueIdType) == sizeof(u16), static_assert(sizeof(metaforce::kUniqueIdType) == sizeof(u16),
"TUniqueId size does not match expected size! Update TUniqueId format string!"); "TUniqueId size does not match expected size! Update TUniqueId format string!");
FMT_CUSTOM_FORMATTER(metaforce::TUniqueId, "{:04X}", obj.id) FMT_CUSTOM_FORMATTER(metaforce::TUniqueId, "{:04X}", obj.id)
FMT_CUSTOM_FORMATTER(metaforce::FourCC, "{:c}{:c}{:c}{:c}", obj.getChars()[0], obj.getChars()[1], obj.getChars()[2],
obj.getChars()[3])
FMT_CUSTOM_FORMATTER(metaforce::SObjectTag, "{} {}", obj.type, obj.id) FMT_CUSTOM_FORMATTER(metaforce::SObjectTag, "{} {}", obj.type, obj.id)
FMT_CUSTOM_FORMATTER(zeus::CVector3f, "({} {} {})", float(obj.x()), float(obj.y()), float(obj.z())) FMT_CUSTOM_FORMATTER(zeus::CVector3f, "({} {} {})", float(obj.x()), float(obj.y()), float(obj.z()))

View File

@ -12,8 +12,8 @@
namespace metaforce { namespace metaforce {
CPlasmaProjectile::RenderObjects::RenderObjects(std::shared_ptr<aurora::TextureHandle> tex, CPlasmaProjectile::RenderObjects::RenderObjects(std::shared_ptr<aurora::gfx::TextureHandle> tex,
std::shared_ptr<aurora::TextureHandle> glowTex) std::shared_ptr<aurora::gfx::TextureHandle> glowTex)
: m_beamStrip1(8, CColoredStripShader::Mode::Additive, {}) : m_beamStrip1(8, CColoredStripShader::Mode::Additive, {})
, m_beamStrip2( 10, CColoredStripShader::Mode::FullAdditive, tex) , m_beamStrip2( 10, CColoredStripShader::Mode::FullAdditive, tex)
, m_beamStrip3( 18, CColoredStripShader::Mode::FullAdditive, tex) , m_beamStrip3( 18, CColoredStripShader::Mode::FullAdditive, tex)

View File

@ -91,8 +91,8 @@ private:
CColoredStripShader m_beamStrip3Sub; CColoredStripShader m_beamStrip3Sub;
CColoredStripShader m_beamStrip4Sub; CColoredStripShader m_beamStrip4Sub;
CColoredStripShader m_motionBlurStrip; CColoredStripShader m_motionBlurStrip;
RenderObjects(std::shared_ptr<aurora::TextureHandle> tex, RenderObjects(std::shared_ptr<aurora::gfx::TextureHandle> tex,
std::shared_ptr<aurora::TextureHandle> glowTex); std::shared_ptr<aurora::gfx::TextureHandle> glowTex);
}; };
std::optional<RenderObjects> m_renderObjs; std::optional<RenderObjects> m_renderObjs;

View File

@ -75,7 +75,7 @@ protected:
bool xe7_30_doTargetDistanceTest : 1 = true; bool xe7_30_doTargetDistanceTest : 1 = true;
bool xe7_31_targetable : 1 = true; bool xe7_31_targetable : 1 = true;
std::shared_ptr<aurora::TextureHandle> m_reflectionCube; std::shared_ptr<aurora::gfx::TextureHandle> m_reflectionCube;
zeus::CColor m_debugAddColor = zeus::skClear; zeus::CColor m_debugAddColor = zeus::skClear;
float m_debugAddColorTime = 0.f; float m_debugAddColorTime = 0.f;

View File

@ -271,7 +271,7 @@ CFluidPlaneShader::RenderSetupInfo CFluidPlaneCPU::RenderSetup(const CStateManag
m_cachedAdditive = mgr.GetThermalDrawFlag() == EThermalDrawFlag::Hot; m_cachedAdditive = mgr.GetThermalDrawFlag() == EThermalDrawFlag::Hot;
m_shader.emplace(x44_fluidType, x10_texPattern1, x20_texPattern2, x30_texColor, xb0_bumpMap, xc0_envMap, m_shader.emplace(x44_fluidType, x10_texPattern1, x20_texPattern2, x30_texColor, xb0_bumpMap, xc0_envMap,
xd0_envBumpMap, xe0_lightmap, xd0_envBumpMap, xe0_lightmap,
m_tessellation ? CFluidPlaneManager::RippleMapTex : std::shared_ptr<aurora::TextureHandle>{}, m_tessellation ? CFluidPlaneManager::RippleMapTex : std::shared_ptr<aurora::gfx::TextureHandle>{},
m_cachedDoubleLightmapBlend, m_cachedAdditive, m_maxVertCount); m_cachedDoubleLightmapBlend, m_cachedAdditive, m_maxVertCount);
} }

View File

@ -81,7 +81,7 @@ static bool g_RippleMapSetup = false;
std::array<std::array<u8, 64>, 64> CFluidPlaneManager::RippleValues{}; std::array<std::array<u8, 64>, 64> CFluidPlaneManager::RippleValues{};
std::array<u8, 64> CFluidPlaneManager::RippleMins{}; std::array<u8, 64> CFluidPlaneManager::RippleMins{};
std::array<u8, 64> CFluidPlaneManager::RippleMaxs{}; std::array<u8, 64> CFluidPlaneManager::RippleMaxs{};
std::shared_ptr<aurora::TextureHandle> CFluidPlaneManager::RippleMapTex; std::shared_ptr<aurora::gfx::TextureHandle> CFluidPlaneManager::RippleMapTex;
void CFluidPlaneManager::SetupRippleMap() { void CFluidPlaneManager::SetupRippleMap() {
if (g_RippleMapSetup) { if (g_RippleMapSetup) {
@ -135,9 +135,9 @@ void CFluidPlaneManager::SetupRippleMap() {
curX += (1.f / 63.f); curX += (1.f / 63.f);
} }
RippleMapTex = RippleMapTex = aurora::gfx::new_static_texture_2d(64, 64, 1, aurora::gfx::TextureFormat::R8,
aurora::new_static_texture_2d(64, 64, 1, aurora::shaders::TextureFormat::R8, {reinterpret_cast<const uint8_t*>(RippleValues.data()), 64 * 64},
{reinterpret_cast<const uint8_t*>(RippleValues.data()), 64 * 64}, "Ripple Map"); "Ripple Map");
} }
} // namespace metaforce } // namespace metaforce

View File

@ -46,7 +46,7 @@ public:
static std::array<std::array<u8, 64>, 64> RippleValues; static std::array<std::array<u8, 64>, 64> RippleValues;
static std::array<u8, 64> RippleMins; static std::array<u8, 64> RippleMins;
static std::array<u8, 64> RippleMaxs; static std::array<u8, 64> RippleMaxs;
static std::shared_ptr<aurora::TextureHandle> RippleMapTex; static std::shared_ptr<aurora::gfx::TextureHandle> RippleMapTex;
CFluidPlaneManager(); CFluidPlaneManager();
void StartFrame(bool); void StartFrame(bool);

View File

@ -1020,7 +1020,7 @@ void CGameArea::PostConstructArea() {
athena::io::MemoryReader r(x12c_postConstructed->x10c8_sclyBuf, x12c_postConstructed->x10d0_sclySize); athena::io::MemoryReader r(x12c_postConstructed->x10c8_sclyBuf, x12c_postConstructed->x10d0_sclySize);
hecl::DNAFourCC magic; hecl::DNAFourCC magic;
magic.read(r); magic.read(r);
if (magic == FOURCC('SCLY')) { if (magic == hecl::FOURCC('SCLY')) {
r.readUint32Big(); r.readUint32Big();
u32 layerCount = r.readUint32Big(); u32 layerCount = r.readUint32Big();
x12c_postConstructed->x110c_layerPtrs.resize(layerCount); x12c_postConstructed->x110c_layerPtrs.resize(layerCount);

View File

@ -2,7 +2,8 @@
#include <vector> #include <vector>
#include "Runtime/RetroTypes.hpp" #include "RetroTypes.hpp"
#include "IOStreams.hpp"
#include <zeus/CAABox.hpp> #include <zeus/CAABox.hpp>
#include <zeus/CVector3f.hpp> #include <zeus/CVector3f.hpp>

10
aurora/CMakeLists.txt Normal file
View File

@ -0,0 +1,10 @@
add_subdirectory(../extern/dawn dawn EXCLUDE_FROM_ALL)
if (NOT MSVC)
target_compile_options(SPIRV-Tools-static PRIVATE -Wno-implicit-fallthrough)
target_compile_options(SPIRV-Tools-opt PRIVATE -Wno-implicit-fallthrough)
endif ()
add_library(aurora STATIC lib/aurora.cpp lib/imgui.cpp lib/gfx/common.cpp)
target_include_directories(aurora PUBLIC include ../Runtime)
target_include_directories(aurora PRIVATE ../imgui ../extern/imgui)
target_link_libraries(aurora PRIVATE webgpu_dawn zeus logvisor) # TODO remove logvisor from rstl.hpp

View File

@ -0,0 +1,231 @@
#pragma once
#include <array>
#include <cinttypes>
#include <type_traits>
#include <vector>
#include <memory>
#ifndef ENABLE_BITWISE_ENUM
#define ENABLE_BITWISE_ENUM(type) \
constexpr type operator|(type a, type b) noexcept { \
using T = std::underlying_type_t<type>; \
return type(static_cast<T>(a) | static_cast<T>(b)); \
} \
constexpr type operator&(type a, type b) noexcept { \
using T = std::underlying_type_t<type>; \
return type(static_cast<T>(a) & static_cast<T>(b)); \
} \
constexpr type& operator|=(type& a, type b) noexcept { \
using T = std::underlying_type_t<type>; \
a = type(static_cast<T>(a) | static_cast<T>(b)); \
return a; \
} \
constexpr type& operator&=(type& a, type b) noexcept { \
using T = std::underlying_type_t<type>; \
a = type(static_cast<T>(a) & static_cast<T>(b)); \
return a; \
} \
constexpr type operator~(type key) noexcept { \
using T = std::underlying_type_t<type>; \
return type(~static_cast<T>(key)); \
} \
constexpr bool True(type key) noexcept { \
using T = std::underlying_type_t<type>; \
return static_cast<T>(key) != 0; \
} \
constexpr bool False(type key) noexcept { \
using T = std::underlying_type_t<type>; \
return static_cast<T>(key) == 0; \
}
#endif
namespace aurora {
enum class SpecialKey : uint8_t {
None = 0,
F1 = 1,
F2 = 2,
F3 = 3,
F4 = 4,
F5 = 5,
F6 = 6,
F7 = 7,
F8 = 8,
F9 = 9,
F10 = 10,
F11 = 11,
F12 = 12,
F13 = 13,
F14 = 14,
F15 = 15,
F16 = 16,
F17 = 17,
F18 = 18,
F19 = 19,
F20 = 20,
F21 = 21,
F22 = 22,
F23 = 23,
F24 = 24,
Esc = 25,
Enter = 26,
Backspace = 27,
Insert = 28,
Delete = 29,
Home = 30,
End = 31,
PgUp = 32,
PgDown = 33,
Left = 34,
Right = 35,
Up = 36,
Down = 37,
Tab = 38,
PrintScreen = 39,
ScrollLock = 40,
Pause = 41,
NumLockClear = 42,
KpDivide = 43,
KpMultiply = 44,
KpMinus = 45,
KpPlus = 46,
KpEnter = 47,
KpNum0 = 48,
KpNum1 = 49,
KpNum2 = 51,
KpNum3 = 52,
KpNum4 = 53,
KpNum5 = 54,
KpNum6 = 55,
KpNum7 = 56,
KpNum8 = 57,
KpNum9 = 58,
KpPercent = 59,
KpPeriod = 60,
KpComma = 61,
KpEquals = 62,
Application = 63,
Power = 64,
Execute = 65,
Help = 66,
Menu = 67,
Select = 68,
Stop = 69,
Again = 70,
Undo = 71,
Cut = 72,
Paste = 73,
Find = 74,
VolumeUp = 75,
VolumeDown = 76,
MAX,
};
enum class ModifierKey : uint16_t {
None = 0,
LeftShift = 1 << 0,
RightShift = 1 << 1,
LeftControl = 1 << 2,
RightControl = 1 << 3,
LeftAlt = 1 << 3,
RightAlt = 1 << 4,
LeftGui = 1 << 5,
RightGui = 1 << 6,
Num = 1 << 7,
Caps = 1 << 8,
Mode = 1 << 9,
// SDL has a reserved value we don't need
};
ENABLE_BITWISE_ENUM(ModifierKey);
enum class ControllerButton : uint8_t {
A,
B,
X,
Y,
Back,
Guide,
Start,
LeftStick,
RightStick,
LeftShoulder,
RightShoulder,
DPadUp,
DPadDown,
DPadLeft,
DPadRight,
Other,
MAX,
};
enum class ControllerAxis : uint8_t {
LeftX,
LeftY,
RightX,
RightY,
TriggerLeft,
TriggerRight,
MAX,
};
struct Icon {
std::unique_ptr<uint8_t[]> data;
uint32_t width;
uint32_t height;
};
struct WindowSize {
uint32_t width;
uint32_t height;
};
enum class Backend : uint8_t {
Invalid,
Vulkan,
Metal,
D3D12,
D3D11,
OpenGL,
WebGPU,
};
struct App;
struct AppDelegate {
AppDelegate() = default;
virtual ~AppDelegate() noexcept = default;
AppDelegate(const AppDelegate&) = delete;
AppDelegate& operator=(const AppDelegate&) = delete;
AppDelegate(AppDelegate&&) = delete;
AppDelegate& operator=(AppDelegate&&) = delete;
virtual void onAppLaunched() noexcept = 0;
virtual bool onAppIdle(float dt) noexcept = 0;
virtual void onAppDraw() noexcept = 0;
virtual void onAppPostDraw() noexcept = 0;
virtual void onAppWindowResized(const WindowSize& size) noexcept = 0;
virtual void onAppWindowMoved(int32_t x, int32_t y) noexcept = 0;
virtual void onAppExiting() noexcept = 0;
// ImGui
virtual void onImGuiInit(float scale) noexcept = 0;
virtual void onImGuiAddTextures() noexcept = 0;
// Input
virtual void onCharKeyDown(uint8_t charCode, ModifierKey mods, bool isRepeat) noexcept = 0;
virtual void onCharKeyUp(uint8_t charCode, ModifierKey mods) noexcept = 0;
virtual void onSpecialKeyDown(SpecialKey key, ModifierKey mods, bool isRepeat) noexcept = 0;
virtual void onSpecialKeyUp(SpecialKey key, ModifierKey mods) noexcept = 0;
// Controller
virtual void onControllerAdded(uint32_t which) noexcept = 0;
virtual void onControllerRemoved(uint32_t which) noexcept = 0;
virtual void onControllerButton(uint32_t which, ControllerButton button, bool pressed) noexcept = 0;
virtual void onControllerAxis(uint32_t which, ControllerAxis axis, int16_t value) noexcept = 0;
};
void app_run(std::unique_ptr<AppDelegate> app, Icon icon) noexcept;
[[nodiscard]] std::vector<std::string> get_args() noexcept;
[[nodiscard]] WindowSize get_window_size() noexcept;
void set_window_title(std::string_view title) noexcept;
[[nodiscard]] Backend get_backend() noexcept;
[[nodiscard]] std::string_view get_backend_string() noexcept;
void set_fullscreen(bool fullscreen) noexcept;
[[nodiscard]] int32_t get_controller_player_index(uint32_t which) noexcept;
void set_controller_player_index(uint32_t which, int32_t index) noexcept;
[[nodiscard]] bool is_controller_gamecube(uint32_t which) noexcept;
[[nodiscard]] std::string get_controller_name(uint32_t which) noexcept;
} // namespace aurora

View File

@ -0,0 +1,72 @@
#pragma once
#include <array>
#include <vector>
#include <type_traits>
#include "RetroTypes.hpp"
namespace aurora {
template <typename T>
class ArrayRef {
public:
using value_type = std::remove_cvref_t<T>;
using pointer = value_type*;
using const_pointer = const value_type*;
using reference = value_type&;
using const_reference = const value_type&;
using iterator = const_pointer;
using const_iterator = const_pointer;
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
using size_type = std::size_t;
using difference_type = std::ptrdiff_t;
ArrayRef() = default;
explicit ArrayRef(const T& one) : ptr(&one), length(1) {}
ArrayRef(const T* data, size_t length) : ptr(data), length(length) {}
ArrayRef(const T* begin, const T* end) : ptr(begin), length(end - begin) {}
template <size_t N>
constexpr ArrayRef(const T (&arr)[N]) : ptr(arr), length(N) {}
template <size_t N>
constexpr ArrayRef(const std::array<T, N>& arr) : ptr(arr.data()), length(arr.size()) {}
ArrayRef(const std::vector<T>& vec) : ptr(vec.data()), length(vec.size()) {}
template <size_t N>
ArrayRef(const rstl::reserved_vector<T, N>& vec) : ptr(vec.data()), length(vec.size()) {}
const T* data() const { return ptr; }
size_t size() const { return length; }
bool empty() const { return length == 0; }
const T& front() const {
assert(!empty());
return ptr[0];
}
const T& back() const {
assert(!empty());
return ptr[length - 1];
}
const T& operator[](size_t i) const {
assert(i < length && "Invalid index!");
return ptr[i];
}
iterator begin() const { return ptr; }
iterator end() const { return ptr + length; }
reverse_iterator rbegin() const { return reverse_iterator(end()); }
reverse_iterator rend() const { return reverse_iterator(begin()); }
/// Disallow accidental assignment from a temporary.
template <typename U>
std::enable_if_t<std::is_same<U, T>::value, ArrayRef<T>>& operator=(U&& Temporary) = delete;
/// Disallow accidental assignment from a temporary.
template <typename U>
std::enable_if_t<std::is_same<U, T>::value, ArrayRef<T>>& operator=(std::initializer_list<U>) = delete;
private:
const T* ptr = nullptr;
size_t length = 0;
};
} // namespace aurora

View File

@ -0,0 +1,129 @@
#pragma once
#include "common.hpp"
#include <cstdint>
#include <zeus/CAABox.hpp>
#include <zeus/CColor.hpp>
#include <zeus/CMatrix4f.hpp>
#include <zeus/CRectangle.hpp>
#include <zeus/CVector2f.hpp>
#include <zeus/CVector3f.hpp>
#include <zeus/CVector4f.hpp>
namespace metaforce {
enum class ERglFogMode : uint32_t {
None = 0x00,
PerspLin = 0x02,
PerspExp = 0x04,
PerspExp2 = 0x05,
PerspRevExp = 0x06,
PerspRevExp2 = 0x07,
OrthoLin = 0x0A,
OrthoExp = 0x0C,
OrthoExp2 = 0x0D,
OrthoRevExp = 0x0E,
OrthoRevExp2 = 0x0F
};
struct CFogState {
zeus::CColor m_color;
float m_A = 0.f;
float m_B = 0.5f;
float m_C = 0.f;
ERglFogMode m_mode;
};
} // namespace metaforce
namespace aurora::gfx {
struct TextureRef {
uint32_t id;
bool render;
};
struct TextureHandle {
TextureRef ref;
explicit TextureHandle(TextureRef ref) : ref(ref) {}
~TextureHandle() noexcept;
TextureHandle(const TextureHandle&) = delete;
TextureHandle& operator=(const TextureHandle&) = delete;
};
enum class TextureFormat : uint8_t {
RGBA8,
R8,
R32Float,
DXT1,
DXT3,
DXT5,
BPTC,
};
struct ClipRect {
int32_t x;
int32_t y;
int32_t width;
int32_t height;
};
enum class CameraFilterType : uint8_t {
Passthru,
Multiply,
Invert,
Add,
Subtract,
Blend,
Widescreen,
SceneAdd,
NoColor,
InvDstMultiply,
};
enum class ZTest : uint8_t {
Never,
Less,
Equal,
LEqual,
Greater,
NEqual,
GEqual,
Always,
};
[[nodiscard]] bool get_dxt_compression_supported() noexcept;
void update_model_view(const zeus::CMatrix4f& mv, const zeus::CMatrix4f& mv_inv) noexcept;
void update_projection(const zeus::CMatrix4f& proj) noexcept;
void update_fog_state(const metaforce::CFogState& state) noexcept;
void set_viewport(const zeus::CRectangle& rect, float znear, float zfar) noexcept;
void set_scissor(uint32_t x, uint32_t y, uint32_t w, uint32_t h) noexcept;
void resolve_color(const ClipRect& rect, uint32_t bind, bool clear_depth) noexcept;
void resolve_depth(const ClipRect& rect, uint32_t bind) noexcept;
void add_material_set(/* TODO */) noexcept;
void add_model(/* TODO */) noexcept;
void queue_aabb(const zeus::CAABox& aabb, const zeus::CColor& color, bool z_only) noexcept;
void queue_fog_volume_plane(const ArrayRef<zeus::CVector4f>& verts, uint8_t pass);
void queue_fog_volume_filter(const zeus::CColor& color, bool two_way) noexcept;
void queue_textured_quad_verts(CameraFilterType filter_type, TextureRef texture, ZTest z_comparison, bool z_test,
const zeus::CColor& color, const ArrayRef<zeus::CVector3f>& pos,
const ArrayRef<zeus::CVector2f>& uvs, float lod) noexcept;
void queue_textured_quad(CameraFilterType filter_type, TextureRef texture, ZTest z_comparison, bool z_test,
const zeus::CColor& color, float uv_scale, const zeus::CRectangle& rect, float z) noexcept;
void queue_colored_quad_verts(CameraFilterType filter_type, ZTest z_comparison, bool z_test, const zeus::CColor& color,
const ArrayRef<zeus::CVector3f>& pos) noexcept;
void queue_colored_quad(CameraFilterType filter_type, ZTest z_comparison, bool z_test, const zeus::CColor& color,
const zeus::CRectangle& rect, float z) noexcept;
void queue_movie_player(TextureRef tex_y, TextureRef tex_u, TextureRef tex_v, const zeus::CColor& color, float h_pad,
float v_pad) noexcept;
std::shared_ptr<TextureHandle> new_static_texture_2d(uint32_t width, uint32_t height, uint32_t mips,
TextureFormat format, ArrayRef<uint8_t> data,
std::string_view label) noexcept;
std::shared_ptr<TextureHandle> new_dynamic_texture_2d(uint32_t width, uint32_t height, uint32_t mips,
TextureFormat format, std::string_view label) noexcept;
std::shared_ptr<TextureHandle> new_render_texture(uint32_t width, uint32_t height, uint32_t color_bind_count,
uint32_t depth_bind_count, std::string_view label) noexcept;
void write_texture(TextureRef ref, ArrayRef<uint8_t> data) noexcept;
} // namespace aurora::gfx

View File

@ -0,0 +1,9 @@
#pragma once
#include "common.hpp"
#include <imgui.h>
namespace aurora::imgui {
ImTextureID add_texture(uint32_t width, uint32_t height, ArrayRef<uint8_t> data) noexcept;
} // namespace aurora::imgui

36
aurora/lib/aurora.cpp Normal file
View File

@ -0,0 +1,36 @@
#include <aurora/aurora.hpp>
#include <memory>
namespace aurora {
void app_run(std::unique_ptr<AppDelegate> app, Icon icon) noexcept {}
std::vector<std::string> get_args() noexcept {
return {}; // TODO
}
WindowSize get_window_size() noexcept {
return {}; // TODO
}
void set_window_title(std::string_view title) noexcept {
// TODO
}
Backend get_backend() noexcept {
return Backend::Vulkan; // TODO
}
std::string_view get_backend_string() noexcept {
return {}; // TODO
}
void set_fullscreen(bool fullscreen) noexcept {
// TODO
}
int32_t get_controller_player_index(uint32_t which) noexcept {
return -1; // TODO
}
void set_controller_player_index(uint32_t which, int32_t index) noexcept {
// TODO
}
bool is_controller_gamecube(uint32_t which) noexcept {
return true; // TODO
}
std::string get_controller_name(uint32_t which) noexcept {
return ""; // TODO
}
} // namespace aurora

81
aurora/lib/gfx/common.cpp Normal file
View File

@ -0,0 +1,81 @@
#include <aurora/gfx.hpp>
namespace aurora::gfx {
bool get_dxt_compression_supported() noexcept {
return true; // TODO
}
void update_model_view(const zeus::CMatrix4f& mv, const zeus::CMatrix4f& mv_inv) noexcept {
// TODO
}
void update_projection(const zeus::CMatrix4f& proj) noexcept {
// TODO
}
void update_fog_state(const metaforce::CFogState& state) noexcept {
// TODO
}
void set_viewport(const zeus::CRectangle& rect, float znear, float zfar) noexcept {
// TODO
}
void set_scissor(uint32_t x, uint32_t y, uint32_t w, uint32_t h) noexcept {
// TODO
}
void resolve_color(const ClipRect& rect, uint32_t bind, bool clear_depth) noexcept {
// TODO
}
void resolve_depth(const ClipRect& rect, uint32_t bind) noexcept {
// TODO
}
void add_material_set(/* TODO */) noexcept {}
void add_model(/* TODO */) noexcept {}
void queue_aabb(const zeus::CAABox& aabb, const zeus::CColor& color, bool z_only) noexcept {
// TODO
}
void queue_fog_volume_plane(const ArrayRef<zeus::CVector4f>& verts, uint8_t pass) {
// TODO
}
void queue_fog_volume_filter(const zeus::CColor& color, bool two_way) noexcept {
// TODO
}
void queue_textured_quad_verts(CameraFilterType filter_type, TextureRef texture, ZTest z_comparison, bool z_test,
const zeus::CColor& color, const ArrayRef<zeus::CVector3f>& pos,
const ArrayRef<zeus::CVector2f>& uvs, float lod) noexcept {
// TODO
}
void queue_textured_quad(CameraFilterType filter_type, TextureRef texture, ZTest z_comparison, bool z_test,
const zeus::CColor& color, float uv_scale, const zeus::CRectangle& rect, float z) noexcept {
// TODO
}
void queue_colored_quad_verts(CameraFilterType filter_type, ZTest z_comparison, bool z_test, const zeus::CColor& color,
const ArrayRef<zeus::CVector3f>& pos) noexcept {
// TODO
}
void queue_colored_quad(CameraFilterType filter_type, ZTest z_comparison, bool z_test, const zeus::CColor& color,
const zeus::CRectangle& rect, float z) noexcept {
// TODO
}
void queue_movie_player(TextureRef tex_y, TextureRef tex_u, TextureRef tex_v, const zeus::CColor& color, float h_pad,
float v_pad) noexcept {
// TODO
}
std::shared_ptr<TextureHandle> new_static_texture_2d(uint32_t width, uint32_t height, uint32_t mips,
TextureFormat format, ArrayRef<uint8_t> data,
std::string_view label) noexcept {
return {}; // TODO
}
std::shared_ptr<TextureHandle> new_dynamic_texture_2d(uint32_t width, uint32_t height, uint32_t mips,
TextureFormat format, std::string_view label) noexcept {
return {}; // TODO
}
std::shared_ptr<TextureHandle> new_render_texture(uint32_t width, uint32_t height, uint32_t color_bind_count,
uint32_t depth_bind_count, std::string_view label) noexcept {
return {}; // TODO
}
void write_texture(TextureRef ref, ArrayRef<uint8_t> data) noexcept {
// TODO
}
} // namespace aurora::gfx

7
aurora/lib/imgui.cpp Normal file
View File

@ -0,0 +1,7 @@
#include <aurora/imgui.hpp>
namespace aurora::imgui {
ImTextureID add_texture(uint32_t width, uint32_t height, ArrayRef<uint8_t> data) noexcept {
return 0; // TODO
}
} // namespace aurora::imgui

1
extern/dawn vendored Submodule

@ -0,0 +1 @@
Subproject commit 883681cafb2563de3b8af270726e30e83f240721

View File

@ -1,6 +1,6 @@
#include "ImGuiEngine.hpp" #include "ImGuiEngine.hpp"
#include "aurora_imgui.h" #include <aurora/imgui.hpp>
#include "athena/Compression.hpp" #include "athena/Compression.hpp"
@ -69,9 +69,9 @@ Icon GetIcon() {
}; };
} }
void ImGuiEngine_AddTextures(ImGuiState& state, const DeviceHolder& gpu) { void ImGuiEngine_AddTextures() {
auto icon = GetIcon(); auto icon = GetIcon();
ImGuiEngine::metaforceIcon = ImGuiEngine::metaforceIcon =
ImGuiEngine_AddTexture(state, gpu, icon.width, icon.height, {icon.data.get(), icon.size}); aurora::imgui::add_texture(icon.width, icon.height, {icon.data.get(), icon.size});
} }
} // namespace metaforce } // namespace metaforce

View File

@ -14,10 +14,7 @@ public:
// Called from Rust // Called from Rust
void ImGuiEngine_Initialize(float scale); void ImGuiEngine_Initialize(float scale);
void ImGuiEngine_AddTextures();
struct ImGuiState;
struct DeviceHolder;
void ImGuiEngine_AddTextures(ImGuiState& state, const DeviceHolder& gpu);
struct Icon { struct Icon {
std::unique_ptr<uint8_t[]> data; std::unique_ptr<uint8_t[]> data;